summaryrefslogtreecommitdiffstats
path: root/libAACenc/src/aacenc.cpp
diff options
context:
space:
mode:
authorpiratfm <piratfm@gmail.com>2013-04-12 00:26:09 +0300
committerMatthias P. Braendli <matthias.braendli@mpb.li>2013-12-14 17:42:30 +0100
commitddb94b9025f6893a6d9543254fedf0a70c0549b8 (patch)
treec53927550c4bba4c2b6e4dbec60d183f70982fcb /libAACenc/src/aacenc.cpp
parent671667db206f8551c21c085158d2f949a93536e6 (diff)
downloadfdk-aac-dabplus-ddb94b9025f6893a6d9543254fedf0a70c0549b8.tar.gz
fdk-aac-dabplus-ddb94b9025f6893a6d9543254fedf0a70c0549b8.tar.bz2
fdk-aac-dabplus-ddb94b9025f6893a6d9543254fedf0a70c0549b8.zip
vlc works with bare aac
Conflicts: .cproject libAACenc/src/aacenc_lib.cpp libAACenc/src/qc_main.cpp libFDK/src/FDK_crc.cpp libSYS/include/FDK_audio.h
Diffstat (limited to 'libAACenc/src/aacenc.cpp')
-rw-r--r--libAACenc/src/aacenc.cpp47
1 files changed, 46 insertions, 1 deletions
diff --git a/libAACenc/src/aacenc.cpp b/libAACenc/src/aacenc.cpp
index e0bda19..3585d80 100644
--- a/libAACenc/src/aacenc.cpp
+++ b/libAACenc/src/aacenc.cpp
@@ -87,7 +87,7 @@ amm-info@iis.fraunhofer.de
contents/description: fast aac coder functions
******************************************************************************/
-
+#include <stdio.h>
#include "aacenc.h"
#include "bitenc.h"
@@ -137,6 +137,7 @@ INT FDKaacEnc_LimitBitrate(
do {
prevBitRate = bitRate;
averageBitsPerFrame = (bitRate*(frameLength>>shift)) / (coreSamplingRate>>shift) / nSubFrames;
+ fprintf(stderr, "FDKaacEnc_LimitBitrate(): averageBitsPerFrame=%d, prevBitRate=%d, nSubFrames=%d\n", averageBitsPerFrame, prevBitRate, bitRate);
if (pAverageBitsPerFrame != NULL) {
*pAverageBitsPerFrame = averageBitsPerFrame;
@@ -144,19 +145,27 @@ INT FDKaacEnc_LimitBitrate(
if (hTpEnc != NULL) {
transportBits = transportEnc_GetStaticBits(hTpEnc, averageBitsPerFrame);
+ //if(hTpEnc->transportFmt == TT_DABPLUS) {
+ fprintf(stderr, "FDKaacEnc_LimitBitrate(): hTpEnc != NULL\n");
+ //transportBits +=
+ //}
} else {
/* Assume some worst case */
transportBits = 208;
}
+ fprintf(stderr, "FDKaacEnc_LimitBitrate(): transportBits=%d, FDKmax(%d, %d)\n", transportBits, bitRate,
+ ((((40 * nChannels) + transportBits) * (coreSamplingRate)) / frameLength));
bitRate = FDKmax(bitRate, ((((40 * nChannels) + transportBits) * (coreSamplingRate)) / frameLength) );
FDK_ASSERT(bitRate >= 0);
+ fprintf(stderr, "FDKaacEnc_LimitBitrate(): FDKmin(%d, %d)\n", bitRate, ((nChannelsEff * MIN_BUFSIZE_PER_EFF_CHAN)*(coreSamplingRate>>shift)) / (frameLength>>shift));
bitRate = FDKmin(bitRate, ((nChannelsEff * MIN_BUFSIZE_PER_EFF_CHAN)*(coreSamplingRate>>shift)) / (frameLength>>shift)) ;
FDK_ASSERT(bitRate >= 0);
} while (prevBitRate != bitRate && iter++ < 3) ;
+ fprintf(stderr, "FDKaacEnc_LimitBitrate(): bitRate=%d\n", bitRate);
return bitRate;
}
@@ -422,6 +431,36 @@ AAC_ENCODER_ERROR FDKaacEnc_Initialize(HANDLE_AAC_ENC hAacEnc,
return AAC_ENC_UNSUPPORTED_BITRATE;
}
+ INT superframe_size = 110*8*(config->bitRate/8000);
+ INT frames_per_superframe = 6;
+ INT staticBits = 0;
+ if((config->syntaxFlags & AC_DAB) && hTpEnc) {
+ staticBits = transportEnc_GetStaticBits(hTpEnc, 0);
+ switch(config->sampleRate) {
+ case 48000:
+ frames_per_superframe=6;
+ break;
+ case 32000:
+ frames_per_superframe=4;
+ break;
+ case 24000:
+ frames_per_superframe=3;
+ break;
+ case 16000:
+ frames_per_superframe=2;
+ break;
+ }
+
+ //config->nSubFrames = frames_per_superframe;
+ fprintf(stderr, "DAB+ superframe size=%d\n", superframe_size);
+ config->bitRate = (superframe_size - 16*(frames_per_superframe-1) - staticBits) * 1000/120;
+ fprintf(stderr, "DAB+ tuned bitrate=%d\n", config->bitRate);
+ config->maxBitsPerFrame = (superframe_size - 16*(frames_per_superframe-1) - staticBits) / frames_per_superframe;
+ config->maxBitsPerFrame += 7; /*padding*/
+ //config->bitreservoir=(superframe_size - 16*(frames_per_superframe-1) - staticBits - 2*8)/frames_per_superframe;
+ fprintf(stderr, "DAB+ tuned maxBitsPerFrame=%d\n", (superframe_size - 16*(frames_per_superframe-1) - staticBits)/frames_per_superframe);
+ }
+
/* check bit rate */
if (FDKaacEnc_LimitBitrate(
@@ -571,12 +610,15 @@ AAC_ENCODER_ERROR FDKaacEnc_Initialize(HANDLE_AAC_ENC hAacEnc,
qcInit.averageBits = (averageBitsPerFrame+7)&~7;
maxBitres = (MIN_BUFSIZE_PER_EFF_CHAN*cm->nChannelsEff) - qcInit.averageBits;
qcInit.bitRes = (config->bitreservoir!=-1) ? FDKmin(config->bitreservoir, maxBitres) : maxBitres;
+ fprintf(stderr, "qcInit.bitRes=%d\n", qcInit.bitRes);
qcInit.maxBits = fixMin(MIN_BUFSIZE_PER_EFF_CHAN*cm->nChannelsEff, ((averageBitsPerFrame+7)&~7)+qcInit.bitRes);
qcInit.maxBits = (config->maxBitsPerFrame!=-1) ? fixMin(qcInit.maxBits, config->maxBitsPerFrame) : qcInit.maxBits;
+ fprintf(stderr, "qcInit.maxBits=%d\n", qcInit.maxBits);
qcInit.minBits = fixMax(0, ((averageBitsPerFrame-1)&~7)-qcInit.bitRes-transportEnc_GetStaticBits(hTpEnc, ((averageBitsPerFrame+7)&~7)+qcInit.bitRes));
qcInit.minBits = (config->minBitsPerFrame!=-1) ? fixMax(qcInit.minBits, config->minBitsPerFrame) : qcInit.minBits;
+ fprintf(stderr, "qcInit.minBits=%d\n", qcInit.minBits);
}
qcInit.sampleRate = config->sampleRate;
@@ -872,10 +914,13 @@ AAC_ENCODER_ERROR FDKaacEnc_EncodeFrame( HANDLE_AAC_ENC hAacEnc,
/* adjust super frame bitrate */
avgTotalBits *= hAacEnc->config->nSubFrames;
+ fprintf(stderr, "avgTotalBits=%d x %d\n", avgTotalBits, hAacEnc->config->nSubFrames);
}
/* Make first estimate of transport header overhead.
Take maximum possible frame size into account to prevent bitreservoir underrun. */
+
+ fprintf(stderr, "avgTotalBits=%d, bitResTot=%d\n", avgTotalBits, hAacEnc->qcKernel->bitResTot);
hAacEnc->qcKernel->globHdrBits = transportEnc_GetStaticBits(hTpEnc, avgTotalBits + hAacEnc->qcKernel->bitResTot);