aboutsummaryrefslogtreecommitdiffstats
path: root/libAACenc
diff options
context:
space:
mode:
authorStefan Pöschel <github@basicmaster.de>2017-02-12 14:31:32 +0100
committerStefan Pöschel <github@basicmaster.de>2017-02-12 14:41:55 +0100
commit725713585f9bbf668abbe5b94c1ed01b921b1fcb (patch)
tree073a2e725c1727c00c646c38f50afc6ca2095789 /libAACenc
parentaad197a2a2e3b8897279a34778946355589b02fa (diff)
downloadfdk-aac-725713585f9bbf668abbe5b94c1ed01b921b1fcb.tar.gz
fdk-aac-725713585f9bbf668abbe5b94c1ed01b921b1fcb.tar.bz2
fdk-aac-725713585f9bbf668abbe5b94c1ed01b921b1fcb.zip
Fix bitrates over 144 kBit/s
When the desired bitrate and therefore the size of the output Superframe was too high (over 144 kBit/s), the default output buffer size (with 2 channels: 2^11 = 2048 bytes) was exceeded. As the buffer write function applies a bitmask to the target address, silently a rollover occured and the function continued to (over)write at the start of the buffer. Thus the encoding output got unusable. To fix this, consider the maximum allowed Superframe size (for 192 kBit/s) when the output buffer size is set.
Diffstat (limited to 'libAACenc')
-rw-r--r--libAACenc/src/aacenc_lib.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/libAACenc/src/aacenc_lib.cpp b/libAACenc/src/aacenc_lib.cpp
index 1037a36..1ea9a5c 100644
--- a/libAACenc/src/aacenc_lib.cpp
+++ b/libAACenc/src/aacenc_lib.cpp
@@ -1361,8 +1361,10 @@ AACENC_ERROR aacEncOpen(
}
{ /* Get bitstream outputbuffer size */
+ UINT buffer_bytes_min = (hAacEncoder->nMaxSubFrames*hAacEncoder->nMaxAacChannels*6144)>>3;
+ buffer_bytes_min = fixMax(buffer_bytes_min, (UINT) (24 * 110)); // consider maximum DAB+ Superframe size
UINT ld_M;
- for (ld_M=1; (UINT)(1<<ld_M) < (hAacEncoder->nMaxSubFrames*hAacEncoder->nMaxAacChannels*6144)>>3; ld_M++) ;
+ for (ld_M=1; (UINT)(1<<ld_M) < buffer_bytes_min; ld_M++) ;
hAacEncoder->outBufferInBytes = (1<<ld_M); /* buffer has to be 2^n */
}
hAacEncoder->outBuffer = GetRam_bsOutbuffer();