aboutsummaryrefslogtreecommitdiffstats
path: root/libPCMutils/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2024-01-05 17:50:19 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2024-01-05 17:50:19 +0100
commit571316f329948dc464cc2be37b210f0b3e7816f7 (patch)
tree8396262af9d84f5a0490af9805cde11cf5fc9eed /libPCMutils/src
parente778887e4e5589528b06b04404ce4c71aaae267a (diff)
parent716f4394641d53f0d79c9ddac3fa93b03a49f278 (diff)
downloadfdk-aac-dabplus2.tar.gz
fdk-aac-dabplus2.tar.bz2
fdk-aac-dabplus2.zip
Merge fdk-aac 'v2.0.3' into dabplus2dabplus2
Diffstat (limited to 'libPCMutils/src')
-rw-r--r--libPCMutils/src/limiter.cpp5
-rw-r--r--libPCMutils/src/pcmdmx_lib.cpp58
2 files changed, 45 insertions, 18 deletions
diff --git a/libPCMutils/src/limiter.cpp b/libPCMutils/src/limiter.cpp
index 598dc0c..c6b8687 100644
--- a/libPCMutils/src/limiter.cpp
+++ b/libPCMutils/src/limiter.cpp
@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
+© Copyright 1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
@@ -322,7 +322,8 @@ TDLIMITER_ERROR pcmLimiter_Apply(TDLimiterPtr limiter, PCM_LIM* samplesIn,
(FIXP_DBL)SATURATE_LEFT_SHIFT(tmp, scaling, DFRACT_BITS));
#else
samplesOut[j] = (INT_PCM)FX_DBL2FX_PCM((FIXP_DBL)SATURATE_LEFT_SHIFT(
- tmp + ((FIXP_DBL)0x8000 >> scaling), scaling, DFRACT_BITS));
+ (tmp >> 1) + ((FIXP_DBL)0x8000 >> (scaling + 1)), scaling + 1,
+ DFRACT_BITS));
#endif
}
}
diff --git a/libPCMutils/src/pcmdmx_lib.cpp b/libPCMutils/src/pcmdmx_lib.cpp
index 534acad..fca12ce 100644
--- a/libPCMutils/src/pcmdmx_lib.cpp
+++ b/libPCMutils/src/pcmdmx_lib.cpp
@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+© Copyright 1995 - 2021 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
@@ -494,13 +494,40 @@ static PCM_DMX_CHANNEL_MODE getChMode4Plain(
return plainChMode;
}
-static inline UINT getIdxSum(UCHAR numCh) {
- UINT result = 0;
- int i;
- for (i = 1; i < numCh; i += 1) {
- result += i;
+/** Validates the channel indices of all channels present in the bitstream.
+ * The channel indices have to be consecutive and unique for each audio channel
+ *type.
+ * @param [in] The total number of channels of the given configuration.
+ * @param [in] The total number of channels of the current audio channel type of
+ *the given configuration.
+ * @param [in] Audio channel type to be examined.
+ * @param [in] Array holding the corresponding channel types for each channel.
+ * @param [in] Array holding the corresponding channel type indices for each
+ *channel.
+ * @returns Returns 1 on success, returns 0 on error.
+ **/
+static UINT validateIndices(UINT numChannels, UINT numChannelsPlaneAndGrp,
+ AUDIO_CHANNEL_TYPE aChType,
+ const AUDIO_CHANNEL_TYPE channelType[],
+ const UCHAR channelIndices[]) {
+ for (UINT reqValue = 0; reqValue < numChannelsPlaneAndGrp; reqValue++) {
+ int found = FALSE;
+ for (UINT i = 0; i < numChannels; i++) {
+ if (channelType[i] == aChType) {
+ if (channelIndices[i] == reqValue) {
+ if (found == TRUE) {
+ return 0; /* Found channel index a second time */
+ } else {
+ found = TRUE; /* Found channel index */
+ }
+ }
+ }
+ }
+ if (found == FALSE) {
+ return 0; /* Did not find channel index */
+ }
}
- return result;
+ return 1; /* Successfully validated channel indices */
}
/** Evaluate a given channel configuration and extract a packed channel mode. In
@@ -523,7 +550,6 @@ static PCMDMX_ERROR getChannelMode(
UCHAR offsetTable[(8)], /* out */
PCM_DMX_CHANNEL_MODE *chMode /* out */
) {
- UINT idxSum[(3)][(4)];
UCHAR numCh[(3)][(4)];
UCHAR mapped[(8)];
PCM_DMX_SPEAKER_POSITION spkrPos[(8)];
@@ -538,7 +564,6 @@ static PCMDMX_ERROR getChannelMode(
FDK_ASSERT(chMode != NULL);
/* For details see ISO/IEC 13818-7:2005(E), 8.5.3 Channel configuration */
- FDKmemclear(idxSum, (3) * (4) * sizeof(UINT));
FDKmemclear(numCh, (3) * (4) * sizeof(UCHAR));
FDKmemclear(mapped, (8) * sizeof(UCHAR));
FDKmemclear(spkrPos, (8) * sizeof(PCM_DMX_SPEAKER_POSITION));
@@ -552,19 +577,22 @@ static PCMDMX_ERROR getChannelMode(
(channelType[ch] & 0x0F) - 1,
0); /* Assign all undefined channels (ACT_NONE) to front channels. */
numCh[channelType[ch] >> 4][chGrp] += 1;
- idxSum[channelType[ch] >> 4][chGrp] += channelIndices[ch];
}
- if (numChannels > TWO_CHANNEL) {
+
+ {
int chGrp;
/* Sanity check on the indices */
for (chGrp = 0; chGrp < (4); chGrp += 1) {
int plane;
for (plane = 0; plane < (3); plane += 1) {
- if (idxSum[plane][chGrp] != getIdxSum(numCh[plane][chGrp])) {
+ if (numCh[plane][chGrp] == 0) continue;
+ AUDIO_CHANNEL_TYPE aChType =
+ (AUDIO_CHANNEL_TYPE)((plane << 4) | ((chGrp + 1) & 0xF));
+ if (!validateIndices(numChannels, numCh[plane][chGrp], aChType,
+ channelType, channelIndices)) {
unsigned idxCnt = 0;
for (ch = 0; ch < numChannels; ch += 1) {
- if (channelType[ch] ==
- (AUDIO_CHANNEL_TYPE)((plane << 4) | ((chGrp + 1) & 0xF))) {
+ if (channelType[ch] == aChType) {
channelIndices[ch] = idxCnt++;
}
}
@@ -583,8 +611,6 @@ static PCMDMX_ERROR getChannelMode(
(channelType[ch] & 0x0F) - 1,
0); /* Assign all undefined channels (ACT_NONE) to front channels. */
- if (channelIndices[ch] >= numCh[channelType[ch] >> 4][chGrp])
- return PCMDMX_INVALID_CH_CONFIG;
spkrPos[ch] = getSpeakerPos(channelType[ch], channelIndices[ch],
numCh[channelType[ch] >> 4][chGrp]);