diff options
author | piratfm <piratfm@gmail.com> | 2013-04-12 00:26:09 +0300 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2013-12-14 17:42:30 +0100 |
commit | ddb94b9025f6893a6d9543254fedf0a70c0549b8 (patch) | |
tree | c53927550c4bba4c2b6e4dbec60d183f70982fcb /libAACenc | |
parent | 671667db206f8551c21c085158d2f949a93536e6 (diff) | |
download | fdk-aac-ddb94b9025f6893a6d9543254fedf0a70c0549b8.tar.gz fdk-aac-ddb94b9025f6893a6d9543254fedf0a70c0549b8.tar.bz2 fdk-aac-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')
-rw-r--r-- | libAACenc/include/aacenc_lib.h | 3 | ||||
-rw-r--r-- | libAACenc/src/aacenc.cpp | 47 | ||||
-rw-r--r-- | libAACenc/src/aacenc_lib.cpp | 54 | ||||
-rw-r--r-- | libAACenc/src/psy_main.cpp | 2 | ||||
-rw-r--r-- | libAACenc/src/qc_main.cpp | 8 |
5 files changed, 102 insertions, 12 deletions
diff --git a/libAACenc/include/aacenc_lib.h b/libAACenc/include/aacenc_lib.h index 94a506a..6e4cbed 100644 --- a/libAACenc/include/aacenc_lib.h +++ b/libAACenc/include/aacenc_lib.h @@ -1023,8 +1023,9 @@ typedef enum For AAC-ELD, the SBR information is transmitted in the ELDSpecific Config, which is part of the AudioSpecificConfig. Therefore, the settings here will have no effect on AAC-ELD.*/ - AACENC_TPSUBFRAMES = 0x0303, /*!< Number of sub frames in a transport frame for LOAS/LATM or ADTS (default 1). + AACENC_TPSUBFRAMES = 0x0303, /*!< Number of sub frames in a transport frame for LOAS/LATM, DAB+ or ADTS (default 1). - ADTS: Maximum number of sub frames restricted to 4. + - DAB+: Maximum number of sub frames restricted to 6. - LOAS/LATM: Maximum number of sub frames restricted to 2.*/ AACENC_PROTECTION = 0x0306, /*!< Configure protection in tranpsort layer: 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); diff --git a/libAACenc/src/aacenc_lib.cpp b/libAACenc/src/aacenc_lib.cpp index 392a0a6..efde05f 100644 --- a/libAACenc/src/aacenc_lib.cpp +++ b/libAACenc/src/aacenc_lib.cpp @@ -87,7 +87,7 @@ amm-info@iis.fraunhofer.de contents/description: FDK HE-AAC Encoder interface library functions ****************************************************************************/ - +#include <stdio.h> #include "aacenc_lib.h" #include "FDK_audio.h" #include "aacenc.h" @@ -427,17 +427,17 @@ static void FDKaacEnc_MapConfig( /* Map virtual aot to transport aot. */ switch (hAacConfig->audioObjectType) { - case AOT_MP2_AAC_LC: case AOT_DABPLUS_AAC_LC: + case AOT_MP2_AAC_LC: transport_AOT = AOT_AAC_LC; break; - case AOT_MP2_SBR: case AOT_DABPLUS_SBR: + case AOT_MP2_SBR: transport_AOT = AOT_SBR; cc->flags |= CC_SBR; break; - case AOT_MP2_PS: case AOT_DABPLUS_PS: + case AOT_MP2_PS: transport_AOT = AOT_PS; cc->flags |= CC_SBR; break; @@ -484,9 +484,27 @@ static void FDKaacEnc_MapConfig( cc->flags |= CC_IS_BASELAYER; cc->channelMode = hAacConfig->channelMode; - cc->nSubFrames = (hAacConfig->nSubFrames > 1 && extCfg->userTpNsubFrames == 1) + if(extCfg->userTpType == TT_DABPLUS && hAacConfig->nSubFrames==1) { + switch(hAacConfig->sampleRate) { + case 48000: + cc->nSubFrames=6; + break; + case 32000: + cc->nSubFrames=4; + break; + case 24000: + cc->nSubFrames=3; + break; + case 16000: + cc->nSubFrames=2; + break; + } + fprintf(stderr, "hAacConfig->nSubFrames=%d hAacConfig->sampleRate=%d\n", hAacConfig->nSubFrames, hAacConfig->sampleRate); + } else { + cc->nSubFrames = (hAacConfig->nSubFrames > 1 && extCfg->userTpNsubFrames == 1) ? hAacConfig->nSubFrames : extCfg->userTpNsubFrames; + } cc->flags |= (extCfg->userTpProtection) ? CC_PROTECTION : 0; @@ -751,6 +769,7 @@ INT aacEncoder_LimitBitrate( FDK_ASSERT(bitRate > 0); + fprintf(stderr, "aacEncoder_LimitBitrate(): bitRate=%d", bitRate); return bitRate; } @@ -809,11 +828,14 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder, case AOT_DABPLUS_PS: hAacConfig->syntaxFlags |= ((config->userSbrEnabled) ? AC_SBR_PRESENT : 0); case AOT_DABPLUS_AAC_LC: - config->userTpType = (config->userTpType!=TT_UNKNOWN) ? config->userTpType : TT_MP4_RAW; + config->userTpType = (config->userTpType!=TT_UNKNOWN) ? config->userTpType : TT_DABPLUS; hAacConfig->framelength = (config->userFramelength!=(UINT)-1) ? config->userFramelength : 960; if (hAacConfig->framelength != 960) { return AACENC_INVALID_CONFIG; } + config->userTpSignaling=2; + if(config->userTpType == TT_DABPLUS) + hAacConfig->syntaxFlags |= AC_DAB; break; #if 0 case AOT_ER_AAC_LC: @@ -857,6 +879,22 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder, break; } + /* We need the frame length to call aacEncoder_LimitBitrate() */ + fprintf(stderr, "##### WARNING ##### REMOVE ME"); + fprintf(stderr, "config->userBitrate=%d\n", config->userBitrate); + hAacConfig->bitRate = aacEncoder_LimitBitrate( + NULL, + hAacConfig->sampleRate, + hAacConfig->framelength, + hAacConfig->nChannels, + hAacConfig->channelMode, + config->userBitrate, + hAacConfig->nSubFrames, + isSbrActive(hAacConfig), + hAacConfig->audioObjectType + ); + fprintf(stderr, "hAacConfig->bitRate=%d\n", hAacConfig->bitRate); + switch ( hAacConfig->audioObjectType ) { case AOT_ER_AAC_LD: case AOT_ER_AAC_ELD: @@ -1014,6 +1052,7 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder, hAacEncoder->metaDataAllowed = 0; } + fprintf(stderr, "hAacEncoder->metaDataAllowed=%d", hAacEncoder->metaDataAllowed); return err; } @@ -1970,6 +2009,7 @@ AACENC_ERROR aacEncoder_SetParam( || ((type==TT_MP4_LATM_MCP1) && ((flags&CAPF_LATM) && (flags&CAPF_RAWPACKETS))) || ((type==TT_MP4_LOAS) && (flags&CAPF_LOAS)) || ((type==TT_MP4_RAW) && (flags&CAPF_RAWPACKETS)) + || ((type==TT_DABPLUS) && ((flags&CAPF_DAB_AAC) && (flags&CAPF_RAWPACKETS))) ) ) { err = AACENC_INVALID_CONFIG; @@ -2007,7 +2047,7 @@ AACENC_ERROR aacEncoder_SetParam( break; case AACENC_TPSUBFRAMES: if (settings->userTpNsubFrames != value) { - if (! ( (value>=1) && (value<=4) ) ) { + if (! ( (value>=1) && (value<=6) ) ) { err = AACENC_INVALID_CONFIG; break; } diff --git a/libAACenc/src/psy_main.cpp b/libAACenc/src/psy_main.cpp index 59193c7..a544b1b 100644 --- a/libAACenc/src/psy_main.cpp +++ b/libAACenc/src/psy_main.cpp @@ -815,7 +815,7 @@ AAC_ENCODER_ERROR FDKaacEnc_psyMain(INT channels, &hThisPsyConf[1]->tnsConf); } - FDK_ASSERT(commonWindow=1); /* all checks for TNS do only work for common windows (which is always set)*/ + FDK_ASSERT(commonWindow==1); /* all checks for TNS do only work for common windows (which is always set)*/ for(w = 0; w < nWindows[0]; w++) { if (isShortWindow[0]) diff --git a/libAACenc/src/qc_main.cpp b/libAACenc/src/qc_main.cpp index b74510a..d7799a5 100644 --- a/libAACenc/src/qc_main.cpp +++ b/libAACenc/src/qc_main.cpp @@ -87,7 +87,7 @@ amm-info@iis.fraunhofer.de contents/description: Quantizing & coding ******************************************************************************/ - +#include <stdio.h> #include "qc_main.h" #include "quantize.h" #include "interface.h" @@ -491,20 +491,24 @@ AAC_ENCODER_ERROR FDKaacEnc_AdjustBitrate(QC_STATE *RESTRICT hQC, INT sampleRate, /* output sampling rate */ INT granuleLength) /* frame length */ { - INT paddingOn; + INT paddingOn=0; INT frameLen; + fprintf(stderr, "hQC->padding.paddingRest=%d bytes! (before)\n", hQC->padding.paddingRest); /* Do we need an extra padding byte? */ paddingOn = FDKaacEnc_framePadding(bitRate, sampleRate, granuleLength, &hQC->padding.paddingRest); + fprintf(stderr, "hQC->padding.paddingRest=%d bytes! (after)\n", hQC->padding.paddingRest); frameLen = paddingOn + FDKaacEnc_calcFrameLen(bitRate, sampleRate, granuleLength, FRAME_LEN_BYTES_INT); + fprintf(stderr, "frameLen=%d bytes!\n", frameLen); + *avgTotalBits = frameLen<<3; return AAC_ENC_OK; |