Add FDK_FALLTHROUGH macro to prevent implicit-fallthrough compiler warnings
Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc
Change-Id: I9f9064fb63ac40e18f245c00b7375b4874f2925b
diff --git a/libAACdec/src/aacdecoder.cpp b/libAACdec/src/aacdecoder.cpp
index 8993927..c2ddc48 100644
--- a/libAACdec/src/aacdecoder.cpp
+++ b/libAACdec/src/aacdecoder.cpp
@@ -234,7 +234,8 @@
MODE_HQ))) { /* MPS decoder does support the requested mode. */
break;
}
- } /* Fall-through: */
+ }
+ FDK_FALLTHROUGH;
default:
if (self->qmfModeUser == NOT_DEFINED) {
/* Revert in case mpegSurroundDecoder_SetParam() fails. */
@@ -938,6 +939,7 @@
case EXT_SBR_DATA_CRC:
crcFlag = 1;
+ FDK_FALLTHROUGH;
case EXT_SBR_DATA:
if (IS_CHANNEL_ELEMENT(previous_element)) {
SBR_ERROR sbrError;
@@ -1076,6 +1078,7 @@
* intentional. */
break;
}
+ FDK_FALLTHROUGH;
case EXT_FIL:
@@ -1495,11 +1498,13 @@
switch (asc->m_aot) {
case AOT_AAC_LC:
self->streamInfo.profile = 1;
+ FDK_FALLTHROUGH;
case AOT_ER_AAC_SCAL:
if (asc->m_sc.m_gaSpecificConfig.m_layer > 0) {
/* aac_scalable_extension_element() currently not supported. */
return AAC_DEC_UNSUPPORTED_FORMAT;
}
+ FDK_FALLTHROUGH;
case AOT_SBR:
case AOT_PS:
case AOT_ER_AAC_LC:
diff --git a/libAACdec/src/channel.cpp b/libAACdec/src/channel.cpp
index cfffd57..a020034 100644
--- a/libAACdec/src/channel.cpp
+++ b/libAACdec/src/channel.cpp
@@ -592,6 +592,7 @@
line: ~599 */
/* Note: The missing "break" is intentional here, since we need to call
* CBlock_ReadScaleFactorData(). */
+ FDK_FALLTHROUGH;
case scale_factor_data:
if (flags & AC_ER_RVLC) {
diff --git a/libAACdec/src/conceal.cpp b/libAACdec/src/conceal.cpp
index a6064b6..cc6de75 100644
--- a/libAACdec/src/conceal.cpp
+++ b/libAACdec/src/conceal.cpp
@@ -1894,6 +1894,7 @@
case ConcealState_FadeIn:
idx = cntFadeFrames;
idx -= TDFadeInStopBeforeFullLevel;
+ FDK_FALLTHROUGH;
case ConcealState_Ok:
fadeFactor = pConcealParams->fadeInFactor;
idx = (concealState == ConcealState_Ok) ? -1 : idx;
diff --git a/libAACenc/src/aacenc_lib.cpp b/libAACenc/src/aacenc_lib.cpp
index f92cff4..9e0630c 100644
--- a/libAACenc/src/aacenc_lib.cpp
+++ b/libAACenc/src/aacenc_lib.cpp
@@ -907,6 +907,7 @@
case AOT_MP2_AAC_LC:
case AOT_MP2_SBR:
hAacConfig->usePns = 0;
+ FDK_FALLTHROUGH;
case AOT_AAC_LC:
case AOT_SBR:
case AOT_PS:
@@ -2091,12 +2092,14 @@
err = AACENC_INVALID_CONFIG;
goto bail;
}
+ FDK_FALLTHROUGH;
case AOT_SBR:
case AOT_MP2_SBR:
if (!(hAacEncoder->encoder_modis & (ENC_MODE_FLAG_SBR))) {
err = AACENC_INVALID_CONFIG;
goto bail;
}
+ FDK_FALLTHROUGH;
case AOT_AAC_LC:
case AOT_MP2_AAC_LC:
case AOT_ER_AAC_LD:
diff --git a/libAACenc/src/bitenc.cpp b/libAACenc/src/bitenc.cpp
index 652d1fd..957e821 100644
--- a/libAACenc/src/bitenc.cpp
+++ b/libAACenc/src/bitenc.cpp
@@ -643,6 +643,7 @@
FDKwriteBits(hBitStream, *extPayloadData++, 4); /* nibble */
}
extBitsUsed += 4;
+ FDK_FALLTHROUGH;
case EXT_DYNAMIC_RANGE:
case EXT_SBR_DATA:
case EXT_SBR_DATA_CRC:
@@ -690,6 +691,7 @@
case EXT_FILL_DATA:
fillByte = 0xA5;
+ FDK_FALLTHROUGH;
case EXT_FIL:
default:
if (hBitStream != NULL) {
diff --git a/libMpegTPDec/src/tpdec_asc.cpp b/libMpegTPDec/src/tpdec_asc.cpp
index 8d411e8..6260cad 100644
--- a/libMpegTPDec/src/tpdec_asc.cpp
+++ b/libMpegTPDec/src/tpdec_asc.cpp
@@ -467,6 +467,7 @@
pPce->BackElementIsCpe[1] = 1;
pPce->NumChannels += 1;
pPce->NumEffectiveChannels += 1;
+ FDK_FALLTHROUGH;
case 11: /* 3/0/3.1ch */
pPce->NumFrontChannelElements += 2;
pPce->FrontElementIsCpe[0] = 0;
@@ -482,25 +483,30 @@
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case 14: /* 2/0/0-3/0/2-0.1ch front height */
pPce->FrontElementHeightInfo[2] = 1; /* Top speaker */
- case 7: /* 5/0/2.1ch front */
+ FDK_FALLTHROUGH;
+ case 7: /* 5/0/2.1ch front */
pPce->NumFrontChannelElements += 1;
pPce->FrontElementIsCpe[2] = 1;
pPce->NumChannels += 2;
pPce->NumEffectiveChannels += 2;
+ FDK_FALLTHROUGH;
case 6: /* 3/0/2.1ch */
pPce->NumLfeChannelElements += 1;
pPce->NumChannels += 1;
+ FDK_FALLTHROUGH;
case 5: /* 3/0/2.0ch */
case 4: /* 3/0/1.0ch */
pPce->NumBackChannelElements += 1;
pPce->BackElementIsCpe[0] = (channelConfig > 4) ? 1 : 0;
pPce->NumChannels += (channelConfig > 4) ? 2 : 1;
pPce->NumEffectiveChannels += (channelConfig > 4) ? 2 : 1;
+ FDK_FALLTHROUGH;
case 3: /* 3/0/0.0ch */
pPce->NumFrontChannelElements += 1;
pPce->FrontElementIsCpe[1] = 1;
pPce->NumChannels += 2;
pPce->NumEffectiveChannels += 2;
+ FDK_FALLTHROUGH;
case 1: /* 1/0/0.0ch */
pPce->NumFrontChannelElements += 1;
pPce->FrontElementIsCpe[0] = 0;
@@ -713,6 +719,7 @@
switch (elType) {
case ID_CPE:
isCpe = 1;
+ FDK_FALLTHROUGH;
case ID_SCE:
/* search in front channels */
for (i = 0; i < pPce->NumFrontChannelElements; i++) {
@@ -1412,7 +1419,7 @@
break;
}
- /* fall-through */
+ FDK_FALLTHROUGH;
default:
for (cnt = 0; cnt < eldExtLen; cnt++) {
FDKreadBits(hBs, 8);
@@ -2022,6 +2029,7 @@
break;
case ASCEXT_MPS: /* 0x76a */
if (self->m_extensionAudioObjectType == AOT_MPEGS) break;
+ FDK_FALLTHROUGH;
case ASCEXT_LDMPS: /* 0x7cc */
if ((ascExtId == ASCEXT_LDMPS) &&
(self->m_extensionAudioObjectType == AOT_LD_MPEGS))
@@ -2498,6 +2506,7 @@
switch (audioMode) {
case 1: /* parametric stereo */
self->m_psPresentFlag = 1;
+ FDK_FALLTHROUGH;
case 0: /* mono */
self->m_channelConfiguration = 1;
break;
diff --git a/libMpegTPDec/src/tpdec_lib.cpp b/libMpegTPDec/src/tpdec_lib.cpp
index 2a40187..1976cb9 100644
--- a/libMpegTPDec/src/tpdec_lib.cpp
+++ b/libMpegTPDec/src/tpdec_lib.cpp
@@ -956,6 +956,7 @@
hTp->parser.latm.m_audioMuxLengthBytes = syncLayerFrameBits;
syncLayerFrameBits <<= 3;
}
+ FDK_FALLTHROUGH;
case TT_MP4_LATM_MCP1:
case TT_MP4_LATM_MCP0:
if (hTp->numberOfRawDataBlocks <= 0) {
diff --git a/libMpegTPEnc/src/tpenc_lib.cpp b/libMpegTPEnc/src/tpenc_lib.cpp
index a8567b9..14ea5fe 100644
--- a/libMpegTPEnc/src/tpenc_lib.cpp
+++ b/libMpegTPEnc/src/tpenc_lib.cpp
@@ -212,6 +212,7 @@
for potential matrix mixdown */
break;
}
+ FDK_FALLTHROUGH;
case TT_MP4_LOAS: /* PCE in ASC if chChonfig==0 */
case TT_MP4_LATM_MCP1: /* PCE in ASC if chChonfig==0 */
default:
diff --git a/libPCMutils/src/pcmdmx_lib.cpp b/libPCMutils/src/pcmdmx_lib.cpp
index b09a848..2070dbc 100644
--- a/libPCMutils/src/pcmdmx_lib.cpp
+++ b/libPCMutils/src/pcmdmx_lib.cpp
@@ -1043,6 +1043,7 @@
case CH_MODE_3_2_1_0:
isValidCfg = FALSE;
err = PCMDMX_INVALID_MODE;
+ FDK_FALLTHROUGH;
case CH_MODE_3_0_3_1: /* chCfg 11 */
/* 6.1ch: C' = C; L' = L; R' = R; LFE' = LFE;
Ls' = Ls*dmix_a_idx + Cs*dmix_b_idx;
@@ -1080,9 +1081,11 @@
LEFT_REAR_CHANNEL, FL2FXCONST_DMX(0.5f), 1);
dmxSetChannel(mixFactors, mixScales, LEFT_REAR_CHANNEL,
LEFT_REAR_CHANNEL, FL2FXCONST_DMX(0.5f), 1);
+ FDK_FALLTHROUGH;
case CH_MODE_5_2_1_0:
isValidCfg = FALSE;
err = PCMDMX_INVALID_MODE;
+ FDK_FALLTHROUGH;
case CH_MODE_5_0_2_1: /* chCfg 7 || 14 */
if (inChCfg == 14) {
/* 7.1ch Front Height: C' = C; Ls' = Ls; Rs' = Rs; LFE' = LFE;
diff --git a/libSACdec/src/sac_dec_lib.cpp b/libSACdec/src/sac_dec_lib.cpp
index 5ae89d1..e881599 100644
--- a/libSACdec/src/sac_dec_lib.cpp
+++ b/libSACdec/src/sac_dec_lib.cpp
@@ -1349,6 +1349,7 @@
pMpegSurroundDecoder->mpegSurroundSscIsGlobalCfg = 0;
}
}
+ FDK_FALLTHROUGH;
case MPEGS_ANCTYPE_FRAME:
if (pMpegSurroundDecoder
diff --git a/libSYS/include/machine_type.h b/libSYS/include/machine_type.h
index be8de37..b66d5ad 100644
--- a/libSYS/include/machine_type.h
+++ b/libSYS/include/machine_type.h
@@ -379,6 +379,17 @@
#define LNK_SECTION_L1_DATA_A
#define LNK_SECTION_L1_DATA_B
+/**************************************************
+ * Macros regarding static code analysis
+ **************************************************/
+#if defined(__clang__)
+#define FDK_FALLTHROUGH [[clang::fallthrough]]
+#elif defined(__GNUC__) && (__GNUC__ >= 7)
+#define FDK_FALLTHROUGH __attribute__((fallthrough))
+#else
+#define FDK_FALLTHROUGH
+#endif
+
#ifdef _MSC_VER
/*
* Sometimes certain features are excluded from compilation and therefore the