Skip to content

Commit

Permalink
Merge commit 'a30bfced6b6d6d976c728552d247cb30dd86e238'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sibras committed Mar 24, 2018
2 parents 53ee7a0 + a30bfce commit f5a15a7
Show file tree
Hide file tree
Showing 24 changed files with 194 additions and 117 deletions.
35 changes: 35 additions & 0 deletions Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
cc_library_static {
name: "libFraunhoferAAC",
vendor_available: true,
srcs: [
"libAACdec/src/*.cpp",
"libAACenc/src/*.cpp",
"libPCMutils/src/*.cpp",
"libFDK/src/*.cpp",
"libSYS/src/*.cpp",
"libMpegTPDec/src/*.cpp",
"libMpegTPEnc/src/*.cpp",
"libSBRdec/src/*.cpp",
"libSBRenc/src/*.cpp",
],
cflags: [
"-Werror",
"-Wno-constant-conversion",
"-Wno-sequence-point",
"-Wno-extra",
"-Wno-#warnings",
"-Wno-constant-logical-operand",
"-Wno-self-assign",
],
export_include_dirs: [
"libAACdec/include",
"libAACenc/include",
"libPCMutils/include",
"libFDK/include",
"libSYS/include",
"libMpegTPDec/include",
"libMpegTPEnc/include",
"libSBRdec/include",
"libSBRenc/include",
],
}
59 changes: 0 additions & 59 deletions Android.mk

This file was deleted.

4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.1.6
- Lots of minor assorted crash/fuzz fixes, mostly for the decoder but
also some for the encoder

0.1.5
- Updated upstream sources
- Fixed building with GCC 3.3 and 3.4
Expand Down
3 changes: 2 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ EXTRA_DIST = \
$(top_srcdir)/autogen.sh \
$(top_srcdir)/MODULE_LICENSE_FRAUNHOFER \
$(top_srcdir)/NOTICE \
$(top_srcdir)/Android.mk \
$(top_srcdir)/OWNERS \
$(top_srcdir)/Android.bp \
$(top_srcdir)/fdk-aac.sym \
$(top_srcdir)/Makefile.vc \
$(top_srcdir)/documentation/*.pdf \
Expand Down
2 changes: 2 additions & 0 deletions OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[email protected]
[email protected]
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dnl -*- Autoconf -*-
dnl Process this file with autoconf to produce a configure script.

AC_INIT([fdk-aac], [0.1.5], [http://sourceforge.net/projects/opencore-amr/])
AC_INIT([fdk-aac], [0.1.6], [http://sourceforge.net/projects/opencore-amr/])
AC_CONFIG_AUX_DIR(.)
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([tar-ustar foreign])
Expand All @@ -26,7 +26,7 @@ AC_SEARCH_LIBS([sin], [m])
dnl soname version to use
dnl goes by ‘current[:revision[:age]]’ with the soname ending up as
dnl current.age.revision
FDK_AAC_VERSION=1:0:0
FDK_AAC_VERSION=1:1:0

AS_IF([test x$enable_shared = xyes], [LIBS_PRIVATE=$LIBS], [LIBS_PUBLIC=$LIBS])
AC_SUBST(FDK_AAC_VERSION)
Expand Down
19 changes: 6 additions & 13 deletions libAACdec/src/aacdecoder_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,36 +791,29 @@ LINKSPEC_CPP AAC_DECODER_ERROR aacDecoder_DecodeFrame(
const UINT flags)
{
AAC_DECODER_ERROR ErrorStatus;
INT layer;
INT nBits;
INT interleaved = self->outputInterleaved;
HANDLE_FDK_BITSTREAM hBs;
int fTpInterruption = 0; /* Transport originated interruption detection. */
int fTpConceal = 0; /* Transport originated concealment. */
INT_PCM *pTimeData = NULL;
INT timeDataSize = 0;


if (self == NULL) {
return AAC_DEC_INVALID_HANDLE;
}

pTimeData = self->pcmOutputBuffer;
timeDataSize = sizeof(self->pcmOutputBuffer)/sizeof(*self->pcmOutputBuffer);
INT interleaved = self->outputInterleaved;
INT_PCM *pTimeData = self->pcmOutputBuffer;
INT timeDataSize = sizeof(self->pcmOutputBuffer)/sizeof(*self->pcmOutputBuffer);

if (flags & AACDEC_INTR) {
self->streamInfo.numLostAccessUnits = 0;
}

hBs = transportDec_GetBitstream(self->hInput, 0);
HANDLE_FDK_BITSTREAM hBs = transportDec_GetBitstream(self->hInput, 0);

/* Get current bits position for bitrate calculation. */
nBits = FDKgetValidBits(hBs);
INT nBits = FDKgetValidBits(hBs);
if (! (flags & (AACDEC_CONCEAL | AACDEC_FLUSH) ) )
{
TRANSPORTDEC_ERROR err;

for(layer = 0; layer < self->nrOfLayers; layer++)
for(INT layer = 0; layer < self->nrOfLayers; layer++)
{
err = transportDec_ReadAccessUnit(self->hInput, layer);
if (err != TRANSPORTDEC_OK) {
Expand Down
5 changes: 4 additions & 1 deletion libAACdec/src/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ LONG CBlock_GetEscape(HANDLE_FDK_BITSTREAM bs, /*!< pointer to bitstream */

if (i > 16)
{
if (i - 16 > CACHE_BITS) { /* cannot read more than "CACHE_BITS" bits at once in the function FDKreadBits() */
if (i >= 31) { /* (1 << i) will shift into the sign bit if i >= 31 */
return (MAX_QUANTIZED_VALUE + 1); /* returning invalid value that will be captured later */
}

Expand Down Expand Up @@ -318,6 +318,9 @@ AAC_DECODER_ERROR CBlock_ReadSectionData(HANDLE_FDK_BITSTREAM bs,
}

sect_len += sect_len_incr;
if (sect_len <= 0) {
return AAC_DEC_PARSE_ERROR;
}


top = band + sect_len;
Expand Down
17 changes: 16 additions & 1 deletion libAACdec/src/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,15 @@ AAC_DECODER_ERROR CChannelElement_Read(HANDLE_FDK_BITSTREAM hBs,
case drmcrc_end_reg:
if (pTpDec != NULL) {
transportDec_CrcEndReg(pTpDec, crcReg1);
crcReg1 = -1;
}
break;
case adtscrc_end_reg2:
if (pTpDec != NULL) {
if (crcReg1 != -1) {
error = AAC_DEC_DECODE_FRAME_ERROR;
} else if (pTpDec != NULL) {
transportDec_CrcEndReg(pTpDec, crcReg2);
crcReg2 = -1;
}
break;
case drmcrc_start_reg:
Expand Down Expand Up @@ -447,5 +451,16 @@ AAC_DECODER_ERROR CChannelElement_Read(HANDLE_FDK_BITSTREAM hBs,
} while (list->id[i] != end_of_sequence);

bail:
if (crcReg1 != -1 || crcReg2 != -1) {
if (error == AAC_DEC_OK) {
error = AAC_DEC_DECODE_FRAME_ERROR;
}
if (crcReg1 != -1) {
transportDec_CrcEndReg(pTpDec, crcReg1);
}
if (crcReg2 != -1) {
transportDec_CrcEndReg(pTpDec, crcReg2);
}
}
return error;
}
5 changes: 4 additions & 1 deletion libAACenc/src/aacenc_tns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ AAC_ENCODER_ERROR FDKaacEnc_InitTnsConfiguration(INT bitRate,
switch (granuleLength) {
case 1024:
/* TNS start line: skip lower MDCT lines to prevent artifacts due to filter mismatch */
tC->lpcStartBand[LOFILT] = (blockType == SHORT_WINDOW) ? 0 : ((sampleRate < 18783) ? 4 : 8);
tC->lpcStartBand[LOFILT] = (blockType == SHORT_WINDOW) ? 0 : ((sampleRate <= 8000) ? 2 : ((sampleRate < 18783) ? 4 : 8));
tC->lpcStartLine[LOFILT] = pC->sfbOffset[tC->lpcStartBand[LOFILT]];

i = tC->lpcStopBand;
Expand Down Expand Up @@ -1147,6 +1147,9 @@ static INT FDKaacEnc_AutoToParcor(
workBuffer++;
}

if (input[0] == 0)
input[0] = 1;

tmp = fMult((FIXP_DBL)((LONG)TNS_PREDGAIN_SCALE<<21), fDivNorm(fAbs(autoCorr_0), fAbs(input[0]), &scale));
if ( fMultDiv2(autoCorr_0, input[0])<FL2FXCONST_DBL(0.0f) ) {
tmp = -tmp;
Expand Down
2 changes: 1 addition & 1 deletion libAACenc/src/adj_thr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ static FIXP_DBL FDKaacEnc_calcChaosMeasure(PSY_OUT_CHANNEL *psyOutChannel,
CalcInvLdData( (((CalcLdData(frameFormFactor)>>1) -
(CalcLdData(frameEnergy)>>(2+1))) -
(fMultDiv2(FL2FXCONST_DBL(0.75f),CalcLdData((FIXP_DBL)frameNLines<<(DFRACT_BITS-1-SCALE_NLINES))) -
(((FIXP_DBL)(SCALE_FORM_FAC-SCALE_NRGS_SQRT4+FORM_FAC_SHIFT-(SCALE_NLINES_P34))<<(DFRACT_BITS-1-LD_DATA_SHIFT))>>1))
(((FIXP_DBL)(-((-SCALE_FORM_FAC+SCALE_NRGS_SQRT4-FORM_FAC_SHIFT+SCALE_NLINES_P34) << (DFRACT_BITS-1-LD_DATA_SHIFT))))>>1))
)<<1 );
} else {

Expand Down
10 changes: 4 additions & 6 deletions libAACenc/src/metadata_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,14 +488,12 @@ static FDK_METADATA_ERROR ProcessCompressor(
{
FDK_METADATA_ERROR err = METADATA_OK;

INT dynrng, compr;
DRC_PROFILE profileDrc = convertProfile(pMetadata->mpegDrc.drc_profile);
DRC_PROFILE profileComp = convertProfile(pMetadata->etsiAncData.comp_profile);

if ( (pMetadata==NULL) || (hDrcComp==NULL) ) {
err = METADATA_INVALID_HANDLE;
return err;
}
DRC_PROFILE profileDrc = convertProfile(pMetadata->mpegDrc.drc_profile);
DRC_PROFILE profileComp = convertProfile(pMetadata->etsiAncData.comp_profile);

/* first, check if profile is same as last frame
* otherwise, update setup */
Expand All @@ -511,8 +509,8 @@ static FDK_METADATA_ERROR ProcessCompressor(
}

/* in case of embedding external values, copy this now (limiter may overwrite them) */
dynrng = decodeDynrng(pMetadata->mpegDrc.dyn_rng_ctl[0], pMetadata->mpegDrc.dyn_rng_sgn[0]);
compr = decodeCompr(pMetadata->etsiAncData.compression_value);
INT dynrng = decodeDynrng(pMetadata->mpegDrc.dyn_rng_ctl[0], pMetadata->mpegDrc.dyn_rng_sgn[0]);
INT compr = decodeCompr(pMetadata->etsiAncData.compression_value);

/* Call compressor */
if (FDK_DRC_Generator_Calc(hDrcComp,
Expand Down
1 change: 1 addition & 0 deletions libAACenc/src/sf_estim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ static void FDKaacEnc_assimilateSingleScf(PSY_OUT_CHANNEL *psyOutChan,
(scfAct > scfMin) &&
(scfAct <= scfMin+MAX_SCF_DELTA) &&
(scfAct >= scfMax-MAX_SCF_DELTA) &&
(scfAct <= fixMin(scfMin,fixMin(*scfLast, *scfNext))+MAX_SCF_DELTA) &&
(*scfLast != prevScfLast[sfbAct] ||
*scfNext != prevScfNext[sfbAct] ||
deltaPe < deltaPeLast[sfbAct])) {
Expand Down
67 changes: 55 additions & 12 deletions libFDK/include/FDK_bitstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,28 @@ FDK_INLINE UINT FDKreadBits(HANDLE_FDK_BITSTREAM hBitStream,
INT missingBits = numberOfBits - hBitStream->BitsInCache;
if (missingBits > 0)
{
UINT bits = hBitStream->CacheWord << missingBits;
hBitStream->CacheWord = FDK_get32 (&hBitStream->hBitBuf) ;
hBitStream->BitsInCache = CACHE_BITS - missingBits;
const UINT bits = hBitStream->CacheWord << missingBits;
const UINT validBits = FDK_getValidBits (&hBitStream->hBitBuf);

if (validBits >= 32)
{
hBitStream->CacheWord = FDK_get32 (&hBitStream->hBitBuf) ;
hBitStream->BitsInCache = CACHE_BITS - missingBits;
}
else
{
hBitStream->CacheWord = FDK_get (&hBitStream->hBitBuf,validBits) ;
if (validBits >= missingBits)
{
hBitStream->BitsInCache = validBits - missingBits;
}
else
{
hBitStream->BitsInCache = 0;
hBitStream->CacheWord <<= missingBits - validBits;
}
}

return ( bits | (hBitStream->CacheWord >> hBitStream->BitsInCache)) & BitMask[numberOfBits];
}

Expand All @@ -226,10 +245,18 @@ FDK_INLINE UINT FDKreadBits(HANDLE_FDK_BITSTREAM hBitStream,

if (hBitStream->BitsInCache <= numberOfBits)
{
const INT freeBits = (CACHE_BITS-1) - hBitStream->BitsInCache ;

hBitStream->CacheWord = (hBitStream->CacheWord << freeBits) | FDK_get (&hBitStream->hBitBuf,freeBits) ;
hBitStream->BitsInCache += freeBits ;
const INT validBits = FDK_getValidBits (&hBitStream->hBitBuf) ;
const INT freeBits = (CACHE_BITS-1) - hBitStream->BitsInCache ;
const INT bitsToRead = (freeBits <= validBits) ? freeBits : validBits ;

hBitStream->CacheWord = (hBitStream->CacheWord << bitsToRead) | FDK_get (&hBitStream->hBitBuf,bitsToRead) ;
hBitStream->BitsInCache += bitsToRead ;
if (hBitStream->BitsInCache < numberOfBits)
{
hBitStream->CacheWord <<= numberOfBits - hBitStream->BitsInCache;
hBitStream->BitsInCache = 0;
return (hBitStream->CacheWord >> hBitStream->BitsInCache) & validMask ;
}
}

hBitStream->BitsInCache -= numberOfBits ;
Expand All @@ -243,8 +270,22 @@ FDK_INLINE UINT FDKreadBit(HANDLE_FDK_BITSTREAM hBitStream)
#ifdef OPTIMIZE_FDKREADBITS
if (!hBitStream->BitsInCache)
{
hBitStream->CacheWord = FDK_get32 (&hBitStream->hBitBuf);
hBitStream->BitsInCache = CACHE_BITS;
const UINT validBits = FDK_getValidBits (&hBitStream->hBitBuf);

if (validBits >= 32)
{
hBitStream->CacheWord = FDK_get32 (&hBitStream->hBitBuf);
hBitStream->BitsInCache = CACHE_BITS;
}
else if (validBits > 0)
{
hBitStream->CacheWord = FDK_get (&hBitStream->hBitBuf,validBits);
hBitStream->BitsInCache = validBits;
}
else
{
return 0;
}
}
hBitStream->BitsInCache--;

Expand All @@ -268,10 +309,12 @@ inline UINT FDKread2Bits(HANDLE_FDK_BITSTREAM hBitStream)
UINT BitsInCache = hBitStream->BitsInCache;
if (BitsInCache < 2) /* Comparison changed from 'less-equal' to 'less' */
{
const INT freeBits = (CACHE_BITS-1) - BitsInCache ;
const INT validBits = FDK_getValidBits (&hBitStream->hBitBuf) ;
const INT freeBits = (CACHE_BITS-1) - BitsInCache ;
const INT bitsToRead = (freeBits <= validBits) ? freeBits : validBits ;

hBitStream->CacheWord = (hBitStream->CacheWord << freeBits) | FDK_get (&hBitStream->hBitBuf,freeBits) ;
BitsInCache += freeBits;
hBitStream->CacheWord = (hBitStream->CacheWord << bitsToRead) | FDK_get (&hBitStream->hBitBuf,bitsToRead) ;
BitsInCache += bitsToRead;
}
hBitStream->BitsInCache = BitsInCache - 2;
return (hBitStream->CacheWord >> hBitStream->BitsInCache) & 0x3;
Expand Down
Loading

0 comments on commit f5a15a7

Please sign in to comment.