diff --git a/LICENSE.md b/LICENSE.md
index ca74eaf483b6772614a49c5025aa865a357e063e..21616d00deb55d678a5ed477119d38700456cab8 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj
index fdc38e7804aabac12fc1b0214283b738f142ed72..ef31eea686298eeea16af44df5c8347944440ce1 100644
--- a/Workspace_msvc/lib_dec.vcxproj
+++ b/Workspace_msvc/lib_dec.vcxproj
@@ -209,11 +209,12 @@
-
+
+
@@ -223,7 +224,6 @@
-
diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters
index 170eada9ad30e017f4f3652be5ee6f08f2080937..59e2aa52d33a60e51eea8424e13518b64b9869b3 100644
--- a/Workspace_msvc/lib_dec.vcxproj.filters
+++ b/Workspace_msvc/lib_dec.vcxproj.filters
@@ -326,9 +326,6 @@
decoder_all_c
-
- decoder_ivas_c
-
decoder_ivas_c
@@ -362,9 +359,6 @@
decoder_ivas_c
-
- decoder_ivas_c
-
decoder_ivas_c
@@ -509,6 +503,12 @@
decoder_all_c
+
+ decoder_ivas_c
+
+
+ decoder_ivas_c
+
diff --git a/Workspace_msvc/lib_isar.vcxproj b/Workspace_msvc/lib_isar.vcxproj
index 0271901c88b4c9ad236ff5e34d925f4d7c107e4c..20c6363098f47d28ca0a42164bd532b2d263c17d 100644
--- a/Workspace_msvc/lib_isar.vcxproj
+++ b/Workspace_msvc/lib_isar.vcxproj
@@ -133,7 +133,6 @@
-
diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj
index b76f3211cbbeb550c4df1977e072f6db0734bc9a..4dba9d23659cf7faacbeae481cc4f429fc0c8d7c 100644
--- a/Workspace_msvc/lib_rend.vcxproj
+++ b/Workspace_msvc/lib_rend.vcxproj
@@ -138,6 +138,7 @@
+
diff --git a/apps/ambi_converter.c b/apps/ambi_converter.c
index 816f96619e0eee30a04a7a61f8afe62ce22faf09..84f3192389c79ffd54c5d2545677ed8e5642c20e 100644
--- a/apps/ambi_converter.c
+++ b/apps/ambi_converter.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/apps/decoder.c b/apps/decoder.c
index 401a26761ce7244356038ff81f2ba9abd4994989..be38d4e859da32cb390f9e92ef983885bad6a9aa 100644
--- a/apps/decoder.c
+++ b/apps/decoder.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -124,7 +124,7 @@ typedef struct
char *outputMdFilename;
IVAS_DEC_COMPLEXITY_LEVEL complexityLevel;
bool tsmEnabled;
- IVAS_RENDER_FRAMESIZE renderFramesize;
+ IVAS_RENDER_NUM_SUBFR render_num_subframes;
AcousticEnvironmentSequence aeSequence;
bool dpidEnabled;
uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS];
@@ -142,9 +142,6 @@ typedef struct
hrtfFileReader *hrtfReader;
char *hrtfFileName;
- IVAS_DEC_HRTF_TD_HANDLE *hHrtfTD;
-
- IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics;
IVAS_BIN_RENDERER_TYPE binaural_renderer;
IVAS_BIN_RENDERER_TYPE binaural_renderer_old;
@@ -196,7 +193,7 @@ int main(
Vector3PairFileReader *referenceVectorReader = NULL;
RenderConfigReader *renderConfigReader = NULL;
int16_t *pcmBuf = NULL;
- IVAS_RENDER_FRAMESIZE asked_frame_size;
+ IVAS_RENDER_NUM_SUBFR asked_num_subframes;
IVAS_DEC_HRTF_BINARY_WRAPPER hHrtfBinary;
ObjectEditFileReader *objectEditFileReader = NULL;
IVAS_ROOM_ACOUSTICS_CONFIG_DATA **pAE = NULL;
@@ -207,8 +204,6 @@ int main(
reset_mem( USE_BYTES );
#endif
- hHrtfBinary.hHrtfTD = NULL; /* just to avoid compilation warning */
- hHrtfBinary.hHrtfStatistics = NULL; /* just to avoid compilation warning */
splitRendBits.bits_buf = splitRendBitsBuf;
@@ -411,11 +406,10 @@ int main(
* Configure the decoder
*------------------------------------------------------------------------------------------*/
- asked_frame_size = arg.renderFramesize;
+ asked_num_subframes = arg.render_num_subframes;
uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : IVAS_DEFAULT_AEID;
- arg.enableHeadRotation = arg.enableHeadRotation || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM;
- if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled,
+ if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.render_num_subframes, arg.customLsOutputEnabled, arg.hrtfReaderEnabled,
arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.roomSize, arg.non_diegetic_pan_enabled,
arg.non_diegetic_pan_gain_fx, arg.dpidEnabled, aeID, arg.objEditEnabled, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK )
{
@@ -423,22 +417,10 @@ int main(
goto cleanup;
}
- if ( ( error = IVAS_DEC_GetRenderFramesize( hIvasDec, &arg.renderFramesize ) ) != IVAS_ERR_OK )
- {
- fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
- goto cleanup;
- }
-
- if ( arg.renderFramesize != asked_frame_size )
- {
- fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for decoding to EXT!\n" );
- }
-
/*------------------------------------------------------------------------------------------*
* Configure Split rendering
*------------------------------------------------------------------------------------------*/
- asked_frame_size = arg.renderFramesize;
if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
{
if ( ( error = IVAS_DEC_EnableSplitRendering( hIvasDec ) ) != IVAS_ERR_OK )
@@ -446,12 +428,17 @@ int main(
fprintf( stderr, "\nSplit rendering configure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
goto cleanup;
}
+ }
- if ( ( error = IVAS_DEC_GetRenderFramesize( hIvasDec, &arg.renderFramesize ) ) != IVAS_ERR_OK )
- {
- fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
- goto cleanup;
- }
+ if ( ( error = IVAS_DEC_GetRenderNumSubfr( hIvasDec, &arg.render_num_subframes ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nIVAS_DEC_GetRenderNumSubfr failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
+ goto cleanup;
+ }
+
+ if ( !arg.renderConfigEnabled && ( arg.render_num_subframes != asked_num_subframes ) )
+ {
+ fprintf( stderr, "\nChanged render framesize, only 20ms allowed!\n" );
}
/*------------------------------------------------------------------------------------------*
@@ -563,24 +550,24 @@ int main(
if ( ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
{
- if ( asked_frame_size != IVAS_RENDER_FRAMESIZE_20MS &&
+ if ( asked_num_subframes != IVAS_RENDER_NUM_SUBFR_20MS &&
( renderConfig.split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ||
renderConfig.split_rend_config.dof == 0 ) )
{
- arg.renderFramesize = asked_frame_size;
+ arg.render_num_subframes = asked_num_subframes;
}
else
{
- arg.renderFramesize = IVAS_RENDER_FRAMESIZE_20MS;
+ arg.render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS;
}
- if ( ( error = IVAS_DEC_SetRenderFramesize( hIvasDec, arg.renderFramesize ) ) != IVAS_ERR_OK )
+ if ( ( error = IVAS_DEC_SetRenderNumSubfr( hIvasDec, arg.render_num_subframes ) ) != IVAS_ERR_OK )
{
- fprintf( stderr, "\nIVAS_DEC_SetRenderFramesize failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
+ fprintf( stderr, "\nIVAS_DEC_SetRenderNumSubfr failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
goto cleanup;
}
- if ( arg.renderFramesize != asked_frame_size )
+ if ( arg.render_num_subframes != asked_num_subframes )
{
fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for non-0dof split rendering!\n" );
}
@@ -605,7 +592,7 @@ int main(
/* ISAR frame size is set from command line, not renderer config file.
* This will be ignored if output format is not split rendering. */
- renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) arg.renderFramesize /* given in number of 5ms subframes */ * 5;
+ renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) arg.render_num_subframes * 5;
if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, renderConfig ) ) != IVAS_ERR_OK )
{
@@ -730,19 +717,6 @@ cleanup:
free( arg.aeSequence.pValidity );
}
- if ( arg.hrtfReaderEnabled )
- {
- destroy_td_hrtf( hHrtfBinary.hHrtfTD );
- destroy_hrtf_statistics( hHrtfBinary.hHrtfStatistics );
- }
-#ifdef FIX_1990_SANITIZER_IN_REVERB_LOAD
- // TODO:
- /* This free differs from float version.
- This is needed as HRTF statistics from ROM are currently converted from Word16 values to scaled Word32 values. */
- IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL;
- IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics );
- destroy_hrtf_statistics( hHrtfStatistics );
-#endif
IVAS_DEC_Close( &hIvasDec );
CustomLsReader_close( &hLsCustomReader );
hrtfFileReader_close( &hrtfReader );
@@ -924,8 +898,9 @@ static bool parseCmdlIVAS_dec(
arg->inputFormat = IVAS_DEC_INPUT_FORMAT_G192;
arg->non_diegetic_pan_enabled = false;
arg->non_diegetic_pan_gain = 0.f;
+ arg->non_diegetic_pan_gain_fx = 0;
arg->tsmEnabled = false;
- arg->renderFramesize = IVAS_RENDER_FRAMESIZE_20MS;
+ arg->render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS;
arg->aeSequence.count = 0;
arg->aeSequence.pID = NULL;
arg->aeSequence.pValidity = NULL;
@@ -1092,13 +1067,13 @@ static bool parseCmdlIVAS_dec(
switch ( (int16_t) tmp )
{
case 5:
- arg->renderFramesize = IVAS_RENDER_FRAMESIZE_5MS;
+ arg->render_num_subframes = IVAS_RENDER_NUM_SUBFR_5MS;
break;
case 10:
- arg->renderFramesize = IVAS_RENDER_FRAMESIZE_10MS;
+ arg->render_num_subframes = IVAS_RENDER_NUM_SUBFR_10MS;
break;
case 20:
- arg->renderFramesize = IVAS_RENDER_FRAMESIZE_20MS;
+ arg->render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS;
break;
default:
fprintf( stderr, "Error: Invalid render frame size %d \n\n", tmp );
@@ -2008,6 +1983,7 @@ static ivas_error decodeG192(
bool needNewFrame;
int16_t nSamplesRendered, nSamplesRendered_loop, nSamplesToRender;
IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS];
+ IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { -12582912, 0, 0, 0, 22 }, { -12582912, 0, 0, 0, 22 }, { -12582912, 0, 0, 0, 22 }, { -12582912, 0, 0, 0, 22 } };
IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 } };
int16_t vec_pos_update, vec_pos_len;
SplitFileReadWrite *splitRendWriter = NULL;
@@ -2148,21 +2124,19 @@ static ivas_error decodeG192(
}
}
- int16_t num_subframes;
- if ( ( error = IVAS_DEC_GetNumOrientationSubframes( hIvasDec, &num_subframes ) ) != IVAS_ERR_OK )
+ IVAS_RENDER_NUM_SUBFR num_subframes;
+ if ( ( error = IVAS_DEC_GetRenderNumSubfr( hIvasDec, &num_subframes ) ) != IVAS_ERR_OK )
{
- fprintf( stderr, "\nIVAS_DEC_GetNumOrientationSubframes failed: \n" );
+ fprintf( stderr, "\nIVAS_DEC_GetRenderNumSubfr failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
goto cleanup;
}
/* Head-tracking input simulation */
- if ( arg.enableHeadRotation )
+ if ( arg.enableHeadRotation || isSplitRend )
{
- IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
-
if ( headRotReader == NULL )
{
- for ( i = 0; i < num_subframes; i++ )
+ for ( i = 0; i < (int16_t) num_subframes; i++ )
{
Quaternions[i].w_fx = -12582912;
Quaternions[i].x_fx = 0;
@@ -2177,7 +2151,7 @@ static ivas_error decodeG192(
}
else
{
- for ( i = 0; i < num_subframes; i++ )
+ for ( i = 0; i < (int16_t) num_subframes; i++ )
{
if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK )
{
@@ -2187,7 +2161,7 @@ static ivas_error decodeG192(
}
}
- for ( i = 0; i < num_subframes; i++ )
+ for ( i = 0; i < (int16_t) num_subframes; i++ )
{
if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i, DEFAULT_AXIS ) ) != IVAS_ERR_OK )
{
@@ -2199,13 +2173,12 @@ static ivas_error decodeG192(
if ( arg.enableExternalOrientation )
{
- IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
int8_t enableHeadRotation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
int8_t enableExternalOrientation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
int8_t enableRotationInterpolation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
int16_t numFramesToTargetOrientation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
- for ( i = 0; i < num_subframes; i++ )
+ for ( i = 0; i < (int16_t) num_subframes; i++ )
{
if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &Quaternions[i], &enableHeadRotation[i], &enableExternalOrientation[i], &enableRotationInterpolation[i], &numFramesToTargetOrientation[i] ) ) != IVAS_ERR_OK )
{
@@ -2213,7 +2186,7 @@ static ivas_error decodeG192(
goto cleanup;
}
}
- for ( i = 0; i < num_subframes; i++ )
+ for ( i = 0; i < (int16_t) num_subframes; i++ )
{
if ( ( error = IVAS_DEC_FeedExternalOrientationData( hIvasDec, Quaternions[i], enableHeadRotation[i], enableExternalOrientation[i], enableRotationInterpolation[i], numFramesToTargetOrientation[i], i ) ) != IVAS_ERR_OK )
{
@@ -2546,16 +2519,30 @@ static ivas_error decodeG192(
}
/* Head-tracking input simulation */
- if ( arg.enableHeadRotation )
+ if ( arg.enableHeadRotation || isSplitRend )
{
- IVAS_QUATERNION Quaternion;
- if ( ( error = HeadRotationFileReading( headRotReader, &Quaternion, &Pos[0] ) ) != IVAS_ERR_OK )
+ if ( headRotReader == NULL )
{
- fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( headRotReader ) );
- goto cleanup;
+ Quaternions[i].w_fx = -12582912;
+ Quaternions[i].x_fx = 0;
+ Quaternions[i].y_fx = 0;
+ Quaternions[i].z_fx = 0;
+ Quaternions[i].q_fact = 22;
+ Pos[i].x = 0.0f;
+ Pos[i].y = 0.0f;
+ Pos[i].z = 0.0f;
+ Pos[i].q_fact = 25;
+ }
+ else
+ {
+ if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[0], &Pos[0] ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( headRotReader ) );
+ goto cleanup;
+ }
}
- if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos[0], 0, DEFAULT_AXIS ) ) != IVAS_ERR_OK )
+ if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[0], Pos[0], 0, DEFAULT_AXIS ) ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
goto cleanup;
@@ -2787,6 +2774,7 @@ static ivas_error decodeVoIP(
IVAS_DEC_BS_FORMAT bsFormat = IVAS_DEC_BS_UNKOWN;
IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS];
+ IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { -12582912, 0, 0, 0, 22 }, { -12582912, 0, 0, 0, 22 }, { -12582912, 0, 0, 0, 22 }, { -12582912, 0, 0, 0, 22 } };
IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 } };
int16_t vec_pos_update, vec_pos_len;
int16_t nOutSamples = 0;
@@ -2979,21 +2967,19 @@ static ivas_error decodeVoIP(
}
}
- int16_t num_subframes;
- if ( ( error = IVAS_DEC_GetNumOrientationSubframes( hIvasDec, &num_subframes ) ) != IVAS_ERR_OK )
+ IVAS_RENDER_NUM_SUBFR num_subframes;
+ if ( ( error = IVAS_DEC_GetRenderNumSubfr( hIvasDec, &num_subframes ) ) != IVAS_ERR_OK )
{
- fprintf( stderr, "\nIVAS_DEC_GetNumOrientationSubframes failed: \n" );
+ fprintf( stderr, "\nIVAS_DEC_GetRenderNumSubfr failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
goto cleanup;
}
/* Head-tracking input simulation */
- if ( arg.enableHeadRotation )
+ if ( arg.enableHeadRotation || isSplitRend )
{
- IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
-
if ( headRotReader == NULL )
{
- for ( i = 0; i < num_subframes; i++ )
+ for ( i = 0; i < (int16_t) num_subframes; i++ )
{
Quaternions[i].w_fx = -12582912;
Quaternions[i].x_fx = 0;
@@ -3008,7 +2994,7 @@ static ivas_error decodeVoIP(
}
else
{
- for ( i = 0; i < num_subframes; i++ )
+ for ( i = 0; i < (int16_t) num_subframes; i++ )
{
if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK )
{
@@ -3018,7 +3004,7 @@ static ivas_error decodeVoIP(
}
}
- for ( i = 0; i < num_subframes; i++ )
+ for ( i = 0; i < (int16_t) num_subframes; i++ )
{
if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i, DEFAULT_AXIS ) ) != IVAS_ERR_OK )
{
@@ -3030,13 +3016,12 @@ static ivas_error decodeVoIP(
if ( arg.enableExternalOrientation )
{
- IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
int8_t enableHeadRotation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
int8_t enableExternalOrientation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
int8_t enableRotationInterpolation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
int16_t numFramesToTargetOrientation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
- for ( i = 0; i < num_subframes; i++ )
+ for ( i = 0; i < (int16_t) num_subframes; i++ )
{
if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &Quaternions[i], &enableHeadRotation[i], &enableExternalOrientation[i], &enableRotationInterpolation[i], &numFramesToTargetOrientation[i] ) ) != IVAS_ERR_OK )
@@ -3046,7 +3031,7 @@ static ivas_error decodeVoIP(
goto cleanup;
}
}
- for ( i = 0; i < num_subframes; i++ )
+ for ( i = 0; i < (int16_t) num_subframes; i++ )
{
if ( ( error = IVAS_DEC_FeedExternalOrientationData( hIvasDec, Quaternions[i], enableHeadRotation[i], enableExternalOrientation[i], enableRotationInterpolation[i], numFramesToTargetOrientation[i], i ) ) != IVAS_ERR_OK )
{
@@ -3756,12 +3741,6 @@ static ivas_error load_hrtf_from_file(
/*------------------------------------------------------------------------------------------*
* Release HRTF binary data
*------------------------------------------------------------------------------------------*/
-
- if ( !( binaural_renderer == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) && binaural_renderer_sec != IVAS_BIN_RENDERER_TYPE_TDREND && hHrtfBinary->hHrtfTD != NULL )
- {
- destroy_td_hrtf( hHrtfBinary->hHrtfTD );
- }
-
if ( ( error = IVAS_DEC_HRTF_binary_close( hIvasDec, hHrtfBinary->binaural_renderer_old ) ) != IVAS_ERR_OK )
{
return error;
@@ -3783,13 +3762,15 @@ static ivas_error load_hrtf_from_file(
if ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer_sec == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT )
{
- if ( ( error = IVAS_DEC_GetHrtfTDrendHandle( hIvasDec, &hHrtfBinary->hHrtfTD ) ) != IVAS_ERR_OK )
+
+ IVAS_DEC_HRTF_TD_HANDLE *hHrtfTD = NULL;
+ if ( ( error = IVAS_DEC_GetHrtfTDrendHandle( hIvasDec, &hHrtfTD ) ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nIVAS_DEC_GetHrtfTDrendHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
return error;
}
- if ( ( error = load_TDrend_HRTF_binary( *hHrtfBinary->hHrtfTD, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK )
+ if ( ( error = load_TDrend_HRTF_binary( *hHrtfTD, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK )
{
if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
{
@@ -3798,7 +3779,7 @@ static ivas_error load_hrtf_from_file(
}
else
{
- destroy_td_hrtf( hHrtfBinary->hHrtfTD );
+ destroy_td_hrtf( hHrtfTD );
}
}
}
@@ -3871,26 +3852,27 @@ static ivas_error load_hrtf_from_file(
}
}
}
- }
-
- if ( hHrtfBinary->hHrtfStatistics == NULL && ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND ) && OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
- {
- if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfBinary->hHrtfStatistics ) ) != IVAS_ERR_OK )
- {
- fprintf( stderr, "\nIVAS_DEC_GetHrtfStatisticsHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
- return error;
- }
- if ( ( error = load_reverb_binary( *hHrtfBinary->hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK )
+ if ( ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND ) && OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
{
- if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
+ IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL;
+ if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ) ) != IVAS_ERR_OK )
{
- fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", hHrtfBinary->hrtfFileName );
+ fprintf( stderr, "\nIVAS_DEC_GetHrtfStatisticsHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
return error;
}
- else
+
+ if ( ( error = load_HrtfStatistics_from_binary( *hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK )
{
- destroy_hrtf_statistics( hHrtfBinary->hHrtfStatistics );
+ if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
+ {
+ fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", hHrtfBinary->hrtfFileName );
+ return error;
+ }
+ else
+ {
+ destroy_hrtf_statistics( hHrtfStatistics );
+ }
}
}
}
@@ -3939,7 +3921,7 @@ static ivas_error restartDecoder(
IVAS_AUDIO_CONFIG outputConfig = ( decMode == IVAS_DEC_MODE_IVAS ) ? arg->outputConfig : IVAS_AUDIO_CONFIG_MONO;
- if ( ( error = IVAS_DEC_Configure( hIvasDec, arg->output_Fs, outputConfig, arg->renderFramesize, arg->customLsOutputEnabled, arg->hrtfReaderEnabled,
+ if ( ( error = IVAS_DEC_Configure( hIvasDec, arg->output_Fs, outputConfig, arg->render_num_subframes, arg->customLsOutputEnabled, arg->hrtfReaderEnabled,
arg->enableHeadRotation, arg->enableExternalOrientation, arg->orientation_tracking, arg->renderConfigEnabled, arg->roomSize, arg->non_diegetic_pan_enabled,
arg->non_diegetic_pan_gain_fx, arg->dpidEnabled, aeID, arg->objEditEnabled, arg->delayCompensationEnabled ) ) != IVAS_ERR_OK )
{
@@ -3947,9 +3929,18 @@ static ivas_error restartDecoder(
goto cleanup;
}
- if ( ( error = IVAS_DEC_GetRenderFramesize( hIvasDec, &arg->renderFramesize ) ) != IVAS_ERR_OK )
+ if ( arg->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
{
- fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
+ if ( ( error = IVAS_DEC_EnableSplitRendering( hIvasDec ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nSplit rendering configure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
+ goto cleanup;
+ }
+ }
+
+ if ( ( error = IVAS_DEC_GetRenderNumSubfr( hIvasDec, &arg->render_num_subframes ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nIVAS_DEC_GetRenderNumSubfr failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
goto cleanup;
}
@@ -3972,7 +3963,7 @@ static ivas_error restartDecoder(
* This will be ignored if output format is not split rendering. */
if ( renderConfig != NULL )
{
- renderConfig->split_rend_config.isar_frame_size_ms = (int16_t) arg->renderFramesize /* given in number of 5ms subframes */ * 5;
+ renderConfig->split_rend_config.isar_frame_size_ms = (int16_t) arg->render_num_subframes * 5;
}
if ( arg->renderConfigEnabled && renderConfig != NULL )
diff --git a/apps/encoder.c b/apps/encoder.c
index 35347dec5489dfce7a86d5d68df6f0158498167c..9e10a9c5c6774d5398b591801feadf8e9282d4f7 100644
--- a/apps/encoder.c
+++ b/apps/encoder.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -2049,7 +2049,7 @@ static void usage_enc( void )
fprintf( stdout, " where 0 = adaptive, 3-100 = fixed in number of frames,\n" );
fprintf( stdout, " default is deactivated\n" );
fprintf( stdout, "-dtx : Activate DTX mode with a SID update rate of 8 frames\n" );
- fprintf( stdout, " Note: DTX is supported in EVS, stereo, ISM, SBA up to 80kbps and MASA up to 128kbps \n" );
+ fprintf( stdout, " Note: DTX is supported on all bitrates for EVS, stereo, ISM, and MASA, and up to 80 kbps for SBA.\n" );
fprintf( stdout, "-rf p o : Activate channel-aware mode for WB and SWB signal at 13.2kbps, \n" );
fprintf( stdout, " where FEC indicator, p: LO or HI, and FEC offset, o: 2, 3, 5, or 7 in number of frames.\n" );
fprintf( stdout, " Alternatively p and o can be replaced by a rf configuration file with each line \n" );
diff --git a/apps/encoder_fmtsw.c b/apps/encoder_fmtsw.c
index 80e1e9a9ca9ac528f249c7978de9446fa2b3b10f..12cc57349ebfe62d144ffb4d9320d9cf3b68d86f 100644
--- a/apps/encoder_fmtsw.c
+++ b/apps/encoder_fmtsw.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -2152,7 +2152,7 @@ static void usage_enc( void )
fprintf( stdout, " where 0 = adaptive, 3-100 = fixed in number of frames,\n" );
fprintf( stdout, " default is deactivated\n" );
fprintf( stdout, "-dtx : Activate DTX mode with a SID update rate of 8 frames\n" );
- fprintf( stdout, " Note: DTX is supported in EVS, stereo, ISM, SBA up to 80kbps and MASA up to 128kbps \n" );
+ fprintf( stdout, " Note: DTX is supported on all bitrates for EVS, stereo, ISM, and MASA, and up to 80 kbps for SBA.\n" );
fprintf( stdout, "-rf p o : Activate channel-aware mode for WB and SWB signal at 13.2kbps, \n" );
fprintf( stdout, " where FEC indicator, p: LO or HI, and FEC offset, o: 2, 3, 5, or 7 in number of frames.\n" );
fprintf( stdout, " Alternatively p and o can be replaced by a rf configuration file with each line \n" );
diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c
index 6ccf204ceb221c7c11035b9f01fb93b9c191853e..c3fe556c8a02adc4ac7793d748f7b4a9a6e5391b 100644
--- a/apps/isar_post_rend.c
+++ b/apps/isar_post_rend.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -106,15 +106,12 @@ typedef struct
int32_t sampleRate;
InputConfig inConfig;
OutputConfig outConfig;
- char inMetadataFilePaths[RENDERER_MAX_ISAR_MD_INPUTS][POST_REND_MAX_CLI_ARG_LENGTH];
- int16_t numInMetadataFiles;
+ char inMetadataFilePath[POST_REND_MAX_CLI_ARG_LENGTH];
char headRotationFilePath[POST_REND_MAX_CLI_ARG_LENGTH];
char splitRendBFIFilePath[POST_REND_MAX_CLI_ARG_LENGTH];
- ISAR_POST_REND_COMPLEXITY_LEVEL complexityLevel;
bool delayCompensationEnabled;
bool quietModeEnabled;
- bool sceneDescriptionInput;
- IVAS_RENDER_FRAMESIZE render_framesize;
+ IVAS_RENDER_NUM_SUBFR render_num_subframes;
} CmdlnArgs;
typedef enum
@@ -124,8 +121,6 @@ typedef enum
CmdLnOptionId_outputFile,
CmdLnOptionId_sampleRate,
CmdLnOptionId_trajFile,
- CmdLnOptionId_orientationTracking,
- CmdLnOptionId_complexityLevel,
CmdLnOptionId_noDelayCmp,
CmdLnOptionId_quietModeEnabled,
CmdLnOptionId_inputMetadata,
@@ -133,6 +128,7 @@ typedef enum
CmdLnOptionId_SplitRendBFIFile,
CmdLnOptionId_framing,
CmdLnOptionId_srParamsFile,
+ CmdLnOptionId_help,
} CmdLnOptionId;
static const CmdLnParser_Option cliOptions[] = {
@@ -140,79 +136,91 @@ static const CmdLnParser_Option cliOptions[] = {
.id = CmdLnOptionId_inputFile,
.match = "input_file",
.matchShort = "i",
- .description = "Path to the input file (WAV, raw PCM or scene description file)",
+ .placeholder = "",
+ .description = "Path to the input file (WAV or raw PCM file with BINAURAL_SPLIT_PCM input format\nor ISAR bitstream file with BINAURAL_SPLIT_CODED input format)",
+ .isMandatory = true,
},
{
.id = CmdLnOptionId_inputFormat,
.match = "input_format",
.matchShort = "if",
- .description = "Audio format of input file (e.g. BINAURAL_SPLIT_PCM, use -l for a list)",
- },
- {
- .id = CmdLnOptionId_inputMetadata,
- .match = "input_metadata",
- .matchShort = "im",
- .description = "Space-separated list of path to metadata files for BINAURAL_SPLIT_PCM input mode",
+ .placeholder = "",
+ .description = "Audio format of input file (BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM or RTPDUMP)",
+ .isMandatory = true,
},
{
.id = CmdLnOptionId_outputFile,
.match = "output_file",
.matchShort = "o",
+ .placeholder = "",
.description = "Path to the output file",
+ .isMandatory = true,
+ },
+ {
+ .id = CmdLnOptionId_inputMetadata,
+ .match = "input_metadata",
+ .matchShort = "im",
+ .placeholder = "",
+ .description = "Path to the input metadata file (mandatory for BINAURAL_SPLIT_PCM input format)",
},
{
.id = CmdLnOptionId_sampleRate,
.match = "sample_rate",
.matchShort = "fs",
- .description = "Input sampling rate in kHz (16, 32, 48) - required only with raw PCM inputs",
+ .placeholder = "",
+ .description = "Input sampling rate in kHz (16, 32, 48) (mandatory for raw PCM input files)",
},
{
.id = CmdLnOptionId_trajFile,
.match = "trajectory_file",
.matchShort = "T",
+ .placeholder = "",
.description = "Head rotation trajectory file for simulation of head tracking",
},
{
.id = CmdLnOptionId_SplitRendBFIFile,
.match = "post_rend_bfi_file",
.matchShort = "prbfi",
- .description = "Split rendering option: bfi file",
+ .placeholder = "",
+ .description = "Split rendering BFI (Bad Frame Indicator) file",
},
{
.id = CmdLnOptionId_noDelayCmp,
.match = "no_delay_compensation",
.matchShort = "no_delay_cmp",
- .description = "[flag] Turn off delay compensation",
- },
- {
- .id = CmdLnOptionId_complexityLevel,
- .match = "complexity_level",
- .matchShort = "level",
- .description = "Complexity level, level = (1, 2, 3), will be defined after characterisation.",
+ .description = "Turn off delay compensation",
},
{
.id = CmdLnOptionId_quietModeEnabled,
.match = "quiet",
.matchShort = "q",
- .description = "[flag] Limit printouts to terminal",
+ .description = "Quiet mode - limit printouts to terminal",
},
{
.id = CmdLnOptionId_listFormats,
.match = "list",
.matchShort = "l",
- .description = "List supported audio formats",
+ .description = "List supported audio formats of input file",
},
{
.id = CmdLnOptionId_framing,
.match = "framing",
.matchShort = "fr",
- .description = "Set Render audio framing.",
+ .placeholder = "",
+ .description = "Set audio rendering frame size in ms (5, 10, 20)",
},
{
.id = CmdLnOptionId_srParamsFile,
.match = "sr_params",
.matchShort = "s",
- .description = "Path to the split rendering init params file",
+ .placeholder = "",
+ .description = "Path to the split rendering SDP init params file (mandatory for RTPDUMP input format)",
+ },
+ {
+ .id = CmdLnOptionId_help,
+ .match = "help",
+ .matchShort = "h",
+ .description = "Show this help message and exit",
},
};
@@ -293,26 +301,12 @@ static const CmdLnParser_Option *findOptionById(
static bool parseInConfig(
const char *inFormatStr,
- InputConfig *inConfig,
- bool *sceneDescriptionInput )
+ InputConfig *inConfig )
{
- char charBuf[FILENAME_MAX];
/* Initialize input config struct */
inConfig->numBinBuses = 0;
- /* First check if input is being set to scene description file - this is not covered by parseAudioConfig(). */
- strncpy( charBuf, inFormatStr, sizeof( charBuf ) - 1 );
- charBuf[sizeof( charBuf ) - 1] = '\0';
- to_upper( charBuf );
- if ( strcmp( charBuf, "META" ) == 0 )
- {
- *sceneDescriptionInput = true;
- /* Parsing the file will be done later. At this point the actual file path
- * may not be known as command line parameters are still being parsed. */
- return true;
- }
-
/* Check for single-format inputs. The given string should map to a member of AUDIO_CONFIG enum. */
bool srRtp = false;
IVAS_AUDIO_CONFIG audioConfig = parseAudioConfig( inFormatStr, &srRtp );
@@ -331,7 +325,7 @@ static bool parseInConfig(
/* Default case covers formats that are defined in the AUDIO_CONFIG enum,
* but cannot be used at input, e.g. BINAURAL */
const CmdLnParser_Option *listOption = findOptionById( CmdLnOptionId_listFormats );
- fprintf( stderr, "Unsupported input format: %s. To list valid formats, use option --%s.\n", inFormatStr, listOption->match );
+ fprintf( stderr, "Error: Unsupported input format: %s. To list valid formats, use option --%s.\n", inFormatStr, listOption->match );
return false;
}
}
@@ -340,13 +334,13 @@ static bool parseInConfig(
}
-static bool parseRenderFramesize(
+static bool parseRenderNumSubfr(
char *value,
- IVAS_RENDER_FRAMESIZE *render_framesize )
+ IVAS_RENDER_NUM_SUBFR *render_num_subframes )
{
int32_t tmp;
- *render_framesize = IVAS_RENDER_FRAMESIZE_UNKNOWN;
+ *render_num_subframes = IVAS_RENDER_NUM_SUBFR_UNKNOWN;
if ( !is_digits_only( value ) )
{
return false;
@@ -355,13 +349,13 @@ static bool parseRenderFramesize(
switch ( (int16_t) tmp )
{
case 5:
- *render_framesize = IVAS_RENDER_FRAMESIZE_5MS;
+ *render_num_subframes = IVAS_RENDER_NUM_SUBFR_5MS;
break;
case 10:
- *render_framesize = IVAS_RENDER_FRAMESIZE_10MS;
+ *render_num_subframes = IVAS_RENDER_NUM_SUBFR_10MS;
break;
case 20:
- *render_framesize = IVAS_RENDER_FRAMESIZE_20MS;
+ *render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS;
break;
default:
return false;
@@ -405,50 +399,6 @@ static IVAS_AUDIO_CONFIG parseAudioConfig(
}
-static bool checkRequiredArgs(
- CmdlnArgs args )
-{
- const CmdLnParser_Option *tmpOption;
-
- /* Check required arguments */
- bool missingRequiredArg = false;
- if ( isEmptyString( args.inputFilePath ) )
- {
- tmpOption = findOptionById( CmdLnOptionId_inputFile );
- fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort );
- missingRequiredArg = true;
- }
-
- const bool singleInputSpecified = ( args.inConfig.numBinBuses != 0 );
-
- if ( !args.sceneDescriptionInput && !singleInputSpecified )
- {
- /* Neither scene description input nor single-type input was specified on command line */
- tmpOption = findOptionById( CmdLnOptionId_inputFormat );
- fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort );
- missingRequiredArg = true;
- }
- if ( isEmptyString( args.outputFilePath ) )
- {
- tmpOption = findOptionById( CmdLnOptionId_outputFile );
- fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort );
- missingRequiredArg = true;
- }
- if ( args.sampleRate == 0 )
- {
- tmpOption = findOptionById( CmdLnOptionId_sampleRate );
- fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort );
- missingRequiredArg = true;
- }
- if ( missingRequiredArg )
- {
- CmdLnParser_printUsage( args.executableName, cliOptions, numCliOptions );
- }
-
- return !missingRequiredArg;
-}
-
-
static CmdlnArgs defaultArgs(
const char *executableName )
{
@@ -461,28 +411,28 @@ static CmdlnArgs defaultArgs(
args.sampleRate = 0;
- args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_INVALID;
+ args.inConfig.numBinBuses = 0;
+ args.inConfig.binBuses[0].srRtp = false;
+ args.inConfig.binBuses[0].audioConfig = IVAS_AUDIO_CONFIG_INVALID;
+ args.inConfig.binBuses[0].inputChannelIndex = 0;
+ args.inConfig.binBuses[0].gain_dB = 0;
- for ( int32_t i = 0; i < RENDERER_MAX_ISAR_MD_INPUTS; ++i )
- {
- clearString( args.inMetadataFilePaths[i] );
- }
- args.numInMetadataFiles = 0;
+ args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_INVALID;
+ clearString( args.inMetadataFilePath );
clearString( args.headRotationFilePath );
clearString( args.splitRendBFIFilePath );
args.delayCompensationEnabled = true;
args.quietModeEnabled = false;
- args.sceneDescriptionInput = false;
- args.render_framesize = IVAS_RENDER_FRAMESIZE_20MS;
+ args.render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS;
return args;
}
-static void parseOption(
+static int16_t parseOption(
const int32_t optionId,
char **optionValues,
const int16_t numOptionValues,
@@ -493,88 +443,155 @@ static void parseOption(
switch ( optionId )
{
case CmdLnOptionId_listFormats:
- assert( numOptionValues == 0 );
printSupportedAudioConfigs();
exit( 0 );
case CmdLnOptionId_inputFile:
- assert( numOptionValues == 1 );
+ if ( numOptionValues == 0 )
+ {
+ fprintf( stderr, "Error: No input file has been provided!\n" );
+ return -1;
+ }
+ else if ( numOptionValues > 1 )
+ {
+ fprintf( stderr, "Error: The program expects a single input file, but %d have been provided!\n", numOptionValues );
+ return -1;
+ }
strncpy( args->inputFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 );
break;
case CmdLnOptionId_inputFormat:
- assert( numOptionValues == 1 );
- if ( !parseInConfig( optionValues[0], &args->inConfig, &args->sceneDescriptionInput ) )
+ if ( numOptionValues == 0 )
{
- exit( -1 ); /* Error printout handled by failing function */
+ fprintf( stderr, "Error: No input file format has been provided!\n" );
+ return -1;
+ }
+ else if ( numOptionValues > 1 )
+ {
+ fprintf( stderr, "Error: The program expects a single input file format, but %d have been provided!\n", numOptionValues );
+ return -1;
+ }
+
+ if ( !parseInConfig( optionValues[0], &args->inConfig ) )
+ {
+ /* Error printout handled by failing function */
+ return -1;
}
break;
case CmdLnOptionId_inputMetadata:
- assert( numOptionValues <= RENDERER_MAX_ISAR_MD_INPUTS );
- for ( int16_t i = 0; i < numOptionValues; ++i )
+ if ( numOptionValues == 0 )
+ {
+ fprintf( stderr, "Error: No input metadata file for BINAURAL_SPLIT_PCM mode has been provided!\n" );
+ return -1;
+ }
+ else if ( numOptionValues > 1 )
{
- strncpy( args->inMetadataFilePaths[i], optionValues[i], POST_REND_MAX_CLI_ARG_LENGTH - 1 );
+ fprintf( stderr, "Error: The program expects a single input metadata file, but %d have been provided!\n", numOptionValues );
+ return -1;
}
- args->numInMetadataFiles = numOptionValues;
+ strncpy( args->inMetadataFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 );
break;
case CmdLnOptionId_outputFile:
- assert( numOptionValues == 1 );
+ if ( numOptionValues == 0 )
+ {
+ fprintf( stderr, "Error: No output file has been provided!\n" );
+ return -1;
+ }
+ else if ( numOptionValues > 1 )
+ {
+ fprintf( stderr, "Error: The program expects a single output file, but %d have been provided!\n", numOptionValues );
+ return -1;
+ }
strncpy( args->outputFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 );
break;
case CmdLnOptionId_sampleRate:
- assert( numOptionValues == 1 );
args->sampleRate = (int32_t) ( strtol( optionValues[0], NULL, 10 ) * 1000 );
if ( args->sampleRate == 0 )
{
- fprintf( stderr, "Invalid sampling rate specified\n" );
- exit( -1 );
+ fprintf( stderr, "Error: Invalid sampling rate specified\n" );
+ return -1;
}
break;
case CmdLnOptionId_trajFile:
- assert( numOptionValues == 1 );
+ if ( numOptionValues == 0 )
+ {
+ fprintf( stderr, "Error: No head rotation trajectory file has been provided!\n" );
+ return -1;
+ }
+ else if ( numOptionValues > 1 )
+ {
+ fprintf( stderr, "Error: The program expects a single head rotation trajectory file, but %d have been provided!\n", numOptionValues );
+ return -1;
+ }
strncpy( args->headRotationFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 );
break;
case CmdLnOptionId_SplitRendBFIFile:
- assert( numOptionValues == 1 );
- strncpy( args->splitRendBFIFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 );
- break;
- case CmdLnOptionId_complexityLevel:
- assert( numOptionValues == 1 );
- args->complexityLevel = (int32_t) ( strtol( optionValues[0], NULL, 10 ) );
- if ( args->complexityLevel < ISAR_POST_REND_COMPLEXITY_LEVEL_ONE || args->complexityLevel > ISAR_POST_REND_COMPLEXITY_LEVEL_THREE )
+ if ( numOptionValues == 0 )
{
- fprintf( stdout, "Invalid complexity level specified.\n" );
- exit( -1 );
+ fprintf( stderr, "Error: No BFI file has been provided!\n" );
+ return -1;
}
- else if ( args->complexityLevel == ISAR_POST_REND_COMPLEXITY_LEVEL_ONE || args->complexityLevel == ISAR_POST_REND_COMPLEXITY_LEVEL_TWO )
+ else if ( numOptionValues > 1 )
{
- fprintf( stdout, "Complexity levels 1 and 2 will be defined after characterisation - default to level 3 (full functionality).\n" );
+ fprintf( stderr, "Error: The program expects a single BFI file, but %d have been provided!\n", numOptionValues );
+ return -1;
}
+ strncpy( args->splitRendBFIFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 );
break;
case CmdLnOptionId_noDelayCmp:
- assert( numOptionValues == 0 );
+ if ( numOptionValues != 0 )
+ {
+ fprintf( stderr, "Error: Incorrect specification of the `-%s/--%s` command-line option!\n", cliOptions[optionId].matchShort, cliOptions[optionId].match );
+ return -1;
+ }
args->delayCompensationEnabled = false;
break;
case CmdLnOptionId_quietModeEnabled:
- assert( numOptionValues == 0 );
+ if ( numOptionValues != 0 )
+ {
+ fprintf( stderr, "Error: Incorrect specification of the `-%s/--%s` command-line option!\n", cliOptions[optionId].matchShort, cliOptions[optionId].match );
+ return -1;
+ }
args->quietModeEnabled = true;
break;
case CmdLnOptionId_framing:
- assert( numOptionValues == 1 );
- if ( !parseRenderFramesize( optionValues[0], &args->render_framesize ) )
+ if ( numOptionValues == 0 )
+ {
+ fprintf( stderr, "Error: Incorrect audio rendering frame size!\n" );
+ return -1;
+ }
+ else if ( numOptionValues > 1 )
{
- fprintf( stderr, "Unknown or invalid option for frame size: %s\n", optionValues[0] );
- exit( -1 );
+ fprintf( stderr, "Error: The program expects a rendering frame size, but %d have been provided!\n", numOptionValues );
+ return -1;
+ }
+ if ( !parseRenderNumSubfr( optionValues[0], &args->render_num_subframes ) )
+ {
+ fprintf( stderr, "Error: Unknown or invalid option for audio rendring frame size: %s\n", optionValues[0] );
+ return -1;
}
break;
case CmdLnOptionId_srParamsFile:
- assert( numOptionValues == 1 );
+ if ( numOptionValues == 0 )
+ {
+ fprintf( stderr, "Error: No path to the parameter initialization file has been provided!\n" );
+ return -1;
+ }
+ else if ( numOptionValues > 1 )
+ {
+ fprintf( stderr, "Error: The program expects a single parameter initialization file, but %d have been provided!\n", numOptionValues );
+ return -1;
+ }
strncpy( args->srParamsFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 );
break;
+ case CmdLnOptionId_help:
+ CmdLnParser_printUsage( args->executableName, cliOptions, numCliOptions );
+ exit( 0 );
default:
- assert( 0 && "This should be unreachable - all command line options should be explicitly handled." );
+ fprintf( stderr, "Error: Incorrect or invalid command-line usage!\n" );
+ return -1;
break;
}
- return;
+ return 0;
}
@@ -589,11 +606,6 @@ static CmdlnArgs parseCmdlnArgs(
exit( -1 ); /* Error printout handled by failing function */
}
- if ( !checkRequiredArgs( args ) )
- {
- exit( -1 ); /* Error printout handled by failing function */
- }
-
return args;
}
@@ -602,13 +614,12 @@ static void printSupportedAudioConfigs( void )
{
uint16_t i;
const char *supportedFormats[] = {
- "BINAURAL (output only)",
"BINAURAL_SPLIT_PCM",
"BINAURAL_SPLIT_CODED",
"RTPDUMP",
};
- fprintf( stdout, "Supported audio formats:\n" );
+ fprintf( stdout, "Supported audio formats:\n\n" );
for ( i = 0; i < sizeof( supportedFormats ) / sizeof( *supportedFormats ); i++ )
{
fprintf( stdout, "%s\n", supportedFormats[i] );
@@ -876,7 +887,6 @@ int main(
convert_backslash( args.inputFilePath );
convert_backslash( args.outputFilePath );
- convert_backslash( args.headRotationFilePath );
convert_backslash( args.srParamsFilePath );
/*------------------------------------------------------------------------------------------*
@@ -885,6 +895,7 @@ int main(
if ( !isEmptyString( args.headRotationFilePath ) )
{
+ convert_backslash( args.headRotationFilePath );
if ( RotationFileReader_open( args.headRotationFilePath, &headRotReader ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nError opening file: %s\n", args.headRotationFilePath );
@@ -899,7 +910,11 @@ int main(
if ( !isEmptyString( args.splitRendBFIFilePath ) )
{
convert_backslash( args.splitRendBFIFilePath );
- SplitRendBFIFileReader_open( args.splitRendBFIFilePath, &splitRendBFIReader );
+ if ( SplitRendBFIFileReader_open( args.splitRendBFIFilePath, &splitRendBFIReader ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError opening file: %s\n", args.splitRendBFIFilePath );
+ goto cleanup;
+ }
}
int32_t inFileSampleRate = 0;
@@ -908,7 +923,7 @@ int main(
if ( ( args.inConfig.numBinBuses > 0 ) && ( args.inConfig.binBuses[0].audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
{
error = split_rend_reader_open( &hSplitRendFileReadWrite,
- args.inMetadataFilePaths[0],
+ args.inMetadataFilePath,
&bitsBuffer.config.codec,
&bitsBuffer.config.poseCorrection,
&bitsBuffer.config.codec_frame_size_ms,
@@ -917,13 +932,21 @@ int main(
&bitsBuffer.config.lc3plusHighRes );
if ( error != IVAS_ERR_OK )
{
- fprintf( stderr, "\nCould not open split rend metadata file %s\n", args.inMetadataFilePaths[0] );
+ if ( isEmptyString( args.inMetadataFilePath ) )
+ {
+ const CmdLnParser_Option *listOption = findOptionById( CmdLnOptionId_inputMetadata );
+ fprintf( stderr, "\nError: Split rendering metadata file not specified, use option -%s/--%s.\n", listOption->matchShort, listOption->match );
+ }
+ else
+ {
+ fprintf( stderr, "\nError: Could not open split rendering metadata file %s!\n", args.inMetadataFilePath );
+ }
goto cleanup;
}
if ( AudioFileReader_open( &audioReader, audioFilePath ) != IVAS_ERR_OK )
{
- fprintf( stderr, "\nError opening file: %s\n", audioFilePath );
+ fprintf( stderr, "\nError: Could not open input file: %s!\n", audioFilePath );
goto cleanup;
}
}
@@ -939,19 +962,19 @@ int main(
&bitsBuffer.config.lc3plusHighRes );
if ( error != IVAS_ERR_OK )
{
- fprintf( stderr, "\nCould not open split rend params file %s\n", args.srParamsFilePath );
+ fprintf( stderr, "\nError: Could not open split rendering init params file %s!\n", args.srParamsFilePath );
goto cleanup;
}
if ( ( error = IVAS_RTP_READER_Init( &srRTP, args.inputFilePath, NULL, false, NULL ) ) != IVAS_ERR_OK )
{
- fprintf( stderr, "error in IVAS_RTP_READER_Init(): %d\n", error );
+ fprintf( stderr, "\nError in IVAS_RTP_READER_Init(), error code: %d!\n", error );
goto cleanup;
}
audioReader = NULL;
/* Force owerwrite of command line provided rendersize to align with codec frame size */
- args.render_framesize = bitsBuffer.config.isar_frame_size_ms / 5;
+ args.render_num_subframes = bitsBuffer.config.isar_frame_size_ms / 5;
}
/*if split renderer is running in post renderer mode*/
else if ( ( args.inConfig.numBinBuses > 0 ) && ( args.inConfig.binBuses[0].audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) )
@@ -966,7 +989,7 @@ int main(
&bitsBuffer.config.lc3plusHighRes );
if ( error != IVAS_ERR_OK )
{
- fprintf( stderr, "\nCould not open split rend metadata file %s\n", args.inputFilePath );
+ fprintf( stderr, "\nError reading input file %s, error code: %d!\n", args.inputFilePath, error );
goto cleanup;
}
audioReader = NULL;
@@ -992,14 +1015,14 @@ int main(
/* else if sampling rate given on command line, compare with wav file */
else if ( inFileSampleRate != args.sampleRate )
{
- fprintf( stderr, "\nSampling rate mismatch: %d Hz requested, but %d Hz found in file %s\n", args.sampleRate, inFileSampleRate, args.inputFilePath );
+ fprintf( stderr, "\nError: Sampling rate mismatch: %d Hz requested, but %d Hz found in file %s!\n", args.sampleRate, inFileSampleRate, args.inputFilePath );
goto cleanup;
}
break;
case IVAS_ERR_SAMPLING_RATE_UNKNOWN: /* Returned when input is raw PCM */
if ( args.sampleRate == 0 )
{
- fprintf( stderr, "\nSampling rate must be specified on command line when using raw PCM input\n" );
+ fprintf( stderr, "\nError: Sampling rate must be specified on command line in case of raw PCM input!\n" );
goto cleanup;
}
break;
@@ -1014,7 +1037,7 @@ int main(
error = AudioFileReader_getNumChannels( audioReader, &inFileNumChannels );
if ( error != IVAS_ERR_OK && error != IVAS_ERR_NUM_CHANNELS_UNKNOWN )
{
- fprintf( stderr, "\nAudioFileReader_getNumChannels failed: %s\n", ivas_error_to_string( error ) );
+ fprintf( stderr, "\nError: AudioFileReader_getNumChannels() failed: %s\n", ivas_error_to_string( error ) );
goto cleanup;
}
}
@@ -1023,9 +1046,9 @@ int main(
* Open ISAR handle
*------------------------------------------------------------------------------------------*/
- const int16_t frameSize_smpls = (int16_t) ( ( args.render_framesize ) * args.sampleRate * 5 / ( 1000 ) );
+ const int16_t frameSize_smpls = (int16_t) ( ( args.render_num_subframes ) * args.sampleRate * 5 / ( 1000 ) );
args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_BINAURAL;
- if ( ( error = ISAR_POST_REND_open( &hIsarPostRend, args.sampleRate, args.outConfig.audioConfig, true, 0, 0, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK )
+ if ( ( error = ISAR_POST_REND_open( &hIsarPostRend, args.sampleRate, args.outConfig.audioConfig, true, 0, 0, (int16_t) args.render_num_subframes ) ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nError opening renderer handle: %s\n", ivas_error_to_string( error ) );
goto cleanup;
@@ -1242,34 +1265,45 @@ int main(
/* Convert from int to float and from interleaved to packed */
convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer_fx );
*inBuffer.pq_fact = 0;
- int16_t num_subframes, sf_idx;
- num_subframes = (int16_t) args.render_framesize;
+ int16_t num_subframes;
+ num_subframes = (int16_t) args.render_num_subframes;
/* Read from head rotation trajectory file if specified */
+ IVAS_QUATERNION headRot[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
+ IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
if ( headRotReader != NULL )
{
- for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ )
+ for ( i = 0; i < num_subframes; i++ )
{
- IVAS_QUATERNION headRot;
- IVAS_VECTOR3 Pos;
-
- IF( ( error = HeadRotationFileReading( headRotReader, &headRot, &Pos ) ) != IVAS_ERR_OK )
+ if ( ( error = HeadRotationFileReading( headRotReader, &headRot[i], &Pos[i] ) ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nError in Head Rotation File Reading: %s\n", ivas_error_to_string( error ) );
goto cleanup;
}
-
- if ( ( error = ISAR_POST_REND_SetHeadRotation( hIsarPostRend, headRot, Pos, DEFAULT_AXIS, sf_idx ) ) != IVAS_ERR_OK )
- {
- fprintf( stderr, "\nError setting Head Rotation: %s\n", ivas_error_to_string( error ) );
- goto cleanup;
- }
}
}
else
{
- fprintf( stderr, "\nHead Rotation should be enabled in post renderer\n" );
- goto cleanup;
+ for ( i = 0; i < num_subframes; i++ )
+ {
+ headRot[i].w_fx = -12582912;
+ headRot[i].x_fx = 0;
+ headRot[i].y_fx = 0;
+ headRot[i].z_fx = 0;
+ headRot[i].q_fact = 22;
+ Pos[i].x_fx = 0;
+ Pos[i].y_fx = 0;
+ Pos[i].z_fx = 0;
+ }
+ }
+
+ for ( i = 0; i < num_subframes; i++ )
+ {
+ if ( ( error = ISAR_POST_REND_SetHeadRotation( hIsarPostRend, headRot[i], Pos[i], DEFAULT_AXIS, i ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError setting Head Rotation: %s\n", ivas_error_to_string( error ) );
+ goto cleanup;
+ }
}
/* Read from split renderer bfi file if specified */
diff --git a/apps/renderer.c b/apps/renderer.c
index 464a9f8930ec7cf70a89f8b23ad4bec185abe4c7..73203597c4ab47b940b6ae7a7b39f4c86693f5b6 100644
--- a/apps/renderer.c
+++ b/apps/renderer.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -87,11 +87,6 @@ static
#define SEP_FOLDER '/'
#endif
-#ifndef _WIN32
-#define max( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
-#define min( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
-#endif
-
/*------------------------------------------------------------------------------------------*
* Local structures
@@ -172,7 +167,6 @@ typedef struct
int16_t numInMetadataFiles;
char outMetadataFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
char headRotationFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
- char splitRendBFIFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
char referenceVectorFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
char referenceRotationFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
char externalOrientationFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
@@ -195,7 +189,7 @@ typedef struct
bool lfeCustomRoutingEnabled;
char inLfePanningMatrixFile[RENDERER_MAX_CLI_ARG_LENGTH];
int16_t syncMdDelay;
- IVAS_RENDER_FRAMESIZE render_framesize;
+ IVAS_RENDER_NUM_SUBFR render_num_subframes;
uint16_t directivityPatternId[RENDERER_MAX_ISM_INPUTS];
AcousticEnvironmentSequence aeSequence;
IVAS_ROOM_SIZE_T reverbRoomSize;
@@ -223,7 +217,6 @@ typedef enum
CmdLnOptionId_listFormats,
CmdLnOptionId_inputGain,
CmdLnOptionId_outputMetadata,
- CmdLnOptionId_SplitRendBFIFile,
CmdLnOptionId_referenceVectorFile,
CmdLnOptionId_exteriorOrientationFile,
CmdLnOptionId_framing,
@@ -238,96 +231,109 @@ static const CmdLnParser_Option cliOptions[] = {
.id = CmdLnOptionId_inputFile,
.match = "input_file",
.matchShort = "i",
+ .placeholder = "",
.description = "Path to the input file (WAV, raw PCM or scene description file)",
+ .isMandatory = true,
},
{
.id = CmdLnOptionId_inputFormat,
.match = "input_format",
.matchShort = "if",
+ .placeholder = "",
.description = "Audio format of input file (e.g. 5_1 or HOA3 or META,\nuse -l for a list)",
+ .isMandatory = true,
},
{
.id = CmdLnOptionId_inputMetadata,
.match = "input_metadata",
.matchShort = "im",
+ .placeholder = " [...]",
.description = "Space-separated list of path to metadata files for ISM/MASA/OMASA/\nOSBA/BINAURAL_SPLIT_PCM inputs. \nFor OMASA, ISM files must be specified first.",
},
{
.id = CmdLnOptionId_outputFile,
.match = "output_file",
.matchShort = "o",
+ .placeholder = "",
.description = "Path to the output file",
+ .isMandatory = true,
},
{
.id = CmdLnOptionId_outputFormat,
.match = "output_format",
.matchShort = "of",
+ .placeholder = "",
.description = "Output format to render.\nAlternatively, can be a custom loudspeaker layout file",
+ .isMandatory = true,
},
{
.id = CmdLnOptionId_sampleRate,
.match = "sample_rate",
.matchShort = "fs",
+ .placeholder = "",
.description = "Input sampling rate in kHz (16, 32, 48) - required only with raw\nPCM inputs",
},
{
.id = CmdLnOptionId_trajFile,
.match = "trajectory_file",
.matchShort = "T",
+ .placeholder = "",
.description = "Head rotation trajectory file for simulation of head tracking\n(only for binaural outputs)",
},
{
.id = CmdLnOptionId_outputMetadata,
.match = "output_metadata",
.matchShort = "om",
+ .placeholder = "",
.description = "coded metadata file for BINAURAL_SPLIT_PCM output mode",
},
- {
- .id = CmdLnOptionId_SplitRendBFIFile,
- .match = "post_rend_bfi_file",
- .matchShort = "prbfi",
- .description = "Split rendering option: bfi file",
- },
{
.id = CmdLnOptionId_refRotFile,
.match = "reference_rotation_file",
.matchShort = "rf",
+ .placeholder = "",
.description = "Reference rotation trajectory file for simulation of head tracking\n(only for binaural outputs)",
},
{
.id = CmdLnOptionId_customHrtfFile,
.match = "custom_hrtf",
.matchShort = "hrtf",
+ .placeholder = "",
.description = "Custom HRTF file for binaural rendering\n(only for binaural outputs)",
},
{
.id = CmdLnOptionId_renderConfigFile,
.match = "render_config_parameters",
.matchShort = "render_config",
+ .placeholder = "",
.description = "Binaural renderer configuration parameters in file\n(only for binaural outputs)",
},
{
.id = CmdLnOptionId_nonDiegeticPan,
.match = "non_diegetic_panning",
.matchShort = "non_diegetic_pan",
+ .placeholder = "",
.description = "Panning mono non diegetic sound to stereo -90<= pan <= 90\nleft or l or 90->left, right or r or -90->right,\ncenter or c or 0 ->middle",
},
{
.id = CmdLnOptionId_orientationTracking,
.match = "tracking_type",
.matchShort = "otr",
+ .placeholder = "",
.description = "Head orientation tracking type: 'none', 'ref', 'avg' or `ref_vec`\nor `ref_vec_lev` (only for binaural outputs)",
},
{
.id = CmdlnOptionId_lfePosition,
.match = "lfe_position",
.matchShort = "lp",
+ .placeholder = ",,",
.description = "Output LFE position. Comma-delimited triplet of [gain, azimuth,\nelevation] where gain is linear (like --gain, -g) and azimuth,\nelevation are in degrees. If specified, overrides the default\nbehavior which attempts to map input to output LFE channel(s)",
},
{
.id = CmdlnOptionId_lfeMatrix,
.match = "lfe_matrix",
.matchShort = "lm",
+ .placeholder = "",
.description = "LFE panning matrix. File (CSV table) containing a matrix of\ndimensions [ num_input_lfe x num_output_channels ] with elements\nspecifying linear routing gain (like --gain, -g). If specified,\noverrides the output LFE position option and the default\nbehavior which attempts to map input to output LFE channel(s)",
},
{
@@ -340,6 +346,7 @@ static const CmdLnParser_Option cliOptions[] = {
.id = CmdLnOptionId_complexityLevel,
.match = "complexity_level",
.matchShort = "level",
+ .placeholder = "",
.description = "Complexity level, level = (1, 2, 3), will be defined after\ncharacterisation.",
},
{
@@ -352,6 +359,7 @@ static const CmdLnParser_Option cliOptions[] = {
.id = CmdLnOptionId_inputGain,
.match = "gain",
.matchShort = "g",
+ .placeholder = "",
.description = "Input gain (linear, not in dB) to be applied to input audio file",
},
{
@@ -364,43 +372,50 @@ static const CmdLnParser_Option cliOptions[] = {
.id = CmdLnOptionId_referenceVectorFile,
.match = "reference_vector_file",
.matchShort = "rvf",
+ .placeholder = "",
.description = "Reference vector trajectory file for simulation of head tracking\n(only for binaural outputs)",
},
{
.id = CmdLnOptionId_exteriorOrientationFile,
.match = "exterior_orientation_file",
.matchShort = "exof",
+ .placeholder = "",
.description = "External orientation trajectory file for simulation of external\norientations",
},
{
.id = CmdLnOptionId_framing,
.match = "framing",
.matchShort = "fr",
- .description = "Set Render audio framing.",
+ .placeholder = "",
+ .description = "Set render audio framing in ms",
},
{
.id = CmdLnOptionId_syncMdDelay,
.match = "sync_md_delay",
.matchShort = "smd",
+ .placeholder = "",
.description = "Metadata Synchronization Delay in ms, Default is 0. Quantized by\n5ms subframes for TDRenderer (13ms -> 10ms -> 2subframes)",
},
{
.id = CmdLnOptionId_directivityPatternId,
.match = "ism_directivity_pattern_id",
.matchShort = "dpid",
+ .placeholder = " [...]",
.description = "Directivity pattern ID(s) = [ID1, ID2, ID3, ID4]. Space-separated\nlist of up to 4 numbers (unsigned integers) can be specified for\nBINAURAL and BINAURAL_ROOM_REVERB output.\nID1, ID2, ID3, ID4 specify the directivity pattern IDs used for\nISMs 1,2,3 and 4 respectively. \nThis option needs to be accompanied by a render_config file,\notherwise a default directivity pattern is used.",
},
{
.id = CmdLnOptionId_acousticEnvironmentId,
.match = "acoustic_environment_id",
.matchShort = "aeid",
+ .placeholder = "",
.description = "Acoustic environment ID (number > 0) alternatively, it can be a text file where each line contains \"ID duration\" for BINAURAL_ROOM_REVERB output configuration.",
},
{
.id = CmdLnOptionId_roomSize,
.match = "room_size",
.matchShort = "rsz",
- .description = "Selects default reverb based on a room size (S - small | M - medium | L - large)",
+ .placeholder = "",
+ .description = "Selects default reverb based on a room size (S - small |\nM - medium | L - large)",
}
};
@@ -660,8 +675,8 @@ static void setupWithSingleFormatInput(
/* It is allowed on CLI to have no metadata for an ISM input - skip opening if string contains "NULL" */
char charBuf[FILENAME_MAX];
- strncpy( charBuf, args.inMetadataFilePaths[i], min( FILENAME_MAX, RENDERER_MAX_CLI_ARG_LENGTH ) - 1 );
- charBuf[min( FILENAME_MAX, RENDERER_MAX_CLI_ARG_LENGTH ) - 1] = '\0';
+ strncpy( charBuf, args.inMetadataFilePaths[i], RENDERER_MAX_CLI_ARG_LENGTH - 1 );
+ charBuf[RENDERER_MAX_CLI_ARG_LENGTH - 1] = '\0';
to_upper( charBuf );
if ( strncmp( charBuf, "NULL", 4 ) == 0 )
{
@@ -763,7 +778,6 @@ int main(
IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[RENDERER_MAX_INPUT_CHANNELS];
IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[RENDERER_MAX_INPUT_CHANNELS];
int16_t cldfb_in_flag, CLDFBframeSize_smpls;
- SplitRendBFIFileReader *splitRendBFIReader = NULL;
Vector3PairFileReader *referenceVectorReader = NULL;
hrtfFileReader *hrtfFileReader = NULL;
IVAS_DEC_HRTF_CREND_HANDLE *hHrtfCrend = NULL;
@@ -893,11 +907,6 @@ int main(
}
}
- if ( !isEmptyString( args.splitRendBFIFilePath ) )
- {
- convert_backslash( args.splitRendBFIFilePath );
- SplitRendBFIFileReader_open( args.splitRendBFIFilePath, &splitRendBFIReader );
- }
if ( !isEmptyString( args.externalOrientationFilePath ) )
{
if ( RotationFileReader_open( args.externalOrientationFilePath, &externalOrientationFileReader ) != IVAS_ERR_OK )
@@ -992,12 +1001,12 @@ int main(
goto cleanup;
}
- const int16_t frameSize_smpls = (int16_t) ( ( args.render_framesize ) * args.sampleRate * 5 / ( 1000 ) );
+ const int16_t frameSize_smpls = (int16_t) ( ( args.render_num_subframes ) * args.sampleRate * BINAURAL_RENDERING_FRAME_SIZE_MS / ( 1000 ) );
Word32 nonDiegeticPanGain_fx = ( args.nonDiegeticPanGain == 1.0f ) ? ONE_IN_Q31 : ( args.nonDiegeticPanGain == -1.0f ) ? L_negate( ONE_IN_Q31 )
: (Word32) ( args.nonDiegeticPanGain * ( 1LL << Q31 ) );
- IF( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, !isEmptyString( args.customHrtfFilePath ), args.nonDiegeticPan, nonDiegeticPanGain_fx, args.Opt_Headrotation, args.Opt_ExternalOrientation, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK )
+ IF( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, !isEmptyString( args.customHrtfFilePath ), args.nonDiegeticPan, nonDiegeticPanGain_fx, args.Opt_Headrotation, args.Opt_ExternalOrientation, (int16_t) args.render_num_subframes ) ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nError opening renderer handle: %s\n", ivas_error_to_string( error ) );
goto cleanup;
@@ -1102,7 +1111,7 @@ int main(
fprintf( stderr, "\nIVAS_REND_GetHrtfStatisticsHandle failed\n\n" );
goto cleanup;
}
- if ( ( error = load_reverb_binary( *hHrtfStatistics, args.sampleRate, hrtfFileReader ) ) != IVAS_ERR_OK )
+ if ( ( error = load_HrtfStatistics_from_binary( *hHrtfStatistics, args.sampleRate, hrtfFileReader ) ) != IVAS_ERR_OK )
{
if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
{
@@ -1221,7 +1230,7 @@ int main(
/* ISAR frame size is set from command line, not renderer config file.
* This will be ignored if output format is not split rendering. */
- renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) args.render_framesize /* given in number of 5ms subframes */ * 5;
+ renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) args.render_num_subframes * BINAURAL_RENDERING_FRAME_SIZE_MS;
if ( ( error = IVAS_REND_FeedRenderConfig( hIvasRend, renderConfig ) ) != IVAS_ERR_OK )
{
@@ -1252,8 +1261,8 @@ int main(
/* Set up output custom layout configuration */
if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM )
{
- floatToFixed_arrL_app( args.outConfig.outSetupCustom.azimuth, args.outConfig.outSetupCustom.azimuth_fx, Q22, RENDERER_MAX_OUTPUT_CHANNELS );
- floatToFixed_arrL_app( args.outConfig.outSetupCustom.elevation, args.outConfig.outSetupCustom.elevation_fx, Q22, RENDERER_MAX_OUTPUT_CHANNELS );
+ floatToFixed_arrL_app( args.outConfig.outSetupCustom.azimuth, args.outConfig.outSetupCustom.azimuth_fx, Q22, args.outConfig.outSetupCustom.num_spk );
+ floatToFixed_arrL_app( args.outConfig.outSetupCustom.elevation, args.outConfig.outSetupCustom.elevation_fx, Q22, args.outConfig.outSetupCustom.num_spk );
if ( ( error = IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( hIvasRend, args.outConfig.outSetupCustom ) ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nError in IVAS_REND_ConfigureCustomOutputLoudspeakerLayout(): %s\n", ivas_error_to_string( error ) );
@@ -1357,8 +1366,8 @@ int main(
if ( args.inConfig.multiChannelBuses[i].audioConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM )
{
- floatToFixed_arrL_app( args.inConfig.inSetupCustom.azimuth, args.inConfig.inSetupCustom.azimuth_fx, Q22, RENDERER_MAX_OUTPUT_CHANNELS );
- floatToFixed_arrL_app( args.inConfig.inSetupCustom.elevation, args.inConfig.inSetupCustom.elevation_fx, Q22, RENDERER_MAX_OUTPUT_CHANNELS );
+ floatToFixed_arrL_app( args.inConfig.inSetupCustom.azimuth, args.inConfig.inSetupCustom.azimuth_fx, Q22, args.inConfig.inSetupCustom.num_spk );
+ floatToFixed_arrL_app( args.inConfig.inSetupCustom.elevation, args.inConfig.inSetupCustom.elevation_fx, Q22, args.inConfig.inSetupCustom.num_spk );
if ( ( error = IVAS_REND_ConfigureCustomInputLoudspeakerLayout( hIvasRend, mcIds[i], args.inConfig.inSetupCustom ) ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nError in IVAS_REND_ConfigureCustomInputLoudspeakerLayout(): %s\n", ivas_error_to_string( error ) );
@@ -1545,7 +1554,7 @@ int main(
if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, outFile, delayNumSamples_temp, delayTimeScale_temp, bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, bitsBuffer.config.codec_frame_size_ms, bitsBuffer.config.isar_frame_size_ms, args.sampleRate, bitsBuffer.config.lc3plus_highres ) ) != IVAS_ERR_OK )
{
- fprintf( stderr, "\nCould not open split rend metadata file %s\n", outFile );
+ fprintf( stderr, "\nError: Could not open split rend metadata file %s!\n", outFile );
goto cleanup;
}
}
@@ -1649,7 +1658,7 @@ int main(
{
int16_t num_in_channels;
num_in_channels = inBuffer.config.numChannels;
- const bool isCurrentFrameMultipleOf20ms = frame % ( 4 / args.render_framesize ) == 0;
+ const bool isCurrentFrameMultipleOf20ms = frame % ( IVAS_RENDER_NUM_SUBFR_20MS / args.render_num_subframes ) == 0;
if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && renderConfigReader != NULL &&
args.aeSequence.count > 0 && args.aeSequence.pValidity[args.aeSequence.selected] != 0 )
@@ -1713,7 +1722,7 @@ int main(
}
int16_t num_subframes, sf_idx;
- num_subframes = (int16_t) args.render_framesize;
+ num_subframes = (int16_t) args.render_num_subframes;
if ( isCurrentFrameMultipleOf20ms && !flushRendererLastFrame )
{
@@ -2179,7 +2188,6 @@ cleanup:
}
split_rend_reader_writer_close( &hSplitRendFileReadWrite );
- SplitRendBFIFileReader_close( &splitRendBFIReader );
for ( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i )
{
@@ -2192,8 +2200,6 @@ cleanup:
RotationFileReader_close( &externalOrientationFileReader );
RotationFileReader_close( &referenceRotReader );
Vector3PairFileReader_close( &referenceVectorReader );
- destroy_td_hrtf( hHrtfTD );
- destroy_hrtf_statistics( hHrtfStatistics );
IVAS_REND_Close( &hIvasRend );
IsmPositionProvider_close( positionProvider );
RenderConfigReader_close( &renderConfigReader );
@@ -2418,13 +2424,13 @@ static bool parseDiegeticPan(
}
-static bool parseRenderFramesize(
+static bool parseRenderNumSubfr(
char *value,
- IVAS_RENDER_FRAMESIZE *render_framesize )
+ IVAS_RENDER_NUM_SUBFR *render_num_subframes )
{
int32_t tmp;
- *render_framesize = IVAS_RENDER_FRAMESIZE_UNKNOWN;
+ *render_num_subframes = IVAS_RENDER_NUM_SUBFR_UNKNOWN;
if ( !is_digits_only( value ) )
{
return false;
@@ -2433,13 +2439,13 @@ static bool parseRenderFramesize(
switch ( (int16_t) tmp )
{
case 5:
- *render_framesize = IVAS_RENDER_FRAMESIZE_5MS;
+ *render_num_subframes = IVAS_RENDER_NUM_SUBFR_5MS;
break;
case 10:
- *render_framesize = IVAS_RENDER_FRAMESIZE_10MS;
+ *render_num_subframes = IVAS_RENDER_NUM_SUBFR_10MS;
break;
case 20:
- *render_framesize = IVAS_RENDER_FRAMESIZE_20MS;
+ *render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS;
break;
default:
return false;
@@ -2698,53 +2704,6 @@ static bool parseReverbRoomSize(
return true;
}
-
-static bool checkRequiredArgs(
- CmdlnArgs args )
-{
- const CmdLnParser_Option *tmpOption;
-
- /* Check required arguments */
- bool missingRequiredArg = false;
- if ( isEmptyString( args.inputFilePath ) )
- {
- tmpOption = findOptionById( CmdLnOptionId_inputFile );
- fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort );
- missingRequiredArg = true;
- }
-
- const bool singleInputSpecified = args.inConfig.numAudioObjects != 0 ||
- args.inConfig.numAmbisonicsBuses != 0 ||
- args.inConfig.numMultiChannelBuses != 0 ||
- args.inConfig.numMasaBuses != 0;
-
- if ( !args.sceneDescriptionInput && !singleInputSpecified )
- {
- /* Neither scene description input nor single-type input was specified on command line */
- tmpOption = findOptionById( CmdLnOptionId_inputFormat );
- fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort );
- missingRequiredArg = true;
- }
- if ( isEmptyString( args.outputFilePath ) )
- {
- tmpOption = findOptionById( CmdLnOptionId_outputFile );
- fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort );
- missingRequiredArg = true;
- }
- if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_INVALID )
- {
- tmpOption = findOptionById( CmdLnOptionId_outputFormat );
- fprintf( stderr, "Missing required argument: %s (%s)\n", tmpOption->match, tmpOption->matchShort );
- missingRequiredArg = true;
- }
- if ( missingRequiredArg )
- {
- CmdLnParser_printUsage( args.executableName, cliOptions, numCliOptions );
- }
-
- return !missingRequiredArg;
-}
-
static CmdlnArgs defaultArgs(
const char *executableName )
{
@@ -2758,6 +2717,13 @@ static CmdlnArgs defaultArgs(
args.inConfig.inSetupCustom.num_spk = 0;
args.inConfig.inSetupCustom.num_lfe = 0;
+ for ( i = 0; i < RENDERER_MAX_INPUT_CHANNELS; i++ )
+ {
+ args.inConfig.inSetupCustom.azimuth[i] = 0.f;
+ args.inConfig.inSetupCustom.azimuth_fx[i] = 0;
+ args.inConfig.inSetupCustom.elevation[i] = 0.f;
+ args.inConfig.inSetupCustom.elevation_fx[i] = 0;
+ }
args.inConfig.numAudioObjects = 0;
args.inConfig.numAmbisonicsBuses = 0;
args.inConfig.numMultiChannelBuses = 0;
@@ -2766,6 +2732,13 @@ static CmdlnArgs defaultArgs(
args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_INVALID;
args.outConfig.outSetupCustom.num_spk = 0;
args.outConfig.outSetupCustom.num_lfe = 0;
+ for ( i = 0; i < RENDERER_MAX_OUTPUT_CHANNELS; i++ )
+ {
+ args.outConfig.outSetupCustom.azimuth[i] = 0.f;
+ args.outConfig.outSetupCustom.azimuth_fx[i] = 0;
+ args.outConfig.outSetupCustom.elevation[i] = 0.f;
+ args.outConfig.outSetupCustom.elevation_fx[i] = 0;
+ }
for ( i = 0; i < RENDERER_MAX_SBA_INPUTS; ++i )
{
args.inConfig.ambisonicsBuses[i].audioConfig = IVAS_AUDIO_CONFIG_INVALID;
@@ -2779,7 +2752,6 @@ static CmdlnArgs defaultArgs(
clearString( args.headRotationFilePath );
clearString( args.outMetadataFilePath );
- clearString( args.splitRendBFIFilePath );
clearString( args.referenceVectorFilePath );
clearString( args.referenceRotationFilePath );
clearString( args.customHrtfFilePath );
@@ -2806,7 +2778,7 @@ static CmdlnArgs defaultArgs(
args.lfeCustomRoutingEnabled = false;
clearString( args.inLfePanningMatrixFile );
- args.render_framesize = IVAS_RENDER_FRAMESIZE_20MS;
+ args.render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS;
args.syncMdDelay = 0;
for ( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i )
{
@@ -2824,7 +2796,7 @@ static CmdlnArgs defaultArgs(
return args;
}
-static void parseOption(
+static int16_t parseOption(
const int32_t optionId,
char **optionValues,
const int16_t numOptionValues,
@@ -2886,10 +2858,6 @@ static void parseOption(
assert( numOptionValues == 1 );
strncpy( args->outMetadataFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 );
break;
- case CmdLnOptionId_SplitRendBFIFile:
- assert( numOptionValues == 1 );
- strncpy( args->splitRendBFIFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 );
- break;
case CmdLnOptionId_referenceVectorFile:
assert( numOptionValues == 1 );
strncpy( args->referenceVectorFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 );
@@ -2975,7 +2943,7 @@ static void parseOption(
break;
case CmdLnOptionId_framing:
assert( numOptionValues == 1 );
- if ( !parseRenderFramesize( optionValues[0], &args->render_framesize ) )
+ if ( !parseRenderNumSubfr( optionValues[0], &args->render_num_subframes ) )
{
fprintf( stderr, "Unknown or invalid option for frame size: %s\n", optionValues[0] );
exit( -1 );
@@ -3014,7 +2982,7 @@ static void parseOption(
break;
}
- return;
+ return 0;
}
static CmdlnArgs parseCmdlnArgs(
@@ -3028,11 +2996,6 @@ static CmdlnArgs parseCmdlnArgs(
exit( -1 ); /* Error printout handled by failing function */
}
- if ( !checkRequiredArgs( args ) )
- {
- exit( -1 ); /* Error printout handled by failing function */
- }
-
if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
{
args.Opt_Headrotation = 1;
diff --git a/lib_basop/basop32.c b/lib_basop/basop32.c
index eebc1684915ccba9a062a49f561a112f2208d36d..27b4992767c28495e79d03bfd466c620fc6e5d57 100644
--- a/lib_basop/basop32.c
+++ b/lib_basop/basop32.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_basop/basop32.h b/lib_basop/basop32.h
index 9bbf24f1c52e1c5159ad4ff22fa6720f3bfcd60a..7fe294167c38a962ea16d6b8dfbbdb14cb52384b 100644
--- a/lib_basop/basop32.h
+++ b/lib_basop/basop32.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_basop/enh40.c b/lib_basop/enh40.c
index 570f4b211ab675c8fd924a2b0d4786ddec25c679..57df99e5c706d64c70ceadb659e837d93f8e244c 100644
--- a/lib_basop/enh40.c
+++ b/lib_basop/enh40.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_basop/enh40.h b/lib_basop/enh40.h
index 9c3742f3ef23b24bced88e87e71b85a8ac83baca..8cfb0c6009194f2c88e2a6713d91f3440515ce1c 100644
--- a/lib_basop/enh40.h
+++ b/lib_basop/enh40.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_basop/move.h b/lib_basop/move.h
index fc4d4e18bdd53a1ba2d006ea049dae81a4c7772a..7f10031193e1add29631c97ce50536d6645966bb 100644
--- a/lib_basop/move.h
+++ b/lib_basop/move.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_basop/stl.h b/lib_basop/stl.h
index d2f82d6742545fc9ea402943a6f6eac2f4958fd0..6badc3bcfc758809a0063793ddef05fb68061813 100644
--- a/lib_basop/stl.h
+++ b/lib_basop/stl.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_basop/typedef.h b/lib_basop/typedef.h
index 6ff6832e61357970317e47348e32fe2cfe14d62f..9968d4c84cba87fc0435c0737579b64448365196 100644
--- a/lib_basop/typedef.h
+++ b/lib_basop/typedef.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ari_hm_fx.c b/lib_com/ari_hm_fx.c
index 87af1a8ebb95c0ef339d7724f96f7cff829d4b42..e35416e5ff223ad28cf3713e3fac1f745df2aee0 100644
--- a/lib_com/ari_hm_fx.c
+++ b/lib_com/ari_hm_fx.c
@@ -2,7 +2,6 @@
EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0
====================================================================================*/
-
#include
#include
#include "options.h"
@@ -11,7 +10,7 @@
#include "rom_com.h"
#include "prot_fx.h"
-#define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) )
+
void UnmapIndex(
const Word16 PeriodicityIndex, /* Q0 */
const Word16 Bandwidth, /* Q0 */
diff --git a/lib_com/basop_com_lpc.c b/lib_com/basop_com_lpc.c
index 589d957071248e229d8a920ca7a4fe8a0889e3be..398d753277625bc398c33e9a3719928979f2d4d5 100644
--- a/lib_com/basop_com_lpc.c
+++ b/lib_com/basop_com_lpc.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/basop_lsf_tools.c b/lib_com/basop_lsf_tools.c
index a982e0f41b3d2b48df2847babbb85a3e951900b6..db40e08ef75a14610eaf89a07882ea955e613deb 100644
--- a/lib_com/basop_lsf_tools.c
+++ b/lib_com/basop_lsf_tools.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/basop_proto_func.h b/lib_com/basop_proto_func.h
index 549cc7ac01af664f9618151aa9648aa9c46dee62..845d14a27604a2a08030620bbb5be4d82dabee20 100644
--- a/lib_com/basop_proto_func.h
+++ b/lib_com/basop_proto_func.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/basop_settings.h b/lib_com/basop_settings.h
index fa809240acb811e2ecf27b5e1439c1607c9d8e27..79544c078cfc742923c9c3c5e874f2f5debe3b9f 100644
--- a/lib_com/basop_settings.h
+++ b/lib_com/basop_settings.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/basop_tcx_utils.c b/lib_com/basop_tcx_utils.c
index 5478dd1fef105a2d78d96c80bf5d6acf4e71ef2c..7fa5e12bebe44c876bba1eccd8f891830e39eaf6 100644
--- a/lib_com/basop_tcx_utils.c
+++ b/lib_com/basop_tcx_utils.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c
index 0bf796702fc3619f5f91c4dd636bea2cba7ae40d..551dbdeef64247b414cf3cb292d5671aed170575 100644
--- a/lib_com/basop_util.c
+++ b/lib_com/basop_util.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h
index c63e62747821ba83e8855005550981d1131f7d50..4265162488781d7effb4ca756968d6353e5f778c 100644
--- a/lib_com/basop_util.h
+++ b/lib_com/basop_util.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c
index 030c4746dbf96d2408be6aa6a214717cca631176..8f985c6ce3aab483a1616de0a45e73e92ad04d00 100644
--- a/lib_com/bitstream_fx.c
+++ b/lib_com/bitstream_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/cldfb_evs_fx.c b/lib_com/cldfb_evs_fx.c
index a471d8f91fb91d4bb2430d2ecd37dbda09ea86c6..8e8b6565fc488ce3ba9ea159c1aacc5e0466877b 100644
--- a/lib_com/cldfb_evs_fx.c
+++ b/lib_com/cldfb_evs_fx.c
@@ -996,6 +996,11 @@ ivas_error openCldfb(
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
}
+#ifdef FIX_2319_CLDFB_INIT_FLAGS
+ hs->flags = 0;
+ move16();
+#endif
+
hs->type = type;
move16();
diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c
index 1cfb30d57266d4063ed3ae0f7a3a0c7fd008b90d..f0c0d815810314a05676293396037a3e71db2ebb 100644
--- a/lib_com/cldfb_fx.c
+++ b/lib_com/cldfb_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -595,6 +595,7 @@ void cldfbAnalysis_ts_fx_var_q(
IF( NE_16( h_cldfb->Q_cldfb_state, *q_cldfb ) )
{
Word16 norm_st = L_norm_arr( timeBuffer_fx, offset );
+ norm_st = sub( norm_st, find_guarded_bits_fx( shr( h_cldfb->no_channels, 2 ) ) );
IF( GE_16( norm_st, sub( *q_cldfb, h_cldfb->Q_cldfb_state ) ) )
{
scale_sig32( timeBuffer_fx, offset, sub( *q_cldfb, h_cldfb->Q_cldfb_state ) );
diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c
index f96fba710c9b17b78e3beb7cd3abd2dc2783605a..3ce3e518fe806c97ac7831f7f4bc966dcdeaf86e 100644
--- a/lib_com/cng_exc_fx.c
+++ b/lib_com/cng_exc_fx.c
@@ -180,12 +180,14 @@ IF( GT_16( element_mode, IVAS_SCE ) )
{
return;
}
+
/*---------------------------------------------------------------------*
* Generate white noise vector
*---------------------------------------------------------------------*/
/*for ( i=0; i gain_pit Q14 to Q9 */
-
- ener2 = extract_h( Dot_product12( code, code, L_SUBFR, &exp2 ) );
-
- exp = norm_l( gain_code );
- tmp = extract_h( L_shl( gain_code, exp ) );
- tmp = mult( tmp, tmp ); /* energy of innovative code excitation */
- ener2 = mult( ener2, tmp );
- exp2 = sub( exp2, add( exp, exp ) );
-
- i = sub( exp1, exp2 );
- BASOP_SATURATE_WARNING_OFF_EVS
- ener1 = shr_sat( ener1, sub( 1, s_min( i, 0 ) ) );
- ener2 = shr_sat( ener2, add( s_max( 0, i ), 1 ) );
- BASOP_SATURATE_WARNING_ON_EVS
- tmp = sub( ener1, ener2 );
- ener1 = add( add( ener1, ener2 ), 1 );
-
- /* find voice factor (1=voiced, -1=unvoiced) */
- exp = div_s( abs_s( tmp ), ener1 );
- if ( tmp < 0 )
- {
- exp = negate( exp );
- }
- *voice_fac = exp;
- move16();
-
- /* tilt of code for next subframe: 0.5=voiced, 0=unvoiced */
-
- /* tilt_code = (float)(0.25*(1.0 + *voice_fac)) */
- tilt_code = mac_r( 8192L /*0.25.Q15*/ * 65536 /*1.Q16*/ - 0x8000 /*1.Q15*/, *voice_fac, 8192 /*0.25.Q15*/ ); /*Q15 */
-
- return tilt_code;
-}
-
-/*======================================================================*/
-/* FUNCTION : est_tilt_ivas_fx() */
-/*-----------------------------------------------------------------------*/
-/* PURPOSE : Estimate spectral tilt based on the relative E of adaptive */
-/* and innovative excitations */
-/* */
-/*-----------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word16 *) exc : adaptive excitation vector Q0 */
-/* _ (Word16) gain_pit : adaptive gain Q14 */
-/* _ (Word16 *) code : algebraic exctitation vector Q12 */
-/* _ (Word32) gain_code : algebraic code gain Q16 */
-/* _ (Word16) Q_exc : Scaling factor of excitation Q0 */
-/*-----------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16 *) voice_fac : voicing factor Q15 */
-/*-----------------------------------------------------------------------*/
-/* INPUT OUTPUT ARGUMENTS */
-/*-----------------------------------------------------------------------*/
-
/*-----------------------------------------------------------------------*/
/* RETURN ARGUMENTS : */
/* _ (Word16) tolt_code : tilt of the code Q15 */
/*=======================================================================*/
/* o : tilt of the code Q15 */
-Word16 est_tilt_ivas_fx(
+Word16 est_tilt_fx(
const Word16 *exc, /* i : adaptive excitation vector Qx */
const Word16 gain_pit, /* i : adaptive gain Q14 */
- const Word16 *code, /* i : algebraic excitation vector Q9 */
+ const Word16 *code, /* i : algebraic excitation vector Q9 */
const Word32 gain_code, /* i : algebraic code gain Q16 */
Word16 *voice_fac, /* o : voicing factor Q15 */
const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */
- const Word16 L_subfr, /* i : Sub frame length */
- const Word16 flag_tilt /* i : flag for special tilt */
+ const Word16 L_subfr /* i : Sub frame length */
)
{
Word16 i, tmp, exp, ener1, exp1, ener2, exp2;
@@ -161,25 +82,7 @@ Word16 est_tilt_ivas_fx(
*voice_fac = exp;
move16();
- IF( flag_tilt == 0 )
- {
- /* tilt of code for next subframe: 0.5=voiced, 0=unvoiced */
-
- /* tilt_code = (float)(0.25*(1.0 + *voice_fac)) */
- tilt_code = mac_r( 8192L /*0.25.Q15*/ * 65536 /*1.Q16*/ - 0x8000 /*1.Q15*/, *voice_fac, 8192 /*0.25.Q15*/ ); /*Q15 */
- }
- ELSE IF( EQ_16( flag_tilt, 1 ) )
- {
- /*Between 0.25 (=unvoiced) and 0.5 (=voiced)*/
- // tilt_code = (float)(0.25f + (*voice_fac + 1.0f) * 0.125f);
- tilt_code = mac_r( 12288L /*0.375.Q15*/ * 65536 /*1.Q16*/ - 0x8000 /*1.Q15*/, *voice_fac, 4096 /*0.125.Q15*/ ); /*Q15 */
- }
- ELSE
- {
- /*Between 0.28 (=unvoiced) and 0.56 (=voiced)*/
- // tilt_code = (float)(0.28f + (*voice_fac + 1.0f) * 0.14f);
- tilt_code = mac_r( 13763L /*0.42.Q15*/ * 65536 /*1.Q16*/ - 0x8000 /*1.Q15*/, *voice_fac, 4588 /*0.14.Q15*/ ); /*Q15 */
- }
+ tilt_code = mac_r( 8192L /*0.25.Q15*/ * 65536 /*1.Q16*/ - 0x8000 /*1.Q15*/, *voice_fac, 8192 /*0.25.Q15*/ ); /*Q15 */
return tilt_code;
}
diff --git a/lib_com/fft_cldfb_fx.c b/lib_com/fft_cldfb_fx.c
index 230dd7ac59f6cff002e6b472a4aab281f04083f8..0be5e21942545a7cfa66763f400cdb289d20e4de 100644
--- a/lib_com/fft_cldfb_fx.c
+++ b/lib_com/fft_cldfb_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c
index 6213e7a644de3aa5a45a01e1ce5bc234c73ee89a..651820c6a9342b61eb646933afe889e8e51717a4 100644
--- a/lib_com/fft_fx.c
+++ b/lib_com/fft_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/fill_spectrum_fx.c b/lib_com/fill_spectrum_fx.c
index 6bf0af3035ae5e95d4fbe7dc67be8d6b5d30236e..e41eca0af2046898dae1c160b152c3d5e6850b3f 100644
--- a/lib_com/fill_spectrum_fx.c
+++ b/lib_com/fill_spectrum_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/findpulse_fx.c b/lib_com/findpulse_fx.c
index 64a31143131d32dd32c59f4ea0e9c2f6cba9b965..e95daaa698e655b54c9bbe633fc79ddd16b61a8a 100644
--- a/lib_com/findpulse_fx.c
+++ b/lib_com/findpulse_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/frame_ener_fx.c b/lib_com/frame_ener_fx.c
index 163142bbfe80ba7f4c5778e21d85e41f4b64a64c..6e7a6f2a2b199b7990edbe53bc6196368e0f63bf 100644
--- a/lib_com/frame_ener_fx.c
+++ b/lib_com/frame_ener_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/get_gain_fx.c b/lib_com/get_gain_fx.c
index 7db540b1902e9f52e37b0ab86aab7da18db861ea..7cf27be0b28700db5352e49015143c173bad6da4 100644
--- a/lib_com/get_gain_fx.c
+++ b/lib_com/get_gain_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c
index 88e9f41d46bea75e5f37656e55e711c7b9b05f8f..769af269246265885b09319b958a202aeb98c982 100644
--- a/lib_com/gs_gains_fx.c
+++ b/lib_com/gs_gains_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -43,11 +43,12 @@
#include "wmc_auto.h"
/*-------------------------------------------------------------------*
- * Local constants
+ * Local function prototypes
*-------------------------------------------------------------------*/
static Word16 VDQ_vec_fx( Word16 *Qvec_out_fx, const Word16 *mean_dic_fx, const Word16 *dic_fx, const Word16 index_fx, const Word16 vec_en_fx );
+
/*========================================================================*/
/* FUNCTION : void Comp_and_apply_gain_enc_fx */
/*------------------------------------------------------------------------*/
@@ -72,9 +73,9 @@ static Word16 VDQ_vec_fx( Word16 *Qvec_out_fx, const Word16 *mean_dic_fx, const
void Comp_and_apply_gain_fx(
Word16 exc_diffQ[], /* i/o: Quantized excitation */
Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */
- Word16 Ener_per_bd_yQ[], /* i/o : Ener per band for norm vector i->Q13/o->Q13 */
- Word16 Mbands_gn, /* i : number of bands */
- const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */
+ Word16 Ener_per_bd_yQ[], /* i/o: Ener per band for norm vector i->Q13/o->Q13 */
+ Word16 Mbands_gn, /* i : number of bands */
+ const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */
Word16 Qexc_diff,
Word16 Q_exc )
{
@@ -114,6 +115,7 @@ void Comp_and_apply_gain_fx(
* y_gain = pow(10.0, (Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band]))
* = pow(2, 3.321928*(Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band]))
*-----------------------------------------------------------------*/
+
L16 = sub( Ener_per_bd_iQ[i_band], Ener_per_bd_yQ[i_band] ); /*Q12 */
L32 = L_mult( L16, 27213 ); /* 3.321928 in Q13 -> Q26 */
L32 = L_shr( L32, 10 ); /* From Q26 to Q16 */
@@ -136,13 +138,15 @@ void Comp_and_apply_gain_fx(
return;
}
+#ifndef FIX_2338_HARM_GSC_GAIN_COMP
+
void Comp_and_apply_gain_ivas_fx(
- Word16 exc_diffQ[], /* i/o: Quantized excitation */
- Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */
+ Word16 exc_diffQ[], /* i/o: Quantized excitation */
+ Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */
Word16 Ener_per_bd_yQ[], /* i/o : Ener per band for norm vector i->Q13/o->Q13 */
- Word16 Mbands_gn, /* i : number of bands */
- const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */
+ Word16 Mbands_gn, /* i : number of bands */
+ const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */
Word16 Qexc_diff,
Word16 *Q_exc )
{
@@ -192,6 +196,7 @@ void Comp_and_apply_gain_ivas_fx(
* y_gain = pow(10.0, (Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band]))
* = pow(2, 3.321928*(Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band]))
*-----------------------------------------------------------------*/
+
L16 = sub_sat( Ener_per_bd_iQ[i_band], Ener_per_bd_yQ[i_band] ); /*Q12 */
L32 = L_mult( L16, 27213 ); /* 3.321928 in Q13 -> Q26 */
L32 = L_shr( L32, 10 ); /* From Q26 to Q16 */
@@ -234,6 +239,7 @@ void Comp_and_apply_gain_ivas_fx(
return;
}
+#endif
/*========================================================================*/
@@ -254,36 +260,44 @@ void Comp_and_apply_gain_ivas_fx(
/* _ (Word32*) etmp14 : Energy band 14 Q_exc_diff*2+1 */
/* _ (Word32*) etmp15 : Energy band 15 Q_exc_diff*2+1 */
/*------------------------------------------------------------------------*/
-
/*------------------------------------------------------------------------*/
/* RETURN ARGUMENTS : */
/* _ None */
/*========================================================================*/
-static Word16 Comp_band_log_ener( /* o : Band gain Q12 */
- const Word16 *pt_fx, /* i : Dct input Q_sc */
- const Word16 Len, /* i : Lenght en energy accumulation */
- const Word16 Q_sc, /* i : scaling of input */
- const Word16 E_sc /* i : Additional scaling factor for energy */
+/* o : Band gain Q12 */
+static Word16 Comp_band_log_ener(
+ const Word16 *pt_fx, /* i : Dct input Q_sc */
+ const Word16 Len, /* i : Lenght en energy accumulation */
+ const Word16 Q_sc, /* i : scaling of input */
+ const Word16 E_sc /* i : Additional scaling factor for energy */
)
{
Word32 L_tmp;
Word16 e_tmp, f_tmp, tmp16, ener_exp;
+
L_tmp = Calc_Energy_Autoscaled( pt_fx, Q_sc, Len, &ener_exp );
e_tmp = norm_l( L_tmp );
f_tmp = Log2_norm_lc( L_shl( L_tmp, e_tmp ) );
e_tmp = sub( sub( add( 30, E_sc ), e_tmp ), ener_exp );
L_tmp = Mpy_32_16( e_tmp, f_tmp, 19728 ); /* Q16 */ /*log10(2) in Q17 */
tmp16 = round_fx( L_shl( L_tmp, 12 - 2 ) ); /* Q12 -1 is to compensate Q17 */
+
return tmp16;
}
+
void Ener_per_band_comp_fx(
const Word16 exc_diff_fx[], /* i : target signal Q_exc_diff */
Word16 y_gain4_fx[], /* o : Energy per band to quantize Q12 */
const Word16 Q_exc, /* i : frame length */
const Word16 Mband, /* i : Max band */
- const Word16 Eflag /* i : flag of highest band */
+#ifdef FIX_1904_HARM_GSC_ENC
+ const Word16 Eflag, /* i : flag of highest band */
+ const Word16 L_frame /* i : frame length */
+#else
+ const Word16 Eflag /* i : flag of highest band */
+#endif
)
{
const Word16 *pt_fx;
@@ -311,9 +325,19 @@ void Ener_per_band_comp_fx(
pt_fx += 32;
}
+#ifdef FIX_1904_HARM_GSC_ENC
+ IF( EQ_16( L_frame, L_FRAME16k ) )
+ {
+ y_gain4_fx[j + 2] = Comp_band_log_ener( pt_fx, 32, Q_exc, -1 ); /*Q12*/
+ move16();
+ y_gain4_fx[j + 3] = Comp_band_log_ener( pt_fx, 64, Q_exc, -1 ); /*Q12*/
+ move16();
+ }
+#endif
+
return;
}
-
+#ifndef FIX_1904_HARM_GSC_ENC
void Ener_per_band_comp_ivas_fx(
const Word16 exc_diff_fx[], /* i : target signal Q_exc_diff */
Word16 y_gain4_fx[], /* o : Energy per band to quantize Q12 */
@@ -359,16 +383,18 @@ void Ener_per_band_comp_ivas_fx(
return;
}
+#endif
/*-------------------------------------------------------------------*
- * gsc_gainQ()
+ * GSC_gain_adj()
+ *
*
- * Quantization of the energy per band
*-------------------------------------------------------------------*/
static void GSC_gain_adj(
const Word16 coder_type, /* i : Coder type */
+ const Word16 Mbands_gn, /* i : Number of band */
const Word32 core_brate, /* i : Bit rate */
const Word16 mean_g, /* i : Average gain Q12 */
Word16 *old_y_gain, /* i/o: Previous frame dequantized vector */
@@ -378,10 +404,15 @@ static void GSC_gain_adj(
{
/* Gain adjustment to fit ACELP generic inactive coding gain at low rate */
Word16 Gain_off, i;
+ Word16 Fac_div;
+
+ Fac_div = 102;
+ move16();
- IF( coder_type != INACTIVE )
+ test();
+ IF( coder_type != INACTIVE && NE_16( coder_type, UNVOICED ) )
{
- FOR( i = 0; i < MBANDS_GN; i++ )
+ FOR( i = 0; i < Mbands_gn; i++ )
{
old_y_gain[i] = y_gain_tmp[i];
move16();
@@ -393,7 +424,16 @@ static void GSC_gain_adj(
{
Gain_off = 0;
move16();
- IF( LE_32( core_brate, ACELP_7k20 ) )
+
+ test();
+ IF( LE_32( core_brate, ACELP_5k00 ) && EQ_16( coder_type, UNVOICED ) ) /* IVAS LR mode only */
+ {
+ Gain_off = 18432;
+ move16(); /* 9 -> Q11 */
+ Fac_div = 205; /* Q15 -> Q16 to compensate for Gain_off being Q11 instead of Q12 */
+ move16();
+ }
+ ELSE IF( LE_32( core_brate, ACELP_7k20 ) )
{
Gain_off = 32767;
move16(); /* 8 -> Q12 */
@@ -425,7 +465,7 @@ static void GSC_gain_adj(
old_y_gain[i] = y_gain_tmp[i];
move16();
/*y_gainQ[i] = y_gain_tmp[i]+mean_4g[0]-(i*(Gain_off/20.f)/((float) Mbands_gn));*/
- y_gainQ[i] = add( y_gain_tmp[i], sub( mean_g, i_mult2( i, mult_r( Gain_off, 102 /* 20/MBANDS_GN in Q15 */ ) ) ) );
+ y_gainQ[i] = add( y_gain_tmp[i], sub( mean_g, i_mult2( i, mult_r( Gain_off, Fac_div /* 20/MBANDS_GN in Q15 */ ) ) ) );
move16();
}
}
@@ -434,183 +474,204 @@ static void GSC_gain_adj(
}
-/*-------------------------------------------------------------------*
- * GSC_gain_adj_ivas_fx()
- *
- * Quantization of the energy per band
- *-------------------------------------------------------------------*/
+/*==========================================================================*/
+/* FUNCTION : Word16 gsc_gaindec_ivas_fx() */
+/*--------------------------------------------------------------------------*/
+/* PURPOSE : Generic signal frequency band decoding and application */
+/*--------------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Word16) pvq_bits_fx : core used Q0 */
+/* _ (Word16) coder_type : coding type Q0 */
+/* _ (Word16) core_fx : core used Q0 */
+/* _ (Word16) bwidth_fx : input signal bandwidth Q0 */
+/*--------------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16[]) y_gainQ_fx : quantized gain per band */
+/*--------------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ (Word16[]) old_y_gain_fx : AR gain quantizer for low rate */
+/*--------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ (Word16) : average frequency gain */
+/*==========================================================================*/
-static void GSC_gain_adj_ivas_fx(
- const Word16 coder_type, /* i : Coder type */
- const Word16 Mbands_gn, /* i : Number of band */
- const Word32 core_brate, /* i : Bit rate */
- const Word16 mean_g, /* i : Average gain Q12 */
- Word16 *old_y_gain, /* i/o: Previous frame dequantized vector */
- const Word16 *y_gain_tmp, /* i : Dequantized gains */
- Word16 *y_gainQ /* i/o: Output gains Q12 */
+/*! r: average frequency gain */
+Word16 gsc_gaindec_fx(
+ Decoder_State *st_fx, /* i/o: decoder state structure */
+ Word16 y_gainQ_fx[], /* o : quantized gain per band Q12 */
+ const Word32 core_brate_fx, /* i : core used */
+ Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 bwidth_fx /* i : input signal bandwidth */
)
{
- /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */
- Word16 Gain_off, i;
+ Word16 idx_g_fx, i;
+ Word16 mean_4g_fx;
+ Word16 Mbands_gn = MBANDS_GN;
+ move16();
+ Word16 y_gain_tmp3_fx[MBANDS_GN];
- test();
- IF( ( coder_type != INACTIVE ) && NE_16( coder_type, UNVOICED ) )
+ if ( EQ_16( st_fx->L_frame, L_FRAME16k ) )
{
- FOR( i = 0; i < Mbands_gn; i++ )
- {
- old_y_gain[i] = y_gain_tmp[i];
- move16();
- y_gainQ[i] = add( y_gain_tmp[i], mean_g );
- move16();
- }
+ Mbands_gn = MBANDS_GN16k;
+ move16();
}
- ELSE
+
+ test();
+ test();
+ IF( ( EQ_16( coder_type, AUDIO ) || ( coder_type == INACTIVE ) ) && EQ_16( bwidth_fx, NB ) )
{
- Gain_off = 0;
- move16();
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
+ VDQ_vec_fx( &mean_4g_fx, Gain_meanNB_fx, Gain_mean_dicNB_fx, idx_g_fx, 1 );
- test();
- IF( LE_32( core_brate, ACELP_5k00 ) && EQ_16( coder_type, UNVOICED ) )
- {
- Gain_off = 18432;
- move16(); /* 9 -> Q11 */
- }
- IF( LE_32( core_brate, ACELP_7k20 ) )
- {
- Gain_off = 16384;
- move16(); /* 8 -> Q11 */
- }
- ELSE IF( LE_32( core_brate, ACELP_8k00 ) )
- {
- Gain_off = 13517;
- move16(); /* 6.6f -> Q11 */
- }
- ELSE IF( LE_32( core_brate, ACELP_9k60 ) )
- {
- Gain_off = 9830;
- move16(); /*4.8f-> Q11 */
- }
- ELSE IF( LE_32( core_brate, ACELP_11k60 ) )
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
+ VDQ_vec_fx( y_gainQ_fx, Mean_dic_NB_fx, Gain_dic1_NB_fx, idx_g_fx, 3 );
+
+ IF( LT_32( core_brate_fx, ACELP_9k60 ) )
{
- Gain_off = 7168;
- move16(); /* 3.5f -> Q11 */
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
+ VDQ_vec_fx( y_gainQ_fx + 3, Mean_dic_NB_fx + 3, Gain_dic2_NB_fx, idx_g_fx, 3 );
+
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 4 );
+ VDQ_vec_fx( y_gainQ_fx + 6, Mean_dic_NB_fx + 6, Gain_dic3_NB_fx, idx_g_fx, 4 );
}
- ELSE IF( LE_32( core_brate, ACELP_13k20 ) )
+ ELSE
{
- Gain_off = 6144;
- move16(); /* 3.0f -> Q11 dB */
- }
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
+ VDQ_vec_fx( y_gainQ_fx + 3, Mean_dic_NB_fx + 3, Gain_dic2_NBHR_fx, idx_g_fx, 3 );
- /*mimic ACELP decay of energy for low rates*/
- FOR( i = 0; i < Mbands_gn; i++ )
- {
- old_y_gain[i] = y_gain_tmp[i];
- move16();
- y_gainQ[i] = add( y_gain_tmp[i], sub( mean_g, i_mult2( i, mult_r( Gain_off, 205 /* 20/MBANDS_GN in Q16 */ ) ) ) );
- move16();
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 7 );
+ VDQ_vec_fx( y_gainQ_fx + 6, Mean_dic_NB_fx + 6, Gain_dic3_NBHR_fx, idx_g_fx, 4 );
}
- }
-
- return;
-}
-
-
-/*-------------------------------------------------------------------*
- * GSC_gain_DQ()
- *
- * Form the final vector after gain quantization/Dequantization
- * Common to both encoder and decoder
- *-------------------------------------------------------------------*/
-
-static void GSC_gain_DQ_fx(
- const Word16 element_mode, /* i : element mode */
- const Word16 enc_dec, /* i : encoder/decoder flag */
- const Word16 coder_type, /* i : Coder type */
- const Word16 Mbands_gn, /* i : Number of band */
- const Word32 core_brate, /* i : Core bitrate */
- const Word16 mean_g, /* i : Average gain Q12 */
- const Word16 *Gain_in, /* i : Unquantized gain vector Q12 */
- Word16 *Gain_out /* o : Level adjusted unquantized gain vector Q12 */
-)
-{
- Word16 Gain_off;
- Word16 i;
- /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */
- Gain_off = 0;
- move16();
-
- test();
- IF( coder_type == INACTIVE || EQ_16( coder_type, UNVOICED ) )
- {
test();
- IF( LE_32( core_brate, ACELP_5k00 ) && EQ_16( coder_type, UNVOICED ) )
+ IF( LE_32( core_brate_fx, ACELP_9k60 ) && ( coder_type == INACTIVE ) )
{
- Gain_off = 1843; // 9/20 in Q12
+ /* Some energy is needed in high band for stat_noise_uv_enc
+ to be functional in inactive speech */
+ y_gainQ_fx[10] = mean_fx( y_gainQ_fx + 6, 3 ); /*Q12*/
move16();
- }
- ELSE IF( LE_32( core_brate, ACELP_7k20 ) )
- {
- Gain_off = 1638; // 8/20 in Q12; /* 0 dB */
+ y_gainQ_fx[11] = mean_fx( y_gainQ_fx + 7, 3 ); /*Q12*/
move16();
- }
- ELSE IF( LE_32( core_brate, ACELP_8k00 ) )
- {
- Gain_off = 1351; // 6.6f/20 in Q12 /* ~-3.3 dB */
+ y_gainQ_fx[12] = mean_fx( y_gainQ_fx + 8, 3 ); /*Q12*/
move16();
- }
- ELSE IF( LE_32( core_brate, ACELP_9k60 ) )
- {
- Gain_off = 983; // 4.8f/20 in Q12 /* ~-2.4 dB */
+ y_gainQ_fx[13] = mean_fx( y_gainQ_fx + 9, 3 ); /*Q12*/
move16();
- }
- ELSE IF( LE_32( core_brate, ACELP_11k60 ) )
- {
- Gain_off = 717; // 3.5f/20 in Q12 /* ~-2.4 dB */
+ y_gainQ_fx[14] = mean_fx( y_gainQ_fx + 10, 3 ); /*Q12*/
move16();
- }
- ELSE IF( LE_32( core_brate, ACELP_13k20 ) )
- {
- Gain_off = 614; // 3.0f/20 in Q12 /* ~-2.4 dB */
+ y_gainQ_fx[15] = mean_fx( y_gainQ_fx + 11, 3 ); /*Q12*/
move16();
}
- }
-
- test();
- IF( coder_type != INACTIVE && NE_16( coder_type, UNVOICED ) )
- {
- FOR( i = 0; i < Mbands_gn; i++ )
+ ELSE
{
- Gain_out[i] = add( Gain_in[i], mean_g ); // Q12
- move16();
+ set16_fx( y_gainQ_fx + 10, 0, MBANDS_GN - 10 );
}
}
ELSE
{
- /*mimic ACELP decay of energy for low rates*/
- test();
- IF( element_mode == EVS_MONO && EQ_16( enc_dec, DEC ) )
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
+
+ VDQ_vec_fx( &mean_4g_fx, mean_m_fx, mean_gain_dic_fx, idx_g_fx, 1 );
+
+ IF( LT_32( core_brate_fx, ACELP_9k60 ) )
{
- /* This is to keep EVS mono bit-exact with the standard (there might be a small desynchronization between encoder and decoder but there is no real quality or interop. issue) */
- FOR( i = 0; i < Mbands_gn; i++ )
+ /*--------------------------------------------------------------------------------------*
+ * UQ of the first 8 bands and half of the last 8 bands
+ *--------------------------------------------------------------------------------------*/
+
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
+
+ VDQ_vec_fx( y_gainQ_fx, YGain_mean_LR_fx, YGain_dic1_LR_fx, idx_g_fx, 3 );
+
+ IF( !( coder_type == INACTIVE && st_fx->tdm_LRTD_flag == 0 && EQ_16( st_fx->idchan, 1 ) ) || GT_32( st_fx->core_brate, GSC_LRES_GAINQ_LIMIT ) )
{
- Gain_out[i] = add( Gain_out[i], sub( mean_g, mult( Gain_off, div_s( i, Mbands_gn ) ) ) ); // Q12
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
+ VDQ_vec_fx( y_gainQ_fx + 3, YGain_mean_LR_fx + 3, YGain_dic2_LR_fx, idx_g_fx, 4 );
+
+ /*----------------------------------------------------------------------*
+ * Interpolation of the last 4 Q bands to create bands 8-16
+ * And scaling
+ *----------------------------------------------------------------------*/
+
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
+
+ VDQ_vec_fx( y_gainQ_fx + 7, YGain_mean_LR_fx + 7, YGain_dic3_LR_fx, idx_g_fx, 5 );
+
+ Copy( y_gainQ_fx + 8, y_gain_tmp3_fx, 4 );
+ set16_fx( y_gainQ_fx + 12, 0, 4 );
+
+ fft_rel_fx( y_gainQ_fx + 8, 4, 2 );
+
+ y_gainQ_fx[15] = y_gainQ_fx[11];
+ move16();
+ y_gainQ_fx[11] = 0;
+ move16();
+
+ ifft_rel_fx( y_gainQ_fx + 8, 8, 3 );
+
+ FOR( i = 8; i < 16; i++ )
+ {
+ y_gainQ_fx[i] = round_fx( L_shl( L_mult( y_gainQ_fx[i], 23101 ), 1 ) ); /*Q12 */
+ move16();
+ }
+
+ /*----------------------------------------------------------------------*
+ * Copy the true Q values in the specific bands
+ *----------------------------------------------------------------------*/
+
+ y_gainQ_fx[8] = y_gain_tmp3_fx[0]; /*Q12*/
+ move16();
+ y_gainQ_fx[10] = y_gain_tmp3_fx[1]; /*Q12*/
move16();
- // Gain_out[i] += mean_g - i * ( Gain_off / 20.f ) / ( (float) Mbands_gn );
+ y_gainQ_fx[12] = y_gain_tmp3_fx[2]; /*Q12*/
+ move16();
+ y_gainQ_fx[14] = y_gain_tmp3_fx[3]; /*Q12*/
+ move16();
+ }
+ ELSE
+ {
+ set16_fx( y_gainQ_fx + 3, 0, MBANDS_GN16k - 3 );
}
}
ELSE
{
- FOR( i = 0; i < Mbands_gn; i++ )
+ IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
- Gain_out[i] = add( Gain_in[i], sub( mean_g, mult( Gain_off, div_s( i, Mbands_gn ) ) ) ); // Q12
- move16();
- // Gain_out[i] = Gain_in[i] + mean_g - ( i * ( Gain_off / 20.f ) / ( (float) Mbands_gn ) );
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
+ VDQ_vec_fx( y_gainQ_fx, YG_mean16_fx, YG_dicMR_1_fx, idx_g_fx, 4 );
+
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
+ VDQ_vec_fx( y_gainQ_fx + 4, YG_mean16_fx + 4, YG_dicMR_2_fx, idx_g_fx, 4 );
+
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
+ VDQ_vec_fx( y_gainQ_fx + 8, YG_mean16_fx + 8, YG_dicMR_3_fx, idx_g_fx, 4 );
+
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 4 );
+ VDQ_vec_fx( y_gainQ_fx + 12, YG_mean16_fx + 12, YG_dicMR_4_fx, idx_g_fx, 4 );
+ }
+ ELSE
+ {
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 7 );
+ VDQ_vec_fx( y_gainQ_fx, YG_mean16HR_fx, YG_dicHR_1_fx, idx_g_fx, 4 );
+
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
+ VDQ_vec_fx( y_gainQ_fx + 4, YG_mean16HR_fx + 4, YG_dicHR_2_fx, idx_g_fx, 4 );
+
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
+ VDQ_vec_fx( y_gainQ_fx + 8, YG_mean16HR_fx + 8, YG_dicHR_3_fx, idx_g_fx, 4 );
+
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
+ VDQ_vec_fx( y_gainQ_fx + 12, YG_mean16HR_16kHz_fx, YG_dicHR_4_16kHz_fx, idx_g_fx, 4 );
+
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 3 );
+ VDQ_vec_fx( y_gainQ_fx + 16, YG_meanL2G_16kHz_fx, YG_dicL2G_16kHz_fx, idx_g_fx, 2 );
}
}
}
- return;
+ GSC_gain_adj( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx );
+
+ return mean_4g_fx;
}
@@ -620,91 +681,77 @@ static void GSC_gain_DQ_fx(
* Quantization of the energy per band
*-------------------------------------------------------------------*/
-Word16 gsc_gainQ_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 element_mode, /* i : element mode */
- const Word16 idchan, /* i : channel ID */
- const Word16 y_gain4[],
- /* i : Energy per band */ // Q12
- Word16 y_gainQ[],
- /* o : quantized energy per band */ // Q12
- const Word32 core_brate, /* i : Core rate */
- const Word16 coder_type, /* i : coding type */
- const Word16 bwidth, /* i : input signal bandwidth */
- const Word16 L_frame, /* i : frame length */
- const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */
- const Word32 core_brate_inp /* i : true core bitrate */
+Word16 gsc_gainQ_fx(
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word16 idchan, /* i : channel ID */
+ const Word16 y_gain4[], /* i : Energy per band Q12*/
+ Word16 y_gainQ[], /* o : quantized energy per band Q12*/
+ const Word32 core_brate, /* i : Core rate */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 bwidth, /* i : input signal bandwidth */
+ const Word16 L_frame, /* i : frame length */
+ const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */
+ const Word32 core_brate_inp /* i : true core bitrate */
)
{
- Word16 y_gain_tmp[MBANDS_GN16k];
- Word16 y_gain_tmp2[MBANDS_GN16k];
+ Word16 y_gain_tmp[MBANDS_GN16k], y_gain_tmp2[MBANDS_GN16k];
Word16 i, idx_g = 0;
move16();
- Word16 mean_4g_fx[1], ftmp1_fx;
- Word16 Mbands_gn = MBANDS_GN;
+ Word16 mean_4g[1] = { 0 }, tmp16, tmp1, tmp2;
move16();
- Word16 y_gain_tmp3[MBANDS_GN];
+ Word16 Mbands_gn = MBANDS_GN;
+ Word16 y_gain_tmp3[MBANDS_GN16k];
+ Word16 cnt;
Word32 L_tmp;
+ mean_4g[0] = 0;
if ( EQ_16( L_frame, L_FRAME16k ) )
{
Mbands_gn = MBANDS_GN16k;
move16();
}
- mean_4g_fx[0] = 0;
- move32();
-
test();
test();
- IF( ( EQ_16( coder_type, AUDIO ) || coder_type == INACTIVE ) && bwidth == NB )
+ IF( ( EQ_16( coder_type, AUDIO ) || ( coder_type == INACTIVE ) ) && ( bwidth == NB ) )
{
- L_tmp = 0;
- move32();
- FOR( i = 0; i < 10; i++ )
+ /*ftmp1 = mean(y_gain4, 10)-0.6f;*/
+ L_tmp = L_deposit_l( 0 );
+ FOR( cnt = 0; cnt < 10; cnt++ )
{
- L_tmp = L_add( L_tmp, y_gain4[i] );
+ L_tmp = L_mac( L_tmp, y_gain4[cnt], 3277 /*0.1 in Q15*/ );
}
- L_tmp = L_sub( Mpy_32_16_1( L_tmp, 3277 /* (1/10.0f) in Q15 */ ), 2457 /* 0.6f in Q12 */ ); // Q12
- ftmp1_fx = extract_l( L_tmp );
+ tmp16 = sub( round_fx( L_tmp ), 4915 );
+
FOR( i = 0; i < Mbands_gn; i++ )
{
- IF( LT_16( y_gain4[i], ftmp1_fx ) )
- {
- y_gain_tmp2[i] = ftmp1_fx; /*Q12*/
- }
- ELSE
- {
- y_gain_tmp2[i] = y_gain4[i]; /*Q12*/
- }
+ y_gain_tmp2[i] = y_gain4[i];
+ move16();
+ /*if(y_gain4[i] < ftmp1-0.6f)*/
+ y_gain_tmp2[i] = s_max( y_gain_tmp2[i], tmp16 );
move16();
}
- /* Quantized mean gain without clipping */
- L_tmp = 0;
- move32();
+ L_tmp = L_deposit_l( 0 );
FOR( i = 0; i < 10; i++ )
{
- L_tmp = L_add( L_tmp, y_gain4[i] );
+ L_tmp = L_mac( L_tmp, y_gain_tmp2[i], 3277 /*0.1 in Q15*/ );
}
- L_tmp = Mpy_32_16_1( L_tmp, 3277 /* (1/10.0f) in Q15 */ ); // Q12
- mean_4g_fx[0] = extract_l( L_tmp ); // Q12
+
+ /* Quantized mean gain without clipping */
+ mean_4g[0] = round_fx( L_tmp );
move16();
- idx_g = vquant_fx( mean_4g_fx, Gain_meanNB_fx, mean_4g_fx, Gain_mean_dicNB_fx, 1, 64 );
+ idx_g = vquant_fx( mean_4g, Gain_meanNB_fx, mean_4g, Gain_mean_dicNB_fx, 1, 64 );
push_indice( hBstr, IND_MEAN_GAIN2, idx_g, 6 );
FOR( i = 0; i < Mbands_gn; i++ )
{
- y_gain_tmp[i] = sub( y_gain_tmp2[i], mean_4g_fx[0] ); // Q12
- move16();
- }
-
- if ( LT_16( y_gain_tmp[9], -1229 /* -0.3f in Q12 */ ) )
- {
- y_gain_tmp[9] = -1229; /* -0.3f in Q12 */
+ y_gain_tmp[i] = sub( y_gain_tmp2[i], mean_4g[0] );
move16();
}
-
+ /*if(y_gain_tmp[9] < -0.3f){y_gain_tmp[9] = -0.3f;}*/
+ y_gain_tmp[9] = s_max( y_gain_tmp[9], -1229 /*0.3 in Q12*/ );
+ move16();
set16_fx( y_gain_tmp + 10, 0, MBANDS_GN - 10 );
idx_g = vquant_fx( y_gain_tmp, Mean_dic_NB_fx, y_gain_tmp, Gain_dic1_NB_fx, 3, 64 );
push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
@@ -713,7 +760,6 @@ Word16 gsc_gainQ_ivas_fx(
{
idx_g = vquant_fx( y_gain_tmp + 3, Mean_dic_NB_fx + 3, y_gain_tmp + 3, Gain_dic2_NB_fx, 3, 32 );
push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
-
idx_g = vquant_fx( y_gain_tmp + 6, Mean_dic_NB_fx + 6, y_gain_tmp + 6, Gain_dic3_NB_fx, 4, 16 );
push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 );
}
@@ -721,26 +767,27 @@ Word16 gsc_gainQ_ivas_fx(
{
idx_g = vquant_fx( y_gain_tmp + 3, Mean_dic_NB_fx + 3, y_gain_tmp + 3, Gain_dic2_NBHR_fx, 3, 64 );
push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
-
idx_g = vquant_fx( y_gain_tmp + 6, Mean_dic_NB_fx + 6, y_gain_tmp + 6, Gain_dic3_NBHR_fx, 4, 128 );
push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 7 );
- }
+ } /*add end */
test();
- IF( LE_32( core_brate, ACELP_9k60 ) && coder_type == INACTIVE )
+ IF( LE_32( core_brate, ACELP_9k60 ) && ( coder_type == INACTIVE ) )
{
- /* Some energy is needed in high band for stat_noise_uv_enc() to be functional in inactive speech */
- y_gain_tmp[10] = mean_fx( y_gain_tmp + 6, 3 ); /*Q12*/
+ /* Some energy is needed in high band for stat_noise_uv_enc
+ to be functional in inactive speech */
+ y_gain_tmp[10] = round_fx( L_mac( L_mac( L_mult( y_gain_tmp[6], 8192 ), y_gain_tmp[7], 8192 ), y_gain_tmp[8], 8192 ) );
move16();
- y_gain_tmp[11] = mean_fx( y_gain_tmp + 7, 3 ); /*Q12*/
+ y_gain_tmp[11] = round_fx( L_mac( L_mac( L_mult( y_gain_tmp[7], 8192 ), y_gain_tmp[8], 8192 ), y_gain_tmp[9], 8192 ) );
move16();
- y_gain_tmp[12] = mean_fx( y_gain_tmp + 8, 3 ); /*Q12*/
+
+ y_gain_tmp[12] = round_fx( L_mac( L_mac( L_mult( y_gain_tmp[8], 8192 ), y_gain_tmp[9], 8192 ), y_gain_tmp[10], 8192 ) );
move16();
- y_gain_tmp[13] = mean_fx( y_gain_tmp + 9, 3 ); /*Q12*/
+ y_gain_tmp[13] = round_fx( L_mac( L_mac( L_mult( y_gain_tmp[9], 8192 ), y_gain_tmp[10], 8192 ), y_gain_tmp[11], 8192 ) );
move16();
- y_gain_tmp[14] = mean_fx( y_gain_tmp + 10, 3 ); /*Q12*/
+ y_gain_tmp[14] = round_fx( L_mac( L_mac( L_mult( y_gain_tmp[10], 8192 ), y_gain_tmp[11], 8192 ), y_gain_tmp[12], 8192 ) );
move16();
- y_gain_tmp[15] = mean_fx( y_gain_tmp + 11, 3 ); /*Q12*/
+ y_gain_tmp[15] = round_fx( L_mac( L_mac( L_mult( y_gain_tmp[11], 8192 ), y_gain_tmp[12], 8192 ), y_gain_tmp[13], 8192 ) );
move16();
}
ELSE
@@ -750,59 +797,55 @@ Word16 gsc_gainQ_ivas_fx(
}
ELSE
{
+ /*ftmp1 = mean(y_gain4, 16);*/
L_tmp = 0;
move32();
- FOR( i = 0; i < 16; i++ )
- {
- L_tmp = L_add( L_tmp, y_gain4[i] );
- }
- L_tmp = Mpy_32_16_1( L_tmp, 2048 /* (1/16.f) in Q15 */ ); // Q12
- ftmp1_fx = extract_l( L_tmp );
- FOR( i = 0; i < Mbands_gn; i++ )
+ FOR( cnt = 0; cnt < 16; cnt++ )
{
- IF( LT_16( y_gain4[i], sub( ftmp1_fx, 2457 /* 0.6 in Q12*/ ) ) )
- {
- y_gain_tmp2[i] = sub( ftmp1_fx, 2457 /* 0.6 in Q12*/ );
- }
- ELSE IF( GT_16( y_gain4[i], add( ftmp1_fx, 2457 /* 0.6 in Q12*/ ) ) )
- {
- y_gain_tmp2[i] = add( ftmp1_fx, 2457 /* 0.6 in Q12*/ );
- }
- ELSE
- {
- y_gain_tmp2[i] = y_gain4[i];
- }
- move16();
+ L_tmp = L_mac( L_tmp, y_gain4[cnt], 2048 );
}
+ tmp16 = round_fx( L_tmp );
+ tmp1 = sub( tmp16, 4915 ); /* 0.6 Q12 */
+ tmp2 = add( tmp16, 4915 );
L_tmp = 0;
move32();
FOR( i = 0; i < 16; i++ )
{
- L_tmp = L_add( L_tmp, y_gain_tmp2[i] );
+ y_gain_tmp2[i] = y_gain4[i];
+ move16();
+ y_gain_tmp2[i] = s_max( y_gain_tmp2[i], tmp1 );
+ move16();
+ y_gain_tmp2[i] = s_min( y_gain_tmp2[i], tmp2 );
+ move16();
+ L_tmp = L_mac( L_tmp, y_gain_tmp2[i], 2048 );
+ }
+ FOR( ; i < Mbands_gn; i++ )
+ {
+ y_gain_tmp2[i] = y_gain4[i];
+ move16();
+ y_gain_tmp2[i] = s_max( y_gain_tmp2[i], tmp1 ); /* Just the last move is needed, because s_max and s_min could be done in 1 line*/
+ move16();
+ y_gain_tmp2[i] = s_min( y_gain_tmp2[i], tmp2 );
+ move16();
}
- L_tmp = Mpy_32_16_1( L_tmp, 2048 /* (1/16.f) in Q15 */ ); // Q12
- mean_4g_fx[0] = extract_l( L_tmp ); // Q12
+
+ /* Quantized mean gain without clipping */
+ mean_4g[0] = round_fx( L_tmp );
move16();
- idx_g = vquant_fx( mean_4g_fx, mean_m_fx, mean_4g_fx, mean_gain_dic_fx, 1, 64 );
+
+ idx_g = vquant_fx( mean_4g, mean_m_fx, mean_4g, mean_gain_dic_fx, 1, 64 );
push_indice( hBstr, IND_MEAN_GAIN2, idx_g, 6 );
- /* Subtraction of the average gain */
FOR( i = 0; i < Mbands_gn; i++ )
{
- y_gain_tmp[i] = sub( y_gain_tmp2[i], mean_4g_fx[0] ); // Q12
+ y_gain_tmp[i] = sub( y_gain_tmp2[i], mean_4g[0] );
move16();
}
IF( LT_32( core_brate, ACELP_9k60 ) )
{
- /* prediction and quantization of the average gain */
-
- /*--------------------------------------------------------------------------------------*
- * Quantization of the first 8 bands
- * Keep only 4 bands out of the last 8 bands
- *--------------------------------------------------------------------------------------*/
-
+ /*mvr2r(y_gain_tmp, y_gain_tmp2, 8); */
Copy( y_gain_tmp, y_gain_tmp2, 8 );
y_gain_tmp2[8] = y_gain_tmp[8];
@@ -816,6 +859,7 @@ Word16 gsc_gainQ_ivas_fx(
idx_g = 0;
move16();
+
idx_g = vquant_fx( y_gain_tmp2, YGain_mean_LR_fx, y_gain_tmp2, YGain_dic1_LR_fx, 3, 32 );
push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
@@ -826,15 +870,8 @@ Word16 gsc_gainQ_ivas_fx(
{
idx_g = vquant_fx( y_gain_tmp2 + 3, YGain_mean_LR_fx + 3, y_gain_tmp2 + 3, YGain_dic2_LR_fx, 4, 32 );
push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
-
- /*----------------------------------------------------------------------*
- * Vector quantization of the first 8 bands + quantization of the 4 bands out of the last 8
- * Interpolation of the last 4 bands Q to create bands 8-16
- *----------------------------------------------------------------------*/
-
idx_g = vquant_fx( y_gain_tmp2 + 7, YGain_mean_LR_fx + 7, y_gain_tmp2 + 7, YGain_dic3_LR_fx, 5, 32 );
push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
-
set16_fx( y_gain_tmp2 + 12, 0, MBANDS_GN - 12 );
/* Update to quantized vector */
@@ -851,7 +888,7 @@ Word16 gsc_gainQ_ivas_fx(
FOR( i = 8; i < 16; i++ )
{
- y_gain_tmp[i] = shl( mult( y_gain_tmp[i], 23101 /* 1.41 in Q14 */ ), 1 ); /*Q12*/
+ y_gain_tmp[i] = shl( mult_r( y_gain_tmp[i], 23101 ), 1 );
move16();
}
@@ -906,585 +943,8 @@ Word16 gsc_gainQ_ivas_fx(
}
}
- GSC_gain_DQ_fx( element_mode, ENC, coder_type, Mbands_gn, core_brate, mean_4g_fx[0], y_gain_tmp, y_gainQ );
-
- return mean_4g_fx[0];
-}
-
-
-/*==========================================================================*/
-/* FUNCTION : Word16 gsc_gaindec_fx() */
-/*--------------------------------------------------------------------------*/
-/* PURPOSE : Generic signal frequency band decoding and application */
-/*--------------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word16) pvq_bits_fx : core used Q0 */
-/* _ (Word16) coder_type : coding type Q0 */
-/* _ (Word16) core_fx : core used Q0 */
-/* _ (Word16) bwidth_fx : input signal bandwidth Q0 */
-/*--------------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16[]) y_gainQ_fx : quantized gain per band */
-/*--------------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/* _ (Word16[]) old_y_gain_fx : AR gain quantizer for low rate */
-/*--------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ (Word16) : average frequency gain */
-/*==========================================================================*/
-
-Word16 gsc_gaindec_fx( /* o : average frequency gain */
- Decoder_State *st_fx, /* i/o: decoder state structure */
- Word16 y_gainQ_fx[], /* o : quantized gain per band */
- const Word32 core_brate_fx, /* i : core used */
- Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */
- const Word16 coder_type, /* i : coding type */
- const Word16 bwidth_fx /* i : input signal bandwidth */
-)
-{
- Word16 idx_g_fx, i;
- Word16 mean_4g_fx;
- Word16 y_gain_tmp3_fx[MBANDS_GN];
-
- test();
- test();
- IF( ( EQ_16( coder_type, AUDIO ) || ( coder_type == INACTIVE ) ) && EQ_16( bwidth_fx, NB ) )
- {
- idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 6 ) );
- VDQ_vec_fx( &mean_4g_fx, Gain_meanNB_fx, Gain_mean_dicNB_fx, idx_g_fx, 1 );
-
- idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 6 ) );
- VDQ_vec_fx( y_gainQ_fx, Mean_dic_NB_fx, Gain_dic1_NB_fx, idx_g_fx, 3 );
-
- IF( LT_32( core_brate_fx, ACELP_9k60 ) )
- {
- idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 5 ) );
- VDQ_vec_fx( y_gainQ_fx + 3, Mean_dic_NB_fx + 3, Gain_dic2_NB_fx, idx_g_fx, 3 );
-
- idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 4 ) );
- VDQ_vec_fx( y_gainQ_fx + 6, Mean_dic_NB_fx + 6, Gain_dic3_NB_fx, idx_g_fx, 4 );
- }
- ELSE
- {
- idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 6 ) );
- VDQ_vec_fx( y_gainQ_fx + 3, Mean_dic_NB_fx + 3, Gain_dic2_NBHR_fx, idx_g_fx, 3 );
-
- idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 7 ) );
- VDQ_vec_fx( y_gainQ_fx + 6, Mean_dic_NB_fx + 6, Gain_dic3_NBHR_fx, idx_g_fx, 4 );
- }
- test();
- IF( LE_32( core_brate_fx, ACELP_9k60 ) && ( coder_type == INACTIVE ) )
- {
- /* Some energy is needed in high band for stat_noise_uv_enc
- to be functional in inactive speech */
- y_gainQ_fx[10] = mean_fx( y_gainQ_fx + 6, 3 );
- move16();
- y_gainQ_fx[11] = mean_fx( y_gainQ_fx + 7, 3 );
- move16();
- y_gainQ_fx[12] = mean_fx( y_gainQ_fx + 8, 3 );
- move16();
- y_gainQ_fx[13] = mean_fx( y_gainQ_fx + 9, 3 );
- move16();
- y_gainQ_fx[14] = mean_fx( y_gainQ_fx + 10, 3 );
- move16();
- y_gainQ_fx[15] = mean_fx( y_gainQ_fx + 11, 3 );
- move16();
- }
- ELSE
- {
- set16_fx( y_gainQ_fx + 10, 0, MBANDS_GN - 10 );
- }
- }
- ELSE
- {
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
-
- VDQ_vec_fx( &mean_4g_fx, mean_m_fx, mean_gain_dic_fx, idx_g_fx, 1 );
-
- IF( LE_32( core_brate_fx, ACELP_9k60 ) )
- {
- /*--------------------------------------------------------------------------------------*
- * UQ of the first 8 bands and half of the last 8 bands
- *--------------------------------------------------------------------------------------*/
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
- VDQ_vec_fx( y_gainQ_fx, YGain_mean_LR_fx, YGain_dic1_LR_fx, idx_g_fx, 3 );
-
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
- VDQ_vec_fx( y_gainQ_fx + 3, YGain_mean_LR_fx + 3, YGain_dic2_LR_fx, idx_g_fx, 4 );
-
- /*----------------------------------------------------------------------*
- * Interpolation of the last 4 Q bands to create bands 8-16
- * And scaling
- *----------------------------------------------------------------------*/
-
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
-
- VDQ_vec_fx( y_gainQ_fx + 7, YGain_mean_LR_fx + 7, YGain_dic3_LR_fx, idx_g_fx, 5 );
-
- Copy( y_gainQ_fx + 8, y_gain_tmp3_fx, 4 );
- set16_fx( y_gainQ_fx + 12, 0, 4 );
-
- fft_rel_fx( y_gainQ_fx + 8, 4, 2 );
-
- y_gainQ_fx[15] = y_gainQ_fx[11];
- move16();
- y_gainQ_fx[11] = 0;
- move16();
- ifft_rel_fx( y_gainQ_fx + 8, 8, 3 );
- FOR( i = 8; i < 16; i++ )
- {
- y_gainQ_fx[i] = round_fx( L_shl( L_mult( y_gainQ_fx[i], 23101 ), 1 ) ); /*Q12 */
- move16();
- }
- /*----------------------------------------------------------------------*
- * Copy the true Q values in the specific bands
- *----------------------------------------------------------------------*/
- y_gainQ_fx[8] = y_gain_tmp3_fx[0];
- move16();
- y_gainQ_fx[10] = y_gain_tmp3_fx[1];
- move16();
- y_gainQ_fx[12] = y_gain_tmp3_fx[2];
- move16();
- y_gainQ_fx[14] = y_gain_tmp3_fx[3];
- move16();
- }
- ELSE
- {
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
- VDQ_vec_fx( y_gainQ_fx, YG_mean16_fx, YG_dicMR_1_fx, idx_g_fx, 4 );
-
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
- VDQ_vec_fx( y_gainQ_fx + 4, YG_mean16_fx + 4, YG_dicMR_2_fx, idx_g_fx, 4 );
-
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
- VDQ_vec_fx( y_gainQ_fx + 8, YG_mean16_fx + 8, YG_dicMR_3_fx, idx_g_fx, 4 );
-
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 4 );
- VDQ_vec_fx( y_gainQ_fx + 12, YG_mean16_fx + 12, YG_dicMR_4_fx, idx_g_fx, 4 );
- }
- }
-
- /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */
- GSC_gain_adj( coder_type, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx );
-
- return mean_4g_fx;
-}
-
-
-/*==========================================================================*/
-/* FUNCTION : Word16 gsc_gaindec_ivas_fx() */
-/*--------------------------------------------------------------------------*/
-/* PURPOSE : Generic signal frequency band decoding and application */
-/*--------------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word16) pvq_bits_fx : core used Q0 */
-/* _ (Word16) coder_type : coding type Q0 */
-/* _ (Word16) core_fx : core used Q0 */
-/* _ (Word16) bwidth_fx : input signal bandwidth Q0 */
-/*--------------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16[]) y_gainQ_fx : quantized gain per band */
-/*--------------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/* _ (Word16[]) old_y_gain_fx : AR gain quantizer for low rate */
-/*--------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ (Word16) : average frequency gain */
-/*==========================================================================*/
-
-Word16 gsc_gaindec_ivas_fx( /* o : average frequency gain */
- Decoder_State *st_fx, /* i/o: decoder state structure */
- Word16 y_gainQ_fx[], /* o : quantized gain per band Q12 */
- const Word32 core_brate_fx, /* i : core used */
- Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */
- const Word16 coder_type, /* i : coding type */
- const Word16 bwidth_fx /* i : input signal bandwidth */
-)
-{
- Word16 idx_g_fx, i;
- Word16 mean_4g_fx;
- Word16 Mbands_gn = MBANDS_GN;
- move16();
- Word16 y_gain_tmp3_fx[MBANDS_GN];
- if ( EQ_16( st_fx->L_frame, L_FRAME16k ) )
- {
- Mbands_gn = MBANDS_GN16k;
- move16();
- }
-
- test();
- test();
- IF( ( EQ_16( coder_type, AUDIO ) || ( coder_type == INACTIVE ) ) && EQ_16( bwidth_fx, NB ) )
- {
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
- VDQ_vec_fx( &mean_4g_fx, Gain_meanNB_fx, Gain_mean_dicNB_fx, idx_g_fx, 1 );
-
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
- VDQ_vec_fx( y_gainQ_fx, Mean_dic_NB_fx, Gain_dic1_NB_fx, idx_g_fx, 3 );
-
- IF( LT_32( core_brate_fx, ACELP_9k60 ) )
- {
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
- VDQ_vec_fx( y_gainQ_fx + 3, Mean_dic_NB_fx + 3, Gain_dic2_NB_fx, idx_g_fx, 3 );
-
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 4 );
- VDQ_vec_fx( y_gainQ_fx + 6, Mean_dic_NB_fx + 6, Gain_dic3_NB_fx, idx_g_fx, 4 );
- }
- ELSE
- {
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
- VDQ_vec_fx( y_gainQ_fx + 3, Mean_dic_NB_fx + 3, Gain_dic2_NBHR_fx, idx_g_fx, 3 );
-
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 7 );
- VDQ_vec_fx( y_gainQ_fx + 6, Mean_dic_NB_fx + 6, Gain_dic3_NBHR_fx, idx_g_fx, 4 );
- }
- test();
- IF( LE_32( core_brate_fx, ACELP_9k60 ) && ( coder_type == INACTIVE ) )
- {
- /* Some energy is needed in high band for stat_noise_uv_enc
- to be functional in inactive speech */
- y_gainQ_fx[10] = mean_fx( y_gainQ_fx + 6, 3 ); /*Q12*/
- move16();
- y_gainQ_fx[11] = mean_fx( y_gainQ_fx + 7, 3 ); /*Q12*/
- move16();
- y_gainQ_fx[12] = mean_fx( y_gainQ_fx + 8, 3 ); /*Q12*/
- move16();
- y_gainQ_fx[13] = mean_fx( y_gainQ_fx + 9, 3 ); /*Q12*/
- move16();
- y_gainQ_fx[14] = mean_fx( y_gainQ_fx + 10, 3 ); /*Q12*/
- move16();
- y_gainQ_fx[15] = mean_fx( y_gainQ_fx + 11, 3 ); /*Q12*/
- move16();
- }
- ELSE
- {
- set16_fx( y_gainQ_fx + 10, 0, MBANDS_GN - 10 );
- }
- }
- ELSE
- {
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
-
- VDQ_vec_fx( &mean_4g_fx, mean_m_fx, mean_gain_dic_fx, idx_g_fx, 1 );
-
- IF( LT_32( core_brate_fx, ACELP_9k60 ) )
- {
- /*--------------------------------------------------------------------------------------*
- * UQ of the first 8 bands and half of the last 8 bands
- *--------------------------------------------------------------------------------------*/
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
- VDQ_vec_fx( y_gainQ_fx, YGain_mean_LR_fx, YGain_dic1_LR_fx, idx_g_fx, 3 );
-
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
- VDQ_vec_fx( y_gainQ_fx + 3, YGain_mean_LR_fx + 3, YGain_dic2_LR_fx, idx_g_fx, 4 );
-
- /*----------------------------------------------------------------------*
- * Interpolation of the last 4 Q bands to create bands 8-16
- * And scaling
- *----------------------------------------------------------------------*/
-
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
-
- VDQ_vec_fx( y_gainQ_fx + 7, YGain_mean_LR_fx + 7, YGain_dic3_LR_fx, idx_g_fx, 5 );
-
- Copy( y_gainQ_fx + 8, y_gain_tmp3_fx, 4 );
- set16_fx( y_gainQ_fx + 12, 0, 4 );
-
- fft_rel_fx( y_gainQ_fx + 8, 4, 2 );
-
- y_gainQ_fx[15] = y_gainQ_fx[11];
- move16();
- y_gainQ_fx[11] = 0;
- move16();
- ifft_rel_fx( y_gainQ_fx + 8, 8, 3 );
- FOR( i = 8; i < 16; i++ )
- {
- y_gainQ_fx[i] = round_fx( L_shl( L_mult( y_gainQ_fx[i], 23101 ), 1 ) ); /*Q12 */
- move16();
- }
- /*----------------------------------------------------------------------*
- * Copy the true Q values in the specific bands
- *----------------------------------------------------------------------*/
- y_gainQ_fx[8] = y_gain_tmp3_fx[0]; /*Q12*/
- move16();
- y_gainQ_fx[10] = y_gain_tmp3_fx[1]; /*Q12*/
- move16();
- y_gainQ_fx[12] = y_gain_tmp3_fx[2]; /*Q12*/
- move16();
- y_gainQ_fx[14] = y_gain_tmp3_fx[3]; /*Q12*/
- move16();
- }
- ELSE
- {
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
- {
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
- VDQ_vec_fx( y_gainQ_fx, YG_mean16_fx, YG_dicMR_1_fx, idx_g_fx, 4 );
-
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
- VDQ_vec_fx( y_gainQ_fx + 4, YG_mean16_fx + 4, YG_dicMR_2_fx, idx_g_fx, 4 );
-
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
- VDQ_vec_fx( y_gainQ_fx + 8, YG_mean16_fx + 8, YG_dicMR_3_fx, idx_g_fx, 4 );
-
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 4 );
- VDQ_vec_fx( y_gainQ_fx + 12, YG_mean16_fx + 12, YG_dicMR_4_fx, idx_g_fx, 4 );
- }
- ELSE
- {
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 7 );
- VDQ_vec_fx( y_gainQ_fx, YG_mean16HR_fx, YG_dicHR_1_fx, idx_g_fx, 4 );
-
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
- VDQ_vec_fx( y_gainQ_fx + 4, YG_mean16HR_fx + 4, YG_dicHR_2_fx, idx_g_fx, 4 );
-
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
- VDQ_vec_fx( y_gainQ_fx + 8, YG_mean16HR_fx + 8, YG_dicHR_3_fx, idx_g_fx, 4 );
-
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
- VDQ_vec_fx( y_gainQ_fx + 12, YG_mean16HR_16kHz_fx, YG_dicHR_4_16kHz_fx, idx_g_fx, 4 );
-
- idx_g_fx = (Word16) get_next_indice_fx( st_fx, 3 );
- VDQ_vec_fx( y_gainQ_fx + 16, YG_meanL2G_16kHz_fx, YG_dicL2G_16kHz_fx, idx_g_fx, 2 );
- }
- }
- }
-
- /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */
- GSC_gain_adj_ivas_fx( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx );
-
- return mean_4g_fx;
-}
-
-
-/*-------------------------------------------------------------------*
- * gsc_gainQ()
- *
- * Quantization of the energy per band
- *-------------------------------------------------------------------*/
-
-Word16 gsc_gainQ_fx( /*Q12*/
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const Word16 y_gain4[], /* i : Energy per band Q12 */
- Word16 y_gainQ[], /* o : quantized energy per band Q12 */
- const Word32 core_brate, /* i : Core rate */
- const Word16 coder_type, /* i : coding type */
- const Word16 bwidth /* i : input signal bandwidth */
-)
-{
- Word16 y_gain_tmp[MBANDS_GN], y_gain_tmp2[MBANDS_GN];
- Word16 i, idx_g = 0;
- move16();
- Word16 mean_4g[1] = { 0 }, tmp16, tmp1, tmp2;
- move16();
- Word16 Mbands_gn = MBANDS_GN;
- Word16 y_gain_tmp3[MBANDS_GN];
- Word16 cnt;
- Word32 L_tmp;
-
- mean_4g[0] = 0;
-
- test();
- test();
- IF( ( EQ_16( coder_type, AUDIO ) || ( coder_type == INACTIVE ) ) && ( bwidth == NB ) )
- {
-
- /*ftmp1 = mean(y_gain4, 10)-0.6f;*/
- L_tmp = L_deposit_l( 0 );
- FOR( cnt = 0; cnt < 10; cnt++ )
- {
- L_tmp = L_mac( L_tmp, y_gain4[cnt], 3277 /*0.1 in Q15*/ );
- }
- tmp16 = sub( round_fx( L_tmp ), 4915 );
-
- FOR( i = 0; i < Mbands_gn; i++ )
- {
- y_gain_tmp2[i] = y_gain4[i];
- move16();
- /*if(y_gain4[i] < ftmp1-0.6f)*/
- y_gain_tmp2[i] = s_max( y_gain_tmp2[i], tmp16 );
- move16();
- }
-
- L_tmp = L_deposit_l( 0 );
- FOR( i = 0; i < 10; i++ )
- {
- L_tmp = L_mac( L_tmp, y_gain_tmp2[i], 3277 /*0.1 in Q15*/ );
- }
-
- /* Quantized mean gain without clipping */
- mean_4g[0] = round_fx( L_tmp );
- move16();
- idx_g = vquant_fx( mean_4g, Gain_meanNB_fx, mean_4g, Gain_mean_dicNB_fx, 1, 64 );
- push_indice( hBstr, IND_MEAN_GAIN2, idx_g, 6 );
-
- FOR( i = 0; i < Mbands_gn; i++ )
- {
- y_gain_tmp[i] = sub( y_gain_tmp2[i], mean_4g[0] );
- move16();
- }
- /*if(y_gain_tmp[9] < -0.3f){y_gain_tmp[9] = -0.3f;}*/
- y_gain_tmp[9] = s_max( y_gain_tmp[9], -1229 /*0.3 in Q12*/ );
- move16();
- set16_fx( y_gain_tmp + 10, 0, MBANDS_GN - 10 );
- idx_g = vquant_fx( y_gain_tmp, Mean_dic_NB_fx, y_gain_tmp, Gain_dic1_NB_fx, 3, 64 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
-
- IF( LT_32( core_brate, ACELP_9k60 ) )
- {
- idx_g = vquant_fx( y_gain_tmp + 3, Mean_dic_NB_fx + 3, y_gain_tmp + 3, Gain_dic2_NB_fx, 3, 32 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
- idx_g = vquant_fx( y_gain_tmp + 6, Mean_dic_NB_fx + 6, y_gain_tmp + 6, Gain_dic3_NB_fx, 4, 16 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 );
- }
- ELSE
- {
- idx_g = vquant_fx( y_gain_tmp + 3, Mean_dic_NB_fx + 3, y_gain_tmp + 3, Gain_dic2_NBHR_fx, 3, 64 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
- idx_g = vquant_fx( y_gain_tmp + 6, Mean_dic_NB_fx + 6, y_gain_tmp + 6, Gain_dic3_NBHR_fx, 4, 128 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 7 );
- } /*add end */
-
- test();
- IF( LE_32( core_brate, ACELP_9k60 ) && ( coder_type == INACTIVE ) )
- {
- /* Some energy is needed in high band for stat_noise_uv_enc
- to be functional in inactive speech */
- y_gain_tmp[10] = round_fx( L_mac( L_mac( L_mult( y_gain_tmp[6], 8192 ), y_gain_tmp[7], 8192 ), y_gain_tmp[8], 8192 ) );
- move16();
- y_gain_tmp[11] = round_fx( L_mac( L_mac( L_mult( y_gain_tmp[7], 8192 ), y_gain_tmp[8], 8192 ), y_gain_tmp[9], 8192 ) );
- move16();
-
- y_gain_tmp[12] = round_fx( L_mac( L_mac( L_mult( y_gain_tmp[8], 8192 ), y_gain_tmp[9], 8192 ), y_gain_tmp[10], 8192 ) );
- move16();
- y_gain_tmp[13] = round_fx( L_mac( L_mac( L_mult( y_gain_tmp[9], 8192 ), y_gain_tmp[10], 8192 ), y_gain_tmp[11], 8192 ) );
- move16();
- y_gain_tmp[14] = round_fx( L_mac( L_mac( L_mult( y_gain_tmp[10], 8192 ), y_gain_tmp[11], 8192 ), y_gain_tmp[12], 8192 ) );
- move16();
- y_gain_tmp[15] = round_fx( L_mac( L_mac( L_mult( y_gain_tmp[11], 8192 ), y_gain_tmp[12], 8192 ), y_gain_tmp[13], 8192 ) );
- move16();
- }
- ELSE
- {
- set16_fx( y_gain_tmp + 10, 0, MBANDS_GN - 10 );
- }
- }
- ELSE
- {
- /*ftmp1 = mean(y_gain4, 16);*/
-
- L_tmp = 0;
- move32();
- FOR( cnt = 0; cnt < 16; cnt++ )
- {
- L_tmp = L_mac( L_tmp, y_gain4[cnt], 2048 );
- }
- tmp16 = round_fx( L_tmp );
-
- tmp1 = sub( tmp16, 4915 );
- tmp2 = add( tmp16, 4915 );
- L_tmp = 0;
- move32();
- FOR( i = 0; i < 16; i++ )
- {
- y_gain_tmp2[i] = y_gain4[i];
- move16();
- y_gain_tmp2[i] = s_max( y_gain_tmp2[i], tmp1 );
- move16();
- y_gain_tmp2[i] = s_min( y_gain_tmp2[i], tmp2 );
- move16();
- L_tmp = L_mac( L_tmp, y_gain_tmp2[i], 2048 );
- }
- FOR( ; i < Mbands_gn; i++ )
- {
- y_gain_tmp2[i] = y_gain4[i];
- move16();
- y_gain_tmp2[i] = s_max( y_gain_tmp2[i], tmp1 ); /* Just the last move is needed, because s_max and s_min could be done in 1 line*/
- move16();
- y_gain_tmp2[i] = s_min( y_gain_tmp2[i], tmp2 );
- move16();
- }
-
- /* Quantized mean gain without clipping */
- mean_4g[0] = round_fx( L_tmp );
- move16();
-
- idx_g = vquant_fx( mean_4g, mean_m_fx, mean_4g, mean_gain_dic_fx, 1, 64 );
- push_indice( hBstr, IND_MEAN_GAIN2, idx_g, 6 );
-
- FOR( i = 0; i < Mbands_gn; i++ )
- {
- y_gain_tmp[i] = sub( y_gain_tmp2[i], mean_4g[0] );
- move16();
- }
-
- IF( LT_32( core_brate, ACELP_9k60 ) )
- {
- /*mvr2r(y_gain_tmp, y_gain_tmp2, 8); */
- Copy( y_gain_tmp, y_gain_tmp2, 8 );
-
- y_gain_tmp2[8] = y_gain_tmp[8];
- move16();
- y_gain_tmp2[9] = y_gain_tmp[10];
- move16();
- y_gain_tmp2[10] = y_gain_tmp[12];
- move16();
- y_gain_tmp2[11] = y_gain_tmp[14];
- move16();
-
- idx_g = 0;
- move16();
-
- idx_g = vquant_fx( y_gain_tmp2, YGain_mean_LR_fx, y_gain_tmp2, YGain_dic1_LR_fx, 3, 32 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
- idx_g = vquant_fx( y_gain_tmp2 + 3, YGain_mean_LR_fx + 3, y_gain_tmp2 + 3, YGain_dic2_LR_fx, 4, 32 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
- idx_g = vquant_fx( y_gain_tmp2 + 7, YGain_mean_LR_fx + 7, y_gain_tmp2 + 7, YGain_dic3_LR_fx, 5, 32 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
- set16_fx( y_gain_tmp2 + 12, 0, MBANDS_GN - 12 );
-
- /* Update to quantized vector */
- Copy( y_gain_tmp2, y_gain_tmp, 8 );
-
- Copy( y_gain_tmp2 + 8, y_gain_tmp3, 4 );
- set16_fx( y_gain_tmp + 8, 0, 8 );
- fft_rel_fx( y_gain_tmp2 + 8, 4, 2 );
-
- Copy( y_gain_tmp2 + 8, y_gain_tmp + 8, 3 );
- y_gain_tmp[15] = y_gain_tmp2[11];
- move16();
- ifft_rel_fx( y_gain_tmp + 8, 8, 3 );
-
- FOR( i = 8; i < 16; i++ )
- {
- y_gain_tmp[i] = shl( mult_r( y_gain_tmp[i], 23101 ), 1 );
- move16();
- }
-
- y_gain_tmp[8] = y_gain_tmp3[0];
- move16();
- y_gain_tmp[10] = y_gain_tmp3[1];
- move16();
- y_gain_tmp[12] = y_gain_tmp3[2];
- move16();
- y_gain_tmp[14] = y_gain_tmp3[3];
- move16();
- }
- ELSE
- {
- idx_g = vquant_fx( y_gain_tmp, YG_mean16_fx, y_gain_tmp, YG_dicMR_1_fx, 4, 64 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 6 );
- idx_g = vquant_fx( y_gain_tmp + 4, YG_mean16_fx + 4, y_gain_tmp + 4, YG_dicMR_2_fx, 4, 32 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
- idx_g = vquant_fx( y_gain_tmp + 8, YG_mean16_fx + 8, y_gain_tmp + 8, YG_dicMR_3_fx, 4, 32 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 5 );
- idx_g = vquant_fx( y_gain_tmp + 12, YG_mean16_fx + 12, y_gain_tmp + 12, YG_dicMR_4_fx, 4, 16 );
- push_indice( hBstr, IND_Y_GAIN_TMP, idx_g, 4 );
- }
- }
-
/* Gain adjustment to fit ACELP generic inactive coding gain at low rate */
- GSC_gain_adj( coder_type, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ );
+ GSC_gain_adj( coder_type, Mbands_gn, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ );
return mean_4g[0]; /*Q12*/
}
@@ -1497,11 +957,11 @@ Word16 gsc_gainQ_fx( /*Q12*/
*-------------------------------------------------------------------*/
static Word16 VDQ_vec_fx(
- Word16 *Qvec_out_fx, /* o: Quanitzed vector */
- const Word16 *mean_dic_fx, /* i: average codebook */
- const Word16 *dic_fx, /* i: codebook */
- const Word16 index_fx, /* i: index of codebook*/
- const Word16 vec_en_fx /* i: vector length */
+ Word16 *Qvec_out_fx, /* o : Quanitzed vector */
+ const Word16 *mean_dic_fx, /* i : average codebook */
+ const Word16 *dic_fx, /* i : codebook */
+ const Word16 index_fx, /* i : index of codebook */
+ const Word16 vec_en_fx /* i : vector length */
)
{
Word16 i, j;
diff --git a/lib_com/gs_inact_switching_fx.c b/lib_com/gs_inact_switching_fx.c
index 0829a934dcef39340f470260e9066e54aecbed4f..a8d2aa6823f103230af4c50772b1ca28b17379b4 100644
--- a/lib_com/gs_inact_switching_fx.c
+++ b/lib_com/gs_inact_switching_fx.c
@@ -77,7 +77,11 @@ void Inac_switch_ematch_fx(
test();
IF( ( EQ_16( coder_type, AUDIO ) || ( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) ) ) && bfi == 0 )
{
+#ifdef FIX_1904_HARM_GSC_ENC
+ Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame );
+#else
Ener_per_band_comp_ivas_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame );
+#endif
/* reset long-term energy per band */
FOR( i = 0; i < MBANDS_GN; i++ )
@@ -91,7 +95,11 @@ void Inac_switch_ematch_fx(
/* Find spectrum and energy per band for GC and VC frames */
edct_16fx( exc2, dct_exc_tmp, L_frame, 5, element_mode );
+#ifdef FIX_1904_HARM_GSC_ENC
+ Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame );
+#else
Ener_per_band_comp_ivas_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame );
+#endif
/* reset long-term energy per band */
FOR( i = 0; i < MBANDS_GN; i++ )
@@ -104,7 +112,12 @@ void Inac_switch_ematch_fx(
{
/* Find spectrum and energy per band for inactive frames */
edct_16fx( exc2, dct_exc_tmp, L_frame, 5, element_mode );
+
+#ifdef FIX_1904_HARM_GSC_ENC
+ Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame );
+#else
Ener_per_band_comp_ivas_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame );
+#endif
/* More agressive smoothing in the first 50 frames */
pt_exc = dct_exc_tmp;
diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c
index 8489cd66de0015dd76d4f18bb75c3861a077fb21..383e2812da07529ebd415d4beca50b1c21b0f5a3 100644
--- a/lib_com/gs_noisefill_fx.c
+++ b/lib_com/gs_noisefill_fx.c
@@ -636,7 +636,7 @@ static void envelop_modify_fx(
return;
}
-
+#ifndef FIX_1904_HARM_GSC_ENC
void highband_exc_dct_in_fx(
const Word32 core_brate, /* i : core bitrate */
const Word16 *mfreq_bindiv, /* i : bin per bands tables */
@@ -751,11 +751,19 @@ void highband_exc_dct_in_fx(
test();
IF( bfi || LT_32( core_brate, 6000 ) || ( LT_32( core_brate, 8600 ) && EQ_16( coder_type, UNVOICED ) ) )
{
+#ifndef FIX_1478_UNINIT_ON_BFI
set16_fx( noisepb, 13107, MBANDS_GN ); /*0.4 in Q15 */
+#else
+ set16_fx( noisepb, 13107, last_bin ); /*0.4 in Q15 */
+#endif
}
ELSE IF( EQ_16( GSC_IVAS_mode, 3 ) || ( GSC_IVAS_mode > 0 && EQ_16( GSC_noisy_speech, 1 ) ) )
{
+#ifndef FIX_1478_UNINIT_ON_BFI
set16_fx( noisepb, 13107 /*0.4f*/, MBANDS_GN16k );
+#else
+ set16_fx( noisepb, 13107 /*0.4f*/, last_bin );
+#endif
}
ELSE
{
@@ -772,7 +780,11 @@ void highband_exc_dct_in_fx(
test();
IF( GSC_IVAS_mode == 0 && GSC_noisy_speech && !bfi && LE_16( element_mode, IVAS_SCE ) )
{
+#ifndef FIX_1478_UNINIT_ON_BFI
set16_fx( noisepb, 3277, MBANDS_GN );
+#else
+ set16_fx( noisepb, 3277, last_bin );
+#endif
}
test();
IF( LT_32( core_brate, 6000 ) && LE_16( coder_type, UNVOICED ) )
@@ -801,12 +813,19 @@ void highband_exc_dct_in_fx(
test();
IF( EQ_32( core_brate, ACELP_8k00 ) && NE_16( bwidth, NB ) )
{
+#ifdef FIX_1904_HARM_GSC_ENC
+ Ener_per_band_comp_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, add( last_bin, 1 ), 0, L_frame );
+#else
Ener_per_band_comp_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, add( last_bin, 1 ), 0 );
+#endif
}
ELSE
{
+#ifdef FIX_1904_HARM_GSC_ENC
+ Ener_per_band_comp_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, MBANDS_GN, 1, L_frame );
+#else
Ener_per_band_comp_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, MBANDS_GN, 1 );
-
+#endif
IF( LT_16( nb_subfr, 4 ) && LT_16( L_frame, L_FRAME16k ) )
{
FOR( i = L_FRAME - 16; i < L_FRAME; i++ )
@@ -1010,8 +1029,14 @@ void highband_exc_dct_in_fx(
return;
}
+#endif
+
+#ifdef FIX_1904_HARM_GSC_ENC
+void highband_exc_dct_in_fx(
+#else
void highband_exc_dct_in_ivas_fx(
+#endif
const Word32 core_brate, /* i : core bitrate */
const Word16 *mfreq_bindiv, /* i : bin per bands tables */
Word16 last_bin, /* i : last bin of bit allocation */
@@ -1125,11 +1150,19 @@ void highband_exc_dct_in_ivas_fx(
test();
IF( bfi || LT_32( core_brate, 6000 ) || ( LT_32( core_brate, 8600 ) && EQ_16( coder_type, UNVOICED ) ) )
{
+#ifndef FIX_1478_UNINIT_ON_BFI
set16_fx( noisepb, 13107, MBANDS_GN ); /*0.4 in Q15 */
+#else
+ set16_fx( noisepb, 13107, last_bin ); /*0.4 in Q15 */
+#endif
}
ELSE IF( EQ_16( GSC_IVAS_mode, 3 ) || ( GSC_IVAS_mode > 0 && EQ_16( GSC_noisy_speech, 1 ) ) )
{
+#ifndef FIX_1478_UNINIT_ON_BFI
set16_fx( noisepb, 13107 /*0.4f*/, MBANDS_GN16k );
+#else
+ set16_fx( noisepb, 13107 /*0.4f*/, last_bin );
+#endif
}
ELSE
{
@@ -1146,7 +1179,11 @@ void highband_exc_dct_in_ivas_fx(
IF( GSC_IVAS_mode == 0 && GSC_noisy_speech && !bfi && LE_16( element_mode, IVAS_SCE ) )
{
+#ifndef FIX_1478_UNINIT_ON_BFI
set16_fx( noisepb, 3277, MBANDS_GN );
+#else
+ set16_fx( noisepb, 3277, last_bin );
+#endif
}
test();
@@ -1168,19 +1205,29 @@ void highband_exc_dct_in_ivas_fx(
{
Apply_NoiseFill_fx( exc_diffQ, seed_tcx, noisepb, Diff_len, last_bin, coder_type, mfreq_bindiv, Qexc_diffQ );
}
+
/*--------------------------------------------------------------------------------------*
* Quantize average gain
* Subtract Q averaged gain
* VQ of remaining gain per band
*--------------------------------------------------------------------------------------*/
+
test();
IF( EQ_32( core_brate, ACELP_8k00 ) && NE_16( bwidth, NB ) )
{
+#ifdef FIX_1904_HARM_GSC_ENC
+ Ener_per_band_comp_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, add( last_bin, 1 ), 0, L_frame );
+#else
Ener_per_band_comp_ivas_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, add( last_bin, 1 ), 0, L_frame );
+#endif
}
ELSE
{
+#ifdef FIX_1904_HARM_GSC_ENC
+ Ener_per_band_comp_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, MBANDS_GN, 1, L_frame );
+#else
Ener_per_band_comp_ivas_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, MBANDS_GN, 1, L_frame );
+#endif
test();
IF( LT_16( nb_subfr, 4 ) && LT_16( L_frame, L_FRAME16k ) )
@@ -1195,9 +1242,11 @@ void highband_exc_dct_in_ivas_fx(
}
}
}
+
/*--------------------------------------------------------------------------------------*
* Check potential energy excitation overshoot
*--------------------------------------------------------------------------------------*/
+
IF( bfi )
{
test();
@@ -1315,9 +1364,10 @@ void highband_exc_dct_in_ivas_fx(
move16();
}
}
-
+#ifndef FIX_2338_HARM_GSC_GAIN_COMP
IF( EQ_16( element_mode, EVS_MONO ) )
{
+#endif
Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, *Q_exc );
IF( exc_wo_nf != NULL )
@@ -1325,6 +1375,7 @@ void highband_exc_dct_in_ivas_fx(
Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, *Q_exc );
Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame );
}
+#ifndef FIX_2338_HARM_GSC_GAIN_COMP
}
ELSE
{
@@ -1355,7 +1406,7 @@ void highband_exc_dct_in_ivas_fx(
Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) );
}
}
-
+#endif
/*--------------------------------------------------------------------------------------*
* add the correction layer to the LF bins,
* and add the quantized pulses or the noise for the higher part of the spectrum
diff --git a/lib_com/gs_preech_fx.c b/lib_com/gs_preech_fx.c
index 083f0d9ca636d684750d84b7c0e2bb9f208676e2..c496a377708fea392fee16a1283e421473e2563c 100644
--- a/lib_com/gs_preech_fx.c
+++ b/lib_com/gs_preech_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -56,7 +56,12 @@ void pre_echo_att_fx(
const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) Q0*/
const Word16 Q_new,
const Word16 last_coder_type, /* i : Last coding mode Q0*/
- const Word16 L_frame /* i : Frame length Q0*/
+#ifdef FIX_1904_HARM_GSC_ENC
+ const Word16 L_frame, /* i : Frame length Q0*/
+ const Word16 element_mode /* i : Current IVAS element mode*/
+#else
+ const Word16 L_frame /* i : Frame length Q0*/
+#endif
)
{
Word32 etmp_fx;
@@ -68,6 +73,9 @@ void pre_echo_att_fx(
Word16 tmp, n1, n2, exp, frac1, frac2;
Word32 etmp1_fx;
Word16 att_len;
+#ifdef FIX_1904_HARM_GSC_ENC
+ Word16 etmp_e, tmp_e;
+#endif
test();
IF( gsc_attack_flag_fx > 0 && EQ_16( last_coder_type, AUDIO ) ) /*gsc_attack_flag_fx does not get set for all the test cases */
@@ -107,33 +115,53 @@ void pre_echo_att_fx(
IF( GT_32( etmp_fx, *Last_frame_ener_fx ) && attack_pos_fx > 0 )
{
/* Find the average energy before the attack */
- L_tmp = sum32_fx( finc_fx, attack_pos_fx ); /*Q1 */
- L_tmp1 = L_shr( L_mult( attack_pos_fx, attack_pos_fx ), 1 ); /*Q0 */
- tmp = round_fx( Isqrt( L_tmp1 ) ); /*Q15 */
- L_tmp = L_shr( L_tmp, 2 ); /*Q1 ; ATT_SEG_LEN=4 */
- etmp_fx = Mult_32_16( L_tmp, tmp ); /*Q1 */
-
- etmp_fx = L_shr( etmp_fx, add( 1 - 4, shl( Q_new, 1 ) ) ); /* makes etmp i nQ4 as *Last_frame_ener_fx */
- /* Find the correction factor and apply it before the attack */
- /* ratio = (float)sqrt(*Last_frame_ener/etmp);*/
- /* = isqrt(etmp/(*Last_frame_ener)) */
- etmp_fx = L_max( etmp_fx, 1 );
- *Last_frame_ener_fx = L_max( *Last_frame_ener_fx, 1 );
- move32();
- n1 = norm_l( etmp_fx );
- n2 = norm_l( *Last_frame_ener_fx );
-
- n1 = sub( n1, 1 );
- exp = sub( n1, n2 );
-
- frac1 = round_fx( L_shl( etmp_fx, n1 ) );
- frac2 = round_fx_sat( L_shl_sat( *Last_frame_ener_fx, n2 ) );
- L_tmp = L_mult0( 128, div_s( frac1, frac2 ) ); /* s = gain_out / gain_in */
- L_tmp = L_shr( L_tmp, exp ); /* add exponent */
-
- L_tmp = Isqrt( L_tmp );
- ratio_fx = round_fx( L_shl( L_tmp, 9 ) ); /* Q13 */
+#ifdef FIX_1904_HARM_GSC_ENC
+ IF( NE_16( element_mode, EVS_MONO ) ) /* This could be harmonized with EVS, but won't be BE */
+ {
+ etmp_fx = sum32_fx( finc_fx, attack_pos_fx );
+ etmp_e = sub( 31, add( shl( Q_new, 1 ), 1 ) );
+ etmp_fx = L_add( etmp_fx, L_shr( 21474836 /*0.01 in Q31*/, etmp_e ) ); /* etmp = etmp + 0.01; (exp = etmp_e) */
+ etmp_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( etmp_fx, L_mult0( attack_pos_fx, ATT_SEG_LEN ), &tmp_e ) );
+ tmp_e = add( tmp_e, sub( etmp_e, 31 ) );
+ etmp_e = tmp_e;
+ move16();
+ /* Find the correction factor and apply it before the attack */
+ tmp = BASOP_Util_Divide3232_Scale( *Last_frame_ener_fx, etmp_fx, &tmp_e ); /* numerator Q = 2 * Q_new + 1; denominator Q = 31 - tmp_e */
+ tmp_e = add( tmp_e, sub( sub( 31, etmp_e ), add( shl( Q_new, 1 ), 1 ) ) ); /* tmp_e = tmp_e + (31 - tmp_e) - (2 * Q_new + 1) */
+ tmp = Sqrt16( tmp, &tmp_e );
+ ratio_fx = shr_sat( tmp, sub( 2, tmp_e ) ); /* Q13 */
+ }
+ ELSE
+#endif
+ {
+ L_tmp = sum32_fx( finc_fx, attack_pos_fx ); /*Q1 */
+ L_tmp1 = L_shr( L_mult( attack_pos_fx, attack_pos_fx ), 1 ); /*Q0 */
+ tmp = round_fx( Isqrt( L_tmp1 ) ); /*Q15 */
+ L_tmp = L_shr( L_tmp, 2 ); /*Q1 ; ATT_SEG_LEN=4 */
+ etmp_fx = Mult_32_16( L_tmp, tmp ); /*Q1 */
+
+ etmp_fx = L_shr( etmp_fx, add( 1 - 4, shl( Q_new, 1 ) ) ); /* makes etmp i nQ4 as *Last_frame_ener_fx */
+ /* Find the correction factor and apply it before the attack */
+ /* ratio = (float)sqrt(*Last_frame_ener/etmp);*/
+ /* = isqrt(etmp/(*Last_frame_ener)) */
+ etmp_fx = L_max( etmp_fx, 1 );
+ *Last_frame_ener_fx = L_max( *Last_frame_ener_fx, 1 );
+ move32();
+ n1 = norm_l( etmp_fx );
+ n2 = norm_l( *Last_frame_ener_fx );
+
+ n1 = sub( n1, 1 );
+ exp = sub( n1, n2 );
+
+ frac1 = round_fx( L_shl( etmp_fx, n1 ) );
+ frac2 = round_fx_sat( L_shl_sat( *Last_frame_ener_fx, n2 ) );
+ L_tmp = L_mult0( 128, div_s( frac1, frac2 ) ); /* s = gain_out / gain_in */
+ L_tmp = L_shr( L_tmp, exp ); /* add exponent */
+
+ L_tmp = Isqrt( L_tmp );
+ ratio_fx = round_fx( L_shl( L_tmp, 9 ) ); /* Q13 */
+ }
/* Pre-echo atttenuation should never increase the energy */
ratio_fx = s_min( ratio_fx, 8192 /* 1 in Q13 */ ); /* Q13 */
FOR( i = 0; i < attack_pos_fx * ATT_SEG_LEN; i++ )
@@ -152,16 +180,31 @@ void pre_echo_att_fx(
* In normal cases, just compute the energy of the frame
*-------------------------------------------------------*/
- etmp_fx = sum2_fx( exc_fx, L_frame ); /*2*Q_new+1 */
- etmp_fx = L_shr( etmp_fx, add( 8 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/
- *Last_frame_ener_fx = etmp_fx;
- move32(); /*2*Q_new+1*/
+#ifdef FIX_1904_HARM_GSC_ENC
+ IF( NE_16( element_mode, EVS_MONO ) ) /* This could be harmonized with EVS, but won't be BE */
+ {
+ Word16 exp_etmp = sub( 15, Q_new );
+ etmp_fx = sum2_16_exp_fx( exc_fx, L_frame, &exp_etmp, 7 ); /* Q = 31-exp_etmp */
+ etmp_fx = L_shr( etmp_fx, 8 ); /*31-exp_etmp//INV_L_FRAME = 1/256*/
+ IF( EQ_16( L_frame, L_FRAME16k ) )
+ {
+ etmp_fx = Mpy_32_16_1( etmp_fx, 26214 /* 0.8 in Q15 */ ); /*31 - exp_etmp*/
+ }
+ *Last_frame_ener_fx = L_shl( etmp_fx, sub( shl( Q_new, 1 ), sub( 30 /*31-1*/, exp_etmp ) ) ); /*2*Q_new+1*/
+ }
+ ELSE
+#endif
+ {
+ etmp_fx = sum2_fx( exc_fx, L_frame ); /*2*Q_new+1 */
+ etmp_fx = L_shr( etmp_fx, add( 8 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/
+ *Last_frame_ener_fx = etmp_fx;
+ move32(); /*2*Q_new+1*/
+ }
}
return;
}
-
-
+#ifndef FIX_1904_HARM_GSC_ENC
void pre_echo_att_ivas_fx(
Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/
Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/
@@ -266,3 +309,4 @@ void pre_echo_att_ivas_fx(
return;
}
+#endif
diff --git a/lib_com/hp50_fx.c b/lib_com/hp50_fx.c
index cbc0dd179f3659930c29f36b5654aa0a669200b5..1622a7b1e900e0a25aea5e5a3658249d09182d98 100644
--- a/lib_com/hp50_fx.c
+++ b/lib_com/hp50_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/hq2_bit_alloc_fx.c b/lib_com/hq2_bit_alloc_fx.c
index e4c671a74c7b65877dd9facc121b2c9dcd644d4a..40df76cae17dd491ce44a34c6e4462d19e055368 100644
--- a/lib_com/hq2_bit_alloc_fx.c
+++ b/lib_com/hq2_bit_alloc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/hq2_core_com_fx.c b/lib_com/hq2_core_com_fx.c
index 78f60d4659b3eb2e3d64e98c2904dd75eccfc1ee..1331b31a172c7d0a914341f5288751c76e1ece2d 100644
--- a/lib_com/hq2_core_com_fx.c
+++ b/lib_com/hq2_core_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -209,171 +209,6 @@ void mdct_spectrum_denorm_fx(
}
-void mdct_spectrum_denorm_ivas_fx(
- const Word32 inp_vector[], /* i : Q0 : */
- Word32 L_y2[], /* i/o : Qs : decoded spectrum */
- const Word16 band_start[], /* i : Q0 : table of start freq for every subband */
- const Word16 band_end[], /* i : Q0 : table of end freq for every subband */
- const Word16 band_width[], /* i : Q0 : table of bandwidth for every subband */
- const Word32 L_band_energy[], /* i : Qbe : band energy */
- const Word16 npulses[], /* i : Q0 : number of coded spectrum */
- const Word16 bands, /* i : Q0 : number of subbands */
- const Word16 ld_slope_fx, /* i : Q15 : */
- const Word16 pd_thresh_fx /* i : Q15 : */
-)
-{
- Word16 i, k;
- Word32 L_Eyy;
- Word32 L_tmp, L_temp;
- Word16 temp_fx, temp_lo_fx, temp_hi_fx;
- Word32 L_inp_tmp[L_FRAME48k];
- Word16 exp_norm;
- Word16 exp_safe;
- Word16 exp_normn, exp_normd;
-
- Word16 pd_fx;
- Word16 Qpd;
-
- Word16 div_pd_fx;
- Word16 Qdivpd;
- Word32 L_div_pd;
-
- Word16 frac, exp;
-
- Word16 gain_tweak_fx;
- Word16 Qtweak;
-
- Word16 exp_shift;
-
- Word16 QEyy;
- Word16 pow_fx;
- Word16 Qpow;
- Word16 Qdiv;
- Word16 Qgamma;
- Word16 gamma_fx;
-
- Word16 cond_fx;
-
- exp_safe = 4; /* safe bit for overflow */
- move16();
-
- FOR( k = 0; k < bands; k++ )
- {
- L_tmp = L_deposit_l( 0 );
- FOR( i = band_start[k]; i <= band_end[k]; i++ )
- {
- L_inp_tmp[i] = L_mult( extract_l( inp_vector[i] ), extract_l( inp_vector[i] ) );
- move32(); /* Q0+Q0+1 */
- L_tmp = L_or( L_tmp, L_inp_tmp[i] );
- }
- exp_norm = norm_l( L_tmp );
- exp_norm = sub( exp_norm, exp_safe );
-
- L_Eyy = L_deposit_l( 0 );
- FOR( i = band_start[k]; i <= band_end[k]; i++ )
- {
- /*Eyy += (float) inp_vector[i] * inp_vector[i]; */
- L_Eyy = L_add( L_Eyy, L_shl( L_inp_tmp[i], exp_norm ) ); /* Q1+exp_norm */
- }
- QEyy = add( 1, exp_norm );
-
- IF( L_Eyy > 0x0L )
- {
- /* Set gamma to be pulse gain which results in perfect quantized subband energy */
- /*gamma = (float) sqrt (pow (2.0f, band_energy[k]) / Eyy); */
-
- /* Pow part (pow(2.0f, band_energy) ) */
- L_temp = L_shr( L_band_energy[k], sub( SWB_BWE_LR_Qbe, 16 ) );
- temp_lo_fx = L_Extract_lc( L_temp, &temp_hi_fx );
- Qpow = sub( 14, temp_hi_fx );
- pow_fx = extract_l( Pow2( 14, temp_lo_fx ) ); /* Qpow */
-
- /* Div part ( pow (2.0f, band_energy[i])/Eyy ) */
- exp_normn = norm_s( pow_fx );
- exp_normn = sub( exp_normn, 1 );
- exp_normd = norm_l( L_Eyy );
- temp_fx = div_s( shl( pow_fx, exp_normn ), extract_h( L_shl( L_Eyy, exp_normd ) ) ); /* ((Qpow + exp_norm) - (QEyy + exp_normd)) + 31 */
- Qdiv = add( sub( add( Qpow, exp_normn ), add( QEyy, exp_normd ) ), 31 );
-
- exp_norm = norm_s( temp_fx );
- temp_fx = shl( temp_fx, exp_norm ); /* Qdiv + exp_norm */
- Qdiv = add( Qdiv, exp_norm );
-
- /* Sqrt part sqrt(pow (2.0f, band_energy[i])/Eyy) */
- Qgamma = add( Qdiv, 16 );
- IF( s_and( Qdiv, 1 ) == 0 ) /* Qdiv % 2 == 0 */
- {
- L_temp = Sqrt_l( L_shr( L_deposit_h( temp_fx ), 1 ), &exp_norm );
- L_temp = L_shr( L_temp, exp_norm );
- Qgamma = sub( shr( Qgamma, 1 ), 1 );
- gamma_fx = round_fx( L_temp );
- }
- ELSE
- {
- L_temp = Sqrt_l( L_deposit_h( temp_fx ), &exp_norm );
- L_temp = L_shr( L_temp, exp_norm );
- Qgamma = shr( Qgamma, 1 );
- gamma_fx = round_fx( L_temp );
- }
-
- /* Adjust gamma based on pulse density (0 bit MSE gain estimator) */
- /*pd = (float) npulses[k] / band_width[k]; */
- exp_normn = norm_s( npulses[k] );
- exp_normn = sub( exp_normn, 1 );
- exp_normd = norm_s( band_width[k] );
- pd_fx = div_s( shl( npulses[k], exp_normn ), shl( band_width[k], exp_normd ) ); /* 15 + (exp_normn + exp_normd) */
- Qpd = add( sub( exp_normn, exp_normd ), 15 );
-
- cond_fx = sub( shl_sat( pd_fx, sub( 15, Qpd ) ), pd_thresh_fx /*Q15*/ ); /* Q15 */
- move16(); /* allow overflow happen. */
- IF( cond_fx < 0 )
- {
- /*gain_tweak = (float) pow (2.0f, (ld_slope * log2_f (pd / pd_thresh))); */
- /* Div part */
- exp_normn = norm_s( pd_fx );
- exp_normn = sub( exp_normn, 1 );
- exp_normd = norm_s( pd_thresh_fx );
- div_pd_fx = div_s( shl( pd_fx, exp_normn ), shl( pd_thresh_fx, exp_normd ) ); /* Qpd+exp_normn - (15 + exp_normd) + 15 */
- Qdivpd = add( sub( add( Qpd, exp_normn ), add( 15, exp_normd ) ), 15 );
-
- /* Log2 part */
- exp_norm = norm_s( div_pd_fx );
- L_div_pd = L_deposit_h( shl( div_pd_fx, exp_norm ) ); /* Qdivpd + exp_norm + 16 */
- Qdivpd = add( add( Qdivpd, exp_norm ), 16 );
-
- frac = Log2_norm_lc( L_div_pd );
- exp = sub( 30, Qdivpd );
- L_tmp = L_Comp( exp, frac ); /* Q16 */
-
- /* Mult part */
- L_tmp = Mpy_32_16_1( L_tmp, ld_slope_fx );
-
- /* Pow part */
- temp_lo_fx = L_Extract_lc( L_tmp, &temp_hi_fx );
- Qtweak = sub( 14, temp_hi_fx );
- gain_tweak_fx = extract_l( Pow2( 14, temp_lo_fx ) );
-
- /*gamma *= gain_tweak; */
- L_tmp = L_mult( gamma_fx, gain_tweak_fx ); /* Qgamma+Qtweak+1 */
- exp_norm = norm_l( L_tmp );
- gamma_fx = round_fx_sat( L_shl( L_tmp, exp_norm ) );
- Qgamma = sub( add( add( Qgamma, Qtweak ), exp_norm ), 15 ); /*Qgamma+Qtweak+1+exp_norm-16; */
- }
-
- exp_shift = sub( SWB_BWE_LR_Qs - 1, Qgamma );
- FOR( i = band_start[k]; i <= band_end[k]; i++ )
- {
- /*y2[i] = gamma * inp_vector[i]; */
- L_tmp = L_mult( gamma_fx, extract_l( inp_vector[i] ) ); /* Qgamma+0+1=Qgamma+1 */
- L_y2[i] = L_shl( L_tmp, exp_shift ); /* SWB_BWE_LR_Qs */
- move32();
- }
- }
- }
-
- return;
-}
-
/*==========================================================================*/
/* FUNCTION : void hq2_core_configure_fx() */
/*--------------------------------------------------------------------------*/
diff --git a/lib_com/hq2_noise_inject_fx.c b/lib_com/hq2_noise_inject_fx.c
index 7fc9f8fe96b93d426f29ba6b472470924d8131fb..c3b373d51d2efde69fa8044f047776fdf0eea8d1 100644
--- a/lib_com/hq2_noise_inject_fx.c
+++ b/lib_com/hq2_noise_inject_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/hq_tools_fx.c b/lib_com/hq_tools_fx.c
index efdbea428063fe26224390f7fd1128fdd72ce812..cc5f483eadb9af737c0a99fb6d02eb3111bfb0c8 100644
--- a/lib_com/hq_tools_fx.c
+++ b/lib_com/hq_tools_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/hvq_pvq_bitalloc_fx.c b/lib_com/hvq_pvq_bitalloc_fx.c
index ea51afe8889a7ada88e3d207702a3f4d529b9ba0..905749d47d8ca12ecf270991ac0cab4a2082c75b 100644
--- a/lib_com/hvq_pvq_bitalloc_fx.c
+++ b/lib_com/hvq_pvq_bitalloc_fx.c
@@ -40,6 +40,9 @@ Word16 hvq_pvq_bitalloc_fx(
UWord16 lsb;
Word16 num_sfm;
+ *n_sel_bands = 0;
+ move16();
+
IF( EQ_16( bwidth_fx, FB ) )
{
num_sfm = SFM_N_HARM_FB;
@@ -107,8 +110,6 @@ Word16 hvq_pvq_bitalloc_fx(
return 0;
}
- *n_sel_bands = 0;
- move16();
envSum = 0;
move16();
E_max = L_deposit_l( 0 );
diff --git a/lib_com/ifft_rel_fx.c b/lib_com/ifft_rel_fx.c
index 450e9195ec0f2bb96c63443a1e1c61d35ef32c2e..933925b11bfdb9619a511f76569ad3f436504639 100644
--- a/lib_com/ifft_rel_fx.c
+++ b/lib_com/ifft_rel_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -139,7 +139,10 @@ void ifft_rel_fx(
/*Can be acheived with a shr */
step = idiv1616( N_MAX_SAS, n2 );
move16();
-
+ IF( LT_16( n8, 2 ) )
+ {
+ continue;
+ }
s = sincos_t_fx + step; /*Q15 */
c = s + 64; /*Q15 */
s3 = sincos_t_fx + i_mult2( step, 3 ); /*Q15 */
diff --git a/lib_com/int_lsp_fx.c b/lib_com/int_lsp_fx.c
index 08ab6ba85458ce3160f9acf2d05af088bff5434e..ab84c76bbf51544f5b24366b9afb61c883e970c9 100644
--- a/lib_com/int_lsp_fx.c
+++ b/lib_com/int_lsp_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -43,13 +43,13 @@
void int_lsp_fx(
- const Word16 L_frame, /* i : length of the frame */
+ const Word16 L_frame, /* i : length of the frame */
const Word16 lsp_old[], /* i : Q15 LSPs from past frame */
const Word16 lsp_new[], /* i : Q15 LSPs from present frame */
Word16 *Aq, /* o : Q12 LP coefficients in both subframes */
- const Word16 m, /* i : order of LP filter */
+ const Word16 m, /* i : order of LP filter */
const Word16 *int_coeffs, /* i : Q15 interpolation coefficients */
- const Word16 Opt_AMR_WB /* i : Q0 flag indicating AMR-WB IO mode */
+ const Word16 Opt_AMR_WB /* i : Q0 flag indicating AMR-WB IO mode */
)
{
Word16 lsp[M], fnew, fold;
@@ -118,81 +118,6 @@ void int_lsp4_fx(
Word32 L_tmp;
const Word16 *pt_int_coeffs;
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- IF( EQ_16( relax_prev_lsf_interp, 1 ) )
- {
- pt_int_coeffs = interpol_frac_mid_relaxprev_12k8_fx; /*Q15*/
- }
- ELSE IF( EQ_16( relax_prev_lsf_interp, 2 ) )
- {
- pt_int_coeffs = interpol_frac_mid_FEC_fx; /*Q15*/
- }
- ELSE IF( EQ_16( relax_prev_lsf_interp, -1 ) )
- {
- pt_int_coeffs = interpol_frac_mid_relaxprev_pred_12k8_fx; /*Q15*/
- }
- ELSE
- {
- pt_int_coeffs = interpol_frac_mid_fx; /*Q15*/
- }
- }
- ELSE /* L_frame == L_FRAME16k */
- {
- IF( EQ_16( relax_prev_lsf_interp, 1 ) )
- {
- pt_int_coeffs = interpol_frac_mid_relaxprev_16k_fx; /*Q15*/
- }
- ELSE IF( EQ_16( relax_prev_lsf_interp, 2 ) )
- {
- pt_int_coeffs = interpol_frac_mid_16k_FEC_fx; /*Q15*/
- }
- ELSE IF( EQ_16( relax_prev_lsf_interp, -1 ) )
- {
- pt_int_coeffs = interpol_frac_mid_relaxprev_pred_16k_fx; /*Q15*/
- }
- ELSE
- {
- pt_int_coeffs = interpol_frac_mid_16k_fx; /*Q15*/
- }
- }
- k = sub( shr( L_frame, 6 ), 1 );
- FOR( j = 0; j < k; j++ )
- {
- FOR( i = 0; i < m; i++ )
- {
- L_tmp = L_mult( lsp_old[i], *pt_int_coeffs ); /*Q31 */
- L_tmp = L_mac( L_tmp, lsp_mid[i], *( pt_int_coeffs + 1 ) ); /*Q31 */
- lsp[i] = mac_r( L_tmp, lsp_new[i], *( pt_int_coeffs + 2 ) );
- move16();
- }
- pt_int_coeffs += 3;
-
- E_LPC_f_lsp_a_conversion( lsp, Aq, m );
- Aq += add( m, 1 );
- }
-
- /* Last subframe */
- E_LPC_f_lsp_a_conversion( lsp_new, Aq, m );
-
- return;
-}
-
-void int_lsp4_ivas_fx(
- const Word16 L_frame, /* i : length of the frame */
- const Word16 lsp_old[], /* i : LSPs from past frame Q15*/
- const Word16 lsp_mid[], /* i : LSPs from mid-frame Q15*/
- const Word16 lsp_new[], /* i : LSPs from present frame Q15*/
- Word16 *Aq, /* o : LP coefficients in both subframes Q12*/
- const Word16 m, /* i : order of LP filter */
- Word16 relax_prev_lsf_interp /* i : relax prev frame lsf interp after erasure */
-)
-{
- Word16 lsp[M16k];
- Word16 i, j, k;
- Word32 L_tmp;
- const Word16 *pt_int_coeffs;
-
IF( EQ_16( L_frame, L_FRAME ) )
{
IF( EQ_16( relax_prev_lsf_interp, 1 ) )
@@ -209,7 +134,6 @@ void int_lsp4_ivas_fx(
}
ELSE IF( EQ_16( relax_prev_lsf_interp, -2 ) )
{
- // This condition not present in int_lsp4_fx
pt_int_coeffs = interpol_frac2_mid_fx; /*Q15*/
}
ELSE
diff --git a/lib_com/interleave_spectrum_fx.c b/lib_com/interleave_spectrum_fx.c
index c12623f0d09809ae6b0f70993e1f099f84bdae3a..8847b9f5b2cf36b5a39aa2f690132efe209f9b34 100644
--- a/lib_com/interleave_spectrum_fx.c
+++ b/lib_com/interleave_spectrum_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/interpol_fx.c b/lib_com/interpol_fx.c
index 5a78eb9bb15cd5a89d48836171606a702c904dd5..78c277a216afe4e35bfa54626d7f70a573a5174c 100644
--- a/lib_com/interpol_fx.c
+++ b/lib_com/interpol_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/isf_dec_amr_wb_fx.c b/lib_com/isf_dec_amr_wb_fx.c
index 5ab82ee6dc158e877fd24f908e16cd20545f4f5c..0d623b3f636ed0c9eb52fa6a41780ddc7adee1f3 100644
--- a/lib_com/isf_dec_amr_wb_fx.c
+++ b/lib_com/isf_dec_amr_wb_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_agc_com_fx.c b/lib_com/ivas_agc_com_fx.c
index 567adeb6b06528b355800b2fb4870fa6cfdbee17..35a4f1581b85ce82e86f16747181dd57c410e9c8 100644
--- a/lib_com/ivas_agc_com_fx.c
+++ b/lib_com/ivas_agc_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_arith_fx.c b/lib_com/ivas_arith_fx.c
index c708976dac8552562abb21fd47637ec18a9eb61f..aa261f69daab8bf32323b2299d212927b82d3afb 100644
--- a/lib_com/ivas_arith_fx.c
+++ b/lib_com/ivas_arith_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_avq_pos_reorder_com_fx.c b/lib_com/ivas_avq_pos_reorder_com_fx.c
index 25f8be3ad2ae64b4b05bc88bfc19b22043377621..5d05618e1b5eaa0b2fd5469f3e5b78df1c12b240 100644
--- a/lib_com/ivas_avq_pos_reorder_com_fx.c
+++ b/lib_com/ivas_avq_pos_reorder_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h
index e6bb49689b558f417d8830afcf6b86e6be47558b..f2cf7ca5cc7ccee588152d5a094359d082ce7bd0 100644
--- a/lib_com/ivas_cnst.h
+++ b/lib_com/ivas_cnst.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -186,12 +186,12 @@ typedef enum
#define IVAS_NUM_SUPPORTED_FS 3 /* number of supported sampling-rates in IVAS */
#define CLDFB_SLOT_NS 1250000L /* 1.25ms: CLDFB slot length */
-#define MAX_JBM_SUBFRAMES_5MS 8
-#define DEFAULT_JBM_SUBFRAMES_5MS 4
-#define JBM_CLDFB_SLOTS_IN_SUBFRAME 4
+#define DEFAULT_JBM_SUBFRAMES_5MS 4 /* == IVAS_MAX_PARAM_SPATIAL_SUBFRAMES */
+#define MAX_JBM_SUBFRAMES_5MS ( DEFAULT_JBM_SUBFRAMES_5MS * 2 )
+#define JBM_CLDFB_SLOTS_IN_SUBFRAME 4 /* == IVAS_MAX_PARAM_SPATIAL_SUBFRAMES */
#define JBM_CLDFB_SLOTS_IN_SUBFRAME_LOG2 2 /* To be used for shift operation instead of division */
-#define MAX_JBM_CLDFB_TIMESLOTS 32
-#define DEFAULT_JBM_CLDFB_TIMESLOTS 16
+#define DEFAULT_JBM_CLDFB_TIMESLOTS CLDFB_NO_COL_MAX
+#define MAX_JBM_CLDFB_TIMESLOTS ( DEFAULT_JBM_CLDFB_TIMESLOTS * 2 )
#define MAX_JBM_L_FRAME48k ( IVAS_MAX_FRAME_SIZE * 2 ) /* 1920: max. time-scaled frame buffer length (per channel) in samples */
#define MAX_JBM_L_FRAME_NS 40000000L /* 40 ms: time-scaled frame size in ns, proportional to MAX_JBM_L_FRAME48k */
#define MAX_SPAR_INTERNAL_CHANNELS IVAS_SPAR_MAX_CH
@@ -561,7 +561,7 @@ typedef enum
#define STEREO_DFT_ITD_FS 32000
#define STEREO_DFT_ITD_MAX 160 /*samples @ 32000*/
#define STEREO_DFT_ITD_MAX_ANA 200
-#define STEREO_DFT_ITD_MIN max( STEREO_DFT_ITD_MAX - 256 + 1, 1 ) /*STEREO_DFT_ITD_MAX-pow(2,STEREO_DFT_ITD_NBITS-1)+1*/
+#define STEREO_DFT_ITD_MIN 1 /* == max( STEREO_DFT_ITD_MAX - pow(2,STEREO_DFT_ITD_NBITS-1) + 1, 1 )*/
#define STEREO_DFT_ITD_NBITS 9 /* 1 bit for sign, the rest for the absolute value*/
#define STEREO_DFT_ITD_MODE_NBITS 1
diff --git a/lib_com/ivas_cov_smooth_fx.c b/lib_com/ivas_cov_smooth_fx.c
index 422717f8e8db37d06a5cb04ca0be00173eafd107..c81de63477e3f2399f2ad222f2753e89d43dab1a 100644
--- a/lib_com/ivas_cov_smooth_fx.c
+++ b/lib_com/ivas_cov_smooth_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c
index 35a2cd4aa3ee53edcafb73ebfe5a3e5578bba4a1..cf256b3681fa7f3f4b1b245a1ac1532b9519babf 100644
--- a/lib_com/ivas_dirac_com_fx.c
+++ b/lib_com/ivas_dirac_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_entropy_coder_common_fx.c b/lib_com/ivas_entropy_coder_common_fx.c
index 7519e9703d798fe9c19c9ce6b255a1b6cb565e56..0ea623d294e90e12c4a6860ef9bac28ad7ce479f 100644
--- a/lib_com/ivas_entropy_coder_common_fx.c
+++ b/lib_com/ivas_entropy_coder_common_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h
index 1b69f35efad13bedbc81bbb43ea04dbfca30a4fa..3e965151e154406e658655cfc9494cbd62968347 100644
--- a/lib_com/ivas_error.h
+++ b/lib_com/ivas_error.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_error_utils.h b/lib_com/ivas_error_utils.h
index 0c3d5ce042d74d7b9ea0c4be32729f5c161889de..791bc458dfd9dbc9fba9986bed8c8c08631f0371 100644
--- a/lib_com/ivas_error_utils.h
+++ b/lib_com/ivas_error_utils.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_fb_mixer_fx.c b/lib_com/ivas_fb_mixer_fx.c
index 2dcd8476b45a0c079fd1585889d8cbccbe34963e..3f1cb29e59419e072a55f2454f9200b21810036c 100644
--- a/lib_com/ivas_fb_mixer_fx.c
+++ b/lib_com/ivas_fb_mixer_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c
index f9e35c65a2ecea4fd18583cf091f4ba29bc586c8..5f1b1423b93703d585690fa03dd2bec6fb3543a0 100644
--- a/lib_com/ivas_filters_fx.c
+++ b/lib_com/ivas_filters_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -67,40 +67,18 @@ void ivas_filters_init_fx(
filter_state->den_fx[IVAS_FILTER_STAGE_0][i] = filt_coeff_fx[i + IVAS_BIQUAD_FILT_LEN];
move32();
move32();
-#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS
filter_state->num_shr[IVAS_FILTER_STAGE_0][i] = Q30 - Q31;
filter_state->den_shr[IVAS_FILTER_STAGE_0][i] = Q30 - Q31;
move16();
move16();
-#else
- filter_state->num_e[IVAS_FILTER_STAGE_0][i] = 1;
- filter_state->den_e[IVAS_FILTER_STAGE_0][i] = 1;
- move16();
- move16();
-#endif
}
-#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS
filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0;
filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0;
filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0;
move64();
move64();
move64();
-#else
- filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0;
- filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0;
- filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0;
- move32();
- move32();
- move32();
- filter_state->state_e[0][0] = 0;
- filter_state->state_e[0][1] = 0;
- filter_state->state_e[0][2] = 0;
- move16();
- move16();
- move16();
-#endif
}
ELSE
{
@@ -117,7 +95,6 @@ void ivas_filters_init_fx(
move32();
move32();
move32();
-#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS
filter_state->num_shr[IVAS_FILTER_STAGE_0][i] = sub( sub( 31, filt_coeff_e[i + 0 * IVAS_BIQUAD_FILT_LEN] ), Q31 );
filter_state->den_shr[IVAS_FILTER_STAGE_0][i] = sub( sub( 31, filt_coeff_e[i + 1 * IVAS_BIQUAD_FILT_LEN] ), Q31 );
filter_state->num_shr[IVAS_FILTER_STAGE_1][i] = sub( sub( 31, filt_coeff_e[i + 2 * IVAS_BIQUAD_FILT_LEN] ), Q31 );
@@ -126,19 +103,8 @@ void ivas_filters_init_fx(
move16();
move16();
move16();
-#else
- filter_state->num_e[IVAS_FILTER_STAGE_0][i] = filt_coeff_e[i];
- filter_state->den_e[IVAS_FILTER_STAGE_0][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN];
- filter_state->num_e[IVAS_FILTER_STAGE_1][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN * 2];
- filter_state->den_e[IVAS_FILTER_STAGE_1][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN * 3];
- move16();
- move16();
- move16();
- move16();
-#endif
}
-#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS
filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0;
filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0;
filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0;
@@ -151,38 +117,11 @@ void ivas_filters_init_fx(
move64();
move64();
move64();
-#else
- filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0;
- filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0;
- filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0;
- filter_state->state_fx[IVAS_FILTER_STAGE_1][0] = 0;
- filter_state->state_fx[IVAS_FILTER_STAGE_1][1] = 0;
- filter_state->state_fx[IVAS_FILTER_STAGE_1][2] = 0;
- move32();
- move32();
- move32();
- move32();
- move32();
- move32();
- filter_state->state_e[0][0] = 0;
- filter_state->state_e[0][1] = 0;
- filter_state->state_e[0][2] = 0;
- filter_state->state_e[1][0] = 0;
- filter_state->state_e[1][1] = 0;
- filter_state->state_e[1][2] = 0;
- move16();
- move16();
- move16();
- move16();
- move16();
- move16();
-#endif
}
return;
}
-#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS
static Word64 ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, const Word16 stage, const Word64 in );
/*-----------------------------------------------------------------------------------------*
@@ -308,142 +247,3 @@ void ivas_filter_process_fx64(
return;
}
-
-#else
-static void ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 *pIn_Out_e );
-
-/*-----------------------------------------------------------------------------------------*
- * Function ivas_filter_process()
- *
- * Process call for selecting the type filter
- *-----------------------------------------------------------------------------------------*/
-
-void ivas_filter_process_fx(
- ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */
- Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */
- const Word16 length, /* i : number of samples to filter */
- Word16 q_factor )
-{
- Word16 pIn_Out_e[L_FRAME_MAX];
- Word16 i;
-
- SWITCH( filter_state->order )
- {
- case IVAS_FILTER_ORDER_1:
- set_val_Word16( pIn_Out_e, sub( Q31, q_factor ), length );
- ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, pIn_Out_e );
- /* Scale pIn_Out_fx back to input Q */
- FOR( i = 0; i < length; i++ )
- {
- pIn_Out_fx[i] = L_shr_r_sat( pIn_Out_fx[i], sub( sub( 31, q_factor ), pIn_Out_e[i] ) ); // Q(31-pIn_Out_e[i]) -> Q(q_factor)
- move32();
- }
- BREAK;
- case IVAS_FILTER_ORDER_4:
- set_val_Word16( pIn_Out_e, sub( Q31, q_factor ), length );
- /* biquad-1 */
- ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, pIn_Out_e );
- /* biquad-2 */
- ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, pIn_Out_e );
- /* Scale pIn_Out_fx back to input Q */
- FOR( i = 0; i < length; i++ )
- {
- pIn_Out_fx[i] = L_shr_r_sat( pIn_Out_fx[i], sub( sub( 31, q_factor ), pIn_Out_e[i] ) ); // Q(31-pIn_Out_e[i]) -> Q(q_factor)
- move32();
- }
- BREAK;
- default:
- BREAK;
- }
-
- return;
-}
-
-void ivas_filter_process_exp_fx(
- ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */
- Word32 *pIn_Out_fx, /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i]) */
- const Word16 length, /* i : number of samples to filter */
- Word16 *pIn_Out_e )
-{
- SWITCH( filter_state->order )
- {
- case IVAS_FILTER_ORDER_1:
- ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, pIn_Out_e );
- /* Scale pIn_Out_fx back to input Q */
- BREAK;
- case IVAS_FILTER_ORDER_4:
- /* biquad-1 */
- ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_0, pIn_Out_e );
- /* biquad-2 */
- ivas_iir_2_filter_fx( filter_state, pIn_Out_fx, length, IVAS_FILTER_STAGE_1, pIn_Out_e );
- /* Scale pIn_Out_fx back to input Q */
- BREAK;
- default:
- BREAK;
- }
-
- return;
-}
-
-/*-----------------------------------------------------------------------------------------*
- * Function ivas_iir_2_filter()
- *
- * Process call for filtering a signal
- *-----------------------------------------------------------------------------------------*/
-
-static void ivas_iir_2_filter_fx(
- ivas_filters_process_state_t *filter_state,
- Word32 *pIn_Out_fx, // Q(31-*pIn_Out_e)
- const Word16 length,
- const Word16 stage,
- Word16 *pIn_Out_e )
-{
- Word16 i, j;
-
- Word32 *pIn_fx = pIn_Out_fx;
- Word32 *pOut_fx = pIn_Out_fx;
- Word32 tmp_pIn_buf_i_fx;
- Word16 tmp_pIn_buf_i_e;
-
- Word32 L_tmp_prod, L_tmp;
- Word16 L_prod_e, L_tmp_e;
-
- FOR( i = 0; i < length; i++ )
- {
- tmp_pIn_buf_i_fx = pIn_fx[i];
- move32();
- tmp_pIn_buf_i_e = pIn_Out_e[i];
- move16();
-
- L_tmp_prod = Mpy_32_32( filter_state->num_fx[stage][0], pIn_fx[i] ); // Q31 -(pIn_Out_e[i]+ filter_state->num_e[stage][0])
- L_prod_e = add( pIn_Out_e[i], filter_state->num_e[stage][0] );
-
- pOut_fx[i] = BASOP_Util_Add_Mant32Exp( filter_state->state_fx[stage][0], filter_state->state_e[stage][0], L_tmp_prod, L_prod_e, &pIn_Out_e[i] ); // Q31 - pIn_Out_e[i]
- move32();
-
- FOR( j = 1; j < filter_state->filt_len; j++ )
- {
- L_tmp_prod = Mpy_32_32( filter_state->num_fx[stage][j], tmp_pIn_buf_i_fx ); // Q31-L_prod_e
- L_prod_e = add( filter_state->num_e[stage][j], tmp_pIn_buf_i_e );
-
- L_tmp = BASOP_Util_Add_Mant32Exp( filter_state->state_fx[stage][j], filter_state->state_e[stage][j], L_tmp_prod, L_prod_e, &L_tmp_e ); // Q31 - L_tmp_e
-
- L_tmp_prod = Mpy_32_32( filter_state->den_fx[stage][j], pOut_fx[i] ); // Q31 - ( pIn_Out_e[i]+filter_state->den_e[stage][j] )
- L_prod_e = add( pIn_Out_e[i], filter_state->den_e[stage][j] );
-
- filter_state->state_fx[stage][j - 1] = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_e, L_negate( L_tmp_prod ), L_prod_e, &filter_state->state_e[stage][j - 1] ); // Q31 - filter_state->state_e[stage][j - 1]
- move32();
- /*In case when exponent is less than -31 the value is very small and negligible hence resetting it to zero to avoid exponent overflow*/
- IF( LT_16( filter_state->state_e[stage][j - 1], -31 ) )
- {
- filter_state->state_fx[stage][j - 1] = 0;
- move32();
- filter_state->state_e[stage][j - 1] = 0;
- move16();
- }
- }
- }
-
- return;
-}
-#endif
diff --git a/lib_com/ivas_ism_com_fx.c b/lib_com/ivas_ism_com_fx.c
index 10c1f04b2c716dc7b534ce38a5553c2ce6d5899e..840949990c2b2f6bc0f7d32473e1ddcbaf9d5710 100644
--- a/lib_com/ivas_ism_com_fx.c
+++ b/lib_com/ivas_ism_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_lfe_com_fx.c b/lib_com/ivas_lfe_com_fx.c
index 03b92a10ff26e1915be85548691c52a4037e5bf9..8047af53ffdadaa5bccd8d628cafd75ee6c9c145 100644
--- a/lib_com/ivas_lfe_com_fx.c
+++ b/lib_com/ivas_lfe_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_limiter_fx.c b/lib_com/ivas_limiter_fx.c
index fdd1bb97c9712613445febcef811a9d44b1fed28..0ef37acdf183f0003e78b6adc89735ffbfb83ce7 100644
--- a/lib_com/ivas_limiter_fx.c
+++ b/lib_com/ivas_limiter_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_masa_com_fx.c b/lib_com/ivas_masa_com_fx.c
index f55e99153704d8e98e64e7726a5a0c3e531e1900..eb08f15bb858955b336bdbfea9db609efaf6e9d0 100644
--- a/lib_com/ivas_masa_com_fx.c
+++ b/lib_com/ivas_masa_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_mc_com_fx.c b/lib_com/ivas_mc_com_fx.c
index c04ded09c1ce8fedc0341313ec664c077735d15a..ffb5265541bcf1335433b8f494f2a71e624455c5 100644
--- a/lib_com/ivas_mc_com_fx.c
+++ b/lib_com/ivas_mc_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_mc_param_com_fx.c b/lib_com/ivas_mc_param_com_fx.c
index 7cb186b583a5dfeebc34db2a5efbed21e46d39d9..01f8614cdd06d0ee8694db3f10159726a6a1d528 100644
--- a/lib_com/ivas_mc_param_com_fx.c
+++ b/lib_com/ivas_mc_param_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_mcmasa_com_fx.c b/lib_com/ivas_mcmasa_com_fx.c
index 23a3800fb792ba9eeee06ef4cd26001a9b54d5e6..b611b1290aa14eef36fd09e95e27a4e9ea8b3e98 100644
--- a/lib_com/ivas_mcmasa_com_fx.c
+++ b/lib_com/ivas_mcmasa_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_mct_com_fx.c b/lib_com/ivas_mct_com_fx.c
index 81a56df146d9ba7378dbcadacb6aeb39b98f28b0..bcfada29e48fc0ef926997cc6f40b06b6ed40ef1 100644
--- a/lib_com/ivas_mct_com_fx.c
+++ b/lib_com/ivas_mct_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_mdct_core_com_fx.c b/lib_com/ivas_mdct_core_com_fx.c
index fe313eecdd7c3be915f9d9aa73c37081e79b61ac..ec623fbf1512b3914acf31aa8606c4fa9a15c1aa 100644
--- a/lib_com/ivas_mdct_core_com_fx.c
+++ b/lib_com/ivas_mdct_core_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_mdct_imdct_fx.c b/lib_com/ivas_mdct_imdct_fx.c
index 960b823ae605a2c890c6b77a3e305039fe0af208..fde3edaddd34d6fd40aa67a67ff0d726193d3b5e 100644
--- a/lib_com/ivas_mdct_imdct_fx.c
+++ b/lib_com/ivas_mdct_imdct_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_mdft_imdft_fx.c b/lib_com/ivas_mdft_imdft_fx.c
index d80d8a1561da6b2af4258d96149dd8cc480e4b38..49d1cbbf11c01d8bd02dd538abad93162ee0fab9 100644
--- a/lib_com/ivas_mdft_imdft_fx.c
+++ b/lib_com/ivas_mdft_imdft_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_omasa_com_fx.c b/lib_com/ivas_omasa_com_fx.c
index 7bbf287ac356282574b6cbcf93b059ec898de8cf..e5986879b9525a064a1fbf6225d475feaf3e7c74 100644
--- a/lib_com/ivas_omasa_com_fx.c
+++ b/lib_com/ivas_omasa_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_osba_com_fx.c b/lib_com/ivas_osba_com_fx.c
index 2f81a95740cb0fece3ae4d04cfd4b7077b0b2b96..5527f53898e41e5fbc4f8f70638a81df90912404 100644
--- a/lib_com/ivas_osba_com_fx.c
+++ b/lib_com/ivas_osba_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_pca_tools_fx.c b/lib_com/ivas_pca_tools_fx.c
index a265a149636fa5e92d0897493f23c873eec0873e..4669b86a36742dc5e4850cd869503be72e2b9867 100644
--- a/lib_com/ivas_pca_tools_fx.c
+++ b/lib_com/ivas_pca_tools_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -1375,11 +1375,7 @@ void pca_enc_s3_fx(
q_ang_2surv_fx( ph1_fx, n1, ph1_q_fx, ind1 );
-#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE
tmp = mac_r( L_mac( L_mult( q_fx[1], q_fx[1] ), q_fx[2], q_fx[2] ), q_fx[3], q_fx[3] ); // Q15 + Q15 - Q15 -> Q15
-#else
- tmp = add( add( mult( q_fx[1], q_fx[1] ), mult( q_fx[2], q_fx[2] ) ), mult( q_fx[3], q_fx[3] ) ); // Q15 + Q15 - Q15 -> Q15
-#endif
r_e = 0;
move16();
r_fx = Sqrt16( tmp, &r_e );
@@ -1433,11 +1429,7 @@ void pca_enc_s3_fx(
q_ang_2surv_fx( ph2_fx, n2[i], ph2_q_fx + 2 * i, ind2 + 2 * i );
}
-#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE
r_fx = Sqrt16( mac_r( L_mult( q_fx[2], q_fx[2] ), q_fx[3], q_fx[3] ), &r_e );
-#else
- r_fx = Sqrt16( add( mult( q_fx[2], q_fx[2] ), mult( q_fx[3], q_fx[3] ) ), &r_e );
-#endif
v_fx = BASOP_Util_Divide1616_Scale( q_fx[2], r_fx, &v_e );
v_e = add( v_e, sub( 0, r_e ) );
diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h
index 85bbcb4b10d2624ab6bd18289af66c0ca77c0f4f..409bf870fdda0de4d459d9e278e103aaf4801aeb 100644
--- a/lib_com/ivas_prot_fx.h
+++ b/lib_com/ivas_prot_fx.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -622,12 +622,6 @@ void ivas_dirac_dec_set_md_map_fx(
const Word16 nCldfbTs /* i : number of CLDFB time slots */
);
-void ivas_jbm_dec_get_adapted_subframes_fx(
- const Word16 nCldfbTs, /* i : number of time slots in the current frame */
- Word16 *subframe_nbslots, /* i/o: subframe grid */
- Word16 *nb_subframes /* i/o: number of subframes in the frame */
-);
-
/*! r: number of bits read */
Word16 read_GR0(
const UWord16 *bit_stream, /* i : bitstream to be read */
@@ -1039,7 +1033,7 @@ void ivas_ism_render_sf_fx(
const Word16 n_samples_to_render /* i : output frame length per channel */
);
-void ivas_omasa_separate_object_render_jbm_fx(
+void ivas_omasa_separate_object_render_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
const UWord16 nSamplesRendered, /* i : number of samples rendered */
Word32 input_fx_in[][L_FRAME48k], /* i : separated object signal */
@@ -1363,13 +1357,22 @@ void stereo_tcx_init_dec_fx(
const Word16 last_element_mode /* i : element mode of previous frame */
);
-void stereo_icBWE_enc_ivas_fx(
+void stereo_icBWE_enc_fx(
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
+#ifdef REMOVE_SCALING_SHB_SPEECH
+ const Word16 shb_speech_ref_fx16[], /* i : SHB speech ref channel Q0*/
+ Word16 shb_speech_nonref_fx_16[], /* i/o: SHB speech non-ref channel shb_speech_nonref_e*/
+#else
const Word32 shb_speech_ref_fx[], /* i : SHB speech ref channel */
const Word16 shb_speech_ref_e, /* i : SHB speech ref channel */
Word32 shb_speech_nonref_fx[], /* i/o: SHB speech non-ref channel */
+#endif
Word16 shb_speech_nonref_e, /* i/o: SHB speech non-ref channel */
+#ifdef REMOVE_SCALING_SHB_SPEECH
+ const Word16 *voice_factors_fx /* i : voicing factors Q15 */
+#else
const Word32 *voice_factors_fx /* i : voicing factors Q31 */
+#endif
);
void initMdctStereoDecData_fx(
@@ -1576,8 +1579,7 @@ void decoder_tcx_imdct_fx(
void ivas_sba_dirac_stereo_dec_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
Word32 *output[CPE_CHANNELS], /* i/o: output synthesis signal */
- const Word16 output_frame, /* i : output frame length per channel */
- const Word16 mcmasa /* i : McMASA flag */
+ const Word16 output_frame /* i : output frame length per channel */
);
ivas_error ivas_osba_render_sf_fx(
@@ -1599,6 +1601,7 @@ void ivas_hq_core_dec_fx(
Word16 *Q_output
);
+#ifndef HARMONIZE_TBE
void ivas_HQ_FEC_Mem_update_fx(
Decoder_State *st_fx, /* i/o: decoder state structure */
Word32 *t_audio_q_fx, /*Q12*/
@@ -1614,7 +1617,7 @@ void ivas_HQ_FEC_Mem_update_fx(
Word16 hq_core_type, /* i : normal or low-rate MDCT(HQ) core */
Word16 output_frame
);
-
+#endif
/* o : Consumed bits Q0 */
Word16 ivas_hq_classifier_dec_fx(
Decoder_State *st_fx, /* i/o: decoder state structure */
@@ -1864,6 +1867,7 @@ void stereoFdCngCoherence_fx(
Word16 fft_exp
);
+#ifndef HARMONIZE_TBE
void ivas_wb_tbe_dec_fx(
Decoder_State *st_fx, /* i/o: decoder state structure */
const Word16 coder_type, /* i : coding type */
@@ -1892,7 +1896,7 @@ void GenShapedWBExcitation_ivas_fx(
const Word16 uv_flag, /* i : unvoiced flag */
const Word16 igf_flag
);
-
+#endif
/* o : Q_syn_hb*/
Word16 ivas_wb_bwe_dec_fx(
Decoder_State *st_fx, /* i/o: decoder state structure */
@@ -2059,19 +2063,37 @@ UWord32 ivas_syn_output_fx(
Word16 *synth_out /* o : integer 16 bits synthesis signal */
);
+#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER
+void ivas_buffer_interleaved_to_deinterleaved_fx(
+ Word32 *audio_in, /* i : interleaved audio buffer */
+ Word32 *audio_out[], /* o : pointers to each channel of deinterleaved audio buffer */
+ const Word16 n_channels, /* i : number of channels */
+ const Word16 frame_length /* i : frame length (one channel) */
+);
+#else
void ivas_buffer_interleaved_to_deinterleaved_fx(
Word32 *audio, /* i/o: audio buffer */
const Word16 n_channels, /* i : number of channels */
const Word16 frame_length, /* i : frame length (one channel) */
const Word16 n_samp_full /* i : full frame length (one channel) */
);
+#endif
+#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER
+void ivas_buffer_deinterleaved_to_interleaved_fx(
+ Word32 *audio_in[], /* i : pointers to each channel of deinterleaved audio buffer */
+ Word32 *audio_out, /* o : interleaved audio buffer */
+ const Word16 n_channels, /* i : number of channels */
+ const Word16 frame_length /* i : frame length (one channel) */
+);
+#else
void ivas_buffer_deinterleaved_to_interleaved_fx(
Word32 *audio[], /* i : deinterleaved audio buffer */
const Word16 n_channels, /* i : number of channels */
const Word16 frame_length, /* i : frame length (one channel) */
Word32 *audio_out /* o : interleaved audio buffer */
);
+#endif
void stereo_tcx_core_dec_fx(
Decoder_State *st, /* i/o: decoder state structure */
@@ -2447,7 +2469,7 @@ void ivas_fb_mixer_cross_fading_fx(
const Word16 cf_offset
);
-ivas_error ivas_omasa_dirac_td_binaural_jbm_fx(
+ivas_error ivas_omasa_dirac_td_binaural_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
const UWord16 nSamplesAsked, /* i : number of samples requested */
UWord16 *nSamplesRendered, /* o : number of samples rendered */
@@ -2484,7 +2506,7 @@ void ivas_sba_get_spar_hoa_md_flag_fx(
Word16 *spar_hoa_dirac2spar_md_flag
);
-void ivas_omasa_dirac_rend_jbm_fx(
+void ivas_omasa_dirac_rend_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
const UWord16 nSamplesAsked, /* i : number of samples requested */
UWord16 *nSamplesRendered, /* o : number of samples rendered */
@@ -2969,17 +2991,6 @@ void stereo_icBWE_preproc_fx(
Word16 shb_speech_nonref[], /* o : SHB speech non-ref channel */
Word16 q_shb_speech_nonref /* i : Q SHB speech non-ref channel */
);
-
-void core_switching_pre_enc_ivas_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz */
- const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */
- const Word16 *old_inp_16k, /* i : old input signal @16kHz */
- const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */
- const Word16 active_cnt, /* i : active frame counter */
- const Word16 last_element_mode /* i : last_element_mode */
-);
-
Word16 ivas_acelp_tcx20_switching_fx(
Encoder_State *st, /* i/o: encoder state structure */
Word16 *inp_fx, /* i : new input signal */
@@ -2996,7 +3007,7 @@ Word16 ivas_acelp_tcx20_switching_fx(
const Word16 flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz */
);
-void encod_gen_2sbfr(
+void encod_gen_2sbfr_fx(
Encoder_State *st, /* i/o: state structure */
const Word16 speech[], /* i : input speech */
const Word16 Aw[], /* i : weighted A(z) unquantized for subframes */
@@ -3010,8 +3021,8 @@ void encod_gen_2sbfr(
Word16 *bwe_exc, /* o : excitation for SWB TBE */
const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
const Word16 tdm_Pri_pitch_buf[], /* i : pitch values for primary channel */
- Word16 Q_new,
- Word16 shift
+ const Word16 Q_new, /* i : Scaling factor */
+ const Word16 shift /* i : Shift needed to obtain 12 bits vectors */
);
void acelp_fast_fx(
@@ -3794,7 +3805,6 @@ void ivas_lfe_enc_fx(
BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */
);
-#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS
void ivas_filter_process_fx32(
ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */
Word32 *pIn_Out_fx, /* i : signal subject to filtering */
@@ -3806,21 +3816,6 @@ void ivas_filter_process_fx64(
Word64 *pIn_Out_fx, /* i : signal subject to filtering */
const Word16 length /* i : number of samples to filter */
);
-#else
-void ivas_filter_process_fx(
- ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */
- Word32 *pIn_Out_fx, /* i : signal subject to filtering */
- const Word16 length, /* i : number of samples to filter */
- Word16 q_factor
-);
-
-void ivas_filter_process_exp_fx(
- ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */
- Word32 *pIn_Out_fx, /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i]) */
- const Word16 length, /* i : number of samples to filter */
- Word16 *pIn_Out_e
-);
-#endif
ivas_error ivas_osba_enc_open_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
);
@@ -3846,7 +3841,7 @@ ivas_error ivas_osba_data_open_fx(
Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */
);
-ivas_error ivas_osba_dirac_td_binaural_jbm_fx(
+ivas_error ivas_osba_dirac_td_binaural_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */
UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */
@@ -4273,8 +4268,7 @@ void ivas_ism_coh_estim_dtx_enc_fx(
void ivas_ism_dtx_limit_noise_energy_for_near_silence_fx(
SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder structures */
const Word16 sce_id_dtx, /* i : SCE DTX ID */
- const Word16 nchan_transport, /* i : number of transport channels */
- Word16 *Q_cngNoiseLevel
+ const Word16 nchan_transport /* i : number of transport channels */
);
ivas_error stereo_dft_enc_create_fx(
@@ -4489,7 +4483,7 @@ ivas_error signaling_enc_secondary_fx(
const Word16 tdm_Pitch_reuse_flag /* i : primary channel pitch reuse flag */
);
-void tdm_low_rate_enc(
+void tdm_low_rate_enc_fx(
Encoder_State *st, /* i/o: State structure */
const Word16 Aq[], /* i : 12k8 Lp coefficient */
const Word16 *res, /* i : residual signal Q_new*/
@@ -4500,8 +4494,8 @@ void tdm_low_rate_enc(
Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/
const Word16 attack_flag, /* i : attack flag */
const Word16 *lsf_new, /* i : current frame ISF vector x2.56 */
- Word16 *tmp_noise, /* o : long-term noise energy Q8 */
- Word16 Q_new
+ Word16 *tmp_noise, /* o : long-term noise energy Q8 */
+ const Word16 Q_new /* i : Scaling factor */
);
void tdm_low_rate_dec_fx(
@@ -5854,7 +5848,7 @@ ivas_error ivas_mct_enc_fx(
const Word16 nb_bits_metadata /* i : number of metadata bits */
);
-ivas_error ivas_compute_core_buffers_fx(
+void ivas_compute_core_buffers_fx(
Encoder_State *st, /* i/o: encoder state structure */
Word16 **inp16k_out_fx, /* o : ptr. to inp. signal in the current frame */
Word16 *old_inp_16k_fx, /* i/o: buffer of old input signal @ 16kHz */
@@ -5868,17 +5862,11 @@ ivas_error ivas_compute_core_buffers_fx(
Word32 epsP[M + 1], /* i/o: LP prediction errors */
Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame */
Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame */
- Word16 Q_old_inp_16k,
+ const Word16 Q_old_inp_16k,
Word16 Q_r[2],
Word16 *Q_new
);
-ivas_error ivas_enc_fx(
- Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
- const Word16 *data, /* i : input signal Q0 */
- const Word16 n_samples /* i : number of input samples */
-);
-
void reset_metadata_spatial_fx(
const IVAS_FORMAT ivas_format, /* i : IVAS format */
BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */
@@ -5929,6 +5917,24 @@ void modify_Rmat_q_fx(
* General IVAS prototypes
*----------------------------------------------------------------------------------*/
+ivas_error ivas_enc_fx(
+ Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
+ const Word16 *data, /* i : input signal Q0 */
+ const Word16 n_samples /* i : number of input samples */
+);
+
+ivas_error ivas_dec_fx(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+);
+
+ivas_error ivas_dec_render_fx(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ const UWord16 nSamplesAsked, /* i : number of samples wanted */
+ UWord16 *nSamplesRendered, /* o : number of samples rendered */
+ UWord16 *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */
+ Word16 *data /* o : output synthesis signal */
+);
+
void copy_encoder_config_ivas_fx(
Encoder_Struct *st_ivas, /* i : IVAS encoder structure */
Encoder_State *st, /* o : encoder state structure */
@@ -5947,67 +5953,63 @@ void ivas_mct_enc_close_fx(
MCT_ENC_HANDLE *hMCT /* i/o: MCT encoder structure */
);
-ivas_error pre_proc_front_ivas_fx(
- SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/
- const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/
- const Word16 input_frame, /* i : frame length Q0*/
- const Word16 n, /* i : channel number Q0*/
- Word16 old_inp_12k8_fx[], /* o : buffer of old input signal Q_new-1*/
- Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q_new-1*/
- Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/
- Word16 *relE_fx, /* o : frame relative energy Q8*/
- Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12*/
- Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12*/
- Word32 epsP_fx[M + 1], /* o : LP prediction errors epsP_fx_q*/
- Word16 *epsP_fx_q,
- Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15*/
- Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15*/
- Word16 *vad_hover_flag, /* o : VAD hangover flag Q0*/
- Word16 *attack_flag, /* o : flag signaling attack Q0*/
- Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer Q(q_re_im_buf)*/
- Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer Q(q_re_im_buf)*/
- Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */
- Word16 old_wsp_fx[], /* o : weighted input signal buffer q_old_wsp*/
- Word16 *q_old_wsp,
- Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6*/
- Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15*/
- Word16 *loc_harm, /* o : harmonicity flag Q0*/
- Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8*/
- Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO Q0*/
- Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/
- Word16 *enerBuffer_fx_exp, /* o : energy buffer */
- Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer fft_buff_fx_q*/
- Word16 *fft_buff_fx_q, /* o : FFT buffer */
- const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12*/
- const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15*/
- const Word32 currFlatness_fx, /* i : flatness parameter Q21*/
- const Word16 tdm_ratio_idx, /* i : Current Ratio_L index Q0*/
- Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) fr_bands_LR_fx_q*/
- Word16 fr_bands_LR_fx_q[CPE_CHANNELS],
- const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/
- Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q)*/
- Word16 lf_E_LR_fx_q,
- const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/
- Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q)*/
- Word16 band_energies_LR_fx_q,
- const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
- const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/
- const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/
- const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision Q0*/
- const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
- const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/
- const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/
- Word16 *Q_new
-#ifdef DEBUG_MODE_INFO
- ,
- const Word16 ch_idx
-#endif
-);
-
-ivas_error pre_proc_ivas_fx(
+void pre_proc_front_ivas_fx(
+ SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */
+ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
+ const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/
+ const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/
+ const Word16 input_frame, /* i : frame length Q0*/
+ const Word16 n, /* i : channel number Q0*/
+ Word16 old_inp_12k8_fx[], /* o : buffer of old input signal (st->Q_inp until preemph, then Q_new, then Q_new-1 towards the end)*/
+ Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q_new-1*/
+ Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/
+ Word16 *relE_fx, /* o : frame relative energy Q8*/
+ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12*/
+ Word32 epsP_fx[M + 1], /* o : LP prediction errors epsP_fx_q*/
+ Word16 *epsP_fx_q, /* o : Q factor of LP prediction errors */
+ Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15*/
+ Word16 *vad_hover_flag, /* o : VAD hangover flag Q0*/
+ Word16 *attack_flag, /* o : flag signaling attack Q0*/
+ Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer Q(q_re_im_buf)*/
+ Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer Q(q_re_im_buf)*/
+ Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */
+ Word16 old_wsp_fx[], /* o : weighted input signal buffer q_old_wsp*/
+ Word16 *q_old_wsp, /* o : Q factor of weighted input signal buffer */
+ Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6*/
+ Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15*/
+ Word16 *loc_harm, /* o : harmonicity flag Q0*/
+ Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8*/
+ Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO Q0*/
+ Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/
+ Word16 *enerBuffer_fx_exp, /* o : energy buffer */
+ Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer fft_buff_fx_q*/
+ Word16 *fft_buff_fx_q, /* o : FFT buffer */
+ const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12*/
+ const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15*/
+ const Word32 currFlatness_fx, /* i : flatness parameter Q21*/
+ const Word16 tdm_ratio_idx, /* i : Current Ratio_L index Q0*/
+ Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands fr_bands_LR_fx_q*/
+ Word16 fr_bands_LR_fx_q[CPE_CHANNELS], /* i : Q factors of energy in frequency bands */
+ const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/
+ Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels lf_E_LR_fx_q*/
+ const Word16 lf_E_LR_fx_q, /* i : Q factor of per bin spectrum energy in lf, LR channels */
+ const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/
+ Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN band_energies_LR_fx_q*/
+ const Word16 band_energies_LR_fx_q, /* o : Q factors of energy in critical bands without minimum noise floor */
+ const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
+ const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/
+ const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/
+ const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision Q0*/
+ const IVAS_FORMAT ivas_format, /* i : IVAS format */
+ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
+ const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/
+ const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/
+ Word16 *Q_new /* i/o : Q factor of speech buffers */
+);
+
+void pre_proc_ivas_fx(
Encoder_State *st, /* i/o: encoder state structure */
const Word16 last_element_mode, /* i : last element mode Q0*/
const Word32 element_brate, /* i : element bitrate Q0*/
@@ -6026,17 +6028,17 @@ ivas_error pre_proc_ivas_fx(
Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_new-1*/
Word16 *Voicing_flag, /* o : voicing flag for HQ FEC Q0*/
Word16 old_wsp_fx[], /* i : weighted input signal buffer e_old_wsp*/
- Word16 e_old_wsp,
+ const Word16 e_old_wsp, /* i : Q value of weighted input signal buffer */
const Word16 loc_harm, /* i : harmonicity flag Q0*/
const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO Q0*/
const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
- Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* e_enerBuffer */
- Word16 e_enerBuffer,
- Word16 fft_buff_fx[2 * L_FFT], /* Qx */
- Word16 cor_map_sum_fx, /* Q8 */
- Word16 *Q_new
+ Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* i : energy buffer e_enerBuffer */
+ const Word16 e_enerBuffer, /* i : Q value of energy buffer */
+ Word16 fft_buff_fx[2 * L_FFT], /* i : FFT buffer Qx*/
+ const Word16 cor_map_sum_fx, /* i : speech/music clasif. parameter Q8*/
+ Word16 *Q_new /* i/o: Q factor of speech buffers */
);
void ivas_initialize_handles_enc_fx(
@@ -6134,21 +6136,9 @@ Word16 is_DTXrate(
/*----------------------------------------------------------------------------------*
- * JBM prototypes
+ * Internal rendering prototypes
*----------------------------------------------------------------------------------*/
-ivas_error ivas_jbm_dec_tc_fx(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-ivas_error ivas_jbm_dec_render_fx(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const UWord16 nSamplesAsked, /* i : number of samples wanted */
- UWord16 *nSamplesRendered, /* o : number of samples rendered */
- UWord16 *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */
- Word16 *data /* o : output synthesis signal */
-);
-
ivas_error ivas_jbm_dec_flush_renderer_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
const Word16 tc_granularity_new, /* i : new renderer granularity */
@@ -6161,7 +6151,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx(
Word16 *data /* o : output synthesis signal */
);
-void ivas_jbm_dec_feed_tc_to_renderer_fx(
+void ivas_dec_feed_tc_to_renderer_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
const Word16 nSamplesForRendering, /* i : number of TC samples available for rendering */
Word16 *nSamplesResidual /* o : number of samples not fitting into the renderer grid and buffer for the next call*/
@@ -6175,80 +6165,80 @@ ivas_error ivas_jbm_dec_set_discard_samples_fx(
Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */
);
-void ivas_jbm_dec_get_adapted_linear_interpolator_fx(
+void ivas_dec_get_adapted_linear_interpolator_fx(
const Word16 default_interp_length, /* i : default length of the (full-frame) interpolator */
const Word16 interp_length, /* i : length of the interpolator to be created */
Word16 *interpolator_fx /* o : the interpolator */
);
-void ivas_jbm_dec_get_adapted_subframes(
+void ivas_dec_get_adapted_subframes_fx(
const Word16 nCldfbTs, /* i : number of time slots in the current frame */
Word16 *subframe_nbslots, /* i/o: subframe grid */
Word16 *nb_subframes /* i/o: number of subframes in the frame */
);
-void ivas_jbm_dec_get_md_map(
+void ivas_dec_get_md_map_fx(
const Word16 default_len, /* i : default frame length in metadata slots */
const Word16 len, /* i : length of the modfied frames in metadata slots */
const Word16 subframe_len, /* i : default length of a subframe */
- const Word16 offset, /* i : current read offset into the md buffer */
+ const Word16 offset, /* i : current read offset into the MD buffer */
const Word16 buf_len, /* i : length of the metadata buffer */
Word16 *map /* o : metadata index map */
);
-Word16 ivas_jbm_dec_get_num_tc_channels_fx(
+Word16 ivas_dec_get_num_tc_channels_fx(
Decoder_Struct *st_ivas /* i : IVAS decoder handle */
);
-void ivas_jbm_dec_get_md_map_even_spacing(
+void ivas_dec_get_md_map_even_spacing_fx(
const Word16 len, /* i : length of the modfied frames in metadata slots */
const Word16 subframe_len, /* i : default length of a subframe */
- const Word16 offset, /* i : current read offset into the md buffer */
+ const Word16 offset, /* i : current read offset into the MD buffer */
const Word16 buf_len, /* i : length of the metadata buffer */
Word16 *map /* o : metadata index map */
);
-TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode_fx(
+TC_BUFFER_MODE ivas_dec_get_tc_buffer_mode_fx(
Decoder_Struct *st_ivas /* i : IVAS decoder handle */
);
-Word16 ivas_jbm_dec_get_render_granularity_fx(
+Word16 ivas_dec_get_render_granularity_fx(
const RENDERER_TYPE renderer_type, /* i : renderer type */
const RENDERER_TYPE renderer_type_sec, /* i : secondary renderer type */
const Word32 output_Fs /* i : sampling rate */
);
-ivas_error ivas_jbm_dec_tc_buffer_open_fx(
+ivas_error ivas_dec_tc_buffer_open_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */
- const Word16 nchan_transport_jbm, /* i : number of real transport channels */
+ const Word16 nchan_transport_rend, /* i : number of TCs for rendering */
const Word16 nchan_transport_internal, /* i : number of totally buffered channels */
const Word16 nchan_full, /* i : number of channels to fully store */
const Word16 n_samples_granularity /* i : granularity of the renderer/buffer */
);
-ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx(
+ivas_error ivas_dec_tc_buffer_reconfigure_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */
- const Word16 nchan_transport_jbm, /* i : new number of real transport channels */
+ const Word16 nchan_transport_rend, /* i : new number of TCs for rendering */
const Word16 nchan_transport_internal, /* i : new number of totally buffered channels */
const Word16 nchan_full, /* i : new number of channels to fully store */
const Word16 n_samples_granularity /* i : new granularity of the renderer/buffer */
);
-void ivas_jbm_dec_tc_buffer_close_fx(
+void ivas_dec_tc_buffer_close_fx(
DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */
);
-void ivas_jbm_dec_td_renderers_adapt_subframes(
+void ivas_dec_td_renderers_adapt_subframes_fx(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
);
-ivas_error ivas_jbm_dec_metadata_open(
+ivas_error ivas_jbm_dec_masa_metadata_open_fx(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
);
-void ivas_jbm_masa_sf_to_sf_map(
+void ivas_jbm_masa_sf_to_sf_map_fx(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
);
@@ -6410,7 +6400,7 @@ UWord16 get_indice_st(
void stereo_mdct_core_enc_fx(
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q0*/
+ Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Qnew-1*/
Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/
Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe Q6*/
);
@@ -6809,11 +6799,12 @@ void ivas_filters_init_fx(
const Word16 order
);
+
/*----------------------------------------------------------------------------------*
* OSBA prototypes
*----------------------------------------------------------------------------------*/
-ivas_error ivas_osba_enc_reconfig(
+ivas_error ivas_osba_enc_reconfig_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
);
@@ -6830,11 +6821,11 @@ void ivas_set_surplus_brate_dec(
Word32 *ism_total_brate /* i : ISM total bitrate */
);
-ivas_error ivas_omasa_separate_object_renderer_open(
+ivas_error ivas_omasa_separate_object_renderer_open_fx(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
);
-void ivas_omasa_separate_object_renderer_close(
+void ivas_omasa_separate_object_renderer_close_fx(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
);
diff --git a/lib_com/ivas_qmetadata_com_fx.c b/lib_com/ivas_qmetadata_com_fx.c
index f1a0a7609e9adff63897a8f26fc9f496bd54bd70..93c3bd806f4cb58668a58882e92fc47173745258 100644
--- a/lib_com/ivas_qmetadata_com_fx.c
+++ b/lib_com/ivas_qmetadata_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_qspherical_com_fx.c b/lib_com/ivas_qspherical_com_fx.c
index 6a965850e2b521584bb630b39d13e441383b9460..2a0e7797c27c0c282680a748e86a4624ac910a38 100644
--- a/lib_com/ivas_qspherical_com_fx.c
+++ b/lib_com/ivas_qspherical_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h
index a145e0ca168eec5dea4dd19211f28e921ffc99fd..6081e450affc3b2e778d31e2a3e89cbf9c2d220d 100644
--- a/lib_com/ivas_rom_com.h
+++ b/lib_com/ivas_rom_com.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c
index 9ba733779cb42af8bd4f61dc8b7709816c22e60a..4ef543df7eac85d5479913267c65404b9e25d60b 100644
--- a/lib_com/ivas_rom_com_fx.c
+++ b/lib_com/ivas_rom_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_rotation_com_fx.c b/lib_com/ivas_rotation_com_fx.c
index 199af90d3656641a0b68bc7bd1f0b654533034de..5fc6261a955b8f0fbee67a48d693230994521342 100644
--- a/lib_com/ivas_rotation_com_fx.c
+++ b/lib_com/ivas_rotation_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -113,7 +113,7 @@ void Copy_Quat_fx(
/*-------------------------------------------------------------------------
- * Scale_Quat_fx()
+ * modify_Quat_q_fx()
*
* Quaternion q factor modification
*------------------------------------------------------------------------*/
@@ -124,10 +124,18 @@ void modify_Quat_q_fx(
Word16 q_new /* i : quaternion describing the rotation */
)
{
+#ifdef FIX_BASOP_2361_OTR
+ Word16 shift = sub( q_new, in_quat->q_fact );
+ out_quat->w_fx = L_shl_sat( in_quat->w_fx, shift ); // q_new
+ out_quat->x_fx = L_shl_sat( in_quat->x_fx, shift ); // q_new
+ out_quat->y_fx = L_shl_sat( in_quat->y_fx, shift ); // q_new
+ out_quat->z_fx = L_shl_sat( in_quat->z_fx, shift ); // q_new
+#else
out_quat->w_fx = L_shl_sat( in_quat->w_fx, sub( q_new, in_quat->q_fact ) ); // q_new
out_quat->x_fx = L_shl_sat( in_quat->x_fx, sub( q_new, in_quat->q_fact ) ); // q_new
out_quat->y_fx = L_shl_sat( in_quat->y_fx, sub( q_new, in_quat->q_fact ) ); // q_new
out_quat->z_fx = L_shl_sat( in_quat->z_fx, sub( q_new, in_quat->q_fact ) ); // q_new
+#endif
out_quat->q_fact = q_new;
return;
}
@@ -147,12 +155,19 @@ void modify_Rmat_q_fx(
)
{
Word16 j, k;
+#ifdef FIX_BASOP_2361_OTR
+ Word16 shift = sub( q_new, q_cur );
+#endif
FOR( j = 0; j < 3; j++ )
{
FOR( k = 0; k < 3; k++ )
{
+#ifdef FIX_BASOP_2361_OTR
+ Rmat_out[j][k] = L_shl( Rmat_in[j][k], shift );
+#else
Rmat_out[j][k] = L_shl( Rmat_in[j][k], sub( q_new, q_cur ) );
+#endif
move32();
}
}
@@ -200,7 +215,7 @@ void Quat2EulerDegree_fx(
Word32 tmp8 = W_extract_l( W_shr( W_mult0_32_32( quat.w_fx, quat.y_fx ), Q22 ) ); // Q22
Word32 tmp9 = W_extract_l( W_shr( W_mult0_32_32( quat.z_fx, quat.x_fx ), Q22 ) ); // Q22
p_fx = L_shl( L_sub( tmp8, tmp9 ), 1 );
- p_fx = max( L_negate( ONE_IN_Q22 ), min( ONE_IN_Q22, p_fx ) ); // Q22
+ p_fx = L_max( L_negate( ONE_IN_Q22 ), L_min( ONE_IN_Q22, p_fx ) ); // Q22
Word32 p_fx_sq = W_extract_l( W_shr( W_mult0_32_32( p_fx, p_fx ), Q22 ) );
Word16 res_exp = 0;
diff --git a/lib_com/ivas_sba_config_fx.c b/lib_com/ivas_sba_config_fx.c
index 7e1fac44b0d2c37097eec3c302e8ef45578e7f47..2658644cccfbd82d4c43785bdb980684baebae4b 100644
--- a/lib_com/ivas_sba_config_fx.c
+++ b/lib_com/ivas_sba_config_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_sns_com_fx.c b/lib_com/ivas_sns_com_fx.c
index 57c4cd66e49a44ba58aaa2cbae80a0f0ebb3637e..652b095c10d9b7541808914c6b338ca3b84cd1d5 100644
--- a/lib_com/ivas_sns_com_fx.c
+++ b/lib_com/ivas_sns_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c
index 4b70d277a46af08f4c2ae44e98bb9934f31d7d16..4733e4fa086c6a370344255238982d9180b38088 100644
--- a/lib_com/ivas_spar_com_fx.c
+++ b/lib_com/ivas_spar_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -3843,7 +3843,8 @@ void ivas_get_spar_md_from_dirac_enc_fx(
Word32 **ppMixer_mat_fx[IVAS_MAX_FB_MIXER_OUT_CH];
Word32 *pMixer_mat_fx[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH];
Word16 q_ppMixer_mat = 0;
- Word32 en_ratio_fac_fx, diff_norm_order1_fx, diff_norm_order2_fx, diff_norm_order3_fx;
+ Word32 en_ratio_fac_fx;
+ Word16 diff_norm_order1_fx, diff_norm_order2_fx, diff_norm_order3_fx;
Word16 active_w;
move16();
move16();
@@ -3862,11 +3863,11 @@ void ivas_get_spar_md_from_dirac_enc_fx(
foa_ch = FOA_CHANNELS;
move16();
diff_norm_order1_fx = 3;
- move32();
+ move16();
diff_norm_order2_fx = 5;
- move32();
+ move16();
diff_norm_order3_fx = 7;
- move32();
+ move16();
FOR( i = 0; i < IVAS_MAX_FB_MIXER_OUT_CH; i++ )
{
@@ -3898,7 +3899,7 @@ void ivas_get_spar_md_from_dirac_enc_fx(
P_norm_fx[0] = L_add( P_norm_fx[0], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31
move32();
}
- P_norm_fx[0] = Mpy_32_32( L_shl( P_norm_fx[0], 3 ), diff_norm_order1_table[min( diff_norm_order1_fx, max( 0, sub( foa_ch, ndm ) ) )] ); // 2*q_P_re - 31
+ P_norm_fx[0] = Mpy_32_32( L_shl( P_norm_fx[0], 3 ), diff_norm_order1_table[s_min( diff_norm_order1_fx, s_max( 0, sub( foa_ch, ndm ) ) )] ); // 2*q_P_re - 31
move32();
P_norm_fx[1] = 0;
@@ -3909,7 +3910,7 @@ void ivas_get_spar_md_from_dirac_enc_fx(
P_norm_fx[1] = L_add( P_norm_fx[1], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31
move32();
}
- P_norm_fx[1] = Mpy_32_32( L_shl( P_norm_fx[1], 3 ), diff_norm_order2_table[min( diff_norm_order2_fx, max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ) )] ); // 2*q_P_re - 31
+ P_norm_fx[1] = Mpy_32_32( L_shl( P_norm_fx[1], 3 ), diff_norm_order2_table[s_min( diff_norm_order2_fx, s_max( 0, ( s_min( num_ch, hoa2_ch ) - ndm ) ) )] ); // 2*q_P_re - 31
move32();
P_norm_fx[2] = 0;
@@ -3919,7 +3920,7 @@ void ivas_get_spar_md_from_dirac_enc_fx(
P_norm_fx[2] = L_add( P_norm_fx[2], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31
move32();
}
- P_norm_fx[2] = Mpy_32_32( L_shl( P_norm_fx[2], 3 ), diff_norm_order3_table[min( diff_norm_order3_fx, max( 0, ( num_ch - ndm ) ) )] ); // 2*q_P_re - 31
+ P_norm_fx[2] = Mpy_32_32( L_shl( P_norm_fx[2], 3 ), diff_norm_order3_table[s_min( diff_norm_order3_fx, s_max( 0, ( num_ch - ndm ) ) )] ); // 2*q_P_re - 31
move32();
len = s_max( 0, sub( foa_ch, ndm ) );
FOR( i = 0; i < len; i++ ) // i < max( 0, ( foa_ch - ndm ) )
@@ -4291,7 +4292,8 @@ void ivas_get_spar_md_from_dirac_fx(
Word32 **ppMixer_mat_fx[IVAS_MAX_FB_MIXER_OUT_CH];
Word32 *pMixer_mat_fx[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH];
Word16 q_ppMixer_mat = 0;
- Word32 en_ratio_fac_fx, diff_norm_order1_fx, diff_norm_order2_fx, diff_norm_order3_fx;
+ Word32 en_ratio_fac_fx;
+ Word16 diff_norm_order1_fx, diff_norm_order2_fx, diff_norm_order3_fx;
Word16 active_w;
move16();
move16();
@@ -4310,11 +4312,11 @@ void ivas_get_spar_md_from_dirac_fx(
foa_ch = FOA_CHANNELS;
move16();
diff_norm_order1_fx = 3;
- move32();
+ move16();
diff_norm_order2_fx = 5;
- move32();
+ move16();
diff_norm_order3_fx = 7;
- move32();
+ move16();
FOR( i = 0; i < IVAS_MAX_FB_MIXER_OUT_CH; i++ )
{
@@ -4346,7 +4348,7 @@ void ivas_get_spar_md_from_dirac_fx(
P_norm_fx[0] = L_add( P_norm_fx[0], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31
move32();
}
- P_norm_fx[0] = Mpy_32_32( L_shl( P_norm_fx[0], 3 ), diff_norm_order1_table[min( diff_norm_order1_fx, max( 0, sub( foa_ch, ndm ) ) )] ); // 2*q_P_re - 31
+ P_norm_fx[0] = Mpy_32_32( L_shl( P_norm_fx[0], 3 ), diff_norm_order1_table[s_min( diff_norm_order1_fx, s_max( 0, sub( foa_ch, ndm ) ) )] ); // 2*q_P_re - 31
move32();
P_norm_fx[1] = 0;
@@ -4357,7 +4359,7 @@ void ivas_get_spar_md_from_dirac_fx(
P_norm_fx[1] = L_add( P_norm_fx[1], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31
move32();
}
- P_norm_fx[1] = Mpy_32_32( L_shl( P_norm_fx[1], 3 ), diff_norm_order2_table[min( diff_norm_order2_fx, max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ) )] ); // 2*q_P_re - 31
+ P_norm_fx[1] = Mpy_32_32( L_shl( P_norm_fx[1], 3 ), diff_norm_order2_table[s_min( diff_norm_order2_fx, s_max( 0, ( s_min( num_ch, hoa2_ch ) - ndm ) ) )] ); // 2*q_P_re - 31
move32();
P_norm_fx[2] = 0;
@@ -4367,7 +4369,7 @@ void ivas_get_spar_md_from_dirac_fx(
P_norm_fx[2] = L_add( P_norm_fx[2], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31
move32();
}
- P_norm_fx[2] = Mpy_32_32( L_shl( P_norm_fx[2], 3 ), diff_norm_order3_table[min( diff_norm_order3_fx, max( 0, ( num_ch - ndm ) ) )] ); // 2*q_P_re - 31
+ P_norm_fx[2] = Mpy_32_32( L_shl( P_norm_fx[2], 3 ), diff_norm_order3_table[s_min( diff_norm_order3_fx, s_max( 0, ( num_ch - ndm ) ) )] ); // 2*q_P_re - 31
move32();
len = s_max( 0, sub( foa_ch, ndm ) );
FOR( i = 0; i < len; i++ ) // i < max( 0, ( foa_ch - ndm ) )
diff --git a/lib_com/ivas_spar_com_quant_util_fx.c b/lib_com/ivas_spar_com_quant_util_fx.c
index 7ea6feb059440e8f1f1f789fd492e140ad172bda..50820e240f241b69348a9e1d683e943dc218b542 100644
--- a/lib_com/ivas_spar_com_quant_util_fx.c
+++ b/lib_com/ivas_spar_com_quant_util_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -346,11 +346,11 @@ void ivas_map_prior_coeffs_quant(
{
ivas_quant_strat_t qs = pSpar_md_cfg->quant_strat[qsi];
ivas_quant_strat_t prev_qs = pSpar_md_cfg->quant_strat[pSpar_md_cfg->prev_quant_idx];
- Word32 one_by_q_lvl_PR_fx = one_by_q_level[max( ( prev_qs.PR.q_levels[0] - 1 ), 1 )]; /*q31*/
+ Word32 one_by_q_lvl_PR_fx = one_by_q_level[s_max( ( prev_qs.PR.q_levels[0] - 1 ), 1 )]; /*q31*/
move32();
- Word32 one_by_q_lvl_C_fx = one_by_q_level[max( ( prev_qs.C.q_levels[0] - 1 ), 1 )]; /*q31*/
+ Word32 one_by_q_lvl_C_fx = one_by_q_level[s_max( ( prev_qs.C.q_levels[0] - 1 ), 1 )]; /*q31*/
move32();
- Word32 one_by_q_lvl_P_r_fx = one_by_q_level[max( ( prev_qs.P_r.q_levels[0] - 1 ), 1 )]; /*q31*/
+ Word32 one_by_q_lvl_P_r_fx = one_by_q_level[s_max( ( prev_qs.P_r.q_levels[0] - 1 ), 1 )]; /*q31*/
move32();
FOR( i = 0; i < nB; i++ )
{
diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h
index 4b232ecc941c8323e6ef06578826f09fd5477c6b..d3737fa1924f76dc7eee101a09fc2c51a8fba7e7 100644
--- a/lib_com/ivas_stat_com.h
+++ b/lib_com/ivas_stat_com.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -655,16 +655,9 @@ typedef struct ivas_filters_process_state_t
Word16 filt_len;
Word32 num_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
Word32 den_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
-#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS
Word64 state_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
Word16 num_shr[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
Word16 den_shr[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
-#else
- Word32 state_fx[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
- Word16 num_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
- Word16 den_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
- Word16 state_e[IVAS_FILTER_MAX_STAGES][IVAS_BIQUAD_FILT_LEN];
-#endif
} ivas_filters_process_state_t;
diff --git a/lib_com/ivas_stereo_dft_com_fx.c b/lib_com/ivas_stereo_dft_com_fx.c
index a23b5b700f1ed6478798e6e4e063496d674013f2..c85ccf53f0b1160264330c4e42698402baa57996 100644
--- a/lib_com/ivas_stereo_dft_com_fx.c
+++ b/lib_com/ivas_stereo_dft_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_stereo_eclvq_com_fx.c b/lib_com/ivas_stereo_eclvq_com_fx.c
index 8328e220ff5eee94753aa6403ea2eb9f0a0a89f3..7d528f5b92207df25c3cc90272dd68e3eca57680 100644
--- a/lib_com/ivas_stereo_eclvq_com_fx.c
+++ b/lib_com/ivas_stereo_eclvq_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_stereo_ica_com_fx.c b/lib_com/ivas_stereo_ica_com_fx.c
index 8b5e1590867166e8952b4a399b722496e5183293..705c1756d66f540acf9149f56233e2443dc81a47 100644
--- a/lib_com/ivas_stereo_ica_com_fx.c
+++ b/lib_com/ivas_stereo_ica_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_stereo_mdct_bands_com_fx.c b/lib_com/ivas_stereo_mdct_bands_com_fx.c
index 43f2f16c7efc13d125717975cc63064027644d3d..09c9d94c2864b945083f67246737565163ffeea8 100644
--- a/lib_com/ivas_stereo_mdct_bands_com_fx.c
+++ b/lib_com/ivas_stereo_mdct_bands_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_stereo_mdct_stereo_com_fx.c b/lib_com/ivas_stereo_mdct_stereo_com_fx.c
index 0a773169d07313155482bed27f0613b1cccb7a40..02d141da2a5d4230507ab7a689789e366e16e52a 100644
--- a/lib_com/ivas_stereo_mdct_stereo_com_fx.c
+++ b/lib_com/ivas_stereo_mdct_stereo_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_stereo_psychlpc_com_fx.c b/lib_com/ivas_stereo_psychlpc_com_fx.c
index df514089560c440dde31ff103bf87fd0b1ff740f..3a130b8cbacc3e3c2070785ccf34bde94ba4d8af 100644
--- a/lib_com/ivas_stereo_psychlpc_com_fx.c
+++ b/lib_com/ivas_stereo_psychlpc_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_stereo_td_bit_alloc_fx.c b/lib_com/ivas_stereo_td_bit_alloc_fx.c
index 52933a5930a1461022e77deef6385f224ee83b2c..45dfb3110223d8c83886c107cec362b670a38c91 100644
--- a/lib_com/ivas_stereo_td_bit_alloc_fx.c
+++ b/lib_com/ivas_stereo_td_bit_alloc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c
index 8cf54ec921780dad935de1e0c6a9abf36a03d82b..fae273974686300a3f790b5aec60bb9435b39a8b 100644
--- a/lib_com/ivas_tools_fx.c
+++ b/lib_com/ivas_tools_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -160,6 +160,38 @@ UWord32 ivas_syn_output_fx(
* Convert an interleaved buffer of audio channels to deinterleaved one
*-------------------------------------------------------------------*/
+#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER
+void ivas_buffer_interleaved_to_deinterleaved_fx(
+ Word32 *audio_in, /* i : interleaved audio buffer */
+ Word32 *audio_out[], /* o : pointers to each channel of deinterleaved audio buffer */
+ const Word16 n_channels, /* i : number of channels */
+ const Word16 frame_length /* i : frame length (one channel) */
+)
+{
+ Word16 ch, s;
+ Word32 buffer[MAX_TRANSPORT_CHANNELS][MAX_JBM_L_FRAME48k]; /* temp buffer needed when "*audio_in" and "*audio_out[]" point to the same memory */
+
+ FOR( ch = 0; ch < n_channels; ch++ )
+ {
+ FOR( s = 0; s < frame_length; s++ )
+ {
+ buffer[ch][s] = audio_in[s * n_channels + ch];
+ move32();
+ }
+ }
+
+ FOR( ch = 0; ch < n_channels; ch++ )
+ {
+ FOR( s = 0; s < frame_length; s++ )
+ {
+ audio_out[ch][s] = buffer[ch][s];
+ move32();
+ }
+ }
+
+ return;
+}
+#else
void ivas_buffer_interleaved_to_deinterleaved_fx(
Word32 *audio, /* i/o: audio buffer */
const Word16 n_channels, /* i : number of channels */
@@ -189,6 +221,7 @@ void ivas_buffer_interleaved_to_deinterleaved_fx(
return;
}
+#endif
/*-------------------------------------------------------------------*
@@ -197,6 +230,38 @@ void ivas_buffer_interleaved_to_deinterleaved_fx(
* Convert a deinterleaved buffer of audio channels to interleaved one
*-------------------------------------------------------------------*/
+#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER
+void ivas_buffer_deinterleaved_to_interleaved_fx(
+ Word32 *audio_in[], /* i : pointers to each channel of deinterleaved audio buffer */
+ Word32 *audio_out, /* o : interleaved audio buffer */
+ const Word16 n_channels, /* i : number of channels */
+ const Word16 frame_length /* i : frame length (one channel) */
+)
+{
+ Word16 ch, s;
+ Word32 buffer[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; /* temp buffer needed when "*audio_in[]" and "*audio_out" point to the same memory */
+
+ FOR( ch = 0; ch < n_channels; ch++ )
+ {
+ FOR( s = 0; s < frame_length; s++ )
+ {
+ buffer[ch][s] = audio_in[ch][s];
+ move32();
+ }
+ }
+
+ FOR( ch = 0; ch < n_channels; ch++ )
+ {
+ FOR( s = 0; s < frame_length; s++ )
+ {
+ audio_out[s * n_channels + ch] = buffer[ch][s];
+ move32();
+ }
+ }
+
+ return;
+}
+#else
void ivas_buffer_deinterleaved_to_interleaved_fx(
Word32 *audio[], /* i/o: deinterleaved audio buffer */
const Word16 n_channels, /* i : number of channels */
@@ -224,6 +289,7 @@ void ivas_buffer_deinterleaved_to_interleaved_fx(
return;
}
+#endif
/*-------------------------------------------------------------------*
@@ -605,7 +671,7 @@ void v_mult_mat_fx(
pt_y++;
}
- MVR2R_WORD32( tmp_y, y, Nc ); /*Qx - guardbits*/
+ Copy32( tmp_y, y, Nc ); /*Qx - guardbits*/
}
diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c
index 9faba6131209544a1465175f89017dd7e3d4f8b4..ea3acdb9e5a981e966b0a2d3f5c83948603d57ff 100644
--- a/lib_com/ivas_transient_det_fx.c
+++ b/lib_com/ivas_transient_det_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -43,12 +43,8 @@
* Local constants
*------------------------------------------------------------------------------------------*/
-#define IVAS_TDET_PARM_ENV_EPS ( 1e-5f )
-#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS
+#define IVAS_TDET_PARM_ENV_EPS ( 1e-5f )
#define IVAS_TDET_PARM_ENV_EPS_fx ( ( (Word64) 21474 ) << 12 ) // Q11+32
-#else
-#define IVAS_TDET_PARM_ENV_EPS_fx 21474 // Q31
-#endif
#define IVAS_TDET_DUCK_MULT_FAC ( 590558003 ) // Q29
#define IVAS_TDET_PARM_TRANS_THR ( 107374182 ) // Q30
@@ -396,7 +392,6 @@ void ivas_td_decorr_get_ducking_gains_fx(
Word32 duck_mult_fac = hTranDet->duck_mult_fac; /*Q29*/
move32();
-#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS
Word64 e_fast_fx[L_FRAME48k], e_slow_fx[L_FRAME48k];
Word32 fast_fx, slow_fx;
Word16 fast_e, slow_e;
@@ -465,63 +460,6 @@ void ivas_td_decorr_get_ducking_gains_fx(
hTranDet->out_duck_gain = out_duck_gain; /*Q30*/
move32();
}
-#else
- Word32 e_fast_fx[L_FRAME48k], e_slow_fx[L_FRAME48k];
- Word16 e_fast_e[L_FRAME48k], e_slow_e[L_FRAME48k];
-
- Copy32( pIn_pcm, e_fast_fx, frame_len ); /*Q11*/
-
- set16_fx( e_fast_e, 31 - Q11, L_FRAME48k );
-
- /* env hpf */
- ivas_filter_process_exp_fx( &hTranDet->env_hpf, e_fast_fx, frame_len, e_fast_e );
-
-
- FOR( i = 0; i < frame_len; i++ )
- {
- // e_fast_fx[i] = L_add( L_abs( e_fast_fx[i] ), L_shr( IVAS_TDET_PARM_ENV_EPS_fx, q_factor_diff ) ); /*Q14*/
- e_fast_fx[i] = BASOP_Util_Add_Mant32Exp( L_abs( e_fast_fx[i] ), e_fast_e[i], IVAS_TDET_PARM_ENV_EPS_fx, 0, &e_fast_e[i] );
- move32();
- e_slow_fx[i] = e_fast_fx[i];
- move32();
- e_slow_e[i] = e_fast_e[i];
- move16();
- }
-
- /* env fast*/
- ivas_filter_process_exp_fx( &hTranDet->env_fast, e_fast_fx, frame_len, e_fast_e );
-
- /* env slow */
- ivas_filter_process_exp_fx( &hTranDet->env_slow, e_slow_fx, frame_len, e_slow_e );
-
- IF( tdet_flag )
- {
- FOR( i = 0; i < frame_len; i++ )
- {
- in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, e_slow_fx[i], e_slow_e[i], e_fast_fx[i], e_fast_e[i], duck_mult_fac ); /*Q30*/
- pIn_duck_gains[i] = in_duck_gain; /*Q30*/
- move32();
- }
- hTranDet->in_duck_gain = in_duck_gain; /*Q30*/
- move32();
- }
- ELSE
- {
- FOR( i = 0; i < frame_len; i++ )
- {
- in_duck_gain = ivas_calc_duck_gain_fx( in_duck_gain, in_duck_coeff, e_slow_fx[i], e_slow_e[i], e_fast_fx[i], e_fast_e[i], duck_mult_fac ); /*Q30*/
- pIn_duck_gains[i] = in_duck_gain; /*Q30*/
- move32();
- out_duck_gain = ivas_calc_duck_gain_fx( out_duck_gain, out_duck_coeff, e_fast_fx[i], e_fast_e[i], e_slow_fx[i], e_slow_e[i], duck_mult_fac ); /*Q30*/
- pOut_duck_gains[i] = out_duck_gain; /*Q30*/
- move32();
- }
- hTranDet->in_duck_gain = in_duck_gain; /*Q30*/
- move32();
- hTranDet->out_duck_gain = out_duck_gain; /*Q30*/
- move32();
- }
-#endif
return;
}
diff --git a/lib_com/lag_wind_fx.c b/lib_com/lag_wind_fx.c
index 3685cb834bc4ccf47e38ba6b5662c9919fc3158e..a83b90b9be26cf4ab7fc2486e73be09a577e14de 100644
--- a/lib_com/lag_wind_fx.c
+++ b/lib_com/lag_wind_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/lerp_fx.c b/lib_com/lerp_fx.c
index 632593c6f10283a4c907e77b595b9f68ef8b094b..2015a074cb9a9f7e44701d29a8cbef995b55dd19 100644
--- a/lib_com/lerp_fx.c
+++ b/lib_com/lerp_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/log2.c b/lib_com/log2.c
index 42b1f1b3daf82918abff7e2568a1888b02ea57d2..6f398df1e66c198ca82f8208c0e496ce788fabd6 100644
--- a/lib_com/log2.c
+++ b/lib_com/log2.c
@@ -57,21 +57,18 @@ Word16 Log2_norm_lc( /* (o) : Fractional part of Log2. (range: 0<=val
{
Word16 i, a;
Word16 y;
-#ifndef FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC
- if ( L_x <= 0 )
- L_x = L_deposit_h( 0x4000 );
-#else
if ( L_x > 0 ) /* There are many cases in the code where L_x == 0 */
assert( L_x >= 0x40000000 ); /* If assert fail, means input is not normalized as it should be */
L_x = L_max( L_x, 0x40000000 );
-#endif
L_x = L_shr( L_x, 9 );
a = extract_l( L_x ); /* Extract b10-b24 of fraction */
a = lshr( a, 1 );
i = mac_r( L_x, -32 * 2 - 1, 16384 ); /* Extract b25-b31 minus 32 */
+ assert( ( i >= 0 ) && ( i < (Word16) ( sizeof( L_table_Log2_norm_lc ) / sizeof( L_table_Log2_norm_lc[0] ) ) ) && ( i < (Word16) ( sizeof( table_diff_Log2_norm_lc ) / sizeof( table_diff_Log2_norm_lc[0] ) ) ) );
+
y = mac_r( L_table_Log2_norm_lc[i], table_diff_Log2_norm_lc[i], a ); /* table[i] << 16 - diff*a*2 */
return y;
@@ -80,6 +77,7 @@ Word16 Log2_norm_lc( /* (o) : Fractional part of Log2. (range: 0<=val
Word32 log10_fx( Word32 Linput ) /*o : Q23, i: 2Q13*/
{
Word16 n1, frac, p1, p2, q1;
+ Word16 idx;
Word32 Ltemp1, Ltemp2;
Word32 L_tmp;
@@ -94,10 +92,16 @@ Word32 log10_fx( Word32 Linput ) /*o : Q23, i: 2Q13*/
Ltemp2 = L_mult( extract_h( Ltemp1 ), 0x40 );
frac = extract_l( Ltemp2 );
- p1 = log2_tab[sub( extract_h( Ltemp2 ), 0x20 )];
+ idx = sub( extract_h( Ltemp2 ), 0x20 );
+ assert( idx >= 0 && idx < (Word16) ( sizeof( log2_tab ) / sizeof( log2_tab[0] ) ) );
+ p1 = log2_tab[idx];
move16();
- p2 = log2_tab[sub( extract_h( Ltemp2 ), 0x1F )];
+
+ idx = sub( extract_h( Ltemp2 ), 0x1F );
+ assert( idx >= 0 && idx < (Word16) ( sizeof( log2_tab ) / sizeof( log2_tab[0] ) ) );
+ p2 = log2_tab[idx];
move16();
+
Ltemp2 = L_mult( n1, 0x200 );
n1 = extract_l( Ltemp2 );
diff --git a/lib_com/logqnorm_fx.c b/lib_com/logqnorm_fx.c
index 70def05ae3d9d619068f6d59571981ead938e3de..4b096ac35a52c814559eca58cea6e97a66976fe3 100644
--- a/lib_com/logqnorm_fx.c
+++ b/lib_com/logqnorm_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/longarith.c b/lib_com/longarith.c
index a922c2b4a0afe55f50a81cc7c5d65ff43c74fcf5..193c358cb5808f579aa0237862c8b88408cb2ab1 100644
--- a/lib_com/longarith.c
+++ b/lib_com/longarith.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/lpc_tools_fx.c b/lib_com/lpc_tools_fx.c
index bb4cec6c21ea2cd1ef3a766595019c800d514b75..5b3b8a1c0b990019220f3b27a10a45a8ad7faedc 100644
--- a/lib_com/lpc_tools_fx.c
+++ b/lib_com/lpc_tools_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c
index e4dbd7e2a9530e465ca94197dd625124167ee4ae..c1638a26948fbcd99d94666bdf1e153c29d409dc 100644
--- a/lib_com/lsf_tools_fx.c
+++ b/lib_com/lsf_tools_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -2963,90 +2963,6 @@ void lsf_syn_mem_backup_fx(
}
-/*-------------------------------------------------------------------*
- * lsf_syn_mem_backup_fx()
- *
- *
- *--------------------------------------------------------------------*/
-
-void lsf_syn_mem_backup_ivas_fx(
- Encoder_State *st_fx, /* i: state structure */
- Word16 *btilt_code_fx, /* i: tilt code Q15 */
- Word32 *gc_threshold_fx, /* i: Q16 */
- Word16 *clip_var_bck_fx, /* o: Q(2.56), Q14, Q7, Q0, Q14, Q14 */
- Word16 *next_force_sf_bck_fx, /* o: */
- Word16 *lsp_new, /* i: LSP vector to quantize Q15 */
- Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */
- Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */
- Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */
- Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */
- Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */
- Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */
- Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */
- Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */
- Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */
- Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */
- Word16 *streaklimit, /* Q15 */
- Word16 *pstreaklen )
-{
- Word16 i;
- LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
-
- *clip_var = st_fx->clip_var_fx[0];
- move16();
-
- FOR( i = 0; i < M; i++ )
- {
- mem_AR[i] = st_fx->mem_AR_fx[i]; // Q2.56
- move16();
- mem_MA[i] = st_fx->mem_MA_fx[i]; // Q2.56
- move16();
- lsp_new_bck[i] = lsp_new[i]; // Q15
- move16();
- lsp_mid_bck[i] = lsp_mid[i]; // Q15
- move16();
- }
-
- *streaklimit = st_fx->streaklimit_fx; // Q15
- move16();
- *pstreaklen = st_fx->pstreaklen;
- move16();
-
- FOR( i = 0; i < L_FFT; i++ )
- {
- Bin_E[i] = st_fx->Bin_E_fx[i]; // Q_new + Q_SCALE - 2
- move32();
- }
-
- FOR( i = 0; i < ( L_FFT / 2 ); i++ )
- {
- Bin_E_old[i] = st_fx->Bin_E_old_fx[i]; // Q_new + Q_SCALE - 2
- move32();
- }
-
- /* back-up memories */
- FOR( i = 0; i < M; i++ )
- {
- mem_syn_bck[i] = hLPDmem->mem_syn[i]; // Q( st_fx->hLPDmem->q_mem_syn )
- move16();
- }
-
- *mem_w0_bck = hLPDmem->mem_w0; // Q( st_fx->hLPDmem->q_mem_syn )
- move16();
-
-
- *btilt_code_fx = hLPDmem->tilt_code; // Q15
- move16();
- *gc_threshold_fx = hLPDmem->gc_threshold; // Q16
- move16();
- Copy( st_fx->clip_var_fx, clip_var_bck_fx, 6 );
- *next_force_sf_bck_fx = st_fx->next_force_safety_net;
- move16();
-
-
- return;
-}
-
void lsf_update_memory(
Word16 narrowband, /* i : narrowband flag */
const Word16 qlsf[], /* i : quantized lsf coefficients */
@@ -3190,83 +3106,6 @@ void lsf_syn_mem_restore_fx(
return;
}
-void lsf_syn_mem_restore_ivas_fx(
- Encoder_State *st_fx, /* o: state structure */
- Word16 btilt_code_fx, /* i: Q15 */
- Word32 gc_threshold_fx, /* i: Q16 */
- Word16 *clip_var_bck_fx, /* i: Q(2.56), Q14, Q7, Q0, Q14, Q14 */
- Word16 next_force_sf_bck_fx, /* i: */
- Word16 *lsp_new, /* o: LSP vector to quantize Q15 */
- Word16 *lsp_mid, /* o: mid-frame LSP vector Q15 */
- Word16 clip_var, /* i: pitch clipping state var Q(2.56), Q14, Q7, Q0, Q14, Q14 */
- Word16 *mem_AR, /* i: quantizer memory for AR model 2.56 */
- Word16 *mem_MA, /* i: quantizer memory for MA model 2.56 */
- Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup Q15 */
- Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup Q15 */
- Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */
- Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */
- Word16 *mem_syn_bck, /* i: synthesis filter memory Q(15 - st_fx->hLPDmem->e_mem_syn ) */
- Word16 mem_w0_bck, /* i: memory of the weighting filter Q(15 - st_fx->hLPDmem->e_mem_syn ) */
- Word16 streaklimit, /* i:LSF quantizer Q15 */
- Word16 pstreaklen /* i:LSF quantizer */
-)
-{
- Word16 i;
- LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
-
- /* restore lsf memories */
- st_fx->clip_var_fx[0] = clip_var;
- move16();
-
- FOR( i = 0; i < M; i++ )
- {
- st_fx->mem_AR_fx[i] = mem_AR[i]; // 2.56
- move16();
- st_fx->mem_MA_fx[i] = mem_MA[i]; // 2.56
- move16();
- lsp_new[i] = lsp_new_bck[i]; // Q15
- move16();
- lsp_mid[i] = lsp_mid_bck[i]; // Q15
- move16();
- }
-
- st_fx->streaklimit_fx = streaklimit; // Q15
- move16();
- st_fx->pstreaklen = pstreaklen;
- move16();
-
- FOR( i = 0; i < L_FFT; i++ )
- {
- st_fx->Bin_E_fx[i] = Bin_E[i]; // Q_new + Q_SCALE - 2
- move16();
- }
-
- FOR( i = 0; i < ( L_FFT / 2 ); i++ )
- {
- st_fx->Bin_E_old_fx[i] = Bin_E_old[i]; // Q_new + Q_SCALE - 2
- move32();
- }
-
- /* restoring memories */
- hLPDmem->mem_w0 = mem_w0_bck; // Q( st_fx->hLPDmem->q_mem_syn )
- move16();
-
- FOR( i = 0; i < M; i++ )
- {
- hLPDmem->mem_syn[i] = mem_syn_bck[i]; // Q( st_fx->hLPDmem->q_mem_syn )
- move16();
- }
-
- move16();
- hLPDmem->tilt_code = btilt_code_fx; // Q15
- move32();
- hLPDmem->gc_threshold = gc_threshold_fx; // Q16
- Copy( clip_var_bck_fx, st_fx->clip_var_fx, 6 );
- st_fx->next_force_safety_net = next_force_sf_bck_fx;
- move16();
-
- return;
-}
/* Returns: codebook index */
Word16 tcxlpc_get_cdk(
diff --git a/lib_com/mime.h b/lib_com/mime.h
index 7d21f6aac0c182941a2df91c96dc617ff4234b8e..803e54cb0f96738d813f1e5975b4a28a43bbe5ba 100644
--- a/lib_com/mime.h
+++ b/lib_com/mime.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/modif_fs_fx.c b/lib_com/modif_fs_fx.c
index 9420d652307724fb98cc908441fc2e0b61a7e91e..97f4ef4135ba2434827ea79755800456d90043c7 100644
--- a/lib_com/modif_fs_fx.c
+++ b/lib_com/modif_fs_fx.c
@@ -168,7 +168,6 @@ Word16 modify_Fs_ivas_fx( /* o : length of output Q
{
autocorr_fx( signal_ana_fx + mem_len_ana + lg - LEN_WIN_SSS, 1, r_fx_h, r_fx_l, &Q_r, LEN_WIN_SSS, wind_sss_fx, 0, 0 );
-
t1 = L_Comp( r_fx_h[1], r_fx_l[1] ); /* R[1] in Q31 */
t2 = L_abs( t1 ); /* abs R[1] */
t0 = L_deposit_l( 0 );
@@ -181,12 +180,10 @@ Word16 modify_Fs_ivas_fx( /* o : length of output Q
t0 = L_negate( t0 ); /* R[1]/R[0] */
}
-
mu_preemph_fx = extract_h( t0 ); /*r_fx[1] / r_fx[0]; */
mem_preemph_fx = signal_ana_fx[mem_len_ana + lg - LEN_WIN_SSS - 1];
move16();
- PREEMPH_FX( signal_ana_fx + mem_len_ana + lg - LEN_WIN_SSS, mu_preemph_fx, LEN_WIN_SSS, &mem_preemph_fx );
-
+ preemph_fx( signal_ana_fx + mem_len_ana + lg - LEN_WIN_SSS, mu_preemph_fx, LEN_WIN_SSS, &mem_preemph_fx );
/* Autocorrelations */
autocorr_fx( signal_ana_fx + mem_len_ana + lg - LEN_WIN_SSS, M, r_fx_h, r_fx_l, &Q_r,
@@ -449,7 +446,6 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
{
autocorr_fx( signal_ana_fx + sub( add( mem_len_ana, lg ), LEN_WIN_SSS ), 1, r_fx_h, r_fx_l, &Q_r, LEN_WIN_SSS, wind_sss_fx, 0, 0 );
-
t1 = L_Comp( r_fx_h[1], r_fx_l[1] ); /* R[1] in Q31 */
t2 = L_abs( t1 ); /* abs R[1] */
t0 = L_deposit_l( 0 );
@@ -462,12 +458,10 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */
t0 = L_negate( t0 ); /* R[1]/R[0] */
}
-
mu_preemph_fx = extract_h( t0 ); /*r_fx[1] / r_fx[0]; */
mem_preemph_fx = signal_ana_fx[mem_len_ana + lg - LEN_WIN_SSS - 1];
move16();
- PREEMPH_FX( signal_ana_fx + sub( add( mem_len_ana, lg ), LEN_WIN_SSS ), mu_preemph_fx, LEN_WIN_SSS, &mem_preemph_fx );
-
+ preemph_fx( signal_ana_fx + sub( add( mem_len_ana, lg ), LEN_WIN_SSS ), mu_preemph_fx, LEN_WIN_SSS, &mem_preemph_fx );
/* Autocorrelations */
autocorr_fx( signal_ana_fx + sub( add( mem_len_ana, lg ), LEN_WIN_SSS ), M, r_fx_h, r_fx_l, &Q_r,
diff --git a/lib_com/mslvq_com_fx.c b/lib_com/mslvq_com_fx.c
index bbca861591070cc59549d592ad221314cc7ebfd9..956f87251ad66b0f988ddb344df30c2a8a6a52a4 100644
--- a/lib_com/mslvq_com_fx.c
+++ b/lib_com/mslvq_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/nelp_fx.c b/lib_com/nelp_fx.c
index 39d57299e7dad568f0bf2d5c65e1f454d250f127..03b80f7ded5afa86d2613cc93a55e9f030d636f7 100644
--- a/lib_com/nelp_fx.c
+++ b/lib_com/nelp_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/options.h b/lib_com/options.h
index 3e6e9f1cb209d362b1242b0b48a548c30659bf1f..409a53692d6b0625bb508b636e59a587fbfe82e0 100644
--- a/lib_com/options.h
+++ b/lib_com/options.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -75,7 +75,6 @@
/*#define DISABLE_LIMITER*/
/* ################### Start MAINTENANCE switches ########################### */
-#define FIX_2255_ISAR_RENDER_POSES /* VA: issue 2255: fix missing check in isar_render_poses() */
/* ################### Start BE switches ################################# */
/* only BE switches wrt wrt. TS 26.251 V3.0 */
@@ -85,21 +84,44 @@
#define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/
#define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */
#define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */
-#define FIX_1435_MOVE_STEREO_PANNING /* VA: issue 1435: do the EVS stereo panning in the renderer */
-#define FIX_2252_SCALING_SAVE_HB_SYNTH /* VA: issue 2252: fix use-of-uninit-value in save_hb_synth_fx[] scaling in FOA decoding with bitstream that starts with an SID */
-#define FIX_2248_EVS_ASSERT /* VA: Include _sat in an EVS related part of the code */
-#define FIX_2254_IMPROV_COMPLEXITY_BE /* VA: BE small complexity reduction */
+#define FIX_2255_ISAR_RENDER_POSES /* VA: issue 2255: fix missing check in isar_render_poses() */
+#define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */
+#define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */
+#define FIX_BASOP_2358_SCALING_OOB /* Eri: Basip issue 2358: Clang-18 reports OOB access where scaling is applied to L_FRAME48k instead of output_frame */
+#define FIX_BASOP_2350_HARM_0B_BWE_2 /* VA: basop issue 2350: Simplify calling of hf_synth_fx() */
+#define FIX_2364_HARM_MULT_HARM /* VA: basop issue 2364 : harmonizing multi_harm_fx function */
+#define FIX_2363_FIND_WSP /* VA: basop issue 2363 : harmonizing find_wsp function */
+#define FIX_2370_UNUSED_BUFFERS_CORE_ENC /* VA: basop issue 2370: remove temporary input buffers in core-encoder */
+#define FIX_2376_FIX_USAN_PRE_PROC /* VA: basop issue 2376: Resolve "USAN: SEGV in ivas_compute_core_buffers_fx() */
+#define FIX_2367_REMOVE_CODE_ICBWE /* VA: basop issue 2367: Remove IC-BWE obsolete code */
+#define REMOVE_SCALING_SHB_SPEECH /* VA: remove unnecessary scaling and 32-bit buffers from ivas_core_enc_fx() */
+#define FIX_2352_COPY_AQ_IN_TCX /* FhG: basop issue 2352: prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX */
+#define FIX_2353_PTR_INIT /* FhG: basop issue 2353: initialize prm_sqQ-pointer, to prevent being uninitialized in case of bfi == 1 */
+#define FIX_2356_GET_CHAN_ENERGIES /* FhG: basop issue 2356: correctly initialize exponents in getChannelEnergies_fx() */
+#define FIX_2355_IGF_EXP_POWERSPEC /* FhG: basop issue 2355: make sure exp_pPowerSpectrumParameter_fx is initialized in all cases */
+#define FIX_2319_CLDFB_INIT_FLAGS /* FhG: basop issue 2319: init hs->flags during openCldfb(), to avoid reading of uninitialized memory */
+#define FIX_BASOP_2357_OBJECT_EDIT_MSAN /* Nokia: basop issue 2357: initialize missing exponents in object edit */
+#define FIX_BASOP_2354_MSAN_DIFF_Q_VALUE /* Nokia: Initialize Q value of diffuseness in rendering to Q30 */
+#define FIX_2371_REMOVE_UNUSED_ISAR_FCNS /* Dolby: basop issue 2371: remove unused ISAR-related functions */
+#define FIX_2384_INIT_DEQUANT_COV /* FhG: basop issue 2384: only read initialized values from Cy_buf_e[k] in ivas_param_mc_dequantize_cov_fx() during renormalization */
+#define FIX_2383_INIT_Q_A_ITF /* FhG: Initialize Q_A_itf, to avoid reading of uninitialized memory in case ITF is not triggered */
+#define FIX_2382_COPY_AQ_IN_MCT /* FhG: basop issue 2382: 2nd instance of prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX */
+#define FIX_2391_INIT_HQ_GENERIC_OFFSET /* FhG/Eri: basop issue 2391: make sure hq_generic_offset is initialized inside hq_hr_dec_fx() */
+#define FIX_2397_COPY_AQ_MDCT_CORE_BFI /* FhG: prevent copying of uninit memory in MDCT stereo core if bfi is set */
+#define HARMONIZE_TBE /* VA: harmonize core-coder TBE function duplications */
/* #################### End BE switches ################################## */
/* #################### Start NON-BE switches ############################ */
/* any switch which is non-be wrt. TS 26.251 V3.0 */
-#define FIX_1454_FIX_STEREO_TO_FOA_JBM /* VA: issue 1454: fix buggy stereo to FOA in JBM */
-#define FIX_1461_CNG_BW_SWITCHING /* Eri: float issue 1461: Stereo parameters are not updated when SID/NODATA forces BW to stay the same */
-#define FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES /* FhG: Using rounding in multiplication to improve precision in cngNoiseLevel[] */
-#define FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC /* VA: Fix issue 2264 by adding a proper safeguard in log2 and by adding a missing normalization in swb_pre_proc_ivas_fx()*/
#define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */
+#define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */
+#define FIX_BASOP_2317_UNINIT_VALUE_IN_STEREO_CNG /* Eri: Basop issue 2317: Uninitialized value read in case of DTX and BW switching */
+#define FIX_BASOP_2361_OTR /* FhG: Basop issue 2361: Orientation tracking tests for equivalent rotations fail */
+#define FIX_1283_STEREO_DFT_COLLAPSE /* FhG: float issue 1283: fix for critical issue with DFT stereo core coder */
+#define FIX_2379_REMOVE_previoussynth_fx_32 /* VA: basop issue 2379: remove duplicated buffer st->previoussynth_fx_32[] */
+#define FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER /* FhG/VA: basop issue 2396: keep TC channel pointers in one constant place during decoding and rendering */
#define FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE /* VA: Precision improvement without increasing complexity, or complexity reduction that might be not BE on the LSB */
#define FIX_2252_LP_CNG_STARTS_SID /* VA: issues 2251 and 2252: fix LP CNG uninitialized value in bitstream that starts with an SID */
#define FIX_2283_ISM_MD_DELAY /* Dolby: Fix ISM metadata delay round-off */
@@ -110,16 +132,4 @@
/* clang-format on */
-/* #################### Start BASOP optimization switches ############################ */
-
-#define OPT_2181_MATRIX_TRANSP_1_MUL /* Dolby: Issue 2181, optimize matrixTransp1Mul_fx. */
-#define OPT_2182_MATRIX_SCALE_OPS /* Dolby: Issue 2181, move matrix scale operations outside mul operations. */
-#define OPT_2185_MATRIX_OUT_SCALING /* Dolby: Issue 2185, optimize matrix-mul output-format. */
-#define NONBE_OPT_2239_IVAS_FILTER_PROCESS /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */
-#define NONBE_OPT_2193_EIG2X2 /* Dolby: Issue 2193, optimize eig2x2_fx. */
-#define BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* FhG: Speeds up covariance calculation e.g. 60 WMOPS for encoding -mc 7_1_4 24400 48 */
-
-/* #################### End BASOP optimization switches ############################ */
-
-
#endif
diff --git a/lib_com/parameter_bitmaping_fx.c b/lib_com/parameter_bitmaping_fx.c
index 92387209012c8cd2dfd7a6bacdb30ab3903715ad..4225879e6b20e56584e35c4bc40240cfc0112337 100644
--- a/lib_com/parameter_bitmaping_fx.c
+++ b/lib_com/parameter_bitmaping_fx.c
@@ -25,24 +25,6 @@ static Word16 PutIntoBitstream_fx(
return value;
}
-static Word16 PutIntoBitstream_ivas_fx(
- const Word16 **pStream,
- TEncodeValue EncodeValue,
- Word16 index,
- BSTR_ENC_HANDLE hBstr,
- const Word16 nBits )
-{
- Word16 value;
- Word16 codedValue;
-
- move16();
- value = *( *pStream )++;
- codedValue = EncodeValue( value, index );
-
- push_next_indice( hBstr, codedValue, nBits );
-
- return value;
-}
static Word16 FixedWidthEncoding( Word16 value, Word16 index )
{
@@ -252,6 +234,8 @@ void SetParameters_fx(
}
}
}
+
+ return;
}
@@ -266,13 +250,11 @@ void WriteToBitstream_fx(
Word16 index;
Word16 iParam, nParams;
-
assert( ( paramsBitMap != NULL ) && ( nArrayLength > 0 ) && ( pStream != NULL ) && ( pnSize != NULL ) && ( hBstr != NULL ) && ( pnBits != NULL ) );
nParams = paramsBitMap->nParams;
FOR( index = 0; index < nArrayLength; index++ )
{
-
FOR( iParam = 0; iParam < nParams; iParam++ )
{
ParamBitMap const *param;
@@ -321,75 +303,11 @@ void WriteToBitstream_fx(
}
}
}
-}
-void WriteToBitstream_ivas_fx(
- ParamsBitMap const *paramsBitMap,
- const Word16 nArrayLength,
- const Word16 **pStream,
- Word16 *pnSize,
- BSTR_ENC_HANDLE hBstr,
- Word16 *pnBits )
-{
- Word16 index;
- Word16 iParam, nParams;
-
-
- assert( ( paramsBitMap != NULL ) && ( nArrayLength > 0 ) && ( pStream != NULL ) && ( pnSize != NULL ) && ( hBstr != NULL ) && ( pnBits != NULL ) );
- nParams = paramsBitMap->nParams;
- move16();
-
- FOR( index = 0; index < nArrayLength; index++ )
- {
- FOR( iParam = 0; iParam < nParams; iParam++ )
- {
- ParamBitMap const *param;
- Word16 nBits;
- /* If a function for encoding/decoding value is defined than it should take care of 0 */
- Word16 fShiftValue;
- TEncodeValue EncodeValue;
- Word16 value;
-
- move16();
- param = ¶msBitMap->params[iParam];
-
- move16();
- nBits = param->nBits;
- IF( param->nBits == 0 )
- {
-#define WMC_TOOL_SKIP
- nBits = param->GetNumberOfBits( **pStream, index );
-#undef WMC_TOOL_SKIP
- }
-
- fShiftValue = s_and( param->fZeroAllowed == 0, param->EncodeValue == NULL );
-
- EncodeValue = param->EncodeValue;
- if ( param->EncodeValue == NULL )
- {
- move16();
- EncodeValue = &FixedWidthEncoding;
- }
- value = PutIntoBitstream_ivas_fx( pStream, EncodeValue, index, hBstr, nBits );
- IF( fShiftValue )
- {
- value = add( value, 1 );
- }
-
- move16();
- *pnSize = add( *pnSize, 1 );
- move16();
- *pnBits = add( *pnBits, nBits );
-
- test();
- IF( ( param->pSubParamBitMap != NULL ) && ( value > 0 ) )
- {
- WriteToBitstream_ivas_fx( param->pSubParamBitMap, value, pStream, pnSize, hBstr, pnBits );
- }
- }
- }
+ return;
}
+
/** Get nBits long value from bitstream into *pStream. */
static Word16 GetFromBitstream(
Decoder_State *st,
@@ -457,6 +375,9 @@ void ReadFromBitstream_fx(
}
}
}
+
move16();
*pnSize = add( *pnSize, i_mult( nParams, nArrayLength ) );
+
+ return;
}
diff --git a/lib_com/ppp_fx.c b/lib_com/ppp_fx.c
index 2f44e1081feb6c81b81d336b92bfe37b088fb00d..12a35b39371dd7e1eb8a155d802b21215ef544ab 100644
--- a/lib_com/ppp_fx.c
+++ b/lib_com/ppp_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/pred_lt4_fx.c b/lib_com/pred_lt4_fx.c
index 591eab841154b0b58b1235137d15a53e96409374..b04456870275c50cc5f02f259d093d6f1c991319 100644
--- a/lib_com/pred_lt4_fx.c
+++ b/lib_com/pred_lt4_fx.c
@@ -58,13 +58,8 @@ void pred_lt4_ivas_fx(
FOR( i = 0; i < nb_coef; i++ )
{
/*s += (*x1--) * (*c1) + (*x2++) * (*c2);*/
-#ifdef FIX_2254_IMPROV_COMPLEXITY_BE
s64 = W_mac_32_16( s64, ( *c1 ), *x1-- ); /* Q_exc + Q32 */
s64 = W_mac_32_16( s64, ( *c2 ), *x2++ ); /* Q_exc + Q32 */
-#else
- s64 = W_mac_32_32( s64, L_deposit_l( *x1-- ), ( *c1 ) ); /* Q_exc + Q32 */
- s64 = W_mac_32_32( s64, L_deposit_l( *x2++ ), ( *c2 ) ); /* Q_exc + Q32 */
-#endif
c1 += up_sample;
c2 += up_sample;
}
diff --git a/lib_com/preemph_fx.c b/lib_com/preemph_fx.c
index 9631c68596fe1934049cd1badd965b0801156e87..46c8ccc36b531cab8b599c1b576afde3c3b97a33 100644
--- a/lib_com/preemph_fx.c
+++ b/lib_com/preemph_fx.c
@@ -8,11 +8,44 @@
#include "wmc_auto.h"
/*-------------------------------------------------------------*
- * preemph_copy_fx()
+ * preemph_fx()
*
* Preemphasis: filtering through 1 - mu z^-1
*-------------------------------------------------------------*/
+void preemph_fx(
+ Word16 x[], /* i/o: input/output signal Qx */
+ const Word16 mu, /* i : preemphasis coefficient Q15 */
+ const Word16 lg, /* i : vector size Q0 */
+ Word16 *mem /* i/o: memory (x[-1]) Qx */
+)
+{
+ Word16 i, temp;
+
+ temp = x[lg - 1]; /* Qx */
+ move16();
+
+ FOR( i = lg - 1; i > 0; i-- )
+ {
+ x[i] = msu_r_sat( L_deposit_h( x[i] ), x[i - 1], mu ); /* Qx */
+ move16();
+ }
+
+ x[0] = msu_r_sat( L_deposit_h( x[0] ), *mem, mu ); /* Qx */
+ move16();
+
+ *mem = temp; /* Qx */
+ move16();
+
+ return;
+}
+
+/*-------------------------------------------------------------*
+ * preemph_copy_fx()
+ *
+ * Preemphasis + copy: filtering through 1 - mu z^-1
+ *-------------------------------------------------------------*/
+
void preemph_copy_fx(
const Word16 x[], /* i : input signal Qx */
Word16 y[], /* o : output signal Qx */
diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h
index bba113ec0430e25ac92fbab05b02909dd86356f7..c45c2a7490d98886919391ee55e3dcb80560eff0 100644
--- a/lib_com/prot_fx.h
+++ b/lib_com/prot_fx.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -33,13 +33,6 @@
#ifndef PROT_FX2_H
#define PROT_FX2_H
-/*----------------------------------------------------------------------------------*
- * Prototypes of RAM counting tool macros
- *----------------------------------------------------------------------------------*/
-
-#define MVR2R_WORD32( x, y, n ) Copy32( x, y, n )
-#define MVR2R_WORD16( x, y, n ) Copy( x, y, n )
-
#include
#include
#include
@@ -59,36 +52,19 @@
#include "complex_basop.h"
-#define TCX_IMDCT_SCALE 15
-#define TCX_IMDCT_HEADROOM 1
-
-
/*----------------------------------------------------------------------------------*
* Prototypes of global macros
*----------------------------------------------------------------------------------*/
-#ifndef min
-#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) )
-#endif
-
-#ifndef max
-#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) )
-#endif
-
-#ifndef ABSVAL
-#define ABSVAL( a ) ( ( a ) >= 0 ? ( a ) : ( -( a ) ) )
-#endif
-
-#ifndef SQR
-#define SQR( a ) ( ( a ) * ( a ) )
-#endif
-
#ifndef SWAP
#define SWAP( a, b ) \
{ \
tempr = ( a ); \
( a ) = ( b ); \
( b ) = tempr; \
+ move32(); \
+ move32(); \
+ move32(); \
}
#endif
@@ -99,6 +75,9 @@
u__p = x; \
x = y; \
y = u__p; \
+ move32(); \
+ move32(); \
+ move32(); \
}
#endif
@@ -927,27 +906,6 @@ void lsf_syn_mem_restore_fx(
Word16 pstreaklen /* i:LSF quantizer */
);
-void lsf_syn_mem_restore_ivas_fx(
- Encoder_State *st_fx, /* o: state structure */
- Word16 btilt_code_fx, /* i: Q15 */
- Word32 gc_threshold_fx, /* i: Q16 */
- Word16 *clip_var_bck_fx, /* i: Q(2.56), Q14, Q7, Q0, Q14, Q14 */
- Word16 next_force_sf_bck_fx, /* i: */
- Word16 *lsp_new, /* o: LSP vector to quantize Q15 */
- Word16 *lsp_mid, /* o: mid-frame LSP vector Q15 */
- Word16 clip_var, /* i: pitch clipping state var Q(2.56), Q14, Q7, Q0, Q14, Q14 */
- Word16 *mem_AR, /* i: quantizer memory for AR model 2.56 */
- Word16 *mem_MA, /* i: quantizer memory for MA model 2.56 */
- Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup Q15 */
- Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup Q15 */
- Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */
- Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */
- Word16 *mem_syn_bck, /* i: synthesis filter memory Q(15 - st_fx->hLPDmem->e_mem_syn ) */
- Word16 mem_w0_bck, /* i: memory of the weighting filter Q(15 - st_fx->hLPDmem->e_mem_syn ) */
- Word16 streaklimit, /* i:LSF quantizer Q15 */
- Word16 pstreaklen /* i:LSF quantizer */
-);
-
void lsf_update_memory(
Word16 narrowband, /* i : narrowband flag */
const Word16 qisf[], /* i : quantized xSF coefficients */
@@ -1546,28 +1504,8 @@ Word16 gsc_gaindec_fx(
const Word16 bwidth_fx /* i : i signal bandwidth */
);
-/*! r: average frequency gain */
-Word16 gsc_gaindec_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- Word16 y_gainQ_fx[], /* o : quantized gain per band */
- const Word32 core_brate_fx, /* i : core used */
- Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */
- const Word16 coder_type, /* i : coding type */
- const Word16 bwidth_fx /* i : input signal bandwidth */
-);
-
Word16 gsc_gainQ_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const Word16 y_gain4[], /* i : Energy per band Q13 */
- Word16 y_gainQ[], /* o : quantized energy per band Q13 */
- const Word32 core_brate, /* i : Core rate */
- const Word16 coder_type, /* i : coding type */
- const Word16 bwidth /* i : signal bandwidth */
-);
-
-Word16 gsc_gainQ_ivas_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 element_mode, /* i : element mode */
const Word16 idchan, /* i : channel ID */
const Word16 y_gain4[], /* i : Energy per band Q12 */
Word16 y_gainQ[], /* o : quantized energy per band Q12 */
@@ -1669,16 +1607,6 @@ void int_lsp4_fx(
Word16 relax_prev_lsf_interp /* i : relax prev frame lsf interp after erasure */
);
-void int_lsp4_ivas_fx(
- const Word16 L_frame, /* i : length of the frame */
- const Word16 lsp_old[], /* i : LSPs from past frame Q15*/
- const Word16 lsp_mid[], /* i : LSPs from mid-frame Q15*/
- const Word16 lsp_new[], /* i : LSPs from present frame Q15*/
- Word16 *Aq, /* o : LP coefficients in both subframes Q12*/
- const Word16 m, /* i : order of LP filter */
- Word16 relax_prev_lsf_interp /* i : relax prev frame lsf interp after erasure */
-);
-
void de_interleave_spectrum_fx(
Word32 *coefs, /* i/o: i and output coefficients Q? */
const Word16 length /* i : length of spectrum Q0 */
@@ -1758,7 +1686,13 @@ void Ener_per_band_comp_fx(
Word16 y_gain4[], /* o : Energy per band to quantize Q12 */
const Word16 Q_exc_diff,
const Word16 Mband, /* i : Max band */
- const Word16 Eflag );
+#ifdef FIX_1904_HARM_GSC_ENC
+ const Word16 Eflag,
+ const Word16 L_frame /* i : frame length */
+#else
+ const Word16 Eflag
+#endif
+);
void Ener_per_band_comp_ivas_fx(
const Word16 exc_diff_fx[], /* i : target signal Q_exc_diff */
@@ -1777,7 +1711,7 @@ void Comp_and_apply_gain_fx(
const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */
Word16 Qexc_diff,
Word16 Q_exc );
-
+#ifndef FIX_2338_HARM_GSC_GAIN_COMP
void Comp_and_apply_gain_ivas_fx(
Word16 exc_diffQ[], /* i/o: Quantized excitation */
Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */
@@ -1786,16 +1720,21 @@ void Comp_and_apply_gain_ivas_fx(
const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */
Word16 Qexc_diff,
Word16 *Q_exc );
-
+#endif
void pre_echo_att_fx(
Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/
Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/
const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) Q0*/
const Word16 Q_new,
const Word16 last_coder_type, /* i : Last coding mode Q0*/
- const Word16 L_frame /* i : Frame length Q0*/
+#ifdef FIX_1904_HARM_GSC_ENC
+ const Word16 L_frame /* i : Frame length Q0*/,
+ const Word16 element_mode /* i : Current IVAS element mode*/
+#else
+ const Word16 L_frame /* i : Frame length Q0*/
+#endif
);
-
+#ifndef FIX_1904_HARM_GSC_ENC
void pre_echo_att_ivas_fx(
Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/
Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/
@@ -1804,6 +1743,7 @@ void pre_echo_att_ivas_fx(
const Word16 last_coder_type, /* i : Last coding mode Q0*/
const Word16 L_frame /* i : Frame length Q0*/
);
+#endif
void tcx_get_windows_mode1(
const Word16 left_mode, /* i: overlap mode of left window half */
@@ -2265,19 +2205,6 @@ void mdct_spectrum_denorm_fx(
const Word16 pd_thresh_fx /* i : Q15 : */
);
-void mdct_spectrum_denorm_ivas_fx(
- const Word32 inp_vector[], /* i : Q0 : */
- Word32 L_y2[], /* i/o : Qs : decoded spectrum */
- const Word16 band_start[], /* i : Q0 : table of start freq for every subband */
- const Word16 band_end[], /* i : Q0 : table of end freq for every subband */
- const Word16 band_width[], /* i : Q0 : table of bandwidth for every subband */
- const Word32 L_band_energy[], /* i : Qbe : band energy */
- const Word16 npulses[], /* i : Q0 : number of coded spectrum */
- const Word16 bands, /* i : Q0 : numbers of subbands */
- const Word16 ld_slope_fx, /* i : Q15 : */
- const Word16 pd_thresh_fx /* i : Q15 : */
-);
-
void hq2_core_configure_fx(
const Word16 frame_length, /* Q0 */
const Word16 num_bits, /* Q0 */
@@ -2686,9 +2613,12 @@ void lag_wind_32(
Word16 strength /* input : LAGW_WEAK, LAGW_MEDIUM, or LAGW_STRONG */
);
-// preemp_fx.c
-#define PREEMPH_FX( signal, mu, L, mem ) preemph_copy_fx( ( signal ), ( signal ), ( mu ), ( L ), ( mem ) )
-#define PREEMPH_32FX( signal, signal_out, mu, L, mem ) preemph_copy_32fx2( ( signal ), ( signal_out ), ( mu ), ( L ), ( mem ) )
+void preemph_fx(
+ Word16 x[], /* i/o: input/output signal Qx */
+ const Word16 mu, /* i : preemphasis coefficient Q15 */
+ const Word16 lg, /* i : vector size Q0 */
+ Word16 *mem /* i/o: memory (x[-1]) Qx */
+);
void preemph_copy_fx(
const Word16 x[], /* i : i signal Qx */
@@ -2898,16 +2828,7 @@ Word16 tbe_celp_exc_offset(
const Word16 L_frame /* i : frame lenght */
);
-void tbe_celp_exc(
- const Word16 L_frame_fx, /* i : Frame lenght */
- const Word16 i_subfr_fx, /* i : sub frame */
- const Word16 T0_fx, /* i : Integer pitch */
- const Word16 T0_frac_fx, /* i : Fractional part of the pitch */
- Word16 *error_fx, /* i/o: Error */
- Word16 *bwe_exc_fx /* i/o: bandwitdh extension signal */
-);
-
-void tbe_celp_exc_ivas(
+void tbe_celp_exc_fx(
const Word16 element_mode, /* i : element mode */
const Word16 idchan, /* i : channel ID */
const Word16 L_frame_fx, /* i : Frame lenght */
@@ -2935,11 +2856,12 @@ void Calc_rc0_h(
Word16 *rc0 /* o : 1st parcor */
);
+#ifndef HARMONIZE_TBE
void Calc_rc0_h_ivas_enc_fx(
Word16 *h, /* i : impulse response of composed filter */
Word16 *rc0 /* o : 1st parcor */
);
-
+#endif
void PostShortTerm_fx(
Word16 *sig_in, /* i : i signal (pointer to current subframe */
Word16 *lpccoeff, /* i : LPC coefficients for current subframe */
@@ -2974,11 +2896,11 @@ void PostShortTerm_ivas_dec_fx(
);
void flip_spectrum_and_decimby4_fx(
- const Word16 i[], /* i : i spectrum */
+ const Word16 i[], /* i : i spectrum */
Word16 output[], /* o : output spectrum */
const Word16 length, /* i : vector length */
- Word16 mem1[], /* i/o : memory */
- Word16 mem2[], /* i/o : memory */
+ Word16 mem1[], /* i/o: memory */
+ Word16 mem2[], /* i/o: memory */
const Word16 ramp_flag /* i : flag to trigger slow ramp-up of output following change of core */
);
@@ -2992,69 +2914,90 @@ void GenShapedWBExcitation_fx(
Word16 *mem_genSHBexc_filt_down3, /* i/o : memory */
Word16 *state_lpc_syn, /* i/o : memory */
const Word16 coder_type, /* i : coding type */
- const Word16 element_mode, /* i : element mode */
+ const Word16 element_mode, /* i : element mode */
const Word16 *bwe_exc_extended, /* i : bandwidth extended exciatation */
- const Word16 Q_bwe_exc,
- Word16 bwe_seed[], /* i/o : random number generator seed */
- const Word16 voice_factors[], /* i : voicing factor */
+ const Word16 Q_bwe_exc, /* i : Q for memories */
+ Word16 bwe_seed[], /* i/o : random number generator seed */
+ const Word16 voice_factors[], /* i : voicing factor */
const Word16 signal_type,
const Word16 igf_flag );
+#ifdef HARMONIZE_TBE
+void GenShapedWBExcitation_ivas_fx(
+ Word16 *excSHB, /* o : synthesized shaped shb exctiation Q_bwe_exc*/
+ const Word16 *lpc_shb, /* i : lpc coefficients Q12 */
+ Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation Q_bwe_exc*/
+ Word32 *mem_csfilt, /* i/o: memory Q_bwe_exc+16*/
+ Word16 *mem_genSHBexc_filt_down1, /* i/o: memory Q_bwe_exc*/
+ Word16 *mem_genSHBexc_filt_down2, /* i/o: memory Q_bwe_exc*/
+ Word16 *mem_genSHBexc_filt_down3, /* i/o: memory Q_bwe_exc*/
+ Word16 *state_lpc_syn, /* i/o: memory Q_bwe_exc*/
+ const Word16 coder_type, /* i : coding type */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 *bwe_exc_extended, /* i : bwidth extended exciatation Q_bwe_exc*/
+ const Word16 Q_bwe_exc, /* i : Q for memories */
+ Word16 bwe_seed[], /* i/o: random number generator seed */
+ const Word16 voice_factors[], /* i : voicing factor Q15*/
+ const Word16 uv_flag, /* i : unvoiced flag */
+ const Word16 igf_flag /* i : IGF flag */
+);
+
+#endif
void GenWBSynth_fx(
- const Word16 *input_synspeech, /* i : i synthesized speech */
+ const Word16 *input_synspeech, /* i : i synthesized speech */
Word16 *shb_syn_speech_16k, /* o : output highband compnent */
Word16 *state_lsyn_filt_shb1, /* i/o: memory */
Word16 *state_lsyn_filt_shb2 /* i/o: memory */
);
void GenShapedSHBExcitation_fx(
- Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/
- const Word16 *lpc_shb, /* i : lpc coefficients Q12*/
- Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */
+ Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/
+ const Word16 *lpc_shb, /* i : lpc coefficients Q12*/
+ Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */
Word32 *mem_csfilt, /* i/o: memory */
Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */
Word16 *state_lpc_syn, /* i/o: memory */
- const Word16 coder_type, /* i : coding type */
- const Word16 element_mode, /* i : element mode */
- const Word16 *bwe_exc_extended, /* i : bandwidth extended excitation */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 *bwe_exc_extended, /* i : bandwidth extended excitation */
Word16 bwe_seed[], /* i/o: random number generator seed */
- Word16 voice_factors[], /* i : voicing factor*/
- const Word16 extl, /* i : extension layer */
+ Word16 voice_factors[], /* i : voicing factor*/
+ const Word16 extl, /* i : extension layer */
Word16 *tbe_demph, /* i/o: de-emphasis memory */
Word16 *tbe_premph, /* i/o: pre-emphasis memory */
- Word16 *lpc_shb_sf, /* i: LP coefficients */
- const Word32 shb_ener_sf_32, /* i: i shb ener, Q31 */
- Word16 *shb_res_gshape, /* i: i res gain shape, Q14 */
+ Word16 *lpc_shb_sf, /* i : LP coefficients */
+ const Word32 shb_ener_sf_32, /* i : i shb ener, Q31 */
+ Word16 *shb_res_gshape, /* i : i res gain shape, Q14 */
Word16 *shb_res,
Word16 *vf_ind,
- const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */
+ const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */
Word16 fb_state_lpc_syn[], /* i/o: memory */
Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */
Word16 *Q_bwe_exc,
Word16 *Q_bwe_exc_fb,
const Word16 Q_shb,
- Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */
- Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */
+ Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */
+ Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */
const Word32 bitrate,
const Word16 prev_bfi );
void GenShapedSHBExcitation_ivas_enc_fx(
- Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/
- const Word16 *lpc_shb, /* i : lpc coefficients Q12*/
- Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc_fb */
+ Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/
+ const Word16 *lpc_shb, /* i : lpc coefficients Q12*/
+ Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc_fb */
Word32 *mem_csfilt, /* i/o: memory */
Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */
Word16 *state_lpc_syn, /* i/o: memory */
- const Word16 coder_type, /* i : coding type */
- const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */
Word16 bwe_seed[], /* i/o: random number generator seed */
- Word16 voice_factors[], /* i : voicing factor*/
- const Word16 extl, /* i : extension layer */
+ Word16 voice_factors[], /* i : voicing factor*/
+ const Word16 extl, /* i : extension layer */
Word16 *tbe_demph, /* i/o: de-emphasis memory */
Word16 *tbe_premph, /* i/o: pre-emphasis memory */
- Word16 *lpc_shb_sf, /* i: LP coefficients */
- const Word32 shb_ener_sf_32, /* i: input shb ener, Q31 */
- Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */
+ Word16 *lpc_shb_sf, /* i : LP coefficients */
+ const Word32 shb_ener_sf_32, /* i : input shb ener, Q31 */
+ Word16 *shb_res_gshape, /* i : input res gain shape, Q14 */
Word16 *shb_res,
Word16 *vf_ind,
const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */
@@ -3166,41 +3109,31 @@ void ScaleShapedSHB_fx32(
Word16 *Q_new );
void ScaleShapedWB_fx(
- const Word16 length, /* i : SHB overlap length */
- Word16 *synSHB, /* i/o : synthesized shb signal */
- Word16 *overlap, /* i/o : buffer for overlap-add */
- const Word16 *subgain, /* i : subframe gain */
- const Word32 frame_gain, /* i : frame gain */
- const Word16 *win, /* i : window */
- const Word16 *subwin, /* i : subframes window */
- const Word16 Q_bwe_exc,
- Word16 L_frame, /* i : Frame length - determines whether 12.8 or 16kHz core in-use */
- Word16 dynQ, /* i : indicate whether output is dynamic Q, or Q0 */
- Word16 *Qx, /* o : newly computed Q factor for synSHB */
- Word16 prev_Qx, /* i : prev_Qx for memory scaling */
- Word32 *Hilbert_Mem /* i : Hilbert memory used for computing Qx */
+ const Word16 length, /* i : SHB overlap length */
+ Word16 *synSHB, /* i/o: synthesized shb signal */
+ Word16 *overlap, /* i/o: buffer for overlap-add */
+ const Word16 *subgain, /* i : subframe gain */
+ const Word32 frame_gain, /* i : frame gain */
+ const Word16 *win, /* i : window */
+ const Word16 *subwin, /* i : subframes window */
+ const Word16 Q_bwe_exc, /* i : Q for memories */
+ Word16 L_frame, /* i : Frame length - determines whether 12.8 or 16kHz core in-use */
+ Word16 dynQ, /* i : indicate whether output is dynamic Q, or Q0 */
+ Word16 *Qx, /* o : newly computed Q factor for synSHB */
+ Word16 prev_Qx, /* i : prev_Qx for memory scaling */
+ Word32 *Hilbert_Mem /* i : Hilbert memory used for computing Qx */
);
void non_linearity_fx(
- const Word16 i[], /* i : i signal Q_inp */
- Word32 output[], /* o : output signal 2*Q_inp */
- const Word16 length, /* i : i length */
- Word32 *prev_scale, /* i/o: memory Q30 */
- Word16 Q_inp,
- Word16 coder_type, /* i : Coder Type */
- Word16 *voice_factors, /* i : Voice Factors */
- const Word16 L_frame /* i : ACELP frame length */
-);
-
-void non_linearity_ivas_fx(
- const Word16 i[], /* i : i signal Q_inp */
- Word32 output[], /* o : output signal 2*Q_inp */
- const Word16 length, /* i : i length */
- Word32 *prev_scale, /* i/o: memory Q30 */
- Word16 Q_inp,
- Word16 coder_type, /* i : Coder Type */
- Word16 *voice_factors, /* i : Voice Factors */
- const Word16 L_frame /* i : ACELP frame length */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 i[], /* i : i signal Q_inp */
+ Word32 output[], /* o : output signal 2*Q_inp */
+ const Word16 length, /* i : i length */
+ Word32 *prev_scale, /* i/o: memory Q30 */
+ const Word16 Q_inp, /* i : scaling of input */
+ const Word16 coder_type, /* i : Coder Type */
+ Word16 *voice_factors, /* i : Voice Factors */
+ const Word16 L_frame /* i : ACELP frame length */
);
void interp_code_5over2_fx(
@@ -3836,13 +3769,6 @@ void nelp_encoder_fx(
Word16 *qIn1,
Word16 reduce_gains );
-void nelp_encoder_ivas_fx(
- Encoder_State *st_fx, /* i/o: encoder state */
- Word16 *in_fx, /* i : residual signal */
- Word16 *exc_fx, /* o : NELP quantized excitation signal */
- Word16 *qIn1,
- Word16 reduce_gains );
-
void swb_bwe_enc_lr_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
const Word32 L_m_core[], /* i : lowband synthesis */
@@ -3868,31 +3794,6 @@ void swb_bwe_enc_lr_fx(
Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */
);
-void swb_bwe_enc_lr_ivas_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word32 L_m_core[], /* i : lowband synthesis */
- Word16 QsL,
- const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */
- Word32 L_m[], /* o : highband synthesis with lowband zeroed */
- const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */
- Word16 BANDS_fx, /* i : Total number of Subbands in a frame */
- Word16 *band_start_fx, /* i : band start of each SB */
- Word16 *band_end_fx, /* i : band end of each SB */
- Word32 *L_band_energy, /* i : band_energy of each SB */
- Word16 Qbe, /* i : Q value of band energy */
- Word16 *p2a_flags_fx, /* i : HF tonal indicator */
- const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */
- Word16 lowlength_fx, /* i : lowband length */
- Word16 highlength_fx, /* i : highband length */
- Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */
- const Word16 har_bands_fx, /* i : Number of LF harmonic bands */
- Word16 *prev_frm_hfe2, /* i/o: */
- Word16 *prev_stab_hfe2, /* i/o: */
- const Word16 band_width_fx[], /* i : band_width information */
- const Word32 L_y2_ni[], /* i : band_width information */
- Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */
-);
-
void isf_enc_amr_wb_fx(
Encoder_State *st, /* i/o: state structure */
Word16 *isf_new, /* i/o: quantized ISF vector */
@@ -4026,44 +3927,17 @@ void CNG_exc_fx(
);
void cng_params_postupd_fx(
- const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */
- Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */
- const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */
- const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */
- const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */
- Word32 ho_env_circ[] /* i/o: Envelope buffer */
-);
-
-void cng_params_postupd_ivas_fx(
const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */
Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */
const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */
const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */
const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */
Word32 ho_env_circ[], /* i/o: Envelope buffer */
- const Word16 element_mode, /* i : Element mode */
- const Word16 bwidth /* i : Audio bandwidth */
+ const Word16 element_mode, /* i : Element mode */
+ const Word16 bwidth /* i : Audio bandwidth */
);
void cng_params_upd_fx(
- const Word16 lsp_new[], /* i : LSP parameters Q15 */
- const Word16 exc2[], /* i : current enhanced excitation Q_exc */
- const Word16 L_frame, /* i : frame length Q0 */
- Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */
- Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */
- Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */
- Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */
- const Word16 Q_exc, /* i : Q value of excitation */
- const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */
- Word32 ho_env_circ[], /* i/o: Envelope buffer */
- Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */
- Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */
- Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */
- Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */
- const Word32 last_active_brate /* i : Last active bit rate Q0 */
-);
-
-void cng_params_upd_ivas_fx(
const Word16 lsp_new[], /* i : LSP aprameters Q15 */
const Word16 exc2[], /* i : current enhanced excitation Q_exc */
const Word16 L_frame, /* i : frame length Q0 */
@@ -4079,8 +3953,8 @@ void cng_params_upd_ivas_fx(
Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */
Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */
const Word32 last_active_brate, /* i : Last active bit rate Q0 */
- const Word16 element_mode, /* i : Element mode */
- const Word16 bwidth /* i : Audio bandwidth */
+ const Word16 element_mode, /* i : Element mode */
+ const Word16 bwidth /* i : Audio bandwidth */
);
Word16 get_cng_mode(
@@ -4828,19 +4702,8 @@ Word16 est_tilt_fx(
const Word16 *code, /* i : algebraic exctitation vector Q9 */
const Word32 gain_code, /* i : algebraic code gain Q16 */
Word16 *voice_fac, /* o : voicing factor Q15 */
- const Word16 Q_exc /* i : Scaling factor of excitation Q0 */
-);
-
-/* o : tilt of the code Q15 */
-Word16 est_tilt_ivas_fx(
- const Word16 *exc, /* i : adaptive excitation vector Qx */
- const Word16 gain_pit, /* i : adaptive gain Q14 */
- const Word16 *code, /* i : algebraic excitation vector Q9 */
- const Word32 gain_code, /* i : algebraic code gain Q16 */
- Word16 *voice_fac, /* o : voicing factor Q15 */
const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */
- const Word16 L_subfr, /* i : Sub frame length */
- const Word16 flag_tilt /* i : flag for special tilt */
+ const Word16 L_subfr /* i : Sub frame length */
);
/* o : tilt of the code */
@@ -5036,6 +4899,7 @@ void freq_dnw_scaling_fx(
const Word16 L_frame /* i : frame length */
);
+#ifndef FIX_1904_HARM_GSC_ENC
void highband_exc_dct_in_fx(
const Word32 core_brate, /* i : core bitrate */
const Word16 *mfreq_bindiv, /* i : bin per bands tables */
@@ -5067,7 +4931,6 @@ void highband_exc_dct_in_fx(
const Word16 element_mode, /* i : IVAS element mode */
const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */
);
-
void highband_exc_dct_in_ivas_fx(
const Word32 core_brate, /* i : core bitrate */
const Word16 *mfreq_bindiv, /* i : bin per bands tables */
@@ -5099,6 +4962,39 @@ void highband_exc_dct_in_ivas_fx(
const Word16 element_mode, /* i : IVAS element mode */
const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */
);
+#else
+void highband_exc_dct_in_fx(
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 *mfreq_bindiv, /* i : bin per bands tables */
+ Word16 last_bin, /* i : last bin of bit allocation */
+ Word16 Diff_len, /* i : number of bin before cut-off frequency */
+ Word16 noise_lev, /* i : pulses dynamic */
+ Word16 pit_band_idx, /* i : bin position of the cut-off frequency */
+ Word16 *exc_diffQ, /* i : frequency coefficients of per band */
+ Word16 *seed_tcx, /* i : Seed for noise */
+ Word16 *Ener_per_bd_iQ, /* i : Quantized energy of targeted vector */
+ Word16 nb_subfr, /* i : Number of subframe considered */
+ Word16 *exc_dct_in, /* o : dct of residual signal */
+ Word16 last_coder_type, /* i : coding type of last frame */
+ Word16 *bitallocation_band, /* i : bit allocation flag of each band */
+ const Word16 *lsf_new, /* i : LSFs at the end of the frame */
+ Word16 *last_exc_dct_in, /* i : dct of residual signal of last frame */
+ Word16 *last_ener, /* i : frequency energy of last frame */
+ Word16 *last_bitallocation_band, /* i : bit allocation flag of each band of last frame */
+ Word16 *bitallocation_exc, /* i : flag of decoded coefficients */
+ Word16 bfi, /* i : bad frame indicator */
+ const Word16 coder_type, /* i : coder type */
+ Word16 bwidth,
+ Word16 *exc_wo_nf, /* o : temporal excitation (in f domain) without noisefill */
+ Word16 Qexc_diffQ,
+ Word16 *Q_exc,
+ const Word16 GSC_noisy_speech,
+ Word16 *lt_ener_per_band_fx, /* i/o: Average per band energy */
+ const Word16 L_frame, /* i : frame length */
+ const Word16 element_mode, /* i : IVAS element mode */
+ const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */
+);
+#endif
void lsf_dec_bfi(
const Word16 codec_mode, /* i: : codec mode: MODE1 | MODE2 */
@@ -5337,14 +5233,6 @@ Word32 sign_l(
const Word32 x /* i : input value of x */
);
-void ivas_updt_dec_common_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- Word16 hq_core_type_fx, /* i : HQ core type */
- const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */
- const Word32 *synth, /* i : decoded synthesis */
- const Word16 Qpostd /* i : Synthesis Q value */
-);
-
/* Random generator with Gaussian distribution with mean 0 and std 1 */
Word32 rand_gauss(
Word16 *seed );
@@ -5909,6 +5797,7 @@ void swb_tbe_dec_fx(
Word16 *Q_synth,
Word16 *pitch_buf );
+#ifndef HARMONIZE_TBE
void ivas_dequantizeSHBparams_fx_9_1(
Decoder_State *st_fx,
const Word16 extl, /* i : extension layer */
@@ -5921,8 +5810,9 @@ void ivas_dequantizeSHBparams_fx_9_1(
Word16 *Q_shb_res_gshape, /* o : Q14 */
Word16 *Q_mixFactors, /* o : Q15 */
Word16 *MSFlag );
-
+#endif
void fb_tbe_dec_fx(
+#ifndef HARMONIZE_TBE
Decoder_State *st, /* i/o: encoder state structure */
const Word16 fb_exc[], /* i : FB excitation from the SWB part */
Word16 Q_fb_exc,
@@ -5930,9 +5820,13 @@ void fb_tbe_dec_fx(
Word16 hb_synth_exp );
void fb_tbe_dec_ivas_fx(
+#endif
Decoder_State *st, /* i/o: encoder state structure */
const Word16 fb_exc[], /* i : FB excitation from the SWB part */
Word16 Q_fb_exc,
+#ifdef HARMONIZE_TBE
+ Word16 *hb_synth16, /* o : high-band synthesis Q(15 - hb_synth_exp) */
+#endif
Word32 *hb_synth, /* o : high-band synthesis */
Word16 hb_synth_exp,
Word16 *fb_synth_ref,
@@ -6159,14 +6053,6 @@ void swb_CNG_dec_fx(
const Word16 Qsyn /* i : Q value of ACELP core synthesis */
);
-void swb_CNG_dec_ivas_fx(
- Decoder_State *st_fx, /* i/o: State structure */
- const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/
- Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/
- const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/
- const Word16 Qsyn /* i : Q value of ACELP core synthesis */
-);
-
void td_cng_dec_init_fx(
DEC_CORE_HANDLE st /* i/o: decoder state structure */
);
@@ -6183,7 +6069,6 @@ void concealment_init_x(
void concealment_init_ivas_fx(
const Word16 L_frameTCX,
T_PLCInfo_HANDLE hPlcInfo );
-
void concealment_update_x(
const Word16 bfi,
const Word16 core,
@@ -6484,18 +6369,7 @@ void hf_synth_reset_fx(
void hf_synth_fx(
ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */
- const Word32 core_brate, /* i : core bitrate Q0*/
- const Word16 output_frame, /* i : output frame length Q0*/
- const Word16 *Aq, /* i : quantized Az Q12*/
- const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/
- Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/
- Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/
- const Word16 Q_exc, /* i : excitation scaling */
- const Word16 Q_syn2 /* i : synthesis scaling */
-);
-
-void hf_synth_ivas_fx(
- ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */
+ const Word16 element_mode, /* i : element mode Q0*/
const Word32 core_brate, /* i : core bitrate Q0*/
const Word16 output_frame, /* i : output frame length Q0*/
const Word16 *Aq, /* i : quantized Az Q12*/
@@ -6563,20 +6437,6 @@ void formant_post_filt_fx(
const Word16 off_flag /* i : off flag */
);
-void Filt_mu_fx(
- Word16 *sig_in, /* i : signal (beginning at sample -1) */
- Word16 *sig_out, /* o : signal with tilt */
- Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */
- Word16 L_subfr /* i : the length of subframe */
-);
-
-void Filt_mu_ivas_fx(
- Word16 *sig_in, /* i : signal (beginning at sample -1) */
- Word16 *sig_out, /* o : signal with tilt */
- Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */
- Word16 L_subfr, /* i : the length of subframe */
- const Word16 extl );
-
void scale_st_fx(
const Word16 *sig_in, /* i : postfilter i signal */
Word16 *sig_out, /* i/o: postfilter o signal */
@@ -6763,17 +6623,6 @@ void gain_dec_tc_fx(
Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */
);
-void gain_dec_tc_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word16 *code_fx, /* i : algebraic code excitation */
- const Word16 i_subfr_fx, /* i : subframe number */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- Word16 *gain_pit_fx, /* o : pitch gain */
- Word32 *gain_code_fx, /* o : Quantized codeebook gain */
- Word16 *gain_inov_fx, /* o : unscaled innovation gain */
- Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */
-);
-
void gain_dec_mless_fx(
Decoder_State *st_fx, /* i/o: decoder state structure */
const Word16 L_frame_fx, /* i : length of the frame */
@@ -6803,15 +6652,7 @@ void gain_dec_lbr_fx(
);
void lp_gain_updt_fx(
- const Word16 i_subfr, /* i : subframe number Q0 */
- const Word16 gain_pit, /* i : Decoded gain pitch Q14 */
- const Word32 norm_gain_code, /* i : Normalised gain code Q16 */
- Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */
- Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */
- const Word16 L_frame /* i : length of the frame */
-);
-
-void lp_gain_updt_ivas_fx(
+ const Word16 element_mode, /* i : element mode */
const Word16 i_subfr, /* i : subframe number Q0 */
const Word16 gain_pit, /* i : Decoded gain pitch Q14 */
const Word32 norm_gain_code, /* i : Normalised gain code Q16 */
@@ -7070,20 +6911,6 @@ void inov_decode_fx(
const Word16 L_subfr /* i : subframe length Q0 */
);
-void inov_decode_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word32 core_brate, /* i : core bitrate Q0 */
- const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode Q0 */
- const Word16 L_frame, /* i : length of the frame Q0 */
- const Word16 sharpFlag, /* i : formant sharpening flag Q0 */
- const Word16 i_subfr, /* i : subframe index Q0 */
- const Word16 *p_Aq, /* i : LP filter coefficients Q12 */
- const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15 */
- const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/
- Word16 *code, /* o : algebraic excitation Q12 */
- const Word16 L_subfr /* i : subframe length Q0 */
-);
-
void dec_acelp_4t64_fx(
Decoder_State *st_fx, /* i/o: decoder state structure */
Word16 nbbits, /* i : number of bits per codebook */
@@ -7135,12 +6962,6 @@ ivas_error acelp_core_switch_dec_bfi_fx(
const Word16 coder_type /* i : coder type */
);
-ivas_error acelp_core_switch_dec_bfi_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- Word16 synth_out[], /* o : synthesis Q_syn */
- const Word16 coder_type /* i : coder type */
-);
-
void pred_lt4(
const Word16 excI[], /* in : excitation buffer Q_exc*/
Word16 excO[], /* out: excitation buffer Q_exc*/
@@ -7732,31 +7553,25 @@ void hq_configure_bfi_fx(
void bandwidth_switching_detect_fx(
Decoder_State *st_fx /* i/o: encoder state structure */
);
-
-void bandwidth_switching_detect_ivas_fx(
- Decoder_State *st_fx /* i/o: encoder state structure */
-);
-
void bw_switching_pre_proc_fx(
- const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/
- Decoder_State *st_fx /* i/o: decoder state structure */
+ Decoder_State *st_fx, /* i/o: decoder state structure */
+ const Word32 last_element_brate, /* i : last element bitrate */
+ const Word16 nchan_out, /* i : number of output channels */
+ const Word16 *old_syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/
);
ivas_error core_switching_pre_dec_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word16 output_frame /* i : frame length Q0*/
-);
+ Decoder_State *st, /* i/o: decoder state structure */
+ const Word16 output_frame, /* i : frame length */
+ const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */
+ const Word16 nchan_out, /* i : number of output channels */
+ const Word16 last_element_mode, /* i : last_element_mode */
+ const Word32 last_element_brate, /* i : last element bitrate */
+ const Word16 Q_old_synthFB,
+ Word16 *Q_olapBufferSynth,
+ Word16 *Q_olapBufferSynth2 );
ivas_error core_switching_post_dec_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- Word16 *synth, /* i/o: output synthesis Qsynth Qsynth*/
- const Word16 output_frame, /* i : frame length Q0*/
- const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/
- const Word16 last_element_mode, /* i : element mode of previous frame Q0*/
- Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */
-);
-
-ivas_error core_switching_post_dec_ivas_fx(
Decoder_State *st_fx, /* i/o: decoder state structure */
Word16 *synth, /* i/o: output synthesis Qsynth*/
Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/
@@ -7803,16 +7618,12 @@ void updt_IO_switch_dec_fx(
Decoder_State *st_fx /* o : Decoder static variables structure */
);
-void updt_bw_switching_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word16 *synth, /* i : synthesis signal Qpost */
- const Word16 Qpost );
-
void updt_dec_common_fx(
Decoder_State *st_fx, /* i/o: decoder state structure */
Word16 hq_core_type_fx, /* i : HQ core type */
const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */
- const Word16 *synth, /* i : decoded synthesis */
+ const Word16 *synth16, /* i : decoded synthesis Qpostd */
+ const Word32 *synth, /* i : decoded synthesis Qpostd */
const Word16 Qpostd /* i : Synthesis Q value */
);
@@ -8767,12 +8578,6 @@ Word16 dlpc_avq_fx(
Word32 sr_core );
Word16 decode_lpc_avq_fx(
- Decoder_State *st, /* i/o: decoder state structure */
- const Word16 numlpc, /* i : Number of sets of lpc */
- Word16 *param_lpc /* o : lpc parameters */
-);
-
-Word16 decode_lpc_avq_ivas_fx(
Decoder_State *st, /* i/o: decoder state structure */
const Word16 numlpc, /* i : Number of sets of lpc */
Word16 *param_lpc, /* o : lpc parameters */
@@ -9265,12 +9070,6 @@ void bpf_pitch_coherence_ivas_fx(
const Word32 pitch_buf[] /* i : pitch for each subframe [0,1,2,3] */
);
-/* fft_rel.c */
-
-#define SIZE_256 256
-#define NUM_STAGE_256 7
-#define SIZE2_256 ( SIZE_256 / 2 )
-
void cldfbAnalysis_ivas_fx(
const Word32 *timeIn_fx, /* i : time buffer Qx */
Word32 **realBuffer_fx, /* o : real value buffer Qx - 5*/
@@ -9486,14 +9285,6 @@ void stereo_dft_dec_open(
const Word16 nchan_transport /* i : number of transport channels */
);
-void ivas_bw_switching_pre_proc_fx(
- Decoder_State *st, /* i/o: decoder state structure */
- const Word32 last_element_brate, /* i : last element bitrate */
- const Word16 nchan_out, /* i : number of output channels */
- Word32 *old_syn_12k8_16k_fx,
- Word16 Q,
- Word16 Q_audio );
-
UWord32 mvl2s_r(
const Word32 x[], /* i : input vector */
const Word16 q,
@@ -10301,11 +10092,11 @@ void ivas_swb_tbe_dec_fx(
STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */
const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */
Word16 Q_exc,
- const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */
- const Word32 old_syn_12k8_16k_fx[], /* i : low band synthesis : old_syn_fx */
- Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/
- Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */
- Word16 *pitch_buf_fx, /* i : Q6 */
+ const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */
+ const Word16 old_syn_12k8_16k_fx16[], /* i : low band synthesis : old_syn_fx */
+ Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/
+ Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */
+ Word16 *pitch_buf_fx, /* i : Q6 */
Word16 *Q_white_exc );
Word16 swb_bwe_dec_fx32(
@@ -10349,17 +10140,6 @@ void wtda_fx32(
const Word16 L /* i : length */
);
-ivas_error core_switching_pre_dec_ivas_fx(
- Decoder_State *st, /* i/o: decoder state structure */
- const Word16 output_frame, /* i : frame length */
- const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */
- const Word16 nchan_out, /* i : number of output channels */
- const Word16 last_element_mode, /* i : last_element_mode */
- const Word32 last_element_brate, /* i : last element bitrate */
- Word16 Q_old_synthFB,
- Word16 *Q_olapBufferSynth,
- Word16 *Q_olapBufferSynth2 );
-
void hp20_fx_32(
Word32 signal_fx[],
const Word16 lg,
@@ -10466,26 +10246,21 @@ void Copy_Scale_sig32(
);
void swb_pre_proc_ivas_fx(
- Encoder_State *st, /* i/o: encoder state structure */
- Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */
+ Encoder_State *st, /* i/o: encoder state structure */
+ Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */
+#ifndef REMOVE_SCALING_SHB_SPEECH
Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q - q_reImBuffer */
- Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz- Q(Q_shb_spch) */
+#endif
+ Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz - Q0*/
+#ifndef REMOVE_SCALING_SHB_SPEECH
Word16 *Q_shb_spch,
+#endif
Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */
Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */
- Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers */
+ Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers*/
CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */
);
-void core_encode_update_ivas_fx(
- Encoder_State *st /* i/o: Encoder state structure */
-);
-
-void updt_enc_common_ivas_fx(
- Encoder_State *st, /* i/o: encoder state structure */
- const Word16 Q_new /* i : CUrrent frame scaling */
-);
-
/* o : Q(2x - 31 - gb) */
Word32 sum2_f_32_fx(
const Word32 *vec, /* i : input vector, Qx */
@@ -10620,26 +10395,6 @@ Word16 ari_decode_14bits_sign_ivas(
Word16 *res,
Tastat *s );
-void lsf_syn_mem_backup_ivas_fx(
- Encoder_State *st_fx, /* i: state structure */
- Word16 *btilt_code_fx, /* i: tilt code Q15 */
- Word32 *gc_threshold_fx, /* i: Q16 */
- Word16 *clip_var_bck_fx, /* o: Q(2.56), Q14, Q7, Q0, Q14, Q14 */
- Word16 *next_force_sf_bck_fx, /* o: */
- Word16 *lsp_new, /* i: LSP vector to quantize Q15 */
- Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */
- Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */
- Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */
- Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */
- Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */
- Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */
- Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */
- Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */
- Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */
- Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */
- Word16 *streaklimit, /* Q15 */
- Word16 *pstreaklen );
-
ivas_error config_acelp1_fx(
const Word16 enc_dec, /* i : encoder/decoder flag */
const Word32 total_brate, /* i : total bitrate */
@@ -10724,12 +10479,6 @@ void writeTCXparam_fx(
const Word16 target_bitsTCX10[2],
const Word16 pre_past_flag );
-void calculate_hangover_attenuation_gain_ivas_fx(
- Encoder_State *st, /* i : encoder state structure */
- Word16 *att, /* o : attenuation factor */
- const Word16 vad_hover_flag /* i : VAD hangover flag */
-);
-
void init_coder_ace_plus_ivas_fx(
Encoder_State *st, /* i : Encoder state */
const Word32 last_total_brate, /* i : last total bitrate */
@@ -10829,20 +10578,6 @@ Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx(
Word16 *dist_ptr_e /* i/o: exp for updated MSE vector for stage1 */
);
-void FEC_encode_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */
- const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_Synth*/
- const Word16 coder_type, /* i : type of coder Q0*/
- Word16 clas, /* i : signal clas for current frame Q0*/
- const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/
- const Word16 *res, /* i : LP residual signal frame Qx*/
- Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/
- const Word16 L_frame, /* i : Frame length Q0*/
- const Word32 total_brate, /* i : total codec bitrate Q0*/
- const Word16 Q_synth /* i : input scaling */
-);
-
ivas_error IGF_Reconfig_fx(
IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */
const Word16 igf, /* i : IGF on/off */
@@ -10853,13 +10588,6 @@ ivas_error IGF_Reconfig_fx(
const Word16 rf_mode /* i : flag to signal the RF mode */
);
-void core_switching_post_enc_ivas_fx(
- Encoder_State *st, /* i/o: encoder state structure */
- Word16 *old_inp_12k8_fx, /* i : old input signal @12.8kHz */
- Word16 *old_inp_16k_fx, /* i : old input signal @16kHz */
- Word16 A_fx[], /* i : unquant. LP filter coefs. */
- Word16 Q_new );
-
void residu_ivas_fx(
const Word16 *a, /* i : LP filter coefficients Q31-a_exp*/
const Word16 a_exp,
@@ -10877,14 +10605,6 @@ void WriteToBitstream_fx(
BSTR_ENC_HANDLE hBstr,
Word16 *pnBits );
-void WriteToBitstream_ivas_fx(
- ParamsBitMap const *paramsBitMap,
- const Word16 nArrayLength,
- const Word16 **pStream,
- Word16 *pnSize,
- BSTR_ENC_HANDLE hBstr,
- Word16 *pnBits );
-
/*===========================================================================================*/
/*----------------------------------------------------------------------------------*
@@ -11150,7 +10870,7 @@ ivas_error acelp_core_enc_ivas_fx(
Word16 *unbits, /* o : number of unused bits Q0*/
STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */
Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/
- Word16 Q_new );
+ const Word16 Q_new );
void flip_and_downmix_generic_fx32(
Word32 input[], /* i : input spectrum Qx*/
@@ -11190,7 +10910,7 @@ void bands_and_bit_alloc_ivas_fx(
const Word16 element_mode, /* i : element mode */
const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */
);
-
+#ifndef FIX_2363_FIND_WSP
void ivas_find_wsp_fx(
const Word16 L_frame, /* i : length of the frame Q0*/
const Word16 L_subfr, /* i : length of subframe Q0*/
@@ -11204,6 +10924,7 @@ void ivas_find_wsp_fx(
const Word16 gamma, /* i : weighting factor Q15 */
const Word16 L_look /* i : look-ahead Q0*/
);
+#endif
Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx(
Word16 *x, /* Q0 */
@@ -11260,7 +10981,8 @@ void UnmapIndex_fx(
Word32 *Lag /* Q0 */
);
-#define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) )
+//#define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) )
+#define GET_ADJ2( T, L, F ) ( sub( shl( L, F ), T ) )
Word32 tcx_hm_render_fx(
const Word32 lag, /* i: pitch lag Q0 */
diff --git a/lib_com/reordvct_fx.c b/lib_com/reordvct_fx.c
index 62eb2f352665c97f24322207fc2092e4ac2e5c64..e89e9ed3817916883af0f99172debd4d115959e3 100644
--- a/lib_com/reordvct_fx.c
+++ b/lib_com/reordvct_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/rom_basop_util.c b/lib_com/rom_basop_util.c
index eb79cc02648c67df6dbd075f3da2a9704142e2f8..321658f7a927a8edbf7f58dbb894dad0f9a5269f 100644
--- a/lib_com/rom_basop_util.c
+++ b/lib_com/rom_basop_util.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/rom_basop_util.h b/lib_com/rom_basop_util.h
index 63b55fe59b013b680023ac62f9706f119d26cbeb..ffbc7292acd5ff5038e8cd5cecc199274cb7e9d8 100644
--- a/lib_com/rom_basop_util.h
+++ b/lib_com/rom_basop_util.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h
index 1ba9251d304ce6969f3889bdd8c55089bee933df..a61ee76afeba95bcb1b93347b81311a7e45e897f 100644
--- a/lib_com/rom_com.h
+++ b/lib_com/rom_com.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/rom_com_fx.c b/lib_com/rom_com_fx.c
index f1fdf7f78d581ff201922df2be5d9f0464f3f811..eff398b330db5b5ab4b9b32bfb8f5537257b8a34 100644
--- a/lib_com/rom_com_fx.c
+++ b/lib_com/rom_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/scale_mem_fx.c b/lib_com/scale_mem_fx.c
index 52ba436de439de14d69c2f354877fac9f50390cb..9047c7ea4a40903db214b7ed79988d908a241c66 100644
--- a/lib_com/scale_mem_fx.c
+++ b/lib_com/scale_mem_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h
index 2a37faef604e3c4189d8c939b9a99be895941167..a85d6c7c013d62a4da41d8f93132dce64e52df2e 100644
--- a/lib_com/stat_com.h
+++ b/lib_com/stat_com.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/stat_noise_uv_mod_fx.c b/lib_com/stat_noise_uv_mod_fx.c
index ad87695e831dd5092ddb9456261828e46ca5ec72..33c5545ce37b4036d4da03314b713530fd1d6377 100644
--- a/lib_com/stat_noise_uv_mod_fx.c
+++ b/lib_com/stat_noise_uv_mod_fx.c
@@ -158,7 +158,7 @@ void stat_noise_uv_mod_fx(
{
exctilt = calc_tilt_fx( &Exc2_local[i_subfr], En_shift, L_SUBFR ); /*Q15 */
exctilt = mult( shl_sat( sub( TILT_COMP_LIM_FX, min_alpha ), 2 ), exctilt ); /*Q15 */
- PREEMPH_FX( &Exc2_local[i_subfr], exctilt, L_SUBFR, exc_pe );
+ preemph_fx( &Exc2_local[i_subfr], exctilt, L_SUBFR, exc_pe );
}
}
@@ -458,7 +458,7 @@ void stat_noise_uv_mod_ivas_fx(
{
exctilt = calc_tilt_fx( &Exc2_local[i_subfr], En_shift, L_SUBFR ); /*Q15 */
exctilt = mult( shl_sat( sub( TILT_COMP_LIM_FX, min_alpha ), 2 ), exctilt ); /*Q15 */
- PREEMPH_FX( &Exc2_local[i_subfr], exctilt, L_SUBFR, exc_pe );
+ preemph_fx( &Exc2_local[i_subfr], exctilt, L_SUBFR, exc_pe );
}
}
@@ -614,7 +614,7 @@ void stat_noise_uv_mod_ivas_fx(
mult( sub( 32767, beta ), lspnew_s[i] ) );
}
- int_lsp4_ivas_fx( L_FRAME, oldlsp_mix, midlsp_mix, newlsp_mix, Aq, M, 0 );
+ int_lsp4_fx( L_FRAME, oldlsp_mix, midlsp_mix, newlsp_mix, Aq, M, 0 );
Copy( lspnew_s, lspold_s, M );
}
ELSE /* (unvoiced_vad != 0) */
diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c
index cc8b22db64fdf8b46a65290c72a58d61667a3615..a413064d2eb6b709c9b037ba1c4f004186060303 100644
--- a/lib_com/swb_bwe_com_fx.c
+++ b/lib_com/swb_bwe_com_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/swb_bwe_com_lr_fx.c b/lib_com/swb_bwe_com_lr_fx.c
index 1326b31a98eac391da7fa04154e79c9759448955..4baf7f9a2e33c153d8da706de9389ded6ebc48d7 100644
--- a/lib_com/swb_bwe_com_lr_fx.c
+++ b/lib_com/swb_bwe_com_lr_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c
index c9d307ef26b0bd5fefabb8f24f3d9941581893cc..8f5f19d13763f2c67f45eaaf9cc77ad6a61e3147 100644
--- a/lib_com/swb_tbe_com_fx.c
+++ b/lib_com/swb_tbe_com_fx.c
@@ -8,30 +8,29 @@
#include "rom_com.h" /* Static table prototypes */
#include "prot_fx.h"
#include "basop_util.h"
-#include "ivas_prot_fx.h"
/*-----------------------------------------------------------------*
* Local constants
*-----------------------------------------------------------------*/
-#define POW_EXC16k_WHTND 1.14e11f /* power of random excitation, length 320 samples, uniform distribution */
-#define POW_EXC16k_WHTND_FX_INV_SQRT 6360 // Q31
+#define POW_EXC16k_WHTND_FX_INV_SQRT 6360 // 1.14e11f in Q31 power of random excitation, length 320 samples, uniform distribution
#define POW_EXC16k_WHTND_FX_INV_SQRT_IN_Q49 1667313793 // Q49
#define POW_EXC16k_WHTND_FX 178125000 // Q-6
-#define THR_ENV_ERROR_PLOSIVE 200.0f /* threshold for envelope error used in plosive detection */
#define THR_ENV_ERROR_PLOSIVE_FX 200 /* threshold for envelope error used in plosive detection Q0 */
+
/*-----------------------------------------------------------------*
* Local function prototypes
*-----------------------------------------------------------------*/
static void create_random_vector_fx( Word16 output[], const Word16 length, Word16 seed[], Word16 element_mode );
static void flip_spectrum_fx( const Word16 input[], Word16 output[], const Word16 length );
-static void Calc_st_filt_tbe( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero );
+static void Calc_st_filt_tbe_fx( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero );
static void Hilbert_transform_fx( Word32 tmp_R[], Word32 tmp_I[], Word32 *tmpi_R, Word32 *tmpi_I, const Word16 length, const Word16 HB_stage_id );
static void Hilbert_transform_sp_fx( Word16 tmp_R[], Word16 tmp_I[], Word32 *tmpi_R, Word32 *tmpi_I, const Word16 length, const Word16 HB_stage_id );
-void Estimate_mix_factors_fx( const Word16 *shb_res, const Word16 Q_shb, const Word16 *exc16kWhtnd, const Word16 Q_bwe_exc, const Word16 *White_exc16k_frac, const Word16 Q_frac, const Word32 pow1, const Word16 Q_pow1, const Word32 pow22, const Word16 Q_pow22, Word16 *vf_modified, Word16 *vf_ind );
+static void Estimate_mix_factors_fx( const Word16 *shb_res, const Word16 Q_shb, const Word16 *exc16kWhtnd, const Word16 Q_bwe_exc, const Word16 *White_exc16k_frac, const Word16 Q_frac, const Word32 pow1, const Word16 Q_pow1, const Word32 pow22, const Word16 Q_pow22, Word16 *vf_modified, Word16 *vf_ind );
+
/*-------------------------------------------------------------------*
* swb_tbe_reset()
@@ -160,85 +159,8 @@ Word16 tbe_celp_exc_offset(
*
* Compute tbe bwe celp excitation
*-------------------------------------------------------------------*/
-void tbe_celp_exc(
- const Word16 L_frame_fx, /* i : Frame lenght */
- const Word16 i_subfr_fx, /* i : sub frame */
- const Word16 T0_fx, /* i : Integer pitch Q0 */
- const Word16 T0_frac_fx, /* i : Fractional part of the pitch Q1 */
- Word16 *error_fx, /* i/o: Error Q5 */
- Word16 *bwe_exc_fx /* i/o: bandwitdh extension signal */
-)
-{
- Word16 offset_fx, tmp_fx, i;
- IF( EQ_16( L_frame_fx, L_FRAME ) )
- {
- /*offset = T0 * HIBND_ACB_L_FAC + (int) ((float) T0_frac * 0.25f * HIBND_ACB_L_FAC + 2 * HIBND_ACB_L_FAC + 0.5f) - 2 * HIBND_ACB_L_FAC;
- for (i=0; i 0 )
- {
- tmp_fx = shr( *error_fx, 5 ); /*Q0*/
- }
- ELSE
- {
- tmp_fx = negate( shr( abs_s( *error_fx ), 5 ) ); /*Q0*/
- }
-
- FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ )
- {
- bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC - offset_fx + tmp_fx]; // Qx
- move16();
- }
- tmp_fx = extract_l( L_mult( T0_frac_fx, 1 ) ); /*Q3; 0.25 in Q2*/
- tmp_fx = add( shl( T0_fx, 3 ), tmp_fx ); /*Q3*/
- tmp_fx = extract_l( L_mult( tmp_fx, 5 ) ); /*Q5, 2.5 in Q1*/
- tmp_fx = sub( shl( offset_fx, 5 ), tmp_fx ); /*Q5*/
- *error_fx = add( *error_fx, tmp_fx ); /*Q5*/
- move16();
- }
- ELSE
- {
- /* offset = T0*2.5 + (int) ((float) T0_frac * 0.25f*2.5 + 2*2.5 + 0.5f) - 2*2.5; - case above*/
- /* offset = T0*2 + (int) ((float) T0_frac * 0.25f*2 + 2*2 + 0.5f) - 2*2; - case here*/
-
- /*(int) ((float) T0_frac * 0.25f*2 + 2*2 + 0.5f)*/
- offset_fx = tbe_celp_exc_offset( T0_fx, T0_frac_fx, L_frame_fx );
- IF( *error_fx > 0 )
- {
- tmp_fx = shr( *error_fx, 5 ); /*Q0*/
- }
- ELSE
- {
- tmp_fx = negate( shr( abs_s( *error_fx ), 5 ) ); /*Q0*/
- }
-
- FOR( i = 0; i < L_SUBFR * 2; i++ )
- {
- bwe_exc_fx[i + i_subfr_fx * 2] = bwe_exc_fx[i + i_subfr_fx * 2 - offset_fx + tmp_fx]; // Qx
- move16();
- }
- /* error += (float) offset - (float) T0 * 2 - 0.5f * (float) T0_frac;*/
- tmp_fx = extract_l( L_mult( T0_frac_fx, 2 ) ); /*Q3; 0.5 in Q2*/
- tmp_fx = add( shl( T0_fx, 4 ), tmp_fx ); /* now tmp_fx = "T0_fx*2+ 0.5f*T0_frac_fx" in Q3*/
- tmp_fx = shl( tmp_fx, 2 ); /*now above tmp_fx in Q5*/
- tmp_fx = sub( shl( offset_fx, 5 ), tmp_fx ); /*move offset_fx to Q5, tmp_fx in Q5, ans tmp_fx in Q5*/
- *error_fx = add( *error_fx, tmp_fx ); /*error_fx in Q5*/
- move16();
- }
-}
-
-/*-------------------------------------------------------------------*
- * swb_tbe_celp_exc_ivas()
- *
- * Compute tbe bwe celp excitation
- *-------------------------------------------------------------------*/
-void tbe_celp_exc_ivas(
+void tbe_celp_exc_fx(
const Word16 element_mode, /* i : element mode */
const Word16 idchan, /* i : channel ID */
const Word16 L_frame_fx, /* i : Frame lenght */
@@ -321,6 +243,8 @@ void tbe_celp_exc_ivas(
*error_fx = add( *error_fx, tmp_fx ); /*error_fx in Q5*/
move16();
}
+
+ return;
}
/*===========================================================================*/
@@ -349,6 +273,14 @@ void tbe_celp_exc_ivas(
/* RETURN ARGUMENTS : */
/* _ None */
/*---------------------------------------------------------------------------*/
+
+static const Word16 local_negsin_table17[17] = { 0, -11793, -22005, -29268, -32609, -31580,
+ -26319, -17530, -6393, 6393, 17530, 26319,
+ 31580, 32609, 29268, 22005, 11793 }; /* Q15 */
+static const Word16 local_cos_table17[17] = { 32767, 30571, 24279, 14732, 3212, -8739,
+ -19519, -27683, -32137, -32137, -27683,
+ -19519, -8739, 3212, 14732, 24279, 30571 }; /* Q15 */
+
void flip_and_downmix_generic_fx(
Word16 input[], /* i : input spectrum Qx*/
Word16 output[], /* o : output spectrum Qx*/
@@ -371,21 +303,11 @@ void flip_and_downmix_generic_fx(
/*Word16 s_tmp[L_FRAME32k];*/
/*Word16 factor;*/
Word16 period;
- Word16 local_negsin_table17[17] = { 0, -11793, -22005, -29268, -32609, -31580,
- -26319, -17530, -6393, 6393, 17530, 26319,
- 31580, 32609, 29268, 22005, 11793 }; /* Q15 */
- Word16 local_cos_table17[17] = { 32767, 30571, 24279, 14732, 3212, -8739,
- -19519, -27683, -32137, -32137, -27683,
- -19519, -8739, 3212, 14732, 24279, 30571 }; /* Q15 */
- Word16 *local_negsin_table, *local_cos_table;
Word32 L_tmp;
/* 1850 Hz downmix */
period = 17;
move16();
- local_negsin_table = local_negsin_table17;
- local_cos_table = local_cos_table17;
-
FOR( i = 0; i < length; i = i + 2 )
{
@@ -467,9 +389,9 @@ void flip_and_downmix_generic_fx(
{
WHILE( ( j < period ) && ( i < length ) )
{
- L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table[j] ); /*//Qx+16 */
- L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table[j] ); /*Qx+16 */
- output[i] = round_fx( L_tmp ); /*Qx */
+ L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table17[j] ); /*//Qx+16 */
+ L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table17[j] ); /*Qx+16 */
+ output[i] = round_fx( L_tmp ); /*Qx */
move16();
i++;
j++;
@@ -511,21 +433,11 @@ void flip_and_downmix_generic_fx32(
/*Word16 s_tmp[L_FRAME32k];*/
/*Word16 factor;*/
Word16 period;
- Word16 local_negsin_table17[17] = { 0, -11793, -22005, -29268, -32609, -31580,
- -26319, -17530, -6393, 6393, 17530, 26319,
- 31580, 32609, 29268, 22005, 11793 }; /* Q15 */
- Word16 local_cos_table17[17] = { 32767, 30571, 24279, 14732, 3212, -8739,
- -19519, -27683, -32137, -32137, -27683,
- -19519, -8739, 3212, 14732, 24279, 30571 }; /* Q15 */
- Word16 *local_negsin_table, *local_cos_table;
Word32 L_tmp;
/* 1850 Hz downmix */
period = 17;
move16();
- local_negsin_table = local_negsin_table17;
- local_cos_table = local_cos_table17;
-
FOR( i = 0; i < length; i = i + 2 )
{
@@ -597,9 +509,9 @@ void flip_and_downmix_generic_fx32(
WHILE( ( j < period ) && ( i < length ) )
{
test();
- L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table[j] ); /*//Qx+16 */
- L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table[j] ); /*Qx+16 */
- output[i] = L_tmp; /*Qx */
+ L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table17[j] ); /*//Qx+16 */
+ L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table17[j] ); /*Qx+16 */
+ output[i] = L_tmp; /*Qx */
move32();
i++;
j++;
@@ -807,9 +719,15 @@ void Calc_rc0_h(
*rc0 = negate( *rc0 );
move16();
}
+
+ return;
}
+#ifdef HARMONIZE_TBE
+static void Calc_rc0_h_ivas_enc_fx(
+#else
void Calc_rc0_h_ivas_enc_fx(
+#endif
Word16 *h, /* i : impulse response of composed filter */
Word16 *rc0 /* o : 1st parcor */
)
@@ -868,7 +786,7 @@ void Calc_rc0_h_ivas_enc_fx(
}
}
-static void Calc_st_filt_tbe(
+static void Calc_st_filt_tbe_fx(
Word16 *apond2, /* i : coefficients of numerator */
Word16 *apond1, /* i : coefficients of denominator */
Word16 *parcor0, /* o : 1st parcor calcul. on composed filter */
@@ -906,6 +824,8 @@ static void Calc_st_filt_tbe(
move16();
}
}
+
+ return;
}
static void Calc_st_filt_tbe_ivas_enc_fx(
@@ -946,8 +866,11 @@ static void Calc_st_filt_tbe_ivas_enc_fx(
move16();
}
}
+
+ return;
}
+#ifndef HARMONIZE_TBE
static void Calc_st_filt_tbe_ivas_dec_fx(
Word16 *apond2, /* i : coefficients of numerator */
Word16 *apond1, /* i : coefficients of denominator */
@@ -986,8 +909,10 @@ static void Calc_st_filt_tbe_ivas_dec_fx(
move16();
}
}
-}
+ return;
+}
+#endif
static void filt_mu_fx(
const Word16 *sig_in, /* i : signal (beginning at sample -1) */
Word16 *sig_out, /* o : output signal */
@@ -1190,7 +1115,7 @@ void PostShortTerm_fx(
move16();
/* Control short term pst filter gain and compute parcor0 */
- Calc_st_filt_tbe( apond2_fx, apond1_fx, &parcor0_fx, sig_ltp_fx + 1, mem_zero );
+ Calc_st_filt_tbe_fx( apond2_fx, apond1_fx, &parcor0_fx, sig_ltp_fx + 1, mem_zero );
/* o: parcor0 in Q15 */
/* i/o: sig_ltp_fx in Q_bwe_exc */
@@ -1310,7 +1235,11 @@ void PostShortTerm_ivas_dec_fx(
move16();
/* Control short term pst filter gain and compute parcor0 */
+#ifdef HARMONIZE_TBE
+ Calc_st_filt_tbe_fx( apond2_fx, apond1_fx, &parcor0_fx, sig_ltp_fx + 1, mem_zero );
+#else
Calc_st_filt_tbe_ivas_dec_fx( apond2_fx, apond1_fx, &parcor0_fx, sig_ltp_fx + 1, mem_zero );
+#endif
/* o: parcor0 in Q15 */
/* i/o: sig_ltp_fx in Q_bwe_exc */
@@ -1327,6 +1256,13 @@ void PostShortTerm_ivas_dec_fx(
return;
}
+
+/*-------------------------------------------------------------------*
+ * flip_spectrum_and_decimby4()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
void flip_spectrum_and_decimby4_fx(
const Word16 input[], /* i : input spectrum Q_inp */
Word16 output[], /* o : output spectrum Q_inp */
@@ -1406,22 +1342,23 @@ void flip_spectrum_and_decimby4_fx(
/*==========================================================================*/
void GenShapedWBExcitation_ivas_fx(
- Word16 *excSHB, /* o : synthesized shaped shb exctiation Q_bwe_exc*/
- const Word16 *lpc_shb, /* i : lpc coefficients Q12*/
- Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation Q_bwe_exc*/
- Word32 *mem_csfilt, /* i/o : memory Q_bwe_exc+16*/
- Word16 *mem_genSHBexc_filt_down1, /* i/o : memory Q_bwe_exc*/
- Word16 *mem_genSHBexc_filt_down2, /* i/o : memory Q_bwe_exc*/
- Word16 *mem_genSHBexc_filt_down3, /* i/o : memory Q_bwe_exc*/
- Word16 *state_lpc_syn, /* i/o : memory Q_bwe_exc*/
- const Word16 coder_type, /* i : coding type */
- const Word16 element_mode, /* i : element mode */
- const Word16 *bwe_exc_extended, /* i : bwidth extended exciatation Q_bwe_exc*/
- const Word16 Q_bwe_exc,
- Word16 bwe_seed[], /* i/o : random number generator seed */
- const Word16 voice_factors[], /* i : voicing factor Q15*/
- const Word16 uv_flag, /* i : unvoiced flag */
- const Word16 igf_flag )
+ Word16 *excSHB, /* o : synthesized shaped shb exctiation Q_bwe_exc*/
+ const Word16 *lpc_shb, /* i : lpc coefficients Q12 */
+ Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation Q_bwe_exc*/
+ Word32 *mem_csfilt, /* i/o: memory Q_bwe_exc+16*/
+ Word16 *mem_genSHBexc_filt_down1, /* i/o: memory Q_bwe_exc*/
+ Word16 *mem_genSHBexc_filt_down2, /* i/o: memory Q_bwe_exc*/
+ Word16 *mem_genSHBexc_filt_down3, /* i/o: memory Q_bwe_exc*/
+ Word16 *state_lpc_syn, /* i/o: memory Q_bwe_exc*/
+ const Word16 coder_type, /* i : coding type */
+ const Word16 element_mode, /* i : element mode */
+ const Word16 *bwe_exc_extended, /* i : bwidth extended exciatation Q_bwe_exc*/
+ const Word16 Q_bwe_exc, /* i : Q for memories */
+ Word16 bwe_seed[], /* i/o: random number generator seed */
+ const Word16 voice_factors[], /* i : voicing factor Q15*/
+ const Word16 uv_flag, /* i : unvoiced flag */
+ const Word16 igf_flag /* i : IGF flag */
+)
{
Word16 i, j, k;
Word16 wht_fil_mem[LPC_WHTN_ORDER_WB];
@@ -2395,9 +2332,7 @@ prev_Q_bwe_exc_fb = *Q_bwe_exc_fb;
move16();
*Q_bwe_exc_fb = sub( add( *Q_bwe_exc, Q_temp ), 13 );
move16();
-deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, tbe_demph );
-/* i/o: White_exc16k (Q_bwe_exc-NOISE_QADJ) */
-/* i: tbe_demph (Q_bwe_exc-NOISE_QADJ) */
+deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, tbe_demph ); // Q_bwe_exc-NOISE_QADJ
{
IF( EQ_16( coder_type, UNVOICED ) )
{
@@ -2412,9 +2347,7 @@ deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, tbe_demph );
move16();
/* exc16kWhtnd: Q_bwe_exc */
}
- PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph );
- /* i/o: exc16kWhtnd (Q_bwe_exc) */
- /* i/o: tbe_premph (Q_bwe_exc) */
+ preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc
}
ELSE
{
@@ -2494,9 +2427,7 @@ deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, tbe_demph );
temp = div_s( temp, temp2 ); /* Q15 */
temp = mult_r( PREEMPH_FAC, temp );
- PREEMPH_FX( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph );
- /* exc16kWhtnd: Q_bwe_exc;
- tbe_premph: Q_bwe_exc*/
+ preemph_fx( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph ); // Q_bwe_exc
}
}
}
@@ -3369,8 +3300,8 @@ void GenShapedSHBExcitation_ivas_enc_fx(
move16();
}
}
- // preemph(exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph);
- PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc
+
+ preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc
}
ELSE
{
@@ -3395,9 +3326,7 @@ void GenShapedSHBExcitation_ivas_enc_fx(
Scale_sig( exc16kWhtnd, L_FRAME16k, sub( *Q_bwe_exc, Q_White_exc16k ) ); // Q_bwe_exc
- PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc
- /* i/o: exc16kWhtnd (Q_bwe_exc) */
- /* i/o: tbe_premph (Q_bwe_exc) */
+ preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc
}
ELSE
{
@@ -3478,9 +3407,7 @@ void GenShapedSHBExcitation_ivas_enc_fx(
temp = div_s( temp, temp2 ); /* Q15 */
temp = mult_r( PREEMPH_FAC, temp );
- PREEMPH_FX( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph ); // Q_bwe_exc
- /* exc16kWhtnd: Q_bwe_exc;
- tbe_premph: Q_bwe_exc*/
+ preemph_fx( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph ); // Q_bwe_exc
}
}
}
@@ -4396,8 +4323,8 @@ void GenShapedSHBExcitation_ivas_dec_fx(
move16();
}
}
- // preemph(exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph);
- PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph );
+
+ preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph );
}
ELSE
{
@@ -4417,9 +4344,7 @@ void GenShapedSHBExcitation_ivas_dec_fx(
exc16kWhtnd[k] = mult_r_sat( White_exc16k[k], scale );
move16();
}
- PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph );
- /* i/o: exc16kWhtnd (Q_exc16kWhtnd) */
- /* i/o: tbe_premph (Q_exc16kWhtnd) */
+ preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_exc16kWhtnd
}
ELSE
{
@@ -4499,9 +4424,7 @@ void GenShapedSHBExcitation_ivas_dec_fx(
temp2 = add( temp, shl( temp1, -1 ) ); /* shift right by 1 to avoid overflow */
temp = div_s( temp, temp2 ); /* Q15 */
temp = mult_r( PREEMPH_FAC, temp );
- PREEMPH_FX( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph );
- /* exc16kWhtnd: Q_exc16kWhtnd;
- tbe_premph: Q_exc16kWhtnd*/
+ preemph_fx( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph ); // Q_exc16kWhtnd
}
}
}
@@ -4969,7 +4892,6 @@ void ScaleShapedSHB_fx(
}
}
-
Q_gFr_norm = norm_l( frame_gain );
if ( frame_gain == 0 )
{
@@ -5207,19 +5129,19 @@ void ScaleShapedSHB_fx32(
*-------------------------------------------------------------------*/
void ScaleShapedWB_fx(
- const Word16 length, /* i : SHB overlap length */
- Word16 *synSHB, /* i/o : synthesized shb signal Q_bwe_exc/Qx */
- Word16 *overlap, /* i/o : buffer for overlap-add Q_bwe_exc/Qx */
- const Word16 *subgain, /* i : subframe gain Q15*/
- const Word32 frame_gain, /* i : frame gain Q18 */
- const Word16 *win, /* i : window Q15*/
- const Word16 *subwin, /* i : subframes window Q15*/
- const Word16 Q_bwe_exc,
- Word16 L_frame, /* i : Frame length - determines whether 12.8 or 16kHz core in-use */
- Word16 dynQ, /* i : indicate whether output is dynamic Q, or Q0 */
- Word16 *Qx, /* o : newly computed Q factor for synSHB */
- Word16 prev_Qx, /* i : prev_Qx for memory scaling */
- Word32 *Hilbert_Mem /* i : Hilbert memory used for computing Qx */
+ const Word16 length, /* i : SHB overlap length */
+ Word16 *synSHB, /* i/o: synthesized shb signal Q_bwe_exc/Qx*/
+ Word16 *overlap, /* i/o: buffer for overlap-add Q_bwe_exc/Qx*/
+ const Word16 *subgain, /* i : subframe gain Q15*/
+ const Word32 frame_gain, /* i : frame gain Q18*/
+ const Word16 *win, /* i : window Q15*/
+ const Word16 *subwin, /* i : subframes window Q15*/
+ const Word16 Q_bwe_exc, /* i : Q for memories */
+ Word16 L_frame, /* i : Frame length - determines whether 12.8 or 16kHz core in-use */
+ Word16 dynQ, /* i : indicate whether output is dynamic Q, or Q0 */
+ Word16 *Qx, /* o : newly computed Q factor for synSHB */
+ Word16 prev_Qx, /* i : prev_Qx for memory scaling */
+ Word32 *Hilbert_Mem /* i : Hilbert memory used for computing Qx */
)
{
const Word16 *skip;
@@ -5229,6 +5151,7 @@ void ScaleShapedWB_fx(
Word16 sum_gain;
Word32 L_tmp;
Word16 max_val, abs_sig, sc1, sc2, shift, max_headroom, min_shift, max_shift, max_shift2;
+
/* Init */
set32_fx( mod_syn, 0, L_FRAME16k + L_SHB_LAHEAD );
@@ -5326,7 +5249,6 @@ void ScaleShapedWB_fx(
}
}
-
max_val = 0;
move16();
FOR( i = 0; i < l_frame + l_shb_lahead; i++ )
@@ -5428,6 +5350,7 @@ void ScaleShapedWB_fx(
return;
}
+
/*-------------------------------------------------------------------*
* non_linearity()
*
@@ -5436,7 +5359,7 @@ void ScaleShapedWB_fx(
static Word32 non_linearity_scaled_copy(
const Word16 input[],
- Word16 j,
+ const Word16 j,
const Word16 length,
Word32 output[],
Word32 prev_scale,
@@ -5446,7 +5369,6 @@ static Word32 non_linearity_scaled_copy(
Word16 i;
Word32 L_tmp;
-
IF( en_abs )
{
FOR( i = 0; i < j; i++ )
@@ -5498,6 +5420,7 @@ static Word32 non_linearity_scaled_copy(
move32();
}
}
+
return prev_scale;
}
@@ -5505,12 +5428,12 @@ static Word32 non_linearity_scaled_copy(
/*-------------------------------------------------------------------*
* non_linearity()
*
- * Apply a non linearity to the SHB excitation
+ * Apply a non linearity to the SHB excitation in IVAS formats
* -------------------------------------------------------------------*/
static Word32 non_linearity_scaled_copy_ivas(
const Word16 input[],
- Word16 j,
+ const Word16 j,
const Word16 length,
Word32 output[],
Word32 prev_scale,
@@ -5520,7 +5443,6 @@ static Word32 non_linearity_scaled_copy_ivas(
Word16 i;
Word32 L_tmp;
-
IF( en_abs )
{
FOR( i = 0; i < j; i++ )
@@ -5608,6 +5530,7 @@ static Word32 non_linearity_scaled_copy_ivas(
move32();
}
}
+
return prev_scale;
}
@@ -5634,15 +5557,15 @@ static Word32 non_linearity_scaled_copy_ivas(
/*==========================================================================*/
void non_linearity_fx(
- const Word16 input[], /* i : input signal Q_inp */
- Word32 output[], /* o : output signal 2*Q_inp */
- const Word16 length, /* i : input length */
- Word32 *pPrevScale, /* i/o: memory Q30 */
- Word16 Q_inp,
- Word16 coder_type, /* i : Coder Type */
- Word16 *voice_factors, /* i : Voice Factors */
- const Word16 L_frame /* i : ACELP frame length */
-
+ const Word16 element_mode, /* i : element mode */
+ const Word16 input[], /* i : input signal Q_inp */
+ Word32 output[], /* o : output signal 2*Q_inp */
+ const Word16 length, /* i : input length */
+ Word32 *pPrevScale, /* i/o: memory Q30 */
+ const Word16 Q_inp, /* i : scaling of input */
+ const Word16 coder_type, /* i : Coder Type */
+ Word16 *voice_factors, /* i : Voice Factors */
+ const Word16 L_frame /* i : ACELP frame length */
)
{
Word16 i, j;
@@ -5664,23 +5587,24 @@ void non_linearity_fx(
Word16 nframes;
Word32 prev_scale;
Word16 length_half;
+ Word16 sc_factor;
+ Word32 prev_scale_factor;
IF( EQ_16( L_frame, L_FRAME16k ) )
{
- nframes = 5;
+ nframes = NB_SUBFR16k;
move16();
ths = 17817;
move16(); /* 0.87*5 in Q12 */
}
ELSE
{
- nframes = 4;
+ nframes = NB_SUBFR;
move16();
ths = 15400;
move16(); /* 0.94*4 in Q12 */
}
-
FOR( i = 0; i < nframes; i++ )
{
v_fac = add( v_fac, shr( voice_factors[i], 3 ) ); /* Q12 */
@@ -5697,7 +5621,6 @@ void non_linearity_fx(
prev_scale = *pPrevScale;
move32();
-
/* Delay Alignment in FX is done inside swb_tbe_enc_fx() */
FOR( i = j = 0; i < length_half; i++ )
@@ -5711,8 +5634,7 @@ void non_linearity_fx(
max_val = s_max( max_val, tmp );
}
-
- IF( GT_16( max_val, shl( 1, Q_inp ) ) )
+ IF( GT_16( max_val, shl_sat( 1, Q_inp ) ) )
{
exp = norm_s( max_val );
tmp = div_s( shl( 1, sub( 14, exp ) ), max_val ); /* Q(29-exp-Q_inp) */
@@ -5724,251 +5646,19 @@ void non_linearity_fx(
move32(); /* Q31; 0.67 in Q31 */
}
- test();
- IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, 32 ), scale ) )
- {
- scale_step = 16384;
- move16(); /* Q14 */
- prev_scale = L_shr( scale, 1 ); /* Q30 */
- }
- ELSE
- {
-
- /* Computing log2(scale) */
- IF( j == 0 )
- {
- scale_step = 32767;
- move16();
- }
- ELSE
- {
- e_tmp = norm_l( scale );
- f_tmp = Log2_norm_lc( L_shl( scale, e_tmp ) );
- e_tmp = sub( -1, e_tmp );
- L_tmp = Mpy_32_16( e_tmp, f_tmp, MAX_16 ); /* Q16 */
-
- /* Computing log2(prev_scale) */
- e_tmp = norm_l( prev_scale );
- f_tmp = Log2_norm_lc( L_shl( prev_scale, e_tmp ) );
- e_tmp = negate( e_tmp );
- L_tmp1 = Mpy_32_16( e_tmp, f_tmp, MAX_16 ); /* Q16 */
-
- /* log2(scale / prev_scale) = log2(scale) - log2(prev_scale) */
- L_tmp = L_sub( L_tmp, L_tmp1 ); /* Q16 */
-
- /* Computing 1/j */
- exp = norm_s( j );
- tmp = div_s( shl( 1, sub( 14, exp ) ), j ); /* Q(29-exp) */
-
- /* (log2(scale / prev_scale))/length */
- L_tmp = L_shl_sat( Mult_32_16( L_tmp, tmp ), sub( exp, 14 ) ); /* Q(16+29-exp+1-16+exp-14)->Q16 */
- frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */
- tmp = extract_l( Pow2( 14, frac ) );
- scale_step = shl_sat( tmp, exp ); /* Q14 */
- }
- }
-
- prev_scale = non_linearity_scaled_copy( input, j, length_half, output, prev_scale, scale_step, en_abs );
-
- max_val = 0;
- move16();
- j = shr( length, 1 );
- FOR( i = length_half; i < length; i++ )
- {
- tmp = abs_s( input[i] );
- if ( GT_16( tmp, max_val ) )
- {
- j = i;
- move16();
- }
- max_val = s_max( max_val, tmp );
- }
-
- IF( GT_16( max_val, shl( 1, Q_inp ) ) )
+ IF( element_mode == EVS_MONO )
{
- exp = norm_s( max_val );
- tmp = div_s( shl( 1, sub( 14, exp ) ), max_val ); /* Q(29-exp-Q_inp) */
- scale = L_shl_sat( L_mult( 21955 /* 0.67 in Q15 */, tmp ), add( exp, sub( Q_inp, 14 ) ) ); /* Q31 */
+ prev_scale_factor = Mult_32_16( prev_scale, 32 );
}
ELSE
{
- scale = 1438814044;
- move32(); /* Q31; 0.67 in Q31 */
+ sc_factor = s_max( sub( 13, norm_s( add( j, 1 ) ) ), 0 ); /* Adapt the scaling factor allowed depending of max position */
+ sc_factor = s_max( sc_factor, 1 ); /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */
+ prev_scale_factor = L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ); /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */
}
test();
- IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, 32 ), scale ) )
- {
- scale_step = 16384;
- move16(); /*Q14 */
- prev_scale = L_shr( scale, 1 ); /*Q30 */
- }
- ELSE
- {
- /*scale_step = (float) exp(1.0f / (float) (j - length/2) * (float) log(scale / prev_scale)); */
- /* Computing log2(scale) */
- IF( EQ_16( j, length_half ) )
- {
- scale_step = 32767;
- move16(); /*Q14 */
- }
- ELSE
- {
- e_tmp = norm_l( scale );
- f_tmp = Log2_norm_lc( L_shl( scale, e_tmp ) );
- e_tmp = sub( -e_tmp, 1 );
- L_tmp = Mpy_32_16( e_tmp, f_tmp, 32767 ); /* Q16 */
-
- /* Computing log2(prev_scale) */
- e_tmp = norm_l( prev_scale );
- f_tmp = Log2_norm_lc( L_shl( prev_scale, e_tmp ) );
- e_tmp = negate( e_tmp );
- L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 32767 ); /* Q16 */
-
- /* log2(scale / prev_scale) = log2(scale) - log2(prev_scale) */
- L_tmp = L_sub( L_tmp, L_tmp1 ); /* Q16 */
-
- /* Computing 1/(j - length/2) */
- tmp = sub( j, length_half );
- exp = norm_s( tmp );
- tmp = div_s( shl( 1, sub( 14, exp ) ), tmp ); /* Q(29-exp) */
-
- /* (log2(scale / prev_scale))/length */
- L_tmp = L_shl_sat( Mult_32_16( L_tmp, tmp ), sub( exp, 14 ) ); /*Q(16+29-exp+1-16+exp-14)->Q16 */
- frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */
- tmp = extract_l( Pow2( 14, frac ) );
- scale_step = shl_sat( tmp, exp ); /*Q14 */
- }
- }
-
- prev_scale = non_linearity_scaled_copy( input + length_half, sub( j, length_half ), sub( length, length_half ), output + length_half, prev_scale, scale_step, en_abs );
-
- *pPrevScale = prev_scale;
- move32();
-
- /* Delay Alignment in FX is done inside swb_tbe_enc_fx() */
-
- return;
-}
-
-
-/*==========================================================================*/
-/* FUNCTION : void non_linearity_ivas_fx() */
-/*--------------------------------------------------------------------------*/
-/* PURPOSE : Apply a non linearity to the SHB excitation */
-/*--------------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* Word16 input[] i : input signal Q_inp */
-/* Word16 length i : input length */
-/*--------------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* Word32 output[] o : output signal 2*Q_inp */
-/*--------------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/* Word32 *prev_scale i/o: memory Q30 */
-/*--------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*--------------------------------------------------------------------------*/
-/* CALLED FROM : */
-/*==========================================================================*/
-
-void non_linearity_ivas_fx(
- const Word16 input[], /* i : input signal Q_inp */
- Word32 output[], /* o : output signal 2*Q_inp */
- const Word16 length, /* i : input length */
- Word32 *pPrevScale, /* i/o: memory Q30 */
- Word16 Q_inp,
- Word16 coder_type, /* i : Coder Type */
- Word16 *voice_factors, /* i : Voice Factors */
- const Word16 L_frame /* i : ACELP frame length */
-
-)
-{
- Word16 i, j;
- Word16 max_val = 0;
- move16();
- Word32 scale;
- Word16 scale_step;
- Word16 exp, tmp;
- Word16 e_tmp, f_tmp;
- Word16 frac;
- Word32 L_tmp;
- Word32 L_tmp1;
-
- Word16 en_abs = 0;
- Word16 v_fac = 0;
- move16();
- move16();
- Word16 ths;
- Word16 nframes;
- Word32 prev_scale;
- Word16 length_half;
- Word16 sc_factor;
-
- IF( EQ_16( L_frame, L_FRAME16k ) )
- {
- nframes = 5;
- move16();
- ths = 17817;
- move16(); /* 0.87*5 in Q12 */
- }
- ELSE
- {
- nframes = 4;
- move16();
- ths = 15400;
- move16(); /* 0.94*4 in Q12 */
- }
-
-
- FOR( i = 0; i < nframes; i++ )
- {
- v_fac = add( v_fac, shr( voice_factors[i], 3 ) ); /* Q12 */
- }
-
- test();
- if ( EQ_16( coder_type, VOICED ) && GT_16( v_fac, ths ) )
- {
- en_abs = 1;
- move16();
- }
-
- length_half = shr( length, 1 );
- prev_scale = *pPrevScale;
- move32();
-
-
- /* Delay Alignment in FX is done inside swb_tbe_enc_fx() */
-
- FOR( i = j = 0; i < length_half; i++ )
- {
- tmp = abs_s( input[i] );
- if ( GT_16( tmp, max_val ) )
- {
- j = i;
- move16();
- }
- max_val = s_max( max_val, tmp );
- }
-
-
- IF( GT_16( max_val, shl_sat( 1, Q_inp ) ) )
- {
- exp = norm_s( max_val );
- tmp = div_s( shl( 1, sub( 14, exp ) ), max_val ); /* Q(29-exp-Q_inp) */
- scale = L_shl( L_mult( 21955, tmp ), add( exp, sub( Q_inp, 14 ) ) ); /* Q31 */
- }
- ELSE
- {
- scale = 1438814044;
- move32(); /* Q31; 0.67 in Q31 */
- }
-
- sc_factor = s_max( sub( 13, norm_s( add( j, 1 ) ) ), 0 ); /* Adapt the scaling factor allowed depending of max position */
- sc_factor = s_max( sc_factor, 1 ); /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */
- test();
- IF( prev_scale <= 0 || GT_32( L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ), scale /*Q31*/ ) ) /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */
+ IF( prev_scale <= 0 || ( GT_32( prev_scale_factor, scale /*Q31*/ ) ) )
{
scale_step = 16384;
move16(); /* Q14 */
@@ -5976,7 +5666,6 @@ void non_linearity_ivas_fx(
}
ELSE
{
-
/* Computing log2(scale) */
IF( j == 0 )
{
@@ -6013,7 +5702,14 @@ void non_linearity_ivas_fx(
}
}
- prev_scale = non_linearity_scaled_copy_ivas( input, j, length_half, output, prev_scale, scale_step, en_abs );
+ IF( element_mode == EVS_MONO )
+ {
+ prev_scale = non_linearity_scaled_copy( input, j, length_half, output, prev_scale, scale_step, en_abs );
+ }
+ ELSE
+ {
+ prev_scale = non_linearity_scaled_copy_ivas( input, j, length_half, output, prev_scale, scale_step, en_abs );
+ }
max_val = 0;
move16();
@@ -6041,12 +5737,19 @@ void non_linearity_ivas_fx(
move32(); /* Q31; 0.67 in Q31 */
}
- /* if ( element_mode > EVS_MONO ) */ /* element mode is not needed because the function is duplicated for IVAS */
- sc_factor = s_max( sub( 12, norm_s( add( sub( j, length_half ), 1 ) ) ), 0 ); /* allowed intra frame jump is smaller */
- sc_factor = s_max( sc_factor, 1 ); /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */
+ IF( element_mode == EVS_MONO )
+ {
+ prev_scale_factor = Mult_32_16( prev_scale, 32 );
+ }
+ ELSE
+ {
+ sc_factor = s_max( sub( 12, norm_s( add( sub( j, length_half ), 1 ) ) ), 0 ); /* allowed intra frame jump is smaller */
+ sc_factor = s_max( sc_factor, 1 ); /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */
+ prev_scale_factor = L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ); /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */
+ }
test();
- IF( prev_scale <= 0 || GT_32( L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ), scale /*Q31*/ ) ) /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */
+ IF( prev_scale <= 0 || ( GT_32( prev_scale_factor, scale /*Q31*/ ) ) )
{
scale_step = 16384;
move16(); /*Q14 */
@@ -6090,7 +5793,14 @@ void non_linearity_ivas_fx(
}
}
- prev_scale = non_linearity_scaled_copy_ivas( input + length_half, sub( j, length_half ), sub( length, length_half ), output + length_half, prev_scale, scale_step, en_abs );
+ IF( element_mode == EVS_MONO )
+ {
+ prev_scale = non_linearity_scaled_copy( input + length_half, sub( j, length_half ), sub( length, length_half ), output + length_half, prev_scale, scale_step, en_abs );
+ }
+ ELSE
+ {
+ prev_scale = non_linearity_scaled_copy_ivas( input + length_half, sub( j, length_half ), sub( length, length_half ), output + length_half, prev_scale, scale_step, en_abs );
+ }
*pPrevScale = prev_scale;
move32();
@@ -6119,6 +5829,7 @@ void create_random_vector_fx(
Word16 i, j, k;
Word16 scale1, scale2;
Word32 L_tmp;
+
/*
Note: the constant 2144047674 is 0.0078f in Q38 from the float reference.
It should read 0.0078125f, which is 1/128.Since 0.0078f is nor exactly
@@ -6129,34 +5840,34 @@ void create_random_vector_fx(
#ifdef FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT
if ( element_mode != EVS_MONO )
{
- L_tmp = L_abs( Mpy_32_16_r( 2144047674, Random( &seed[0] ) ) ); /*Q23 */
+ j = shr( abs_s( Random( &seed[0] ) ), 7 ); /* Random( &seed[0] * 0.0078125f ) */
}
else
{
L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */
+ j = extract_l( L_shr( L_tmp, 23 ) );
}
#else
- L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */
-#endif
-
+ L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */
j = extract_l( L_shr( L_tmp, 23 ) );
+#endif
j = s_and( j, 0xff );
#ifdef FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT
if ( element_mode != EVS_MONO )
{
- L_tmp = L_abs( Mpy_32_16_r( 2144047674, Random( &seed[1] ) ) ); /*Q23 */
+ k = shr( abs_s( Random( &seed[1] ) ), 7 ); /* Random( &seed[0] * 0.0078125f ) */
}
else
{
L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */
+ k = extract_l( L_shr( L_tmp, 23 ) );
}
-
#else
- L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */
+ L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */
+ k = extract_l( L_shr( L_tmp, 23 ) );
#endif
- k = extract_l( L_shr( L_tmp, 23 ) );
k = s_and( k, 0xff );
WHILE( EQ_16( k, j ) )
@@ -6164,17 +5875,18 @@ void create_random_vector_fx(
#ifdef FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT
if ( element_mode != EVS_MONO )
{
- L_tmp = L_abs( Mpy_32_16_r( 2144047674, Random( &seed[1] ) ) ); /*Q23 */
+ k = shr( abs_s( Random( &seed[1] ) ), 7 );
}
else
{
L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */
+ k = extract_l( L_shr( L_tmp, 23 ) );
}
#else
L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */
+ k = extract_l( L_shr( L_tmp, 23 ) );
#endif
- k = extract_l( L_shr( L_tmp, 23 ) );
k = s_and( k, 0xff );
}
@@ -6308,6 +6020,7 @@ void interp_code_5over2_fx(
Ltemp = L_mult( inp_code_fx[kk], factor_j_fx[1] ); /*Q(16+x) */
interp_code_fx[i + 1] = round_fx( Ltemp ); /*Qx */
move16();
+
return;
}
@@ -6535,7 +6248,6 @@ void elliptic_bpf_48k_generic_fx(
} /*IsUpsampled3*/
-
memory_fx2[0][0] = input_fx[L_FRAME48k - 4];
memory_fx2[0][1] = input_fx[L_FRAME48k - 3];
memory_fx2[0][2] = input_fx[L_FRAME48k - 2];
@@ -6583,7 +6295,6 @@ void elliptic_bpf_48k_generic_fx(
}
}
-
Q_temp = norm_l( L_tmpMax );
Q_temp = sub( Q_temp, 4 );
Scale_sig32( L_tmp2, 960, Q_temp );
@@ -6645,7 +6356,6 @@ void elliptic_bpf_48k_generic_fx(
}
}
-
memory_fx2[2][0] = L_tmp2[L_FRAME48k - 4];
memory_fx2[2][1] = L_tmp2[L_FRAME48k - 3];
memory_fx2[2][2] = L_tmp2[L_FRAME48k - 2];
@@ -6683,6 +6393,8 @@ void elliptic_bpf_48k_generic_fx(
return;
}
+
+
/*-------------------------------------------------------------------*
* synthesise_fb_high_band()
*
@@ -6739,20 +6451,12 @@ void synthesise_fb_high_band_fx(
IF( EQ_16( L_frame, L_FRAME16k ) )
{
/* for 16kHz ACELP core */
- elliptic_bpf_48k_generic_fx(
- element_mode,
- 1, // IsUpsampled3
- excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_3_fx
-
- );
+ elliptic_bpf_48k_generic_fx( element_mode, 1, /* IsUpsampled3 */ excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_3_fx );
}
ELSE
{
/* for 12.8kHz ACELP core */
- elliptic_bpf_48k_generic_fx(
- element_mode,
- 1, // IsUpsampled3
- excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_1_fx );
+ elliptic_bpf_48k_generic_fx( element_mode, 1, /* IsUpsampled3 */ excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_1_fx );
}
/* temp1 = sum2_f( tmp, L_FRAME48k ) + 0.001f */
temp1 = sum2_fx_mod( tmp, L_FRAME48k );
@@ -6835,15 +6539,18 @@ void synthesise_fb_high_band_fx(
move16();
}
}
+
return;
}
+
/*-------------------------------------------------------------------*
* Estimate_mix_factors_fx() *
* *
* Estimate mix factors for SHB excitation generation *
*-------------------------------------------------------------------*/
-void Estimate_mix_factors_fx(
+
+static void Estimate_mix_factors_fx(
const Word16 *shb_res, /* i : SHB LP residual in Q = Q_shb */
const Word16 Q_shb,
const Word16 *exc16kWhtnd, /* i : SHB transformed low band excitation Q_bwe_exc */
@@ -6907,7 +6614,6 @@ void Estimate_mix_factors_fx(
/* (Q_bwe_exc) */
}
-
length = L_FRAME16k;
move16();
temp_p1_p2 = Dot_product( temp_numer1, temp_numer2, length ); /* 2*(Q_bwe_exc)+1 */
@@ -6983,6 +6689,7 @@ void Estimate_mix_factors_fx(
return;
}
+
/*======================================================================================*/
/* FUNCTION : prep_tbe_exc_fx() */
/*--------------------------------------------------------------------------------------*/
@@ -7032,7 +6739,6 @@ void prep_tbe_exc_fx(
const Word16 idchan, /* i : channel ID */
const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */
const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */
-
)
{
Word16 i;
diff --git a/lib_com/tcx_ltp_fx.c b/lib_com/tcx_ltp_fx.c
index 4eb334205f5230fce05a392f84970bacb68586f5..29febbbfc0ba569368b8fa6ace26bdcf9756765a 100644
--- a/lib_com/tcx_ltp_fx.c
+++ b/lib_com/tcx_ltp_fx.c
@@ -401,9 +401,14 @@ void predict_signal(
x0--;
}
- win = &inter4_2tcx2[frac][0]; /* Q15 */
- if ( EQ_16( frac_max, 6 ) )
+ IF( EQ_16( frac_max, 6 ) )
+ {
win = &inter6_2tcx2[frac][0]; /* Q15 */
+ }
+ ELSE
+ {
+ win = &inter4_2tcx2[frac][0]; /* Q15 */
+ }
FOR( j = 0; j < L_subfr; j++ )
{
diff --git a/lib_com/tcx_mdct_window_fx.c b/lib_com/tcx_mdct_window_fx.c
index 6075d034be9cd9ae81541781278913106d5fbc37..dd3ad48feedb75dd5440e59510b8e76c4966b882 100644
--- a/lib_com/tcx_mdct_window_fx.c
+++ b/lib_com/tcx_mdct_window_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c
index 4d5107de70b8027fe4ba7e9ac5febd9e22f14e1c..cd5ad9667d9fd56c238f1809e5e46a7978e5d686 100644
--- a/lib_com/tools_fx.c
+++ b/lib_com/tools_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_com/trans_direct_fx.c b/lib_com/trans_direct_fx.c
index 4e259e0cc5076d1d74b4a16d3ed1410fdad505f4..c84cd9efad4c495df32efee54db2a27c02a2faa0 100644
--- a/lib_com/trans_direct_fx.c
+++ b/lib_com/trans_direct_fx.c
@@ -76,14 +76,13 @@ void direct_transform_fx(
move32();
}
- iseg_fx = &in32_r16_fx[-segment_length4]; /*Q*/
- oseg_fx = out32_fx; /*Q*/
+ oseg_fx = out32_fx; /*Q*/
wh_fx = &win_fx[segment_length4]; /*Q15*/
wl_fx = wh_fx - 1; /*Q15*/
shift = extract_l( L_mult0( 3, segment_length4 ) ); /*Q0*/
- sh_fx = &iseg_fx[shift]; /*Q*/
+ sh_fx = &in32_r16_fx[segment_length2]; /*Q*/
sl_fx2 = sh_fx - 1; /*Q*/
@@ -94,7 +93,7 @@ void direct_transform_fx(
move32();
}
- sl_fx2 = &iseg_fx[( segment_length2 - 1 )]; /*Q*/
+ sl_fx2 = &in32_r16_fx[( segment_length4 - 1 )]; /*Q*/
FOR( i = segment_length4; i < segment_length2; i++ )
{
@@ -107,7 +106,7 @@ void direct_transform_fx(
edct_fx( dctin32_fx, oseg_fx, segment_length2, &Qs[0] );
Qmin = s_min( Qs[0], Qmin );
- iseg_fx += segment_length2;
+ iseg_fx = &in32_r16_fx[segment_length4];
oseg_fx += segment_length2;
FOR( seg = 1; seg < NUM_TIME_SWITCHING_BLOCKS - 1; seg++ )
diff --git a/lib_com/trans_inv_fx.c b/lib_com/trans_inv_fx.c
index 8bf63fccac0734f9e46e5332ae9ba842825e42ea..34d424f26e0bcdebff96c44bcc3584ff2f2f725c 100644
--- a/lib_com/trans_inv_fx.c
+++ b/lib_com/trans_inv_fx.c
@@ -1032,7 +1032,7 @@ void Inverse_Transform(
}
}
- out_segment = out_alias - segment_length_div4;
+ out_segment = out_alias;
in_segment = in_mdct_modif; /*Q*/
tmp = *Q;
@@ -1051,7 +1051,7 @@ void Inverse_Transform(
FOR( ta = segment_length_div4; ta < segment_length_div2; ta++ )
{
- out_segment[ta] = L_shr( alias[ta], tmp ); /*q_out*/
+ *out_segment++ = L_shr( alias[ta], tmp ); /*q_out*/
move32();
}
/* This previous loop fills the output buffer from [0..seg_len_div4-1] */
@@ -1059,13 +1059,13 @@ void Inverse_Transform(
win2 = &win[segment_length_div2]; /*Q15*/
FOR( ta = segment_length_div2; ta < segment_length; ta++ )
{
- out_segment[ta] = L_shr( Mult_32_16( alias[ta], *--win2 ), tmp ); /*q_out*/
+ *out_segment++ = L_shr( Mult_32_16( alias[ta], *--win2 ), tmp ); /*q_out*/
move32();
}
/* This previous loop fills the output buffer from [seg_len_div4..seg_len-seg_len_div4-1] */
- out_segment += segment_length_div2; /*q_out*/
- in_segment += segment_length_div2; /*Q*/
+ out_segment = &out_alias[segment_length_div4]; /*q_out*/
+ in_segment += segment_length_div2; /*Q*/
FOR( seg = 1; seg < NUM_TIME_SWITCHING_BLOCKS - 1; seg++ )
{
diff --git a/lib_debug/debug.c b/lib_debug/debug.c
index f9b0e34c3d44bbbfc4c40ae16464fc3dfa83caac..59ca6252eee2afbbfdd03ee7c96f23e10d99f7b4 100644
--- a/lib_debug/debug.c
+++ b/lib_debug/debug.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_debug/debug.h b/lib_debug/debug.h
index f1a40606b0b56ff98ca436fce7cac7c6b2bb65c4..5d905d0e467e61ac787397982da38c6a3a0e9880 100644
--- a/lib_debug/debug.h
+++ b/lib_debug/debug.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_debug/sba_debug.c b/lib_debug/sba_debug.c
index 18892a0d527981ebaf42e221c6e202849b229ddd..5f7e846ae1bd166a5354b72507356e9a570f0bb2 100644
--- a/lib_debug/sba_debug.c
+++ b/lib_debug/sba_debug.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_debug/sba_debug.h b/lib_debug/sba_debug.h
index 2be427d524e82f92deec2ab9e8c0964374474dab..850e7ab67460da4f0aace38de4956e4772be23ff 100644
--- a/lib_debug/sba_debug.h
+++ b/lib_debug/sba_debug.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_debug/snr.c b/lib_debug/snr.c
index cf15a2907b50dec0580121c2773f91191c8b4afc..743a632a609ae7e4b3170cd43e0dec193aa6e207 100644
--- a/lib_debug/snr.c
+++ b/lib_debug/snr.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ACcontextMapping_dec_fx.c b/lib_dec/ACcontextMapping_dec_fx.c
index 60269751b1da0ff3c090390a467677449519fc6d..9b6ac8434f6235b4fd38a4c91d051cfdcf0748c9 100644
--- a/lib_dec/ACcontextMapping_dec_fx.c
+++ b/lib_dec/ACcontextMapping_dec_fx.c
@@ -614,6 +614,7 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx(
move16();
s = 0;
move16();
+
/* Main Loop through the 2-tuples */
FOR( k = 0; k < lastnz; k += 2 )
{
@@ -701,9 +702,9 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx(
c = add( 12, esc_nb );
}
- s = (UWord16) L_shl( s, 4 ); /*Shift old 4 bits*/
- s = (UWord16) L_add( s, c ); /*replace last 4 bits*/
- t = (UWord16) L_and( s, 0xFF );
+ s = shl( s_and( s, 0x0F ), 4 ); /*Shift old 4 bits*/
+ s = add( s, c ); /*replace last 4 bits*/
+ t = s_and( s, 0xFF );
}
/* Decode signs */
diff --git a/lib_dec/FEC_HQ_core_fx.c b/lib_dec/FEC_HQ_core_fx.c
index 43d1e26276cd38025a1f819bc580aa761ea3ec8d..641f6005913ec14383212465558f765c5cd7975c 100644
--- a/lib_dec/FEC_HQ_core_fx.c
+++ b/lib_dec/FEC_HQ_core_fx.c
@@ -399,285 +399,6 @@ void HQ_FEC_processing_fx(
return;
}
-void ivas_HQ_FEC_Mem_update_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- Word32 *t_audio_q_fx, /*Q12*/
- Word32 *normq_fx, /*Q14*/
- Word16 *ynrm,
- Word16 *Num_bands_p,
- Word16 is_transient,
- Word16 hqswb_clas,
- Word16 c_switching_flag,
- Word16 nb_sfm,
- Word16 num_Sb,
- Word16 *mean_en_high_fx, /*Q5*/
- Word16 hq_core_type, /* i : normal or low-rate MDCT(HQ) core */
- Word16 output_frame )
-{
- Word16 Min_ind;
- Word32 Min_value;
- Word16 Max_ind;
- Word16 stat_mode_curr;
-
- Word16 i, j, k;
- Word16 offset;
- Word16 exp, exp1, exp2, tmp_fx;
- Word32 *norm_values_fx; // Q12
- Word32 L_tmp, tmp_energy_fx = 0 /*Q8*/, Max_coeff_fx /*Q12*/;
- Word32 en_high_fx[MAX_SB_NB]; // Q12
- HQ_NBFEC_HANDLE hHQ_nbfec;
- HQ_DEC_HANDLE hHQ_core;
- hHQ_nbfec = st_fx->hHQ_nbfec;
- hHQ_core = st_fx->hHQ_core;
- move32(); // for tmp_energy_fx
- IF( EQ_16( output_frame, L_FRAME8k ) )
- {
-
- IF( is_transient )
- {
- set16_fx( hHQ_nbfec->prev_sign_switch_2, 0, HQ_FEC_SIGN_SFM );
- set16_fx( hHQ_nbfec->prev_sign_switch, 0, HQ_FEC_SIGN_SFM );
- }
- ELSE
- {
- FOR( j = 0; j < HQ_FEC_SIGN_SFM; j++ )
- {
- hHQ_nbfec->prev_sign_switch[j] = hHQ_nbfec->prev_sign_switch_2[j];
- move16();
- hHQ_nbfec->prev_sign_switch_2[j] = 0;
- move16();
-
- FOR( i = 0; i < HQ_FEC_BAND_SIZE; i++ )
- {
- test();
- test();
- test();
- IF( ( hHQ_nbfec->old_coeffs_fx[i + j * HQ_FEC_BAND_SIZE] > 0 && t_audio_q_fx[i + j * HQ_FEC_BAND_SIZE] < 0 ) || ( hHQ_nbfec->old_coeffs_fx[i + j * HQ_FEC_BAND_SIZE] < 0 && t_audio_q_fx[i + j * HQ_FEC_BAND_SIZE] > 0 ) )
- {
- hHQ_nbfec->prev_sign_switch[j] = add( hHQ_nbfec->prev_sign_switch[j], 1 );
- move16();
- hHQ_nbfec->prev_sign_switch_2[j] = add( hHQ_nbfec->prev_sign_switch_2[j], 1 );
- move16();
- }
- }
- }
- }
- /* if LR MDCT core is used, recalculate norms from decoded MDCT spectrum (using code from hq_hr_enc_fx()) */
- test();
- IF( ( EQ_16( hqswb_clas, HQ_HVQ ) ) || ( EQ_16( hq_core_type, LOW_RATE_HQ_CORE ) ) )
- {
- /* First group */
- logqnorm_fx( t_audio_q_fx, 12, ynrm, 32, WID_G1, (const Word16) EQ_16( hqswb_clas, HQ_HVQ ) );
- j = ynrm[0];
- move16();
- offset = WID_G1;
- move16();
-
- FOR( i = 1; i < SFM_G1; i++ )
- {
- logqnorm_fx( &t_audio_q_fx[offset], 12, &ynrm[i], 40, WID_G1, (const Word16) EQ_16( hqswb_clas, HQ_HVQ ) );
- offset = add( offset, WID_G1 );
- }
-
- /* Second group */
- FOR( i = SFM_G1; i < SFM_G1 + 2; i++ )
- {
- logqnorm_fx( &t_audio_q_fx[offset], 12, &ynrm[i], 40, WID_G2, (const Word16) EQ_16( hqswb_clas, HQ_HVQ ) );
- offset = add( offset, WID_G2 );
- }
- }
-
- /* Memory update for the LGF log2 Norm */
- FOR( i = 0; i < nb_sfm; i++ )
- {
- normq_fx[i] = dicn_fx[ynrm[i]];
- move32();
- }
- k = 0;
- move16();
- FOR( i = 0; i < num_Sb; i++ )
- {
- norm_values_fx = &hHQ_nbfec->ynrm_values_fx[i][0];
- Copy32( norm_values_fx, &norm_values_fx[1], MAX_PGF - 1 );
-
- L_tmp = L_deposit_l( 0 );
- FOR( j = 0; j < Num_bands_p[i]; j++ )
- {
- L_tmp = L_add( L_tmp, L_shr( normq_fx[k], 3 ) ); /*11*/
- k = add( k, 1 );
- }
- tmp_fx = shl_sat( inv_tbl_fx[Num_bands_p[i]], 1 ); /*16*/
- norm_values_fx[0] = Mult_32_16( L_tmp, tmp_fx ); /*11 + 16 - 15*/
- move32();
- tmp_energy_fx = L_add( tmp_energy_fx, L_shr( L_tmp, 3 ) ); /*8*/
- }
- test();
- test();
- IF( ( c_switching_flag ) || ( ( st_fx->last_core == ACELP_CORE ) && ( EQ_16( st_fx->core, HQ_CORE ) ) ) )
- {
- FOR( i = 0; i < MAX_SB_NB; i++ )
- {
- FOR( j = 1; j < MAX_PGF; j++ )
- {
- hHQ_nbfec->ynrm_values_fx[i][j] = hHQ_nbfec->ynrm_values_fx[i][0];
- move32();
- }
- }
- }
- set16_fx( hHQ_nbfec->Norm_gain_fx, 32767, SFM_N_NB ); /*15*/
- /* st->energy_MA_Curr[1]=Energy of the current frame */
- tmp_fx = inv_tbl_fx[nb_sfm];
- move16(); /*15*/
- L_tmp = Mult_32_16( tmp_energy_fx, tmp_fx ); /*8 + 15 - 15*/
-
- hHQ_nbfec->energy_MA_Curr_fx[1] = extract_h( L_shl( L_tmp, 16 - 8 ) );
- move16();
- /* Moving Average */
- hHQ_nbfec->energy_MA_Curr_fx[0] = s_max( 1, add( mult_r( 26214, hHQ_nbfec->energy_MA_Curr_fx[0] ), mult_r( 6554, hHQ_nbfec->energy_MA_Curr_fx[1] ) ) );
- move16();
-
- /*st->diff_energy = (float)fabs((st->energy_MA_Curr[1] - st->energy_MA_Curr[0])/st->energy_MA_Curr[0]); */
- hHQ_nbfec->diff_energy_fx = abs_s( sub( hHQ_nbfec->energy_MA_Curr_fx[1], hHQ_nbfec->energy_MA_Curr_fx[0] ) );
- move16();
- exp1 = sub( norm_l( hHQ_nbfec->diff_energy_fx ), 1 );
- exp2 = norm_l( hHQ_nbfec->energy_MA_Curr_fx[0] );
- hHQ_nbfec->diff_energy_fx = div_s( extract_h( L_shl( hHQ_nbfec->diff_energy_fx, exp1 ) ), extract_h( L_shl( hHQ_nbfec->energy_MA_Curr_fx[0], exp2 ) ) );
- move16();
- exp = add( 15, sub( exp1, exp2 ) );
- hHQ_nbfec->diff_energy_fx = shl( hHQ_nbfec->diff_energy_fx, sub( 11, exp ) ); /*11*/
- move16();
-
- /* Classify the stationary mode : 12% */
- IF( LT_16( hHQ_nbfec->diff_energy_fx, ED_THRES_12P_fx ) )
- {
- stat_mode_curr = 1;
- move16();
- }
- ELSE
- {
- stat_mode_curr = 0;
- move16();
- }
-
- /* Apply Hysteresis to prevent frequent mode changing */
- if ( EQ_16( hHQ_nbfec->stat_mode_old, stat_mode_curr ) )
- {
- hHQ_nbfec->stat_mode_out = stat_mode_curr;
- move16();
- }
-
- hHQ_nbfec->stat_mode_old = stat_mode_curr;
- move16();
-
- /* Find max. band index (Minimum value means maximum energy) */
- Min_ind = 0;
- move16();
- Min_value = L_deposit_l( 100 );
- FOR( i = 0; i < num_Sb; i++ )
- {
- IF( GT_32( Min_value, ynrm[i] ) )
- {
- Min_value = ynrm[i];
- move16();
- Min_ind = i;
- move16();
- }
- }
-
- /* Find max. coeff in band 0 */
- Max_ind = 0;
- move16();
- IF( Min_ind == 0 )
- {
- Max_coeff_fx = L_deposit_l( 0 );
- FOR( i = 0; i < 8; i++ )
- {
- L_tmp = L_abs( t_audio_q_fx[i] ); // Q12
- IF( LT_32( Max_coeff_fx, L_tmp ) )
- {
- Max_coeff_fx = L_add( L_tmp, 0 );
- Max_ind = i;
- move16();
- }
- }
- }
-
- /* Find energy difference from band 16 */
- k = 1;
- move16();
-
- FOR( i = k; i < num_Sb; i++ )
- {
- en_high_fx[i] = L_deposit_l( 0 );
- FOR( j = 0; j < 2; j++ )
- {
- /*en_high[i] += 0.5f*st->ynrm_values[i][j+1];*/
- en_high_fx[i] = L_add( en_high_fx[i], L_shr( hHQ_nbfec->ynrm_values_fx[i][j + 1], 1 ) ); /*Q12*/
- move32();
- }
- }
-
- *mean_en_high_fx = 0;
- move16();
- FOR( i = k; i < num_Sb; i++ )
- {
- /* *mean_en_high += (float)(en_high[i]/st->ynrm_values[i][0]);*/
- exp1 = sub( norm_l( en_high_fx[i] ), 1 );
- exp2 = norm_l( hHQ_nbfec->ynrm_values_fx[i][0] );
- tmp_fx = div_s( extract_h( L_shl( en_high_fx[i], exp1 ) ), extract_h( L_shl( hHQ_nbfec->ynrm_values_fx[i][0], exp2 ) ) );
- exp = add( 15, sub( exp1, exp2 ) );
- *mean_en_high_fx = add_sat( *mean_en_high_fx, shr_sat( tmp_fx, sub( exp, 5 ) ) );
- move16();
- }
- *mean_en_high_fx = mult( *mean_en_high_fx, inv_tbl_fx[sub( num_Sb, k )] );
- move16();
-
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( LT_16( Min_ind, 5 ) ) && ( LT_16( abs_s( sub( Min_ind, hHQ_nbfec->old_Min_ind ) ), 2 ) ) && ( LT_16( hHQ_nbfec->diff_energy_fx, ED_THRES_90P_fx ) ) && ( !st_fx->bfi ) && ( !st_fx->prev_bfi ) && ( !st_fx->prev_old_bfi ) && ( !is_transient ) && ( !hHQ_core->old_is_transient[1] ) && ( EQ_16( hHQ_nbfec->prev_last_core, HQ_CORE ) ) && ( EQ_16( st_fx->last_core, HQ_CORE ) ) )
- {
- hHQ_nbfec->phase_mat_flag = 1;
- move16();
- test();
- if ( ( Min_ind == 0 ) && ( LT_16( Max_ind, 3 ) ) )
- {
- hHQ_nbfec->phase_mat_flag = 0;
- move16();
- }
- }
- ELSE
- {
- hHQ_nbfec->phase_mat_flag = 0;
- move16();
- }
-
- hHQ_nbfec->old_Min_ind = Min_ind;
- move16();
-
- FOR( i = 0; i < L_FRAME8k; i++ )
- {
- hHQ_nbfec->old_coeffs_fx[i] = t_audio_q_fx[i];
- move32();
- }
- }
-
- hHQ_core->old_is_transient[2] = hHQ_core->old_is_transient[1];
- move16();
- hHQ_core->old_is_transient[1] = hHQ_core->old_is_transient[0];
- move16();
- hHQ_core->old_is_transient[0] = is_transient;
- move16();
-
- return;
-}
-
void HQ_FEC_Mem_update_fx(
Decoder_State *st_fx, /* i/o: decoder state structure */
Word32 *t_audio_q_fx, /*Q12*/
diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c
index e163662c8d2a4a4f9b14b3103e64850f3146151c..5dcc848ade5ef21ec0c3ac49eba9c3fb24e7add3 100644
--- a/lib_dec/acelp_core_dec_fx.c
+++ b/lib_dec/acelp_core_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -74,7 +74,9 @@ ivas_error acelp_core_dec_fx(
const Word16 read_sid_info /* i : read SID info flag */
)
{
+#ifndef FIX_BASOP_2350_HARM_0B_BWE_2
Word32 synth_fx[960], save_hb_synth_fx[960] /*, bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]*/;
+#endif
Word16 old_exc_fx[L_EXC_DEC], *exc_fx; /* excitation signal buffer */
Word16 syn_tmp_fx[L_FRAME16k + L_SUBFR], *psyn_fx; /* synthesis signal buffer */
Word16 output_frame; /* frame length at output sampling freq. */
@@ -968,7 +970,7 @@ ivas_error acelp_core_dec_fx(
tmpF_fx = *old_exc_s_fx;
st->mem_deemph_fx = shl_sat( old_exc_s_fx[st->L_frame - 1], st->Q_syn ); /* Q0 -> Q_syn */
move16();
- PREEMPH_FX( old_exc_s_fx, st->preemph_fac, st->L_frame, &tmpF_fx );
+ preemph_fx( old_exc_s_fx, st->preemph_fac, st->L_frame, &tmpF_fx );
Copy( old_exc_s_fx + sub( st->L_frame, M ), st->mem_syn2_fx, M );
Scale_sig( st->mem_syn2_fx, M, st->Q_syn ); /* Q0 -> Q_syn */
Residu3_fx( Aq_fx, old_exc_s_fx, old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, 0 );
@@ -1035,7 +1037,7 @@ ivas_error acelp_core_dec_fx(
test();
IF( ( st->stab_fac_fx == 0 ) && ( st->old_bfi_cnt > 0 ) && NE_16( st->clas_dec, VOICED_CLAS ) && NE_16( st->clas_dec, ONSET ) && ( st->relax_prev_lsf_interp == 0 ) && !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) )
{
- int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 );
+ int_lsp4_fx( st->L_frame, st->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 );
}
/*---------------------------------------------------------------*
@@ -1896,6 +1898,9 @@ ivas_error acelp_core_dec_fx(
st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type, st->Q_syn, bpf_error_signal_16fx );
}
+#ifdef FIX_BASOP_2350_HARM_0B_BWE_2
+ Word32 synth_fx[L_FRAME48k];
+#endif
Word32 syn_tmp_32_fx[L_FRAME16k + L_SUBFR], *syn_32_fx;
set32_fx( syn_tmp_32_fx, 0, L_FRAME16k + L_SUBFR );
syn_32_fx = syn_tmp_32_fx + L_SUBFR;
@@ -2049,7 +2054,11 @@ ivas_error acelp_core_dec_fx(
}
}
- cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB );
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*tmp buffer for save_hb_synth_fx[] */, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB );
+
+#ifdef FIX_BASOP_2350_HARM_0B_BWE_2
+ Copy_Scale_sig_32_16( synth_fx, save_hb_synth_fx16, output_frame, 0 ); // Q0
+#endif
/* restore lowband */
FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
@@ -2103,7 +2112,11 @@ ivas_error acelp_core_dec_fx(
}
/* save synthesis - needed in case of core switching */
+#ifdef FIX_2379_REMOVE_previoussynth_fx_32
+ Copy_Scale_sig_32_16( synth_fx, st->previoussynth_fx, output_frame, 0 ); // Q0
+#else
Copy32( synth_fx, st->previoussynth_fx_32, output_frame ); // Q0
+#endif
}
ELSE
{
@@ -2197,6 +2210,9 @@ ivas_error acelp_core_dec_fx(
Copy( psyn_fx, output_fx, st->L_frame ); /*Q_syn*/
}
+#ifdef FIX_BASOP_2350_HARM_0B_BWE_2
+ Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q_syn2
+#endif
st->Q_syn2 = 0;
move16();
}
@@ -2217,16 +2233,20 @@ ivas_error acelp_core_dec_fx(
IF( ( EQ_16( st->L_frame, L_FRAME ) && ( st->bwidth != NB ) && GE_16( output_frame, L_FRAME16k ) &&
( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) || ( EQ_16( st->extl, WB_BWE ) && st->extl_brate == 0 && NE_16( st->coder_type, AUDIO ) ) ) ) )
{
+#ifdef FIX_BASOP_2350_HARM_0B_BWE_2
+ hf_synth_fx( st->hBWE_zero, st->element_mode, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 );
+#else
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
- hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 );
+ hf_synth_fx( st->hBWE_zero, EVS_MONO, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 );
}
ELSE
{
Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q0
- hf_synth_ivas_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 );
+ hf_synth_fx( st->hBWE_zero, st->element_mode, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 );
Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, output_frame, 0 );
}
+#endif
}
ELSE
{
@@ -2277,12 +2297,12 @@ ivas_error acelp_core_dec_fx(
{
IF( EQ_16( st->element_mode, EVS_MONO ) )
{
- non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame );
+ non_linearity_fx( st->element_mode, bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame );
}
ELSE
{
Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( st->Q_exc, 1 ), st->hBWE_TD->q_old_bwe_exc_extended_fx ) ) ); /* Q(q_old_bwe_exc_extended_fx) -> Q(2 * Q_exc) */
- non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame );
+ non_linearity_fx( st->element_mode, bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame );
exp = sub( L_norm_arr( bwe_exc_extended_fx + L_FRAME32k, NL_BUFF_OFFSET ), 16 );
Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, exp ); /* Q(2 * Q_exc) -> Q(q_old_bwe_exc_extended_fx) */
st->hBWE_TD->q_old_bwe_exc_extended_fx = add( shl( st->Q_exc, 1 ), exp );
@@ -2309,17 +2329,8 @@ ivas_error acelp_core_dec_fx(
IF( GT_32( st->core_brate, SID_2k40 ) && st->hTdCngDec != NULL && st->hFdCngDec != NULL )
{
/* update CNG parameters in active frames */
- IF( EQ_16( st->element_mode, EVS_MONO ) )
- {
- cng_params_upd_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx,
- st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate );
- }
- ELSE
- {
- cng_params_upd_ivas_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size,
- st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode,
- st->hFdCngDec->hFdCngCom->CngBandwidth );
- }
+ cng_params_upd_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx,
+ st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth );
/* Set 16k LSP flag for CNG buffer */
st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 0;
@@ -2331,23 +2342,16 @@ ivas_error acelp_core_dec_fx(
}
}
+#ifndef FIX_BASOP_2350_HARM_0B_BWE_2
IF( NE_16( st->element_mode, EVS_MONO ) )
{
-#ifdef FIX_2252_SCALING_SAVE_HB_SYNTH
IF( save_hb_synth_fx16 != NULL )
-#else
- IF( save_hb_synth_fx16 )
-#endif
{
-#ifdef FIX_2252_SCALING_SAVE_HB_SYNTH
Copy_Scale_sig_32_16( save_hb_synth_fx, save_hb_synth_fx16, output_frame, 0 ); // Q0
-#else
- Copy_Scale_sig_32_16( save_hb_synth_fx, save_hb_synth_fx16, L_FRAME48k, 0 ); // Q0
-#endif
}
Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q_syn2
}
-
+#endif
pop_wmops();
return error;
}
diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c
index 2df489cc115889a8c470e271a0024175d44b0235..dd477874f1de42f56209d021d5f2a4edca6a9cde 100644
--- a/lib_dec/acelp_core_switch_dec_fx.c
+++ b/lib_dec/acelp_core_switch_dec_fx.c
@@ -360,6 +360,7 @@ ivas_error acelp_core_switch_dec_bfi_fx(
{
Word16 old_exc[L_EXC_DEC], *exc; /* excitation signal buffer */
Word16 syn[L_FRAME16k]; /* synthesis signal buffer */
+ Word32 syn32[L_FRAME16k]; /* synthesis signal buffer */
Word16 lsf_new[M]; /* LSFs at the end of the frame */
Word16 lsp_new[M]; /* LSPs at the end of the frame */
Word16 Aq[NB_SUBFR16k * ( M + 1 )]; /* A(q) quantized for the 4 subframes */
@@ -378,16 +379,15 @@ ivas_error acelp_core_switch_dec_bfi_fx(
Word32 tmp8;
Word16 voice_factors[NB_SUBFR16k];
Word16 pitch_buf[NB_SUBFR16k];
- Word16 Q_exc;
+ Word16 Q_exc, Qtmp;
Word32 *realBuffer[CLDFB_NO_COL_MAX_SWITCH_BFI], *imagBuffer[CLDFB_NO_COL_MAX_SWITCH_BFI];
Word32 realBufferTmp[CLDFB_NO_COL_MAX_SWITCH_BFI][CLDFB_NO_CHANNELS_MAX], imagBufferTmp[CLDFB_NO_COL_MAX_SWITCH_BFI][CLDFB_NO_CHANNELS_MAX];
Word16 i;
- CLDFB_SCALE_FACTOR scaleFactor;
- Word32 workBuffer[128 * 3];
+ Word32 synth32[L_FRAME48k];
MUSIC_POSTFILT_HANDLE hMusicPF;
BPF_DEC_HANDLE hBPF;
ivas_error error;
-
+ Word16 Prev_Q_syn_r;
hMusicPF = st_fx->hMusicPF;
hBPF = st_fx->hBPF;
error = IVAS_ERR_OK;
@@ -404,6 +404,7 @@ ivas_error acelp_core_switch_dec_bfi_fx(
/*----------------------------------------------------------------*
* Initialization
*----------------------------------------------------------------*/
+
Q_exc = st_fx->Q_exc;
move16();
st_fx->bpf_off = 1;
@@ -426,7 +427,7 @@ ivas_error acelp_core_switch_dec_bfi_fx(
exc2 = old_exc2 + L_EXC_MEM;
IF( st_fx->hBWE_TD != NULL )
{
- Copy( st_fx->hBWE_TD->old_bwe_exc_fx, old_bwe_exc, PIT16k_MAX * 2 ); // Q_exc
+ Copy( st_fx->hBWE_TD->old_bwe_exc_fx, old_bwe_exc, PIT16k_MAX * 2 );
bwe_exc = old_bwe_exc + PIT16k_MAX * 2;
}
ELSE
@@ -515,8 +516,14 @@ ivas_error acelp_core_switch_dec_bfi_fx(
* Synthesis
*-----------------------------------------------------------------*/
+ Prev_Q_syn_r = st_fx->Q_syn;
+ move16();
Rescale_mem( Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, 4, &st_fx->mem_deemph_fx,
hBPF->pst_old_syn_fx, &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, 1, 0, NULL );
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ Scale_sig( st_fx->mem_syn_r, L_SYN_MEM, sub( st_fx->Q_syn, Prev_Q_syn_r ) ); // Q_syn
+ }
Copy( st_fx->mem_syn2_fx, tmp1, M );
syn_12k8_fx( st_fx->L_frame, Aq, exc2, syn, tmp1, 1, Q_exc, st_fx->Q_syn );
@@ -527,6 +534,7 @@ ivas_error acelp_core_switch_dec_bfi_fx(
/*------------------------------------------------------------------*
* Perform fixed deemphasis through 1/(1 - g*z^-1)
*-----------------------------------------------------------------*/
+
tmp1[0] = st_fx->mem_deemph_fx;
move16(); /*if in acelp_core_dec_fx deemph_fx is used*/
/*tmp1 = shr(st_fx->mem_deemph_fx, sub(st_fx->Q_syn,1)); if in acelp_core_dec_fx Deemph2 is used*/
@@ -565,285 +573,68 @@ ivas_error acelp_core_switch_dec_bfi_fx(
Copy( tmp6, hBPF->vibrato_hist, L_TRACK_HIST );
hBPF->psf_att_fx = tmp7;
move16();
- /*----------------------------------------------------------------*
- * Resamping to the output sampling frequency
- *----------------------------------------------------------------*/
- /* CLDFB analysis of the synthesis at internal sampling rate */
- IF( NE_32( ( error = cldfb_save_memory( st_fx->cldfbAna ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn, negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer );
- cldfb_restore_memory( st_fx->cldfbAna );
-
- scaleFactor.hb_scale = scaleFactor.lb_scale;
- move16();
-
- /* CLDFB synthesis of the combined signal */
- IF( NE_32( ( error = cldfb_save_memory( st_fx->cldfbSyn ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out,
- negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer );
-
- /* output to Q0 */
- Scale_sig( synth_out, L_FRAME48k, negate( st_fx->Q_syn ) ); // Q0
-
- cldfb_restore_memory( st_fx->cldfbSyn );
-
- return error;
-}
-
-ivas_error acelp_core_switch_dec_bfi_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- Word16 synth_out[], /* o : synthesis Q_syn */
- const Word16 coder_type /* i : coder type */
-)
-{
- Word16 old_exc[L_EXC_DEC], *exc; /* excitation signal buffer */
- Word16 syn[L_FRAME16k]; /* synthesis signal buffer */
- Word32 syn32[L_FRAME16k]; /* synthesis signal buffer */
- Word16 lsf_new[M]; /* LSFs at the end of the frame */
- Word16 lsp_new[M]; /* LSPs at the end of the frame */
- Word16 Aq[NB_SUBFR16k * ( M + 1 )]; /* A(q) quantized for the 4 subframes */
- Word16 old_exc2[L_FRAME16k + L_EXC_MEM], *exc2; /* total excitation buffer */
- Word16 tmp_noise; /* Long term temporary noise energy */
- Word16 FEC_pitch; /* FEC pitch */
- Word16 old_bwe_exc[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */
- Word16 *bwe_exc; /* Excitation for SWB TBE */
- Word16 tmp1[NBPSF_PIT_MAX];
- Word16 tmp2[M];
- Word16 tmp3;
- Word16 tmp4[L_TRACK_HIST];
- Word16 tmp5[L_TRACK_HIST];
- Word16 tmp6[L_TRACK_HIST];
- Word16 tmp7;
- Word32 tmp8;
- Word16 voice_factors[NB_SUBFR16k];
- Word16 pitch_buf[NB_SUBFR16k];
- Word16 Q_exc, Qtmp;
- Word32 *realBuffer[CLDFB_NO_COL_MAX_SWITCH_BFI], *imagBuffer[CLDFB_NO_COL_MAX_SWITCH_BFI];
- Word32 realBufferTmp[CLDFB_NO_COL_MAX_SWITCH_BFI][CLDFB_NO_CHANNELS_MAX], imagBufferTmp[CLDFB_NO_COL_MAX_SWITCH_BFI][CLDFB_NO_CHANNELS_MAX];
- Word16 i;
- Word32 synth32[L_FRAME48k];
- MUSIC_POSTFILT_HANDLE hMusicPF;
- BPF_DEC_HANDLE hBPF;
- ivas_error error;
- Word16 Prev_Q_syn_r;
- hMusicPF = st_fx->hMusicPF;
- hBPF = st_fx->hBPF;
- error = IVAS_ERR_OK;
- move32();
-
- FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH_BFI; i++ )
- {
- set32_fx( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX );
- set32_fx( imagBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX );
- realBuffer[i] = realBufferTmp[i];
- imagBuffer[i] = imagBufferTmp[i];
- }
/*----------------------------------------------------------------*
- * Initialization
- *----------------------------------------------------------------*/
- Q_exc = st_fx->Q_exc;
- move16();
- st_fx->bpf_off = 1;
- move16();
- st_fx->clas_dec = st_fx->last_good;
- move16();
- tmp_noise = 0;
- move16();
-
- Copy( st_fx->old_exc_fx, old_exc, L_EXC_MEM_DEC ); // Q_exc
- exc = old_exc + L_EXC_MEM_DEC;
- IF( st_fx->hWIDec != NULL )
- {
- Copy( st_fx->hWIDec->old_exc2_fx, old_exc2, L_EXC_MEM );
- }
- ELSE
- {
- set16_fx( old_exc2, 0, L_EXC_MEM );
- }
- exc2 = old_exc2 + L_EXC_MEM;
- IF( st_fx->hBWE_TD != NULL )
- {
- Copy( st_fx->hBWE_TD->old_bwe_exc_fx, old_bwe_exc, PIT16k_MAX * 2 );
- bwe_exc = old_bwe_exc + PIT16k_MAX * 2;
- }
- ELSE
- {
- bwe_exc = NULL;
- }
-
- st_fx->GSC_noisy_speech = 0;
- move16();
- st_fx->relax_prev_lsf_interp = 0;
- move16();
-
- /* SC-VBR */
- if ( EQ_16( st_fx->last_nelp_mode_dec, 1 ) )
- {
- st_fx->nelp_mode_dec = 1;
- move16();
- }
-
- Copy( st_fx->mem_AR_fx, tmp1, M );
- Copy( st_fx->mem_MA_fx, tmp2, M );
-
- /* LSF estimation and A(z) calculation */
- lsf_dec_bfi( MODE1, lsf_new, st_fx->lsf_old_fx, st_fx->lsf_adaptive_mean_fx, NULL, st_fx->mem_MA_fx, st_fx->mem_AR_fx,
- st_fx->stab_fac_fx, st_fx->last_coder_type, st_fx->L_frame, st_fx->last_good,
- st_fx->nbLostCmpt, 0, NULL, NULL, NULL, st_fx->hGSCDec->Last_GSC_pit_band_idx, st_fx->Opt_AMR_WB, 0, st_fx->bwidth );
-
- FEC_lsf2lsp_interp( st_fx, st_fx->L_frame, Aq, lsf_new, lsp_new );
-
- Copy( tmp1, st_fx->mem_AR_fx, M );
- Copy( tmp2, st_fx->mem_MA_fx, M );
-
- /*----------------------------------------------------------------*
- * Excitation decoding
+ * Resamping to the output sampling frequency
*----------------------------------------------------------------*/
- IF( EQ_16( st_fx->nelp_mode_dec, 1 ) )
+ IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
{
- Word16 gain_buf[NB_SUBFR16k];
- Scale_sig( exc - L_EXC_MEM, L_EXC_MEM, negate( st_fx->Q_exc ) ); // Q0
- st_fx->Q_exc = 0;
- move16();
- /* SC-VBR */
- decod_nelp_fx( st_fx, &tmp_noise, pitch_buf, exc, exc2, voice_factors, bwe_exc, &Q_exc, st_fx->bfi, gain_buf );
- FEC_pitch = pitch_buf[3];
- move16();
- Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc, NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &Q_exc, st_fx->Q_subfr, exc2, L_FRAME, coder_type );
- st_fx->Q_exc = Q_exc;
- move16();
- }
- ELSE
- {
- tmp1[0] = st_fx->bfi_pitch_fx;
- move16();
- tmp1[1] = st_fx->bfi_pitch_frame;
- move16();
- tmp1[2] = st_fx->lp_gainp_fx;
- move16();
- tmp1[3] = st_fx->lp_gainc_fx;
- move16();
- tmp1[4] = st_fx->upd_cnt;
- move16();
- tmp1[5] = st_fx->seed;
- move16();
+ CLDFB_SCALE_FACTOR scaleFactor;
+ Word32 workBuffer[128 * 3];
- /* calculation of excitation signal */
- FEC_exc_estim_fx( st_fx, st_fx->L_frame, exc, exc2, syn /* dummy buffer */, pitch_buf, voice_factors, &FEC_pitch, bwe_exc, lsf_new, &Q_exc, &tmp_noise );
- Rescale_exc( NULL, exc, bwe_exc, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame, L_FRAME32k, (Word32) 0,
- &Q_exc, st_fx->Q_subfr, exc2, st_fx->L_frame, st_fx->last_coder_type );
+ IF( NE_32( ( error = cldfb_save_memory( st_fx->cldfbAna ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn, negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer );
+ cldfb_restore_memory( st_fx->cldfbAna );
- st_fx->seed = tmp1[5];
- move16();
- st_fx->bfi_pitch_fx = tmp1[0];
- move16();
- st_fx->bfi_pitch_frame = tmp1[1];
- move16();
- st_fx->lp_gainp_fx = tmp1[2];
- move16();
- st_fx->lp_gainc_fx = tmp1[3];
- move16();
- st_fx->upd_cnt = tmp1[4];
+ scaleFactor.hb_scale = scaleFactor.lb_scale;
move16();
- }
-
- /*------------------------------------------------------------------*
- * Synthesis
- *-----------------------------------------------------------------*/
- Prev_Q_syn_r = st_fx->Q_syn;
- move16();
- Rescale_mem( Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, 4, &st_fx->mem_deemph_fx,
- hBPF->pst_old_syn_fx, &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, 1, 0, NULL );
- Scale_sig( st_fx->mem_syn_r, L_SYN_MEM, sub( st_fx->Q_syn, Prev_Q_syn_r ) ); // Q_syn
- Copy( st_fx->mem_syn2_fx, tmp1, M );
- syn_12k8_fx( st_fx->L_frame, Aq, exc2, syn, tmp1, 1, Q_exc, st_fx->Q_syn );
- tmp8 = st_fx->enr_old_fx;
- move32();
- frame_ener_fx( st_fx->L_frame, st_fx->last_good, syn, shr( add( FEC_pitch, 32 ), 6 ), &tmp8, st_fx->L_frame, st_fx->Q_syn, 3, 0 );
+ /* CLDFB synthesis of the combined signal */
+ IF( NE_32( ( error = cldfb_save_memory( st_fx->cldfbSyn ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out,
+ negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer );
- /*------------------------------------------------------------------*
- * Perform fixed deemphasis through 1/(1 - g*z^-1)
- *-----------------------------------------------------------------*/
- tmp1[0] = st_fx->mem_deemph_fx;
- move16(); /*if in acelp_core_dec_fx deemph_fx is used*/
- /*tmp1 = shr(st_fx->mem_deemph_fx, sub(st_fx->Q_syn,1)); if in acelp_core_dec_fx Deemph2 is used*/
+ /* output to Q0 */
+ Scale_sig( synth_out, L_FRAME48k, negate( st_fx->Q_syn ) ); // Q0
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
- {
- deemph_fx( syn, PREEMPH_FAC, L_FRAME, &tmp1[0] ); /*Q0*/
+ cldfb_restore_memory( st_fx->cldfbSyn );
}
ELSE
{
- deemph_fx( syn, PREEMPH_FAC_16k, L_FRAME16k, &tmp1[0] ); /*Q0*/
- }
-
- /*----------------------------------------------------------------*
- * Bass post-filter
- *----------------------------------------------------------------*/
-
- st_fx->bpf_off = 1;
- move16();
- Copy( hBPF->pst_old_syn_fx, tmp1, NBPSF_PIT_MAX );
-
- tmp3 = st_fx->stab_fac_smooth_fx;
- move16();
- Copy( hBPF->mem_mean_pit_fx, tmp4, L_TRACK_HIST );
- Copy( hBPF->Track_on_hist, tmp5, L_TRACK_HIST );
- Copy( hBPF->vibrato_hist, tmp6, L_TRACK_HIST );
- tmp7 = hBPF->psf_att_fx;
- move16();
+ /* CLDFB analysis of the synthesis at internal sampling rate */
+ Qtmp = sub( 11, st_fx->Q_syn );
+ Copy_Scale_sig_16_32_no_sat( syn, syn32, L_FRAME16k, Qtmp ); // Q(11)
+ IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st_fx->cldfbAna ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ cldfbAnalysis_ivas_fx( syn32, realBuffer, imagBuffer, shr( st_fx->L_frame, 1 ), st_fx->cldfbAna );
+ cldfb_restore_memory_ivas_fx( st_fx->cldfbAna );
- bass_psfilter_fx( st_fx->hBPF, st_fx->Opt_AMR_WB, syn, st_fx->L_frame, pitch_buf,
- st_fx->bpf_off, st_fx->stab_fac_fx, &tmp3, coder_type, st_fx->Q_syn, old_exc /* tmp buffer*/ );
+ /* CLDFB synthesis of the combined signal */
+ IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st_fx->cldfbSyn ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
- Copy( tmp1, hBPF->pst_old_syn_fx, NBPSF_PIT_MAX );
- Copy( tmp4, hBPF->mem_mean_pit_fx, L_TRACK_HIST );
- Copy( tmp5, hBPF->Track_on_hist, L_TRACK_HIST );
- Copy( tmp6, hBPF->vibrato_hist, L_TRACK_HIST );
- hBPF->psf_att_fx = tmp7;
- move16();
- /*----------------------------------------------------------------*
- * Resamping to the output sampling frequency
- *----------------------------------------------------------------*/
- /* CLDFB analysis of the synthesis at internal sampling rate */
- Qtmp = sub( 11, st_fx->Q_syn );
- Copy_Scale_sig_16_32_no_sat( syn, syn32, L_FRAME16k, Qtmp ); // Q(11)
- IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st_fx->cldfbAna ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- /*cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn,
- negate(st_fx->Q_syn), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer);*/
- cldfbAnalysis_ivas_fx( syn32, realBuffer, imagBuffer, shr( st_fx->L_frame, 1 ), st_fx->cldfbAna );
- cldfb_restore_memory_ivas_fx( st_fx->cldfbAna );
+ Word16 out_len = extract_l( Mpy_32_16_1( st_fx->output_Fs, 328 ) );
+ cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, synth32, out_len, -1, 0, st_fx->cldfbSyn );
- /* CLDFB synthesis of the combined signal */
- IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st_fx->cldfbSyn ) ), IVAS_ERR_OK ) )
- {
- return error;
+ Copy_Scale_sig_32_16( synth32, synth_out, out_len, -4 );
+ cldfb_restore_memory_ivas_fx( st_fx->cldfbSyn );
}
- /*cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out,
- negate(st_fx->Q_syn), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer );*/
- Word16 out_len = extract_l( Mpy_32_16_1( st_fx->output_Fs, 328 ) );
- cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, synth32, out_len, -1, 0, st_fx->cldfbSyn );
- Copy_Scale_sig_32_16( synth32, synth_out, out_len, -4 );
-
-
- // Scale_sig( synth_out, L_FRAME48k, negate( st_fx->Q_syn ) );
-
- cldfb_restore_memory_ivas_fx( st_fx->cldfbSyn );
return error;
}
+
/*-------------------------------------------------------------------*
* decod_gen_voic_core_switch()
*
@@ -854,8 +645,8 @@ static void decod_gen_voic_core_switch_fx(
Decoder_State *st_fx, /* i/o: decoder static memory */
const Word16 L_frame, /* i : length of the frame */
const Word16 sharpFlag, /* i : flag for formant sharpening */
- const Word16 *Aq, /* i : LP filter coefficient Q_12 */
- Word16 *exc, /* i/o: adapt. excitation exc Q_exc */
+ const Word16 *Aq, /* i : LP filter coefficient Q_12 */
+ Word16 *exc, /* i/o: adapt. excitation exc Q_exc */
const Word32 core_brate, /* i : switching frame bit-rate */
Word16 *Q_exc )
{
@@ -873,7 +664,6 @@ static void decod_gen_voic_core_switch_fx(
GSC_DEC_HANDLE hGSCDec;
hGSCDec = st_fx->hGSCDec;
-
/*----------------------------------------------------------------------*
* initializations
*----------------------------------------------------------------------*/
@@ -902,6 +692,7 @@ static void decod_gen_voic_core_switch_fx(
/*--------------------------------------------------------------*
* Find the adaptive codebook vector.
*--------------------------------------------------------------*/
+
IF( st_fx->element_mode != EVS_MONO )
{
pred_lt4_ivas_fx( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
@@ -910,6 +701,7 @@ static void decod_gen_voic_core_switch_fx(
{
pred_lt4( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
}
+
/*--------------------------------------------------------------*
* LP filtering of the adaptive excitation
*--------------------------------------------------------------*/
@@ -936,11 +728,7 @@ static void decod_gen_voic_core_switch_fx(
gain_dec_mless_fx( st_fx, L_frame, GENERIC, 0, -1, code, st_fx->old_Es_pred_fx, &gain_pit, &gain_code, &gain_inov, &norm_gain_code );
}
- /* _ (Word16*) gain_pit : quantized pitch gain (Q14) */
- /* _ (Word32*) gain_code : quantized codebook gain (Q16) */
- /* _ (Word16*) gain_inov : gain of the innovation (used for normalization) (Q12) */
- /* _ (Word32*) norm_gain_code : norm. gain of the codebook excitation (Q16) */
- st_fx->tilt_code_fx = est_tilt_fx( exc, gain_pit, code, gain_code, &voice_fac, *Q_exc ); /*Q15*/
+ st_fx->tilt_code_fx = est_tilt_fx( exc, gain_pit, code, gain_code, &voice_fac, *Q_exc, L_SUBFR ); /*Q15*/
move16();
/*----------------------------------------------------------------------*
@@ -977,6 +765,7 @@ static void decod_gen_voic_core_switch_fx(
/*-----------------------------------------------------------------*
* long term prediction on the 2nd sub frame
*-----------------------------------------------------------------*/
+
IF( st_fx->element_mode != EVS_MONO )
{
pred_lt4_ivas_fx( &exc[L_SUBFR], &exc[L_SUBFR], T0, T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c
index d7dcf5b0315eb9da72405cfd072d546c53d8887d..3806f8c2a920021b5ce46b0a7d6d7d62c7539b25 100644
--- a/lib_dec/amr_wb_dec_fx.c
+++ b/lib_dec/amr_wb_dec_fx.c
@@ -172,7 +172,7 @@ ivas_error amr_wb_dec_fx(
}
/* Updates in case of EVS -> AMR-WB IO switching */
- IF( NE_32( ( error = core_switching_pre_dec_fx( st_fx, output_frame ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = core_switching_pre_dec_fx( st_fx, output_frame, -1, 1, EVS_MONO, EVS_MONO, -1, &tmp16, &tmp16 ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -993,7 +993,7 @@ ivas_error amr_wb_dec_fx(
st_fx->last_flag_cna = flag_cna;
move16();
- updt_dec_common_fx( st_fx, -1, -1, NULL, 0 );
+ updt_dec_common_fx( st_fx, -1, -1, NULL, NULL, 0 );
/*----------------------------------------------------------------*
* Overlap of ACELP synthesis with old MDCT memory
diff --git a/lib_dec/ari_hm_dec_fx.c b/lib_dec/ari_hm_dec_fx.c
index ecbf0b6b7fe405df68c12f6e652b08311718f549..f2b1a011021a6c53d1d0e368b2ce14179ce8064f 100644
--- a/lib_dec/ari_hm_dec_fx.c
+++ b/lib_dec/ari_hm_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/bass_psfilter_fx.c b/lib_dec/bass_psfilter_fx.c
index 29672d3e0db3bd71b28c6515249fca15b37434c9..d2558f47c1f1bc9a5ff1b5dca78acb5763eeff17 100644
--- a/lib_dec/bass_psfilter_fx.c
+++ b/lib_dec/bass_psfilter_fx.c
@@ -1041,11 +1041,7 @@ Word16 res_bpf_adapt_ivas_fx(
bpf_error_ratio = ONE_IN_Q14; // Q13
move16();
}
-#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE
bpf_error_ratio = mac_r( L_mult( STEREO_DFT_BPF_ADAPT_BETA_FX, bpf_error_ratio ), ( MAX_16 - STEREO_DFT_BPF_ADAPT_BETA_FX ), hStereoDft->bpf_error_ratio_mem_fx );
-#else
- bpf_error_ratio = add( mult( STEREO_DFT_BPF_ADAPT_BETA_FX, bpf_error_ratio ), mult( ( MAX_16 - STEREO_DFT_BPF_ADAPT_BETA_FX ), hStereoDft->bpf_error_ratio_mem_fx ) );
-#endif
hStereoDft->bpf_error_ratio_mem_fx = bpf_error_ratio;
move16();
diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c
index 0006bacbbd2e6354d3e976b80a362a608103ee88..56d2bd29c3e33ac9724922d7936ab0c301c0c909 100644
--- a/lib_dec/cng_dec_fx.c
+++ b/lib_dec/cng_dec_fx.c
@@ -9,9 +9,6 @@
#include "prot_fx.h"
#include "ivas_cnst.h"
-/*Temporary location to be move in prot* when merge is done*/
-void E_LPC_f_isp_a_conversion( const Word16 *isp, Word16 *a, const Word16 m );
-void E_LPC_f_lsp_a_conversion( const Word16 *isp, Word16 *a, const Word16 m );
/*-----------------------------------------------------------------*
* Local function prototypes
@@ -19,7 +16,6 @@ void E_LPC_f_lsp_a_conversion( const Word16 *isp, Word16 *a, const Word16 m );
static void shb_CNG_decod_fx( Decoder_State *st_fx, const Word16 *synth_fx, Word16 *shb_synth_fx, const Word16 sid_bw, const Word16 Qsyn );
-static void shb_CNG_decod_ivas_fx( Decoder_State *st_fx, const Word16 *synth_fx, Word16 *shb_synth_fx, const Word16 sid_bw, const Word16 Qsyn );
/*-----------------------------------------------------------------*
* CNG_dec_fx()
@@ -723,7 +719,7 @@ void swb_CNG_dec_fx(
{
st_fx->last_vad_fx = 1;
move16();
- st_fx->hTdCngDec->burst_cnt_fx = add( st_fx->hTdCngDec->burst_cnt_fx, 1 );
+ st_fx->hTdCngDec->burst_cnt_fx = add_sat( st_fx->hTdCngDec->burst_cnt_fx, 1 );
move16();
if ( GT_16( st_fx->hTdCngDec->burst_cnt_fx, 10 ) )
{
@@ -735,43 +731,6 @@ void swb_CNG_dec_fx(
return;
}
-void swb_CNG_dec_ivas_fx(
- Decoder_State *st_fx, /* i/o: State structure */
- const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/
- Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/
- const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/
- const Word16 Qsyn /* i : Q value of ACELP core synthesis */
-)
-{
- test();
- IF( EQ_32( st_fx->core_brate, FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- /* SHB SID decoding and CNG */
- test();
- IF( EQ_16( st_fx->cng_type, LP_CNG ) && EQ_16( st_fx->extl, SWB_CNG ) )
- {
- shb_CNG_decod_ivas_fx( st_fx, synth_fx, shb_synth_fx, sid_bw, Qsyn );
- }
- st_fx->last_vad_fx = 0;
- move16();
- st_fx->hTdCngDec->burst_cnt_fx = 0;
- move16();
- }
- ELSE
- {
- st_fx->last_vad_fx = 1;
- move16();
- st_fx->hTdCngDec->burst_cnt_fx = add_sat( st_fx->hTdCngDec->burst_cnt_fx, 1 ); // saturation reached?
- move16();
- if ( GT_16( st_fx->hTdCngDec->burst_cnt_fx, 10 ) )
- {
- st_fx->hTdCngDec->burst_cnt_fx = 0;
- move16();
- }
- }
-
- return;
-}
/*---------------------------------------------------------------------*
* shb_CNG_decod()
@@ -780,7 +739,7 @@ void swb_CNG_dec_ivas_fx(
*---------------------------------------------------------------------*/
static void shb_CNG_decod_fx(
- Decoder_State *st_fx, /* i/o: State structure */
+ Decoder_State *st, /* i/o: State structure */
const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/
Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/
const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/
@@ -788,7 +747,7 @@ static void shb_CNG_decod_fx(
)
{
Word16 i;
- Word16 idx_ener_fx;
+ Word16 idx_ener;
TD_CNG_DEC_HANDLE hTdCngDec;
Word16 shb_lpcCNG_fx[LPC_SHB_ORDER + 1];
Word16 shb_lspCNG_fx[LPC_SHB_ORDER];
@@ -799,410 +758,237 @@ static void shb_CNG_decod_fx(
Word32 wb_ener_fx;
Word16 wb_ener16_fx;
Word32 L_gain_fx;
- Word16 gain_fx;
+ Word32 gain_fx;
Word16 shb_syn16k_fx[L_FRAME16k];
- Word16 tmp;
- Word16 step_fx;
+ Word32 tmp;
+ Word32 step_fx;
Word16 interp_fx;
- Word16 ener_fx;
+ Word32 ener_fx;
Word16 exp, exp1;
Word16 fra;
Word32 L_tmp;
- Word16 tmp2;
- Word16 allow_cn_step_fx = 0;
- move16();
+ Word16 tmp_16, tmp_16_2, step_fx16, gain_fx16, ener_fx16;
+ Word16 allow_cn_step_fx;
Word16 q;
TD_BWE_DEC_HANDLE hBWE_TD;
- hBWE_TD = st_fx->hBWE_TD;
- hTdCngDec = st_fx->hTdCngDec;
+ hBWE_TD = st->hBWE_TD;
+ hTdCngDec = st->hTdCngDec;
+ allow_cn_step_fx = 0;
+ move16();
- IF( st_fx->bfi == 0 )
+ IF( st->bfi == 0 )
{
test();
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) && EQ_16( sid_bw, 1 ) )
+ IF( EQ_32( st->core_brate, SID_2k40 ) && EQ_16( sid_bw, 1 ) )
{
- idx_ener_fx = get_next_indice_fx( st_fx, 4 );
+ idx_ener = get_next_indice_fx( st, 4 );
- if ( !idx_ener_fx )
+ IF( idx_ener == 0 )
{
- idx_ener_fx = -15;
+ idx_ener = -15;
move16();
}
- IF( st_fx->element_mode == EVS_MONO )
+
+ /* de-quantization of SHB CNG parameters */
+ IF( st->element_mode == EVS_MONO )
{
- /* de-quantization of SHB CNG parameters */
- L_tmp = L_mult( idx_ener_fx, 27400 ); /*Q14 */
+ L_tmp = L_mult( idx_ener, 27400 ); /*Q14 */
hTdCngDec->last_shb_cng_ener_fx = extract_l( L_shr( L_sub( L_tmp, 295924 ), 6 ) ); /*Q8 */
move16();
}
ELSE
{
+ hTdCngDec->last_shb_cng_ener_fx_32 = L_sub( L_mult0( idx_ener, 8807 ), 36991 ); // Q11
+ move32();
}
}
}
/* SHB spectrum estimation */
-
-
interp_fx = s_min( hTdCngDec->shb_dtx_count_fx, 32 );
interp_fx = shl_sat( interp_fx, 10 ); /*Q15*/
- FOR( i = 0; i < LPC_SHB_ORDER; i++ )
- {
- tmp2 = mult( interp_fx, hTdCngDec->lsp_shb_prev_fx[i] ); /*Q14*/
- tmp = mult( sub( 32767, interp_fx ), hTdCngDec->lsp_shb_prev_prev_fx[i] ); /*Q14*/
- shb_lspCNG_fx[i] = add( tmp2, tmp );
- move16(); /*Q14*/
- }
- IF( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) )
+ IF( st->element_mode == EVS_MONO )
{
- if ( LT_16( hTdCngDec->shb_dtx_count_fx, 1000 ) )
+ FOR( i = 0; i < LPC_SHB_ORDER; i++ )
{
- hTdCngDec->shb_dtx_count_fx = add( hTdCngDec->shb_dtx_count_fx, 1 );
- move16();
+ tmp_16_2 = mult( interp_fx, hTdCngDec->lsp_shb_prev_fx[i] ); /*Q14*/
+ tmp_16 = mult( sub( 32767, interp_fx ), hTdCngDec->lsp_shb_prev_prev_fx[i] ); /*Q14*/
+ shb_lspCNG_fx[i] = add( tmp_16_2, tmp_16 );
+ move16(); /*Q14*/
}
}
- E_LPC_lsf_lsp_conversion( shb_lspCNG_fx, tmp_lsp, LPC_SHB_ORDER ); /*Q14*/
- E_LPC_f_lsp_a_conversion( tmp_lsp, shb_lpcCNG_fx, LPC_SHB_ORDER );
-
- Copy_Scale_sig( shb_lpcCNG_fx, shb_lpcCNG_fx, LPC_SHB_ORDER + 1, sub( norm_s( shb_lpcCNG_fx[0] ), 2 ) ); /* Q12 */
-
- /* SHB energy estimation */
- wb_ener_fx = L_deposit_l( 1 ); /*Q1 */
- FOR( i = 0; i < L_FRAME32k; i++ )
- {
- wb_ener_fx = L_add( wb_ener_fx, Mpy_32_16_1( L_mult0( synth_fx[i], synth_fx[i] ), 51 ) ); /* 2*Qsyn */
- }
- exp = norm_l( wb_ener_fx );
- fra = Log2_norm_lc( L_shl( wb_ener_fx, exp ) );
- exp = sub( 30, add( exp, shl( Qsyn, 1 ) ) );
- wb_ener_fx = Mpy_32_16( exp, fra, LG10 );
- wb_ener16_fx = round_fx( L_shl( wb_ener_fx, 10 ) ); /*wb_ener_fx in Q8 */
- if ( !st_fx->first_CNG )
- {
- hTdCngDec->wb_cng_ener_fx = wb_ener16_fx;
- move16(); /*Q8 */
- }
- if ( GT_16( abs_s( sub( wb_ener16_fx, hTdCngDec->wb_cng_ener_fx ) ), 3072 ) )
- {
- allow_cn_step_fx = 1;
- move16();
- }
-
- IF( EQ_16( allow_cn_step_fx, 1 ) )
- {
- hTdCngDec->wb_cng_ener_fx = wb_ener16_fx;
- move16(); /*Q8 */
- }
ELSE
{
- tmp = sub( wb_ener16_fx, hTdCngDec->wb_cng_ener_fx ); /*Q8 */
- tmp = mult_r( tmp, 29491 ); /*Q8 */
- hTdCngDec->wb_cng_ener_fx = add( hTdCngDec->wb_cng_ener_fx, tmp ); /*Q8 */
- move16();
- }
- test();
- test();
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) && EQ_16( sid_bw, 1 ) && ( st_fx->bfi == 0 ) )
- {
- hTdCngDec->last_wb_cng_ener_fx = hTdCngDec->wb_cng_ener_fx;
- move16();
-
- if ( !st_fx->first_CNG )
+ FOR( i = 0; i < LPC_SHB_ORDER; i++ )
{
- hTdCngDec->shb_cng_ener_fx = hTdCngDec->last_shb_cng_ener_fx;
+ shb_lspCNG_fx[i] = add( mult_r( interp_fx, hTdCngDec->lsp_shb_prev_fx[i] ), mult_r( sub( 32767, interp_fx ), hTdCngDec->lsp_shb_prev_prev_fx[i] ) ); // Q14
move16();
}
}
- gain_fx = sub( hTdCngDec->wb_cng_ener_fx, hTdCngDec->last_wb_cng_ener_fx ); /* Q8 */
- if ( GT_16( gain_fx, 15 ) )
- {
- gain_fx = 15;
- move16();
- }
- step_fx = sub( add( gain_fx, hTdCngDec->last_shb_cng_ener_fx ), hTdCngDec->shb_cng_ener_fx ); /*Q8 */
- test();
- IF( EQ_16( allow_cn_step_fx, 1 ) || GT_32( st_fx->last_core_brate, SID_2k40 ) )
- {
- hTdCngDec->shb_cng_ener_fx = add( hTdCngDec->shb_cng_ener_fx, step_fx ); /* Q8 */
- move16();
- }
- ELSE
+ IF( LE_16( hTdCngDec->shb_dtx_count_fx, 1000 ) )
{
- hTdCngDec->shb_cng_ener_fx = add( hTdCngDec->shb_cng_ener_fx, mult( 8192, step_fx ) ); /*Q8 */
+ hTdCngDec->shb_dtx_count_fx = add( hTdCngDec->shb_dtx_count_fx, 1 );
move16();
}
- /* generate white noise excitation */
- FOR( i = 0; i < L_FRAME16k; i++ )
- {
- excTmp_fx[i] = shr_r( Random( &hTdCngDec->swb_cng_seed ), 8 );
- move16(); /*Q-8*/
- }
-
- /* synthesis filtering */
- Syn_filt_s( 0, shb_lpcCNG_fx, LPC_SHB_ORDER, excTmp_fx, excSHB_fx, L_FRAME16k, hBWE_TD->state_lpc_syn_fx, 1 );
+ E_LPC_lsf_lsp_conversion( shb_lspCNG_fx, tmp_lsp, LPC_SHB_ORDER ); /*Q14*/
+ E_LPC_f_lsp_a_conversion( tmp_lsp, shb_lpcCNG_fx, LPC_SHB_ORDER );
- /* synthesis signal gain shaping */
- L_tmp = 0;
- move32();
- FOR( i = 0; i < L_FRAME16k; i++ )
+ IF( st->element_mode != EVS_MONO )
{
- L_tmp = L_add( L_tmp, Mpy_32_16_1( L_mult0( excSHB_fx[i], excSHB_fx[i] ), 102 ) ); /*Q-16*/
+ Copy_Scale_sig( shb_lpcCNG_fx, hTdCngDec->shb_lpcCNG_fx, LPC_SHB_ORDER + 1, sub( norm_s( shb_lpcCNG_fx[0] ), -1 ) ); /* Q15 */
}
- q = norm_l( L_tmp );
- L_tmp = L_shl( L_tmp, q );
- q = sub( q, 32 );
- ener_excSHB_fx = round_fx( L_tmp ); /*Qq */
- IF( EQ_16( st_fx->last_vad_fx, 1 ) )
+ Copy_Scale_sig( shb_lpcCNG_fx, shb_lpcCNG_fx, LPC_SHB_ORDER + 1, sub( norm_s( shb_lpcCNG_fx[0] ), 2 ) ); /* Q12 */
+
+ /* SHB energy estimation */
+ IF( st->element_mode == EVS_MONO )
{
- hTdCngDec->trans_cnt_fx = 0;
- move16();
- test();
- IF( GT_16( hTdCngDec->burst_cnt_fx, 3 ) && NE_16( st_fx->last_core, HQ_CORE ) )
+ wb_ener_fx = L_deposit_l( 1 ); /*Q1 */
+ FOR( i = 0; i < L_FRAME32k; i++ )
{
- hTdCngDec->trans_cnt_fx = 5;
+ wb_ener_fx = L_add( wb_ener_fx, Mpy_32_16_1( L_mult0( synth_fx[i], synth_fx[i] ), 51 ) ); /* 2*Qsyn */
+ }
+ exp = norm_l( wb_ener_fx );
+ fra = Log2_norm_lc( L_shl( wb_ener_fx, exp ) );
+ exp = sub( 30, add( exp, shl( Qsyn, 1 ) ) );
+ wb_ener_fx = Mpy_32_16( exp, fra, LG10 );
+ wb_ener16_fx = round_fx( L_shl( wb_ener_fx, 10 ) ); /*wb_ener_fx in Q8 */
+ if ( !st->first_CNG )
+ {
+ hTdCngDec->wb_cng_ener_fx = wb_ener16_fx;
+ move16(); /*Q8 */
+ }
+ if ( GT_16( abs_s( sub( wb_ener16_fx, hTdCngDec->wb_cng_ener_fx ) ), 3072 ) )
+ {
+ allow_cn_step_fx = 1;
move16();
}
- }
- ener_fx = hTdCngDec->shb_cng_ener_fx;
- move16(); /*Q8 */
- IF( hTdCngDec->trans_cnt_fx > 0 )
- {
- i = extract_l( L_mult0( hTdCngDec->trans_cnt_fx, 17 ) ); /*Q0 */
- ener_fx = add_sat( hTdCngDec->shb_cng_ener_fx, mult( sin_table256_fx[i], sub_sat( hTdCngDec->last_shb_ener_fx, hTdCngDec->shb_cng_ener_fx ) ) ); /*Q8 */
- hTdCngDec->trans_cnt_fx = sub( hTdCngDec->trans_cnt_fx, 1 );
- move16();
- }
-
- tmp = mult( 3277, ener_fx ); /*Q8 */
- L_tmp = L_mult( 27213, tmp ); /*Q22, 27213=3.321928 in Q13 */
- L_tmp = L_shr( L_tmp, 6 ); /*Q16 */
- L_tmp = L_add( L_tmp, 10 << 16 );
- if ( L_tmp < 0 )
- {
- L_tmp = 0;
- move32();
- }
- fra = L_Extract_lc( L_tmp, &exp );
- L_tmp = L_shl_sat( Pow2( exp, fra ), 5 ); /*Q5 */
- L_tmp = L_shr( L_tmp, 10 );
- if ( !L_tmp )
- {
- L_tmp = 1; /*Q5 */
- }
- exp = norm_l( L_tmp );
- L_tmp = L_shl( L_tmp, exp ); /*Q31*/
- tmp = extract_h( L_tmp ); /*Q15*/
- exp = sub( exp, 16 );
- exp1 = norm_s( ener_excSHB_fx );
- fra = shl( ener_excSHB_fx, exp1 ); /*Q15*/
-
- IF( GT_16( fra, tmp ) )
- {
- fra = shr( fra, 1 ); /*Q15*/
- exp1 = sub( exp1, 1 );
- }
- tmp = div_s( fra, tmp ); /*Q15*/
-
- L_tmp = L_deposit_h( tmp ); /*Q31 */
- tmp = sub( add( 5, exp ), add( q, exp1 ) );
- L_gain_fx = Isqrt_lc( L_tmp, &tmp ); /*Q31-Qtmp */
-
- FOR( i = 0; i < L_FRAME16k; i++ )
- {
- shb_syn16k_fx[i] = extract_l( L_shr( Mpy_32_16_1( L_gain_fx, excSHB_fx[i] ), sub( 5, tmp ) ) ); /*Q3 = 31-Qtmp-8-15-5+Qtmp */
- move16();
- }
-
- test();
- IF( EQ_16( st_fx->last_extl, SWB_TBE ) || EQ_16( st_fx->last_extl, FB_TBE ) )
- {
- /* rescale the Hilbert memories to Q0 */
- FOR( i = 0; i < HILBERT_MEM_SIZE; i++ )
+ IF( EQ_16( allow_cn_step_fx, 1 ) )
{
- hBWE_TD->genSHBsynth_Hilbert_Mem_fx[i] = L_shr( hBWE_TD->genSHBsynth_Hilbert_Mem_fx[i], hBWE_TD->prev_Q_bwe_syn2 ); /* hBWE_TD->prev_Q_bwe_syn2 */
- move32();
+ hTdCngDec->wb_cng_ener_fx = wb_ener16_fx;
+ move16(); /*Q8 */
}
-
- FOR( i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++ )
+ ELSE
{
- hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx[i] = shr( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx[i], hBWE_TD->prev_Q_bwe_syn2 ); /* hBWE_TD->prev_Q_bwe_syn2 */
+ tmp_16 = sub( wb_ener16_fx, hTdCngDec->wb_cng_ener_fx ); /*Q8 */
+ tmp_16 = mult_r( tmp_16, 29491 ); /*Q8 */
+ hTdCngDec->wb_cng_ener_fx = add( hTdCngDec->wb_cng_ener_fx, tmp_16 ); /*Q8 */
move16();
}
- }
- GenSHBSynth_fx( shb_syn16k_fx, shb_synth_fx, hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, st_fx->L_frame, &( hBWE_TD->syn_dm_phase ) );
-
- IF( EQ_32( st_fx->output_Fs, 48000 ) )
- {
- interpolate_3_over_2_allpass_fx( shb_synth_fx, L_FRAME32k, shb_synth_fx, hTdCngDec->interpol_3_2_cng_dec_fx, allpass_poles_3_ov_2 );
- }
-
- ResetSHBbuffer_Dec_fx( st_fx->hBWE_TD, st_fx->extl );
- return;
-}
-
-static void shb_CNG_decod_ivas_fx(
- Decoder_State *st, /* i/o: State structure */
- const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/
- Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/
- const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/
- const Word16 Qsyn )
-{
- Word16 i;
- Word16 idx_ener;
- TD_CNG_DEC_HANDLE hTdCngDec;
- Word16 shb_lpcCNG_fx[LPC_SHB_ORDER + 1];
- Word16 shb_lspCNG_fx[LPC_SHB_ORDER];
- Word16 excTmp_fx[L_FRAME16k];
- Word16 excSHB_fx[L_FRAME16k];
- Word16 tmp_lsp[LPC_SHB_ORDER];
- Word16 ener_excSHB_fx;
- Word32 wb_ener_fx;
- Word16 wb_ener16_fx;
- Word32 L_gain_fx;
- Word32 gain_fx;
- Word16 shb_syn16k_fx[L_FRAME16k];
- Word32 tmp;
- Word32 step_fx;
- Word16 interp_fx;
- Word32 ener_fx;
- Word16 exp, exp1;
- Word16 fra;
- Word32 L_tmp;
- Word16 allow_cn_step_fx;
- Word16 q;
- TD_BWE_DEC_HANDLE hBWE_TD;
-
- hBWE_TD = st->hBWE_TD;
- hTdCngDec = st->hTdCngDec;
- allow_cn_step_fx = 0;
- move16();
-
- IF( st->bfi == 0 )
- {
test();
- IF( EQ_32( st->core_brate, SID_2k40 ) && EQ_16( sid_bw, 1 ) )
+ test();
+ IF( EQ_32( st->core_brate, SID_2k40 ) && EQ_16( sid_bw, 1 ) && ( st->bfi == 0 ) )
{
- idx_ener = get_next_indice_fx( st, 4 );
+ hTdCngDec->last_wb_cng_ener_fx = hTdCngDec->wb_cng_ener_fx;
+ move16();
- IF( idx_ener == 0 )
+ if ( !st->first_CNG )
{
- idx_ener = -15;
+ hTdCngDec->shb_cng_ener_fx = hTdCngDec->last_shb_cng_ener_fx;
move16();
}
-
- /* de-quantization of SHB CNG parameters */
- IF( st->element_mode == EVS_MONO )
- {
- hTdCngDec->last_shb_cng_ener_fx_32 = L_sub( L_mult0( idx_ener, 6850 ), 36991 ); // Q11
- move32();
- }
- ELSE
- {
- hTdCngDec->last_shb_cng_ener_fx_32 = L_sub( L_mult0( idx_ener, 8807 ), 36991 ); // Q11
- move32();
- }
}
- }
- /* SHB spectrum estimation */
- interp_fx = s_min( hTdCngDec->shb_dtx_count_fx, 32 );
- interp_fx = shl_sat( interp_fx, 10 ); /*Q15*/
+ gain_fx16 = sub( hTdCngDec->wb_cng_ener_fx, hTdCngDec->last_wb_cng_ener_fx ); /* Q8 */
+ if ( GT_16( gain_fx16, 15 ) )
+ {
+ gain_fx16 = 15;
+ move16();
+ }
+ step_fx16 = sub( add( gain_fx16, hTdCngDec->last_shb_cng_ener_fx ), hTdCngDec->shb_cng_ener_fx ); /*Q8 */
- FOR( i = 0; i < LPC_SHB_ORDER; i++ )
- {
- shb_lspCNG_fx[i] = add( mult_r( interp_fx, hTdCngDec->lsp_shb_prev_fx[i] ), mult_r( sub( 32767, interp_fx ), hTdCngDec->lsp_shb_prev_prev_fx[i] ) ); // Q14
- move16();
+ test();
+ IF( EQ_16( allow_cn_step_fx, 1 ) || GT_32( st->last_core_brate, SID_2k40 ) )
+ {
+ hTdCngDec->shb_cng_ener_fx = add( hTdCngDec->shb_cng_ener_fx, step_fx16 ); /* Q8 */
+ move16();
+ }
+ ELSE
+ {
+ hTdCngDec->shb_cng_ener_fx = add( hTdCngDec->shb_cng_ener_fx, mult( 8192, step_fx16 ) ); /*Q8 */
+ move16();
+ }
}
-
- IF( LE_16( hTdCngDec->shb_dtx_count_fx, 1000 ) )
+ ELSE
{
- hTdCngDec->shb_dtx_count_fx = add( hTdCngDec->shb_dtx_count_fx, 1 );
- move16();
- }
+ wb_ener_fx = L_deposit_l( 1 ); /*Q1 */
+ IF( NE_16( st->element_mode, IVAS_CPE_DFT ) )
+ {
+ FOR( i = 0; i < L_FRAME32k; i++ )
+ {
+ wb_ener_fx = L_add( wb_ener_fx, Mpy_32_16_1( L_mult0( synth_fx[i], synth_fx[i] ), 51 ) ); /* 2*Qsyn */
+ }
+ }
+ exp = norm_l( wb_ener_fx );
+ fra = Log2_norm_lc( L_shl( wb_ener_fx, exp ) );
+ exp = sub( 30, add( exp, shl( Qsyn, 1 ) ) );
+ wb_ener_fx = Mpy_32_16( exp, fra, LG10 );
+ wb_ener16_fx = round_fx( L_shl( wb_ener_fx, 10 ) ); /*wb_ener_fx in Q8 */
+ Word32 wb_ener32_fx = L_shl( wb_ener16_fx, 3 ); /*wb_ener_fx in Q11 */
+ if ( EQ_16( st->first_CNG, 0 ) )
+ {
+ hTdCngDec->wb_cng_ener_fx_32 = wb_ener32_fx;
+ move32(); /*Q11 */
+ }
+ if ( GT_32( L_abs( L_sub( wb_ener32_fx, hTdCngDec->wb_cng_ener_fx_32 ) ), 24576 ) ) /* 12.0f in Q11 */
+ {
+ allow_cn_step_fx = 1;
+ move16();
+ }
- E_LPC_lsf_lsp_conversion( shb_lspCNG_fx, tmp_lsp, LPC_SHB_ORDER ); /*Q14*/
- E_LPC_f_lsp_a_conversion( tmp_lsp, shb_lpcCNG_fx, LPC_SHB_ORDER );
+ IF( EQ_16( allow_cn_step_fx, 1 ) )
+ {
+ hTdCngDec->wb_cng_ener_fx_32 = wb_ener32_fx;
+ move32(); /*Q11 */
+ }
+ ELSE
+ {
+ tmp = L_sub( wb_ener32_fx, hTdCngDec->wb_cng_ener_fx_32 ); /*Q11 */
+ tmp = Mpy_32_16_1( tmp, 29491 ); /*Q11 */
+ hTdCngDec->wb_cng_ener_fx_32 = L_add( hTdCngDec->wb_cng_ener_fx_32, tmp ); /*Q11 */
+ move32();
+ }
- Copy_Scale_sig( shb_lpcCNG_fx, hTdCngDec->shb_lpcCNG_fx, LPC_SHB_ORDER + 1, sub( norm_s( shb_lpcCNG_fx[0] ), -1 ) ); /* Q15 */
+ test();
+ test();
+ IF( EQ_32( st->core_brate, SID_2k40 ) && EQ_16( sid_bw, 1 ) && EQ_16( st->bfi, 0 ) )
+ {
+ hTdCngDec->last_wb_cng_ener_fx_32 = hTdCngDec->wb_cng_ener_fx_32; /* Q11 */
+ move32();
- Copy_Scale_sig( shb_lpcCNG_fx, shb_lpcCNG_fx, LPC_SHB_ORDER + 1, sub( norm_s( shb_lpcCNG_fx[0] ), 2 ) ); /* Q12 */
+ if ( !st->first_CNG )
+ {
+ hTdCngDec->shb_cng_ener_fx_32 = hTdCngDec->last_shb_cng_ener_fx_32; /* Q11 */
+ move32();
+ }
+ }
- /* SHB energy estimation */
- wb_ener_fx = L_deposit_l( 1 ); /*Q1 */
- IF( NE_16( st->element_mode, IVAS_CPE_DFT ) )
- {
- FOR( i = 0; i < L_FRAME32k; i++ )
+ gain_fx = L_sub( hTdCngDec->wb_cng_ener_fx_32, hTdCngDec->last_wb_cng_ener_fx_32 ); /*Q11 */
+ if ( GT_32( gain_fx, 30720 ) )
{
- wb_ener_fx = L_add( wb_ener_fx, Mpy_32_16_1( L_mult0( synth_fx[i], synth_fx[i] ), 51 ) ); /* 2*Qsyn */
+ gain_fx = 30720;
+ move32();
}
- }
- exp = norm_l( wb_ener_fx );
- fra = Log2_norm_lc( L_shl( wb_ener_fx, exp ) );
- exp = sub( 30, add( exp, shl( Qsyn, 1 ) ) );
- wb_ener_fx = Mpy_32_16( exp, fra, LG10 );
- wb_ener16_fx = round_fx( L_shl( wb_ener_fx, 10 ) ); /*wb_ener_fx in Q8 */
- Word32 wb_ener32_fx = L_shl( wb_ener16_fx, 3 ); /*wb_ener_fx in Q11 */
- if ( EQ_16( st->first_CNG, 0 ) )
- {
- hTdCngDec->wb_cng_ener_fx_32 = wb_ener32_fx;
- move32(); /*Q11 */
- }
- if ( GT_32( L_abs( L_sub( wb_ener32_fx, hTdCngDec->wb_cng_ener_fx_32 ) ), 24576 ) ) /* 12.0f in Q11 */
- {
- allow_cn_step_fx = 1;
- move16();
- }
+ step_fx = L_sub( L_add( gain_fx, hTdCngDec->last_shb_cng_ener_fx_32 ), hTdCngDec->shb_cng_ener_fx_32 ); /*Q11 */
- IF( EQ_16( allow_cn_step_fx, 1 ) )
- {
- hTdCngDec->wb_cng_ener_fx_32 = wb_ener32_fx;
- move32(); /*Q11 */
- }
- ELSE
- {
- tmp = L_sub( wb_ener32_fx, hTdCngDec->wb_cng_ener_fx_32 ); /*Q11 */
- tmp = Mpy_32_16_1( tmp, 29491 ); /*Q11 */
- hTdCngDec->wb_cng_ener_fx_32 = L_add( hTdCngDec->wb_cng_ener_fx_32, tmp ); /*Q11 */
- move32();
- }
- test();
- test();
- IF( EQ_32( st->core_brate, SID_2k40 ) && EQ_16( sid_bw, 1 ) && EQ_16( st->bfi, 0 ) )
- {
- hTdCngDec->last_wb_cng_ener_fx_32 = hTdCngDec->wb_cng_ener_fx_32; /* Q11 */
- move32();
-
- if ( !st->first_CNG )
+ test();
+ IF( EQ_16( allow_cn_step_fx, 1 ) || GT_32( st->last_core_brate, SID_2k40 ) )
{
- hTdCngDec->shb_cng_ener_fx_32 = hTdCngDec->last_shb_cng_ener_fx_32; /* Q11 */
+ hTdCngDec->shb_cng_ener_fx_32 = L_add( hTdCngDec->shb_cng_ener_fx_32, step_fx ); /* Q11 */
+ move32();
+ }
+ ELSE
+ {
+ hTdCngDec->shb_cng_ener_fx_32 = L_add( hTdCngDec->shb_cng_ener_fx_32, L_shr( step_fx, 2 ) ); /*Q11 */
move32();
}
}
- gain_fx = L_sub( hTdCngDec->wb_cng_ener_fx_32, hTdCngDec->last_wb_cng_ener_fx_32 ); /*Q11 */
- if ( GT_32( gain_fx, 30720 ) )
- {
- gain_fx = 30720;
- move32();
- }
- step_fx = L_sub( L_add( gain_fx, hTdCngDec->last_shb_cng_ener_fx_32 ), hTdCngDec->shb_cng_ener_fx_32 ); /*Q11 */
- test();
- IF( EQ_16( allow_cn_step_fx, 1 ) || GT_32( st->last_core_brate, SID_2k40 ) )
- {
- hTdCngDec->shb_cng_ener_fx_32 = L_add( hTdCngDec->shb_cng_ener_fx_32, step_fx ); /* Q11 */
- move32();
- }
- ELSE
- {
- hTdCngDec->shb_cng_ener_fx_32 = L_add( hTdCngDec->shb_cng_ener_fx_32, L_shr( step_fx, 2 ) ); /*Q11 */
- move32();
- }
/* generate white noise excitation */
FOR( i = 0; i < L_FRAME16k; i++ )
{
@@ -1213,7 +999,6 @@ static void shb_CNG_decod_ivas_fx(
/* synthesis filtering */
Syn_filt_s( 0, shb_lpcCNG_fx, LPC_SHB_ORDER, excTmp_fx, excSHB_fx, L_FRAME16k, hBWE_TD->state_lpc_syn_fx, 1 );
-
/* synthesis signal gain shaping */
L_tmp = 0;
move32();
@@ -1238,56 +1023,105 @@ static void shb_CNG_decod_ivas_fx(
}
}
- ener_fx = hTdCngDec->shb_cng_ener_fx_32;
- move32(); /*Q11 */
- IF( GT_16( st->hTdCngDec->trans_cnt_fx, 0 ) )
+ IF( st->element_mode == EVS_MONO )
{
- i = extract_l( L_mult0( hTdCngDec->trans_cnt_fx, 17 ) ); /*Q0 */
- ener_fx = L_add( hTdCngDec->shb_cng_ener_fx_32, Mpy_32_16_1( L_sub( hTdCngDec->last_shb_ener_fx_32, hTdCngDec->shb_cng_ener_fx_32 ), sin_table256_fx[i] ) ); /*Q11 */
- hTdCngDec->trans_cnt_fx = sub( hTdCngDec->trans_cnt_fx, 1 );
- move16();
- }
+ ener_fx16 = hTdCngDec->shb_cng_ener_fx;
+ move16(); /*Q8 */
+ IF( hTdCngDec->trans_cnt_fx > 0 )
+ {
+ i = extract_l( L_mult0( hTdCngDec->trans_cnt_fx, 17 ) ); /*Q0 */
+ ener_fx16 = add_sat( hTdCngDec->shb_cng_ener_fx, mult( sin_table256_fx[i], sub_sat( hTdCngDec->last_shb_ener_fx, hTdCngDec->shb_cng_ener_fx ) ) ); /*Q8 */
+ hTdCngDec->trans_cnt_fx = sub( hTdCngDec->trans_cnt_fx, 1 );
+ move16();
+ }
- tmp = L_shr( Mpy_32_16_1( ener_fx, 3277 ), 3 ); /*Q8 */
- IF( GT_32( tmp, 32767 ) )
- abort();
- Word16 tmp_16;
- tmp_16 = (Word16) tmp;
- move16();
- L_tmp = L_mult( 27213, tmp_16 ); /*Q22, 27213=3.321928 in Q13 */
- L_tmp = L_shr( L_tmp, 6 ); /*Q16 */
- L_tmp = L_add( L_tmp, L_shl( 10, 16 ) );
- if ( ( L_tmp < 0 ) )
- {
- L_tmp = 0;
- move32();
- }
- fra = L_Extract_lc( L_tmp, &exp );
- L_tmp = L_shr( Pow2( exp, fra ), 5 ); /*Q5 */
- if ( !L_tmp )
- {
- L_tmp = 1;
- move32(); /*Q5 */
+ tmp_16 = mult( 3277, ener_fx16 ); /*Q8 */
+ L_tmp = L_mult( 27213, tmp_16 ); /*Q22, 27213=3.321928 in Q13 */
+ L_tmp = L_shr( L_tmp, 6 ); /*Q16 */
+ L_tmp = L_add( L_tmp, 10 << 16 );
+ if ( L_tmp < 0 )
+ {
+ L_tmp = 0;
+ move32();
+ }
+ fra = L_Extract_lc( L_tmp, &exp );
+ L_tmp = L_shl_sat( Pow2( exp, fra ), 5 ); /*Q5 */
+ L_tmp = L_shr( L_tmp, 10 );
+ if ( !L_tmp )
+ {
+ L_tmp = 1; /*Q5 */
+ }
+ exp = norm_l( L_tmp );
+ L_tmp = L_shl( L_tmp, exp ); /*Q31*/
+ tmp_16 = extract_h( L_tmp ); /*Q15*/
+ exp = sub( exp, 16 );
+ exp1 = norm_s( ener_excSHB_fx );
+ fra = shl( ener_excSHB_fx, exp1 ); /*Q15*/
+
+ IF( GT_16( fra, tmp_16 ) )
+ {
+ fra = shr( fra, 1 ); /*Q15*/
+ exp1 = sub( exp1, 1 );
+ }
+ tmp_16 = div_s( fra, tmp_16 ); /*Q15*/
+
+ L_tmp = L_deposit_h( tmp_16 ); /*Q31 */
+ tmp_16 = sub( add( 5, exp ), add( q, exp1 ) );
+ L_gain_fx = Isqrt_lc( L_tmp, &tmp_16 ); /*Q31-Qtmp */
}
- exp = norm_l( L_tmp );
- L_tmp = L_shl( L_tmp, exp ); /*Q31*/
- tmp_16 = extract_h( L_tmp ); /*Q15*/
- exp = sub( exp, 16 );
- exp1 = norm_s( ener_excSHB_fx );
- fra = shl( ener_excSHB_fx, exp1 ); /*Q15*/
-
- IF( GT_16( fra, tmp_16 ) )
+ ELSE
{
- fra = shr( fra, 1 ); /*Q15*/
- exp1 = sub( exp1, 1 );
+ ener_fx = hTdCngDec->shb_cng_ener_fx_32;
+ move32(); /*Q11 */
+ IF( GT_16( st->hTdCngDec->trans_cnt_fx, 0 ) )
+ {
+ i = extract_l( L_mult0( hTdCngDec->trans_cnt_fx, 17 ) ); /*Q0 */
+ ener_fx = L_add( hTdCngDec->shb_cng_ener_fx_32, Mpy_32_16_1( L_sub( hTdCngDec->last_shb_ener_fx_32, hTdCngDec->shb_cng_ener_fx_32 ), sin_table256_fx[i] ) ); /*Q11 */
+ hTdCngDec->trans_cnt_fx = sub( hTdCngDec->trans_cnt_fx, 1 );
+ move16();
+ }
+
+ tmp = L_shr( Mpy_32_16_1( ener_fx, 3277 ), 3 ); /*Q8 */
+ IF( GT_32( tmp, 32767 ) )
+ abort();
+ tmp_16 = (Word16) tmp;
+ move16();
+ L_tmp = L_mult( 27213, tmp_16 ); /*Q22, 27213=3.321928 in Q13 */
+ L_tmp = L_shr( L_tmp, 6 ); /*Q16 */
+ L_tmp = L_add( L_tmp, L_shl( 10, 16 ) );
+ if ( L_tmp < 0 )
+ {
+ L_tmp = 0;
+ move32();
+ }
+ fra = L_Extract_lc( L_tmp, &exp );
+ L_tmp = L_shr( Pow2( exp, fra ), 5 ); /*Q5 */
+ if ( !L_tmp )
+ {
+ L_tmp = 1;
+ move32(); /*Q5 */
+ }
+ exp = norm_l( L_tmp );
+ L_tmp = L_shl( L_tmp, exp ); /*Q31*/
+ tmp_16 = extract_h( L_tmp ); /*Q15*/
+ exp = sub( exp, 16 );
+ exp1 = norm_s( ener_excSHB_fx );
+ fra = shl( ener_excSHB_fx, exp1 ); /*Q15*/
+
+ IF( GT_16( fra, tmp_16 ) )
+ {
+ fra = shr( fra, 1 ); /*Q15*/
+ exp1 = sub( exp1, 1 );
+ }
+ tmp_16 = div_s( fra, tmp_16 ); /*Q15*/
+
+ L_tmp = L_deposit_h( tmp_16 ); /*Q31 */
+ tmp_16 = sub( add( 5, exp ), add( q, exp1 ) );
+ L_gain_fx = Isqrt_lc( L_tmp, &tmp_16 ); /*Q31-Qtmp */
+ hTdCngDec->shb_cng_gain_fx_32 = ener_fx;
+ move32();
}
- tmp_16 = div_s( fra, tmp_16 ); /*Q15*/
- L_tmp = L_deposit_h( tmp_16 ); /*Q31 */
- tmp_16 = sub( add( 5, exp ), add( q, exp1 ) );
- L_gain_fx = Isqrt_lc( L_tmp, &tmp_16 ); /*Q31-Qtmp */
- hTdCngDec->shb_cng_gain_fx_32 = ener_fx;
- move32();
FOR( i = 0; i < L_FRAME16k; i++ )
{
shb_syn16k_fx[i] = extract_l( L_shr( Mpy_32_16_1( L_gain_fx, excSHB_fx[i] ), sub( 5, tmp_16 ) ) ); /*Q3 = 31-Qtmp-8-15-5+Qtmp */
@@ -1317,7 +1151,17 @@ static void shb_CNG_decod_ivas_fx(
interpolate_3_over_2_allpass_fx( shb_synth_fx, L_FRAME32k, shb_synth_fx, hTdCngDec->interpol_3_2_cng_dec_fx, allpass_poles_3_ov_2 );
}
- Scale_sig( shb_synth_fx, L_FRAME48k, -3 ); /* Qx - 3 */
+ IF( st->element_mode != EVS_MONO )
+ {
+ IF( EQ_32( st->output_Fs, 32000 ) )
+ {
+ Scale_sig( shb_synth_fx, L_FRAME32k, -3 ); /* Qx - 3 */
+ }
+ ELSE
+ {
+ Scale_sig( shb_synth_fx, L_FRAME48k, -3 ); /* Qx - 3 */
+ }
+ }
ResetSHBbuffer_Dec_fx( st->hBWE_TD, st->extl );
diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c
index 22fed24cb2640ca07b98af6f1d0d7e2741e9924e..79b75b02f20db6120e5428c92ecf95e417a4a391 100644
--- a/lib_dec/core_dec_init_fx.c
+++ b/lib_dec/core_dec_init_fx.c
@@ -1978,7 +1978,7 @@ void open_decoder_LPD_ivas_fx(
IF( st->hTcxDec != NULL && ( st->ini_frame == 0 || LT_32( last_total_brate, HQ_48k ) || EQ_16( st->last_codec_mode, MODE1 ) || st->force_lpd_reset ) )
{
- concealment_init_ivas_fx( st->hTcxDec->L_frameTCX, st->hPlcInfo );
+ concealment_init_x( st->hTcxDec->L_frameTCX, st->hPlcInfo );
}
}
ELSE
diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c
index 8bab0d0615082173235cbc1d82893dd6957d809d..9d36d2c5e2f4d8f57f27efe347b5676afd9a2859 100644
--- a/lib_dec/core_switching_dec_fx.c
+++ b/lib_dec/core_switching_dec_fx.c
@@ -12,128 +12,13 @@
/*---------------------------------------------------------------------*
- * bandwidth_switching_detect_fx()
- *
- *
+ * Local prototypes
*---------------------------------------------------------------------*/
static void smoothTransitionDtxToTcx_fx( Word16 synth[], const Word16 output_frame, const Word16 delay_comp );
-static void core_switch_lb_upsamp_fx( Decoder_State *st, Word32 *output );
-
-void bandwidth_switching_detect_fx(
- Decoder_State *st_fx /* i/o: encoder state structure */
-)
-{
- test();
- test();
- IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
- {
- /* there is no BWE in TD stereo secondary channel and in MDCT stereo, IGF is part of the core decoding -> no BW switching -> reset BWS counters */
- st_fx->prev_bws_cnt = 0;
- st_fx->bws_cnt = 0;
- st_fx->bws_cnt1 = 0;
- move16();
- move16();
- move16();
-
- return;
- }
- /* update band-width switching counter */
- test();
- test();
- test();
- IF( GE_16( st_fx->bws_cnt1, N_NS2W_FRAMES ) )
- {
- st_fx->bws_cnt1 = 0;
- move16();
- }
- ELSE IF( GT_32( st_fx->total_brate, ACELP_9k60 ) && LT_32( st_fx->last_core_brate, ACELP_9k60 ) && EQ_16( st_fx->bwidth, SWB ) && EQ_16( st_fx->last_bwidth, WB ) )
- {
- st_fx->bws_cnt1 = add( st_fx->bws_cnt1, 1 ); /* Q0 */
- move16();
- }
- ELSE IF( st_fx->bws_cnt1 > 0 )
- {
- IF( LT_16( st_fx->bwidth, st_fx->last_bwidth ) )
- {
- st_fx->bws_cnt = sub( shl( sub( N_NS2W_FRAMES, st_fx->bws_cnt1 ), 1 ), 1 ); /* Q0 */
- move16();
- }
- ELSE
- {
- st_fx->bws_cnt = 0;
- move16();
- }
-
- IF( LT_16( st_fx->bwidth, st_fx->last_bwidth ) )
- {
- st_fx->bws_cnt1 = 0;
- move16();
- }
- ELSE
- {
- IF( EQ_16( st_fx->bwidth, SWB ) )
- {
- st_fx->bws_cnt1 = add( st_fx->bws_cnt1, 1 ); /* Q0 */
- move16();
- }
- ELSE
- {
- st_fx->bws_cnt1 = 0;
- move16();
- }
- }
- }
- /* update band-width switching counter */
- test();
- test();
- test();
- IF( GE_16( st_fx->bws_cnt, N_WS2N_FRAMES ) )
- {
- st_fx->bws_cnt = 0;
- move16();
- }
- ELSE IF( LT_32( st_fx->total_brate, ACELP_9k60 ) && GT_32( st_fx->last_core_brate, ACELP_9k60 ) && LT_16( st_fx->bwidth, st_fx->last_bwidth ) && EQ_16( st_fx->bwidth, WB ) )
- {
- st_fx->bws_cnt = add( st_fx->bws_cnt, 1 ); /* Q0 */
- move16();
- }
- ELSE IF( st_fx->bws_cnt > 0 )
- {
- IF( GT_16( st_fx->bwidth, st_fx->last_bwidth ) )
- {
- st_fx->bws_cnt1 = shr( sub( N_WS2N_FRAMES, st_fx->bws_cnt ), 1 ); /* Q0 */
- move16();
- }
- ELSE
- {
- st_fx->bws_cnt1 = 0;
- move16();
- }
-
- IF( GT_16( st_fx->bwidth, st_fx->last_bwidth ) )
- {
- st_fx->bws_cnt = 0;
- move16();
- }
- ELSE
- {
- IF( EQ_16( st_fx->bwidth, WB ) )
- {
- st_fx->bws_cnt = add( st_fx->bws_cnt, 1 );
- move16();
- }
- ELSE
- {
- st_fx->bws_cnt = 0;
- move16();
- }
- }
- }
+static void core_switch_lb_upsamp_fx( Decoder_State *st, Word32 *output );
- return;
-}
/*---------------------------------------------------------------------*
* Calc_freq_ener_fx()
@@ -167,6 +52,7 @@ static Word32 Calc_freq_ener_fx(
return enerLL_fx;
}
+
/*---------------------------------------------------------------------*
* bw_switching_pre_proc_fx()
*
@@ -174,8 +60,10 @@ static Word32 Calc_freq_ener_fx(
*---------------------------------------------------------------------*/
void bw_switching_pre_proc_fx(
- const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/
- Decoder_State *st_fx /* i/o: decoder state structure */
+ Decoder_State *st_fx, /* i/o: decoder state structure */
+ const Word32 last_element_brate, /* i : last element bitrate */
+ const Word16 nchan_out, /* i : number of output channels */
+ const Word16 *old_syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/
)
{
Word16 i;
@@ -184,6 +72,28 @@ void bw_switching_pre_proc_fx(
IF( st_fx->element_mode > EVS_MONO )
{
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( st_fx->core == ACELP_CORE ) && !( EQ_16( st_fx->bfi, 1 ) && EQ_16( st_fx->con_tcx, 1 ) ) && st_fx->hBWE_FD != NULL && !( LE_32( st_fx->core_brate, SID_2k40 ) && EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) ) && !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st_fx->idchan, 1 ) && LE_32( last_element_brate, IVAS_SID_5k2 ) ) )
+ {
+ /* Calculate tilt of the ACELP core synthesis - needed in SWB BWE decoding */
+ Word16 old_syn_12k8_16k_tmp_16fx[L_FRAME16k];
+ Word32 old_syn_12k8_16k_tmp_32fx[L_FRAME16k];
+ Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx, old_syn_12k8_16k_tmp_32fx, st_fx->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1))
+ Copy_Scale_sig_32_16( old_syn_12k8_16k_tmp_32fx, old_syn_12k8_16k_tmp_16fx, st_fx->L_frame, sub( -1, Q11 ) );
+ st_fx->tilt_wb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_syn_12k8_16k_tmp_16fx, -1, st_fx->L_frame ), sub( Q11, 8 ) ) ); // Q24+(Q11-8) - 16
+ move16();
+ }
+
+ return;
}
test();
@@ -196,986 +106,73 @@ void bw_switching_pre_proc_fx(
st_fx->tilt_wb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_syn_12k8_16k_fx, -1, st_fx->L_frame ), 3 ) ); /* Q11 */
move16();
+
/*-------------------------------------------------------------------------------*
* Calculate frequency energy of 0~3.2kHz and 3.2~6.4kHz the ACELP core synthesis
*-------------------------------------------------------------------------------*/
edct_16fx( old_syn_12k8_16k_fx, syn_dct_fx, L_FRAME, 6, st_fx->element_mode );
- L_tmp = L_deposit_l( 0 );
- FOR( i = 0; i < L_FRAME / 2; i++ )
- {
- L_tmp = L_mac0_sat( L_tmp, syn_dct_fx[i], syn_dct_fx[i] ); /* (2 * Q_syn2) */
- }
- L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */
- st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */
- move32();
- L_tmp = L_deposit_l( 0 );
- FOR( ; i < L_FRAME; i++ )
- {
- L_tmp = L_mac0_sat( L_tmp, syn_dct_fx[i], syn_dct_fx[i] );
- }
- L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */
- st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */
- move32();
- }
- ELSE
- {
- IF( st_fx->hHQ_core->old_is_transient[0] )
- {
- L_tmp = L_deposit_l( 0 );
- FOR( i = 0; i < 32; i++ )
- {
- L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */
- }
- L_tmp = L_shr( L_tmp, 5 ); /* 2 * Q_syn2 */
- st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */
- move32();
- L_tmp = L_deposit_l( 0 );
- FOR( ; i < 64; i++ )
- {
- L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */
- }
- L_tmp = L_shr( L_tmp, 5 ); /* 2 * Q_syn2 */
- st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */
- move32();
- }
- ELSE
- {
- L_tmp = L_deposit_l( 0 );
- FOR( i = 0; i < L_FRAME / 2; i++ )
- {
- L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */
- }
- L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */
- st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */
- move32();
- L_tmp = L_deposit_l( 0 );
- FOR( ; i < L_FRAME; i++ )
- {
- L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */
- }
- L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */
- st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */
- move32();
- }
- }
-
-
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( st_fx->last_bwidth == 0 && LE_16( st_fx->extl, SWB_CNG ) )
- {
- st_fx->prev_ener_shb_fx = 0;
- move16();
- set16_fx( st_fx->hBWE_FD->prev_SWB_fenv_fx, 0, SWB_FENV );
- }
- ELSE IF( ( ( st_fx->core == ACELP_CORE && ( EQ_16( st_fx->last_core, HQ_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) || EQ_16( st_fx->last_core, TCX_20_CORE ) ) ) || ( EQ_16( st_fx->core, st_fx->last_core ) && NE_16( st_fx->extl, st_fx->last_extl ) ) ) && GE_16( st_fx->last_bwidth, SWB ) )
- {
- st_fx->attenu_fx = 3277; /* Q15 */
- move16();
- }
-
- test();
- test();
- test();
- test();
- test();
- IF( EQ_16( st_fx->last_core, HQ_CORE ) || ( EQ_16( st_fx->last_core, ACELP_CORE ) && !( EQ_16( st_fx->last_extl, WB_TBE ) || EQ_16( st_fx->last_extl, SWB_TBE ) || EQ_16( st_fx->last_extl, FB_TBE ) ) && GT_32( st_fx->core_brate, ACELP_8k00 ) ) )
- {
- st_fx->prev_fractive = 0;
- move16();
- }
- return;
-}
-
-
-/*---------------------------------------------------------------------*
- * core_switching_pre_dec_fx()
- *
- * Preprocessing/preparation for ACELP/HQ core switching
- *---------------------------------------------------------------------*/
-ivas_error core_switching_pre_dec_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word16 output_frame /* i : frame length Q0*/
-)
-{
- Word16 oldLenClasBuff, newLenClasBuff, i;
- BPF_DEC_HANDLE hBPF;
- TD_BWE_DEC_HANDLE hBWE_TD;
- FD_BWE_DEC_HANDLE hBWE_FD;
- HQ_DEC_HANDLE hHQ_core;
- TCX_DEC_HANDLE hTcxDec;
- ivas_error error;
-
- hBWE_TD = st_fx->hBWE_TD;
- hBWE_FD = st_fx->hBWE_FD;
- hHQ_core = st_fx->hHQ_core;
- hBPF = st_fx->hBPF;
- hTcxDec = st_fx->hTcxDec;
-
- error = IVAS_ERR_OK;
- move32();
- test();
- test();
- test();
- /* Codec switching */
- IF( EQ_16( st_fx->last_codec_mode, MODE2 ) || ( ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) && st_fx->element_mode > EVS_MONO ) )
- {
- st_fx->mem_deemph_fx = st_fx->syn[M]; /* Q_syn */
- move16();
- set16_fx( st_fx->agc_mem_fx, 0, 2 ); /* Q0 */
- Scale_sig( &( st_fx->mem_deemph_fx ), 1, st_fx->Q_syn ); /* Brings mem_deemph to Qsyn */
-
- Copy_Scale_sig( st_fx->mem_syn2_fx, st_fx->mem_syn1_fx, M, sub( -1, st_fx->Q_syn ) ); /*Q-1*/
-
- st_fx->bpf_off = 1;
- move16();
- Scale_sig( st_fx->hPFstat->mem_pf_in, L_SUBFR, st_fx->Q_syn ); /* Post_filter mem */ /* st_fx->Q_syn*/
- Scale_sig( st_fx->hPFstat->mem_res2, DECMEM_RES2, st_fx->Q_syn ); /* NB post_filter mem */ /* st_fx->Q_syn */
- Scale_sig( st_fx->hPFstat->mem_stp, L_SUBFR, st_fx->Q_syn ); /* Post_filter mem */ /* st_fx->Q_syn */
- IF( hBPF != NULL )
- {
- set16_fx( hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/
- hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st_fx->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10 */
- hBPF->pst_mem_deemp_err_fx = 0;
- move16();
- move16();
- }
- move16();
- st_fx->psf_lp_noise_fx = round_fx( L_shl( st_fx->lp_noise, 1 ) ); /* 2 * lp_noise_q - 16 */
-
- /* reset old HB synthesis buffer */
- IF( EQ_16( st_fx->last_L_frame, L_FRAME ) )
- {
- st_fx->old_bwe_delay = NS2SA_FX2( st_fx->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS ); /* Q0 */
- }
- ELSE
- {
- st_fx->old_bwe_delay = NS2SA_FX2( st_fx->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS ); /* Q0 */
- }
- move16();
- set16_fx( st_fx->hb_prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) );
-
- /* reset upd_cnt */
- st_fx->upd_cnt = MAX_UPD_CNT;
- move16();
- st_fx->igf = 0;
- move16();
-
-
- test();
- IF( hBWE_TD != NULL && NE_16( st_fx->last_core, ACELP_CORE ) )
- {
- hBWE_TD->prev_hb_synth_fx_exp = 31;
- move16();
- /* reset BWE memories */
- set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); /* Q_exc */
- hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 );
- move32();
- }
-
- test();
- IF( GE_32( st_fx->output_Fs, 16000 ) && st_fx->hBWE_zero != NULL )
- {
- hf_synth_reset_fx( st_fx->hBWE_zero );
- }
- IF( st_fx->hBWE_FD != NULL )
- {
- set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
- }
- IF( st_fx->hHQ_core != NULL )
- {
- set32_fx( hHQ_core->prev_env_fx, 0, SFM_N_WB );
- set32_fx( hHQ_core->prev_normq_fx, 0, SFM_N_WB );
-
- set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX );
- set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX );
- hHQ_core->last_max_pos_pulse = 0;
- move16();
-
- IF( GT_32( st_fx->output_Fs, 16000 ) )
- {
- set32_fx( hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE );
- }
-
- /* pre-echo */
- hHQ_core->pastpre = 0;
- move16();
- }
- /* reset the GSC pre echo energy threshold in case of switching */
- IF( st_fx->hGSCDec != NULL )
- {
- st_fx->hGSCDec->Last_frame_ener_fx = MAX_32;
- }
- move32();
-
- test();
- IF( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) )
- {
- IF( st_fx->element_mode == EVS_MONO )
- {
- st_fx->last_core = HQ_CORE;
- move16();
- Copy( hTcxDec->FBTCXdelayBuf, st_fx->prev_synth_buffer_fx, NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); /* st_fx->q_prev_synth_buffer_fx */
- }
- IF( hHQ_core != NULL )
- {
- set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX );
- set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX );
- hHQ_core->last_max_pos_pulse = 0;
- move16();
-
- set16_fx( hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM );
- hHQ_core->prev_frm_hfe2 = 0;
- move16();
- hHQ_core->prev_stab_hfe2 = 0;
- move16();
- }
- }
-
- IF( st_fx->prev_bfi != 0 )
- {
- Word16 delay_comp;
-
- /*switch off Hq Voicing as it was not uodated in MODE2*/
- IF( hHQ_core != NULL )
- {
- hHQ_core->oldHqVoicing = 0;
- hHQ_core->HqVoicing = 0;
- move16();
- move16();
- }
-
- delay_comp = NS2SA_FX2( st_fx->output_Fs, DELAY_CLDFB_NS );
-
- test();
- test();
- IF( !st_fx->last_con_tcx && st_fx->last_core_bfi == ACELP_CORE && EQ_16( st_fx->core, HQ_CORE ) )
- {
-
- Word16 no_col;
- Word32 *realBuffer[CLDFB_NO_COL_MAX_SWITCH], *imagBuffer[CLDFB_NO_COL_MAX_SWITCH];
- Word32 realBufferTmp[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX], imagBufferTmp[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX];
- CLDFB_SCALE_FACTOR scaleFactor;
- Word32 workBuffer[128 * 3];
-
- FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH; i++ )
- {
- set32_fx( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX );
- set32_fx( imagBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX );
- realBuffer[i] = realBufferTmp[i];
- move32();
- imagBuffer[i] = imagBufferTmp[i];
- move32();
- }
-
- no_col = s_min( st_fx->cldfbAna->no_col, idiv1616( sub( add( delay_comp, st_fx->cldfbAna->no_channels ), 1 ), st_fx->cldfbAna->no_channels ) ); /* Q0 */
-
- /* CLDFB analysis of the synthesis at internal sampling rate */
- IF( ( error = cldfb_save_memory( st_fx->cldfbAna ) ) != IVAS_ERR_OK )
- {
- return error;
- }
- cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, hTcxDec->syn_Overl, 0, no_col, workBuffer );
- cldfb_restore_memory( st_fx->cldfbAna );
-
- scaleFactor.hb_scale = scaleFactor.lb_scale;
- move16();
-
- /* CLDFB synthesis of the combined signal */
- IF( ( error = cldfb_save_memory( st_fx->cldfbSyn ) ) != IVAS_ERR_OK )
- {
- return error;
- }
- cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, hHQ_core->fer_samples_fx, 0, no_col, workBuffer );
- cldfb_restore_memory( st_fx->cldfbSyn );
- }
-
- test();
- test();
- IF( !st_fx->last_con_tcx && st_fx->last_core_bfi == ACELP_CORE && EQ_16( st_fx->core, HQ_CORE ) )
- {
- lerp( hTcxDec->syn_Overl, hHQ_core->fer_samples_fx + delay_comp, shr( st_fx->output_frame_fx, 1 ), shr( st_fx->last_L_frame, 1 ) );
- /*Set to zero the remaining part*/
- set16_fx( hHQ_core->fer_samples_fx + delay_comp + shr( st_fx->output_frame_fx, 1 ), 0, shr( st_fx->output_frame_fx, 1 ) - delay_comp );
- }
- }
-
- st_fx->use_acelp_preq = 0;
- move16();
- st_fx->reset_mem_AR = 0;
- move16();
- }
-
- /*FEC*/
- IF( LE_16( st_fx->L_frame, L_FRAME16k ) )
- {
- test();
- IF( LE_16( st_fx->last_L_frame, L_FRAME16k ) && NE_16( st_fx->core, HQ_CORE ) )
- {
- IF( NE_16( st_fx->L_frame, st_fx->last_L_frame ) )
- {
- IF( GT_16( st_fx->L_frame, st_fx->last_L_frame ) )
- {
- oldLenClasBuff = extract_l( L_shr( Mpy_32_16_1( L_mult0( st_fx->last_L_frame, getInvFrameLen( st_fx->L_frame ) /*Q21*/ ) /*Q21*/, L_SYN_MEM_CLAS_ESTIM /*Q0*/ ) /*Q6*/, 6 ) /*Q0*/ );
- newLenClasBuff = L_SYN_MEM_CLAS_ESTIM;
- move16();
- }
- ELSE
- {
- oldLenClasBuff = L_SYN_MEM_CLAS_ESTIM;
- move16();
- newLenClasBuff = extract_l( L_shr( Mpy_32_16_1( L_mult0( st_fx->L_frame, getInvFrameLen( st_fx->last_L_frame ) /*Q21*/ ) /*Q21*/, L_SYN_MEM_CLAS_ESTIM /*Q0*/ ) /*Q6*/, 6 ) /*Q0*/ );
- }
- lerp( &st_fx->mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM - oldLenClasBuff], &st_fx->mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM - newLenClasBuff], newLenClasBuff, oldLenClasBuff );
- }
- }
- ELSE
- {
- set16_fx( st_fx->mem_syn_clas_estim_fx, 0, L_SYN_MEM_CLAS_ESTIM );
- st_fx->classifier_Q_mem_syn = 0;
- move16();
- }
- }
-
- /* Here we only handle cases where last_ppp and last_nelp not updated when coming from CodecB or other cores
- within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */
- test();
- test();
- IF( EQ_16( st_fx->core, ACELP_CORE ) && ( NE_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) ) )
- {
- st_fx->last_ppp_mode_dec = 0;
- move16();
- st_fx->last_nelp_mode_dec = 0;
- move16();
- }
-
- test();
- test();
- test();
- IF( EQ_16( st_fx->core, ACELP_CORE ) && ( NE_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) || LE_32( st_fx->last_total_brate, PPP_NELP_2k80 ) ) )
- {
- st_fx->act_count = 3;
- move16();
- st_fx->uv_count = 0;
- move16();
- }
-
- test();
- test();
- IF( ( ( EQ_16( st_fx->core, ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) )
- {
- test();
- IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
- {
- st_fx->hPFstat->reset = 1;
- move16();
- }
-
- IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
- {
- Copy( TRWB2_Ave_fx, st_fx->lsf_old_fx, M ); /* Q2.56 */
- Copy( TRWB2_Ave_fx, st_fx->lsfoldbfi1_fx, M ); /* Q2.56 */
- Copy( TRWB2_Ave_fx, st_fx->lsfoldbfi0_fx, M ); /* Q2.56*/
- Copy( TRWB2_Ave_fx, st_fx->lsf_adaptive_mean_fx, M ); /* Q2.56 */
- lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_16k );
- }
- ELSE
- {
- Copy( TRWB_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */ /* Q2.56 */
- Copy( TRWB_Ave_fx, st_fx->lsfoldbfi1_fx, M ); /* Q2.56 */
- Copy( TRWB_Ave_fx, st_fx->lsfoldbfi0_fx, M ); /* Q2.56 */
- Copy( TRWB_Ave_fx, st_fx->lsf_adaptive_mean_fx, M ); /* Q2.56 */
- lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX );
- }
-
-
- set16_fx( st_fx->agc_mem_fx, 0, 2 );
- st_fx->mem_deemph_fx = 0;
- move16();
- IF( !st_fx->last_con_tcx )
- {
- set16_fx( st_fx->mem_syn2_fx, 0, M );
- }
- set16_fx( st_fx->mem_syn1_fx, 0, M );
- IF( hBWE_TD != NULL )
- {
- hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
- move16();
- }
- /* Reset ACELP parameters */
- set16_fx( st_fx->mem_MA_fx, 0, M );
- IF( EQ_32( st_fx->sr_core, INT_FS_16k ) )
- {
- Copy( GEWB2_Ave_fx, st_fx->mem_AR_fx, M ); /* Q2.56 */
- }
- ELSE
- {
- Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); /* Q2.56 */
- }
- st_fx->tilt_code_fx = 0;
- move16();
- st_fx->gc_threshold_fx = 0;
- move16();
- st_fx->dm_fx.prev_gain_code = L_deposit_l( 0 ); /* Q16 */
- move32();
- set16_fx( st_fx->dm_fx.prev_gain_pit, 0, 6 );
- st_fx->dm_fx.prev_state = 0;
- move16();
-
- st_fx->last_coder_type = GENERIC;
- move16();
-
- frame_ener_fx( output_frame, UNVOICED_CLAS, st_fx->previoussynth_fx, -1, &st_fx->enr_old_fx, 1, 0, 0, 0 );
- st_fx->lp_gainp_fx = 0;
- move16();
-
- /* the sqrt below needs to be changed to use basop Sqrt16 */
- /*st_fx->lp_gainc_fx = (float)sqrt( st_fx->lp_ener_fx ); */
- IF( st_fx->lp_ener_fx != 0 )
- {
- Word32 L_tmp;
- Word16 tmp, exp;
- exp = norm_l( st_fx->lp_ener_fx ); /* In Q6 */
- tmp = extract_h( L_shl( st_fx->lp_ener_fx, exp ) );
- exp = sub( exp, 30 - 6 );
-
- tmp = div_s( 16384, tmp );
- L_tmp = L_deposit_h( tmp );
- L_tmp = Isqrt_lc( L_tmp, &exp );
-
- st_fx->lp_gainc_fx = round_fx( L_shl( L_tmp, sub( exp, 12 ) ) ); /* In Q3 */
- move16();
- }
-
-
- st_fx->last_voice_factor_fx = 0;
- move16();
- st_fx->Last_GSC_noisy_speech_flag = 0;
- move16();
-
- /* reset CLDFB memories */
- cldfb_reset_memory( st_fx->cldfbAna );
- cldfb_reset_memory( st_fx->cldfbBPF );
- cldfb_reset_memory( st_fx->cldfbSyn );
-
- /* reset TBE memories */
- test();
- test();
-
- IF( !st_fx->last_con_tcx && !( ( EQ_16( st_fx->last_core, HQ_CORE ) ) && st_fx->element_mode > EVS_MONO ) )
- {
- set16_fx( st_fx->old_exc_fx, 0, L_EXC_MEM_DEC );
- }
- ELSE IF( LT_16( st_fx->L_frame, L_FRAME16k ) )
- {
- /* resample from 16kHz to 12.8kHZ */
- synth_mem_updt2( st_fx->L_frame, L_FRAME16k, st_fx->old_exc_fx, st_fx->mem_syn_r, st_fx->mem_syn2_fx, NULL, DEC );
- }
-
- IF( hBWE_TD != NULL )
- {
- set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
- }
-
- test();
- IF( GE_32( st_fx->output_Fs, 16000L ) && st_fx->hBWE_zero != NULL )
- {
- hf_synth_reset_fx( st_fx->hBWE_zero );
- }
- IF( hBWE_FD != NULL )
- {
- set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_NS ) );
- }
- }
-
- test();
- test();
- test();
- test();
- test();
- IF( hHQ_core != NULL && EQ_16( st_fx->core, HQ_CORE ) && ( EQ_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) || ( st_fx->element_mode != EVS_MONO && NE_16( st_fx->last_core, HQ_CORE ) ) ) )
- {
- set32_fx( hHQ_core->prev_env_fx, 0, SFM_N_WB );
- set32_fx( hHQ_core->prev_normq_fx, 0, SFM_N_WB );
-
- set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX );
- set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX );
- hHQ_core->last_max_pos_pulse = 0;
- move16();
-
- set16_fx( hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM );
- hHQ_core->prev_frm_hfe2 = 0;
- hHQ_core->prev_stab_hfe2 = 0;
- move16();
- move16();
- IF( GT_32( st_fx->output_Fs, 16000 ) )
- {
- set32_fx( hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE );
- }
-
- if ( st_fx->element_mode != EVS_MONO )
- {
- }
- else
- {
- set16_fx( hHQ_core->old_out_fx, 0, output_frame );
- hHQ_core->Q_old_wtda_LB = 15;
- hHQ_core->Q_old_wtda = 15;
- move16();
- }
- }
-
- test();
- /* handle switching cases where preecho_sb was not called in the last frame (memory not up to date) */
- IF( hHQ_core != NULL )
- {
- hHQ_core->pastpre = sub( hHQ_core->pastpre, 1 ); /* Q0 */
- move16();
- IF( hHQ_core->pastpre <= 0 )
- {
- reset_preecho_dec_fx( hHQ_core );
- }
- }
- IF( EQ_32( st_fx->core_brate, FRAME_NO_DATA ) )
- {
- st_fx->VAD = 0;
- move16();
- st_fx->m_frame_type = ZERO_FRAME;
- move16();
- }
- ELSE IF( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) )
- {
- st_fx->VAD = 0;
- move16();
- st_fx->m_frame_type = SID_FRAME;
- move16();
- }
- ELSE
- {
- st_fx->VAD = 1;
- move16();
- st_fx->m_frame_type = ACTIVE_FRAME;
- move16();
- }
-
- /*switch on CNA on active frames*/
- IF( st_fx->element_mode == EVS_MONO ) /* for IVAS modes, st->flag_cna is set earlier */
- {
- test();
- test();
- test();
- test();
- test();
- test();
- IF( NE_16( st_fx->core, AMR_WB_CORE ) && st_fx->VAD && LE_32( st_fx->total_brate, CNA_MAX_BRATE ) )
- {
- st_fx->flag_cna = 1;
- move16();
- }
- ELSE IF( EQ_16( st_fx->core, AMR_WB_CORE ) && st_fx->VAD && LE_32( st_fx->total_brate, ACELP_8k85 ) )
- {
- st_fx->flag_cna = 1;
- move16();
- }
- ELSE IF( st_fx->VAD || ( EQ_16( st_fx->cng_type, FD_CNG ) && EQ_16( st_fx->L_frame, L_FRAME16k ) ) )
- {
- st_fx->flag_cna = 0;
- move16();
- }
- }
- if ( EQ_16( st_fx->core, AMR_WB_CORE ) )
- {
- st_fx->cng_type = LP_CNG;
- move16();
- }
-
- test();
- test();
- test();
- test();
- IF( st_fx->hFdCngDec && ( ( NE_16( st_fx->last_L_frame, st_fx->L_frame ) ) ||
- ( NE_16( st_fx->hFdCngDec->hFdCngCom->frameSize, st_fx->L_frame ) ) ||
- st_fx->ini_frame == 0 || NE_16( st_fx->bwidth, st_fx->last_bwidth ) ) )
- {
-
- IF( NE_16( st_fx->core, AMR_WB_CORE ) )
- {
- Word32 tmp;
-
- tmp = st_fx->total_brate;
- move32();
- test();
- if ( EQ_16( st_fx->rf_flag, 1 ) && EQ_32( st_fx->total_brate, ACELP_13k20 ) )
- {
- tmp = ACELP_9k60;
- move32();
- }
- configureFdCngDec_fx( st_fx->hFdCngDec, st_fx->bwidth, tmp, st_fx->L_frame, st_fx->last_L_frame, st_fx->element_mode );
- }
- ELSE
- {
- configureFdCngDec_fx( st_fx->hFdCngDec, 1, ACELP_8k00, st_fx->L_frame, st_fx->last_L_frame, st_fx->element_mode );
-
- if ( st_fx->VAD )
- {
- st_fx->hFdCngDec->hFdCngCom->CngBitrate = st_fx->total_brate;
- move32();
- }
- }
-
- test();
- test();
- IF( NE_16( st_fx->last_L_frame, st_fx->L_frame ) && LE_16( st_fx->L_frame, L_FRAME16k ) && LE_16( st_fx->last_L_frame, L_FRAME16k ) )
- {
- test();
- IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
- {
- }
-
- lerp( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st_fx->L_frame, 1 ), shl( st_fx->last_L_frame, 1 ) );
- test();
- IF( LE_32( st_fx->total_brate, SID_2k40 ) && LE_32( st_fx->last_total_brate, SID_2k40 ) )
- {
- lerp( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth, st_fx->hFdCngDec->hFdCngCom->olapBufferSynth, shl( st_fx->L_frame, 1 ), shl( st_fx->last_L_frame, 1 ) );
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
- {
- FOR( i = 0; i < shl( st_fx->L_frame, 1 ); i++ )
- {
- st_fx->hFdCngDec->hFdCngCom->olapBufferSynth[i] = mult_r( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth[i], 20480 /* Q15*/ ); /* q_olapBuffer */
- move16();
- }
- }
- ELSE
- {
- FOR( i = 0; i < shl( st_fx->L_frame, 1 ); i++ )
- {
- st_fx->hFdCngDec->hFdCngCom->olapBufferSynth[i] = mult_r( shl( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth[i], 1 ), 26214 /* Q14*/ ); /* q_olapBuffer */
- move16();
- }
- }
- }
- }
- }
-
- return error;
-}
-
-/*---------------------------------------------------------------------*
- * core_switching_post_dec()
- *
- * Postprocessing for ACELP/HQ core switching
- *---------------------------------------------------------------------*/
-
-ivas_error core_switching_post_dec_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- Word16 *synth, /* i/o: output synthesis Qsynth*/
- const Word16 output_frame, /* i : frame length Q0*/
- const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/
- const Word16 last_element_mode, /* i : element mode of previous frame Q0*/
- Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */
-)
-{
- Word16 i, delay_comp, delta;
- Word16 tmpF, tmp, Fs_kHz, shift, *ptmp1, *ptmp2;
- Word32 L_tmp;
- Word16 synth_subfr_out[SWITCH_MAX_GAP], synth_subfr_bwe[SWITCH_MAX_GAP];
- Word16 mem_synth[NS2SA( 16000, DELAY_CLDFB_NS ) + 2];
- Word16 Qtmp;
- Word16 Qsubfr;
- TD_BWE_DEC_HANDLE hBWE_TD;
- FD_BWE_DEC_HANDLE hBWE_FD;
- HQ_DEC_HANDLE hHQ_core;
- ivas_error error;
-
- (void) ( last_element_mode );
- hBWE_TD = st_fx->hBWE_TD;
- hBWE_FD = st_fx->hBWE_FD;
- hHQ_core = st_fx->hHQ_core;
- error = IVAS_ERR_OK;
- move32();
-
- /* Rescale synthesis in Q0 to avoid multiple rescaling after */
- tmp = Find_Max_Norm16( synth, output_frame );
- Scale_sig( synth, output_frame, tmp );
- *Qsynth = add( *Qsynth, tmp );
- move16();
-
- test();
- test();
- test();
- IF( st_fx->core == ACELP_CORE && st_fx->bfi && hHQ_core != NULL && !st_fx->con_tcx )
- {
- if ( ( error = acelp_core_switch_dec_bfi_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK )
- {
- return error;
- } /*the output at Q0*/
- }
-
- /* set multiplication factor according to the sampling rate */
- tmp = extract_l( L_shr( st_fx->output_Fs, 13 ) ); /* Q0 */
- Fs_kHz = shl( add( tmp, 1 ), 3 ); /* Q0 */
-
- delta = 1;
- move16();
- if ( GE_16( output_frame, L_FRAME16k ) )
- {
- delta = shr( Fs_kHz, 3 ); /* Q0 */
- }
-
- /* set delay compensation between HQ synthesis and ACELP synthesis */
- delay_comp = i_mult2( delta, HQ_DELAY_COMP ); /* Q0 */
-
- IF( EQ_16( st_fx->core, HQ_CORE ) )
- {
- st_fx->use_acelp_preq = 0;
- move16();
- /* rescaling to the min exp of the 2 */
- /* Qtmp=s_min(*Qsynth,st_fx->Q_old_postdec);
- Scale_sig(synth, output_frame, sub(Qtmp,*Qsynth));
- Scale_sig(st_fx->delay_buf_out_fx, delay_comp, sub(Qtmp,st_fx->Q_old_postdec));*/
-
- hBWE_FD->mem_deemph_old_syn_fx = 0;
- move16();
-
- test();
- test();
- test();
- IF( core_switching_flag && EQ_16( st_fx->last_L_frame, st_fx->last_L_frame_ori ) && ( EQ_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) )
- {
- if ( ( error = acelp_core_switch_dec_fx( st_fx, synth_subfr_out, synth_subfr_bwe, output_frame, core_switching_flag, mem_synth, &Qsubfr ) ) != IVAS_ERR_OK )
- {
- return error;
- }
- }
- test();
- test();
- IF( core_switching_flag && EQ_16( st_fx->last_core, HQ_CORE ) && st_fx->prev_bfi )
- {
- Copy( st_fx->delay_buf_out_fx, synth_subfr_out, delay_comp ); /* hHQ_core->Q_old_postdec */
- Qsubfr = hHQ_core->Q_old_postdec;
- move16();
- }
-
- /* delay HQ synthesis to synchronize with ACELP synthesis */
- /* rescaling to the min exp of the 2 */
- Qtmp = s_min( *Qsynth, hHQ_core->Q_old_postdec );
- Scale_sig( synth, output_frame, sub( Qtmp, *Qsynth ) ); /* Qtmp */
- *Qsynth = Qtmp;
- move16();
- Scale_sig( st_fx->delay_buf_out_fx, delay_comp, sub( Qtmp, hHQ_core->Q_old_postdec ) ); /* Qtmp */
- hHQ_core->Q_old_postdec = Qtmp;
- move16();
- delay_signal_fx( synth, output_frame, st_fx->delay_buf_out_fx, delay_comp ); /* Qsynth, Q0 */
-
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( core_switching_flag && EQ_16( st_fx->last_L_frame, st_fx->last_L_frame_ori ) && ( st_fx->last_core == ACELP_CORE || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) )
- {
- /* mem_over_hp_fx : Qsubfr */
- core_switching_OLA_fx( mem_synth, st_fx->last_L_frame, st_fx->output_Fs, synth, synth_subfr_out, synth_subfr_bwe, output_frame, st_fx->bwidth, Qsynth, &Qsubfr );
- }
- ELSE IF( core_switching_flag && EQ_16( st_fx->last_core, HQ_CORE ) && st_fx->prev_bfi ) /* HQ | ACELP | TRANSITION with ACELP frame lost */
- {
- /* Overlapp between old->out (stocked in st_fx->fer_samples)and good HQ frame on L/2 */
- ptmp1 = &synth[delay_comp]; /* Qsynth */
- shift = i_mult2( Fs_kHz, 10 );
- tmp = i_mult2( delta, shr( N16_CORE_SW, 1 ) );
-
- Scale_sig( hHQ_core->fer_samples_fx, output_frame, *Qsynth ); /* Qsynth */
- ptmp2 = &hHQ_core->fer_samples_fx[tmp];
- tmp = div_s( 1, shift ); /*Q15*/
- tmpF = 0;
- move16();
-
- FOR( i = 0; i < shift; i++ )
- {
- L_tmp = L_mult( ( *ptmp1 ), tmpF ); /*Qsynth + 16*/
- *ptmp1 = round_fx_sat( L_mac_sat( L_tmp, add_sat( sub( 24576, tmpF ), 8192 ), ( *ptmp2 ) ) ); /*Qsynth*/
- ptmp1++;
- ptmp2++;
- tmpF = add( tmpF, tmp );
- }
- }
- ELSE IF( ( !core_switching_flag && EQ_16( st_fx->core, HQ_CORE ) && ( st_fx->last_core == ACELP_CORE || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) /* ACELP | TRANSITION | HQ with TRANSITION lost */
- || ( core_switching_flag && st_fx->prev_bfi && NE_16( st_fx->last_L_frame, st_fx->last_L_frame_ori ) ) )
+ L_tmp = L_deposit_l( 0 );
+ FOR( i = 0; i < L_FRAME / 2; i++ )
{
- /* Overlapp between CELP estimation (BFI) and good HQ frame on L/2 */
- shift = i_mult2( Fs_kHz, 10 );
- tmp = div_s( 1, shift ); /*Q15*/
- tmpF = 0;
- move16();
- ptmp1 = synth;
- Scale_sig( hHQ_core->fer_samples_fx, output_frame, *Qsynth ); /* Qsynth */
- ptmp2 = hHQ_core->fer_samples_fx;
- FOR( i = 0; i < shift; i++ )
- {
- L_tmp = L_mult( ( *ptmp1 ), tmpF ); /*Qsynth + 16*/
- *ptmp1 = round_fx_sat( L_mac_sat( L_tmp, add_sat( sub( 24576, tmpF ), 8192 ), ( *ptmp2 ) ) ); /*Qsynth*/
- move16();
- tmpF = add( tmpF, tmp );
- ptmp1++;
- ptmp2++;
- }
+ L_tmp = L_mac0_sat( L_tmp, syn_dct_fx[i], syn_dct_fx[i] ); /* (2 * Q_syn2) */
}
-
- hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 );
+ L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */
+ st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */
move32();
- IF( !( EQ_16( inner_frame_tbl[st_fx->bwidth], L_FRAME16k ) && EQ_32( st_fx->core_brate, HQ_32k ) ) )
+ L_tmp = L_deposit_l( 0 );
+ FOR( ; i < L_FRAME; i++ )
{
- set32_fx( hHQ_core->prev_env_fx, 0, SFM_N_WB );
- set32_fx( hHQ_core->prev_normq_fx, 0, SFM_N_WB );
+ L_tmp = L_mac0_sat( L_tmp, syn_dct_fx[i], syn_dct_fx[i] );
}
- Copy_Scale_sig( synth, st_fx->previoussynth_fx, output_frame, negate( *Qsynth ) ); /*scaling of st_fx->previoussynth_fx set at Q0*/
-
- /*Set post-filtering flag to zero*/
- st_fx->hPFstat->on = 0;
- move16();
+ L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */
+ st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */
+ move32();
}
ELSE
{
- IF( EQ_16( st_fx->last_core, HQ_CORE ) ) /* MDCT to ACELP transition */
+ IF( st_fx->hHQ_core->old_is_transient[0] )
{
- Qtmp = s_min( s_min( *Qsynth, hHQ_core->Q_old_postdec ), hHQ_core->Q_old_wtda );
-
- Scale_sig( synth, output_frame, sub( Qtmp, *Qsynth ) ); /* Qsynth */
- Scale_sig( st_fx->delay_buf_out_fx, delay_comp, sub( Qtmp, hHQ_core->Q_old_postdec ) ); /* Qtmp */
- Scale_sig( hHQ_core->old_out_fx, L_FRAME48k, sub( Qtmp, hHQ_core->Q_old_wtda ) ); /* Qtmp */
- *Qsynth = Qtmp;
- move16();
- hHQ_core->Q_old_postdec = Qtmp;
- move16();
- hHQ_core->Q_old_wtda = Qtmp;
- move16();
-
- Copy( st_fx->delay_buf_out_fx, synth, delay_comp ); /* copy the HQ/ACELP delay synchroniation buffer at the beginning of ACELP frame Q0*/
-
- tmp = i_mult2( delta, N_ZERO_8 );
- shift = i_mult2( Fs_kHz, 3 );
- test();
- IF( st_fx->prev_bfi && hHQ_core->HqVoicing )
+ L_tmp = L_deposit_l( 0 );
+ FOR( i = 0; i < 32; i++ )
{
- Copy_Scale_sig( hHQ_core->fer_samples_fx, &hHQ_core->old_out_fx[tmp], shift, *Qsynth ); /* Qsynth */
+ L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */
}
-
- ptmp2 = &hHQ_core->old_out_fx[tmp];
- tmp = div_s( 1, shift );
- ptmp1 = &synth[delay_comp];
- tmpF = 0;
- move16();
- FOR( i = 0; i < shift; i++ )
+ L_tmp = L_shr( L_tmp, 5 ); /* 2 * Q_syn2 */
+ st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */
+ move32();
+ L_tmp = L_deposit_l( 0 );
+ FOR( ; i < 64; i++ )
{
- *ptmp1 = add( mult_r( tmpF, *ptmp1 ), mult_r( sub( 32767, tmpF ), *ptmp2++ ) ); /* Q0 */
- move16();
- ptmp1++;
- tmpF = add( tmpF, tmp );
+ L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */
}
+ L_tmp = L_shr( L_tmp, 5 ); /* 2 * Q_syn2 */
+ st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */
+ move32();
}
-
- set16_fx( st_fx->delay_buf_out_fx, 0, HQ_DELTA_MAX * HQ_DELAY_COMP );
- hHQ_core->oldHqVoicing = 0;
- move16();
-
- set16_fx( hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM );
- hHQ_core->prev_frm_hfe2 = 0;
- move16();
- hHQ_core->prev_stab_hfe2 = 0;
- move16();
- }
-
- /* reset SWB BWE buffers */
- test();
- test();
- test();
- IF( st_fx->bws_cnt == 0 || ( st_fx->bws_cnt > 0 && NE_16( st_fx->coder_type, INACTIVE ) && NE_16( st_fx->coder_type, AUDIO ) ) )
- {
- st_fx->attenu_fx = 3277; /* Q15 */
- move16();
- }
-
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( NE_16( st_fx->last_extl, SWB_BWE ) && EQ_16( st_fx->extl, SWB_BWE ) ) || ( NE_16( st_fx->last_extl, FB_BWE ) && EQ_16( st_fx->extl, FB_BWE ) ) ||
- ( ( EQ_16( st_fx->last_core, HQ_CORE ) || EQ_16( st_fx->last_extl, SWB_TBE ) ) && st_fx->extl < 0 && NE_16( st_fx->core, HQ_CORE ) ) || ( st_fx->last_core == ACELP_CORE && st_fx->core == ACELP_CORE && ( ( NE_16( st_fx->prev_coder_type, INACTIVE ) && EQ_16( st_fx->coder_type, INACTIVE ) ) || ( NE_16( st_fx->prev_coder_type, AUDIO ) && EQ_16( st_fx->coder_type, AUDIO ) ) ) && st_fx->bws_cnt > 0 ) )
- {
- set16_fx( hBWE_FD->L_old_wtda_swb_fx, 0, output_frame );
- hBWE_FD->old_wtda_swb_fx_exp = 0;
- move16();
- if ( NE_16( st_fx->last_extl, WB_BWE ) )
+ ELSE
{
- hBWE_FD->prev_mode = NORMAL;
- move16();
+ L_tmp = L_deposit_l( 0 );
+ FOR( i = 0; i < L_FRAME / 2; i++ )
+ {
+ L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */
+ }
+ L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */
+ st_fx->enerLL_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */
+ move32();
+ L_tmp = L_deposit_l( 0 );
+ FOR( ; i < L_FRAME; i++ )
+ {
+ L_tmp = L_mac0_sat( L_tmp, st_fx->t_audio_q_fx[i], st_fx->t_audio_q_fx[i] ); /* 2 * Q_syn2 */
+ }
+ L_tmp = L_shr( L_tmp, 7 ); /* 2 * Q_syn2 */
+ st_fx->enerLH_fx = Calc_freq_ener_fx( L_tmp, shl( st_fx->Q_syn2, 1 ) ); /* Q_syn2 */
+ move32();
}
-
- hBWE_FD->prev_Energy_fx = 0;
- move16();
- hBWE_FD->prev_L_swb_norm = 8;
- move16();
- hBWE_FD->prev_frica_flag = 0;
- move16();
- set16_fx( hBWE_FD->mem_imdct_fx, 0, L_FRAME48k );
- hBWE_FD->prev_td_energy_fx = 0;
- move16();
- hBWE_FD->prev_weight_fx = 6554;
- move16(); /*0.2 in Q15*/
- hBWE_FD->prev_fb_ener_adjust_fx = 0;
- move16();
}
- /* reset WB BWE buffers */
- test();
- IF( NE_16( st_fx->last_extl, WB_BWE ) && EQ_16( st_fx->extl, WB_BWE ) )
- {
- set16_fx( hBWE_FD->L_old_wtda_swb_fx, 0, output_frame );
-
- test();
- IF( NE_16( st_fx->last_extl, SWB_BWE ) && NE_16( st_fx->last_extl, FB_BWE ) )
- {
- hBWE_FD->prev_mode = NORMAL;
- move16();
- }
- hBWE_FD->prev_Energy_wb_fx = 0;
- move16();
- hBWE_FD->prev_L_swb_norm = 8;
- move16();
- set16_fx( hBWE_FD->mem_imdct_fx, 0, L_FRAME48k );
- hBWE_FD->prev_flag = 0;
- move16();
- }
- /* reset SWB TBE buffers */
- test();
- test();
- test();
- test();
- test();
- test();
test();
test();
test();
@@ -1183,82 +180,37 @@ ivas_error core_switching_post_dec_fx(
test();
test();
test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) || EQ_16( st_fx->extl, SWB_CNG ) ) &&
- ( NE_16( st_fx->L_frame, st_fx->last_L_frame ) || ( NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) ) || EQ_16( st_fx->last_core, HQ_CORE ) ) ) ||
- ( LT_16( st_fx->bwidth, st_fx->last_bwidth ) && NE_16( st_fx->last_extl, SWB_TBE ) ) || st_fx->old_ppp_mode || ( ( EQ_16( st_fx->prev_coder_type, AUDIO ) || EQ_16( st_fx->prev_coder_type, INACTIVE ) ) && st_fx->bws_cnt > 0 ) || ( st_fx->bws_cnt == 0 && EQ_16( st_fx->prev_bws_cnt, N_WS2N_FRAMES ) ) )
+ IF( st_fx->last_bwidth == 0 && LE_16( st_fx->extl, SWB_CNG ) )
{
- swb_tbe_reset_fx( hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx,
- hBWE_TD->syn_overlap_fx, hBWE_TD->state_syn_shbexc_fx, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), hBWE_TD->mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ) );
-
- set16_fx( hBWE_TD->GainShape_Delay_fx, 0, NUM_SHB_SUBFR / 2 );
- swb_tbe_reset_synth_fx( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32 );
-
- IF( EQ_16( output_frame, L_FRAME16k ) )
- {
- /* reset in case that SWB TBE layer is transmitted, but the output is 16kHz sampled */
- set16_fx( hBWE_TD->mem_resamp_HB_32k_fx, 0, 2 * ALLPASSSECTIONS_STEEP + 1 );
- set32_fx( hBWE_TD->mem_resamp_HB_32k_fx_32, 0, 2 * ALLPASSSECTIONS_STEEP + 1 );
- }
- set16_fx( hBWE_TD->int_3_over_2_tbemem_dec_fx, 0, INTERP_3_2_MEM_LEN );
- set32_fx( hBWE_TD->int_3_over_2_tbemem_dec_fx_32, 0, INTERP_3_2_MEM_LEN );
+ st_fx->prev_ener_shb_fx = 0;
+ move16();
+ set16_fx( st_fx->hBWE_FD->prev_SWB_fenv_fx, 0, SWB_FENV );
}
- ELSE IF( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) ) &&
- ( NE_32( st_fx->last_total_brate, st_fx->total_brate ) || NE_16( st_fx->last_bwidth, st_fx->bwidth ) ||
- NE_16( st_fx->last_codec_mode, MODE1 ) || NE_16( st_fx->rf_flag, st_fx->rf_flag_last ) ) )
+ ELSE IF( ( ( st_fx->core == ACELP_CORE && ( EQ_16( st_fx->last_core, HQ_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) || EQ_16( st_fx->last_core, TCX_20_CORE ) ) ) || ( EQ_16( st_fx->core, st_fx->last_core ) && NE_16( st_fx->extl, st_fx->last_extl ) ) ) && GE_16( st_fx->last_bwidth, SWB ) )
{
- set16_fx( hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER );
- set16_fx( hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD );
- set16_fx( hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER );
- set16_fx( hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER );
- hBWE_TD->gain_prec_swb_fx = 16384;
- move16(); /*Q14 = 1 */
+ st_fx->attenu_fx = 3277; /* Q15 */
+ move16();
}
- /* Interp_3_2 CNG buffers reset */
test();
test();
test();
- IF( st_fx->hTdCngDec != NULL && EQ_32( st_fx->output_Fs, 48000 ) && ( ( GT_32( st_fx->last_core_brate, SID_2k40 ) ) && ( EQ_32( st_fx->core_brate, FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_2k40 ) ) ) )
- {
- set16_fx( st_fx->hTdCngDec->interpol_3_2_cng_dec_fx, 0, INTERP_3_2_MEM_LEN );
- }
-
- /* reset FB TBE buffers */
test();
test();
- IF( EQ_16( st_fx->extl, FB_TBE ) && ( NE_16( st_fx->last_extl, FB_TBE ) || NE_16( st_fx->L_frame, st_fx->last_L_frame ) ) )
+ IF( EQ_16( st_fx->last_core, HQ_CORE ) || ( EQ_16( st_fx->last_core, ACELP_CORE ) && !( EQ_16( st_fx->last_extl, WB_TBE ) || EQ_16( st_fx->last_extl, SWB_TBE ) || EQ_16( st_fx->last_extl, FB_TBE ) ) && GT_32( st_fx->core_brate, ACELP_8k00 ) ) )
{
- set16_fx( hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER );
- hBWE_TD->fb_tbe_demph_fx = 0;
+ st_fx->prev_fractive = 0;
move16();
- fb_tbe_reset_synth_fx( hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, &hBWE_TD->prev_fbbwe_ratio_fx );
- }
-
- /* reset WB TBE buffers */
- test();
- IF( NE_16( st_fx->last_extl, WB_TBE ) && EQ_16( st_fx->extl, WB_TBE ) )
- {
- wb_tbe_extras_reset_fx( hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx );
- wb_tbe_extras_reset_synth_fx( hBWE_TD->state_lsyn_filt_shb_fx, hBWE_TD->state_lsyn_filt_dwn_shb_fx, hBWE_TD->state_32and48k_WB_upsample_fx, hBWE_TD->mem_resamp_HB_fx );
-
- set16_fx( hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD / 4 );
- set16_fx( hBWE_TD->syn_overlap_fx, 0, L_SHB_LAHEAD );
- set32_fx( hBWE_TD->mem_csfilt_fx, 0, 2 );
}
- return error;
+ return;
}
-ivas_error core_switching_post_dec_ivas_fx(
+
+ivas_error core_switching_post_dec_fx(
Decoder_State *st_fx, /* i/o: decoder state structure */
Word16 *synth, /* i/o: output synthesis Qsynth*/
- Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/
+ Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/
Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/
const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/
const Word16 output_frame, /* i : frame length Q0*/
@@ -1302,8 +254,7 @@ ivas_error core_switching_post_dec_ivas_fx(
test();
IF( st_fx->core == ACELP_CORE && st_fx->bfi && hHQ_core != NULL && !st_fx->con_tcx )
{
- /*needed to be converted to fixed curretnly using evs implementation not in line*/
- if ( ( error = acelp_core_switch_dec_bfi_ivas_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK )
+ IF( ( error = acelp_core_switch_dec_bfi_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK )
{
return error;
} /*the output at Q0*/
@@ -1315,14 +266,14 @@ ivas_error core_switching_post_dec_ivas_fx(
delta = 1;
move16();
- IF( GE_16( output_frame, L_FRAME16k ) )
+ if ( GE_16( output_frame, L_FRAME16k ) )
{
delta = shr( Fs_kHz, 3 );
}
/* set delay compensation between HQ synthesis and ACELP synthesis */
delay_comp = i_mult2( delta, HQ_DELAY_COMP ); /* Q0 */
- /*needed to add more condition in if*/
+
test();
test();
test();
@@ -1339,10 +290,7 @@ ivas_error core_switching_post_dec_ivas_fx(
{
st_fx->use_acelp_preq = 0;
move16();
- /* rescaling to the min exp of the 2 */
- /* Qtmp=s_min(*Qsynth,st_fx->Q_old_postdec);
- Scale_sig(synth, output_frame, sub(Qtmp,*Qsynth));
- Scale_sig(st_fx->delay_buf_out_fx, delay_comp, sub(Qtmp,st_fx->Q_old_postdec));*/
+
IF( st_fx->hBWE_FD != NULL )
{
hBWE_FD->mem_deemph_old_syn_fx = 0;
@@ -1372,27 +320,31 @@ ivas_error core_switching_post_dec_ivas_fx(
move16();
}
}
+
/* delay HQ synthesis to synchronize with ACELP synthesis */
/* rescaling to the min exp of the 2 */
- Word16 NonZero = 1;
- move16();
- FOR( i = 0; i < delay_comp; i++ )
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
{
- IF( st_fx->delay_buf_out_fx[i] != 0 )
+ Word16 NonZero = 1;
+ move16();
+ FOR( i = 0; i < delay_comp; i++ )
+ {
+ IF( st_fx->delay_buf_out_fx[i] != 0 )
+ {
+ NonZero = 0;
+ move16();
+ break;
+ }
+ }
+ test();
+ IF( hHQ_core->Q_old_postdec >= 0 || EQ_16( NonZero, 1 ) )
{
- NonZero = 0;
+ Scale_sig( st_fx->delay_buf_out_fx, delay_comp, negate( hHQ_core->Q_old_postdec ) ); /* Q0 */
+ hHQ_core->Q_old_postdec = 0;
move16();
- break;
}
- }
- test();
- IF( hHQ_core->Q_old_postdec >= 0 || EQ_16( NonZero, 1 ) )
- {
- Scale_sig( st_fx->delay_buf_out_fx, delay_comp, negate( hHQ_core->Q_old_postdec ) ); /* Q0 */
- hHQ_core->Q_old_postdec = 0;
move16();
}
- move16();
Qtmp = s_min( *Qsynth, hHQ_core->Q_old_postdec );
Scale_sig( synth, output_frame, sub( Qtmp, *Qsynth ) ); /* Qtmp */
*Qsynth = Qtmp;
@@ -1557,7 +509,6 @@ ivas_error core_switching_post_dec_ivas_fx(
}
ELSE IF( st_fx->element_mode != EVS_MONO )
{
- /*needed to be filled with ivas specific code*/
/* Reset memories of CLDFBs */
IF( st_fx->cldfbAna != NULL )
{
@@ -1605,6 +556,7 @@ ivas_error core_switching_post_dec_ivas_fx(
move16();
}
}
+
IF( st_fx->hBWE_TD != NULL )
{
hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 );
@@ -1723,6 +675,15 @@ ivas_error core_switching_post_dec_ivas_fx(
hHQ_core->oldHqVoicing = 0;
move16();
}
+
+ IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ set16_fx( hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM );
+ hHQ_core->prev_frm_hfe2 = 0;
+ move16();
+ hHQ_core->prev_stab_hfe2 = 0;
+ move16();
+ }
}
}
ELSE
@@ -2165,22 +1126,36 @@ static void smoothTransitionDtxToTcx_fx(
*
* Preprocessing/preparation for ACELP/HQ core switching
*---------------------------------------------------------------------*/
-ivas_error core_switching_pre_dec_ivas_fx(
+
+ivas_error core_switching_pre_dec_fx(
Decoder_State *st, /* i/o: decoder state structure */
const Word16 output_frame, /* i : frame length */
const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */
const Word16 nchan_out, /* i : number of output channels */
const Word16 last_element_mode, /* i : last_element_mode */
const Word32 last_element_brate, /* i : last element bitrate */
- Word16 Q_old_synthFB,
+ const Word16 Q_old_synthFB,
Word16 *Q_olapBufferSynth,
Word16 *Q_olapBufferSynth2 )
{
Word32 tmp_fx; /*Q-12*/
Word16 i, oldLenClasBuff, newLenClasBuff;
ivas_error error;
- Word16 exp = 25;
+ Word16 tmp, exp = Q25;
+ Word32 L_tmp;
move16();
+ BPF_DEC_HANDLE hBPF;
+ TD_BWE_DEC_HANDLE hBWE_TD;
+ FD_BWE_DEC_HANDLE hBWE_FD;
+ HQ_DEC_HANDLE hHQ_core;
+ TCX_DEC_HANDLE hTcxDec;
+
+ hBWE_TD = st->hBWE_TD;
+ hBWE_FD = st->hBWE_FD;
+ hHQ_core = st->hHQ_core;
+ hBPF = st->hBPF;
+ hTcxDec = st->hTcxDec;
+
error = IVAS_ERR_OK;
move32();
@@ -2190,9 +1165,9 @@ ivas_error core_switching_pre_dec_ivas_fx(
test();
IF( EQ_16( st->last_codec_mode, MODE2 ) || ( ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) && ( st->element_mode > EVS_MONO ) ) )
{
- st->mem_deemph_fx = st->syn[M];
+ st->mem_deemph_fx = st->syn[M]; /* Q_syn */
move16();
- set16_fx( st->agc_mem_fx, 0, 2 );
+ set16_fx( st->agc_mem_fx, 0, 2 ); /* Q0 */
Scale_sig( &( st->mem_deemph_fx ), 1, st->Q_syn ); /* Brings mem_deemph to Qsyn */
Copy_Scale_sig( st->mem_syn2_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); /*Q-1*/
@@ -2204,12 +1179,12 @@ ivas_error core_switching_pre_dec_ivas_fx(
Scale_sig( st->hPFstat->mem_pf_in, L_SUBFR, st->Q_syn ); /* Post_filter mem ,Q_syn*/
Scale_sig( st->hPFstat->mem_res2, DECMEM_RES2, st->Q_syn ); /* NB post_filter mem , Q_syn*/
Scale_sig( st->hPFstat->mem_stp, L_SUBFR, st->Q_syn ); /* Post_filter mem ,Q_syn*/
- set16_fx( st->hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/
}
- IF( st->hBPF != NULL )
+ IF( hBPF != NULL )
{
- st->hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10 */
- st->hBPF->pst_mem_deemp_err_fx = 0;
+ set16_fx( hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/
+ hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10 */
+ hBPF->pst_mem_deemp_err_fx = 0;
move16();
move16();
}
@@ -2219,23 +1194,23 @@ ivas_error core_switching_pre_dec_ivas_fx(
/* reset old HB synthesis buffer */
IF( EQ_16( st->last_L_frame, L_FRAME ) )
{
- st->old_bwe_delay = NS2SA( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS );
+ st->old_bwe_delay = NS2SA_FX2( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS );
}
ELSE
{
- st->old_bwe_delay = NS2SA( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS );
+ st->old_bwe_delay = NS2SA_FX2( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS );
}
move16();
set16_fx( st->hb_prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) );
test();
- IF( st->hBWE_TD != NULL && ( st->last_core != ACELP_CORE ) )
+ IF( hBWE_TD != NULL && ( st->last_core != ACELP_CORE ) )
{
- st->hBWE_TD->prev_hb_synth_fx_exp = 31;
+ hBWE_TD->prev_hb_synth_fx_exp = Q31;
move16();
/* reset BWE memories */
- set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
- st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
+ set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); /* Q_exc */
+ hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
move32();
}
@@ -2247,35 +1222,36 @@ ivas_error core_switching_pre_dec_ivas_fx(
move16();
test();
- IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL )
+ IF( GE_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL )
{
hf_synth_reset_fx( st->hBWE_zero );
+ IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - it is a bug in EVS but condition is here to keep EVS bit-exact for the moment
set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 );
}
- IF( st->hBWE_FD != NULL )
+ IF( hBWE_FD != NULL )
{
- set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
+ set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
}
- IF( st->hHQ_core != NULL )
+ IF( hHQ_core != NULL )
{
- set32_fx( st->hHQ_core->prev_env_fx, 0, SFM_N_WB );
- set32_fx( st->hHQ_core->prev_normq_fx, 0, SFM_N_WB );
+ set32_fx( hHQ_core->prev_env_fx, 0, SFM_N_WB );
+ set32_fx( hHQ_core->prev_normq_fx, 0, SFM_N_WB );
- set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX );
- set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX );
+ set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX );
+ set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX );
- st->hHQ_core->last_max_pos_pulse = 0;
+ hHQ_core->last_max_pos_pulse = 0;
move16();
IF( GT_32( st->output_Fs, 16000 ) )
{
- set32_fx( st->hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE );
+ set32_fx( hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE );
}
/* pre-echo */
- st->hHQ_core->pastpre = 0;
+ hHQ_core->pastpre = 0;
move16();
}
@@ -2294,20 +1270,19 @@ ivas_error core_switching_pre_dec_ivas_fx(
st->last_core = HQ_CORE;
move16();
- Copy32( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer32_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) );
- // Copy_Scale_sig_32_16( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -11 ); //Q11 -> Q0
+ Copy( hTcxDec->FBTCXdelayBuf, st->prev_synth_buffer_fx, NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); /* st->q_prev_synth_buffer_fx */
}
- IF( st->hHQ_core != NULL )
+ IF( hHQ_core != NULL )
{
- set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX );
- set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX );
- st->hHQ_core->last_max_pos_pulse = 0;
+ set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX );
+ set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX );
+ hHQ_core->last_max_pos_pulse = 0;
move16();
- set16_fx( st->hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM );
- st->hHQ_core->prev_frm_hfe2 = 0;
- st->hHQ_core->prev_stab_hfe2 = 0;
+ set16_fx( hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM );
+ hHQ_core->prev_frm_hfe2 = 0;
+ hHQ_core->prev_stab_hfe2 = 0;
move16();
move16();
}
@@ -2318,66 +1293,114 @@ ivas_error core_switching_pre_dec_ivas_fx(
Word16 delay_comp;
/*switch off Hq Voicing as it was not updated in MODE2*/
- IF( st->hHQ_core != NULL )
+ IF( hHQ_core != NULL )
{
- st->hHQ_core->oldHqVoicing = 0;
- st->hHQ_core->HqVoicing = 0;
+ hHQ_core->oldHqVoicing = 0;
+ hHQ_core->HqVoicing = 0;
move16();
move16();
}
- delay_comp = NS2SA( st->output_Fs, DELAY_CLDFB_NS );
- /*TODO To be tested:control not entering the block*/
- test();
- test();
- IF( !st->last_con_tcx && ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) )
+ delay_comp = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS );
+
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ test();
+ test();
+ IF( !st->last_con_tcx && st->last_core_bfi == ACELP_CORE && EQ_16( st->core, HQ_CORE ) )
+ {
+ Word16 no_col;
+ Word32 *realBuffer[CLDFB_NO_COL_MAX_SWITCH], *imagBuffer[CLDFB_NO_COL_MAX_SWITCH];
+ Word32 realBufferTmp[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX], imagBufferTmp[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX];
+ CLDFB_SCALE_FACTOR scaleFactor;
+ Word32 workBuffer[128 * 3];
+
+ FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH; i++ )
+ {
+ set32_fx( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX );
+ set32_fx( imagBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX );
+ realBuffer[i] = realBufferTmp[i];
+ move32();
+ imagBuffer[i] = imagBufferTmp[i];
+ move32();
+ }
+
+ no_col = s_min( st->cldfbAna->no_col, idiv1616( sub( add( delay_comp, st->cldfbAna->no_channels ), 1 ), st->cldfbAna->no_channels ) ); /* Q0 */
+
+ /* CLDFB analysis of the synthesis at internal sampling rate */
+ IF( ( error = cldfb_save_memory( st->cldfbAna ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ cldfbAnalysis_fx( st->cldfbAna, realBuffer, imagBuffer, &scaleFactor, hTcxDec->syn_Overl, 0, no_col, workBuffer );
+ cldfb_restore_memory( st->cldfbAna );
+
+ scaleFactor.hb_scale = scaleFactor.lb_scale;
+ move16();
+
+ /* CLDFB synthesis of the combined signal */
+ IF( ( error = cldfb_save_memory( st->cldfbSyn ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ cldfbSynthesis_fx( st->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, hHQ_core->fer_samples_fx, 0, no_col, workBuffer );
+ cldfb_restore_memory( st->cldfbSyn );
+ }
+ }
+ ELSE
{
- /*TODO None of the test dtreams are entering this block,hence enabled assert(0)*/
- assert( 0 );
- Word32 *realBuffer_fx[CLDFB_NO_COL_MAX_SWITCH], *imagBuffer_fx[CLDFB_NO_COL_MAX_SWITCH];
- Word32 realBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX], imagBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX];
- Word32 syn_Overl_fx[320];
- Word32 fer_samples_fx[960];
- Copy_Scale_sig_16_32_DEPREC( st->hTcxDec->syn_Overl, syn_Overl_fx, 320, 15 );
- Copy_Scale_sig_16_32_DEPREC( st->hHQ_core->fer_samples_fx, fer_samples_fx, 960, 15 );
+ /*TODO To be tested:control not entering the block*/
+ test();
+ test();
+ IF( !st->last_con_tcx && ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) )
+ {
+ /*TODO None of the test dtreams are entering this block,hence enabled assert(0)*/
+ assert( 0 );
+ Word32 *realBuffer_fx[CLDFB_NO_COL_MAX_SWITCH], *imagBuffer_fx[CLDFB_NO_COL_MAX_SWITCH];
+ Word32 realBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX], imagBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX];
+ Word32 syn_Overl_fx[320];
+ Word32 fer_samples_fx[960];
+ Copy_Scale_sig_16_32_DEPREC( hTcxDec->syn_Overl, syn_Overl_fx, 320, 15 );
+ Copy_Scale_sig_16_32_DEPREC( hHQ_core->fer_samples_fx, fer_samples_fx, 960, 15 );
- FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH; i++ )
- {
- set32_fx( realBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX );
- set32_fx( imagBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX );
- realBuffer_fx[i] = realBufferTmp_fx[i];
- imagBuffer_fx[i] = imagBufferTmp_fx[i];
- }
+ FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH; i++ )
+ {
+ set32_fx( realBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX );
+ set32_fx( imagBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX );
+ realBuffer_fx[i] = realBufferTmp_fx[i];
+ imagBuffer_fx[i] = imagBufferTmp_fx[i];
+ }
- /* CLDFB analysis of the synthesis at internal sampling rate */
- IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st->cldfbAna ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
+ /* CLDFB analysis of the synthesis at internal sampling rate */
+ IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st->cldfbAna ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
- cldfbAnalysis_ivas_fx( syn_Overl_fx, realBuffer_fx, imagBuffer_fx, delay_comp, st->cldfbAna );
- cldfb_restore_memory_ivas_fx( st->cldfbAna ); /*Assuming Q10*/
+ cldfbAnalysis_ivas_fx( syn_Overl_fx, realBuffer_fx, imagBuffer_fx, delay_comp, st->cldfbAna );
+ cldfb_restore_memory_ivas_fx( st->cldfbAna ); /*Assuming Q10*/
- /* CLDFB synthesis of the combined signal */
- IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st->cldfbSyn ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
+ /* CLDFB synthesis of the combined signal */
+ IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st->cldfbSyn ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
- cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, fer_samples_fx, delay_comp, 0, 0, st->cldfbSyn );
- cldfb_restore_memory_ivas_fx( st->cldfbSyn );
- Copy_Scale_sig_32_16( syn_Overl_fx, st->hTcxDec->syn_Overl, 320, 15 );
- Copy_Scale_sig_32_16( fer_samples_fx, st->hHQ_core->fer_samples_fx, 960, 9 );
+ cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, fer_samples_fx, delay_comp, 0, 0, st->cldfbSyn );
+ cldfb_restore_memory_ivas_fx( st->cldfbSyn );
+ Copy_Scale_sig_32_16( syn_Overl_fx, hTcxDec->syn_Overl, 320, 15 );
+ Copy_Scale_sig_32_16( fer_samples_fx, hHQ_core->fer_samples_fx, 960, 9 );
+ }
}
test();
test();
IF( !st->last_con_tcx && ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) )
{
- lerp( st->hTcxDec->syn_Overl, st->hHQ_core->fer_samples_fx + delay_comp, shr( output_frame, 1 ), shr( st->last_L_frame, 1 ) );
+ lerp( hTcxDec->syn_Overl, hHQ_core->fer_samples_fx + delay_comp, shr( output_frame, 1 ), shr( st->last_L_frame, 1 ) );
/*Set to zero the remaining part*/
- set16_fx( st->hHQ_core->fer_samples_fx + delay_comp + output_frame / 2, 0, sub( shr( output_frame, 1 ), delay_comp ) );
+ set16_fx( hHQ_core->fer_samples_fx + delay_comp + output_frame / 2, 0, sub( shr( output_frame, 1 ), delay_comp ) );
}
}
@@ -2395,17 +1418,35 @@ ivas_error core_switching_pre_dec_ivas_fx(
{
IF( NE_16( st->L_frame, st->last_L_frame ) )
{
- IF( GT_16( st->L_frame, st->last_L_frame ) )
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
{
- oldLenClasBuff = mult_r( L_SYN_MEM_CLAS_ESTIM, div_s( st->last_L_frame, st->L_frame ) );
- newLenClasBuff = L_SYN_MEM_CLAS_ESTIM;
- move16();
+ IF( GT_16( st->L_frame, st->last_L_frame ) )
+ {
+ oldLenClasBuff = extract_l( L_shr( Mpy_32_16_1( L_mult0( st->last_L_frame, getInvFrameLen( st->L_frame ) /*Q21*/ ) /*Q21*/, L_SYN_MEM_CLAS_ESTIM /*Q0*/ ) /*Q6*/, 6 ) /*Q0*/ );
+ newLenClasBuff = L_SYN_MEM_CLAS_ESTIM;
+ move16();
+ }
+ ELSE
+ {
+ oldLenClasBuff = L_SYN_MEM_CLAS_ESTIM;
+ move16();
+ newLenClasBuff = extract_l( L_shr( Mpy_32_16_1( L_mult0( st->L_frame, getInvFrameLen( st->last_L_frame ) /*Q21*/ ) /*Q21*/, L_SYN_MEM_CLAS_ESTIM /*Q0*/ ) /*Q6*/, 6 ) /*Q0*/ );
+ }
}
ELSE
{
- oldLenClasBuff = L_SYN_MEM_CLAS_ESTIM;
- move16();
- newLenClasBuff = mult_r( L_SYN_MEM_CLAS_ESTIM, div_s( st->L_frame, st->last_L_frame ) );
+ IF( GT_16( st->L_frame, st->last_L_frame ) )
+ {
+ oldLenClasBuff = mult_r( L_SYN_MEM_CLAS_ESTIM, div_s( st->last_L_frame, st->L_frame ) );
+ newLenClasBuff = L_SYN_MEM_CLAS_ESTIM;
+ move16();
+ }
+ ELSE
+ {
+ oldLenClasBuff = L_SYN_MEM_CLAS_ESTIM;
+ move16();
+ newLenClasBuff = mult_r( L_SYN_MEM_CLAS_ESTIM, div_s( st->L_frame, st->last_L_frame ) );
+ }
}
lerp( &st->mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM - oldLenClasBuff], &st->mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM - newLenClasBuff], newLenClasBuff, oldLenClasBuff );
}
@@ -2413,6 +1454,8 @@ ivas_error core_switching_pre_dec_ivas_fx(
ELSE
{
set16_fx( st->mem_syn_clas_estim_fx, 0, L_SYN_MEM_CLAS_ESTIM );
+ st->classifier_Q_mem_syn = 0;
+ move16();
}
}
@@ -2490,10 +1533,11 @@ ivas_error core_switching_pre_dec_ivas_fx(
IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && EQ_16( nchan_out, 2 ) && GT_32( st->core_brate, SID_2k40 ) && ( ( last_core_brate_st0 == FRAME_NO_DATA ) || EQ_32( last_core_brate_st0, SID_2k40 ) ) && st->hTcxDec != NULL )
{
/* Last frame was Stereo CNG and the synthesis memory is outdated -- reset */
- set16_fx( st->hTcxDec->old_syn_Overl, 0, L_FRAME32k / 2 );
+ set16_fx( hTcxDec->old_syn_Overl, 0, L_FRAME32k / 2 );
set16_fx( st->hFdCngDec->hFdCngCom->olapBufferAna_fx, 0, FFTLEN );
- set16_fx( st->agc_mem_fx, 0, 2 );
}
+
+ set16_fx( st->agc_mem_fx, 0, 2 );
st->mem_deemph_fx = 0;
move16();
IF( !st->last_con_tcx )
@@ -2501,9 +1545,9 @@ ivas_error core_switching_pre_dec_ivas_fx(
set16_fx( st->mem_syn2_fx, 0, M );
}
set16_fx( st->mem_syn1_fx, 0, M );
- if ( st->hBWE_TD != NULL )
+ if ( hBWE_TD != NULL )
{
- st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
+ hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
move32();
}
@@ -2512,11 +1556,11 @@ ivas_error core_switching_pre_dec_ivas_fx(
IF( EQ_32( st->sr_core, INT_FS_16k ) )
{
- Copy( GEWB2_Ave_fx, st->mem_AR_fx, M );
+ Copy( GEWB2_Ave_fx, st->mem_AR_fx, M ); /* Q2.56 */
}
ELSE
{
- Copy( GEWB_Ave_fx, st->mem_AR_fx, M );
+ Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); /* Q2.56 */
}
st->tilt_code_fx = 0;
@@ -2532,13 +1576,42 @@ ivas_error core_switching_pre_dec_ivas_fx(
st->last_coder_type = GENERIC;
move16();
- fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/
- st->lp_gainp_fx = 0;
- move16();
- st->lp_gainc_fx = extract_h( Sqrt32( st->lp_ener_fx, &exp ) ); /*Q=15-exp*/
- move16();
- st->lp_gainc_fx = shr( st->lp_gainc_fx, sub( 12, exp ) ); /*Q3*/
- move16();
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ frame_ener_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx, -1, &st->enr_old_fx, 1, 0, 0, 0 );
+ st->lp_gainp_fx = 0;
+ move16();
+
+ IF( st->lp_ener_fx != 0 )
+ {
+ exp = norm_l( st->lp_ener_fx ); /* In Q6 */
+ tmp = extract_h( L_shl( st->lp_ener_fx, exp ) );
+ exp = sub( exp, 30 - 6 );
+
+ tmp = div_s( 16384, tmp );
+ L_tmp = L_deposit_h( tmp );
+ L_tmp = Isqrt_lc( L_tmp, &exp );
+
+ st->lp_gainc_fx = round_fx( L_shl( L_tmp, sub( exp, 12 ) ) ); /* In Q3 */
+ move16();
+ }
+ }
+ ELSE
+ {
+#ifdef FIX_2379_REMOVE_previoussynth_fx_32
+ Word32 previoussynth_fx_32[L_FRAME48k];
+ Copy_Scale_sig_16_32_no_sat( st->previoussynth_fx, previoussynth_fx_32, output_frame, 0 );
+ fer_energy_fx( output_frame, UNVOICED_CLAS, previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q0*/
+#else
+ fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/
+#endif
+ st->lp_gainp_fx = 0;
+ move16();
+ st->lp_gainc_fx = extract_h( Sqrt32( st->lp_ener_fx, &exp ) ); /*Q=15-exp*/
+ move16();
+ st->lp_gainc_fx = shr( st->lp_gainc_fx, sub( 12, exp ) ); /*Q3*/
+ move16();
+ }
st->last_voice_factor_fx = 0;
st->Last_GSC_noisy_speech_flag = 0;
@@ -2546,9 +1619,18 @@ ivas_error core_switching_pre_dec_ivas_fx(
move16();
/* reset CLDFB memories */
- cldfb_reset_memory_fx( st->cldfbAna );
- cldfb_reset_memory_fx( st->cldfbBPF );
- cldfb_reset_memory_fx( st->cldfbSyn );
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
+ {
+ cldfb_reset_memory( st->cldfbAna );
+ cldfb_reset_memory( st->cldfbBPF );
+ cldfb_reset_memory( st->cldfbSyn );
+ }
+ ELSE
+ {
+ cldfb_reset_memory_fx( st->cldfbAna );
+ cldfb_reset_memory_fx( st->cldfbBPF );
+ cldfb_reset_memory_fx( st->cldfbSyn );
+ }
/* reset TBE memories */
test();
@@ -2563,21 +1645,22 @@ ivas_error core_switching_pre_dec_ivas_fx(
synth_mem_updt2( st->L_frame, L_FRAME16k, st->old_exc_fx, st->mem_syn_r, st->mem_syn2_fx, NULL, DEC );
}
- IF( st->hBWE_TD != NULL )
+ IF( hBWE_TD != NULL )
{
- set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
+ set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
}
test();
- IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL )
+ IF( GE_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL )
{
hf_synth_reset_fx( st->hBWE_zero );
+ IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - it is a bug in EVS but condition is here to keep EVS bit-exact for the moment
set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 );
}
- IF( st->hBWE_FD != NULL )
+ IF( hBWE_FD != NULL )
{
- set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
+ set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_NS ) );
}
}
@@ -2586,11 +1669,11 @@ ivas_error core_switching_pre_dec_ivas_fx(
test();
IF( ( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) )
{
- IF( st->hBWE_TD != NULL )
+ IF( hBWE_TD != NULL )
{
- st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
+ hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
move32();
- set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
+ set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
}
st->tilt_code_fx = 0;
@@ -2604,7 +1687,13 @@ ivas_error core_switching_pre_dec_ivas_fx(
set16_fx( st->dm_fx.prev_gain_pit, 0, 6 );
st->last_coder_type = GENERIC;
move16();
- fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/
+#ifdef FIX_2379_REMOVE_previoussynth_fx_32
+ Word32 previoussynth_fx_32[L_FRAME48k];
+ Copy_Scale_sig_16_32_no_sat( st->previoussynth_fx, previoussynth_fx_32, output_frame, 0 );
+ fer_energy_fx( output_frame, UNVOICED_CLAS, previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q0*/
+#else
+ fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/
+#endif
st->lp_gainp_fx = 0;
move16();
@@ -2619,15 +1708,15 @@ ivas_error core_switching_pre_dec_ivas_fx(
move16();
test();
- IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL )
+ IF( GE_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL )
{
hf_synth_reset_fx( st->hBWE_zero );
set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 );
}
- IF( st->hBWE_FD != NULL )
+ IF( hBWE_FD != NULL )
{
- set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
+ set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
}
test();
@@ -2638,17 +1727,11 @@ ivas_error core_switching_pre_dec_ivas_fx(
/* update cldbf state with previous frame TCX synthesis when going from a bitrate with residual coding to a bitrate without it */
Word16 offset;
offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels );
- Word32 *old_synthFB_fx;
- IF( ( old_synthFB_fx = (Word32 *) malloc( st->hTcxDec->old_synth_lenFB * sizeof( Word32 ) ) ) == NULL )
- {
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for old_synth_lenFB (32 bit) \n" ) );
- }
- Copy_Scale_sig_16_32_no_sat( st->hTcxDec->old_synthFB_fx, old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub( Q10, Q_old_synthFB ) ); // Q10
- Copy32( old_synthFB_fx + st->hTcxDec->old_synth_lenFB - offset, st->cldfbAna->cldfb_state_fx, offset );
+ Word32 old_synthFB_fx[L_FRAME_PLUS * 2];
+ Copy_Scale_sig_16_32_no_sat( hTcxDec->old_synthFB_fx, old_synthFB_fx, hTcxDec->old_synth_lenFB, sub( Q10, Q_old_synthFB ) ); // Q10
+ Copy32( old_synthFB_fx + hTcxDec->old_synth_lenFB - offset, st->cldfbAna->cldfb_state_fx, offset );
st->cldfbAna->Q_cldfb_state = Q10;
move16();
- IF( old_synthFB_fx )
- free( old_synthFB_fx );
}
}
@@ -2658,22 +1741,22 @@ ivas_error core_switching_pre_dec_ivas_fx(
test();
IF( EQ_16( st->core, HQ_CORE ) && ( ( st->last_core == ACELP_CORE ) || EQ_16( st->last_core, AMR_WB_CORE ) || ( ( ( st->element_mode != EVS_MONO ) ) && ( NE_16( st->last_core, HQ_CORE ) ) ) ) )
{
- set32_fx( st->hHQ_core->prev_env_fx, 0, SFM_N_WB );
- set32_fx( st->hHQ_core->prev_normq_fx, 0, SFM_N_WB );
+ set32_fx( hHQ_core->prev_env_fx, 0, SFM_N_WB );
+ set32_fx( hHQ_core->prev_normq_fx, 0, SFM_N_WB );
- set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX );
- set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX );
- st->hHQ_core->last_max_pos_pulse = 0;
+ set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX );
+ set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX );
+ hHQ_core->last_max_pos_pulse = 0;
move16();
- set16_fx( st->hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM );
- st->hHQ_core->prev_frm_hfe2 = 0;
- st->hHQ_core->prev_stab_hfe2 = 0;
+ set16_fx( hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM );
+ hHQ_core->prev_frm_hfe2 = 0;
+ hHQ_core->prev_stab_hfe2 = 0;
move16();
move16();
IF( GT_32( st->output_Fs, 16000 ) )
{
- set32_fx( st->hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE );
+ set32_fx( hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE );
}
IF( st->element_mode != EVS_MONO )
@@ -2681,48 +1764,53 @@ ivas_error core_switching_pre_dec_ivas_fx(
/* Estimate mem_env_delta to reinit env_stab */
tmp_fx = L_max( 0, L_add( ENV_STAB_EST1_FX, L_add( Mult_32_16( st->stab_fac_smooth_lt_fx, ENV_STAB_EST2_FX ), Mult_32_16( st->log_energy_diff_lt_fx, ENV_STAB_EST3_FX ) ) ) ); /*Q12*/
- st->hHQ_core->mem_env_delta = extract_l( L_min( MAX16B, tmp_fx ) ); /* Convert to Q12 and handle saturation */
+ hHQ_core->mem_env_delta = extract_l( L_min( MAX16B, tmp_fx ) ); /* Convert to Q12 and handle saturation */
move16();
test();
IF( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) )
{
- set16_fx( st->hHQ_core->old_out_fx, 0, output_frame );
- set32_fx( st->hHQ_core->old_out_LB_fx32, 0, L_FRAME16k );
- set16_fx( st->hHQ_core->old_out_LB_fx, 0, L_FRAME16k );
+ set16_fx( hHQ_core->old_out_fx, 0, output_frame );
+ set32_fx( hHQ_core->old_out_LB_fx32, 0, L_FRAME16k );
+ set16_fx( hHQ_core->old_out_LB_fx, 0, L_FRAME16k );
}
- st->hHQ_core->no_att_hangover = 0;
+ hHQ_core->no_att_hangover = 0;
move16();
- st->hHQ_core->energy_lt_fx = 2457600; /*300.0f Q13*/
+ hHQ_core->energy_lt_fx = 2457600; /*300.0f Q13*/
move32();
- set16_fx( st->hHQ_core->old_is_transient, 0, 3 );
- set16_fx( st->hHQ_core->prev_noise_level_fx, 0, 2 );
- st->hHQ_core->prev_R = 0;
+ set16_fx( hHQ_core->old_is_transient, 0, 3 );
+ set16_fx( hHQ_core->prev_noise_level_fx, 0, 2 );
+ hHQ_core->prev_R = 0;
move16();
- set16_fx( st->hHQ_core->mem_norm + 1, 39, SFM_N_ENV_STAB - 1 );
- st->hHQ_core->prev_hqswb_clas = HQ_NORMAL;
- st->hHQ_core->prev_ni_ratio_fx = 16384; /*Q15*/
+ set16_fx( hHQ_core->mem_norm + 1, 39, SFM_N_ENV_STAB - 1 );
+ hHQ_core->prev_hqswb_clas = HQ_NORMAL;
+ hHQ_core->prev_ni_ratio_fx = 16384; /*Q15*/
move16();
move16();
- set16_fx( st->hHQ_core->prev_En_sb_fx, 0, NB_SWB_SUBBANDS );
+ set16_fx( hHQ_core->prev_En_sb_fx, 0, NB_SWB_SUBBANDS );
}
ELSE
{
- set16_fx( st->hHQ_core->old_out_fx, 0, output_frame );
- set32_fx( st->hHQ_core->old_out_LB_fx32, 0, L_FRAME16k );
+ set16_fx( hHQ_core->old_out_fx, 0, output_frame );
+ set16_fx( hHQ_core->old_out_LB_fx, 0, L_FRAME16k );
+ hHQ_core->Q_old_wtda_LB = Q15;
+ move16();
+ hHQ_core->Q_old_wtda = Q15;
+ move16();
}
}
/* handle switching cases where preecho_sb was not called in the last frame (memory not up to date) */
- IF( st->hHQ_core != NULL )
+ IF( hHQ_core != NULL )
{
- st->hHQ_core->pastpre = sub( st->hHQ_core->pastpre, 1 );
+ hHQ_core->pastpre = sub( hHQ_core->pastpre, 1 );
move16();
- IF( st->hHQ_core->pastpre < 0 )
+ IF( hHQ_core->pastpre < 0 )
{
- reset_preecho_dec_fx( st->hHQ_core );
+ reset_preecho_dec_fx( hHQ_core );
}
}
+
test();
IF( st->core_brate == FRAME_NO_DATA )
{
@@ -2740,10 +1828,8 @@ ivas_error core_switching_pre_dec_ivas_fx(
st->m_frame_type = ACTIVE_FRAME;
}
- move16();
- move16();
/*switch on CNA on active frames*/
- IF( ( st->element_mode == EVS_MONO ) ) /* for IVAS modes, st->flag_cna is set earlier */
+ IF( st->element_mode == EVS_MONO ) /* for IVAS modes, st->flag_cna is set earlier */
{
test();
test();
@@ -2779,10 +1865,18 @@ ivas_error core_switching_pre_dec_ivas_fx(
/* || st->last_core == AMR_WB_CORE || st->last_codec_mode == MODE2)){*/
IF( NE_16( st->core, AMR_WB_CORE ) )
{
+ L_tmp = st->total_brate;
+ move32();
test();
- IF( EQ_16( st->rf_flag, 1 ) && EQ_32( st->total_brate, ACELP_13k20 ) )
+ if ( EQ_16( st->rf_flag, 1 ) && EQ_32( st->total_brate, ACELP_13k20 ) )
+ {
+ L_tmp = ACELP_9k60;
+ move32();
+ }
+
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
{
- configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, ACELP_9k60, st->L_frame, st->last_L_frame, st->element_mode );
+ configureFdCngDec_fx( st->hFdCngDec, st->bwidth, L_tmp, st->L_frame, st->last_L_frame, st->element_mode );
}
ELSE
{
@@ -2791,7 +1885,7 @@ ivas_error core_switching_pre_dec_ivas_fx(
}
ELSE
{
- configureFdCngDec_ivas_fx( st->hFdCngDec, WB, ACELP_8k00, st->L_frame, st->last_L_frame, st->element_mode );
+ configureFdCngDec_fx( st->hFdCngDec, WB, ACELP_8k00, st->L_frame, st->last_L_frame, st->element_mode );
if ( st->VAD )
{
@@ -2799,6 +1893,7 @@ ivas_error core_switching_pre_dec_ivas_fx(
move32();
}
}
+
test();
test();
IF( NE_16( st->last_L_frame, st->L_frame ) && LE_16( st->L_frame, L_FRAME16k ) && LE_16( st->last_L_frame, L_FRAME16k ) )
@@ -2809,27 +1904,56 @@ ivas_error core_switching_pre_dec_ivas_fx(
lerp( st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->last_L_frame, st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->L_frame, st->L_frame, st->last_L_frame );
}
- L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth2 );
-
- test();
- IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) )
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
{
- L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth );
-
- IF( EQ_16( st->L_frame, L_FRAME ) )
+ lerp( st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ) );
+ test();
+ IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) )
{
- FOR( i = 0; i < ( st->L_frame * 2 ); i++ )
+ lerp( st->hFdCngDec->hFdCngCom->olapBufferSynth, st->hFdCngDec->hFdCngCom->olapBufferSynth, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ) );
+
+ IF( EQ_16( st->L_frame, L_FRAME ) )
{
- st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], (Word16) 20480 /* 0.6250f in Q15 */ );
- move32();
+ FOR( i = 0; i < shl( st->L_frame, 1 ); i++ )
+ {
+ st->hFdCngDec->hFdCngCom->olapBufferSynth[i] = mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth[i], 20480 /* Q15*/ ); /* q_olapBuffer */
+ move16();
+ }
+ }
+ ELSE
+ {
+ FOR( i = 0; i < shl( st->L_frame, 1 ); i++ )
+ {
+ st->hFdCngDec->hFdCngCom->olapBufferSynth[i] = mult_r( shl( st->hFdCngDec->hFdCngCom->olapBufferSynth[i], 1 ), 26214 /* Q14*/ ); /* q_olapBuffer */
+ move16();
+ }
}
}
- ELSE
+ }
+ ELSE
+ {
+ L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth2 );
+
+ test();
+ IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) )
{
- FOR( i = 0; i < ( st->L_frame * 2 ); i++ )
+ L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth );
+
+ IF( EQ_16( st->L_frame, L_FRAME ) )
{
- st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( L_shl( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], 1 ), (Word16) 26214 /* 1.6f in Q14 */ );
- move32();
+ FOR( i = 0; i < shl( st->L_frame, 1 ); i++ )
+ {
+ st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], (Word16) 20480 /* 0.6250f in Q15 */ );
+ move32();
+ }
+ }
+ ELSE
+ {
+ FOR( i = 0; i < shl( st->L_frame, 1 ); i++ )
+ {
+ st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( L_shl( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], 1 ), (Word16) 26214 /* 1.6f in Q14 */ );
+ move32();
+ }
}
}
}
@@ -2838,12 +1962,7 @@ ivas_error core_switching_pre_dec_ivas_fx(
return error;
}
-/*---------------------------------------------------------------------*
- * core_switching_hq_prepare_dec()
- *
- * Preprocessing in the first HQ frame after ACELP frame
- * Modify bit allocation for HQ core by removing ACELP subframe budget
- *---------------------------------------------------------------------*/
+
/*---------------------------------------------------------------------*
* bandwidth_switching_detect()
@@ -2851,7 +1970,7 @@ ivas_error core_switching_pre_dec_ivas_fx(
* Classification for band-width switching
*---------------------------------------------------------------------*/
-void bandwidth_switching_detect_ivas_fx(
+void bandwidth_switching_detect_fx(
Decoder_State *st_fx /* i/o: encoder state structure */
)
{
@@ -2966,191 +2085,3 @@ void bandwidth_switching_detect_ivas_fx(
return;
}
-
-
-/*---------------------------------------------------------------------*
- * bw_switching_pre_proc()
- *
- * Band-width switching pre-processing
- *---------------------------------------------------------------------*/
-void ivas_bw_switching_pre_proc_fx(
- Decoder_State *st, /* i/o: decoder state structure */
- const Word32 last_element_brate, /* i : last element bitrate */
- const Word16 nchan_out /* i : number of output channels */,
- Word32 *old_syn_12k8_16k_fx,
- Word16 Q,
- Word16 Q_audio )
-{
- Word16 i;
- Word32 syn_dct_fx[L_FRAME];
-
-
- IF( st->element_mode > EVS_MONO )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) && st->hBWE_FD != NULL && !( LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) ) && !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st->idchan, 1 ) && LE_32( last_element_brate, IVAS_SID_5k2 ) ) )
- {
- /* Calculate tilt of the ACELP core synthesis - needed in SWB BWE decoding */
- Word16 old_syn_12k8_16k_tmp_16fx[L_FRAME16k];
- Copy_Scale_sig_32_16( old_syn_12k8_16k_fx, old_syn_12k8_16k_tmp_16fx, st->L_frame, sub( -1, Q ) );
- st->tilt_wb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_syn_12k8_16k_tmp_16fx, -1, st->L_frame ), sub( Q, 8 ) ) ); // Q24+(Q-8) - 16
- move16();
- }
-
- return;
- }
-
-
- test();
- test();
- IF( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) )
- {
- /*----------------------------------------------------------------------*
- * Calculate tilt of the ACELP core synthesis
- *----------------------------------------------------------------------*/
-
- st->tilt_wb_fx = ivas_calc_tilt_bwe_fx( old_syn_12k8_16k_fx, Q, st->L_frame );
- move16();
- /*-------------------------------------------------------------------------------*
- * Calculate frequency energy of 0~3.2kHz and 3.2~6.4kHz the ACELP core synthesis
- *-------------------------------------------------------------------------------*/
- edct_fx( old_syn_12k8_16k_fx, syn_dct_fx, L_FRAME, &Q );
- Word64 W_tmp = 0;
- move64();
- Word32 tmp;
- Word16 shift;
- FOR( i = 0; i < L_FRAME / 2; i++ )
- {
- W_tmp = W_add( W_tmp, W_shr( W_mult0_32_32( syn_dct_fx[i], syn_dct_fx[i] ), Q ) );
- }
- shift = W_norm( W_tmp );
- W_tmp = W_shl( W_tmp, shift );
- tmp = W_extract_h( W_tmp );
- tmp = L_shr( tmp, 8 );
-
- tmp = getSqrtWord32( tmp );
- st->enerLL_fx = tmp;
- move32();
- st->enerLL_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 );
- move16();
- W_tmp = 0;
- move64();
- FOR( ; i < L_FRAME; i++ )
- {
- W_tmp = W_add( W_tmp, W_shr( W_mult0_32_32( syn_dct_fx[i], syn_dct_fx[i] ), Q ) );
- }
- shift = W_norm( W_tmp );
- W_tmp = W_shl( W_tmp, shift );
- tmp = W_extract_h( W_tmp ); // Q = Q + shift - 32
- tmp = L_shr( tmp, 7 ); // divide by 128
- tmp = getSqrtWord32( tmp );
- st->enerLH_fx = tmp;
- move32();
- st->enerLH_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 );
- move16();
- }
- ELSE
- {
- IF( st->hHQ_core->old_is_transient[0] )
- {
- Word32 tmp, L_tmp = 0;
- move32();
- FOR( i = 0; i < 32; i++ )
- {
- L_tmp = L_mac0_sat( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i] );
- }
- tmp = L_shr( L_tmp, 5 ); // divide by 32
- tmp = getSqrtWord32( tmp );
- st->enerLL_fx = tmp;
- move32();
- st->enerLL_fx_Q = Q_audio;
- move16();
-
- L_tmp = 0;
- move32();
- FOR( ; i < 64; i++ )
- {
- L_tmp = L_mac0_sat( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i] );
- }
-
- tmp = L_shr( L_tmp, 5 ); // divide by 32
- tmp = getSqrtWord32( tmp );
- st->enerLH_fx = tmp;
- move32();
- st->enerLH_fx_Q = Q_audio;
- move16();
- }
- ELSE
- {
- Word32 tmp, L_tmp = 0;
- move32();
- FOR( i = 0; i < L_FRAME / 2; i++ )
- {
- L_tmp = L_mac0_sat( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i] );
- }
- tmp = L_shr( L_tmp, 5 ); // divide by 32
- tmp = getSqrtWord32( tmp );
- st->enerLL_fx = tmp;
- move32();
- st->enerLL_fx_Q = Q_audio;
- move16();
-
- L_tmp = 0;
- move32();
- FOR( ; i < L_FRAME; i++ )
- {
- L_tmp = L_mac0_sat( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i] );
- }
- tmp = L_shr( L_tmp, 5 ); // divide by 32
- tmp = getSqrtWord32( tmp );
- st->enerLL_fx = tmp;
- move32();
- st->enerLL_fx_Q = Q_audio;
- move16();
- }
- }
-
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( EQ_16( st->last_bwidth, 0 ) && LE_16( st->extl, SWB_CNG ) )
- {
- st->prev_ener_shb_fx = 0;
- move16();
- IF( st->hBWE_FD != NULL )
- {
- set16_fx( st->hBWE_FD->prev_SWB_fenv_fx, 0, SWB_FENV );
- }
- }
- ELSE IF( ( ( ( st->core == ACELP_CORE ) && ( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, TCX_20_CORE ) ) ) || ( EQ_16( st->core, st->last_core ) && NE_16( st->extl, st->last_extl ) ) ) && GE_16( st->last_bwidth, SWB ) )
- {
- st->attenu_fx = 3277; // 0.1f in Q15
- move16();
- }
-
- test();
- test();
- test();
- test();
- test();
- if ( EQ_16( st->last_core, HQ_CORE ) || ( ( st->last_core == ACELP_CORE ) && !( EQ_16( st->last_extl, WB_TBE ) || EQ_16( st->last_extl, SWB_TBE ) || EQ_16( st->last_extl, FB_TBE ) ) && GT_32( st->core_brate, ACELP_8k00 ) ) )
- {
- st->prev_fractive = 0;
- move16();
- }
-
- return;
-}
diff --git a/lib_dec/dec_LPD_fx.c b/lib_dec/dec_LPD_fx.c
index 9515aefe898464d21f318f419e654ab748d92957..00ff81afedaba35ac89a81a7cc2ebca47e030fe1 100644
--- a/lib_dec/dec_LPD_fx.c
+++ b/lib_dec/dec_LPD_fx.c
@@ -556,7 +556,7 @@ void decoder_LPD_fx(
move16();
}
- int_lsp4_ivas_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp );
+ int_lsp4_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp );
}
ELSE
{
@@ -930,16 +930,14 @@ void decoder_LPD_fx(
E_LPC_lev_dur( r_h, r_l, A, NULL, M, NULL );
E_LPC_a_lsp_conversion( A, lsptmp, &xspnew_uw[0], M );
Residu3_fx( A, buf + L_LP - L_FRAME, res, L_FRAME, 1 );
- cng_params_upd_fx( lsptmp, res, st->L_frame, &st->hTdCngDec->ho_circ_ptr,
- st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx,
- Qexc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate );
+
+ cng_params_upd_fx( lsptmp, res, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx,
+ Qexc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, EVS_MONO, -1 );
}
ELSE
{
- cng_params_upd_fx( &lsp[M], st->old_exc_fx + L_EXC_MEM_DEC - st->L_frame,
- st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx,
- &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC,
- st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate );
+ cng_params_upd_fx( &lsp[M], st->old_exc_fx + L_EXC_MEM_DEC - st->L_frame, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx,
+ st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, EVS_MONO, -1 );
}
/* Set 16k LSP flag for CNG buffer */
diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c
index 0d867fd6f0708fc01193345fa209e6302c4eabc9..ac137b37c99be1174fcc91f5a549d265eeeff808 100644
--- a/lib_dec/dec_ace_fx.c
+++ b/lib_dec/dec_ace_fx.c
@@ -353,7 +353,7 @@ void decoder_acelp_fx(
IF( st->igf != 0 )
{
- tbe_celp_exc( st->L_frame, i_subfr, T0, T0_frac, &error, bwe_exc );
+ tbe_celp_exc_fx( EVS_MONO, 0, st->L_frame, L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, 0 );
}
pitch_buffer[idx] = shl( add( shl( T0, 2 ), T0_frac ), 4 ); // Q6
diff --git a/lib_dec/dec_acelp_tcx_main_fx.c b/lib_dec/dec_acelp_tcx_main_fx.c
index 94d4486b1692b4bb9c0d9d76ae127ae2d526748a..1eccbfeab0344714846a2e1d48fb2330596446d6 100644
--- a/lib_dec/dec_acelp_tcx_main_fx.c
+++ b/lib_dec/dec_acelp_tcx_main_fx.c
@@ -479,7 +479,7 @@ Word16 dec_acelp_tcx_frame_fx(
test();
IF( st->core == ACELP_CORE && st->igf != 0 && st->con_tcx == 0 )
{
- non_linearity_fx( ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors, st->L_frame );
+ non_linearity_fx( EVS_MONO, ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors, st->L_frame );
/* update the old BWE exe memory */
Copy( &old_bwe_exc[L_FRAME32k], hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2 );
}
diff --git a/lib_dec/dec_amr_wb_fx.c b/lib_dec/dec_amr_wb_fx.c
index c65162afcdb24dac8a49a954240e671cfc1272eb..af6c706f707b26fa9080b21007ba168478c7c1cc 100644
--- a/lib_dec/dec_amr_wb_fx.c
+++ b/lib_dec/dec_amr_wb_fx.c
@@ -84,6 +84,7 @@ void decod_amr_wb_fx(
*--------------------------------------------------------------*/
lp_filt_exc_dec_fx( st_fx, MODE1, i_subfr, L_SUBFR, L_FRAME, lp_flag, exc_fx );
+
/*--------------------------------------------------------------*
* Innovation decoding
*--------------------------------------------------------------*/
@@ -98,9 +99,9 @@ void decod_amr_wb_fx(
gain_dec_amr_wb_fx( st_fx, st_fx->core_brate, &gain_pit_fx, &L_gain_code_fx, hAmrwb_IO->past_qua_en_fx, &gain_inov_fx, code_fx, &L_norm_gain_code_fx );
/* update LP filtered gains for the case of frame erasures */
- lp_gain_updt_fx( i_subfr, gain_pit_fx, L_norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME );
+ lp_gain_updt_fx( EVS_MONO, i_subfr, gain_pit_fx, L_norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME );
- st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, L_gain_code_fx, &voice_fac_fx, st_fx->Q_exc );
+ st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, L_gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR );
move16();
Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr], NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_SUBFR, 0,
diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c
index f7640abe7f632fc12eede8fbd214f933d651677c..e1a3917df5d5f1e1885f1db2cc5c36e825e02ab5 100644
--- a/lib_dec/dec_gen_voic_fx.c
+++ b/lib_dec/dec_gen_voic_fx.c
@@ -164,6 +164,7 @@ ivas_error decod_gen_voic_fx(
/*--------------------------------------------------------------*
* Find the adaptive codebook vector
*--------------------------------------------------------------*/
+
IF( st_fx->element_mode != EVS_MONO )
{
pred_lt4_ivas_fx( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
@@ -173,13 +174,14 @@ ivas_error decod_gen_voic_fx(
pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
}
- // tbe_celp_exc(L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx);
- tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag );
+ tbe_celp_exc_fx( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag );
/*--------------------------------------------------------------*
* LP filtering of the adaptive excitation
*--------------------------------------------------------------*/
+
lp_filt_exc_dec_fx( st_fx, MODE1, i_subfr_fx, L_SUBFR, L_frame, st_fx->acelp_cfg.ltf_mode, exc_fx );
+
/*-----------------------------------------------------------------*
* Transform-domain contribution decoding (active frames)
*-----------------------------------------------------------------*/
@@ -215,12 +217,14 @@ ivas_error decod_gen_voic_fx(
{
gain_dec_mless_fx( st_fx, L_frame, st_fx->coder_type, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx );
}
- st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 ); // Q15
+
+ st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); // Q15
move16();
/*-----------------------------------------------------------------*
* Transform domain contribution decoding
*-----------------------------------------------------------------*/
+
test();
IF( !st_fx->inactive_coder_type_flag && st_fx->coder_type == INACTIVE )
{
@@ -228,14 +232,7 @@ ivas_error decod_gen_voic_fx(
}
/* update LP filtered gains for the case of frame erasures */
- IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
- {
- lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame );
- }
- ELSE
- {
- lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame );
- }
+ lp_gain_updt_fx( st_fx->element_mode, i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame );
/*----------------------------------------------------------------------*
* Find the total excitation
@@ -368,7 +365,6 @@ ivas_error decod_gen_voic_fx(
}
/* FEC fast recovery */
-
IF( do_WI_fx )
{
/* shft_prev = L_EXC_MEM - rint_new_fx(st_fx->bfi_pitch_fx);*/
diff --git a/lib_dec/dec_higher_acelp_fx.c b/lib_dec/dec_higher_acelp_fx.c
index e6cc62e239e208d7f1c1dd6a225f7400570a57bc..5e02f9913af51236c2fd65bef4eb000879738288 100644
--- a/lib_dec/dec_higher_acelp_fx.c
+++ b/lib_dec/dec_higher_acelp_fx.c
@@ -197,7 +197,8 @@ void transf_cdbk_dec_fx(
st_fx->last_code_preq = code_preQ[L_SUBFR - 1]; // q_Code_preQ
move16();
- PREEMPH_FX( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &st_fx->mem_preemp_preQ_fx );
+ preemph_fx( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &st_fx->mem_preemp_preQ_fx );
+
/*--------------------------------------------------------------*
* Compute normalized prequantizer excitation gain for FEC
*
diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c
index 645444e7da153aae1e206c04a23616839199f2c9..83818d1c9aae785f8534622fa770f1b6dc283cc1 100644
--- a/lib_dec/dec_pit_exc_fx.c
+++ b/lib_dec/dec_pit_exc_fx.c
@@ -202,12 +202,11 @@ void dec_pit_exc_fx(
gain_dec_mless_fx( st_fx, st_fx->L_frame, LOCAL_CT, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx );
- st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx, 0 );
+ st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx );
move16();
}
ELSE IF( EQ_16( use_fcb, 2 ) ) /* IVAS only */
{
- /*inov_decode_fx(st_fx, Local_BR_fx, 0, st_fx->L_frame, 1, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_subfr_fx);*/
inov_decode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, 0, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_subfr_fx );
/*--------------------------------------------------------------*
@@ -217,7 +216,7 @@ void dec_pit_exc_fx(
gain_dec_lbr_fx( st_fx, GENERIC, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_subfr_fx );
- st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx, 0 );
+ st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx );
move16();
}
ELSE
@@ -250,6 +249,7 @@ void dec_pit_exc_fx(
/*----------------------------------------------------------------------*
* Find the total excitation
*----------------------------------------------------------------------*/
+
Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[( i_subfr_fx * ( 2 * HIBND_ACB_L_FAC ) ) / 2], hGSCDec->last_exc_dct_in_fx,
L_subfr_fx, shr( imult1616( L_subfr_fx, 2 * HIBND_ACB_L_FAC ), 1 ), gain_code_fx, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, i_subfr_fx, coder_type );
@@ -418,7 +418,7 @@ void dec_pit_exc_fx(
move16();
pt_gain++;
- lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, 0, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, st_fx->L_frame );
+ lp_gain_updt_fx( st_fx->element_mode, i_subfr_fx, gain_pit_fx, 0, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, st_fx->L_frame );
}
}
diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c
index bb24978b22dbfac33cece7743f571b7b12242d9a..1a568cbf9a109fabc600841fc3ed3afab2f9aad7 100644
--- a/lib_dec/dec_post_fx.c
+++ b/lib_dec/dec_post_fx.c
@@ -35,7 +35,7 @@ static void modify_pst_param_fx( const Word16 lp_noise, Word16 *g1, Word16 *g2,
static void Dec_formant_postfilt_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 );
-static void calc_st_filt_ivas_fx( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero, const Word16 extl );
+static void Filt_mu_fx( Word16 *sig_in, Word16 *sig_out, Word16 parcor0, Word16 L_subfr );
/*--------------------------------------------------------------------------
@@ -72,11 +72,13 @@ void Init_post_filter_fx(
return;
}
+
/*--------------------------------------------------------------------------
* NB_post_filt:
*
* Main routine to perform post filtering on NB synthesis
*--------------------------------------------------------------------------*/
+
void nb_post_filt_fx(
const Word16 L_frame, /* i : frame length */
PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
@@ -132,7 +134,6 @@ void nb_post_filt_fx(
move16();
}
-
/* run the post filter */
p_Aq = Aq; // Q12
move16();
@@ -148,10 +149,10 @@ void nb_post_filt_fx(
j = add( j, 1 );
}
-
return;
}
+
/*----------------------------------------------------------------------------
* Dec_postfilt()
*
@@ -175,15 +176,16 @@ void nb_post_filt_fx(
* 1. search around 1st subframe delay (3 integer values)
* 2. search around best integer with fract. delays (1/8)
*----------------------------------------------------------------------------*/
+
static void Dec_postfilt_fx(
PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */
const Word16 t0, /* i : pitch delay given by coder Q0 */
const Word16 *signal_ptr, /* i : input signal (pointer to current subframe Q0 */
- const Word16 *coeff, /* i : LPC coefficients for current subframe Q12 */
+ const Word16 *coeff, /* i : LPC coefficients for current subframe Q12 */
Word16 *sig_out, /* o : postfiltered output Q15*/
const Word16 gamma1, /* i : short term postfilt. den. weighting factor Q15*/
const Word16 gamma2, /* i : short term postfilt. num. weighting factor Q15*/
- const Word16 Gain_factor, /* i : Gain Factor (Q15) */
+ const Word16 Gain_factor, /* i : Gain Factor (Q15) */
const Word16 disable_hpf )
{
/* Local variables and arrays */
@@ -191,14 +193,11 @@ static void Dec_postfilt_fx(
Word16 apond2[LONG_H_ST]; // Q12
Word16 sig_ltp[L_SUBFR + 1]; /* H0 output signal */
Word16 res2[SIZ_RES2]; // Q0
-
Word16 *sig_ltp_ptr;
Word16 *res2_ptr;
Word16 *ptr_mem_stp;
-
Word16 parcor0; // Q15
-
/* Init pointers and restore memories */
res2_ptr = res2 + DECMEM_RES2;
ptr_mem_stp = hPFstat->mem_stp + L_SYN_MEM - 1;
@@ -244,10 +243,10 @@ static void Dec_postfilt_fx(
/* Update for next subframe */
Copy( &res2[L_SUBFR], hPFstat->mem_res2, DECMEM_RES2 );
-
return;
}
+
/*--------------------------------------------------------------------------
* formant_post_filt_fx:
*
@@ -445,7 +444,7 @@ static void Dec_formant_postfilt_fx(
}
/* Controls short term pst filter gain and compute parcor0 */
- calc_st_filt_ivas_fx( apond2, apond1, &parcor0, res2, hPFstat->mem_zero, -1 );
+ calc_st_filt_local_fx( apond2, apond1, &parcor0, res2, hPFstat->mem_zero );
/* 1/A(gamma1) filtering, mem_stp is updated */
resynth[0] = *( hPFstat->mem_stp + sub( L_SYN_MEM, 1 ) );
@@ -463,7 +462,8 @@ static void Dec_formant_postfilt_fx(
}
/* Tilt filtering */
- Filt_mu_ivas_fx( resynth, sig_out, parcor0, L_SUBFR, -1 );
+ Filt_mu_fx( resynth, sig_out, parcor0, L_SUBFR );
+
IF( scale_down )
{
Scale_sig( sig_out, L_SUBFR, 1 );
@@ -472,10 +472,10 @@ static void Dec_formant_postfilt_fx(
/* Gain control */
scale_st_fx( signal_ptr, sig_out, &hPFstat->gain_prec, L_SUBFR );
-
return;
}
+
/*------------------------------------------------------------------------------------
* modify_pst_param()
*
@@ -494,7 +494,6 @@ static void modify_pst_param_fx(
Word16 lp_noiseQ12;
Word32 L_tmp;
-
test();
IF( NE_16( coder_type, INACTIVE ) && LT_16( lp_noise, LP_NOISE_THR_FX ) )
{
@@ -534,20 +533,21 @@ static void modify_pst_param_fx(
*gain_factor = extract_h( L_shl( L_tmp, 7 ) ); /* Q24=>Q31=>Q15 */
-
return;
}
+
/*----------------------------------------------------------------------------
* pst_ltp_fx
*
* Perform harmonic postfilter
*----------------------------------------------------------------------------*/
+
static void pst_ltp_fx(
Word16 t0, /* i : pitch delay given by coder Q0 */
Word16 *ptr_sig_in, /* i : postfilter i filter (residu2) Qx */
- Word16 *ptr_sig_pst0, /* o : harmonic postfilter o Qx */
- Word16 gain_factor /* i : Gain Factor (Q15) */
+ Word16 *ptr_sig_pst0, /* o : harmonic postfilter o Qx */
+ Word16 gain_factor /* i : Gain Factor (Q15) */
)
{
Word32 L_temp;
@@ -570,7 +570,6 @@ static void pst_ltp_fx(
Word16 off_yup;
Word16 nb_sh_sig;
-
/* i signal justified on 13 bits */
ptr_sig = ptr_sig_in - DECMEM_RES2; // Qx
nb_sh_sig = getScaleFactor16( ptr_sig, DECMEM_RES2 + L_SUBFR );
@@ -587,7 +586,6 @@ static void pst_ltp_fx(
/* Sub optimal delay search */
search_del_fx( t0, ptr_sig_cadr, <pdel, &phase, &num_gltp, &den_gltp, &sh_num, &sh_den, y_up, &off_yup );
-
IF( num_gltp == 0 )
{
Copy( ptr_sig_in, ptr_sig_pst0, L_SUBFR );
@@ -603,7 +601,6 @@ static void pst_ltp_fx(
/* Filtering with long filter */
compute_ltp_l_fx( ptr_sig_cadr, ltpdel, phase, ptr_sig_pst0, &num2_gltp, &den2_gltp, &sh_num2, &sh_den2 );
-
IF( EQ_16( select_ltp_fx( num_gltp, den_gltp, sh_num, sh_den, num2_gltp, den2_gltp, sh_num2, sh_den2 ), 1 ) )
{
/* select short filter */
@@ -672,15 +669,19 @@ static void pst_ltp_fx(
/** filtering by H0(z) = harmonic filter **/
filt_plt_fx( ptr_sig_in, ptr_y_up, ptr_sig_pst0, gain_plt );
}
+
+ return;
}
+
/*----------------------------------------------------------------------------
* search_del_fx:
*
* Computes best (shortest) integer LTP delay + fine search
*---------------------------------------------------------------------------*/
+
static void search_del_fx(
- Word16 t0, /* i : pitch delay given by coder Q0 */
+ Word16 t0, /* i : pitch delay given by coder Q0 */
Word16 *ptr_sig_in, /* i : i signal (with delay line) */
Word16 *ltpdel, /* o : delay = *ltpdel - *phase / f_up */
Word16 *phase, /* o : phase */
@@ -715,7 +716,6 @@ static void search_del_fx(
Word16 i_max, lambda, phi, phi_max, ioff;
Word16 temp;
-
/*-------------------------------------
* Computes energy of current signal
*-------------------------------------*/
@@ -747,6 +747,7 @@ static void search_del_fx(
* Selects best of 3 integer delays
* Maximum of 3 numerators around t0
*-------------------------------------*/
+
lambda = sub( t0, 1 );
ptr_sig_past = ptr_sig_in - lambda;
L_num_int = L_deposit_l( -1 );
@@ -947,7 +948,6 @@ static void search_del_fx(
ptr_L_den1 = L_den1;
ptr_y_up = y_up;
-
/* if den_max = 0 : will be selected and declared unvoiced */
/* if num!=0 & den=0 : will be selected and declared unvoiced */
/* degenerated seldom cases, switch off LT is OK */
@@ -1025,6 +1025,7 @@ static void search_del_fx(
/*---------------------------------------------------
* test if normalized crit0[iopt] > THRESHCRIT
*--------------------------------------------------*/
+
test();
IF( num_max == 0 || LE_16( den_max, 1 ) )
{
@@ -1093,30 +1094,28 @@ static void search_del_fx(
move16();
}
-
return;
}
+
/*----------------------------------------------------------------------------
* filt_plt_fx:
*
* Perform long term postfilter
*----------------------------------------------------------------------------*/
+
static void filt_plt_fx(
Word16 *s_in, /* i : i signal with past Qx */
Word16 *s_ltp, /* i : filtered signal with gain 1 Qx*/
Word16 *s_out, /* o : signal Qx */
- Word16 gain_plt /* i : filter gain Q15 */
+ Word16 gain_plt /* i : filter gain Q15 */
)
{
-
/* Local variables */
Word32 L_acc;
-
Word16 n;
Word16 gain_plt_1;
-
gain_plt_1 = sub( 32767, gain_plt ); // Q15
gain_plt_1 = add( gain_plt_1, 1 ); /* 2**15 (1 - g) */
@@ -1128,7 +1127,6 @@ static void filt_plt_fx(
move16(); /* no overflow */
}
-
return;
}
@@ -1139,6 +1137,7 @@ static void filt_plt_fx(
* compute delayed signal, num & den of gain for fractional delay
* with long interpolation filter
*----------------------------------------------------------------------------*/
+
static void compute_ltp_l_fx(
Word16 *s_in, /* i/o: signal with past */
Word16 ltpdel, /* i : delay factor */
@@ -1214,10 +1213,10 @@ static void compute_ltp_l_fx(
move16();
move16();
-
return;
}
+
/*----------------------------------------------------------------------------
* select_ltp_fx:
*
@@ -1225,23 +1224,22 @@ static void compute_ltp_l_fx(
* with gain1 = num1 * 2** sh_num1 / den1 * 2** sh_den1
* and gain2 = num2 * 2** sh_num2 / den2 * 2** sh_den2
*----------------------------------------------------------------------------*/
-static Word16 select_ltp_fx( /* o : 1 = 1st gain, 2 = 2nd gain */
- Word16 num1, /* i : numerator of gain1 Q(sh_num1) */
- Word16 den1, /* i : denominator of gain1 Q(sh_den1) */
- Word16 sh_num1, /* i : just. factor for num1 */
- Word16 sh_den1, /* i : just. factor for den1 */
- Word16 num2, /* i : numerator of gain2 Q(sh_num2) */
- Word16 den2, /* i : denominator of gain2 Q(sh_den2) */
- Word16 sh_num2, /* i : just. factor for num2 */
- Word16 sh_den2 /* i : just. factor for den2 */
+/* o : 1 = 1st gain, 2 = 2nd gain */
+static Word16 select_ltp_fx(
+ Word16 num1, /* i : numerator of gain1 Q(sh_num1) */
+ Word16 den1, /* i : denominator of gain1 Q(sh_den1) */
+ Word16 sh_num1, /* i : just. factor for num1 */
+ Word16 sh_den1, /* i : just. factor for den1 */
+ Word16 num2, /* i : numerator of gain2 Q(sh_num2) */
+ Word16 den2, /* i : denominator of gain2 Q(sh_den2) */
+ Word16 sh_num2, /* i : just. factor for num2 */
+ Word16 sh_den2 /* i : just. factor for den2 */
)
{
Word32 L_temp1, L_temp2;
Word32 L_temp;
-
Word16 temp1, temp2;
-
IF( den2 == 0 )
{
return 1;
@@ -1283,6 +1281,7 @@ static Word16 select_ltp_fx( /* o : 1 = 1st gain, 2 = 2nd gain
return temp1;
}
+
/*----------------------------------------------------------------------------
* calc_st_filt_local_fx
*
@@ -1290,22 +1289,20 @@ static Word16 select_ltp_fx( /* o : 1 = 1st gain, 2 = 2nd gain
* controls gain : computation of energy impulse response as
* SUMn (abs (h[n])) and computes parcor0
*---------------------------------------------------------------------------- */
+
static void calc_st_filt_local_fx(
Word16 *apond2, /* i : coefficients of numerator Q12 */
- Word16 *apond1, /* i : coefficients of denominator Q12 */
+ Word16 *apond1, /* i : coefficients of denominator Q12 */
Word16 *parcor0, /* o : 1st parcor calcul. on composed filter Q15*/
- Word16 *sig_ltp_ptr, /* i/o: i of 1/A(gamma1) : scaled by 1/g0 Qx */
- Word16 *mem_zero /* i : All zero memory */
+ Word16 *sig_ltp_ptr, /* i/o: i of 1/A(gamma1) : scaled by 1/g0 Qx */
+ Word16 *mem_zero /* i : All zero memory */
)
{
Word32 L_g0;
-
Word16 h[LONG_H_ST];
-
Word16 g0, temp;
Word16 i;
-
temp = sub( 2, norm_s( apond2[0] ) );
/* compute i.r. of composed filter apond2 / apond1 */
@@ -1333,71 +1330,18 @@ static void calc_st_filt_local_fx(
}
}
-
return;
}
-static void calc_st_filt_ivas_fx(
- Word16 *apond2, /* i : coefficients of numerator Q12 */
- Word16 *apond1, /* i : coefficients of denominator Q12 */
- Word16 *parcor0, /* o : 1st parcor calcul. on composed filter Q15 */
- Word16 *sig_ltp_ptr, /* i/o: i of 1/A(gamma1) : scaled by 1/g0 Qx*/
- Word16 *mem_zero, /* i : All zero memory */
- const Word16 extl /* i : extension layer info */
-)
-{
- Word32 L_g0;
-
- Word16 h[LONG_H_ST]; // Q12
-
- Word16 g0, temp;
- Word16 i;
-
-
- temp = sub( 2, norm_s( apond2[0] ) );
- /* compute i.r. of composed filter apond2 / apond1 */
- IF( EQ_16( extl, SWB_TBE ) )
- {
- E_UTIL_synthesis( temp, apond1, apond2, h, LONG_H_ST, mem_zero, 0, LPC_SHB_ORDER );
- }
- ELSE
- {
- E_UTIL_synthesis( temp, apond1, apond2, h, LONG_H_ST, mem_zero, 0, M );
- }
-
- /* compute 1st parcor */
- Calc_rc0_h( h, parcor0 );
-
- /* compute g0 */
- L_g0 = L_mult0( 1, abs_s( h[0] ) ); // Q12
- FOR( i = 1; i < LONG_H_ST; i++ )
- {
- L_g0 = L_mac0( L_g0, 1, abs_s( h[i] ) ); // Q12
- }
- g0 = extract_h( L_shl( L_g0, 14 ) ); // Q10
-
- /* Scale signal i of 1/A(gamma1) */
- IF( GT_16( g0, 1024 ) ) /*1024 = 1.Q10*/
- {
- temp = div_s( 1024, g0 ); /* temp => Q15 / gain0 */ /*1024 = 1.Q10*/
- FOR( i = 0; i < L_SUBFR; i++ )
- {
- sig_ltp_ptr[i] = mult_r( sig_ltp_ptr[i], temp ); // Qx
- move16();
- }
- }
-
-
- return;
-}
/*----------------------------------------------------------------------------
* filt_mu
*
* tilt filtering with : (1 + mu z-1) * (1/1-|mu|)
* computes y[n] = (1/1-|mu|) (x[n]+mu*x[n-1])
*---------------------------------------------------------------------------*/
-void Filt_mu_fx(
+
+static void Filt_mu_fx(
Word16 *sig_in, /* i : signal (beginning at sample -1) */
Word16 *sig_out, /* o : signal with tilt */
Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */
@@ -1405,14 +1349,11 @@ void Filt_mu_fx(
)
{
Word32 L_acc, L_temp, L_fact;
-
Word16 *ptrs;
-
Word16 n;
Word16 mu, mu2, ga, temp;
Word16 fact, sh_fact;
-
IF( parcor0 > 0 )
{
mu = mult_r( parcor0, GAMMA3_PLUS_FX ); // Q15
@@ -1458,105 +1399,17 @@ void Filt_mu_fx(
BASOP_SATURATE_WARNING_ON_EVS;
}
-
return;
}
-void Filt_mu_ivas_fx(
- Word16 *sig_in, /* i : signal (beginning at sample -1) */
- Word16 *sig_out, /* o : signal with tilt */
- Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) Q15 */
- Word16 L_subfr, /* i : the length of subframe */
- const Word16 extl )
-{
- Word32 L_acc, L_temp, L_fact;
-
- Word16 *ptrs;
-
- Word16 n;
- Word16 mu, mu2, ga, temp;
- Word16 fact, sh_fact;
- IF( EQ_16( extl, SWB_TBE ) )
- {
- IF( parcor0 > 0 )
- {
- mu = mult_r( parcor0, GAMMA3_PLUS_WB_FX ); // Q15
- /* GAMMA3_PLUS_FX < 0.5 */
- sh_fact = 14;
- move16(); /* sh_fact */
- fact = (Word16) 0x4000;
- move16(); /* Q(sh_fact) */
- L_fact = L_deposit_l( 0x2000 ); /* fact >> 1 */
- }
- ELSE
- {
- mu = mult_r( parcor0, GAMMA3_MINUS_WB_FX ); // Q15
- /* GAMMA3_MINUS_FX < 0.9375 */
- sh_fact = 11;
- move16(); /* sh_fact */
- fact = (Word16) 0x0800;
- move16(); /* Q(sh_fact) */
- L_fact = L_deposit_l( 0x0400 ); /* fact >> 1 */
- }
- }
- ELSE
- {
- IF( parcor0 > 0 )
- {
- mu = mult_r( parcor0, GAMMA3_PLUS_FX ); // Q15
- /* GAMMA3_PLUS_FX < 0.5 */
- sh_fact = 14;
- move16(); /* sh_fact */
- fact = (Word16) 0x4000;
- move16(); /* Q(sh_fact) */
- L_fact = L_deposit_l( 0x2000 ); /* fact >> 1 */
- }
- ELSE
- {
- mu = mult_r( parcor0, GAMMA3_MINUS_FX ); // Q15
- /* GAMMA3_MINUS_FX < 0.9375 */
- sh_fact = 11;
- move16(); /* sh_fact */
- fact = (Word16) 0x0800;
- move16(); /* Q(sh_fact) */
- L_fact = L_deposit_l( 0x0400 ); /* fact >> 1 */
- }
- }
-
- temp = sub( 1, abs_s( mu ) );
- BASOP_SATURATE_WARNING_OFF_EVS;
- mu2 = add_sat( 32767, temp ); /* Q15 (1 - |mu|) */
- BASOP_SATURATE_WARNING_ON_EVS;
- ga = div_s( fact, mu2 ); /* Q(sh_fact) / (1 - |mu|) */
-
- ptrs = sig_in; /* points on sig_in(-1) */
-
- sh_fact = sub( sh_fact, 16 ); /* to remove the saturate(), should shl by 16 before rounding */
-
- FOR( n = 0; n < L_subfr; n++ )
- {
- L_acc = L_mult0( mu, *ptrs++ );
- L_temp = L_mac( L_acc, 16384, *ptrs ); /* sig_in(n) * 2**15 */
-
- L_temp = Madd_32_16( L_fact, L_temp, ga );
- L_temp = L_shr( L_temp, sh_fact ); /* mult. temp x ga */
-
- BASOP_SATURATE_WARNING_OFF_EVS;
- /*sig_out[n] = saturate(L_temp); move16();*/
- sig_out[n] = round_fx_sat( L_temp );
- BASOP_SATURATE_WARNING_ON_EVS;
- }
-
-
- return;
-}
/*----------------------------------------------------------------------------
* scale_st_fx()
*
* control of the subframe gain
* gain[n] = AGC_FAC_FX * gain[n-1] + (1 - AGC_FAC_FX) g_in/g_out
*---------------------------------------------------------------------------*/
+
void scale_st_fx(
const Word16 *sig_in, /* i : postfilter i signal Qx */
Word16 *sig_out, /* i/o: postfilter o signal Qx */
@@ -1564,12 +1417,11 @@ void scale_st_fx(
Word16 L_subfr )
{
Word32 L_acc, L_temp;
-
Word16 i;
Word16 scal_in, scal_out;
Word16 s_g_in, s_g_out, temp, sh_g0, g0;
Word16 gain = 0;
-
+ move16();
/* compute i gain */
L_acc = L_deposit_l( 0 );
@@ -1648,10 +1500,10 @@ void scale_st_fx(
*gain_prec = gain;
move16();
-
return;
}
+
/*----------------------------------------------------------------------------
* blend_subfr2_fx()
*
@@ -1671,6 +1523,7 @@ void blend_subfr2_fx(
move16();
move16();
move16();
+
FOR( i = 0; i < L_SUBFR / 2; i++ )
{
sigOut[i] = mac_r_sat( L_mult_sat( fac1, sigIn1[i] ), fac2, sigIn2[i] ); // Qx
diff --git a/lib_dec/dec_prm_fx.c b/lib_dec/dec_prm_fx.c
index 6b6748b803ff1933f7b06c897de86590e86258e7..41a2e9842cd2657b9f28f019e4a75462e9e93f22 100644
--- a/lib_dec/dec_prm_fx.c
+++ b/lib_dec/dec_prm_fx.c
@@ -52,7 +52,7 @@ void getLPCparam_fx(
{
IF( st->lpcQuantization == 0 )
{
- decode_lpc_avq_ivas_fx( st0, st->numlpc, param_lpc, ch, st->element_mode, sns_low_br_mode );
+ decode_lpc_avq_fx( st0, st->numlpc, param_lpc, ch, st->element_mode, sns_low_br_mode );
}
ELSE IF( EQ_16( st->lpcQuantization, 1 ) )
{
@@ -1003,7 +1003,7 @@ void dec_prm_fx(
{
IF( st->lpcQuantization == 0 )
{
- decode_lpc_avq_fx( st, st->numlpc, param_lpc );
+ decode_lpc_avq_fx( st, st->numlpc, param_lpc, 0, EVS_MONO, 0 );
move16();
}
ELSE IF( EQ_16( st->lpcQuantization, 1 ) )
diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c
index 13cf9e9eb5a26b97e96a6a92f1c7bc4326c3cbd0..ed170d5982cf679da5651bb1eb9ef3adc4683609 100644
--- a/lib_dec/dec_tcx_fx.c
+++ b/lib_dec/dec_tcx_fx.c
@@ -1075,6 +1075,10 @@ void decoder_tcx_fx(
Word16 predictionGain; /* not counted */
predictionGain = 0;
move16();
+#ifdef FIX_2383_INIT_Q_A_ITF
+ Q_A_itf = 15;
+ move16();
+#endif
FOR( j = startLine; j < endLine; j++ )
{
@@ -4021,6 +4025,9 @@ void decoder_tcx_ivas_fx(
move16();
fUseTns = 0; /* flag that is set if TNS data is present */
move16();
+#ifdef FIX_2353_PTR_INIT
+ prm_sqQ = NULL;
+#endif
set16_fx( xn_buf_fx, 0, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX );
diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c
index b00b445d791133d719b9027e7956584ccc86388f..20d5f4b22bfec94ffa76a46023927e9d4511f8bc 100644
--- a/lib_dec/dec_tran_fx.c
+++ b/lib_dec/dec_tran_fx.c
@@ -87,6 +87,7 @@ void decod_tran_fx(
move16();
set16_fx( code_preQ_fx, 0, L_SUBFR ); // Q10
+
/*----------------------------------------------------------------*
* ACELP subframe loop
*----------------------------------------------------------------*/
@@ -118,9 +119,11 @@ void decod_tran_fx(
transition_dec_fx( st_fx, 0, L_frame_fx, i_subfr, tc_subfr_fx, &Jopt_flag, exc_fx,
&T0, &T0_frac, &T0_min, &T0_max, &pt_pitch_fx, &position, bwe_exc_fx, &st_fx->Q_exc );
+
/*-----------------------------------------------------------------*
* Transform domain contribution decoding - active frames
*-----------------------------------------------------------------*/
+
IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) )
{
gain_code_fx = 0;
@@ -142,14 +145,7 @@ void decod_tran_fx(
IF( Jopt_flag == 0 )
{
/* 2/3-bit decoding */
- IF( st_fx->element_mode == EVS_MONO )
- {
- gain_dec_tc_fx( st_fx, code_fx, i_subfr, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx );
- }
- ELSE
- {
- gain_dec_tc_ivas_fx( st_fx, code_fx, i_subfr, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx );
- }
+ gain_dec_tc_fx( st_fx, code_fx, i_subfr, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx );
}
ELSE
{
@@ -165,24 +161,15 @@ void decod_tran_fx(
}
/* update LP filtered gains for the case of frame erasures */
- IF( st_fx->element_mode == EVS_MONO )
- {
- lp_gain_updt_fx( i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx );
-
- st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc );
- move16();
- }
- ELSE
- {
- lp_gain_updt_ivas_fx( i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx );
+ lp_gain_updt_fx( st_fx->element_mode, i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx );
- st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 );
- move16();
- }
+ st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR );
+ move16();
/*----------------------------------------------------------------------*
* Find the total excitation
*----------------------------------------------------------------------*/
+
test();
test();
test();
@@ -219,6 +206,7 @@ void decod_tran_fx(
/*-----------------------------------------------------------------*
* Add the ACELP pre-quantizer contribution
*-----------------------------------------------------------------*/
+
IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) )
{
IF( ( st_fx->element_mode == EVS_MONO ) )
@@ -244,6 +232,7 @@ void decod_tran_fx(
/*-----------------------------------------------------------------*
* Prepare TBE excitation
*-----------------------------------------------------------------*/
+
Word16 tmp_idx_2;
tmp_idx_2 = 0;
move16();
diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c
index b5c10232c4034725f0ef48a73c45102630738d31..83e5666b4f44ad691d655fdaa355ce364695ff40 100644
--- a/lib_dec/dec_uv_fx.c
+++ b/lib_dec/dec_uv_fx.c
@@ -5,6 +5,8 @@
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
#include "prot_fx.h" /* Function prototypes */
+
+
static void gain_dec_gacelp_uv_fx(
Word16 index, /* i : Quantization index vector Q0 */
Word16 *code, /* i : algebraic code excitation Q9 */
@@ -90,19 +92,18 @@ void decod_unvoiced_fx(
* Innovation decoding
*--------------------------------------------------------------*/
- // inov_decode(st, st->core_brate, 0, L_FRAME, 1, i_subfr, p_Aq, st->tilt_code, *pt_pitch, code, L_SUBFR);
inov_decode_fx( st_fx, st_fx->core_brate, 0, L_FRAME, 1, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_SUBFR );
/*-------------------------------------------------------*
* Generate Gaussian excitation *
*-------------------------------------------------------*/
- // gaus_L2_dec_flt(code2, st->tilt_code, p_Aq, FORMANT_SHARPENING_G1_FLT, &(st->seed_acelp));
gaus_L2_dec( code2_fx, st_fx->tilt_code_fx, p_Aq_fx, FORMANT_SHARPENING_G1, &( st_fx->seed_acelp ) );
/*-----------------------------------------------------------------*
* Gain encoding
*-----------------------------------------------------------------*/
+
Word16 tmp_idx_1;
tmp_idx_1 = 0;
move16();
@@ -115,18 +116,11 @@ void decod_unvoiced_fx(
gain_dec_gacelp_uv_fx( index, code_fx, code2_fx, Es_pred_fx, L_SUBFR, &gain_pit_fx, &gain_code_fx, &gain_code2_fx, &( st_fx->past_gpit ), &norm_gain_code_fx, &gain_inov_fx );
- st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 );
+ st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR );
move16();
/* update LP filtered gains for the case of frame erasures */
- IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
- {
- lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME );
- }
- ELSE
- {
- lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME );
- }
+ lp_gain_updt_fx( st_fx->element_mode, i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME );
/*-------------------------------------------------------*
* - Find the total excitation. *
diff --git a/lib_dec/decision_matrix_dec_fx.c b/lib_dec/decision_matrix_dec_fx.c
index cddc163147a47c1fed76a5905838b3a80495613c..055f1325f884406f175cbf35e8ecc5d54ef82375 100644
--- a/lib_dec/decision_matrix_dec_fx.c
+++ b/lib_dec/decision_matrix_dec_fx.c
@@ -84,11 +84,9 @@ void decision_matrix_dec_fx(
{
st->L_frame = L_FRAME16k;
move16();
-#ifdef FIX_2252_LP_CNG_STARTS_SID
st->nb_subfr = NB_SUBFR16k;
move16();
st->bwidth = s_max( st->bwidth, WB );
-#endif
}
}
ELSE
diff --git a/lib_dec/dlpc_avq_fx.c b/lib_dec/dlpc_avq_fx.c
index 97b41d98ba05840ab02db7f9be0a44e2a443cb68..9080fd5aa2693b1a960bedf79275a55cd42b6be2 100644
--- a/lib_dec/dlpc_avq_fx.c
+++ b/lib_dec/dlpc_avq_fx.c
@@ -146,145 +146,6 @@ static Word16 pack4bits_fx(
}
Word16 decode_lpc_avq_fx(
- Decoder_State *st, /* i/o: decoder state structure */
- const Word16 numlpc, /* i : Number of sets of lpc */
- Word16 *param_lpc /* o : lpc parameters */
-)
-{
- Word16 k, j;
- Word16 nb, qn1, qn2, avqBits, q_type;
- Word16 start_bit_pos;
- move16();
- move16();
- move16();
- j = 0;
- start_bit_pos = st->next_bit_pos;
-
- FOR( k = 0; k < numlpc; k++ )
- {
- /* Decode quantizer type */
-
- IF( k == 0 )
- {
- move16();
- move16();
- q_type = 0;
- nb = 0;
- }
- ELSE
- {
- move16();
- nb = 1;
- q_type = get_next_indice_fx( st, nb );
- move16();
- param_lpc[j] = q_type;
- j = add( j, 1 );
- }
- /* Decode quantization indices */
-
- IF( q_type == 0 )
- {
- /* Absolute quantizer with 1st stage stochastic codebook */
- {
- move16();
- param_lpc[j] = get_next_indice_fx( st, 8 );
- }
- j = add( j, 1 );
- }
- /*
- * 2nd stage decoding is skipped if:
- * - we are in low bitrate mode and no joint SNS coding is used
- * - OR the side-SNS-is-zero flag is set for joint SNS
- */
- {
- /* 2 bits to specify Q2,Q3,Q4,ext */
- qn1 = add( 2, get_next_indice_fx( st, 2 ) );
- qn2 = add( 2, get_next_indice_fx( st, 2 ) );
-
- /* Unary code */
- /* Q5 = 0, Q6=10, Q0=110, Q7=1110, ... */
-
- IF( GT_16( qn1, 4 ) )
- {
- nb = unary_decode_fx( st, &qn1 );
-
- if ( EQ_16( nb, 1 ) )
- {
- qn1 = add( qn1, 5 );
- }
- if ( EQ_16( nb, 2 ) )
- {
- qn1 = add( qn1, 4 );
- }
- if ( EQ_16( nb, 3 ) )
- {
- move16();
- qn1 = 0;
- }
- if ( GT_16( nb, 3 ) )
- {
- qn1 = add( qn1, 3 );
- }
- }
-
- IF( GT_16( qn2, 4 ) )
- {
- nb = unary_decode_fx( st, &qn2 );
-
- if ( EQ_16( nb, 1 ) )
- {
- qn2 = add( qn2, 5 );
- }
- if ( EQ_16( nb, 2 ) )
- {
- qn2 = add( qn2, 4 );
- }
- if ( EQ_16( nb, 3 ) )
- {
- move16();
- qn2 = 0;
- }
- if ( GT_16( nb, 3 ) )
- {
- qn2 = add( qn2, 3 );
- }
- }
-
- /* check for potential bit errors */
- test();
- IF( ( GT_16( qn1, NB_SPHERE ) ) || ( GT_16( qn2, NB_SPHERE ) ) )
- {
- qn1 = 0;
- move16();
- qn2 = 0;
- move16();
- st->BER_detect = 1;
- move16();
- }
-
- move16();
- param_lpc[j] = qn1;
- j = add( j, 1 );
- move16();
- param_lpc[j] = qn2;
- j = add( j, 1 );
-
- /* Decode Split-by-2 algebraic VQ */
- avqBits = shl( qn1, 2 );
-
- pack4bits_fx( avqBits, st, ¶m_lpc[j] );
- j = add( j, qn1 );
-
- avqBits = shl( qn2, 2 );
- pack4bits_fx( avqBits, st, ¶m_lpc[j] );
- j = add( j, qn2 );
- }
- }
-
- return sub( st->next_bit_pos, start_bit_pos );
-}
-
-Word16 decode_lpc_avq_ivas_fx(
Decoder_State *st, /* i/o: decoder state structure */
const Word16 numlpc, /* i : Number of sets of lpc */
Word16 *param_lpc, /* o : lpc parameters */
@@ -324,6 +185,7 @@ Word16 decode_lpc_avq_ivas_fx(
param_lpc[j] = q_type;
j = add( j, 1 );
}
+
test();
IF( EQ_16( element_mode, IVAS_CPE_MDCT ) && k == 0 )
{
@@ -338,6 +200,7 @@ Word16 decode_lpc_avq_ivas_fx(
j = add( j, 1 );
move16();
}
+
/* Decode quantization indices */
IF( q_type == 0 )
@@ -362,6 +225,7 @@ Word16 decode_lpc_avq_ivas_fx(
}
j = add( j, 1 );
}
+
/*
* 2nd stage decoding is skipped if:
* - we are in low bitrate mode and no joint SNS coding is used
diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c
index a358cbe8ad5929f44104d7a45e7e9b53bb57dc5a..07b2deddc3d6b0309a992cb26e82a6784253f8e7 100644
--- a/lib_dec/evs_dec_fx.c
+++ b/lib_dec/evs_dec_fx.c
@@ -315,7 +315,7 @@ ivas_error evs_dec_fx(
* Preprocessing (preparing) for ACELP/HQ core switching
*---------------------------------------------------------------------*/
- IF( ( error = core_switching_pre_dec_fx( st_fx, output_frame ) ) != IVAS_ERR_OK )
+ IF( ( error = core_switching_pre_dec_fx( st_fx, output_frame, -1, 1, EVS_MONO, EVS_MONO, -1, &tmp16, &tmp16 ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -346,7 +346,7 @@ ivas_error evs_dec_fx(
* Postprocessing for ACELP/HQ core switching
*---------------------------------------------------------------------*/
- if ( ( error = core_switching_post_dec_fx( st_fx, synth_fx, output_frame, core_switching_flag, EVS_MONO, &Qpostd ) ) != IVAS_ERR_OK )
+ if ( ( error = core_switching_post_dec_fx( st_fx, synth_fx, NULL, NULL, 0, output_frame, core_switching_flag, 0, 1, EVS_MONO, &Qpostd ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -355,7 +355,7 @@ ivas_error evs_dec_fx(
* Pre-processing for bandwidth switching
*---------------------------------------------------------------------*/
- bw_switching_pre_proc_fx( old_syn_12k8_16k_fx, st_fx );
+ bw_switching_pre_proc_fx( st_fx, -1, 1, old_syn_12k8_16k_fx );
/*---------------------------------------------------------------------*
* WB TBE decoding
@@ -408,7 +408,11 @@ ivas_error evs_dec_fx(
test();
IF( EQ_16( output_frame, L_FRAME48k ) && EQ_16( st_fx->extl, FB_TBE ) )
{
+#ifdef HARMONIZE_TBE
+ fb_tbe_dec_fx( st_fx, fb_exc_fx, Q_fb_exc, hb_synth_fx, NULL, hb_synth_fx_exp, NULL, -1, output_frame );
+#else
fb_tbe_dec_fx( st_fx, fb_exc_fx, Q_fb_exc, hb_synth_fx, hb_synth_fx_exp );
+#endif
}
}
ELSE IF( EQ_16( st_fx->extl, SWB_BWE ) || EQ_16( st_fx->extl, FB_BWE ) ||
@@ -843,7 +847,11 @@ ivas_error evs_dec_fx(
test();
IF( EQ_16( st_fx->extl, FB_TBE ) && EQ_16( output_frame, L_FRAME48k ) )
{
+#ifdef HARMONIZE_TBE
+ fb_tbe_dec_fx( st_fx, fb_exc_fx, Q_fb_exc, hb_synth_fx, NULL, hb_synth_fx_exp, NULL, -1, output_frame );
+#else
fb_tbe_dec_fx( st_fx, fb_exc_fx, Q_fb_exc, hb_synth_fx, hb_synth_fx_exp );
+#endif
}
}
Copy( hb_synth_fx, hBWE_TD->old_hb_synth_fx, output_frame ); /*Q15 - hb_synth_fx_exp*/
@@ -1374,7 +1382,8 @@ ivas_error evs_dec_fx(
st_fx->bfi = 1;
move16();
}
- updt_dec_common_fx( st_fx, -1, concealWholeFrameTmp, output_sp, Qpostd );
+
+ updt_dec_common_fx( st_fx, -1, concealWholeFrameTmp, output_sp, NULL, Qpostd );
}
ELSE
{
@@ -1383,7 +1392,8 @@ ivas_error evs_dec_fx(
st_fx->bfi = 0;
move16();
}
- updt_dec_common_fx( st_fx, hq_core_type, concealWholeFrameTmp, output_sp, Qpostd );
+
+ updt_dec_common_fx( st_fx, hq_core_type, concealWholeFrameTmp, output_sp, NULL, Qpostd );
}
pop_wmops();
diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c
index 8c4d104995ded05ce095e67d0e53cdc897aa9cab..471600ca384bdf57eb243d35a22f4ea120904fde 100644
--- a/lib_dec/fd_cng_dec_fx.c
+++ b/lib_dec/fd_cng_dec_fx.c
@@ -1095,11 +1095,7 @@ Word16 ApplyFdCng_fx(
s = s_max( s_min( s, sub( WORD32_BITS, 1 ) ), negate( sub( WORD32_BITS, 1 ) ) );
FOR( ; j <= hFdCngCom->part[k]; j++ )
{
-#ifdef FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES
cngNoiseLevel[j] = L_shl_r( Mpy_32_16_r( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/
-#else
- cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/
-#endif
move32();
}
}
@@ -1710,11 +1706,7 @@ void perform_noise_estimation_dec_ivas_fx(
FOR( p = 0; p < npart; p++ )
{
temp = L_shl( msPeriodog[p], q_shift );
-#ifdef FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES
msNoiseEst[p] = Madd_32_16( Mpy_32_16_r( msNoiseEst[p], sub( MAX_16, alpha ) ), temp, alpha ); /*Q31 - hFdCngDec->msNoiseEst_exp*/
-#else
- msNoiseEst[p] = Madd_32_16( Mpy_32_16_1( msNoiseEst[p], sub( MAX_16, alpha ) ), temp, alpha ); /*Q31 - hFdCngDec->msNoiseEst_exp*/
-#endif
move32();
}
}
@@ -1792,11 +1784,7 @@ void perform_noise_estimation_dec_ivas_fx(
L_tmp = L_shr( msPeriodog[p], sub( sub( 31, hFdCngDec->hFdCngCom->periodog_exp ), 4 ) );
IF( LT_32( L_tmp, msNoiseEst[p] ) )
{
-#ifdef FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES
msNoiseEst[p] = Madd_32_16( Mpy_32_16_r( msNoiseEst[p], wght ), L_tmp, (Word16) L_sub( shr( MAX_16, sub( 15, scale ) ), wght ) ); /*temp_q_msNoiseEst[p]*/
-#else
- msNoiseEst[p] = Madd_32_16( Mpy_32_16_1( msNoiseEst[p], wght ), L_tmp, (Word16) L_sub( shr( MAX_16, sub( 15, scale ) ), wght ) ); /*temp_q_msNoiseEst[p]*/
-#endif
move32();
temp_q_msNoiseEst[p] = sub( add( hFdCngDec->msNoiseEst_exp, scale ), 15 );
move16();
@@ -1819,11 +1807,7 @@ void perform_noise_estimation_dec_ivas_fx(
L_tmp = L_shr_sat( hFdCngDec->msPeriodog_ST_fx[p], sub( hFdCngDec->msNoiseEst_exp, hFdCngDec->msPeriodog_ST_exp ) ); /*Q31 - hFdCngDec->msPeriodog_ST_exp*/
IF( LT_32( L_tmp, msNoiseEst[p] ) )
{
-#ifdef FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES
msNoiseEst[p] = Madd_32_16( Mpy_32_16_r( msNoiseEst[p], CNA_ACT_DN_FACT_Q15 ), L_tmp, ONE_IN_Q15 - CNA_ACT_DN_FACT_Q15 ); /*Q31 - hFdCngDec->msNoiseEst_exp*/
-#else
- msNoiseEst[p] = Madd_32_16( Mpy_32_16_1( msNoiseEst[p], CNA_ACT_DN_FACT_Q15 ), L_tmp, ONE_IN_Q15 - CNA_ACT_DN_FACT_Q15 ); /*Q31 - hFdCngDec->msNoiseEst_exp*/
-#endif
move32();
}
}
@@ -5001,7 +4985,7 @@ void generate_masking_noise_lb_dirac_fx(
n_samples_start = add( n_samples_start, hFdCngCom->frameSize );
}
- /* move generated noise to the 5ms subframe starts in the tc buffer according to the output sampling frequency to avoid
+ /* move generated noise to the 5ms subframe starts in the TC buffer according to the output sampling frequency to avoid
overwriting it with the synthesis in case of shared tc and synth channel memory, i.e. non-TSM mode */
slot_size_cng = shr( hFdCngCom->frameSize, 4 /* DEFAULT_JBM_CLDFB_TIMESLOTS */ );
/* move start indices forward to the end of the last subframe */
diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c
index 0848104afa84f0eb798d41eb438c02502ccc57de..551e04205f4030c9b5c74c55883e0f286a580299 100644
--- a/lib_dec/gain_dec_fx.c
+++ b/lib_dec/gain_dec_fx.c
@@ -113,8 +113,10 @@ void gain_dec_tc_fx(
/*----------------------------------------------------------------*
* find number of bits for gain dequantization
*----------------------------------------------------------------*/
- nBits = st_fx->acelp_cfg.gains_mode[( i_subfr_fx / 64 )];
+
+ nBits = st_fx->acelp_cfg.gains_mode[( i_subfr_fx / L_SUBFR )];
move16();
+
/*-----------------------------------------------------------------*
* calculate the predicted gain code
*-----------------------------------------------------------------*/
@@ -132,7 +134,6 @@ void gain_dec_tc_fx(
*gain_inov_fx = extract_h( L_shl( L_tmp, sub( expg, 3 ) ) );
move16(); /* gain_inov in Q12 */
-
/* Ei = 10 * (float)log10( Ecode );*/
e_tmp = norm_l( L_tmp1 );
f_tmp = Log2_norm_lc( L_shl( L_tmp1, e_tmp ) ); /*Q15*/
@@ -147,6 +148,7 @@ void gain_dec_tc_fx(
* = pow(2, 3.321928*gcode0/20)
* = pow(2, 0.166096*gcode0)
*-----------------------------------------------------------------*/
+
L_tmp = L_mult( gcode0_fx, 21771 ); /* *0.166096 in Q17 -> Q26 */
L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */
frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */
@@ -154,24 +156,38 @@ void gain_dec_tc_fx(
/* output of Pow2() will be: */
/* 16384 < Pow2() <= 32767 */
exp_gcode0 = sub( exp_gcode0, 14 );
+
/*------------------------------------------------------------------------------------------*
* Select the gain quantization table and dequantize the gain
*------------------------------------------------------------------------------------------*/
- /* index = (Word16)get_indice( st_fx,"gain_code", i_subfr_fx, ACELP_CORE);move16();*/
- index = (Word16) get_next_indice_fx( st_fx, nBits );
- move16();
-
+ index = (Word16) get_next_indice_fx( st_fx, nBits ); /*Q0*/
- IF( GT_16( nBits, 3 ) )
+ IF( st_fx->element_mode == EVS_MONO )
{
- wgain_code = gain_dequant_fx( index, G_CODE_MIN_TC_Q15, G_CODE_MAX_TC_Q0, nBits, &expg );
- wgain_code = shl_sat( wgain_code, add( expg, 13 ) ); /* wgain_code in Q13*/
+ IF( GT_16( nBits, 3 ) )
+ {
+ wgain_code = gain_dequant_fx( index, G_CODE_MIN_TC_Q15, G_CODE_MAX_TC_Q0, nBits, &expg );
+ wgain_code = shl_sat( wgain_code, add( expg, 13 ) ); /* wgain_code in Q13*/
+ }
+ ELSE /* nBits == 3 */
+ {
+ wgain_code = tbl_gain_code_tc_fx[index]; /*Q13*/
+ move16();
+ }
}
- ELSE /* nBits == 3 */
+ ELSE
{
- wgain_code = tbl_gain_code_tc_fx[index]; /*Q13*/
- move16();
+ IF( GT_16( nBits, 3 ) )
+ {
+ wgain_code = gain_dequant_fx( index, G_CODE_MIN_TC_Q15, G_CODE_MAX_TC_Q0, nBits, &expg );
+ wgain_code = shl( wgain_code, add( expg, 12 ) ); /* wgain_code in Q12*/
+ }
+ ELSE /* nBits == 3 */
+ {
+ wgain_code = shr( tbl_gain_code_tc_fx[index], 1 ); // Q12
+ move16();
+ }
}
/*-----------------------------------------------------------------*
@@ -179,139 +195,16 @@ void gain_dec_tc_fx(
*-----------------------------------------------------------------*/
/* *gain_code *= gcode0;*/
- L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q13*Q0 -> Q14 */
- *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 2 ) ); /*Q16*/
- move32();
-
- /**norm_gain_code = *gain_code / *gain_inov;*/
- expg = sub( norm_s( *gain_inov_fx ), 1 );
- expg = s_max( expg, 0 );
-
- tmp_fx = div_s( shr( 8192, expg ), *gain_inov_fx );
- *norm_gain_code_fx = L_shr( Mult_32_16( *gain_code_fx, tmp_fx ), sub( 1, expg ) ); /*Q16*/
- move32();
-
- return;
-}
-
-/*======================================================================================*/
-/* FUNCTION : void gain_dec_tc_ivas_fx () */
-/*--------------------------------------------------------------------------------------*/
-/* PURPOSE : Decoding of pitch and codebook gains and updating long term energies */
-/*--------------------------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* Word32 core_brate_fx i : core bitrate */
-/* Word16 *code_fx i : algebraic code excitation */
-/* Word16 L_frame_fx i : length of the frame */
-/* Word16 i_subfr_fx i : subframe number */
-/* Word16 tc_subfr_fx i : TC subframe index */
-/* Word16 Es_pred_fx i : predicted scaled innov. energy Q8 */
-/*--------------------------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* Word16 *gain_pit_fx o : pitch gain Q14 */
-/* Word32 *gain_code_fx o : Quantized codeebook gain Q16 */
-/* Word16 *gain_inov_fx o : unscaled innovation gain Q12 */
-/* Word32 *norm_gain_code_fx o : norm. gain of the codebook excit. Q16 */
-/*--------------------------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/*--------------------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*--------------------------------------------------------------------------------------*/
-/* CALLED FROM : */
-/*======================================================================================*/
-
-void gain_dec_tc_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word16 *code_fx, /* i : algebraic code excitation */
- const Word16 i_subfr_fx, /* i : subframe number */
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
- Word16 *gain_pit_fx, /* o : pitch gain */
- Word32 *gain_code_fx, /* o : Quantized codeebook gain */
- Word16 *gain_inov_fx, /* o : unscaled innovation gain */
- Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */
-)
-{
- Word16 index, nBits;
- Word16 gcode0_fx;
- Word16 Ei_fx;
- Word16 expg, expg2, e_tmp, f_tmp, exp_gcode0, tmp_fx, frac;
- Word32 L_tmp, L_tmp1;
- Word16 wgain_code = 0;
- move16();
- *gain_pit_fx = 0;
- move16();
-
- /*----------------------------------------------------------------*
- * find number of bits for gain dequantization
- *----------------------------------------------------------------*/
- nBits = st_fx->acelp_cfg.gains_mode[( i_subfr_fx / 64 )];
- move16();
- /*-----------------------------------------------------------------*
- * calculate the predicted gain code
- *-----------------------------------------------------------------*/
-
- /*Ecode = (dotp( code, code, L_SUBFR) + 0.01f) / L_SUBFR;
- *gain_inov = 1.0f / (float)sqrt( Ecode );*/
- L_tmp = Dot_product12( code_fx, code_fx, L_SUBFR, &expg ); /*Q31 - expg*/
- expg = sub( expg, 18 + 6 ); /* exp: -18 (code in Q9), -6 (/L_SUBFR) */
- expg2 = expg;
- move16();
- L_tmp1 = L_tmp; /* sets to 'L_tmp' in 1 clock */
- move32();
- L_tmp = Isqrt_lc( L_tmp, &expg ); /*Q31 - expg*/
-
- *gain_inov_fx = extract_h( L_shl( L_tmp, sub( expg, 3 ) ) );
- move16(); /* gain_inov in Q12 */
-
-
- /* Ei = 10 * (float)log10( Ecode );*/
- e_tmp = norm_l( L_tmp1 );
- f_tmp = Log2_norm_lc( L_shl( L_tmp1, e_tmp ) ); /*Q15*/
- e_tmp = sub( expg2, add( 1, e_tmp ) );
- L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 12330 ); /* Q13 */ /* 10*log10(2) in Q12*/
- Ei_fx = round_fx( L_shl( L_tmp1, 11 ) ); /* Q8 */
- /* gcode0 = (float) pow(10, 0.05 * (Es_pred - Ei));*/
- gcode0_fx = sub( Es_pred_fx, Ei_fx ); /* Q8 */
-
- /*-----------------------------------------------------------------*
- * gcode0 = pow(10.0, gcode0/20)
- * = pow(2, 3.321928*gcode0/20)
- * = pow(2, 0.166096*gcode0)
- *-----------------------------------------------------------------*/
- L_tmp = L_mult( gcode0_fx, 21771 ); /* *0.166096 in Q17 -> Q26 */
- L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */
- frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */
- gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */
- /* output of Pow2() will be: */
- /* 16384 < Pow2() <= 32767 */
- exp_gcode0 = sub( exp_gcode0, 14 );
- /*------------------------------------------------------------------------------------------*
- * Select the gain quantization table and dequantize the gain
- *------------------------------------------------------------------------------------------*/
-
- /* index = (Word16)get_indice( st_fx,"gain_code", i_subfr_fx, ACELP_CORE);move16();*/
- index = (Word16) get_next_indice_fx( st_fx, nBits ); /*Q0*/
-
-
- IF( GT_16( nBits, 3 ) )
+ IF( st_fx->element_mode == EVS_MONO )
{
- wgain_code = gain_dequant_fx( index, G_CODE_MIN_TC_Q15, G_CODE_MAX_TC_Q0, nBits, &expg );
- wgain_code = shl( wgain_code, add( expg, 12 ) ); /* wgain_code in Q12*/
+ L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q13*Q0 -> Q14 */
+ *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 2 ) ); /*Q16*/
}
- ELSE /* nBits == 3 */
+ ELSE
{
- wgain_code = shr( tbl_gain_code_tc_fx[index], 1 ); // Q12
- move16();
+ L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q12*Q0 -> Q13 */
+ *gain_code_fx = L_shl( L_tmp, add( exp_gcode0, 3 ) ); /* Q13 -> Q16 */
}
-
- /*-----------------------------------------------------------------*
- * decode normalized codebook gain
- *-----------------------------------------------------------------*/
-
- /* *gain_code *= gcode0;*/
- L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q12*Q0 -> Q13 */
- *gain_code_fx = L_shl( L_tmp, add( exp_gcode0, 3 ) ); /* Q13 -> Q16 */
move32();
/**norm_gain_code = *gain_code / *gain_inov;*/
@@ -353,8 +246,9 @@ void gain_dec_tc_ivas_fx(
/* RETURN ARGUMENTS : */
/* _ None */
/*======================================================================================*/
+
void gain_dec_mless_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
+ Decoder_State *st_fx, /* i/o: decoder state structure */
const Word16 L_frame_fx, /* i : length of the frame */
const Word16 coder_type, /* i : coding type */
const Word16 i_subfr_fx, /* i : subframe number */
@@ -431,6 +325,7 @@ void gain_dec_mless_fx(
* = pow(2, 3.321928*gcode0/20)
* = pow(2, 0.166096*gcode0)
*-----------------------------------------------------------------*/
+
L_tmp = L_mult( gcode0_fx, 21771 ); /* *0.166096 in Q17 -> Q26 */
L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */
frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */
@@ -528,6 +423,7 @@ void gain_dec_mless_fx(
L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 12330 ); /* Q13 */ /* 10*log10(2) in Q12*/
Ei_fx = round_fx( L_shl( L_tmp1, 11 ) ); /* Q8 */
}
+
/*-----------------------------------------------------------------*
* calculate the predicted gain code
*-----------------------------------------------------------------*/
@@ -540,6 +436,7 @@ void gain_dec_mless_fx(
* = pow(2, 3.321928*gcode0/20)
* = pow(2, 0.166096*gcode0)
*-----------------------------------------------------------------*/
+
L_tmp = L_mult( gcode0_fx, 21771 ); /* *0.166096 in Q17 -> Q26 */
L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */
frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */
@@ -650,6 +547,7 @@ void gain_dec_lbr_fx(
* calculate prediction of gcode
* search for the best codeword
*-----------------------------------------------------------------*/
+
test();
IF( i_subfr == 0 )
{
@@ -698,7 +596,6 @@ void gain_dec_lbr_fx(
gcode0_fx = round_fx( L_shl( L_tmp, 11 ) ); /* Q8 */
-
/*-----------------------------------------------------------------*
* gcode0 = pow(10.0, gcode0/20)
* = pow(2, 3.321928*gcode0/20)
@@ -775,6 +672,7 @@ void gain_dec_lbr_fx(
* gcode0 = pow(10.0, dotp(b, aux, n_pred)
* = pow(2, 3.321928*dotp(b, aux, n_pred)
*-----------------------------------------------------------------*/
+
L_tmp = Dot_product( b_fx, aux_fx, n_pred ); /*Q25*/
L_tmp = Mult_32_16( L_tmp, 27213 ); /* *3.321928 in Q13 -> Q23 */
L_tmp = L_shr( L_tmp, 7 ); /* From Q23 to Q16 */
@@ -848,6 +746,7 @@ void gain_dec_lbr_fx(
* gcode0 = pow(10.0, dotp(b, aux, n_pred)
* = pow(2, 3.321928*dotp(b, aux, n_pred)
*-----------------------------------------------------------------*/
+
L_tmp = Dot_product( b_fx, aux_fx, n_pred ); /*Q25*/
L_tmp = Mult_32_16( L_tmp, 27213 ); /* *3.321928 in Q13 -> Q23 */
L_tmp = L_shr( L_tmp, 7 ); /* From Q23 to Q16 */
@@ -879,7 +778,6 @@ void gain_dec_lbr_fx(
n_pred = 8;
move16();
-
cdbk_fx = gp_gamma_4sfr_6b_fx; /*Q14*/
IF( EQ_16( nBits, 7 ) )
@@ -984,126 +882,13 @@ void gain_dec_lbr_fx(
/* _ (Word16 *) lp_gainp : LP-filtered pitch gain(FEC) Q14 */
/* _ (Word16 *) lp_gainc : LP-filtered code gain (FEC) Q3 */
/*-----------------------------------------------------------------------*/
-
/*-----------------------------------------------------------------------*/
/* RETURN ARGUMENTS : */
/* _ None */
/*=======================================================================*/
-
void lp_gain_updt_fx(
- const Word16 i_subfr, /* i : subframe number Q0 */
- const Word16 gain_pit, /* i : Decoded gain pitch Q14 */
- const Word32 norm_gain_code, /* i : Normalised gain code Q16 */
- Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */
- Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */
- const Word16 L_frame /* i : length of the frame */
-)
-{
- Word16 tmp;
-
- tmp = extract_h( L_shl_sat( norm_gain_code, 3 ) ); /*(16+3)-16 -> Q3*/
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- IF( EQ_16( i_subfr, 0 ) )
- {
- *lp_gainp = mult( 3277, gain_pit );
- move16(); /*0.1 in Q15 = 3277 , (15+14)-15 -> Q14*/
- *lp_gainc = mult_r( 3277, tmp );
- move16(); /* (15+3)-15 -> Q3*/
- }
- ELSE IF( EQ_16( i_subfr, L_SUBFR ) )
- {
- *lp_gainp = add( *lp_gainp, mult( 6554, gain_pit ) );
- move16(); /*Q14 (0.2 in Q15 = 6554)*/
- *lp_gainc = mac_r( L_deposit_h( *lp_gainc ), 6554, tmp );
- move16(); /*Q3*/
- }
- ELSE IF( EQ_16( i_subfr, 2 * L_SUBFR ) )
- {
- *lp_gainp = add( *lp_gainp, mult( 9830, gain_pit ) );
- move16(); /*Q14 (0.3 in Q15 = 9830)*/
- *lp_gainc = mac_r( L_deposit_h( *lp_gainc ), 9830, tmp );
- move16(); /*Q3*/
- }
- ELSE /* i_subfr == 3*L_SUBFR */
- {
- *lp_gainp = add( *lp_gainp, mult( 13107, gain_pit ) );
- move16(); /*Q14 (0.4 in Q15 = 13107)*/
- *lp_gainc = mac_r_sat( L_deposit_h( *lp_gainc ), 13107, tmp );
- move16(); /*Q3*/
- }
- }
- ELSE
- {
- IF( i_subfr == 0 )
- {
- *lp_gainp = mult( 2185, gain_pit );
- move16(); /*(1.0/15.0) in Q15 = 2185 , (15+14)-15 -> Q14*/
- *lp_gainc = mult_r( 2185, tmp );
- move16(); /* (15+3)-15 -> Q3*/
- }
- ELSE IF( EQ_16( i_subfr, L_SUBFR ) )
- {
- *lp_gainp = add( *lp_gainp, mult( 4369, gain_pit ) );
- move16(); /*Q14 (2.0/15.0 in Q15 = 4369)*/
- *lp_gainc = mac_r( L_deposit_h( *lp_gainc ), 4369, tmp );
- move16(); /*Q3*/
- }
- ELSE IF( EQ_16( i_subfr, 2 * L_SUBFR ) )
- {
- *lp_gainp = add( *lp_gainp, mult( 6554, gain_pit ) );
- move16(); /*Q14 (3.0/15.0 in Q15 = 6554)*/
- *lp_gainc = mac_r( L_deposit_h( *lp_gainc ), 6554, tmp );
- move16(); /*Q3*/
- }
- ELSE IF( EQ_16( i_subfr, 3 * L_SUBFR ) )
- {
- *lp_gainp = add( *lp_gainp, mult( 8738, gain_pit ) );
- move16(); /*Q14 (4.0/15.0 in Q15 = 8738)*/
- *lp_gainc = mac_r( L_deposit_h( *lp_gainc ), 8738, tmp );
- move16(); /*Q3*/
- }
- ELSE /* i_subfr == 4*L_SUBFR */
- {
- *lp_gainp = add( *lp_gainp, mult( 10923, gain_pit ) );
- move16(); /*Q14 (5.0/15.0 in Q15 = 10923)*/
- *lp_gainc = mac_r_sat( L_deposit_h( *lp_gainc ), 10923, tmp );
- move16(); /*Q3*/
- }
- }
- return;
-}
-
-/*====================================================================== */
-/* FUNCTION : lp_gain_updt_ivas_fx() */
-/*-----------------------------------------------------------------------*/
-/* PURPOSE : Update of LP pitch and code gains (FEC) */
-/* */
-/*-----------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word16) i_subfr : subframe number Q0 */
-/* _ (Word16) gain_pit : Decoded gain pitch Q14 */
-/* _ (Word32) norm_gain_code : Normalised gain code Q16 */
-/* _ (Word16) L_frame : length of the frame Q0 */
-/*-----------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16 *) T0 : close loop integer pitch */
-/* _ (Word16 *) T0_frac : close loop fractional part of the pitch */
-/* _ (Word16 ) pitch : pitch value Q6 */
-/*-----------------------------------------------------------------------*/
-/* INPUT OUTPUT ARGUMENTS */
-/* _ (Word16 *) lp_gainp : LP-filtered pitch gain(FEC) Q14 */
-/* _ (Word16 *) lp_gainc : LP-filtered code gain (FEC) Q3 */
-/*-----------------------------------------------------------------------*/
-
-/*-----------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*=======================================================================*/
-
-
-void lp_gain_updt_ivas_fx(
+ const Word16 element_mode, /* i : element mode */
const Word16 i_subfr, /* i : subframe number Q0 */
const Word16 gain_pit, /* i : Decoded gain pitch Q14 */
const Word32 norm_gain_code, /* i : Normalised gain code Q16 */
@@ -1117,7 +902,8 @@ void lp_gain_updt_ivas_fx(
tmp = extract_h( L_shl_sat( norm_gain_code, 3 ) ); /*(16+3)-16 -> Q3*/
/* To handle extremely low values */
test();
- if ( norm_gain_code != 0 && tmp == 0 )
+ test();
+ if ( element_mode != EVS_MONO && norm_gain_code != 0 && tmp == 0 )
{
tmp = 1;
move16();
@@ -1195,7 +981,8 @@ void lp_gain_updt_ivas_fx(
/* To handle extremely low values */
test();
- if ( tmp != 0 && *lp_gainc == 0 )
+ test();
+ if ( element_mode != EVS_MONO && tmp != 0 && *lp_gainc == 0 )
{
*lp_gainc = 1;
move16();
@@ -1245,6 +1032,7 @@ Word32 gain_dec_gaus_fx(
L_enr_q = L_mult( index, stepSize ); /* Q0 * QstepSize_Exp -> QstepSize_Exp+1 */
L_enr_q = L_shl( L_enr_q, sub( 24 - 1, stepSize_Exp ) ); /* QstepSize_Exp+1 -> Q24 */
L_enr_q = L_add( L_enr_q, L_shl( L_deposit_h( lowBound ), 8 ) ); /* Q24 */
+
/*------------------------------------------------------------*
* gain = pow(10.0, enr/20)
* = pow(2, 3.321928*enr/20)
@@ -1384,7 +1172,7 @@ void gain_dec_SQ_fx(
*---------------------------------------------------------------------*/
void gain_dec_amr_wb_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
+ Decoder_State *st_fx, /* i/o: decoder state structure */
const Word32 core_brate, /* i : core bitrate */
Word16 *gain_pit, /* o : Quantized pitch gain Q14*/
Word32 *gain_code, /* o : Quantized codeebook gain Q16*/
@@ -1402,7 +1190,6 @@ void gain_dec_amr_wb_fx(
Word32 L_tmp;
Word16 expg, exp_gcode0, fracg;
-
/**gain_inov = 1.0f/ (float)sqrt( ( dotp( code, code, L_SUBFR ) + 0.01f ) / L_SUBFR );*/
L_tmp = Dot_product12( code, code, L_SUBFR, &expg ); /*Q31 - expg*/
@@ -1415,6 +1202,7 @@ void gain_dec_amr_wb_fx(
/*-----------------------------------------------------------------*
* Select the gain quantization table
*-----------------------------------------------------------------*/
+
nbits = 7;
move16();
t_qua_gain = t_qua_gain7b_fx;
@@ -1451,6 +1239,7 @@ void gain_dec_amr_wb_fx(
* = pow(2, 3.321928*gcode0/20)
* = pow(2, 0.166096*gcode0)
*-----------------------------------------------------------------*/
+
L_tmp = L_mult( gcode0, 21771 ); /* *0.166096 in Q17 -> Q27 */
L_tmp = L_shr( L_tmp, 9 + 2 ); /* From Q27 to Q16 */
L_Extract( L_tmp, &exp_gcode0, &fracg ); /* Extract exponent of gcode0 */
@@ -1473,6 +1262,7 @@ void gain_dec_amr_wb_fx(
/*-----------------------------------------------------------------*
* Decode code gain
*-----------------------------------------------------------------*/
+
qua_en = t_qua_gain[( index2 + 1 )];
move16();
@@ -1496,12 +1286,14 @@ void gain_dec_amr_wb_fx(
past_qua_en[i] = past_qua_en[i - 1];
move16();
}
+
/*past_qua_en[0] = (float)(20.0*log10(qua_en));*/
/*----------------------------------------------------------*
* past_qua_en[0] = 20*log10(t_qua_gain[indice*2+1])
* = 6.0206*log2(t_qua_gain[indice*2+1])
* = 6.0206*(log2(t_qua_gain[indice*2+1]Q11 -11)
*----------------------------------------------------------*/
+
tmp = norm_l( qua_en );
fracg = Log2_norm_lc( L_shl( qua_en, tmp ) );
expg = sub( 30, tmp );
@@ -1515,6 +1307,7 @@ void gain_dec_amr_wb_fx(
/*-----------------------------------------------------------------*
* Normalized code gain
*-----------------------------------------------------------------*/
+
/**norm_gain_code = *gain_code / *gain_inov;*/
expg = sub( norm_s( *gain_inov ), 1 );
expg = s_max( expg, 0 );
diff --git a/lib_dec/gaus_dec_fx.c b/lib_dec/gaus_dec_fx.c
index d49ecb5b7a90acfa8ff9ef6503a90004bfe22adc..0d38c40bcae3b2bb344d92d0a21cb4c379361fca 100644
--- a/lib_dec/gaus_dec_fx.c
+++ b/lib_dec/gaus_dec_fx.c
@@ -87,14 +87,7 @@ void gaus_dec_fx(
move32();
/* update LP filtered gains for the case of frame erasures */
- IF( st_fx->element_mode == EVS_MONO )
- {
- lp_gain_updt_fx( i_subfr, 0, *L_norm_gain_code, lp_gainp, lp_gainc, L_FRAME ); /* supposes that gain_dec_gaus() is used for ACELP@12k8 only */
- }
- ELSE
- {
- lp_gain_updt_ivas_fx( i_subfr, 0, *L_norm_gain_code, lp_gainp, lp_gainc, L_FRAME ); /* supposes that gain_dec_gaus() is used for ACELP@12k8 only */
- }
+ lp_gain_updt_fx( st_fx->element_mode, i_subfr, 0, *L_norm_gain_code, lp_gainp, lp_gainc, L_FRAME ); /* supposes that gain_dec_gaus() is used for ACELP@12k8 only */
/*------------------------------------------------------------------------------------------*
* Updates
diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c
index 5564dc1b8176c177c0076abf7362b40c43a02a26..a314bb232a5fe452b27616d7cf343ee1edbd92f1 100644
--- a/lib_dec/gs_dec_fx.c
+++ b/lib_dec/gs_dec_fx.c
@@ -241,6 +241,7 @@ void decod_audio_fx(
nbits = 4; /* Q0 */
move16();
}
+
test();
IF( LT_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->coder_type != INACTIVE )
{
@@ -276,6 +277,7 @@ void decod_audio_fx(
Diff_len = mfreq_loc_div_25[pit_band_idx]; /* Q0 */
move16();
}
+
hGSCDec->Last_GSC_pit_band_idx = pit_band_idx; /* Q0 */
move16();
@@ -283,11 +285,13 @@ void decod_audio_fx(
* Decode adaptive (pitch) excitation contribution
* Reset unvaluable part of the adaptive (pitch) excitation contribution
*--------------------------------------------------------------------------------------*/
+
IF( GT_16( pit_band_idx, BAND1k2 ) )
{
/*---------------------------------------------------------------*
* Decode adaptive (pitch) excitation contribution
*---------------------------------------------------------------*/
+
test();
test();
test();
@@ -351,6 +355,7 @@ void decod_audio_fx(
/*---------------------------------------------------------------*
* DCT transform
*---------------------------------------------------------------*/
+
edct_16fx( exc, dct_epit, st_fx->L_frame, 7, st_fx->element_mode );
/*---------------------------------------------------------------*
@@ -469,7 +474,6 @@ void decod_audio_fx(
}
}
-
Word16 Q_exc_old = st_fx->Q_exc;
move16();
gsc_dec_fx( st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, &st_fx->Q_exc );
@@ -486,17 +490,23 @@ void decod_audio_fx(
Scale_sig( bwe_exc - PIT16k_MAX * 2, ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2, Q_exc_old ); /* Q_exc_old */
}
}
+
/*--------------------------------------------------------------------------------------*
* iDCT transform
*--------------------------------------------------------------------------------------*/
edct_16fx( dct_epit, exc, st_fx->L_frame, 7, st_fx->element_mode );
edct_16fx( exc_wo_nf, exc_wo_nf, st_fx->L_frame, 7, st_fx->element_mode );
+
/*----------------------------------------------------------------------*
* Remove potential pre-echo in case an onset has been detected
*----------------------------------------------------------------------*/
+#ifdef FIX_1904_HARM_GSC_ENC
+ pre_echo_att_fx( &hGSCDec->Last_frame_ener_fx, exc, gsc_attack_flag, st_fx->Q_exc, st_fx->last_coder_type, st_fx->L_frame, 0 );
+#else
pre_echo_att_fx( &hGSCDec->Last_frame_ener_fx, exc, gsc_attack_flag, st_fx->Q_exc, st_fx->last_coder_type, st_fx->L_frame );
+#endif
/*--------------------------------------------------------------------------------------*
* Update BWE excitation
@@ -530,6 +540,7 @@ void decod_audio_fx(
return;
}
+
/*==========================================================================*/
/* FUNCTION : void gsc_dec_fx () */
/*--------------------------------------------------------------------------*/
@@ -595,6 +606,7 @@ void gsc_dec_fx(
/*--------------------------------------------------------------------------------------*
* Initialization
*--------------------------------------------------------------------------------------*/
+
bit = bits_used;
move16();
@@ -655,14 +667,7 @@ void gsc_dec_fx(
i--;
}
- IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
- {
- mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */
- }
- ELSE
- {
- mean_gain = gsc_gaindec_ivas_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */
- }
+ mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */
st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */
move16();
@@ -849,10 +854,17 @@ void gsc_dec_fx(
* Estimate noise level
*--------------------------------------------------------------------------------------*/
+#ifdef FIX_1904_HARM_GSC_ENC
+ highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, *last_bin, Diff_len, hGSCDec->noise_lev, pit_band_idx, exc_diffQ,
+ &hGSCDec->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new,
+ hGSCDec->last_exc_dct_in_fx, &hGSCDec->last_ener_fx, hGSCDec->last_bitallocation_band, bitallocation_exc, st_fx->bfi, coder_type,
+ st_fx->bwidth, exc_wo_nf, Qexc_diffQ, Q_exc, st_fx->GSC_noisy_speech, hGSCDec->lt_ener_per_band_fx, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode );
+#else
highband_exc_dct_in_ivas_fx( st_fx->core_brate, mfreq_bindiv_loc, *last_bin, Diff_len, hGSCDec->noise_lev, pit_band_idx, exc_diffQ,
&hGSCDec->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new,
hGSCDec->last_exc_dct_in_fx, &hGSCDec->last_ener_fx, hGSCDec->last_bitallocation_band, bitallocation_exc, st_fx->bfi, coder_type,
st_fx->bwidth, exc_wo_nf, Qexc_diffQ, Q_exc, st_fx->GSC_noisy_speech, hGSCDec->lt_ener_per_band_fx, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode );
+#endif
exc_dct_in[0] = 0;
move16();
@@ -860,6 +872,7 @@ void gsc_dec_fx(
return;
}
+
/*-------------------------------------------------------------------*
* GSC_dec_init()
*
@@ -891,5 +904,6 @@ void GSC_dec_init_fx(
hGSCDec->Last_frame_ener_fx = MAX_32;
move32();
+
return;
}
diff --git a/lib_dec/hf_synth_fx.c b/lib_dec/hf_synth_fx.c
index 87e8b1fd7b813b8716bb15d9306a870631495ebf..153b760804e41756ed7400e9d6731de8e8332579 100644
--- a/lib_dec/hf_synth_fx.c
+++ b/lib_dec/hf_synth_fx.c
@@ -20,8 +20,7 @@
*---------------------------------------------------------------------*/
static void filt_6k_7k_scale_fx( Word16 signal[], Word16 lg, Word16 mem[], Word16 fact, Word16 exp );
-static void hf_synthesis_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, const Word32 core_brate, const Word16 output_subfr, const Word16 Aq[], const Word16 exc[], const Word16 Q_exc, Word16 synth[], Word16 synth16k[], const Word16 Q_syn );
-static void hf_synthesis_ivas_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, const Word32 core_brate, const Word16 output_subfr, const Word16 Aq[], const Word16 exc[], const Word16 Q_exc, Word16 synth[], Word16 synth16k[], const Word16 Q_syn );
+static void hf_synthesis_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, const Word16 element_mode, const Word32 core_brate, const Word16 output_subfr, const Word16 Aq[], const Word16 exc[], const Word16 Q_exc, Word16 synth[], Word16 synth16k[], const Word16 Q_syn );
static void hf_synthesis_amr_wb_fx( const Word32 core_brate, const Word16 output_subfr, const Word16 Ap[], Word16 exc16k[], Word16 synth_out[], Word16 *mem_syn_hf, Word16 *delay_syn_hf, Word16 *mem_hp_interp, Word16 p_r, Word16 HF_corr_gain, Word16 til, Word16 voice_factors, const Word16 exc[], const Word16 Q_exc, const Word16 Q_out, Word16 qhf );
static void envelope_fx( AMRWB_IO_DEC_HANDLE hAmrwb_IO, const Word32 core_brate, const Word16 Aq[], Word16 Ap[], Word16 *r, Word16 tilt0, Word16 tilt, Word16 voice_factor );
static void AdaptiveStartBand_fx( Word16 *start_band, const Word32 rate, const Word16 *lsf, const Word16 voicing_fac, const Word16 clas, Word16 *voicing_flag, Word16 *start_band_old, Word32 *OptCrit_old );
@@ -80,14 +79,15 @@ void hf_synth_reset_fx(
void hf_synth_fx(
ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */
+ const Word16 element_mode, /* i : element mode Q0*/
const Word32 core_brate, /* i : core bitrate Q0*/
const Word16 output_frame, /* i : output frame length Q0*/
const Word16 *Aq, /* i : quantized Az Q12*/
const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/
Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/
Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/
- const Word16 Q_exc, /* i : excitation scaling */
- const Word16 Q_syn2 /* i : synthesis scaling */
+ const Word16 Q_exc, /* i : excitation scaling */
+ const Word16 Q_syn2 /* i : synthesis scaling */
)
{
const Word16 *p_Aq;
@@ -99,8 +99,7 @@ void hf_synth_fx(
p_Aq = Aq; /* Q12 */
FOR( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR )
{
- hf_synthesis_fx( hBWE_zero, core_brate, output_subfr, p_Aq, &exc[i_subfr], Q_exc, &synth[i_subfr], &synth16k[imult3216( (Word32) i_subfr, output_subfr ) / L_SUBFR], Q_syn2 );
-
+ hf_synthesis_fx( hBWE_zero, element_mode, core_brate, output_subfr, p_Aq, &exc[i_subfr], Q_exc, &synth[i_subfr], &synth16k[i_subfr * output_subfr / L_SUBFR], Q_syn2 );
p_Aq += ( M + 1 ); /* Q12 */
}
@@ -120,6 +119,7 @@ void hf_synth_fx(
static void hf_synthesis_fx(
ZERO_BWE_DEC_HANDLE hBWE_zero,
+ const Word16 element_mode, /* i : element mode Q0*/
const Word32 core_brate, /* i : core bitrate Q0*/
const Word16 output_subfr, /* i : output sub-frame length Q0*/
const Word16 Aq[], /* i : quantized Az Q12*/
@@ -135,6 +135,9 @@ static void hf_synthesis_fx(
Word16 HF_exc[L_SUBFR16k];
Word16 tmp, ener, exp1, exp2, scale;
Word32 L_tmp;
+ Word16 Q_tmp, Q_ener, sft;
+ Word32 ONE, P_ONE;
+ Word64 prod;
Word16 Ap[M16k + 1];
/*-----------------------------------------------------------------*
@@ -157,280 +160,148 @@ static void hf_synthesis_fx(
/*tmp = round_fx(Dot_product12(HF_exc, HF_exc, output_subfr, &exp1)); */
L_tmp = Dot_product12( HF_exc, HF_exc, L_SUBFR16k, &exp1 );
tmp = round_fx( L_tmp ); /* Q15 */
- /* tmp = (float)(sqrt(ener/tmp)) */
- /* scale is -1 if tmp > ener */
- scale = shr( sub( ener, tmp ), 15 ); /* Q0 */
- tmp = shl( tmp, scale ); /* Q15 + scale*/
- exp1 = sub( exp1, scale );
-
- tmp = div_s( tmp, ener ); /* Q15 */
- exp1 = sub( exp1, exp2 );
-
- L_tmp = L_deposit_h( tmp ); /* Q31 */
-
- L_tmp = Isqrt_lc( L_tmp, &exp1 );
- scale = round_fx( L_tmp ); /* Q18 when Q_exc=-1, HF_exc in Q-3 */
-
- exp2 = sub( hBWE_zero->memExp1, exp1 );
- hBWE_zero->memExp1 = exp1;
- move16();
-
- /*-----------------------------------------------------------------*
- * calculate energy scaling factor to respect tilt of synth12k8
- * (tilt: 1=voiced, -1=unvoiced)
- *-----------------------------------------------------------------*/
- hp400_12k8_fx( synth, L_SUBFR, hBWE_zero->mem_hp400_fx );
- /* i: mem_hp400 in Q_syn */
- /* i: synth in Q_syn */
- /* o: synth in Q_syn-3 */
- L_tmp = L_mac( 1L, synth[0], synth[0] ); /* 2*(Q_syn-3)+1 */
- FOR( i = 1; i < L_SUBFR; i++ )
+ IF( element_mode == EVS_MONO )
{
- L_tmp = L_mac_sat( L_tmp, synth[i], synth[i] ); /* 2*(Q_syn-3)+1 */
- }
- tmp = norm_l( L_tmp );
- ener = extract_h( L_shl( L_tmp, tmp ) ); /* ener = r[0] */
- /*ener in Q = 2*(Q_syn-3)+1 = Q-5 when Q_syn=0*/
+ /* tmp = (float)(sqrt(ener/tmp)) */
+ /* scale is -1 if tmp > ener */
+ scale = shr( sub( ener, tmp ), 15 ); /* Q0 */
+ tmp = shl( tmp, scale ); /* Q15 + scale*/
+ exp1 = sub( exp1, scale );
- L_tmp = L_mac( 1L, synth[1], synth[0] ); /* 2*(Q_syn-3)+1 */
- FOR( i = 2; i < L_SUBFR; i++ )
- {
- L_tmp = L_mac_sat( L_tmp, synth[i], synth[i - 1] ); /* 2*(Q_syn-3)+1 */
- }
- tmp = extract_h( L_shl( L_tmp, tmp ) ); /* tmp = r[1] */
- /*tmp in Q = 2*(Q_syn-3)+1 = Q-5 when Q_syn=0 */
- /*we use the same normalization factor for both ener and tmp, */
- /*if the headroom in "tmp" is less than "ener", tmp can saturate */
- /*but this is ok since below we apply some thresholds to tmp */
-
- tmp = s_max( 0, tmp );
- if ( tmp > 0 )
- {
tmp = div_s( tmp, ener ); /* Q15 */
- }
+ exp1 = sub( exp1, exp2 );
- /*-----------------------------------------------------------------*
- * modify energy of white noise according to synthesis tilt
- *-----------------------------------------------------------------*/
- /* tmp = 1.0 - fac */
- tmp = add_sat( 1, sub( 32767 /* 1 in Q15 */, tmp ) );
- test();
- if ( core_brate == FRAME_NO_DATA || EQ_32( core_brate, SID_2k40 ) )
- {
- /* emphasize HF noise in CNG */
- /*fac *= 2.0f;*/
- tmp = add_sat( tmp, tmp ); /* Q15 */
- }
- tmp = s_max( tmp, 3277 ); /* 0.1 in Q15 */
+ L_tmp = L_deposit_h( tmp ); /* Q31 */
- /*scale *= fac;*/
- tmp = mult_r( scale, tmp );
- /*-----------------------------------------------------------------*
- * modify HF excitation according to both calculated scaling factors
- * high pass filtering (0.94ms of delay)
- *-----------------------------------------------------------------*/
-
- filt_6k_7k_scale_fx( HF_exc, L_SUBFR16k, hBWE_zero->mem_hf_fx, tmp, exp2 );
- /* i: input HF_exc is scaled in float, here scaling is done inside this filter */
- /* i: mem_hf in Q-2 */
- /* o: HF_exc in Q0 */
+ L_tmp = Isqrt_lc( L_tmp, &exp1 );
+ scale = round_fx( L_tmp ); /* Q18 when Q_exc=-1, HF_exc in Q-3 */
- /*-----------------------------------------------------------------*
- * synthesis of noise: 4.8kHz..5.6kHz --> 6kHz..7kHz
- *-----------------------------------------------------------------*/
+ /*-----------------------------------------------------------------*
+ * calculate energy scaling factor to respect tilt of synth12k8
+ * (tilt: 1=voiced, -1=unvoiced)
+ *-----------------------------------------------------------------*/
- /*weight_a( Aq, Ap, 0.6f, M );*/
- weight_a_lc_fx( Aq, Ap, Gamma_19661_Tbl_fx, M );
- /* o: Ap in Q14 */
+ hp400_12k8_fx( synth, L_SUBFR, hBWE_zero->mem_hp400_fx );
- Syn_filt_s( 0, Ap, M, HF_exc, HF_syn, L_SUBFR16k, hBWE_zero->mem_syn_hf_fx, 1 );
- /* i: Ap in Q14 */
- /* i: HF_exc in Q0 */
- /* o: HF_syn in Q0 */
- /* i/o: mem_syn_hf in Q0 */
+ L_tmp = L_mac( 1L, synth[0], synth[0] ); /* 2*(Q_syn-3)+1 */
+ FOR( i = 1; i < L_SUBFR; i++ )
+ {
+ L_tmp = L_mac_sat( L_tmp, synth[i], synth[i] ); /* 2*(Q_syn-3)+1 */
+ }
+ tmp = norm_l( L_tmp );
+ ener = extract_h( L_shl( L_tmp, tmp ) ); /* ener = r[0] */
+ /*ener in Q = 2*(Q_syn-3)+1 = Q-5 when Q_syn=0*/
- Scale_sig( HF_syn, L_SUBFR16k, ( add( Q_syn, exp1 ) ) ); /* bring HF_syn to (Q_syn+exp1) */
+ L_tmp = L_mac( 1L, synth[1], synth[0] ); /* 2*(Q_syn-3)+1 */
+ FOR( i = 2; i < L_SUBFR; i++ )
+ {
+ L_tmp = L_mac_sat( L_tmp, synth[i], synth[i - 1] ); /* 2*(Q_syn-3)+1 */
+ }
+ tmp = extract_h( L_shl( L_tmp, tmp ) ); /* tmp = r[1] */
+ /*tmp in Q = 2*(Q_syn-3)+1 = Q-5 when Q_syn=0 */
+ /*we use the same normalization factor for both ener and tmp, */
+ /*if the headroom in "tmp" is less than "ener", tmp can saturate */
+ /*but this is ok since below we apply some thresholds to tmp */
+ tmp = s_max( 0, tmp );
+ if ( tmp > 0 )
+ {
+ tmp = div_s( tmp, ener ); /* Q15 */
+ }
- /*-----------------------------------------------------------------*
- * add filtered HF noise to speech synthesis
- *-----------------------------------------------------------------*/
+ /*-----------------------------------------------------------------*
+ * modify energy of white noise according to synthesis tilt
+ *-----------------------------------------------------------------*/
- /* delay by 5 samples @16kHz to compensate CLDFB resampling delay (20samples) and HP filtering delay (roughly 15 samples) */
- delay_signal_fx( HF_syn, L_SUBFR16k, hBWE_zero->delay_syn_hf_fx, NS2SA_FX2( 16000, DELAY_CLDFB_NS ) - 15 );
+ /* tmp = 1.0 - fac */
+ tmp = add_sat( 1, sub( 32767 /* 1 in Q15 */, tmp ) );
+ test();
+ if ( core_brate == FRAME_NO_DATA || EQ_32( core_brate, SID_2k40 ) )
+ {
+ /* emphasize HF noise in CNG */
+ /*fac *= 2.0f;*/
+ tmp = add_sat( tmp, tmp ); /* Q15 */
+ }
+ tmp = s_max( tmp, 3277 ); /* 0.1 in Q15 */
- /* interpolate the HF synthesis */
- IF( EQ_16( output_subfr, L_SUBFR48k ) ) /* 48kHz sampled output */
- {
- s = s_max( s_min( sub( s_min( Find_Max_Norm16( HF_syn, L_SUBFR16k ), Find_Max_Norm16( hBWE_zero->mem_hp_interp_fx, INTERP_3_1_MEM_LEN - 3 ) ), 3 ),
- sub( Find_Max_Norm16( hBWE_zero->mem_hp_interp_fx + INTERP_3_1_MEM_LEN - 3, 3 ), 1 ) ),
- 0 );
- Scale_sig( HF_syn, L_SUBFR16k, s ); /* Q_syn+exp1+s */
- Scale_sig( hBWE_zero->mem_hp_interp_fx, INTERP_3_1_MEM_LEN, s ); /* Qx + s */
- interpolate_3_over_1_allpass_fx( HF_syn, L_SUBFR16k, upsampled_HF_syn, hBWE_zero->mem_hp_interp_fx );
- Scale_sig( upsampled_HF_syn, 3 * L_SUBFR16k, -s ); /* Q_syn + exp1 + s */
- Scale_sig( hBWE_zero->mem_hp_interp_fx, INTERP_3_1_MEM_LEN, -s ); /* Qx */
- Scale_sig( HF_syn, L_SUBFR16k, -s ); /* Q_syn+exp1 */
- Scale_sig( upsampled_HF_syn, L_SUBFR48k, -1 );
- }
- ELSE IF( EQ_16( output_subfr, L_SUBFR32k ) ) /* 32kHz sampled output */
- {
- s = s_max( sub( s_min( Find_Max_Norm16( HF_syn, L_SUBFR16k ), Find_Max_Norm16( hBWE_zero->mem_hp_interp_fx, 2 * ALLPASSSECTIONS_STEEP ) ), 2 ), 0 );
- Scale_sig( HF_syn, L_SUBFR16k, s ); /* Q_syn+exp1+s */
- Scale_sig( hBWE_zero->mem_hp_interp_fx, 2 * ALLPASSSECTIONS_STEEP, s ); /* Qx + s */
- Interpolate_allpass_steep_fx( HF_syn, hBWE_zero->mem_hp_interp_fx, L_SUBFR16k, upsampled_HF_syn );
- Scale_sig( upsampled_HF_syn, 2 * L_SUBFR16k, -s ); /* Q_syn + exp1 */
- Scale_sig( hBWE_zero->mem_hp_interp_fx, 2 * ALLPASSSECTIONS_STEEP, -s ); /* Qx */
- Scale_sig( HF_syn, L_SUBFR16k, -s ); /* Q_syn+exp1 */
- }
- ELSE /* 16kHz sampled output */
- {
- Copy( HF_syn, upsampled_HF_syn, L_SUBFR16k ); /* Q_syn */
+ /*scale *= fac;*/
+ tmp = mult_r( scale, tmp );
}
- Vr_add( synth16k, upsampled_HF_syn, synth16k, output_subfr );
-
- return;
-}
-
-void hf_synth_ivas_fx(
- ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */
- const Word32 core_brate, /* i : core bitrate Q0*/
- const Word16 output_frame, /* i : output frame length Q0*/
- const Word16 *Aq, /* i : quantized Az Q12*/
- const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/
- Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/
- Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/
- const Word16 Q_exc, /* i : excitation scaling */
- const Word16 Q_syn2 /* i : synthesis scaling */
-)
-{
- const Word16 *p_Aq;
- Word16 i_subfr, output_subfr;
-
- output_subfr = shr( output_frame, 2 );
-
- p_Aq = Aq; /* Q12 */
- FOR( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR )
+ ELSE
{
- hf_synthesis_ivas_fx( hBWE_zero, core_brate, output_subfr, p_Aq, &exc[i_subfr], Q_exc, &synth[i_subfr], &synth16k[i_subfr * output_subfr / L_SUBFR], Q_syn2 );
-
- p_Aq += ( M + 1 ); /* Q12 */
- }
-
- return;
-}
-
-static void hf_synthesis_ivas_fx(
- ZERO_BWE_DEC_HANDLE hBWE_zero,
- const Word32 core_brate, /* i : core bitrate Q0*/
- const Word16 output_subfr, /* i : output sub-frame length Q0*/
- const Word16 Aq[], /* i : quantized Az Q12*/
- const Word16 exc[], /* i : excitation at 12.8 kHz Q_exc*/
- const Word16 Q_exc, /* i : excitation scaling */
- Word16 synth[], /* i : 12.8kHz synthesis signal Q_syn*/
- Word16 synth16k[], /* i/o: 16kHz synthesis signal Q_syn*/
- const Word16 Q_syn /* i : synthesis scaling */
-)
-{
- Word16 i, s;
- Word16 HF_syn[L_SUBFR16k], upsampled_HF_syn[L_FRAME48k / NB_SUBFR];
- Word16 HF_exc[L_SUBFR16k];
- Word16 exp1, exp2, scale, tmp, ener, Q_tmp, Q_ener, sft;
- Word32 L_tmp, ONE, P_ONE;
- Word16 Ap[M16k + 1];
- Word64 prod;
+ exp1 = add( exp1, 6 ); /* tmp exponent */
- /*-----------------------------------------------------------------*
- * generate white noise vector
- *-----------------------------------------------------------------*/
+ ener = shr( ener, 1 ); /* to avoid the assertion in div_s() further*/
+ exp2 = add( exp2, 1 );
- Random_Fill( &hBWE_zero->seed2, L_SUBFR16k, HF_exc, 3 ); /* 3 = Shift Right by 3 */
+ tmp = div_s( ener, tmp );
+ exp1 = sub( exp2, exp1 );
- /* o: HF_exc in Q(-3) */
+ scale = Sqrt16( tmp, &exp1 ); /* scale exponent = exp1 */
- /*-----------------------------------------------------------------*
- * calculate energy scaling factor so that white noise would have the
- * same energy as exc12k8
- *-----------------------------------------------------------------*/
-
- /*ener = sum2_f( exc, L_SUBFR ) + 0.01f*/
- ener = extract_h( Dot_product12( exc, exc, L_SUBFR, &exp2 ) );
- exp2 = sub( exp2, add( Q_exc, Q_exc ) ); // ener exponent
+ /*-----------------------------------------------------------------*
+ * calculate energy scaling factor to respect tilt of synth12k8
+ * (tilt: 1=voiced, -1=unvoiced)
+ *-----------------------------------------------------------------*/
- /*tmp = round_fx(Dot_product12(HF_exc, HF_exc, output_subfr, &exp1)); */
- L_tmp = Dot_product12( HF_exc, HF_exc, L_SUBFR16k, &exp1 );
- tmp = round_fx( L_tmp );
- exp1 = add( exp1, 6 ); /* tmp exponent */
+ hp400_12k8_ivas_fx( synth, L_SUBFR, hBWE_zero->mem_hp400_fx );
- ener = shr( ener, 1 ); /* to avoid the assertion in div_s() further*/
- exp2 = add( exp2, 1 );
-
- tmp = div_s( ener, tmp );
- exp1 = sub( exp2, exp1 );
-
- scale = Sqrt16( tmp, &exp1 ); /* scale exponent = exp1 */
+ /* i: mem_hp400 in Q_syn */
+ /* i: synth in Q_syn */
+ /* o: synth in Q_syn-3 */
+ prod = W_mac0_16_16( 1L, synth[0], synth[0] ); /* 2*(Q_syn-3) */
+ FOR( i = 1; i < L_SUBFR; i++ )
+ {
+ prod = W_mac0_16_16( prod, synth[i], synth[i] ); /* 2*(Q_syn-3) */
+ }
+ sft = W_norm( prod );
+ ener = extract_h( W_extract_h( W_shl( prod, sft ) ) );
+ Q_ener = sub( add( shl( sub( Q_syn, 3 ), 1 ), sft ), 48 );
- /*-----------------------------------------------------------------*
- * calculate energy scaling factor to respect tilt of synth12k8
- * (tilt: 1=voiced, -1=unvoiced)
- *-----------------------------------------------------------------*/
+ prod = W_mac0_16_16( 1L, synth[1], synth[0] ); /* 2*(Q_syn-3) */
+ FOR( i = 2; i < L_SUBFR; i++ )
+ {
+ prod = W_mac0_16_16( prod, synth[i], synth[i - 1] ); /* 2*(Q_syn-3) */
+ }
+ sft = sub( W_norm( prod ), 1 );
+ tmp = extract_h( W_extract_h( W_shl( prod, sft ) ) );
+ Q_tmp = sub( add( shl( sub( Q_syn, 3 ), 1 ), sft ), 48 );
- hp400_12k8_ivas_fx( synth, L_SUBFR, hBWE_zero->mem_hp400_fx );
+ tmp = s_max( 0, tmp );
+ IF( tmp > 0 )
+ {
+ tmp = div_s( tmp, ener );
+ Q_tmp = add( 15, sub( Q_tmp, Q_ener ) );
+ }
- /* i: mem_hp400 in Q_syn */
- /* i: synth in Q_syn */
- /* o: synth in Q_syn-3 */
- prod = W_mac0_16_16( 1L, synth[0], synth[0] ); /* 2*(Q_syn-3) */
- FOR( i = 1; i < L_SUBFR; i++ )
- {
- prod = W_mac0_16_16( prod, synth[i], synth[i] ); /* 2*(Q_syn-3) */
- }
- sft = W_norm( prod );
- ener = extract_h( W_extract_h( W_shl( prod, sft ) ) );
- Q_ener = sub( add( shl( sub( Q_syn, 3 ), 1 ), sft ), 48 );
+ /*-----------------------------------------------------------------*
+ * modify energy of white noise according to synthesis tilt
+ *-----------------------------------------------------------------*/
+ /* tmp = 1.0 - fac */
+ ONE = L_shl( 1, Q_tmp );
+ P_ONE = L_shl( 3277 /* 0.1 in Q15 */, sub( Q_tmp, 15 ) );
+ L_tmp = L_msu0( ONE, tmp, 1 );
+ test();
+ if ( core_brate == FRAME_NO_DATA || EQ_32( core_brate, SID_2k40 ) )
+ {
+ /* emphasize HF noise in CNG */
+ /*fac *= 2.0f;*/
+ L_tmp = L_add( L_tmp, L_tmp );
+ }
+ L_tmp = L_max( L_tmp, P_ONE );
+ L_tmp = L_min( L_tmp, ONE );
- prod = W_mac0_16_16( 1L, synth[1], synth[0] ); /* 2*(Q_syn-3) */
- FOR( i = 2; i < L_SUBFR; i++ )
- {
- prod = W_mac0_16_16( prod, synth[i], synth[i - 1] ); /* 2*(Q_syn-3) */
- }
- sft = sub( W_norm( prod ), 1 );
- tmp = extract_h( W_extract_h( W_shl( prod, sft ) ) );
- Q_tmp = sub( add( shl( sub( Q_syn, 3 ), 1 ), sft ), 48 );
+ sft = norm_l( L_tmp );
+ L_tmp = L_shl( L_tmp, sft );
- tmp = s_max( 0, tmp );
- IF( tmp > 0 )
- {
- tmp = div_s( tmp, ener );
- Q_tmp = add( 15, sub( Q_tmp, Q_ener ) );
- }
+ tmp = round_fx( L_tmp );
+ Q_tmp = sub( add( Q_tmp, sft ), 16 );
- /*-----------------------------------------------------------------*
- * modify energy of white noise according to synthesis tilt
- *-----------------------------------------------------------------*/
- /* tmp = 1.0 - fac */
- ONE = L_shl( 1, Q_tmp );
- P_ONE = L_shl( 3277 /* 0.1 in Q15 */, sub( Q_tmp, 15 ) );
- L_tmp = L_msu0( ONE, tmp, 1 );
- test();
- if ( core_brate == FRAME_NO_DATA || EQ_32( core_brate, SID_2k40 ) )
- {
- /* emphasize HF noise in CNG */
- /*fac *= 2.0f;*/
- L_tmp = L_add( L_tmp, L_tmp );
+ /*scale *= fac;*/
+ tmp = mult_r( scale, tmp ); /* Q = (15 - exp1) + Q_tmp - 15 */
+ Q_tmp = sub( Q_tmp, exp1 );
}
- L_tmp = L_max( L_tmp, P_ONE );
- L_tmp = L_min( L_tmp, ONE );
- sft = norm_l( L_tmp );
- L_tmp = L_shl( L_tmp, sft );
-
- tmp = round_fx( L_tmp );
- Q_tmp = sub( add( Q_tmp, sft ), 16 );
-
- /*scale *= fac;*/
- tmp = mult_r( scale, tmp ); /* Q = (15 - exp1) + Q_tmp - 15 */
- Q_tmp = sub( Q_tmp, exp1 );
/*-----------------------------------------------------------------*
* modify HF excitation according to both calculated scaling factors
* high pass filtering (0.94ms of delay)
@@ -441,21 +312,17 @@ static void hf_synthesis_ivas_fx(
move16();
filt_6k_7k_scale_fx( HF_exc, L_SUBFR16k, hBWE_zero->mem_hf_fx, tmp, exp2 );
- /* i: HF_exc in Q(-3) */
- /* o: HF_exc in ((-3) + Q_tmp - 17) */
- /* o: hBWE_zero->mem_hf_fx in Q(HF_exc)-2 */
+ /* i: input HF_exc is scaled in float, here scaling is done inside this filter */
+ /* i: mem_hf in Q-2 */
+ /* o: HF_exc in Q0 */
/*-----------------------------------------------------------------*
* synthesis of noise: 4.8kHz..5.6kHz --> 6kHz..7kHz
*-----------------------------------------------------------------*/
- /*weight_a( Aq, Ap, 0.6f, M );*/
weight_a_lc_fx( Aq, Ap, Gamma_19661_Tbl_fx, M );
- /* o: Ap in Q14 */
Syn_filt_s( 0, Ap, M, HF_exc, HF_syn, L_SUBFR16k, hBWE_zero->mem_syn_hf_fx, 1 );
- /* o: HF_syn in same Q as HF_exc */
- /* o: mem_syn_hf_fx same Q as HF_syn */
Scale_sig( HF_syn, L_SUBFR16k, ( add( Q_syn, exp1 ) ) ); /* bring HF_syn to (Q_syn+exp1) */
@@ -494,11 +361,13 @@ static void hf_synthesis_ivas_fx(
{
Copy( HF_syn, upsampled_HF_syn, L_SUBFR16k ); /* Q_syn */
}
+
Vr_add( synth16k, upsampled_HF_syn, synth16k, output_subfr );
return;
}
+
/*-------------------------------------------------------------------*
* filt_6k_7k:
*
@@ -508,6 +377,7 @@ static void hf_synthesis_ivas_fx(
* dB loss: -60dB -45dB -13dB -3dB 0dB -3dB -13dB -45dB
* (gain=4.0)
*-------------------------------------------------------------------*/
+
static void filt_6k_7k_scale_fx(
Word16 signal[], /* i/o: signal Qx*/
Word16 lg, /* i : length of input Q0*/
@@ -539,9 +409,13 @@ static void filt_6k_7k_scale_fx(
signal[i] = round_fx_sat( L_tmp ); /* Q0 */
move16();
}
+
Copy( x + lg, mem, L_FIR - 1 ); /* Qx - 2 */
+
+ return;
}
+
/*-------------------------------------------------------------------*
* hf_synth_amr_wb_init()
*
@@ -578,7 +452,7 @@ void hf_synth_amr_wb_init_fx(
move16();
hAmrwb_IO->OptCrit_old_fx = 32768;
move32(); /*1.0f in Q15*/
- ;
+
return;
}
@@ -589,6 +463,7 @@ void hf_synth_amr_wb_init_fx(
* reset of HF synthesis filters
* - needed in switching scenarios
*-------------------------------------------------------------------*/
+
void hf_synth_amr_wb_reset_fx(
ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */
AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */
@@ -634,6 +509,7 @@ void hf_synth_amr_wb_reset_fx(
return;
}
+
/*-------------------------------------------------------------------*
* hf_synth_amr_wb()
*
@@ -641,8 +517,8 @@ void hf_synth_amr_wb_reset_fx(
*-------------------------------------------------------------------*/
void hf_synth_amr_wb_fx(
- AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle */
- ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */
+ AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle */
+ ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */
const Word32 core_brate, /* i : core bitrate Q0*/
const Word16 output_frame, /* i : output frame length Q0*/
const Word16 *Aq, /* i : quantized Az : Q12*/
@@ -883,7 +759,6 @@ void hf_synth_amr_wb_fx(
tmp = sub( 18022 /* 1.1f in Q14 */, tmp ); /*Q14 */
fmerit_w = round_fx( L_shl( L_mult( fmerit_w, tmp ), 1 ) ); /*Q: 14+14+1+1-16 = 14 */
-
L_tmp = L_deposit_l( fmerit_w ); /*Q14 */
L_tmp = Isqrt( L_tmp ); /*Q(31-7) */
tmp = round_fx( L_tmp ); /*Q8 */
@@ -1201,6 +1076,8 @@ void hf_synth_amr_wb_fx(
return;
}
+
+
static void hf_synthesis_amr_wb_fx(
const Word32 core_brate, /* i : core bitrate : Q0*/
const Word16 output_subfr, /* i : output sub-frame length : Q0*/
@@ -1226,6 +1103,7 @@ static void hf_synthesis_amr_wb_fx(
Word32 L_tmp;
Word16 q1, q2, q3, shift;
Word16 *pt1, *pt2, flag;
+
IF( EQ_32( core_brate, ACELP_23k85 ) )
{
ener = dot_prod_satcontr( exc, exc, Q_exc, Q_exc, &q1, L_SUBFR );
@@ -1361,6 +1239,7 @@ static void hf_synthesis_amr_wb_fx(
return;
}
+
static Word16 EnhanceClass_fx(
const Word16 qq_fx, /* Qx */
const Word16 pp_fx, /* Qx */
@@ -1423,10 +1302,12 @@ static Word16 EnhanceClass_fx(
*unvoicing_flag = 0;
move16();
}
+
test();
return ( *unvoicing_flag && GT_16( qq_fx, pp_fx ) );
}
+
static void envelope_fx(
AMRWB_IO_DEC_HANDLE hAmrwb_IO,
const Word32 core_brate, /* i : core bitrate Q0*/
@@ -1450,7 +1331,6 @@ static void envelope_fx(
const Word16 *pt2, *pt3;
Word16 Aq[M + 1];
-
/* Aq has dynamic scaling
go back to Q12 to make sure there's no overflow while calculating qx,qy*/
shift = sub( norm_s( Aq_dyn_scal[0] ), 2 );
@@ -1644,7 +1524,6 @@ static void envelope_fx(
}
qy = round_fx( L_shr( L_tmp, 1 ) ); /*Q(10+q1)*/
-
L_tmp = L_mult( qx, qx ); /* Q21 + 2q1 */
L_tmp = L_mac( L_tmp, qy, qy ); /* Q21 + 2q1 */
qq = round_fx( Isqrt( L_shr( L_tmp, add( 11, shl( q1, 1 ) ) ) ) ); /*Q10*/
@@ -1711,16 +1590,17 @@ static void envelope_fx(
rr = s_min( est_level1, est_level2 );
}
-
q1 = norm_s( pp );
tmp = div_s( shl( 1, sub( 14, q1 ) ), pp ); /*Q(29-q1-10) */
L_tmp = L_mult( rr, tmp ); /*Q(30-q1-10+10) */
*sub_gain = s_min( 20480 /* 5.0f in Q12 */, round_fx_sat( L_shl_sat( L_tmp, sub( q1, 2 ) ) ) ); /*Q12 */
move16();
+
return;
}
+
/*---------------------------------------------------------------------*
* AdaptiveStartBand_fx()
*
diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c
index 6be36bd1ac5cd96048cfda606148eb5f02ac6e29..e34527da088bf6dae44a94234ce3aa1b7715c0e2 100644
--- a/lib_dec/hq_core_dec_fx.c
+++ b/lib_dec/hq_core_dec_fx.c
@@ -484,15 +484,13 @@ void ivas_hq_core_dec_fx(
Word32 normq_fx[NB_SFM];
Word16 mean_en_high_fx;
Word16 SWB_fenv_fx[SWB_FENV + DIM_FB];
- const Word16 *sfmsize, *sfm_start, *sfm_end;
Word16 gapsynth_fx[L_FRAME48k];
Word16 tmp, tmp_loop;
Word32 L_tmp;
UWord16 lsb;
Word16 L_spec;
- HQ_NBFEC_HANDLE hHQ_nbfec;
HQ_DEC_HANDLE hHQ_core;
- hHQ_nbfec = st_fx->hHQ_nbfec;
+
hHQ_core = st_fx->hHQ_core;
TCX_DEC_HANDLE hTcxDec;
@@ -519,11 +517,10 @@ void ivas_hq_core_dec_fx(
set16_fx( wtda_audio_16, 0, 2 * L_FRAME48k );
mean_en_high_fx = 0;
move16();
- Q_audio = 12;
+ Q_audio = Q12;
move16();
- Q_G_audio = 12;
+ Q_G_audio = Q12;
move16();
- sfm_start = sfm_end = NULL;
num_Sb = nb_sfm = 0;
move16();
move16();
@@ -565,14 +562,7 @@ void ivas_hq_core_dec_fx(
}
ELSE
{
- core_switching_hq_prepare_dec_fx( st_fx, &num_bits, output_frame );
-
- /* During ACELP->HQ core switching, limit the HQ core bitrate to 48kbps */
- if ( GT_16( num_bits, HQ_48k / 50 ) )
- {
- num_bits = (Word16) ( HQ_48k / 50 );
- move16();
- }
+ /* this cannot happen in IVAS */
}
}
IF( hq_recovery_flag )
@@ -625,11 +615,6 @@ void ivas_hq_core_dec_fx(
}
}
- IF( EQ_16( output_frame, L_FRAME8k ) )
- {
- hq_configure_bfi_fx( &nb_sfm, &num_Sb, num_bands_p, &sfmsize, &sfm_start, &sfm_end );
- }
-
/*--------------------------------------------------------------------------
* transform-domain decoding
*--------------------------------------------------------------------------*/
@@ -645,11 +630,6 @@ void ivas_hq_core_dec_fx(
&hHQ_core->last_fec, hHQ_core->ph_ecu_HqVoicing, &hHQ_core->ph_ecu_active, gapsynth_fx, st_fx->prev_bfi, hHQ_core->old_is_transient, hHQ_core->mag_chg_1st_fx,
hHQ_core->Xavg_fx, &hHQ_core->beta_mute_fx, output_frame, st_fx );
}
- ELSE
- {
- HQ_FEC_processing_fx( st_fx, t_audio_q, is_transient, hHQ_nbfec->ynrm_values_fx, hHQ_nbfec->r_p_values_fx, num_Sb, nb_sfm, num_bands_p,
- output_frame, sfm_start, sfm_end );
- }
hHQ_core->old_is_transient[2] = hHQ_core->old_is_transient[1]; /* Q0 */
move16();
@@ -675,16 +655,10 @@ void ivas_hq_core_dec_fx(
{
IF( EQ_16( hq_core_type, LOW_RATE_HQ_CORE ) )
{
- IF( EQ_16( st_fx->prev_bfi, 1 ) )
- {
- set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX );
- set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX );
- hHQ_core->last_max_pos_pulse = 0;
- move16();
- }
+ /* this cannot happen in IVAS */
- /* HQ low rate decoder */
- hq_lr_dec_fx( st_fx, t_audio_q, inner_frame, num_bits, &is_transient );
+ is_transient = 0;
+ move16();
hqswb_clas = is_transient; /* Q0 */
move16();
Q_audio = 12;
@@ -730,9 +704,11 @@ void ivas_hq_core_dec_fx(
}
}
}
- ivas_HQ_FEC_Mem_update_fx( st_fx, t_audio_q, normq_fx, ynrm, num_bands_p, is_transient, hqswb_clas,
- core_switching_flag, nb_sfm, num_Sb, &mean_en_high_fx, hq_core_type, output_frame );
+
+ HQ_FEC_Mem_update_fx( st_fx, t_audio_q, normq_fx, ynrm, num_bands_p, is_transient, hqswb_clas,
+ core_switching_flag, nb_sfm, num_Sb, &mean_en_high_fx, hq_core_type, output_frame );
}
+
/*--------------------------------------------------------------------------
* Attenuate HFs in case of band-width switching (from higher BW to lower BW)
*--------------------------------------------------------------------------*/
@@ -914,43 +890,6 @@ void ivas_hq_core_dec_fx(
move16();
}
- IF( EQ_16( output_frame, L_FRAME8k ) )
- {
- test();
- IF( EQ_16( st_fx->bfi, 0 ) && st_fx->prev_bfi == 0 )
- {
- Copy_Scale_sig( hHQ_core->old_out_fx + N_ZERO_NB, hHQ_nbfec->prev_oldauOut_fx, output_frame - N_ZERO_NB, negate( hHQ_core->Q_old_wtda ) ); /* 31 - exp_old_out - Q_old_wtda */
- }
- ELSE IF( EQ_16( st_fx->prev_bfi, 1 ) )
- {
- set16_fx( hHQ_nbfec->prev_oldauOut_fx, 0, output_frame );
- }
-
- test();
- test();
- test();
- test();
- IF( ( EQ_16( st_fx->prev_bfi, 1 ) || EQ_16( st_fx->bfi, 1 ) ) && EQ_16( hHQ_core->old_is_transient[2], 0 ) && EQ_16( st_fx->last_core, HQ_CORE ) && EQ_16( st_fx->last_codec_mode, MODE1 ) )
- {
- time_domain_FEC_HQ_fx( st_fx, wtda_audio, synth, mean_en_high_fx, output_frame, Q_synth );
- }
- ELSE
- {
- window_ola_fx( wtda_audio, synth, Q_synth, hHQ_core->old_out_fx, &hHQ_core->Q_old_wtda, output_frame,
- st_fx->hTcxCfg->tcx_last_overlap_mode, st_fx->hTcxCfg->tcx_curr_overlap_mode, st_fx->prev_bfi, hHQ_core->oldHqVoicing, hHQ_core->oldgapsynth_fx );
- hHQ_nbfec->phase_mat_next = 0;
- move16();
- }
-
- test();
- test();
- IF( ( EQ_16( st_fx->bfi, 0 ) && EQ_16( st_fx->prev_bfi, 0 ) ) || !( GE_16( output_frame, L_FRAME16k ) ) )
- {
- preecho_sb_fx( st_fx->core_brate, wtda_audio, Q_audio, synth, *Q_synth, output_frame, &hHQ_core->memfilt_lb_fx,
- &hHQ_core->mean_prev_hb_fx, &hHQ_core->smoothmem_fx, &hHQ_core->mean_prev_fx, &hHQ_core->mean_prev_nc_fx, &hHQ_core->wmold_hb_fx, &hHQ_core->prevflag, &hHQ_core->pastpre, st_fx->bwidth );
- }
- }
- ELSE
{
test();
IF( EQ_16( st_fx->bfi, 1 ) && GE_16( output_frame, L_FRAME16k ) )
@@ -986,28 +925,6 @@ void ivas_hq_core_dec_fx(
}
}
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( !st_fx->bfi && st_fx->prev_bfi && GE_32( st_fx->last_total_brate, HQ_48k ) && EQ_16( st_fx->last_codec_mode, MODE2 ) && ( EQ_16( st_fx->last_core_bfi, TCX_20_CORE ) || EQ_16( st_fx->last_core_bfi, TCX_10_CORE ) ) && EQ_16( st_fx->hPlcInfo->concealment_method, TCX_NONTONAL ) && LT_32( st_fx->hPlcInfo->nbLostCmpt, 4 ) )
- {
- st_fx->hPlcInfo->recovery_gain = shl_sat( st_fx->hPlcInfo->recovery_gain, *Q_synth ); /* Q15 */
- move16();
- IF( st_fx->hTonalMDCTConc->q_lastPcmOut != 0 )
- {
- Scale_sig( st_fx->hTonalMDCTConc->secondLastPcmOut, shr( st_fx->hPlcInfo->L_frameTCX, 1 ), negate( st_fx->hTonalMDCTConc->q_lastPcmOut ) );
- Scale_sig( st_fx->hTonalMDCTConc->lastPcmOut, st_fx->hPlcInfo->L_frameTCX, negate( st_fx->hTonalMDCTConc->q_lastPcmOut ) );
- st_fx->hTonalMDCTConc->q_lastPcmOut = 0;
- move16();
- }
- waveform_adj2_fix( st_fx->hPlcInfo, st_fx->hTonalMDCTConc->secondLastPcmOut, synth, 0, add( extract_l( st_fx->hPlcInfo->nbLostCmpt ), 1 ), st_fx->bfi );
- }
-
IF( GE_16( output_frame, L_FRAME16k ) )
{
IF( EQ_16( hHQ_core->ph_ecu_HqVoicing, 1 ) )
@@ -1034,13 +951,6 @@ void ivas_hq_core_dec_fx(
move16();
}
- IF( EQ_16( output_frame, L_FRAME8k ) )
- {
- Copy32( wtda_audio, hHQ_nbfec->oldIMDCTout_fx, L_FRAME8k / 2 ); /* q_wtda */
- Copy( &hHQ_nbfec->old_auOut_2fr_fx[output_frame], hHQ_nbfec->old_auOut_2fr_fx, output_frame ); /* Q_old_auOut */
- Copy_Scale_sig( synth, &hHQ_nbfec->old_auOut_2fr_fx[output_frame], output_frame, negate( *Q_synth ) ); /* Q0 */
- }
-
/* prepare synthesis output buffer (as recent as possible) for HQ FEC */
{
diff --git a/lib_dec/hq_hr_dec_fx.c b/lib_dec/hq_hr_dec_fx.c
index 0d342ba2dca4b8d6c76ba11a26494c5d88a9d067..bcc330d61fdd1c410f020afb213e6f69bbb9379d 100644
--- a/lib_dec/hq_hr_dec_fx.c
+++ b/lib_dec/hq_hr_dec_fx.c
@@ -166,7 +166,8 @@ void ivas_hq_hr_dec_fx(
Word16 csw_flag1, csw_flag2;
HQ_DEC_HANDLE hHQ_core = st_fx->hHQ_core;
-
+ hq_generic_offset = 0;
+ move16();
move16();
move16();
@@ -434,7 +435,10 @@ void hq_hr_dec_fx(
move16();
HQ_DEC_HANDLE hHQ_core = st_fx->hHQ_core;
-
+#ifdef FIX_2391_INIT_HQ_GENERIC_OFFSET
+ hq_generic_offset = 0;
+ move16();
+#endif
move16();
Q_audio = 0; /* to avoid compilation warnings */
diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c
index e7fec949230200a3fdbcccaff7a0d7fc188925e3..fba40748cd832d65b1b32a2a3ea0aac9ee6229a1 100644
--- a/lib_dec/igf_dec_fx.c
+++ b/lib_dec/igf_dec_fx.c
@@ -1838,11 +1838,11 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
FOR( tb = 0; tb < hopsize; tb++ )
{
/* calculate of the current sfb width */
- width = sub( hGrid->swb_offset[min( sfb + tb + 1, stop_sfb )], /* 15Q0 | width is Q0 */
- hGrid->swb_offset[min( sfb + tb, stop_sfb )] );
+ width = sub( hGrid->swb_offset[s_min( sfb + tb + 1, stop_sfb )], /* 15Q0 | width is Q0 */
+ hGrid->swb_offset[s_min( sfb + tb, stop_sfb )] );
- tmp = dS[min( sfb + tb, stop_sfb - 1 )];
- tmp_e = dS_e[min( sfb + tb, stop_sfb - 1 )];
+ tmp = dS[s_min( sfb + tb, stop_sfb - 1 )];
+ tmp_e = dS_e[s_min( sfb + tb, stop_sfb - 1 )];
move16();
move16();
@@ -2507,11 +2507,11 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in
FOR( tb = 0; tb < hopsize; tb++ )
{
/* calculate of the current sfb width */
- width = sub( hGrid->swb_offset[min( sfb + tb + 1, stop_sfb )], /* 15Q0 | width is Q0 */
- hGrid->swb_offset[min( sfb + tb, stop_sfb )] );
+ width = sub( hGrid->swb_offset[s_min( sfb + tb + 1, stop_sfb )], /* 15Q0 | width is Q0 */
+ hGrid->swb_offset[s_min( sfb + tb, stop_sfb )] );
- tmp = dS[min( sfb + tb, stop_sfb - 1 )];
- tmp_e = dS_e[min( sfb + tb, stop_sfb - 1 )];
+ tmp = dS[s_min( sfb + tb, stop_sfb - 1 )];
+ tmp_e = dS_e[s_min( sfb + tb, stop_sfb - 1 )];
move16();
move16();
diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c
index baed0184c7db78a367d394b85175e190c88beab3..a3e2c48e3092886d8f82f7425aa8db9ab0004d3a 100644
--- a/lib_dec/init_dec_fx.c
+++ b/lib_dec/init_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -91,7 +91,6 @@ ivas_error init_decoder_fx(
move16();
st_fx->ini_frame = 0;
move16();
-#ifdef FIX_2252_LP_CNG_STARTS_SID
IF( st_fx->element_mode == EVS_MONO )
{
st_fx->bwidth = NB;
@@ -101,23 +100,11 @@ ivas_error init_decoder_fx(
}
ELSE
{
-#if 0 // keep deactivated for the moment to keep BE
st_fx->bwidth = WB;
move16();
st_fx->last_bwidth = WB;
-#else
- st_fx->bwidth = NB;
- move16();
- st_fx->last_bwidth = NB;
-#endif
move16();
}
-#else
- st_fx->bwidth = NB;
- move16();
- st_fx->last_bwidth = NB;
- move16();
-#endif
st_fx->extl_brate = 0;
move16();
@@ -449,7 +436,9 @@ ivas_error init_decoder_fx(
set16_fx( st_fx->previoussynth_fx, 0, L_FRAME48k );
set32_fx( st_fx->delay_buf_out32_fx, 0, HQ_DELTA_MAX * HQ_DELAY_COMP );
+#ifndef FIX_2379_REMOVE_previoussynth_fx_32
set32_fx( st_fx->previoussynth_fx_32, 0, L_FRAME48k );
+#endif
IF( st_fx->element_mode == EVS_MONO )
{
diff --git a/lib_dec/inov_dec_fx.c b/lib_dec/inov_dec_fx.c
index 4d44e5b5b421cffb7f2d5faa669a5fbfd39ad139..21e70e083045a138a72ac4a8a909e9654abe63c4 100644
--- a/lib_dec/inov_dec_fx.c
+++ b/lib_dec/inov_dec_fx.c
@@ -191,188 +191,3 @@ void inov_decode_fx(
cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, code, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr );
return;
}
-
-/*======================================================================*/
-/* FUNCTION : inov_decode_ivas_fx() */
-/*-----------------------------------------------------------------------*/
-/* PURPOSE : Decode the algebraic innovation and do pitch sharpening */
-/* */
-/*-----------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word32) core_brate : Core bitrate Q0 */
-/* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode Q0 */
-/* _ (Word16) L_frame : length of the frame Q0 */
-/* _ (Word16) i_subfr : length of the frame Q0 */
-/* _ (Word16) coder_type : coding type */
-/* _ (Word16) L_subfr : subframe length */
-/* _ (Word16) sharpFlag : formant sharpening flag */
-/* _ (Word16) tc_subfr : TC subframe index */
-/* _ (Word16 *) p_Aq : LP filter coefficients Q12 */
-/* _ (Word16) tilt_code : tilt of the excitation of previous subframe Q15*/
-/* _ (Word16) pt_pitch : current subframe fractional pitch Q6 */
-/*-----------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16 *[]) code : subframe length Q12 */
-/* _ (Word16 []) index_buf_4T : subframe length */
-/*-----------------------------------------------------------------------*/
-/* INPUT OUTPUT ARGUMENTS */
-/*-----------------------------------------------------------------------*/
-
-/*-----------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*=======================================================================*/
-
-void inov_decode_ivas_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word32 core_brate, /* i : core bitrate Q0 */
- const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode Q0 */
- const Word16 L_frame, /* i : length of the frame Q0 */
- const Word16 sharpFlag, /* i : formant sharpening flag Q0 */
- const Word16 i_subfr, /* i : subframe index Q0 */
- const Word16 *p_Aq, /* i : LP filter coefficients Q12 */
- const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15 */
- const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/
- Word16 *code, /* o : algebraic excitation Q12 */
- const Word16 L_subfr /* i : subframe length Q0 */
-)
-{
- Word16 nBits;
- Word16 g1, g2;
-
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- g1 = FORMANT_SHARPENING_G1;
- move16();
- g2 = FORMANT_SHARPENING_G2;
- move16();
- }
- ELSE
- {
- g1 = FORMANT_SHARPENING_G1_16k;
- move16();
- g2 = FORMANT_SHARPENING_G2_16k;
- move16();
- }
-
- IF( !Opt_AMR_WB )
- {
- IF( st_fx->acelp_cfg.fcb_mode )
- {
- Word16 i;
- Word16 indexing_indices[8], wordcnt, bitcnt;
- PulseConfig config;
- test();
- test();
- test();
- IF( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr] >= 0 )
- {
- IF( EQ_16( L_subfr, 2 * L_SUBFR ) )
- {
- nBits = st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr]; // Q0
- move16();
-
- IF( EQ_16( nBits, 8 ) )
- {
- dec_acelp_1t64_fx( st_fx, code, L_subfr );
- }
- ELSE
- {
- dec_acelp_fast_fx( st_fx, nBits, code, L_subfr );
- }
- }
- ELSE IF( ( EQ_16( st_fx->idchan, 1 ) && LE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 7 ) ) || ( ( st_fx->idchan == 0 ) && LE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 3 ) ) )
- {
- IF( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] == 0 )
- {
- dec_acelp_1t64_fx( st_fx, code, L_SUBFR );
- }
- ELSE
- {
- dec_acelp_fast_fx( st_fx, st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], code, L_SUBFR );
- }
- }
- ELSE
- {
- wordcnt = shr( ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ), 4 ); // Q0
- move16();
- bitcnt = s_and( ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ), 15 ); // Q0
- move16();
-
- FOR( i = 0; i < wordcnt; i++ )
- {
- indexing_indices[i] = get_next_indice_fx( st_fx, 16 ); // Q0
- move16();
- }
- IF( bitcnt )
- {
- indexing_indices[i] = get_next_indice_fx( st_fx, bitcnt ); // Q0
- move16();
- }
- config = PulseConfTable[st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR]];
- D_ACELP_indexing_fx( code, config, NB_TRACK_FCB_4T, indexing_indices, &st_fx->BER_detect );
- }
- }
- ELSE
- {
- set16_fx( code, 0, L_SUBFR );
- }
- }
- ELSE
- {
- nBits = st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR]; // Q0
- move16();
-
- IF( EQ_16( nBits, 7 ) )
- {
- dec_acelp_1t64_fx( st_fx, code, L_SUBFR );
- }
- ELSE IF( EQ_16( nBits, 12 ) )
- {
- dec_acelp_2t32_fx( st_fx, code );
- }
- ELSE
- {
- dec_acelp_4t64_fx( st_fx, nBits, code, Opt_AMR_WB );
- }
- }
- }
- ELSE
- {
- IF( EQ_32( core_brate, ACELP_6k60 ) )
- {
- dec_acelp_2t32_fx( st_fx, code );
- }
- ELSE IF( EQ_32( core_brate, ACELP_8k85 ) )
- {
- dec_acelp_4t64_fx( st_fx, 20, code, Opt_AMR_WB );
- }
- ELSE IF( EQ_32( core_brate, ACELP_12k65 ) )
- {
- dec_acelp_4t64_fx( st_fx, 36, code, Opt_AMR_WB );
- }
- ELSE IF( EQ_32( core_brate, ACELP_14k25 ) )
- {
- dec_acelp_4t64_fx( st_fx, 44, code, Opt_AMR_WB );
- }
- ELSE IF( EQ_32( core_brate, ACELP_15k85 ) )
- {
- dec_acelp_4t64_fx( st_fx, 52, code, Opt_AMR_WB );
- }
- ELSE IF( EQ_32( core_brate, ACELP_18k25 ) )
- {
- dec_acelp_4t64_fx( st_fx, 64, code, Opt_AMR_WB );
- }
- ELSE IF( EQ_32( core_brate, ACELP_19k85 ) )
- {
- dec_acelp_4t64_fx( st_fx, 72, code, Opt_AMR_WB );
- }
- ELSE
- {
- dec_acelp_4t64_fx( st_fx, 88, code, Opt_AMR_WB );
- }
- }
-
- cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, code, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr );
- return;
-}
diff --git a/lib_dec/ivas_agc_dec_fx.c b/lib_dec/ivas_agc_dec_fx.c
index eb6f6693f9db03a39b32165905ec2db17bbd2bfe..c091579e49590469de74283c12003cf0f948e3fa 100644
--- a/lib_dec/ivas_agc_dec_fx.c
+++ b/lib_dec/ivas_agc_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c
index 690797e2044cbbccc4bb1a6c03eb5651e140797f..a7eebafb52ad074c4d463f449fb59273acbc515a 100644
--- a/lib_dec/ivas_core_dec_fx.c
+++ b/lib_dec/ivas_core_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -70,19 +70,13 @@ ivas_error ivas_core_dec_fx(
Word16 tmp_buffer_fx[L_FRAME48k];
Word16 tmp16, tmp16_2, j;
Word16 Q_white_exc;
-
- set16_fx( tmp_buffer_fx, 0, L_FRAME48k );
-
Word16 tmps, incr;
Word16 flag_bwe_bws, flaf_swb_tbe;
Word32 *bwe_exc_extended_fx[CPE_CHANNELS] = { NULL, NULL };
-
Word16 voice_factors_fx[CPE_CHANNELS][NB_SUBFR16k]; // Q15
Word16 core_switching_flag[CPE_CHANNELS];
-
Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k]; // Q6
- Word32 old_syn_12k8_16k_fx[CPE_CHANNELS][L_FRAME16k];
-
+ Word16 old_syn_12k8_16k_fx[CPE_CHANNELS][L_FRAME16k];
Word16 unbits[CPE_CHANNELS];
Word16 sid_bw[CPE_CHANNELS];
FRAME_MODE frameMode[CPE_CHANNELS];
@@ -101,14 +95,9 @@ ivas_error ivas_core_dec_fx(
Word16 Q_synth;
Word16 output_16_fx[CPE_CHANNELS][L_FRAME48k];
Word16 hb_synth_16_fx[CPE_CHANNELS][L_FRAME48k];
-
Word16 synth_16_fx[CPE_CHANNELS][L_FRAME48k];
Word32 synth_32_fx[CPE_CHANNELS][L_FRAME48k];
Word16 e_sig[CPE_CHANNELS];
- e_sig[0] = e_sig[1] = 15;
- move16();
- move16();
-
Word16 tdm_lsfQ_PCh_fx[M];
Word32 conceal_eof_gain32;
@@ -116,6 +105,11 @@ ivas_error ivas_core_dec_fx(
move32();
push_wmops( "ivas_core_dec" );
+ set16_fx( tmp_buffer_fx, 0, L_FRAME48k );
+ e_sig[0] = e_sig[1] = Q15;
+ move16();
+ move16();
+
/*------------------------------------------------------------------*
* General initialization
*-----------------------------------------------------------------*/
@@ -439,7 +433,7 @@ ivas_error ivas_core_dec_fx(
* Detect bandwidth switching
*---------------------------------------------------------------------*/
- bandwidth_switching_detect_ivas_fx( st );
+ bandwidth_switching_detect_fx( st );
/*---------------------------------------------------------------------*
* Preprocessing (preparing) for ACELP/HQ core switching
@@ -452,9 +446,10 @@ ivas_error ivas_core_dec_fx(
move16();
move16();
+#ifndef FIX_2379_REMOVE_previoussynth_fx_32
Copy_Scale_sig_16_32_DEPREC( st->previoussynth_fx, st->previoussynth_fx_32, L_FRAME48k, 0 ); // Q0
-
- IF( NE_32( ( error = core_switching_pre_dec_ivas_fx( st, output_frame, sts[0]->last_core_brate, nchan_out, last_element_mode, last_element_brate, st->Q_syn, &Q_olapBufferSynth, &Q_olapBufferSynth2 ) ), IVAS_ERR_OK ) )
+#endif
+ IF( NE_32( ( error = core_switching_pre_dec_fx( st, output_frame, sts[0]->last_core_brate, nchan_out, last_element_mode, last_element_brate, st->Q_syn, &Q_olapBufferSynth, &Q_olapBufferSynth2 ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -478,7 +473,6 @@ ivas_error ivas_core_dec_fx(
IF( st->core == ACELP_CORE )
{
/* ACELP core decoder */
- Word16 old_syn_12k8_16k_fx_16[L_FRAME16k];
Word16 save_hb_synth_fx_arr[L_FRAME48k], *save_hb_synth_16_fx;
IF( save_hb_synth_32_fx )
@@ -529,7 +523,7 @@ ivas_error ivas_core_dec_fx(
st->Q_syn_factor = 0;
move16();
- IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_16_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16, sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_16_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx[n], sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -562,12 +556,11 @@ ivas_error ivas_core_dec_fx(
hSCE->q_save_hb_synth_fx = Q11;
move16();
}
-
- Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n], L_FRAME16k, Q11 - ( -Q1 ) ); // Q(11 - (-1))
}
+#ifndef FIX_2379_REMOVE_previoussynth_fx_32
Copy_Scale_sig_32_16( st->previoussynth_fx_32, st->previoussynth_fx, L_FRAME48k, 0 ); // Q0
-
+#endif
test();
test();
IF( ( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
@@ -845,11 +838,7 @@ ivas_error ivas_core_dec_fx(
move16();
}
- Word16 q_audio, old_syn_fx;
- old_syn_fx = Q11;
- move16();
- q_audio = Q12;
- move16();
+
test();
test();
test();
@@ -901,7 +890,7 @@ ivas_error ivas_core_dec_fx(
Copy_Scale_sig_16_32_no_sat( synth_16_fx[n], hSCE->save_synth_fx, output_frame, sub( hSCE->q_save_synth_fx, Q_synth ) ); // q_save_synth_fx
}
- IF( NE_32( ( error = core_switching_post_dec_ivas_fx( st, synth_16_fx[n], output_32_fx[n], p_output_mem_16, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = core_switching_post_dec_fx( st, synth_16_fx[n], output_32_fx[n], p_output_mem_16, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -931,7 +920,7 @@ ivas_error ivas_core_dec_fx(
* Pre-processing for bandwidth switching
*---------------------------------------------------------------------*/
- ivas_bw_switching_pre_proc_fx( st, last_element_brate, nchan_out, old_syn_12k8_16k_fx[n], old_syn_fx, q_audio );
+ bw_switching_pre_proc_fx( st, last_element_brate, nchan_out, old_syn_12k8_16k_fx[n] );
IF( st->hHQ_core == NULL )
{
@@ -1026,7 +1015,11 @@ ivas_error ivas_core_dec_fx(
IF( EQ_16( st->extl, WB_TBE ) )
{
/* WB TBE decoder */
+#ifdef HARMONIZE_TBE
+ wb_tbe_dec_fx( st, st->coder_type, bwe_exc_extended_fx[n], st->Q_exc, voice_factors_fx[n], hb_synth_16_fx[n], &Q_hb_synth_fx );
+#else
ivas_wb_tbe_dec_fx( st, st->coder_type, bwe_exc_extended_fx[n], st->Q_exc, voice_factors_fx[n], hb_synth_16_fx[n], &Q_hb_synth_fx );
+#endif
}
ELSE IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( n, 1 ) && !tdm_LRTD_flag && NE_16( st->extl, -1 ) && st->bws_cnt == 0 && st->extl_brate == 0 )
{
@@ -1090,7 +1083,11 @@ ivas_error ivas_core_dec_fx(
/* FB TBE decoder */
IF( EQ_16( st->extl, FB_TBE ) )
{
+#ifdef HARMONIZE_TBE
+ fb_tbe_dec_fx( st, tmp_buffer_fx /*fb_exc*/, Q_white_exc, NULL, hb_synth_32_fx[n], 0, tmp_buffer_fx /*fb_synth_ref*/, Q_white_exc, output_frame );
+#else
fb_tbe_dec_ivas_fx( st, tmp_buffer_fx /*fb_exc*/, Q_white_exc, hb_synth_32_fx[n], 0, tmp_buffer_fx /*fb_synth_ref*/, Q_white_exc, output_frame );
+#endif
}
}
ELSE IF( EQ_16( st->extl, SWB_BWE ) || EQ_16( st->extl, FB_BWE ) || flag_bwe_bws )
@@ -1154,17 +1151,17 @@ ivas_error ivas_core_dec_fx(
q = 2;
move16();
- Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0
+ Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0
Copy_Scale_sig_32_16( synth_32_fx[n], synth_fxl, output_frame, negate( add( Q11, q ) ) ); // Q0
Scale_sig( hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, sub( Q8, hBWE_TD->prev_Q_bwe_syn ) ); // Q8
Copy_Scale_sig_32_16( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, ( 2 * ALLPASSSECTIONS_STEEP ), sub( hBWE_TD->prev_Q_bwe_syn2, Q11 ) ); // prev_Q_bew_syn2
- swb_CNG_dec_ivas_fx( st, synth_fxl, hb_synth_16_fx[n], sid_bw[n], negate( q ) );
+ swb_CNG_dec_fx( st, synth_fxl, hb_synth_16_fx[n], sid_bw[n], negate( q ) );
test();
IF( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) )
{
- Copy_Scale_sig_16_32_DEPREC( hb_synth_16_fx[n], hb_synth_32_fx[n], L_FRAME48k, ( Q11 ) ); // Q11
+ Copy_Scale_sig_16_32_DEPREC( hb_synth_16_fx[n], hb_synth_32_fx[n], output_frame, ( Q11 ) ); // Q11
}
Scale_sig( hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, negate( sub( Q8, hBWE_TD->prev_Q_bwe_syn ) ) ); // Q0
@@ -1182,11 +1179,13 @@ ivas_error ivas_core_dec_fx(
q = 11;
move16();
+#ifndef FIX_2367_REMOVE_CODE_ICBWE
if ( hCPE->hStereoDft != NULL )
{
hCPE->hStereoDft->td_gain_fx[0] = 1;
move32();
}
+#endif
stereo_icBWE_dec_fx( hCPE, hb_synth_32_fx[0], hb_synth_32_fx[1], tmp_buffer_fx /*fb_synth_ref*/, voice_factors_fx[0], output_frame, &q, Q_white_exc );
test();
test();
@@ -1486,7 +1485,7 @@ ivas_error ivas_core_dec_fx(
save_synthesis_hq_fec_fx( st, NULL, output_fx_loc, output_frame, 0, hCPE );
/* Updates */
- ivas_updt_dec_common_fx( st, NORMAL_HQ_CORE, -1, output_32_fx[n], Q11 );
+ updt_dec_common_fx( st, NORMAL_HQ_CORE, -1, NULL, output_32_fx[n], Q11 );
Scale_sig( st->delay_buf_out_fx, NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ), negate( exp_max ) ); // Q0
diff --git a/lib_dec/ivas_corecoder_dec_reconfig_fx.c b/lib_dec/ivas_corecoder_dec_reconfig_fx.c
index 288cd9a0373fe7247a3cb4c3f8dbc5ea3c6df7ef..6e6ac9d3545b46c15e39f4baf6d60a8ce62f7ce3 100644
--- a/lib_dec/ivas_corecoder_dec_reconfig_fx.c
+++ b/lib_dec/ivas_corecoder_dec_reconfig_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c
index 8e94de138d99f5eb9f8059fea4f9fdd435581d82..45007974483505fb416b1075b6e00456be83df21 100644
--- a/lib_dec/ivas_cpe_dec_fx.c
+++ b/lib_dec/ivas_cpe_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_dec_fx.c b/lib_dec/ivas_dec_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..bd3eab3e4feb8c9131b76321da996b6d835e91f4
--- /dev/null
+++ b/lib_dec/ivas_dec_fx.c
@@ -0,0 +1,1565 @@
+/******************************************************************************************************
+
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository. All Rights Reserved.
+
+ This software is protected by copyright law and by international treaties.
+ The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository retain full ownership rights in their respective contributions in
+ the software. This notice grants no license of any kind, including but not limited to patent
+ license, nor is any license granted by implication, estoppel or otherwise.
+
+ Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
+ contributions.
+
+ This software is provided "AS IS", without any express or implied warranties. The software is in the
+ development stage. It is intended exclusively for experts who have experience with such software and
+ solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
+ and fitness for a particular purpose are hereby disclaimed and excluded.
+
+ Any dispute, controversy or claim arising under or in relation to providing this software shall be
+ submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
+ accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
+ the United Nations Convention on Contracts on the International Sales of Goods.
+
+*******************************************************************************************************/
+
+#include
+#include "options.h"
+#include "ivas_cnst.h"
+#include "prot_fx.h"
+#include "ivas_prot_fx.h"
+#include "ivas_prot_rend_fx.h"
+#include "ivas_rom_com.h"
+#include "wmc_auto.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_dec()
+ *
+ * Principal IVAS decoder routine, decoding of metadata and transport channels
+ *--------------------------------------------------------------------------*/
+
+ivas_error ivas_dec_fx(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+)
+{
+ Word16 ch, n, output_frame, nchan_out, i, s;
+ Decoder_State *st; /* used for bitstream handling */
+ Word32 *p_output_fx[MAX_TRANSPORT_CHANNELS]; /* buffer for output synthesis */
+ Word16 nchan_remapped;
+ Word16 nb_bits_metadata[MAX_SCE + 1];
+ Word32 output_Fs, ivas_total_brate;
+ AUDIO_CONFIG output_config;
+ ivas_error error;
+ Word16 num_md_sub_frames;
+ Word32 ism_total_brate;
+
+ push_wmops( "ivas_dec" );
+ /*----------------------------------------------------------------*
+ * Initialization of local vars after struct has been set
+ *----------------------------------------------------------------*/
+
+ output_Fs = st_ivas->hDecoderConfig->output_Fs;
+ move32();
+ nchan_out = st_ivas->hTcBuffer->nchan_transport_rend;
+ move16();
+ output_config = st_ivas->hDecoderConfig->output_config;
+ ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
+ move32();
+
+ output_frame = extract_l( Mult_32_16( output_Fs, INV_FRAME_PER_SEC_Q15 ) ) /* output_Fs / FRAMES_PER_SEC */;
+
+ /* set pointers to transport channels audio */
+ FOR( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ )
+ {
+ p_output_fx[n] = st_ivas->p_output_fx[n];
+ IF( p_output_fx[n] != NULL )
+ {
+ set32_fx( p_output_fx[n], 0, L_FRAME48k );
+ }
+ }
+
+ /*----------------------------------------------------------------*
+ * Decoding + pre-rendering
+ *----------------------------------------------------------------*/
+
+ test();
+ IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
+
+ {
+ st_ivas->hCPE[0]->element_brate = ivas_total_brate;
+ move32();
+ IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, 0 ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ /* HP filtering */
+ FOR( n = 0; n < s_min( nchan_out, st_ivas->nchan_transport ); n++ )
+ {
+ hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs );
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
+ {
+ /* Metadata decoding and configuration */
+ test();
+ IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) )
+ {
+ ivas_ism_dtx_dec_fx( st_ivas, nb_bits_metadata );
+
+ IF( ( error = ivas_sce_dec_fx( st_ivas, st_ivas->hISMDTX.sce_id_dtx, &p_output_fx[st_ivas->hISMDTX.sce_id_dtx], output_frame, nb_bits_metadata[st_ivas->hISMDTX.sce_id_dtx] ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( st_ivas->hSCE, st_ivas->hISMDTX.sce_id_dtx, st_ivas->nchan_transport );
+
+ ivas_param_ism_dec_dequant_md_fx( st_ivas );
+ }
+ ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
+ {
+ IF( NE_32( ( error = ivas_ism_metadata_dec_fx( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hParamIsmDec->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ ivas_param_ism_dec_dequant_md_fx( st_ivas );
+ }
+ ELSE /* ISM_MODE_DISC */
+ {
+ IF( NE_32( ( error = ivas_ism_metadata_dec_fx( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ FOR( n = 0; n < st_ivas->nchan_transport; n++ )
+ {
+ /* for DTX frames, dominant object has already been decoded before */
+ test();
+ test();
+ IF( !( ( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) && EQ_16( n, st_ivas->hISMDTX.sce_id_dtx ) ) )
+ {
+ IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, n, &p_output_fx[n], output_frame, nb_bits_metadata[n] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ /* HP filtering */
+ hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs );
+ }
+
+ test();
+ test();
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) )
+ {
+ ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame );
+
+ Scale_sig32( p_output_fx[0], output_frame, Q11 - Q8 );
+ }
+ ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) )
+ {
+ /* loudness correction */
+ ivas_dirac_dec_binaural_sba_gain_fx( p_output_fx, st_ivas->nchan_transport, output_frame ); /*returns Q-1*/
+
+ FOR( i = 0; i < st_ivas->nchan_transport; i++ )
+ {
+ Scale_sig32( p_output_fx[i], output_frame, 1 ); // Q-1 -> Q
+ }
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
+ {
+ set16_fx( nb_bits_metadata, 0, MAX_SCE );
+
+ /* read parameters from the bitstream */
+ test();
+ IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && st_ivas->hQMetaData != NULL )
+ {
+ // st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0];
+ IF( st_ivas->nSCE > 0 )
+ {
+ st = st_ivas->hSCE[0]->hCoreCoder[0];
+ }
+ ELSE
+ {
+ st = st_ivas->hCPE[0]->hCoreCoder[0];
+ }
+
+ IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st, &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
+ {
+ IF( NE_32( ( error = ivas_spar_dec_fx( st_ivas, nb_bits_metadata ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ test();
+ IF( EQ_16( st_ivas->nchan_transport, CPE_CHANNELS ) && GE_16( st_ivas->nCPE, 1 ) )
+ {
+ st_ivas->hCPE[0]->brate_surplus = 0;
+ move32();
+ st_ivas->hCPE[0]->element_brate = ivas_total_brate;
+ move32();
+ }
+
+ /* core-decoding of transport channels */
+ IF( EQ_16( st_ivas->nSCE, 1 ) )
+ {
+ IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE IF( EQ_16( st_ivas->nCPE, 1 ) )
+ {
+ IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE IF( GT_16( st_ivas->nCPE, 1 ) )
+ {
+ IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ /* TCs remapping */
+ nchan_remapped = st_ivas->nchan_transport;
+ move16();
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( st_ivas->sba_dirac_stereo_flag )
+ {
+ nchan_remapped = nchan_out;
+ move16();
+
+ IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) )
+ {
+ FOR( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ )
+ {
+ Scale_sig32( p_output_fx[i], output_frame, Q14 - Q11 ); // Q14
+ }
+ SPAR_DEC_HANDLE hSpar = st_ivas->hSpar;
+ Word16 nchan_transport;
+ nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport;
+ move16();
+ nchan_out = nchan_transport;
+ move16();
+
+ ivas_agc_dec_process_fx( st_ivas->hSpar->hAgcDec, ( p_output_fx ), ( p_output_fx ), st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame );
+
+ IF( st_ivas->hSpar->hPCA != NULL )
+ {
+ ivas_pca_dec_fx( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, p_output_fx );
+ }
+
+ ivas_spar_dec_gen_umx_mat_fx( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ) );
+ }
+
+ ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame );
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) || ( LE_32( ivas_total_brate, IVAS_SID_5k2 ) && st_ivas->nCPE > 0 && EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) ) ) )
+ {
+ nchan_remapped = 1; /* Only one channel transported */
+ move16();
+ }
+
+ /* HP filtering */
+ FOR( n = 0; n < nchan_remapped; n++ )
+ {
+ hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs );
+ }
+
+ IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
+ {
+ nchan_remapped = ivas_sba_remapTCs_fx( p_output_fx, st_ivas, output_frame );
+
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
+ {
+ num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate );
+
+ SPAR_DEC_HANDLE hSpar = st_ivas->hSpar;
+ Word16 Q_p_output = MAX_16, temp_min;
+ move16();
+ Word16 nchan_transport;
+
+ nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport;
+ move16();
+ nchan_out = nchan_transport;
+ move16();
+ FOR( ch = 0; ch < nchan_transport; ch++ )
+ {
+ temp_min = L_norm_arr( p_output_fx[ch], output_frame );
+ Q_p_output = s_min( Q_p_output, temp_min );
+ }
+ Q_p_output = sub( Q_p_output, 2 );
+ if ( GT_16( Q_p_output, 20 ) )
+ {
+ Q_p_output = 20;
+ move16();
+ }
+ FOR( ch = 0; ch < nchan_transport; ch++ )
+ {
+ Scale_sig32( p_output_fx[ch], output_frame, Q_p_output ); // Q(11+Q_p_output)
+ }
+
+ ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, p_output_fx, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames, Q_p_output );
+ FOR( Word16 c = 0; c < nchan_transport; c++ )
+ {
+ Scale_sig32( p_output_fx[c], output_frame, 11 ); // Q11
+ }
+ }
+ ELSE IF( NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) )
+ {
+ Word16 size = st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport;
+ move16();
+ if ( EQ_16( st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, 3 ) )
+ size = add( size, 1 );
+
+ FOR( i = 0; i < size; i++ )
+ {
+ Scale_sig32( p_output_fx[i], output_frame, Q14 - Q11 ); // Q14
+ }
+
+ ivas_spar_dec_agc_pca_fx( st_ivas, p_output_fx, output_frame );
+ }
+ }
+
+ test();
+ test();
+ IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
+ {
+ Word16 q_shift = 0;
+ move16();
+
+ ivas_masa_prerender_fx( st_ivas, p_output_fx, &q_shift, output_frame, nchan_remapped );
+
+ FOR( i = 0; i < CPE_CHANNELS; i++ )
+ {
+ Scale_sig32( p_output_fx[i], output_frame, negate( q_shift ) );
+ }
+
+ test();
+ /* external output */
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && EQ_32( st_ivas->hMasa->config.input_ivas_format, MASA_ISM_FORMAT ) )
+ {
+ FOR( n = 0; n < st_ivas->nchan_ism; n++ )
+ {
+ set_zero_fx( p_output_fx[add( st_ivas->nchan_transport, n )], output_frame );
+ }
+
+ ivas_omasa_rearrange_channels_fx( p_output_fx, st_ivas->nchan_ism, output_frame );
+ }
+ }
+ ELSE IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) && ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) )
+ {
+ /* loudness correction */
+ ivas_dirac_dec_binaural_sba_gain_fx( p_output_fx, nchan_remapped, output_frame );
+
+ FOR( i = 0; i < st_ivas->nchan_transport; i++ )
+ {
+ Scale_sig32( p_output_fx[i], output_frame, 1 ); // Q-1 -> Q
+ }
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
+ {
+ Word16 nchan_ism, nchan_transport_ism;
+ Word16 dirac_bs_md_write_idx;
+
+ set16_fx( nb_bits_metadata, 0, MAX_SCE + 1 );
+
+ /* Set the number of objects for the parametric rendering */
+ dirac_bs_md_write_idx = 0;
+ move16();
+ IF( st_ivas->hSpatParamRendCom != NULL )
+ {
+ st_ivas->hSpatParamRendCom->numIsmDirections = 0;
+ move16();
+ test();
+ if ( NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && NE_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) )
+ {
+ st_ivas->hSpatParamRendCom->numIsmDirections = st_ivas->nchan_ism;
+ move16();
+ }
+
+ dirac_bs_md_write_idx = st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx; /* Store the write-index for this frame */
+ move16();
+ }
+
+ /* MASA metadata decoding */
+ IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st_ivas->hCPE[0]->hCoreCoder[0], &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ /* Configuration of combined-format bit-budget distribution */
+ ivas_set_surplus_brate_dec( st_ivas, &ism_total_brate );
+
+ st_ivas->hCPE[0]->hCoreCoder[0]->bit_stream = &( st_ivas->bit_stream[( ism_total_brate / FRAMES_PER_SEC )] );
+
+ IF( NE_32( ( error = ivas_omasa_ism_metadata_dec_fx( st_ivas, ism_total_brate, &nchan_ism, &nchan_transport_ism, dirac_bs_md_write_idx, &nb_bits_metadata[1] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ FOR( n = 0; n < nchan_transport_ism; n++ )
+ {
+ IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, n, &p_output_fx[st_ivas->nchan_transport + n], output_frame, nb_bits_metadata[1] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ /* decode MASA channels */
+ IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ IF( EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) )
+ {
+ Copy32( p_output_fx[0], p_output_fx[1], output_frame ); /* Copy mono signal to stereo output channels */
+ }
+
+ FOR( n = 0; n < getNumChanSynthesis( st_ivas ); n++ )
+ {
+ hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs );
+ }
+
+ Word16 output_q = Q11;
+ move16();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) )
+ {
+ ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame );
+
+ output_q = Q8;
+ move16();
+ }
+ ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
+ {
+ IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
+ {
+ ivas_omasa_rearrange_channels_fx( p_output_fx, nchan_transport_ism, output_frame );
+ }
+ ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) )
+ {
+ /* Convert separate object to MASA, combine with the original MASA, and output combined MASA + empty objects. */
+ ivas_omasa_combine_separate_ism_with_masa_fx( st_ivas, p_output_fx, &output_q, st_ivas->nchan_ism, output_frame );
+ }
+ ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) )
+ {
+ /* Extract objects from MASA, output MASA + all objects (i.e., extracted and separated objects) */
+ ivas_omasa_render_objects_from_mix_fx( st_ivas, p_output_fx, st_ivas->nchan_ism, output_frame, &output_q );
+ }
+ }
+
+ IF( NE_16( output_q, Q11 ) )
+ {
+ FOR( n = 0; n < s_max( getNumChanSynthesis( st_ivas ), nchan_transport_ism + st_ivas->nchan_transport ); n++ )
+ {
+ Scale_sig32( p_output_fx[n], output_frame, sub( Q11, output_q ) ); // Q11
+ }
+ st_ivas->hCPE[0]->q_output_mem_fx[0] = output_q;
+ st_ivas->hCPE[0]->q_output_mem_fx[1] = output_q;
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
+ {
+ Word16 nchan_ism, sba_ch_idx;
+
+ set16_fx( nb_bits_metadata, 0, MAX_SCE + 1 );
+ nchan_ism = st_ivas->nchan_ism;
+ move16();
+ IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
+ {
+ /* set ISM parameters and decode ISM metadata in OSBA format */
+ IF( NE_32( ( error = ivas_osba_ism_metadata_dec_fx( st_ivas, ivas_total_brate, &nchan_ism, &nb_bits_metadata[1] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ sba_ch_idx = st_ivas->nchan_ism;
+ move16();
+ }
+ ELSE
+ {
+ nb_bits_metadata[1] = add( nb_bits_metadata[1], NO_BITS_MASA_ISM_NO_OBJ );
+ sba_ch_idx = 0;
+ move16();
+ move16();
+ }
+
+ /* SBA metadata decoding */
+ IF( NE_32( ( error = ivas_spar_dec_fx( st_ivas, nb_bits_metadata ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ test();
+ IF( EQ_16( st_ivas->nchan_transport, CPE_CHANNELS ) && GE_16( st_ivas->nCPE, 1 ) )
+ {
+ st_ivas->hCPE[0]->element_brate = ivas_total_brate;
+ move32();
+ }
+
+ /* core-decoding of transport channels */
+ IF( EQ_16( st_ivas->nSCE, 1 ) )
+ {
+ IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE IF( EQ_16( st_ivas->nCPE, 1 ) )
+ {
+ IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, add( nb_bits_metadata[0], nb_bits_metadata[1] ) ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE IF( GT_16( st_ivas->nCPE, 1 ) )
+ {
+ IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ IF( st_ivas->sba_dirac_stereo_flag )
+ {
+ FOR( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ )
+ {
+ Scale_sig32( p_output_fx[i + sba_ch_idx], output_frame, Q14 - Q11 ); // Q14
+ }
+ SPAR_DEC_HANDLE hSpar = st_ivas->hSpar;
+ Word16 nchan_transport;
+ nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport;
+ move16();
+ nchan_out = nchan_transport;
+ move16();
+ ivas_agc_dec_process_fx( st_ivas->hSpar->hAgcDec, ( p_output_fx + sba_ch_idx ), ( p_output_fx + sba_ch_idx ), st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame );
+
+ IF( st_ivas->hSpar->hPCA != NULL )
+ {
+ ivas_pca_dec_fx( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &p_output_fx[sba_ch_idx] );
+ }
+
+ ivas_spar_dec_gen_umx_mat_fx( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) );
+
+ ivas_sba_dirac_stereo_dec_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame );
+ }
+
+ /* HP filtering */
+ FOR( n = 0; n < getNumChanSynthesis( st_ivas ); n++ )
+ {
+ hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs );
+ }
+
+ nchan_remapped = ivas_sba_remapTCs_fx( &p_output_fx[sba_ch_idx], st_ivas, output_frame );
+
+ test();
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
+ {
+ num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate );
+ SPAR_DEC_HANDLE hSpar = st_ivas->hSpar;
+ Word16 nchan_transport;
+ // num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands;
+ nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport;
+ move16();
+ nchan_out = nchan_transport;
+ move16();
+ Word16 Q_p_output;
+ Word16 min_norm = 31;
+ move16();
+
+ FOR( ch = 0; ch < nchan_transport; ++ch )
+ {
+ Word16 norm = L_norm_arr( p_output_fx[sba_ch_idx + ch], output_frame ); // Normalize per channel
+ min_norm = s_min( norm, min_norm );
+ }
+
+ Q_p_output = s_max( 3, sub( min_norm, 1 ) );
+
+ Q_p_output = s_min( Q_p_output, 19 ); // to restrict Q-factor of p_ouptut to Q30
+ FOR( ch = 0; ch < nchan_transport; ch++ )
+ {
+ Scale_sig32( p_output_fx[sba_ch_idx + ch], output_frame, Q_p_output ); // Q_p_output + Q11
+ }
+ Q_p_output = add( Q11, Q_p_output );
+ hSpar->hMdDec->Q_mixer_mat = 31;
+ move16();
+
+ ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, &p_output_fx[sba_ch_idx], st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames, sub( Q_p_output, Q11 ) );
+ FOR( Word16 c = 0; c < nchan_transport; c++ )
+ {
+ Scale_sig32( p_output_fx[sba_ch_idx + c], output_frame, Q11 ); // Q11
+ }
+ }
+ ELSE IF( NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) && st_ivas->sba_dirac_stereo_flag == 0 )
+ {
+ Word16 size = add( st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, sba_ch_idx );
+ if ( EQ_16( size, 3 ) )
+ {
+ size = add( size, 1 );
+ }
+
+ FOR( i = sba_ch_idx; i < size; i++ )
+ {
+ Scale_sig32( p_output_fx[i], output_frame, ( Q14 - Q11 ) ); // Q14
+ }
+
+ ivas_spar_dec_agc_pca_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame );
+ }
+
+ test();
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
+ {
+ /* loudness correction */
+ ivas_dirac_dec_binaural_sba_gain_fx( &p_output_fx[sba_ch_idx], nchan_remapped, output_frame ); /*returns Q-1*/
+
+ FOR( i = 0; i < nchan_remapped; i++ )
+ {
+ Scale_sig32( p_output_fx[i], output_frame, 1 ); // Q-1 -> Q
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
+ {
+ ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame );
+
+ Scale_sig32( p_output_fx[0], output_frame, Q11 - Q8 ); // Q11
+
+ /* add W */
+ FOR( n = 0; n < nchan_out; n++ )
+ {
+ v_add_32( p_output_fx[n], p_output_fx[n + s_max( nchan_out, nchan_ism )], p_output_fx[n], output_frame );
+ }
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) )
+ {
+ IF( st_ivas->nSCE > 0 )
+ {
+ st = st_ivas->hSCE[0]->hCoreCoder[0];
+ }
+ ELSE
+ {
+ st = st_ivas->hCPE[0]->hCoreCoder[0];
+ }
+
+ IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) )
+ {
+ /* LFE channel decoder */
+ ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] );
+
+ Scale_sig32( p_output_fx[LFE_CHANNEL], output_frame, Q11 - Q9 ); // Q11
+
+ IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, 0 ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ /* HP filtering */
+ FOR( n = 0; n < st_ivas->nchan_transport; n++ )
+ {
+ IF( NE_16( n, LFE_CHANNEL ) )
+ {
+ hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs );
+ }
+ }
+
+ test();
+ test();
+ test();
+ IF( NE_32( st_ivas->transport_config, st_ivas->intern_config ) && ( NE_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_FOA ) || NE_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA2 ) || NE_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA3 ) ) )
+ {
+ IF( GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ) ) )
+ {
+ ivas_mc2sba_fx( st_ivas->hTransSetup, p_output_fx, p_output_fx, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE_FX );
+ }
+ }
+
+ test();
+ test();
+ IF( ( EQ_32( st_ivas->renderer_type, RENDERER_MC ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) && GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ) )
+ {
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) )
+ {
+ s = Q16 - Q11;
+ move16();
+ s = sub( s, find_guarded_bits_fx( st_ivas->nchan_transport ) );
+ FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i )
+ {
+ Scale_sig32( p_output_fx[i], output_frame, s ); // Q(11+s)
+ }
+ ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx );
+ FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i )
+ {
+ Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); // Q11
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
+ {
+ ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, output_frame, st_ivas->hOutSetup.ambisonics_order, 0 );
+ }
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
+ {
+ /* LFE channel decoder */
+ ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] );
+
+ Scale_sig32( p_output_fx[LFE_CHANNEL], output_frame, Q11 - Q9 ); // Q11
+
+ ivas_mc_paramupmix_dec_read_BS( st_ivas, st, st_ivas->hMCParamUpmix, &nb_bits_metadata[0] );
+
+ IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ /* HP filtering */
+ FOR( n = 0; n < st_ivas->nchan_transport; n++ )
+ {
+ IF( NE_16( n, LFE_CHANNEL ) )
+ {
+ hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs );
+ }
+ }
+
+ /* Rendering */
+ test();
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) && ( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) )
+ {
+ /* Compensate loudness for not doing full upmix */
+ FOR( n = 4; n < 8; n++ )
+ {
+ Scale_sig32( p_output_fx[n], output_frame, 1 );
+ }
+
+ test();
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) )
+ {
+ s = Q16 - Q11;
+ move16();
+ Word16 nchan_transport;
+ nchan_transport = audioCfg2channels( IVAS_AUDIO_CONFIG_5_1_2 );
+ s = sub( s, find_guarded_bits_fx( nchan_transport ) );
+ FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i )
+ {
+ Scale_sig32( p_output_fx[i], output_frame, s );
+ }
+
+ ivas_ls_setup_conversion_fx( st_ivas, nchan_transport, output_frame, p_output_fx, p_output_fx );
+
+ FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i )
+ {
+ Scale_sig32( p_output_fx[i], output_frame, negate( s ) );
+ }
+ }
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
+ {
+ /* read Parametric MC parameters from the bitstream */
+ ivas_param_mc_dec_read_BS_fx( ivas_total_brate, st, st_ivas->hParamMC, &nb_bits_metadata[0] );
+
+ IF( EQ_16( st_ivas->nCPE, 1 ) )
+ {
+ IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE IF( GT_16( st_ivas->nCPE, 1 ) )
+ {
+ IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+
+ /* HP filtering */
+ FOR( n = 0; n < st_ivas->nchan_transport; n++ )
+ {
+ hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs );
+ }
+
+ /* Rendering */
+ test();
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) )
+ {
+ ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx );
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
+ {
+ IF( st_ivas->hOutSetup.separateChannelEnabled )
+ {
+ st = st_ivas->hCPE[0]->hCoreCoder[0]; /* Metadata is always with CPE in the case of separated channel */
+ }
+
+ /* read McMASA parameters from the bitstream */
+ IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st, &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ IF( st_ivas->hOutSetup.separateChannelEnabled )
+ {
+ /* Decode the transport audio signals */
+ IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ /* Identify the index of the separated channel, always LFE_CHANNEL-1 here */
+ n = LFE_CHANNEL - 1;
+ move16();
+
+ /* Decode the separated channel to output[n] to be combined with the synthesized channels */
+ IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[n], output_frame, 0 ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ /* Delay the separated channel to sync with CLDFB delay of the DirAC synthesis, and synthesize the LFE signal. */
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) ||
+ EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || ( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe > 0 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
+ {
+ ivas_lfe_synth_with_filters_fx( st_ivas->hMasa->hMasaLfeSynth, p_output_fx, output_frame, n, LFE_CHANNEL );
+ }
+ ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe == 0 )
+ {
+ /* Delay the separated channel to sync with the DirAC rendering */
+ delay_signal32_fx( p_output_fx[n], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_fx, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size );
+ }
+ }
+ ELSE
+ {
+ IF( EQ_16( st_ivas->nSCE, 1 ) )
+ {
+ IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE IF( EQ_16( st_ivas->nCPE, 1 ) )
+ {
+ IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ }
+
+ IF( st_ivas->sba_dirac_stereo_flag != 0 ) /* use the flag to trigger the DFT upmix */
+ {
+ ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame );
+ }
+
+ /* HP filtering */
+ FOR( n = 0; n < getNumChanSynthesis( st_ivas ); n++ )
+ {
+ hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs );
+ }
+
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_MCMASA_MONO_STEREO ) )
+ {
+ ivas_mono_stereo_downmix_mcmasa_fx( st_ivas, p_output_fx, output_frame );
+ }
+ }
+ }
+
+ /*----------------------------------------------------------------*
+ * Common updates
+ *----------------------------------------------------------------*/
+
+ IF( !st_ivas->bfi ) /* do not update if first frame(s) are lost or NO_DATA */
+ {
+ st_ivas->hDecoderConfig->last_ivas_total_brate = ivas_total_brate;
+ move32();
+ IF( LE_32( ivas_total_brate, IVAS_SID_5k2 ) )
+ {
+ st_ivas->last_active_ivas_total_brate = st_ivas->last_active_ivas_total_brate;
+ move32();
+ }
+ ELSE
+ {
+ st_ivas->last_active_ivas_total_brate = ivas_total_brate;
+ move32();
+ }
+ }
+
+ test();
+ test();
+ if ( LT_16( st_ivas->ini_frame, MAX_FRAME_COUNTER ) && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) ) /* keep "st_ivas->ini_frame = 0" until first good received frame */
+ {
+ st_ivas->ini_frame = add( st_ivas->ini_frame, 1 );
+ move16();
+ }
+
+ test();
+ test();
+ if ( LT_16( st_ivas->ini_active_frame, MAX_FRAME_COUNTER ) && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) && GT_32( ivas_total_brate, IVAS_SID_5k2 ) ) /* needed in MASA decoder in case the first active frame is BFI, and there were SID-frames decoded before */
+ {
+ st_ivas->ini_active_frame = add( st_ivas->ini_active_frame, 1 );
+ move16();
+ }
+
+ st_ivas->last_ivas_format = st_ivas->ivas_format;
+ move32();
+ pop_wmops();
+
+ return IVAS_ERR_OK;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_dec_get_num_tc_channels()
+ *
+ * Get the number of transport channels provided to the renderer
+ *--------------------------------------------------------------------------*/
+
+Word16 ivas_dec_get_num_tc_channels_fx(
+ Decoder_Struct *st_ivas /* i : IVAS decoder handle */
+)
+{
+ Word16 num_tc;
+ Word32 ivas_total_brate;
+ AUDIO_CONFIG output_config;
+
+ IF( EQ_16( st_ivas->renderer_type, RENDERER_DISABLE ) )
+ {
+ num_tc = st_ivas->hDecoderConfig->nchan_out;
+ move16();
+ }
+ ELSE
+ {
+ num_tc = st_ivas->nchan_transport;
+ move16();
+ }
+ output_config = st_ivas->hDecoderConfig->output_config;
+ move16();
+
+ ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
+ move32();
+
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) )
+ {
+ num_tc = 1;
+ move16();
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) && EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) )
+ {
+ num_tc = 1;
+ move16();
+ }
+ ELSE IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) )
+ {
+ if ( EQ_16( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) )
+ {
+ num_tc = 1;
+ move16();
+ }
+ }
+ ELSE IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_FORMAT ) )
+ {
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( st_ivas->sba_dirac_stereo_flag )
+ {
+ num_tc = CPE_CHANNELS;
+ move16();
+ }
+ ELSE IF( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) || ( LE_32( ivas_total_brate, IVAS_SID_5k2 ) && GT_16( st_ivas->nCPE, 0 ) && st_ivas->hCPE[0] != NULL && EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) ) ) )
+ {
+ num_tc = 1; /* Only one channel transported */
+ move16();
+ }
+
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) && EQ_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && EQ_16( st_ivas->nchan_transport, 2 ) && LT_32( st_ivas->hDecoderConfig->ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && GT_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) )
+ {
+ num_tc = CPE_CHANNELS;
+ move16();
+ }
+ IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) )
+ {
+ if ( EQ_16( num_tc, 3 ) )
+ {
+ num_tc = add( num_tc, 1 );
+ }
+ }
+ }
+ ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
+ {
+ IF( NE_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
+ {
+ test();
+ IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) )
+ {
+ num_tc = add( num_tc, 1 );
+ }
+ ELSE IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
+ {
+ num_tc = add( num_tc, st_ivas->nchan_ism );
+ }
+ }
+ }
+ ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
+ {
+ if ( st_ivas->sba_dirac_stereo_flag )
+ {
+ num_tc = CPE_CHANNELS;
+ move16();
+ }
+
+ if ( EQ_16( num_tc, 3 ) )
+ {
+ num_tc = add( num_tc, 1 );
+ }
+ if ( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
+ {
+ num_tc = add( num_tc, st_ivas->nchan_ism );
+ }
+ }
+ ELSE IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) )
+ {
+ IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_MONO ) )
+ {
+ num_tc = 1;
+ move16();
+ }
+ ELSE IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) )
+ {
+ num_tc = 2;
+ move16();
+ }
+ ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) )
+ {
+ /* do all static dmx already in the TC decoder if less channels than transported... */
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( NE_16( st_ivas->transport_config, st_ivas->intern_config ) && ( EQ_16( st_ivas->intern_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_16( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_16( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA3 ) ) )
+ {
+ if ( GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ) ) )
+ {
+ num_tc = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe );
+ }
+ }
+ ELSE IF( ( EQ_16( st_ivas->renderer_type, RENDERER_MC ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) && GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ) )
+ {
+ num_tc = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe );
+ }
+ }
+ ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
+ {
+ num_tc = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS;
+ move16();
+ }
+ ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) )
+ {
+ if ( st_ivas->hOutSetup.separateChannelEnabled )
+ {
+ num_tc = add( num_tc, 1 );
+ }
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ if ( st_ivas->hOutSetup.separateChannelEnabled && ( EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_7_1 ) ||
+ EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) ||
+ EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || ( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe > 0 ) ) )
+ {
+ /* LFE is synthesized in TD with the TCs*/
+ num_tc = add( num_tc, 1 );
+ }
+ }
+ }
+
+ return num_tc;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_dec_get_tc_buffer_mode()
+ *
+ *
+ *--------------------------------------------------------------------------*/
+
+TC_BUFFER_MODE ivas_dec_get_tc_buffer_mode_fx(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+)
+{
+ TC_BUFFER_MODE buffer_mode;
+
+ buffer_mode = TC_BUFFER_MODE_BUFFER;
+ move16();
+
+ SWITCH( st_ivas->renderer_type )
+ {
+ /* all renderers where we are done after TC decoding (might include DMX to mono/stereo */
+ case RENDERER_DISABLE:
+ case RENDERER_MCMASA_MONO_STEREO:
+ case RENDERER_OSBA_STEREO:
+ case RENDERER_MONO_DOWNMIX:
+ buffer_mode = TC_BUFFER_MODE_BUFFER;
+ move16();
+ BREAK;
+ case RENDERER_NON_DIEGETIC_DOWNMIX:
+ case RENDERER_TD_PANNING:
+ case RENDERER_BINAURAL_OBJECTS_TD:
+ case RENDERER_BINAURAL_FASTCONV:
+ case RENDERER_BINAURAL_FASTCONV_ROOM:
+ case RENDERER_BINAURAL_PARAMETRIC:
+ case RENDERER_BINAURAL_PARAMETRIC_ROOM:
+ case RENDERER_STEREO_PARAMETRIC:
+ case RENDERER_DIRAC:
+ case RENDERER_PARAM_ISM:
+ case RENDERER_BINAURAL_MIXER_CONV:
+ case RENDERER_BINAURAL_MIXER_CONV_ROOM:
+ case RENDERER_OMASA_OBJECT_EXT:
+ case RENDERER_OMASA_MIX_EXT:
+ case RENDERER_OSBA_AMBI:
+ case RENDERER_OSBA_LS:
+ buffer_mode = TC_BUFFER_MODE_RENDERER;
+ move16();
+ BREAK;
+ case RENDERER_MC_PARAMMC:
+ IF( EQ_32( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) )
+ {
+ buffer_mode = TC_BUFFER_MODE_BUFFER; /* TCs are already the DMX to mono or stereo */
+ move16();
+ }
+ ELSE
+ {
+ buffer_mode = TC_BUFFER_MODE_RENDERER;
+ move16();
+ }
+ BREAK;
+ case RENDERER_MC:
+ if ( NE_16( ivas_dec_get_num_tc_channels_fx( st_ivas ), st_ivas->hDecoderConfig->nchan_out ) )
+ {
+ buffer_mode = TC_BUFFER_MODE_RENDERER;
+ move16();
+ }
+ BREAK;
+ case RENDERER_SBA_LINEAR_ENC:
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) && ( EQ_32( st_ivas->renderer_type, RENDERER_MC ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) && GE_16( ( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ) ), ( add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ) ) )
+ {
+ buffer_mode = TC_BUFFER_MODE_BUFFER;
+ move16();
+ }
+ ELSE
+ {
+ buffer_mode = TC_BUFFER_MODE_RENDERER;
+ move16();
+ }
+ BREAK;
+ case RENDERER_SBA_LINEAR_DEC:
+ test();
+ test();
+ IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) && ( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) ) )
+ {
+ buffer_mode = TC_BUFFER_MODE_BUFFER;
+ move16();
+ }
+ ELSE
+ {
+ buffer_mode = TC_BUFFER_MODE_RENDERER;
+ move16();
+ }
+ BREAK;
+ }
+
+ return buffer_mode;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_dec_tc_audio_allocate()
+ *
+ * allocate and initialize TC audio buffer
+ *--------------------------------------------------------------------------*/
+
+static ivas_error ivas_dec_tc_audio_allocate_fx(
+ DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: TC buffer handle */
+ const Word32 output_Fs, /* i : output sampling rate */
+ const Word16 Opt_tsm /* i : TSM option flag */
+)
+{
+ Word16 nsamp_to_allocate;
+ Word16 ch_idx, n_samp_full, n_samp_residual, offset;
+
+ IF( Opt_tsm )
+ {
+ n_samp_full = NS2SA_FX2( output_Fs, MAX_JBM_L_FRAME_NS );
+ n_samp_full = s_max( n_samp_full, L_FRAME48k ); /* buffers are shared between 'hTcBuffer->tc[]' and 'p_output_f[]': ensure minimal length */
+ n_samp_residual = sub( hTcBuffer->n_samples_granularity, 1 );
+ }
+ ELSE
+ {
+ n_samp_full = extract_l( Mpy_32_32( output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) );
+ n_samp_residual = 0;
+ move16();
+ }
+
+ nsamp_to_allocate = imult1616( s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ), n_samp_full );
+
+ IF( Opt_tsm )
+ {
+ /* note: this is stack memory buffer for TC decoded and also time-scale modified audio signals */
+ IF( ( hTcBuffer->tc_buffer_fx = (Word32 *) malloc( nsamp_to_allocate * sizeof( Word32 ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TC Buffer\n" ) );
+ }
+ set_zero_fx( hTcBuffer->tc_buffer_fx, nsamp_to_allocate );
+
+ offset = 0;
+ move16();
+ FOR( ch_idx = 0; ch_idx < s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); ch_idx++ )
+ {
+ hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset];
+ offset = add( offset, n_samp_full );
+ }
+ FOR( ; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ )
+ {
+ hTcBuffer->tc_fx[ch_idx] = NULL;
+ }
+
+ /* memory buffer for TC audio samples not rendered in the previous frame */
+ FOR( ch_idx = 0; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ )
+ {
+ IF( ( hTcBuffer->tc_buffer_old_fx[ch_idx] = (Word32 *) malloc( n_samp_residual * sizeof( Word32 ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TC Buffer\n" ) );
+ }
+ set_zero_fx( hTcBuffer->tc_buffer_old_fx[ch_idx], n_samp_residual );
+ }
+ FOR( ; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ )
+ {
+ hTcBuffer->tc_buffer_old_fx[ch_idx] = NULL;
+ }
+ }
+ else
+ {
+ hTcBuffer->tc_buffer_fx = NULL;
+
+ FOR( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ )
+ {
+ hTcBuffer->tc_fx[ch_idx] = NULL;
+ }
+
+ FOR( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ )
+ {
+ hTcBuffer->tc_buffer_old_fx[ch_idx] = NULL;
+ }
+ }
+
+ hTcBuffer->tc_buffer2_fx = NULL;
+
+ return IVAS_ERR_OK;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_dec_tc_buffer_open()
+ *
+ * Open and initialize transport channel buffer handle
+ *--------------------------------------------------------------------------*/
+
+ivas_error ivas_dec_tc_buffer_open_fx(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */
+ const Word16 nchan_transport_rend, /* i : number of TCs for rendering */
+ const Word16 nchan_transport_internal, /* i : number of totally buffered channels */
+ const Word16 nchan_full, /* i : number of channels to fully store */
+ const Word16 n_samples_granularity /* i : granularity of the renderer/buffer */
+)
+{
+ DECODER_TC_BUFFER_HANDLE hTcBuffer;
+ Word16 nMaxSlotsPerSubframe;
+ ivas_error error;
+ Word16 tmp, tmp_e;
+
+ /*-----------------------------------------------------------------*
+ * prepare library opening
+ *-----------------------------------------------------------------*/
+
+ IF( ( hTcBuffer = (DECODER_TC_BUFFER_HANDLE) malloc( sizeof( DECODER_TC_BUFFER ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TC Buffer\n" ) );
+ }
+
+ hTcBuffer->tc_buffer_mode = tc_buffer_mode;
+ move16();
+ hTcBuffer->nchan_transport_rend = nchan_transport_rend;
+ move16();
+ hTcBuffer->nchan_transport_internal = nchan_transport_internal;
+ move16();
+ hTcBuffer->nchan_buffer_full = nchan_full;
+ move16();
+ hTcBuffer->n_samples_granularity = n_samples_granularity;
+ move16();
+ hTcBuffer->n_samples_available = 0;
+ move16();
+ hTcBuffer->n_samples_buffered = 0;
+ move16();
+ hTcBuffer->n_samples_rendered = 0;
+ move16();
+ hTcBuffer->slots_rendered = 0;
+ move16();
+ hTcBuffer->subframes_rendered = 0;
+ move16();
+ hTcBuffer->n_samples_discard = 0;
+ move16();
+ hTcBuffer->n_samples_flushed = 0;
+ move16();
+ hTcBuffer->nb_subframes = MAX_PARAM_SPATIAL_SUBFRAMES;
+ move16();
+
+ /* nMaxSlotsPerSubframe = (Word16)(st_ivas->hDecoderConfig->output_Fs / (FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)) / st_ivas->hTcBuffer->n_samples_granularity; */
+ tmp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) );
+ tmp = BASOP_Util_Divide1616_Scale( tmp, hTcBuffer->n_samples_granularity, &tmp_e );
+ nMaxSlotsPerSubframe = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */
+
+ hTcBuffer->num_slots = mult0( nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES );
+ move16();
+
+ set16_fx( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS );
+ set16_fx( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES );
+
+ IF( ( error = ivas_dec_tc_audio_allocate_fx( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ st_ivas->hTcBuffer = hTcBuffer;
+
+ return IVAS_ERR_OK;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_jbm_dec_tc_audio_deallocate()
+ *
+ * deallocate TC audio buffer
+ *--------------------------------------------------------------------------*/
+
+static void ivas_jbm_dec_tc_audio_deallocate_fx(
+ DECODER_TC_BUFFER_HANDLE hTcBuffer /* i/o: JBM TSM buffer handle */
+)
+{
+ Word16 ch_idx;
+
+ IF( hTcBuffer != NULL )
+ {
+ IF( hTcBuffer->tc_buffer_fx != NULL )
+ {
+ FOR( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ )
+ {
+ hTcBuffer->tc_fx[ch_idx] = NULL;
+ }
+
+ free( hTcBuffer->tc_buffer_fx );
+ hTcBuffer->tc_buffer_fx = NULL;
+ }
+
+ FOR( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ )
+ {
+ IF( hTcBuffer->tc_buffer_old_fx[ch_idx] != NULL )
+ {
+ free( hTcBuffer->tc_buffer_old_fx[ch_idx] );
+ hTcBuffer->tc_buffer_old_fx[ch_idx] = NULL;
+ }
+ }
+
+ IF( hTcBuffer->tc_buffer2_fx != NULL )
+ {
+ free( hTcBuffer->tc_buffer2_fx );
+ hTcBuffer->tc_buffer2_fx = NULL;
+ }
+ }
+
+ return;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_dec_tc_buffer_close()
+ *
+ * Close transport channel buffer handle
+ *--------------------------------------------------------------------------*/
+
+void ivas_dec_tc_buffer_close_fx(
+ DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */
+)
+{
+ IF( *phTcBuffer != NULL )
+ {
+ ivas_jbm_dec_tc_audio_deallocate_fx( *phTcBuffer );
+
+ free( *phTcBuffer );
+ *phTcBuffer = NULL;
+ }
+
+ return;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_dec_tc_buffer_reconfigure()
+ *
+ * Reconfigure transport channel buffer handle
+ *--------------------------------------------------------------------------*/
+
+ivas_error ivas_dec_tc_buffer_reconfigure_fx(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */
+ const Word16 nchan_transport_rend, /* i : new number of TCs for rendering */
+ const Word16 nchan_transport_internal, /* i : new number of totally buffered channels */
+ const Word16 nchan_full, /* i : new number of channels to fully store */
+ const Word16 n_samples_granularity /* i : new granularity of the renderer/buffer */
+)
+{
+ Word16 ch_idx, num_tc_buffer_mem, n_samples_still_available;
+ Word32 tc_buffer_mem[MAX_INTERN_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES - 1];
+ ivas_error error;
+ DECODER_TC_BUFFER_HANDLE hTcBuffer;
+
+ hTcBuffer = st_ivas->hTcBuffer;
+ move16();
+
+ num_tc_buffer_mem = 0;
+ move16();
+ n_samples_still_available = 0;
+ move16();
+
+ IF( st_ivas->hDecoderConfig->Opt_tsm )
+ {
+ /* save samples of the TC buffer from the previous frame */
+ num_tc_buffer_mem = s_min( hTcBuffer->nchan_transport_internal, nchan_transport_internal );
+ n_samples_still_available = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_rendered );
+
+ /* what is remaining from last frame needs always be smaller than the new granularity */
+ assert( n_samples_still_available < n_samples_granularity );
+
+ FOR( ch_idx = 0; ch_idx < num_tc_buffer_mem; ch_idx++ )
+ {
+ Copy32( hTcBuffer->tc_buffer_old_fx[ch_idx] + hTcBuffer->n_samples_flushed, tc_buffer_mem[ch_idx], n_samples_still_available );
+ }
+ }
+
+ /* if granularity changes, adapt subframe_nb_slots */
+ IF( NE_16( n_samples_granularity, hTcBuffer->n_samples_granularity ) )
+ {
+ Word16 nMaxSlotsPerSubframeNew;
+ Word16 tmp, tmp_e;
+
+ /* nMaxSlotsPerSubframeNew = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / n_samples_granularity; */
+ tmp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) );
+ tmp = BASOP_Util_Divide1616_Scale( tmp, n_samples_granularity, &tmp_e );
+ nMaxSlotsPerSubframeNew = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */
+
+ /* if samples were flushed, take that into account here */
+ test();
+ IF( LT_16( n_samples_granularity, hTcBuffer->n_samples_granularity ) && hTcBuffer->n_samples_flushed > 0 )
+ {
+ hTcBuffer->subframe_nbslots[hTcBuffer->subframes_rendered - 1] = idiv1616( hTcBuffer->n_samples_flushed, n_samples_granularity );
+ hTcBuffer->n_samples_flushed = 0;
+ move16();
+ move16();
+ }
+ ELSE
+ {
+ hTcBuffer->subframe_nbslots[hTcBuffer->subframes_rendered - 1] = nMaxSlotsPerSubframeNew;
+ move16();
+ }
+ }
+
+ hTcBuffer->tc_buffer_mode = tc_buffer_mode;
+ move16();
+ hTcBuffer->nchan_transport_rend = nchan_transport_rend;
+ move16();
+ hTcBuffer->nchan_transport_internal = nchan_transport_internal;
+ move16();
+ hTcBuffer->nchan_buffer_full = nchan_full;
+ move16();
+ hTcBuffer->n_samples_granularity = n_samples_granularity;
+ move16();
+
+ /* reallocate TC audio buffers */
+
+ ivas_jbm_dec_tc_audio_deallocate_fx( hTcBuffer );
+
+ IF( ( error = ivas_dec_tc_audio_allocate_fx( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ /* propagate samples of the TC buffer from the previous frame */
+ FOR( ch_idx = 0; ch_idx < num_tc_buffer_mem; ch_idx++ )
+ {
+ Copy32( tc_buffer_mem[ch_idx], hTcBuffer->tc_buffer_old_fx[ch_idx], n_samples_still_available );
+ }
+
+ return IVAS_ERR_OK;
+}
diff --git a/lib_dec/ivas_dec_render_fx.c b/lib_dec/ivas_dec_render_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..93e30218b0d6b1b3ea1b1ec41b93f9d34b2e6eba
--- /dev/null
+++ b/lib_dec/ivas_dec_render_fx.c
@@ -0,0 +1,2364 @@
+/******************************************************************************************************
+
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository. All Rights Reserved.
+
+ This software is protected by copyright law and by international treaties.
+ The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository retain full ownership rights in their respective contributions in
+ the software. This notice grants no license of any kind, including but not limited to patent
+ license, nor is any license granted by implication, estoppel or otherwise.
+
+ Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
+ contributions.
+
+ This software is provided "AS IS", without any express or implied warranties. The software is in the
+ development stage. It is intended exclusively for experts who have experience with such software and
+ solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
+ and fitness for a particular purpose are hereby disclaimed and excluded.
+
+ Any dispute, controversy or claim arising under or in relation to providing this software shall be
+ submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
+ accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
+ the United Nations Convention on Contracts on the International Sales of Goods.
+
+*******************************************************************************************************/
+
+#include
+#include "options.h"
+#include "ivas_cnst.h"
+#include "prot_fx.h"
+#include "ivas_prot_fx.h"
+#include "ivas_prot_rend_fx.h"
+#include "ivas_rom_com.h"
+#include "wmc_auto.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
+
+
+/*-----------------------------------------------------------------------*
+ * Local function prototypes
+ *-----------------------------------------------------------------------*/
+
+static void ivas_dec_tc_buffer_playout_fx( Decoder_Struct *st_ivas, const UWord16 nSamplesAsked, UWord16 *nSamplesRendered, Word32 *output_fx[] );
+
+static void ivas_jbm_dec_copy_masa_meta_to_buffer_fx( Decoder_Struct *st_ivas );
+
+static void ivas_jbm_masa_sf_to_slot_map_fx( Decoder_Struct *st_ivas, const Word16 nCldfbTs );
+
+static Word16 ceil_fx16(
+ const Word16 inp,
+ const Word16 Q )
+{
+ Word16 ret = shr( inp, Q );
+
+ IF( ( s_and( inp, sub( shl( 1, Q ), 1 ) ) ) > 0 )
+ {
+ ret = add( ret, 1 );
+ }
+
+ return ret;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_dec_feed_tc_to_renderer()
+ *
+ * Feed decoded transport channels to the IVAS renderer routine
+ * + digest TC channels in ParamISM and ParamMC
+ *--------------------------------------------------------------------------*/
+
+void ivas_dec_feed_tc_to_renderer_fx(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ const Word16 nSamplesForRendering, /* i : number of TC samples available for rendering */
+ Word16 *nSamplesResidual /* o : number of samples not fitting into the renderer grid and buffer for the next call*/
+)
+{
+ Word32 tmp_buf_fx[MAX_JBM_L_FRAME48k];
+ Word32 *p_data_fx[FOA_CHANNELS + MAX_NUM_OBJECTS];
+#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER
+ Word16 n, n_render_timeslots, n_ch_cldfb, ch;
+#else
+ Word16 n, n_render_timeslots, n_ch_cldfb;
+ Word16 ch, offset, len_offset;
+#endif
+ DECODER_TC_BUFFER_HANDLE hTcBuffer;
+
+ hTcBuffer = st_ivas->hTcBuffer;
+ n_ch_cldfb = sub( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full );
+ move16();
+
+ hTcBuffer->q_tc_fx = Q11;
+ move16();
+
+ IF( st_ivas->hDecoderConfig->Opt_tsm )
+ {
+ Word16 n_samples_still_available;
+ Word16 n_ch_full_copy, n_ch_res_copy;
+
+ n_samples_still_available = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_rendered );
+ hTcBuffer->n_samples_buffered = add( add( n_samples_still_available, nSamplesForRendering ), hTcBuffer->n_samples_discard );
+ hTcBuffer->n_samples_available = i_mult( hTcBuffer->n_samples_granularity, idiv1616( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_granularity ) );
+ *nSamplesResidual = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_available );
+ move16();
+ move16();
+ move16();
+ n_ch_full_copy = s_min( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full );
+ n_ch_res_copy = sub( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full );
+
+#ifndef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER
+ /* buffers are shared between 'hTcBuffer->tc[]' and 'p_output_f[]':
+ in case of 'length(hTcBuffer->tc[]) < length(p_output_f[])', reset of TC buffer
+ pointers is needed after ivas_buffer_interleaved_to_deinterleaved() */
+ len_offset = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS );
+ IF( LT_16( len_offset, L_FRAME48k ) )
+ {
+ offset = 0;
+ move16();
+ FOR( ch = 0; ch < s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); ch++ )
+ {
+ hTcBuffer->tc_fx[ch] = &hTcBuffer->tc_buffer_fx[offset];
+ st_ivas->p_output_fx[ch] = hTcBuffer->tc_fx[ch];
+ offset = add( offset, len_offset );
+ }
+ }
+
+#endif
+ FOR( ch = 0; ch < n_ch_full_copy; ch++ )
+ {
+ Copy32( hTcBuffer->tc_fx[ch], tmp_buf_fx, nSamplesForRendering );
+ set_zero_fx( hTcBuffer->tc_fx[ch], hTcBuffer->n_samples_discard );
+ Copy32( hTcBuffer->tc_buffer_old_fx[ch], hTcBuffer->tc_fx[ch] + hTcBuffer->n_samples_discard, n_samples_still_available );
+ Copy32( tmp_buf_fx, hTcBuffer->tc_fx[ch] + n_samples_still_available + hTcBuffer->n_samples_discard, nSamplesForRendering - *nSamplesResidual );
+ Copy32( tmp_buf_fx + nSamplesForRendering - *nSamplesResidual, hTcBuffer->tc_buffer_old_fx[ch], *nSamplesResidual );
+ }
+
+ IF( n_ch_res_copy > 0 )
+ {
+ FOR( ; ch < hTcBuffer->nchan_transport_rend; ch++ )
+ {
+ p_data_fx[ch] = hTcBuffer->tc_fx[ch];
+ Copy32( hTcBuffer->tc_fx[ch], tmp_buf_fx, nSamplesForRendering );
+ Copy32( hTcBuffer->tc_buffer_old_fx[ch], p_data_fx[ch], n_samples_still_available );
+ Copy32( tmp_buf_fx, p_data_fx[ch] + n_samples_still_available, sub( nSamplesForRendering, *nSamplesResidual ) );
+ Copy32( tmp_buf_fx + nSamplesForRendering - *nSamplesResidual, hTcBuffer->tc_buffer_old_fx[ch], *nSamplesResidual );
+ }
+ }
+
+ n_render_timeslots = idiv1616( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity );
+ }
+ ELSE
+ {
+ FOR( n = 0; n < n_ch_cldfb; n++ )
+ {
+ p_data_fx[n] = &st_ivas->p_output_fx[n][0];
+ move16();
+ }
+
+ ch = s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full );
+ FOR( n = 0; n < ch; n++ )
+ {
+ hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n]; /* note: buffers needed in the TD decorellator */
+ move16();
+ }
+
+ hTcBuffer->n_samples_buffered = nSamplesForRendering;
+ hTcBuffer->n_samples_available = hTcBuffer->n_samples_buffered;
+ *nSamplesResidual = 0;
+ move16();
+ move16();
+ move16();
+
+ n_render_timeslots = DEFAULT_JBM_CLDFB_TIMESLOTS;
+ move16();
+ }
+
+ /* CLDFB analysis for ParamMC/ParamISM */
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && ( EQ_32( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) )
+ {
+ ivas_param_ism_dec_digest_tc_fx( st_ivas, n_render_timeslots, p_data_fx, Q11 );
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) && EQ_32( hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_RENDERER ) )
+ {
+ ivas_param_mc_dec_digest_tc_fx( st_ivas, (UWord8) n_render_timeslots, p_data_fx, Q11 );
+ }
+
+ hTcBuffer->n_samples_rendered = 0;
+ move16();
+ hTcBuffer->subframes_rendered = 0;
+ move16();
+
+ return;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_dec_render()
+ *
+ * Principal IVAS internal rendering routine
+ *--------------------------------------------------------------------------*/
+
+ivas_error ivas_dec_render_fx(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ const UWord16 nSamplesAsked, /* i : number of samples wanted */
+ UWord16 *nSamplesRendered, /* o : number of samples rendered */
+ UWord16 *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */
+ Word16 *data /* o : output synthesis signal Q0*/
+)
+{
+ Word16 n, nchan_out;
+ Word16 nchan_transport_rend;
+ Word16 nchan_remapped;
+ Word32 output_Fs;
+ AUDIO_CONFIG output_config;
+ Word16 nSamplesAskedLocal;
+ ivas_error error;
+ Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS];
+ Word32 *p_tc_fx[MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS];
+ Word16 subframe_len, gd_bits, exp, nchan_in, i, j, ch;
+ const Word16 output_q_factor = Q11;
+ move16();
+ Word16 nchan_out_syn_output;
+
+ push_wmops( "ivas_dec_render" );
+ /*----------------------------------------------------------------*
+ * Initialization of local vars after struct has been set
+ *----------------------------------------------------------------*/
+
+ output_Fs = st_ivas->hDecoderConfig->output_Fs;
+ move32();
+ nchan_out = st_ivas->hDecoderConfig->nchan_out;
+ move16();
+ nchan_transport_rend = st_ivas->hTcBuffer->nchan_transport_rend;
+ move16();
+ output_config = st_ivas->hDecoderConfig->output_config;
+ move32();
+ nSamplesAskedLocal = add( nSamplesAsked, st_ivas->hTcBuffer->n_samples_discard );
+ move16();
+
+ FOR( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ )
+ {
+ p_output_fx[n] = st_ivas->p_output_fx[n];
+ }
+
+ IF( !st_ivas->hDecoderConfig->Opt_tsm )
+ {
+ FOR( n = 0; n < MAX_INTERN_CHANNELS; n++ )
+ {
+ st_ivas->hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n];
+ }
+ }
+
+ FOR( n = 0; n < st_ivas->hTcBuffer->nchan_buffer_full; n++ )
+ {
+ p_tc_fx[n] = &st_ivas->hTcBuffer->tc_fx[n][st_ivas->hTcBuffer->n_samples_rendered];
+ }
+
+ /*----------------------------------------------------------------*
+ * Update combined orientation access index
+ *----------------------------------------------------------------*/
+
+ IF( st_ivas->hCombinedOrientationData != NULL )
+ {
+ /* take the discard samples into account here to make sure head rotation stays on the correct 5ms grid */
+ st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered_start = sub( st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered_start, st_ivas->hTcBuffer->n_samples_discard );
+ move16();
+
+ ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData );
+ }
+
+ /*----------------------------------------------------------------*
+ * Rendering
+ *----------------------------------------------------------------*/
+
+ *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal );
+ move16();
+
+ test();
+ test();
+ IF( EQ_32( st_ivas->ivas_format, UNDEFINED_FORMAT ) )
+ {
+ assert( 0 );
+ }
+ ELSE IF( EQ_32( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) )
+ {
+ ivas_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx );
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
+ {
+ /* Rendering */
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) )
+ {
+ ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc_fx, p_output_fx );
+ }
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) )
+ {
+ ivas_apply_non_diegetic_panning_fx( p_tc_fx[0], p_output_fx, st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered );
+ }
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
+ {
+ ivas_stereo2sba_fx( p_tc_fx, p_output_fx, *nSamplesRendered );
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
+ {
+ /* Rendering */
+ IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
+ {
+ test();
+ test();
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
+ {
+ ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, st_ivas->nchan_transport, p_output_fx );
+ }
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
+ {
+ ivas_param_ism_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx );
+
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
+ {
+ /* Convert CICP19 -> Ambisonics */
+ ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 );
+ }
+ }
+ }
+ ELSE /* ISM_MODE_DISC */
+ {
+ test();
+ test();
+ /* Loudspeaker or Ambisonics rendering */
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_TD_PANNING ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
+ {
+ /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */
+ ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_fx, *nSamplesRendered );
+ }
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) )
+ {
+ ivas_apply_non_diegetic_panning_fx( p_tc_fx[0], p_output_fx, st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered );
+ }
+#ifdef DEBUGGING
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) )
+#else
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
+#endif
+ {
+ /* Convert to Ambisonics */
+ FOR( i = 0; i < st_ivas->nchan_transport; i++ )
+ {
+ FOR( j = 0; j < HOA3_CHANNELS; j++ )
+ {
+ st_ivas->hIsmRendererData->gains_fx[i][j] = L_shr( st_ivas->hIsmRendererData->gains_fx[i][j], 1 ); // Q30 -> Q29
+ move32();
+ st_ivas->hIsmRendererData->prev_gains_fx[i][j] = L_shr( st_ivas->hIsmRendererData->prev_gains_fx[i][j], 1 ); // Q30 -> Q29
+ move32();
+ }
+ }
+
+ ivas_ism2sba_sf_fx( p_tc_fx, p_output_fx, st_ivas->hIsmRendererData, st_ivas->nchan_transport, *nSamplesRendered, st_ivas->hTcBuffer->n_samples_rendered, st_ivas->hIntSetup.ambisonics_order );
+
+ Word16 sba_num_chans = imult1616( add( st_ivas->hIntSetup.ambisonics_order, 1 ), add( st_ivas->hIntSetup.ambisonics_order, 1 ) );
+ FOR( j = 0; j < sba_num_chans; j++ )
+ {
+ scale_sig32( p_output_fx[j], *nSamplesRendered, sub( Q11, sub( add( output_q_factor, 29 ), 31 ) ) ); // Q11
+ }
+
+ FOR( i = 0; i < st_ivas->nchan_transport; i++ )
+ {
+ FOR( j = 0; j < 16; j++ )
+ {
+ st_ivas->hIsmRendererData->gains_fx[i][j] = L_shl( st_ivas->hIsmRendererData->gains_fx[i][j], 1 ); // Q29 -> Q30
+ move32();
+ st_ivas->hIsmRendererData->prev_gains_fx[i][j] = L_shl( st_ivas->hIsmRendererData->prev_gains_fx[i][j], 1 ); // Q29 -> Q30
+ move32();
+ }
+ }
+ }
+
+ /* Binaural rendering */
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) )
+ {
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
+ {
+ IF( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output_fx, *nSamplesRendered ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ ELSE
+ {
+ IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
+ {
+ st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor;
+ subframe_len = imult1616( st_ivas->hTcBuffer->subframe_nbslots[0], st_ivas->hTcBuffer->n_samples_granularity );
+ gd_bits = find_guarded_bits_fx( subframe_len );
+ exp = 13;
+ move16();
+ nchan_in = 12;
+ move16();
+ nchan_out = 2;
+ move16();
+ exp = sub( exp, gd_bits );
+ *st_ivas->hCrendWrapper->p_io_qfactor = exp;
+ move16();
+ FOR( i = 0; i < nchan_in; i++ )
+ {
+ scale_sig32( p_output_fx[i], *nSamplesRendered, negate( sub( 11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q11
+ }
+
+ IF( NE_32( ( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, *nSamplesRendered, output_Fs, 0 ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ FOR( i = 0; i < nchan_out; i++ )
+ {
+ scale_sig32( p_output_fx[i], *nSamplesRendered, sub( 11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11
+ }
+ }
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
+ {
+ nchan_remapped = nchan_transport_rend;
+ move16();
+
+ test();
+ test();
+ /* Loudspeakers, Ambisonics or Binaural rendering */
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
+ {
+ ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx );
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
+ {
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) )
+ {
+ ivas_dirac_dec_render_fx( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx );
+ }
+ }
+ ELSE
+ {
+ IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
+ {
+ nchan_remapped = st_ivas->nchan_transport;
+ move16();
+ test();
+ test();
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
+ {
+ test();
+ IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) )
+ {
+ IF( NE_32( ( error = ivas_omasa_dirac_td_binaural_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE
+ {
+ ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx );
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) )
+ {
+ ivas_omasa_dirac_rend_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx );
+ }
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) || EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) )
+ {
+ ivas_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx );
+ ivas_omasa_rearrange_channels_fx( p_output_fx, st_ivas->nchan_ism, *nSamplesRendered );
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
+ {
+ nchan_remapped = nchan_transport_rend;
+ move16();
+
+ /* Loudspeakers, Ambisonics or Binaural rendering */
+ IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
+ {
+ test();
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) )
+ {
+ SPAR_DEC_HANDLE hSpar;
+ hSpar = st_ivas->hSpar;
+ hSpar->hMdDec->Q_mixer_mat = 30;
+ move16();
+
+ IF( NE_32( ( error = ivas_osba_dirac_td_binaural_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_STEREO ) )
+ {
+ test();
+ /* shift SBA channels to avoid overwrite by ISM upmix in 1 object case and non-TSM unified channel memory*/
+ IF( EQ_16( st_ivas->nchan_ism, 1 ) && EQ_16( st_ivas->hDecoderConfig->Opt_tsm, 0 ) )
+ {
+ Copy32( p_tc_fx[2], p_output_fx[3], *nSamplesRendered );
+ Copy32( p_tc_fx[1], p_output_fx[2], *nSamplesRendered );
+ p_tc_fx[1] = p_output_fx[2];
+ p_tc_fx[2] = p_output_fx[3];
+ }
+
+ /* render objects */
+ ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_fx, *nSamplesRendered );
+
+ /* add already rendered SBA part */
+ ivas_osba_stereo_add_channels_fx( p_tc_fx, p_output_fx, st_ivas->hSbaIsmData->gain_bed_fx, nchan_out, st_ivas->nchan_ism, st_ivas->ism_mode, *nSamplesRendered );
+ }
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || EQ_32( st_ivas->renderer_type, RENDERER_OSBA_LS ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
+ {
+ IF( NE_32( ( error = ivas_osba_render_sf_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) /*EXT output = individual objects + HOA3*/
+ {
+ IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, &p_output_fx[st_ivas->nchan_ism] ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ FOR( n = 0; n < st_ivas->nchan_ism; n++ )
+ {
+ Copy32( p_tc_fx[n], p_output_fx[n], *nSamplesRendered );
+ }
+ }
+ ELSE
+ {
+ IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
+ {
+ ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx );
+
+ FOR( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ )
+ {
+ scale_sig32( p_output_fx[n], *nSamplesRendered, 1 );
+ }
+ }
+ ELSE
+ {
+ IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
+ {
+ FOR( n = st_ivas->hIntSetup.nchan_out_woLFE - 1; n >= 0; n-- )
+ {
+ Copy32( p_output_fx[n], p_output_fx[n + st_ivas->nchan_ism], *nSamplesRendered );
+ }
+ FOR( n = 0; n < st_ivas->nchan_ism; n++ )
+ {
+ set32_fx( p_output_fx[n], 0, *nSamplesRendered );
+ }
+ }
+ FOR( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ )
+ {
+ scale_sig32( p_output_fx[n], *nSamplesRendered, 1 );
+ }
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) )
+ {
+ IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) )
+ {
+ Word16 crendInPlaceRotation = FALSE;
+ move16();
+
+ test();
+ test();
+ test();
+ IF( NE_32( st_ivas->transport_config, st_ivas->intern_config ) && ( EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA3 ) ) )
+ {
+ IF( LT_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ) ) )
+ {
+ crendInPlaceRotation = TRUE;
+ move16();
+
+ ivas_mc2sba_fx( st_ivas->hTransSetup, p_tc_fx, p_output_fx, *nSamplesRendered, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE_FX );
+ }
+ }
+
+ /* Rendering */
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
+ {
+ st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor;
+ subframe_len = imult1616( st_ivas->hTcBuffer->subframe_nbslots[0], st_ivas->hTcBuffer->n_samples_granularity );
+ gd_bits = find_guarded_bits_fx( subframe_len );
+ exp = 13;
+ move16();
+ IF( NE_32( ( error = getAudioConfigNumChannels( st_ivas->intern_config, &nchan_in ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ IF( NE_32( ( error = getAudioConfigNumChannels( st_ivas->hOutSetup.output_config, &nchan_out ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ exp = sub( exp, gd_bits );
+ *st_ivas->hCrendWrapper->p_io_qfactor = exp;
+ move16();
+
+ IF( crendInPlaceRotation )
+ {
+ FOR( i = 0; i < nchan_in; i++ )
+ {
+ scale_sig32( p_output_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor
+ }
+ }
+ ELSE
+ {
+ FOR( i = 0; i < nchan_in; i++ )
+ {
+ scale_sig32( p_tc_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor
+ }
+ }
+
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
+ {
+ IF( ( error = ivas_rend_crendProcessSubframesSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData,
+ &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, p_output_fx, p_output_fx, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ ELSE
+ {
+ IF( NE_32( ( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData,
+ &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, p_output_fx, p_output_fx, *nSamplesRendered, output_Fs, 0 ) ),
+ IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx );
+ }
+
+ IF( crendInPlaceRotation )
+ {
+ n = nchan_in;
+ }
+ ELSE
+ {
+ n = nchan_out;
+ }
+ move16();
+
+ FOR( i = 0; i < n; i++ )
+ {
+ scale_sig32( p_output_fx[i], *nSamplesRendered, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11
+ }
+
+ FOR( i = n; i < nchan_in; i++ )
+ {
+ scale_sig32( p_tc_fx[i], *nSamplesRendered, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) )
+ {
+ ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc_fx, p_output_fx );
+ }
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
+ {
+ ivas_mc2sba_fx( st_ivas->hIntSetup, p_tc_fx, p_output_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 );
+ }
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) )
+ {
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
+ {
+ IF( NE_32( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ else
+ {
+ IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx );
+ }
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
+ {
+ ivas_mc_paramupmix_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_tc_fx, p_output_fx );
+
+ /* Rendering */
+ test();
+ test();
+ IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) && !st_ivas->hDecoderConfig->Opt_Headrotation )
+ {
+ /* handled in CLDFB domain already */
+ IF( NE_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
+ {
+ ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_output_fx, p_output_fx );
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) )
+ {
+ ivas_ls_setup_conversion_fx( st_ivas, MC_PARAMUPMIX_MAX_INPUT_CHANS, *nSamplesRendered, p_output_fx, p_output_fx );
+ }
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
+ {
+ ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 );
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
+ {
+ Word16 channel_active_fx[MAX_OUTPUT_CHANNELS];
+ Word16 nchan_out_cov;
+ Word16 nchan_out_cldfb = 0;
+ move16();
+
+ set16_fx( channel_active_fx, 0, MAX_LS_CHANNELS );
+ Word16 nchan_transport_tmp = st_ivas->nchan_transport;
+ move16();
+ output_Fs = st_ivas->hDecoderConfig->output_Fs;
+ move32();
+ Word16 nchan_out_transport = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe );
+ test();
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
+ {
+ nchan_out_cldfb = BINAURAL_CHANNELS;
+ move16();
+ set16_fx( channel_active_fx, 1, BINAURAL_CHANNELS );
+ nchan_out_cov = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe );
+ }
+ ELSE IF( EQ_32( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_CLDFB ) )
+ {
+ nchan_out_cov = nchan_out_transport;
+ move16();
+ nchan_out_cldfb = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe );
+ }
+ ELSE IF( EQ_32( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_32( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) )
+ {
+ nchan_out_cov = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe );
+ nchan_out_cldfb = nchan_out_cov;
+ move16();
+ set16_fx( channel_active_fx, 1, nchan_out_cov );
+ }
+ ELSE
+ {
+ nchan_out_cov = nchan_out_transport;
+ move16();
+ nchan_out_cldfb = nchan_out_transport;
+ move16();
+ set16_fx( channel_active_fx, 1, nchan_out_cov );
+ }
+ IF( st_ivas->hParamMC->max_band_decorr > 0 )
+ {
+ Word16 tmp;
+ tmp = L_norm_arr( st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_fx, st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_len );
+ scale_sig32( st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_fx, st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_len, tmp ); // Q(st_ivas->hParamMC->h_freq_domain_decorr_ap_state->q_decorr_buffer+ tmp)
+ st_ivas->hParamMC->h_freq_domain_decorr_ap_state->q_decorr_buffer = add( st_ivas->hParamMC->h_freq_domain_decorr_ap_state->q_decorr_buffer, tmp );
+ move16();
+ }
+ /* CLDFB synthesis */
+ FOR( ch = 0; ch < nchan_out_cldfb; ch++ )
+ {
+ IF( st_ivas->cldfbSynDec[ch] )
+ {
+ scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, ( Q5 - Q11 ) ); // Q5
+ st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q5;
+ move16();
+ }
+ }
+ Word16 tempp;
+ FOR( Word16 param_band_idx = 0; param_band_idx < st_ivas->hParamMC->num_param_bands_synth; param_band_idx++ )
+ {
+ tempp = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_len );
+ scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_len, tempp ); // Q(31-(st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx]- tempp))
+ st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx] = sub( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx], tempp );
+ move16();
+
+ IF( LT_16( st_ivas->hParamMC->band_grouping[param_band_idx], st_ivas->hParamMC->h_output_synthesis_params.max_band_decorr ) )
+ {
+ tempp = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_len );
+ scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_len, tempp ); // Q(31- (st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx] - tempp))
+ st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx] = sub( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx], tempp );
+ move16();
+ }
+ }
+
+ ivas_param_mc_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx, channel_active_fx );
+
+ FOR( ch = 0; ch < nchan_out_cldfb; ch++ )
+ {
+ IF( st_ivas->cldfbSynDec[ch] )
+ {
+ scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, Q11 - Q5 ); // Q11
+ st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11;
+ move16();
+ }
+ }
+ IF( EQ_16( st_ivas->hParamMC->slots_rendered, st_ivas->hParamMC->num_slots ) )
+ {
+ FOR( Word16 param_band_idx = 0; param_band_idx < st_ivas->hParamMC->hMetadataPMC->nbands_coded; param_band_idx++ )
+ {
+ IF( LT_16( st_ivas->hParamMC->band_grouping[param_band_idx], st_ivas->hParamMC->h_output_synthesis_params.max_band_decorr ) )
+ {
+ Copy32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_fx[param_band_idx], imult1616( nchan_transport_tmp, nchan_out_cov ) );
+ st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_exp[param_band_idx] = st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx];
+ move16();
+ }
+ Copy32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[param_band_idx], imult1616( nchan_transport_tmp, nchan_out_cov ) );
+ st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_exp[param_band_idx] = st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx];
+ move16();
+ }
+ }
+ }
+ ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
+ {
+ nchan_remapped = st_ivas->nchan_transport;
+ move16();
+
+ test();
+ test();
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
+ {
+ ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx );
+ }
+ ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) /* rendering to CICPxx and Ambisonics */
+ {
+ ivas_dirac_dec_render_fx( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx );
+
+ test();
+ test();
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
+ {
+ /* we still need to copy the separate channel if available */
+ IF( st_ivas->hOutSetup.separateChannelEnabled )
+ {
+ Copy32( p_tc_fx[LFE_CHANNEL - 1], p_output_fx[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered );
+ }
+
+ ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 );
+ }
+ ELSE IF( EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_5_1 ) && ( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) ) )
+ {
+ FOR( n = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; n < ( st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ); n++ )
+ {
+ set32_fx( p_output_fx[n], 0, *nSamplesRendered );
+ }
+ }
+ }
+
+ /* copy discrete C and TD LFE from internal TC to output */
+ IF( st_ivas->hOutSetup.separateChannelEnabled )
+ {
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) ||
+ EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) ||
+ EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || ( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && GT_16( st_ivas->hOutSetup.num_lfe, 0 ) ) )
+ {
+ Copy32( p_tc_fx[LFE_CHANNEL], p_output_fx[LFE_CHANNEL], *nSamplesRendered );
+ Copy32( p_tc_fx[LFE_CHANNEL - 1], p_output_fx[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered );
+ }
+ ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe == 0 )
+ {
+ Copy32( p_tc_fx[LFE_CHANNEL - 1], p_output_fx[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered );
+ }
+ }
+ }
+ }
+
+ /*----------------------------------------------------------------*
+ * Write IVAS output channels
+ * - compensation for saturation
+ * - float to integer conversion
+ *----------------------------------------------------------------*/
+
+ st_ivas->hTcBuffer->n_samples_available = sub( st_ivas->hTcBuffer->n_samples_available, *nSamplesRendered );
+ st_ivas->hTcBuffer->n_samples_rendered = add( st_ivas->hTcBuffer->n_samples_rendered, *nSamplesRendered );
+ move16();
+ move16();
+
+ /* update global combined orientation start index */
+ ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, *nSamplesRendered );
+
+ IF( st_ivas->hTcBuffer->n_samples_discard > 0 )
+ {
+ FOR( n = 0; n < s_min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); n++ )
+ {
+ p_output_fx[n] += st_ivas->hTcBuffer->n_samples_discard;
+ }
+ *nSamplesRendered = sub( (Word16) *nSamplesRendered, st_ivas->hTcBuffer->n_samples_discard );
+ move16();
+ st_ivas->hTcBuffer->n_samples_discard = 0;
+ move16();
+ }
+
+ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
+ {
+ const Word32 *p_output_fx_const[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS];
+
+ nchan_out_syn_output = i_mult( BINAURAL_CHANNELS, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses );
+
+ /* Save TD signals for pose correction if they are to be used.
+ *
+ * NOTE: Here BASOP differs from the float version. In float, we push samples to TD ring buffer in lib_dec.c function isar_render_poses. */
+ IF( st_ivas->hSplitBinRend->hMultiBinTdData != NULL )
+ {
+ FOR( i = 0; i < nchan_out_syn_output; i++ )
+ {
+ p_output_fx_const[i] = p_output_fx[i];
+ }
+ ivas_TD_RINGBUF_PushChannels( st_ivas->hSplitBinRend->hMultiBinTdData, p_output_fx_const, *nSamplesRendered );
+ }
+
+#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR
+ if ( st_ivas->flushing )
+ {
+ nchan_out_syn_output = BINAURAL_CHANNELS;
+ move16();
+ }
+#endif
+ }
+ ELSE
+ {
+ nchan_out_syn_output = nchan_out;
+ move16();
+ }
+
+ IF( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 )
+ {
+ IF( NE_32( st_ivas->ivas_format, MONO_FORMAT ) )
+ {
+#ifndef DISABLE_LIMITER
+ ivas_limiter_dec_fx( st_ivas->hLimiter, p_output_fx, nchan_out, *nSamplesRendered, st_ivas->BER_detect, output_q_factor );
+#endif
+ }
+ }
+
+ ivas_syn_output_fx( p_output_fx, output_q_factor, *nSamplesRendered, nchan_out_syn_output, data );
+
+ *nSamplesAvailableNext = st_ivas->hTcBuffer->n_samples_available;
+ move16();
+
+ pop_wmops();
+ return IVAS_ERR_OK;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_jbm_dec_flush_renderer()
+ *
+ * Flush samples if renderer granularity changes on a bitrate change in JBM
+ *--------------------------------------------------------------------------*/
+
+ivas_error ivas_jbm_dec_flush_renderer_fx(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ const Word16 tc_granularity_new, /* i : new renderer granularity */
+ const RENDERER_TYPE renderer_type_old, /* i : old renderer type */
+ const AUDIO_CONFIG intern_config_old, /* i : old internal config */
+ const IVAS_OUTPUT_SETUP_HANDLE hIntSetupOld, /* i : old internal output setup */
+ const MC_MODE mc_mode_old, /* i : old MC mode */
+ const ISM_MODE ism_mode_old, /* i : old ISM mode */
+ UWord16 *nSamplesRendered, /* o : number of samples flushed */
+ Word16 *data /* o : output synthesis signal Q0*/
+)
+{
+ ivas_error error;
+ Word16 n_samples_still_available;
+ Word16 n_slots_still_available;
+ Word16 n_samples_to_render;
+ Word16 n_samples_granularity;
+ DECODER_TC_BUFFER_HANDLE hTcBuffer;
+ Word32 *p_output_fx[MAX_LS_CHANNELS + MAX_NUM_OBJECTS];
+ Word16 nchan_in, nchan_out;
+ Word16 ch_idx;
+
+
+ IF( !st_ivas->hDecoderConfig->Opt_tsm )
+ {
+ return IVAS_ERR_OK;
+ }
+
+ FOR( ch_idx = 0; ch_idx < ( MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ); ch_idx++ )
+ {
+ p_output_fx[ch_idx] = st_ivas->p_output_fx[ch_idx];
+ }
+
+ *nSamplesRendered = 0;
+ move16();
+ hTcBuffer = st_ivas->hTcBuffer;
+ n_samples_granularity = hTcBuffer->n_samples_granularity;
+ move16();
+
+ /* get number of possible slots in new granularity */
+ n_samples_still_available = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_rendered );
+
+ // n_slots_still_available = n_samples_still_available / tc_granularity_new;
+ Word16 tmp, tmp_e;
+ tmp = BASOP_Util_Divide1616_Scale( n_samples_still_available, tc_granularity_new, &tmp_e );
+ n_slots_still_available = shr( tmp, sub( 15, tmp_e ) );
+ *nSamplesRendered = imult1616( n_slots_still_available, tc_granularity_new );
+ n_samples_to_render = *nSamplesRendered;
+ move16();
+ move16();
+ n_samples_still_available = sub( n_samples_still_available, n_samples_to_render );
+ assert( n_samples_still_available < tc_granularity_new );
+
+ /* update combined orientation access index */
+ ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData );
+
+ IF( n_slots_still_available )
+ {
+
+ /* render available full slots (with new lower granularity) */
+ FOR( ch_idx = 0; ch_idx < s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); ch_idx++ )
+ {
+ /* move it at the beginning of the TC buffer with zero padding */
+ Copy32( hTcBuffer->tc_buffer_old_fx[ch_idx], hTcBuffer->tc_fx[ch_idx], n_samples_to_render );
+ set_zero_fx( hTcBuffer->tc_fx[ch_idx] + n_samples_to_render, sub( hTcBuffer->n_samples_granularity, n_samples_to_render ) );
+ }
+
+ /* simple change of the slot info */
+ hTcBuffer->num_slots = 1;
+ hTcBuffer->nb_subframes = 1;
+ hTcBuffer->subframes_rendered = 0;
+ hTcBuffer->slots_rendered = 0;
+ hTcBuffer->subframe_nbslots[0] = 1;
+ hTcBuffer->n_samples_buffered = add( n_samples_granularity, n_samples_still_available );
+ hTcBuffer->n_samples_available = 0;
+ hTcBuffer->n_samples_flushed = n_samples_to_render;
+ hTcBuffer->n_samples_rendered = 0;
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+
+
+ test();
+ IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) )
+ {
+ IF( EQ_16( ism_mode_old, ISM_MODE_DISC ) )
+ {
+ /* Binaural rendering */
+ IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_OBJECTS_TD ) )
+ {
+ IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, n_samples_granularity ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ ELSE IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
+ {
+ /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */
+ set16_fx( st_ivas->hIsmRendererData->interpolator_fx, 32767, n_samples_granularity ); // 32767=1.0f in Q15
+
+ ivas_ism_render_sf_fx( st_ivas, renderer_type_old, p_output_fx, n_samples_granularity );
+
+ st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor;
+ *st_ivas->hCrendWrapper->p_io_qfactor = 11;
+
+ move16();
+ IF( NE_32( ( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL,
+ NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ),
+ IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
+ }
+ ELSE
+ {
+ return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong ISM_MODE in VoIP renderer flushing!" );
+ }
+ }
+ ELSE IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) )
+ {
+ IF( EQ_16( mc_mode_old, MC_MODE_MCT ) )
+ {
+ Word16 crendInPlaceRotation = FALSE;
+
+ test();
+ test();
+ test();
+ IF( NE_16( st_ivas->transport_config, intern_config_old ) && ( EQ_16( intern_config_old, IVAS_AUDIO_CONFIG_FOA ) || EQ_16( intern_config_old, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_16( intern_config_old, IVAS_AUDIO_CONFIG_HOA3 ) ) )
+ {
+ IF( GT_16( sub( add( hIntSetupOld->nchan_out_woLFE, hIntSetupOld->num_lfe ), add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ) ), 0 ) )
+ {
+ crendInPlaceRotation = TRUE;
+ move16();
+ ivas_mc2sba_fx( st_ivas->hTransSetup, hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, hIntSetupOld->ambisonics_order, GAIN_LFE_FX );
+ }
+ }
+
+ test();
+ IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV ) || EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
+ {
+ st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor;
+ IF( NE_32( ( error = getAudioConfigNumChannels( intern_config_old, &nchan_in ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ IF( NE_32( ( error = getAudioConfigNumChannels( st_ivas->hOutSetup.output_config, &nchan_out ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ Word16 subframe_len, gd_bits;
+ subframe_len = imult1616( st_ivas->hTcBuffer->subframe_nbslots[0], n_samples_granularity );
+ gd_bits = find_guarded_bits_fx( subframe_len );
+ *st_ivas->hCrendWrapper->p_io_qfactor = sub( 13, gd_bits );
+ FOR( Word16 i = 0; i < nchan_in; i++ )
+ {
+ scale_sig32( p_output_fx[i], *nSamplesRendered, sub( *st_ivas->hCrendWrapper->p_io_qfactor, Q11 ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor
+ }
+
+ IF( NE_32( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : st_ivas->hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ ivas_binaural_add_LFE_fx( st_ivas, n_samples_granularity, hTcBuffer->tc_fx, p_output_fx );
+
+ FOR( Word16 i = 0; i < nchan_in; i++ )
+ {
+ scale_sig32( p_output_fx[i], *nSamplesRendered, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11
+ }
+ }
+ ELSE IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_OBJECTS_TD ) )
+ {
+ IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, n_samples_granularity ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, hTcBuffer->tc_fx, p_output_fx );
+ }
+ ELSE
+ {
+ return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong renderer in MCT VoIP renderer flushing!" );
+ }
+ }
+ ELSE
+ {
+ return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong MC_MODE in VoIP renderer flushing!" );
+ }
+ }
+ ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_FORMAT ) )
+ {
+ IF( EQ_16( ism_mode_old, ISM_MASA_MODE_DISC ) )
+ {
+ Word32 *tc_local_fx[MAX_NUM_OBJECTS];
+ Word16 last_dirac_md_idx;
+ UWord16 nSamplesAvailableNext;
+ ISM_MODE ism_mode_orig;
+ RENDERER_TYPE renderer_type_orig;
+ Word32 ivas_total_brate;
+
+ /* copy from ISM delay buffer to the correct place in TCs */
+ move16();
+ FOR( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ )
+ {
+ tc_local_fx[ch_idx] = &st_ivas->hTcBuffer->tc_fx[ch_idx + 2][hTcBuffer->n_samples_rendered];
+ Copy32( st_ivas->hMasaIsmData->delayBuffer_fx[ch_idx], tc_local_fx[ch_idx], st_ivas->hMasaIsmData->delayBuffer_size ); /*Q11*/
+ }
+
+ /* to render flushed samples, use configuration from the last received frame */
+ ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
+ renderer_type_orig = st_ivas->renderer_type;
+ ism_mode_orig = st_ivas->ism_mode;
+ st_ivas->ism_mode = ism_mode_old;
+ st_ivas->renderer_type = renderer_type_old;
+ st_ivas->hDecoderConfig->ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate;
+ last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1];
+
+ /* transfer adapted sf info from hTcBuffer to DirAC */
+ st_ivas->hSpatParamRendCom->nb_subframes = 1;
+ st_ivas->hSpatParamRendCom->subframes_rendered = 0;
+ st_ivas->hSpatParamRendCom->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME;
+ st_ivas->hSpatParamRendCom->slots_rendered = 0;
+ st_ivas->hSpatParamRendCom->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME;
+ set16_fx( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available );
+
+ IF( ( error = ivas_omasa_dirac_td_binaural_fx( st_ivas, (UWord16) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, CPE_CHANNELS, p_output_fx ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ /* restore original configuration */
+ st_ivas->ism_mode = ism_mode_orig;
+ st_ivas->renderer_type = renderer_type_orig;
+ st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate;
+ }
+ }
+ ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
+ {
+ IF( EQ_32( ism_mode_old, ISM_SBA_MODE_DISC ) )
+ {
+ Word32 *tc_local_fx[MAX_TRANSPORT_CHANNELS];
+ Word16 last_spar_md_idx;
+ Word16 last_dirac_md_idx;
+ UWord16 nSamplesAvailableNext;
+ ISM_MODE ism_mode_orig;
+ RENDERER_TYPE renderer_type_orig;
+ Word32 ivas_total_brate;
+
+ ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
+ renderer_type_orig = st_ivas->renderer_type;
+ ism_mode_orig = st_ivas->ism_mode;
+
+ /* to render flushed samples, use configuration from the last received frame */
+ move32();
+ st_ivas->ism_mode = ism_mode_old;
+ st_ivas->renderer_type = renderer_type_old;
+ st_ivas->hDecoderConfig->ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate;
+
+ last_spar_md_idx = st_ivas->hSpar->render_to_md_map[st_ivas->hSpar->slots_rendered - 1];
+ last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1];
+ move16();
+ move16();
+
+ /* copy from ISM delay buffer to the correct place in TCs */
+ FOR( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ )
+ {
+ tc_local_fx[ch_idx] = &st_ivas->hTcBuffer->tc_fx[ch_idx][hTcBuffer->n_samples_rendered];
+ Copy32( st_ivas->hSbaIsmData->delayBuffer_fx[ch_idx], tc_local_fx[ch_idx], st_ivas->hSbaIsmData->delayBuffer_size );
+ }
+
+ /* transfer adapted sf info from hTcBuffer to SPAR and DirAC */
+ st_ivas->hSpar->nb_subframes = 1;
+ st_ivas->hSpar->subframes_rendered = 0;
+ st_ivas->hSpar->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME;
+ st_ivas->hSpar->slots_rendered = 0;
+ st_ivas->hSpar->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME;
+ st_ivas->hSpatParamRendCom->nb_subframes = 1;
+ st_ivas->hSpatParamRendCom->subframes_rendered = 0;
+ st_ivas->hSpatParamRendCom->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME;
+ st_ivas->hSpatParamRendCom->slots_rendered = 0;
+ st_ivas->hSpatParamRendCom->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME;
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+
+ /* also adapt md maps, just use the last index */
+ set16_fx( st_ivas->hSpar->render_to_md_map, last_spar_md_idx, n_slots_still_available );
+ set16_fx( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available );
+
+ /* render the last subframe */
+ IF( NE_32( ( error = ivas_osba_dirac_td_binaural_fx( st_ivas, (UWord16) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+
+ /* restore original configuration */
+ st_ivas->ism_mode = ism_mode_orig;
+ st_ivas->renderer_type = renderer_type_orig;
+ st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate;
+ }
+ }
+ ELSE
+ {
+ return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong IVAS format in VoIP renderer flushing!" );
+ }
+
+ hTcBuffer->n_samples_rendered = hTcBuffer->n_samples_granularity;
+ }
+
+ /* update global combined orientation start index */
+ ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, *nSamplesRendered );
+
+ *nSamplesRendered = n_samples_to_render;
+ move16();
+
+ /* Only write out the valid data*/
+ IF( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 )
+ {
+ IF( NE_16( st_ivas->ivas_format, MONO_FORMAT ) )
+ {
+#ifndef DISABLE_LIMITER
+ Word16 exp = 11;
+ move16();
+ FOR( ch_idx = 0; ch_idx < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ )
+ {
+ p_output_fx[ch_idx] = st_ivas->p_output_fx[ch_idx];
+ }
+ ivas_limiter_dec_fx( st_ivas->hLimiter, p_output_fx, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, exp );
+#endif
+ }
+ }
+
+ ivas_syn_output_fx( p_output_fx, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, data );
+
+ return IVAS_ERR_OK;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_jbm_dec_set_discard_samples()
+ *
+ * Set number of samples to discard in the first subframe
+ * if the renderer granularity changes on a bitrate change in JBM processing
+ *--------------------------------------------------------------------------*/
+
+ivas_error ivas_jbm_dec_set_discard_samples_fx(
+ Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */
+)
+{
+ Word16 nMaxSlotsPerSubframe, nSlotsInFirstSubframe;
+ Word16 temp, temp_e;
+
+ /* render first frame with front zero padding and discarding those samples */
+ /* nMaxSlotsPerSubframe = (Word16)(st_ivas->hDecoderConfig->output_Fs / (FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)) / st_ivas->hTcBuffer->n_samples_granularity; */
+ temp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) );
+ temp = BASOP_Util_Divide1616_Scale( temp, st_ivas->hTcBuffer->n_samples_granularity, &temp_e );
+ nMaxSlotsPerSubframe = shr( temp, sub( 15, temp_e ) ); /* Q0 */
+ nSlotsInFirstSubframe = sub( nMaxSlotsPerSubframe, st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] );
+
+ IF( nSlotsInFirstSubframe > 0 )
+ {
+ st_ivas->hTcBuffer->n_samples_discard = imult1616( sub( nMaxSlotsPerSubframe, nSlotsInFirstSubframe ), st_ivas->hTcBuffer->n_samples_granularity );
+ /* set last subframes number to max to ensure correct continuation */
+ st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nMaxSlotsPerSubframe;
+ move16();
+ move16();
+ }
+
+ return IVAS_ERR_OK;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_dec_get_adapted_linear_interpolator()
+ *
+ * Get an interpolator that is adapted to (time scale modified) IVAS frame
+ *--------------------------------------------------------------------------*/
+
+void ivas_dec_get_adapted_linear_interpolator_fx(
+ const Word16 default_interp_length, /* i : default length of the (full-frame) interpolator */
+ const Word16 interp_length, /* i : length of the interpolator to be created */
+ Word16 *interpolator_fx /* o : the interpolator Q15 */
+)
+{
+ Word16 segment_len, idx;
+ Word16 dec_fx;
+ Word16 dec_e;
+
+ segment_len = shr( default_interp_length, 1 );
+ dec_fx = divide1616( 1, default_interp_length ); /*32767 / default_interp_length*/
+
+ interpolator_fx[interp_length - 1] = 32767; /* (1.0f in Q15) -1 */
+ move16();
+ interpolator_fx[interp_length - 2] = add( sub( 32767, dec_fx ), 1 ); // Use 32768 to maintain precision
+ move16();
+ FOR( idx = interp_length - 3; idx >= segment_len; idx-- )
+ {
+ interpolator_fx[idx] = s_max( 0, sub( interpolator_fx[idx + 1], dec_fx ) );
+ move16();
+ }
+
+ IF( interpolator_fx[idx + 1] > 0 )
+ {
+ dec_fx = BASOP_Util_Divide1616_Scale( interpolator_fx[idx + 1], add( segment_len, 1 ), &dec_e );
+ dec_fx = shr( dec_fx, sub( 15, dec_e ) ); // Q0
+ FOR( ; idx >= 0; idx-- )
+ {
+ interpolator_fx[idx] = sub( interpolator_fx[idx + 1], dec_fx );
+ move16();
+ }
+ }
+ ELSE
+ {
+ set16_fx( interpolator_fx, 0, add( idx, 1 ) );
+ }
+
+ return;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_dec_get_adapted_subframes()
+ *
+ * Get an interpolator that is adapted to (time scale modified) IVAS frame
+ *--------------------------------------------------------------------------*/
+
+void ivas_dec_get_adapted_subframes_fx(
+ const Word16 nCldfbTs, /* i : number of time slots in the current frame */
+ Word16 *subframe_nbslots, /* i/o: subframe grid */
+ Word16 *nb_subframes /* i/o: number of subframes in the frame */
+)
+{
+ UWord16 nSlotsInLastSubframe, nSlotsInFirstSubframe;
+ UWord16 nCldfbSlotsLocal = nCldfbTs;
+ move16();
+ Word16 temp, temp_e;
+
+ /* get last subframe size from previous frame, determine how many slots have to be processed
+ in the first subframe (i.e. potential leftover of a 5ms subframe) */
+ nSlotsInFirstSubframe = ( sub( PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, subframe_nbslots[*nb_subframes - 1] ) );
+ *nb_subframes = 0;
+ move16();
+ IF( nSlotsInFirstSubframe > 0 )
+ {
+ *nb_subframes = 1;
+ move16();
+ nCldfbSlotsLocal = sub( nCldfbSlotsLocal, nSlotsInFirstSubframe );
+ }
+
+ temp = BASOP_Util_Divide3232_Scale( L_add( nCldfbSlotsLocal, PARAM_MC_MAX_NSLOTS_IN_SUBFRAME - 1 ), PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, &temp_e );
+ *nb_subframes = add( *nb_subframes, shr( temp, sub( 15, temp_e ) ) ); // Q0
+ move16();
+ nSlotsInLastSubframe = nCldfbSlotsLocal % PARAM_MC_MAX_NSLOTS_IN_SUBFRAME;
+ move16();
+
+ set16_fx( subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS );
+ set16_fx( subframe_nbslots, PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, *nb_subframes );
+
+ IF( nSlotsInFirstSubframe > 0 )
+ {
+ subframe_nbslots[0] = nSlotsInFirstSubframe;
+ move16();
+ }
+
+ IF( nSlotsInLastSubframe > 0 )
+ {
+ subframe_nbslots[*nb_subframes - 1] = nSlotsInLastSubframe;
+ move16();
+ }
+
+ return;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_dec_get_md_map()
+ *
+ * Get an meta data map adapted to a time scale modified IVAS frame
+ *--------------------------------------------------------------------------*/
+
+void ivas_dec_get_md_map_fx(
+ const Word16 default_len, /* i : default frame length in metadata slots */
+ const Word16 len, /* i : length of the modified frames in metadata slots*/
+ const Word16 subframe_len, /* i : default length of a subframe */
+ const Word16 offset, /* i : current read offset into the MD buffer */
+ const Word16 buf_len, /* i : length of the metadata buffer */
+ Word16 *map /* o : metadata index map */
+)
+{
+ Word16 jbm_segment_len, map_idx, src_idx, src_idx_map;
+ Word32 dec_fx, src_idx_fx;
+ Word16 temp_e;
+ Word16 temp;
+ jbm_segment_len = shr( default_len, 1 );
+
+ FOR( ( map_idx = len - 1, src_idx = default_len - 1 ); map_idx >= jbm_segment_len; ( map_idx--, src_idx-- ) )
+ {
+ temp = BASOP_Util_Divide1616_Scale( src_idx, subframe_len, &temp_e );
+ temp = shr( temp, sub( 15, temp_e ) ); // Q0
+ src_idx_map = s_max( 0, temp );
+ map[map_idx] = add( offset, src_idx_map ) % buf_len;
+ move16();
+ }
+
+ /* changed part (first segment), interpolate index to parameters
+ (we do not want to interpolate and smooth acutal direction/diffuseness values even more) */
+ IF( src_idx >= 0 )
+ {
+ dec_fx = BASOP_Util_Divide3232_Scale( L_shl( add( src_idx, 1 ), 16 ), jbm_segment_len, &temp_e );
+ dec_fx = L_shr( dec_fx, sub( 15, temp_e ) );
+ src_idx_fx = L_sub( L_shl( add( src_idx, 1 ), 16 ), dec_fx );
+ FOR( ; map_idx >= 0; map_idx-- )
+ {
+ temp = BASOP_Util_Divide1616_Scale( round_fx( src_idx_fx ), subframe_len, &temp_e );
+ temp = shr( temp, sub( 15, temp_e ) ); // Q0
+ src_idx = s_max( 0, temp );
+ map[map_idx] = add( offset, src_idx ) % buf_len;
+ src_idx_fx = L_sub( src_idx_fx, dec_fx );
+ }
+ }
+ ELSE
+ {
+ set16_fx( map, offset, add( map_idx, 1 ) );
+ }
+
+ return;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_dec_get_md_map_even_spacing()
+ *
+ * Get an meta data map adapted to (time scale modified) IVAS frame.
+ * Distribute slots evenly across the (modified) frame.
+ *--------------------------------------------------------------------------*/
+
+void ivas_dec_get_md_map_even_spacing_fx(
+ const Word16 len, /* i : length of the modified frames in metadata slots*/
+ const Word16 subframe_len, /* i : default length of a subframe */
+ const Word16 offset, /* i : current read offset into the MD buffer */
+ const Word16 buf_len, /* i : length of the metadata buffer */
+ Word16 *map /* o : metadata index map */
+)
+{
+ Word16 map_idx, sf_idx, sf_length, increment, subframes_written;
+ Word32 decimal_fx, decimal_sum_fx, eps_fx; // q = 16
+ Word16 subframe_map_length[MAX_PARAM_SPATIAL_SUBFRAMES];
+
+ /* subframe map length */
+ sf_length = idiv1616( len, subframe_len );
+ IF( len % subframe_len == 0 )
+ {
+ /* even subframes */
+ FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
+ {
+ subframe_map_length[sf_idx] = sf_length;
+ move16();
+ }
+ }
+ ELSE
+ {
+ /* uneven subframes */
+ Word32 temp;
+ Word16 temp_e;
+ temp = BASOP_Util_Divide3232_Scale( L_shl( len, 16 ), subframe_len, &temp_e );
+ temp = L_shr( temp, sub( 15, temp_e ) ); // Q16
+ decimal_fx = L_sub( temp, L_shl( sf_length, 16 ) ); // Q16
+ decimal_sum_fx = decimal_fx;
+
+ eps_fx = 65;
+ move32();
+ move32();
+ FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
+ {
+ increment = extract_l( L_shr( L_add( decimal_sum_fx, eps_fx ), 16 ) );
+ subframe_map_length[sf_idx] = add( sf_length, increment );
+ move16();
+ IF( increment > 0 )
+ {
+ decimal_sum_fx = L_sub( decimal_sum_fx, ONE_IN_Q16 );
+ }
+ decimal_sum_fx = L_add( decimal_sum_fx, decimal_fx );
+ }
+ }
+
+ /* map slots to subframes */
+ sf_idx = 0;
+ subframes_written = 0;
+ move16();
+ move16();
+ FOR( map_idx = 0; map_idx < len; map_idx++ )
+ {
+ map[map_idx] = add( offset, sf_idx ) % buf_len;
+ move16();
+ IF( GE_16( sub( map_idx, subframes_written ), sub( subframe_map_length[sf_idx], 1 ) ) )
+ {
+ subframes_written = add( subframes_written, subframe_map_length[sf_idx] );
+ sf_idx = add( sf_idx, 1 );
+ }
+ }
+
+ return;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_dec_get_render_granularity()
+ *
+ * Get renderer granularity
+ *--------------------------------------------------------------------------*/
+
+/*! r: render granularity */
+Word16 ivas_dec_get_render_granularity_fx(
+ const RENDERER_TYPE renderer_type, /* i : renderer type */
+ const RENDERER_TYPE renderer_type_sec, /* i : secondary renderer type */
+ const Word32 output_Fs /* i : sampling rate */
+)
+{
+ Word16 render_granularity;
+
+ test();
+ test();
+ test();
+ IF( EQ_32( renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) || /* TD renderer */
+ EQ_32( renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_32( renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) || /* Crend */
+ EQ_32( renderer_type_sec, RENDERER_BINAURAL_OBJECTS_TD ) /* TD rend as a secondary renderer -> set the common granularity for both renderers */
+ )
+ {
+ /* 5 ms granularity */
+ render_granularity = NS2SA_FX2( output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES );
+ move16();
+ }
+ ELSE
+ {
+ /* 1.25 ms granularity */
+ render_granularity = NS2SA_FX2( output_Fs, CLDFB_SLOT_NS );
+ move16();
+ }
+
+ return render_granularity;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_dec_tc_buffer_playout()
+ *
+ * Get TC buffer playout
+ *--------------------------------------------------------------------------*/
+
+static void ivas_dec_tc_buffer_playout_fx(
+ Decoder_Struct *st_ivas,
+ const UWord16 nSamplesAsked,
+ UWord16 *nSamplesRendered,
+ Word32 *output_fx[] /*Q11*/
+)
+{
+ Word16 ch_idx, slot_size, slots_to_render, first_sf, last_sf, tmp, e;
+ DECODER_TC_BUFFER_HANDLE hTcBuffer;
+
+ hTcBuffer = st_ivas->hTcBuffer;
+ slot_size = hTcBuffer->n_samples_granularity;
+ move16();
+
+ /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */
+ tmp = BASOP_Util_Divide1616_Scale( nSamplesAsked, slot_size, &e );
+ tmp = shr( tmp, sub( 15, e ) ); // Q0
+ slots_to_render = s_min( sub( hTcBuffer->num_slots, hTcBuffer->slots_rendered ), tmp );
+ hTcBuffer->slots_rendered = add( hTcBuffer->slots_rendered, slots_to_render ); // Q0
+ *nSamplesRendered = (UWord16) L_mult0( slots_to_render, slot_size );
+ first_sf = hTcBuffer->subframes_rendered;
+ last_sf = first_sf;
+ move16();
+ move16();
+ move16();
+ move16();
+
+ WHILE( slots_to_render > 0 )
+ {
+ slots_to_render = sub( slots_to_render, hTcBuffer->subframe_nbslots[last_sf] );
+ last_sf = add( last_sf, 1 );
+ }
+#ifdef DEBUGGING
+ assert( slots_to_render == 0 );
+#endif
+
+ FOR( ch_idx = 0; ch_idx < hTcBuffer->nchan_transport_rend; ch_idx++ )
+ {
+ output_fx[ch_idx] = hTcBuffer->tc_fx[ch_idx] + hTcBuffer->n_samples_rendered;
+ move32();
+ }
+
+ hTcBuffer->subframes_rendered = last_sf;
+ move16();
+
+ return;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_dec_td_renderers_adapt_subframes()
+ *
+ * Adapt subframes for TD renderers
+ *--------------------------------------------------------------------------*/
+
+void ivas_dec_td_renderers_adapt_subframes_fx(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+)
+{
+ Word16 nMaxSlotsPerSubframe, nSlotsAvailable, tmp, tmp_e, tmp1, tmp2, s1, s2;
+ UWord16 nSlotsInLastSubframe, nSlotsInFirstSubframe;
+ DECODER_TC_BUFFER_HANDLE hTcBuffer;
+
+ hTcBuffer = st_ivas->hTcBuffer;
+
+ /* nMaxSlotsPerSubframe = (Word16) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / hTcBuffer->n_samples_granularity; */
+ tmp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) );
+ tmp = BASOP_Util_Divide1616_Scale( tmp, hTcBuffer->n_samples_granularity, &tmp_e );
+ nMaxSlotsPerSubframe = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */
+
+ /* nSlotsAvailable = hTcBuffer->n_samples_available / hTcBuffer->n_samples_granularity; */
+ tmp = BASOP_Util_Divide1616_Scale( hTcBuffer->n_samples_available, hTcBuffer->n_samples_granularity, &tmp_e );
+ nSlotsAvailable = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */
+
+ hTcBuffer->num_slots = nSlotsAvailable;
+ move16();
+ /* hTcBuffer->n_samples_available = nSlotsAvailable * hTcBuffer->n_samples_granularity; */
+ hTcBuffer->n_samples_available = i_mult( nSlotsAvailable, hTcBuffer->n_samples_granularity );
+ move16();
+ nSlotsInFirstSubframe = sub( nMaxSlotsPerSubframe, hTcBuffer->subframe_nbslots[hTcBuffer->nb_subframes - 1] );
+ hTcBuffer->nb_subframes = 0;
+ move16();
+
+ IF( nSlotsInFirstSubframe > 0 )
+ {
+ hTcBuffer->nb_subframes = 1;
+ move16();
+ nSlotsAvailable = sub( nSlotsAvailable, nSlotsInFirstSubframe );
+ }
+
+ s1 = sub( norm_s( nSlotsAvailable ), 1 );
+ s2 = norm_s( nMaxSlotsPerSubframe );
+
+ tmp1 = shl( nSlotsAvailable, s1 );
+ tmp2 = shl( nMaxSlotsPerSubframe, s2 );
+
+ tmp = div_s( tmp1, tmp2 );
+ hTcBuffer->nb_subframes = add( hTcBuffer->nb_subframes, ceil_fx16( tmp, sub( 15, sub( s2, s1 ) ) ) );
+ move16();
+
+ nSlotsInLastSubframe = nSlotsAvailable % nMaxSlotsPerSubframe;
+ move16();
+ set16_fx( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS );
+ set16_fx( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, hTcBuffer->nb_subframes );
+
+ if ( nSlotsInFirstSubframe > 0 )
+ {
+ hTcBuffer->subframe_nbslots[0] = nSlotsInFirstSubframe;
+ move16();
+ }
+
+ if ( nSlotsInLastSubframe > 0 )
+ {
+ hTcBuffer->subframe_nbslots[hTcBuffer->nb_subframes - 1] = nSlotsInLastSubframe;
+ move16();
+ }
+
+ hTcBuffer->slots_rendered = 0;
+ move16();
+ hTcBuffer->subframes_rendered = 0;
+ move16();
+
+ return;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_jbm_dec_masa_metadata_open()
+ *
+ * Open structure for MASA metadata buffering in JBM processing
+ *--------------------------------------------------------------------------*/
+
+ivas_error ivas_jbm_dec_masa_metadata_open_fx(
+ Decoder_Struct *st_ivas )
+{
+ JBM_METADATA_HANDLE hJbmMetadata;
+
+ IF( ( hJbmMetadata = (JBM_METADATA_HANDLE) malloc( sizeof( JBM_METADATA ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM metadata handle\n" ) );
+ }
+
+ hJbmMetadata->sf_write_idx = 0;
+ move16();
+ hJbmMetadata->sf_md_buffer_length = MASA_JBM_RINGBUFFER_FRAMES * MAX_PARAM_SPATIAL_SUBFRAMES;
+ move16();
+
+ hJbmMetadata->slot_write_idx = 0;
+ move16();
+ hJbmMetadata->slot_read_idx = 0;
+ move16();
+ hJbmMetadata->slot_md_buffer_length = MASA_JBM_RINGBUFFER_FRAMES * MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME;
+ move16();
+
+ st_ivas->hJbmMetadata = hJbmMetadata;
+
+ return IVAS_ERR_OK;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_jbm_dec_copy_masa_meta_to_buffer()
+ *
+ * Copy decoded MASA metadata to a ring buffer in JBM processing
+ *--------------------------------------------------------------------------*/
+
+static void ivas_jbm_dec_copy_masa_meta_to_buffer_fx(
+ Decoder_Struct *st_ivas )
+{
+ Word16 sf, dir, band;
+ JBM_METADATA_HANDLE hJbmMetadata;
+ MASA_DECODER_EXT_OUT_META *extOutMeta;
+ Word16 write_idx;
+
+ hJbmMetadata = st_ivas->hJbmMetadata;
+ extOutMeta = st_ivas->hMasa->data.extOutMeta;
+
+ FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ )
+ {
+ write_idx = ( hJbmMetadata->sf_write_idx + sf ) % hJbmMetadata->sf_md_buffer_length;
+ move16();
+ FOR( dir = 0; dir < MASA_MAXIMUM_DIRECTIONS; dir++ )
+ {
+ FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ )
+ {
+ hJbmMetadata->directionIndexBuffer[dir][write_idx][band] = extOutMeta->directionIndex[dir][sf][band];
+ move16();
+ hJbmMetadata->directToTotalRatioBuffer[dir][write_idx][band] = extOutMeta->directToTotalRatio[dir][sf][band];
+ move16();
+ hJbmMetadata->spreadCoherenceBuffer[dir][write_idx][band] = extOutMeta->spreadCoherence[dir][sf][band];
+ move16();
+ }
+ }
+
+ FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ )
+ {
+ hJbmMetadata->diffuseToTotalRatioBuffer[write_idx][band] = extOutMeta->diffuseToTotalRatio[sf][band];
+ move16();
+ hJbmMetadata->surroundCoherenceBuffer[write_idx][band] = extOutMeta->surroundCoherence[sf][band];
+ move16();
+ }
+
+ hJbmMetadata->numberOfDirections[write_idx] = extOutMeta->descriptiveMeta.numberOfDirections;
+ move16();
+ }
+
+ return;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_jbm_masa_sf_to_slot_map()
+ *
+ * Map input MASA metadata subframes to slots in JBM processing
+ *--------------------------------------------------------------------------*/
+
+static void ivas_jbm_masa_sf_to_slot_map_fx(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ const Word16 nCldfbTs /* i : number of CLDFB time slots */
+)
+{
+ Word16 sf_to_slot_map[MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME];
+ Word16 num_slots_in_subfr;
+ JBM_METADATA_HANDLE hJbmMetadata;
+ Word16 slot_idx;
+ Word16 write_idx, sf_index;
+
+ ivas_jbm_dec_copy_masa_meta_to_buffer_fx( st_ivas );
+
+ /* Set values */
+ hJbmMetadata = st_ivas->hJbmMetadata;
+ num_slots_in_subfr = CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES;
+ move16();
+
+ /* Map input subframes to slots */
+ ivas_dec_get_md_map_even_spacing_fx( nCldfbTs, num_slots_in_subfr, 0, MAX_PARAM_SPATIAL_SUBFRAMES, sf_to_slot_map );
+
+ FOR( slot_idx = 0; slot_idx < nCldfbTs; slot_idx++ )
+ {
+ write_idx = ( add( hJbmMetadata->slot_write_idx, slot_idx ) ) % hJbmMetadata->slot_md_buffer_length;
+ move16();
+ sf_index = ( add( hJbmMetadata->sf_write_idx, sf_to_slot_map[slot_idx] ) ) % hJbmMetadata->sf_md_buffer_length;
+ move16();
+
+ hJbmMetadata->sf_to_slot_map[write_idx] = sf_index;
+ move16();
+ }
+
+ hJbmMetadata->sf_write_idx = ( add( hJbmMetadata->sf_write_idx, MAX_PARAM_SPATIAL_SUBFRAMES ) ) % hJbmMetadata->sf_md_buffer_length;
+ move16();
+ hJbmMetadata->slot_write_idx = ( add( hJbmMetadata->slot_write_idx, nCldfbTs ) ) % hJbmMetadata->slot_md_buffer_length;
+ move16();
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*
+ * ivas_jbm_masa_sf_to_sf_map()
+ *
+ * Map input MASA metadata subframes to output subframes in JBM processing
+ *--------------------------------------------------------------------------*/
+
+void ivas_jbm_masa_sf_to_sf_map_fx(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+)
+{
+ Word16 sf_to_sf_map[MAX_PARAM_SPATIAL_SUBFRAMES];
+ JBM_METADATA_HANDLE hJbmMetadata;
+ MASA_DECODER_EXT_OUT_META *extOutMeta;
+ Word16 slot_read_idx, sf_read_idx;
+ Word16 sf_idx;
+ Word16 dir, band;
+ UWord8 numberOfDirections;
+
+ /* Set values */
+ hJbmMetadata = st_ivas->hJbmMetadata;
+ extOutMeta = st_ivas->hMasa->data.extOutMeta;
+
+ /* Map slots to subframes */
+ FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
+ {
+ slot_read_idx = ( add( hJbmMetadata->slot_read_idx, 2 ) ) % hJbmMetadata->slot_md_buffer_length; /* Take the latter one of the middle slots of the output subframe */
+ move16();
+ sf_to_sf_map[sf_idx] = hJbmMetadata->sf_to_slot_map[slot_read_idx];
+ move16();
+ hJbmMetadata->slot_read_idx = ( add( hJbmMetadata->slot_read_idx, CLDFB_SLOTS_PER_SUBFRAME ) ) % hJbmMetadata->slot_md_buffer_length;
+ move16();
+ }
+
+ /* Copy mapped metadata to the EXT meta buffer for writing */
+ FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
+ {
+ sf_read_idx = sf_to_sf_map[sf_idx];
+ move16();
+
+ FOR( dir = 0; dir < MASA_MAXIMUM_DIRECTIONS; dir++ )
+ {
+ FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ )
+ {
+ extOutMeta->directionIndex[dir][sf_idx][band] = hJbmMetadata->directionIndexBuffer[dir][sf_read_idx][band];
+ move16();
+ extOutMeta->directToTotalRatio[dir][sf_idx][band] = hJbmMetadata->directToTotalRatioBuffer[dir][sf_read_idx][band];
+ move16();
+ extOutMeta->spreadCoherence[dir][sf_idx][band] = hJbmMetadata->spreadCoherenceBuffer[dir][sf_read_idx][band];
+ move16();
+ }
+ }
+
+ FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ )
+ {
+ extOutMeta->diffuseToTotalRatio[sf_idx][band] = hJbmMetadata->diffuseToTotalRatioBuffer[sf_read_idx][band];
+ move16();
+ extOutMeta->surroundCoherence[sf_idx][band] = hJbmMetadata->surroundCoherenceBuffer[sf_read_idx][band];
+ move16();
+ }
+ }
+
+ /* Determine the number of directions for the frame to be written */
+ numberOfDirections = 0;
+ move16();
+ FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
+ {
+ sf_read_idx = sf_to_sf_map[sf_idx];
+ move16();
+
+ IF( hJbmMetadata->numberOfDirections[sf_read_idx] == 1 )
+ {
+ numberOfDirections = 1;
+ move16();
+ BREAK;
+ }
+ }
+
+ extOutMeta->descriptiveMeta.numberOfDirections = numberOfDirections;
+ move16();
+
+ return;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * ivas_dec_prepare_renderer()
+ *
+ * Prepare IVAS renderer routine
+ *--------------------------------------------------------------------------*/
+
+void ivas_dec_prepare_renderer_fx(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+)
+{
+ Word16 n, n_render_timeslots, n_samples_available, tmp, exp, shift;
+ AUDIO_CONFIG output_config;
+ DECODER_TC_BUFFER_HANDLE hTcBuffer;
+
+ push_wmops( "ivas_dec_prepare_renderer" );
+
+ output_config = st_ivas->hDecoderConfig->output_config;
+ move16();
+ hTcBuffer = st_ivas->hTcBuffer;
+ n_samples_available = hTcBuffer->n_samples_available;
+ move16();
+
+ /* n_render_timeslots = n_samples_available / hTcBuffer->n_samples_granularity; */
+ tmp = BASOP_Util_Divide1616_Scale( n_samples_available, hTcBuffer->n_samples_granularity, &exp );
+ n_render_timeslots = shr( tmp, sub( 15, exp ) ); // Q0
+
+ test();
+ IF( EQ_16( hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) )
+ {
+ ivas_dec_td_renderers_adapt_subframes_fx( st_ivas );
+
+ test();
+ test();
+ test();
+ IF( ( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) && EQ_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && st_ivas->hDecoderConfig->Opt_tsm )
+ {
+ ivas_jbm_masa_sf_to_slot_map_fx( st_ivas, n_render_timeslots );
+ }
+ /* MASA transport gaining for edited disc OMASA EXT. For ISMs, only metadata is modified */
+ test();
+ test();
+ test();
+ IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && EQ_16( st_ivas->hMasaIsmData->masa_gain_is_edited, 1 ) )
+ {
+ ivas_omasa_gain_masa_tc_fx( hTcBuffer->tc_fx, st_ivas->hMasaIsmData->gain_masa_edited_fx, st_ivas->nchan_ism, n_samples_available );
+ }
+ }
+ ELSE IF( EQ_16( st_ivas->ivas_format, MONO_FORMAT ) || EQ_16( st_ivas->ivas_format, STEREO_FORMAT ) )
+ {
+ ivas_dec_td_renderers_adapt_subframes_fx( st_ivas );
+ }
+ ELSE IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) )
+ {
+ /* Rendering */
+ IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) )
+ {
+ test();
+ test();
+ test();
+ IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
+ {
+ ivas_dirac_dec_set_md_map_fx( st_ivas, n_render_timeslots );
+
+ ivas_param_ism_params_to_masa_param_mapping_fx( st_ivas );
+ }
+ ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
+ {
+ ivas_param_ism_dec_prepare_renderer_fx( st_ivas, n_render_timeslots );
+ }
+ }
+ ELSE /* ISM_MODE_DISC */
+ {
+ ivas_ism_dec_digest_tc_fx( st_ivas );
+ }
+ }
+ ELSE IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_FORMAT ) )
+ {
+ IF( st_ivas->hSCE[0] )
+ {
+ shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN );
+ IF( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) )
+ {
+ shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 );
+ }
+ scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31-cngNoiseLevelExp+shift)
+ st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift );
+ }
+
+ ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, n_samples_available );
+ }
+ ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
+ {
+ IF( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
+ {
+ ivas_ism_dec_digest_tc_fx( st_ivas );
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ /* delay the objects here for all renderers where it is needed */
+ IF(
+ (
+ EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ||
+ EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ||
+ EQ_16( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) ||
+ EQ_16( st_ivas->renderer_type, RENDERER_OSBA_LS ) ||
+ EQ_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) &&
+ ( NE_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) )
+ {
+ FOR( n = 0; n < st_ivas->nchan_ism; n++ )
+ {
+ delay_signal32_fx( hTcBuffer->tc_fx[n], n_samples_available, st_ivas->hSbaIsmData->delayBuffer_fx[n], st_ivas->hSbaIsmData->delayBuffer_size );
+ }
+ }
+
+ IF( !st_ivas->sba_dirac_stereo_flag )
+ {
+ IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) )
+ {
+ Word16 temp, temp_e;
+ temp = BASOP_Util_Divide1616_Scale( hTcBuffer->n_samples_granularity, st_ivas->hSpatParamRendCom->slot_size, &temp_e );
+ n_render_timeslots = extract_l( L_shr( L_mult0( n_render_timeslots, temp ), sub( 15, temp_e ) ) );
+ }
+
+ IF( st_ivas->hSCE[0] )
+ {
+ shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN );
+ if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) )
+ {
+ shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 );
+ }
+ scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31-cngNoiseLevelExp+shift)
+ st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift );
+ }
+ ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, n_samples_available );
+ }
+ }
+ ELSE
+ {
+ ivas_dec_td_renderers_adapt_subframes_fx( st_ivas );
+
+ IF( st_ivas->hSCE[0] )
+ {
+ shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN );
+ if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) )
+ {
+ shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 );
+ }
+ scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31-cngNoiseLevelExp+shift)
+ st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift );
+ }
+
+ ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, n_samples_available );
+ }
+ }
+ ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
+ {
+ test();
+ IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) || EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) )
+ {
+ ivas_dec_td_renderers_adapt_subframes_fx( st_ivas );
+
+ IF( st_ivas->hDecoderConfig->Opt_tsm )
+ {
+ ivas_jbm_masa_sf_to_slot_map_fx( st_ivas, n_render_timeslots );
+ }
+ /* MASA transport gaining for edited param_one OMASA EXT. For ISMs, only metadata is modified. */
+ test();
+ IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && EQ_16( st_ivas->hMasaIsmData->masa_gain_is_edited, 1 ) )
+ {
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ v_multc_fx_16( hTcBuffer->tc_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, hTcBuffer->tc_fx[n], n_samples_available ); // Q8
+ Scale_sig32( hTcBuffer->tc_fx[n], n_samples_available, Q3 ); // Q8 -> Q11
+ }
+ }
+ }
+ ELSE
+ {
+ test();
+ IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
+ {
+ n_render_timeslots = i_mult( n_render_timeslots, idiv1616( hTcBuffer->n_samples_granularity, st_ivas->hSpatParamRendCom->slot_size ) );
+ }
+
+ IF( st_ivas->hSCE[0] )
+ {
+ shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN );
+ if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) )
+ {
+ shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 );
+ }
+ scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31- (st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp - shift)
+ st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift );
+ move16();
+ }
+
+ ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, n_samples_available );
+
+ IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
+ {
+ ivas_ism_dec_digest_tc_fx( st_ivas );
+ }
+ }
+
+ test();
+ IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_DIRAC ) )
+ {
+ Word16 nchan_transport_ism;
+
+ /* Delay the signal to match CLDFB delay. Delay the whole buffer. */
+ nchan_transport_ism = 0;
+ move16();
+
+ test();
+ test();
+ IF( ( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) )
+ {
+ nchan_transport_ism = 1;
+ move16();
+ }
+ ELSE IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
+ {
+ nchan_transport_ism = st_ivas->nchan_ism;
+ move16();
+ }
+
+ test();
+ test();
+ IF( st_ivas->hDecoderConfig->Opt_tsm && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) )
+ {
+ /* Gain MASA part, if edited */
+ IF( st_ivas->hMasaIsmData->masa_gain_is_edited )
+ {
+ FOR( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ v_multc_fx_16( hTcBuffer->tc_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, hTcBuffer->tc_fx[n], n_samples_available );
+ Scale_sig32( hTcBuffer->tc_fx[n], n_samples_available, Q3 ); // Q8 -> Q11
+ }
+ }
+ }
+
+ FOR( n = 0; n < nchan_transport_ism; n++ )
+ {
+ test();
+ IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) )
+ {
+ v_multc_fx_16( hTcBuffer->tc_fx[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN_FX, hTcBuffer->tc_fx[CPE_CHANNELS + n], n_samples_available );
+
+ IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] )
+ {
+ v_multc_fx_16( hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], hTcBuffer->tc_fx[CPE_CHANNELS + n], n_samples_available );
+ Scale_sig32( hTcBuffer->tc_fx[CPE_CHANNELS + n], n_samples_available, Q3 ); // Q8 -> Q11
+ }
+ }
+
+ test();
+ IF( NE_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
+ {
+ delay_signal32_fx( hTcBuffer->tc_fx[CPE_CHANNELS + n], n_samples_available, st_ivas->hMasaIsmData->delayBuffer_fx[n], st_ivas->hMasaIsmData->delayBuffer_size );
+ }
+ }
+
+ test();
+ IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) )
+ {
+ IF( st_ivas->hMasaIsmData->masa_gain_is_edited )
+ {
+ FOR( n = 0; n < BINAURAL_CHANNELS; n++ )
+ {
+ v_multc_fx_16( hTcBuffer->tc_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, hTcBuffer->tc_fx[n], n_samples_available ); // Q8
+ Scale_sig32( hTcBuffer->tc_fx[n], n_samples_available, Q3 ); // Q8 -> Q11
+ }
+ }
+ }
+ }
+ }
+ ELSE IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) )
+ {
+ IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) )
+ {
+ ivas_dec_td_renderers_adapt_subframes_fx( st_ivas );
+ }
+ ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
+ {
+ ivas_mc_paramupmix_dec_digest_tc_fx( st_ivas, (UWord8) n_render_timeslots, n_samples_available );
+ }
+ ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
+ {
+ Word16 nchan_transport = st_ivas->nchan_transport;
+ move16();
+ Word16 nchan_out_transport = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe );
+ Word16 nchan_out_cov;
+
+ test();
+ test();
+ IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
+ {
+ nchan_out_cov = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe );
+ }
+ ELSE IF( EQ_16( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_CLDFB ) )
+ {
+ nchan_out_cov = nchan_out_transport;
+ move16();
+ }
+ ELSE IF( EQ_16( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_16( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) )
+ {
+ nchan_out_cov = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe );
+ }
+ ELSE
+ {
+ nchan_out_cov = nchan_out_transport;
+ move16();
+ }
+
+ scale_sig32( st_ivas->hParamMC->proto_matrix_int_fx, st_ivas->hParamMC->proto_matrix_int_len, -1 ); // Q(31-1)
+ st_ivas->hParamMC->proto_matrix_int_e = 1;
+ move16();
+
+ ivas_param_mc_dec_prepare_renderer( st_ivas, (UWord8) n_render_timeslots );
+
+ scale_sig32( st_ivas->hParamMC->proto_matrix_int_fx, st_ivas->hParamMC->proto_matrix_int_len, 1 ); // Q(31-1+1)
+
+ FOR( Word16 param_band_idx = 0; param_band_idx < st_ivas->hParamMC->num_param_bands_synth; param_band_idx++ )
+ {
+ shift = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_fx[param_band_idx], s_min( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_len, nchan_transport * nchan_transport ) );
+ scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_fx[param_band_idx], s_min( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_len, i_mult( nchan_transport, nchan_transport ) ), shift ); // Q(31-cx_old_e+shift)
+ st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx] = sub( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx], shift );
+ move16();
+
+ shift = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_fx[param_band_idx], nchan_out_cov * nchan_out_cov );
+ scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_fx[param_band_idx], i_mult( nchan_out_cov, nchan_out_cov ), shift ); // Q(31-cy_old_e+shift)
+ st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx] = sub( st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx], shift );
+ move16();
+ }
+ }
+ ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) )
+ {
+ IF( st_ivas->hSCE[0] )
+ {
+ shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN );
+ if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) )
+ {
+ shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 );
+ }
+ scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31-cngNoiseLevelExp+shift)
+ st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift );
+ move16();
+ }
+
+ ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, n_samples_available );
+ }
+ }
+
+ pop_wmops();
+ return;
+}
diff --git a/lib_dec/ivas_decision_matrix_dec_fx.c b/lib_dec/ivas_decision_matrix_dec_fx.c
index fadd9d008a8a9fede030a54c86ebc8e2b76fce76..06f11158acfd8fa947a04f850f59b01ee723d2d4 100644
--- a/lib_dec/ivas_decision_matrix_dec_fx.c
+++ b/lib_dec/ivas_decision_matrix_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -115,11 +115,9 @@ void ivas_decision_matrix_dec_fx(
{
st->L_frame = L_FRAME16k;
move16();
-#ifdef FIX_2252_LP_CNG_STARTS_SID
st->nb_subfr = NB_SUBFR16k;
move16();
st->bwidth = s_max( st->bwidth, WB );
-#endif
}
ELSE
{
diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c
index f43ac5c09a122765f99ade88531118e1a512d93d..d61e3ff4bdc9101c4923d27fc65744d464110fe9 100644
--- a/lib_dec/ivas_dirac_dec_fx.c
+++ b/lib_dec/ivas_dirac_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -1965,9 +1965,9 @@ void ivas_dirac_dec_set_md_map_fx(
hSpatParamRendCom->subframes_rendered = 0;
move16();
- ivas_jbm_dec_get_adapted_subframes( nCldfbTs, hSpatParamRendCom->subframe_nbslots, &hSpatParamRendCom->nb_subframes );
+ ivas_dec_get_adapted_subframes_fx( nCldfbTs, hSpatParamRendCom->subframe_nbslots, &hSpatParamRendCom->nb_subframes );
- /* copy also to tc buffer */
+ /* copy also to TC buffer */
/* only for non-combined formats and combinded formats w/o discrete objects */
test();
test();
@@ -1986,15 +1986,15 @@ void ivas_dirac_dec_set_md_map_fx(
test();
IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
{
- ivas_jbm_dec_get_md_map_even_spacing( nCldfbTs, num_slots_in_subfr, 0, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map );
+ ivas_dec_get_md_map_even_spacing_fx( nCldfbTs, num_slots_in_subfr, 0, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map );
}
ELSE IF( hDirAC == NULL || hDirAC->hConfig == NULL || hDirAC->hConfig->dec_param_estim == 0 )
{
- ivas_jbm_dec_get_md_map( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, num_slots_in_subfr, 0, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map );
+ ivas_dec_get_md_map_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, num_slots_in_subfr, 0, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map );
}
ELSE
{
- ivas_jbm_dec_get_md_map( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, num_slots_in_subfr, hSpatParamRendCom->dirac_read_idx, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map );
+ ivas_dec_get_md_map_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, num_slots_in_subfr, hSpatParamRendCom->dirac_read_idx, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map );
}
test();
@@ -3706,7 +3706,7 @@ void ivas_dirac_dec_render_sf_fx(
test();
IF( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] )
{
- ivas_jbm_dec_get_adapted_linear_interpolator_fx( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator_fx );
+ ivas_dec_get_adapted_linear_interpolator_fx( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator_fx );
st_ivas->hIsmRendererData->interp_offset_fx = 0;
move16();
}
diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c
index 7d389ec0f2797cbda3cf0f3baf069077cad11cee..b18a76052527644f20421b0cc1edc650b383f22f 100644
--- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c
+++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_entropy_decoder_fx.c b/lib_dec/ivas_entropy_decoder_fx.c
index f8bf3c0910563b96492446ff76aa581507552b77..ea350ff4a1f1996fb1a4101c9818bbf06f5e5bd6 100644
--- a/lib_dec/ivas_entropy_decoder_fx.c
+++ b/lib_dec/ivas_entropy_decoder_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c
index f93b5a69c1e6010d2542ecc0bbef5f449963f9ec..6e603171298e513797abf9fc04d7a2eaf1e22664 100644
--- a/lib_dec/ivas_init_dec_fx.c
+++ b/lib_dec/ivas_init_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -1557,7 +1557,7 @@ ivas_error ivas_init_decoder_front(
IF( st_ivas->hDecoderConfig->Opt_ExternalOrientation )
{
- IF( NE_32( ( error = ivas_external_orientation_open_fx( &( st_ivas->hExtOrientationData ), st_ivas->hDecoderConfig->render_framesize ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_external_orientation_open_fx( &( st_ivas->hExtOrientationData ), st_ivas->hDecoderConfig->render_num_subframes ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1570,7 +1570,7 @@ ivas_error ivas_init_decoder_front(
test();
IF( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation )
{
- IF( NE_32( ( error = ivas_combined_orientation_open_fx( &( st_ivas->hCombinedOrientationData ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->render_framesize ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_combined_orientation_open_fx( &( st_ivas->hCombinedOrientationData ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->render_num_subframes ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1622,7 +1622,7 @@ ivas_error ivas_init_decoder_fx(
Word16 i, n, k;
Word16 sce_id, cpe_id;
Word16 numCldfbAnalyses, numCldfbSyntheses;
- Word16 granularity, n_channels_transport_jbm;
+ Word16 granularity, n_channels_transport;
Word16 nchan_out_buff;
Word32 output_Fs, ivas_total_brate, tmp_br, tmp32;
Word32 delay_ns;
@@ -1799,7 +1799,8 @@ ivas_error ivas_init_decoder_fx(
IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
{
/* Init HRTF statistics */
- IF( NE_32( ( error = ivas_HRTF_statistics_init_fx( &st_ivas->hHrtfStatistics, output_Fs ) ), IVAS_ERR_OK ) )
+ /* Allocate HRTF and init statistics */
+ IF( NE_32( ( error = ivas_reverb_HRTF_statistics_open_fx( &( st_ivas->hHrtfStatistics ), output_Fs ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2859,7 +2860,7 @@ ivas_error ivas_init_decoder_fx(
return error;
}
- IF( NE_32( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_omasa_separate_object_renderer_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -3078,16 +3079,16 @@ ivas_error ivas_init_decoder_fx(
}
/*-----------------------------------------------------------------*
- * Allocate and initialize JBM struct + buffer
+ * Allocate and initialize TC struct + buffer
*-----------------------------------------------------------------*/
IF( st_ivas->hTcBuffer == NULL )
{
/* no module has yet open the TC buffer, open a default one */
- granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), output_Fs );
- n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
+ granularity = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), output_Fs );
+ n_channels_transport = ivas_dec_get_num_tc_channels_fx( st_ivas );
- IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode_fx( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_dec_tc_buffer_open_fx( st_ivas, ivas_dec_get_tc_buffer_mode_fx( st_ivas ), n_channels_transport, n_channels_transport, n_channels_transport, granularity ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -3099,7 +3100,7 @@ ivas_error ivas_init_decoder_fx(
{
IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
- IF( NE_32( ( error = ivas_jbm_dec_metadata_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_jbm_dec_masa_metadata_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -3356,7 +3357,7 @@ void ivas_initialize_handles_dec(
{
st_ivas->hTdRendHandles[i] = NULL;
}
- /* JBM handles */
+
st_ivas->hTcBuffer = NULL;
st_ivas->hJbmMetadata = NULL;
@@ -3541,23 +3542,12 @@ void ivas_destroy_dec_fx(
ivas_combined_orientation_close_fx( &st_ivas->hCombinedOrientationData );
/* Time Domain binaural renderer handle */
- IF( st_ivas->hBinRendererTd != NULL )
- {
- ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd );
- }
-
- IF( st_ivas->hHrtfTD != NULL )
- {
- BSplineModelEvalDealloc_fx( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval );
-
- ivas_HRTF_binary_close_fx( &st_ivas->hHrtfTD );
- }
+ ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd );
+ ivas_HRTF_td_binary_close_fx( &st_ivas->hHrtfTD );
/* CRend binaural renderer handle */
ivas_HRTF_CRend_binary_close_fx( &st_ivas->hHrtfCrend );
- /* Fastconv HRTF memories */
- ivas_binaural_hrtf_close_fx( &st_ivas->hHrtfFastConv );
/* Fastconv HRTF filters */
ivas_HRTF_fastconv_binary_close_fx( &st_ivas->hHrtfFastConv );
@@ -3566,7 +3556,7 @@ void ivas_destroy_dec_fx(
ivas_HRTF_parambin_binary_close_fx( &st_ivas->hHrtfParambin );
/* HRTF statistics */
- ivas_HRTF_statistics_close_fx( &st_ivas->hHrtfStatistics );
+ ivas_HRTF_statistics_binary_close_fx( &st_ivas->hHrtfStatistics );
/* Config. Renderer */
ivas_render_config_close_fx( &( st_ivas->hRenderConfig ) );
@@ -3588,8 +3578,8 @@ void ivas_destroy_dec_fx(
st_ivas->hDecoderConfig = NULL;
}
- /* JBM TC buffer structure */
- ivas_jbm_dec_tc_buffer_close_fx( &st_ivas->hTcBuffer );
+ /* TC buffer structure */
+ ivas_dec_tc_buffer_close_fx( &st_ivas->hTcBuffer );
IF( st_ivas->hJbmMetadata != NULL )
{
diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c
index 4537b384078329dd47d40a02b300be63b0232b09..b087ab906b537a98f5c1c328033644490acc74a8 100644
--- a/lib_dec/ivas_ism_dec_fx.c
+++ b/lib_dec/ivas_ism_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -55,9 +55,6 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
Word32 element_brate_tmp[MAX_NUM_OBJECTS];
Word16 nSCE_old, nCPE_old;
Word16 numCldfbAnalyses_old, numCldfbSyntheses_old, ism_mode;
- TC_BUFFER_MODE tc_buffer_mode_new;
- Word16 tc_nchan_tc_new;
- Word16 tc_nchan_allocate_new;
Word16 tc_granularity_new;
Word16 nchan_out_buff;
@@ -124,7 +121,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
test();
test();
- /* transfer subframe info from DirAC or ParamMC to central tc buffer */
+ /* transfer subframe info from DirAC or ParamMC to central TC buffer */
/* only do this if we are not having done everything already in the TC decoding part and having only played out from the TC buffer */
IF( EQ_32( last_ism_mode, ISM_MODE_PARAM ) && st_ivas->hSpatParamRendCom != NULL && NE_32( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) )
{
@@ -139,15 +136,15 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
Copy( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
}
- /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv
- render what still fits in the new granularity */
- tc_granularity_new = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs );
+ /* when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv
+ render what still fits in the new granularity */
+ tc_granularity_new = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs );
IF( LT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) )
{
/* flush already done in IVAS_DEC_ReadFormat() */
}
- /* JBM: when granularity goes up set samples to discard at the beginning of the frame */
+ /* when granularity goes up set samples to discard at the beginning of the frame */
ELSE IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) )
{
IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples_fx( st_ivas ) ), IVAS_ERR_OK ) )
@@ -303,18 +300,21 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
}
/*-----------------------------------------------------------------*
- * JBM TC buffers
+ * TC buffer
*-----------------------------------------------------------------*/
Word16 tc_nchan_full_new;
+ TC_BUFFER_MODE tc_buffer_mode_new;
+ Word16 tc_nchan_rend_new;
+ Word16 tc_nchan_allocate_new;
DECODER_TC_BUFFER_HANDLE hTcBuffer;
hTcBuffer = st_ivas->hTcBuffer;
- tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode_fx( st_ivas );
- tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
- tc_nchan_allocate_new = tc_nchan_tc_new;
+ tc_buffer_mode_new = ivas_dec_get_tc_buffer_mode_fx( st_ivas );
+ tc_nchan_rend_new = ivas_dec_get_num_tc_channels_fx( st_ivas );
+ tc_nchan_allocate_new = tc_nchan_rend_new;
move16();
- tc_nchan_full_new = tc_nchan_tc_new;
+ tc_nchan_full_new = tc_nchan_rend_new;
move16();
test();
@@ -327,32 +327,32 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
move16();
}
- /* reconfigure buffer */
+ /* reconfigure TC buffer */
test();
test();
test();
- IF( NE_32( hTcBuffer->tc_buffer_mode, tc_buffer_mode_new ) || NE_16( hTcBuffer->nchan_transport_jbm, tc_nchan_tc_new ) ||
+ IF( NE_32( hTcBuffer->tc_buffer_mode, tc_buffer_mode_new ) || NE_16( hTcBuffer->nchan_transport_rend, tc_nchan_rend_new ) ||
NE_16( hTcBuffer->nchan_buffer_full, tc_nchan_full_new ) || NE_16( hTcBuffer->nchan_transport_internal, tc_nchan_allocate_new ) )
{
- IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode_new, tc_nchan_rend_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ), IVAS_ERR_OK ) )
{
return error;
}
}
- /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */
+ /* transfer subframe info from central TC buffer to ParamMC or McMASA (DirAC) */
IF( st_ivas->hSpatParamRendCom != NULL )
{
- st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes;
+ st_ivas->hSpatParamRendCom->nb_subframes = hTcBuffer->nb_subframes;
move16();
- st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered;
+ st_ivas->hSpatParamRendCom->subframes_rendered = hTcBuffer->subframes_rendered;
move16();
- st_ivas->hSpatParamRendCom->num_slots = st_ivas->hTcBuffer->num_slots;
+ st_ivas->hSpatParamRendCom->num_slots = hTcBuffer->num_slots;
move16();
- st_ivas->hSpatParamRendCom->slots_rendered = st_ivas->hTcBuffer->slots_rendered;
+ st_ivas->hSpatParamRendCom->slots_rendered = hTcBuffer->slots_rendered;
move16();
- Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
+ Copy( hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
}
/*-----------------------------------------------------------------*
diff --git a/lib_dec/ivas_ism_dtx_dec_fx.c b/lib_dec/ivas_ism_dtx_dec_fx.c
index 162cc42ed5ac60975c925ba61789c1846d45fefd..d283832b33714cb68193bd1795ea5852e733a732 100644
--- a/lib_dec/ivas_ism_dtx_dec_fx.c
+++ b/lib_dec/ivas_ism_dtx_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -126,6 +126,10 @@ void ivas_ism_dtx_dec_fx(
move16();
}
}
+ ELSE
+ {
+ set16_fx( nb_bits_metadata, 0, st_ivas->nchan_transport );
+ }
IF( !st_ivas->bfi )
{
@@ -152,16 +156,34 @@ void ivas_ism_dtx_dec_fx(
* for DTX frames where the energy of the sent noise estimate of the dominant object
* is near silence, limit the other objects CNG energies to the same level
*-------------------------------------------------------------------*/
+
void ivas_ism_dtx_limit_noise_energy_for_near_silence_fx(
- SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder structures */
- const Word16 sce_id_dtx, /* i : SCE DTX ID */
- const Word16 nchan_transport, /* i : number of transport channels */
- Word16 *Q_cngNoiseLevel /* i : stores Q factor of hFdCngCom->cngNoiseLevel for various channels*/
+ SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder structures */
+ const Word16 sce_id_dtx, /* i : SCE DTX ID */
+ const Word16 nchan_transport /* i : number of transport channels */
)
{
Word32 fac_fx, cng_noise_nrg_obj_fx, cng_noise_nrg_dominant_fx;
Word16 ch, cng_noise_level_len, Q_cng_noise_nrg_dominant, exp;
HANDLE_FD_CNG_COM hFdCngCom;
+ Word16 Q_cngNoiseLevel[MAX_SCE];
+
+ FOR( ch = 0; ch < nchan_transport; ch++ )
+ {
+ IF( hSCE[ch] != NULL )
+ {
+ Word16 shift = getScaleFactor32( hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN );
+ if ( LT_16( sub( hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) )
+ {
+ shift = sub( hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 );
+ }
+ scale_sig32( hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31-(cngNoiseLevelExp -shift) )
+ hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift );
+ Q_cngNoiseLevel[ch] = sub( 31, hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp );
+ move16();
+ move16();
+ }
+ }
hFdCngCom = hSCE[sce_id_dtx]->hCoreCoder[0]->hFdCngDec->hFdCngCom;
cng_noise_level_len = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand );
diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c
index c89eb8c497232f96a1f5ae3ca31df9eed73ad247..e937b9dfe606c3389e295ffd22ca8efbde647b35 100644
--- a/lib_dec/ivas_ism_metadata_dec_fx.c
+++ b/lib_dec/ivas_ism_metadata_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -54,8 +54,8 @@ static Word16 decode_radius_fx( DEC_CORE_HANDLE st0, Word16 *last_radius_idx, Wo
#define IVAS_ISM_DTX_HO_MAX 5
-#define CNG_MD_MAX_DIFF_AZIMUTH 5
-#define CNG_MD_MAX_DIFF_ELEVATION 5
+#define CNG_MD_MAX_DIFF_AZIMUTH_FX ( 5 << Q22 )
+#define CNG_MD_MAX_DIFF_ELEVATION_FX ( 5 << Q22 )
#define MAX_BITS_ISM_METADATA ( 2 * ISM_EXTENDED_METADATA_BITS + MAX_NUM_OBJECTS * ( 1 /*number of objects*/ + ISM_METADATA_MD_FLAG_BITS + 2 * ISM_METADATA_FLAG_BITS + ISM_METADATA_IS_NDP_BITS + 1 /*abs.flag*/ + ISM_AZIMUTH_NBITS + ISM_ELEVATION_NBITS + 1 /*abs.flag*/ + ISM_RADIUS_NBITS + 1 /*abs.flag*/ + ISM_AZIMUTH_NBITS + ISM_ELEVATION_NBITS ) + 10 /* margin */ ) /* max. bit-budget of ISM metadata */
@@ -95,20 +95,20 @@ static void ism_metadata_smooth_fx(
}
test();
- IF( GT_32( ism_total_brate, IVAS_SID_5k2 ) && GT_32( L_abs( diff_fx ), L_shl( IVAS_ISM_DTX_HO_MAX * CNG_MD_MAX_DIFF_AZIMUTH, Q22 ) ) )
+ IF( GT_32( ism_total_brate, IVAS_SID_5k2 ) && GT_32( L_abs( diff_fx ), IVAS_ISM_DTX_HO_MAX * CNG_MD_MAX_DIFF_AZIMUTH_FX ) )
{
/* skip the smoothing */
}
- ELSE IF( GT_32( L_abs( diff_fx ), L_shl( CNG_MD_MAX_DIFF_AZIMUTH, Q22 ) ) )
+ ELSE IF( GT_32( L_abs( diff_fx ), CNG_MD_MAX_DIFF_AZIMUTH_FX ) )
{
Word32 temp;
IF( ( diff_fx > 0 ) )
{
- temp = L_shl( CNG_MD_MAX_DIFF_AZIMUTH, Q22 );
+ temp = CNG_MD_MAX_DIFF_AZIMUTH_FX;
}
ELSE
{
- temp = L_negate( L_shl( CNG_MD_MAX_DIFF_AZIMUTH, Q22 ) );
+ temp = L_negate( CNG_MD_MAX_DIFF_AZIMUTH_FX );
}
hIsmMetaData->azimuth_fx = L_add( hIsmMetaData->last_azimuth_fx, temp );
move32();
@@ -129,20 +129,20 @@ static void ism_metadata_smooth_fx(
diff_fx = L_sub( hIsmMetaData->last_true_elevation_fx, hIsmMetaData->last_elevation_fx );
test();
- IF( GT_32( ism_total_brate, IVAS_SID_5k2 ) && GT_32( diff_fx, L_shl( IVAS_ISM_DTX_HO_MAX * CNG_MD_MAX_DIFF_ELEVATION, Q22 ) ) )
+ IF( GT_32( ism_total_brate, IVAS_SID_5k2 ) && GT_32( L_abs( diff_fx ), IVAS_ISM_DTX_HO_MAX * CNG_MD_MAX_DIFF_ELEVATION_FX ) )
{
/* skip the smoothing */
}
- ELSE IF( GT_32( L_abs( diff_fx ), L_shl( CNG_MD_MAX_DIFF_ELEVATION, Q22 ) ) )
+ ELSE IF( GT_32( L_abs( diff_fx ), CNG_MD_MAX_DIFF_ELEVATION_FX ) )
{
Word32 temp;
IF( ( diff_fx > 0 ) )
{
- temp = L_shl( CNG_MD_MAX_DIFF_ELEVATION, Q22 );
+ temp = CNG_MD_MAX_DIFF_ELEVATION_FX;
}
ELSE
{
- temp = L_negate( L_shl( CNG_MD_MAX_DIFF_ELEVATION, Q22 ) );
+ temp = L_negate( CNG_MD_MAX_DIFF_ELEVATION_FX );
}
hIsmMetaData->elevation_fx = L_add( hIsmMetaData->last_elevation_fx, temp );
move32();
diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c
index 83fc9833beec07dd46d22bb39adbf5a3c5312cf6..00c95d6dca854c9fca1705b310646540067c482a 100644
--- a/lib_dec/ivas_ism_param_dec_fx.c
+++ b/lib_dec/ivas_ism_param_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -760,7 +760,7 @@ ivas_error ivas_param_ism_dec_open_fx(
st_ivas->hParamIsmDec = hParamIsmDec;
st_ivas->hSpatParamRendCom = hSpatParamRendCom;
- granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs );
+ granularity = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs );
test();
IF( NE_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) && NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) )
@@ -807,7 +807,7 @@ ivas_error ivas_param_ism_dec_open_fx(
IF( st_ivas->hTcBuffer == NULL )
{
- IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, granularity ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, granularity ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -820,7 +820,7 @@ ivas_error ivas_param_ism_dec_open_fx(
IF( st_ivas->hTcBuffer == NULL )
{
Word16 nchan_to_allocate = st_ivas->hDecoderConfig->nchan_out;
- IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -921,7 +921,7 @@ void ivas_ism_dec_digest_tc_fx(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
)
{
- ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas );
+ ivas_dec_td_renderers_adapt_subframes_fx( st_ivas );
test();
test();
@@ -979,9 +979,10 @@ void ivas_ism_dec_digest_tc_fx(
}
ELSE
{
- ivas_jbm_dec_get_adapted_linear_interpolator_fx( extract_l( Mpy_32_32( st_ivas->hDecoderConfig->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), st_ivas->hTcBuffer->n_samples_available, st_ivas->hIsmRendererData->interpolator_fx );
+ ivas_dec_get_adapted_linear_interpolator_fx( extract_l( Mpy_32_32( st_ivas->hDecoderConfig->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), st_ivas->hTcBuffer->n_samples_available, st_ivas->hIsmRendererData->interpolator_fx );
move16();
}
+
st_ivas->hIsmRendererData->interp_offset_fx = 0;
move16();
@@ -1092,7 +1093,7 @@ void ivas_param_ism_dec_digest_tc_fx(
num_freq_bands = st_ivas->hSpatParamRendCom->num_freq_bands;
move16();
output_frame = imult1616( nCldfbSlots, st_ivas->hSpatParamRendCom->num_freq_bands );
- n_ch_cldfb = sub( st_ivas->hTcBuffer->nchan_transport_jbm, st_ivas->hTcBuffer->nchan_buffer_full );
+ n_ch_cldfb = sub( st_ivas->hTcBuffer->nchan_transport_rend, st_ivas->hTcBuffer->nchan_buffer_full );
cldfb_real_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx;
cldfb_imag_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx;
@@ -1226,11 +1227,11 @@ void ivas_param_ism_dec_prepare_renderer_fx(
}
/* general setup */
- ivas_jbm_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator_fx );
+ ivas_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator_fx );
ivas_dirac_dec_set_md_map_fx( st_ivas, nCldfbSlots );
- /* set buffers to zero */
+ /* set buffers to zero */
set_zero_fx( &cx_diag_fx[0][0], CLDFB_NO_CHANNELS_MAX * PARAM_ISM_MAX_DMX );
set16_zero_fx( &exp_cx_diag[0][0], CLDFB_NO_CHANNELS_MAX * PARAM_ISM_MAX_DMX );
diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c
index 2da2053645ed9f9d1b734d88c4e2705525dd7176..bd1b654e9ca4b22e40b4b8467bb8a02a5e7539ea 100644
--- a/lib_dec/ivas_ism_renderer_fx.c
+++ b/lib_dec/ivas_ism_renderer_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -173,7 +173,7 @@ void ivas_ism_render_sf_fx(
Word32 gain_fx, prev_gain_fx;
Word32 tc_local_fx[MAX_NUM_OBJECTS][L_FRAME48k];
Word32 *p_tc_fx[MAX_NUM_OBJECTS];
- Word16 ism_md_subframe_update_jbm, slots_to_render, first_sf, last_sf, subframe_idx;
+ Word16 ism_md_subframe_update, slots_to_render, first_sf, last_sf, subframe_idx;
Word16 n_samples_rendered_loop;
/* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */
@@ -209,11 +209,11 @@ void ivas_ism_render_sf_fx(
/* Number of subframes to delay metadata to sync with audio */
IF( st_ivas->hDecoderConfig->Opt_delay_comp )
{
- ism_md_subframe_update_jbm = s_max( 0, sub( st_ivas->hTcBuffer->nb_subframes, 3 ) );
+ ism_md_subframe_update = s_max( 0, sub( st_ivas->hTcBuffer->nb_subframes, 3 ) );
}
ELSE
{
- ism_md_subframe_update_jbm = sub( st_ivas->hTcBuffer->nb_subframes, 2 );
+ ism_md_subframe_update = sub( st_ivas->hTcBuffer->nb_subframes, 2 );
}
FOR( i = 0; i < num_objects; i++ )
@@ -235,7 +235,7 @@ void ivas_ism_render_sf_fx(
test();
IF( st_ivas->hCombinedOrientationData && EQ_16( st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx], 1 ) )
{
- ivas_jbm_dec_get_adapted_linear_interpolator_fx( n_samples_in_subframe, n_samples_in_subframe, st_ivas->hIsmRendererData->interpolator_fx );
+ ivas_dec_get_adapted_linear_interpolator_fx( n_samples_in_subframe, n_samples_in_subframe, st_ivas->hIsmRendererData->interpolator_fx );
interp_offset = 0;
move16();
}
@@ -246,7 +246,7 @@ void ivas_ism_render_sf_fx(
test();
IF( st_ivas->hCombinedOrientationData != NULL && EQ_16( st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx], 1 ) )
{
- if ( GE_16( subframe_idx, ism_md_subframe_update_jbm ) )
+ if ( GE_16( subframe_idx, ism_md_subframe_update ) )
{
rotateAziEle_fx( extract_l( L_shr( st_ivas->hIsmMetaData[i]->edited_azimuth_fx, 22 ) ), extract_l( L_shr( st_ivas->hIsmMetaData[i]->edited_elevation_fx, 22 ) ), &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat_fx[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup );
}
@@ -405,7 +405,7 @@ void ivas_ism_get_stereo_gains_fx(
* Open structures, reserve memory, and init values.
*-------------------------------------------------------------------------*/
-ivas_error ivas_omasa_separate_object_renderer_open(
+ivas_error ivas_omasa_separate_object_renderer_open_fx(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
)
{
@@ -454,7 +454,7 @@ ivas_error ivas_omasa_separate_object_renderer_open(
* Close structures, free memory.
*-------------------------------------------------------------------------*/
-void ivas_omasa_separate_object_renderer_close(
+void ivas_omasa_separate_object_renderer_close_fx(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
)
{
@@ -485,16 +485,16 @@ void ivas_omasa_separate_object_renderer_close(
/*-------------------------------------------------------------------------*
- * ivas_omasa_separate_object_render_jbm()
+ * ivas_omasa_separate_object_render()
*
- * Rendering separated objects and mixing them to the parametrically rendered signals for JBM
+ * Rendering separated objects and mixing them to the parametrically rendered signals
*-------------------------------------------------------------------------*/
-void ivas_omasa_separate_object_render_jbm_fx(
+void ivas_omasa_separate_object_render_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
const UWord16 nSamplesRendered, /* i : number of samples rendered */
- Word32 input_fx_in[][L_FRAME48k], /* i : separated object signal Q11*/
- Word32 *output_fx[], /* o : rendered time signal Q11*/
+ Word32 input_fx_in[][L_FRAME48k], /* i : separated object signal Q11*/
+ Word32 *output_fx[], /* o : rendered time signal Q11*/
const Word16 subframes_rendered /* i : number of subframes rendered */
)
{
diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c
deleted file mode 100644
index ece09b600313bbbeda9d421866e6ab4ca72a12fe..0000000000000000000000000000000000000000
--- a/lib_dec/ivas_jbm_dec_fx.c
+++ /dev/null
@@ -1,4428 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-#include
-#include "options.h"
-#include "ivas_cnst.h"
-#include "prot_fx.h"
-#include "ivas_prot_fx.h"
-#include "ivas_prot_rend_fx.h"
-#include "ivas_rom_com.h"
-#include "wmc_auto.h"
-#ifdef DEBUGGING
-#include "debug.h"
-#endif
-
-
-/*-----------------------------------------------------------------------*
- * Local function prototypes
- *-----------------------------------------------------------------------*/
-
-static void ivas_jbm_dec_tc_buffer_playout_fx( Decoder_Struct *st_ivas, const UWord16 nSamplesAsked, UWord16 *nSamplesRendered, Word32 *output_fx[] );
-
-static void ivas_jbm_dec_copy_masa_meta_to_buffer( Decoder_Struct *st_ivas );
-
-static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, const Word16 nCldfbTs );
-
-static Word16 ceil_fx16(
- const Word16 inp,
- const Word16 Q )
-{
- Word16 ret = shr( inp, Q );
-
- IF( ( s_and( inp, sub( shl( 1, Q ), 1 ) ) ) > 0 )
- {
- ret = add( ret, 1 );
- }
-
- return ret;
-}
-
-/*--------------------------------------------------------------------------*
- * ivas_jbm_dec_tc()
- *
- * Principal IVAS JBM decoder routine, decoding of metadata and transport channels
- *--------------------------------------------------------------------------*/
-
-ivas_error ivas_jbm_dec_tc_fx(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-)
-{
- Word16 ch, n, output_frame, nchan_out, i, ii;
- Decoder_State *st; /* used for bitstream handling */
- Word32 *p_output_fx[MAX_TRANSPORT_CHANNELS]; /* buffer for output synthesis */
- Word16 nchan_remapped;
- Word16 nb_bits_metadata[MAX_SCE + 1];
- Word32 output_Fs, ivas_total_brate;
- AUDIO_CONFIG output_config;
- ivas_error error;
- Word16 num_md_sub_frames;
- Word32 ism_total_brate;
- Word16 s;
-
- CPE_DEC_HANDLE hCPE;
- SCE_DEC_HANDLE hSCE;
- push_wmops( "ivas_jbm_dec_tc" );
-
- /*----------------------------------------------------------------*
- * Initialization of local vars after struct has been set
- *----------------------------------------------------------------*/
-
- output_Fs = st_ivas->hDecoderConfig->output_Fs;
- move32();
- nchan_out = st_ivas->hTcBuffer->nchan_transport_jbm;
- move16();
- output_config = st_ivas->hDecoderConfig->output_config;
- ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
- move32();
-
- output_frame = extract_l( Mult_32_16( output_Fs, INV_FRAME_PER_SEC_Q15 ) ) /* output_Fs / FRAMES_PER_SEC */;
-
- /* set pointers to transport channels audio */
- FOR( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ )
- {
- p_output_fx[n] = st_ivas->p_output_fx[n];
-
- IF( p_output_fx[n] != NULL )
- {
- set32_fx( p_output_fx[n], 0, L_FRAME48k );
- }
- }
-
- /*----------------------------------------------------------------*
- * Decoding + pre-rendering
- *----------------------------------------------------------------*/
-
- test();
- test();
- IF( st_ivas->bfi != 0 && st_ivas->ini_frame == 0 )
- {
- /* zero output when first frame(s) is lost */
- FOR( n = 0; n < nchan_out; n++ )
- {
- set32_fx( p_output_fx[n], 0, output_frame );
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
- {
- st_ivas->hCPE[0]->element_brate = ivas_total_brate;
- move32();
- Word16 q_output = 11;
- move16();
- set32_fx( &p_output_fx[0][0], 0, L_FRAME48k );
- set32_fx( &p_output_fx[1][0], 0, L_FRAME48k );
-
- IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, 0 ) ) != IVAS_ERR_OK )
- {
- return error;
- }
-
- IF( NE_16( q_output, Q11 ) )
- {
- Scale_sig32( p_output_fx[0], L_FRAME48k, sub( Q11, q_output ) ); // Q11
- Scale_sig32( p_output_fx[1], L_FRAME48k, sub( Q11, q_output ) ); // Q11
- }
-
- /* HP filtering */
- FOR( n = 0; n < s_min( nchan_out, st_ivas->nchan_transport ); n++ )
- {
- hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs );
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
- {
- /* Metadata decoding and configuration */
- test();
- IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) )
- {
- ivas_ism_dtx_dec_fx( st_ivas, nb_bits_metadata );
-
- set32_fx( p_output_fx[st_ivas->hISMDTX.sce_id_dtx], 0, L_FRAME48k );
-
- IF( ( error = ivas_sce_dec_fx( st_ivas, st_ivas->hISMDTX.sce_id_dtx, &p_output_fx[st_ivas->hISMDTX.sce_id_dtx], output_frame, nb_bits_metadata[st_ivas->hISMDTX.sce_id_dtx] ) ) != IVAS_ERR_OK )
- {
- return error;
- }
- Word16 Q_cngNoiseLevel[MAX_SCE];
- FOR( ch = 0; ch < 4; ch++ )
- {
- IF( st_ivas->hSCE[ch] != NULL )
- {
- Word16 shift = getScaleFactor32( st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN );
- if ( LT_16( sub( st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) )
- {
- shift = sub( st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 );
- }
- scale_sig32( st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31-(cngNoiseLevelExp -shift) )
- st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift );
- Q_cngNoiseLevel[ch] = sub( 31, st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp );
- move16();
- move16();
- }
- }
-
- ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( st_ivas->hSCE, st_ivas->hISMDTX.sce_id_dtx, st_ivas->nchan_transport, Q_cngNoiseLevel );
-
- ivas_param_ism_dec_dequant_md_fx( st_ivas );
- }
- ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
- {
- IF( NE_32( ( error = ivas_ism_metadata_dec_fx( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hParamIsmDec->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- ivas_param_ism_dec_dequant_md_fx( st_ivas );
- }
- ELSE /* ISM_MODE_DISC */
- {
- IF( NE_32( ( error = ivas_ism_metadata_dec_fx( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- FOR( n = 0; n < st_ivas->nchan_transport; n++ )
- {
- /* for DTX frames, dominant object has already been decoded before */
- test();
- test();
- IF( !( ( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) && EQ_16( n, st_ivas->hISMDTX.sce_id_dtx ) ) )
- {
- set32_fx( p_output_fx[n], 0, L_FRAME48k );
-
- IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, n, &p_output_fx[n], output_frame, nb_bits_metadata[n] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- /* HP filtering */
- hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs );
- }
-
- test();
- test();
- test();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) )
- {
- ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame );
-
- Scale_sig32( p_output_fx[0], L_FRAME48k, 3 );
- }
- ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) )
- {
- /* loudness correction */
- ivas_dirac_dec_binaural_sba_gain_fx( p_output_fx, st_ivas->nchan_transport, output_frame ); /*returns Q-1*/
-
- FOR( i = 0; i < st_ivas->nchan_transport; i++ )
- {
- Scale_sig32( p_output_fx[i], output_frame, 1 ); // Q-1 -> Q
- }
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
- {
- set16_fx( nb_bits_metadata, 0, MAX_SCE );
-
-
- /* read parameters from the bitstream */
- test();
- IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && st_ivas->hQMetaData != NULL )
- {
- // st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0];
-
- IF( st_ivas->nSCE > 0 )
- {
- st = st_ivas->hSCE[0]->hCoreCoder[0];
- }
- ELSE
- {
- st = st_ivas->hCPE[0]->hCoreCoder[0];
- }
-
- IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st, &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
- {
- IF( NE_32( ( error = ivas_spar_dec_fx( st_ivas, nb_bits_metadata ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- test();
- IF( EQ_16( st_ivas->nchan_transport, CPE_CHANNELS ) && GE_16( st_ivas->nCPE, 1 ) )
- {
- st_ivas->hCPE[0]->brate_surplus = 0;
- move32();
- st_ivas->hCPE[0]->element_brate = ivas_total_brate;
- move32();
- }
-
- /* core-decoding of transport channels */
- Word16 q_output = Q11;
- move16();
- IF( EQ_16( st_ivas->nSCE, 1 ) )
- {
- set32_fx( p_output_fx[0], 0, L_FRAME48k );
-
- IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- ELSE IF( EQ_16( st_ivas->nCPE, 1 ) )
- {
- set32_fx( &p_output_fx[0][0], 0, L_FRAME48k );
- set32_fx( &p_output_fx[1][0], 0, L_FRAME48k );
-
- IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- IF( NE_16( q_output, Q11 ) )
- {
- Scale_sig32( p_output_fx[0], L_FRAME48k, sub( Q11, q_output ) ); // Q11
- Scale_sig32( p_output_fx[1], L_FRAME48k, sub( Q11, q_output ) ); // Q11
- }
- }
- ELSE IF( GT_16( st_ivas->nCPE, 1 ) )
- {
- IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- /* TCs remapping */
- nchan_remapped = st_ivas->nchan_transport;
- move16();
-
- test();
- test();
- test();
- test();
- test();
- IF( st_ivas->sba_dirac_stereo_flag )
- {
- nchan_remapped = nchan_out;
- move16();
-
- IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) )
- {
- FOR( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ )
- {
- Scale_sig32( p_output_fx[i], output_frame, Q14 - Q11 ); // Q14
- }
- SPAR_DEC_HANDLE hSpar = st_ivas->hSpar;
- Word16 nchan_transport;
- nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport;
- move16();
- nchan_out = nchan_transport;
- move16();
- ivas_agc_dec_process_fx( st_ivas->hSpar->hAgcDec, ( p_output_fx ), ( p_output_fx ), st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame );
-
- IF( st_ivas->hSpar->hPCA != NULL )
- {
- ivas_pca_dec_fx( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, p_output_fx );
- }
-
- ivas_spar_dec_gen_umx_mat_fx( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ) );
- }
- {
- Word16 q;
- hCPE = st_ivas->hCPE[0];
- hSCE = st_ivas->hSCE[0];
-
- s = 0;
- move16();
- FOR( i = 0; i < 2; i++ )
- {
- s = s_min( s, L_norm_arr( p_output_fx[i], L_FRAME48k ) - 11 ) /* Guard bits */; // L_frame should be used instead of L_FRAME48k */
- }
- FOR( i = 0; i < 2; i++ )
- {
- Scale_sig32( p_output_fx[i], L_FRAME48k, s ); // Q(11+s)
- }
- hCPE->hStereoDft->q_dft = add( Q11, s );
- move16();
- IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) )
- {
- hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft;
- move16();
- hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft;
- move16();
- }
- q = hCPE->hStereoDft->q_dft;
- move16();
- scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft
- FOR( i = 0; i < CPE_CHANNELS; ++i )
- {
- scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft
- scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft
- }
- IF( hCPE->hCoreCoder[0] != NULL )
- {
- Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q
- Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q
- hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q;
- move16();
- }
- IF( hCPE->hStereoDft != NULL )
- {
- IF( LE_16( st_ivas->nchan_transport, 1 ) )
- {
- st = hCPE->hCoreCoder[0];
- test();
- test();
- test();
- test();
- test();
- IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) || ( EQ_16( st->bfi, 1 ) && EQ_16( st->core, ACELP_CORE ) && EQ_16( st->con_tcx, 1 ) ) )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( ( ( st->last_core != ACELP_CORE ) || ( EQ_16( st->prev_bfi, 1 ) && ( st->last_core == ACELP_CORE ) && EQ_16( st->last_con_tcx, 1 ) ) ) && NE_16( st->last_core, AMR_WB_CORE ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_16( st->cng_type, FD_CNG ) ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */
- {
- scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft
- }
- ELSE IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) ) /* ACELP -> TCX/HQ */
- {
- IF( !st->tcxonly )
- {
- scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft
- }
- }
- }
- ELSE /* ACELP core */
- {
- test();
- test();
- IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, HQ_CORE ) ) /* TCX/HQ -> ACELP */
- {
- test();
- test();
- test();
- test();
- IF( ( LE_16( st->last_L_frame, L_FRAME16k ) && LE_16( st->L_frame, L_FRAME16k ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) )
- {
- scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft
- }
- }
- }
- }
- scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // q_dft
- hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft;
- move16();
- }
-
- IF( hSCE != NULL )
- {
- Scale_sig32( &hSCE->save_hb_synth_fx[0], extract_l( Mult_32_16( hCPE->hCoreCoder[0]->output_Fs, INV_FRAME_PER_SEC_Q15 ) ), sub( hCPE->hStereoDft->q_dft, hSCE->q_save_hb_synth_fx ) ); // q_dft
- hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft;
- move16();
- Scale_sig32( &hSCE->save_synth_fx[0], extract_l( Mult_32_16( hCPE->hCoreCoder[0]->output_Fs, INV_FRAME_PER_SEC_Q15 ) ), sub( hCPE->hStereoDft->q_dft, hSCE->q_save_synth_fx ) ); // q_dft
- hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft;
- move16();
- }
- FOR( ii = 0; ii < CPE_CHANNELS; ii++ )
- {
- scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft
- hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft;
- move16();
- }
- FOR( ii = 0; ii < CPE_CHANNELS; ii++ )
- {
- Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx
- }
-
- ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame, st_ivas->ivas_format == MC_FORMAT );
-
- FOR( i = 0; i < 2; i++ )
- {
- Scale_sig32( p_output_fx[i], L_FRAME48k, negate( s ) );
- }
- FOR( ii = 0; ii < CPE_CHANNELS; ii++ )
- {
- Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11
- }
-
- scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) );
- FOR( i = 0; i < CPE_CHANNELS; ++i )
- {
- scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11
- scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11
- }
-
- IF( hCPE->hCoreCoder[0] != NULL )
- {
- Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB - q ); // Q_old_wtda_LB
- Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda - q ); // Q_old_wtda_LB
- }
- IF( hCPE->hStereoDft != NULL )
- {
- IF( LE_16( st_ivas->nchan_transport, 1 ) )
- {
- st = hCPE->hCoreCoder[0];
- test();
- test();
- test();
- test();
- test();
- IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) || ( EQ_16( st->bfi, 1 ) && st->core == ACELP_CORE && EQ_16( st->con_tcx, 1 ) ) )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( ( st->last_core != ACELP_CORE || ( EQ_16( st->prev_bfi, 1 ) && st->last_core == ACELP_CORE && EQ_16( st->last_con_tcx, 1 ) ) ) && NE_16( st->last_core, AMR_WB_CORE ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_16( st->cng_type, FD_CNG ) ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */
- {
- scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11
- }
- ELSE IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) ) /* ACELP -> TCX/HQ */
- {
- IF( !st->tcxonly )
- {
- scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11
- }
- }
- }
- ELSE /* ACELP core */
- {
- test();
- test();
- IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, HQ_CORE ) ) /* TCX/HQ -> ACELP */
- {
- test();
- test();
- test();
- test();
- IF( ( LE_16( st->last_L_frame, L_FRAME16k ) && LE_16( st->L_frame, L_FRAME16k ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) )
- {
- scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11
- }
- }
- }
- }
- scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // Q11
- hCPE->hStereoDft->q_ap_fade_mem_fx = Q11;
- test();
- }
-
- st_ivas->hSpar->hMdDec->Q_mixer_mat = 30;
- move16();
- FOR( ii = 0; ii < CPE_CHANNELS; ii++ )
- {
- scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11
- hCPE->q_output_mem_fx[ii] = Q11;
- move16();
- }
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) || ( LE_32( ivas_total_brate, IVAS_SID_5k2 ) && st_ivas->nCPE > 0 && EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) ) ) )
- {
- nchan_remapped = 1; /* Only one channel transported */
- move16();
- }
-
- /* HP filtering */
- FOR( n = 0; n < nchan_remapped; n++ )
- {
- hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs );
- }
-
- IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
- {
- nchan_remapped = ivas_sba_remapTCs_fx( p_output_fx, st_ivas, output_frame );
-
- test();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
- {
- num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate );
-
- SPAR_DEC_HANDLE hSpar = st_ivas->hSpar;
- Word16 Q_p_output = MAX_16, temp_min;
- move16();
- Word16 nchan_transport;
-
- nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport;
- move16();
- nchan_out = nchan_transport;
- move16();
- FOR( ch = 0; ch < nchan_transport; ch++ )
- {
- temp_min = L_norm_arr( p_output_fx[ch], output_frame );
- Q_p_output = s_min( Q_p_output, temp_min );
- }
- Q_p_output = sub( Q_p_output, 2 );
- if ( GT_16( Q_p_output, 20 ) )
- {
- Q_p_output = 20;
- move16();
- }
- FOR( ch = 0; ch < nchan_transport; ch++ )
- {
- Scale_sig32( p_output_fx[ch], output_frame, Q_p_output ); // Q(11+Q_p_output)
- }
-
- ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, p_output_fx, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames, Q_p_output );
- FOR( Word16 c = 0; c < nchan_transport; c++ )
- {
- Scale_sig32( p_output_fx[c], output_frame, 11 ); // Q11
- }
- }
- ELSE IF( NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) )
- {
- Word16 size = st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport;
- move16();
- if ( EQ_16( st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, 3 ) )
- size = add( size, 1 );
-
- FOR( i = 0; i < size; i++ )
- {
- Scale_sig32( p_output_fx[i], output_frame, Q14 - Q11 ); // Q14
- }
-
- ivas_spar_dec_agc_pca_fx( st_ivas, p_output_fx, output_frame );
- }
- }
-
- test();
- test();
- IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
- {
- Word16 q_shift = 0;
- move16();
-
- ivas_masa_prerender_fx( st_ivas, p_output_fx, &q_shift, output_frame, nchan_remapped );
- FOR( i = 0; i < 2; i++ )
- {
- Scale_sig32( p_output_fx[i], output_frame, negate( q_shift ) );
- }
-
- test();
- /* external output */
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && EQ_32( st_ivas->hMasa->config.input_ivas_format, MASA_ISM_FORMAT ) )
- {
- FOR( n = 0; n < st_ivas->nchan_ism; n++ )
- {
- set_zero_fx( p_output_fx[add( st_ivas->nchan_transport, n )], output_frame );
- }
-
- ivas_omasa_rearrange_channels_fx( p_output_fx, st_ivas->nchan_ism, output_frame );
- }
- }
- ELSE IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) && ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) )
- {
- /* loudness correction */
- ivas_dirac_dec_binaural_sba_gain_fx( p_output_fx, nchan_remapped, output_frame );
-
- FOR( i = 0; i < st_ivas->nchan_transport; i++ )
- {
- Scale_sig32( p_output_fx[i], output_frame, 1 ); // Q-1 -> Q
- }
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
- {
- Word16 nchan_ism, nchan_transport_ism;
- Word16 dirac_bs_md_write_idx;
-
- set16_fx( nb_bits_metadata, 0, MAX_SCE + 1 );
-
- /* Set the number of objects for the parametric rendering */
- dirac_bs_md_write_idx = 0;
- move16();
- IF( st_ivas->hSpatParamRendCom != NULL )
- {
- st_ivas->hSpatParamRendCom->numIsmDirections = 0;
- move16();
- test();
- if ( NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && NE_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) )
- {
- st_ivas->hSpatParamRendCom->numIsmDirections = st_ivas->nchan_ism;
- move16();
- }
-
- dirac_bs_md_write_idx = st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx; /* Store the write-index for this frame */
- move16();
- }
-
-
- /* set ISM parameters and decode ISM metadata in OMASA format */
- Word16 q_output = 11;
- move16();
- // NOTE: the following is done to calculate the number of hIsmMetaData indices
- Word16 tmp_nchan_ism;
- IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) )
- {
- tmp_nchan_ism = 1;
- move16();
- }
- ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) )
- {
- tmp_nchan_ism = 0;
- move16();
- }
- ELSE
- {
- tmp_nchan_ism = st_ivas->nchan_ism;
- move16();
- }
-
- FOR( n = 0; n < tmp_nchan_ism; n++ )
- {
- set32_fx( p_output_fx[n], 0, L_FRAME48k );
- }
-
- /* MASA metadata decoding */
- IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st_ivas->hCPE[0]->hCoreCoder[0], &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- /* Configuration of combined-format bit-budget distribution */
- ivas_set_surplus_brate_dec( st_ivas, &ism_total_brate );
-
- st_ivas->hCPE[0]->hCoreCoder[0]->bit_stream = &( st_ivas->bit_stream[( ism_total_brate / FRAMES_PER_SEC )] );
-
- IF( NE_32( ( error = ivas_omasa_ism_metadata_dec_fx( st_ivas, ism_total_brate, &nchan_ism, &nchan_transport_ism, dirac_bs_md_write_idx, &nb_bits_metadata[1] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- FOR( n = 0; n < nchan_transport_ism; n++ )
- {
- IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, n, &p_output_fx[st_ivas->nchan_transport + n], output_frame, nb_bits_metadata[1] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- /* decode MASA channels */
- IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- /* shifting both the channels from variable q_output to constant Q-factor (Q11) */
- FOR( Word16 k = 0; k < output_frame; k++ )
- {
- p_output_fx[0][k] = L_shr( p_output_fx[0][k], sub( Q11, q_output ) );
- move32();
- p_output_fx[1][k] = L_shr( p_output_fx[1][k], sub( Q11, q_output ) );
- move32();
- }
-
- IF( EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) )
- {
- Copy32( p_output_fx[0], p_output_fx[1], output_frame ); /* Copy mono signal to stereo output channels */
- }
-
- FOR( n = 0; n < getNumChanSynthesis( st_ivas ); n++ )
- {
- hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs );
- }
-
- Word16 output_q = 11;
- move16();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) )
- {
- ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame );
-
- output_q = 8;
- move16();
- }
- ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
- {
- IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
- {
- ivas_omasa_rearrange_channels_fx( p_output_fx, nchan_transport_ism, output_frame );
- }
- ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) )
- {
- /* Convert separate object to MASA, combine with the original MASA, and output combined MASA + empty objects. */
- ivas_omasa_combine_separate_ism_with_masa_fx( st_ivas, p_output_fx, &output_q, st_ivas->nchan_ism, output_frame );
- }
- ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) )
- {
- /* Extract objects from MASA, output MASA + all objects (i.e., extracted and separated objects) */
- ivas_omasa_render_objects_from_mix_fx( st_ivas, p_output_fx, st_ivas->nchan_ism, output_frame, &output_q );
- }
- }
- IF( NE_16( output_q, Q11 ) )
- {
- FOR( n = 0; n < s_max( getNumChanSynthesis( st_ivas ), nchan_transport_ism + st_ivas->nchan_transport ); n++ )
- {
- Scale_sig32( p_output_fx[n], output_frame, sub( Q11, output_q ) ); // Q11
- }
- st_ivas->hCPE[0]->q_output_mem_fx[0] = output_q;
- st_ivas->hCPE[0]->q_output_mem_fx[1] = output_q;
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
- {
- Word16 nchan_ism, sba_ch_idx;
-
- set16_fx( nb_bits_metadata, 0, MAX_SCE + 1 );
- nchan_ism = st_ivas->nchan_ism;
- move16();
- IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
- {
- /* set ISM parameters and decode ISM metadata in OSBA format */
- IF( NE_32( ( error = ivas_osba_ism_metadata_dec_fx( st_ivas, ivas_total_brate, &nchan_ism, &nb_bits_metadata[1] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- sba_ch_idx = st_ivas->nchan_ism;
- move16();
- }
- ELSE
- {
- nb_bits_metadata[1] = add( nb_bits_metadata[1], NO_BITS_MASA_ISM_NO_OBJ );
- sba_ch_idx = 0;
- move16();
- move16();
- }
-
- /* SBA metadata decoding */
- IF( NE_32( ( error = ivas_spar_dec_fx( st_ivas, nb_bits_metadata ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- test();
- IF( EQ_16( st_ivas->nchan_transport, CPE_CHANNELS ) && GE_16( st_ivas->nCPE, 1 ) )
- {
- st_ivas->hCPE[0]->element_brate = ivas_total_brate;
- move32();
- }
-
- /* core-decoding of transport channels */
- Word16 q_output = 11;
- move16();
-
- IF( EQ_16( st_ivas->nSCE, 1 ) )
- {
- set32_fx( p_output_fx[0], 0, L_FRAME48k );
-
- IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- ELSE IF( EQ_16( st_ivas->nCPE, 1 ) )
- {
-
- IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, add( nb_bits_metadata[0], nb_bits_metadata[1] ) ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- IF( NE_16( q_output, Q11 ) )
- {
- Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11
- Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11
- }
- }
- ELSE IF( GT_16( st_ivas->nCPE, 1 ) )
- {
- IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- IF( st_ivas->sba_dirac_stereo_flag )
- {
- FOR( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ )
- {
- Scale_sig32( p_output_fx[i + sba_ch_idx], output_frame, Q14 - Q11 ); // Q14
- }
- SPAR_DEC_HANDLE hSpar = st_ivas->hSpar;
- Word16 nchan_transport;
- nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport;
- move16();
- nchan_out = nchan_transport;
- move16();
- ivas_agc_dec_process_fx( st_ivas->hSpar->hAgcDec, ( p_output_fx + sba_ch_idx ), ( p_output_fx + sba_ch_idx ), st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame );
-
- IF( st_ivas->hSpar->hPCA != NULL )
- {
- ivas_pca_dec_fx( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &p_output_fx[sba_ch_idx] );
- }
- ivas_spar_dec_gen_umx_mat_fx( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) );
- {
- Word16 q;
- hCPE = st_ivas->hCPE[0];
- hSCE = st_ivas->hSCE[0];
- s = 0;
- move16();
- FOR( i = 0; i < 2; i++ )
- {
- s = s_min( s, L_norm_arr( p_output_fx[sba_ch_idx + i], L_FRAME48k ) - 11 /* Guard bits */ );
- }
- FOR( i = 0; i < 2; i++ )
- {
- Scale_sig32( p_output_fx[sba_ch_idx + i], L_FRAME48k, s ); // Q(11+s)
- }
- hCPE->hStereoDft->q_dft = add( Q11, s );
- move16();
- IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) )
- {
- hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft;
- hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft;
- move16();
- move16();
- }
-
- q = hCPE->hStereoDft->q_dft;
- move16();
- scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) );
- FOR( i = 0; i < CPE_CHANNELS; ++i )
- {
- scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft
- scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft
- }
- IF( hCPE->hCoreCoder[0] != NULL )
- {
- Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ) ); // q
- Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ) ); // q
- hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q;
- move16();
- }
- IF( hCPE->hStereoDft != NULL )
- {
- scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft
- scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // q_dft
- hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft;
- move16();
- }
-
- IF( hSCE != NULL )
- {
- Scale_sig32( &hSCE->save_hb_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_hb_synth_fx ); // q_dft
- hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft;
- move16();
- Scale_sig32( &hSCE->save_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_synth_fx ); // q_dft
- hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft;
- move16();
- }
- FOR( ii = 0; ii < CPE_CHANNELS; ii++ )
- {
- scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft
- hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft;
- move16();
- }
- FOR( i = 0; i < CPE_CHANNELS; i++ )
- Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx
- ivas_sba_dirac_stereo_dec_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame, 0 );
- FOR( i = 0; i < 2; i++ )
- {
- Scale_sig32( p_output_fx[sba_ch_idx + i], L_FRAME48k, negate( s ) );
- }
-
- FOR( i = 0; i < CPE_CHANNELS; i++ )
- Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( 11, hCPE->q_prev_synth_fx ) ); // Q11
-
- scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11
- FOR( i = 0; i < CPE_CHANNELS; ++i )
- {
- scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11
- scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11
- }
-
- IF( hCPE->hCoreCoder[0] != NULL )
- {
- Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB, q ) ); // Q_old_wtda_LB
- Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda, q ) ); // Q_old_wtda
- }
- IF( hCPE->hStereoDft != NULL )
- {
- scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11
- scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // Q11
- hCPE->hStereoDft->q_ap_fade_mem_fx = Q11;
- move16();
- }
-
- FOR( ii = 0; ii < CPE_CHANNELS; ii++ )
- {
- scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11
- hCPE->q_output_mem_fx[ii] = Q11;
- move16();
- }
- }
- }
-
- /* HP filtering */
- FOR( n = 0; n < getNumChanSynthesis( st_ivas ); n++ )
- {
- hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs );
- }
-
- nchan_remapped = ivas_sba_remapTCs_fx( &p_output_fx[sba_ch_idx], st_ivas, output_frame );
-
- test();
- test();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
- {
- num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate );
- SPAR_DEC_HANDLE hSpar = st_ivas->hSpar;
- Word16 nchan_transport;
- // num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands;
- nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport;
- move16();
- nchan_out = nchan_transport;
- move16();
- Word16 Q_p_output;
- Word16 min_norm = 31;
- move16();
-
- FOR( ch = 0; ch < nchan_transport; ++ch )
- {
- Word16 norm = L_norm_arr( p_output_fx[sba_ch_idx + ch], output_frame ); // Normalize per channel
- min_norm = s_min( norm, min_norm );
- }
-
- Q_p_output = s_max( 3, sub( min_norm, 1 ) );
-
- Q_p_output = s_min( Q_p_output, 19 ); // to restrict Q-factor of p_ouptut to Q30
- FOR( ch = 0; ch < nchan_transport; ch++ )
- {
- Scale_sig32( p_output_fx[sba_ch_idx + ch], output_frame, Q_p_output ); // Q_p_output + Q11
- }
- Q_p_output = add( Q11, Q_p_output );
- hSpar->hMdDec->Q_mixer_mat = 31;
- move16();
-
- ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, &p_output_fx[sba_ch_idx], st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames, sub( Q_p_output, Q11 ) );
- FOR( Word16 c = 0; c < nchan_transport; c++ )
- {
- Scale_sig32( p_output_fx[sba_ch_idx + c], output_frame, Q11 ); // Q11
- }
- }
- ELSE IF( NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) && st_ivas->sba_dirac_stereo_flag == 0 )
- {
- Word16 size = add( st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, sba_ch_idx );
- if ( EQ_16( size, 3 ) )
- {
- size = add( size, 1 );
- }
-
- FOR( i = sba_ch_idx; i < size; i++ )
- {
- Scale_sig32( p_output_fx[i], output_frame, ( Q14 - Q11 ) ); // Q14
- }
-
- ivas_spar_dec_agc_pca_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame );
- }
-
- test();
- test();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
- {
- /* loudness correction */
- ivas_dirac_dec_binaural_sba_gain_fx( &p_output_fx[sba_ch_idx], nchan_remapped, output_frame ); /*returns Q-1*/
-
- FOR( i = 0; i < nchan_remapped; i++ )
- {
- Scale_sig32( p_output_fx[i], output_frame, 1 ); // Q-1 -> Q
- }
- }
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
- {
- ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame );
-
- Scale_sig32( p_output_fx[0], L_FRAME48k, Q11 - Q8 ); // Q11
-
- /* add W */
- FOR( n = 0; n < nchan_out; n++ )
- {
- v_add_32( p_output_fx[n], p_output_fx[n + s_max( nchan_out, nchan_ism )], p_output_fx[n], output_frame );
- }
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) )
- {
- IF( st_ivas->nSCE > 0 )
- {
- st = st_ivas->hSCE[0]->hCoreCoder[0];
- }
- ELSE
- {
- st = st_ivas->hCPE[0]->hCoreCoder[0];
- }
-
- IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) )
- {
- /* LFE channel decoder */
- ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] );
-
- Scale_sig32( p_output_fx[LFE_CHANNEL], L_FRAME48k, Q11 - Q9 ); // Q11
- IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, 0 ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- /* HP filtering */
- FOR( n = 0; n < st_ivas->nchan_transport; n++ )
- {
- IF( NE_16( n, LFE_CHANNEL ) )
- {
- hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs );
- }
- }
-
- test();
- test();
- test();
- IF( NE_32( st_ivas->transport_config, st_ivas->intern_config ) && ( NE_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_FOA ) || NE_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA2 ) || NE_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA3 ) ) )
- {
- IF( GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ) ) )
- {
- ivas_mc2sba_fx( st_ivas->hTransSetup, p_output_fx, p_output_fx, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE_FX );
- }
- }
-
- test();
- test();
- IF( ( EQ_32( st_ivas->renderer_type, RENDERER_MC ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) && GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ) )
- {
- IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) )
- {
- s = Q16 - Q11;
- move16();
- s = sub( s, find_guarded_bits_fx( st_ivas->nchan_transport ) );
- FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i )
- {
- Scale_sig32( p_output_fx[i], output_frame, s ); // Q(11+s)
- }
- ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx );
- FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i )
- {
- Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); // Q11
- }
- }
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
- {
- ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, output_frame, st_ivas->hOutSetup.ambisonics_order, 0 );
- }
- }
- }
- ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
- {
- /* LFE channel decoder */
- ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] );
-
- Scale_sig32( p_output_fx[LFE_CHANNEL], L_FRAME48k, Q11 - Q9 ); // Q11
-
- ivas_mc_paramupmix_dec_read_BS( st_ivas, st, st_ivas->hMCParamUpmix, &nb_bits_metadata[0] );
-
- IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- /* HP filtering */
- FOR( n = 0; n < st_ivas->nchan_transport; n++ )
- {
- IF( NE_16( n, LFE_CHANNEL ) )
- {
- hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs );
- }
- }
-
- /* Rendering */
- test();
- test();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) && ( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) )
- {
- /* Compensate loudness for not doing full upmix */
- FOR( n = 4; n < 8; n++ )
- {
- Scale_sig32( p_output_fx[n], output_frame, 1 );
- }
-
- test();
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) )
- {
- s = Q16 - Q11;
- move16();
- Word16 nchan_transport;
- nchan_transport = audioCfg2channels( IVAS_AUDIO_CONFIG_5_1_2 );
- s = sub( s, find_guarded_bits_fx( nchan_transport ) );
- FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i )
- {
- Scale_sig32( p_output_fx[i], output_frame, s );
- }
- ivas_ls_setup_conversion_fx( st_ivas, nchan_transport, output_frame, p_output_fx, p_output_fx );
- FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i )
- {
- Scale_sig32( p_output_fx[i], output_frame, negate( s ) );
- }
- }
- }
- }
- ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
- {
- /* read Parametric MC parameters from the bitstream */
- ivas_param_mc_dec_read_BS_fx( ivas_total_brate, st, st_ivas->hParamMC, &nb_bits_metadata[0] );
-
- IF( EQ_16( st_ivas->nCPE, 1 ) )
- {
- Word16 q_output = 11;
- move16();
-
- IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- IF( NE_16( q_output, Q11 ) )
- {
- Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11
- Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11
- }
- }
- ELSE IF( GT_16( st_ivas->nCPE, 1 ) )
- {
- IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
-
- /* HP filtering */
- FOR( n = 0; n < st_ivas->nchan_transport; n++ )
- {
- hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs );
- }
-
- /* Rendering */
- test();
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) )
- {
- ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx );
- }
- }
- ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
- {
- IF( st_ivas->hOutSetup.separateChannelEnabled )
- {
- st = st_ivas->hCPE[0]->hCoreCoder[0]; /* Metadata is always with CPE in the case of separated channel */
- }
-
- /* read McMASA parameters from the bitstream */
- IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st, &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- IF( st_ivas->hOutSetup.separateChannelEnabled )
- {
- /* Decode the transport audio signals */
- Word16 q_output = 11;
- move16();
-
- IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- IF( NE_16( q_output, Q11 ) )
- {
- Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11
- Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11
- }
-
- /* Identify the index of the separated channel, always LFE_CHANNEL-1 here */
- n = LFE_CHANNEL - 1;
- move16();
-
- /* Decode the separated channel to output[n] to be combined with the synthesized channels */
- set32_fx( p_output_fx[n], 0, L_FRAME48k );
- IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[n], output_frame, 0 ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- /* Delay the separated channel to sync with CLDFB delay of the DirAC synthesis, and synthesize the LFE signal. */
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) ||
- EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || ( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe > 0 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
- {
- ivas_lfe_synth_with_filters_fx( st_ivas->hMasa->hMasaLfeSynth, p_output_fx, output_frame, n, LFE_CHANNEL );
- }
- ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe == 0 )
- {
- /* Delay the separated channel to sync with the DirAC rendering */
- delay_signal32_fx( p_output_fx[n], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_fx, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size );
- }
- }
- ELSE
- {
- Word16 q_output = 11;
- move16();
- IF( EQ_16( st_ivas->nSCE, 1 ) )
- {
- set32_fx( p_output_fx[0], 0, L_FRAME48k );
-
- IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- ELSE IF( EQ_16( st_ivas->nCPE, 1 ) )
- {
- IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- IF( NE_16( q_output, Q11 ) )
- {
- Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11
- Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11
- }
- }
- }
-
- IF( st_ivas->sba_dirac_stereo_flag != 0 ) /* use the flag to trigger the DFT upmix */
- {
- Word16 q;
- hCPE = st_ivas->hCPE[0];
- hSCE = st_ivas->hSCE[0];
- s = 0;
- move16();
- FOR( i = 0; i < 2; i++ )
- {
- s = s_min( s, L_norm_arr( p_output_fx[i], L_FRAME48k ) - 11 /* Guard bits */ );
- }
- FOR( i = 0; i < 2; i++ )
- {
- Scale_sig32( p_output_fx[i], L_FRAME48k, s ); // Q(11+s)
- }
-
- hCPE->hStereoDft->q_dft = add( Q11, s );
- move16();
- IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) )
- {
- hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft;
- hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft;
-
- move16();
- move16();
- }
-
- q = hCPE->hStereoDft->q_dft;
- move16();
-
- scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) );
- FOR( i = 0; i < CPE_CHANNELS; ++i )
- {
- scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft
- scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft
- }
-
- IF( hCPE->hCoreCoder[0] != NULL )
- {
- Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q
- Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q
- hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q;
- move16();
- }
- IF( hCPE->hStereoDft != NULL )
- {
- scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft
- scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // q_dft
- hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft;
- move16();
- }
- IF( st_ivas->hSpar != NULL )
- {
- st_ivas->hSpar->hMdDec->Q_mixer_mat = 30;
- move16();
- }
-
- IF( hSCE != NULL )
- {
- Scale_sig32( &hSCE->save_hb_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_hb_synth_fx ); // q_dft
- hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft;
- move16();
- Scale_sig32( &hSCE->save_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_synth_fx ); // q_dft
- hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft;
- move16();
- }
- FOR( ii = 0; ii < CPE_CHANNELS; ii++ )
- {
- scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->q_output_mem_fx[ii] ) ); // q_dft
- hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft;
- move16();
- }
- FOR( i = 0; i < CPE_CHANNELS; i++ )
- Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx
- ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame, 1 );
- FOR( i = 0; i < 2; i++ )
- {
- Scale_sig32( p_output_fx[i], L_FRAME48k, negate( s ) );
- }
- FOR( i = 0; i < CPE_CHANNELS; i++ )
- Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11
-
- scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) );
- FOR( i = 0; i < CPE_CHANNELS; ++i )
- {
- scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11
- scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11
- }
-
- IF( hCPE->hCoreCoder[0] != NULL )
- {
- Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB, q ) ); // Q_old_wtda_LB
- Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda, q ) ); // Q_old_wtda
- }
- IF( hCPE->hStereoDft != NULL )
- {
- scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11
- scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // Q11
- hCPE->hStereoDft->q_ap_fade_mem_fx = Q11;
- move16();
- }
- IF( st_ivas->hSpar != NULL )
- {
- FOR( ii = 0; ii < CPE_CHANNELS; ii++ )
- {
- scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11
- hCPE->q_output_mem_fx[ii] = Q11;
- move16();
- }
- }
- }
-
- /* HP filtering */
- FOR( n = 0; n < getNumChanSynthesis( st_ivas ); n++ )
- {
- hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs );
- }
-
- IF( EQ_32( st_ivas->renderer_type, RENDERER_MCMASA_MONO_STEREO ) )
- {
- ivas_mono_stereo_downmix_mcmasa_fx( st_ivas, p_output_fx, output_frame );
- }
- }
- }
-
- /*----------------------------------------------------------------*
- * Common updates
- *----------------------------------------------------------------*/
-
- IF( !st_ivas->bfi ) /* do not update if first frame(s) are lost or NO_DATA */
- {
- st_ivas->hDecoderConfig->last_ivas_total_brate = ivas_total_brate;
- move32();
- IF( LE_32( ivas_total_brate, IVAS_SID_5k2 ) )
- {
- st_ivas->last_active_ivas_total_brate = st_ivas->last_active_ivas_total_brate;
- move32();
- }
- ELSE
- {
- st_ivas->last_active_ivas_total_brate = ivas_total_brate;
- move32();
- }
- }
-
- test();
- test();
- if ( LT_16( st_ivas->ini_frame, MAX_FRAME_COUNTER ) && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) ) /* keep "st_ivas->ini_frame = 0" until first good received frame */
- {
- st_ivas->ini_frame = add( st_ivas->ini_frame, 1 );
- move16();
- }
-
- test();
- test();
- if ( LT_16( st_ivas->ini_active_frame, MAX_FRAME_COUNTER ) && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) && GT_32( ivas_total_brate, IVAS_SID_5k2 ) ) /* needed in MASA decoder in case the first active frame is BFI, and there were SID-frames decoded before */
- {
- st_ivas->ini_active_frame = add( st_ivas->ini_active_frame, 1 );
- move16();
- }
-
- st_ivas->last_ivas_format = st_ivas->ivas_format;
- move32();
- pop_wmops();
-
- return IVAS_ERR_OK;
-}
-
-
-/*--------------------------------------------------------------------------*
- * ivas_dec_feed_tc_to_renderer()
- *
- * Feed decoded transport channels to the IVAS renderer routine
- * + digest TC channels in ParamISM and ParamMC
- *--------------------------------------------------------------------------*/
-
-void ivas_jbm_dec_feed_tc_to_renderer_fx(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const Word16 nSamplesForRendering, /* i : number of TC samples available for rendering */
- Word16 *nSamplesResidual /* o : number of samples not fitting into the renderer grid and buffer for the next call*/
-)
-{
- Word32 tmp_buf_fx[MAX_JBM_L_FRAME48k];
- Word32 *p_data_fx[FOA_CHANNELS + MAX_NUM_OBJECTS];
- Word16 n, n_render_timeslots, n_ch_cldfb;
- Word16 ch, offset, len_offset;
- DECODER_TC_BUFFER_HANDLE hTcBuffer;
-
- hTcBuffer = st_ivas->hTcBuffer;
- n_ch_cldfb = sub( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full );
- move16();
-
- hTcBuffer->q_tc_fx = Q11;
- move16();
-
- IF( st_ivas->hDecoderConfig->Opt_tsm )
- {
- Word16 n_samples_still_available;
- Word16 n_ch_full_copy, n_ch_res_copy;
-
- n_samples_still_available = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_rendered );
- hTcBuffer->n_samples_buffered = add( add( n_samples_still_available, nSamplesForRendering ), hTcBuffer->n_samples_discard );
- hTcBuffer->n_samples_available = i_mult( hTcBuffer->n_samples_granularity, idiv1616( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_granularity ) );
- *nSamplesResidual = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_available );
- move16();
- move16();
- move16();
- n_ch_full_copy = s_min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full );
- n_ch_res_copy = sub( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full );
-
- /* buffers are shared between 'hTcBuffer->tc[]' and 'p_output_f[]':
- in case of 'length(hTcBuffer->tc[]) < length(p_output_f[])', reset of TC buffers
- pointers is needed after ivas_buffer_interleaved_to_deinterleaved() */
- len_offset = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS );
- IF( LT_16( len_offset, L_FRAME48k ) )
- {
- offset = 0;
- move16();
- FOR( ch = 0; ch < s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch++ )
- {
- hTcBuffer->tc_fx[ch] = &hTcBuffer->tc_buffer_fx[offset];
- st_ivas->p_output_fx[ch] = hTcBuffer->tc_fx[ch];
- offset = add( offset, len_offset );
- }
- }
-
- FOR( ch = 0; ch < n_ch_full_copy; ch++ )
- {
- Copy32( hTcBuffer->tc_fx[ch], tmp_buf_fx, nSamplesForRendering );
- set_zero_fx( hTcBuffer->tc_fx[ch], hTcBuffer->n_samples_discard );
- Copy32( hTcBuffer->tc_buffer_old_fx[ch], hTcBuffer->tc_fx[ch] + hTcBuffer->n_samples_discard, n_samples_still_available );
- Copy32( tmp_buf_fx, hTcBuffer->tc_fx[ch] + n_samples_still_available + hTcBuffer->n_samples_discard, nSamplesForRendering - *nSamplesResidual );
- Copy32( tmp_buf_fx + nSamplesForRendering - *nSamplesResidual, hTcBuffer->tc_buffer_old_fx[ch], *nSamplesResidual );
- }
-
- IF( n_ch_res_copy > 0 )
- {
- FOR( ; ch < hTcBuffer->nchan_transport_jbm; ch++ )
- {
- p_data_fx[ch] = hTcBuffer->tc_fx[ch];
- Copy32( hTcBuffer->tc_fx[ch], tmp_buf_fx, nSamplesForRendering );
- Copy32( hTcBuffer->tc_buffer_old_fx[ch], p_data_fx[ch], n_samples_still_available );
- Copy32( tmp_buf_fx, p_data_fx[ch] + n_samples_still_available, sub( nSamplesForRendering, *nSamplesResidual ) );
- Copy32( tmp_buf_fx + nSamplesForRendering - *nSamplesResidual, hTcBuffer->tc_buffer_old_fx[ch], *nSamplesResidual );
- }
- }
-
- n_render_timeslots = idiv1616( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity );
- }
- ELSE
- {
- FOR( n = 0; n < n_ch_cldfb; n++ )
- {
- p_data_fx[n] = &st_ivas->p_output_fx[n][0];
- move16();
- }
-
- ch = s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full );
- FOR( n = 0; n < ch; n++ )
- {
- hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n]; /* note: buffers needed in the TD decorellator */
- move16();
- }
-
- hTcBuffer->n_samples_buffered = nSamplesForRendering;
- hTcBuffer->n_samples_available = hTcBuffer->n_samples_buffered;
- *nSamplesResidual = 0;
- move16();
- move16();
- move16();
-
- n_render_timeslots = DEFAULT_JBM_CLDFB_TIMESLOTS;
- move16();
- }
-
- /* CLDFB analysis for ParamMC/ParamISM */
- test();
- test();
- test();
- test();
- test();
- test();
- IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && ( EQ_32( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) )
- {
- ivas_param_ism_dec_digest_tc_fx( st_ivas, n_render_timeslots, p_data_fx, Q11 );
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) && EQ_32( hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_RENDERER ) )
- {
- ivas_param_mc_dec_digest_tc_fx( st_ivas, (UWord8) n_render_timeslots, p_data_fx, Q11 );
- }
-
- hTcBuffer->n_samples_rendered = 0;
- move16();
- hTcBuffer->subframes_rendered = 0;
- move16();
-
- return;
-}
-
-
-/*--------------------------------------------------------------------------*
- * ivas_dec_render()
- *
- * Principal IVAS JBM rendering routine
- *--------------------------------------------------------------------------*/
-
-ivas_error ivas_jbm_dec_render_fx(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const UWord16 nSamplesAsked, /* i : number of samples wanted */
- UWord16 *nSamplesRendered, /* o : number of samples rendered */
- UWord16 *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */
- Word16 *data /* o : output synthesis signal Q0*/
-)
-{
- Word16 n, nchan_out;
- Word16 nchan_transport;
- Word16 nchan_remapped;
- Word32 output_Fs;
- AUDIO_CONFIG output_config;
- Word16 nSamplesAskedLocal;
- ivas_error error;
- Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS];
- Word32 *p_tc_fx[MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS];
- Word16 subframe_len, gd_bits, exp, nchan_in, i, j, ch;
- const Word16 output_q_factor = Q11;
- move16();
- Word16 nchan_out_syn_output;
-
- push_wmops( "ivas_dec_render" );
- /*----------------------------------------------------------------*
- * Initialization of local vars after struct has been set
- *----------------------------------------------------------------*/
-
- output_Fs = st_ivas->hDecoderConfig->output_Fs;
- move32();
- nchan_out = st_ivas->hDecoderConfig->nchan_out;
- move16();
- nchan_transport = st_ivas->hTcBuffer->nchan_transport_jbm;
- move16();
- output_config = st_ivas->hDecoderConfig->output_config;
- move32();
- nSamplesAskedLocal = add( nSamplesAsked, st_ivas->hTcBuffer->n_samples_discard );
- move16();
-
- FOR( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ )
- {
- p_output_fx[n] = st_ivas->p_output_fx[n];
- }
-
- IF( !st_ivas->hDecoderConfig->Opt_tsm )
- {
- FOR( n = 0; n < MAX_INTERN_CHANNELS; n++ )
- {
- st_ivas->hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n];
- }
- }
-
- FOR( n = 0; n < st_ivas->hTcBuffer->nchan_buffer_full; n++ )
- {
- p_tc_fx[n] = &st_ivas->hTcBuffer->tc_fx[n][st_ivas->hTcBuffer->n_samples_rendered];
- }
-
- st_ivas->hTcBuffer->no_channels = st_ivas->hTcBuffer->nchan_buffer_full;
- move16();
-
- /*----------------------------------------------------------------*
- * Update combined orientation access index
- *----------------------------------------------------------------*/
-
- IF( st_ivas->hCombinedOrientationData != NULL )
- {
- /* take the discard samples into account here to make sure head rotation stays on the correct 5ms grid */
- st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered_start = sub( st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered_start, st_ivas->hTcBuffer->n_samples_discard );
- move16();
-
- ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData );
- }
-
- /*----------------------------------------------------------------*
- * Rendering
- *----------------------------------------------------------------*/
-
- *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal );
- move16();
-
- test();
- test();
- IF( EQ_32( st_ivas->ivas_format, UNDEFINED_FORMAT ) )
- {
- assert( 0 );
- }
- ELSE IF( EQ_32( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) )
- {
-#ifndef FIX_1435_MOVE_STEREO_PANNING
- Word16 slot_size, tmp, e;
-
- slot_size = st_ivas->hTcBuffer->n_samples_granularity;
- move16();
-
- /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */
- tmp = BASOP_Util_Divide1616_Scale( nSamplesAsked, slot_size, &e );
- tmp = shr( tmp, sub( 15, e ) );
-#endif
- ivas_jbm_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx );
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
- {
- /* Rendering */
- IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) )
- {
- ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc_fx, p_output_fx );
- }
-#ifdef FIX_1435_MOVE_STEREO_PANNING
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) )
- {
- ivas_apply_non_diegetic_panning_fx( p_tc_fx[0], p_output_fx, st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered );
- }
-#endif
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
- {
-#ifdef FIX_1454_FIX_STEREO_TO_FOA_JBM
- ivas_stereo2sba_fx( p_tc_fx, p_output_fx, *nSamplesRendered );
-#else
- ivas_stereo2sba_fx( p_output_fx, p_output_fx, *nSamplesRendered );
-#endif
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
- {
- /* Rendering */
- IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
- {
- test();
- test();
- test();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
- {
- ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, st_ivas->nchan_transport, p_output_fx );
- }
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
- {
- ivas_param_ism_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx );
-
- IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
- {
- /* Convert CICP19 -> Ambisonics */
- ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 );
- }
- }
- }
- ELSE /* ISM_MODE_DISC */
- {
- test();
- test();
- /* Loudspeaker or Ambisonics rendering */
- IF( EQ_32( st_ivas->renderer_type, RENDERER_TD_PANNING ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
- {
- /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */
- ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_fx, *nSamplesRendered );
- }
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) )
- {
- ivas_apply_non_diegetic_panning_fx( p_tc_fx[0], p_output_fx, st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered );
- }
-#ifdef DEBUGGING
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) )
-#else
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
-#endif
- {
- /* Convert to Ambisonics */
- FOR( i = 0; i < st_ivas->nchan_transport; i++ )
- {
- FOR( j = 0; j < HOA3_CHANNELS; j++ )
- {
- st_ivas->hIsmRendererData->gains_fx[i][j] = L_shr( st_ivas->hIsmRendererData->gains_fx[i][j], 1 ); // Q30 -> Q29
- move32();
- st_ivas->hIsmRendererData->prev_gains_fx[i][j] = L_shr( st_ivas->hIsmRendererData->prev_gains_fx[i][j], 1 ); // Q30 -> Q29
- move32();
- }
- }
-
- ivas_ism2sba_sf_fx( p_tc_fx, p_output_fx, st_ivas->hIsmRendererData, st_ivas->nchan_transport, *nSamplesRendered, st_ivas->hTcBuffer->n_samples_rendered, st_ivas->hIntSetup.ambisonics_order );
-
- Word16 sba_num_chans = imult1616( add( st_ivas->hIntSetup.ambisonics_order, 1 ), add( st_ivas->hIntSetup.ambisonics_order, 1 ) );
- FOR( j = 0; j < sba_num_chans; j++ )
- {
- scale_sig32( p_output_fx[j], *nSamplesRendered, sub( Q11, sub( add( output_q_factor, 29 ), 31 ) ) ); // Q11
- }
-
- FOR( i = 0; i < st_ivas->nchan_transport; i++ )
- {
- FOR( j = 0; j < 16; j++ )
- {
- st_ivas->hIsmRendererData->gains_fx[i][j] = L_shl( st_ivas->hIsmRendererData->gains_fx[i][j], 1 ); // Q29 -> Q30
- move32();
- st_ivas->hIsmRendererData->prev_gains_fx[i][j] = L_shl( st_ivas->hIsmRendererData->prev_gains_fx[i][j], 1 ); // Q29 -> Q30
- move32();
- }
- }
- }
-
- /* Binaural rendering */
- IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) )
- {
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
- {
- IF( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output_fx, *nSamplesRendered ) ) != IVAS_ERR_OK )
- {
- return error;
- }
- }
- ELSE
- {
- IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- }
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
- {
- st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor;
- subframe_len = imult1616( st_ivas->hTcBuffer->subframe_nbslots[0], st_ivas->hTcBuffer->n_samples_granularity );
- gd_bits = find_guarded_bits_fx( subframe_len );
- exp = 13;
- move16();
- nchan_in = 12;
- move16();
- nchan_out = 2;
- move16();
- exp = sub( exp, gd_bits );
- *st_ivas->hCrendWrapper->p_io_qfactor = exp;
- move16();
- FOR( i = 0; i < nchan_in; i++ )
- {
- scale_sig32( p_output_fx[i], *nSamplesRendered, negate( sub( 11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q11
- }
-
- IF( NE_32( ( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, *nSamplesRendered, output_Fs, 0 ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- FOR( i = 0; i < nchan_out; i++ )
- {
- scale_sig32( p_output_fx[i], *nSamplesRendered, sub( 11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11
- }
- }
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
- {
- nchan_remapped = nchan_transport;
- move16();
- test();
- test();
- /* Loudspeakers, Ambisonics or Binaural rendering */
- IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
- {
- ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx );
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) )
- {
- IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) )
- {
- ivas_dirac_dec_render_fx( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx );
- }
- }
- ELSE
- {
- IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
- {
- nchan_remapped = st_ivas->nchan_transport;
- move16();
- test();
- test();
- test();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
- {
- test();
- IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) )
- {
- IF( NE_32( ( error = ivas_omasa_dirac_td_binaural_jbm_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- ELSE
- {
- ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx );
- }
- }
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) )
- {
- ivas_omasa_dirac_rend_jbm_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx );
- }
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) || EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) )
- {
- ivas_jbm_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx );
- ivas_omasa_rearrange_channels_fx( p_output_fx, st_ivas->nchan_ism, *nSamplesRendered );
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
- {
- nchan_remapped = nchan_transport;
- move16();
- /* Loudspeakers, Ambisonics or Binaural rendering */
- IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
- {
- test();
- test();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) )
- {
- SPAR_DEC_HANDLE hSpar;
- hSpar = st_ivas->hSpar;
- hSpar->hMdDec->Q_mixer_mat = 30;
- move16();
-
- IF( NE_32( ( error = ivas_osba_dirac_td_binaural_jbm_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_STEREO ) )
- {
- test();
- /* shift SBA channels to avoid overwrite by ISM upmix in 1 object case and non-TSM unified channel memory*/
- IF( EQ_16( st_ivas->nchan_ism, 1 ) && EQ_16( st_ivas->hDecoderConfig->Opt_tsm, 0 ) )
- {
- Copy32( p_tc_fx[2], p_output_fx[3], *nSamplesRendered );
- Copy32( p_tc_fx[1], p_output_fx[2], *nSamplesRendered );
- p_tc_fx[1] = p_output_fx[2];
- p_tc_fx[2] = p_output_fx[3];
- }
-
- /* render objects */
- ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_fx, *nSamplesRendered );
-
- /* add already rendered SBA part */
- ivas_osba_stereo_add_channels_fx( p_tc_fx, p_output_fx, st_ivas->hSbaIsmData->gain_bed_fx, nchan_out, st_ivas->nchan_ism, st_ivas->ism_mode, *nSamplesRendered );
- }
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || EQ_32( st_ivas->renderer_type, RENDERER_OSBA_LS ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
- {
- IF( NE_32( ( error = ivas_osba_render_sf_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) /*EXT output = individual objects + HOA3*/
- {
- IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, &p_output_fx[st_ivas->nchan_ism] ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- FOR( n = 0; n < st_ivas->nchan_ism; n++ )
- {
- Copy32( p_tc_fx[n], p_output_fx[n], *nSamplesRendered );
- }
- }
- ELSE
- {
- IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- }
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
- {
- ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx );
-
- FOR( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ )
- {
- scale_sig32( p_output_fx[n], *nSamplesRendered, 1 );
- }
- }
- ELSE
- {
- IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
- {
- FOR( n = st_ivas->hIntSetup.nchan_out_woLFE - 1; n >= 0; n-- )
- {
- Copy32( p_output_fx[n], p_output_fx[n + st_ivas->nchan_ism], *nSamplesRendered );
- }
- FOR( n = 0; n < st_ivas->nchan_ism; n++ )
- {
- set32_fx( p_output_fx[n], 0, *nSamplesRendered );
- }
- }
- FOR( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ )
- {
- scale_sig32( p_output_fx[n], *nSamplesRendered, 1 );
- }
- }
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) )
- {
- IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) )
- {
- Word16 crendInPlaceRotation = FALSE;
- move16();
-
- test();
- test();
- test();
- IF( NE_32( st_ivas->transport_config, st_ivas->intern_config ) && ( EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA3 ) ) )
- {
- IF( LT_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ) ) )
- {
- crendInPlaceRotation = TRUE;
- move16();
-
- ivas_mc2sba_fx( st_ivas->hTransSetup, p_tc_fx, p_output_fx, *nSamplesRendered, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE_FX );
- }
- }
-
- test();
- /* Rendering */
- IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
- {
- st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor;
- subframe_len = imult1616( st_ivas->hTcBuffer->subframe_nbslots[0], st_ivas->hTcBuffer->n_samples_granularity );
- gd_bits = find_guarded_bits_fx( subframe_len );
- exp = 13;
- move16();
- IF( NE_32( ( error = getAudioConfigNumChannels( st_ivas->intern_config, &nchan_in ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- IF( NE_32( ( error = getAudioConfigNumChannels( st_ivas->hOutSetup.output_config, &nchan_out ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- exp = sub( exp, gd_bits );
- *st_ivas->hCrendWrapper->p_io_qfactor = exp;
- move16();
-
- IF( crendInPlaceRotation )
- {
- FOR( i = 0; i < nchan_in; i++ )
- {
- scale_sig32( p_output_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor
- }
- }
- ELSE
- {
- FOR( i = 0; i < nchan_in; i++ )
- {
- scale_sig32( p_tc_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor
- }
- }
-
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
- {
- IF( ( error = ivas_rend_crendProcessSubframesSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData,
- &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, p_output_fx, p_output_fx, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK )
- {
- return error;
- }
- }
- ELSE
- {
- IF( NE_32( ( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData,
- &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, p_output_fx, p_output_fx, *nSamplesRendered, output_Fs, 0 ) ),
- IVAS_ERR_OK ) )
- {
- return error;
- }
-
- ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx );
- }
-
- IF( crendInPlaceRotation )
- {
- n = nchan_in;
- }
- ELSE
- {
- n = nchan_out;
- }
- move16();
-
- FOR( i = 0; i < n; i++ )
- {
- scale_sig32( p_output_fx[i], *nSamplesRendered, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11
- }
-
- FOR( i = n; i < nchan_in; i++ )
- {
- scale_sig32( p_tc_fx[i], *nSamplesRendered, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11
- }
- }
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) )
- {
- ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc_fx, p_output_fx );
- }
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
- {
- ivas_mc2sba_fx( st_ivas->hIntSetup, p_tc_fx, p_output_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 );
- }
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) )
- {
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
- {
- IF( NE_32( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- else
- {
- IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx );
- }
- }
- }
- ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
- {
- ivas_mc_paramupmix_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_tc_fx, p_output_fx );
-
- test();
- test();
- /* Rendering */
- IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) && !st_ivas->hDecoderConfig->Opt_Headrotation )
- {
- /* handled in CLDFB domain already */
- IF( NE_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
- {
- ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_output_fx, p_output_fx );
- }
- }
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) )
- {
- ivas_ls_setup_conversion_fx( st_ivas, MC_PARAMUPMIX_MAX_INPUT_CHANS, *nSamplesRendered, p_output_fx, p_output_fx );
- }
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
- {
- ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 );
- }
- }
- ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
- {
- Word16 channel_active_fx[MAX_OUTPUT_CHANNELS];
- Word16 nchan_out_cov;
- Word16 nchan_out_cldfb = 0;
- move16();
-
- set16_fx( channel_active_fx, 0, MAX_LS_CHANNELS );
- Word16 nchan_transport_tmp = st_ivas->nchan_transport;
- move16();
- output_Fs = st_ivas->hDecoderConfig->output_Fs;
- move32();
- Word16 nchan_out_transport = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe );
- test();
- test();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
- {
- nchan_out_cldfb = BINAURAL_CHANNELS;
- move16();
- set16_fx( channel_active_fx, 1, BINAURAL_CHANNELS );
- nchan_out_cov = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe );
- }
- ELSE IF( EQ_32( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_CLDFB ) )
- {
- nchan_out_cov = nchan_out_transport;
- move16();
- nchan_out_cldfb = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe );
- }
- ELSE IF( EQ_32( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_32( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) )
- {
- nchan_out_cov = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe );
- nchan_out_cldfb = nchan_out_cov;
- move16();
- set16_fx( channel_active_fx, 1, nchan_out_cov );
- }
- ELSE
- {
- nchan_out_cov = nchan_out_transport;
- move16();
- nchan_out_cldfb = nchan_out_transport;
- move16();
- set16_fx( channel_active_fx, 1, nchan_out_cov );
- }
- IF( st_ivas->hParamMC->max_band_decorr > 0 )
- {
- Word16 tmp;
- tmp = L_norm_arr( st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_fx, st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_len );
- scale_sig32( st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_fx, st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_len, tmp ); // Q(st_ivas->hParamMC->h_freq_domain_decorr_ap_state->q_decorr_buffer+ tmp)
- st_ivas->hParamMC->h_freq_domain_decorr_ap_state->q_decorr_buffer = add( st_ivas->hParamMC->h_freq_domain_decorr_ap_state->q_decorr_buffer, tmp );
- move16();
- }
- /* CLDFB synthesis */
- FOR( ch = 0; ch < nchan_out_cldfb; ch++ )
- {
- IF( st_ivas->cldfbSynDec[ch] )
- {
- scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, ( Q5 - Q11 ) ); // Q5
- st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q5;
- move16();
- }
- }
- Word16 tempp;
- FOR( Word16 param_band_idx = 0; param_band_idx < st_ivas->hParamMC->num_param_bands_synth; param_band_idx++ )
- {
- tempp = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_len );
- scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_len, tempp ); // Q(31-(st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx]- tempp))
- st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx] = sub( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx], tempp );
- move16();
-
- IF( LT_16( st_ivas->hParamMC->band_grouping[param_band_idx], st_ivas->hParamMC->h_output_synthesis_params.max_band_decorr ) )
- {
- tempp = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_len );
- scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_len, tempp ); // Q(31- (st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx] - tempp))
- st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx] = sub( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx], tempp );
- move16();
- }
- }
-
- ivas_param_mc_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx, channel_active_fx );
-
- FOR( ch = 0; ch < nchan_out_cldfb; ch++ )
- {
- IF( st_ivas->cldfbSynDec[ch] )
- {
- scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, Q11 - Q5 ); // Q11
- st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11;
- move16();
- }
- }
- IF( EQ_16( st_ivas->hParamMC->slots_rendered, st_ivas->hParamMC->num_slots ) )
- {
- FOR( Word16 param_band_idx = 0; param_band_idx < st_ivas->hParamMC->hMetadataPMC->nbands_coded; param_band_idx++ )
- {
- IF( LT_16( st_ivas->hParamMC->band_grouping[param_band_idx], st_ivas->hParamMC->h_output_synthesis_params.max_band_decorr ) )
- {
- Copy32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_fx[param_band_idx], imult1616( nchan_transport_tmp, nchan_out_cov ) );
- st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_exp[param_band_idx] = st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx];
- move16();
- }
- Copy32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[param_band_idx], imult1616( nchan_transport_tmp, nchan_out_cov ) );
- st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_exp[param_band_idx] = st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx];
- move16();
- }
- }
- }
- ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
- {
- nchan_remapped = st_ivas->nchan_transport;
- move16();
-
- test();
- test();
- test();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
- {
- ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx );
- }
- ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) /* rendering to CICPxx and Ambisonics */
- {
- ivas_dirac_dec_render_fx( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx );
-
- test();
- test();
- test();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
- {
- /* we still need to copy the separate channel if available */
- IF( st_ivas->hOutSetup.separateChannelEnabled )
- {
- Copy32( p_tc_fx[LFE_CHANNEL - 1], p_output_fx[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered );
- }
-
- ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 );
- }
- ELSE IF( EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_5_1 ) && ( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) ) )
- {
- FOR( n = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; n < ( st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ); n++ )
- {
- set32_fx( p_output_fx[n], 0, *nSamplesRendered );
- }
- }
- }
-
- /* copy discrete C and TD LFE from internal TC to output */
- IF( st_ivas->hOutSetup.separateChannelEnabled )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) ||
- EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) ||
- EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || ( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && GT_16( st_ivas->hOutSetup.num_lfe, 0 ) ) )
- {
- Copy32( p_tc_fx[LFE_CHANNEL], p_output_fx[LFE_CHANNEL], *nSamplesRendered );
- Copy32( p_tc_fx[LFE_CHANNEL - 1], p_output_fx[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered );
- }
- ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe == 0 )
- {
- Copy32( p_tc_fx[LFE_CHANNEL - 1], p_output_fx[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered );
- }
- }
- }
- }
-
- /*----------------------------------------------------------------*
- * Write IVAS output channels
- * - compensation for saturation
- * - float to integer conversion
- *----------------------------------------------------------------*/
-
- st_ivas->hTcBuffer->n_samples_available = sub( st_ivas->hTcBuffer->n_samples_available, *nSamplesRendered );
- st_ivas->hTcBuffer->n_samples_rendered = add( st_ivas->hTcBuffer->n_samples_rendered, *nSamplesRendered );
- move16();
- move16();
-
- /* update global combined orientation start index */
- ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, *nSamplesRendered );
-
- IF( st_ivas->hTcBuffer->n_samples_discard > 0 )
- {
- FOR( n = 0; n < s_min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); n++ )
- {
- p_output_fx[n] += st_ivas->hTcBuffer->n_samples_discard;
- }
- *nSamplesRendered = sub( (Word16) *nSamplesRendered, st_ivas->hTcBuffer->n_samples_discard );
- move16();
- st_ivas->hTcBuffer->n_samples_discard = 0;
- move16();
- }
-
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
- {
- const Word32 *p_output_fx_const[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS];
-
- nchan_out_syn_output = i_mult( BINAURAL_CHANNELS, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses );
-
- /* Save TD signals for pose correction if they are to be used.
- *
- * NOTE: Here BASOP differs from the float version. In float, we push samples to TD ring buffer in lib_dec.c function isar_render_poses. */
- IF( st_ivas->hSplitBinRend->hMultiBinTdData != NULL )
- {
- FOR( i = 0; i < nchan_out_syn_output; i++ )
- {
- p_output_fx_const[i] = p_output_fx[i];
- }
- ivas_TD_RINGBUF_PushChannels( st_ivas->hSplitBinRend->hMultiBinTdData, p_output_fx_const, *nSamplesRendered );
- }
-
-#ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR
- if ( st_ivas->flushing )
- {
- nchan_out_syn_output = BINAURAL_CHANNELS;
- move16();
- }
-#endif
- }
- ELSE
- {
- nchan_out_syn_output = nchan_out;
- move16();
- }
-
- IF( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 )
- {
- IF( NE_32( st_ivas->ivas_format, MONO_FORMAT ) )
- {
-#ifndef DISABLE_LIMITER
- ivas_limiter_dec_fx( st_ivas->hLimiter, p_output_fx, nchan_out, *nSamplesRendered, st_ivas->BER_detect, output_q_factor );
-#endif
- }
- }
-
- ivas_syn_output_fx( p_output_fx, output_q_factor, *nSamplesRendered, nchan_out_syn_output, data );
-
- *nSamplesAvailableNext = st_ivas->hTcBuffer->n_samples_available;
- move16();
-
- pop_wmops();
- return IVAS_ERR_OK;
-}
-
-/*--------------------------------------------------------------------------*
- * ivas_jbm_dec_flush_renderer()
- *
- * Flush samples if renderer granularity changes on a bitrate change
- *--------------------------------------------------------------------------*/
-
-ivas_error ivas_jbm_dec_flush_renderer_fx(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const Word16 tc_granularity_new, /* i : new renderer granularity */
- const RENDERER_TYPE renderer_type_old, /* i : old renderer type */
- const AUDIO_CONFIG intern_config_old, /* i : old internal config */
- const IVAS_OUTPUT_SETUP_HANDLE hIntSetupOld, /* i : old internal output setup */
- const MC_MODE mc_mode_old, /* i : old MC mode */
- const ISM_MODE ism_mode_old, /* i : old ISM mode */
- UWord16 *nSamplesRendered, /* o : number of samples flushed */
- Word16 *data /* o : output synthesis signal Q0*/
-)
-{
- ivas_error error;
- Word16 n_samples_still_available;
- Word16 n_slots_still_available;
- Word16 n_samples_to_render;
- DECODER_TC_BUFFER_HANDLE hTcBuffer;
- Word32 *p_output_fx[MAX_LS_CHANNELS + MAX_NUM_OBJECTS];
- Word16 nchan_in, nchan_out;
-
- IF( !st_ivas->hDecoderConfig->Opt_tsm )
- {
- return IVAS_ERR_OK;
- }
-
- *nSamplesRendered = 0;
- move16();
- hTcBuffer = st_ivas->hTcBuffer;
-
- /* get number of possible slots in new granularity */
- n_samples_still_available = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_rendered );
-
- // n_slots_still_available = n_samples_still_available / tc_granularity_new;
- Word16 tmp, tmp_e;
- tmp = BASOP_Util_Divide1616_Scale( n_samples_still_available, tc_granularity_new, &tmp_e );
- n_slots_still_available = shr( tmp, sub( 15, tmp_e ) );
- *nSamplesRendered = imult1616( n_slots_still_available, tc_granularity_new );
- n_samples_to_render = *nSamplesRendered;
- move16();
- move16();
- n_samples_still_available = sub( n_samples_still_available, n_samples_to_render );
- assert( n_samples_still_available < tc_granularity_new );
-
- /* update combined orientation access index */
- ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData );
-
- IF( n_slots_still_available )
- {
- Word16 ch_idx;
-
- /* render available full slots (with new lower granularity) */
- FOR( ch_idx = 0; ch_idx < s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch_idx++ )
- {
- /* move it at the beginning of the TC buffer with zero padding */
- Copy32( hTcBuffer->tc_buffer_old_fx[ch_idx], hTcBuffer->tc_fx[ch_idx], n_samples_to_render );
- set_zero_fx( hTcBuffer->tc_fx[ch_idx] + n_samples_to_render, sub( hTcBuffer->n_samples_granularity, n_samples_to_render ) );
- }
-
- /* simple change of the slot info */
- hTcBuffer->num_slots = 1;
- hTcBuffer->nb_subframes = 1;
- hTcBuffer->subframes_rendered = 0;
- hTcBuffer->slots_rendered = 0;
- hTcBuffer->subframe_nbslots[0] = 1;
- hTcBuffer->n_samples_buffered = add( hTcBuffer->n_samples_granularity, n_samples_still_available );
- hTcBuffer->n_samples_available = 0;
- hTcBuffer->n_samples_flushed = n_samples_to_render;
- hTcBuffer->n_samples_rendered = 0;
- move16();
- move16();
- move16();
- move16();
- move16();
- move16();
- move16();
- move16();
- move16();
-
- FOR( ch_idx = 0; ch_idx < ( MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ); ch_idx++ )
- {
- p_output_fx[ch_idx] = st_ivas->p_output_fx[ch_idx];
- }
-
- test();
- IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) )
- {
- IF( EQ_16( ism_mode_old, ISM_MODE_DISC ) )
- {
- /* Binaural rendering */
- IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_OBJECTS_TD ) )
- {
- IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, hTcBuffer->n_samples_granularity ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- ELSE IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
- {
- /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */
- set16_fx( st_ivas->hIsmRendererData->interpolator_fx, 32767, hTcBuffer->n_samples_granularity ); // 32767=1.0f in Q15
-
- ivas_ism_render_sf_fx( st_ivas, renderer_type_old, p_output_fx, hTcBuffer->n_samples_granularity );
-
- st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor;
- *st_ivas->hCrendWrapper->p_io_qfactor = 11;
-
- move16();
- IF( NE_32( ( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL,
- NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ),
- IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- }
- ELSE
- {
- return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong ISM_MODE in VoIP renderer flushing!" );
- }
- }
- ELSE IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) )
- {
- IF( EQ_16( mc_mode_old, MC_MODE_MCT ) )
- {
- Word16 crendInPlaceRotation = FALSE;
-
- test();
- test();
- test();
- IF( NE_16( st_ivas->transport_config, intern_config_old ) && ( EQ_16( intern_config_old, IVAS_AUDIO_CONFIG_FOA ) || EQ_16( intern_config_old, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_16( intern_config_old, IVAS_AUDIO_CONFIG_HOA3 ) ) )
- {
- IF( GT_16( sub( add( hIntSetupOld->nchan_out_woLFE, hIntSetupOld->num_lfe ), add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ) ), 0 ) )
- {
- crendInPlaceRotation = TRUE;
- move16();
- ivas_mc2sba_fx( st_ivas->hTransSetup, hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, hIntSetupOld->ambisonics_order, GAIN_LFE_FX );
- }
- }
-
- test();
- IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV ) || EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
- {
- st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor;
- IF( NE_32( ( error = getAudioConfigNumChannels( intern_config_old, &nchan_in ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- IF( NE_32( ( error = getAudioConfigNumChannels( st_ivas->hOutSetup.output_config, &nchan_out ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- Word16 subframe_len, gd_bits;
- subframe_len = imult1616( st_ivas->hTcBuffer->subframe_nbslots[0], st_ivas->hTcBuffer->n_samples_granularity );
- gd_bits = find_guarded_bits_fx( subframe_len );
- *st_ivas->hCrendWrapper->p_io_qfactor = sub( 13, gd_bits );
- FOR( Word16 i = 0; i < nchan_in; i++ )
- {
- scale_sig32( p_output_fx[i], *nSamplesRendered, sub( *st_ivas->hCrendWrapper->p_io_qfactor, Q11 ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor
- }
-
- IF( NE_32( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : st_ivas->hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- ivas_binaural_add_LFE_fx( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc_fx, p_output_fx );
-
- FOR( Word16 i = 0; i < nchan_in; i++ )
- {
- scale_sig32( p_output_fx[i], *nSamplesRendered, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11
- }
- }
- ELSE IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_OBJECTS_TD ) )
- {
- IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, hTcBuffer->n_samples_granularity ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->tc_fx, p_output_fx );
- }
- ELSE
- {
- return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong renderer in MCT VoIP renderer flushing!" );
- }
- }
- ELSE
- {
- return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong MC_MODE in VoIP renderer flushing!" );
- }
- }
- ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_FORMAT ) )
- {
- IF( EQ_16( ism_mode_old, ISM_MASA_MODE_DISC ) )
- {
- Word32 *tc_local_fx[MAX_NUM_OBJECTS];
- Word16 last_dirac_md_idx;
- UWord16 nSamplesAvailableNext;
- ISM_MODE ism_mode_orig;
- RENDERER_TYPE renderer_type_orig;
- Word32 ivas_total_brate;
-
- /* copy from ISM delay buffer to the correct place in TCs */
- move16();
- FOR( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ )
- {
- tc_local_fx[ch_idx] = &st_ivas->hTcBuffer->tc_fx[ch_idx + 2][hTcBuffer->n_samples_rendered];
- Copy32( st_ivas->hMasaIsmData->delayBuffer_fx[ch_idx], tc_local_fx[ch_idx], st_ivas->hMasaIsmData->delayBuffer_size ); /*Q11*/
- }
-
- /* to render flushed samples, use configuration from the last received frame */
- ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
- renderer_type_orig = st_ivas->renderer_type;
- ism_mode_orig = st_ivas->ism_mode;
- st_ivas->ism_mode = ism_mode_old;
- st_ivas->renderer_type = renderer_type_old;
- st_ivas->hDecoderConfig->ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate;
- last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1];
-
- /* transfer adapted sf info from hTcBuffer to DirAC */
- st_ivas->hSpatParamRendCom->nb_subframes = 1;
- st_ivas->hSpatParamRendCom->subframes_rendered = 0;
- st_ivas->hSpatParamRendCom->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME;
- st_ivas->hSpatParamRendCom->slots_rendered = 0;
- st_ivas->hSpatParamRendCom->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME;
- set16_fx( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available );
-
- IF( ( error = ivas_omasa_dirac_td_binaural_jbm_fx( st_ivas, (UWord16) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, CPE_CHANNELS, p_output_fx ) ) != IVAS_ERR_OK )
- {
- return error;
- }
-
- /* restore original configuration */
- st_ivas->ism_mode = ism_mode_orig;
- st_ivas->renderer_type = renderer_type_orig;
- st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate;
- }
- }
- ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
- {
- IF( EQ_32( ism_mode_old, ISM_SBA_MODE_DISC ) )
- {
- Word32 *tc_local_fx[MAX_TRANSPORT_CHANNELS];
- Word16 last_spar_md_idx;
- Word16 last_dirac_md_idx;
- UWord16 nSamplesAvailableNext;
- ISM_MODE ism_mode_orig;
- RENDERER_TYPE renderer_type_orig;
- Word32 ivas_total_brate;
-
- ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
- renderer_type_orig = st_ivas->renderer_type;
- ism_mode_orig = st_ivas->ism_mode;
-
- /* to render flushed samples, use configuration from the last received frame */
- move32();
- st_ivas->ism_mode = ism_mode_old;
- st_ivas->renderer_type = renderer_type_old;
- st_ivas->hDecoderConfig->ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate;
-
- last_spar_md_idx = st_ivas->hSpar->render_to_md_map[st_ivas->hSpar->slots_rendered - 1];
- last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1];
- move16();
- move16();
-
- /* copy from ISM delay buffer to the correct place in TCs */
- FOR( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ )
- {
- tc_local_fx[ch_idx] = &st_ivas->hTcBuffer->tc_fx[ch_idx][hTcBuffer->n_samples_rendered];
- Copy32( st_ivas->hSbaIsmData->delayBuffer_fx[ch_idx], tc_local_fx[ch_idx], st_ivas->hSbaIsmData->delayBuffer_size );
- }
-
- /* transfer adapted sf info from hTcBuffer to SPAR and DirAC */
- st_ivas->hSpar->nb_subframes = 1;
- st_ivas->hSpar->subframes_rendered = 0;
- st_ivas->hSpar->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME;
- st_ivas->hSpar->slots_rendered = 0;
- st_ivas->hSpar->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME;
- st_ivas->hSpatParamRendCom->nb_subframes = 1;
- st_ivas->hSpatParamRendCom->subframes_rendered = 0;
- st_ivas->hSpatParamRendCom->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME;
- st_ivas->hSpatParamRendCom->slots_rendered = 0;
- st_ivas->hSpatParamRendCom->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME;
- move16();
- move16();
- move16();
- move16();
- move16();
- move16();
- move16();
- move16();
- move16();
- move16();
-
- /* also adapt md maps, just use the last index */
- set16_fx( st_ivas->hSpar->render_to_md_map, last_spar_md_idx, n_slots_still_available );
- set16_fx( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available );
-
- /* render the last subframe */
- IF( NE_32( ( error = ivas_osba_dirac_td_binaural_jbm_fx( st_ivas, (UWord16) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output_fx ) ), IVAS_ERR_OK ) )
- {
- return error;
- }
-
- /* restore original configuration */
- st_ivas->ism_mode = ism_mode_orig;
- st_ivas->renderer_type = renderer_type_orig;
- st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate;
- }
- }
- ELSE
- {
- return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong IVAS format in VoIP renderer flushing!" );
- }
-
- hTcBuffer->n_samples_rendered = hTcBuffer->n_samples_granularity;
- }
-
- /* update global combined orientation start index */
- ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, *nSamplesRendered );
-
- *nSamplesRendered = n_samples_to_render;
- move16();
-
- /* Only write out the valid data*/
- IF( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 )
- {
- IF( NE_16( st_ivas->ivas_format, MONO_FORMAT ) )
- {
-#ifndef DISABLE_LIMITER
- Word16 ch_idx, exp = 11;
- move16();
- FOR( ch_idx = 0; ch_idx < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ )
- {
- p_output_fx[ch_idx] = st_ivas->p_output_fx[ch_idx];
- }
- ivas_limiter_dec_fx( st_ivas->hLimiter, p_output_fx, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, exp );
-#endif
- }
- }
-
- ivas_syn_output_fx( p_output_fx, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, data );
-
- return IVAS_ERR_OK;
-}
-
-
-/*--------------------------------------------------------------------------*
- * ivas_jbm_dec_set_discard_samples()
- *
- * Set number of samples to discard in the first subframe if the renderer granularity changes on a bitrate change
- *--------------------------------------------------------------------------*/
-
-ivas_error ivas_jbm_dec_set_discard_samples_fx(
- Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */
-)
-{
- Word16 nMaxSlotsPerSubframe, nSlotsInFirstSubframe;
- Word16 temp, temp_e;
-
- /* render first frame with front zero padding and discarding those samples */
- /* nMaxSlotsPerSubframe = (Word16)(st_ivas->hDecoderConfig->output_Fs / (FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)) / st_ivas->hTcBuffer->n_samples_granularity; */
- temp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) );
- temp = BASOP_Util_Divide1616_Scale( temp, st_ivas->hTcBuffer->n_samples_granularity, &temp_e );
- nMaxSlotsPerSubframe = shr( temp, sub( 15, temp_e ) ); /* Q0 */
- nSlotsInFirstSubframe = sub( nMaxSlotsPerSubframe, st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] );
- IF( nSlotsInFirstSubframe > 0 )
- {
- st_ivas->hTcBuffer->n_samples_discard = imult1616( sub( nMaxSlotsPerSubframe, nSlotsInFirstSubframe ), st_ivas->hTcBuffer->n_samples_granularity );
- /* set last subframes number to max to ensure correct continuation */
- st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nMaxSlotsPerSubframe;
- move16();
- move16();
- }
-
- return IVAS_ERR_OK;
-}
-
-
-/*--------------------------------------------------------------------------*
- * ivas_jbm_dec_get_adapted_linear_interpolator()
- *
- * Get an interpolator that is adapted to time scale modified IVAS frame
- *--------------------------------------------------------------------------*/
-void ivas_jbm_dec_get_adapted_linear_interpolator_fx(
- const Word16 default_interp_length, /* i : default length of the (full-frame) interpolator */
- const Word16 interp_length, /* i : length of the interpolator to be created */
- Word16 *interpolator_fx /* o : the interpolator Q15 */
-)
-{
- Word16 jbm_segment_len, idx;
- Word16 dec_fx;
- Word16 dec_e;
-
- jbm_segment_len = shr( default_interp_length, 1 );
- dec_fx = divide1616( 1, default_interp_length ); /*32767 / default_interp_length*/
-
- interpolator_fx[interp_length - 1] = 32767; /* (1.0f in Q15) -1 */
- move16();
- interpolator_fx[interp_length - 2] = add( sub( 32767, dec_fx ), 1 ); // Use 32768 to maintain precision
- move16();
- FOR( idx = interp_length - 3; idx >= jbm_segment_len; idx-- )
- {
- interpolator_fx[idx] = s_max( 0, sub( interpolator_fx[idx + 1], dec_fx ) );
- move16();
- }
-
- IF( interpolator_fx[idx + 1] > 0 )
- {
- dec_fx = BASOP_Util_Divide1616_Scale( interpolator_fx[idx + 1], add( jbm_segment_len, 1 ), &dec_e );
- dec_fx = shr( dec_fx, sub( 15, dec_e ) ); // Q0
- FOR( ; idx >= 0; idx-- )
- {
- interpolator_fx[idx] = sub( interpolator_fx[idx + 1], dec_fx );
- move16();
- }
- }
- ELSE
- {
- set16_fx( interpolator_fx, 0, add( idx, 1 ) );
- }
-
- return;
-}
-
-
-/*--------------------------------------------------------------------------*
- * ivas_jbm_dec_get_adapted_subframes()
- *
- * Get an interpolator that is adapted to time scale modified IVAS frame
- *--------------------------------------------------------------------------*/
-
-void ivas_jbm_dec_get_adapted_subframes(
- const Word16 nCldfbTs, /* i : number of time slots in the current frame */
- Word16 *subframe_nbslots, /* i/o: subframe grid */
- Word16 *nb_subframes /* i/o: number of subframes in the frame */
-)
-{
- UWord16 nSlotsInLastSubframe, nSlotsInFirstSubframe;
- UWord16 nCldfbSlotsLocal = nCldfbTs;
- move16();
- Word16 temp, temp_e;
-
- /* get last subframe size from previous frame, determine how many slots have to be processed
- in the first subframe (i.e. potential leftover of a 5ms subframe) */
- nSlotsInFirstSubframe = ( sub( PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, subframe_nbslots[*nb_subframes - 1] ) );
- *nb_subframes = 0;
- move16();
- IF( nSlotsInFirstSubframe > 0 )
- {
- *nb_subframes = 1;
- move16();
- nCldfbSlotsLocal = sub( nCldfbSlotsLocal, nSlotsInFirstSubframe );
- }
-
- temp = BASOP_Util_Divide3232_Scale( L_add( nCldfbSlotsLocal, PARAM_MC_MAX_NSLOTS_IN_SUBFRAME - 1 ), PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, &temp_e );
- *nb_subframes = add( *nb_subframes, shr( temp, sub( 15, temp_e ) ) ); // Q0
- move16();
- nSlotsInLastSubframe = nCldfbSlotsLocal % PARAM_MC_MAX_NSLOTS_IN_SUBFRAME;
- move16();
-
- set16_fx( subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS );
- set16_fx( subframe_nbslots, PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, *nb_subframes );
-
- IF( nSlotsInFirstSubframe > 0 )
- {
- subframe_nbslots[0] = nSlotsInFirstSubframe;
- move16();
- }
-
- IF( nSlotsInLastSubframe > 0 )
- {
- subframe_nbslots[*nb_subframes - 1] = nSlotsInLastSubframe;
- move16();
- }
-
- return;
-}
-
-
-/*--------------------------------------------------------------------------*
- * ivas_jbm_dec_get_adapted_linear_interpolator()
- *
- * Get an meta data map adapted to a time scale modified IVAS frame
- *--------------------------------------------------------------------------*/
-
-void ivas_jbm_dec_get_md_map(
- const Word16 default_len, /* i : default frame length in metadata slots */
- const Word16 len, /* i : length of the modfied frames in metadata slots */
- const Word16 subframe_len, /* i : default length of a subframe */
- const Word16 offset, /* i : current read offset into the md buffer */
- const Word16 buf_len, /* i : length of the metadata buffer */
- Word16 *map /* o : metadata index map */
-)
-{
- Word16 jbm_segment_len, map_idx, src_idx, src_idx_map;
- Word32 dec_fx, src_idx_fx;
- Word16 temp_e;
- Word16 temp;
- jbm_segment_len = shr( default_len, 1 );
-
- FOR( ( map_idx = len - 1, src_idx = default_len - 1 ); map_idx >= jbm_segment_len; ( map_idx--, src_idx-- ) )
- {
- temp = BASOP_Util_Divide1616_Scale( src_idx, subframe_len, &temp_e );
- temp = shr( temp, sub( 15, temp_e ) ); // Q0
- src_idx_map = s_max( 0, temp );
- map[map_idx] = add( offset, src_idx_map ) % buf_len;
- move16();
- }
-
- /* changed part (first segment), interpolate index to parameters
- (we do not want to interpolate and smooth acutal direction/diffuseness values even more) */
- IF( src_idx >= 0 )
- {
- dec_fx = BASOP_Util_Divide3232_Scale( L_shl( add( src_idx, 1 ), 16 ), jbm_segment_len, &temp_e );
- dec_fx = L_shr( dec_fx, sub( 15, temp_e ) );
- src_idx_fx = L_sub( L_shl( add( src_idx, 1 ), 16 ), dec_fx );
- FOR( ; map_idx >= 0; map_idx-- )
- {
- temp = BASOP_Util_Divide1616_Scale( round_fx( src_idx_fx ), subframe_len, &temp_e );
- temp = shr( temp, sub( 15, temp_e ) ); // Q0
- src_idx = s_max( 0, temp );
- map[map_idx] = add( offset, src_idx ) % buf_len;
- src_idx_fx = L_sub( src_idx_fx, dec_fx );
- }
- }
- ELSE
- {
- set16_fx( map, offset, add( map_idx, 1 ) );
- }
-
- return;
-}
-
-/*--------------------------------------------------------------------------*
- * ivas_jbm_dec_get_md_map_even_spacing()
- *
- * Get an meta data map adapted to a time scale modified IVAS frame. Distribute slots evenly across the modified frame.
- *--------------------------------------------------------------------------*/
-
-void ivas_jbm_dec_get_md_map_even_spacing(
- const Word16 len, /* i : length of the modfied frames in metadata slots */
- const Word16 subframe_len, /* i : default length of a subframe */
- const Word16 offset, /* i : current read offset into the md buffer */
- const Word16 buf_len, /* i : length of the metadata buffer */
- Word16 *map /* o : metadata index map */
-)
-{
- Word16 map_idx, sf_idx, sf_length, increment, subframes_written;
- Word32 decimal_fx, decimal_sum_fx, eps_fx; // q = 16
- Word16 subframe_map_length[MAX_PARAM_SPATIAL_SUBFRAMES];
-
- /* subframe map length */
- sf_length = idiv1616( len, subframe_len );
- IF( len % subframe_len == 0 )
- {
- /* even subframes */
- FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
- {
- subframe_map_length[sf_idx] = sf_length;
- move16();
- }
- }
- ELSE
- {
- /* uneven subframes */
- Word32 temp;
- Word16 temp_e;
- temp = BASOP_Util_Divide3232_Scale( L_shl( len, 16 ), subframe_len, &temp_e );
- temp = L_shr( temp, sub( 15, temp_e ) ); // Q16
- decimal_fx = L_sub( temp, L_shl( sf_length, 16 ) ); // Q16
- decimal_sum_fx = decimal_fx;
-
- eps_fx = 65;
- move32();
- move32();
- FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
- {
- increment = extract_l( L_shr( L_add( decimal_sum_fx, eps_fx ), 16 ) );
- subframe_map_length[sf_idx] = add( sf_length, increment );
- move16();
- IF( increment > 0 )
- {
- decimal_sum_fx = L_sub( decimal_sum_fx, ONE_IN_Q16 );
- }
- decimal_sum_fx = L_add( decimal_sum_fx, decimal_fx );
- }
- }
-
- /* map slots to subframes */
- sf_idx = 0;
- subframes_written = 0;
- move16();
- move16();
- FOR( map_idx = 0; map_idx < len; map_idx++ )
- {
- map[map_idx] = add( offset, sf_idx ) % buf_len;
- move16();
- IF( GE_16( sub( map_idx, subframes_written ), sub( subframe_map_length[sf_idx], 1 ) ) )
- {
- subframes_written = add( subframes_written, subframe_map_length[sf_idx] );
- sf_idx = add( sf_idx, 1 );
- }
- }
-
- return;
-}
-
-/*--------------------------------------------------------------------------*
- * ivas_jbm_dec_get_num_tc_channels()
- *
- * Get the number of transport channels provided by the JBM transport channel decode function
- *--------------------------------------------------------------------------*/
-
-
-Word16 ivas_jbm_dec_get_num_tc_channels_fx(
- Decoder_Struct *st_ivas /* i : IVAS decoder handle */
-)
-{
- Word16 num_tc;
- Word32 ivas_total_brate;
- AUDIO_CONFIG output_config;
-
- IF( EQ_16( st_ivas->renderer_type, RENDERER_DISABLE ) )
- {
- num_tc = st_ivas->hDecoderConfig->nchan_out;
- move16();
- }
- ELSE
- {
- num_tc = st_ivas->nchan_transport;
- move16();
- }
- output_config = st_ivas->hDecoderConfig->output_config;
- move16();
-
- ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
- move32();
-
- test();
- test();
- test();
-#ifdef FIX_1435_MOVE_STEREO_PANNING
- test();
- IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) )
- {
- num_tc = 1;
- move16();
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) && EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) )
-#else
- IF( EQ_16( st_ivas->ivas_format, STEREO_FORMAT ) && EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) )
-#endif
- {
- num_tc = 1;
- move16();
- }
- ELSE IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) )
- {
- if ( EQ_16( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) )
- {
- num_tc = 1;
- move16();
- }
- }
- ELSE IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_FORMAT ) )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- IF( st_ivas->sba_dirac_stereo_flag )
- {
- num_tc = CPE_CHANNELS;
- move16();
- }
- ELSE IF( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) || ( LE_32( ivas_total_brate, IVAS_SID_5k2 ) && GT_16( st_ivas->nCPE, 0 ) && st_ivas->hCPE[0] != NULL && EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) ) ) )
- {
- num_tc = 1; /* Only one channel transported */
- move16();
- }
-
- test();
- test();
- test();
- test();
- IF( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) && EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && EQ_16( st_ivas->nchan_transport, 2 ) && LT_32( st_ivas->hDecoderConfig->ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && GT_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) )
- {
- num_tc = CPE_CHANNELS;
- move16();
- }
- IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) )
- {
- if ( EQ_16( num_tc, 3 ) )
- {
- num_tc = add( num_tc, 1 );
- }
- }
- }
- ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
- {
- IF( NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
- {
- test();
- IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) )
- {
- num_tc = add( num_tc, 1 );
- }
- ELSE IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
- {
- num_tc = add( num_tc, st_ivas->nchan_ism );
- }
- }
- }
- ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
- {
-
-
- if ( st_ivas->sba_dirac_stereo_flag )
- {
- num_tc = CPE_CHANNELS;
- move16();
- }
-
- if ( EQ_16( num_tc, 3 ) )
- {
- num_tc = add( num_tc, 1 );
- }
- if ( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
- {
- num_tc = add( num_tc, st_ivas->nchan_ism );
- }
- }
- ELSE IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) )
- {
- IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) )
- {
- num_tc = 1;
- move16();
- }
- ELSE IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) )
- {
- num_tc = 2;
- move16();
- }
- ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) )
- {
- /* do all static dmx already in the TC decoder if less channels than transported... */
- test();
- test();
- test();
- test();
- test();
- IF( NE_16( st_ivas->transport_config, st_ivas->intern_config ) && ( EQ_16( st_ivas->intern_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_16( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_16( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA3 ) ) )
- {
- if ( GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ) ) )
- {
- num_tc = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe );
- }
- }
- ELSE IF( ( EQ_16( st_ivas->renderer_type, RENDERER_MC ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) && GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ) )
- {
- num_tc = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe );
- }
- }
- ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
- {
- num_tc = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS;
- move16();
- }
- ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) )
- {
- if ( st_ivas->hOutSetup.separateChannelEnabled )
- {
- num_tc = add( num_tc, 1 );
- }
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- if ( st_ivas->hOutSetup.separateChannelEnabled && ( EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_7_1 ) ||
- EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) ||
- EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || ( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe > 0 ) ) )
- {
- /* LFE is synthesized in TD with the TCs*/
- num_tc = add( num_tc, 1 );
- }
- }
- }
-#ifndef FIX_1435_MOVE_STEREO_PANNING
- ELSE IF( EQ_16( st_ivas->ivas_format, MONO_FORMAT ) && EQ_16( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) )
- {
- num_tc = MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN;
- move16();
- }
-#endif
-
- return num_tc;
-}
-
-
-/*--------------------------------------------------------------------------*
- * ivas_jbm_dec_get_render_granularity()
- *
- *
- *--------------------------------------------------------------------------*/
-
-/*! r: render granularity */
-Word16 ivas_jbm_dec_get_render_granularity_fx(
- const RENDERER_TYPE renderer_type, /* i : renderer type */
- const RENDERER_TYPE renderer_type_sec, /* i : secondary renderer type */
- const Word32 output_Fs /* i : sampling rate */
-)
-{
- Word16 render_granularity;
-
- test();
- test();
- test();
- IF( EQ_32( renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) || /* TD renderer */
- EQ_32( renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_32( renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) || /* Crend */
- EQ_32( renderer_type_sec, RENDERER_BINAURAL_OBJECTS_TD ) /* TD rend as a secondary renderer -> set the common granularity for both renderers */
- )
- {
- /* 5 ms granularity */
- render_granularity = NS2SA_FX2( output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES );
- move16();
- }
- ELSE
- {
- /* 1.25 ms granularity */
- render_granularity = NS2SA_FX2( output_Fs, CLDFB_SLOT_NS );
- move16();
- }
-
- return render_granularity;
-}
-
-
-/*--------------------------------------------------------------------------*
- * ivas_jbm_dec_tc_audio_allocate()
- *
- * allocate and initialize TC audio buffer
- *--------------------------------------------------------------------------*/
-
-static ivas_error ivas_jbm_dec_tc_audio_allocate_fx(
- DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM TSM buffer handle */
- const Word32 output_Fs, /* i : output sampling rate */
- const Word16 Opt_tsm /* i : TSM option flag */
-)
-{
- Word16 nsamp_to_allocate;
- Word16 ch_idx, n_samp_full, n_samp_residual, offset;
-
- IF( Opt_tsm )
- {
- n_samp_full = NS2SA_FX2( output_Fs, MAX_JBM_L_FRAME_NS );
- n_samp_full = s_max( n_samp_full, L_FRAME48k ); /* buffers are shared between 'hTcBuffer->tc[]' and 'p_output_f[]': ensure minimal length */
- n_samp_residual = sub( hTcBuffer->n_samples_granularity, 1 );
- }
- ELSE
- {
- n_samp_full = extract_l( Mpy_32_32( output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) );
- n_samp_residual = 0;
- move16();
- }
-
- nsamp_to_allocate = imult1616( s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ), n_samp_full );
-
- IF( Opt_tsm )
- {
- /* note: this is stack memory buffer for time-scale modified audio signals */
- IF( ( hTcBuffer->tc_buffer_fx = (Word32 *) malloc( nsamp_to_allocate * sizeof( Word32 ) ) ) == NULL )
- {
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) );
- }
- set_zero_fx( hTcBuffer->tc_buffer_fx, nsamp_to_allocate );
-
- offset = 0;
- move16();
- FOR( ch_idx = 0; ch_idx < s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch_idx++ )
- {
- hTcBuffer->tc_fx[ch_idx] = &hTcBuffer->tc_buffer_fx[offset];
- offset = add( offset, n_samp_full );
- }
- FOR( ; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ )
- {
- hTcBuffer->tc_fx[ch_idx] = NULL;
- }
-
- /* memory buffer for TC audio samples not rendered in the previous frame */
- FOR( ch_idx = 0; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ )
- {
- IF( ( hTcBuffer->tc_buffer_old_fx[ch_idx] = (Word32 *) malloc( n_samp_residual * sizeof( Word32 ) ) ) == NULL )
- {
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) );
- }
- set_zero_fx( hTcBuffer->tc_buffer_old_fx[ch_idx], n_samp_residual );
- }
- FOR( ; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ )
- {
- hTcBuffer->tc_buffer_old_fx[ch_idx] = NULL;
- }
- }
- else
- {
- hTcBuffer->tc_buffer_fx = NULL;
-
- FOR( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ )
- {
- hTcBuffer->tc_fx[ch_idx] = NULL;
- }
-
- FOR( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ )
- {
- hTcBuffer->tc_buffer_old_fx[ch_idx] = NULL;
- }
- }
-
- hTcBuffer->tc_buffer2_fx = NULL;
-
- return IVAS_ERR_OK;
-}
-
-
-/*--------------------------------------------------------------------------*
- * ivas_jbm_dec_tc_audio_deallocate()
- *
- * deallocate TC audio buffer
- *--------------------------------------------------------------------------*/
-
-static void ivas_jbm_dec_tc_audio_deallocate_fx(
- DECODER_TC_BUFFER_HANDLE hTcBuffer /* i/o: JBM TSM buffer handle */
-)
-{
- Word16 ch_idx;
-
- IF( hTcBuffer != NULL )
- {
- IF( hTcBuffer->tc_buffer_fx != NULL )
- {
- FOR( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ )
- {
- hTcBuffer->tc_fx[ch_idx] = NULL;
- }
-
- free( hTcBuffer->tc_buffer_fx );
- hTcBuffer->tc_buffer_fx = NULL;
- }
-
- FOR( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ )
- {
- IF( hTcBuffer->tc_buffer_old_fx[ch_idx] != NULL )
- {
- free( hTcBuffer->tc_buffer_old_fx[ch_idx] );
- hTcBuffer->tc_buffer_old_fx[ch_idx] = NULL;
- }
- }
-
- IF( hTcBuffer->tc_buffer2_fx != NULL )
- {
- free( hTcBuffer->tc_buffer2_fx );
- hTcBuffer->tc_buffer2_fx = NULL;
- }
- }
-
- return;
-}
-
-/*--------------------------------------------------------------------------*
- * ivas_jbm_dec_tc_buffer_open()
- *
- * open and initialize JBM transport channel buffer
- *--------------------------------------------------------------------------*/
-
-ivas_error ivas_jbm_dec_tc_buffer_open_fx(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */
- const Word16 nchan_transport_jbm, /* i : number of real transport channels */
- const Word16 nchan_transport_internal, /* i : number of totally buffered channels */
- const Word16 nchan_full, /* i : number of channels to fully store */
- const Word16 n_samples_granularity /* i : granularity of the renderer/buffer */
-)
-{
- DECODER_TC_BUFFER_HANDLE hTcBuffer;
- Word16 nMaxSlotsPerSubframe;
- ivas_error error;
- Word16 tmp, tmp_e;
-
- /*-----------------------------------------------------------------*
- * prepare library opening
- *-----------------------------------------------------------------*/
-
- IF( ( hTcBuffer = (DECODER_TC_BUFFER_HANDLE) malloc( sizeof( DECODER_TC_BUFFER ) ) ) == NULL )
- {
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) );
- }
-
- hTcBuffer->tc_buffer_mode = tc_buffer_mode;
- move16();
- hTcBuffer->nchan_transport_jbm = nchan_transport_jbm;
- move16();
- hTcBuffer->nchan_transport_internal = nchan_transport_internal;
- move16();
- hTcBuffer->nchan_buffer_full = nchan_full;
- move16();
- hTcBuffer->n_samples_granularity = n_samples_granularity;
- move16();
- hTcBuffer->n_samples_available = 0;
- move16();
- hTcBuffer->n_samples_buffered = 0;
- move16();
- hTcBuffer->n_samples_rendered = 0;
- move16();
- hTcBuffer->slots_rendered = 0;
- move16();
- hTcBuffer->subframes_rendered = 0;
- move16();
- hTcBuffer->n_samples_discard = 0;
- move16();
- hTcBuffer->n_samples_flushed = 0;
- move16();
- hTcBuffer->nb_subframes = MAX_PARAM_SPATIAL_SUBFRAMES;
- move16();
-
- /* nMaxSlotsPerSubframe = (Word16)(st_ivas->hDecoderConfig->output_Fs / (FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)) / st_ivas->hTcBuffer->n_samples_granularity; */
- tmp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) );
- tmp = BASOP_Util_Divide1616_Scale( tmp, hTcBuffer->n_samples_granularity, &tmp_e );
- nMaxSlotsPerSubframe = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */
-
- hTcBuffer->num_slots = mult0( nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES );
- move16();
-
- set16_fx( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS );
- set16_fx( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES );
-
- IF( ( error = ivas_jbm_dec_tc_audio_allocate_fx( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK )
- {
- return error;
- }
-
- st_ivas->hTcBuffer = hTcBuffer;
-
- return IVAS_ERR_OK;
-}
-
-
-/*--------------------------------------------------------------------------*
- * ivas_jbm_dec_tc_buffer_reconfigure()
- *
- * open and initialize JBM transport channel buffer
- *--------------------------------------------------------------------------*/
-
-ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */
- const Word16 nchan_transport_jbm, /* i : new number of real transport channels */
- const Word16 nchan_transport_internal, /* i : new number of totally buffered channels */
- const Word16 nchan_full, /* i : new number of channels to fully store */
- const Word16 n_samples_granularity /* i : new granularity of the renderer/buffer */
-)
-{
- Word16 ch_idx, num_tc_buffer_mem, n_samples_still_available;
- Word32 tc_buffer_mem[MAX_INTERN_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES - 1];
- ivas_error error;
- DECODER_TC_BUFFER_HANDLE hTcBuffer;
-
- hTcBuffer = st_ivas->hTcBuffer;
- move16();
-
- num_tc_buffer_mem = 0;
- move16();
- n_samples_still_available = 0;
- move16();
-
- IF( st_ivas->hDecoderConfig->Opt_tsm )
- {
- /* save samples of the TC buffer from the previous frame */
- num_tc_buffer_mem = s_min( hTcBuffer->nchan_transport_internal, nchan_transport_internal );
- n_samples_still_available = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_rendered );
-
- /* what is remaining from last frame needs always be smaller than the new granularity */
- assert( n_samples_still_available < n_samples_granularity );
-
- FOR( ch_idx = 0; ch_idx < num_tc_buffer_mem; ch_idx++ )
- {
- Copy32( hTcBuffer->tc_buffer_old_fx[ch_idx] + hTcBuffer->n_samples_flushed, tc_buffer_mem[ch_idx], n_samples_still_available );
- }
- }
-
- /* if granularity changes, adapt subframe_nb_slots */
- IF( NE_16( n_samples_granularity, hTcBuffer->n_samples_granularity ) )
- {
- Word16 nMaxSlotsPerSubframeNew;
- Word16 tmp, tmp_e;
-
- /* nMaxSlotsPerSubframeNew = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / n_samples_granularity; */
- tmp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) );
- tmp = BASOP_Util_Divide1616_Scale( tmp, n_samples_granularity, &tmp_e );
- nMaxSlotsPerSubframeNew = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */
-
- /* if samples were flushed, take that into account here */
- test();
- IF( LT_16( n_samples_granularity, hTcBuffer->n_samples_granularity ) && hTcBuffer->n_samples_flushed > 0 )
- {
- hTcBuffer->subframe_nbslots[hTcBuffer->subframes_rendered - 1] = idiv1616( hTcBuffer->n_samples_flushed, n_samples_granularity );
- hTcBuffer->n_samples_flushed = 0;
- move16();
- move16();
- }
- ELSE
- {
- hTcBuffer->subframe_nbslots[hTcBuffer->subframes_rendered - 1] = nMaxSlotsPerSubframeNew;
- move16();
- }
- }
-
- hTcBuffer->tc_buffer_mode = tc_buffer_mode;
- move16();
- hTcBuffer->nchan_transport_jbm = nchan_transport_jbm;
- move16();
- hTcBuffer->nchan_transport_internal = nchan_transport_internal;
- move16();
- hTcBuffer->nchan_buffer_full = nchan_full;
- move16();
- hTcBuffer->n_samples_granularity = n_samples_granularity;
- move16();
-
- /* reallocate TC audio buffers */
-
- ivas_jbm_dec_tc_audio_deallocate_fx( hTcBuffer );
-
- IF( ( error = ivas_jbm_dec_tc_audio_allocate_fx( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK )
- {
- return error;
- }
-
- /* propagate samples of the TC buffer from the previous frame */
- FOR( ch_idx = 0; ch_idx < num_tc_buffer_mem; ch_idx++ )
- {
- Copy32( tc_buffer_mem[ch_idx], hTcBuffer->tc_buffer_old_fx[ch_idx], n_samples_still_available );
- }
-
- return IVAS_ERR_OK;
-}
-
-
-/*--------------------------------------------------------------------------*
- * ivas_jbm_dec_tc_buffer_playout()
- *
- *
- *--------------------------------------------------------------------------*/
-
-static void ivas_jbm_dec_tc_buffer_playout_fx(
- Decoder_Struct *st_ivas,
- const UWord16 nSamplesAsked,
- UWord16 *nSamplesRendered,
- Word32 *output_fx[] /*Q11*/
-)
-{
- Word16 ch_idx, slot_size, slots_to_render, first_sf, last_sf, tmp, e;
-
- slot_size = st_ivas->hTcBuffer->n_samples_granularity;
- move16();
-
- /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */
- tmp = BASOP_Util_Divide1616_Scale( nSamplesAsked, slot_size, &e );
- tmp = shr( tmp, sub( 15, e ) ); // Q0
- slots_to_render = s_min( sub( st_ivas->hTcBuffer->num_slots, st_ivas->hTcBuffer->slots_rendered ), tmp );
- st_ivas->hTcBuffer->slots_rendered = add( st_ivas->hTcBuffer->slots_rendered, slots_to_render ); // Q0
- *nSamplesRendered = (UWord16) L_mult0( slots_to_render, slot_size );
- first_sf = st_ivas->hTcBuffer->subframes_rendered;
- last_sf = first_sf;
- move16();
- move16();
- move16();
- move16();
-
- WHILE( slots_to_render > 0 )
- {
- slots_to_render = sub( slots_to_render, st_ivas->hTcBuffer->subframe_nbslots[last_sf] );
- last_sf = add( last_sf, 1 );
- }
-#ifdef DEBUGGING
- assert( slots_to_render == 0 );
-#endif
-
- FOR( ch_idx = 0; ch_idx < st_ivas->hTcBuffer->nchan_transport_jbm; ch_idx++ )
- {
- output_fx[ch_idx] = st_ivas->hTcBuffer->tc_fx[ch_idx] + st_ivas->hTcBuffer->n_samples_rendered;
- move32();
- }
-
- st_ivas->hTcBuffer->subframes_rendered = last_sf;
- move16();
-
- return;
-}
-
-
-/*--------------------------------------------------------------------------*
- * ivas_jbm_dec_tc_buffer_close()
- *
- * Close JBM transport channel buffer
- *--------------------------------------------------------------------------*/
-
-void ivas_jbm_dec_tc_buffer_close_fx(
- DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */
-)
-{
- IF( *phTcBuffer != NULL )
- {
- ivas_jbm_dec_tc_audio_deallocate_fx( *phTcBuffer );
-
- free( *phTcBuffer );
- *phTcBuffer = NULL;
- }
-
- return;
-}
-
-
-/*--------------------------------------------------------------------------*
- * ivas_jbm_dec_td_renderers_adapt_subframes()
- *
- * Close JBM transport channel buffer
- *--------------------------------------------------------------------------*/
-
-void ivas_jbm_dec_td_renderers_adapt_subframes(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-)
-{
- Word16 nMaxSlotsPerSubframe, nSlotsAvailable, tmp, tmp_e, tmp1, tmp2, s1, s2;
- UWord16 nSlotsInLastSubframe, nSlotsInFirstSubframe;
-
- /* nMaxSlotsPerSubframe = (Word16) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; */
- tmp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) );
- tmp = BASOP_Util_Divide1616_Scale( tmp, st_ivas->hTcBuffer->n_samples_granularity, &tmp_e );
- nMaxSlotsPerSubframe = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */
-
- /* nSlotsAvailable = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; */
- tmp = BASOP_Util_Divide1616_Scale( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity, &tmp_e );
- nSlotsAvailable = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */
-
- st_ivas->hTcBuffer->num_slots = nSlotsAvailable;
- move16();
- /* st_ivas->hTcBuffer->n_samples_available = nSlotsAvailable * st_ivas->hTcBuffer->n_samples_granularity; */
- st_ivas->hTcBuffer->n_samples_available = i_mult( nSlotsAvailable, st_ivas->hTcBuffer->n_samples_granularity );
- move16();
- nSlotsInFirstSubframe = sub( nMaxSlotsPerSubframe, st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] );
- st_ivas->hTcBuffer->nb_subframes = 0;
- move16();
-
- IF( nSlotsInFirstSubframe > 0 )
- {
- st_ivas->hTcBuffer->nb_subframes = 1;
- move16();
- nSlotsAvailable = sub( nSlotsAvailable, nSlotsInFirstSubframe );
- }
-
- s1 = sub( norm_s( nSlotsAvailable ), 1 );
- s2 = norm_s( nMaxSlotsPerSubframe );
-
- tmp1 = shl( nSlotsAvailable, s1 );
- tmp2 = shl( nMaxSlotsPerSubframe, s2 );
-
- tmp = div_s( tmp1, tmp2 );
- st_ivas->hTcBuffer->nb_subframes = add( st_ivas->hTcBuffer->nb_subframes, ceil_fx16( tmp, sub( 15, sub( s2, s1 ) ) ) );
- move16();
-
- nSlotsInLastSubframe = nSlotsAvailable % nMaxSlotsPerSubframe;
- move16();
- set16_fx( st_ivas->hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS );
- set16_fx( st_ivas->hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, st_ivas->hTcBuffer->nb_subframes );
-
- if ( nSlotsInFirstSubframe > 0 )
- {
- st_ivas->hTcBuffer->subframe_nbslots[0] = nSlotsInFirstSubframe;
- move16();
- }
-
- if ( nSlotsInLastSubframe > 0 )
- {
- st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nSlotsInLastSubframe;
- move16();
- }
-
- st_ivas->hTcBuffer->slots_rendered = 0;
- move16();
- st_ivas->hTcBuffer->subframes_rendered = 0;
- move16();
-
- return;
-}
-
-
-/*--------------------------------------------------------------------------*
- * ivas_jbm_dec_get_tc_buffer_mode()
- *
- *
- *--------------------------------------------------------------------------*/
-
-TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode_fx(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-)
-{
- TC_BUFFER_MODE buffer_mode;
-
- buffer_mode = TC_BUFFER_MODE_BUFFER;
- move16();
-
- SWITCH( st_ivas->renderer_type )
- {
- /* all renderers where we are done after TC decoding (might include DMX to mono/stereo */
- case RENDERER_DISABLE:
- case RENDERER_MCMASA_MONO_STEREO:
- case RENDERER_OSBA_STEREO:
- case RENDERER_MONO_DOWNMIX:
- buffer_mode = TC_BUFFER_MODE_BUFFER;
- move16();
- BREAK;
-#ifdef FIX_1435_MOVE_STEREO_PANNING
- case RENDERER_NON_DIEGETIC_DOWNMIX:
-#endif
- case RENDERER_TD_PANNING:
- case RENDERER_BINAURAL_OBJECTS_TD:
- case RENDERER_BINAURAL_FASTCONV:
- case RENDERER_BINAURAL_FASTCONV_ROOM:
- case RENDERER_BINAURAL_PARAMETRIC:
- case RENDERER_BINAURAL_PARAMETRIC_ROOM:
- case RENDERER_STEREO_PARAMETRIC:
- case RENDERER_DIRAC:
- case RENDERER_PARAM_ISM:
- case RENDERER_BINAURAL_MIXER_CONV:
- case RENDERER_BINAURAL_MIXER_CONV_ROOM:
- case RENDERER_OMASA_OBJECT_EXT:
- case RENDERER_OMASA_MIX_EXT:
- case RENDERER_OSBA_AMBI:
- case RENDERER_OSBA_LS:
- buffer_mode = TC_BUFFER_MODE_RENDERER;
- move16();
- BREAK;
-#ifndef FIX_1435_MOVE_STEREO_PANNING
- case RENDERER_NON_DIEGETIC_DOWNMIX:
- IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) )
- {
- buffer_mode = TC_BUFFER_MODE_BUFFER;
- move16();
- }
- ELSE
- {
- buffer_mode = TC_BUFFER_MODE_RENDERER;
- move16();
- }
- break;
-#endif
- case RENDERER_MC_PARAMMC:
- IF( EQ_32( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) )
- {
- buffer_mode = TC_BUFFER_MODE_BUFFER; /* TCs are already the DMX to mono or stereo */
- move16();
- }
- ELSE
- {
- buffer_mode = TC_BUFFER_MODE_RENDERER;
- move16();
- }
- BREAK;
- case RENDERER_MC:
- if ( NE_16( ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ), st_ivas->hDecoderConfig->nchan_out ) )
- {
- buffer_mode = TC_BUFFER_MODE_RENDERER;
- move16();
- }
- BREAK;
- case RENDERER_SBA_LINEAR_ENC:
- test();
- test();
- test();
- test();
- IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) && ( EQ_32( st_ivas->renderer_type, RENDERER_MC ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) && GE_16( ( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ) ), ( add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ) ) )
- {
- buffer_mode = TC_BUFFER_MODE_BUFFER;
- move16();
- }
- ELSE
- {
- buffer_mode = TC_BUFFER_MODE_RENDERER;
- move16();
- }
- BREAK;
- case RENDERER_SBA_LINEAR_DEC:
- test();
- test();
- IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) && ( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) ) )
- {
- buffer_mode = TC_BUFFER_MODE_BUFFER;
- move16();
- }
- ELSE
- {
- buffer_mode = TC_BUFFER_MODE_RENDERER;
- move16();
- }
- BREAK;
- }
-
- return buffer_mode;
-}
-
-
-/*--------------------------------------------------------------------------*
- * ivas_jbm_dec_metadata_open()
- *
- * Open structure for metadata buffering in JBM
- *--------------------------------------------------------------------------*/
-
-ivas_error ivas_jbm_dec_metadata_open(
- Decoder_Struct *st_ivas )
-{
- JBM_METADATA_HANDLE hJbmMetadata;
-
- IF( ( hJbmMetadata = (JBM_METADATA_HANDLE) malloc( sizeof( JBM_METADATA ) ) ) == NULL )
- {
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM metadata handle\n" ) );
- }
-
- hJbmMetadata->sf_write_idx = 0;
- move16();
- hJbmMetadata->sf_md_buffer_length = MASA_JBM_RINGBUFFER_FRAMES * MAX_PARAM_SPATIAL_SUBFRAMES;
- move16();
-
- hJbmMetadata->slot_write_idx = 0;
- move16();
- hJbmMetadata->slot_read_idx = 0;
- move16();
- hJbmMetadata->slot_md_buffer_length = MASA_JBM_RINGBUFFER_FRAMES * MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME;
- move16();
-
- st_ivas->hJbmMetadata = hJbmMetadata;
-
- return IVAS_ERR_OK;
-}
-
-
-/*--------------------------------------------------------------------------*
- * ivas_jbm_dec_copy_masa_meta_to_buffer()
- *
- * Copy decoded MASA metadata to a ring buffer
- *--------------------------------------------------------------------------*/
-
-static void ivas_jbm_dec_copy_masa_meta_to_buffer(
- Decoder_Struct *st_ivas )
-{
- Word16 sf, dir, band;
- JBM_METADATA_HANDLE hJbmMetadata;
- MASA_DECODER_EXT_OUT_META *extOutMeta;
- Word16 write_idx;
-
- hJbmMetadata = st_ivas->hJbmMetadata;
- extOutMeta = st_ivas->hMasa->data.extOutMeta;
-
- FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ )
- {
- write_idx = ( hJbmMetadata->sf_write_idx + sf ) % hJbmMetadata->sf_md_buffer_length;
- move16();
- FOR( dir = 0; dir < MASA_MAXIMUM_DIRECTIONS; dir++ )
- {
- FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ )
- {
- hJbmMetadata->directionIndexBuffer[dir][write_idx][band] = extOutMeta->directionIndex[dir][sf][band];
- move16();
- hJbmMetadata->directToTotalRatioBuffer[dir][write_idx][band] = extOutMeta->directToTotalRatio[dir][sf][band];
- move16();
- hJbmMetadata->spreadCoherenceBuffer[dir][write_idx][band] = extOutMeta->spreadCoherence[dir][sf][band];
- move16();
- }
- }
-
- FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ )
- {
- hJbmMetadata->diffuseToTotalRatioBuffer[write_idx][band] = extOutMeta->diffuseToTotalRatio[sf][band];
- move16();
- hJbmMetadata->surroundCoherenceBuffer[write_idx][band] = extOutMeta->surroundCoherence[sf][band];
- move16();
- }
-
- hJbmMetadata->numberOfDirections[write_idx] = extOutMeta->descriptiveMeta.numberOfDirections;
- move16();
- }
-
- return;
-}
-
-
-/*--------------------------------------------------------------------------*
- * ivas_jbm_masa_sf_to_slot_map()
- *
- * Map input MASA metadata subframes to slots in JBM processing
- *--------------------------------------------------------------------------*/
-
-static void ivas_jbm_masa_sf_to_slot_map(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- const Word16 nCldfbTs /* i : number of CLDFB time slots */
-)
-{
- Word16 sf_to_slot_map[MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME];
- Word16 num_slots_in_subfr;
- JBM_METADATA_HANDLE hJbmMetadata;
- Word16 slot_idx;
- Word16 write_idx, sf_index;
-
- ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas );
-
- /* Set values */
- hJbmMetadata = st_ivas->hJbmMetadata;
- num_slots_in_subfr = CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES;
- move16();
-
- /* Map input subframes to slots */
- ivas_jbm_dec_get_md_map_even_spacing( nCldfbTs, num_slots_in_subfr, 0, MAX_PARAM_SPATIAL_SUBFRAMES, sf_to_slot_map );
-
- FOR( slot_idx = 0; slot_idx < nCldfbTs; slot_idx++ )
- {
- write_idx = ( add( hJbmMetadata->slot_write_idx, slot_idx ) ) % hJbmMetadata->slot_md_buffer_length;
- move16();
- sf_index = ( add( hJbmMetadata->sf_write_idx, sf_to_slot_map[slot_idx] ) ) % hJbmMetadata->sf_md_buffer_length;
- move16();
-
- hJbmMetadata->sf_to_slot_map[write_idx] = sf_index;
- move16();
- }
-
- hJbmMetadata->sf_write_idx = ( add( hJbmMetadata->sf_write_idx, MAX_PARAM_SPATIAL_SUBFRAMES ) ) % hJbmMetadata->sf_md_buffer_length;
- move16();
- hJbmMetadata->slot_write_idx = ( add( hJbmMetadata->slot_write_idx, nCldfbTs ) ) % hJbmMetadata->slot_md_buffer_length;
- move16();
-
- return;
-}
-
-/*--------------------------------------------------------------------------*
- * ivas_jbm_masa_sf_to_sf_map()
- *
- * Map input MASA metadata subframes to output subframes in JBM processing
- *--------------------------------------------------------------------------*/
-
-void ivas_jbm_masa_sf_to_sf_map(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-)
-{
- Word16 sf_to_sf_map[MAX_PARAM_SPATIAL_SUBFRAMES];
- JBM_METADATA_HANDLE hJbmMetadata;
- MASA_DECODER_EXT_OUT_META *extOutMeta;
- Word16 slot_read_idx, sf_read_idx;
- Word16 sf_idx;
- Word16 dir, band;
- UWord8 numberOfDirections;
-
- /* Set values */
- hJbmMetadata = st_ivas->hJbmMetadata;
- extOutMeta = st_ivas->hMasa->data.extOutMeta;
-
- /* Map slots to subframes */
- FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
- {
- slot_read_idx = ( add( hJbmMetadata->slot_read_idx, 2 ) ) % hJbmMetadata->slot_md_buffer_length; /* Take the latter one of the middle slots of the output subframe */
- move16();
- sf_to_sf_map[sf_idx] = hJbmMetadata->sf_to_slot_map[slot_read_idx];
- move16();
- hJbmMetadata->slot_read_idx = ( add( hJbmMetadata->slot_read_idx, CLDFB_SLOTS_PER_SUBFRAME ) ) % hJbmMetadata->slot_md_buffer_length;
- move16();
- }
-
- /* Copy mapped metadata to the EXT meta buffer for writing */
- FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
- {
- sf_read_idx = sf_to_sf_map[sf_idx];
- move16();
-
- FOR( dir = 0; dir < MASA_MAXIMUM_DIRECTIONS; dir++ )
- {
- FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ )
- {
- extOutMeta->directionIndex[dir][sf_idx][band] = hJbmMetadata->directionIndexBuffer[dir][sf_read_idx][band];
- move16();
- extOutMeta->directToTotalRatio[dir][sf_idx][band] = hJbmMetadata->directToTotalRatioBuffer[dir][sf_read_idx][band];
- move16();
- extOutMeta->spreadCoherence[dir][sf_idx][band] = hJbmMetadata->spreadCoherenceBuffer[dir][sf_read_idx][band];
- move16();
- }
- }
-
- FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ )
- {
- extOutMeta->diffuseToTotalRatio[sf_idx][band] = hJbmMetadata->diffuseToTotalRatioBuffer[sf_read_idx][band];
- move16();
- extOutMeta->surroundCoherence[sf_idx][band] = hJbmMetadata->surroundCoherenceBuffer[sf_read_idx][band];
- move16();
- }
- }
-
- /* Determine the number of directions for the frame to be written */
- numberOfDirections = 0;
- move16();
- FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
- {
- sf_read_idx = sf_to_sf_map[sf_idx];
- move16();
-
- IF( hJbmMetadata->numberOfDirections[sf_read_idx] == 1 )
- {
- numberOfDirections = 1;
- move16();
- BREAK;
- }
- }
-
- extOutMeta->descriptiveMeta.numberOfDirections = numberOfDirections;
- move16();
-
- return;
-}
-
-
-/*--------------------------------------------------------------------------*
- * ivas_dec_prepare_renderer()
- *
- * prepare IVAS renderer routine
- *--------------------------------------------------------------------------*/
-
-void ivas_dec_prepare_renderer_fx(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-)
-{
- Word16 n, n_render_timeslots, tmp, exp, shift;
-
- push_wmops( "ivas_dec_prepare_renderer" );
-
- /* n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; */
- tmp = BASOP_Util_Divide1616_Scale( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity, &exp );
- n_render_timeslots = shr( tmp, sub( 15, exp ) ); // Q0
-
- test();
- IF( EQ_16( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) )
- {
- ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas );
-
- test();
- test();
- test();
- IF( ( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) && EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && st_ivas->hDecoderConfig->Opt_tsm )
- {
- ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots );
- }
- /* MASA transport gaining for edited disc OMASA EXT. For ISMs, only metadata is modified */
- test();
- test();
- test();
- IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && EQ_16( st_ivas->hMasaIsmData->masa_gain_is_edited, 1 ) )
- {
- ivas_omasa_gain_masa_tc_fx( st_ivas->hTcBuffer->tc_fx, st_ivas->hMasaIsmData->gain_masa_edited_fx, st_ivas->nchan_ism, st_ivas->hTcBuffer->n_samples_available );
- }
- }
- ELSE IF( EQ_16( st_ivas->ivas_format, MONO_FORMAT ) || EQ_16( st_ivas->ivas_format, STEREO_FORMAT ) )
- {
- ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas );
- }
- ELSE IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) )
- {
- /* Rendering */
- IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) )
- {
- test();
- test();
- test();
- IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
- {
- ivas_dirac_dec_set_md_map_fx( st_ivas, n_render_timeslots );
-
- ivas_param_ism_params_to_masa_param_mapping_fx( st_ivas );
- }
- ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
- {
- ivas_param_ism_dec_prepare_renderer_fx( st_ivas, n_render_timeslots );
- }
- }
- ELSE /* ISM_MODE_DISC */
- {
- ivas_ism_dec_digest_tc_fx( st_ivas );
- }
- }
- ELSE IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_FORMAT ) )
- {
- IF( st_ivas->hSCE[0] )
- {
- shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN );
- IF( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) )
- {
- shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 );
- }
- scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31-cngNoiseLevelExp+shift)
- st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift );
- }
-
- ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available );
- }
- ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
- {
- IF( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
- {
- ivas_ism_dec_digest_tc_fx( st_ivas );
-
- test();
- test();
- test();
- test();
- test();
- test();
- /* delay the objects here for all renderers where it is needed */
- IF(
- (
- EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ||
- EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ||
- EQ_16( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) ||
- EQ_16( st_ivas->renderer_type, RENDERER_OSBA_LS ) ||
- EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) &&
- ( NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) )
- {
- FOR( n = 0; n < st_ivas->nchan_ism; n++ )
- {
- delay_signal32_fx( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hSbaIsmData->delayBuffer_fx[n], st_ivas->hSbaIsmData->delayBuffer_size );
- }
- }
-
- IF( !st_ivas->sba_dirac_stereo_flag )
- {
- IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) )
- {
- Word16 temp, temp_e;
- temp = BASOP_Util_Divide1616_Scale( st_ivas->hTcBuffer->n_samples_granularity, st_ivas->hSpatParamRendCom->slot_size, &temp_e );
- n_render_timeslots = extract_l( L_shr( L_mult0( n_render_timeslots, temp ), sub( 15, temp_e ) ) );
- }
-
- IF( st_ivas->hSCE[0] )
- {
- shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN );
- if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) )
- {
- shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 );
- }
- scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31-cngNoiseLevelExp+shift)
- st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift );
- }
- ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available );
- }
- }
- ELSE
- {
- ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas );
-
- IF( st_ivas->hSCE[0] )
- {
- shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN );
- if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) )
- {
- shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 );
- }
- scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31-cngNoiseLevelExp+shift)
- st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift );
- }
-
- ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available );
- }
- }
- ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
- {
- test();
- IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) || EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) )
- {
- ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas );
-
- IF( st_ivas->hDecoderConfig->Opt_tsm )
- {
- ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots );
- }
- /* MASA transport gaining for edited param_one OMASA EXT. For ISMs, only metadata is modified. */
- test();
- IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && EQ_16( st_ivas->hMasaIsmData->masa_gain_is_edited, 1 ) )
- {
- FOR( n = 0; n < CPE_CHANNELS; n++ )
- {
- v_multc_fx_16( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available ); // Q8
- Scale_sig32( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available, Q3 ); // Q8 -> Q11
- }
- }
- }
- ELSE
- {
- test();
- IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
- {
- n_render_timeslots = i_mult( n_render_timeslots, idiv1616( st_ivas->hTcBuffer->n_samples_granularity, st_ivas->hSpatParamRendCom->slot_size ) );
- }
-
- IF( st_ivas->hSCE[0] )
- {
- shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN );
- if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) )
- {
- shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 );
- }
- scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31- (st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp - shift)
- st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift );
- move16();
- }
-
- ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available );
-
- IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
- {
- ivas_ism_dec_digest_tc_fx( st_ivas );
- }
- }
-
- test();
- IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_DIRAC ) )
- {
- Word16 nchan_transport_ism;
-
- /* Delay the signal to match CLDFB delay. Delay the whole buffer. */
- nchan_transport_ism = 0;
- move16();
-
- test();
- test();
- IF( ( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) )
- {
- nchan_transport_ism = 1;
- move16();
- }
- ELSE IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
- {
- nchan_transport_ism = st_ivas->nchan_ism;
- move16();
- }
-
- test();
- test();
- IF( st_ivas->hDecoderConfig->Opt_tsm && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) )
- {
- /* Gain MASA part, if edited */
- IF( st_ivas->hMasaIsmData->masa_gain_is_edited )
- {
- FOR( n = 0; n < CPE_CHANNELS; n++ )
- {
- v_multc_fx_16( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available );
- Scale_sig32( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available, Q3 ); // Q8 -> Q11
- }
- }
- }
-
- FOR( n = 0; n < nchan_transport_ism; n++ )
- {
- test();
- IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) )
- {
- v_multc_fx_16( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN_FX, st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available );
-
- IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] )
- {
- v_multc_fx_16( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available );
- Scale_sig32( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, Q3 ); // Q8 -> Q11
- }
- }
-
- test();
- IF( NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
- {
- delay_signal32_fx( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer_fx[n], st_ivas->hMasaIsmData->delayBuffer_size );
- }
- }
-
- test();
- IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) )
- {
- IF( st_ivas->hMasaIsmData->masa_gain_is_edited )
- {
- FOR( n = 0; n < BINAURAL_CHANNELS; n++ )
- {
- v_multc_fx_16( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available ); // Q8
- Scale_sig32( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available, Q3 ); // Q8 -> Q11
- }
- }
- }
- }
- }
- ELSE IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) )
- {
- IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) )
- {
- ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas );
- }
- ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
- {
- ivas_mc_paramupmix_dec_digest_tc_fx( st_ivas, (UWord8) n_render_timeslots, st_ivas->hTcBuffer->n_samples_available );
- }
- ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
- {
- Word16 nchan_transport = st_ivas->nchan_transport;
- move16();
- Word16 nchan_out_transport = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe );
- Word16 nchan_out_cov;
-
- test();
- test();
- IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
- {
- nchan_out_cov = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe );
- }
- ELSE IF( EQ_16( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_CLDFB ) )
- {
- nchan_out_cov = nchan_out_transport;
- move16();
- }
- ELSE IF( EQ_16( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_16( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) )
- {
- nchan_out_cov = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe );
- }
- ELSE
- {
- nchan_out_cov = nchan_out_transport;
- move16();
- }
-
- scale_sig32( st_ivas->hParamMC->proto_matrix_int_fx, st_ivas->hParamMC->proto_matrix_int_len, -1 ); // Q(31-1)
- st_ivas->hParamMC->proto_matrix_int_e = 1;
- move16();
-
- ivas_param_mc_dec_prepare_renderer( st_ivas, (UWord8) n_render_timeslots );
-
- scale_sig32( st_ivas->hParamMC->proto_matrix_int_fx, st_ivas->hParamMC->proto_matrix_int_len, 1 ); // Q(31-1+1)
-
- FOR( Word16 param_band_idx = 0; param_band_idx < st_ivas->hParamMC->num_param_bands_synth; param_band_idx++ )
- {
- shift = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_fx[param_band_idx], s_min( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_len, nchan_transport * nchan_transport ) );
- scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_fx[param_band_idx], s_min( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_len, i_mult( nchan_transport, nchan_transport ) ), shift ); // Q(31-cx_old_e+shift)
- st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx] = sub( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx], shift );
- move16();
-
- shift = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_fx[param_band_idx], nchan_out_cov * nchan_out_cov );
- scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_fx[param_band_idx], i_mult( nchan_out_cov, nchan_out_cov ), shift ); // Q(31-cy_old_e+shift)
- st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx] = sub( st_ivas->hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx], shift );
- move16();
- }
- }
- ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) )
- {
- IF( st_ivas->hSCE[0] )
- {
- shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN );
- if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) )
- {
- shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 );
- }
- scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31-cngNoiseLevelExp+shift)
- st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift );
- move16();
- }
-
- ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available );
- }
- }
-
- pop_wmops();
- return;
-}
diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c
index 2fa66e34cdbd205522e94a756139a74f3bef19f7..20b2ac7c72be1af61f308794e502fb0b0a7ccdfd 100644
--- a/lib_dec/ivas_lfe_dec_fx.c
+++ b/lib_dec/ivas_lfe_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -407,11 +407,7 @@ void ivas_lfe_dec_fx(
IF( hLFE->filter_state.order > 0 )
{
/* Low Pass Filter */
-#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS
ivas_filter_process_fx32( &hLFE->filter_state, output_lfe_ch, output_frame );
-#else
- ivas_filter_process_fx( &hLFE->filter_state, output_lfe_ch, output_frame, q_out );
-#endif
}
/* add delay to make overall max(block_offset, 11.5) */
diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c
index b50fe21202c769645c6309f6a57e978464698fdc..0d3da5e33e91f6b88914702a6a356d892cdcdf79 100755
--- a/lib_dec/ivas_lfe_plc_fx.c
+++ b/lib_dec/ivas_lfe_plc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_ls_custom_dec_fx.c b/lib_dec/ivas_ls_custom_dec_fx.c
index 5ad390f9a66786ed847e1f78cc278c1fa165826c..b6ae99039b6a6d5fcaf06fe46d23ba253dc56559 100644
--- a/lib_dec/ivas_ls_custom_dec_fx.c
+++ b/lib_dec/ivas_ls_custom_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c
index e24fa019b14169486dc8dbf19272a1f71a03621d..140eb764de581bae399a18050ec25be7ec8da890 100644
--- a/lib_dec/ivas_masa_dec_fx.c
+++ b/lib_dec/ivas_masa_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -925,7 +925,7 @@ ivas_error ivas_masa_dec_open_fx(
move16();
}
- nchan_transport = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
+ nchan_transport = ivas_dec_get_num_tc_channels_fx( st_ivas );
nchan_to_allocate = nchan_transport;
move16();
@@ -951,9 +951,9 @@ ivas_error ivas_masa_dec_open_fx(
nchan_to_allocate = add( nchan_to_allocate, 1 );
}
- granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs );
+ granularity = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs );
- IF( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_transport, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_transport, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1937,7 +1937,7 @@ ivas_error ivas_masa_dec_reconfigure_fx(
ivas_masa_set_elements_fx( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &tmp, &tmp, &tmp, st_ivas->ivas_format, st_ivas->ism_mode, ism_total_brate );
/*-----------------------------------------------------------------*
- * JBM TC buffers
+ * TC buffer
*-----------------------------------------------------------------*/
{
Word16 tc_nchan_to_allocate;
@@ -1945,9 +1945,9 @@ ivas_error ivas_masa_dec_reconfigure_fx(
TC_BUFFER_MODE buffer_mode_new;
Word16 n_samples_granularity;
- n_samples_granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), st_ivas->hDecoderConfig->output_Fs );
- buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode_fx( st_ivas );
- tc_nchan_transport = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
+ n_samples_granularity = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), st_ivas->hDecoderConfig->output_Fs );
+ buffer_mode_new = ivas_dec_get_tc_buffer_mode_fx( st_ivas );
+ tc_nchan_transport = ivas_dec_get_num_tc_channels_fx( st_ivas );
tc_nchan_to_allocate = tc_nchan_transport;
move16();
@@ -2007,11 +2007,13 @@ ivas_error ivas_masa_dec_reconfigure_fx(
tc_nchan_transport = add( st_ivas->nchan_transport, st_ivas->nchan_ism );
tc_nchan_to_allocate = add( st_ivas->nchan_transport, st_ivas->nchan_ism );
}
+
+ /* reconfigure TC buffer */
test();
test();
- IF( NE_16( tc_nchan_transport, st_ivas->hTcBuffer->nchan_transport_jbm ) || NE_16( tc_nchan_to_allocate, st_ivas->hTcBuffer->nchan_transport_internal ) || NE_16( buffer_mode_new, st_ivas->hTcBuffer->tc_buffer_mode ) )
+ IF( NE_16( tc_nchan_transport, st_ivas->hTcBuffer->nchan_transport_rend ) || NE_16( tc_nchan_to_allocate, st_ivas->hTcBuffer->nchan_transport_internal ) || NE_16( buffer_mode_new, st_ivas->hTcBuffer->tc_buffer_mode ) )
{
- IF( NE_32( error = ivas_jbm_dec_tc_buffer_reconfigure_fx( st_ivas, buffer_mode_new, tc_nchan_transport, tc_nchan_to_allocate, tc_nchan_to_allocate, n_samples_granularity ), IVAS_ERR_OK ) )
+ IF( NE_32( error = ivas_dec_tc_buffer_reconfigure_fx( st_ivas, buffer_mode_new, tc_nchan_transport, tc_nchan_to_allocate, tc_nchan_to_allocate, n_samples_granularity ), IVAS_ERR_OK ) )
{
return error;
}
diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c
index 43937a0779c6b797d18a0698b14049f0dbbc2267..70b4b645c47202fa83b0762157ed76515794d22a 100644
--- a/lib_dec/ivas_mc_param_dec_fx.c
+++ b/lib_dec/ivas_mc_param_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -523,9 +523,9 @@ ivas_error ivas_param_mc_dec_open_fx(
IF( st_ivas->hTcBuffer == NULL )
{
- granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs );
+ granularity = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs );
- IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, granularity ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, granularity ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1520,7 +1520,7 @@ void ivas_param_mc_dec_digest_tc_fx(
/* Initialization */
num_freq_bands = st_ivas->hParamMC->num_freq_bands;
move16();
- n_ch_cldfb = sub( st_ivas->hTcBuffer->nchan_transport_jbm, st_ivas->hTcBuffer->nchan_buffer_full );
+ n_ch_cldfb = sub( st_ivas->hTcBuffer->nchan_transport_rend, st_ivas->hTcBuffer->nchan_buffer_full );
cldfb_real_buffer = st_ivas->hParamMC->Cldfb_RealBuffer_tc_fx;
cldfb_imag_buffer = st_ivas->hParamMC->Cldfb_ImagBuffer_tc_fx;
@@ -1642,7 +1642,7 @@ void ivas_param_mc_dec_prepare_renderer(
move16();
hParamMC->subframes_rendered = 0;
move16();
- ivas_jbm_dec_get_adapted_subframes( nCldfbSlots, hParamMC->subframe_nbslots, &hParamMC->nb_subframes );
+ ivas_dec_get_adapted_subframes_fx( nCldfbSlots, hParamMC->subframe_nbslots, &hParamMC->nb_subframes );
st_ivas->hTcBuffer->nb_subframes = hParamMC->nb_subframes;
move16();
Copy( hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hParamMC->nb_subframes );
@@ -2608,7 +2608,7 @@ static void ivas_param_mc_dec_compute_interpolator_fx(
}
ELSE
{
- ivas_jbm_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, interp_length, interpolator );
+ ivas_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, interp_length, interpolator );
}
return;
@@ -3142,6 +3142,9 @@ static void ivas_param_mc_dequantize_cov_fx(
const PARAM_MC_ILD_MAPPING *h_ild_mapping;
Word32 Cy_state_int_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS];
Word16 Cy_state_int_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS];
+#ifdef FIX_2384_INIT_DEQUANT_COV
+ Word16 nY_norm;
+#endif
set16_fx( Cp_buf_e, Cproto_e, MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS );
set32_fx( Nrqq_fx, 0, MAX_OUTPUT_CHANNELS );
@@ -3395,22 +3398,38 @@ static void ivas_param_mc_dequantize_cov_fx(
Cyp_e += nY_cov;
}
}
+#ifdef FIX_2384_INIT_DEQUANT_COV
+ nY_norm = nY_cov;
+ move16();
+#endif
}
ELSE
{
Copy32( Cy_state_int_fx, Cy_state_fx, imult1616( nY_int, nY_int ) );
Copy( Cy_state_int_e, Cy_buf_e, imult1616( nY_int, nY_int ) );
+#ifdef FIX_2384_INIT_DEQUANT_COV
+ nY_norm = nY_int;
+ move16();
+#endif
}
/*normalize output matrix to a common exponent*/
tmp = 0;
+#ifdef FIX_2384_INIT_DEQUANT_COV
+ FOR( k = 0; k < nY_norm * nY_norm; k++ )
+#else
FOR( k = 0; k < nY_int * nY_int; k++ )
+#endif
{
Cy_state_fx[k] = BASOP_Util_Add_Mant32Exp( Cy_state_fx[k], Cy_buf_e[k], 0, 0, &Cy_buf_e[k] );
move32();
tmp = s_max( tmp, Cy_buf_e[k] );
}
+#ifdef FIX_2384_INIT_DEQUANT_COV
+ FOR( k = 0; k < nY_norm * nY_norm; k++ )
+#else
FOR( k = 0; k < nY_int * nY_int; k++ )
+#endif
{
L_tmp = L_shr( Cy_state_fx[k], sub( tmp, Cy_buf_e[k] ) );
Cy_state_fx[k] = L_tmp;
diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c
index 833947efd1bc7e6d7d90fdc3faa0f2d1a817e814..608644c7246dbebee4c9893f8b29e81ec5a1a889 100644
--- a/lib_dec/ivas_mc_paramupmix_dec_fx.c
+++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -216,9 +216,9 @@ void ivas_mc_paramupmix_dec_digest_tc_fx(
ivas_param_upmix_dec_decorr_subframes( st_ivas, nSamplesForRendering );
/* adapt subframes */
- ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas );
+ ivas_dec_td_renderers_adapt_subframes_fx( st_ivas );
- ivas_jbm_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hMCParamUpmix->param_interpolator_fx );
+ ivas_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hMCParamUpmix->param_interpolator_fx );
pop_wmops();
return;
@@ -399,10 +399,11 @@ ivas_error ivas_mc_paramupmix_dec_open(
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for interpolator\n" ) );
}
+
hMCParamUpmix->free_param_interpolator = 1;
move16();
- ivas_jbm_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, DEFAULT_JBM_CLDFB_TIMESLOTS, hMCParamUpmix->param_interpolator_fx );
+ ivas_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, DEFAULT_JBM_CLDFB_TIMESLOTS, hMCParamUpmix->param_interpolator_fx );
IF( st_ivas->hTcBuffer == NULL )
{
@@ -412,7 +413,7 @@ ivas_error ivas_mc_paramupmix_dec_open(
TC_BUFFER_MODE buffer_mode;
buffer_mode = TC_BUFFER_MODE_RENDERER;
- nchan_tc = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
+ nchan_tc = ivas_dec_get_num_tc_channels_fx( st_ivas );
nchan_to_allocate = MC_PARAMUPMIX_MAX_INPUT_CHANS;
move16();
move16();
@@ -435,9 +436,9 @@ ivas_error ivas_mc_paramupmix_dec_open(
move16();
}
- granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs );
+ granularity = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs );
- IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -496,12 +497,12 @@ void ivas_mc_paramupmix_dec_close(
/*-------------------------------------------------------------------------
- * paramupmix_td_decorr_process_jbm_fx()
+ * paramupmix_td_decorr_process()
*
*
*------------------------------------------------------------------------*/
-static void paramupmix_td_decorr_process_jbm_fx(
+static void paramupmix_td_decorr_process_fx(
ivas_td_decorr_state_t *hTdDecorr[], /* i/o: SPAR Covar. decoder handle */
Word32 *pcm_in[], /* i : input audio channels */
Word32 **pp_out_pcm, /* o : output audio channels */
@@ -561,8 +562,9 @@ static void paramupmix_td_decorr_process_jbm_fx(
*------------------------------------------------------------------------*/
static void ivas_param_upmix_dec_decorr_subframes(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
- const Word16 nSamplesForRendering )
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
+ const Word16 nSamplesForRendering /* i : number of samples provided */
+)
{
MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix;
Word32 *pPcm_tmp_fx[MC_PARAMUPMIX_COMBINATIONS];
@@ -591,23 +593,21 @@ static void ivas_param_upmix_dec_decorr_subframes(
WHILE( nSamplesLeftForTD )
{
Word16 nSamplesToDecorr = s_min( nSamplesLeftForTD, default_frame );
+ Word16 i, q_format[MC_PARAMUPMIX_COMBINATIONS];
+ FOR( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ )
{
- Word16 i, q_format[MC_PARAMUPMIX_COMBINATIONS];
-
- FOR( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ )
- {
- q_format[i] = Q11;
- move16();
- }
+ q_format[i] = Q11;
+ move16();
+ }
- paramupmix_td_decorr_process_jbm_fx( hMCParamUpmix->hTdDecorr, p_tc_fx, pPcm_tmp_fx, nSamplesToDecorr, q_format );
+ paramupmix_td_decorr_process_fx( hMCParamUpmix->hTdDecorr, p_tc_fx, pPcm_tmp_fx, nSamplesToDecorr, q_format );
- FOR( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ )
- {
- Scale_sig32( pPcm_tmp_fx[i], nSamplesToDecorr, sub( Q11, q_format[i] ) ); // Setting Q to changed q in q_format
- }
+ FOR( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ )
+ {
+ Scale_sig32( pPcm_tmp_fx[i], nSamplesToDecorr, sub( Q11, q_format[i] ) ); // Setting Q to changed q in q_format
}
+
FOR( ch = 0; ch < nchan_internal; ch++ )
{
p_tc_fx[ch] += nSamplesToDecorr;
diff --git a/lib_dec/ivas_mcmasa_dec_fx.c b/lib_dec/ivas_mcmasa_dec_fx.c
index d12b190c640728b55825a1a5a4b948591e481b70..b4fa9d08cc31ce1158e4c0dcbfa328d7b07ccf2e 100644
--- a/lib_dec/ivas_mcmasa_dec_fx.c
+++ b/lib_dec/ivas_mcmasa_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_mct_core_dec_fx.c b/lib_dec/ivas_mct_core_dec_fx.c
index 5f764533ade6a84ef4377ec59f516637d4a3952c..2bba7429bdcd74fed0b6e3aba0416dfde11fbc9c 100644
--- a/lib_dec/ivas_mct_core_dec_fx.c
+++ b/lib_dec/ivas_mct_core_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c
index 3b2c60277eafb280e2a3ffbfe5b0caae8f7fe769..b50fb4ae9799edacf6e9bfd2077bd24cedccd1bf 100644
--- a/lib_dec/ivas_mct_dec_fx.c
+++ b/lib_dec/ivas_mct_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -214,22 +214,53 @@ ivas_error ivas_mct_dec_fx(
}
}
+#ifndef FIX_2382_COPY_AQ_IN_MCT
Word32 Aq_fx_32[6][2][102];
+#endif
/* MCT reconstruction and CoreCoder updates */
FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
{
+#ifdef FIX_2382_COPY_AQ_IN_MCT
+ Word32 Aq_fx_32[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )];
+#endif
hCPE = st_ivas->hCPE[cpe_id];
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
+#ifdef FIX_2382_COPY_AQ_IN_MCT
+#ifdef FIX_2397_COPY_AQ_MDCT_CORE_BFI
+ test();
+ IF( !st_ivas->bfi && NE_16( hCPE->hCoreCoder[n]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
+#else
+ IF( NE_16( hCPE->hCoreCoder[n]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
+#endif
+ {
+ Word16 nSubframes;
+
+ nSubframes = 1; /* Q0 */
+ move16();
+ if ( EQ_16( hCPE->hCoreCoder[n]->core, TCX_10_CORE ) )
+ {
+ nSubframes = NB_DIV;
+ move16();
+ }
+
+ Copy_Scale_sig_16_32_DEPREC( Aq_fx[cpe_id][n], Aq_fx_32[n], i_mult( nSubframes, M ), Q16 - Q12 ); // Q16
+ }
+#else
Copy_Scale_sig_16_32_DEPREC( Aq_fx[cpe_id][n], Aq_fx_32[cpe_id][n], 102, Q16 - Q12 ); // Q16
- x_fx[n][0] = output_fx[n + ( cpe_id * CPE_CHANNELS )]; // Q11
- x_fx[n][1] = output_fx[n + ( cpe_id * CPE_CHANNELS )] + ( L_FRAME48k / 2 ); // Q11
+#endif
+ x_fx[n][0] = output_fx[n + ( cpe_id * CPE_CHANNELS )]; // Q11
+ x_fx[n][1] = output_fx[n + ( cpe_id * CPE_CHANNELS )] + ( L_FRAME48k / 2 ); // Q11
move16();
move16();
}
+#ifdef FIX_2382_COPY_AQ_IN_MCT
+ ivas_mdct_core_tns_ns_fx( hCPE, fUseTns[cpe_id], tnsData[cpe_id], x_fx, Aq_fx_32, 1, 20 );
+#else
ivas_mdct_core_tns_ns_fx( hCPE, fUseTns[cpe_id], tnsData[cpe_id], x_fx, Aq_fx_32[cpe_id], 1, 20 );
+#endif
}
test();
@@ -363,7 +394,8 @@ ivas_error ivas_mct_dec_fx(
{
dirac_stereo_flag = 0;
}
- IF( NE_32( ( error = core_switching_post_dec_ivas_fx( sts[n], synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], output_mem_fx, 0, output_frame, 0 /*core_switching_flag*/, dirac_stereo_flag, -1, hCPE->last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) )
+
+ IF( NE_32( ( error = core_switching_post_dec_fx( sts[n], synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], output_mem_fx, 0, output_frame, 0 /*core_switching_flag*/, dirac_stereo_flag, -1, hCPE->last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -380,7 +412,7 @@ ivas_error ivas_mct_dec_fx(
save_synthesis_hq_fec_fx( sts[n], NULL, output_fx_, output_frame, 0, hCPE );
/* CoreCoder common updates */
- ivas_updt_dec_common_fx( hCPE->hCoreCoder[n], NORMAL_HQ_CORE, -1, output_fx[( cpe_id * CPE_CHANNELS ) + n], 11 );
+ updt_dec_common_fx( hCPE->hCoreCoder[n], NORMAL_HQ_CORE, -1, NULL, output_fx[( cpe_id * CPE_CHANNELS ) + n], Q11 );
} /* n_channels loop */
@@ -699,7 +731,7 @@ ivas_error mct_dec_reconfigure_fx(
move16();
/* MDCT stereo initialization */
- IF( ( hMCT->hBlockData[n]->hStereoMdct = (STEREO_MDCT_DEC_DATA_HANDLE) malloc( sizeof( STEREO_MDCT_ENC_DATA ) ) ) == NULL )
+ IF( ( hMCT->hBlockData[n]->hStereoMdct = (STEREO_MDCT_DEC_DATA_HANDLE) malloc( sizeof( STEREO_MDCT_DEC_DATA ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MDCT Stereo \n" ) );
}
@@ -895,12 +927,14 @@ static ivas_error ivas_mc_dec_reconfig_fx(
Decoder_State *st;
ivas_error error;
MC_MODE mc_mode, last_mc_mode;
+ DECODER_TC_BUFFER_HANDLE hTcBuffer;
TC_BUFFER_MODE tc_buffer_mode_new;
Word16 tc_nchan_tc_new;
Word16 tc_nchan_allocate_new;
Word16 tc_granularity_new;
Word16 nchan_out_buff;
+ hTcBuffer = st_ivas->hTcBuffer;
ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
move32();
nchan_transport_old = st_ivas->nchan_transport;
@@ -946,45 +980,45 @@ static ivas_error ivas_mc_dec_reconfig_fx(
/* side effect of the renderer selection can be a changed internal config */
ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config );
- /* transfer subframe info from DirAC or ParamMC to central tc buffer */
- IF( NE_32( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) )
+ /* transfer subframe info from DirAC or ParamMC to central TC buffer */
+ IF( NE_32( hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) )
{
test();
IF( EQ_16( last_mc_mode, MC_MODE_PARAMMC ) )
{
- st_ivas->hTcBuffer->nb_subframes = st_ivas->hParamMC->nb_subframes;
+ hTcBuffer->nb_subframes = st_ivas->hParamMC->nb_subframes;
move16();
- st_ivas->hTcBuffer->subframes_rendered = st_ivas->hParamMC->subframes_rendered;
+ hTcBuffer->subframes_rendered = st_ivas->hParamMC->subframes_rendered;
move16();
- st_ivas->hTcBuffer->num_slots = st_ivas->hParamMC->num_slots;
+ hTcBuffer->num_slots = st_ivas->hParamMC->num_slots;
move16();
- st_ivas->hTcBuffer->slots_rendered = st_ivas->hParamMC->slots_rendered;
+ hTcBuffer->slots_rendered = st_ivas->hParamMC->slots_rendered;
move16();
- Copy( st_ivas->hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
+ Copy( st_ivas->hParamMC->subframe_nbslots, hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
}
ELSE IF( EQ_16( last_mc_mode, MC_MODE_MCMASA ) && st_ivas->hSpatParamRendCom != NULL )
{
- st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes;
+ hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes;
move16();
- st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered;
+ hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered;
move16();
- st_ivas->hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots;
+ hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots;
move16();
- st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered;
+ hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered;
move16();
- Copy( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
+ Copy( st_ivas->hSpatParamRendCom->subframe_nbslots, hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
}
}
- /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv
- render what still fits in the new granularity */
- tc_granularity_new = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs );
- IF( LT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) )
+ /* when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv
+ render what still fits in the new granularity */
+ tc_granularity_new = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs );
+ IF( LT_16( tc_granularity_new, hTcBuffer->n_samples_granularity ) )
{
/* flush already done in IVAS_DEC_ReadFormat() */
}
- /* JBM: when granularity goes up set samples to discard at the beginning of the frame */
- ELSE IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) )
+ /* when granularity goes up set samples to discard at the beginning of the frame */
+ ELSE IF( GT_16( tc_granularity_new, hTcBuffer->n_samples_granularity ) )
{
IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
@@ -1522,16 +1556,13 @@ static ivas_error ivas_mc_dec_reconfig_fx(
}
/*-----------------------------------------------------------------*
- * JBM TC buffers
+ * TC buffer
*-----------------------------------------------------------------*/
-
{
Word16 tc_nchan_full_new;
- DECODER_TC_BUFFER_HANDLE hTcBuffer;
- hTcBuffer = st_ivas->hTcBuffer;
- tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode_fx( st_ivas );
- tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
+ tc_buffer_mode_new = ivas_dec_get_tc_buffer_mode_fx( st_ivas );
+ tc_nchan_tc_new = ivas_dec_get_num_tc_channels_fx( st_ivas );
tc_nchan_allocate_new = tc_nchan_tc_new;
move16();
tc_nchan_full_new = tc_nchan_tc_new;
@@ -1589,39 +1620,40 @@ static ivas_error ivas_mc_dec_reconfig_fx(
test();
test();
test();
- IF( NE_16( hTcBuffer->tc_buffer_mode, tc_buffer_mode_new ) || NE_16( hTcBuffer->nchan_transport_jbm, tc_nchan_tc_new ) ||
+ IF( NE_16( hTcBuffer->tc_buffer_mode, tc_buffer_mode_new ) || NE_16( hTcBuffer->nchan_transport_rend, tc_nchan_tc_new ) ||
NE_16( hTcBuffer->nchan_buffer_full, tc_nchan_full_new ) || NE_16( hTcBuffer->nchan_transport_internal, tc_nchan_allocate_new ) ||
NE_16( tc_granularity_new, hTcBuffer->n_samples_granularity ) )
{
- IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ), IVAS_ERR_OK ) )
{
return error;
}
}
- /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */
+
+ /* transfer subframe info from central TC buffer to ParamMC or McMASA (DirAC) */
IF( st_ivas->hSpatParamRendCom != NULL )
{
- st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes;
+ st_ivas->hSpatParamRendCom->nb_subframes = hTcBuffer->nb_subframes;
move16();
- st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered;
+ st_ivas->hSpatParamRendCom->subframes_rendered = hTcBuffer->subframes_rendered;
move16();
- st_ivas->hSpatParamRendCom->num_slots = st_ivas->hTcBuffer->num_slots;
+ st_ivas->hSpatParamRendCom->num_slots = hTcBuffer->num_slots;
move16();
- st_ivas->hSpatParamRendCom->slots_rendered = st_ivas->hTcBuffer->slots_rendered;
+ st_ivas->hSpatParamRendCom->slots_rendered = hTcBuffer->slots_rendered;
move16();
- Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
+ Copy( hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
}
ELSE IF( st_ivas->hParamMC != NULL )
{
- st_ivas->hParamMC->nb_subframes = st_ivas->hTcBuffer->nb_subframes;
+ st_ivas->hParamMC->nb_subframes = hTcBuffer->nb_subframes;
move16();
- st_ivas->hParamMC->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered;
+ st_ivas->hParamMC->subframes_rendered = hTcBuffer->subframes_rendered;
move16();
- st_ivas->hParamMC->num_slots = st_ivas->hTcBuffer->num_slots;
+ st_ivas->hParamMC->num_slots = hTcBuffer->num_slots;
move16();
- st_ivas->hParamMC->slots_rendered = st_ivas->hTcBuffer->slots_rendered;
+ st_ivas->hParamMC->slots_rendered = hTcBuffer->slots_rendered;
move16();
- Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hParamMC->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
+ Copy( hTcBuffer->subframe_nbslots, st_ivas->hParamMC->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
}
}
@@ -1630,7 +1662,7 @@ static ivas_error ivas_mc_dec_reconfig_fx(
*-----------------------------------------------------------------*/
nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 );
- IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff, st_ivas->hDecoderConfig->Opt_tsm, hTcBuffer ) ) != IVAS_ERR_OK )
{
return error;
}
diff --git a/lib_dec/ivas_mct_dec_mct_fx_fx.c b/lib_dec/ivas_mct_dec_mct_fx_fx.c
index 8f8d3c7b1ab5756b9a950abcbe950d22e9b4981a..f4d289ee28e28ef03bff8bf679f6d810a3fed9f0 100644
--- a/lib_dec/ivas_mct_dec_mct_fx_fx.c
+++ b/lib_dec/ivas_mct_dec_mct_fx_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c
index 41fed3e0c0f7590fabdf779da3e4a3e33d3da6fe..c085d5674d93cc609b236e82860de45c7ecbf739 100644
--- a/lib_dec/ivas_mdct_core_dec_fx.c
+++ b/lib_dec/ivas_mdct_core_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_mono_dmx_renderer_fx.c b/lib_dec/ivas_mono_dmx_renderer_fx.c
index 63cf7f87addfb02b2925bfee3c4f6248bf3b4c1e..36d5bd48aa7446b2c8c58386c7cb4d701a9a3d58 100644
--- a/lib_dec/ivas_mono_dmx_renderer_fx.c
+++ b/lib_dec/ivas_mono_dmx_renderer_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c
index 428c6512ec2a3701d18263b831906708cd205d81..999fe3824c93ee34ad56e917605469209f9b4a26 100644
--- a/lib_dec/ivas_objectRenderer_internal_fx.c
+++ b/lib_dec/ivas_objectRenderer_internal_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -94,7 +94,7 @@ ivas_error ivas_td_binaural_renderer_sf_fx(
Word16 ch, slot_size, slots_to_render, output_frame, tmp;
ivas_error error;
- Word16 ism_md_subframe_update_jbm;
+ Word16 ism_md_subframe_update;
Word16 c_indx, nS, i;
Word16 nchan_ism_internal, nchan_ism, ch_offset;
@@ -136,16 +136,16 @@ ivas_error ivas_td_binaural_renderer_sf_fx(
/* Number of subframes to delay metadata to sync with audio */
IF( st_ivas->hDecoderConfig->Opt_delay_comp )
{
- ism_md_subframe_update_jbm = s_max( 0, sub( st_ivas->hTcBuffer->nb_subframes, 3 ) );
+ ism_md_subframe_update = s_max( 0, sub( st_ivas->hTcBuffer->nb_subframes, 3 ) );
}
ELSE
{
- ism_md_subframe_update_jbm = sub( st_ivas->hTcBuffer->nb_subframes, 2 );
+ ism_md_subframe_update = sub( st_ivas->hTcBuffer->nb_subframes, 2 );
}
IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
{
- ism_md_subframe_update_jbm = s_max( 0, sub( st_ivas->hTcBuffer->nb_subframes, 2 ) );
+ ism_md_subframe_update = s_max( 0, sub( st_ivas->hTcBuffer->nb_subframes, 2 ) );
}
FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
@@ -206,7 +206,7 @@ ivas_error ivas_td_binaural_renderer_sf_fx(
}
}
- IF( EQ_16( subframe_idx, ism_md_subframe_update_jbm ) )
+ IF( EQ_16( subframe_idx, ism_md_subframe_update ) )
{
test();
test();
@@ -311,7 +311,7 @@ ivas_error ivas_td_binaural_renderer_sf_fx(
}
/* Render subframe */
- /* ism_md_subframe_update_jbm != subframe_idx: trigger update only for ism_md_subframe_update_jbm == subframe_idx,
+ /* ism_md_subframe_updatem != subframe_idx: trigger update only for ism_md_subframe_update_jbm == subframe_idx,
where then the two TDREND_GetMix()-arguments subframe_idx and ism_md_subframe_update are equal, and we want to enforce the update inside TDREND_GetMix to use subframe_idx == 0 */
IF( NE_32( ( error = TDREND_GetMix_fx( st_ivas->hBinRendererTd, output_fx_local, output_frame, 0 ) ), IVAS_ERR_OK ) )
{
diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c
index 0021a7b763c988b97ccaa25daecfa0cacff149a3..1659d4912e8663b43bcfb540f131c9fb1c64c7d9 100644
--- a/lib_dec/ivas_omasa_dec_fx.c
+++ b/lib_dec/ivas_omasa_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -344,8 +344,16 @@ ivas_error ivas_omasa_data_open_fx(
move16();
hMasaIsmData->preprocEneTarget_fx[band_idx] = 0;
move32();
+#ifdef FIX_BASOP_2357_OBJECT_EDIT_MSAN
+ hMasaIsmData->preprocEneTarget_e[band_idx] = 0;
+ move16();
+#endif
hMasaIsmData->preprocEneRealized_fx[band_idx] = 0;
move32();
+#ifdef FIX_BASOP_2357_OBJECT_EDIT_MSAN
+ hMasaIsmData->preprocEneRealized_e[band_idx] = 0;
+ move16();
+#endif
}
hMasaIsmData->objectsEdited = 0;
@@ -652,7 +660,7 @@ ivas_error ivas_omasa_dec_config_fx(
IF( st_ivas->hMasaIsmData != NULL || st_ivas->hIsmRendererData != NULL )
{
/* this calls also ivas_ism_renderer_close() closing st_ivas->hIsmRendererData used by the EXT renderers. also cleans st_ivas->hMasaIsmData */
- ivas_omasa_separate_object_renderer_close( st_ivas );
+ ivas_omasa_separate_object_renderer_close_fx( st_ivas );
}
test();
@@ -708,7 +716,7 @@ ivas_error ivas_omasa_dec_config_fx(
}
/* ISM renderer handle + ISM data handle */
- ivas_omasa_separate_object_renderer_close( st_ivas );
+ ivas_omasa_separate_object_renderer_close_fx( st_ivas );
}
}
@@ -729,7 +737,7 @@ ivas_error ivas_omasa_dec_config_fx(
return error;
}
- IF( NE_32( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_omasa_separate_object_renderer_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -737,7 +745,7 @@ ivas_error ivas_omasa_dec_config_fx(
ELSE
{
/* ISM renderer handle + ISM data handle */
- ivas_omasa_separate_object_renderer_close( st_ivas );
+ ivas_omasa_separate_object_renderer_close_fx( st_ivas );
}
IF( EQ_32( old_renderer_type, RENDERER_MONO_DOWNMIX ) )
@@ -1075,19 +1083,20 @@ ivas_error ivas_omasa_ism_metadata_dec_fx(
return IVAS_ERR_OK;
}
+
/*--------------------------------------------------------------------------*
- * ivas_omasa_dirac_rend_jbm_fx()
+ * ivas_omasa_dirac_rend()
*
- * Rendering in OMASA format for JBM
+ * Rendering in OMASA format
*--------------------------------------------------------------------------*/
-void ivas_omasa_dirac_rend_jbm_fx(
+void ivas_omasa_dirac_rend_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
const UWord16 nSamplesAsked, /* i : number of samples requested */
UWord16 *nSamplesRendered, /* o : number of samples rendered */
UWord16 *nSamplesAvailable, /* o : number of samples still to render */
const Word16 nchan_transport, /* i : number of transport channels */
- Word32 *output_fx[] /* o : rendered time signal Q11*/
+ Word32 *output_fx[] /* o : rendered time signal Q11*/
)
{
Word16 subframes_rendered;
@@ -1150,7 +1159,7 @@ void ivas_omasa_dirac_rend_jbm_fx(
scale_sig32( st_ivas->hIsmRendererData->prev_gains_fx[ind1], MAX_OUTPUT_CHANNELS, -1 ); // Q30 -> Q29
}
- ivas_omasa_separate_object_render_jbm_fx( st_ivas, *nSamplesRendered, data_separated_objects, output_fx, subframes_rendered );
+ ivas_omasa_separate_object_render_fx( st_ivas, *nSamplesRendered, data_separated_objects, output_fx, subframes_rendered );
FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ )
{
@@ -1164,16 +1173,16 @@ void ivas_omasa_dirac_rend_jbm_fx(
/*--------------------------------------------------------------------------*
* ivas_omasa_dirac_td_binaural_render()
*
- * Binaural rendering in OMASA format for JBM
+ * Binaural rendering in OMASA format
*--------------------------------------------------------------------------*/
-ivas_error ivas_omasa_dirac_td_binaural_jbm_fx(
+ivas_error ivas_omasa_dirac_td_binaural_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */
const UWord16 nSamplesAsked, /* i : number of samples requested */
UWord16 *nSamplesRendered, /* o : number of samples rendered */
UWord16 *nSamplesAvailable, /* o : number of samples still to render */
const Word16 nchan_transport, /* i : number of transport channels */
- Word32 *output_fx[] /* o : rendered time signal Q11*/
+ Word32 *output_fx[] /* o : rendered time signal Q11*/
)
{
Word16 n;
diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c
index c9a6e0d70c9d3ec33361133896f95466067ad078..622cd88c853cf7f4e458e09125e78eaade9411d1 100644
--- a/lib_dec/ivas_osba_dec_fx.c
+++ b/lib_dec/ivas_osba_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -119,17 +119,17 @@ void ivas_osba_data_close_fx(
/*--------------------------------------------------------------------------*
- * ivas_osba_dirac_td_binaural_jbm()
+ * ivas_osba_dirac_td_binaural()
*
- * Binaural rendering in JBM OSBA format
+ * Binaural rendering in OSBA format
*--------------------------------------------------------------------------*/
-ivas_error ivas_osba_dirac_td_binaural_jbm_fx(
+ivas_error ivas_osba_dirac_td_binaural_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */
UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */
UWord16 *nSamplesAvailable, /* o : number of CLDFB slots still to render */
- Word32 *output_fx[] /* o : rendered time signal Q11*/
+ Word32 *output_fx[] /* o : rendered time signal Q11*/
)
{
Word16 n;
diff --git a/lib_dec/ivas_out_setup_conversion_fx.c b/lib_dec/ivas_out_setup_conversion_fx.c
index 01f78da0528e18afe57b139d016211ac36746172..a8fe1d0b0aabd9722e190bc3dc2f9328b7bba2e9 100644
--- a/lib_dec/ivas_out_setup_conversion_fx.c
+++ b/lib_dec/ivas_out_setup_conversion_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c
index abf80add0da1b9f2af4f621c1d3680a42b573064..b57f4100b985753392cfa5b58e71a48c189e4c20 100644
--- a/lib_dec/ivas_output_config_fx.c
+++ b/lib_dec/ivas_output_config_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -283,14 +283,14 @@ void ivas_renderer_select(
* Non-binaural rendering configurations
*-----------------------------------------------------------------*/
- ELSE IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) )
+ ELSE IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
{
test();
test();
test();
test();
test();
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) )
+ IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) )
{
*renderer_type = RENDERER_NON_DIEGETIC_DOWNMIX;
move16();
@@ -300,27 +300,12 @@ void ivas_renderer_select(
*renderer_type = RENDERER_MC;
move16();
}
- }
- ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA3 ) )
+ ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) &&
+ ( EQ_32( output_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) )
{
*renderer_type = RENDERER_SBA_LINEAR_ENC;
move16();
}
- ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
- {
- *renderer_type = RENDERER_MC;
- move16();
- }
}
ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
{
diff --git a/lib_dec/ivas_pca_dec_fx.c b/lib_dec/ivas_pca_dec_fx.c
index fc531c34deee6c308cca7c0ffbe211a7cd093995..e5cab04c04b1854ff71d1d6b1ea8f3fccd889f0e 100644
--- a/lib_dec/ivas_pca_dec_fx.c
+++ b/lib_dec/ivas_pca_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_post_proc_fx.c b/lib_dec/ivas_post_proc_fx.c
index 02be03d21234b92da0b72f18bf5b97b28ece6f40..b6eb91fd9a9f7649902dfdcff7f7a45b6185010f 100644
--- a/lib_dec/ivas_post_proc_fx.c
+++ b/lib_dec/ivas_post_proc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -584,7 +584,7 @@ void stereo_dft_dec_core_switching_fx(
IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) || ( EQ_16( st->bfi, 1 ) && EQ_16( st->core, ACELP_CORE ) && EQ_16( st->con_tcx, 1 ) ) )
{
Word16 numZeros = (Word16) ( NS2SA_FX2( st->sr_core, N_ZERO_MDCT_NS ) ); /*Q0*/
- Word32 tmp_fade_fx[max( STEREO_DFT_ALLPASS_FADELEN_12k8, STEREO_DFT_ALLPASS_FADELEN_16k )];
+ Word32 tmp_fade_fx[STEREO_DFT_ALLPASS_FADELEN_16k /*max( STEREO_DFT_ALLPASS_FADELEN_12k8, STEREO_DFT_ALLPASS_FADELEN_16k )*/];
Copy32( st->hHQ_core->old_out_LB_fx32 + numZeros, hCPE->hStereoDft->ap_fade_mem_fx, ap_fade_len ); /*st->hHQ_core->q_old_outLB_fx*/
hCPE->hStereoDft->q_ap_fade_mem_fx = st->hHQ_core->Q_old_out_fx32;
diff --git a/lib_dec/ivas_qmetadata_dec_fx.c b/lib_dec/ivas_qmetadata_dec_fx.c
index 261133d93088ff97e411f3751e199036b3cd6029..7974350ce2b651139a251a2346f55c13c7d7d71e 100644
--- a/lib_dec/ivas_qmetadata_dec_fx.c
+++ b/lib_dec/ivas_qmetadata_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_qspherical_dec_fx.c b/lib_dec/ivas_qspherical_dec_fx.c
index f443cc81de370ba99f5e6d3f4d018a40ff96322a..f0a7b03f67ee8025be0cc94b8579741fe4230af3 100644
--- a/lib_dec/ivas_qspherical_dec_fx.c
+++ b/lib_dec/ivas_qspherical_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_range_uni_dec_fx.c b/lib_dec/ivas_range_uni_dec_fx.c
index 7b6d428dbd007cdfd7f683333a67978f58e530ca..540c33123f7cdc50cc46fe61bc9803692b6bd6f6 100644
--- a/lib_dec/ivas_range_uni_dec_fx.c
+++ b/lib_dec/ivas_range_uni_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_rom_dec.h b/lib_dec/ivas_rom_dec.h
index 0b29588b2207de3cbb2cb1d3d2f7dd9839a940f6..04613f1a541c1d04490915680f1e5935a5ba0451 100644
--- a/lib_dec/ivas_rom_dec.h
+++ b/lib_dec/ivas_rom_dec.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_rom_dec_fx.c b/lib_dec/ivas_rom_dec_fx.c
index 3209278ed91737364e8355d988bc7be9a738c110..f86a8ee88d1cde78201291a911ad1b974711d051 100644
--- a/lib_dec/ivas_rom_dec_fx.c
+++ b/lib_dec/ivas_rom_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c
index 90cca685536a087a41f21ac3207506ca4befa4e4..789c0e954b36e8f0c2fecc64cdd3af5192fc8bbf 100644
--- a/lib_dec/ivas_sba_dec_fx.c
+++ b/lib_dec/ivas_sba_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -102,7 +102,7 @@ void ivas_sba_set_cna_cng_flag(
}
/*-------------------------------------------------------------------*
- * ivas_sba_dec_reconfigure_fx()
+ * ivas_sba_dec_reconfigure()
*
* Reconfigure IVAS SBA decoder
*-------------------------------------------------------------------*/
@@ -180,7 +180,7 @@ ivas_error ivas_sba_dec_reconfigure_fx(
IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) )
{
/* determine new granularity */
- granularity_new = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), st_ivas->hDecoderConfig->output_Fs );
+ granularity_new = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), st_ivas->hDecoderConfig->output_Fs );
/* flush renderer on granularity change form 5ms to 1.25ms, again only possible for binaural rendering */
IF( LT_16( granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) )
@@ -585,9 +585,8 @@ ivas_error ivas_sba_dec_reconfigure_fx(
}
/*-----------------------------------------------------------------*
- * JBM TC buffers
+ * TC buffer
*-----------------------------------------------------------------*/
-
{
Word16 tc_nchan_to_allocate;
Word16 tc_nchan_tc;
@@ -595,8 +594,8 @@ ivas_error ivas_sba_dec_reconfigure_fx(
tc_buffer_mode = TC_BUFFER_MODE_RENDERER;
move16();
- tc_nchan_tc = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); /*Q0*/
- tc_nchan_to_allocate = tc_nchan_tc; /*Q0*/
+ tc_nchan_tc = ivas_dec_get_num_tc_channels_fx( st_ivas ); /*Q0*/
+ tc_nchan_to_allocate = tc_nchan_tc; /*Q0*/
move16();
test();
test();
@@ -647,19 +646,20 @@ ivas_error ivas_sba_dec_reconfigure_fx(
}
}
+ /* reconfigure TC buffer */
test();
test();
test();
- IF( NE_16( tc_nchan_tc, st_ivas->hTcBuffer->nchan_transport_jbm ) || NE_16( tc_nchan_to_allocate, st_ivas->hTcBuffer->nchan_transport_internal ) || NE_16( tc_buffer_mode, st_ivas->hTcBuffer->tc_buffer_mode ) || NE_16( granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) )
+ IF( NE_16( tc_nchan_tc, st_ivas->hTcBuffer->nchan_transport_rend ) || NE_16( tc_nchan_to_allocate, st_ivas->hTcBuffer->nchan_transport_internal ) || NE_16( tc_buffer_mode, st_ivas->hTcBuffer->tc_buffer_mode ) || NE_16( granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) )
{
- if ( NE_32( ( error = ivas_jbm_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, granularity_new ) ), IVAS_ERR_OK ) )
+ if ( NE_32( ( error = ivas_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, granularity_new ) ), IVAS_ERR_OK ) )
{
return error;
}
}
}
- /* resync SPAR and DirAC JBM info from TC Buffer */
+ /* resync SPAR and DirAC info from TC Buffer */
test();
IF( st_ivas->hSpatParamRendCom != NULL && EQ_16( st_ivas->hSpatParamRendCom->slot_size, st_ivas->hTcBuffer->n_samples_granularity ) )
{
diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c
index 0c380ea5cde44f3cbe054d3f1f14f1a9c6bee200..0f18a6eab2a1fd0b39eb0bded7cfc7f5d1580e29 100644
--- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c
+++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -1231,13 +1231,13 @@ void ivas_sba_dirac_stereo_smooth_parameters_fx(
void ivas_sba_dirac_stereo_dec_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
Word32 *output[CPE_CHANNELS], /* i/o: output synthesis signal */
- const Word16 output_frame, /* i : output frame length per channel Q0*/
- const Word16 mcmasa /* i : McMASA flag Q0*/
+ const Word16 output_frame /* i : output frame length per channel Q0*/
)
{
Word16 dtx_flag, fd_cng_flag;
Word16 sba_mono_flag;
Word16 memOffset;
+ Word32 output_Fs;
Word32 tmp_buf[NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS )];
Word32 tmp_synth[L_FRAME16k];
Word32 hb_gain[NB_DIV];
@@ -1250,27 +1250,173 @@ void ivas_sba_dirac_stereo_dec_fx(
SCE_DEC_HANDLE hSCE;
CPE_DEC_HANDLE hCPE;
STEREO_DFT_DEC_DATA_HANDLE hStereoDft;
+ Word16 mcmasa;
- FOR( Word16 i = 0; i < CPE_CHANNELS; i++ )
+ mcmasa = 0;
+ move16();
+ if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) )
{
- set32_fx( DFT[i], 0, STEREO_DFT_BUF_MAX );
+ mcmasa = 1;
+ move16();
}
- hSCE = st_ivas->hSCE[0];
+ output_Fs = st_ivas->hDecoderConfig->output_Fs;
+ move32();
+
hCPE = st_ivas->hCPE[0];
+ hSCE = st_ivas->hSCE[0];
hStereoDft = hCPE->hStereoDft;
- q = hCPE->hStereoDft->q_dft;
+
+ /*----------------------------------------------------------------*
+ * Adjust scaling of buffers
+ *----------------------------------------------------------------*/
+
+ Decoder_State *st;
+ Word16 i, ii, s;
+
+ s = 0;
+ move16();
+ FOR( i = 0; i < CPE_CHANNELS; i++ )
+ {
+ s = s_min( s, L_norm_arr( output[i], output_frame ) - Q11 ) /* Guard bits */;
+ }
+ FOR( i = 0; i < CPE_CHANNELS; i++ )
+ {
+ Scale_sig32( output[i], output_frame, s ); // Q(11+s)
+ }
+ hStereoDft->q_dft = add( Q11, s );
+ move16();
+ IF( EQ_16( hStereoDft->first_frame, 1 ) )
+ {
+ hStereoDft->q_smoothed_nrg = Q6; // hStereoDft->q_dft;
+ move16();
+ hStereoDft->q_ap_delay_mem_fx = hStereoDft->q_dft;
+ move16();
+ }
+
+ q = hStereoDft->q_dft;
+ move16();
+
+ scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hStereoDft->q_dft, Q11 ) ); // q_dft
+ FOR( i = 0; i < CPE_CHANNELS; ++i )
+ {
+ scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hStereoDft->q_dft, Q11 ) ); // q_dft
+ scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hStereoDft->q_dft, Q11 ) ); // q_dft
+ }
+ IF( hCPE->hCoreCoder[0] != NULL )
+ {
+ Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q
+ Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, output_frame, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q
+ hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q;
+ move16();
+ }
+ IF( hStereoDft != NULL )
+ {
+ IF( LE_16( st_ivas->nchan_transport, 1 ) && EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
+ {
+ st = hCPE->hCoreCoder[0];
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) || ( EQ_16( st->bfi, 1 ) && EQ_16( st->core, ACELP_CORE ) && EQ_16( st->con_tcx, 1 ) ) )
+ {
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( ( ( st->last_core != ACELP_CORE ) || ( EQ_16( st->prev_bfi, 1 ) && ( st->last_core == ACELP_CORE ) && EQ_16( st->last_con_tcx, 1 ) ) ) && NE_16( st->last_core, AMR_WB_CORE ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_16( st->cng_type, FD_CNG ) ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */
+ {
+ scale_sig32( hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( hStereoDft->q_dft, Q11 ) ); // q_dft
+ }
+ ELSE IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) ) /* ACELP -> TCX/HQ */
+ {
+ IF( !st->tcxonly )
+ {
+ scale_sig32( hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( hStereoDft->q_dft, Q11 ) ); // q_dft
+ }
+ }
+ }
+ ELSE /* ACELP core */
+ {
+ test();
+ test();
+ IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, HQ_CORE ) ) /* TCX/HQ -> ACELP */
+ {
+ test();
+ test();
+ test();
+ test();
+ IF( ( LE_16( st->last_L_frame, L_FRAME16k ) && LE_16( st->L_frame, L_FRAME16k ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) )
+ {
+ scale_sig32( hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( hStereoDft->q_dft, Q11 ) ); // q_dft
+ }
+ }
+ }
+ }
+
+ IF( NE_32( st_ivas->ivas_format, SBA_FORMAT ) )
+ {
+ scale_sig32( hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hStereoDft->q_dft, Q11 ) ); // q_dft
+ }
+ scale_sig32( hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( hStereoDft->q_dft, hStereoDft->q_ap_fade_mem_fx ) ); // q_dft
+ hStereoDft->q_ap_fade_mem_fx = hStereoDft->q_dft;
+ move16();
+ }
+
+ test();
+ if ( st_ivas->hSpar != NULL && EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
+ {
+ st_ivas->hSpar->hMdDec->Q_mixer_mat = Q30;
+ move16();
+ }
+
+ IF( hSCE != NULL )
+ {
+ Scale_sig32( &hSCE->save_hb_synth_fx[0], extract_l( Mult_32_16( output_Fs, INV_FRAME_PER_SEC_Q15 ) ), sub( hStereoDft->q_dft, hSCE->q_save_hb_synth_fx ) ); // q_dft
+ hSCE->q_save_hb_synth_fx = hStereoDft->q_dft;
+ move16();
+ Scale_sig32( &hSCE->save_synth_fx[0], extract_l( Mult_32_16( output_Fs, INV_FRAME_PER_SEC_Q15 ) ), sub( hStereoDft->q_dft, hSCE->q_save_synth_fx ) ); // q_dft
+ hSCE->q_save_synth_fx = hStereoDft->q_dft;
+ move16();
+ }
+ FOR( ii = 0; ii < CPE_CHANNELS; ii++ )
+ {
+ scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hStereoDft->q_dft, Q11 ) ); // q_dft
+ hCPE->q_output_mem_fx[ii] = hStereoDft->q_dft;
+ move16();
+ }
+ FOR( ii = 0; ii < CPE_CHANNELS; ii++ )
+ {
+ Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx
+ }
+
+ /*----------------------------------------------------------------*
+ * Processing
+ *----------------------------------------------------------------*/
+
+ FOR( i = 0; i < CPE_CHANNELS; i++ )
+ {
+ set32_fx( DFT[i], 0, STEREO_DFT_BUF_MAX );
+ }
+
+ q = hStereoDft->q_dft;
move16();
- q_dft[0] = hCPE->hStereoDft->q_dft;
+ q_dft[0] = hStereoDft->q_dft;
move16();
- q_dft[1] = hCPE->hStereoDft->q_dft;
+ q_dft[1] = hStereoDft->q_dft;
move16();
- Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hCPE->hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hCPE->hStereoDft->q_dft - Q11*/
+ Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hStereoDft->q_dft - Q11*/
IF( hSCE != NULL )
{
- Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hCPE->hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hCPE->hStereoDft->q_dft - Q11*/
- hSCE->q_prev_hb_synth_fx = hCPE->hStereoDft->q_dft;
+ Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hStereoDft->q_dft - Q11*/
+ hSCE->q_prev_hb_synth_fx = hStereoDft->q_dft;
move16();
}
@@ -1297,10 +1443,13 @@ void ivas_sba_dirac_stereo_dec_fx(
move16();
ivas_sba_dirac_stereo_config( hStereoDft->hConfig );
+
test();
test();
- hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, st_ivas->hDecoderConfig->output_Fs, hStereoDft->NFFT, ( ( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !mcmasa ) );
+ hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, output_Fs, hStereoDft->NFFT, ( ( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !mcmasa ) );
+
stereo_dft_dec_update_fx( hStereoDft, output_frame, 1 /*st_ivas->sba_dirac_stereo_flag*/ );
+
IF( GT_16( st_ivas->nchan_transport, 1 ) )
{
stereo_dft_dec_analyze_fx( hCPE, output[0], DFT, 0, output_frame, output_frame, DFT_STEREO_DEC_ANA_FB, 0, 0, &q, &q_dft[0] );
@@ -1318,7 +1467,7 @@ void ivas_sba_dirac_stereo_dec_fx(
stereo_dft_dec_core_switching_fx( hCPE, output[0] /*hSCE->save_output*/, hSCE->save_synth_fx, hSCE->save_hb_synth_fx, DFT, output_frame, 0, dtx_flag, &q, &q_dft[0] );
/* do updates here after skipping this in SCE decoder (needs to be done after core switching) */
- ivas_updt_dec_common_fx( hSCE->hCoreCoder[0], NORMAL_HQ_CORE, -1, hSCE->save_synth_fx, q );
+ updt_dec_common_fx( hSCE->hCoreCoder[0], NORMAL_HQ_CORE, -1, NULL, hSCE->save_synth_fx, q );
q_synth = sub( getScaleFactor32( tmp_synth, hSCE->hCoreCoder[0]->L_frame ), 10 );
scale_sig32( tmp_synth, hSCE->hCoreCoder[0]->L_frame, q_synth ); /*hSCE->q_save_synth_fx + q_synth*/
@@ -1341,7 +1490,7 @@ void ivas_sba_dirac_stereo_dec_fx(
/* DFT Stereo upmix */
stereo_dft_dec_fx( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1 /*st_ivas->sba_dirac_stereo_flag*/, sba_mono_flag, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : NULL, ( st_ivas->hSpar != NULL && ( !mcmasa ) ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0,
- st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) );
+ output_Fs, st_ivas->nchan_transport, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) );
/* DFT synthesis */
stereo_dft_dec_synthesize_fx( hCPE, DFT, 0, output[0], output_frame );
@@ -1399,13 +1548,113 @@ void ivas_sba_dirac_stereo_dec_fx(
set32_fx( output[ch], 0, output_frame );
}
- Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hCPE->hStereoDft->q_dft*/
+ Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hStereoDft->q_dft*/
IF( hSCE != NULL )
{
- Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hCPE->hStereoDft->q_dft*/
+ Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hStereoDft->q_dft*/
hSCE->q_prev_hb_synth_fx = Q11;
move16();
}
+ /*----------------------------------------------------------------*
+ * Adjust scaling of buffers
+ *----------------------------------------------------------------*/
+
+ FOR( i = 0; i < CPE_CHANNELS; i++ )
+ {
+ Scale_sig32( output[i], output_frame, negate( s ) );
+ }
+
+ FOR( ii = 0; ii < CPE_CHANNELS; ii++ )
+ {
+ Scale_sig32( hCPE->prev_synth_fx[ii], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11
+ }
+
+ scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hStereoDft->q_dft ) );
+
+ FOR( i = 0; i < CPE_CHANNELS; ++i )
+ {
+ scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hStereoDft->q_dft ) ); // Q11
+ scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hStereoDft->q_dft ) ); // Q11
+ }
+
+ IF( hCPE->hCoreCoder[0] != NULL )
+ {
+ Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB - q ); // Q_old_wtda_LB
+ Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, output_frame, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda - q ); // Q_old_wtda_LB
+ }
+
+ IF( hStereoDft != NULL )
+ {
+ IF( LE_16( st_ivas->nchan_transport, 1 ) && EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
+ {
+ st = hCPE->hCoreCoder[0];
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) || ( EQ_16( st->bfi, 1 ) && st->core == ACELP_CORE && EQ_16( st->con_tcx, 1 ) ) )
+ {
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( ( st->last_core != ACELP_CORE || ( EQ_16( st->prev_bfi, 1 ) && st->last_core == ACELP_CORE && EQ_16( st->last_con_tcx, 1 ) ) ) && NE_16( st->last_core, AMR_WB_CORE ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_16( st->cng_type, FD_CNG ) ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */
+ {
+ scale_sig32( hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hStereoDft->q_dft ) ); // Q11
+ }
+ ELSE IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) ) /* ACELP -> TCX/HQ */
+ {
+ IF( !st->tcxonly )
+ {
+ scale_sig32( hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hStereoDft->q_dft ) ); // Q11
+ }
+ }
+ }
+ ELSE /* ACELP core */
+ {
+ test();
+ test();
+ IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, HQ_CORE ) ) /* TCX/HQ -> ACELP */
+ {
+ test();
+ test();
+ test();
+ test();
+ IF( ( LE_16( st->last_L_frame, L_FRAME16k ) && LE_16( st->L_frame, L_FRAME16k ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) )
+ {
+ scale_sig32( hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( s_max( hCPE->hCoreCoder[0]->L_frame, hCPE->hCoreCoder[0]->last_L_frame ), FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), sub( Q11, hStereoDft->q_dft ) ); // Q11
+ }
+ }
+ }
+ }
+
+ IF( NE_32( st_ivas->ivas_format, SBA_FORMAT ) )
+ {
+ scale_sig32( hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hStereoDft->q_dft ) ); // Q11
+ }
+ scale_sig32( hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hStereoDft->q_ap_fade_mem_fx ) ); // Q11
+ hStereoDft->q_ap_fade_mem_fx = Q11;
+ test();
+ }
+
+ if ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
+ {
+ st_ivas->hSpar->hMdDec->Q_mixer_mat = Q30;
+ move16();
+ }
+
+ FOR( ii = 0; ii < CPE_CHANNELS; ii++ )
+ {
+ scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hStereoDft->q_dft ) ); // Q11
+ hCPE->q_output_mem_fx[ii] = Q11;
+ move16();
+ }
+
return;
}
diff --git a/lib_dec/ivas_sba_rendering_internal_fx.c b/lib_dec/ivas_sba_rendering_internal_fx.c
index 7cfe4f821949818e22c06bebcf1221a9c68e0635..d595b8ae5494a6dd2ff0507cf4f2516c1b69111a 100644
--- a/lib_dec/ivas_sba_rendering_internal_fx.c
+++ b/lib_dec/ivas_sba_rendering_internal_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c
index a889c505d8edc37f4147d4221f9690541477120b..75266dcefe26e5520f6efc901ca57ed6edf3b0f6 100644
--- a/lib_dec/ivas_sce_dec_fx.c
+++ b/lib_dec/ivas_sce_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -385,6 +385,8 @@ ivas_error create_sce_dec(
move16();
hSCE->element_brate = element_brate; /*Q0*/
move32();
+ hSCE->last_element_brate = hSCE->element_brate;
+ move32();
set32_fx( hSCE->prev_hb_synth_fx, 0, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ) );
@@ -402,6 +404,8 @@ ivas_error create_sce_dec(
st->total_brate = hSCE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
move32();
+ st->element_brate = -1;
+ move32();
st->mct_chan_mode = MCT_CHAN_MODE_REGULAR;
move16();
st->is_ism_format = 0;
diff --git a/lib_dec/ivas_sns_dec_fx.c b/lib_dec/ivas_sns_dec_fx.c
index 2f0217b48ad7cbc167a7d35cd5999e7218685644..1120c4eb969f732d1da5a977fc0d16bae3641dde 100644
--- a/lib_dec/ivas_sns_dec_fx.c
+++ b/lib_dec/ivas_sns_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten FORschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -81,11 +81,7 @@ static void sns_1st_dec_fx(
FOR( i = 0; i < M / 2; i++ )
{
-#ifdef FIX_2254_IMPROV_COMPLEXITY_BE
snsq_fx[i] = L_mac( L_mult( ( *p_dico++ ), cdbk_fix ), means[i], means_fix ); // Q16
-#else
- snsq_fx[i] = L_add( L_mult( ( *p_dico++ ), cdbk_fix ), L_mult( means[i], means_fix ) ); // Q16
-#endif
move32();
}
@@ -93,11 +89,7 @@ static void sns_1st_dec_fx(
FOR( i = M / 2; i < M; i++ )
{
-#ifdef FIX_2254_IMPROV_COMPLEXITY_BE
snsq_fx[i] = L_mac( L_mult( ( *p_dico++ ), cdbk_fix ), means[i], means_fix ); /*Q16*/
-#else
- snsq_fx[i] = L_add( L_mult( ( *p_dico++ ), cdbk_fix ), L_mult( means[i], means_fix ) ); /*Q16*/
-#endif
move32();
}
diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c
index 7cb1297a7231e3a64544d95585a8f318af57eca4..bc819763bab4f78b7d0ae0d1205162b3cbdb1747 100644
--- a/lib_dec/ivas_spar_decoder_fx.c
+++ b/lib_dec/ivas_spar_decoder_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -246,8 +246,8 @@ ivas_error ivas_spar_dec_open_fx(
buffer_mode = TC_BUFFER_MODE_RENDERER;
move32();
- nchan_tc = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); /*Q0*/
- nchan_to_allocate = num_channels_internal; /*Q0*/
+ nchan_tc = ivas_dec_get_num_tc_channels_fx( st_ivas ); /*Q0*/
+ nchan_to_allocate = num_channels_internal; /*Q0*/
move16();
test();
@@ -288,9 +288,9 @@ ivas_error ivas_spar_dec_open_fx(
move16();
}
- granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), output_Fs );
+ granularity = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), output_Fs );
- IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -1525,9 +1525,9 @@ void ivas_spar_dec_set_render_map_fx(
move16();
set16_fx( hSpar->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME );
- ivas_jbm_dec_get_adapted_subframes( nCldfbTs, hSpar->subframe_nbslots, &hSpar->nb_subframes );
+ ivas_dec_get_adapted_subframes_fx( nCldfbTs, hSpar->subframe_nbslots, &hSpar->nb_subframes );
- /* copy also to tc buffer */
+ /* copy also to TC buffer */
/* only for non-combined formats and combinded formats w/o discrete objects */
test();
IF( !( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) )
@@ -1537,7 +1537,7 @@ void ivas_spar_dec_set_render_map_fx(
Copy( hSpar->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hSpar->nb_subframes ); /*Q0*/
}
- ivas_jbm_dec_get_md_map( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, 1, 0, DEFAULT_JBM_CLDFB_TIMESLOTS, hSpar->render_to_md_map );
+ ivas_dec_get_md_map_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, 1, 0, DEFAULT_JBM_CLDFB_TIMESLOTS, hSpar->render_to_md_map );
return;
}
diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c
index 64c4375a5be4edc008f1a579f6e20a65bfe9d35d..9bce073cdd0a4ed0de63902af745980eae919633 100644
--- a/lib_dec/ivas_spar_md_dec_fx.c
+++ b/lib_dec/ivas_spar_md_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -631,6 +631,11 @@ ivas_error ivas_spar_md_dec_init(
hMdDec->first_valid_frame = 1;
move16();
+ hMdDec->spar_md.res_ind = 0;
+ hMdDec->spar_md.prior_dyn_active_w_flag = 0;
+ move16();
+ move16();
+
return IVAS_ERR_OK;
}
diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h
index 15100622536e8915bf5662d9725672dac522a016..1f406c3380e16b4b8e0dd1d9e9937bfc629abd33 100644
--- a/lib_dec/ivas_stat_dec.h
+++ b/lib_dec/ivas_stat_dec.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -993,7 +993,7 @@ typedef struct ivas_masa_ism_data_structure
/*----------------------------------------------------------------------------------*
- * JBM structures
+ * TC buffer structure, stores decoder and renderer audio samples, and rendering parameters
*----------------------------------------------------------------------------------*/
typedef struct decoder_tc_buffer_structure
@@ -1001,16 +1001,15 @@ typedef struct decoder_tc_buffer_structure
Word32 *tc_buffer_old_fx[MAX_INTERN_CHANNELS]; /* TC audio samples not rendered in the previous frame */
Word32 *tc_buffer_fx; /* the buffer itself */
Word32 *tc_fx[MAX_INTERN_CHANNELS]; /* pointers into the buffer to the beginning of each tc */
- Word16 no_channels; /*Stores no of channels in tc_fx with values*/
- Word16 q_tc_fx;
- TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */
- Word16 nchan_transport_jbm; /* number of TCs after TC decoding */
- Word16 nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */
- Word16 nchan_buffer_full; /* number of channels to be fully buffered */
- Word16 n_samples_available; /* samples still available for rendering in the current frame */
- Word16 n_samples_buffered; /* full number of samples in the buffer (including spill to next frame) */
- Word16 n_samples_rendered; /* samples already rendered in the current frame */
- Word16 n_samples_granularity; /* render granularity */
+ Word16 q_tc_fx; /* TC channels Q-factor */
+ TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */
+ Word16 nchan_transport_rend; /* number of TCs provided to the renderer */
+ Word16 nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */
+ Word16 nchan_buffer_full; /* number of channels to be fully buffered */
+ Word16 n_samples_available; /* samples still available for rendering in the current frame */
+ Word16 n_samples_buffered; /* full number of samples in the buffer (including spill to next frame) */
+ Word16 n_samples_rendered; /* samples already rendered in the current frame */
+ Word16 n_samples_granularity; /* render granularity */
Word16 n_samples_flushed;
Word16 subframe_nbslots[MAX_JBM_SUBFRAMES_5MS];
Word16 nb_subframes;
@@ -1023,6 +1022,11 @@ typedef struct decoder_tc_buffer_structure
} DECODER_TC_BUFFER, *DECODER_TC_BUFFER_HANDLE;
+
+/*----------------------------------------------------------------------------------*
+ * JBM metadata structure
+ *----------------------------------------------------------------------------------*/
+
typedef struct jbm_metadata_structure
{
Word16 sf_write_idx;
@@ -1069,8 +1073,8 @@ typedef struct decoder_config_structure
Word16 Opt_aeid_on; /* indicates whether Acoustic environment option is used */
Word16 Opt_ObjEdit_on; /* indicates whether object editing option is used */
Word16 Opt_tsm; /* indicates whether time scaling modification is activated */
- IVAS_RENDER_FRAMESIZE render_framesize;
- Word16 Opt_delay_comp; /* flag indicating delay compensation active */
+ IVAS_RENDER_NUM_SUBFR render_num_subframes; /* renderer number of subframes */
+ Word16 Opt_delay_comp; /* flag indicating delay compensation active */
} DECODER_CONFIG, *DECODER_CONFIG_HANDLE;
@@ -1181,8 +1185,7 @@ typedef struct Decoder_Struct
ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; /* ISAR split binaural rendering handle */
BINAURAL_TD_OBJECT_RENDERER_HANDLE hTdRendHandles[MAX_HEAD_ROT_POSES - 1]; /* TD object renderer handles */
- /* JBM module */
- DECODER_TC_BUFFER_HANDLE hTcBuffer; /* JBM structure */
+ DECODER_TC_BUFFER_HANDLE hTcBuffer; /* transport channels (TC) structure */
JBM_METADATA_HANDLE hJbmMetadata; /* Structure for metadata buffering in JBM */
Word32 last_active_ivas_total_brate;
diff --git a/lib_dec/ivas_stereo_adapt_GR_dec_fx.c b/lib_dec/ivas_stereo_adapt_GR_dec_fx.c
index 57166fae4c34e72e6145b560345ef2c264385b84..064f317199632999e021d0d3960cc07ecbe0686c 100644
--- a/lib_dec/ivas_stereo_adapt_GR_dec_fx.c
+++ b/lib_dec/ivas_stereo_adapt_GR_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_stereo_cng_dec_fx.c b/lib_dec/ivas_stereo_cng_dec_fx.c
index d08b38852953f2d5dc6122556bd17b469c296921..bf09e23361b8a3e1055bf81da85661c33e50ba5f 100644
--- a/lib_dec/ivas_stereo_cng_dec_fx.c
+++ b/lib_dec/ivas_stereo_cng_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -119,9 +119,7 @@ static void stereo_dft_generate_comfort_noise_fx(
Word32 tmp32_1, tmp32_2;
Word16 q_div, q_sqrt1, q_sqrt2, q_sqrt, sqrt_res;
Word16 q_shift, q_shift_1, q_shift_2, min_q;
-#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE
Word16 tmp16, tmp_p, tmp_s;
-#endif
hFdCngCom = st->hFdCngDec->hFdCngCom;
push_wmops( "DFT_CNG" );
@@ -164,11 +162,7 @@ static void stereo_dft_generate_comfort_noise_fx(
}
ELSE
{
-#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE
hStereoDft->g_state_fx[b] = mac_r( L_mult( ONE_MINUS_A_GFILT_FX, extract_h( *pSideGain++ ) ), A_GFILT_FX, hStereoDft->g_state_fx[b] ); /* Q15 */
-#else
- hStereoDft->g_state_fx[b] = add( mult( ONE_MINUS_A_GFILT_FX, extract_h( *pSideGain++ ) ), mult( A_GFILT_FX, hStereoDft->g_state_fx[b] ) ); /* Q15 */
-#endif
move16();
}
@@ -195,21 +189,13 @@ static void stereo_dft_generate_comfort_noise_fx(
}
ELSE
{
-#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE
hStereoCng->cm_fx[b] = mac_r( L_mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), A_GFILT_FX, hStereoCng->cm_fx[b] ); /* Q15 */
-#else
- hStereoCng->cm_fx[b] = add( mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), mult( A_GFILT_FX, hStereoCng->cm_fx[b] ) ); /* Q15 */
-#endif
move16();
}
}
ELSE
{
-#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE
hStereoCng->cm_fx[b] = mac_r( L_mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), A_GFILT_FX, hStereoCng->cm_fx[b] ); /* Q15 */
-#else
- hStereoCng->cm_fx[b] = add( mult( ONE_MINUS_A_GFILT_FX, hStereoCng->coh_fx[b] ), mult( A_GFILT_FX, hStereoCng->cm_fx[b] ) ); /* Q15 */
-#endif
move16();
}
}
@@ -241,7 +227,6 @@ static void stereo_dft_generate_comfort_noise_fx(
}
LR_ratio = extract_h( tdm_ratio_tabl_fx[hStereoCng->last_tdm_idx] ); /* Q15 */
-#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE
tmp16 = shr( hStereoDft->g_state_fx[b], 2 );
tmp_p = add( ONE_IN_Q13, tmp16 );
tmp_s = sub( ONE_IN_Q13, tmp16 );
@@ -251,16 +236,6 @@ static void stereo_dft_generate_comfort_noise_fx(
L_mac( L_mult( tmp_p, tmp_p ), gamma, tmp16 ),
L_mac( L_mult( tmp_s, tmp_s ), gamma, tmp16 ),
&c_e );
-#else
- c = BASOP_Util_Divide3232_Scale(
- L_add( L_mult( add( ONE_IN_Q13, shr( hStereoDft->g_state_fx[b], 2 ) ),
- add( ONE_IN_Q13, shr( hStereoDft->g_state_fx[b], 2 ) ) ),
- L_shr( L_mult( gamma, gamma ), 4 ) ),
- L_add( L_mult( sub( ONE_IN_Q13, shr( hStereoDft->g_state_fx[b], 2 ) ),
- sub( ONE_IN_Q13, shr( hStereoDft->g_state_fx[b], 2 ) ) ),
- L_shr( L_mult( gamma, gamma ), 4 ) ),
- &c_e );
-#endif
q_sqrt = c_e;
move16();
sqrt_res = Sqrt16( mult( c, hStereoCng->cm_fx[b] ), &q_sqrt );
diff --git a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c
index 32321454c9df7b60a31ac24c550328c5483648b5..125063b3f3daafb5a5e6bd7ddd9a6ecd0a82385e 100644
--- a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c
+++ b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c
index 72527526a06700f007393df396a8c248fd2e1bb6..b578f52c30791786936a82cf59a8cd0380d7d339 100644
--- a/lib_dec/ivas_stereo_dft_dec_fx.c
+++ b/lib_dec/ivas_stereo_dft_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -3719,11 +3719,7 @@ void stereo_dft_dec_sid_coh_fx(
pred_fx = add( pred_fx, shl( mult( ( *pptr_fx++ ), cohBandq_fx[i] ), 2 ) ); /*q-13*/
}
/* Weighted intra/inter-frame prediction */
-#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE
pred_fx = mac_r( L_mult( alpha_fx, pred_fx ), sub( 32767, alpha_fx ), shr( coh_fx[b], 2 ) ); /*q-13*/
-#else
- pred_fx = add( mult( alpha_fx, pred_fx ), mult( sub( 32767, alpha_fx ), shr( coh_fx[b], 2 ) ) ); /*q-13*/
-#endif
/* Read residual index from bitstream */
IF( LT_16( *nb_bits, nr_of_sid_stereo_bits ) ) /* If the bit limit is reached, res_index = 0 is assumed for remaining indices */
{
@@ -3766,8 +3762,11 @@ void stereo_dft_dec_sid_coh_fx(
get_next_indice_fx( st, 1 );
( *nb_bits )++;
}
+
return;
}
+
+
void stereo_dft_dequantize_itd_fx(
Word16 *ind, /* Q0 */
Word32 *out_fx, /* Q15 */
@@ -3784,13 +3783,16 @@ void stereo_dft_dequantize_itd_fx(
{
itd = imult1616( -1, itd ); /* Q0 */
}
- assert( ( ABSVAL( itd ) <= STEREO_DFT_ITD_MAX ) && ( ABSVAL( itd ) >= STEREO_DFT_ITD_MIN ) );
+ assert( ( abs_s( itd ) <= STEREO_DFT_ITD_MAX ) && ( abs_s( itd ) >= STEREO_DFT_ITD_MIN ) );
/*Convert back @ fs*/
*out_fx = L_mult( itd, divide3232( output_Fs, STEREO_DFT_ITD_FS << 1 ) ); /*Q15*/
move32();
+
return;
}
+
+
/*-------------------------------------------------------------------------
* stereo_dft_dec_read_BS()
*
diff --git a/lib_dec/ivas_stereo_dft_plc_fx.c b/lib_dec/ivas_stereo_dft_plc_fx.c
index 5eb94868e0a346f88b119d725260002515377645..4ded8044f211e566a7ab650d2a8753b034ae9fff 100644
--- a/lib_dec/ivas_stereo_dft_plc_fx.c
+++ b/lib_dec/ivas_stereo_dft_plc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_stereo_eclvq_dec_fx.c b/lib_dec/ivas_stereo_eclvq_dec_fx.c
index 9d777c9b7bbd1d46ab705d89a8ad8ad1165e6cdc..f487d2f0c6383f7bca9254ca0cd400b75e5170cc 100644
--- a/lib_dec/ivas_stereo_eclvq_dec_fx.c
+++ b/lib_dec/ivas_stereo_eclvq_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_stereo_esf_dec_fx.c b/lib_dec/ivas_stereo_esf_dec_fx.c
index d4219f1e60464e7dbaf87c7effb4c814e18bc0ae..a438c3e5ccc5954b6038fb6327cce98e55cb35b0 100644
--- a/lib_dec/ivas_stereo_esf_dec_fx.c
+++ b/lib_dec/ivas_stereo_esf_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_stereo_ica_dec_fx.c b/lib_dec/ivas_stereo_ica_dec_fx.c
index b6bdb559b33b23b4e13fa4ddd440de7ee0de1f69..9345fccaebfca269ed67ca8ac538e835852c3991 100644
--- a/lib_dec/ivas_stereo_ica_dec_fx.c
+++ b/lib_dec/ivas_stereo_ica_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -193,11 +193,7 @@ void stereo_tca_dec_fx(
IF( currentNCShift != 0 )
{
-#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE
currentNCShift = mac_r( L_mult( 19660 /* 0.6 in Q15 */, prevNCShift ), 13106 /* 0.4 in Q15 */, currentNCShift ); /* Q0 */
-#else
- currentNCShift = add( mult( 19660 /* 0.6 in Q15 */, prevNCShift ), mult( 13106 /* 0.4 in Q15 */, currentNCShift ) ); /* Q0 */
-#endif
}
prevNCShift = hStereoTCA->interp_dec_prevNCShift; /* Q0 */
@@ -350,13 +346,10 @@ void stereo_tca_scale_R_channel_fx(
test();
IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_TD ) && EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
- Word64 local_value;
- // to be deleted next MR
- // hCPE->hStereoDftDmx->prevTargetGain *= 2.0f;
- // hCPE->hStereoDftDmx->prevTargetGain = min( hCPE->hStereoDftDmx->prevTargetGain, powf( 10, ( ( 1 << STEREO_BITS_TCA_GD ) - 1 ) * STEREO_TCA_GDSTEP + STEREO_TCA_GDMIN ) );
- local_value = W_shl( hCPE->hStereoDftDmx->prevTargetGain_fx, 1 ); /* Q29 */
- hCPE->hStereoDftDmx->prevTargetGain_fx = (Word32) min( local_value, MAX_TARGET_GAIN_Q29 ); /* Q29 */
- hCPE->hStereoDftDmx->targetGain_fx = ONE_IN_Q29; /* Q29 */
+ Word32 local_value;
+ local_value = L_shl( hCPE->hStereoDftDmx->prevTargetGain_fx, 1 ); /* Q29 */
+ hCPE->hStereoDftDmx->prevTargetGain_fx = L_min( local_value, MAX_TARGET_GAIN_Q29 ); /* Q29 */
+ hCPE->hStereoDftDmx->targetGain_fx = ONE_IN_Q29; /* Q29 */
move32();
flat_old = NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS ); /* Q0 */
diff --git a/lib_dec/ivas_stereo_icbwe_dec_fx.c b/lib_dec/ivas_stereo_icbwe_dec_fx.c
index 8cf565a5e5d6904a30e33fc3ab1dca27bcf7a038..1c51fc2d125f1a021b0e2ee2ca928a71f530f696 100644
--- a/lib_dec/ivas_stereo_icbwe_dec_fx.c
+++ b/lib_dec/ivas_stereo_icbwe_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -112,6 +112,12 @@ static Word16 FindScale(
}
+/*-------------------------------------------------------------------*
+ * stereo_icBWE_dec()
+ *
+ * Spatial mapping of reference to the non-reference channels in SHB
+ *-------------------------------------------------------------------*/
+
void stereo_icBWE_dec_fx(
CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
Word32 *synthRef_fx, /* i/o: Reference channel HB synthesis at output Fs Q11 */
@@ -150,6 +156,14 @@ void stereo_icBWE_dec_fx(
STEREO_ICBWE_DEC_HANDLE hStereoICBWE = hCPE->hStereoICBWE;
st = hCPE->hCoreCoder[0];
+#ifdef FIX_2367_REMOVE_CODE_ICBWE
+ if ( hCPE->hStereoDft != NULL )
+ {
+ hCPE->hStereoDft->td_gain_fx[0] = 1;
+ move32();
+ }
+
+#endif
/*--------------------------------------------------------------------*
* skip IC-BWE in case of mono DMX output *
* -------------------------------------------------------------------*/
@@ -251,6 +265,7 @@ void stereo_icBWE_dec_fx(
/*--------------------------------------------------------------------*
* IC-BWE *
* -------------------------------------------------------------------*/
+
test();
test();
test();
@@ -265,7 +280,6 @@ void stereo_icBWE_dec_fx(
return;
}
-
set16_fx( fb_synth_nonref_fx, 0, L_FRAME48k );
/* core switching reset */
@@ -408,7 +422,6 @@ void stereo_icBWE_dec_fx(
}
// hStereoICBWE->prevgsMapping = powf( 10, hStereoICBWE->prevgsMapping );
-
specMapping_fx = hStereoICBWE->prevSpecMapping_fx; // Q15
move16();
gsMapping_fx = hStereoICBWE->prevgsMapping_fx; // Q14
@@ -637,7 +650,6 @@ void stereo_icBWE_dec_fx(
}
/* generate 32kHz SHB synthesis from 12.8(16)kHz signal */
-
tmp = 31;
move16();
tmp = FindScale( shb_synth_nonref_fx, L_FRAME16k + L_SHB_LAHEAD, Q_syn_shb, tmp );
@@ -669,7 +681,6 @@ void stereo_icBWE_dec_fx(
alpha_fx = winSlope_fx; /* Q15 */
move16();
-
IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
ratio_L_fx = 16384; /* 0.5 in Q15 */
@@ -685,7 +696,6 @@ void stereo_icBWE_dec_fx(
move16();
IF( hStereoICBWE->refChanIndx_bwe == L_CH_INDX )
{
-
IF( GE_16( ratio_L_fx, 3276 /* 0.1 in Q15 */ ) )
{
tmp = mult_r( sub( 32767 /* 1.0 in Q15 */, ratio_L_fx ), sub( 32767 /* 1.0 in Q15 */, ratio_L_fx ) ); // Q15
@@ -775,8 +785,6 @@ void stereo_icBWE_dec_fx(
}
/* resample to output FS */
-
-
IF( EQ_32( st->output_Fs, 48000 /* Q0 */ ) )
{
tmp = 31;
@@ -829,7 +837,6 @@ void stereo_icBWE_dec_fx(
}
/* copy to outputHB and reset hb_synth values */
-
IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) )
{
ratio_L_fx = 16384; /* 1.0 in Q15 */
@@ -926,6 +933,7 @@ void stereo_icBWE_dec_fx(
return;
}
+
/*-------------------------------------------------------------------*
* stereo_icBWE_decproc()
*
@@ -1084,7 +1092,7 @@ void stereo_icBWE_decproc_fx(
move32();
BREAK;
}
- // memOffset for 16K 32K 48K are 15 30 45 respectively.camera
+ // memOffset for 16K 32K 48K are 15 30 45 respectively
}
ELSE
{
@@ -1172,7 +1180,7 @@ void stereo_icBWE_decproc_fx(
move16();
BREAK;
}
- // memOffset for 16K 32K 48K are 15 30 45 respectively.camera
+ // memOffset for 16K 32K 48K are 15 30 45 respectively
}
ELSE
{
@@ -1354,6 +1362,7 @@ void stereo_icBWE_decproc_fx(
return;
}
+
/*-------------------------------------------------------------------*
* stereo_icBWE_init_dec()
*
diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c
index d8c1ad18fc989a67a13eed14b9c1167384b32a47..d61e541e906141b3c00db8f462b35ef90029ca38 100644
--- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c
+++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -298,8 +298,19 @@ void stereo_mdct_core_dec_fx(
FOR( ch = 0; ch < nChannels; ch++ )
{
+#ifdef FIX_2382_COPY_AQ_IN_MCT
+ nSubframes[ch] = 1; /* Q0 */
+ move16();
+
+ if ( EQ_16( sts[ch]->core, TCX_10_CORE ) )
+ {
+ nSubframes[ch] = NB_DIV;
+ move16();
+ }
+#else
nSubframes[ch] = EQ_16( sts[ch]->core, TCX_10_CORE ) ? NB_DIV : 1; /* Q0 */
move16();
+#endif
FOR( k = 0; k < nSubframes[ch]; k++ )
{
@@ -371,10 +382,36 @@ void stereo_mdct_core_dec_fx(
}
}
+#ifdef FIX_2397_COPY_AQ_MDCT_CORE_BFI
+ IF( !bfi )
+ {
+#ifdef FIX_2352_COPY_AQ_IN_TCX
+ FOR( ch = 0; ch < nChannels; ch++ )
+#else
+ FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
+#endif
+ {
+#ifdef FIX_2352_COPY_AQ_IN_TCX
+ Copy_Scale_sig_16_32_DEPREC( Aq_fx[ch], Aq_fx_32[ch], i_mult( nSubframes[ch], M ), sub( Q16, Q12 ) ); /* Q16 */
+#else
+ Copy_Scale_sig_16_32_DEPREC( Aq_fx[ch], Aq_fx_32[ch], ( NB_SUBFR16k + 1 ) * ( M + 1 ), sub( Q16, Q12 ) ); /* Q16 */
+#endif
+ }
+ }
+#else
+#ifdef FIX_2352_COPY_AQ_IN_TCX
+ FOR( ch = 0; ch < nChannels; ch++ )
+#else
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
+#endif
{
+#ifdef FIX_2352_COPY_AQ_IN_TCX
+ Copy_Scale_sig_16_32_DEPREC( Aq_fx[ch], Aq_fx_32[ch], nSubframes[ch] * M, sub( Q16, Q12 ) ); /* Q16 */
+#else
Copy_Scale_sig_16_32_DEPREC( Aq_fx[ch], Aq_fx_32[ch], ( NB_SUBFR16k + 1 ) * ( M + 1 ), sub( Q16, Q12 ) ); /* Q16 */
+#endif
}
+#endif
/*--------------------------------------------------------------------------------*
* Stereo processing
diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c
index 6ea211cb25b102d9a607a14cd9ea1247e6d9e031..654f2bd13ac191aa1f35845cc986f408926661c3 100644
--- a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c
+++ b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c
index e8fddd58cf10bbf11eb12aaebff10f02bacceddc..63e9e792ed444a85b2be0c356976e8f8d2de7053 100644
--- a/lib_dec/ivas_stereo_switching_dec_fx.c
+++ b/lib_dec/ivas_stereo_switching_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_stereo_td_dec_fx.c b/lib_dec/ivas_stereo_td_dec_fx.c
index 0c91bd3c471142d49a89c3a963a4aaaf4929b5a4..39b861ace07c42a23c0b0f5b5607a545571e2cdb 100644
--- a/lib_dec/ivas_stereo_td_dec_fx.c
+++ b/lib_dec/ivas_stereo_td_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_svd_dec_fx.c b/lib_dec/ivas_svd_dec_fx.c
index b7a0eaedfdaf03b493e01d1aebc78ff234b706be..422617f7a9d8361adb36d166c442d2adf62982b2 100755
--- a/lib_dec/ivas_svd_dec_fx.c
+++ b/lib_dec/ivas_svd_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c
index 3b4cc87f3c1231ef6de92f19f9e033863d21b30a..a3feb62ff24c407342543da582dee56a38670a22 100644
--- a/lib_dec/ivas_tcx_core_dec_fx.c
+++ b/lib_dec/ivas_tcx_core_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -753,13 +753,16 @@ void stereo_tcx_core_dec_fx(
IF( st->hTdCngDec != NULL )
{
- cng_params_upd_ivas_fx( lsptmp, res, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth );
+ cng_params_upd_fx( lsptmp, res, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx,
+ st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth );
}
}
ELSE IF( st->hTdCngDec != NULL )
{
- cng_params_upd_ivas_fx( &lsp_fx[M], st->old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth );
+ cng_params_upd_fx( &lsp_fx[M], st->old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx,
+ st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth );
}
+
/* Set 16k LSP flag for CNG buffer */
// st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = ( st->L_frame == L_FRAME ? 0 : 1 );
IF( EQ_16( st->L_frame, L_FRAME ) )
diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c
index 8ed51cdab548697726070c48fe96262991bc444a..6273cd1862199ab438f2c233c8d79712b71dc335 100644
--- a/lib_dec/ivas_td_low_rate_dec_fx.c
+++ b/lib_dec/ivas_td_low_rate_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -103,10 +103,6 @@ void tdm_low_rate_dec_fx(
attack_flag = 0;
move16();
- move16();
- move16();
- move16();
- move16();
/*--------------------------------------------------------------------------------------*
* GSC decoder
*--------------------------------------------------------------------------------------*/
@@ -152,12 +148,16 @@ void tdm_low_rate_dec_fx(
Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, &exc[0], NULL, st->hGSCDec->last_exc_dct_in_fx,
L_FRAME, L_FRAME * HIBND_ACB_L_FAC, L_shl( st->lp_gainc_fx, 13 /* Q3 -> Q16*/ ), &( st->Q_exc ), st->Q_subfr, NULL, 0, st->coder_type );
}
+
/*----------------------------------------------------------------------*
* Remove potential pre-echo in case an onset has been detected
*----------------------------------------------------------------------*/
+#ifdef FIX_1904_HARM_GSC_ENC
+ pre_echo_att_fx( &hGSCDec->Last_frame_ener_fx, exc, attack_flag, st->Q_exc, st->last_coder_type, st->L_frame, 0 );
+#else
pre_echo_att_fx( &hGSCDec->Last_frame_ener_fx, exc, attack_flag, st->Q_exc, st->last_coder_type, st->L_frame );
-
+#endif
/*--------------------------------------------------------------------------------------*
* Update BWE excitation
@@ -248,9 +248,6 @@ void decod_gen_2sbfr_fx(
error = 0;
move16();
- move16();
- move16();
- move16();
/*------------------------------------------------------------------*
* ACELP subframe loop
*------------------------------------------------------------------*/
@@ -270,12 +267,13 @@ void decod_gen_2sbfr_fx(
test();
IF( !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) && !( st->tdm_LRTD_flag ) ) )
{
- tbe_celp_exc( L_frame, i_subfr, T0, T0_frac, &error, bwe_exc );
+ tbe_celp_exc_fx( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, 0 );
}
/*--------------------------------------------------------------*
* Find the adaptive codebook vector
*--------------------------------------------------------------*/
+
IF( st->element_mode != EVS_MONO )
{
pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], T0, T0_frac, 2 * L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
@@ -295,7 +293,7 @@ void decod_gen_2sbfr_fx(
* Innovation decoding
*--------------------------------------------------------------*/
- inov_decode_ivas_fx( st, st->core_brate, 0, L_frame, sharpFlag, i_subfr, p_Aq, st->tilt_code_fx, *pt_pitch, code, 2 * L_SUBFR );
+ inov_decode_fx( st, st->core_brate, 0, L_frame, sharpFlag, i_subfr, p_Aq, st->tilt_code_fx, *pt_pitch, code, 2 * L_SUBFR );
/*--------------------------------------------------------------*
* Gain decoding
@@ -303,12 +301,13 @@ void decod_gen_2sbfr_fx(
*--------------------------------------------------------------*/
gain_dec_lbr_fx( st, GENERIC, i_subfr, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, gc_mem, gp_mem, 2 * L_SUBFR );
- st->tilt_code_fx = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, st->Q_exc, 2 * L_SUBFR, 0 ); /* Q15 */
+
+ st->tilt_code_fx = est_tilt_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, st->Q_exc, 2 * L_SUBFR ); /* Q15 */
move16();
/* update LP filtered gains for the case of frame erasures */
- lp_gain_updt_ivas_fx( i_subfr, gain_pit, norm_gain_code, &st->lp_gainp_fx, &st->lp_gainc_fx, L_frame );
- lp_gain_updt_ivas_fx( add( i_subfr, L_SUBFR ), gain_pit, norm_gain_code, &st->lp_gainp_fx, &st->lp_gainc_fx, L_frame );
+ lp_gain_updt_fx( st->element_mode, i_subfr, gain_pit, norm_gain_code, &st->lp_gainp_fx, &st->lp_gainc_fx, L_frame );
+ lp_gain_updt_fx( st->element_mode, add( i_subfr, L_SUBFR ), gain_pit, norm_gain_code, &st->lp_gainp_fx, &st->lp_gainc_fx, L_frame );
/*----------------------------------------------------------------------*
* Find the total excitation
diff --git a/lib_dec/jbm_jb4_circularbuffer.h b/lib_dec/jbm_jb4_circularbuffer.h
index 36325c8c71942843674cb0388f01b553ab4cad6f..4817f16497928d81b274c7d7664cb884fde39a2b 100644
--- a/lib_dec/jbm_jb4_circularbuffer.h
+++ b/lib_dec/jbm_jb4_circularbuffer.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/jbm_jb4_circularbuffer_fx.c b/lib_dec/jbm_jb4_circularbuffer_fx.c
index 94341968436e8f28bf43ba8f4136a39b20062476..b26e8c49ed68bb1b0a947415f3fa8cbd510ab1fd 100644
--- a/lib_dec/jbm_jb4_circularbuffer_fx.c
+++ b/lib_dec/jbm_jb4_circularbuffer_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/jbm_jb4_inputbuffer.h b/lib_dec/jbm_jb4_inputbuffer.h
index 93174a08284b532b449f6bef2d05fe7c730e1dbe..efd782488481a7dd32c6931518c50d40ebc11825 100644
--- a/lib_dec/jbm_jb4_inputbuffer.h
+++ b/lib_dec/jbm_jb4_inputbuffer.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/jbm_jb4_inputbuffer_fx.c b/lib_dec/jbm_jb4_inputbuffer_fx.c
index 3e16f8ef5d415d17ee13950bee113812a37f8168..9dc8130228224d55546cd976c8a42308a82e656f 100644
--- a/lib_dec/jbm_jb4_inputbuffer_fx.c
+++ b/lib_dec/jbm_jb4_inputbuffer_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/jbm_jb4_jmf.h b/lib_dec/jbm_jb4_jmf.h
index 255c8a39a3025264bc2bffb1d84fee3e2e583f62..a55991780460d49e2791a182bbd7b1e1d7321888 100644
--- a/lib_dec/jbm_jb4_jmf.h
+++ b/lib_dec/jbm_jb4_jmf.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/jbm_jb4_jmf_fx.c b/lib_dec/jbm_jb4_jmf_fx.c
index 086c76e5a1640493e37b0e659e9ec997abf5e7f0..ba17c5cd804ffd1880655c0d59d0a232b4e793f5 100644
--- a/lib_dec/jbm_jb4_jmf_fx.c
+++ b/lib_dec/jbm_jb4_jmf_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/jbm_jb4sb.h b/lib_dec/jbm_jb4sb.h
index f579a5f25ef2104de71a7a53a5ca718550cffbbb..ced9edadbf025e6f28d8793405772e372ff71093 100644
--- a/lib_dec/jbm_jb4sb.h
+++ b/lib_dec/jbm_jb4sb.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/jbm_jb4sb_fx.c b/lib_dec/jbm_jb4sb_fx.c
index c4b33817c3cac3db35d8b7691da69b7343042c83..e93e4f7cfd5a2b650645ba6f0c1a9f4b472dbf8f 100644
--- a/lib_dec/jbm_jb4sb_fx.c
+++ b/lib_dec/jbm_jb4sb_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/jbm_pcmdsp_apa.h b/lib_dec/jbm_pcmdsp_apa.h
index 2fdc1f6253a48cdf75526760aba33b0f02b40a2c..220d301a7d74300aa71fbd6e76df17c9894c5dfa 100644
--- a/lib_dec/jbm_pcmdsp_apa.h
+++ b/lib_dec/jbm_pcmdsp_apa.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/jbm_pcmdsp_apa_fx.c b/lib_dec/jbm_pcmdsp_apa_fx.c
index 63cbe2e1e1771d489cbe22ac8dd7b16b5f1f7a49..27fc1afa0672ebdc42f4d25a60e743f87e891885 100644
--- a/lib_dec/jbm_pcmdsp_apa_fx.c
+++ b/lib_dec/jbm_pcmdsp_apa_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -690,11 +690,7 @@ UWord8 apa_exec_fx(
)
{
UWord16 i;
-#ifdef FIX_1435_MOVE_STEREO_PANNING
Word16 frm_in[APA_BUF_PER_CHANNEL]; /* NOTE: this buffer could be smaller if alocated dynamically based on the actual sampling rate */
-#else
- Word16 frm_in[CPE_CHANNELS * APA_BUF / APA_MAX_NUM_CHANNELS]; /* in EVS, 2 output channels */ /* NOTE: this buffer could be smaller if alocated dynamically based on the actual sampling rate and number of channels */
-#endif
UWord16 l_frm_out;
Word16 l_rem;
Word32 dl_scaled, dl_copied, l_frm_out_target;
diff --git a/lib_dec/jbm_pcmdsp_fifo.h b/lib_dec/jbm_pcmdsp_fifo.h
index 80a3ddb900a73fdf8c6ee86a3e27e99c5094e892..77e9b655ca4ecc2dd45caa43eb878aaa039058f9 100644
--- a/lib_dec/jbm_pcmdsp_fifo.h
+++ b/lib_dec/jbm_pcmdsp_fifo.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/jbm_pcmdsp_similarityestimation.h b/lib_dec/jbm_pcmdsp_similarityestimation.h
index 5b3b6ac61335005145ad9b6ca64505c4467f00a0..5ab60f3bea9a13cbe5731d451b4df963af6d5181 100644
--- a/lib_dec/jbm_pcmdsp_similarityestimation.h
+++ b/lib_dec/jbm_pcmdsp_similarityestimation.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c
index f6a15302a6eea25b4a76cdfc1e27ce6c31853200..16fd9193f328427f11517cc28cfb20f69d86f89f 100644
--- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c
+++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/jbm_pcmdsp_window.h b/lib_dec/jbm_pcmdsp_window.h
index 2d0d0be0b193cb12ff62adbd2aa275053f4d602d..c18d11ec7e06412fe3f9e595845bc1c453c7fbd3 100644
--- a/lib_dec/jbm_pcmdsp_window.h
+++ b/lib_dec/jbm_pcmdsp_window.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/jbm_pcmdsp_window_fx.c b/lib_dec/jbm_pcmdsp_window_fx.c
index 62565ba526d88fda3f8644d41ee0804bd748d3f9..73faf37e21824d3693b98f462c10f5d2d4e3367d 100644
--- a/lib_dec/jbm_pcmdsp_window_fx.c
+++ b/lib_dec/jbm_pcmdsp_window_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h
index 58c33c92d81582f3048d2de103d6f762482afa12..d89bd37c28613a70e06089f7d33ad7c0061cd3f9 100644
--- a/lib_dec/lib_dec.h
+++ b/lib_dec/lib_dec.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -112,7 +112,7 @@ ivas_error IVAS_DEC_Configure(
IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */
const UWord32 sampleRate, /* i : output sampling frequency */
const IVAS_AUDIO_CONFIG outputConfig, /* i : output configuration */
- const IVAS_RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */
+ const IVAS_RENDER_NUM_SUBFR render_num_subframes, /* i : rendering number of subframes */
const bool customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */
const bool hrtfReaderEnabled, /* i : enable HRTF binary file input */
const bool enableHeadRotation, /* i : enable head rotation for binaural output */
@@ -352,14 +352,14 @@ ivas_error IVAS_DEC_EnableSplitRendering(
IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */
);
-ivas_error IVAS_DEC_SetRenderFramesize(
+ivas_error IVAS_DEC_SetRenderNumSubfr(
IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */
- const IVAS_RENDER_FRAMESIZE render_framesize /* i : render framesize */
+ const IVAS_RENDER_NUM_SUBFR render_num_subframes /* i : rendering number of subframes */
);
-ivas_error IVAS_DEC_GetRenderFramesize(
+ivas_error IVAS_DEC_GetRenderNumSubfr(
IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */
- IVAS_RENDER_FRAMESIZE *render_framesize /* o : render framesize */
+ IVAS_RENDER_NUM_SUBFR *render_num_subframes /* o : rendering number of subframes */
);
ivas_error IVAS_DEC_GetRenderFramesizeSamples(
@@ -372,14 +372,9 @@ ivas_error IVAS_DEC_GetReferencesUpdateFrequency(
Word16 *update_frequency /* o : update frequency Q0 */
);
-ivas_error IVAS_DEC_GetNumOrientationSubframes(
- IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */
- Word16 *num_subframes /* o : render framesize */
-);
-
ivas_error IVAS_DEC_GetRenderFramesizeMs(
IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */
- UWord32 *render_framesize /* o : render framesize in samples Q0 */
+ UWord32 *render_framesize_ms /* o : render framesize in ms Q0 */
);
diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c
index 0bc064d05f677a71a64d3b0f18c1f4f242dad926..fbd748b84eda2ba57872d0af37e58ae1366edf26 100644
--- a/lib_dec/lib_dec_fx.c
+++ b/lib_dec/lib_dec_fx.c
@@ -1,6 +1,6 @@
-/******************************************************************************************************
+/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -116,7 +116,7 @@ static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas );
static ivas_error ivas_dec_init_split_rend( Decoder_Struct *st_ivas );
static ivas_error ivas_create_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out );
static void ivas_destroy_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out );
-static Word16 get_render_frame_size_ms( IVAS_RENDER_FRAMESIZE render_framesize );
+static Word16 get_render_frame_size_ms( const IVAS_RENDER_NUM_SUBFR render_num_subframes );
static Word16 get_render_frame_size_samples( const DECODER_CONFIG_HANDLE hDecoderConfig );
static Word16 ivas_dec_split_rend_cldfb_in( const RENDERER_TYPE renderer_type );
static void update_voip_rendered20ms( IVAS_DEC_HANDLE hIvasDec, const Word16 nSamplesRendered );
@@ -232,43 +232,41 @@ ivas_error IVAS_DEC_Open(
move16();
/* set high-level parameters */
+ st_ivas->codec_mode = 0; /* unknown before first frame */
+ st_ivas->transport_config = IVAS_AUDIO_CONFIG_INVALID;
+ st_ivas->intern_config = IVAS_AUDIO_CONFIG_INVALID;
+ st_ivas->writeFECoffset = 0;
+ st_ivas->sba_analysis_order = 0; /* not really used in EVS mode, but initialize here to fix MSAN complaint */
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+
IF( EQ_16( mode, IVAS_DEC_MODE_EVS ) )
{
- st_ivas->codec_mode = 0; /* unknown before first frame */
st_ivas->element_mode_init = EVS_MONO;
st_ivas->ivas_format = MONO_FORMAT;
- st_ivas->transport_config = IVAS_AUDIO_CONFIG_INVALID;
- st_ivas->intern_config = IVAS_AUDIO_CONFIG_INVALID;
- st_ivas->writeFECoffset = 0;
hIvasDec->hasDecodedFirstGoodFrame = true; /* Functionality to suppress output for initial lost frames is disabled in EVS operation */
move16();
move16();
move16();
- move16();
- move16();
- move16();
- move16();
return IVAS_ERR_OK;
}
ELSE IF( EQ_16( mode, IVAS_DEC_MODE_IVAS ) )
{
- st_ivas->codec_mode = 0; /* unknown before first frame */
st_ivas->element_mode_init = -1;
st_ivas->ivas_format = UNDEFINED_FORMAT;
- st_ivas->transport_config = IVAS_AUDIO_CONFIG_INVALID;
- st_ivas->intern_config = IVAS_AUDIO_CONFIG_INVALID;
st_ivas->renderer_type = RENDERER_DISABLE;
st_ivas->ini_frame = 0;
st_ivas->ini_active_frame = 0;
- st_ivas->writeFECoffset = 0;
st_ivas->ism_mode = ISM_MODE_NONE;
st_ivas->mc_mode = MC_MODE_NONE;
st_ivas->sba_order = 0;
st_ivas->sba_planar = 0;
- st_ivas->sba_analysis_order = 0;
move16();
move16();
@@ -279,11 +277,6 @@ ivas_error IVAS_DEC_Open(
move16();
move16();
move16();
- move16();
- move16();
- move16();
- move16();
- move16();
return IVAS_ERR_OK;
}
@@ -494,23 +487,23 @@ static ivas_error create_flush_buffer_fx(
*---------------------------------------------------------------------*/
ivas_error IVAS_DEC_Configure(
- IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */
- const UWord32 sampleRate, /* i : output sampling frequency */
- const IVAS_AUDIO_CONFIG outputConfig, /* i : output configuration */
- const IVAS_RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */
- const bool customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */
- const bool hrtfReaderEnabled, /* i : enable HRTF binary file input */
- const bool enableHeadRotation, /* i : enable head rotation for binaural output */
- const bool enableExternalOrientation, /* i : enable external orientations */
- const IVAS_HEAD_ORIENT_TRK_T orientation_tracking, /* i : head orientation tracking type */
- const bool renderConfigEnabled, /* i : enable Renderer config. file for binaural output */
- const IVAS_ROOM_SIZE_T roomSize, /* i : room size selector for reverb */
- const bool non_diegetic_pan_enabled, /* i : enabled diegetic panning */
- const Word16 non_diegetic_pan_gain_fx, /* i : non diegetic panning gain */
- const bool dpidEnabled, /* i : enable directivity pattern option */
- const UWord16 acousticEnvironmentId, /* i : Acoustic environment ID */
- const bool objEditEnabled, /* i : enable object editing */
- const bool delayCompensationEnabled /* i : enable delay compensation */
+ IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */
+ const UWord32 sampleRate, /* i : output sampling frequency */
+ const IVAS_AUDIO_CONFIG outputConfig, /* i : output configuration */
+ const IVAS_RENDER_NUM_SUBFR render_num_subframes, /* i : rendering number of subframes */
+ const bool customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */
+ const bool hrtfReaderEnabled, /* i : enable HRTF binary file input */
+ const bool enableHeadRotation, /* i : enable head rotation for binaural output */
+ const bool enableExternalOrientation, /* i : enable external orientations */
+ const IVAS_HEAD_ORIENT_TRK_T orientation_tracking, /* i : head orientation tracking type */
+ const bool renderConfigEnabled, /* i : enable Renderer config. file for binaural output */
+ const IVAS_ROOM_SIZE_T roomSize, /* i : room size selector for reverb */
+ const bool non_diegetic_pan_enabled, /* i : enabled diegetic panning */
+ const Word16 non_diegetic_pan_gain_fx, /* i : non diegetic panning gain */
+ const bool dpidEnabled, /* i : enable directivity pattern option */
+ const UWord16 acousticEnvironmentId, /* i : Acoustic environment ID */
+ const bool objEditEnabled, /* i : enable object editing */
+ const bool delayCompensationEnabled /* i : enable delay compensation */
)
{
Decoder_Struct *st_ivas;
@@ -614,18 +607,24 @@ ivas_error IVAS_DEC_Configure(
move16();
move16();
- IF( EQ_16( renderFramesize, IVAS_RENDER_FRAMESIZE_UNKNOWN ) )
+ IF( EQ_16( outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
+ {
+ hDecoderConfig->Opt_Headrotation = 1;
+ move16();
+ }
+
+ IF( EQ_16( render_num_subframes, IVAS_RENDER_NUM_SUBFR_UNKNOWN ) )
{
return IVAS_ERR_WRONG_PARAMS;
}
IF( EQ_16( outputConfig, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
- hDecoderConfig->render_framesize = IVAS_RENDER_FRAMESIZE_20MS;
+ hDecoderConfig->render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS;
}
ELSE
{
- hDecoderConfig->render_framesize = renderFramesize;
+ hDecoderConfig->render_num_subframes = render_num_subframes;
}
move16();
@@ -679,7 +678,7 @@ ivas_error IVAS_DEC_EnableSplitRendering(
hDecoderConfig->Opt_Headrotation = 1;
move16();
- hDecoderConfig->render_framesize = IVAS_RENDER_FRAMESIZE_20MS;
+ hDecoderConfig->render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS;
move32();
return IVAS_ERR_OK;
@@ -692,35 +691,23 @@ ivas_error IVAS_DEC_EnableSplitRendering(
* Get render framesize in ms
*---------------------------------------------------------------------*/
+/*! r: render framesize in ms */
static Word16 get_render_frame_size_ms(
- const IVAS_RENDER_FRAMESIZE render_framesize )
+ const IVAS_RENDER_NUM_SUBFR render_num_subframes )
{
- IF( EQ_16( render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) )
- {
- return ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) );
- }
- ELSE IF( EQ_16( render_framesize, IVAS_RENDER_FRAMESIZE_10MS ) )
- {
- return ( ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) << 1 );
- }
- ELSE IF( EQ_16( render_framesize, IVAS_RENDER_FRAMESIZE_20MS ) )
- {
- return ( ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) << 2 );
- }
-
- return 0;
+ return (int16_t) ( render_num_subframes * ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) );
}
/*---------------------------------------------------------------------*
- * IVAS_DEC_SetRenderFramesize( )
+ * IVAS_DEC_SetRenderNumSubfr( )
*
- * Set render framesize
+ * Set number of rendering subrames
*---------------------------------------------------------------------*/
-ivas_error IVAS_DEC_SetRenderFramesize(
- IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */
- const IVAS_RENDER_FRAMESIZE render_framesize /* i : render framesize */
+ivas_error IVAS_DEC_SetRenderNumSubfr(
+ IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */
+ const IVAS_RENDER_NUM_SUBFR render_num_subframes /* i : renderer number of subframes */
)
{
test();
@@ -730,18 +717,18 @@ ivas_error IVAS_DEC_SetRenderFramesize(
return IVAS_ERR_UNEXPECTED_NULL_POINTER;
}
- hIvasDec->st_ivas->hDecoderConfig->render_framesize = render_framesize;
+ hIvasDec->st_ivas->hDecoderConfig->render_num_subframes = render_num_subframes;
move16();
IF( hIvasDec->st_ivas->hExtOrientationData != NULL )
{
- hIvasDec->st_ivas->hExtOrientationData->num_subframes = (Word16) render_framesize;
+ hIvasDec->st_ivas->hExtOrientationData->num_subframes = (Word16) render_num_subframes;
move16();
}
IF( hIvasDec->st_ivas->hCombinedOrientationData != NULL )
{
- hIvasDec->st_ivas->hCombinedOrientationData->num_subframes = (Word16) render_framesize;
+ hIvasDec->st_ivas->hCombinedOrientationData->num_subframes = (Word16) render_num_subframes;
move16();
}
@@ -750,24 +737,24 @@ ivas_error IVAS_DEC_SetRenderFramesize(
/*---------------------------------------------------------------------*
- * IVAS_DEC_GetGetRenderFramesize( )
+ * IVAS_DEC_GetRenderNumSubfr( )
*
- * Get render framesize
+ * Get number of rendering subframes
*---------------------------------------------------------------------*/
-ivas_error IVAS_DEC_GetRenderFramesize(
- IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */
- IVAS_RENDER_FRAMESIZE *render_framesize /* o : render framesize */
+ivas_error IVAS_DEC_GetRenderNumSubfr(
+ IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */
+ IVAS_RENDER_NUM_SUBFR *render_num_subframes /* o : rendering number of subframes */
)
{
test();
test();
- IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL || render_framesize == NULL )
+ IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL || render_num_subframes == NULL )
{
return IVAS_ERR_UNEXPECTED_NULL_POINTER;
}
- *render_framesize = hIvasDec->st_ivas->hDecoderConfig->render_framesize;
+ *render_num_subframes = hIvasDec->st_ivas->hDecoderConfig->render_num_subframes;
move16();
return IVAS_ERR_OK;
@@ -788,15 +775,15 @@ static Word16 get_render_frame_size_samples(
tmp = extract_l( Mpy_32_16_1( hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) );
- IF( EQ_16( hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) )
+ IF( EQ_16( hDecoderConfig->render_num_subframes, IVAS_RENDER_NUM_SUBFR_5MS ) )
{
/* correct value already in tmp */
}
- ELSE IF( EQ_16( hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_10MS ) )
+ ELSE IF( EQ_16( hDecoderConfig->render_num_subframes, IVAS_RENDER_NUM_SUBFR_10MS ) )
{
tmp = shl( tmp, 1 );
}
- ELSE IF( EQ_16( hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_20MS ) )
+ ELSE IF( EQ_16( hDecoderConfig->render_num_subframes, IVAS_RENDER_NUM_SUBFR_20MS ) )
{
tmp = shl( tmp, 2 );
}
@@ -810,7 +797,7 @@ static Word16 get_render_frame_size_samples(
/*---------------------------------------------------------------------*
- * IVAS_DEC_GetGetRenderFramesizeSamples( )
+ * IVAS_DEC_GetRenderFramesizeSamples( )
*
* Get render framesize in samples
*---------------------------------------------------------------------*/
@@ -852,7 +839,7 @@ ivas_error IVAS_DEC_GetRenderFramesizeMs(
return IVAS_ERR_UNEXPECTED_NULL_POINTER;
}
- *render_framesize = get_render_frame_size_ms( hIvasDec->st_ivas->hDecoderConfig->render_framesize );
+ *render_framesize = get_render_frame_size_ms( hIvasDec->st_ivas->hDecoderConfig->render_num_subframes );
move32();
return IVAS_ERR_OK;
@@ -877,17 +864,17 @@ ivas_error IVAS_DEC_GetReferencesUpdateFrequency(
return IVAS_ERR_UNEXPECTED_NULL_POINTER;
}
- IF( EQ_16( hIvasDec->st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) )
+ IF( EQ_16( hIvasDec->st_ivas->hDecoderConfig->render_num_subframes, IVAS_RENDER_NUM_SUBFR_5MS ) )
{
*update_frequency = IVAS_MAX_PARAM_SPATIAL_SUBFRAMES;
move16();
}
- ELSE IF( EQ_16( hIvasDec->st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_10MS ) )
+ ELSE IF( EQ_16( hIvasDec->st_ivas->hDecoderConfig->render_num_subframes, IVAS_RENDER_NUM_SUBFR_10MS ) )
{
*update_frequency = IVAS_MAX_PARAM_SPATIAL_SUBFRAMES >> 1;
move16();
}
- ELSE IF( EQ_16( hIvasDec->st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_20MS ) )
+ ELSE IF( EQ_16( hIvasDec->st_ivas->hDecoderConfig->render_num_subframes, IVAS_RENDER_NUM_SUBFR_20MS ) )
{
*update_frequency = IVAS_MAX_PARAM_SPATIAL_SUBFRAMES >> 2;
move16();
@@ -896,30 +883,6 @@ ivas_error IVAS_DEC_GetReferencesUpdateFrequency(
return IVAS_ERR_OK;
}
-/*---------------------------------------------------------------------*
- * IVAS_DEC_GetGetNumOrientationSubframes( )
- *
- * Get the number of subframes for head/external orientation per render frame
- *---------------------------------------------------------------------*/
-
-ivas_error IVAS_DEC_GetNumOrientationSubframes(
- IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */
- Word16 *num_subframes /* o : render framesize */
-)
-{
- test();
- test();
- IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL || num_subframes == NULL )
- {
- return IVAS_ERR_UNEXPECTED_NULL_POINTER;
- }
-
- *num_subframes = (Word16) hIvasDec->st_ivas->hDecoderConfig->render_framesize;
- move16();
-
- return IVAS_ERR_OK;
-}
-
/*---------------------------------------------------------------------*
* IVAS_DEC_EnableVoIP( )
@@ -1150,12 +1113,12 @@ static Word16 isar_get_frame_size(
test();
test();
- IF( NE_32( st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_20MS ) &&
+ IF( NE_32( st_ivas->hDecoderConfig->render_num_subframes, IVAS_RENDER_NUM_SUBFR_20MS ) &&
( EQ_32( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ||
EQ_32( st_ivas->hRenderConfig->split_rend_config.dof, 0 ) ) )
{
nSamplesPerChannel = extract_l( Mpy_32_16_1( output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) );
- nSamplesPerChannel = imult1616( nSamplesPerChannel, st_ivas->hDecoderConfig->render_framesize );
+ nSamplesPerChannel = imult1616( nSamplesPerChannel, st_ivas->hDecoderConfig->render_num_subframes );
}
ELSE
{
@@ -1523,7 +1486,7 @@ ivas_error IVAS_DEC_GetSamplesRenderer(
}
/* render IVAS frames directly to the output buffer */
- IF( ( error = ivas_jbm_dec_render_fx( st_ivas, sub( nSamplesAsked, nSamplesRendered ), &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_dec_render_fx( st_ivas, sub( nSamplesAsked, nSamplesRendered ), &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1624,16 +1587,10 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream(
{
scale_sig32( p_head_pose_buf[i], numSamplesPerChannelToOutput, sub( Q11, Q_out[i] ) ); // Q11
}
- IF( EQ_32( st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) )
- {
+
#ifndef DISABLE_LIMITER
- ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 );
+ ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 );
#endif
- }
- ELSE
- {
- ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToOutput, st_ivas->BER_detect, Q11 );
- }
ivas_syn_output_fx( p_head_pose_buf, Q11, numSamplesPerChannelToOutput, st_ivas->hDecoderConfig->nchan_out, pcmBuf_out );
}
@@ -1658,18 +1615,7 @@ static ivas_error ivas_dec_setup_all(
IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) )
{
-#ifdef FIX_1435_MOVE_STEREO_PANNING
*nTransportChannels = 1;
-#else
- IF( EQ_16( (Word16) hIvasDec->st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) )
- {
- *nTransportChannels = MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN;
- }
- ELSE
- {
- *nTransportChannels = 1;
- }
-#endif
move16();
}
ELSE
@@ -1704,7 +1650,7 @@ static ivas_error ivas_dec_setup_all(
}
}
- *nTransportChannels = (UWord8) st_ivas->hTcBuffer->nchan_transport_jbm;
+ *nTransportChannels = (UWord8) st_ivas->hTcBuffer->nchan_transport_rend;
move16();
/*-----------------------------------------------------------------*
@@ -2085,7 +2031,7 @@ ivas_error IVAS_DEC_GetMasaMetadata(
IF( getFromJbmBuffer )
{
- ivas_jbm_masa_sf_to_sf_map( hIvasDec->st_ivas );
+ ivas_jbm_masa_sf_to_sf_map_fx( hIvasDec->st_ivas );
}
*hMasaExtOutMeta = hIvasDec->st_ivas->hMasa->data.extOutMeta;
@@ -2470,9 +2416,8 @@ ivas_error IVAS_DEC_GetHrtfParamBinHandle(
*---------------------------------------------------------------------*/
ivas_error IVAS_DEC_GetHrtfStatisticsHandle(
- IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */
- IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */
-)
+ IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */
+ IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics )
{
test();
test();
@@ -2516,7 +2461,7 @@ ivas_error IVAS_DEC_HRTF_binary_open(
test();
IF( ( EQ_32( binaural_renderer, IVAS_BIN_RENDERER_TYPE_TDREND ) || EQ_32( binaural_renderer, IVAS_BIN_RENDERER_TYPE_DEFAULT ) ) && st_ivas->hHrtfTD == NULL )
{
- IF( ( error = ivas_HRTF_binary_open_fx( &( st_ivas->hHrtfTD ) ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_HRTF_td_binary_open_fx( &( st_ivas->hHrtfTD ) ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -2598,7 +2543,7 @@ ivas_error IVAS_DEC_HRTF_binary_close(
test();
IF( !( EQ_32( binaural_renderer_old, IVAS_BIN_RENDERER_TYPE_TDREND ) || EQ_32( binaural_renderer_old, IVAS_BIN_RENDERER_TYPE_DEFAULT ) ) )
{
- ivas_HRTF_binary_close_fx( &st_ivas->hHrtfTD );
+ ivas_HRTF_td_binary_close_fx( &st_ivas->hHrtfTD );
}
test();
@@ -2611,8 +2556,6 @@ ivas_error IVAS_DEC_HRTF_binary_close(
test();
IF( !( EQ_32( binaural_renderer_old, IVAS_BIN_RENDERER_TYPE_FASTCONV ) || EQ_32( binaural_renderer_old, IVAS_BIN_RENDERER_TYPE_DEFAULT ) ) )
{
- /* Fastconv HRTF memories */
- ivas_binaural_hrtf_close_fx( &st_ivas->hHrtfFastConv );
/* Fastconv HRTF filters */
ivas_HRTF_fastconv_binary_close_fx( &st_ivas->hHrtfFastConv );
@@ -3813,7 +3756,7 @@ ivas_error IVAS_DEC_ReadFormat(
( NE_32( renderer_type_old, st_ivas->renderer_type ) ||
NE_32( renderer_type_sec_old, renderer_type_sec_new ) ) )
{
- Word16 tc_granularity_new = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, renderer_type_sec_new, st_ivas->hDecoderConfig->output_Fs );
+ Word16 tc_granularity_new = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, renderer_type_sec_new, st_ivas->hDecoderConfig->output_Fs );
st_ivas->nchan_transport = nchan_transport_old;
move16();
@@ -3864,11 +3807,7 @@ static ivas_error apa_exec_evs_wrapper(
{
Word16 ch;
UWord16 apa_buff_len;
-#ifdef FIX_1435_MOVE_STEREO_PANNING
Word16 tmp_apaExecBuffer[APA_BUF_PER_CHANNEL];
-#else
- Word16 tmp_apaExecBuffer[CPE_CHANNELS * APA_BUF / APA_MAX_NUM_CHANNELS]; /* in EVS, 2 output channels */
-#endif
DECODER_TC_BUFFER_HANDLE hTcBuffer;
test();
@@ -3960,7 +3899,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder(
}
ELSE IF( EQ_32( hIvasDec->mode, IVAS_DEC_MODE_IVAS ) )
{
- IF( ( error = ivas_jbm_dec_tc_fx( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_dec_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -3995,7 +3934,11 @@ ivas_error IVAS_DEC_GetSamplesDecoder(
}
/* convert deinterleaved decoded TC audio channels buffer to an interleaved one */
+#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER
+ ivas_buffer_deinterleaved_to_interleaved_fx( st_ivas->p_output_fx, st_ivas->hTcBuffer->tc_buffer_fx, nTransportChannels, hIvasDec->nSamplesFrame );
+#else
ivas_buffer_deinterleaved_to_interleaved_fx( st_ivas->p_output_fx, nTransportChannels, hIvasDec->nSamplesFrame, st_ivas->hTcBuffer->tc_buffer_fx );
+#endif
IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) )
{
@@ -4015,7 +3958,11 @@ ivas_error IVAS_DEC_GetSamplesDecoder(
move16();
/* convert interleaved time-scaled TC audio channels buffer to deinterleaved one */
+#ifdef FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER
+ ivas_buffer_interleaved_to_deinterleaved_fx( st_ivas->hTcBuffer->tc_buffer_fx, st_ivas->p_output_fx, nTransportChannels, nSamplesTcsScaled );
+#else
ivas_buffer_interleaved_to_deinterleaved_fx( st_ivas->hTcBuffer->tc_buffer_fx, nTransportChannels, nSamplesTcsScaled, NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) );
+#endif
}
else
{
@@ -4026,7 +3973,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder(
* Feed decoded transport channels samples to the renderer
*-----------------------------------------------------------------*/
- ivas_jbm_dec_feed_tc_to_renderer_fx( st_ivas, nSamplesTcsScaled, &nResidualSamples );
+ ivas_dec_feed_tc_to_renderer_fx( st_ivas, nSamplesTcsScaled, &nResidualSamples );
IF( st_ivas->hDecoderConfig->Opt_tsm )
{
@@ -4982,16 +4929,9 @@ IF( hIvasDec->hasDecodedFirstGoodFrame &&splitRendBits != NULL )
scale_sig32( p_head_pose_buf[i], *nSamplesRendered, sub( Q11, Q_out[i] ) ); // Q11
}
- IF( EQ_32( st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) )
- {
#ifndef DISABLE_LIMITER
- ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 );
+ ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 );
#endif
- }
- ELSE
- {
- ivas_limiter_dec_fx( st_ivas->hLimiter, p_head_pose_buf, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, Q11 );
- }
ivas_syn_output_fx( p_head_pose_buf, Q11, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, pcmBuf );
}
@@ -5172,7 +5112,7 @@ ivas_error IVAS_DEC_Flush(
test();
IF( GT_16( nSamplesToRender, 0 ) && NE_16( (Word16) hIvasDec->st_ivas->ivas_format, (Word16) MONO_FORMAT ) )
{
- error = ivas_jbm_dec_render_fx( hIvasDec->st_ivas, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmBuf );
+ error = ivas_dec_render_fx( hIvasDec->st_ivas, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmBuf );
}
ELSE
{
@@ -5406,7 +5346,7 @@ static ivas_error printConfigInfo_dec(
const bool quietModeEnabled )
{
ivas_error error;
- Word8 config_str[50];
+ Word8 config_str[200];
AUDIO_CONFIG output_config;
/*-----------------------------------------------------------------*
@@ -5526,7 +5466,7 @@ static ivas_error printConfigInfo_dec(
test();
IF( ( EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) )
{
- fprintf( stdout, "Render framesize: %dms\n", get_render_frame_size_ms( st_ivas->hDecoderConfig->render_framesize ) );
+ fprintf( stdout, "Render framesize: %dms\n", get_render_frame_size_ms( st_ivas->hDecoderConfig->render_num_subframes ) );
}
IF( st_ivas->hDecoderConfig->Opt_HRTF_binary )
{
@@ -5651,14 +5591,8 @@ static ivas_error evs_dec_main_fx(
Decoder_Struct *st_ivas )
{
DEC_CORE_HANDLE *hCoreCoder;
-#ifndef FIX_1435_MOVE_STEREO_PANNING
- Word16 mixer_left_fx, mixer_right_fx;
- Word32 *p_output_fx[MAX_TRANSPORT_CHANNELS];
- Word16 ch, i, nOutSamples;
-#else
Word32 *p_output_fx[1];
Word16 i, nOutSamples;
-#endif
Word16 output_16[L_FRAME48k];
ivas_error error;
@@ -5672,18 +5606,7 @@ static ivas_error evs_dec_main_fx(
mdct_switching_dec_fx( hCoreCoder[0] );
-#ifdef FIX_1435_MOVE_STEREO_PANNING
p_output_fx[0] = st_ivas->p_output_fx[0];
-#else
- FOR( ch = 0; ch < MAX_TRANSPORT_CHANNELS; ch++ )
- {
- p_output_fx[ch] = st_ivas->p_output_fx[ch]; // Q0
- IF( p_output_fx[ch] != NULL )
- {
- set_zero_fx( p_output_fx[ch], L_FRAME48k );
- }
- }
-#endif
/* run the main EVS decoding routine */
IF( EQ_16( hCoreCoder[0]->codec_mode, MODE1 ) )
@@ -5735,16 +5658,6 @@ static ivas_error evs_dec_main_fx(
st_ivas->BER_detect = hCoreCoder[0]->BER_detect;
move16();
-#ifndef FIX_1435_MOVE_STEREO_PANNING
- IF( EQ_16( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) )
- {
- mixer_left_fx = add( shr( st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, Q1 ), ONE_IN_Q14 ); // Q14
- mixer_right_fx = sub( MAX16B, mixer_left_fx );
-
- v_multc_fx_16( p_output_fx[0], mixer_right_fx, p_output_fx[1], nOutSamples ); /* Q11 */
- v_multc_fx_16( p_output_fx[0], mixer_left_fx, p_output_fx[0], nOutSamples ); /* Q11 */
- }
-#endif
/*if ( st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO )*/
{
@@ -6365,7 +6278,7 @@ static ivas_error ivas_dec_init_split_rend(
move16();
}
- error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->render_framesize, mixed_td_cldfb_flag );
+ error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->render_num_subframes, mixed_td_cldfb_flag );
move16();
return error;
@@ -6439,7 +6352,7 @@ static ivas_error feedSinglePIorientation(
{
IF( !st_ivas->hExtOrientationData )
{
- IF( NE_32( error = ivas_external_orientation_open_fx( &( st_ivas->hExtOrientationData ), st_ivas->hDecoderConfig->render_framesize ), IVAS_ERR_OK ) )
+ IF( NE_32( error = ivas_external_orientation_open_fx( &( st_ivas->hExtOrientationData ), st_ivas->hDecoderConfig->render_num_subframes ), IVAS_ERR_OK ) )
{
return error;
}
@@ -6447,7 +6360,7 @@ static ivas_error feedSinglePIorientation(
IF( !st_ivas->hCombinedOrientationData )
{
- IF( NE_32( error = ivas_combined_orientation_open_fx( &( st_ivas->hCombinedOrientationData ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->render_framesize ), IVAS_ERR_OK ) )
+ IF( NE_32( error = ivas_combined_orientation_open_fx( &( st_ivas->hCombinedOrientationData ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->render_num_subframes ), IVAS_ERR_OK ) )
{
return error;
}
diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c
index 3af2e35ed787b63cec3d72949833666bf8ed04e8..32c8c99581caeac996bc96bdbd233d9afb94c2a3 100644
--- a/lib_dec/lsf_dec_fx.c
+++ b/lib_dec/lsf_dec_fx.c
@@ -236,10 +236,12 @@ void lsf_dec_fx(
}
lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, st_fx->sr_core );
}
+
/*-------------------------------------------------------------------------------------*
* Mid-frame LSF decoding
* LSP interpolation and conversion of LSPs to A(z)
*-------------------------------------------------------------------------------------*/
+
IF( st_fx->rate_switching_reset )
{
/*extrapolation in case of unstable LSF convert*/
@@ -298,13 +300,14 @@ void lsf_dec_fx(
}
/* LSP interpolation and conversion of LSPs to A(z) - two-subframe mode */
- int_lsp4_ivas_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, -2 );
+ int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, -2 );
}
ELSE
{
/* LSP interpolation and conversion of LSPs to A(z) */
- int_lsp4_ivas_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, st_fx->relax_prev_lsf_interp );
+ int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, st_fx->relax_prev_lsf_interp );
}
+
/*------------------------------------------------------------------*
* Check LSF stability (distance between old LSFs and current LSFs)
*------------------------------------------------------------------*/
diff --git a/lib_dec/rom_dec.h b/lib_dec/rom_dec.h
index b4c7e4780e61b1727c14c3ee912fbbd50d2654e0..cfa8455bfa7fbc2301f388811da7c4fe7d13e9ee 100644
--- a/lib_dec/rom_dec.h
+++ b/lib_dec/rom_dec.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/rom_dec_fx.c b/lib_dec/rom_dec_fx.c
index 01be2c7cc6b7baabe998292d80626cdb6ccf93c9..f3539d64095a922968b574519abb8f691db135e1 100644
--- a/lib_dec/rom_dec_fx.c
+++ b/lib_dec/rom_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h
index 57072b9a436f30695aa72302cbce529fbcc92476..a1646e82ebb470b219fcbd964e451b1e5d3f69f2 100644
--- a/lib_dec/stat_dec.h
+++ b/lib_dec/stat_dec.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -1258,7 +1258,9 @@ typedef struct Decoder_State
Word16 last_L_frame_ori;
Word16 previoussynth_fx[L_FRAME48k];
+#ifndef FIX_2379_REMOVE_previoussynth_fx_32
Word32 previoussynth_fx_32[L_FRAME48k];
+#endif
Word16 old_synth_sw_fx[NS2SA( 48000, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS )];
Word16 delay_buf_out_fx[HQ_DELTA_MAX * HQ_DELAY_COMP]; /*Q0*/
Word32 delay_buf_out32_fx[HQ_DELTA_MAX * HQ_DELAY_COMP]; /*Q11*/
diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c
index c61e4ddf31c40ee60b9fe0624ce1300cbdcbd23e..2d99d9a4a27d6d849bd47e1bc6719296bf2a35d5 100644
--- a/lib_dec/swb_tbe_dec_fx.c
+++ b/lib_dec/swb_tbe_dec_fx.c
@@ -2,22 +2,22 @@
EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0
====================================================================================*/
-
#include
#include "options.h"
#include "rom_com.h"
#include "prot_fx.h"
#include "rom_dec.h"
-#include "stl.h"
-
#include "ivas_prot_fx.h"
/*-----------------------------------------------------------------*
* Local functions
*-----------------------------------------------------------------*/
+#ifdef HARMONIZE_TBE
+static void dequantizeSHBparams_fx( Decoder_State *st_fx, const Word16 extl, Word32 extl_brate, Word16 *Q_lsf, Word16 *Q_subgain, Word32 *Q_framegrain, Word16 *uv_flag, Word32 *Q_shb_ener_sf_32, Word16 *Q_shb_res_gshape, Word16 *Q_mixFactors, Word16 *MSFlag );
+#else
static void dequantizeSHBparams_fx_9_1( Decoder_State *st_fx, const Word16 extl, Word32 extl_brate, Word16 *Q_lsf, Word16 *Q_subgain, Word32 *Q_framegrain, Word16 *uv_flag, Word32 *Q_shb_ener_sf_32, Word16 *Q_shb_res_gshape, Word16 *Q_mixFactors );
-
+#endif
static void find_max_mem_dec( Decoder_State *st_fx, Word16 *n_mem, Word16 *n_mem2, Word16 *n_mem3 );
static void rescale_genSHB_mem_dec( Decoder_State *st_fx, Word16 sf );
static void find_max_mem_wb( Decoder_State *st_fx, Word16 *n_mem );
@@ -27,15 +27,15 @@ static void Map_higher_LSF_fx( Word16 lsf_q[], const Word16 m, const Word16 grid
static void Dequant_mirror_point_fx( const Word16 lsf_q[], const Word16 m_idx, Word16 *m );
static Word16 dotp_loc( const Word16 x[], const Word32 y[], const Word16 n );
static void find_max_mem_dec_m3( Decoder_State *st, Word16 *n_mem3 );
-
-/* gain shape concealment code */
static void gradientGainShape( Decoder_State *st_fx, Word16 *GainShape, Word32 *GainFrame );
+
/*-------------------------------------------------------------------*
* find_max_mem_dec()
*
* Find norm and max in TBE memories and past buffers
*-------------------------------------------------------------------*/
+
static void find_max_mem_dec(
Decoder_State *st_fx,
Word16 *n_mem,
@@ -219,14 +219,17 @@ static void find_max_mem_dec(
because of the Hilber transform and Q14 coeffs */
*n_mem3 = s_max( tempQ15, 0 );
move16();
- /* --------------------------------------------------------------*/
+
+ return;
}
+
/*-------------------------------------------------------------------*
* rescale_genSHB_mem_dec()
*
* Rescale genSHB memories
*-------------------------------------------------------------------*/
+
static void rescale_genSHB_mem_dec(
Decoder_State *st_fx,
Word16 sf )
@@ -255,20 +258,25 @@ static void rescale_genSHB_mem_dec(
{
FOR( i = 0; i < LPC_SHB_ORDER; i++ )
{
+#ifdef HARMONIZE_TBE
+ hBWE_TD->state_lpc_syn_fx[i] = shl_sat( hBWE_TD->state_lpc_syn_fx[i], sf );
+#else
hBWE_TD->state_lpc_syn_fx[i] = shl( hBWE_TD->state_lpc_syn_fx[i], sf );
+#endif
move16();
}
FOR( i = 0; i < L_SHB_LAHEAD; i++ )
{
+#ifdef HARMONIZE_TBE
+ hBWE_TD->state_syn_shbexc_fx[i] = shl_sat( hBWE_TD->state_syn_shbexc_fx[i], sf );
+#else
hBWE_TD->state_syn_shbexc_fx[i] = shl( hBWE_TD->state_syn_shbexc_fx[i], sf );
+#endif
move16();
}
}
- if ( EQ_16( st_fx->extl, FB_TBE ) )
- {
- }
hBWE_TD->mem_csfilt_fx[0] = L_shl( hBWE_TD->mem_csfilt_fx[0], sf );
move32();
@@ -276,9 +284,14 @@ static void rescale_genSHB_mem_dec(
move16();
hBWE_TD->tbe_premph_fx = shl_r( hBWE_TD->tbe_premph_fx, sf );
move16();
+
+ return;
}
-void find_max_mem_wb( Decoder_State *st_fx, Word16 *n_mem )
+
+static void find_max_mem_wb(
+ Decoder_State *st_fx,
+ Word16 *n_mem )
{
Word16 i;
Word16 max = 0;
@@ -311,21 +324,18 @@ void find_max_mem_wb( Decoder_State *st_fx, Word16 *n_mem )
FOR( i = 0; i < 7; i++ )
{
-
if ( GT_16( abs_s( hBWE_TD->mem_genSHBexc_filt_down_wb3_fx[i] ), max ) )
max = abs_s( hBWE_TD->mem_genSHBexc_filt_down_wb3_fx[i] );
}
FOR( i = 0; i < 10; i++ )
{
-
if ( GT_16( abs_s( hBWE_TD->state_lpc_syn_fx[i] ), max ) )
max = abs_s( hBWE_TD->state_lpc_syn_fx[i] );
}
FOR( i = 0; i < 5; i++ )
{
-
if ( GT_16( abs_s( hBWE_TD->state_syn_shbexc_fx[i] ), max ) )
max = abs_s( hBWE_TD->state_syn_shbexc_fx[i] );
}
@@ -341,10 +351,8 @@ void find_max_mem_wb( Decoder_State *st_fx, Word16 *n_mem )
move16();
}
-
FOR( i = 0; i < 2; i++ )
{
-
if ( GT_32( L_abs( hBWE_TD->mem_csfilt_fx[i] ), Lmax ) )
Lmax = L_abs( hBWE_TD->mem_csfilt_fx[i] );
}
@@ -363,9 +371,14 @@ void find_max_mem_wb( Decoder_State *st_fx, Word16 *n_mem )
move16();
*n_mem = s_max( *n_mem, 0 );
move16();
+
+ return;
}
-void rescale_genWB_mem( Decoder_State *st_fx, Word16 sf )
+
+static void rescale_genWB_mem(
+ Decoder_State *st_fx,
+ Word16 sf )
{
Word16 i;
TD_BWE_DEC_HANDLE hBWE_TD;
@@ -466,6 +479,12 @@ static void InitSWBdecBuffer_fx(
}
+/*-------------------------------------------------------------------*
+ * ResetSHBbuffer_Dec()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
void ResetSHBbuffer_Dec_fx(
TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
const Word16 extl /* i : BWE extension layer */
@@ -587,20 +606,25 @@ void ResetSHBbuffer_Dec_fx(
/* _Word16 *synth o : WB synthesis/final synthesis Q_synth */
/*--------------------------------------------------------------------------*/
/* INPUT/OUTPUT ARGUMENTS : */
-/* Decoder_State *st_fx, i/o: decoder state structure */
+/* Decoder_State *st_fx, i/o: decoder state structure */
/*--------------------------------------------------------------------------*/
/* RETURN ARGUMENTS : */
/* _ None */
/*--------------------------------------------------------------------------*/
/* CALLED FROM : */
/*==========================================================================*/
+
+#ifdef HARMONIZE_TBE
+void wb_tbe_dec_fx(
+#else
void ivas_wb_tbe_dec_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word16 coder_type, /* i : coding type Q0 */
- Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation 2*Q_exc*/
- const Word16 Q_exc,
- const Word16 voice_factors[], /* i : voicing factors Q15 */
- Word16 *synth, /* o : WB synthesis/final synthesis Q_synth */
+#endif
+ Decoder_State *st_fx, /* i/o: decoder state structure */
+ const Word16 coder_type, /* i : coding type Q0 */
+ Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation 2*Q_exc */
+ const Word16 Q_exc, /* i : Q_exc factor */
+ const Word16 voice_factors[], /* i : voicing factors Q15 */
+ Word16 *synth, /* o : WB synthesis/final synthesis Q_synth */
Word16 *Q_synth )
{
Word16 i;
@@ -635,8 +659,10 @@ void ivas_wb_tbe_dec_fx(
Word16 f, inc;
Word64 W_tmp;
TD_BWE_DEC_HANDLE hBWE_TD;
+
hBWE_TD = st_fx->hBWE_TD;
set32_fx( &dummy2[0], 0, HILBERT_MEM_SIZE );
+
IF( st_fx->bws_cnt == 0 )
{
/* Initialization */
@@ -750,9 +776,14 @@ void ivas_wb_tbe_dec_fx(
}
ELSE
{
+#ifdef HARMONIZE_TBE
+ /* de-quantization */
+ dequantizeSHBparams_fx( st_fx, st_fx->extl, st_fx->extl_brate, lsf_wb, GainShape, &GainFrame, &uv_flag, 0, 0, 0, &j /*temp*/ );
+#else
/* de-quantization */
Word16 ignore;
ivas_dequantizeSHBparams_fx_9_1( st_fx, st_fx->extl, st_fx->extl_brate, lsf_wb, GainShape, &GainFrame, &uv_flag, 0, 0, 0, &ignore );
+#endif
}
}
ELSE
@@ -835,9 +866,21 @@ void ivas_wb_tbe_dec_fx(
/* From low band excitation, generate highband excitation */
Lmax = 0;
move32();
- FOR( cnt = 0; cnt < L_FRAME32k + NL_BUFF_OFFSET; cnt++ )
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
{
- Lmax = L_max( Lmax, L_abs( bwe_exc_extended[cnt] ) );
+ FOR( cnt = 0; cnt < L_FRAME32k; cnt++ )
+ {
+ Lmax = L_max( Lmax, L_abs( bwe_exc_extended[cnt] ) );
+ }
+ }
+ ELSE
+#endif
+ {
+ FOR( cnt = 0; cnt < L_FRAME32k + NL_BUFF_OFFSET; cnt++ )
+ {
+ Lmax = L_max( Lmax, L_abs( bwe_exc_extended[cnt] ) );
+ }
}
IF( Lmax == 0 )
{
@@ -848,7 +891,16 @@ void ivas_wb_tbe_dec_fx(
{
Q_bwe_exc = norm_l( Lmax );
}
- Q_bwe_exc = sub( Q_bwe_exc, 3 );
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ Q_bwe_exc = sub( Q_bwe_exc, 1 );
+ }
+ ELSE
+#endif
+ {
+ Q_bwe_exc = sub( Q_bwe_exc, 3 );
+ }
Q_bwe_exc = add( Q_bwe_exc, add( Q_exc, Q_exc ) );
find_max_mem_wb( st_fx, &n_mem );
@@ -865,38 +917,82 @@ void ivas_wb_tbe_dec_fx(
move16(); /* restrict this to 21 due to the Q factor requireemnt of the random number generator (keep 1 bit headroom) */
}
- W_tmp = 0;
- move64();
- IF( st_fx->element_mode > EVS_MONO )
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
{
- tmp = sub( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 31 + 16 );
- W_tmp = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/
+ prev_pow = 0;
+ move32();
+ FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ )
+ {
+ prev_pow = L_mac0_sat( prev_pow, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/
+ }
}
- FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ )
+ ELSE
+#endif
{
- W_tmp = W_mac_16_16( W_tmp, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /*Q(2*(st_fx->prev_Q_bwe_exc-16 + 1))*/
+ W_tmp = 0;
+ move64();
+ tmp = sub( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 31 + 16 );
+ W_tmp = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/
+ FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ )
+ {
+ W_tmp = W_mac_16_16( W_tmp, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /*Q(2*(st_fx->prev_Q_bwe_exc-16 + 1))*/
+ }
+ exp = W_norm( W_tmp );
+ prev_pow = W_extract_h( W_shl( W_tmp, exp ) );
+ exp = sub( add( add( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 1 ), exp ), 32 );
}
- exp = W_norm( W_tmp );
- prev_pow = W_extract_h( W_shl( W_tmp, exp ) );
- exp = sub( add( add( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 1 ), exp ), 32 );
rescale_genWB_mem( st_fx, sub( Q_bwe_exc, st_fx->prev_Q_bwe_exc ) );
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ Copy( hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_16, NL_BUFF_OFFSET );
+ }
+#endif
+
sc = sub( Q_bwe_exc, add( Q_exc, Q_exc ) );
- FOR( cnt = 0; cnt < L_FRAME32k + NL_BUFF_OFFSET; cnt++ )
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
{
- bwe_exc_extended_16[cnt] = round_fx( L_shl( bwe_exc_extended[cnt], sc ) );
- move16();
+ FOR( cnt = 0; cnt < L_FRAME32k; cnt++ )
+ {
+ bwe_exc_extended_16[cnt + NL_BUFF_OFFSET] = round_fx_sat( L_shl_sat( bwe_exc_extended[cnt], sc ) );
+ }
+ Copy( bwe_exc_extended_16 + L_FRAME32k, hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET );
+ }
+
+ ELSE
+#endif
+ {
+ FOR( cnt = 0; cnt < L_FRAME32k + NL_BUFF_OFFSET; cnt++ )
+ {
+ bwe_exc_extended_16[cnt] = round_fx( L_shl( bwe_exc_extended[cnt], sc ) );
+ move16();
+ }
}
Copy( hBWE_TD->state_syn_shbexc_fx, shaped_wb_excitation, L_SHB_LAHEAD / 4 );
Q_bwe_exc_ext = sub( Q_bwe_exc, 16 );
- GenShapedWBExcitation_ivas_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx,
- hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx,
- hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, hBWE_TD->state_lpc_syn_fx, coder_type, st_fx->element_mode,
- bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, vf_modified, uv_flag, st_fx->igf );
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ GenShapedWBExcitation_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx,
+ hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx,
+ hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, hBWE_TD->state_lpc_syn_fx, coder_type, st_fx->element_mode,
+ bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, vf_modified, uv_flag, st_fx->igf );
+ }
+ ELSE
+#endif
+ {
+ GenShapedWBExcitation_ivas_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx,
+ hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx,
+ hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, hBWE_TD->state_lpc_syn_fx, coder_type, st_fx->element_mode,
+ bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, vf_modified, uv_flag, st_fx->igf );
+ }
curr_pow = 0;
move32();
@@ -915,8 +1011,16 @@ void ivas_wb_tbe_dec_fx(
curr_pow = L_shr( curr_pow, 2 ); /* Q(2*Q_bwe_exc_ext) */
}
- Lscale = root_a_over_b_fx( curr_pow, shl_r( Q_bwe_exc_ext, 1 ), prev_pow,
- exp, &exp );
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ Lscale = root_a_over_b_fx( curr_pow, shl_r( Q_bwe_exc_ext, 1 ), prev_pow, shl_r( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), &exp );
+ }
+ ELSE
+#endif
+ {
+ Lscale = root_a_over_b_fx( curr_pow, shl_r( Q_bwe_exc_ext, 1 ), prev_pow, exp, &exp );
+ }
FOR( i = 0; i < L_SHB_LAHEAD / 4 - 1; i++ )
{
@@ -932,7 +1036,6 @@ void ivas_wb_tbe_dec_fx(
/* Update SHB excitation */
Copy( shaped_wb_excitation + L_FRAME16k / 4, hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD / 4 );
-
/* Adjust the subframe and frame gain of the synthesized shb signal */
/* Scale the shaped excitation */
ScaleShapedWB_fx( SHB_OVERLAP_LEN / 2, shaped_wb_excitation, hBWE_TD->syn_overlap_fx, GainShape, GainFrame,
@@ -941,9 +1044,21 @@ void ivas_wb_tbe_dec_fx(
max = 0;
move16();
- FOR( i = 0; i < L_FRAME16k / 4; i++ )
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ FOR( i = 0; i < L_FRAME16k / 4; i++ )
+ {
+ max = s_max( max, shaped_wb_excitation[i] ); /*Q0*/
+ }
+ }
+ ELSE
+#endif
{
- max = s_max( max, abs_s( shaped_wb_excitation[i] ) );
+ FOR( i = 0; i < L_FRAME16k / 4; i++ )
+ {
+ max = s_max( max, abs_s( shaped_wb_excitation[i] ) );
+ }
}
IF( max == 0 )
@@ -985,8 +1100,12 @@ void ivas_wb_tbe_dec_fx(
}
test();
+#ifdef HARMONIZE_TBE
+ IF( !st_fx->bfi && st_fx->prev_bfi )
+#else
test();
IF( !st_fx->bfi && ( st_fx->prev_bfi || st_fx->prev_use_partial_copy ) )
+#endif
{
IF( GT_32( L_shr( curr_frame_pow, 1 ), hBWE_TD->prev_wb_bwe_frame_pow_fx ) )
{
@@ -1063,13 +1182,17 @@ void ivas_wb_tbe_dec_fx(
FOR( i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++ )
{
if ( GT_16( abs_s( hBWE_TD->state_lsyn_filt_shb_fx[i] ), max ) )
+ {
max = abs_s( hBWE_TD->state_lsyn_filt_shb_fx[i] );
+ }
}
FOR( i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++ )
{
if ( GT_16( abs_s( hBWE_TD->state_lsyn_filt_dwn_shb_fx[i] ), max ) )
+ {
max = abs_s( hBWE_TD->state_lsyn_filt_dwn_shb_fx[i] );
+ }
}
IF( EQ_32( st_fx->output_Fs, 32000 ) )
@@ -1178,10 +1301,21 @@ void ivas_wb_tbe_dec_fx(
}
ELSE IF( EQ_32( st_fx->output_Fs, 48000 ) )
{
- Copy_Scale_sig_16_32_no_sat( synth, tmp_synL, L_FRAME48k, sub( Q11, Qx ) );
- interpolate_3_over_1_allpass_fx32( tmp_synL, L_FRAME16k, upsampled_synth_32fx, hBWE_TD->mem_resamp_HB_fx_32 );
- Copy_Scale_sig_32_16( hBWE_TD->mem_resamp_HB_fx_32, hBWE_TD->mem_resamp_HB_fx, INTERP_3_1_MEM_LEN, sub( Qx, Q11 ) );
- Copy_Scale_sig_32_16( upsampled_synth_32fx, synth, L_FRAME48k, sub( Qx, Q11 ) );
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ Scale_sig( hBWE_TD->mem_resamp_HB_fx, INTERP_3_1_MEM_LEN, sub( Qx, hBWE_TD->prev_Qx ) );
+ interpolate_3_over_1_allpass_fx( synth, L_FRAME16k, upsampled_synth, hBWE_TD->mem_resamp_HB_fx );
+ Copy( upsampled_synth, synth, L_FRAME48k );
+ }
+ ELSE
+#endif
+ {
+ Copy_Scale_sig_16_32_no_sat( synth, tmp_synL, L_FRAME48k, sub( Q11, Qx ) );
+ interpolate_3_over_1_allpass_fx32( tmp_synL, L_FRAME16k, upsampled_synth_32fx, hBWE_TD->mem_resamp_HB_fx_32 );
+ Copy_Scale_sig_32_16( hBWE_TD->mem_resamp_HB_fx_32, hBWE_TD->mem_resamp_HB_fx, INTERP_3_1_MEM_LEN, sub( Qx, Q11 ) );
+ Copy_Scale_sig_32_16( upsampled_synth_32fx, synth, L_FRAME48k, sub( Qx, Q11 ) );
+ }
}
}
ELSE
@@ -1238,7 +1372,7 @@ void ivas_wb_tbe_dec_fx(
return;
}
-
+#ifndef HARMONIZE_TBE
void wb_tbe_dec_fx(
Decoder_State *st_fx, /* i/o: decoder state structure */
const Word16 coder_type, /* i : coding type */
@@ -1877,7 +2011,7 @@ void wb_tbe_dec_fx(
return;
}
-
+#endif
/*======================================================================================*/
/* FUNCTION : void swb_tbe_dec_fx () */
@@ -1896,13 +2030,14 @@ void wb_tbe_dec_fx(
/* _(Word16*)White_exc16k : shaped white excitation for the FB TBE Q_synth */
/*--------------------------------------------------------------------------------------*/
/* INPUT/OUTPUT ARGUMENTS : */
-/* _ Decoder_State *st_fx: : Decoder state structure */
+/* _ Decoder_State *st_fx: : Decoder state structure */
/*--------------------------------------------------------------------------------------*/
/* RETURN ARGUMENTS : */
/* _ None */
/*--------------------------------------------------------------------------------------*/
/* CALLED FROM : RX */
/*======================================================================================*/
+
void swb_tbe_dec_fx(
Decoder_State *st_fx, /* i/o: decoder state structure */
const Word16 coder_type, /* i : coding type */
@@ -2210,10 +2345,14 @@ void swb_tbe_dec_fx(
}
ELSE
{
-
/* de-quantization */
+#ifdef HARMONIZE_TBE
+ dequantizeSHBparams_fx( st_fx, st_fx->extl, st_fx->extl_brate, lsf_shb, GainShape, &GainFrame, &stemp,
+ &shb_ener_sf_32, shb_res_gshape, &mixFactors, &j /*temp*/ );
+#else
dequantizeSHBparams_fx_9_1( st_fx, st_fx->extl, st_fx->extl_brate, lsf_shb, GainShape, &GainFrame, &stemp,
&shb_ener_sf_32, shb_res_gshape, &mixFactors );
+#endif
Q_shb = 0;
move16();
/* o: shb_ener_sf_32 in (2*Q_shb) */
@@ -3867,6 +4006,7 @@ static Word16 dotp_loc(
Word16 i;
Word32 suma;
Word16 guarded_bits = find_guarded_bits_fx( n );
+
suma = L_shr( Mpy_32_16_1( y[0], x[0] ), guarded_bits ); /*Qx + Qy - guarded_bits*/
FOR( i = 1; i < n; i++ )
@@ -3878,7 +4018,18 @@ static Word16 dotp_loc(
return extract_h( suma ); /*Qx + Qy - 16*/
}
+
+/*-------------------------------------------------------------------*
+ * dequantizeSHBparams()
+ *
+ * Dequantize super highband spectral envolope, temporal gains and frame gain
+ *-------------------------------------------------------------------*/
+
+#ifdef HARMONIZE_TBE
+static void dequantizeSHBparams_fx(
+#else
void ivas_dequantizeSHBparams_fx_9_1(
+#endif
Decoder_State *st_fx,
const Word16 extl, /* i : extension layer */
Word32 extl_brate, /* i : extensiuon layer bitrate */
@@ -4310,7 +4461,7 @@ void ivas_dequantizeSHBparams_fx_9_1(
return;
}
-
+#ifndef HARMONIZE_TBE
/*==========================================================================*/
/* FUNCTION : static void dequantizeSHBparams_fx_9_1 () */
/*--------------------------------------------------------------------------*/
@@ -4629,13 +4780,16 @@ static void dequantizeSHBparams_fx_9_1(
return;
}
+#endif
/*-------------------------------------------------------------------*
* fb_tbe_dec()
*
* FB TBE decoder, 14(resp. 15.5) - 20 kHz band decoding module
*-------------------------------------------------------------------*/
+
void fb_tbe_dec_fx(
+#ifndef HARMONIZE_TBE
Decoder_State *st, /* i/o: encoder state structure */
const Word16 fb_exc[], /* i : FB excitation from the SWB part Q_fb_exc */
Word16 Q_fb_exc,
@@ -4690,9 +4844,13 @@ void fb_tbe_dec_fx(
}
void fb_tbe_dec_ivas_fx(
+#endif
Decoder_State *st, /* i/o: encoder state structure */
const Word16 fb_exc[], /* i : FB excitation from the SWB part Q_fb_exc */
Word16 Q_fb_exc,
+#ifdef HARMONIZE_TBE
+ Word16 *hb_synth16, /* o : high-band synthesis Q(15 - hb_synth_exp) */
+#endif
Word32 *hb_synth, /* o : high-band synthesis Q(15 - hb_synth_exp) */
Word16 hb_synth_exp,
Word16 *fb_synth_ref, /*Q_fb_synth_ref*/
@@ -4754,17 +4912,31 @@ void fb_tbe_dec_ivas_fx(
{
Copy_Scale_sig( fb_synth, fb_synth_ref, L_FRAME48k, sub( Q_fb_synth_ref, add( hb_synth_exp, 16 ) ) ); // scaling is required
}
+
/* add the fb_synth component to the hb_synth component */
- /* v_add_fx( hb_synth, fb_synth, hb_synth, L_FRAME48k );*/
- FOR( i = 0; i < L_FRAME48k; i++ )
+#ifdef HARMONIZE_TBE
+ IF( st->element_mode == EVS_MONO )
{
- // hb_synth[i] = L_add( hb_synth[i], L_deposit_l(fb_synth[i]));
- hb_synth[i] = L_add( hb_synth[i], L_shl( fb_synth[i], Q11 ) ); // hb_synth_exp
- move16();
+ FOR( i = 0; i < L_FRAME48k; i++ )
+ {
+ hb_synth16[i] = add_sat( hb_synth16[i], fb_synth[i] );
+ move16();
+ }
+ }
+ ELSE
+#endif
+ {
+ FOR( i = 0; i < L_FRAME48k; i++ )
+ {
+ hb_synth[i] = L_add( hb_synth[i], L_shl( fb_synth[i], Q11 ) ); // hb_synth_exp
+ move16();
+ }
}
+
return;
}
+
void tbe_read_bitstream_fx(
Decoder_State *st_fx )
{
@@ -5381,6 +5553,7 @@ static void calc_tilt_bwe_fx_loc(
return;
}
+#ifndef HARMONIZE_TBE
/*-------------------------------------------------------------------*
* swb_tbe_dec()
*
@@ -5427,6 +5600,7 @@ static void rescale_genSHB_mem_dec_ivas(
return;
}
+#endif
static void find_max_mem_dec_m3(
Decoder_State *st,
@@ -5461,23 +5635,27 @@ static void find_max_mem_dec_m3(
*n_mem3 = 15;
move16();
}
+
+ return;
}
+
/*-------------------------------------------------------------------*
* ivas_swb_tbe_dec_fx()
*
* SWB TBE decoder, 6 - 14 kHz (or 7.5 - 15.5 kHz) band decoding module
*-------------------------------------------------------------------*/
+
void ivas_swb_tbe_dec_fx(
Decoder_State *st, /* i/o: decoder state structure */
STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */
const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */
Word16 Q_exc,
- const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */
- const Word32 old_syn_12k8_16k_fx[], /* i : low band synthesis : old_syn_fx */
- Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/
- Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */
- Word16 *pitch_buf_fx, /* i : Q6 */
+ const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */
+ const Word16 old_syn_12k8_16k_fx16[], /* i : low band synthesis : old_syn_fx */
+ Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/
+ Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */
+ Word16 *pitch_buf_fx, /* i : Q6 */
Word16 *Q_white_exc )
{
Word16 i, j, cnt, n;
@@ -5545,6 +5723,9 @@ void ivas_swb_tbe_dec_fx(
hBWE_TD = st->hBWE_TD;
+ Word32 old_syn_12k8_16k_fx[L_FRAME16k];
+ Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx16, old_syn_12k8_16k_fx, st->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1))
+
/* initializations */
GainFrame_fx = 0;
move32();
@@ -5790,8 +5971,13 @@ void ivas_swb_tbe_dec_fx(
ELSE
{
/* de-quantization */
+#ifdef HARMONIZE_TBE
+ dequantizeSHBparams_fx( st, st->extl, st->extl_brate, lsf_shb_fx, GainShape_fx, &GainFrame_fx, &stemp,
+ &shb_ener_sf_32, shb_res_gshape_fx, &mixFactors_fx, &MSFlag );
+#else
ivas_dequantizeSHBparams_fx_9_1( st, st->extl, st->extl_brate, lsf_shb_fx, GainShape_fx, &GainFrame_fx, &stemp,
&shb_ener_sf_32, shb_res_gshape_fx, &mixFactors_fx, &MSFlag );
+#endif
if ( hStereoICBWE != NULL )
{
hStereoICBWE->MSFlag = MSFlag;
@@ -6185,7 +6371,11 @@ void ivas_swb_tbe_dec_fx(
sc = sub( Q_bwe_exc, st->prev_Q_bwe_exc );
IF( sc != 0 )
{
+#ifdef HARMONIZE_TBE
+ rescale_genSHB_mem_dec( st, sc );
+#else
rescale_genSHB_mem_dec_ivas( st, sc );
+#endif
}
/* rescale the bwe_exc_extended and bring it to 16-bit single precision with dynamic norm */
diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c
index eec8198bfcbfab63300ffc0b4063534776db28f1..93a5ab064261ff067116cc0ae0b1a43c248c0735 100644
--- a/lib_dec/tonalMDCTconcealment_fx.c
+++ b/lib_dec/tonalMDCTconcealment_fx.c
@@ -209,8 +209,8 @@ ivas_error TonalMDCTConceal_Init_ivas_fx(
/* just the second half of the second last pcm output is needed */
set16_fx( hTonalMDCTConc->timeDataBuffer, 0, ( 3 * L_FRAME_MAX ) / 2 );
- hTonalMDCTConc->secondLastPcmOut = &hTonalMDCTConc->timeDataBuffer[( 3 * L_FRAME_MAX ) / 2 - ( 3 * min( L_FRAME_MAX, nSamples ) / 2 )];
- hTonalMDCTConc->lastPcmOut = &hTonalMDCTConc->timeDataBuffer[( 3 * L_FRAME_MAX ) / 2 - min( L_FRAME_MAX, nSamples )];
+ hTonalMDCTConc->secondLastPcmOut = &hTonalMDCTConc->timeDataBuffer[( 3 * L_FRAME_MAX ) / 2 - ( 3 * s_min( L_FRAME_MAX, nSamples ) / 2 )];
+ hTonalMDCTConc->lastPcmOut = &hTonalMDCTConc->timeDataBuffer[( 3 * L_FRAME_MAX ) / 2 - s_min( L_FRAME_MAX, nSamples )];
/* If the second last frame was lost, we reuse saved TonalComponentsInfo and don't update pcm buffers */
assert( sizeof( *hTonalMDCTConc->pTCI ) <= ( hTonalMDCTConc->lastPcmOut - hTonalMDCTConc->timeDataBuffer ) * sizeof( hTonalMDCTConc->timeDataBuffer[0] ) );
diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c
index 240f9545c4cc8669299569d18ff755cbd35d77be..868c62fe7ccef8a24297047d6501b6d2a6633aa7 100644
--- a/lib_dec/updt_dec_fx.c
+++ b/lib_dec/updt_dec_fx.c
@@ -14,17 +14,18 @@
*
* Common updates (all frame types)
*-------------------------------------------------------------------*/
+
void updt_dec_fx(
- Decoder_State *st_fx, /* i/o: state structure */
- const Word16 *old_exc_fx, /* i : buffer of excitation Q_exc */
+ Decoder_State *st_fx, /* i/o: state structure */
+ const Word16 *old_exc_fx, /* i : buffer of excitation Q_exc */
const Word16 *pitch_buf_fx, /* i : fixed point pitch values for each subframe Q6*/
- const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/
- const Word16 *Aq, /* i : A(z) quantized for all subframes Q12 */
- const Word16 *lsf_new_fx, /* i : current frame LSF vector Qlog2(2.56)*/
- const Word16 *lsp_new_fx, /* i : current frame LSP vector Q15*/
- const Word16 voice_factors[], /* i : voicing factors Q15*/
- const Word16 *old_bwe_exc_fx, /* i : buffer of excitation Q_syn*/
- const Word16 *gain_buf /* i : fixed point pitch gain for each subframe Q14*/
+ const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/
+ const Word16 *Aq, /* i : A(z) quantized for all subframes Q12 */
+ const Word16 *lsf_new_fx, /* i : current frame LSF vector Qlog2(2.56)*/
+ const Word16 *lsp_new_fx, /* i : current frame LSP vector Q15*/
+ const Word16 voice_factors[], /* i : voicing factors Q15*/
+ const Word16 *old_bwe_exc_fx, /* i : buffer of excitation Q_syn*/
+ const Word16 *gain_buf /* i : fixed point pitch gain for each subframe Q14*/
)
{
Word16 i, len;
@@ -56,6 +57,7 @@ void updt_dec_fx(
st_fx->last_coder_type = UNVOICED;
move16();
}
+
IF( st_fx->hGSCDec != NULL )
{
test();
@@ -68,13 +70,13 @@ void updt_dec_fx(
}
/* this ensures that st_fx->last_coder_type is never set to INACTIVE in case of AVQ inactive because the FEC does not distinguish between GSC inactive and AVQ inactive */
-
test();
if ( GT_32( st_fx->total_brate, ACELP_24k40 ) && EQ_16( st_fx->coder_type, INACTIVE ) )
{
st_fx->last_coder_type = GENERIC;
move16();
}
+
test();
test();
test();
@@ -91,7 +93,6 @@ void updt_dec_fx(
IF( !st_fx->Opt_AMR_WB )
{
/* update voicing factor of TBE to help FEC */
-
st_fx->last_voice_factor_fx = voice_factors[NB_SUBFR16k - 1];
move16();
if ( EQ_16( st_fx->L_frame, L_FRAME ) )
@@ -100,6 +101,7 @@ void updt_dec_fx(
move16();
}
}
+
test();
test();
IF( st_fx->hGSCDec != NULL && NE_16( st_fx->coder_type, AUDIO ) && NE_16( st_fx->coder_type, INACTIVE ) )
@@ -159,7 +161,6 @@ void updt_dec_fx(
move16();
}
-
/* FEC - update adaptive LSF mean vector */
Copy( st_fx->lsfoldbfi0_fx, st_fx->lsfoldbfi1_fx, M );
Copy( lsf_new_fx, st_fx->lsfoldbfi0_fx, M );
@@ -198,13 +199,15 @@ void updt_dec_fx(
return;
}
+
/*-------------------------------------------------------------------*
* updt_IO_switch()
*
* Common updates for AMR-WB IO mode and EVS primary switching
*-------------------------------------------------------------------*/
+
void updt_IO_switch_dec_fx(
- const Word16 output_frame, /* i : output frame length */
+ const Word16 output_frame, /* i : output frame length */
Decoder_State *st_fx /* o : Decoder static variables structure */
)
{
@@ -393,15 +396,24 @@ void updt_IO_switch_dec_fx(
* Updates for BW switching
*-------------------------------------------------------------------*/
-void updt_bw_switching_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word16 *synth, /* i : synthesis signal Qpost */
- const Word16 Qpost )
+static void updt_bw_switching_fx(
+ Decoder_State *st_fx, /* i/o: decoder state structure */
+ const Word16 *synth, /* i : synthesis signal Qpost */
+ const Word32 *synth32, /* i : synthesis signal32 Qpost */
+ const Word16 Qpost /* i : Synthesis Q value */
+)
{
test();
IF( EQ_32( st_fx->output_Fs, 32000 ) && EQ_16( st_fx->bwidth, SWB ) )
{
- st_fx->tilt_swb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( synth, Qpost, L_FRAME32k ), 3 ) ); // Q27 - 16 = Q11
+ IF( st_fx->element_mode != EVS_MONO )
+ {
+ st_fx->tilt_swb_fx = ivas_calc_tilt_bwe_fx( synth32, Qpost, L_FRAME32k );
+ }
+ ELSE
+ {
+ st_fx->tilt_swb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( synth, Qpost, L_FRAME32k ), 3 ) ); // Q27 - 16 = Q11
+ }
}
st_fx->prev_enerLH_fx = st_fx->enerLH_fx; // enerLH_fx_Q
@@ -433,365 +445,21 @@ void updt_bw_switching_fx(
move16();
}
}
+
st_fx->prev_bws_cnt = st_fx->bws_cnt;
move16();
+
return;
}
+
/*-------------------------------------------------------------------*
* updt_dec_common()
*
* Common updates for MODE1 and MODE2
*-------------------------------------------------------------------*/
-void updt_dec_common_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- Word16 hq_core_type_fx, /* i : HQ core type */
- const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */
- const Word16 *synth, /* i : decoded synthesis Qpostd */
- const Word16 Qpostd /* i : Synthesis Q value */
-
-)
-{
- Word16 i;
- Word32 L_tmp;
-
- TCX_DEC_HANDLE hTcxDec;
- hTcxDec = st_fx->hTcxDec;
-
- st_fx->last_codec_mode = st_fx->codec_mode;
- move16();
- st_fx->last_extl = st_fx->extl;
- move16();
- st_fx->last_L_frame = st_fx->L_frame;
- move16();
-
- st_fx->prev_old_bfi = st_fx->prev_bfi;
- move16();
- st_fx->prev_bfi = st_fx->bfi;
- move16();
- if ( NE_16( st_fx->core, AMR_WB_CORE ) )
- {
- st_fx->old_bfi_cnt = st_fx->nbLostCmpt;
- move16();
- }
- move16();
- st_fx->last_con_tcx = st_fx->con_tcx;
- move16();
- st_fx->con_tcx = 0;
-
- move16();
- if ( st_fx->hHQ_nbfec != NULL )
- {
- st_fx->hHQ_nbfec->prev_last_core = st_fx->last_core;
- }
- if ( st_fx->hTcxDec != NULL )
- {
- hTcxDec->tcxConceal_recalc_exc = 0;
- move16();
- }
- test();
- test();
- IF( ( GE_16( st_fx->rf_frame_type, RF_TCXFD ) && LE_16( st_fx->rf_frame_type, RF_TCXTD2 ) && st_fx->use_partial_copy && st_fx->bfi ) || !st_fx->bfi )
- {
- test();
- test();
- test();
- test();
- if ( st_fx->bfi && ( LE_16( st_fx->last_good, UNVOICED_TRANSITION ) ) && ( GT_16( st_fx->clas_dec, UNVOICED_TRANSITION ) ) && st_fx->last_con_tcx && st_fx->hTcxDec != NULL )
- {
- hTcxDec->tcxConceal_recalc_exc = 1;
- move16();
- }
- st_fx->last_good = st_fx->clas_dec;
- move16();
- }
- IF( st_fx->use_partial_copy )
- {
- st_fx->prev_rf_frame_type = st_fx->rf_frame_type;
- move16();
- }
- ELSE
- {
- st_fx->prev_rf_frame_type = INACTIVE;
- move16();
- }
-
- if ( EQ_16( st_fx->m_frame_type, ACTIVE_FRAME ) && ( NE_16( st_fx->bfi, 1 ) || st_fx->use_partial_copy != 0 ) )
- {
- st_fx->rf_flag_last = st_fx->rf_flag;
- move16();
- }
-
- IF( EQ_16( st_fx->codec_mode, MODE1 ) )
- {
- test();
- if ( !st_fx->bfi && ( GT_32( st_fx->core_brate, SID_2k40 ) || ( GT_32( st_fx->core_brate, SID_1k75 ) && EQ_16( st_fx->core, AMR_WB_CORE ) ) ) )
- {
- move16();
- st_fx->last_active_brate = st_fx->total_brate;
- }
-
- move16();
- move16();
- st_fx->last_core = st_fx->core;
- if ( st_fx->hHQ_core != NULL )
- {
- st_fx->hHQ_core->last_hq_core_type = hq_core_type_fx;
- }
- }
- ELSE IF( EQ_16( st_fx->codec_mode, MODE2 ) )
- {
- test();
- if ( ( !st_fx->bfi ) && ( st_fx->last_is_cng == 0 ) )
- {
- move16();
- st_fx->last_active_brate = st_fx->total_brate;
- }
- /* INFO: moved from update_decoder_LPD_cng() */
- if ( NE_16( st_fx->m_frame_type, ACTIVE_FRAME ) )
- {
- move16();
- st_fx->last_is_cng = 1;
- }
-
-
- if ( !st_fx->bfi )
- {
- st_fx->last_core = st_fx->core;
- }
- move16();
- move16();
- st_fx->last_core_bfi = st_fx->core; /* also required for clean channel decoding */
- }
- move16();
- st_fx->last_core_brate = st_fx->core_brate;
-
- /* save synthesis for core switching */
- test();
- IF( EQ_16( st_fx->element_mode, EVS_MONO ) && NE_16( st_fx->core, AMR_WB_CORE ) )
- {
- Copy_Scale_sig( synth + NS2SA_FX2( st_fx->output_Fs, ACELP_LOOK_NS + DELAY_BWE_TOTAL_NS ), st_fx->old_synth_sw_fx, NS2SA_FX2( st_fx->output_Fs, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ), st_fx->hHQ_core->Q_old_postdec );
- }
- test();
- test();
- test();
- IF( ( ( LE_32( st_fx->core_brate, SID_2k40 ) ) && EQ_16( st_fx->cng_type, FD_CNG ) ) || ( st_fx->tcxonly && EQ_16( st_fx->codec_mode, MODE2 ) ) )
-
- {
- /* reset LP memories */
- set16_fx( st_fx->mem_MA_fx, 0, M );
- IF( EQ_32( st_fx->sr_core, INT_FS_16k ) )
- {
- Copy( GEWB2_Ave_fx, st_fx->mem_AR_fx, M );
- }
- ELSE
- {
- Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M );
- }
- }
- IF( EQ_16( st_fx->codec_mode, MODE2 ) )
- {
- test();
- IF( EQ_16( st_fx->use_partial_copy, 1 ) && EQ_16( st_fx->rf_frame_type, RF_NELP ) )
- {
- st_fx->last_nelp_mode_dec = 1;
- move16();
- }
- ELSE
- {
- st_fx->last_nelp_mode_dec = 0;
- move16();
- }
- }
-
- st_fx->prev_use_partial_copy = st_fx->use_partial_copy;
- move16();
-
- st_fx->prev_tilt_code_dec_fx = 0;
- move16();
-
- st_fx->prev_Q_exc = st_fx->Q_exc;
- move16();
-
- L_tmp = L_mult( st_fx->tilt_code_dec_fx[0], 4096 );
- FOR( i = 1; i < NB_SUBFR; i++ )
- {
- L_tmp = L_mac( L_tmp, st_fx->tilt_code_dec_fx[i], 4096 );
- }
- st_fx->prev_tilt_code_dec_fx = round_fx( L_tmp );
-
- IF( EQ_16( st_fx->core, HQ_CORE ) )
- {
- st_fx->prev_coder_type = GENERIC;
- move16();
- }
- ELSE IF( NE_16( st_fx->core, AMR_WB_CORE ) )
- {
- st_fx->prev_coder_type = st_fx->coder_type;
- move16();
- }
-
- test();
- IF( ( GT_32( st_fx->core_brate, SID_2k40 ) || ( GT_32( st_fx->core_brate, SID_1k75 ) && EQ_16( st_fx->core, AMR_WB_CORE ) ) ) && EQ_16( st_fx->first_CNG, 1 ) && st_fx->hTdCngDec != NULL )
- {
- if ( GE_16( st_fx->hTdCngDec->act_cnt, BUF_DEC_RATE ) )
- {
- st_fx->hTdCngDec->act_cnt = 0;
- move16();
- }
-
- st_fx->hTdCngDec->act_cnt = add( st_fx->hTdCngDec->act_cnt, 1 );
-
- test();
- if ( ( EQ_16( st_fx->hTdCngDec->act_cnt, BUF_DEC_RATE ) ) && ( st_fx->hTdCngDec->ho_hist_size > 0 ) )
- {
- st_fx->hTdCngDec->ho_hist_size = sub( st_fx->hTdCngDec->ho_hist_size, 1 );
- }
-
- st_fx->hTdCngDec->act_cnt2 = add( st_fx->hTdCngDec->act_cnt2, 1 );
- if ( GE_16( st_fx->hTdCngDec->act_cnt2, MIN_ACT_CNG_UPD ) )
- {
- st_fx->hTdCngDec->act_cnt2 = MIN_ACT_CNG_UPD;
- move16();
- }
- }
-
- test();
- test();
- if ( LE_32( st_fx->core_brate, SID_2k40 ) && st_fx->first_CNG == 0 && ( EQ_16( st_fx->cng_type, LP_CNG ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) )
- {
- st_fx->first_CNG = 1;
- move16();
- }
-
- /* update bandwidth switching parameters */
- st_fx->last_flag_cna = st_fx->flag_cna;
- move16();
- if ( st_fx->hFdCngDec != NULL )
- {
- st_fx->hFdCngDec->hFdCngCom->frame_type_previous = st_fx->m_frame_type;
- move16();
- }
-
- if ( GT_16( st_fx->element_mode, EVS_MONO ) )
- {
- st_fx->m_old_frame_type = st_fx->m_frame_type;
- move16();
- }
- test();
- test();
- /* update bandwidth switching parameters */
- IF( EQ_16( st_fx->core, AMR_WB_CORE ) )
- {
- st_fx->last_bwidth = WB;
-
- st_fx->prev_bws_cnt = 0;
- st_fx->bws_cnt = 0;
- st_fx->bws_cnt1 = 0;
- move16();
- move16();
- move16();
- move16();
- }
- ELSE IF( EQ_16( st_fx->codec_mode, MODE1 ) && ( ( GT_32( st_fx->core_brate, SID_2k40 ) ) || ( EQ_16( st_fx->element_mode, EVS_MONO ) ) ) )
- {
- updt_bw_switching_fx( st_fx, synth, Qpostd );
- }
- ELSE
- {
- st_fx->last_bwidth = st_fx->bwidth;
- st_fx->prev_bws_cnt = st_fx->bws_cnt;
- move32();
- move16();
- }
-
- /* synchronisation of CNG seeds*/
- test();
- test();
- test();
- test();
- IF( st_fx->hTdCngDec != NULL && ( st_fx->bfi || ( NE_32( st_fx->core_brate, FRAME_NO_DATA ) && NE_32( st_fx->core_brate, SID_2k40 ) ) ) && NE_16( st_fx->core, AMR_WB_CORE ) )
- {
- Random( &( st_fx->hTdCngDec->cng_seed ) );
- Random( &( st_fx->hTdCngDec->cng_ener_seed ) );
- }
-
- test();
- test();
- test();
- IF( st_fx->hTcxDec != NULL && st_fx->enablePlcWaveadjust && !concealWholeFrameTmp && NE_16( st_fx->core, AMR_WB_CORE ) )
- {
- /* update the parameters used in waveform adjustment */
- concealment_update2_x( (const Word16 *) synth, st_fx->hPlcInfo, hTcxDec->L_frameTCX );
- }
-
- st_fx->last_total_brate_ber = st_fx->total_brate;
- move32();
- IF( st_fx->bfi == 0 )
- {
- st_fx->last_total_brate = st_fx->total_brate;
- st_fx->last_bits_frame_nominal = st_fx->bits_frame_nominal;
- move32();
- move32();
- }
- st_fx->last_low_rate_mode = st_fx->low_rate_mode;
- move16();
- if ( LT_16( st_fx->ini_frame, MAX_FRAME_COUNTER ) )
- {
- st_fx->ini_frame = add( st_fx->ini_frame, 1 );
- }
-
- return;
-}
-
-
-static void ivas_updt_bw_switching_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word32 *synth, /* i : fixed point synthesis signal Qpost */
- const Word16 Qpost )
-{
- test();
- IF( EQ_32( st_fx->output_Fs, 32000 ) && EQ_16( st_fx->bwidth, SWB ) )
- {
- st_fx->tilt_swb_fx = ivas_calc_tilt_bwe_fx( synth, Qpost, L_FRAME32k );
- }
-
- st_fx->prev_enerLH_fx = st_fx->enerLH_fx; // enerLH_fx_Q
- move32();
- st_fx->prev_enerLL_fx = st_fx->enerLL_fx; // enerLL_fx_Q
- move32();
- st_fx->last_bwidth = st_fx->bwidth;
- move32();
-
- IF( EQ_16( st_fx->core, ACELP_CORE ) )
- {
- st_fx->last_inner_frame = L_FRAME32k;
- move16();
- test();
- if ( EQ_16( st_fx->bwidth, WB ) && ( st_fx->bws_cnt == 0 ) )
- {
- st_fx->last_inner_frame = L_FRAME16k;
- move16();
- }
- }
- ELSE
- {
- test();
- test();
- test();
- IF( !( GE_16( st_fx->last_inner_frame, L_FRAME16k ) && LE_16( inner_frame_tbl[st_fx->bwidth], L_FRAME16k ) && st_fx->bws_cnt > 0 && LT_16( st_fx->bws_cnt, N_WS2N_FRAMES ) ) )
- {
- st_fx->last_inner_frame = inner_frame_tbl[st_fx->bwidth];
- move16();
- }
- }
- st_fx->prev_bws_cnt = st_fx->bws_cnt;
- move16();
- return;
-}
-
-static Word32 sum_32_32_fx( const Word32 *x, Word16 length ) // Qx
+static Word32 sum_32_32_fx( const Word32 *x, const Word16 length ) // Qx
{
Word64 sum = 0;
Word16 i;
@@ -802,19 +470,20 @@ static Word32 sum_32_32_fx( const Word32 *x, Word16 length ) // Qx
return W_round64_L( sum );
}
-void ivas_updt_dec_common_fx(
+void updt_dec_common_fx(
Decoder_State *st_fx, /* i/o: decoder state structure */
Word16 hq_core_type_fx, /* i : HQ core type */
const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */
- const Word32 *synth, /* i : decoded synthesis Qpostd */
+ const Word16 *synth16, /* i : decoded synthesis Qpostd */
+ const Word32 *synth, /* i : decoded synthesis Qpostd */
const Word16 Qpostd /* i : Synthesis Q value */
)
{
Word16 i;
Word32 L_tmp;
-
TCX_DEC_HANDLE hTcxDec;
+
hTcxDec = st_fx->hTcxDec;
st_fx->last_codec_mode = st_fx->codec_mode;
@@ -845,11 +514,12 @@ void ivas_updt_dec_common_fx(
move16();
}
- IF( st_fx->hTcxDec != NULL )
+ IF( hTcxDec != NULL )
{
hTcxDec->tcxConceal_recalc_exc = 0;
move16();
}
+
test();
test();
test();
@@ -860,8 +530,7 @@ void ivas_updt_dec_common_fx(
test();
test();
test();
-
- if ( st_fx->bfi && ( LE_16( st_fx->last_good, UNVOICED_TRANSITION ) ) && ( GT_16( st_fx->clas_dec, UNVOICED_TRANSITION ) ) && st_fx->last_con_tcx && st_fx->hTcxDec != NULL )
+ if ( st_fx->bfi && ( LE_16( st_fx->last_good, UNVOICED_TRANSITION ) ) && ( GT_16( st_fx->clas_dec, UNVOICED_TRANSITION ) ) && st_fx->last_con_tcx && hTcxDec != NULL )
{
hTcxDec->tcxConceal_recalc_exc = 1;
move16();
@@ -869,6 +538,7 @@ void ivas_updt_dec_common_fx(
st_fx->last_good = st_fx->clas_dec;
move16();
}
+
IF( st_fx->use_partial_copy )
{
st_fx->prev_rf_frame_type = st_fx->rf_frame_type;
@@ -879,9 +549,10 @@ void ivas_updt_dec_common_fx(
st_fx->prev_rf_frame_type = INACTIVE;
move16();
}
+
test();
test();
- if ( EQ_16( st_fx->m_frame_type, ACTIVE_FRAME ) && ( st_fx->bfi != 0 || st_fx->use_partial_copy != 0 ) )
+ if ( EQ_16( st_fx->m_frame_type, ACTIVE_FRAME ) && ( NE_16( st_fx->bfi, 1 ) || st_fx->use_partial_copy != 0 ) )
{
st_fx->rf_flag_last = st_fx->rf_flag;
move16();
@@ -898,13 +569,23 @@ void ivas_updt_dec_common_fx(
st_fx->last_active_brate = st_fx->total_brate;
}
- move16();
- move16();
- if ( !st_fx->bfi || st_fx->element_mode == EVS_MONO )
+ IF( st_fx->element_mode == EVS_MONO )
{
st_fx->last_core = st_fx->core;
+ move16();
}
- st_fx->last_core_bfi = st_fx->core; /* also required for clean channel decoding */
+ ELSE
+ {
+ test();
+ if ( !st_fx->bfi || st_fx->element_mode == EVS_MONO )
+ {
+ st_fx->last_core = st_fx->core;
+ move16();
+ }
+ st_fx->last_core_bfi = st_fx->core; /* also required for clean channel decoding */
+ move16();
+ }
+
if ( st_fx->hHQ_core != NULL )
{
st_fx->hHQ_core->last_hq_core_type = hq_core_type_fx;
@@ -919,14 +600,13 @@ void ivas_updt_dec_common_fx(
move16();
st_fx->last_active_brate = st_fx->total_brate;
}
- /* INFO: moved from update_decoder_LPD_cng() */
+
if ( NE_16( st_fx->m_frame_type, ACTIVE_FRAME ) )
{
move16();
st_fx->last_is_cng = 1;
}
-
if ( !st_fx->bfi )
{
st_fx->last_core = st_fx->core;
@@ -942,8 +622,9 @@ void ivas_updt_dec_common_fx(
test();
IF( EQ_16( st_fx->element_mode, EVS_MONO ) && NE_16( st_fx->core, AMR_WB_CORE ) )
{
- Copy_Scale_sig_32_16( synth + NS2SA_FX2( st_fx->output_Fs, ACELP_LOOK_NS + DELAY_BWE_TOTAL_NS ), st_fx->old_synth_sw_fx, NS2SA_FX2( st_fx->output_Fs, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ), st_fx->hHQ_core->Q_old_postdec );
+ Copy_Scale_sig( synth16 + NS2SA_FX2( st_fx->output_Fs, ACELP_LOOK_NS + DELAY_BWE_TOTAL_NS ), st_fx->old_synth_sw_fx, NS2SA_FX2( st_fx->output_Fs, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ), st_fx->hHQ_core->Q_old_postdec );
}
+
test();
test();
test();
@@ -987,6 +668,7 @@ void ivas_updt_dec_common_fx(
Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M );
}
}
+
IF( EQ_16( st_fx->codec_mode, MODE2 ) )
{
test();
@@ -1035,7 +717,6 @@ void ivas_updt_dec_common_fx(
test();
IF( ( GT_32( st_fx->core_brate, SID_2k40 ) || ( GT_32( st_fx->core_brate, SID_1k75 ) && EQ_16( st_fx->core, AMR_WB_CORE ) ) ) && EQ_16( st_fx->first_CNG, 1 ) && st_fx->hTdCngDec != NULL )
{
-
if ( GE_16( st_fx->hTdCngDec->act_cnt, BUF_DEC_RATE ) )
{
st_fx->hTdCngDec->act_cnt = 0;
@@ -1045,12 +726,15 @@ void ivas_updt_dec_common_fx(
st_fx->hTdCngDec->act_cnt = add( st_fx->hTdCngDec->act_cnt, 1 );
test();
-
if ( ( EQ_16( st_fx->hTdCngDec->act_cnt, BUF_DEC_RATE ) ) && ( st_fx->hTdCngDec->ho_hist_size > 0 ) )
{
st_fx->hTdCngDec->ho_hist_size = sub( st_fx->hTdCngDec->ho_hist_size, 1 );
}
+ if ( EQ_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ st_fx->hTdCngDec->act_cnt2 = add( st_fx->hTdCngDec->act_cnt2, 1 );
+ }
if ( GE_16( st_fx->hTdCngDec->act_cnt2, MIN_ACT_CNG_UPD ) )
{
st_fx->hTdCngDec->act_cnt2 = MIN_ACT_CNG_UPD;
@@ -1101,7 +785,7 @@ void ivas_updt_dec_common_fx(
}
ELSE IF( EQ_16( st_fx->codec_mode, MODE1 ) && ( ( GT_32( st_fx->core_brate, SID_2k40 ) ) || ( EQ_16( st_fx->element_mode, EVS_MONO ) ) ) )
{
- ivas_updt_bw_switching_fx( st_fx, synth, Qpostd );
+ updt_bw_switching_fx( st_fx, synth16, synth, Qpostd );
}
ELSE
{
@@ -1125,10 +809,17 @@ void ivas_updt_dec_common_fx(
test();
test();
test();
- IF( st_fx->hTcxDec != NULL && st_fx->enablePlcWaveadjust && !concealWholeFrameTmp && NE_16( st_fx->core, AMR_WB_CORE ) )
+ IF( hTcxDec != NULL && st_fx->enablePlcWaveadjust && !concealWholeFrameTmp && NE_16( st_fx->core, AMR_WB_CORE ) )
{
/* update the parameters used in waveform adjustment */
- concealment_update2_x( (const Word16 *) synth, st_fx->hPlcInfo, hTcxDec->L_frameTCX );
+ IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ concealment_update2_x( (const Word16 *) synth16, st_fx->hPlcInfo, hTcxDec->L_frameTCX );
+ }
+ ELSE
+ {
+ concealment_update2_x( (const Word16 *) synth, st_fx->hPlcInfo, hTcxDec->L_frameTCX );
+ }
}
st_fx->last_total_brate_ber = st_fx->total_brate;
@@ -1140,8 +831,10 @@ void ivas_updt_dec_common_fx(
move32();
move32();
}
+
st_fx->last_low_rate_mode = st_fx->low_rate_mode;
move16();
+
if ( LT_16( st_fx->ini_frame, MAX_FRAME_COUNTER ) )
{
st_fx->ini_frame = add( st_fx->ini_frame, 1 );
diff --git a/lib_dec/waveadjust_fec_dec_fx.c b/lib_dec/waveadjust_fec_dec_fx.c
index f72dfde5cb9a448bfda91c4f4ab3a65da22e20fb..1776d31a236c3d7bf2be8f6be3ce7be37bff2e3f 100644
--- a/lib_dec/waveadjust_fec_dec_fx.c
+++ b/lib_dec/waveadjust_fec_dec_fx.c
@@ -840,65 +840,6 @@ void concealment_init_x(
}
-void concealment_init_ivas_fx(
- const Word16 L_frameTCX,
- T_PLCInfo_HANDLE hPlcInfo )
-{
- Word16 i;
-
- hPlcInfo->L_frameTCX = L_frameTCX;
- move16();
- hPlcInfo->Pitch_fx = 0;
- move16();
- hPlcInfo->T_bfi_fx = 0;
- move16();
- hPlcInfo->outx_new_n1_fx = 0;
- move16();
- hPlcInfo->nsapp_gain_fx = 0;
- move16();
- hPlcInfo->nsapp_gain_n_fx = 0;
- move16();
- hPlcInfo->ener_mean_fx = L_deposit_l( 15213 );
- hPlcInfo->ener_fx = L_deposit_l( 0 );
- hPlcInfo->zp_fx = L_frameTCX;
- move16();
- hPlcInfo->recovery_gain = 0;
- move16();
- hPlcInfo->step_concealgain_fx = 0;
- move16();
- hPlcInfo->concealment_method = TCX_NONTONAL;
- move16();
- hPlcInfo->subframe_fx = 0;
- move16();
- hPlcInfo->nbLostCmpt = (Word16) L_deposit_l( 0 );
- move16();
- hPlcInfo->seed = RANDOM_INITSEED;
- move16();
-
- FOR( i = 0; i < TCX_TONALITY_INIT_CNT; i++ )
- {
- hPlcInfo->TCX_Tonality[i] = 1;
- move16();
- }
- FOR( i = TCX_TONALITY_INIT_CNT; i < DEC_STATE_LEN; i++ )
- {
- hPlcInfo->TCX_Tonality[i] = 0;
- move16();
- }
- FOR( i = 0; i < MAX_POST_LEN; i++ )
- {
- hPlcInfo->Transient[i] = 1;
- move16();
- }
-
- FOR( i = 0; i < L_FRAME_MAX; i++ )
- {
- hPlcInfo->data_reci2_fx[i] = L_deposit_l( 0 );
- move32();
- }
- return;
-}
-
static Word16 own_random_fix( /* o : output random value */
Word16 *seed /* i/o: random seed Q0 */
)
@@ -924,7 +865,7 @@ void concealment_decode_fix(
IF( EQ_16( curr_mode, 1 ) )
{
/* copy the data of the last frame */
- MVR2R_WORD32( hPlcInfo->data_reci2_fx, invkoef, N );
+ Copy32( hPlcInfo->data_reci2_fx, invkoef, N );
*invkoef_scale = hPlcInfo->data_reci2_scale;
move16();
/* sign randomization */
@@ -1404,7 +1345,7 @@ static Word16 waveform_adj_fix(
/* maximum pitch lag is 3/4 Framesize; pitch125_data is reused for
temporary storage, since outdata2 (holding the pcm data of the
last good frame) is still needed and overlapbuf overlaps outdata2 */
- Copy( &sbuf[Framesize / 4], pitch125_data, shr( imult1616( 3, Framesize ), 2 ) );
+ Copy( &sbuf[shr( Framesize, 2 )], pitch125_data, shr( imult1616( 3, Framesize ), 2 ) );
hPlcInfo->nsapp_gain_fx = 0;
move16();
@@ -1416,10 +1357,10 @@ static Word16 waveform_adj_fix(
add_noise( sbuf, &( hPlcInfo->outx_new_n1_fx ), outdata2, tmp, &( hPlcInfo->nsapp_gain_fx ), &( hPlcInfo->nsapp_gain_n_fx ), 1 );
/* save current (noisy) output from IMDCT */
- MVR2R_WORD16( outx_new, hPlcInfo->data_noise, tmp );
+ Copy( outx_new, hPlcInfo->data_noise, tmp );
/* overlapbuf can now be filled with sbuf, needed for subsequently lost frames */
- Copy( pitch125_data, &overlapbuf[Framesize / 4], shr( imult1616( 3, Framesize ), 2 ) );
+ Copy( pitch125_data, &overlapbuf[shr( Framesize, 2 )], shr( imult1616( 3, Framesize ), 2 ) );
}
FOR( i = 0; i < Framesize; i++ )
{
@@ -1482,7 +1423,7 @@ void waveform_adj2_fix(
/* save current (noisy) output from IMDCT */
IF( bfi )
{
- MVR2R_WORD16( outx_new, noise_ptr, size );
+ Copy( outx_new, noise_ptr, size );
}
}
test();
diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c
index 91edc47a5bf9fadfcd14628755e9408acf72c9b9..b637047a2fa8f182e55c5cec56b5bdc0dcbba03d 100644
--- a/lib_enc/ACcontextMapping_enc_fx.c
+++ b/lib_enc/ACcontextMapping_enc_fx.c
@@ -1099,8 +1099,8 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
}
/*Shift old 4 bits, replace last 4 bits*/
- s = (UWord16) ( L_add( L_shl( s, 4 ), cp ) );
- t = (UWord16) L_and( s, 0xFF );
+ s = add( shl( s_and( s, 0x0F ), 4 ), cp );
+ t = s_and( s, 0xFF );
} /*end of the 2-tuples loop*/
}
@@ -1564,7 +1564,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
cp = add( 12, esc_nb ); /* Q0 */
}
/*shift old bits and replace last 4 bits*/
- s = (UWord16) L_add( L_shl( s, 4 ), cp );
+ s = add( shl( s_and( s, 0x0F ), 4 ), cp );
t = s_and( s, 0xFF );
} /*end of the 2-tuples loop*/
diff --git a/lib_enc/FEC_enc_fx.c b/lib_enc/FEC_enc_fx.c
index d6db81232ee9376c593bcaf04828c7e3bc90d869..3be0ff74c399dafafe2093c70288201e6cbd9585 100644
--- a/lib_enc/FEC_enc_fx.c
+++ b/lib_enc/FEC_enc_fx.c
@@ -3,12 +3,11 @@
====================================================================================*/
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-#include "rom_com.h" /* Static table prototypes */
-#include "prot_fx.h" /* Function prototypes */
-#include "prot_fx_enc.h" /* Function prototypes */
-#include "ivas_prot_fx.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
+#include "rom_com.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
+#include "prot_fx_enc.h" /* Function prototypes */
/*============================================================================*/
@@ -63,6 +62,7 @@ void FEC_encode_fx(
move16();
sign = 0;
move16();
+
test();
test();
IF( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) && acelp_cfg.FEC_mode > 0 )
@@ -70,6 +70,7 @@ void FEC_encode_fx(
/*-----------------------------------------------------------------*
* encode signal class (not needed for VC mode since it is clearly voiced) (2 bits)
*-----------------------------------------------------------------*/
+
IF( NE_16( coder_type, VOICED ) )
{
/* encode signal clas with 2 bits */
@@ -94,12 +95,14 @@ void FEC_encode_fx(
index = 3;
move16();
}
+
push_indice( hBstr, IND_FEC_CLAS, index, FEC_BITS_CLS );
}
/*-----------------------------------------------------------------*
* encode frame energy (5 bits)
*-----------------------------------------------------------------*/
+
IF( GT_16( acelp_cfg.FEC_mode, 1 ) ) /* GENERIC and VOICED frames */
{
/* frame energy (maximum energy per pitch period for voiced frames or mean energy per sample over 2nd halframe for unvoiced frames) */
@@ -114,14 +117,16 @@ void FEC_encode_fx(
Ltmp = Mpy_32_16( enr_lg_ent, enr_lg_frac, LG10_s3_0 ); /* Q14 */
tmpS = extract_h( L_shl( Ltmp, 1 ) ); /* Q15 + 1 -> Q0*/
- tmpS = s_min( tmpS, 31 );
+ tmpS = s_min( tmpS, FEC_ENR_QLIMIT );
tmpS = s_max( tmpS, 0 );
push_indice( hBstr, IND_FEC_ENR, tmpS, FEC_BITS_ENR );
}
+
/*-----------------------------------------------------------------*
* Encode last glottal pulse position (8 bits)
*-----------------------------------------------------------------*/
+
IF( GT_16( acelp_cfg.FEC_mode, 2 ) ) /* GENERIC frames */
{
/* retrieve the last glottal pulse position of the previous frame */
@@ -197,8 +202,8 @@ void FEC_encode_fx(
*-------------------------------------------------------------------*/
void FEC_lsf_estim_enc_fx(
- Encoder_State *st_fx, /* i : Encoder static memory */
- Word16 *lsf /* o : estimated LSF vector Qlog2(2.56)*/
+ Encoder_State *st_fx, /* i : Encoder static memory */
+ Word16 *lsf /* o : estimated LSF vector Qlog2(2.56)*/
)
{
Word16 i;
@@ -262,9 +267,11 @@ void FEC_lsf_estim_enc_fx(
move16();
}
}
+
/*----------------------------------------------------------------------*
* Extrapolate LSF vector
*----------------------------------------------------------------------*/
+
tmp = sub( 32767, alpha ); /* Q15 */
/* extrapolate the old LSF vector */
FOR( i = 0; i < M; i++ )
@@ -292,175 +299,3 @@ void FEC_lsf_estim_enc_fx(
return;
}
-
-/*-------------------------------------------------------------------*
- * FEC_encode()
- *
- * Encoder supplementary information for FEC
- *-------------------------------------------------------------------*/
-
-void FEC_encode_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */
- const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_Synth*/
- const Word16 coder_type, /* i : type of coder Q0*/
- Word16 clas, /* i : signal clas for current frame Q0*/
- const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/
- const Word16 *res, /* i : LP residual signal frame Qx*/
- Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/
- const Word16 L_frame, /* i : Frame length Q0*/
- const Word32 total_brate, /* i : total codec bitrate Q0*/
- const Word16 Q_synth /* i : input scaling */
-)
-{
- Word16 tmpS, index;
- Word16 maxi, sign, tmp_FER_pitch;
- Word32 enr_q, Ltmp;
- Word16 exp_enrq;
-
- tmpS = 0;
- move16();
- enr_q = 1;
- move16();
- sign = 0;
- move16();
- test();
- test();
- IF( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) && acelp_cfg.FEC_mode > 0 )
- {
- /*-----------------------------------------------------------------*
- * encode signal class (not needed for VC mode since it is clearly voiced) (2 bits)
- *-----------------------------------------------------------------*/
- IF( NE_16( coder_type, VOICED ) )
- {
- /* encode signal clas with 2 bits */
- test();
- IF( clas == UNVOICED_CLAS )
- {
- index = 0;
- move16();
- }
- ELSE IF( EQ_16( clas, VOICED_TRANSITION ) || EQ_16( clas, UNVOICED_TRANSITION ) )
- {
- index = 1;
- move16();
- }
- ELSE IF( EQ_16( clas, VOICED_CLAS ) )
- {
- index = 2;
- move16();
- }
- ELSE
- {
- index = 3;
- move16();
- }
- push_indice( hBstr, IND_FEC_CLAS, index, FEC_BITS_CLS );
- }
-
- /*-----------------------------------------------------------------*
- * encode frame energy (5 bits)
- *-----------------------------------------------------------------*/
- IF( GT_16( acelp_cfg.FEC_mode, 1 ) ) /* GENERIC and VOICED frames */
- {
- /* frame energy (maximum energy per pitch period for voiced frames or mean energy per sample over 2nd halframe for unvoiced frames) */
- /*frame_ener( L_frame, clas, synth, fpit[(L_frame>>6)-1], &enr_q, 0 );*/
- Word32 synth32[L_FRAME16k];
- Copy_Scale_sig_16_32_DEPREC( synth, synth32, L_FRAME16k, 0 ); /* Qsynth */
- fer_energy_fx( L_frame, clas, synth32, Q_synth, shr_r( fpit[( L_frame >> 6 ) - 1], 6 ), &enr_q, L_frame );
- exp_enrq = sub( 31, shl( Q_synth, 1 ) );
-
- test();
- test();
- if ( EQ_16( clas, VOICED_CLAS ) || EQ_16( clas, ONSET ) || EQ_16( clas, SIN_ONSET ) ) /* Voiced or Onset current frame */
- {
- exp_enrq = 31;
- move16();
- }
- /* linearly quantize the energy in the range 0 : FEC_ENR_STEP : 96 dB */
- /*tmpS = (short)( 10.0 * log10( enr_q + 0.001f ) / FEC_ENR_STEP )*/ /*To be converted fl_2_fx*/
-
- Ltmp = Mpy_32_32( BASOP_Util_Log10( enr_q, exp_enrq ), 894784853 /* 10 / FEC_ENR_STEP Q28 */ ); // Q 25 + 28 - 31 = Q22
- IF( Ltmp < 0 )
- {
- tmpS = extract_l( L_negate( L_shr( L_negate( Ltmp ), Q22 ) ) ); /* Q0 */
- }
- ELSE
- {
- tmpS = extract_l( L_shr( Ltmp, Q22 ) ); /* Q0 */
- }
-
- tmpS = s_min( tmpS, FEC_ENR_QLIMIT );
- tmpS = s_max( tmpS, 0 );
-
- push_indice( hBstr, IND_FEC_ENR, tmpS, FEC_BITS_ENR );
- }
- /*-----------------------------------------------------------------*
- * Encode last glottal pulse position (8 bits)
- *-----------------------------------------------------------------*/
-
- IF( GT_16( acelp_cfg.FEC_mode, 2 ) ) /* GENERIC frames */
- {
- /* retrieve the last glottal pulse position of the previous frame */
- /* use the current pitch information to scale or not the quantization */
- tmp_FER_pitch = shr( fpit[0], 6 ); /* take the 1st subframe pit, since it is easier to get on decoder side */
- sign = 0;
- move16();
- maxi = *last_pulse_pos; /* Q0 */
- move16();
- IF( maxi < 0 )
- {
- sign = 1;
- move16();
- /*maxi = -maxi; */
- maxi = negate( maxi );
- }
-
- if ( GE_16( tmp_FER_pitch, 128 ) )
- {
- maxi = shr( maxi, 1 );
- }
-
- if ( GT_16( maxi, 127 ) )
- {
- /* better not use the glottal pulse position at all instead of using a wrong pulse */
- /* can happen only with pitch > 254 and max pit = 289 and should happen very rarely */
- maxi = 0;
- move16();
- }
-
- if ( EQ_16( sign, 1 ) )
- {
- maxi = add( maxi, 128 ); /* use 8 bits (MSB represent the sign of the pulse) Q0*/
- }
-
- push_indice( hBstr, IND_FEC_POS, maxi, FEC_BITS_POS );
- }
- maxi = 0;
- move16();
-
- /* If bitrate < 24k4, then the pitch
- is not represented in the same domain (12.k instead of 16k) */
- test();
- IF( GE_16( clas, VOICED_CLAS ) && GE_32( total_brate, ACELP_24k40 ) )
- {
- /*maxi = findpulse( L_frame, res, (short)(fpit[(L_frame>>6)-1]), 0, &sign ); */
- maxi = findpulse_fx( L_frame, res, shr_r( fpit[( L_frame >> 6 ) - 1], 6 ), 0, &sign );
- if ( EQ_16( sign, 1 ) )
- {
- /*maxi = -maxi;*/
- maxi = negate( maxi );
- }
- }
-
- *last_pulse_pos = maxi; /* Q0 */
- move16();
- }
- ELSE
- {
- *last_pulse_pos = 0;
- move16();
- }
-
- return;
-}
diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c
index ff4c684e838c33e383021cd56e61be3292302b23..c5dc5e51196e8e1a18583a0705b8ce5f4728fe2a 100644
--- a/lib_enc/acelp_core_enc_fx.c
+++ b/lib_enc/acelp_core_enc_fx.c
@@ -95,12 +95,9 @@ ivas_error acelp_core_enc_fx(
ivas_error error;
error = IVAS_ERR_OK;
- test();
- IF( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && LE_32( st_fx->core_brate, SID_2k40 ) )
- {
- /* Core was ACELP because of DTX in MDCT-Stereo, but SID encoding for that is done in separate function */
- return error;
- }
+
+ (void) hStereoTD;
+ (void) ener_fx;
/*------------------------------------------------------------------*
* Initialization
*------------------------------------------------------------------*/
@@ -196,31 +193,17 @@ ivas_error acelp_core_enc_fx(
move16();
}
- /* TD stereo */
- test();
- IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) )
- {
- tdm_lp_reuse_flag = hStereoTD->tdm_lp_reuse_flag;
- tdm_low_rate_mode = hStereoTD->tdm_low_rate_mode;
- tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag;
- tdm_Pri_pitch_buf = hStereoTD->tdm_Pri_pitch_buf_fx;
- }
- ELSE
{
tdm_lp_reuse_flag = 0;
tdm_low_rate_mode = 0;
move16();
move16();
- if ( EQ_16( st_fx->element_mode, IVAS_SCE ) && st_fx->low_rate_mode )
- {
- tdm_low_rate_mode = 1;
- move16();
- }
tdm_Pitch_reuse_flag = 0;
tdm_Pri_pitch_buf = NULL;
move16();
move16();
}
+
/*-----------------------------------------------------------------*
* ACELP@12k8 / ACELP@16k switching
*-----------------------------------------------------------------*/
@@ -293,9 +276,10 @@ ivas_error acelp_core_enc_fx(
{
/* Run CNG post parameter update */
cng_params_postupd_fx( hTdCngEnc->ho_circ_ptr, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf,
- hTdCngEnc->cng_brate_buf, hTdCngEnc->ho_env_circ_fx );
+ hTdCngEnc->cng_brate_buf, hTdCngEnc->ho_env_circ_fx, EVS_MONO, -1 );
+
/* encode CNG parameters */
- CNG_enc_fx( st_fx, Aq_fx, inp_fx, ener_fx, lsp_mid_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sub( Q_new, 1 ), q_env, &sid_bw );
+ CNG_enc_fx( st_fx, Aq_fx, inp_fx, lsp_mid_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sub( Q_new, 1 ), q_env, &sid_bw );
/* comfort noise generation */
CNG_exc_fx( st_fx->core_brate, st_fx->L_frame, &hTdCngEnc->Enew_fx, &hTdCngEnc->cng_seed, exc_fx, exc2_fx, &hTdCngEnc->lp_ener_fx, st_fx->last_core_brate,
@@ -436,7 +420,7 @@ ivas_error acelp_core_enc_fx(
if ( !tdm_lp_reuse_flag )
{
- lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, st_fx->Nb_ACELP_frames, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, Q_new );
+ lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, NULL, Q_new );
}
/*---------------------------------------------------------------*
@@ -510,7 +494,7 @@ ivas_error acelp_core_enc_fx(
config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag, tc_subfr_fx, 0, &nb_bits, unbits_fx, 0, &uc_two_stage_flag, 0, 0, st_fx->idchan, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
/* redo LSF quantization */
- lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, st_fx->Nb_ACELP_frames, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, Q_new );
+ lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, 0, -1, NULL, Q_new );
/* recalculation of LP residual (filtering through A[z] filter) */
calc_residu_fx( st_fx, inp_fx, res_fx, Aq_fx );
@@ -551,21 +535,11 @@ ivas_error acelp_core_enc_fx(
E_UTIL_deemph2( sub( Q_new, 1 ), syn1_fx, st_fx->preemph_fac, st_fx->L_frame, &hLPDmem->syn[M] );
Copy( syn1_fx + st_fx->L_frame - M - 1, hLPDmem->syn, M + 1 ); // Q_syn
- test();
- IF( st_fx->element_mode > EVS_MONO && st_fx->hTcxEnc != NULL )
- {
- Copy( syn1_fx + st_fx->L_frame / 2, st_fx->hTcxEnc->Txnq, st_fx->L_frame / 2 ); // Q_syn
- }
-
/*--------------------------------------------------------------------------------------*
* Modify the excitation signal when the noise is stationary
*--------------------------------------------------------------------------------------*/
- test();
- test();
- test();
- test();
- IF( !( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) && NE_16( nelp_mode, 1 ) && !( EQ_16( st_fx->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) )
+ IF( NE_16( nelp_mode, 1 ) )
{
L_epsP[0] = L_Comp( epsP_h_fx[2], epsP_l_fx[2] );
move32();
@@ -640,7 +614,7 @@ ivas_error acelp_core_enc_fx(
IF( !st_fx->Opt_SC_VBR )
{
/* Apply a non linearity to the SHB excitation */
- non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, coder_type, voice_factors_fx, st_fx->L_frame );
+ non_linearity_fx( st_fx->element_mode, bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, coder_type, voice_factors_fx, st_fx->L_frame );
}
test();
if ( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, FRAME_NO_DATA ) )
@@ -658,9 +632,8 @@ ivas_error acelp_core_enc_fx(
IF( hTdCngEnc != NULL && ( st_fx->Opt_DTX_ON != 0 ) && ( GT_32( st_fx->core_brate, SID_2k40 ) ) )
{
/* update CNG parameters in active frames */
- cng_params_upd_fx( lsp_new_fx, exc_fx, st_fx->L_frame, &hTdCngEnc->ho_circ_ptr, hTdCngEnc->ho_ener_circ_fx,
- &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx, Q_new, ENC, NULL, &hTdCngEnc->cng_buf_cnt,
- hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hDtxEnc->last_active_brate );
+ cng_params_upd_fx( lsp_new_fx, exc_fx, st_fx->L_frame, &hTdCngEnc->ho_circ_ptr, hTdCngEnc->ho_ener_circ_fx, &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx,
+ Q_new, ENC, NULL, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hDtxEnc->last_active_brate, EVS_MONO, -1 );
IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
@@ -694,11 +667,13 @@ ivas_error acelp_core_enc_fx(
return error;
}
+
/*-------------------------------------------------------------------*
* acelp_core_enc_ivas_fx()
*
* ACELP core encoder
*--------------------------------------------------------------------*/
+
ivas_error acelp_core_enc_ivas_fx(
Encoder_State *st, /* i/o: encoder state structure */
const Word16 inp[], /* i : input signal of the current frame Q_new*/
@@ -717,7 +692,7 @@ ivas_error acelp_core_enc_ivas_fx(
Word16 *unbits, /* o : number of unused bits Q0*/
STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */
Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/
- Word16 Q_new )
+ const Word16 Q_new )
{
Word16 i, nBits; /* reserved bits */
LPD_state_HANDLE hLPDmem; /* i/o: acelp memories */
@@ -726,14 +701,10 @@ ivas_error acelp_core_enc_ivas_fx(
Word32 int_fs;
Word16 nb_bits; /* parameters handling */
- /* SC-VBR - back-up memories for LSF quantizer and synthesis filter */
- Word16 pstreaklen;
Word16 sid_bw = -1;
move16();
- Word16 next_force_sf_bck;
Word16 uc_two_stage_flag;
Word16 position;
- Word16 ppp_mode, nelp_mode;
Word16 tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag;
/* bitstream */
@@ -748,18 +719,12 @@ ivas_error acelp_core_enc_ivas_fx(
Word16 tmp_noise_fx; /* NB post-filter long-term noise energy*/
Word16 old_bwe_exc_fx[( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2]; /* excitation buffer Q_new */
Word16 *bwe_exc_fx; /* excitation for SWB TBE Q_new */
- Word16 mem_MA_fx[M], mem_AR_fx[M], lsp_new_bck_fx[M], /*lsf_new_bck_fx[M],*/ lsp_mid_bck_fx[M], mem_syn_bck_fx[M];
- Word32 Bin_E_fx[L_FFT], Bin_E_old_fx[L_FFT / 2];
- Word16 clip_var_fx, mem_w0_bck_fx, streaklimit_fx;
set16_fx( old_bwe_exc_fx, 0, ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 );
set16_fx( old_exc_fx, 0, L_EXC );
set16_fx( Aq, 0, NB_SUBFR16k * ( M + 1 ) );
set16_fx( syn_fx, 0, L_FRAME16k );
- Word16 tilt_code_bck_fx;
- Word32 gc_threshold_bck_fx;
- Word16 clip_var_bck_fx[6];
Word32 q_env_fx[NUM_ENV_CNG];
set32_fx( q_env_fx, 0, NUM_ENV_CNG );
set16_fx( exc2_fx, 0, L_FRAME16k );
@@ -882,36 +847,9 @@ ivas_error acelp_core_enc_ivas_fx(
position = -1;
move16();
- /* SC-VBR temporary variables */
- pstreaklen = 0;
- move16();
- clip_var_fx = 0;
- move16();
- mem_w0_bck_fx = 0;
- move16();
- streaklimit_fx = 0;
- move16();
-
- /* channel-aware mode */
- reset_rf_indices_fx( st );
-
- /* VBR modes */
- IF( st->Opt_SC_VBR )
- {
- ppp_mode = st->hSC_VBR->ppp_mode;
- nelp_mode = st->hSC_VBR->nelp_mode;
- }
- ELSE
- {
- ppp_mode = 0;
- nelp_mode = 0;
- }
- move16();
- move16();
test();
/* TD stereo */
-
IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) )
{
tdm_lp_reuse_flag = hStereoTD->tdm_lp_reuse_flag; // Q0
@@ -976,11 +914,11 @@ ivas_error acelp_core_enc_ivas_fx(
IF( st->rate_switching_reset )
{
/*extrapolation in case of unstable LSP*/
- int_lsp4_ivas_fx( st->L_frame, lsp_mid, lsp_mid, lsp_new, A, M, 0 );
+ int_lsp4_fx( st->L_frame, lsp_mid, lsp_mid, lsp_new, A, M, 0 );
}
ELSE
{
- int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, A, M, 0 );
+ int_lsp4_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, A, M, 0 );
}
/* Reset LPC mem */
@@ -1008,16 +946,17 @@ ivas_error acelp_core_enc_ivas_fx(
/*----------------------------------------------------------------*
* Encoding of CNG frames
*----------------------------------------------------------------*/
+
test();
IF( EQ_32( st->core_brate, SID_2k40 ) || st->core_brate == FRAME_NO_DATA )
{
IF( st->cng_type == LP_CNG )
{
/* Run CNG post parameter update */
- cng_params_postupd_ivas_fx( st->hTdCngEnc->ho_circ_ptr, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hTdCngEnc->ho_env_circ_fx, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth );
+ cng_params_postupd_fx( st->hTdCngEnc->ho_circ_ptr, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hTdCngEnc->ho_env_circ_fx, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth );
/* encode CNG parameters */
- CNG_enc_ivas_fx( st, Aq, inp, /*ener_fx,*/ lsp_mid, lsp_new, lsf_new_fx, &allow_cn_step, sub( Q_new, 1 ), q_env_fx, &sid_bw );
+ CNG_enc_fx( st, Aq, inp, lsp_mid, lsp_new, lsf_new_fx, &allow_cn_step, sub( Q_new, 1 ), q_env_fx, &sid_bw );
/* comfort noise generation */
CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngEnc->Enew_fx, &st->hTdCngEnc->cng_seed, exc_fx, exc2_fx, &st->hTdCngEnc->lp_ener_fx, st->last_core_brate,
@@ -1099,11 +1038,6 @@ ivas_error acelp_core_enc_ivas_fx(
move16();
st->hLPDmem->q_mem_syn = st->Q_syn;
move16();
- // Scaling Aq to Q12
- FOR( Word16 k = 0; k < NB_SUBFR16k; k++ )
- {
- Scale_sig( &Aq[( M + 1 ) * k], M + 1, sub( norm_s( Aq[( M + 1 ) * k] ), 2 ) );
- }
/* synthesis at 12.8kHz sampling rate */
syn_12k8_fx( st->L_frame, Aq, exc3_fx, syn1_fx, hLPDmem->mem_syn3, 1, sub( Q_new, 1 ), st->Q_syn );
@@ -1144,17 +1078,18 @@ ivas_error acelp_core_enc_ivas_fx(
/*----------------------------------------------------------------*
* Encoding of all other frames
*----------------------------------------------------------------*/
+
ELSE
{
+ Word16 temp = getScaleFactor16( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k );
+ Scale_sig( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k, temp ); /* Q_last_exc_dct_in + temp */
+ st->hGSCEnc->Q_last_exc_dct_in = add( st->hGSCEnc->Q_last_exc_dct_in, temp );
+ move16();
/*-----------------------------------------------------------------*
* Configure ACELP bit allocation
*-----------------------------------------------------------------*/
- Word16 temp = getScaleFactor16( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k );
- Scale_sig( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k, temp ); /* Q_last_exc_dct_in + temp */
- st->hGSCEnc->Q_last_exc_dct_in = add( st->hGSCEnc->Q_last_exc_dct_in, temp );
- move16();
nb_bits = 0;
move16();
st->acelp_cfg.FEC_mode = 0;
@@ -1162,11 +1097,7 @@ ivas_error acelp_core_enc_ivas_fx(
uc_two_stage_flag = 0;
move16();
- test();
- IF( !nelp_mode && !ppp_mode )
- {
- config_acelp1_fx( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
- }
+ config_acelp1_fx( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
/*-----------------------------------------------------------------*
* After inactive period, use the most up-to-date ISPs
@@ -1203,12 +1134,9 @@ ivas_error acelp_core_enc_ivas_fx(
* A[z] calculation
*-----------------------------------------------------------------*/
- /* SC-VBR & channel-aware mode - back-up memories for LSF quantizer and synthesis filter */
- lsf_syn_mem_backup_ivas_fx( st, &tilt_code_bck_fx, &gc_threshold_bck_fx, clip_var_bck_fx, &next_force_sf_bck, lsp_new, lsp_mid, &clip_var_fx, mem_AR_fx, mem_MA_fx, lsp_new_bck_fx, lsp_mid_bck_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, &mem_w0_bck_fx, &streaklimit_fx, &pstreaklen );
-
IF( !tdm_lp_reuse_flag )
{
- lsf_enc_ivas_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, st->GSC_IVAS_mode, tdm_lsfQ_PCh, Q_new );
+ lsf_enc_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, st->GSC_IVAS_mode, tdm_lsfQ_PCh, Q_new );
}
ELSE
{
@@ -1244,18 +1172,13 @@ ivas_error acelp_core_enc_ivas_fx(
st->stab_fac_fx = lsf_stab_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame ); // Q15
move16();
}
- // Scaling Aq to Q12
- FOR( Word16 k = 0; k < NB_SUBFR16k; k++ )
- {
- Scale_sig( &Aq[( M + 1 ) * k], M + 1, sub( norm_s( Aq[( M + 1 ) * k] ), 2 ) );
- }
test();
IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO )
{
/* Prepare ACB memory from last HQ frame */
tmpF_fx = hLPDmem->old_exc[0];
move16();
- PREEMPH_FX( hLPDmem->old_exc, st->preemph_fac, st->L_frame, &tmpF_fx );
+ preemph_fx( hLPDmem->old_exc, st->preemph_fac, st->L_frame, &tmpF_fx );
Copy( hLPDmem->old_exc + sub( st->L_frame, M ), hLPDmem->mem_syn, M ); /* Q_new */
Scale_sig( st->hLPDmem->mem_syn, M, sub( st->hLPDmem->q_mem_syn, Q_new ) );
Residu3_fx( Aq, hLPDmem->old_exc, old_exc_fx, st->L_frame, 0 );
@@ -1280,7 +1203,8 @@ ivas_error acelp_core_enc_ivas_fx(
*---------------------------------------------------------------*/
calc_residu_fx( st, inp, res_fx, Aq );
- calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag );
+
+ calculate_hangover_attenuation_gain_fx( st, &att_fx, vad_hover_flag );
IF( NE_16( att_fx, 32767 /* ONE_IN_Q15 */ ) )
{
@@ -1318,65 +1242,35 @@ ivas_error acelp_core_enc_ivas_fx(
{
IF( LE_16( st->coder_type, UNVOICED ) )
{
- tdm_low_rate_enc( st, Aq, res_fx, syn_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, 0 /*attack_flag*/, lsf_new_fx, &tmp_noise_fx, Q_new );
+ tdm_low_rate_enc_fx( st, Aq, res_fx, syn_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, 0 /*attack_flag*/, lsf_new_fx, &tmp_noise_fx, Q_new );
}
ELSE /* GENERIC */
{
- encod_gen_2sbfr( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 );
+ encod_gen_2sbfr_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 );
}
}
- ELSE IF( nelp_mode )
- {
- /* SC-VBR - NELP frames */
- encod_nelp_ivas_fx( st, inp, Aw, Aq, res_fx, syn_fx, &tmp_noise_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 );
- }
-
ELSE IF( EQ_16( st->coder_type, UNVOICED ) )
{
/* UNVOICED frames (Gauss. excitation) */
- encod_unvoiced_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, uc_two_stage_flag, res_fx, syn_fx, &tmp_noise_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 );
+ encod_unvoiced_fx( st, inp, Aw, Aq, Es_pred_fx, uc_two_stage_flag, res_fx, syn_fx, &tmp_noise_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 );
}
ELSE IF( EQ_16( st->coder_type, TRANSITION ) )
{
- encod_tran_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tc_subfr, position, unbits, 0, Q_new );
- }
- ELSE IF( ppp_mode )
- {
- /* SC-VBR - PPP frames */
- IF( ( error = encod_ppp_ivas_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 ) ) != IVAS_ERR_OK )
- {
- return error;
- }
-
- IF( st->hSC_VBR->bump_up ) /* PPP failed, bump up */
- {
- /* restore memories of LSF quantizer and synthesis filter */
- lsf_syn_mem_restore_ivas_fx( st, tilt_code_bck_fx, gc_threshold_bck_fx, clip_var_bck_fx, next_force_sf_bck, lsp_new, lsp_mid, clip_var_fx, mem_AR_fx, mem_MA_fx, lsp_new_bck_fx, lsp_mid_bck_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, mem_w0_bck_fx, streaklimit_fx, pstreaklen );
-
- /* Configure ACELP bit allocation */
- config_acelp1_fx( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, 0, &uc_two_stage_flag, 0, 0, st->idchan, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode );
-
- /* redo LSF quantization */
- lsf_enc_ivas_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, 0, NULL, Q_new );
-
- /* recalculation of LP residual (filtering through A[z] filter) */
- calc_residu_fx( st, inp, res_fx, Aq );
- st->hTdCngEnc->burst_ho_cnt = 0;
- move16();
-
- /* VOICED frames in SC-VBR */
- encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new );
- }
+ encod_tran_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tc_subfr, position, unbits, 0, Q_new );
}
ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( st->coder_type == INACTIVE && st->inactive_coder_type_flag ) )
{
/* AUDIO and INACTIVE frames (coded by GSC technology) */
+#ifndef FIX_1904_HARM_GSC_ENC
encod_audio_ivas_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, attack_flag, lsf_new_fx, &tmp_noise_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 );
+#else
+ encod_audio_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, attack_flag, lsf_new_fx, &tmp_noise_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 );
+#endif
}
ELSE
{
/* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */
- encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new );
+ encod_gen_voic_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new );
}
/* update mem_syn1_flt for ACELP core switching */
@@ -1384,8 +1278,8 @@ ivas_error acelp_core_enc_ivas_fx(
/* update old synthesis buffer - needed for ACELP internal sampling rate switching */
Copy( syn_fx + sub( st->L_frame, L_SYN_MEM ), hLPDmem->mem_syn_r, L_SYN_MEM ); // hLPDmem->q_mem_syn
- // st->Q_syn = Q_new - 1;
- Scale_sig( syn_fx, L_FRAME16k, sub( st->Q_syn, Q_new - 1 ) ); // Q_syn
+ Scale_sig( syn_fx, L_FRAME16k, sub( st->Q_syn, Q_new - 1 ) ); // Q_syn
+
/* save and delay synthesis to be used by SWB BWE */
IF( st->hBWE_FD != NULL )
{
@@ -1425,11 +1319,11 @@ ivas_error acelp_core_enc_ivas_fx(
/*--------------------------------------------------------------------------------------*
* Modify the excitation signal when the noise is stationary
*--------------------------------------------------------------------------------------*/
+
test();
test();
test();
- test();
- IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && NE_16( nelp_mode, 1 ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) )
+ IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) )
{
/* exc2 buffer is needed only for updating of Aq[] which is needed for core switching */
Copy( exc_fx, exc2_fx, st->L_frame ); // Q_new
@@ -1442,9 +1336,8 @@ ivas_error acelp_core_enc_ivas_fx(
* Encode supplementary information for Frame Error Concealment
*-----------------------------------------------------------------*/
- Scale_sig( syn_fx, L_FRAME, sub( s_min( st->Q_syn, Q_new ), st->Q_syn ) ); // min( st->Q_syn, Q_new )
- Scale_sig( res_fx, st->L_frame, sub( s_min( st->Q_syn, Q_new ), Q_new ) ); // min( st->Q_syn, Q_new )
- FEC_encode_ivas_fx( hBstr, st->acelp_cfg, syn_fx, st->coder_type, st->clas, pitch_buf, res_fx, &st->Last_pulse_pos, st->L_frame, st->total_brate, s_min( st->Q_syn, Q_new ) );
+ FEC_encode_fx( hBstr, st->acelp_cfg, syn_fx, st->coder_type, st->clas, pitch_buf, res_fx, &st->Last_pulse_pos, st->L_frame, st->total_brate, add( st->Q_syn, 1 ), 0 );
+
IF( st->hBWE_TD != NULL )
{
IF( EQ_16( st->L_frame, L_FRAME ) )
@@ -1460,9 +1353,11 @@ ivas_error acelp_core_enc_ivas_fx(
} /* end of active inp coding */
+
/*-----------------------------------------------------------------*
* Write ACELP unused bits
*-----------------------------------------------------------------*/
+
test();
test();
IF( NE_32( st->core_brate, SID_2k40 ) && st->core_brate != FRAME_NO_DATA && NE_32( st->core_brate, PPP_NELP_2k80 ) )
@@ -1491,9 +1386,7 @@ ivas_error acelp_core_enc_ivas_fx(
test();
test();
test();
- test();
- test();
- IF( ( EQ_16( st->last_Opt_SC_VBR, 1 ) && st->Opt_SC_VBR == 0 ) || ( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, WB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && !st->tdm_LRTD_flag ) )
+ IF( ( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, WB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && !st->tdm_LRTD_flag ) )
{
st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
move16();
@@ -1504,12 +1397,11 @@ ivas_error acelp_core_enc_ivas_fx(
test();
test();
test();
- test();
- IF( !st->Opt_SC_VBR && ( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) )
+ IF( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) )
{
/* Apply a non linearity to the SHB excitation */
Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( Q_new, 1 ), sub( st->hBWE_TD->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc
- non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, st->coder_type, voice_factors_fx, st->L_frame );
+ non_linearity_fx( st->element_mode, bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, st->coder_type, voice_factors_fx, st->L_frame );
Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( Q_new, 1 ), sub( st->hBWE_TD->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc
}
@@ -1555,10 +1447,9 @@ ivas_error acelp_core_enc_ivas_fx(
st->hTdCngEnc->cng_Qexc_buf[ii] = q_exc;
move16();
}
- cng_params_upd_ivas_fx( lsp_new, exc_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx,
- &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, q_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt,
- st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode,
- st->hFdCngEnc->hFdCngCom->CngBandwidth );
+
+ cng_params_upd_fx( lsp_new, exc_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx,
+ q_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth );
IF( EQ_16( st->L_frame, L_FRAME ) )
{
@@ -1576,6 +1467,7 @@ ivas_error acelp_core_enc_ivas_fx(
st->hTdCngEnc->ho_16k_lsp[st->hTdCngEnc->ho_circ_ptr] = 1;
}
move16();
+
/* efficient DTX hangover control */
IF( GT_16( st->hTdCngEnc->burst_ho_cnt, 1 ) )
{
@@ -1583,15 +1475,6 @@ ivas_error acelp_core_enc_ivas_fx(
}
}
- /* SC-VBR update of average data rate */
- IF( EQ_16( st->vad_flag, 1 ) )
- {
- /* reset in case of bitrate switching in EVS */
- if ( st->hSC_VBR != NULL )
- {
- update_average_rate_fx( st->hSC_VBR, st->core_brate );
- }
- }
pop_wmops();
return error;
diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c
index 2f51be28e414ed30a524fe93305985f51a158c48..b4c10b9acc5795dd1ab5351e9cca00f36055c22e 100644
--- a/lib_enc/acelp_core_switch_enc_fx.c
+++ b/lib_enc/acelp_core_switch_enc_fx.c
@@ -15,15 +15,12 @@
* Local function prototypes
*---------------------------------------------------------------------*/
-static void encod_gen_voic_core_switch_fx( Encoder_State *st_fx, const Word16 L_frame_fx, const Word16 inp_fx[], const Word16 Aq_fx[], const Word16 A_fx[], const Word16 T_op[], Word16 *exc_fx, const Word32 core_bitrate_fx, Word16 shift, Word16 Q_new );
-
-static void encod_gen_voic_core_switch_ivas_fx( Encoder_State *st_fx, const Word16 L_frame_fx, const Word16 inp_fx[], const Word16 Aq_fx[], const Word16 A_fx[], const Word16 T_op[], Word16 *exc_fx, const Word32 core_bitrate_fx, Word16 shift, Word16 Q_new );
+static void encod_gen_voic_core_switch_fx( Encoder_State *st_fx, const Word16 L_frame_fx, const Word16 inp_fx[], const Word16 Aq_fx[], const Word16 A_fx[], const Word16 T_op[], Word16 *exc_fx, const Word32 core_bitrate_fx, const Word16 shift, const Word16 Q_new );
static void bwe_switch_enc_fx( Encoder_State *st_fx, const Word16 *new_speech );
-static void bwe_switch_enc_ivas_fx( Encoder_State *st_fx, const Word16 *new_speech );
+static Word16 dotprod_satcont( const Word16 *x, const Word16 *y, const Word16 qx, const Word16 qy, Word16 *qo, const Word16 len, const Word16 delta );
-static Word16 dotprod_satcont( const Word16 *x, const Word16 *y, Word16 qx, Word16 qy, Word16 *qo, Word16 len, Word16 delta );
/*-------------------------------------------------------------------*
* acelp_core_switch_enc_fx()
@@ -36,8 +33,8 @@ void acelp_core_switch_enc_fx(
const Word16 inp12k8[], /* i : input signal @12.8 kHz Q0 */
const Word16 inp16k[], /* i : input signal @16 kHz Q0 */
const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/
- Word16 shift,
- Word16 Q_new )
+ const Word16 shift,
+ const Word16 Q_new )
{
Word16 i, j, T_op[2];
Word16 old_exc[L_EXC], *exc; /* excitation signal buffer Qexc */
@@ -164,117 +161,6 @@ void acelp_core_switch_enc_fx(
}
-void acelp_core_switch_enc_ivas_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 inp12k8[], /* i : input signal @12.8 kHz Q0 */
- const Word16 inp16k[], /* i : input signal @16 kHz Q0 */
- const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/
- Word16 shift,
- Word16 Q_new )
-{
- Word16 i, j, T_op[2];
- Word16 old_exc[L_EXC], *exc; /* excitation signal buffer Qexc */
- const Word16 *inp;
- Word32 cbrate;
- Word16 Aq[2 * ( M + 1 )];
- LPD_state_HANDLE hLPDmem; /* ACELP LPDmem memories */
- BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
- Word16 nb_bits;
- UWord16 value;
-
- hLPDmem = st_fx->hLPDmem;
-
- /* initializations */
- exc = &old_exc[L_EXC_MEM];
- move16(); /* pointer to excitation signal in the current frame */
- Copy( hLPDmem->old_exc, old_exc, L_EXC_MEM ); /*now old_exc has the same scaling as st_fx->old_exc; need to change later? */
-
- Copy( st_fx->old_Aq_12_8_fx, Aq, M + 1 ); /* Q12 */
- Copy( st_fx->old_Aq_12_8_fx, Aq + ( M + 1 ), M + 1 ); /* Q12 */
- T_op[0] = st_fx->pitch[0]; /* Q12 */
- move16();
- T_op[1] = st_fx->pitch[1]; /* Q12 */
- move16();
-
- /*----------------------------------------------------------------*
- * set switching frame bitrate
- *----------------------------------------------------------------*/
-
- IF( EQ_16( st_fx->last_L_frame, L_FRAME ) ) /* ACELP@12k8 core */
- {
- inp = inp12k8; /* Q0 */
-
- IF( GT_32( st_fx->core_brate, ACELP_24k40 ) )
- {
- cbrate = L_add( ACELP_24k40, 0 );
- }
- ELSE
- {
- cbrate = L_add( st_fx->core_brate, 0 );
- }
- }
- ELSE /* ACELP@16k core */
- {
- inp = inp16k; /* Q0 */
-
- IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
- {
- cbrate = L_add( ACELP_8k00, 0 );
- }
- ELSE IF( LE_32( st_fx->core_brate, ACELP_14k80 ) )
- {
- cbrate = L_add( ACELP_14k80, 0 );
- }
- ELSE
- {
- cbrate = L_min( st_fx->core_brate, ACELP_22k60 ); /* Q0 */
- }
- }
-
- IF( NE_16( st_fx->last_L_frame, L_FRAME ) )
- {
- T_op[0] = shr( add( round_fx( L_shl( L_mult( 20480 /* 1.25 in Q14 */, T_op[0] ), 2 ) ), 1 ), 1 ); /* Q0 */
- move16();
- T_op[1] = shr( add( round_fx( L_shl( L_mult( 20480 /* 1.25 in Q14 */, T_op[1] ), 2 ) ), 1 ), 1 ); /* Q0 */
- move16();
- }
-
- /*----------------------------------------------------------------*
- * Excitation encoding
- *----------------------------------------------------------------*/
-
- config_acelp1_fx( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ );
-
- encod_gen_voic_core_switch_ivas_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new );
-
- /*----------------------------------------------------------------*
- * bit-stream: modify the layer of sub frame CELP
- *----------------------------------------------------------------*/
-
- i = find_indice( hBstr, TAG_ACELP_SUBFR_LOOP_START, &value, &nb_bits ); /* Q0 */
-
- while ( hBstr->ind_list[i].id == TAG_ACELP_SUBFR_LOOP_START )
- {
- push_indice( hBstr, IND_CORE_SWITCHING_CELP_SUBFRAME, hBstr->ind_list[i].value, hBstr->ind_list[i].nb_bits );
- i++;
- }
- delete_indice( hBstr, TAG_ACELP_SUBFR_LOOP_START );
-
- /*----------------------------------------------------------------*
- * BWE encoding
- *----------------------------------------------------------------*/
-
- test();
- test();
- IF( !( ( EQ_16( st_fx->last_L_frame, L_FRAME16k ) && EQ_16( inner_frame_tbl[st_fx->bwidth], L_FRAME16k ) ) || EQ_16( inner_frame_tbl[st_fx->bwidth], L_FRAME8k ) ) )
- {
- bwe_switch_enc_ivas_fx( st_fx, (const Word16 *) st_fx->old_input_signal_fx );
- }
-
- return;
-}
-
-
/*-------------------------------------------------------------------*
* encod_gen_voic_core_switch()
*
@@ -290,8 +176,8 @@ static void encod_gen_voic_core_switch_fx(
const Word16 T_op[], /* i : open loop pitch Q0*/
Word16 *exc, /* i/o: current non-enhanced excitation Q_exc*/
const Word32 core_bitrate, /* i : switching frame bitrate Q0*/
- Word16 shift,
- Word16 Q_new )
+ const Word16 shift,
+ const Word16 Q_new )
{
Word16 res[L_SUBFR]; /* residual signal Qexc */
Word16 Ap[M + 1]; /* A(z) with spectral expansion Q12 */
@@ -374,7 +260,6 @@ static void encod_gen_voic_core_switch_fx(
* ACELP subframe loop
*------------------------------------------------------------------*/
-
Copy( res, exc, L_SUBFR ); /* Q1 */
IF( EQ_16( L_frame, L_FRAME16k ) )
@@ -419,6 +304,7 @@ static void encod_gen_voic_core_switch_fx(
/*-----------------------------------------------------------------*
* LP filtering of the adaptive excitation, codebook target computation
*-----------------------------------------------------------------*/
+
lp_flag = st_fx->acelp_cfg.ltf_mode; /* Q0 */
lp_select = lp_filt_exc_enc_fx( MODE1, GENERIC, 0, exc, h1, xn, y1, xn2, L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */
@@ -432,11 +318,12 @@ static void encod_gen_voic_core_switch_fx(
*-----------------------------------------------------------------*/
inov_encode_fx( st_fx, core_bitrate, 0, L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, 0, -1, Aq, gain_pit, cn, exc,
- h2, hLPDmem->tilt_code, pitch, xn2, code, y2, &unbits, L_SUBFR, shift );
+ h2, hLPDmem->tilt_code, pitch, xn2, code, y2, &unbits, L_SUBFR, shift, 0 );
/*-----------------------------------------------------------------*
* Gain encoding
*-----------------------------------------------------------------*/
+
IF( EQ_16( L_frame, L_FRAME ) )
{
gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, 0, -1, xn, y1, shift_wsp, y2, code, st_fx->old_Es_pred_fx,
@@ -489,216 +376,6 @@ static void encod_gen_voic_core_switch_fx(
return;
}
-static void encod_gen_voic_core_switch_ivas_fx(
- Encoder_State *st_fx, /* i/o: state structure */
- const Word16 L_frame, /* i : length of the frame Q0*/
- const Word16 inp[], /* i : input signal Q0*/
- const Word16 Aq[], /* i : LP coefficients Q12*/
- const Word16 A[], /* i : unquantized A(z) filter Q12*/
- const Word16 T_op[], /* i : open loop pitch Q0*/
- Word16 *exc, /* i/o: current non-enhanced excitation Q_exc*/
- const Word32 core_bitrate, /* i : switching frame bitrate Q0*/
- Word16 shift,
- Word16 Q_new )
-{
- Word16 res[L_SUBFR]; /* residual signal Qexc */
- Word16 Ap[M + 1]; /* A(z) with spectral expansion Q12 */
- Word16 xn[L_SUBFR]; /* Target vector for pitch search */
- Word16 xn2[L_SUBFR]; /* Target vector for codebook search */
- Word16 cn[L_SUBFR]; /* Target vector in residual domain */
- Word16 h1[L_SUBFR + ( M + 1 )]; /* Impulse response vector */
-
- Word16 code[L_SUBFR]; /* Fixed codebook excitation Q9 */
- Word16 y1[L_SUBFR]; /* Filtered adaptive excitation */
- Word16 y2[L_SUBFR]; /* Filtered algebraic excitation */
- Word16 gain_pit; /* Pitch gain Q15 */
- Word16 voice_fac; /* Voicing factor Q15 */
- Word32 gain_code; /* Gain of code Q16 */
- Word16 gain_inov; /* inovation gain */
- Word16 i, gcode16; /* tmp variables */
- Word16 T0, T0_frac; /* close loop integer pitch and fractional part */
- Word16 T0_min, T0_max; /* pitch variables */
-
- Word16 pitch, tmp16; /* floating pitch value */
- Word16 g_corr[6]; /* ACELP correl, values + gain pitch */
- Word16 clip_gain; /* ISF clip gain */
-
- Word16 unbits; /* number of unused bits for PI */
- Word32 norm_gain_code;
- Word16 pitch_limit_flag;
- Word32 L_tmp, Lgcode;
- Word16 shift_wsp;
- Word16 h2[L_SUBFR + ( M + 1 )];
- Word16 dummyF[NB_SUBFR16k];
- Word16 lp_select, lp_flag;
- Word16 q_h1;
- LPD_state_HANDLE hLPDmem; /* ACELP LPDmem memories */
- BSTR_ENC_HANDLE hBstr;
-
- hLPDmem = st_fx->hLPDmem;
- hBstr = st_fx->hBstr;
-
- // TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc;
-
- /*------------------------------------------------------------------*
- * Initializations
- *------------------------------------------------------------------*/
-
- shift_wsp = add( Q_new, shift );
-
- unbits = 0;
- move16();
-
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- T0_max = PIT_MAX;
- move16();
- T0_min = PIT_MIN;
- move16();
- }
- ELSE /* L_frame == L_FRAME16k */
- {
- T0_max = PIT16k_MAX;
- move16();
- T0_min = PIT16k_MIN;
- move16();
- }
-
- /*------------------------------------------------------------------*
- * Calculation of LP residual (filtering through A[z] filter)
- *------------------------------------------------------------------*/
-
- tmp16 = st_fx->L_frame; /* Q0 */
- move16();
- st_fx->L_frame = L_SUBFR;
- move16();
- calc_residu_fx( st_fx, inp, res, Aq );
-
- // hTdCngEnc->burst_ho_cnt = 0;
- st_fx->L_frame = tmp16; /* Q0 */
- move16();
-
- /*------------------------------------------------------------------*
- * ACELP subframe loop
- *------------------------------------------------------------------*/
-
-
- Copy( res, exc, L_SUBFR ); /* Q_exc */
-
- IF( EQ_16( L_frame, L_FRAME16k ) )
- {
- weight_a_fx( A, Ap, GAMMA16k, M ); /* Bandwidth expansion of A(z) filter coefficients */
- find_targets_ivas_fx( inp, hLPDmem->mem_syn, 0, &( hLPDmem->mem_w0 ), Aq, res, L_SUBFR, Ap, PREEMPH_FAC_16k, xn, cn, h1 );
- }
- ELSE
- {
- weight_a_fx( A, Ap, GAMMA1, M ); /* Bandwidth expansion of A(z) filter coefficients */
- find_targets_ivas_fx( inp, hLPDmem->mem_syn, 0, &( hLPDmem->mem_w0 ), Aq, res, L_SUBFR, Ap, TILT_FAC_FX, xn, cn, h1 );
- }
-
- q_h1 = sub( 14, norm_s( h1[0] ) );
- Copy_Scale_sig( h1, h2, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/
-
- /* scaling of xn[] to limit dynamic at 12 bits */
- Scale_sig( xn, L_SUBFR, shift ); /* Q_new */
-
- /*----------------------------------------------------------------*
- * Close-loop pitch search and quantization
- * Adaptive exc. construction
- *----------------------------------------------------------------*/
-
- set16_fx( dummyF, -1, NB_SUBFR16k ); /* hack to signal ACELP->HQ switching frame */
- pitch = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/, st_fx->element_mode, Q_new ); /* Q6 */
-
-
- /*-----------------------------------------------------------------*
- * Find adaptive exitation
- *-----------------------------------------------------------------*/
-
- pred_lt4_ivas_fx( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
-
- /*-----------------------------------------------------------------*
- * Gain clipping test to avoid unstable synthesis on frame erasure
- * or in case of floating point encoder & fixed p. decoder
- *-----------------------------------------------------------------*/
-
- clip_gain = gp_clip_fx( st_fx->element_mode, core_bitrate, st_fx->voicing_fx, 0, GENERIC, xn, st_fx->clip_var_fx, sub( shift_wsp, 1 ) ); /* Q0 */
-
- /*-----------------------------------------------------------------*
- * LP filtering of the adaptive excitation, codebook target computation
- *-----------------------------------------------------------------*/
- lp_flag = st_fx->acelp_cfg.ltf_mode; /* Q0 */
- Scale_sig( h1, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14+shift*/
- lp_select = lp_filt_exc_enc_fx( MODE1, GENERIC, 0, exc, h1, xn, y1, xn2, L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */
- IF( EQ_16( lp_flag, NORMAL_OPERATION ) )
- {
- push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 );
- }
-
- /*-----------------------------------------------------------------*
- * Innovation encoding
- *-----------------------------------------------------------------*/
-
- inov_encode_ivas_fx( st_fx, core_bitrate, 0, L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, 0, -1, Aq, gain_pit, cn, exc,
- h2, hLPDmem->tilt_code, pitch, xn2, code, y2, &unbits, L_SUBFR, shift, Q_new );
-
- /*-----------------------------------------------------------------*
- * Gain encoding
- *-----------------------------------------------------------------*/
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, 0, -1, xn, y1, shift_wsp, y2, code, st_fx->old_Es_pred_fx,
- &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain );
- }
- ELSE
- {
- gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, 0, -1, xn, y1, shift_wsp, y2, code, st_fx->old_Es_pred_fx,
- &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain );
- }
- gp_clip_test_gain_pit_fx( st_fx->element_mode, core_bitrate, gain_pit, st_fx->clip_var_fx );
-
- Lgcode = L_shl( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/
- gcode16 = round_fx( Lgcode ); /* Q0 */
-
- // hLPDmem->tilt_code = Est_tilt2( exc + 0, gain_pit, code, gain_code, &voice_fac, shift );
- // Q_new or shift ?? ->Qexc
- hLPDmem->tilt_code = est_tilt_ivas_fx( exc + 0, gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); /* Q15 */
- move16();
- /*-----------------------------------------------------------------*
- * Construct adaptive part of the excitation
- *-----------------------------------------------------------------*/
-
- FOR( i = 0; i < L_SUBFR; i++ )
- {
- /* code in Q9, gain_pit in Q14 */
- L_tmp = L_mult( gcode16, code[i] ); /* Q10 */
- L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 */
- L_tmp = L_mac_sat( L_tmp, exc[i], gain_pit );
- L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here */
- exc[i] = round_fx_sat( L_tmp ); /* Q_exc */
- move16();
- }
-
- /* write reserved bits */
- IF( unbits )
- {
- push_indice( hBstr, IND_UNUSED, 0, unbits );
- }
-
- /*-----------------------------------------------------------------*
- * long term prediction on the 2nd sub frame
- *-----------------------------------------------------------------*/
-
- pred_lt4_ivas_fx( &exc[L_SUBFR], &exc[L_SUBFR], T0, T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
-
- FOR( i = L_SUBFR; i < 2 * L_SUBFR; i++ )
- {
- exc[i] = round_fx_sat( L_shl_sat( L_mult_sat( exc[i], gain_pit ), 1 ) ); /* Q_exc */
- move16();
- }
-
- return;
-}
/*-------------------------------------------------------------------*
* bwe_switch_enc()
@@ -850,155 +527,14 @@ static void bwe_switch_enc_fx(
}
-static void bwe_switch_enc_ivas_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 *new_speech_fx /* i : original input signal Q0 */
-)
-{
-
- Word16 k, Loverlapp_fx, d1m_fx, maxd1_fx, ind1_fx, gapsize_fx;
- Word16 delta_fx, fdelay_fx;
- const Word16 *hp_filter_fx;
- const Word16 *fpointers_tab[6] = { hp12800_16000_fx, hp12800_32000_fx, hp12800_48000_fx, hp16000_48000_fx, hp16000_32000_fx, hp16000_48000_fx };
- Word16 tmp, shift;
- const Word16 *ptmp;
- Word16 tmp_mem_fx[2 * L_FILT48k], tmp_mem2_fx[2 * L_FILT48k], hb_synth_tmp_fx[480];
- Word16 Fs_kHz;
- Word16 q_tmp1, q_tmp2, Qmc, Qsq;
- Word32 L_tmp1, L_tmp2, L_tmp3, min_sq_cross_fx;
- Word16 accA_fx, accB_fx, min_corr_fx, E1_fx, E2_fx, gain_fx;
- Word16 synth_subfr_bwe_fx[SWITCH_MAX_GAP]; /* synthesized bwe for core switching */
- Word16 n, L;
- BSTR_ENC_HANDLE hBstr;
-
- hBstr = st_fx->hBstr;
- L = NS2SA_FX2( st_fx->input_Fs, FRAME_SIZE_NS );
-
- /* set multiplication factor according to the sampling rate */
- tmp = extract_l( L_shr( st_fx->input_Fs, 14 ) );
- delta_fx = add( tmp, 1 );
- Fs_kHz = shl( delta_fx, 4 );
- tmp = add( tmp, i_mult2( 3, ( sub( st_fx->last_L_frame, L_FRAME ) != 0 ) ) );
- ptmp = fpointers_tab[tmp];
- move16();
-
- hp_filter_fx = ptmp;
- fdelay_fx = i_mult2( 16, delta_fx );
- IF( EQ_16( st_fx->last_L_frame, L_FRAME ) )
- {
- fdelay_fx = i_mult2( 20, delta_fx );
- }
-
- n = i_mult2( N16_CORE_SW, delta_fx );
-
- set16_fx( tmp_mem_fx, 0, 2 * L_FILT48k );
- set16_fx( tmp_mem2_fx, 0, 2 * L_FILT48k );
-
- Loverlapp_fx = i_mult2( delta_fx, SWITCH_OVERLAP_8k * 2 );
- gapsize_fx = i_mult2( delta_fx, NS2SA( 16000, SWITCH_GAP_LENGTH_NS ) );
-
- shift = sub( add( add( shr( L, 1 ), n ), Loverlapp_fx ), gapsize_fx );
- Copy( new_speech_fx + shift, synth_subfr_bwe_fx, add( gapsize_fx, fdelay_fx ) );
- Copy( new_speech_fx + sub( shift, fdelay_fx ), tmp_mem_fx, fdelay_fx );
-
- tmp = add( gapsize_fx, fdelay_fx );
- fir_fx( synth_subfr_bwe_fx, hp_filter_fx, synth_subfr_bwe_fx, tmp_mem_fx, tmp, fdelay_fx, 0, 0 );
- Copy( synth_subfr_bwe_fx + shr( fdelay_fx, 1 ), synth_subfr_bwe_fx, sub( gapsize_fx, shr( fdelay_fx, 1 ) ) );
-
- tmp = i_mult2( Fs_kHz, 10 );
- fir_fx( new_speech_fx, hp_filter_fx, hb_synth_tmp_fx, tmp_mem2_fx, tmp, fdelay_fx, 1, 0 );
-
- min_sq_cross_fx = L_negate( 1 );
- Qsq = 0;
- move16();
- min_corr_fx = 0;
- move16();
- Qmc = 0;
- move16();
- d1m_fx = 0;
- move16();
-
- maxd1_fx = sub( tmp, add( gapsize_fx, fdelay_fx ) );
-
- IF( EQ_16( delta_fx, 2 ) )
- {
- maxd1_fx = shr( maxd1_fx, 1 );
- }
- ELSE IF( EQ_16( delta_fx, 3 ) )
- {
- maxd1_fx = extract_h( L_mult( maxd1_fx, 10923 ) );
- }
-
- /* find delay */
- ptmp = &hb_synth_tmp_fx[fdelay_fx];
-
- FOR( k = 0; k < maxd1_fx; k++ )
- {
- accA_fx = dotprod_satcont( ptmp, ptmp, 0, 0, &q_tmp1, gapsize_fx, delta_fx );
- accB_fx = dotprod_satcont( ptmp, synth_subfr_bwe_fx, 0, 0, &q_tmp2, gapsize_fx, delta_fx );
- ptmp += delta_fx;
- L_tmp1 = L_mult0( accB_fx, accB_fx ); /*2*q_tmp2; */
- L_tmp2 = Mult_32_16( L_tmp1, min_corr_fx ); /*2*q_tmp2+Qmc-15 */
- L_tmp3 = Mult_32_16( min_sq_cross_fx, accA_fx ); /*Qsq+q_tmp1-15 */
- shift = s_min( add( shl( q_tmp2, 1 ), Qmc ), add( q_tmp1, Qsq ) );
- L_tmp2 = L_shr( L_tmp2, sub( add( shl( q_tmp2, 1 ), Qmc ), shift ) );
- L_tmp3 = L_shr( L_tmp3, sub( add( q_tmp1, Qsq ), shift ) );
-
- IF( GE_32( L_tmp2, L_tmp3 ) )
- {
- d1m_fx = k;
- move16();
- min_corr_fx = accA_fx;
- move16();
- Qmc = q_tmp1;
- move16();
- min_sq_cross_fx = L_add( L_tmp1, 0 );
- Qsq = shl( q_tmp2, 1 );
- move16();
- }
- }
-
- push_indice( hBstr, IND_CORE_SWITCHING_AUDIO_DELAY, d1m_fx, AUDIODELAYBITS );
-
- tmp = add( i_mult2( d1m_fx, delta_fx ), fdelay_fx );
- ptmp = &hb_synth_tmp_fx[tmp];
- move16();
- E1_fx = dotprod_satcont( synth_subfr_bwe_fx, synth_subfr_bwe_fx, 0, 0, &q_tmp1, gapsize_fx, 1 );
- E2_fx = dotprod_satcont( ptmp, ptmp, 0, 0, &q_tmp2, gapsize_fx, 1 );
-
- IF( !E1_fx )
- {
- E1_fx = shl( 1, 14 );
- q_tmp1 = 14;
- move16();
- }
- IF( !E2_fx )
- {
- E2_fx = shl( 1, 14 );
- q_tmp2 = 14;
- move16();
- }
-
- tmp = div_s( shl( 1, 14 ), E1_fx ); /*Q(29-q_tmp1) */
- L_tmp1 = L_mult( tmp, E2_fx ); /*30-q_tmp1+q_tmp2 */
- q_tmp2 = sub( q_tmp1, q_tmp2 ); /*30-q_tmp2 */
- L_tmp1 = L_shl( L_tmp1, sub( q_tmp2, 24 ) );
- gain_fx = round_fx_sat( Isqrt( L_tmp1 ) ); /*Q12 */
- ind1_fx = usquant_fx( gain_fx, &gain_fx, shr( MINVALUEOFFIRSTGAIN_FX, 1 ), shr( DELTAOFFIRSTGAIN_FX, 4 ), ( 1 << NOOFGAINBITS1 ) );
- push_indice( hBstr, IND_CORE_SWITCHING_AUDIO_GAIN, ind1_fx, NOOFGAINBITS1 );
-
- return;
-}
-
-
static Word16 dotprod_satcont(
const Word16 *x, /* qx */
const Word16 *y, /* qy */
- Word16 qx,
- Word16 qy,
+ const Word16 qx,
+ const Word16 qy,
Word16 *qo,
- Word16 len, /* Q0 */
- Word16 delta /* Q0 */
+ const Word16 len, /* Q0 */
+ const Word16 delta /* Q0 */
)
{
Word16 tmp_tabx[L_FRAME48k], tmp_taby[L_FRAME48k];
diff --git a/lib_enc/acelp_enc_util_fx.c b/lib_enc/acelp_enc_util_fx.c
index 26ca2a020123a1c560ef400954049903ec854b0a..cd93c7f13973c4ee3e1c3b801b96fba2483e925d 100644
--- a/lib_enc/acelp_enc_util_fx.c
+++ b/lib_enc/acelp_enc_util_fx.c
@@ -6,7 +6,6 @@
#include
#include
#include "options.h"
-//#include "prot_fx.h"
#include "basop_util.h"
#include "cnst.h"
#include "prot_fx.h" /* Function prototypes */
@@ -176,30 +175,6 @@ void E_ACELP_conv(
}
}
-void E_ACELP_conv_ivas_fx(
- const Word16 xn2[], /* i Qnew - 1*/
- const Word16 h2[], /* i Q12*/
- Word16 cn2[] /* o Qnew*/
-)
-{
- Word16 i, k;
- Word32 L_tmp;
-
- FOR( k = 0; k < L_SUBFR; k++ )
- {
- /*cn2[k] = xn2[k]; */
- Word64 L_tmp_64;
- L_tmp_64 = W_deposit32_l( L_mult0( xn2[k], 0x800 ) ); /* Qnew -1 + 12 */
- FOR( i = 0; i < k; i++ )
- {
- /*cn2[k]-=cn2[i]*h2[k-i];*/
- L_tmp_64 = W_msu0_16_16( L_tmp_64, cn2[i], h2[k - i] ); /*Qnew + 11*/
- }
- L_tmp = W_sat_l( L_tmp_64 ); /* Qnew + 11 */
- cn2[k] = round_fx_sat( L_shl_sat( L_tmp, 5 ) ); /* Qnew*/
- move16();
- }
-}
void E_ACELP_build_code(
Word16 nb_pulse, /* i Q0*/
const Word16 codvec[], /* i Q0*/
diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c
index 9b20100ba13a75354a9069b188cc48b38997d9c2..876cc94fdea57a9c793cf063f1817efe14352b32 100644
--- a/lib_enc/amr_wb_enc_fx.c
+++ b/lib_enc/amr_wb_enc_fx.c
@@ -136,7 +136,7 @@ void amr_wb_enc_fx(
/* Updates in case of HQ -> AMR-WB IO mode switching */
Q_new = 0;
move16(); /* prevent compiler warning only*/
- core_switching_pre_enc_fx( st, NULL, NULL, 0, 0 );
+ core_switching_pre_enc_fx( st, NULL, 0, NULL, 0, 0, 0 );
set16_fx( hf_gain_fx, 0, NB_SUBFR );
set16_fx( old_inp, 0, L_INP_12k8 );
@@ -310,7 +310,7 @@ void amr_wb_enc_fx(
}
/* apply DTX hangover for CNG analysis */
- vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), 0, &vad_hover_flag, NULL, NULL );
+ vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), 0, &vad_hover_flag, NULL, NULL, NULL );
/*-----------------------------------------------------------------*
* Select SID or FRAME_NO_DATA frame if DTX enabled
@@ -332,7 +332,7 @@ void amr_wb_enc_fx(
move16();
}
- dtx_fx( st, vad_flag_dtx, inp, Q_new );
+ dtx_fx( st, -1, -1, vad_flag_dtx, inp, Q_new );
/*----------------------------------------------------------------*
* Noise energy down-ward update and total noise energy estimation
@@ -459,7 +459,7 @@ void amr_wb_enc_fx(
IF( EQ_32( st->core_brate, SID_1k75 ) || EQ_32( st->core_brate, FRAME_NO_DATA ) )
{
/* encode CNG parameters */
- CNG_enc_fx( st, Aq, inp, ener, isp_new, isp_new, isf_new, &allow_cn_step, sub( Q_new, 1 ), q_env, &sid_bw );
+ CNG_enc_fx( st, Aq, inp, isp_new, isp_new, isf_new, &allow_cn_step, sub( Q_new, 1 ), q_env, &sid_bw );
/* comfort noise generation */
CNG_exc_fx( st->core_brate, L_FRAME, &hTdCngEnc->Enew_fx, &hTdCngEnc->cng_seed, exc, exc2, &hTdCngEnc->lp_ener_fx,
@@ -579,7 +579,7 @@ void amr_wb_enc_fx(
updt_enc_fx( st, old_exc, pitch_buf, 0, Aq, isf_new, isp_new, dummy_buf );
/* update main codec parameters */
- updt_enc_common_fx( st, Etot, Q_new );
+ updt_enc_common_fx( st, Q_new );
#ifdef DEBUG_MODE_INFO
dbgwrite( &st->codec_mode, sizeof( short ), 1, input_frame, "res/codec" );
diff --git a/lib_enc/analy_lp_fx.c b/lib_enc/analy_lp_fx.c
index 8739661168a5dd90e7c596fd8b261f9b572ac612..162b87ea488cc23b5a98d80b8882628fd0cace1a 100644
--- a/lib_enc/analy_lp_fx.c
+++ b/lib_enc/analy_lp_fx.c
@@ -39,7 +39,7 @@ void analy_lp_fx(
const Word32 Core_sr, /* i :(q0) Internal core sampling rate */
const Word16 element_mode, /* i : element mode */
const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */
- Word16 Q_new, /* i : stores Q for speech */
+ const Word16 Q_new, /* i : stores Q for speech */
Word16 *Q_r /*stores q for ener*/
)
{
@@ -115,12 +115,12 @@ void analy_lp_fx(
IF( EQ_16( sec_chan_low_rate, 1 ) )
{
/* LSP interpolation */
- int_lsp4_ivas_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 );
+ int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 );
}
ELSE
{
/* LSP interpolation */
- int_lsp4_ivas_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 );
+ int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 );
}
Copy( lsp_new, lsp_old, M ); /* Q15 */
*ener = L_Comp( epsP_h[M], epsP_l[M] ); /* Q_r */
@@ -152,7 +152,7 @@ void analy_lp_AMR_WB_fx(
Word16 isf_new[], /* o : current frame ISPs Q15*/
Word16 Top, /* i : open loop pitch lag Q0*/
Word16 Tnc, /* i : open loop pitch gain Qx*/
- Word16 Q_new,
+ const Word16 Q_new,
Word16 *Q_r )
{
Word16 r_h[M + 1]; /* Autocorrelations of windowed speech MSB */
diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c
index 6909c512d280002efcc43550c36cd99802ec061f..e7d09c786d06b16f010c79b5529d09ca260195f1 100644
--- a/lib_enc/analy_sp_fx.c
+++ b/lib_enc/analy_sp_fx.c
@@ -20,6 +20,15 @@ static void find_enr( Word16 data[], Word32 band[], Word32 *ptE, Word32 *LEtot,
static void ivas_find_enr( Word16 *data, Word16 q_data, Word32 *band, Word16 *q_band, Word32 *ptE, Word16 *q_ptE, Word64 *LEtot, const Word16 min_band, const Word16 max_band, Word32 *Bin_E, Word16 BIN_FREQ_FX, Word32 *band_energies );
+/*-------------------------------------------------------------------*
+ * Local constants
+ *-------------------------------------------------------------------*/
+
+#define SIZE_256 256
+#define NUM_STAGE_256 7
+#define SIZE2_256 ( SIZE_256 / 2 )
+
+
/*-------------------------------------------------------------------*
* analy_sp_fx()
*
@@ -404,7 +413,7 @@ static void find_enr_dft_ivas_fx(
move16();
L_lerp_fx( BinE_fx, Bin_E_fx, L_FFT / 2, STEREO_DFT_N_12k8_ENC / 2, q_Bin_E );
- MVR2R_WORD32( Bin_E_fx, ptE_fx, VOIC_BINS ); // *q_Bin_E
+ Copy32( Bin_E_fx, ptE_fx, VOIC_BINS ); // *q_Bin_E
*q_ptE = *q_Bin_E;
move16();
@@ -593,10 +602,10 @@ void ivas_analy_sp_fx(
hCPE->hStereoDft->DFT_fx_e[0] = sub( hCPE->hStereoDft->DFT_fx_e[0], exp );
move16();
find_enr_dft_ivas_fx( hCPE, input_Fs, hCPE->hStereoDft->DFT_fx[0], pt_bands, q_fr_bands, lf_E, q_lf_E, &LEtot, min_band, max_band, Bin_E, q_Bin_E, band_energies, sub( Q31, hCPE->hStereoDft->DFT_fx_e[0] ) );
- MVR2R_WORD32( lf_E, lf_E + VOIC_BINS, VOIC_BINS );
- MVR2R_WORD32( Bin_E, Bin_E + ( L_FFT / 2 ), L_FFT / 2 );
- MVR2R_WORD32( band_energies, band_energies + NB_BANDS, NB_BANDS );
- MVR2R_WORD32( pt_bands, pt_bands + NB_BANDS, NB_BANDS );
+ Copy32( lf_E, lf_E + VOIC_BINS, VOIC_BINS );
+ Copy32( Bin_E, Bin_E + ( L_FFT / 2 ), L_FFT / 2 );
+ Copy32( band_energies, band_energies + NB_BANDS, NB_BANDS );
+ Copy32( pt_bands, pt_bands + NB_BANDS, NB_BANDS );
/* Average total log energy over both half-frames */
*Etot = -838860800 /* 10.f * log10f(0.00001f) in Q24 : This is when LEtot is 0*/;
diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c
index 253c05956aa1c9f71deecfa9fc5c376d238924b7..e54dfeda293c25c78b4754231af24600de21acb7 100644
--- a/lib_enc/avq_cod_fx.c
+++ b/lib_enc/avq_cod_fx.c
@@ -609,7 +609,7 @@ void AVQ_cod_lpc_fx(
Word16 i, l, pos;
Word32 I;
Word32 x1[8];
- UWord16 I16;
+ UWord16 I16 = 0;
/* quantize all subvector using estimated gain */
diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c
index 33e00aae1d6b6422ac3c30b6b12fb977f629615e..2e04b986ff3813d6ba305070632b388d41938a4b 100644
--- a/lib_enc/bw_detect_fx.c
+++ b/lib_enc/bw_detect_fx.c
@@ -16,7 +16,9 @@
/*-------------------------------------------------------------------*
* Local constants
*-------------------------------------------------------------------*/
+
#define BWD_MIN_BRATE_WIDER_BW_MDCT IVAS_48k
+#define BWD_MIN_BRATE_WIDER_BW_MASA IVAS_48k
#define BWD_MIN_BRATE_WIDER_BW_ISM IVAS_32k
#define BWD_MAX_BRATE_WIDER_BW_MDCT IVAS_80k
#define BWD_MAX_BRATE_WIDER_BW_ISM IVAS_64k
@@ -28,8 +30,6 @@
#define BWD_COUNT_WIDER_BW 10
#define BWD_COUNT_WIDER_BW_MDCT 0
-#define BWD_N_BINS_MAX 13
-
#define CLDFB_ENER_OFFSET_FX 26214 /* 1.6 in Q14 */
/*-------------------------------------------------------------------*
@@ -40,8 +40,8 @@
void bw_detect_fx(
Encoder_State *st, /* i/o: Encoder State */
- const Word16 signal_in[], /* i : input signal */
- Word16 *spectrum, /* i : MDCT spectrum Q_spec */
+ const Word16 signal_in[], /* i : input signal */
+ Word16 *spectrum, /* i : MDCT spectrum Q_spec */
const Word32 *enerBuffer, /* i : CLDFB Energy Q31 */
const Word16 *cldfbBuf_Ener_Exp, /* i : CLDFB Energy Exponent */
const IVAS_FORMAT ivas_format, /* i : IVAS format */
@@ -75,12 +75,16 @@ void bw_detect_fx(
test();
test();
test();
+ test();
+ test();
if ( st->ini_frame > 0 && ( ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && ( GE_32( st->element_brate, BWD_MIN_BRATE_WIDER_BW_MDCT ) || mct_on ) ) ||
- ( EQ_16( ivas_format, ISM_FORMAT ) && GE_32( st->element_brate, BWD_MIN_BRATE_WIDER_BW_ISM ) ) ) )
+ ( st->is_ism_format && GE_32( st->element_brate, BWD_MIN_BRATE_WIDER_BW_ISM ) ) ||
+ ( EQ_16( ivas_format, MASA_FORMAT ) && GE_32( st->element_brate, BWD_MIN_BRATE_WIDER_BW_MASA ) ) ) )
{
bwd_count_wider_bw = BWD_COUNT_WIDER_BW_MDCT;
move16();
}
+
IF( GT_32( st->input_Fs, 8000 ) )
{
diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c
index e51dd4884a0c67da51b2261aa6754de2c62cd071..e622c9857e3c3ffbd9c80d2769ad8e1cd079e62b 100644
--- a/lib_enc/cng_enc_fx.c
+++ b/lib_enc/cng_enc_fx.c
@@ -1,6 +1,7 @@
/*====================================================================================
EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0
====================================================================================*/
+
#include
#include "options.h" /* Compilation switches */
#include "cnst.h" /* Common constants */
@@ -8,9 +9,9 @@
#include "rom_com.h" /* Static table prototypes */
#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
-//#include "basop_mpy.h"
-
#include
+
+
/*---------------------------------------------------------------------*
* Local constants
*---------------------------------------------------------------------*/
@@ -20,24 +21,26 @@
#define INT_H 50
#define INT_L 8
+
/*---------------------------------------------------------------------*
* Local function prototypes
*---------------------------------------------------------------------*/
+
static void shb_CNG_encod_fx( Encoder_State *st_fx, const Word16 update_fx );
static Word16 shb_DTX_fx( Encoder_State *st_fx, const Word16 *shb_speech_fx, const Word16 *syn_12k8_16k );
-static Word16 shb_DTX_ivas_fx( Encoder_State *st, const Word16 *shb_speech_fx, const Word16 *syn_12k8_16k_fx );
-static void shb_CNG_encod_ivas_fx( Encoder_State *st, const Word16 update );
+
+
/*---------------------------------------------------------------------*
* CNG_enc()
*
* Confort noise generation for the coder
*---------------------------------------------------------------------*/
+
void CNG_enc_fx(
Encoder_State *st_fx, /* i/o: State structure */
Word16 Aq[], /* o : LP coefficients Q12 */
const Word16 *speech, /* i : pointer to current frame input speech buffer Q_new */
- Word32 L_enr, /* i : residual energy from Levinson-Durbin Q6 */
- const Word16 *lsp_mid, /* i : mid frame LSPs Q15 */
+ const Word16 *lsp_mid, /* i : mid frame LSPs Q15 */
Word16 *lsp_new, /* i/o: current frame ISPs Q15 */
Word16 *lsf_new, /* i/o: current frame ISFs Qlog2(2.56) */
Word16 *allow_cn_step, /* o : allow CN step Q0 */
@@ -49,46 +52,34 @@ void CNG_enc_fx(
Word16 i, j, ptr;
Word16 m1;
Word16 res[L_FRAME16k];
- Word16 step_inv = 0;
- move16();
+ Word16 step_inv;
Word16 hi, lo;
- Word16 maxl = 0;
- move16();
- Word16 num_bits = 0;
- move16();
- Word16 step = 0;
- move16();
- Word16 *pt_res;
- const Word16 *pt_sp;
+ Word16 maxl;
+ Word16 num_bits;
+ Word16 step;
Word16 enr;
- Word32 L_tmp, L_ener;
+ Word32 L_tmp;
Word16 k, tmp1;
Word16 weights;
Word16 sp_enr;
Word32 L_tmp1;
Word16 exp;
- Word16 m = 0;
- move16();
+ Word16 m;
Word16 tmp[HO_HIST_SIZE * M];
Word16 ll, s_ptr;
- Word16 tmpv, maxv, scale, att = 1;
- move16();
+ Word16 tmpv, att;
Word16 lsf_tmp[M];
Word32 C[M];
Word32 max_val[2];
Word16 max_idx[2];
Word16 ftmp_fx;
Word16 lsp_tmp[M];
- Word16 dev;
- Word16 max_dev;
- Word16 dist;
- Word16 max_idx1[2] = { 0, 0 };
- move16();
- move16();
+ Word32 dev, max_dev, dist;
+ Word16 dev16, max_dev16, dist16;
+ Word16 max_idx1[2];
Word16 fft_io[L_FRAME16k];
Word16 *ptR, *ptI;
- Word32 enr1 = 0;
- move32();
+ Word32 enr1;
Word32 env[NUM_ENV_CNG];
Word32 min1;
Word16 min1_idx;
@@ -98,53 +89,136 @@ void CNG_enc_fx(
Word16 fra;
Word16 temp_lo_fx, temp_hi_fx;
Word16 exp_pow;
- Word16 force_cn_step = 0;
- move16();
+ Word16 force_cn_step;
Word16 tmp_loop;
Word16 st_lp_sp_enr;
DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc;
TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc;
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
+ Word16 lp_ener_thr_scale;
+ Word64 w_temp;
+ Word32 inv_frame_len;
+ Word32 L_ener;
+ Word16 *pt_res;
+ const Word16 *pt_sp;
+
+ step_inv = 0;
+ move16();
+ maxl = 0;
+ move16();
+ num_bits = 0;
+ move16();
+ step = 0;
+ move16();
+ m = 0;
+ move16();
+ att = 1;
+ move16();
+ max_idx1[0] = 0;
+ max_idx1[1] = 0;
+ move16();
+ move16();
+ enr1 = 0;
+ move32();
+ force_cn_step = 0;
+ move16();
st_lp_sp_enr = hTdCngEnc->lp_sp_enr_fx;
move16();
- Word16 lp_ener_thr_scale;
- lp_ener_thr_scale = 8; /* 4.0f*/ /*IVAS_CODE Q2 */
+ lp_ener_thr_scale = 8; /* 4.0f*/ /* Q1 */
move16();
if ( st_fx->element_mode != EVS_MONO )
{
- lp_ener_thr_scale = 7; /* 3.5f;*/
+ lp_ener_thr_scale = 7; /* 3.5f;*/ /* Q1 */
move16();
}
- /*sp_enr = (float) log10( sum2_f( speech, L_frame )/L_frame + 0.1f )/ (float)log10(2.0f);*/ /*9.1 */
- pt_sp = speech;
- L_ener = L_deposit_l( 1 );
- /* L_ener = L_add(L_shr(sum2_f_fx( speech, L_frame ), 8) , L_ener);*/
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
- {
- FOR( j = 0; j < 128; j++ )
- {
- L_tmp = L_mult0( *pt_sp, *pt_sp );
- pt_sp++;
- L_tmp = L_mac0( L_tmp, *pt_sp, *pt_sp );
- pt_sp++;
- L_ener = L_add( L_ener, L_shr( L_tmp, 7 ) ); /* 2*Q_new + 1, divide by L_frame done here */
- }
- }
- ELSE /* L_FRAME16k */
+
+ IF( st_fx->element_mode == EVS_MONO )
{
- FOR( i = 0; i < 2; i++ )
+ pt_sp = speech;
+ L_ener = L_deposit_l( 1 );
+ /* L_ener = L_add(L_shr(sum2_f_fx( speech, L_frame ), 8) , L_ener);*/
+ IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
- FOR( j = 0; j < 80; j++ )
+ FOR( j = 0; j < 128; j++ )
{
L_tmp = L_mult0( *pt_sp, *pt_sp );
pt_sp++;
L_tmp = L_mac0( L_tmp, *pt_sp, *pt_sp );
pt_sp++;
- L_ener = L_add( L_ener, L_shr( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7 ) ); /* 2*Q_new + 1, divide by L_frame done here */
+ L_ener = L_add( L_ener, L_shr( L_tmp, 7 ) ); /* 2*Q_new + 1, divide by L_frame done here */
+ }
+ }
+ ELSE /* L_FRAME16k */
+ {
+ FOR( i = 0; i < 2; i++ )
+ {
+ FOR( j = 0; j < 80; j++ )
+ {
+ L_tmp = L_mult0( *pt_sp, *pt_sp );
+ pt_sp++;
+ L_tmp = L_mac0( L_tmp, *pt_sp, *pt_sp );
+ pt_sp++;
+ L_ener = L_add( L_ener, L_shr( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7 ) ); /* 2*Q_new + 1, divide by L_frame done here */
+ }
}
}
}
+ ELSE
+ {
+ w_temp = 1;
+ move64();
+
+ FOR( j = 0; j < st_fx->L_frame; j++ )
+ {
+ w_temp = W_mac0_16_16( w_temp, speech[j], speech[j] );
+ }
+ exp = W_norm( w_temp );
+
+ inv_frame_len = 0;
+ move32();
+
+ SWITCH( st_fx->L_frame )
+ {
+ case L_FRAME25_6k:
+ inv_frame_len = ONE_BY_L_FRAME25_6k_Q31;
+ move16();
+ BREAK;
+ case L_FRAME:
+ inv_frame_len = ONE_BY_L_FRAME_Q31;
+ move16();
+ BREAK;
+ case L_FRAME48k:
+ inv_frame_len = ONE_BY_L_FRAME48k_Q31;
+ move16();
+ BREAK;
+ case 240:
+ inv_frame_len = ONE_BY_240_Q31;
+ move16();
+ BREAK;
+ case L_FRAME32k:
+ inv_frame_len = ONE_BY_L_FRAME32k_Q31;
+ move16();
+ BREAK;
+ case L_FRAME16k:
+ inv_frame_len = ONE_BY_L_FRAME16k_Q31;
+ move16();
+ BREAK;
+ case L_FRAME8k:
+ inv_frame_len = ONE_BY_L_FRAME8k_Q31;
+ move16();
+ BREAK;
+ case L_FRAME4k:
+ inv_frame_len = ONE_BY_L_FRAME4k_Q31;
+ move16();
+ BREAK;
+ default:
+ inv_frame_len = divide3216( 1, st_fx->L_frame );
+ }
+ L_ener = W_extract_h( W_shl( w_temp, exp ) ); /* Q = 2*Q_new+exp-32 */
+ L_ener = Mpy_32_32( L_ener, inv_frame_len ); /* Q = 2*Q_new+exp-32 */
+ L_ener = L_shl( L_ener, sub( 33, exp ) ); /* Q = 2*Q_new+1 */
+ }
hi = norm_l( L_ener );
lo = Log2_norm_lc( L_shl( L_ener, hi ) );
@@ -174,7 +248,7 @@ void CNG_enc_fx(
IF( GT_32( st_fx->last_core_brate, SID_2k40 ) && ( EQ_16( st_fx->last_core, HQ_CORE ) || st_fx->hTdCngEnc->burst_ho_cnt > 0 ) && LT_16( hTdCngEnc->lp_sp_enr_fx, 1536 /*6.0f in Q8*/ ) &&
GT_16( sub( sp_enr, hTdCngEnc->lp_sp_enr_fx ), 1024 /*4.0f in Q8*/ ) && GT_16( sp_enr, 1536 /*6.0f in Q8*/ ) )
{
- hTdCngEnc->lp_sp_enr_fx = sp_enr;
+ hTdCngEnc->lp_sp_enr_fx = sp_enr; /* Q8 */
move16();
force_cn_step = 1;
move16();
@@ -185,6 +259,7 @@ void CNG_enc_fx(
move16();
}
}
+
/* update the pointer to circular buffer of old LSP vectors */
hTdCngEnc->cng_hist_ptr = add( hTdCngEnc->cng_hist_ptr, 1 );
move16();
@@ -201,6 +276,7 @@ void CNG_enc_fx(
* Find CNG spectral envelope
* Find LSP median
*-----------------------------------------------------------------*/
+
test();
test();
IF( ( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) ) && GE_16( hDtxEnc->cng_cnt, sub( hDtxEnc->cng_hist_size, 1 ) ) )
@@ -213,7 +289,7 @@ void CNG_enc_fx(
IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
lsp2lsf_fx( &hTdCngEnc->cng_lsp_hist_fx[i * M], lsf_tmp, M, INT_FS_FX );
- ftmp_fx = 964; /*(6400/(M+1))X2.56 */
+ ftmp_fx = 964; /*(6400/(M+1))X2.56*/
move16(); /*QX2.56 */
tmpv = sub( 16384, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */
@@ -235,7 +311,7 @@ void CNG_enc_fx(
L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536 */
}
- C[i] = Mpy_32_16_1( L_tmp, 1928 /*.0588235f Q15*/ );
+ C[i] = Mpy_32_16_1( L_tmp, 1928 );
move32(); /*QX6.5536 */
IF( GT_32( C[i], max_val[0] ) )
@@ -283,6 +359,7 @@ void CNG_enc_fx(
* Quantize CNG spectral envelope (only in SID frame)
* Quantize the LSF vector
*-----------------------------------------------------------------*/
+
*allow_cn_step = 0;
move16();
test();
@@ -314,13 +391,12 @@ void CNG_enc_fx(
FOR( i = 0; i < M; i++ )
{
/*lsp_new[i] = 0.5f * (lsp_mid[i] + lsp_new[i]);*/
- lsp_new[i] = mac_r( L_mult( lsp_mid[i], 16384 ), lsp_new[i], 16384 /*.5 Q15*/ );
+ lsp_new[i] = mac_r( L_mult( lsp_mid[i], 16384 /*.5f Q15*/ ), lsp_new[i], 16384 /*.5f Q15*/ );
move16();
}
}
}
-
test();
IF( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) )
{
@@ -331,8 +407,9 @@ void CNG_enc_fx(
}
ELSE
{
- lsf_enc_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 100, 0, 0, Q_new );
+ lsf_enc_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 0, 0, NULL, Q_new );
}
+
/* Reset CNG history if CNG frame length is changed */
test();
test();
@@ -354,10 +431,12 @@ void CNG_enc_fx(
* Find A(z) coefficients
*---------------------------------------------------------------------*/
- IF( LE_32( st_fx->last_core_brate, SID_2k40 ) )
+ test();
+ test();
+ IF( ( st_fx->last_core_brate == FRAME_NO_DATA ) || EQ_32( st_fx->last_core_brate, SID_1k75 ) || EQ_32( st_fx->last_core_brate, SID_2k40 ) )
{
/* Reset hangover counter if not first SID period */
- if ( GT_32( st_fx->core_brate, FRAME_NO_DATA ) )
+ if ( st_fx->core_brate > FRAME_NO_DATA )
{
hTdCngEnc->num_ho = 0;
move16();
@@ -369,7 +448,7 @@ void CNG_enc_fx(
FOR( i = 0; i < M; i++ )
{
/* AR low-pass filter */
- hDtxEnc->lspCNG_fx[i] = mac_r( L_mult( CNG_ISF_FACT_FX, hDtxEnc->lspCNG_fx[i] ), 32768 - CNG_ISF_FACT_FX, lsp_new[i] );
+ hDtxEnc->lspCNG_fx[i] = mac_r( L_mult( CNG_ISF_FACT_FX, hDtxEnc->lspCNG_fx[i] ), 32768 /*1f Q15*/ - CNG_ISF_FACT_FX, lsp_new[i] );
move16(); /* Q15 (15+15+1-16) */
}
}
@@ -381,7 +460,7 @@ void CNG_enc_fx(
test();
test();
test();
- IF( st_fx->element_mode == EVS_MONO && ( ( st_fx->Opt_AMR_WB || EQ_16( st_fx->bwidth, WB ) ) && ( !hDtxEnc->first_CNG || GE_16( hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) ) ) )
+ IF( ( st_fx->element_mode == EVS_MONO ) && ( ( st_fx->Opt_AMR_WB || EQ_16( st_fx->bwidth, WB ) ) && ( !hDtxEnc->first_CNG || GE_16( hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) ) ) )
{
IF( GT_32( hDtxEnc->last_active_brate, ACELP_16k40 ) )
{
@@ -456,23 +535,34 @@ void CNG_enc_fx(
IF( hTdCngEnc->burst_ho_cnt > 0 )
{
- /**allow_cn_step |= ( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] > 4 * hTdCngEnc->lp_ener_fx ); */
- /*allow_cn_step |= (hDtxEnc->first_CNG || st->element_mode == EVS_MONO) && (hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener);*/
- /* (hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener); */
- L_tmp1 = L_shr( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr], 2 );
- IF( NE_16( lp_ener_thr_scale, 8 ) )
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ /**allow_cn_step |= ( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] > 4 * hTdCngEnc->lp_ener_fx ); */
+ /*allow_cn_step |= (hDtxEnc->first_CNG || st->element_mode == EVS_MONO) && (hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener);*/
+ /* (hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener); */
+ L_tmp1 = L_shr( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr], 2 );
+ IF( NE_16( lp_ener_thr_scale, 8 ) )
+ {
+ L_tmp1 = L_add( L_tmp1, L_shr( hTdCngEnc->lp_ener_fx, 8 ) );
+ }
+ L_tmp1 = L_sub( L_tmp1, hTdCngEnc->lp_ener_fx );
+ w_temp = W_deposit32_l( L_tmp1 );
+ }
+ ELSE
{
- L_tmp1 = L_add( L_tmp1, L_shr( hTdCngEnc->lp_ener_fx, 8 ) );
+ /**allow_cn_step |= ( hDtxEnc->first_CNG || st->element_mode == EVS_MONO ) && ( hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener );*/
+ w_temp = W_msu_32_16( W_shl( W_deposit32_l( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] ), 2 ), hTdCngEnc->lp_ener_fx, lp_ener_thr_scale ); /*Q8*/
}
- L_tmp1 = L_sub( L_tmp1, hTdCngEnc->lp_ener_fx );
+
test();
test();
- IF( ( hDtxEnc->first_CNG > 0 || st_fx->element_mode == EVS_MONO ) && L_tmp1 > 0 )
+ IF( ( hDtxEnc->first_CNG > 0 || ( st_fx->element_mode == EVS_MONO ) ) && w_temp > 0 )
{
*allow_cn_step = s_or( *allow_cn_step, 1 );
move16();
}
}
+
test();
IF( *allow_cn_step == 0 && hTdCngEnc->ho_hist_size > 0 )
{
@@ -482,13 +572,13 @@ void CNG_enc_fx(
Copy( &( hTdCngEnc->ho_lsp_hist_fx[ptr * M] ), tmp, M );
m1 = 0;
move16();
- IF( L_and( hTdCngEnc->ho_sid_bw, (Word32) 0x1 ) == 0 )
+ IF( L_and( hTdCngEnc->ho_sid_bw, 1 ) == 0 )
{
Copy32( &hTdCngEnc->ho_env_hist_fx[ptr * NUM_ENV_CNG], tmp_env, NUM_ENV_CNG );
m1 = 1;
move16();
}
- L_enr = Mult_32_16( hTdCngEnc->ho_ener_hist_fx[ptr], W_DTX_HO_FX[0] ); /* Q6+15-15->Q6 */
+ L_ener = Mult_32_16( hTdCngEnc->ho_ener_hist_fx[ptr], W_DTX_HO_FX[0] ); /* Q6+15-15->Q6 */
weights = W_DTX_HO_FX[0]; /* Q15 */
move16();
@@ -509,13 +599,13 @@ void CNG_enc_fx(
{
/*enr += W_DTX_HO[k] * st_fx->ho_ener_hist[ptr]; */
L_tmp1 = Mult_32_16( hTdCngEnc->ho_ener_hist_fx[ptr], W_DTX_HO_FX[k] ); /* Q6+15-15->Q6 */
- L_enr = L_add( L_enr, L_tmp1 ); /* Q6 */
+ L_ener = L_add( L_ener, L_tmp1 ); /* Q6 */
/*weights += W_DTX_HO[k]; */
weights = add( weights, W_DTX_HO_FX[k] ); /* Q15 */
Copy( &hTdCngEnc->ho_lsp_hist_fx[ptr * M], &tmp[m * M], M );
- IF( L_and( hTdCngEnc->ho_sid_bw, L_shl( (Word32) 0x1, k ) ) == 0 )
+ IF( L_and( hTdCngEnc->ho_sid_bw, L_shl( 1, k ) ) == 0 )
{
Copy32( &hTdCngEnc->ho_env_hist_fx[ptr * NUM_ENV_CNG], &tmp_env[m1 * NUM_ENV_CNG], NUM_ENV_CNG );
m1 = add( m1, 1 );
@@ -527,10 +617,10 @@ void CNG_enc_fx(
/*enr /= weights; */
exp = norm_s( weights );
tmp1 = div_s( shl( 1, sub( 14, exp ) ), weights ); /* Q(15+14-exp-15) */
- L_tmp1 = Mult_32_16( L_enr, tmp1 ); /* Q(14-exp+6-15)->Q(5-exp) */
- L_enr = L_shl( L_tmp1, add( exp, 1 ) ); /* Q6 */
+ L_tmp1 = Mult_32_16( L_ener, tmp1 ); /* Q(14-exp+6-15)->Q(5-exp) */
+ L_ener = L_shl( L_tmp1, add( exp, 1 ) ); /* Q6 */
- hTdCngEnc->lp_ener_fx = L_enr;
+ hTdCngEnc->lp_ener_fx = L_ener;
move32(); /* Q6 */
set32_fx( max_val, 0, 2 );
@@ -604,6 +694,7 @@ void CNG_enc_fx(
tmpv = div_s( 1, sub( m, 1 ) ); /*Q15 */
L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */
lsp_tmp[i] = extract_l( L_tmp ); /*Q15 */
+ move16();
}
}
ELSE
@@ -617,29 +708,53 @@ void CNG_enc_fx(
}
L_tmp = L_sub( L_tmp, L_add( L_deposit_l( tmp[max_idx[0] * M + i] ), L_deposit_l( tmp[max_idx[1] * M + i] ) ) ); /*Q15 */
- tmpv = div_s( 1, sub( m, 2 ) ); /*Q15 */
- L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */
- lsp_tmp[i] = extract_l( L_tmp ); /*Q15 */
+ tmpv = div_s( 1, sub( m, 2 ) ); /*Q15 */ /*Q15 */
+ L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */ /*Q15 */
+ lsp_tmp[i] = extract_l( L_tmp ); /*Q15 */ /*Q15 */
+ move16();
}
}
- dist = 0; /*Q15 */
- max_dev = 0; /*Q15 */
- move16();
- move16();
- FOR( i = 0; i < M; i++ )
+ IF( st_fx->element_mode == EVS_MONO )
{
- dev = abs_s( sub( lsp_tmp[i], lsp_new[i] ) ); /*Q15 */
- dist = add_sat( dist, dev ); /*Q15 */
- if ( GT_16( dev, max_dev ) )
+ dist16 = 0; /*Q15 */
+ move16();
+ max_dev16 = 0; /*Q15 */
+ move16();
+ move16();
+ FOR( i = 0; i < M; i++ )
{
- max_dev = dev;
- move16();
+ dev16 = abs_s( sub( lsp_tmp[i], lsp_new[i] ) ); /*Q15 */
+ dist16 = add_sat( dist16, dev16 ); /*Q15 */
+ if ( GT_16( dev16, max_dev16 ) )
+ {
+ max_dev16 = dev16;
+ move16();
+ }
+ }
+ dist = L_deposit_l( dist16 );
+ max_dev = L_deposit_l( max_dev16 );
+ }
+ ELSE
+ {
+ dist = 0; /*Q15 */
+ move32();
+ max_dev = 0; /*Q15 */
+ move32();
+ FOR( i = 0; i < M; i++ )
+ {
+ dev = L_abs( L_sub( L_deposit_l( lsp_tmp[i] ), L_deposit_l( lsp_new[i] ) ) ); /*Q15 */
+ dist = L_add( dist, dev ); /*Q15 */
+ if ( GT_32( dev, max_dev ) )
+ {
+ max_dev = dev;
+ move32();
+ }
}
}
test();
- IF( GT_16( dist, 13107 ) || GT_16( max_dev, 3277 ) )
+ IF( GT_32( dist, 13107 ) || GT_32( max_dev, 3277 ) )
{
FOR( i = 0; i < M; i++ )
{
@@ -652,7 +767,7 @@ void CNG_enc_fx(
FOR( i = 0; i < M; i++ )
{
/* AR low-pass filter */
- hDtxEnc->lspCNG_fx[i] = add( mult_r( 26214, lsp_tmp[i] ), mult_r( 6554, lsp_new[i] ) );
+ hDtxEnc->lspCNG_fx[i] = add( mult_r( 26214 /*.8f Q15*/, lsp_tmp[i] ), mult_r( 6554 /*.2f Q15*/, lsp_new[i] ) ); /* Q15 */
move16();
}
}
@@ -679,24 +794,30 @@ void CNG_enc_fx(
L_tmp = L_sub_sat( L_tmp, L_add_sat( hTdCngEnc->lp_ener_fx, hTdCngEnc->lp_ener_fx ) );
}
- env[i] = L_tmp;
+ env[i] = L_tmp; /* Q6*/
move32();
}
- Copy32( env, hTdCngEnc->lp_env_fx, NUM_ENV_CNG );
+ Copy32( env, hTdCngEnc->lp_env_fx, NUM_ENV_CNG ); /* Q6 */
}
}
ELSE
{
- Copy( lsp_new, hDtxEnc->lspCNG_fx, M ); /* use newly analyzed ISFs */
+ Copy( lsp_new, hDtxEnc->lspCNG_fx, M ); /* use newly analyzed ISFs */ /* Q15 */
}
}
+
IF( st_fx->Opt_AMR_WB != 0 )
{
E_LPC_f_isp_a_conversion( hDtxEnc->lspCNG_fx, Aq, M );
}
ELSE
{
- E_LPC_f_lsp_a_conversion( hDtxEnc->lspCNG_fx, Aq, M ); /* Find A(z) (not interpolated) */
+ E_LPC_f_lsp_a_conversion( hDtxEnc->lspCNG_fx, Aq, M );
+ IF( st_fx->element_mode != EVS_MONO )
+ {
+ exp = sub( Q14, norm_s( Aq[0] ) );
+ Scale_sig( Aq, M + 1, sub( Q12, exp ) ); // Q12
+ }
}
tmp_loop = shr( st_fx->L_frame, 6 );
@@ -704,6 +825,7 @@ void CNG_enc_fx(
{
Copy( Aq, &Aq[i * ( M + 1 )], M + 1 );
}
+
/*-----------------------------------------------------------------*
* Find residual signal
* Calculate residual signal energy per sample
@@ -711,12 +833,16 @@ void CNG_enc_fx(
/* calculate the residual signal */
Residu3_fx( Aq, speech, res, st_fx->L_frame, 0 );
- Copy( res, res1, st_fx->L_frame );
+ Copy( res, res1, st_fx->L_frame ); /* Q_new */
test();
IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
{
+ L_tmp1 = L_mult0( hTdCngEnc->CNG_att_fx, 26214 /* 1/20.0f in Q19 */ ); // Q26 (7 + 19)
+ L_tmp1 = BASOP_Util_fPow( 1342177280 /*10 in Q27 */, 4, L_tmp1, 5, &exp );
+ att = extract_h( L_shl( L_sub( L_tmp1, EPSILON_FX ), exp ) ); // Q15 // Subtracting by EPSILON_FX to avoid assertion when L_tmp1 value is 1073741824 and exp =1
+ v_multc_fx_16_16( res1, att, res1, st_fx->L_frame ); /* Q_new */
}
- ELSE IF( NE_16( st_fx->bwidth, NB ) )
+ ELSE IF( st_fx->bwidth != NB )
{
test();
IF( EQ_16( st_fx->bwidth, WB ) && hDtxEnc->CNG_mode >= 0 )
@@ -726,13 +852,13 @@ void CNG_enc_fx(
}
ELSE
{
- ftmp_fx = 19661; /*0.6f in Q15*/
+ ftmp_fx = 19661; /*.6f in Q15*/
move16();
}
- att = mult( ftmp_fx, 5461 /*1/6f in Q15*/ ); /* Q15 */
- L_tmp = L_mult( att, 8 ); /* Q16 */
- tmp1 = extract_l( L_shr( L_tmp, 2 ) ); /* Q14 */
+ att = mult( ftmp_fx, 5461 ); /* Q15 */
+ L_tmp = L_mult( att, 8 ); /* Q16 */
+ tmp1 = extract_l( L_shr( L_tmp, 2 ) ); /* Q14 */
tmp1 = add( 16384, tmp1 );
att = div_s( 16374, tmp1 ); /* Q15 */
@@ -747,7 +873,7 @@ void CNG_enc_fx(
}
/* calculate the spectrum of residual signal */
- Copy( res1, fft_io, st_fx->L_frame );
+ Copy( res1, fft_io, st_fx->L_frame ); /* Q_new */
IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
{
@@ -775,49 +901,124 @@ void CNG_enc_fx(
/* calculate the residual signal energy */
/*enr = dotp( res, res, L_frame ) / L_frame; */
- maxv = 0;
- move16();
- FOR( i = 0; i < st_fx->L_frame; i++ )
- {
- maxv = s_max( maxv, abs_s( res[i] ) );
- }
- scale = norm_s( maxv );
- pt_res = res;
- L_ener = L_deposit_l( 1 );
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
+ IF( st_fx->element_mode == EVS_MONO )
{
- FOR( j = 0; j < 128; j++ )
+ Word16 maxv, scale;
+
+ maxv = 0;
+ move16();
+ FOR( i = 0; i < st_fx->L_frame; i++ )
+ {
+ maxv = s_max( maxv, abs_s( res[i] ) );
+ }
+ scale = norm_s( maxv );
+ pt_res = res;
+ L_ener = L_deposit_l( 1 );
+ IF( EQ_16( st_fx->L_frame, L_FRAME ) )
+ {
+ FOR( j = 0; j < 128; j++ )
+ {
+ tmpv = shl( *pt_res, scale );
+ L_tmp = L_mult0( tmpv, tmpv );
+ pt_res++;
+ tmpv = shl( *pt_res, scale );
+ L_tmp = L_mac0_sat( L_tmp, tmpv, tmpv ); /* 2*(Q_new+scale) */
+ pt_res++;
+ L_ener = L_add_sat( L_ener, L_shr( L_tmp, 7 ) ); /* 2*(Q_new+scale)+1, divide by L_frame done here */
+ }
+ }
+ ELSE /* L_FRAME16k */
{
- tmpv = shl( *pt_res, scale );
- L_tmp = L_mult0( tmpv, tmpv );
- pt_res++;
- tmpv = shl( *pt_res, scale );
- L_tmp = L_mac0_sat( L_tmp, tmpv, tmpv ); /* 2*(Q_new+scale) */
- pt_res++;
- L_ener = L_add_sat( L_ener, L_shr( L_tmp, 7 ) ); /* 2*(Q_new+scale)+1, divide by L_frame done here */
+ FOR( j = 0; j < 160; j++ )
+ {
+ tmpv = shl( *pt_res, scale );
+ L_tmp = L_mult0( tmpv, tmpv );
+ pt_res++;
+ tmpv = shl( *pt_res, scale );
+ L_tmp = L_mac0_sat( L_tmp, tmpv, tmpv ); /* 2*(Q_new+scale) */
+ pt_res++;
+ L_ener = L_add_sat( L_ener, L_shr( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7 ) ); /* 2*(Q_new+scale)+15+1-16+1, divide by L_frame done here */
+ }
}
+
+ /* convert log2 of residual signal energy */
+ /*enr = (float)log10( enr + 0.1f ) / (float)log10( 2.0f ); */
+ hi = norm_l( L_ener );
+ lo = Log2_norm_lc( L_shl( L_ener, hi ) );
+ hi = sub( 29, hi ); /* log2 exp in Q2*(Q_new+scale) */
+ hi = sub( hi, shl( add( Q_new, scale ), 1 ) ); /* Q0 */
+ L_tmp = L_Comp( hi, lo ); /* Q16 */
+ enr = round_fx( L_shl( L_tmp, 8 ) ); /* Q8 (16+8-16) */
}
- ELSE /* L_FRAME16k */
+ ELSE
{
- FOR( j = 0; j < 160; j++ )
+ w_temp = 1;
+ move64();
+ FOR( j = 0; j < st_fx->L_frame; j++ )
+ {
+ w_temp = W_mac0_16_16( w_temp, res[j], res[j] );
+ }
+ exp = W_norm( w_temp );
+
+ SWITCH( st_fx->L_frame )
+ {
+ case L_FRAME25_6k:
+ inv_frame_len = ONE_BY_L_FRAME25_6k_Q31;
+ move16();
+ BREAK;
+ case L_FRAME:
+ inv_frame_len = ONE_BY_L_FRAME_Q31;
+ move16();
+ BREAK;
+ case L_FRAME48k:
+ inv_frame_len = ONE_BY_L_FRAME48k_Q31;
+ move16();
+ BREAK;
+ case 240:
+ inv_frame_len = ONE_BY_240_Q31;
+ move16();
+ BREAK;
+ case L_FRAME32k:
+ inv_frame_len = ONE_BY_L_FRAME32k_Q31;
+ move16();
+ BREAK;
+ case L_FRAME16k:
+ inv_frame_len = ONE_BY_L_FRAME16k_Q31;
+ move16();
+ BREAK;
+ case L_FRAME8k:
+ inv_frame_len = ONE_BY_L_FRAME8k_Q31;
+ move16();
+ BREAK;
+ case L_FRAME4k:
+ inv_frame_len = ONE_BY_L_FRAME4k_Q31;
+ move16();
+ BREAK;
+ default:
+ inv_frame_len = divide3216( 1, st_fx->L_frame );
+ }
+ L_ener = W_extract_h( W_shl( w_temp, exp ) ); /* Q = 2*Q_new+exp-32 */
+ L_ener = Mpy_32_32( L_ener, inv_frame_len ); /* Q = 2*Q_new+exp-32 */
+ L_ener = L_shl( L_ener, sub( 33, exp ) ); /* Q = 2*Q_new+1 */
+
+ /* convert log2 of residual signal energy */
+ /*enr = (float)log10( enr + 0.1f ) / (float)log10( 2.0f ); */
+
+ IF( L_ener == 0 )
+ {
+ enr = -850; /*log(0.1) base 2 in Q8*/
+ move16();
+ }
+ ELSE
{
- tmpv = shl( *pt_res, scale );
- L_tmp = L_mult0( tmpv, tmpv );
- pt_res++;
- tmpv = shl( *pt_res, scale );
- L_tmp = L_mac0_sat( L_tmp, tmpv, tmpv ); /* 2*(Q_new+scale) */
- pt_res++;
- L_ener = L_add_sat( L_ener, L_shr( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7 ) ); /* 2*(Q_new+scale)+15+1-16+1, divide by L_frame done here */
+ hi = norm_l( L_ener );
+ lo = Log2_norm_lc( L_shl( L_ener, hi ) );
+ hi = sub( 29, hi ); /* log2 exp in Q2*Q_new */
+ hi = sub( hi, shl( Q_new, 1 ) ); /* Q0 */
+ L_tmp = L_Comp( hi, lo ); /* Q16 */
+ enr = round_fx( L_shl( L_tmp, 8 ) ); /* Q8 (16+8-16) */
}
}
- /* convert log2 of residual signal energy */
- /*enr = (float)log10( enr + 0.1f ) / (float)log10( 2.0f ); */
- hi = norm_l( L_ener );
- lo = Log2_norm_lc( L_shl( L_ener, hi ) );
- hi = sub( 29, hi ); /* log2 exp in Q2*(Q_new+scale) */
- hi = sub( hi, shl( add( Q_new, scale ), 1 ) ); /* Q0 */
- L_tmp = L_Comp( hi, lo ); /* Q16 */
- enr = round_fx( L_shl( L_tmp, 8 ) ); /* Q8 (16+8-16) */
/* update the circular buffer of old energies */
hTdCngEnc->cng_ener_hist_fx[hTdCngEnc->cng_hist_ptr] = enr;
@@ -826,6 +1027,7 @@ void CNG_enc_fx(
/*-----------------------------------------------------------------*
* Quantize residual signal energy (only in SID frame)
*-----------------------------------------------------------------*/
+
test();
IF( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) )
{
@@ -891,8 +1093,9 @@ void CNG_enc_fx(
test();
IF( EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) )
{
+ enr = add( enr, mult( hTdCngEnc->CNG_att_fx, FAC_LOG2_BY10_Q16 ) ); /* Q8 (Q7 + Q16 - Q15)*/
}
- ELSE IF( NE_16( st_fx->bwidth, NB ) )
+ ELSE IF( st_fx->bwidth != NB )
{
IF( EQ_16( st_fx->bwidth, WB ) )
{
@@ -912,14 +1115,14 @@ void CNG_enc_fx(
ELSE
{
att = 384;
- move16(); /*Q8*/
+ move16(); /*1.5f Q8*/
}
enr = sub( enr, att );
}
/* intialize the energy quantization parameters */
IF( st_fx->Opt_AMR_WB == 0 )
{
- step = STEP_SID_FX;
+ step = STEP_SID_FX; // Q12
move16();
step_inv = ISTEP_SID_FX;
move16();
@@ -1027,7 +1230,8 @@ void CNG_enc_fx(
}
/* codebook search */
- min1 = L_add( 1310588928, 0 ); /* Q17 */
+ min1 = 1310588928; /* 9999.0f Q17 */
+ move32();
min1_idx = 0;
move16();
@@ -1043,12 +1247,13 @@ void CNG_enc_fx(
tmp1 = extract_h( L_tmp ); /*Q(exp+6-16)=exp-10*/
L_tmp = L_mult_sat( tmp1, tmp1 ); /*Q(2*exp - 19)*/
L_tmp = L_shr( L_tmp, sub( add( exp, exp ), 36 ) ); /* Q17 */
- d = L_add( d, L_tmp );
+ d = L_add( d, L_tmp ); /* Q17 */
}
IF( LT_32( d, min1 ) )
{
- min1 = L_add( d, 0 );
+ min1 = d;
+ move32();
min1_idx = i;
move16();
}
@@ -1125,7 +1330,7 @@ void CNG_enc_fx(
push_indice( hBstr, IND_ACELP_16KHZ, 0, 1 );
}
- push_indice( hBstr, IND_CNG_HO, s_min( hTdCngEnc->burst_ho_cnt, 7 ), 3 );
+ push_indice( hBstr, IND_CNG_HO, s_min( hTdCngEnc->burst_ho_cnt, HO_HIST_SIZE - 1 ), 3 );
hTdCngEnc->num_ho = m;
move16();
push_indice( hBstr, IND_SID_TYPE, 0, 1 );
@@ -1142,6 +1347,7 @@ void CNG_enc_fx(
/*-----------------------------------------------------------------*
* Updates
*-----------------------------------------------------------------*/
+
/* update the SID frames counter */
test();
IF( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) )
@@ -1163,1555 +1369,18 @@ void CNG_enc_fx(
return;
}
-void CNG_enc_ivas_fx(
- Encoder_State *st_fx, /* i/o: State structure */
- Word16 Aq[], /* o : LP coefficients Q12 */
- const Word16 *speech, /* i : pointer to current frame input speech buffer Q_new */
- // Word32 L_ener, /* i : residual energy from Levinson-Durbin Q6 */
- const Word16 *lsp_mid, /* i : mid frame LSPs Q15 */
- Word16 *lsp_new, /* i/o: current frame ISPs Q15 */
- Word16 *lsf_new, /* i/o: current frame ISFs Qlog2(2.56) */
- Word16 *allow_cn_step, /* o : allow CN step Q0 */
- Word16 Q_new, /* i : Q value of speech */
- Word32 *q_env,
- Word16 *sid_bw )
-{
- Word16 enr_index;
- Word16 i, j, ptr;
- Word16 m1;
- Word16 res[L_FRAME16k];
- Word16 step_inv;
- Word16 hi, lo;
- Word16 maxl;
- Word16 num_bits;
- Word16 step;
- Word16 enr;
- Word32 L_tmp;
- Word16 k, tmp1;
- Word16 weights;
- Word16 sp_enr;
- Word32 L_tmp1;
- Word16 exp;
- Word16 m;
- Word16 tmp[HO_HIST_SIZE * M];
- Word16 ll, s_ptr;
- Word16 tmpv, att;
- Word16 lsf_tmp[M];
- Word32 C[M];
- Word32 max_val[2];
- Word16 max_idx[2];
- Word16 ftmp_fx;
- Word16 lsp_tmp[M];
- Word32 dev;
- Word32 max_dev;
- Word32 dist;
- Word16 max_idx1[2];
- Word16 fft_io[L_FRAME16k];
- Word16 *ptR, *ptI;
- Word32 enr1;
- Word32 env[NUM_ENV_CNG];
- Word32 min1;
- Word16 min1_idx;
- Word32 d;
- Word16 res1[L_FRAME16k];
- Word32 tmp_env[HO_HIST_SIZE * NUM_ENV_CNG];
- Word16 fra;
- Word16 temp_lo_fx, temp_hi_fx;
- Word16 exp_pow;
- Word16 force_cn_step;
- Word16 tmp_loop;
- Word16 st_lp_sp_enr;
- DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc;
- TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc;
- BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
- Word16 lp_ener_thr_scale;
- Word64 w_temp;
- Word32 inv_frame_len;
- Word32 L_ener;
-
- step_inv = 0;
- move16();
- maxl = 0;
- move16();
- num_bits = 0;
- move16();
- step = 0;
- move16();
- m = 0;
- move16();
- att = 1;
- move16();
- max_idx1[0] = 0;
- max_idx1[1] = 0;
- move16();
- move16();
- enr1 = 0;
- move32();
- force_cn_step = 0;
- move16();
- st_lp_sp_enr = hTdCngEnc->lp_sp_enr_fx;
- move16();
- /* Temp variables for floating point functions */
-
- lp_ener_thr_scale = 8; /* 4.0f*/ /* Q1 */
- move16();
- if ( st_fx->element_mode != EVS_MONO )
- {
- lp_ener_thr_scale = 7; /* 3.5f;*/ /* Q1 */
- move16();
- }
-
- w_temp = 1;
- move64();
-
- FOR( j = 0; j < st_fx->L_frame; j++ )
- {
- w_temp = W_mac0_16_16( w_temp, speech[j], speech[j] );
- }
- exp = W_norm( w_temp );
-
- inv_frame_len = 0;
- move32();
-
- SWITCH( st_fx->L_frame )
- {
- case L_FRAME25_6k:
- inv_frame_len = ONE_BY_L_FRAME25_6k_Q31;
- move16();
- BREAK;
- case L_FRAME:
- inv_frame_len = ONE_BY_L_FRAME_Q31;
- move16();
- BREAK;
- case L_FRAME48k:
- inv_frame_len = ONE_BY_L_FRAME48k_Q31;
- move16();
- BREAK;
- case 240:
- inv_frame_len = ONE_BY_240_Q31;
- move16();
- BREAK;
- case L_FRAME32k:
- inv_frame_len = ONE_BY_L_FRAME32k_Q31;
- move16();
- BREAK;
- case L_FRAME16k:
- inv_frame_len = ONE_BY_L_FRAME16k_Q31;
- move16();
- BREAK;
- case L_FRAME8k:
- inv_frame_len = ONE_BY_L_FRAME8k_Q31;
- move16();
- BREAK;
- case L_FRAME4k:
- inv_frame_len = ONE_BY_L_FRAME4k_Q31;
- move16();
- BREAK;
- default:
- inv_frame_len = divide3216( 1, st_fx->L_frame );
- }
- L_ener = W_extract_h( W_shl( w_temp, exp ) ); /* Q = 2*Q_new+exp-32 */
- L_ener = Mpy_32_32( L_ener, inv_frame_len ); /* Q = 2*Q_new+exp-32 */
- L_ener = L_shl( L_ener, sub( 33, exp ) ); /* Q = 2*Q_new+1 */
-
- hi = norm_l( L_ener );
- lo = Log2_norm_lc( L_shl( L_ener, hi ) );
- hi = sub( 29, hi ); /* log2 exp in Q2*Q_new */
- hi = sub( hi, shl( Q_new, 1 ) ); /* Q0 */
- L_tmp = L_Comp( hi, lo ); /* Q16 */
- sp_enr = round_fx( L_shl( L_tmp, 8 ) ); /* Q8 (16+8-16) */
-
- if ( sp_enr < 0 )
- {
- sp_enr = 0;
- move16();
- }
- test();
- IF( hDtxEnc->first_CNG == 0 || hTdCngEnc->old_enr_index < 0 )
- {
- hTdCngEnc->lp_sp_enr_fx = sp_enr;
- move16(); /* Q8 */
- }
- ELSE
- {
- test();
- test();
- test();
- test();
- test();
- IF( GT_32( st_fx->last_core_brate, SID_2k40 ) && ( EQ_16( st_fx->last_core, HQ_CORE ) || st_fx->hTdCngEnc->burst_ho_cnt > 0 ) && LT_16( hTdCngEnc->lp_sp_enr_fx, 1536 /*6.0f in Q8*/ ) &&
- GT_16( sub( sp_enr, hTdCngEnc->lp_sp_enr_fx ), 1024 /*4.0f in Q8*/ ) && GT_16( sp_enr, 1536 /*6.0f in Q8*/ ) )
- {
- hTdCngEnc->lp_sp_enr_fx = sp_enr; /* Q8 */
- move16();
- force_cn_step = 1;
- move16();
- }
- ELSE
- {
- hTdCngEnc->lp_sp_enr_fx = round_fx( L_mac( L_mult( 29491 /* 0.9, Q15 */, hTdCngEnc->lp_sp_enr_fx ), 3277 /* 0.1, Q15 */, sp_enr ) ); /* Q8 (8+15+1-16) */
- move16();
- }
- }
- /* update the pointer to circular buffer of old LSP vectors */
- hTdCngEnc->cng_hist_ptr = add( hTdCngEnc->cng_hist_ptr, 1 );
- move16();
- if ( EQ_16( hTdCngEnc->cng_hist_ptr, DTX_HIST_SIZE ) )
- {
- hTdCngEnc->cng_hist_ptr = 0;
- move16();
- }
-
- /* update the circular buffer of old LSP vectors with the new LSP vector */
- Copy( lsp_new, &( hTdCngEnc->cng_lsp_hist_fx[( hTdCngEnc->cng_hist_ptr ) * M] ), M );
-
- /*-----------------------------------------------------------------*
- * Find CNG spectral envelope
- * Find LSP median
- *-----------------------------------------------------------------*/
- test();
- test();
- IF( ( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) ) && GE_16( hDtxEnc->cng_cnt, sub( hDtxEnc->cng_hist_size, 1 ) ) )
- {
- set32_fx( max_val, 0, 2 );
- set16_fx( max_idx, 0, 2 );
-
- FOR( i = 0; i < hDtxEnc->cng_hist_size; i++ )
- {
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
- {
- lsp2lsf_fx( &hTdCngEnc->cng_lsp_hist_fx[i * M], lsf_tmp, M, INT_FS_FX );
- ftmp_fx = 964; /*(6400/(M+1))X2.56*/
- move16(); /*QX2.56 */
- tmpv = sub( 16384, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
- L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */
- }
- ELSE
- {
- lsp2lsf_fx( &hTdCngEnc->cng_lsp_hist_fx[i * M], lsf_tmp, M, INT_FS_16k );
- ftmp_fx = 1205; /*(8000/(M+1))X2.56*/
- move16(); /*QX2.56 */
- tmpv = sub( 20480, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
- L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */
- }
-
- tmpv = sub( lsf_tmp[0], ftmp_fx ); /*QX2.56 */
- L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536 */
- FOR( j = 0; j < M - 1; j++ )
- {
- tmpv = sub( sub( lsf_tmp[j + 1], lsf_tmp[j] ), ftmp_fx ); /*QX2.56 */
- L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536 */
- }
-
- C[i] = Mpy_32_16_1( L_tmp, 1928 );
- move32(); /*QX6.5536 */
-
- IF( GT_32( C[i], max_val[0] ) )
- {
- max_val[1] = max_val[0];
- move32();
- max_idx[1] = max_idx[0];
- move16();
- max_val[0] = C[i];
- move32();
- max_idx[0] = i;
- move16();
- }
- ELSE IF( GT_32( C[i], max_val[1] ) )
- {
- max_val[1] = C[i];
- move32();
- max_idx[1] = i;
- move16();
- }
- }
-
- FOR( i = 0; i < M; i++ )
- {
- L_tmp = 0;
- move32();
- FOR( j = 0; j < hDtxEnc->cng_hist_size; j++ )
- {
- L_tmp = L_add( L_tmp, L_deposit_l( hTdCngEnc->cng_lsp_hist_fx[j * M + i] ) ); /*Q15 */
- }
-
- L_tmp = L_sub( L_tmp, L_add( L_deposit_l( hTdCngEnc->cng_lsp_hist_fx[max_idx[0] * M + i] ), L_deposit_l( hTdCngEnc->cng_lsp_hist_fx[max_idx[1] * M + i] ) ) ); /*Q15 */
- tmpv = div_s( 1, sub( hDtxEnc->cng_hist_size, 2 ) ); /*Q15 */
- L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */
- lsp_new[i] = extract_l( L_tmp ); /*Q15 */
- move16();
- }
- max_idx1[0] = max_idx[0];
- move16();
- max_idx1[1] = max_idx[1];
- move16();
- }
-
- /*-----------------------------------------------------------------*
- * Quantize CNG spectral envelope (only in SID frame)
- * Quantize the LSF vector
- *-----------------------------------------------------------------*/
- *allow_cn_step = 0;
- move16();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( ( hDtxEnc->cng_cnt == 0 ) &&
- GT_16( hTdCngEnc->lp_sp_enr_fx, 1536 /* 6.0, Q8 */ ) &&
- ( LT_16( add( st_lp_sp_enr, 1024 /* 4.0, Q8 */ ), sp_enr ) ) &&
- ( hDtxEnc->first_CNG != 0 ) &&
- ( hTdCngEnc->old_enr_index >= 0 ) &&
- ( GT_32( st_fx->last_core_brate, SID_2k40 ) ) ) ||
- EQ_16( force_cn_step, 1 ) )
- {
- *allow_cn_step = 1;
- move16();
- }
-
- /* Initialize the CNG spectral envelope in case of the very first CNG frame */
- IF( hDtxEnc->first_CNG == 0 )
- {
- Copy( st_fx->lsp_old_fx, hDtxEnc->lspCNG_fx, M );
-
- /* Average the CNG spectral envelope in case of the very first CNG frame */
- IF( st_fx->element_mode != EVS_MONO )
- {
- FOR( i = 0; i < M; i++ )
- {
- /*lsp_new[i] = 0.5f * (lsp_mid[i] + lsp_new[i]);*/
- lsp_new[i] = mac_r( L_mult( lsp_mid[i], 16384 /*.5f Q15*/ ), lsp_new[i], 16384 /*.5f Q15*/ );
- move16();
- }
- }
- }
-
-
- test();
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) )
- {
- /* LSF quantization */
- IF( st_fx->Opt_AMR_WB != 0 )
- {
- isf_enc_amr_wb_fx( st_fx, lsf_new, lsp_new, 0 );
- }
- ELSE
- {
- lsf_enc_ivas_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 0, 0, NULL, Q_new );
- }
- /* Reset CNG history if CNG frame length is changed */
- test();
- test();
- if ( EQ_16( st_fx->bwidth, WB ) && hDtxEnc->first_CNG != 0 && NE_16( st_fx->L_frame, hDtxEnc->last_CNG_L_frame ) )
- {
- hTdCngEnc->ho_hist_size = 0;
- move16();
- }
- }
- ELSE
- {
- /* Use old LSP vector */
- Copy( st_fx->lsp_old_fx, lsp_new, M );
- Copy( st_fx->lsf_old_fx, lsf_new, M );
- }
-
- /*---------------------------------------------------------------------*
- * CNG spectral envelope update
- * Find A(z) coefficients
- *---------------------------------------------------------------------*/
- test();
- test();
- IF( ( st_fx->last_core_brate == FRAME_NO_DATA ) || EQ_32( st_fx->last_core_brate, SID_1k75 ) || EQ_32( st_fx->last_core_brate, SID_2k40 ) )
- {
- /* Reset hangover counter if not first SID period */
- if ( st_fx->core_brate > FRAME_NO_DATA )
- {
- hTdCngEnc->num_ho = 0;
- move16();
- }
- /* Update LSPs if last SID energy not outlier or insufficient number of hangover frames */
- test();
- IF( LT_16( hTdCngEnc->num_ho, 3 ) || LT_32( Mult_32_16( hTdCngEnc->Enew_fx, 21845 /*1/1.5f, Q15*/ ), hTdCngEnc->lp_ener_fx ) )
- {
- FOR( i = 0; i < M; i++ )
- {
- /* AR low-pass filter */
- hDtxEnc->lspCNG_fx[i] = mac_r( L_mult( CNG_ISF_FACT_FX, hDtxEnc->lspCNG_fx[i] ), 32768 /*1f Q15*/ - CNG_ISF_FACT_FX, lsp_new[i] );
- move16(); /* Q15 (15+15+1-16) */
- }
- }
- }
- ELSE
- {
- /* Update CNG_mode if allowed */
- test();
- test();
- test();
- test();
- IF( ( st_fx->element_mode == EVS_MONO ) && ( ( st_fx->Opt_AMR_WB || EQ_16( st_fx->bwidth, WB ) ) && ( !hDtxEnc->first_CNG || GE_16( hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) ) ) )
- {
- IF( GT_32( hDtxEnc->last_active_brate, ACELP_16k40 ) )
- {
- hDtxEnc->CNG_mode = -1;
- move16();
- }
- ELSE
- {
- hDtxEnc->CNG_mode = get_cng_mode( hDtxEnc->last_active_brate );
- move16();
- }
- }
-
- /* If first sid after active burst update LSF history from circ buffer */
- hTdCngEnc->burst_ho_cnt = s_min( hTdCngEnc->burst_ho_cnt, hTdCngEnc->ho_circ_size );
- move16();
- hTdCngEnc->act_cnt = 0;
- move16();
- s_ptr = add( sub( hTdCngEnc->ho_circ_ptr, hTdCngEnc->burst_ho_cnt ), 1 );
-
- if ( s_ptr < 0 )
- {
- s_ptr = add( s_ptr, hTdCngEnc->ho_circ_size );
- }
-
- FOR( ll = hTdCngEnc->burst_ho_cnt; ll > 0; ll-- )
- {
- hTdCngEnc->ho_hist_ptr = add( hTdCngEnc->ho_hist_ptr, 1 );
- move16();
- if ( EQ_16( hTdCngEnc->ho_hist_ptr, HO_HIST_SIZE ) )
- {
- hTdCngEnc->ho_hist_ptr = 0;
- move16();
- }
-
- /* Conversion between 12.8k and 16k LSPs */
- test();
- test();
- IF( EQ_16( st_fx->L_frame, L_FRAME ) && EQ_16( hTdCngEnc->ho_16k_lsp[s_ptr], 1 ) )
- {
- /* Conversion from 16k LPSs to 12k8 */
- lsp_convert_poly_fx( &( hTdCngEnc->ho_lsp_circ_fx[s_ptr * M] ), st_fx->L_frame, 0 );
- }
- ELSE IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && hTdCngEnc->ho_16k_lsp[s_ptr] == 0 )
- {
- /* 16k LSPs already converted and stored, just copy to the other buffer */
- Copy( &( hTdCngEnc->ho_lsp_circ2_fx[s_ptr * M] ), &( hTdCngEnc->ho_lsp_circ_fx[s_ptr * M] ), M );
- }
- /* update the circular buffers */
- Copy( &( hTdCngEnc->ho_lsp_circ_fx[s_ptr * M] ), &( hTdCngEnc->ho_lsp_hist_fx[hTdCngEnc->ho_hist_ptr * M] ), M );
- Copy32( &( hTdCngEnc->ho_ener_circ_fx[s_ptr] ), &( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] ), 1 );
- hTdCngEnc->ho_sid_bw = L_shl( L_and( hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 );
- move32();
- Copy32( &( hTdCngEnc->ho_env_circ_fx[s_ptr * NUM_ENV_CNG] ), &( hTdCngEnc->ho_env_hist_fx[hTdCngEnc->ho_hist_ptr * NUM_ENV_CNG] ), NUM_ENV_CNG );
-
- hTdCngEnc->ho_hist_size = add( hTdCngEnc->ho_hist_size, 1 );
- move16();
- if ( GT_16( hTdCngEnc->ho_hist_size, HO_HIST_SIZE ) )
- {
- hTdCngEnc->ho_hist_size = HO_HIST_SIZE;
- move16();
- }
-
- s_ptr = add( s_ptr, 1 );
-
- if ( EQ_16( s_ptr, hTdCngEnc->ho_circ_size ) )
- {
- s_ptr = 0;
- move16();
- }
- }
-
- IF( hTdCngEnc->burst_ho_cnt > 0 )
- {
- /**allow_cn_step |= ( hDtxEnc->first_CNG || st->element_mode == EVS_MONO ) && ( hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener );*/
- w_temp = W_msu_32_16( W_shl( W_deposit32_l( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] ), 2 ), hTdCngEnc->lp_ener_fx, lp_ener_thr_scale ); /*Q8*/
-
- test();
- test();
- IF( ( hDtxEnc->first_CNG > 0 || ( st_fx->element_mode == EVS_MONO ) ) && w_temp > 0 )
- {
- *allow_cn_step = s_or( *allow_cn_step, 1 );
- move16();
- }
- }
- test();
- IF( *allow_cn_step == 0 && hTdCngEnc->ho_hist_size > 0 )
- {
- /* Use average of energies below last energy */
- ptr = hTdCngEnc->ho_hist_ptr;
- move16();
- Copy( &( hTdCngEnc->ho_lsp_hist_fx[ptr * M] ), tmp, M );
- m1 = 0;
- move16();
- IF( L_and( hTdCngEnc->ho_sid_bw, 1 ) == 0 )
- {
- Copy32( &hTdCngEnc->ho_env_hist_fx[ptr * NUM_ENV_CNG], tmp_env, NUM_ENV_CNG );
- m1 = 1;
- move16();
- }
- L_ener = Mult_32_16( hTdCngEnc->ho_ener_hist_fx[ptr], W_DTX_HO_FX[0] ); /* Q6+15-15->Q6 */
-
- weights = W_DTX_HO_FX[0]; /* Q15 */
- move16();
- m = 1;
- move16();
- FOR( k = 1; k < hTdCngEnc->ho_hist_size; k++ )
- {
- ptr = sub( ptr, 1 );
- if ( ptr < 0 )
- {
- ptr = HO_HIST_SIZE - 1;
- move16();
- }
-
- test();
- IF( LT_32( Mult_32_16( hTdCngEnc->ho_ener_hist_fx[ptr], ONE_OVER_BUF_H_NRG_FX ), hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] ) &&
- GT_32( hTdCngEnc->ho_ener_hist_fx[ptr], Mult_32_16( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr], BUF_L_NRG_FX ) ) )
- {
- /*enr += W_DTX_HO[k] * st_fx->ho_ener_hist[ptr]; */
- L_tmp1 = Mult_32_16( hTdCngEnc->ho_ener_hist_fx[ptr], W_DTX_HO_FX[k] ); /* Q6+15-15->Q6 */
- L_ener = L_add( L_ener, L_tmp1 ); /* Q6 */
-
- /*weights += W_DTX_HO[k]; */
- weights = add( weights, W_DTX_HO_FX[k] ); /* Q15 */
-
- Copy( &hTdCngEnc->ho_lsp_hist_fx[ptr * M], &tmp[m * M], M );
- IF( L_and( hTdCngEnc->ho_sid_bw, L_shl( 1, k ) ) == 0 )
- {
- Copy32( &hTdCngEnc->ho_env_hist_fx[ptr * NUM_ENV_CNG], &tmp_env[m1 * NUM_ENV_CNG], NUM_ENV_CNG );
- m1 = add( m1, 1 );
- }
- m = add( m, 1 );
- }
- }
-
- /*enr /= weights; */
- exp = norm_s( weights );
- tmp1 = div_s( shl( 1, sub( 14, exp ) ), weights ); /* Q(15+14-exp-15) */
- L_tmp1 = Mult_32_16( L_ener, tmp1 ); /* Q(14-exp+6-15)->Q(5-exp) */
- L_ener = L_shl( L_tmp1, add( exp, 1 ) ); /* Q6 */
-
- hTdCngEnc->lp_ener_fx = L_ener;
- move32(); /* Q6 */
-
- set32_fx( max_val, 0, 2 );
- set16_fx( max_idx, 0, 2 );
-
- FOR( i = 0; i < m; i++ )
- {
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
- {
- lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_FX );
- ftmp_fx = 964; /*(6400/(M+1))X2.56*/
- move16(); /*QX2.56 */
- tmpv = sub( 16384, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
- L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */
- }
- ELSE
- {
- lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_16k );
- ftmp_fx = 1205; /*(8000/(M+1))X2.56*/
- move16(); /*QX2.56 */
- tmpv = sub( 20480, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */
- L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */
- }
-
- tmpv = sub( lsf_tmp[0], ftmp_fx ); /*QX2.56 */
- L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536 */
- FOR( j = 0; j < M - 1; j++ )
- {
- tmpv = sub( sub( lsf_tmp[j + 1], lsf_tmp[j] ), ftmp_fx ); /*QX2.56 */
- L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536 */
- }
-
- C[i] = Mpy_32_16_1( L_tmp, 1928 );
- move32(); /*QX6.5536 */
-
- IF( GT_32( C[i], max_val[0] ) )
- {
- max_val[1] = max_val[0];
- move32();
- max_idx[1] = max_idx[0];
- move16();
- max_val[0] = C[i];
- move32();
- max_idx[0] = i;
- move16();
- }
- ELSE IF( GT_32( C[i], max_val[1] ) )
- {
- max_val[1] = C[i];
- move32();
- max_idx[1] = i;
- move16();
- }
- }
-
- IF( EQ_16( m, 1 ) )
- {
- Copy( tmp, lsp_tmp, M );
- }
- ELSE IF( LT_16( m, 4 ) )
- {
- FOR( i = 0; i < M; i++ )
- {
- L_tmp = L_deposit_l( 0 );
- FOR( j = 0; j < m; j++ )
- {
- L_tmp = L_add( L_tmp, L_deposit_l( tmp[j * M + i] ) );
- }
-
- L_tmp = L_sub( L_tmp, L_deposit_l( tmp[max_idx[0] * M + i] ) );
- tmpv = div_s( 1, sub( m, 1 ) ); /*Q15 */
- L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */
- lsp_tmp[i] = extract_l( L_tmp ); /*Q15 */
- move16();
- }
- }
- ELSE
- {
- FOR( i = 0; i < M; i++ )
- {
- L_tmp = L_deposit_l( 0 );
- FOR( j = 0; j < m; j++ )
- {
- L_tmp = L_add( L_tmp, L_deposit_l( tmp[j * M + i] ) );
- }
-
- L_tmp = L_sub( L_tmp, L_add( L_deposit_l( tmp[max_idx[0] * M + i] ), L_deposit_l( tmp[max_idx[1] * M + i] ) ) ); /*Q15 */
- tmpv = div_s( 1, sub( m, 2 ) ); /*Q15 */ /*Q15 */
- L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */ /*Q15 */
- lsp_tmp[i] = extract_l( L_tmp ); /*Q15 */ /*Q15 */
- move16();
- }
- }
-
- dist = 0; /*Q15 */
- move32();
- max_dev = 0; /*Q15 */
- move32();
- FOR( i = 0; i < M; i++ )
- {
- dev = L_abs( L_sub( L_deposit_l( lsp_tmp[i] ), L_deposit_l( lsp_new[i] ) ) ); /*Q15 */
- dist = L_add( dist, dev ); /*Q15 */
- if ( GT_32( dev, max_dev ) )
- {
- max_dev = dev;
- move32();
- }
- }
-
- test();
- IF( GT_32( dist, 13107 ) || GT_32( max_dev, 3277 ) )
- {
- FOR( i = 0; i < M; i++ )
- {
- hDtxEnc->lspCNG_fx[i] = lsp_tmp[i];
- move16(); /*Q15 */
- }
- }
- ELSE
- {
- FOR( i = 0; i < M; i++ )
- {
- /* AR low-pass filter */
- hDtxEnc->lspCNG_fx[i] = add( mult_r( 26214 /*.8f Q15*/, lsp_tmp[i] ), mult_r( 6554 /*.2f Q15*/, lsp_new[i] ) ); /* Q15 */
- move16();
- }
- }
- IF( m1 > 0 )
- {
- FOR( i = 0; i < NUM_ENV_CNG; i++ )
- {
- L_tmp = L_deposit_l( 0 );
- FOR( j = 0; j < m1; j++ )
- {
- /* env[i] += tmp_env[j*NUM_ENV_CNG+i]; */
- L_tmp = L_add_sat( L_tmp, tmp_env[j * NUM_ENV_CNG + i] );
- }
- /* env[i] /= (float)m1; */
- /* env[i] = env[i] - 2*hTdCngEnc->lp_ener_fx; */
- IF( EQ_16( m1, 1 ) )
- {
- L_tmp = L_sub_sat( L_tmp, L_add_sat( hTdCngEnc->lp_ener_fx, hTdCngEnc->lp_ener_fx ) );
- }
- ELSE
- {
- tmp1 = div_s( 1, m1 );
- L_tmp = Mult_32_16( L_tmp, tmp1 );
- L_tmp = L_sub_sat( L_tmp, L_add_sat( hTdCngEnc->lp_ener_fx, hTdCngEnc->lp_ener_fx ) );
- }
-
- env[i] = L_tmp; /* Q6*/
- move32();
- }
- Copy32( env, hTdCngEnc->lp_env_fx, NUM_ENV_CNG ); /* Q6 */
- }
- }
- ELSE
- {
- Copy( lsp_new, hDtxEnc->lspCNG_fx, M ); /* use newly analyzed ISFs */ /* Q15 */
- }
- }
- IF( st_fx->Opt_AMR_WB != 0 )
- {
- E_LPC_f_isp_a_conversion( hDtxEnc->lspCNG_fx, Aq, M );
- }
- ELSE
- {
- E_LPC_f_lsp_a_conversion( hDtxEnc->lspCNG_fx, Aq, M );
- exp = sub( Q14, norm_s( Aq[0] ) );
- Scale_sig( Aq, M + 1, sub( Q12, exp ) ); // Q12
- }
-
- tmp_loop = shr( st_fx->L_frame, 6 );
- FOR( i = 1; i < tmp_loop; i++ )
- {
- Copy( Aq, &Aq[i * ( M + 1 )], M + 1 );
- }
- /*-----------------------------------------------------------------*
- * Find residual signal
- * Calculate residual signal energy per sample
- *-----------------------------------------------------------------*/
-
- /* calculate the residual signal */
- Residu3_fx( Aq, speech, res, st_fx->L_frame, 0 );
- Copy( res, res1, st_fx->L_frame ); /* Q_new */
- test();
- IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
- {
- L_tmp1 = L_mult0( hTdCngEnc->CNG_att_fx, 26214 /* 1/20.0f in Q19 */ ); // Q26 (7 + 19)
- L_tmp1 = BASOP_Util_fPow( 1342177280 /*10 in Q27 */, 4, L_tmp1, 5, &exp );
- att = extract_h( L_shl( L_sub( L_tmp1, EPSILON_FX ), exp ) ); // Q15 // Subtracting by EPSILON_FX to avoid assertion when L_tmp1 value is 1073741824 and exp =1
- v_multc_fx_16_16( res1, att, res1, st_fx->L_frame ); /* Q_new */
- }
- ELSE IF( st_fx->bwidth != NB )
- {
- test();
- IF( EQ_16( st_fx->bwidth, WB ) && hDtxEnc->CNG_mode >= 0 )
- {
- ftmp_fx = HO_ATT_FX[hDtxEnc->CNG_mode];
- move16();
- }
- ELSE
- {
- ftmp_fx = 19661; /*.6f in Q15*/
- move16();
- }
-
- att = mult( ftmp_fx, 5461 ); /* Q15 */
- L_tmp = L_mult( att, 8 ); /* Q16 */
- tmp1 = extract_l( L_shr( L_tmp, 2 ) ); /* Q14 */
- tmp1 = add( 16384, tmp1 );
- att = div_s( 16374, tmp1 ); /* Q15 */
-
- att = s_max( att, ftmp_fx );
- FOR( i = 0; i < st_fx->L_frame; i++ )
- {
- /*res1[i] *= att;*/
- res1[i] = mult( res1[i], att );
- move16(); /* Q_new */
- }
- att = shr( att, 7 ); /* Q8 */
- }
-
- /* calculate the spectrum of residual signal */
- Copy( res1, fft_io, st_fx->L_frame ); /* Q_new */
-
- IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
- {
- modify_Fs_fx( fft_io, L_FRAME16k, 16000, fft_io, 12800, hTdCngEnc->exc_mem2_fx, 0 );
- }
-
- fft_rel_fx( fft_io, L_FFT, LOG2_L_FFT );
- ptR = &fft_io[1];
- ptI = &fft_io[L_FFT - 1];
- FOR( i = 0; i < NUM_ENV_CNG; i++ )
- {
- /* env[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */
- L_tmp = L_mult_sat( *ptR, *ptR ); /* 2*Q_new+1 */
- L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_new+1 */
- L_tmp = L_add_sat( L_tmp, L_tmp ); /* 2*Q_new+1 */
- L_tmp = Mult_32_16( L_tmp, 128 ); /* 2*Q_new+1 */
- tmp1 = add( add( Q_new, Q_new ), 1 );
- env[i] = L_shr( L_tmp, sub( tmp1, 6 ) );
- move32(); /* Q6 */
- ptR++;
- ptI--;
- }
-
- Copy32( env, &( hTdCngEnc->cng_res_env_fx[( hTdCngEnc->cng_hist_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG );
-
- /* calculate the residual signal energy */
- /*enr = dotp( res, res, L_frame ) / L_frame; */
- w_temp = 1;
- move64();
- FOR( j = 0; j < st_fx->L_frame; j++ )
- {
- w_temp = W_mac0_16_16( w_temp, res[j], res[j] );
- }
- exp = W_norm( w_temp );
-
- SWITCH( st_fx->L_frame )
- {
- case L_FRAME25_6k:
- inv_frame_len = ONE_BY_L_FRAME25_6k_Q31;
- move16();
- BREAK;
- case L_FRAME:
- inv_frame_len = ONE_BY_L_FRAME_Q31;
- move16();
- BREAK;
- case L_FRAME48k:
- inv_frame_len = ONE_BY_L_FRAME48k_Q31;
- move16();
- BREAK;
- case 240:
- inv_frame_len = ONE_BY_240_Q31;
- move16();
- BREAK;
- case L_FRAME32k:
- inv_frame_len = ONE_BY_L_FRAME32k_Q31;
- move16();
- BREAK;
- case L_FRAME16k:
- inv_frame_len = ONE_BY_L_FRAME16k_Q31;
- move16();
- BREAK;
- case L_FRAME8k:
- inv_frame_len = ONE_BY_L_FRAME8k_Q31;
- move16();
- BREAK;
- case L_FRAME4k:
- inv_frame_len = ONE_BY_L_FRAME4k_Q31;
- move16();
- BREAK;
- default:
- inv_frame_len = divide3216( 1, st_fx->L_frame );
- }
- L_ener = W_extract_h( W_shl( w_temp, exp ) ); /* Q = 2*Q_new+exp-32 */
- L_ener = Mpy_32_32( L_ener, inv_frame_len ); /* Q = 2*Q_new+exp-32 */
- L_ener = L_shl( L_ener, sub( 33, exp ) ); /* Q = 2*Q_new+1 */
-
- /* convert log2 of residual signal energy */
- /*enr = (float)log10( enr + 0.1f ) / (float)log10( 2.0f ); */
-
- IF( L_ener == 0 )
- {
- enr = -850; /*log(0.1) base 2 in Q8*/
- move16();
- }
- ELSE
- {
- hi = norm_l( L_ener );
- lo = Log2_norm_lc( L_shl( L_ener, hi ) );
- hi = sub( 29, hi ); /* log2 exp in Q2*Q_new */
- hi = sub( hi, shl( Q_new, 1 ) ); /* Q0 */
- L_tmp = L_Comp( hi, lo ); /* Q16 */
- enr = round_fx( L_shl( L_tmp, 8 ) ); /* Q8 (16+8-16) */
- }
- /* update the circular buffer of old energies */
- hTdCngEnc->cng_ener_hist_fx[hTdCngEnc->cng_hist_ptr] = enr;
- move16(); /* Q8 */
-
- /*-----------------------------------------------------------------*
- * Quantize residual signal energy (only in SID frame)
- *-----------------------------------------------------------------*/
- test();
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) )
- {
- IF( GE_16( hDtxEnc->cng_cnt, sub( hDtxEnc->cng_hist_size, 1 ) ) )
- {
- /* average the envelope except outliers */
- FOR( i = 0; i < NUM_ENV_CNG; i++ )
- {
- L_tmp1 = L_add( env[i], 0 );
- FOR( j = 0; j < hDtxEnc->cng_hist_size; j++ )
- {
- L_tmp1 = L_add_sat( L_tmp1, hTdCngEnc->cng_res_env_fx[j * NUM_ENV_CNG + i] );
- }
- L_tmp = L_add( hTdCngEnc->cng_res_env_fx[max_idx1[0] * NUM_ENV_CNG + i], hTdCngEnc->cng_res_env_fx[max_idx1[1] * NUM_ENV_CNG + i] );
- L_tmp1 = L_sub( L_tmp1, L_tmp );
-
- /* env[i] /= (float)(st_fx->cng_hist_size - 2); */
- tmp1 = sub( hDtxEnc->cng_hist_size, 2 );
- IF( GT_16( tmp1, 1 ) )
- {
- tmp1 = div_s( 1, tmp1 );
- L_tmp1 = Mult_32_16( L_tmp1, tmp1 );
- }
-
- env[i] = L_tmp1;
- move32();
- }
- /* compute average excitation energy */
- L_tmp = L_deposit_l( 0 );
- ptr = hTdCngEnc->cng_hist_ptr;
- move16();
-
- FOR( k = 0; k < hDtxEnc->cng_hist_size; k++ )
- {
- /* enr += W_HIST[k]*cng_ener_hist[ptr] */
- L_tmp = L_mac0( L_tmp, W_HIST_FX[k], hTdCngEnc->cng_ener_hist_fx[ptr] ); /* Q24 (8+16) */
- ptr = sub( ptr, 1 );
- if ( ptr < 0 ) /* check for circular pointer */
- {
- ptr = DTX_HIST_SIZE - 1;
- move16();
- }
- }
- /*-----------------------------------------------------------
- * here we want to divide L_tmp by the sum
- * of all the coefs used W_HIST[0..cng_hist_size-1]
- * The table W_HIST_S already contains the inverted sum.
- * That is
- * W_HIST_S[k] 1
- * ------------- = ---------------------------
- * 4096 W_HIST[0] + ... + W_HIST[k]
- *
- * 1 / Sum(W_HIST[0..k]) is always > 1 since the sum
- * of the coefs 0..k is always < 1 but > 0
- * enr is in Q8 since the history buffer constains Q8 energies
- *-----------------------------------------------------------*/
- /*L_tmp = Mpy_32_16_1(L_tmp, W_HIST_S_FX[k-1]); */ /* normalize average value */
- L_tmp = Mult_32_16( L_tmp, W_HIST_S_FX[k - 1] ); /* Q21 (24+12+1-16) */
- L_tmp = L_shl( L_tmp, 3 ); /* Q24 */
- enr = round_fx( L_tmp ); /* Q8 */
- }
- /* decrease the energy in case of WB input */
- test();
- IF( EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) )
- {
- enr = add( enr, mult( hTdCngEnc->CNG_att_fx, FAC_LOG2_BY10_Q16 ) ); /* Q8 (Q7 + Q16 - Q15)*/
- }
- ELSE IF( st_fx->bwidth != NB )
- {
- IF( EQ_16( st_fx->bwidth, WB ) )
- {
- IF( hDtxEnc->CNG_mode >= 0 )
- {
- /* Bitrate adapted attenuation */
- att = ENR_ATT_fx[hDtxEnc->CNG_mode];
- move16();
- }
- ELSE
- {
- /* Use least attenuation for higher bitrates */
- att = ENR_ATT_fx[4];
- move16();
- }
- }
- ELSE
- {
- att = 384;
- move16(); /*1.5f Q8*/
- }
- enr = sub( enr, att );
- }
- /* intialize the energy quantization parameters */
- IF( st_fx->Opt_AMR_WB == 0 )
- {
- step = STEP_SID_FX; // Q12
- move16();
- step_inv = ISTEP_SID_FX;
- move16();
- maxl = 127;
- move16();
- num_bits = 7;
- move16();
- }
- ELSE
- {
- step = STEP_AMR_WB_SID_FX;
- move16();
- step_inv = ISTEP_AMR_WB_SID_FX;
- move16();
- maxl = 63;
- move16();
- num_bits = 6;
- move16();
- }
-
- /* calculate the energy quantization index */
- enr_index = add( enr, 512 /* Q8(2.0) */ ); /* enr + 2.0 */
- enr_index = extract_l( L_shr( L_mult0( enr_index, step ), 12 + 8 ) ); /* Q0 (8+12-(8+12)) */
-
- /* limit the energy quantization index */
- enr_index = s_min( enr_index, maxl );
- enr_index = s_max( enr_index, 0 );
-
- /* allow only slow energy increase */
- test();
- IF( hTdCngEnc->old_enr_index >= 0 && GT_16( enr_index, add( hTdCngEnc->old_enr_index, MAX_DELTA ) ) )
- {
- IF( *allow_cn_step != 0 )
- {
- tmp1 = mult( 27853 /* Q15(0.85) */, sub( enr_index, hTdCngEnc->old_enr_index ) );
- enr_index = add( hTdCngEnc->old_enr_index, tmp1 );
- }
- ELSE
- {
- enr_index = add( hTdCngEnc->old_enr_index, MAX_DELTA );
- }
- }
- hTdCngEnc->old_enr_index = enr_index;
- move16();
-
- push_indice( hBstr, IND_ENERGY, enr_index, num_bits );
- if ( enr_index == 0 )
- {
- enr_index = -5;
- move16();
- }
- /* Find quantized energy */
- /* *Enew = (float)enr_index / step - 2.0 */
- /* *Enew = (float)pow(2.0, *Enew) */
- L_tmp = L_mult( enr_index, step_inv ); /* Q16(0+15+1) */
- /* substract by 2 not done to leave Energy in Q2 */
- lo = L_Extract_lc( L_tmp, &hi );
- hTdCngEnc->Enew_fx = Pow2( add( hi, 4 ), lo ); /* Q6 */
- move32();
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- /* enr1 = (float)log10( st->Enew*L_frame + 0.1f ) / (float)log10( 2.0f );*/
- exp = norm_l( hTdCngEnc->Enew_fx );
- L_tmp = L_shl( hTdCngEnc->Enew_fx, exp ); /*Q(exp+6) */
- L_tmp = Mult_32_16( L_tmp, shl( st_fx->L_frame, 5 ) ); /* Q(exp+6+5-15=exp-4) */
-
- L_tmp = L_shr_sat( L_tmp, sub( exp, 10 ) ); /* Q6 */
-
- exp = norm_l( L_tmp );
- fra = Log2_norm_lc( L_shl( L_tmp, exp ) );
- exp = sub( sub( 30, exp ), 6 );
- L_tmp = L_Comp( exp, fra );
- enr1 = L_shr( L_tmp, 10 ); /* Q6 */
-
- FOR( i = 0; i < NUM_ENV_CNG; i++ )
- {
- /* env[i] -= 2 * st->Enew;*/
- L_tmp1 = L_add( env[i], 0 );
- L_tmp = L_add( hTdCngEnc->Enew_fx, hTdCngEnc->Enew_fx );
- L_tmp1 = L_sub( L_tmp1, L_tmp ); /*Q6*/
-
- IF( L_tmp1 < 0 )
- {
- L_tmp1 = L_deposit_l( 6 ); /* (0.1)Q6 */
- }
- /* env[i] = (float)log10( env[i] + 0.1f ) / (float)log10( 2.0f ); */
- exp = norm_l( L_tmp1 );
- fra = Log2_norm_lc( L_shl( L_tmp1, exp ) );
- exp = sub( sub( 30, exp ), 6 );
- L_tmp = L_Comp( exp, fra );
- L_tmp1 = L_shr( L_tmp, 10 ); /* Q6 */
-
- L_tmp = L_shr( L_deposit_l( att ), 2 ); /* Q6 */
- L_tmp1 = L_sub( L_tmp1, L_tmp );
-
- IF( L_tmp1 < 0 )
- {
- L_tmp1 = L_deposit_l( 0 );
- }
-
- L_tmp1 = L_sub( enr1, L_tmp1 );
-
- env[i] = L_tmp1;
- move32();
- }
-
- /* codebook search */
- min1 = 1310588928; /* 9999.0f Q17 */
- move32();
- min1_idx = 0;
- move16();
-
- FOR( i = 0; i < 64; i++ )
- {
- d = L_deposit_l( 0 );
- FOR( j = 0; j < NUM_ENV_CNG; j++ )
- {
- /* d += (env[j] - CNG_details_codebook_fx[i][j]) * (env[j] - CNG_details_codebook_fx[i][j]);*/
- L_tmp = L_sub( env[j], L_deposit_l( CNG_details_codebook_fx[i][j] ) ); /* Q6 */
- exp = norm_l( L_tmp );
- L_tmp = L_shl( L_tmp, exp ); /*Q(exp+6)*/
- tmp1 = extract_h( L_tmp ); /*Q(exp+6-16)=exp-10*/
- L_tmp = L_mult_sat( tmp1, tmp1 ); /*Q(2*exp - 19)*/
- L_tmp = L_shr( L_tmp, sub( add( exp, exp ), 36 ) ); /* Q17 */
- d = L_add( d, L_tmp ); /* Q17 */
- }
-
- IF( LT_32( d, min1 ) )
- {
- min1 = d;
- move32();
- min1_idx = i;
- move16();
- }
- }
- push_indice( hBstr, IND_CNG_ENV1, min1_idx, 6 );
- /* get quantized res_env_details */
- FOR( i = 0; i < NUM_ENV_CNG; i++ )
- {
- q_env[i] = L_deposit_l( CNG_details_codebook_fx[min1_idx][i] );
- move32();
- }
- }
- /* Update hangover memory during CNG */
- test();
- IF( *allow_cn_step == 0 && LT_32( Mult_32_16( hTdCngEnc->Enew_fx, 21845 /*1/1.5f, Q15*/ ), hTdCngEnc->lp_ener_fx ) )
- {
- /* update the pointer to circular buffer of old LSP vectors */
- hTdCngEnc->ho_hist_ptr = add( hTdCngEnc->ho_hist_ptr, 1 );
- move16();
- if ( EQ_16( hTdCngEnc->ho_hist_ptr, HO_HIST_SIZE ) )
- {
- hTdCngEnc->ho_hist_ptr = 0;
- move16();
- }
-
- /* update the circular buffer of old LSP vectors with the new LSP vector */
- Copy( lsp_new, &( hTdCngEnc->ho_lsp_hist_fx[( hTdCngEnc->ho_hist_ptr ) * M] ), M );
-
- /* update the hangover energy buffer */
- hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] = hTdCngEnc->Enew_fx;
- move32();
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- FOR( i = 0; i < NUM_ENV_CNG; i++ )
- {
- /* get quantized envelope */
- /* env[i] = pow(2.0f,(enr1 - q_env[i])) + 2*st->Enew;*/
- L_tmp = L_sub( enr1, q_env[i] ); /* Q6 */
- L_tmp = L_shl( L_tmp, 10 ); /* 16 */
- temp_lo_fx = L_Extract_lc( L_tmp, &temp_hi_fx );
-
- exp_pow = sub( 14, temp_hi_fx );
- L_tmp = Pow2( 14, temp_lo_fx ); /* Qexp_pow */
- env[i] = L_shl( L_tmp, sub( 6, exp_pow ) );
- move32(); /* Q6 */
- L_tmp = L_add( hTdCngEnc->Enew_fx, hTdCngEnc->Enew_fx );
- env[i] = L_add( env[i], L_tmp );
- move32(); /* Q6 */
- }
- Copy32( env, &( hTdCngEnc->ho_env_hist_fx[( hTdCngEnc->ho_hist_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG );
- }
- hTdCngEnc->ho_hist_size = add( hTdCngEnc->ho_hist_size, 1 );
- move16();
- if ( GT_16( hTdCngEnc->ho_hist_size, HO_HIST_SIZE ) )
- {
- hTdCngEnc->ho_hist_size = HO_HIST_SIZE;
- move16();
- }
- }
- }
- /* dithering bit for AMR-WB IO mode is always set to 0 */
- IF( EQ_32( st_fx->core_brate, SID_1k75 ) )
- {
- push_indice( hBstr, IND_DITHERING, 0, 1 );
- }
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
- {
- push_indice( hBstr, IND_ACELP_16KHZ, 1, 1 );
- }
- ELSE
- {
- push_indice( hBstr, IND_ACELP_16KHZ, 0, 1 );
- }
-
- push_indice( hBstr, IND_CNG_HO, s_min( hTdCngEnc->burst_ho_cnt, HO_HIST_SIZE - 1 ), 3 );
- hTdCngEnc->num_ho = m;
- move16();
- push_indice( hBstr, IND_SID_TYPE, 0, 1 );
-
- test();
- IF( LT_32( st_fx->input_Fs, 32000 ) && NE_16( st_fx->element_mode, IVAS_CPE_DFT ) )
- {
- push_indice( hBstr, IND_SID_BW, 0, 1 );
- *sid_bw = 0;
- move16();
- }
- }
-
- /*-----------------------------------------------------------------*
- * Updates
- *-----------------------------------------------------------------*/
- /* update the SID frames counter */
- test();
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) )
- {
- hDtxEnc->cng_cnt = 0;
- move16();
- hTdCngEnc->cng_hist_ptr = -1;
- move16();
- /* update frame length memory */
- hDtxEnc->last_CNG_L_frame = st_fx->L_frame;
- move16();
- }
- ELSE
- {
- hDtxEnc->cng_cnt = add( hDtxEnc->cng_cnt, 1 );
- move16();
- }
-
- return;
-}
-/*---------------------------------------------------------------------*
- * swb_CNG_enc()
- *
- * SWB DTX/CNG encoding
- *---------------------------------------------------------------------*/
-void swb_CNG_enc_fx(
- Encoder_State *st_fx, /* i/o: State structure */
- const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz (Q0) */
- const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz (st_fx->Q_syn = 0) */
-)
-{
- Word16 shb_SID_updt_fx = 0;
- move16();
- TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc;
-
- test();
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) || st_fx->core_brate == FRAME_NO_DATA )
- {
- IF( EQ_16( st_fx->cng_type, LP_CNG ) )
- {
- IF( GE_32( st_fx->input_Fs, L_FRAME32k * FRAMES_PER_SEC ) )
- {
- /* decide if SHB SID encoding or not */
- shb_SID_updt_fx = shb_DTX_fx( st_fx, shb_speech_fx, syn_12k8_16k_fx );
-
- /* SHB CNG encoding */
- shb_CNG_encod_fx( st_fx, shb_SID_updt_fx );
- }
- ELSE IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- }
- }
- hTdCngEnc->last_vad = 0;
- move16();
- }
- ELSE
- {
- hTdCngEnc->last_vad = 1;
- move16();
- }
-
- return;
-}
-
-/*---------------------------------------------------------------------*
- * shb_CNG_encod()
- *
- * SID parameters encoding for SHB signal
- *---------------------------------------------------------------------*/
-static void shb_CNG_encod_fx(
- Encoder_State *st_fx, /* i/o: State structure */
- const Word16 update_fx /* i : SID update flag */
-)
-{
- Word16 idx_ener_fx;
- TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc;
- BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
-
- idx_ener_fx = 0;
- move16();
- IF( EQ_16( update_fx, 1 ) )
- {
- /* SHB energy quantization */
- IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
- {
- idx_ener_fx = shr( add( mult( hTdCngEnc->mov_shb_cng_ener_fx, 9797 ), 1510 ), 8 ); /* Q0 */
- }
- ELSE
- {
- }
-
- if ( LT_16( st_fx->bwidth, SWB ) )
- {
- idx_ener_fx = 0;
- move16();
- }
-
- IF( GT_16( idx_ener_fx, 15 ) )
- {
- idx_ener_fx = 15;
- move16();
- }
- ELSE
- {
- idx_ener_fx = s_max( idx_ener_fx, 0 );
- }
-
- push_indice( hBstr, IND_SHB_CNG_GAIN, idx_ener_fx, 4 );
- push_indice( hBstr, IND_SID_BW, 1, 1 );
- delete_indice( hBstr, IND_CNG_ENV1 );
- move16();
- move16();
-
- if ( st_fx->element_mode == IVAS_CPE_DFT )
- {
- }
- else
- {
- push_indice( hBstr, IND_UNUSED, 0, 2 );
- }
- hTdCngEnc->ho_sid_bw = L_shl( L_and( hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 );
- hTdCngEnc->ho_sid_bw = L_or( hTdCngEnc->ho_sid_bw, 0x1L );
- move32();
- move32();
- }
- ELSE
- {
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- hTdCngEnc->ho_sid_bw = L_shl( L_and( hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 );
- push_indice( hBstr, IND_SID_BW, 0, 1 );
- }
- }
-
- return;
-}
-
-/*---------------------------------------------------------------------*
- * shb_DTX()
- *
- * Decide if encoding SHB SID or not
- *---------------------------------------------------------------------*/
-static Word16 shb_DTX_fx(
- Encoder_State *st_fx, /* i/o: State structure */
- const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz (Q0) */
- const Word16 *syn_12k8_16k /* i : ACELP core synthesis at 12.8kHz or 16kHz (st_fx->Q_syn = 0) */
-)
-{
- Word16 i;
- Word16 update_fx;
- Word16 shb_old_speech_fx[( ACELP_LOOK_12k8 + L_SUBFR + L_FRAME ) * 5 / 4];
- Word16 *shb_new_speech_fx;
- Word32 wb_ener_fx;
- Word32 shb_ener_fx;
- Word16 log_wb_ener_fx;
- Word16 log_shb_ener_fx;
- Word16 tmp;
- Word16 exp;
- Word16 fra;
- Word16 att; /*Q8*/
- Word16 allow_cn_step_fx = 0;
- move16();
- DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc;
- TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc;
- TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD;
-
- shb_new_speech_fx = shb_old_speech_fx + ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4;
- Copy( hBWE_TD->old_speech_shb_fx, shb_old_speech_fx, ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4 );
- Copy( shb_speech_fx, shb_new_speech_fx, L_FRAME16k );
- Copy( shb_old_speech_fx + L_FRAME16k, hBWE_TD->old_speech_shb_fx, ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4 );
-
- shb_ener_fx = L_deposit_l( 0 );
- FOR( i = 0; i < L_FRAME16k; i++ )
- {
- shb_ener_fx = L_mac_sat( shb_ener_fx, shb_old_speech_fx[i], shb_old_speech_fx[i] );
- }
-
- shb_ener_fx = L_add( Mpy_32_16_1( shb_ener_fx, 102 ), 1 ); /* 102 in Q15, shb_ener_fx in Q1 */
-
- wb_ener_fx = L_deposit_l( 0 );
- FOR( i = 0; i < st_fx->L_frame; i++ )
- {
- wb_ener_fx = L_mac_sat( wb_ener_fx, syn_12k8_16k[i], syn_12k8_16k[i] );
- }
-
- wb_ener_fx = L_add( Mpy_32_16_1( wb_ener_fx, 128 ), 1 ); /* 128 in Q15, wb_ener_fx in Q1 */
-
- exp = norm_l( wb_ener_fx );
- fra = Log2_norm_lc( L_shl( wb_ener_fx, exp ) );
- exp = sub( 30 - 1, exp );
- wb_ener_fx = Mpy_32_16( exp, fra, LG10 );
- log_wb_ener_fx = round_fx_sat( L_shl_sat( wb_ener_fx, 10 ) ); /* log_wb_ener_fx in Q8 */
- exp = norm_l( shb_ener_fx );
- fra = Log2_norm_lc( L_shl( shb_ener_fx, exp ) );
- exp = sub( 30 - 1, exp );
- shb_ener_fx = Mpy_32_16( exp, fra, LG10 );
-
- test();
- IF( EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) )
- {
- att = 0;
- move16();
- }
- ELSE
- {
- att = 1664; /*6.5 in Q8*/
- move16();
- }
-
- log_shb_ener_fx = sub_sat( round_fx_sat( L_shl_sat( shb_ener_fx, 10 ) ), att ); /* log_shb_ener_fx in Q8 */
- IF( hDtxEnc->first_CNG == 0 )
- {
- hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx;
- move16();
- hTdCngEnc->mov_shb_cng_ener_fx = log_shb_ener_fx;
- move16();
- hTdCngEnc->last_wb_cng_ener_fx = log_wb_ener_fx;
- move16();
- hTdCngEnc->last_shb_cng_ener_fx = log_shb_ener_fx;
- move16();
- }
-
- if ( GT_16( abs_s( sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ) ), 3072 /*12.0f Q8*/ ) )
- {
- allow_cn_step_fx = 1;
- move16();
- }
-
- IF( EQ_16( allow_cn_step_fx, 1 ) )
- {
- hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx;
- move16();
- hTdCngEnc->mov_shb_cng_ener_fx = log_shb_ener_fx;
- move16();
- }
- ELSE
- {
- tmp = sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ); /* Q8 */
- tmp = mult( tmp, 29491 /*.9f in Q15*/ ); /* Q8 */
- hTdCngEnc->mov_wb_cng_ener_fx = add( hTdCngEnc->mov_wb_cng_ener_fx, tmp ); /* Q8 */
- move16();
- tmp = sub( log_shb_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx );
- tmp = mult( tmp, 8192 /*.25f in Q15*/ ); /* Q8 */
- hTdCngEnc->mov_shb_cng_ener_fx = add( hTdCngEnc->mov_shb_cng_ener_fx, tmp ); /* Q8 */
- move16();
- }
- hTdCngEnc->shb_NO_DATA_cnt = add( hTdCngEnc->shb_NO_DATA_cnt, 1 );
- move16();
- update_fx = 0;
- move16();
- IF( EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- test();
- test();
- IF( hDtxEnc->first_CNG == 0 || EQ_16( hTdCngEnc->last_vad, 1 ) || GE_16( hTdCngEnc->shb_NO_DATA_cnt, 100 ) )
- {
- update_fx = 1;
- move16();
- }
- ELSE
- {
- IF( hTdCngEnc->shb_cng_ini_cnt > 0 )
- {
- update_fx = 1;
- move16();
- hTdCngEnc->shb_cng_ini_cnt = sub( hTdCngEnc->shb_cng_ini_cnt, 1 );
- move16();
- }
- ELSE
- {
- IF( GT_16( abs_s( sub( sub( hTdCngEnc->mov_wb_cng_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx ), sub( hTdCngEnc->last_wb_cng_ener_fx, hTdCngEnc->last_shb_cng_ener_fx ) ) ), 768 /*3.0f in Q8*/ ) )
- {
- update_fx = 1;
- move16();
- }
- ELSE
- {
- test();
- IF( GE_16( st_fx->bwidth, SWB ) && LT_16( hTdCngEnc->last_SID_bwidth, SWB ) )
- {
- update_fx = 1;
- move16();
- }
- ELSE
- {
- test();
- IF( LT_16( st_fx->bwidth, SWB ) && GE_16( hTdCngEnc->last_SID_bwidth, SWB ) )
- {
- update_fx = 1;
- move16();
- }
- }
- }
- }
- }
-
- hTdCngEnc->last_SID_bwidth = st_fx->bwidth;
- move16();
- }
- /* LF-boost not yet implemented in decoder which means that the specific wb_sid information is not used */
- test();
- test();
- if ( ( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) && EQ_32( st_fx->core_brate, SID_2k40 ) )
- {
- update_fx = 1;
- move16();
- }
-
- IF( EQ_16( update_fx, 1 ) )
- {
- hTdCngEnc->last_wb_cng_ener_fx = hTdCngEnc->mov_wb_cng_ener_fx;
- move16();
- hTdCngEnc->last_shb_cng_ener_fx = hTdCngEnc->mov_shb_cng_ener_fx;
- move16();
- hTdCngEnc->shb_NO_DATA_cnt = 0;
- move16();
- }
-
-
- return ( update_fx );
-}
-
-/*---------------------------------------------------------------------*
- * calculate_hangover_attenuation_gain_fx()
- *
- *
- *---------------------------------------------------------------------*/
-void calculate_hangover_attenuation_gain_fx(
- Encoder_State *st, /* i : encoder state structure */
- Word16 *att, /* o : attenuation factor Q15 */
- const Word16 vad_hover_flag /* i : VAD hangover flag */
-)
-{
- Word16 offset;
- TD_CNG_ENC_HANDLE hTdCngEnc = st->hTdCngEnc;
-
- *att = 32767; // 1.0f in Q15
-
- move16();
- /* smoothing in case of CNG */
- IF( hTdCngEnc != NULL )
- {
- test();
- test();
- test();
- IF( hTdCngEnc->burst_ho_cnt > 0 && ( vad_hover_flag != 0 ) && ( NE_16( st->bwidth, NB ) || st->element_mode > EVS_MONO ) ) /* corresponds to line 504 in FLT acelp_core_enc.c */
- {
- if ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD )
- {
- }
- else
- {
- offset = 5;
- move16();
- test();
- if ( EQ_16( st->bwidth, WB ) && st->hDtxEnc->CNG_mode >= 0 )
- {
- offset = st->hDtxEnc->CNG_mode;
- move16();
- }
- assert( hTdCngEnc->burst_ho_cnt > 0 );
- *att = CNG_burst_att_fx[offset][hTdCngEnc->burst_ho_cnt - 1]; /*Q15*/
- move16();
- }
- }
- }
- return;
-}
-
-void calculate_hangover_attenuation_gain_ivas_fx(
- Encoder_State *st, /* i : encoder state structure */
- Word16 *att, /* o : attenuation factor Q15 */
- const Word16 vad_hover_flag /* i : VAD hangover flag */
-)
+
+/*---------------------------------------------------------------------*
+ * calculate_hangover_attenuation_gain_fx()
+ *
+ *
+ *---------------------------------------------------------------------*/
+
+void calculate_hangover_attenuation_gain_fx(
+ Encoder_State *st, /* i : encoder state structure */
+ Word16 *att, /* o : attenuation factor Q15 */
+ const Word16 vad_hover_flag /* i : VAD hangover flag */
+)
{
Word16 lim, result_e;
@@ -2732,6 +1401,20 @@ void calculate_hangover_attenuation_gain_ivas_fx(
*att = extract_h( L_shl_sat( L_tmp, result_e ) );
move16();
}
+ ELSE IF( st->element_mode == EVS_MONO )
+ {
+ Word16 offset = 5;
+ move16();
+ test();
+ if ( EQ_16( st->bwidth, WB ) && st->hDtxEnc->CNG_mode >= 0 )
+ {
+ offset = st->hDtxEnc->CNG_mode;
+ move16();
+ }
+ assert( st->hTdCngEnc->burst_ho_cnt > 0 );
+ *att = CNG_burst_att_fx[offset][st->hTdCngEnc->burst_ho_cnt - 1]; /*Q15*/
+ move16();
+ }
ELSE
{
test();
@@ -2761,10 +1444,17 @@ void calculate_hangover_attenuation_gain_ivas_fx(
return;
}
-void swb_CNG_enc_ivas_fx(
- Encoder_State *st, /* i/o: State structure */
- const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */
- const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */
+
+/*---------------------------------------------------------------------*
+ * swb_CNG_enc()
+ *
+ * SWB DTX/CNG encoding
+ *---------------------------------------------------------------------*/
+
+void swb_CNG_enc_fx(
+ Encoder_State *st, /* i/o: State structure */
+ const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */
+ const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */
)
{
Word16 shb_SID_updt;
@@ -2778,10 +1468,10 @@ void swb_CNG_enc_ivas_fx(
IF( GE_32( st->input_Fs, L_FRAME32k * FRAMES_PER_SEC ) )
{
/* decide if SHB SID encoding or not */
- shb_SID_updt = shb_DTX_ivas_fx( st, shb_speech_fx, syn_12k8_16k_fx );
+ shb_SID_updt = shb_DTX_fx( st, shb_speech_fx, syn_12k8_16k_fx );
/* SHB CNG encoding */
- shb_CNG_encod_ivas_fx( st, shb_SID_updt );
+ shb_CNG_encod_fx( st, shb_SID_updt );
}
ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_32( st->core_brate, SID_2k40 ) )
{
@@ -2811,7 +1501,7 @@ void swb_CNG_enc_ivas_fx(
* SID parameters encoding for SHB signal
*---------------------------------------------------------------------*/
-static void shb_CNG_encod_ivas_fx(
+static void shb_CNG_encod_fx(
Encoder_State *st, /* i/o: State structure */
const Word16 update /* i : SID update flag */
)
@@ -2819,17 +1509,13 @@ static void shb_CNG_encod_ivas_fx(
Word16 idx_ener = 0;
move16();
BSTR_ENC_HANDLE hBstr = st->hBstr;
-
Word16 ener_mid_dec_thr_fx;
IF( EQ_16( update, 1 ) )
{
IF( st->element_mode == EVS_MONO )
{
- /* 6.0 in Q8 -> 1510 */
- /* 0.9 in Q15 29491 */
- /* ( 1 / log10(2.0) ) * 0.1 in Q15 ->10886 */
- idx_ener = shr( mult( add( mult( st->hTdCngEnc->mov_shb_cng_ener_fx, 10886 ), 1510 ), 29491 ), 8 ); /* Q0 */
+ idx_ener = shr( add( mult( st->hTdCngEnc->mov_shb_cng_ener_fx, 9797 ), 1510 ), 8 ); /* Q0 */
}
ELSE
{
@@ -2840,7 +1526,6 @@ static void shb_CNG_encod_ivas_fx(
idx_ener = shr( mult( add( mult( st->hTdCngEnc->mov_shb_cng_ener_fx, 10886 ), 1510 ), 22938 ), 8 ); /* Q0 */
}
-
if ( LT_16( st->bwidth, SWB ) )
{
idx_ener = 0;
@@ -2901,6 +1586,7 @@ static void shb_CNG_encod_ivas_fx(
push_indice( hBstr, IND_SHB_CNG_GAIN, idx_ener, 4 );
push_indice( hBstr, IND_SID_BW, 1, 1 );
delete_indice( hBstr, IND_CNG_ENV1 );
+
IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) )
{
push_indice( st->hBstr, IND_BWIDTH, st->bwidth, 2 );
@@ -2909,6 +1595,7 @@ static void shb_CNG_encod_ivas_fx(
{
push_indice( hBstr, IND_UNUSED, 0, 2 );
}
+
st->hTdCngEnc->ho_sid_bw = L_shl( L_and( st->hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 );
st->hTdCngEnc->ho_sid_bw = L_or( st->hTdCngEnc->ho_sid_bw, 0x1L );
move32();
@@ -2924,21 +1611,21 @@ static void shb_CNG_encod_ivas_fx(
return;
}
+
/*---------------------------------------------------------------------*
* shb_DTX()
*
* Decide if encoding SHB SID or not
*---------------------------------------------------------------------*/
-static Word16 shb_DTX_ivas_fx(
+static Word16 shb_DTX_fx(
Encoder_State *st, /* i/o: State structure */
- const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */
- const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */
+ const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */
+ const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */
)
{
Word16 i;
Word16 update;
-
Word16 allow_cn_step = 0;
move16();
Word16 shb_old_speech_fx[( ACELP_LOOK_12k8 + L_SUBFR + L_FRAME ) * 5 / 4];
@@ -2987,7 +1674,6 @@ static Word16 shb_DTX_ivas_fx(
exp = sub( 30 - 1, exp );
shb_ener_fx = Mpy_32_16( exp, fra, LG10 );
-
test();
IF( EQ_16( st->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) )
{
@@ -3001,7 +1687,7 @@ static Word16 shb_DTX_ivas_fx(
}
ELSE
{
- att_fx = -1664; // Q8
+ att_fx = 1664; /*6.5 in Q8*/
move16();
}
@@ -3009,8 +1695,6 @@ static Word16 shb_DTX_ivas_fx(
IF( st->hDtxEnc->first_CNG == 0 )
{
-
-
hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; // Q8
hTdCngEnc->mov_shb_cng_ener_fx = log_shb_ener_fx; // Q8
hTdCngEnc->last_wb_cng_ener_fx = log_wb_ener_fx; // Q8
@@ -3020,6 +1704,7 @@ static Word16 shb_DTX_ivas_fx(
move16();
move16();
}
+
IF( GT_16( abs_s( sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ) ), 3072 /*12 in Q8*/ ) )
{
allow_cn_step = 1;
@@ -3057,7 +1742,6 @@ static Word16 shb_DTX_ivas_fx(
hTdCngEnc->shb_NO_DATA_cnt = add( hTdCngEnc->shb_NO_DATA_cnt, 1 );
update = 0;
-
move16();
move16();
@@ -3071,7 +1755,7 @@ static Word16 shb_DTX_ivas_fx(
update = 1;
move16();
}
- ELSE IF( hTdCngEnc->shb_cng_ini_cnt > 0 )
+ ELSE IF( st->element_mode != EVS_MONO && hTdCngEnc->shb_cng_ini_cnt > 0 )
{
hTdCngEnc->shb_cng_ini_cnt = sub( hTdCngEnc->shb_cng_ini_cnt, 1 );
update = 1;
@@ -3088,6 +1772,13 @@ static Word16 shb_DTX_ivas_fx(
update = 1;
move16();
}
+ ELSE IF( st->element_mode == EVS_MONO && hTdCngEnc->shb_cng_ini_cnt > 0 )
+ {
+ hTdCngEnc->shb_cng_ini_cnt = sub( hTdCngEnc->shb_cng_ini_cnt, 1 );
+ update = 1;
+ move16();
+ move16();
+ }
ELSE IF( GT_16( abs_s( sub( sub( hTdCngEnc->mov_wb_cng_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx ), sub( hTdCngEnc->last_wb_cng_ener_fx, hTdCngEnc->last_shb_cng_ener_fx ) ) ), 768 ) )
{
update = 1;
diff --git a/lib_enc/cod4t64_fast_fx.c b/lib_enc/cod4t64_fast_fx.c
index 0cf8074f652cc9d121a751a311d8a7233df3b83f..4bba582550f9f62581730bb163b60a4e43de336b 100644
--- a/lib_enc/cod4t64_fast_fx.c
+++ b/lib_enc/cod4t64_fast_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c
index 66819c4acfaff9185d2be31f54171452a3ba7286..f4b74b351d9928d059ea9a61eb36108a7fe691fc 100644
--- a/lib_enc/cod_ace_fx.c
+++ b/lib_enc/cod_ace_fx.c
@@ -262,7 +262,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
IF( st->igf != 0 )
{
- tbe_celp_exc( L_frame, i_subfr, T0, T0_frac, &error, bwe_exc );
+ tbe_celp_exc_fx( EVS_MONO, 0, L_frame, L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, 0 );
}
pitch_buf[i_subfr / L_SUBFR] = shl( add( shl( T0, 2 ), T0_frac ), 4 );
diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c
index 5d54b97292ae93d182c6d07be21bd4293ecc0772..922ae177a6f313b5f11331b8dbf9e42be1537856 100644
--- a/lib_enc/cod_tcx_fx.c
+++ b/lib_enc/cod_tcx_fx.c
@@ -621,7 +621,13 @@ void ShapeSpectrum_ivas_fx(
}
test();
+ test();
+ test();
+#ifndef FIX_1283_STEREO_DFT_COLLAPSE
IF( LE_32( total_brate, ACELP_13k20 ) && EQ_16( st->bwidth, SWB ) )
+#else
+ IF( ( LE_32( total_brate, ACELP_13k20 ) || ( LE_32( st->element_brate, IVAS_16k4 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( st->bwidth, SWB ) )
+#endif
{
max_low_pre = 0;
move32();
@@ -697,7 +703,13 @@ void ShapeSpectrum_ivas_fx(
/* reduce the peaks in the IGF region, to make life of the core-coder easier... */
test();
+ test();
+ test();
+#ifndef FIX_1283_STEREO_DFT_COLLAPSE
IF( LE_32( total_brate, ACELP_13k20 ) && EQ_16( st->bwidth, SWB ) )
+#else
+ IF( ( LE_32( total_brate, ACELP_13k20 ) || ( LE_32( st->element_brate, IVAS_16k4 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( st->bwidth, SWB ) )
+#endif
{
Word16 sf_width;
Word16 dist_low, dist_high;
@@ -3617,7 +3629,7 @@ void QuantizeTCXSpectrum_fx(
test();
IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) )
{
- calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag );
+ calculate_hangover_attenuation_gain_fx( st, &att_fx, vad_hover_flag );
*gain_tcx_fx = mult( *gain_tcx_fx, att_fx );
move16();
}
@@ -3908,8 +3920,8 @@ void coder_tcx_post_fx(
const Word16 *A,
const Word16 *Ai,
Word16 *wsig,
- Word16 Q_new,
- Word16 shift )
+ const Word16 Q_new,
+ const Word16 shift )
{
Word16 xn_buf[L_FRAME_MAX];
diff --git a/lib_enc/core_enc_ol_fx.c b/lib_enc/core_enc_ol_fx.c
index cdecaf3d6f34caa5d7f2bce86f20c85b8bc0ace5..2cbbd5c9aa8454dd7513aeb90790cb99d7241afd 100644
--- a/lib_enc/core_enc_ol_fx.c
+++ b/lib_enc/core_enc_ol_fx.c
@@ -460,18 +460,14 @@ void core_encode_openloop_fx(
E_LPC_lev_dur( r_h, r_l, A, NULL, M, NULL );
E_LPC_a_lsp_conversion( A, lsptmp, lsp_new, M );
Residu3_fx( A, buf + L_LP - L_FRAME, res, L_FRAME, 1 );
- cng_params_upd_fx( lsptmp, res, st->L_frame, &hTdCngEnc->ho_circ_ptr,
- hTdCngEnc->ho_ener_circ_fx, &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx,
- Q_new, ENC, NULL, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf,
- hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hDtxEnc->last_active_brate );
+
+ cng_params_upd_fx( lsptmp, res, st->L_frame, &hTdCngEnc->ho_circ_ptr, hTdCngEnc->ho_ener_circ_fx, &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx,
+ Q_new, ENC, NULL, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hDtxEnc->last_active_brate, EVS_MONO, -1 );
}
ELSE
{
- cng_params_upd_fx( lsp_new, hLPDmem->old_exc + L_EXC_MEM - st->L_frame,
- st->L_frame, &hTdCngEnc->ho_circ_ptr, hTdCngEnc->ho_ener_circ_fx,
- &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx, Q_new, ENC, NULL,
- &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf,
- hDtxEnc->last_active_brate );
+ cng_params_upd_fx( lsp_new, hLPDmem->old_exc + L_EXC_MEM - st->L_frame, st->L_frame, &hTdCngEnc->ho_circ_ptr, hTdCngEnc->ho_ener_circ_fx, &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx,
+ Q_new, ENC, NULL, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hDtxEnc->last_active_brate, EVS_MONO, -1 );
}
IF( EQ_16( st->L_frame, L_FRAME ) )
diff --git a/lib_enc/core_enc_updt_fx.c b/lib_enc/core_enc_updt_fx.c
index 94a2ef74651e237f5f7d2930b346d7cd00143bf1..f6aba6f612395a6ef00d9b002f6376151556a4af 100644
--- a/lib_enc/core_enc_updt_fx.c
+++ b/lib_enc/core_enc_updt_fx.c
@@ -3,7 +3,6 @@
====================================================================================*/
#include
-//#include "prot_fx.h"
#include "options.h"
#include "cnst.h" /* Common constants */
#include "basop_util.h"
@@ -12,60 +11,13 @@
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
-void core_encode_update_fx( Encoder_State *st )
-{
- Word16 n;
- TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;
-
- /*--------------------------------------------------------------*
- * Update Buffers
- *---------------------------------------------------------------*/
-
- /* Update Input Signal Buffers */
-
- n = add( st->encoderPastSamples_enc, st->encoderLookahead_enc );
-
- Copy( st->buf_speech_enc + st->L_frame, st->buf_speech_enc, n );
- Copy( st->buf_speech_enc_pe + st->L_frame, st->buf_speech_enc_pe, n );
-
-
- IF( !st->tcxonly )
- {
- n = add( st->L_frame, shr( st->L_frame, 2 ) );
- Copy( st->buf_wspeech_enc + st->L_frame, st->buf_wspeech_enc, n );
- }
-
-
- IF( hTcxEnc != NULL )
- {
- IF( ( st->core == ACELP_CORE ) || EQ_32( st->core_brate, SID_2k40 ) || ( st->core_brate == FRAME_NO_DATA ) || EQ_32( st->core, AMR_WB_CORE ) )
- {
- Copy( st->buf_speech_enc + st->L_frame, hTcxEnc->buf_speech_ltp + st->L_frame, st->L_frame );
- }
- }
- n = add( st->encoderPastSamples_enc, st->encoderLookahead_enc );
- Copy( st->buf_synth + st->L_frame, st->buf_synth, add( st->L_frame, L_SUBFR ) );
- if ( hTcxEnc != NULL )
- {
- Copy( hTcxEnc->buf_speech_ltp + st->L_frame, hTcxEnc->buf_speech_ltp, n );
- }
- /* Update previous mode */
- test();
- test();
- test();
- IF( ( st->Opt_DTX_ON && LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) || ( st->tcxonly && EQ_16( st->codec_mode, MODE2 ) ) )
- {
- /* reset LP memories */
- set16_fx( st->mem_MA_fx, 0, M );
- Copy( GEWB_Ave_fx, st->mem_AR_fx, M );
- }
-}
/*-------------------------------------------------------------------*
* core_encode_update_cng_fx()
*
* Common updates in case of CNG
*-------------------------------------------------------------------*/
+
void core_encode_update_cng_fx(
Encoder_State *st,
Word16 *timeDomainBuffer,
@@ -150,7 +102,6 @@ void core_encode_update_cng_fx(
p_A += ( M + 1 );
}
-
tmp = sub( st->wspeech_enc[-1], shl( hLPDmem->mem_w0, shift ) );
E_UTIL_deemph2( negate( shift ), wsyn, st->preemph_fac, st->L_frame, &tmp );
hLPDmem->mem_w0 = sub_sat( st->wspeech_enc[st->L_frame - 1], tmp );
@@ -200,7 +151,7 @@ void core_encode_update_cng_fx(
* Common updates of buffers
*-------------------------------------------------------------------*/
-void core_encode_update_ivas_fx(
+void core_encode_update_fx(
Encoder_State *st /* i/o: Encoder state structure */
)
{
@@ -226,11 +177,18 @@ void core_encode_update_ivas_fx(
test();
IF( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) || EQ_32( st->core_brate, SID_2k40 ) || ( st->core_brate == FRAME_NO_DATA ) )
{
- Word16 max_e = s_max( st->hTcxEnc->exp_buf_speech_ltp, st->exp_buf_speech_enc );
- Scale_sig( hTcxEnc->buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, negate( sub( max_e, st->hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(31-max_e)
- Copy_Scale_sig( st->buf_speech_enc + st->L_frame, hTcxEnc->buf_speech_ltp + st->L_frame, st->L_frame, negate( sub( max_e, st->exp_buf_speech_enc ) ) ); // Q(31-max_e)
- st->hTcxEnc->exp_buf_speech_ltp = max_e;
- move16();
+ IF( st->element_mode == EVS_MONO )
+ {
+ Copy( st->buf_speech_enc + st->L_frame, hTcxEnc->buf_speech_ltp + st->L_frame, st->L_frame );
+ }
+ ELSE
+ {
+ Word16 max_e = s_max( st->hTcxEnc->exp_buf_speech_ltp, st->exp_buf_speech_enc );
+ Scale_sig( hTcxEnc->buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, negate( sub( max_e, st->hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(31-max_e)
+ Copy_Scale_sig( st->buf_speech_enc + st->L_frame, hTcxEnc->buf_speech_ltp + st->L_frame, st->L_frame, negate( sub( max_e, st->exp_buf_speech_enc ) ) ); // Q(31-max_e)
+ st->hTcxEnc->exp_buf_speech_ltp = max_e;
+ move16();
+ }
}
}
@@ -265,5 +223,6 @@ void core_encode_update_ivas_fx(
set16_fx( st->mem_MA_fx, 0, M );
Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); // 2.56 scaling
}
+
return;
}
diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c
index aa06b12d20d5eeff4b7469045355661ab18be1d9..497f4ad9e4410f381ca3d485ceaff6042686a7c1 100644
--- a/lib_enc/core_switching_enc_fx.c
+++ b/lib_enc/core_switching_enc_fx.c
@@ -19,9 +19,11 @@
*---------------------------------------------------------------------*/
void core_switching_pre_enc_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
+ Encoder_State *st_fx, /* i/o: encoder state structure */
const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz Qx*/
+ const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */
const Word16 *old_inp_16k, /* i : old input signal @16kHz Qx*/
+ const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */
const Word16 active_cnt, /* i : active frame counter Q0*/
const Word16 last_element_mode /* i : last_element_mode Q0*/
)
@@ -64,6 +66,7 @@ void core_switching_pre_enc_fx(
set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
}
+
test();
IF( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) )
{
@@ -112,7 +115,7 @@ void core_switching_pre_enc_fx(
test();
test();
test();
- IF( EQ_16( st_fx->last_core, -1 ) && ( EQ_16( st_fx->core, HQ_CORE ) || EQ_16( st_fx->core, TCX_20_CORE ) || EQ_16( st_fx->core, TCX_10_CORE ) ) )
+ if ( EQ_16( st_fx->last_core, -1 ) && ( EQ_16( st_fx->core, HQ_CORE ) || EQ_16( st_fx->core, TCX_20_CORE ) || EQ_16( st_fx->core, TCX_10_CORE ) ) )
{
/* very first frame is HQ_CORE */
st_fx->last_core = HQ_CORE;
@@ -200,12 +203,15 @@ void core_switching_pre_enc_fx(
/* Reset ACELP parameters */
IF( hLPDmem != NULL )
{
- move16();
hLPDmem->syn[M] = 0;
move16();
set16_fx( hLPDmem->mem_syn2, 0, M );
set16_fx( hLPDmem->mem_syn, 0, M );
set16_fx( hLPDmem->mem_syn1_fx, 0, M );
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ hLPDmem->q_mem_syn = Q15;
+ }
hLPDmem->mem_w0 = 0;
move16();
hLPDmem->tilt_code = 0;
@@ -237,7 +243,14 @@ void core_switching_pre_enc_fx(
}
Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); /*Q6*/
- set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 );
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR << 6, tmp16 );
+ }
+ ELSE
+ {
+ set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 );
+ }
/* Reset old ACELP buffers */
test();
@@ -251,12 +264,14 @@ void core_switching_pre_enc_fx(
/* reset BWE memories */
hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
+ move32();
}
IF( hBWE_FD != NULL )
{
set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
}
}
+
test();
test();
test();
@@ -292,7 +307,7 @@ void core_switching_pre_enc_fx(
{
set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
- move16();
+ move32();
}
/* reset BWE memories */
@@ -301,6 +316,7 @@ void core_switching_pre_enc_fx(
set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
}
}
+
test();
test();
test();
@@ -341,7 +357,25 @@ void core_switching_pre_enc_fx(
}
Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) );
}
- Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); /*Qx*/
+
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ IF( GT_16( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) )
+ {
+ Copy_Scale_sig( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_12k8 ) ); // prev_Q_input_lp
+ }
+ ELSE
+ {
+ Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) ); // q_old_inp_12k8
+ hBWE_FD->prev_Q_input_lp = q_old_inp_12k8;
+ move16();
+ Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP );
+ }
+ }
+ ELSE
+ {
+ Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); /*Qx*/
+ }
}
ELSE
{
@@ -356,12 +390,30 @@ void core_switching_pre_enc_fx(
Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) );
}
- Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); /*Qx*/
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ IF( GT_16( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) )
+ {
+ Copy_Scale_sig( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_16k ) ); // prev_Q_input_lp
+ }
+ ELSE
+ {
+ Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) ); // q_old_inp_16k
+ hBWE_FD->prev_Q_input_lp = q_old_inp_16k;
+ move16();
+ Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP );
+ }
+ }
+ ELSE
+ {
+ Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); /*Qx*/
+ }
}
tmp = sub( L_LOOK_16k + L_SUBFR16k, Sample_Delay_HP );
Copy( &hBWE_TD->old_speech_shb_fx[tmp], hBWE_FD->new_input_hp_fx, Sample_Delay_HP ); /*Q(Q_shb_spch)*/
- add( 0, 0 );
+ hBWE_FD->Q_new_input_hp = 0;
+ move16();
IF( NE_16( st_fx->last_extl, WB_BWE ) )
{
@@ -377,6 +429,33 @@ void core_switching_pre_enc_fx(
move16(); /* Set to a High Exponent so it is 1^-30 */
}
+ /*---------------------------------------------------------------------*
+ * band-width switching from WB -> SWB/FB
+ *---------------------------------------------------------------------*/
+
+ IF( st_fx->element_mode > EVS_MONO )
+ {
+ IF( st_fx->bwidth_sw_cnt == 0 )
+ {
+ test();
+ IF( GE_16( st_fx->bwidth, SWB ) && EQ_16( st_fx->last_bwidth, WB ) )
+ {
+ st_fx->bwidth_sw_cnt = add( st_fx->bwidth_sw_cnt, 1 );
+ move16();
+ }
+ }
+ ELSE
+ {
+ st_fx->bwidth_sw_cnt = add( st_fx->bwidth_sw_cnt, 1 );
+ move16();
+ IF( EQ_16( st_fx->bwidth_sw_cnt, BWS_TRAN_PERIOD ) )
+ {
+ st_fx->bwidth_sw_cnt = 0;
+ move16();
+ }
+ }
+ }
+
return;
}
@@ -386,13 +465,14 @@ void core_switching_pre_enc_fx(
*
* Postprocessing for ACELP/HQ core switching
*---------------------------------------------------------------------*/
+
void core_switching_post_enc_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
const Word16 old_inp_12k8[], /* i : input signal @12.8 kHz Qinp */
const Word16 old_inp_16k[], /* i : input signal @16 kHz Qinp */
const Word16 A[], /* i : unquant. LP filter coefs. (Q12) */
- Word16 Qshift,
- Word16 Q_new,
+ const Word16 Qshift,
+ const Word16 Q_new,
const Word16 Qsp, /* i/o : Q from acelp synthsis */
Word16 *Qmus /* i/o : Q from mdct synthsis / Q of output synthesis */
)
@@ -416,11 +496,20 @@ void core_switching_post_enc_fx(
hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 );
hBWE_FD->mem_deemph_old_syn_fx = 0;
move16();
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ hBWE_FD->q_mem_deemph_old_syn = 0;
+ move16();
+ }
}
ELSE
{
- *Qmus = Qsp; /* Write Qout */
- move16();
+ IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ *Qmus = Qsp; /* Write Qout */
+ move16();
+ }
+
IF( hBWE_TD == NULL )
{
return;
@@ -454,23 +543,44 @@ void core_switching_post_enc_fx(
test();
test();
test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
IF( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) ) &&
( EQ_16( st_fx->last_core, HQ_CORE ) || NE_16( st_fx->L_frame, st_fx->last_L_frame ) ||
( NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) && NE_16( st_fx->last_core, TCX_20_CORE ) && NE_16( st_fx->last_core, TCX_10_CORE ) ) ) )
{
set16_fx( hBWE_TD->state_ana_filt_shb_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) );
- set16_fx( hBWE_TD->old_speech_shb_fx, 0, L_LOOK_16k + L_SUBFR16k );
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ InitSWBencBufferStates_fx( st_fx->hBWE_TD, NULL );
+ }
+ ELSE
+ {
+ set16_fx( hBWE_TD->old_speech_shb_fx, 0, L_LOOK_16k + L_SUBFR16k );
+ }
swb_tbe_reset_fx( hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx,
hBWE_TD->syn_overlap_fx, hBWE_TD->state_syn_shbexc_fx, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ),
hBWE_TD->mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ) );
- set16_fx( hBWE_TD->dec_2_over_3_mem_fx, 0, 12 );
- set16_fx( hBWE_TD->dec_2_over_3_mem_lp_fx, 0, 6 );
+ set16_fx( hBWE_TD->dec_2_over_3_mem_fx, 0, L_FILT_2OVER3 );
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ set16_fx( st_fx->hBWE_TD->dec_2_over_3_mem_lp_fx, 0, L_FILT_2OVER3_LP );
+ }
+ ELSE
+ {
+ set16_fx( hBWE_TD->dec_2_over_3_mem_lp_fx, 0, 6 );
+ }
}
ELSE IF( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) ) &&
- ( NE_32( st_fx->last_total_brate, st_fx->total_brate ) || NE_16( st_fx->last_bwidth, st_fx->bwidth ) ||
- NE_16( st_fx->last_codec_mode, MODE1 ) || NE_16( st_fx->rf_mode, st_fx->rf_mode_last ) ) )
+ ( ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) ) || ( NE_16( st_fx->element_mode, IVAS_CPE_TD ) && NE_32( st_fx->last_total_brate, st_fx->total_brate ) ) ||
+ ( NE_16( st_fx->last_bwidth, st_fx->bwidth ) ) || ( NE_16( st_fx->last_codec_mode, MODE1 ) ) || ( NE_16( st_fx->rf_mode_last, st_fx->rf_mode ) ) ) )
{
set16_fx( hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER );
set16_fx( hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD );
@@ -483,6 +593,7 @@ void core_switching_post_enc_fx(
{
TBEreset_enc_fx( st_fx->hBWE_TD, st_fx->last_core, st_fx->bwidth );
}
+
test();
test();
test();
@@ -493,6 +604,16 @@ void core_switching_post_enc_fx(
hBWE_TD->fb_tbe_demph_fx = 0;
fb_tbe_reset_enc_fx( hBWE_TD->elliptic_bpf_2_48k_mem_fx, &hBWE_TD->prev_fb_energy_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, &hBWE_TD->prev_fb_energy_fx_Q );
}
+
+ /* Fade towards init value for non HQ_CORE */
+ test();
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) && st_fx->hHQ_core != NULL )
+ {
+ st_fx->hHQ_core->crest_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st_fx->hHQ_core->crest_lp_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), L_shr( HQ_CREST_THRESHOLD_FX, sub( Q28, st_fx->hHQ_core->crest_lp_q ) ) ) ); /*crest_lp_q*/
+ move32();
+ st_fx->hHQ_core->crest_mod_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st_fx->hHQ_core->crest_mod_lp_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), L_shr( HQ_CREST_MOD_THRESHOLD_FX, sub( Q29, st_fx->hHQ_core->crest_mod_lp_q ) ) ) ); /*crest_mod_lp_q*/
+ move32();
+ }
}
return;
@@ -627,554 +748,3 @@ void core_switching_hq_prepare_enc_fx(
}
return;
}
-
-void core_switching_pre_enc_ivas_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz q_old_inp_12k8 */
- const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */
- const Word16 *old_inp_16k, /* i : old input signal @16kHz q_old_inp_16k */
- const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */
- const Word16 active_cnt, /* i : active frame counter */
- const Word16 last_element_mode /* i : last_element_mode */
-)
-{
- Word16 Sample_Delay_HP, Sample_Delay_LP;
- Word16 tmp16;
- Word16 tmp;
- SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
- LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
- HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core;
- TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD;
- TCX_ENC_HANDLE hTcxEnc = st_fx->hTcxEnc;
- FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD;
-
- /* Mode switching */
- test();
- test();
- test();
- IF( EQ_16( st_fx->last_codec_mode, MODE2 ) || ( ( ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) && ( st_fx->element_mode > EVS_MONO ) ) ) )
- {
- IF( hLPDmem != NULL )
- {
- Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M );
- }
-
- if ( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
- {
- st_fx->igf = 0;
- move16();
- }
-
- IF( hBWE_TD != NULL )
- {
- IF( st_fx->last_core != ACELP_CORE )
- {
- /* reset BWE memories */
- set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
- hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 );
- move32();
- }
-
- set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
- }
- test();
- IF( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) )
- {
- if ( st_fx->element_mode == EVS_MONO )
- {
- st_fx->last_core = HQ_CORE;
- move16();
- }
- IF( hHQ_core != NULL )
- {
- set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX );
- set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX );
- hHQ_core->last_max_pos_pulse = 0;
- move16();
-
- hHQ_core->mode_count = 0;
- move16();
- hHQ_core->mode_count1 = 0;
- move16();
-
- set16_fx( hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM );
- hHQ_core->prev_frm_hfe2 = 0;
- move16();
- hHQ_core->prev_stab_hfe2 = 0;
- move16();
- }
- test();
- /*ALDO overlap windowed past: also used in MODE2 but for other MDCT-LB*/
- IF( ( st_fx->element_mode == EVS_MONO ) && hTcxEnc != NULL )
- {
- set16_fx( hTcxEnc->old_out_fx, 0, L_FRAME32k );
- }
- }
-
- test();
- IF( ( EQ_16( st_fx->L_frame, L_FRAME16k ) ) && ( EQ_16( st_fx->last_L_frame, L_FRAME ) ) )
- {
- Copy( st_fx->lsp_old_fx, st_fx->lsp_old16k_fx, M );
-
- st_fx->rate_switching_reset_16kHz = lsp_convert_poly_fx( st_fx->lsp_old16k_fx, st_fx->L_frame, 0 );
- move16();
- }
-
- st_fx->use_acelp_preq = 0;
- move16();
- }
-
- test();
- test();
- test();
- if ( EQ_16( st_fx->last_core, -1 ) && ( EQ_16( st_fx->core, HQ_CORE ) || EQ_16( st_fx->core, TCX_20_CORE ) || EQ_16( st_fx->core, TCX_10_CORE ) ) )
- {
- /* very first frame is HQ_CORE */
- st_fx->last_core = HQ_CORE;
- move16();
- }
-
- test();
- test();
- IF( EQ_16( st_fx->core, HQ_CORE ) && ( ( st_fx->last_core == ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) /* HQ init */
- {
- set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX );
- set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX );
- hHQ_core->last_max_pos_pulse = 0;
- move16();
-
- hHQ_core->mode_count = 0;
- move16();
- hHQ_core->mode_count1 = 0;
- move16();
-
- set16_fx( hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM );
- hHQ_core->prev_frm_hfe2 = 0;
- move16();
- hHQ_core->prev_stab_hfe2 = 0;
- move16();
-
- IF( hTcxEnc != NULL )
- {
- set16_fx( hTcxEnc->old_out_fx, 0, L_FRAME32k );
- }
- }
-
- /* Here we only handle cases where last_ppp and last_nelp not updated when coming from CodecB or other cores
- within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */
- test();
- test();
- IF( ( st_fx->core == ACELP_CORE ) && ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) ) )
- {
- IF( hSC_VBR != NULL )
- {
- hSC_VBR->last_last_ppp_mode = 0;
- move16();
- hSC_VBR->last_ppp_mode = 0;
- move16();
- hSC_VBR->last_nelp_mode = 0;
- move16();
- }
- }
-
- test();
- test();
- test();
- IF( ( st_fx->core == ACELP_CORE ) && ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) || LE_32( st_fx->last_total_brate, PPP_NELP_2k80 ) ) )
- {
- st_fx->act_count = 3;
- move16();
- st_fx->uv_count = 0;
- move16();
- }
-
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( ( ( st_fx->core == ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) /* EVS and HQ -> ACELP */ ||
- ( ( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( active_cnt, 1 ) ) ||
- ( st_fx->core == ACELP_CORE && GT_16( st_fx->last_L_frame, L_FRAME16k ) ) /* TCX @ 25.6/32 kHz -> ACELP */ )
- {
- IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
- {
- Copy( TRWB2_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */
- lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_16k );
- }
- ELSE
- {
- Copy( TRWB_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */
- lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX );
- }
-
- /* Reset ACELP parameters */
- IF( hLPDmem != NULL )
- {
- move16();
- hLPDmem->syn[M] = 0;
- move16();
- set16_fx( hLPDmem->mem_syn2, 0, M );
- set16_fx( hLPDmem->mem_syn, 0, M );
- set16_fx( hLPDmem->mem_syn1_fx, 0, M );
- hLPDmem->q_mem_syn = Q15;
- move16();
- hLPDmem->mem_w0 = 0;
- move16();
- hLPDmem->tilt_code = 0;
- move16();
- hLPDmem->gc_threshold = 0;
- move32();
- /* set16_fx( st_fx->dispMem, 0, 8 ); */
- set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 );
- hLPDmem->dm_fx.prev_state = 0;
- move16();
- hLPDmem->dm_fx.prev_gain_code = L_deposit_l( 0 );
- }
- st_fx->Nb_ACELP_frames = 0;
- move16();
-
- set16_fx( st_fx->mem_MA_fx, 0, M );
- Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M );
- init_gp_clip_fx( st_fx->clip_var_fx );
- st_fx->last_coder_type = GENERIC;
- move16();
-
- tmp16 = add( NB_SUBFR, 1 );
-
- if ( EQ_16( st_fx->L_frame, L_FRAME ) )
- {
- tmp16 = NB_SUBFR;
- move16();
- }
-
- Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 );
- set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR << 6, tmp16 );
- /* Reset old ACELP buffers */
- test();
- IF( ( st_fx->element_mode == EVS_MONO ) && hLPDmem != NULL )
- {
- set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM );
- }
- IF( hBWE_TD != NULL )
- {
- set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
-
- /* reset BWE memories */
- hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
- move32();
- }
- IF( hBWE_FD != NULL )
- {
- set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
- }
- }
- test();
- test();
- test();
- IF( ( ( st_fx->core == ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) )
- {
- /* Reset the ACELP core in case of TCX->ACELP core switching */
- st_fx->Nb_ACELP_frames = 0;
- move16();
-
- IF( hLPDmem != NULL )
- {
- hLPDmem->mem_w0 = 0;
- move16();
- hLPDmem->tilt_code = 0;
- move16();
- hLPDmem->gc_threshold = 0;
- move32();
- init_gp_clip_fx( st_fx->clip_var_fx );
- set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 );
- hLPDmem->dm_fx.prev_state = 0;
- move16();
- hLPDmem->dm_fx.prev_gain_code = 0;
- move32();
- }
-
- st_fx->last_coder_type = GENERIC;
- move16();
-
- tmp16 = shr( st_fx->L_frame, 6 );
- Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 );
- set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR << 6, tmp16 );
- /* Reset old TD BWE buffers */
- IF( hBWE_TD != NULL )
- {
- set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
- hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
- move32();
- }
-
- /* reset BWE memories */
- IF( hBWE_FD != NULL )
- {
- set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
- }
- }
- test();
- test();
- test();
- IF( GE_32( st_fx->input_Fs, 16000 ) && NE_16( st_fx->last_extl, WB_BWE ) && EQ_16( st_fx->extl, WB_BWE ) && hBWE_FD != NULL )
- {
- test();
- IF( NE_16( st_fx->last_extl, SWB_BWE ) && NE_16( st_fx->last_extl, FB_BWE ) )
- {
- hBWE_FD->prev_mode = NORMAL;
- move16();
- hBWE_FD->modeCount = 0;
- move16();
- }
-
- hBWE_FD->prev_L_swb_norm1 = 8;
- move16();
- }
-
- test();
- test();
- test();
- test();
- test();
- IF( ( GE_32( st_fx->input_Fs, 32000 ) && NE_16( st_fx->last_extl, SWB_BWE ) && EQ_16( st_fx->extl, SWB_BWE ) ) ||
- ( GE_32( st_fx->input_Fs, 48000 ) && NE_16( st_fx->last_extl, FB_BWE ) && EQ_16( st_fx->extl, FB_BWE ) ) )
- {
- /* we are switching to SWB BWE - reset SWB BWE buffers */
-
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
- {
- Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS );
- Sample_Delay_LP = NS2SA( 12800, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS );
- IF( ( st_fx->element_mode > EVS_MONO ) )
- {
- IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
- {
- Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS );
- }
- Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) );
- }
- IF( GT_16( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) )
- {
- Copy_Scale_sig( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_12k8 ) ); // prev_Q_input_lp
- }
- ELSE
- {
- Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) ); // q_old_inp_12k8
- hBWE_FD->prev_Q_input_lp = q_old_inp_12k8;
- move16();
- Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP );
- }
- }
- ELSE
- {
- Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS );
- Sample_Delay_LP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS );
- IF( GT_16( st_fx->element_mode, EVS_MONO ) )
- {
- IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
- {
- Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS );
- }
- Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) );
- }
- IF( GT_16( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) )
- {
- Copy_Scale_sig( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_16k ) ); // prev_Q_input_lp
- }
- ELSE
- {
- Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) ); // q_old_inp_16k
- hBWE_FD->prev_Q_input_lp = q_old_inp_16k;
- move16();
- Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP );
- }
- }
-
- tmp = sub( L_LOOK_16k + L_SUBFR16k, Sample_Delay_HP );
- Copy( &hBWE_TD->old_speech_shb_fx[tmp], hBWE_FD->new_input_hp_fx, Sample_Delay_HP );
- hBWE_FD->Q_new_input_hp = 0;
- move16();
-
- IF( NE_16( st_fx->last_extl, WB_BWE ) )
- {
- hBWE_FD->prev_mode = NORMAL;
- move16();
- hBWE_FD->modeCount = 0;
- move16();
- }
- hBWE_FD->EnergyLF_fx = 0;
- hBWE_FD->EnergyLF_exp = 0;
- move32();
- move16();
- hBWE_FD->prev_L_swb_norm1 = 8;
- move16(); /*8.0 in Q0 */
- st_fx->EnergyLT_fx_exp = 30;
- move16(); /* Set to a High Exponent so it is 1^-30 */
- }
- /*---------------------------------------------------------------------*
- * band-width switching from WB -> SWB/FB
- *---------------------------------------------------------------------*/
- IF( st_fx->element_mode > EVS_MONO )
- {
- IF( st_fx->bwidth_sw_cnt == 0 )
- {
- test();
- IF( GE_16( st_fx->bwidth, SWB ) && EQ_16( st_fx->last_bwidth, WB ) )
- {
- st_fx->bwidth_sw_cnt = add( st_fx->bwidth_sw_cnt, 1 );
- move16();
- }
- }
- ELSE
- {
- st_fx->bwidth_sw_cnt = add( st_fx->bwidth_sw_cnt, 1 );
- move16();
- IF( EQ_16( st_fx->bwidth_sw_cnt, BWS_TRAN_PERIOD ) )
- {
- st_fx->bwidth_sw_cnt = 0;
- move16();
- }
- }
- }
-
- return;
-}
-
-/*---------------------------------------------------------------------*
- * core_switching_post_enc()
- *
- * Postprocessing for ACELP/HQ core switching
- *---------------------------------------------------------------------*/
-
-void core_switching_post_enc_ivas_fx(
- Encoder_State *st, /* i/o: encoder state structure */
- Word16 *old_inp_12k8_fx, /* i : old input signal @12.8kHz Q_new-1 */
- Word16 *old_inp_16k_fx, /* i : old input signal @16kHz Q_new-1 */
- Word16 A_fx[], /* i : unquant. LP filter coefs. Q12 */
- Word16 Q_new )
-{
- IF( EQ_16( st->core, HQ_CORE ) )
- {
- st->use_acelp_preq = 0;
- move16();
- test();
- test();
- IF( ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) && st->element_mode == EVS_MONO ) /* core switching ==> ACELP subframe encoding */
- {
- /* Memory scaling to keep everything in common q */
- Scale_sig( st->hLPDmem->mem_syn, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */
- Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */
- Scale_sig( st->hLPDmem->mem_syn2, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */
- Scale_sig( st->hLPDmem->mem_syn3, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */
- Scale_sig( st->hLPDmem->mem_syn_r, L_SYN_MEM, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */
- st->hLPDmem->mem_w0 = shl( st->hLPDmem->mem_w0, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */
- move16();
- st->hLPDmem->q_mem_syn = sub( Q_new, 1 );
- move16();
-
- acelp_core_switch_enc_ivas_fx( st, old_inp_12k8_fx + L_INP_MEM - NS2SA( INT_FS_12k8, ACELP_LOOK_NS ), old_inp_16k_fx + L_INP_MEM - NS2SA( INT_FS_16k, ACELP_LOOK_NS ), A_fx, 0, sub( Q_new, 1 ) );
- }
-
- st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
- move32();
- st->hBWE_FD->mem_deemph_old_syn_fx = 0;
- move16();
- st->hBWE_FD->q_mem_deemph_old_syn = 0;
- move16();
- }
- ELSE
- {
- IF( st->hBWE_TD == NULL )
- {
- return;
- }
-
- test();
- /* reset SWB TBE buffers */
- IF( EQ_16( st->extl, WB_TBE ) && NE_16( st->last_extl, WB_TBE ) )
- {
- wb_tbe_extras_reset_fx( st->hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, st->hBWE_TD->mem_genSHBexc_filt_down_wb3_fx );
-
- IF( NE_16( st->last_extl, WB_BWE ) )
- {
- set16_fx( st->hBWE_TD->decim_state1_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) );
- set16_fx( st->hBWE_TD->decim_state2_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) );
- }
-
- set16_fx( st->hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD / 4 );
- set16_fx( st->hBWE_TD->syn_overlap_fx, 0, L_SHB_LAHEAD );
- set32_fx( st->hBWE_TD->mem_csfilt_fx, 0, 2 );
- }
-
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
-
- IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) &&
- ( EQ_16( st->last_core, HQ_CORE ) || NE_16( st->L_frame, st->last_L_frame ) || ( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) && NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) ) )
- {
- set16_fx( st->hBWE_TD->state_ana_filt_shb_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) );
-
- InitSWBencBufferStates_fx( st->hBWE_TD, NULL );
- swb_tbe_reset_fx( st->hBWE_TD->mem_csfilt_fx, st->hBWE_TD->mem_genSHBexc_filt_down_shb_fx, st->hBWE_TD->state_lpc_syn_fx, st->hBWE_TD->syn_overlap_fx, st->hBWE_TD->state_syn_shbexc_fx, &( st->hBWE_TD->tbe_demph_fx ), &( st->hBWE_TD->tbe_premph_fx ), st->hBWE_TD->mem_stp_swb_fx, &( st->hBWE_TD->gain_prec_swb_fx ) );
-
- set16_fx( st->hBWE_TD->dec_2_over_3_mem_fx, 0, L_FILT_2OVER3 );
- set16_fx( st->hBWE_TD->dec_2_over_3_mem_lp_fx, 0, L_FILT_2OVER3_LP );
- }
- ELSE IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && ( ( EQ_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_32( st->last_total_brate, st->total_brate ) ) || ( NE_16( st->last_bwidth, st->bwidth ) ) || ( NE_16( st->last_codec_mode, MODE1 ) ) || ( NE_16( st->rf_mode_last, st->rf_mode ) ) ) )
- {
- set16_fx( st->hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER );
- set16_fx( st->hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD );
- set16_fx( st->hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER );
- set16_fx( st->hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER );
- st->hBWE_TD->gain_prec_swb_fx = ONE_IN_Q14;
- move16();
- }
- ELSE IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) )
- {
- TBEreset_enc_fx( st->hBWE_TD, st->last_core, st->bwidth );
- }
-
- test();
- test();
- test();
- test();
- /* Interp_3_2 CNG buffers reset */
- IF( EQ_16( st->extl, FB_TBE ) && ( ( NE_16( st->last_extl, FB_TBE ) && NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) || NE_16( st->L_frame, st->last_L_frame ) ) )
- {
- set16_fx( st->hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER );
- st->hBWE_TD->fb_tbe_demph_fx = 0;
- move16();
- fb_tbe_reset_enc_fx( st->hBWE_TD->elliptic_bpf_2_48k_mem_fx, &st->hBWE_TD->prev_fb_energy_fx, st->hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, &st->hBWE_TD->prev_fb_energy_fx_Q );
- }
- /* Fade towards init value for non HQ_CORE */
- IF( st->hHQ_core != NULL )
- {
- st->hHQ_core->crest_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st->hHQ_core->crest_lp_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), L_shr( HQ_CREST_THRESHOLD_FX, sub( Q28, st->hHQ_core->crest_lp_q ) ) ) ); /*crest_lp_q*/
- move32();
- st->hHQ_core->crest_mod_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st->hHQ_core->crest_mod_lp_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), L_shr( HQ_CREST_MOD_THRESHOLD_FX, sub( Q29, st->hHQ_core->crest_mod_lp_q ) ) ) ); /*crest_mod_lp_q*/
- move32();
- }
- }
-
- return;
-}
diff --git a/lib_enc/decision_matrix_enc_fx.c b/lib_enc/decision_matrix_enc_fx.c
index 086b6e86aedcdb5772da37fd780e00be60f03e7a..0b51816dc9cc657f532c97b240b782abbb0ba1a4 100644
--- a/lib_enc/decision_matrix_enc_fx.c
+++ b/lib_enc/decision_matrix_enc_fx.c
@@ -752,85 +752,12 @@ void signalling_enc_fx(
}
/*---------------------------------------------------------------------*
- * signalling_enc_rf()
+ * signaling_enc_rf()
*
* write channel-aware signalling information into the bitstream
*---------------------------------------------------------------------*/
-void signaling_enc_rf_fx(
- Encoder_State *st /* i : encoder state structure */
-)
-{
- Word16 i;
- Word16 sfr;
- RF_ENC_HANDLE hRF = st->hRF;
- /* write partial copy into bitstream */
- IF( EQ_16( st->rf_mode, 1 ) )
- {
- enc_prm_rf_ivas_fx( st, hRF->rf_indx_frametype[st->rf_fec_offset], st->rf_fec_offset );
- hRF->rf_indx_tbeGainFr[0] = hRF->RF_bwe_gainFr_ind; /*Q0*/
- move16();
- }
-
- /* Shift the RF indices such that the partial copy associated with
- (n-fec_offset)th frame is included in the bitstream in nth frame. */
- IF( hRF != NULL )
- {
- FOR( i = st->rf_fec_offset; i >= 0; i-- )
- {
- /* rf frame type */
- hRF->rf_indx_frametype[i + 1] = hRF->rf_indx_frametype[i];
- move16();
- /* rf target bits buffer */
- hRF->rf_targetbits_buff[i + 1] = hRF->rf_targetbits_buff[i];
- move16();
- /* lsf indx */
- hRF->rf_indx_lsf[i + 1][0] = hRF->rf_indx_lsf[i][0];
- hRF->rf_indx_lsf[i + 1][1] = hRF->rf_indx_lsf[i][1];
- hRF->rf_indx_lsf[i + 1][2] = hRF->rf_indx_lsf[i][2];
- move16();
- move16();
- move16();
- /* ES pred energy */
- hRF->rf_indx_EsPred[i + 1] = hRF->rf_indx_EsPred[i];
- move16();
- /* LTF mode, sfr params: pitch, fcb and gain */
- FOR( sfr = 0; sfr < st->nb_subfr; sfr++ )
- {
- hRF->rf_indx_ltfMode[i + 1][sfr] = hRF->rf_indx_ltfMode[i][sfr];
- hRF->rf_indx_pitch[i + 1][sfr] = hRF->rf_indx_pitch[i][sfr];
- hRF->rf_indx_fcb[i + 1][sfr] = hRF->rf_indx_fcb[i][sfr];
- hRF->rf_indx_gain[i + 1][sfr] = hRF->rf_indx_gain[i][sfr];
- move16();
- move16();
- move16();
- move16();
- }
-
- /* shift the nelp indices */
- hRF->rf_indx_nelp_iG1[i + 1] = hRF->rf_indx_nelp_iG1[i];
- hRF->rf_indx_nelp_iG2[i + 1][0] = hRF->rf_indx_nelp_iG2[i][0];
- hRF->rf_indx_nelp_iG2[i + 1][1] = hRF->rf_indx_nelp_iG2[i][1];
- hRF->rf_indx_nelp_fid[i + 1] = hRF->rf_indx_nelp_fid[i];
- move16();
- move16();
- move16();
- move16();
- /* tbe gain Fr shift */
- hRF->rf_indx_tbeGainFr[i + 1] = hRF->rf_indx_tbeGainFr[i];
- hRF->rf_clas[i + 1] = hRF->rf_clas[i];
- hRF->rf_gain_tcx[i + 1] = hRF->rf_gain_tcx[i];
- hRF->rf_tcxltp_param[i + 1] = hRF->rf_tcxltp_param[i];
- move16();
- move16();
- move16();
- move16();
- }
- }
- return;
-}
-
-void signalling_enc_rf_fx(
+void signaling_enc_rf_fx(
Encoder_State *st /* i : encoder state structure */
)
{
diff --git a/lib_enc/detect_transient_fx.c b/lib_enc/detect_transient_fx.c
index 71c56cecf76462223fb91a1f104a79b2dd5b9b5a..173092cdf8562ab854f5c880534346183d0c701f 100644
--- a/lib_enc/detect_transient_fx.c
+++ b/lib_enc/detect_transient_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c
index 483304cdedf36ced3b85cb458bcec935acadf4fd..b6b4e5a3414aca3d9d28c4a8bb1c4edd63c9f3f7 100644
--- a/lib_enc/dtx_fx.c
+++ b/lib_enc/dtx_fx.c
@@ -43,7 +43,7 @@ static void update_SID_cnt_fx( DTX_ENC_HANDLE hDtxEnc, const Word32 core_brate,
/*==================================================================================*/
-/* FUNCTION : dtx_ivas_fx() */
+/* FUNCTION : dtx_fx() */
/*----------------------------------------------------------------------------------*/
/* PURPOSE : Discontinuous transmission operation */
/*----------------------------------------------------------------------------------*/
@@ -58,595 +58,66 @@ static void update_SID_cnt_fx( DTX_ENC_HANDLE hDtxEnc, const Word32 core_brate,
/* _ (Word16*) qener : frame_ener/lt_ener_voiced/lt_ener_noise buf qformat */
/* _ (Encoder_State_Fx) st_fx : encoder state structure */
/*----------------------------------------------------------------------------------*/
-
/*----------------------------------------------------------------------------------*/
/* RETURN ARGUMENTS : */
/* _ None */
/*==================================================================================*/
-void dtx_ivas_fx(
+
+void dtx_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/
const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/
const Word16 vad, /* i : vad flag for DTX Q0*/
const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/
- Word16 Q_speech /* i : Q factor for speech */
+ const Word16 Q_speech /* i : Q factor for speech */
)
{
Word16 alpha, i, j, Q_speech2;
Word32 L_tmp;
DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc;
TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc;
-
Word16 last_br_cng_flag, last_br_flag, br_dtx_flag;
Word32 total_brate_ref;
+ Word16 flag_lp_noise;
- total_brate_ref = st_fx->total_brate;
- move32();
-
- IF( st_fx->dtx_sce_sba != 0 )
- {
- last_br_cng_flag = 1;
- last_br_flag = 1;
- move16();
- move16();
- }
- ELSE
- {
- test();
- test();
- test();
- last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_EVS ) || LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_IVAS ) );
-
- test();
- test();
- test();
-
- last_br_flag = ( st_fx->element_mode == EVS_MONO && LE_32( st_fx->last_total_brate, MAX_BRATE_DTX_EVS ) ) ||
- ( st_fx->element_mode != EVS_MONO && LE_32( last_ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) ||
- LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 );
- }
-
- /* Initialization */
- IF( st_fx->ini_frame == 0 )
- {
- st_fx->active_cnt = CNG_TYPE_HO;
- move16();
-
- st_fx->cng_type = FD_CNG;
- move16();
- test();
- test();
- test();
- if ( ( EQ_16( st_fx->codec_mode, MODE1 ) || st_fx->Opt_AMR_WB ) && NE_16( st_fx->element_mode, IVAS_SCE ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
- {
- st_fx->cng_type = LP_CNG;
- move16();
- }
- }
- test();
- test();
- test();
- test();
- test();
- IF( st_fx->Opt_DTX_ON && vad == 0 &&
- GT_16( st_fx->ini_frame, 2 ) && /* CNG coding starts after 2 frames */
- st_fx->fd_cng_reset_flag == 0 &&
- NE_16( st_fx->last_core, AMR_WB_CORE ) &&
- st_fx->Opt_AMR_WB == 0 )
- {
- test();
- test();
- test();
- IF( GT_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate_cng, -1 ) &&
- NE_32( st_fx->last_total_brate_cng, st_fx->total_brate ) && last_br_cng_flag )
- {
- st_fx->total_brate = st_fx->last_total_brate_cng;
- move32();
- test();
- if ( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) )
- {
- st_fx->Opt_SC_VBR = 0;
- move16();
- }
- st_fx->rf_mode = st_fx->last_rf_mode_cng;
- move16();
- st_fx->bwidth = st_fx->last_bwidth_cng;
- move16();
- st_fx->codec_mode = st_fx->last_codec_mode_cng;
- move16();
- }
- test();
- test();
- IF( LE_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate, st_fx->total_brate ) && last_br_flag )
-
- {
- st_fx->total_brate = st_fx->last_total_brate;
- move32();
- test();
- if ( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) )
- {
- st_fx->Opt_SC_VBR = 0;
- move16();
- }
-
- st_fx->Opt_RF_ON = 0;
- move16();
- test();
- test();
- test();
- if ( st_fx->rf_mode && st_fx->rf_fec_offset > 0 && EQ_32( st_fx->total_brate, ACELP_13k20 ) && ( st_fx->bwidth != NB ) )
- {
- st_fx->Opt_RF_ON = 1;
- move16();
- }
- st_fx->rf_mode = st_fx->Opt_RF_ON;
- move16();
- st_fx->bwidth = st_fx->last_bwidth;
- move32();
- IF( st_fx->element_mode > EVS_MONO )
- {
- st_fx->codec_mode = MODE1;
- move16();
- }
- ELSE
- {
- st_fx->codec_mode = get_codec_mode( st_fx->total_brate );
- move16();
- }
- }
- }
-
- /*------------------------------------------------------------------------*
- * Select SID or FRAME_NO_DATA frame if DTX is enabled
- *------------------------------------------------------------------------*/
-
- br_dtx_flag = 1;
+ flag_lp_noise = 0;
move16();
-
- IF( st_fx->dtx_sce_sba == 0 )
- {
- test();
- test();
- test();
- test();
- br_dtx_flag = ( ( st_fx->element_mode == EVS_MONO ) && LE_32( st_fx->total_brate, MAX_BRATE_DTX_EVS ) ) ||
- ( ( st_fx->element_mode != EVS_MONO ) && LE_32( ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) ||
- LT_16( extract_h( st_fx->lp_noise_32fx ), DTX_THR * 256 );
- }
- test();
- test();
test();
test();
- IF( st_fx->Opt_DTX_ON && vad == 0 &&
- GT_16( st_fx->ini_frame, 2 ) && /* CNG coding starts after 2 frames */
- br_dtx_flag &&
- st_fx->fd_cng_reset_flag == 0 )
- {
- /* reset counter */
- st_fx->active_cnt = 0;
- move16();
-
- IF( st_fx->Opt_AMR_WB )
- {
- st_fx->last_total_brate_cng = -1;
- move16();
- }
- ELSE
- {
- st_fx->last_total_brate_cng = st_fx->total_brate;
- move16();
- st_fx->last_bwidth_cng = st_fx->bwidth;
- move16();
- st_fx->last_codec_mode_cng = st_fx->codec_mode;
- move16();
- st_fx->last_rf_mode_cng = st_fx->rf_mode;
- move16();
- }
-
- IF( hDtxEnc->cnt_SID == 0 )
- {
- /* this will be a SID frame */
- IF( st_fx->Opt_AMR_WB )
- {
- st_fx->core_brate = SID_1k75;
- move32();
- }
- ELSE
- {
- st_fx->core_brate = SID_2k40;
- move32();
- }
- }
- ELSE
- {
- /* this will be a no data frame */
- st_fx->core_brate = FRAME_NO_DATA;
- move32();
- }
-
- test();
- test();
- IF( ( st_fx->core_brate == FRAME_NO_DATA ) && ( st_fx->last_core != ACELP_CORE ) && !st_fx->Opt_AMR_WB )
- {
- /* force SID frame when switching from HQ core or AMR-WB IO mode into inactive frame in ACELP core when DTX is on */
- st_fx->core_brate = SID_2k40;
- move32();
- }
- test();
- test();
- IF( ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->cng_type, FD_CNG ) ) && EQ_16( st_fx->dtx_sce_sba, 1 ) )
- {
- st_fx->cng_type = FD_CNG;
- move16();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( st_fx->element_mode == EVS_MONO ) && ( EQ_32( st_fx->total_brate, ACELP_9k60 ) || EQ_32( st_fx->total_brate, ACELP_16k40 ) || EQ_32( st_fx->total_brate, ACELP_24k40 ) || EQ_32( st_fx->total_brate, ACELP_48k ) || EQ_32( st_fx->total_brate, HQ_96k ) || EQ_32( st_fx->total_brate, HQ_128k ) ) )
- {
- st_fx->codec_mode = MODE2;
- move16();
- }
- }
- ELSE
- {
- test();
- test();
- test();
- test();
- IF( ( EQ_16( st_fx->cng_type, FD_CNG ) && ( LE_32( st_fx->total_brate, MAX_BRATE_DTX_EVS ) || ( ( st_fx->element_mode != EVS_MONO ) && LE_32( ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) ) ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) /* at highest bitrates, use exclusively LP_CNG */
- {
- test();
- test();
- test();
- IF( ( st_fx->element_mode == EVS_MONO ) && ( EQ_32( st_fx->total_brate, ACELP_9k60 ) || EQ_32( st_fx->total_brate, ACELP_16k40 ) || EQ_32( st_fx->total_brate, ACELP_24k40 ) ) )
- {
- st_fx->codec_mode = MODE2;
- move16();
- }
- }
- ELSE
- {
- st_fx->cng_type = LP_CNG;
- move16();
- if ( EQ_16( st_fx->codec_mode, MODE2 ) )
- {
- hTdCngEnc->lp_cng_mode2 = 1;
- move16();
- }
- st_fx->codec_mode = MODE1;
- move16();
- }
- }
- /* reset the bitstream (IVAS format signalling was already written) */
- test();
- IF( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->hBstr != NULL )
- {
-
- reset_indices_enc_fx( st_fx->hBstr, st_fx->hBstr->nb_ind_tot );
- }
- }
- ELSE IF( st_fx->element_mode != EVS_MONO )
- {
- st_fx->total_brate = total_brate_ref;
- move32();
- }
-
- /*------------------------------------------------------------------------*
- * Reset counters when in active frame (not in SID or FRAME_NO_DATA frame)
- *------------------------------------------------------------------------*/
- /* NB core bit rate can be "-1" at startup , so one can not use core_brate_fx <=2400 */
- test();
- test();
- IF( ( NE_32( st_fx->core_brate, SID_2k40 ) ) && ( NE_32( st_fx->core_brate, SID_1k75 ) ) && ( st_fx->core_brate != FRAME_NO_DATA ) )
- {
- IF( hDtxEnc != NULL )
- {
- hDtxEnc->cnt_SID = 0;
- move16();
-
- /* change SID update rate */
- /* first SID update is only 8 (3) frames after the active speech end */
- IF( !st_fx->Opt_AMR_WB )
- {
- hDtxEnc->max_SID = FIXED_SID_RATE;
- move16();
- }
- ELSE
- {
- hDtxEnc->max_SID = 3;
- move16(); /* first SID update is only 3 frames after the active speech end */
- }
-
- if ( LT_16( hDtxEnc->interval_SID, hDtxEnc->max_SID ) )
- {
- hDtxEnc->max_SID = hDtxEnc->interval_SID;
- move16(); /* change SID update rate */
- }
-
- hDtxEnc->cng_cnt = 0;
- move16(); /* reset the counter of CNG frames for averaging */
- }
- test();
- test();
- IF( GE_16( st_fx->active_cnt, CNG_TYPE_HO ) && st_fx->Opt_AMR_WB == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
- {
- IF( EQ_16( st_fx->element_mode, IVAS_SCE ) )
- {
- Word32 lp_thresh, fd_thresh;
- test();
- IF( st_fx->Opt_DTX_ON && EQ_16( st_fx->dtx_sce_sba, 1 ) )
- {
- lp_thresh = 327680; // 5 in Q16
- move32();
- fd_thresh = 131072; // 2 in Q16
- move32();
- }
- ELSE
- {
- lp_thresh = 655360; // 10 in Q16
- move32();
- fd_thresh = 327680; // 5 in Q16
- move32();
- }
-
- /*More conservative selection of LP-CNG for SCE*/
- test();
- test();
- test();
- IF( st_fx->cng_type == LP_CNG && ( GT_32( st_fx->bckr_tilt_lt, lp_thresh ) ) )
- {
- st_fx->cng_type = FD_CNG;
- move16();
- }
- ELSE IF( EQ_16( st_fx->cng_type, FD_CNG ) && ( LT_32( st_fx->bckr_tilt_lt, fd_thresh ) ) && ( GT_32( st_fx->lp_noise_32fx, 67108864 /* 2 in Q24 */ ) ) )
- {
- st_fx->cng_type = LP_CNG;
- move16();
- }
- }
- ELSE
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( st_fx->cng_type == LP_CNG ) && ( ( ( st_fx->input_bwidth == NB ) && GT_32( st_fx->bckr_tilt_lt, 589824 /*9.f Q16*/ ) ) || ( ( st_fx->input_bwidth > NB ) && GT_32( st_fx->bckr_tilt_lt, 2949120l /*45.f Q16*/ ) ) ) )
- {
- st_fx->cng_type = FD_CNG;
- move16();
- }
- ELSE IF( EQ_16( st_fx->cng_type, FD_CNG ) && ( ( ( st_fx->input_bwidth == NB ) && LT_32( st_fx->bckr_tilt_lt, 131072l /*2.f Q16*/ ) ) || ( ( st_fx->input_bwidth > NB ) && LT_32( st_fx->bckr_tilt_lt, 655360l /*10.f Q16*/ ) ) ) )
- {
- st_fx->cng_type = LP_CNG;
- move16();
- }
- }
- st_fx->last_total_brate_cng = -1;
- move16();
- }
- ELSE IF( st_fx->Opt_AMR_WB )
- {
- st_fx->cng_type = LP_CNG;
- move16();
- }
- st_fx->active_cnt = add( st_fx->active_cnt, 1 );
- move16();
- st_fx->active_cnt = s_min( st_fx->active_cnt, 200 );
- move16();
- }
-
- /*------------------------------------------------------------------------*
- * Update speech and background noise long-term energy
- *------------------------------------------------------------------------*/
- IF( hDtxEnc != NULL )
- {
- hDtxEnc->frame_ener_fx = L_deposit_l( 0 );
- move32();
-
- IF( st_fx->Opt_DTX_ON )
- {
- Q_speech2 = add( shl( Q_speech, 1 ), 7 );
- FOR( j = 0; j < 16; j++ )
- {
- L_tmp = L_mult0( *speech, *speech ); /*2*Q_speech*/
- speech++;
- FOR( i = 1; i < L_FRAME / 16; i++ )
- {
- L_tmp = L_mac0_sat( L_tmp, *speech, *speech ); /*2*Q_speech*/
- speech++;
- }
- hDtxEnc->frame_ener_fx = L_add( hDtxEnc->frame_ener_fx, L_shr( L_tmp, Q_speech2 ) ); /* Q(-7) */
- move32();
- }
-
- /* Active speech (voiced) */
-
- IF( EQ_16( st_fx->clas, VOICED_CLAS ) )
- {
- alpha = ALPHA_ENER_SLOW_FX; /*Q15 */
- move16();
- if ( GT_32( hDtxEnc->frame_ener_fx, hDtxEnc->lt_ener_voiced_fx ) )
- {
- alpha = ALPHA_ENER_FAST_FX; /*Q15 */
- move16();
- }
-
- /*st_fx->lt_ener_voiced_fx = alpha * st_fx->lt_ener_voiced_fx + (1.0f-alpha) * st_fx->frame_ener_fx;*/
- L_tmp = L_sub( hDtxEnc->lt_ener_voiced_fx, hDtxEnc->frame_ener_fx ); /*Q(-7)*/
- L_tmp = Mult_32_16( L_tmp, alpha ); /*Q(-7)*/
- hDtxEnc->lt_ener_voiced_fx = L_add( L_tmp, hDtxEnc->frame_ener_fx ); /* Q(-7) */
- move32();
-
- hDtxEnc->VarDTX_cnt_voiced = add( hDtxEnc->VarDTX_cnt_voiced, 1 );
- move16();
-
- hDtxEnc->VarDTX_cnt_voiced = s_min( hDtxEnc->VarDTX_cnt_voiced, MIN_CNT );
- move16();
- }
- /* Background noise */
- ELSE IF( !st_fx->Opt_AMR_WB )
- {
- alpha = ALPHA_ENER_SLOW_FX; /*Q15*/
- move16();
- if ( LT_32( hDtxEnc->frame_ener_fx, hDtxEnc->lt_ener_noise_fx ) )
- {
- alpha = ALPHA_ENER_FAST_FX; /*Q15*/
- move16();
- }
-
- /*st_fx->lt_ener_noise_fx = alpha * st_fx->lt_ener_noise_fx + (1.0f-alpha) * st_fx->frame_ener_fx;*/
- L_tmp = L_sub( hDtxEnc->lt_ener_noise_fx, hDtxEnc->frame_ener_fx ); /* Q(-7) */
- L_tmp = Mult_32_16( L_tmp, alpha ); /* Q(-7) */
- hDtxEnc->lt_ener_noise_fx = L_add( L_tmp, hDtxEnc->frame_ener_fx ); /* Q(-7) */
- move32();
-
- hDtxEnc->VarDTX_cnt_noise = add( hDtxEnc->VarDTX_cnt_noise, 1 );
- move16();
-
- hDtxEnc->VarDTX_cnt_noise = s_min( hDtxEnc->VarDTX_cnt_noise, MIN_CNT );
- move16();
- }
- }
- }
-
- /* Update of the SID counter */
- update_SID_cnt_fx( hDtxEnc, st_fx->core_brate, st_fx->Opt_AMR_WB );
-
- /* Update encoded bandwidth */
- test();
- test();
- IF( st_fx->Opt_DTX_ON && ( EQ_32( st_fx->core_brate, SID_2k40 ) || ( st_fx->core_brate == FRAME_NO_DATA ) ) )
- {
-
- st_fx->bwidth = st_fx->last_bwidth;
- move16();
- test();
- IF( GT_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate_cng, -1 ) )
- {
- st_fx->bwidth = st_fx->last_bwidth_cng;
- move16();
- }
-
- test();
- test();
- IF( st_fx->Opt_RF_ON && ( EQ_32( st_fx->total_brate, ACELP_13k20 ) ) && ( ( st_fx->bwidth == NB ) ) )
- {
- st_fx->codec_mode = MODE1;
- move16();
- reset_rf_indices_fx( st_fx );
- st_fx->Opt_RF_ON = 0;
- move16();
- st_fx->rf_mode = 0;
- move16();
- }
-
- test();
- IF( st_fx->Opt_RF_ON && NE_32( st_fx->total_brate, ACELP_13k20 ) )
- {
- reset_rf_indices_fx( st_fx );
- move16();
- st_fx->Opt_RF_ON = 0;
- move16();
- st_fx->rf_mode = 0;
- }
-
- /* Set and limit the encoded bandwidth */
- IF( EQ_16( st_fx->codec_mode, MODE2 ) )
- {
- Word16 n, bits_frame_nominal;
-
- UWord16 lsb;
- Word16 tmpbandwidthMin;
-
- Mpy_32_16_ss( st_fx->total_brate, 5243, &L_tmp, &lsb ); /* 5243 is 1/50 in Q18. (0+18-15=3) */
- bits_frame_nominal = extract_l( L_shr( L_tmp, 3 ) ); /* Q0 */
-
- FOR( n = 0; n < FRAME_SIZE_NB; n++ )
- {
- IF( EQ_16( FrameSizeConfig[n].frame_bits, bits_frame_nominal ) )
- {
- BREAK;
- }
- }
- IF( EQ_16( n, FRAME_SIZE_NB ) )
- {
- assert( !"Bitrate not supported: not part of EVS" );
- }
- tmpbandwidthMin = FrameSizeConfig[n].bandwidth_min;
- move16();
- if ( EQ_16( st_fx->rf_mode, 1 ) )
- {
- tmpbandwidthMin = WB;
- move16();
- }
- st_fx->bwidth = s_max( s_min( st_fx->bwidth, FrameSizeConfig[n].bandwidth_max ), tmpbandwidthMin );
- move16();
- }
- }
-
- return;
-}
-
-/*==================================================================================*/
-/* FUNCTION : dtx_fx() */
-/*----------------------------------------------------------------------------------*/
-/* PURPOSE : Discontinuous transmission operation */
-/*----------------------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Encoder_State_Fx) st_fx : encoder state structure */
-/* _ (Word16) vad : vad flag Q0 */
-/* _ (Word16[]) speech_fx : Pointer to the speech frame qSpeech */
-/* _ (Word16) qSpeech : speech buffer qformat value */
-/* _ (Word16*) qener : frame_ener/lt_ener_voiced/lt_ener_noise buf qformat */
-/*----------------------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16*) qener : frame_ener/lt_ener_voiced/lt_ener_noise buf qformat */
-/* _ (Encoder_State_Fx) st_fx : encoder state structure */
-/*----------------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*==================================================================================*/
-void dtx_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 vad, /* i : vad flag for DTX Q0*/
- const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/
- Word16 Q_speech /* i : Q factor for speech */
-
-)
-{
- Word16 alpha, j, i, Q_speech2;
- Word32 L_tmp;
- DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc;
- TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc;
+ test();
+ IF( ( st_fx->element_mode == EVS_MONO && LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) ) ||
+ ( st_fx->element_mode != EVS_MONO && LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 ) ) )
+ {
+ flag_lp_noise = 1;
+ move16();
+ }
- Word16 last_br_cng_flag, last_br_flag, br_dtx_flag;
+ total_brate_ref = st_fx->total_brate;
+ move32();
IF( st_fx->dtx_sce_sba != 0 )
{
last_br_cng_flag = 1;
last_br_flag = 1;
- br_dtx_flag = 1;
- move16();
move16();
move16();
}
ELSE
{
- last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, ACELP_32k ) );
+ test();
+ test();
+ test();
+ last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_EVS ) || flag_lp_noise || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_IVAS ) );
- last_br_flag = LE_32( st_fx->last_total_brate, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate, ACELP_32k ) );
- br_dtx_flag = 0;
- move16();
+ test();
+ test();
+ test();
+ test();
+ last_br_flag = ( st_fx->element_mode == EVS_MONO && LE_32( st_fx->last_total_brate, MAX_BRATE_DTX_EVS ) ) ||
+ ( st_fx->element_mode != EVS_MONO && LE_32( last_ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) ||
+ flag_lp_noise;
}
+
/* Initialization */
IF( st_fx->ini_frame == 0 )
{
@@ -655,13 +126,20 @@ void dtx_fx(
st_fx->cng_type = FD_CNG;
move16();
+
test();
- IF( ( EQ_16( st_fx->codec_mode, MODE1 ) || st_fx->Opt_AMR_WB ) && EQ_16( st_fx->element_mode, IVAS_SCE ) && EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
+ test();
+ test();
+ if ( ( EQ_16( st_fx->codec_mode, MODE1 ) || st_fx->Opt_AMR_WB ) && NE_16( st_fx->element_mode, IVAS_SCE ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
{
st_fx->cng_type = LP_CNG;
move16();
}
}
+
+ test();
+ test();
+ test();
test();
test();
IF( st_fx->Opt_DTX_ON && vad == 0 &&
@@ -678,12 +156,14 @@ void dtx_fx(
{
st_fx->total_brate = st_fx->last_total_brate_cng;
move32();
+
test();
- IF( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) )
+ if ( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) )
{
st_fx->Opt_SC_VBR = 0;
move16();
}
+
st_fx->rf_mode = st_fx->last_rf_mode_cng;
move16();
st_fx->bwidth = st_fx->last_bwidth_cng;
@@ -691,15 +171,16 @@ void dtx_fx(
st_fx->codec_mode = st_fx->last_codec_mode_cng;
move16();
}
+
test();
test();
IF( LE_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate, st_fx->total_brate ) && last_br_flag )
-
{
st_fx->total_brate = st_fx->last_total_brate;
move32();
+
test();
- IF( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) )
+ if ( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) )
{
st_fx->Opt_SC_VBR = 0;
move16();
@@ -710,16 +191,18 @@ void dtx_fx(
test();
test();
test();
- IF( st_fx->rf_mode && st_fx->rf_fec_offset > 0 && EQ_32( st_fx->total_brate, ACELP_13k20 ) && NE_16( st_fx->bwidth, NB ) )
+ if ( st_fx->rf_mode && st_fx->rf_fec_offset > 0 && EQ_32( st_fx->total_brate, ACELP_13k20 ) && ( st_fx->bwidth != NB ) )
{
st_fx->Opt_RF_ON = 1;
move16();
}
+
st_fx->rf_mode = st_fx->Opt_RF_ON;
move16();
st_fx->bwidth = st_fx->last_bwidth;
move32();
- IF( ( st_fx->element_mode > EVS_MONO ) )
+
+ IF( st_fx->element_mode > EVS_MONO )
{
st_fx->codec_mode = MODE1;
move16();
@@ -727,6 +210,7 @@ void dtx_fx(
ELSE
{
st_fx->codec_mode = get_codec_mode( st_fx->total_brate );
+ move16();
}
}
}
@@ -735,11 +219,20 @@ void dtx_fx(
* Select SID or FRAME_NO_DATA frame if DTX is enabled
*------------------------------------------------------------------------*/
- if ( st_fx->dtx_sce_sba == 0 )
+ br_dtx_flag = 1;
+ move16();
+
+ IF( st_fx->dtx_sce_sba == 0 )
{
- br_dtx_flag = LE_32( st_fx->total_brate, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->total_brate, ACELP_32k ) ) ||
- EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && ( LE_32( st_fx->element_brate, IVAS_64k ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) ) );
+ test();
+ test();
+ test();
+ test();
+ br_dtx_flag = ( ( st_fx->element_mode == EVS_MONO ) && LE_32( st_fx->total_brate, MAX_BRATE_DTX_EVS ) ) ||
+ ( ( st_fx->element_mode != EVS_MONO ) && LE_32( ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) ||
+ flag_lp_noise;
}
+
test();
test();
test();
@@ -756,17 +249,17 @@ void dtx_fx(
IF( st_fx->Opt_AMR_WB )
{
st_fx->last_total_brate_cng = -1;
- st_fx->last_rf_mode_cng = st_fx->rf_mode;
- move32();
move16();
}
ELSE
{
st_fx->last_total_brate_cng = st_fx->total_brate;
+ move16();
st_fx->last_bwidth_cng = st_fx->bwidth;
+ move16();
st_fx->last_codec_mode_cng = st_fx->codec_mode;
- move32();
move16();
+ st_fx->last_rf_mode_cng = st_fx->rf_mode;
move16();
}
@@ -800,16 +293,37 @@ void dtx_fx(
move32();
}
+ test();
+ test();
+ IF( ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->cng_type, FD_CNG ) ) && EQ_16( st_fx->dtx_sce_sba, 1 ) )
+ {
+ st_fx->cng_type = FD_CNG;
+ move16();
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( ( st_fx->element_mode == EVS_MONO ) && ( EQ_32( st_fx->total_brate, ACELP_9k60 ) || EQ_32( st_fx->total_brate, ACELP_16k40 ) || EQ_32( st_fx->total_brate, ACELP_24k40 ) || EQ_32( st_fx->total_brate, ACELP_48k ) || EQ_32( st_fx->total_brate, HQ_96k ) || EQ_32( st_fx->total_brate, HQ_128k ) ) )
+ {
+ st_fx->codec_mode = MODE2;
+ move16();
+ }
+ }
+ ELSE
{
test();
test();
test();
test();
- IF( ( EQ_16( st_fx->cng_type, FD_CNG ) && ( LE_32( st_fx->total_brate, ACELP_24k40 ) || ( ( st_fx->element_mode != EVS_MONO ) && LE_32( st_fx->total_brate, ACELP_32k ) ) ) ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) /* at highest bitrates, use exclusively LP_CNG */
+ IF( ( EQ_16( st_fx->cng_type, FD_CNG ) && ( LE_32( st_fx->total_brate, MAX_BRATE_DTX_EVS ) || ( ( st_fx->element_mode != EVS_MONO ) && LE_32( ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) ) ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) /* at highest bitrates, use exclusively LP_CNG */
{
test();
test();
- IF( EQ_16( st_fx->element_mode, EVS_MONO ) && ( EQ_32( st_fx->total_brate, ACELP_9k60 ) || EQ_32( st_fx->total_brate, ACELP_16k40 ) || EQ_32( st_fx->total_brate, ACELP_24k40 ) ) )
+ test();
+ IF( ( st_fx->element_mode == EVS_MONO ) && ( EQ_32( st_fx->total_brate, ACELP_9k60 ) || EQ_32( st_fx->total_brate, ACELP_16k40 ) || EQ_32( st_fx->total_brate, ACELP_24k40 ) ) )
{
st_fx->codec_mode = MODE2;
move16();
@@ -819,7 +333,7 @@ void dtx_fx(
{
st_fx->cng_type = LP_CNG;
move16();
- IF( st_fx->codec_mode == MODE2 )
+ if ( EQ_16( st_fx->codec_mode, MODE2 ) )
{
hTdCngEnc->lp_cng_mode2 = 1;
move16();
@@ -830,16 +344,23 @@ void dtx_fx(
}
/* reset the bitstream (IVAS format signalling was already written) */
+ test();
IF( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->hBstr != NULL )
{
+
reset_indices_enc_fx( st_fx->hBstr, st_fx->hBstr->nb_ind_tot );
}
}
+ ELSE IF( st_fx->element_mode != EVS_MONO )
+ {
+ st_fx->total_brate = total_brate_ref;
+ move32();
+ }
/*------------------------------------------------------------------------*
* Reset counters when in active frame (not in SID or FRAME_NO_DATA frame)
*------------------------------------------------------------------------*/
- /* NB core bit rate can be "-1" at startup , so one can not use core_brate_fx <=2400 */
+
test();
test();
IF( ( NE_32( st_fx->core_brate, SID_2k40 ) ) && ( NE_32( st_fx->core_brate, SID_1k75 ) ) && ( st_fx->core_brate != FRAME_NO_DATA ) )
@@ -862,7 +383,7 @@ void dtx_fx(
move16(); /* first SID update is only 3 frames after the active speech end */
}
- IF( LT_16( hDtxEnc->interval_SID, hDtxEnc->max_SID ) )
+ if ( LT_16( hDtxEnc->interval_SID, hDtxEnc->max_SID ) )
{
hDtxEnc->max_SID = hDtxEnc->interval_SID;
move16(); /* change SID update rate */
@@ -872,10 +393,42 @@ void dtx_fx(
move16(); /* reset the counter of CNG frames for averaging */
}
test();
+ test();
IF( GE_16( st_fx->active_cnt, CNG_TYPE_HO ) && st_fx->Opt_AMR_WB == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
{
IF( EQ_16( st_fx->element_mode, IVAS_SCE ) )
{
+ Word32 lp_thresh, fd_thresh;
+ test();
+ IF( st_fx->Opt_DTX_ON && EQ_16( st_fx->dtx_sce_sba, 1 ) )
+ {
+ lp_thresh = 327680; // 5 in Q16
+ move32();
+ fd_thresh = 131072; // 2 in Q16
+ move32();
+ }
+ ELSE
+ {
+ lp_thresh = 655360; // 10 in Q16
+ move32();
+ fd_thresh = 327680; // 5 in Q16
+ move32();
+ }
+
+ /*More conservative selection of LP-CNG for SCE*/
+ test();
+ test();
+ test();
+ IF( st_fx->cng_type == LP_CNG && ( GT_32( st_fx->bckr_tilt_lt, lp_thresh ) ) )
+ {
+ st_fx->cng_type = FD_CNG;
+ move16();
+ }
+ ELSE IF( EQ_16( st_fx->cng_type, FD_CNG ) && ( LT_32( st_fx->bckr_tilt_lt, fd_thresh ) ) && ( GT_32( st_fx->lp_noise_32fx, 67108864 /* 2 in Q24 */ ) ) )
+ {
+ st_fx->cng_type = LP_CNG;
+ move16();
+ }
}
ELSE
{
@@ -887,34 +440,41 @@ void dtx_fx(
test();
test();
test();
- IF( EQ_16( st_fx->cng_type, LP_CNG ) && ( ( EQ_16( st_fx->input_bwidth, NB ) && GT_32( st_fx->bckr_tilt_lt, 589824l /*9.f Q16*/ ) ) || ( GT_16( st_fx->input_bwidth, NB ) && GT_32( st_fx->bckr_tilt_lt, 2949120l /*45.f Q16*/ ) ) ) )
+ IF( ( st_fx->cng_type == LP_CNG ) && ( ( ( st_fx->input_bwidth == NB ) && GT_32( st_fx->bckr_tilt_lt, 589824 /*9.f Q16*/ ) ) || ( ( st_fx->input_bwidth > NB ) && GT_32( st_fx->bckr_tilt_lt, 2949120l /*45.f Q16*/ ) ) ) )
{
st_fx->cng_type = FD_CNG;
move16();
}
- ELSE IF( EQ_16( st_fx->cng_type, FD_CNG ) && ( ( EQ_16( st_fx->input_bwidth, NB ) && LT_32( st_fx->bckr_tilt_lt, 131072l /*2.f Q16*/ ) ) || ( GT_16( st_fx->input_bwidth, NB ) && LT_32( st_fx->bckr_tilt_lt, 655360l /*10.f Q16*/ ) ) ) )
+ ELSE IF( EQ_16( st_fx->cng_type, FD_CNG ) && ( ( ( st_fx->input_bwidth == NB ) && LT_32( st_fx->bckr_tilt_lt, 131072l /*2.f Q16*/ ) ) || ( ( st_fx->input_bwidth > NB ) && LT_32( st_fx->bckr_tilt_lt, 655360l /*10.f Q16*/ ) ) ) )
{
st_fx->cng_type = LP_CNG;
move16();
}
}
+
st_fx->last_total_brate_cng = -1;
+ move16();
}
ELSE IF( st_fx->Opt_AMR_WB )
{
st_fx->cng_type = LP_CNG;
move16();
}
+
st_fx->active_cnt = add( st_fx->active_cnt, 1 );
+ move16();
st_fx->active_cnt = s_min( st_fx->active_cnt, 200 );
+ move16();
}
/*------------------------------------------------------------------------*
* Update speech and background noise long-term energy
*------------------------------------------------------------------------*/
+
IF( hDtxEnc != NULL )
{
hDtxEnc->frame_ener_fx = L_deposit_l( 0 );
+ move32();
IF( st_fx->Opt_DTX_ON )
{
@@ -928,14 +488,14 @@ void dtx_fx(
L_tmp = L_mac0_sat( L_tmp, *speech, *speech ); /*2*Q_speech*/
speech++;
}
- hDtxEnc->frame_ener_fx = L_add( hDtxEnc->frame_ener_fx, L_shr( L_tmp, Q_speech2 ) ); /*Q(-7) */
+ hDtxEnc->frame_ener_fx = L_add( hDtxEnc->frame_ener_fx, L_shr( L_tmp, Q_speech2 ) ); /* Q(-7) */
+ move32();
}
/* Active speech (voiced) */
-
IF( EQ_16( st_fx->clas, VOICED_CLAS ) )
{
- alpha = ALPHA_ENER_SLOW_FX;
+ alpha = ALPHA_ENER_SLOW_FX; /*Q15 */
move16();
if ( GT_32( hDtxEnc->frame_ener_fx, hDtxEnc->lt_ener_voiced_fx ) )
{
@@ -946,32 +506,37 @@ void dtx_fx(
/*st_fx->lt_ener_voiced_fx = alpha * st_fx->lt_ener_voiced_fx + (1.0f-alpha) * st_fx->frame_ener_fx;*/
L_tmp = L_sub( hDtxEnc->lt_ener_voiced_fx, hDtxEnc->frame_ener_fx ); /*Q(-7)*/
L_tmp = Mult_32_16( L_tmp, alpha ); /*Q(-7)*/
- hDtxEnc->lt_ener_voiced_fx = L_add( L_tmp, hDtxEnc->frame_ener_fx ); /*Q(-7)*/
+ hDtxEnc->lt_ener_voiced_fx = L_add( L_tmp, hDtxEnc->frame_ener_fx ); /* Q(-7) */
+ move32();
hDtxEnc->VarDTX_cnt_voiced = add( hDtxEnc->VarDTX_cnt_voiced, 1 );
+ move16();
hDtxEnc->VarDTX_cnt_voiced = s_min( hDtxEnc->VarDTX_cnt_voiced, MIN_CNT );
+ move16();
}
/* Background noise */
ELSE IF( !st_fx->Opt_AMR_WB )
{
- alpha = ALPHA_ENER_SLOW_FX; /*Q15 */
+ alpha = ALPHA_ENER_SLOW_FX; /*Q15*/
move16();
if ( LT_32( hDtxEnc->frame_ener_fx, hDtxEnc->lt_ener_noise_fx ) )
{
- alpha = ALPHA_ENER_FAST_FX; /*Q15 */
+ alpha = ALPHA_ENER_FAST_FX; /*Q15*/
move16();
}
/*st_fx->lt_ener_noise_fx = alpha * st_fx->lt_ener_noise_fx + (1.0f-alpha) * st_fx->frame_ener_fx;*/
- L_tmp = L_sub( hDtxEnc->lt_ener_noise_fx, hDtxEnc->frame_ener_fx ); /*Q(-7)*/
- L_tmp = Mult_32_16( L_tmp, alpha ); /*Q(-7)*/
- hDtxEnc->lt_ener_noise_fx = L_add( L_tmp, hDtxEnc->frame_ener_fx ); /*Q(-7)*/
+ L_tmp = L_sub( hDtxEnc->lt_ener_noise_fx, hDtxEnc->frame_ener_fx ); /* Q(-7) */
+ L_tmp = Mult_32_16( L_tmp, alpha ); /* Q(-7) */
+ hDtxEnc->lt_ener_noise_fx = L_add( L_tmp, hDtxEnc->frame_ener_fx ); /* Q(-7) */
move32();
hDtxEnc->VarDTX_cnt_noise = add( hDtxEnc->VarDTX_cnt_noise, 1 );
+ move16();
hDtxEnc->VarDTX_cnt_noise = s_min( hDtxEnc->VarDTX_cnt_noise, MIN_CNT );
+ move16();
}
}
}
@@ -982,9 +547,8 @@ void dtx_fx(
/* Update encoded bandwidth */
test();
test();
- IF( st_fx->Opt_DTX_ON && ( st_fx->core_brate == SID_2k40 || st_fx->core_brate == FRAME_NO_DATA ) )
+ IF( st_fx->Opt_DTX_ON && ( EQ_32( st_fx->core_brate, SID_2k40 ) || ( st_fx->core_brate == FRAME_NO_DATA ) ) )
{
-
st_fx->bwidth = st_fx->last_bwidth;
move16();
test();
@@ -996,7 +560,7 @@ void dtx_fx(
test();
test();
- IF( st_fx->Opt_RF_ON && ( EQ_32( st_fx->total_brate, ACELP_13k20 ) ) && ( EQ_16( st_fx->bwidth, NB ) ) )
+ IF( st_fx->Opt_RF_ON && ( EQ_32( st_fx->total_brate, ACELP_13k20 ) ) && ( ( st_fx->bwidth == NB ) ) )
{
st_fx->codec_mode = MODE1;
move16();
@@ -1007,7 +571,6 @@ void dtx_fx(
move16();
}
- test();
test();
IF( st_fx->Opt_RF_ON && NE_32( st_fx->total_brate, ACELP_13k20 ) )
{
@@ -1016,14 +579,12 @@ void dtx_fx(
st_fx->Opt_RF_ON = 0;
move16();
st_fx->rf_mode = 0;
- move16();
}
/* Set and limit the encoded bandwidth */
IF( EQ_16( st_fx->codec_mode, MODE2 ) )
{
Word16 n, bits_frame_nominal;
-
UWord16 lsb;
Word16 tmpbandwidthMin;
@@ -1041,18 +602,25 @@ void dtx_fx(
{
assert( !"Bitrate not supported: not part of EVS" );
}
+
tmpbandwidthMin = FrameSizeConfig[n].bandwidth_min;
+ move16();
+
if ( EQ_16( st_fx->rf_mode, 1 ) )
{
tmpbandwidthMin = WB;
+ move16();
}
+
st_fx->bwidth = s_max( s_min( st_fx->bwidth, FrameSizeConfig[n].bandwidth_max ), tmpbandwidthMin );
+ move16();
}
}
return;
}
+
/*---------------------------------------------------------------------*
* update_SID_cnt()
*
@@ -1201,6 +769,12 @@ static void update_SID_cnt_fx(
}
+/*-------------------------------------------------------------------*
+ * dtx_hangover_control()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
void dtx_hangover_control_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
const Word16 lsp_new_fx[M] /* i : current frame LSPs Q15*/
@@ -1480,6 +1054,7 @@ void dtx_hangover_control_fx(
return;
}
+
/*-------------------------------------------------------------------*
* td_cng_enc_init_fx()
*
@@ -1492,96 +1067,6 @@ void td_cng_enc_init_fx(
const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/
)
{
-
- hTdCngEnc->cng_seed = RANDOM_INITSEED;
- hTdCngEnc->cng_ener_seed = RANDOM_INITSEED;
- hTdCngEnc->cng_ener_seed1 = RANDOM_INITSEED;
- hTdCngEnc->lp_ener_fx = 0;
- hTdCngEnc->old_enr_index = -1;
- hTdCngEnc->Enew_fx = 0;
-
- hTdCngEnc->lp_sp_enr_fx = 0;
- hTdCngEnc->last_allow_cn_step = 0;
- move16();
- move32();
- move16();
- move16();
- move32();
- move16();
- move16();
-
- IF( Opt_DTX_ON )
- {
- hTdCngEnc->cng_hist_ptr = -1;
- move16();
- set16_fx( hTdCngEnc->cng_lsp_hist_fx, 0, DTX_HIST_SIZE * M );
- set16_fx( hTdCngEnc->cng_ener_hist_fx, 0, DTX_HIST_SIZE );
-
- hTdCngEnc->ho_hist_ptr = -1;
- move16();
- hTdCngEnc->ho_sid_bw = L_deposit_l( 0 );
- set16_fx( hTdCngEnc->ho_lsp_hist_fx, 0, HO_HIST_SIZE * M );
- set32_fx( hTdCngEnc->ho_ener_hist_fx, 0, HO_HIST_SIZE );
- set32_fx( hTdCngEnc->ho_env_hist_fx, 0, HO_HIST_SIZE * NUM_ENV_CNG );
- hTdCngEnc->ho_hist_size = 0;
- move16();
- hTdCngEnc->act_cnt = 0;
- move16();
- }
-
- set16_fx( hTdCngEnc->ho_16k_lsp, 0, HO_HIST_SIZE );
- hTdCngEnc->act_cnt2 = 0;
- hTdCngEnc->num_ho = 0;
- move16();
- move16();
-
- hTdCngEnc->ho_circ_ptr = -1;
- move16();
- set16_fx( hTdCngEnc->ho_lsp_circ_fx, 0, HO_HIST_SIZE * M );
- set32_fx( hTdCngEnc->ho_ener_circ_fx, 0, HO_HIST_SIZE );
- set32_fx( hTdCngEnc->ho_env_circ_fx, 0, HO_HIST_SIZE * NUM_ENV_CNG );
- hTdCngEnc->ho_circ_size = 0;
- hTdCngEnc->burst_ho_cnt = 0;
- move16();
- move16();
-
- hTdCngEnc->cng_buf_cnt = 0;
-
-
- set32_fx( hTdCngEnc->lp_env_fx, 0, 20 );
- set32_fx( hTdCngEnc->cng_res_env_fx, 0, 20 * 8 );
- set16_fx( hTdCngEnc->exc_mem_fx, 0, 24 );
- set16_fx( hTdCngEnc->exc_mem1_fx, 0, 30 );
- set16_fx( hTdCngEnc->exc_mem2_fx, 0, 30 );
- set32_fx( hTdCngEnc->old_env_fx, 0, NUM_ENV_CNG );
-
- /* SWB CNG/DTX */
- hTdCngEnc->last_wb_cng_ener_fx = -1541; /* Q8 */
- move16();
- hTdCngEnc->last_shb_cng_ener_fx = -1541; /* Q8 */
- move16();
- hTdCngEnc->mov_wb_cng_ener_fx = -1541; /* Q8 */
- move16();
- hTdCngEnc->mov_shb_cng_ener_fx = -1541; /* Q8 */
- move16();
- hTdCngEnc->shb_cng_ini_cnt = 1;
- move16();
- hTdCngEnc->shb_NO_DATA_cnt = 0;
- move16();
- hTdCngEnc->last_SID_bwidth = s_min( max_bwidth, SWB );
- hTdCngEnc->last_vad = 0;
- move16();
-
- return;
-}
-
-void td_cng_enc_init_ivas_fx(
- TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */
- const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/
- const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/
-)
-{
-
hTdCngEnc->cng_seed = RANDOM_INITSEED;
move16();
hTdCngEnc->cng_ener_seed = RANDOM_INITSEED;
@@ -1672,6 +1157,7 @@ void td_cng_enc_init_ivas_fx(
return;
}
+
/*-------------------------------------------------------------------*
* dtx_enc_init_fx()
*
@@ -1734,5 +1220,6 @@ void dtx_enc_init_fx(
move16();
}
}
+
return;
}
diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c
index bdbc32fec52c796dd776d963b7e3c080382baba1..0f4e772534fcb5eb5a9ff452ca4899210a21de8e 100644
--- a/lib_enc/enc_acelp_fx.c
+++ b/lib_enc/enc_acelp_fx.c
@@ -997,7 +997,10 @@ void E_ACELP_corrmatrix_fx(
p3 = &rrixiy[2][pos]; /* Q9 */
p2 = &rrixiy[1][pos];
p1 = &rrixiy[0][pos];
- p0 = &rrixiy[3][pos - 16];
+ p0 = &rrixiy[3][pos];
+ /* decrement pointer instead of indexing the array to avoid CLANG Usan complaint */
+ /* for last loop iteration, this points to rrixiy[3][-1], but is not actually accessed in later loop (k = 15 then, so inner loop will not run) */
+ p0 -= 16;
cor = L_deposit_h( 0 );
ptr_h1 = h; /*Q12*/
diff --git a/lib_enc/enc_acelp_tcx_main_fx.c b/lib_enc/enc_acelp_tcx_main_fx.c
index da8443f06c0045c58772ae2284c051a81a7e5126..b3bd7d112b850a0f708343296bd577beb645013b 100644
--- a/lib_enc/enc_acelp_tcx_main_fx.c
+++ b/lib_enc/enc_acelp_tcx_main_fx.c
@@ -63,15 +63,15 @@ void enc_acelp_tcx_main_fx(
{
core_encode_twodiv_fx( new_samples, st, st->coder_type, Aw, vad_hover_flag, Q_new, shift );
}
+
/*-----------------------------------------------------------------*
* Apply non linearity to the SHB excitation
*-----------------------------------------------------------------*/
-
test();
IF( EQ_16( st->core, ACELP_CORE ) && st->igf != 0 )
{
- non_linearity_fx( ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, *Q_new, st->coder_type, voice_factors, st->L_frame );
+ non_linearity_fx( EVS_MONO, ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, *Q_new, st->coder_type, voice_factors, st->L_frame );
/* update the old BWE exe memory */
Copy( &old_bwe_exc[L_FRAME32k], hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2 ); /*Q_exc*/
diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c
index 089c3bbb4d23fb9d4e536d691a0d413b66eeb589..a5b11f3b06ca27d9da208a793c7c7d8a54d0d14c 100644
--- a/lib_enc/enc_acelpx_fx.c
+++ b/lib_enc/enc_acelpx_fx.c
@@ -292,12 +292,8 @@ static void E_ACELP_1pulse_searchx_fx(
/*alp0 = *alp + R[0]; INDIRECT(1);*/
ps0 = *ps; /* Qdn */
move16();
- alp0 = L_deposit_h( *alp ); /* Q22 */
-#ifndef FIX_2248_EVS_ASSERT
- alp0 = L_mac( alp0, R[0], sign_val_1 ); /* Qalp = (Q_R=Q_cor)*Q_signval */
-#else
+ alp0 = L_deposit_h( *alp ); /* Q22 */
alp0 = L_mac_sat( alp0, R[0], sign_val_1 ); /* Qalp = (Q_R=Q_cor)*Q_signval */
-#endif
/* Ensure that in the loop below s > 0 in the first iteration, the actual values do not matter. */
move16();
move16();
diff --git a/lib_enc/enc_amr_wb_fx.c b/lib_enc/enc_amr_wb_fx.c
index f68b94daf048b36d3bc6bced9833598f64a1c11a..e31578c7a3993e639d5bbcce12002687d1f863d4 100644
--- a/lib_enc/enc_amr_wb_fx.c
+++ b/lib_enc/enc_amr_wb_fx.c
@@ -29,8 +29,8 @@ void encod_amr_wb_fx(
Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6*/
Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain Q0*/
const Word16 *speech16k_fx, /* i : input speech @16kHz Qx*/
- Word16 shift,
- Word16 Q_new )
+ const Word16 shift,
+ const Word16 Q_new )
{
Word16 xn[L_SUBFR]; /* Target vector for pitch search */
Word16 xn2[L_SUBFR]; /* Target vector for codebook search */
@@ -175,7 +175,7 @@ void encod_amr_wb_fx(
*-----------------------------------------------------------------*/
inov_encode_fx( st, st->core_brate, 1, L_FRAME, st->last_L_frame, -1, -1, 0, i_subfr, -1, p_Aq, gain_pit, cn,
- exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits, L_SUBFR, shift );
+ exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits, L_SUBFR, shift, 0 );
/*-----------------------------------------------------------------*
* Gain encoding
diff --git a/lib_enc/enc_gain_fx.c b/lib_enc/enc_gain_fx.c
index 8c53a5d12204779630e1f0bc893a2b76dd8311fd..2e1a5019b0358a1056cd07e600984cb0596e86a2 100644
--- a/lib_enc/enc_gain_fx.c
+++ b/lib_enc/enc_gain_fx.c
@@ -5,6 +5,7 @@
#include
#include
#include "options.h"
+#include "stl.h"
#include "cnst.h"
#include "rom_com.h"
#include "rom_enc.h"
@@ -253,7 +254,7 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[], /*Q_new*/
{
Word16 corr_v[32 + 2 * L_INTERPOL1 + 1];
Word16 cor_max, max, temp;
- Word16 *corr;
+ Word16 corr_idx;
Word16 i, fraction, frac1, frac2, step;
Word16 t0, t_min, t_max;
@@ -269,27 +270,29 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[], /*Q_new*/
move16();
move16();
- /* allocate memory to normalized correlation vector */
- corr = &corr_v[negate( t_min )]; /* corr[t_min..t_max] */
+ corr_idx = negate( t_min );
/* Compute normalized correlation between target and filtered excitation */
E_GAIN_norm_corr_fx( exc, xn, h, t_min, t_max, corr_v, L_subfr );
/* find integer pitch */
- max = corr[t0_min]; /*(Q15+(Q_new+shift-1)+scale)*/
+ max = corr_v[add( t0_min, corr_idx )]; /*(Q15+(Q_new+shift-1)+scale)*/
move16();
t0 = t0_min; /*Q0*/
move16();
FOR( i = t0_min + 1; i <= t0_max; i++ )
{
+ Word16 corr_tmp;
+
+ corr_tmp = corr_v[add( corr_idx, i )];
BASOP_SATURATE_WARNING_OFF_EVS;
- if ( GE_16( corr[i], max ) )
+ if ( GE_16( corr_tmp, max ) )
{
t0 = i;
move16();
}
- max = s_max( max, corr[i] );
+ max = s_max( max, corr_tmp );
BASOP_SATURATE_WARNING_ON_EVS;
}
@@ -354,15 +357,16 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[], /*Q_new*/
}
assert( frac1 <= 0 && frac2 >= 0 && frac2 > frac1 );
+ corr_idx = add( corr_idx, t0 );
IF( EQ_16( pit_res_max, 6 ) )
{
- cor_max = E_GAIN_norm_corr_interpolate6_fx( &corr[t0], frac1 ); /*(Q15+(Q_new+shift-1)+scale)*/
- fraction = frac1; /*Q0*/
+ cor_max = E_GAIN_norm_corr_interpolate6_fx( &corr_v[corr_idx], frac1 ); /*(Q15+(Q_new+shift-1)+scale)*/
+ fraction = frac1; /*Q0*/
move16();
FOR( i = ( frac1 + step ); i <= frac2; i += step )
{
- temp = E_GAIN_norm_corr_interpolate6_fx( &corr[t0], i ); /*(Q15+(Q_new+shift-1)+scale)*/
+ temp = E_GAIN_norm_corr_interpolate6_fx( &corr_v[corr_idx], i ); /*(Q15+(Q_new+shift-1)+scale)*/
IF( GT_16( temp, cor_max ) )
{
cor_max = temp; /*(Q15+(Q_new+shift-1)+scale)*/
@@ -374,13 +378,13 @@ Word16 E_GAIN_closed_loop_search_fx( Word16 exc[], /*Q_new*/
}
ELSE
{
- cor_max = E_GAIN_norm_corr_interpolate_fx( &corr[t0], frac1 ); /*(Q15+(Q_new+shift-1)+scale)*/
- fraction = frac1; /*Q0*/
+ cor_max = E_GAIN_norm_corr_interpolate_fx( &corr_v[corr_idx], frac1 ); /*(Q15+(Q_new+shift-1)+scale)*/
+ fraction = frac1; /*Q0*/
move16();
FOR( i = ( frac1 + step ); i <= frac2; i += step )
{
- temp = E_GAIN_norm_corr_interpolate_fx( &corr[t0], i ); /*(Q15+(Q_new+shift-1)+scale)*/
+ temp = E_GAIN_norm_corr_interpolate_fx( &corr_v[corr_idx], i ); /*(Q15+(Q_new+shift-1)+scale)*/
IF( GT_16( temp, cor_max ) )
{
cor_max = temp; /*(Q15+(Q_new+shift-1)+scale)*/
diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c
index bfe50a588edf8c5f1fe5f0313c815d22fc7b6f77..5e1a43a8cde4dcc1150fd16238950a50c4731080 100644
--- a/lib_enc/enc_gen_voic_fx.c
+++ b/lib_enc/enc_gen_voic_fx.c
@@ -80,22 +80,23 @@ static void rem_offset(
void encod_gen_voic_fx(
Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech Q0*/
+ const Word16 speech_fx[], /* i : input speech Q0 / Qnew -1 */
const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
const Word16 *res_fx, /* i : residual signal Q_new*/
- Word16 *syn_fx, /* i/o: core synthesis Q_new*/
- Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/
- Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/
+ Word16 *syn_fx, /* i/o: core synthesis Qnew / Q_new - 1*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0 / Q_new*/
+ Word16 *exc2_fx, /* i/o: current enhanced excitation Q0 / Q_new*/
Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
Word16 *voice_factors_fx, /* o : voicing factors Q15*/
Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/
Word16 *unbits_fx, /* i/o: number of unused bits Q0*/
const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
- Word16 shift,
- Word16 Q_new )
+ const Word16 shift, /* i : Shift needed to obtain 12 bits vectors */
+ const Word16 Q_new /* i : Scaling factor */
+)
{
Word16 xn_fx[L_SUBFR]; /* Target vector for pitch search */
Word16 xn2_fx[L_SUBFR]; /* Target vector for codebook search */
@@ -109,8 +110,8 @@ void encod_gen_voic_fx(
move16();
Word16 voice_fac_fx; /* Voicing factor */
Word32 gain_code_fx = 0; /* Gain of code */
- move32();
Word16 gain_inov_fx = 0; /* inovation gain */
+ move32();
move16();
Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes*/
@@ -141,9 +142,9 @@ void encod_gen_voic_fx(
Word16 shift_wsp;
Word16 harm_flag_acelp;
Word16 lp_select, lp_flag, L_frame;
+ Word16 q_h1;
SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
- SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas;
LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
/*------------------------------------------------------------------*
@@ -162,7 +163,6 @@ void encod_gen_voic_fx(
L_frame = st_fx->L_frame;
move16();
-
IF( EQ_16( L_frame, L_FRAME ) )
{
T0_max_fx = PIT_MAX;
@@ -183,14 +183,19 @@ void encod_gen_voic_fx(
*unbits_fx = 0;
move16();
- p_Aw_fx = Aw_fx; /* Q12 */
- p_Aq_fx = Aq_fx; /* Q12 */
- pt_pitch_fx = pitch_buf_fx; /* Q6 */
+ p_Aw_fx = Aw_fx; /*Q12*/
+ p_Aq_fx = Aq_fx; /*Q12*/
+ pt_pitch_fx = pitch_buf_fx; /*Q6*/
gain_preQ_fx = 0;
move16();
set16_fx( code_preQ_fx, 0, L_SUBFR );
shift_wsp = add( Q_new, shift );
+ test();
+ if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && NE_32( st_fx->element_mode, EVS_MONO ) )
+ {
+ shift_wsp = sub( shift_wsp, 1 );
+ }
/* set and write harmonicity flag */
harm_flag_acelp = 0;
@@ -224,386 +229,39 @@ void encod_gen_voic_fx(
Copy( &res_fx[i_subfr_fx], &exc_fx[i_subfr_fx], L_SUBFR ); /*Q_new*/
- find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx,
- res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx );
-
- Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 ); /*Q11*/
- Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution Q(14+shift)*/
-
- /* scaling of xn[] to limit dynamic at 12 bits */
- Scale_sig( xn_fx, L_SUBFR, shift );
-
- /*----------------------------------------------------------------*
- * Close-loop pitch search and quantization
- *----------------------------------------------------------------*/
-
- *pt_pitch_fx = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, st_fx->core_brate, 0, L_frame, st_fx->coder_type, &pitch_limit_flag, i_subfr_fx, exc_fx,
- L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, st_fx->element_mode, Q_new ); /* Q6 */
-
-
- tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx );
-
- /*-----------------------------------------------------------------*
- * Find adaptive exitation
- *-----------------------------------------------------------------*/
-
- pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
-
- /*-----------------------------------------------------------------*
- * Gain clipping test to avoid unstable synthesis on frame erasure
- *-----------------------------------------------------------------*/
-
- clip_gain_fx = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr_fx, st_fx->coder_type, xn_fx, st_fx->clip_var_fx, sub( shift_wsp, 1 ) );
-
- if ( EQ_16( st_fx->coder_type, INACTIVE ) )
+ IF( st_fx->element_mode == EVS_MONO )
{
- /* in case of AVQ inactive, limit the gain to 0.65 */
- clip_gain_fx = 2;
- move16();
- }
+ find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx,
+ res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx );
- /*-----------------------------------------------------------------*
- * LP filtering of the adaptive excitation, codebook target computation
- *-----------------------------------------------------------------*/
+ Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 ); /*Q11*/
+ Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution Q(14+shift)*/
- lp_select = lp_filt_exc_enc_fx( MODE1, st_fx->coder_type, i_subfr_fx, exc_fx, h1_fx,
- xn_fx, y1_fx, xn2_fx, L_SUBFR, L_frame, g_corr_fx, clip_gain_fx, &gain_pit_fx, &lp_flag );
-
- IF( EQ_16( lp_flag, NORMAL_OPERATION ) )
- {
- push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 );
- }
-
- /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/
- hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/
-
- /*-----------------------------------------------------------------*
- * Transform domain contribution encoding - active frames
- *-----------------------------------------------------------------*/
-
- test();
- IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && NE_16( st_fx->coder_type, INACTIVE ) )
- {
- transf_cdbk_enc_fx( st_fx, harm_flag_acelp, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx,
- xn2_fx, y1_fx, y2_fx, Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift );
- }
-
- /*-----------------------------------------------------------------*
- * Innovation encoding
- *-----------------------------------------------------------------*/
-
- inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame,
- st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx,
- gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift );
-
- /*-----------------------------------------------------------------*
- * Gain encoding
- *-----------------------------------------------------------------*/
-
- IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
- {
- gain_enc_lbr_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->coder_type, i_subfr_fx, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx,
- &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR,
- st_fx->element_mode );
- }
- ELSE IF( GT_32( st_fx->core_brate, ACELP_32k ) )
- {
- gain_enc_SQ_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr_fx, xn_fx, y1_fx, y2_fx, code_fx, Es_pred_fx,
- &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx, shift_wsp );
+ /* scaling of xn[] to limit dynamic at 12 bits */
+ Scale_sig( xn_fx, L_SUBFR, shift );
}
ELSE
{
- gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, i_subfr_fx, -1, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx, Es_pred_fx,
- &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx );
- }
- IF( st_fx->Opt_SC_VBR )
- {
- if ( EQ_16( hSC_VBR->last_ppp_mode, 1 ) )
- {
- /* SC-VBR - all other st->clip_var values will be updated even in a PPP frame */
- st_fx->clip_var_fx[1] = gain_pit_fx; /*Q14*/
- move16();
- }
- }
- gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit_fx, st_fx->clip_var_fx );
-
- Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/
- gcode16 = round_fx_sat( Lgcode ); /*Q0*/
- hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, Lgcode, &voice_fac_fx, shift ); /* Q15 */
- move16();
-
- /*-----------------------------------------------------------------*
- * Transform domain contribution encoding - inactive frames
- *-----------------------------------------------------------------*/
+ find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx,
+ res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx );
- test();
- IF( GE_32( st_fx->core_brate, MAX_GSC_INACTIVE_BRATE ) && EQ_16( st_fx->coder_type, INACTIVE ) )
- {
- transf_cdbk_enc_fx( st_fx, 0, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx,
- Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift );
- }
-
- /*-----------------------------------------------------------------*
- * Update memory of the weighting filter
- *-----------------------------------------------------------------*/
+ q_h1 = sub( 14, norm_s( h1_fx[0] ) );
+ Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/
+ Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/
- /* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */
- Ltmp = L_mult( gcode16, y2_fx[L_SUBFR - 1] ); /*Q10*/
- Ltmp = L_shl( Ltmp, add( 5, shift ) ); /*Q15+shift*/
- Ltmp = L_negate( Ltmp );
- Ltmp = L_mac( Ltmp, xn_fx[L_SUBFR - 1], 16384 /*Q14*/ ); /* Q_new-1+shift+14+1 */
- Ltmp = L_msu( Ltmp, y1_fx[L_SUBFR - 1], gain_pit_fx /*Q14*/ ); /* Q_new-1+shift+14+1 */
- Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* 15 + Q_new */
- hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
- move16();
- IF( gain_preQ_fx != 0 )
- {
- tmp1_fx = add( 16 - ( 2 + Q_AVQ_OUT_DEC + 1 ), Q_new );
-
- FOR( i = 0; i < L_SUBFR; i++ )
- {
- /* Contribution from AVQ layer */
- Ltmp1 = L_mult_sat( gain_preQ_fx, code_preQ_fx[i] ); /* Q2 + Q6 -> Q9*/
- Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx ); /* Q16 + Q_exc */
-
- /* Compute exc2 */
- Ltmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); /* Q16 */
- exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); /* Q0 */
- move16();
-
- /* code in Q9, gain_pit in Q14 */
- Ltmp = L_mult( gcode16, code_fx[i] ); /* Q10 */
- Ltmp = L_shl( Ltmp, 5 ); /* Q15 */
- Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /* Q15 */
- Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16*/
- exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); /* Q0 */
- }
- }
- ELSE
- {
- /*-----------------------------------------------------------------*
- * Construct adaptive part of the excitation
- * Save the non-enhanced excitation for FEC_exc
- *-----------------------------------------------------------------*/
+ /* scaling of xn[] to limit dynamic at 12 bits */
+ Scale_sig( xn_fx, L_SUBFR, shift );
- FOR( i = 0; i < L_SUBFR; i++ )
+ test();
+ test();
+ IF( Es_pred_fx < 0 && LE_16( i_subfr_fx, L_SUBFR ) && NE_16( st_fx->last_core, ACELP_CORE ) )
{
- /* code in Q9, gain_pit in Q14 */
- Ltmp = L_mult( gcode16, code_fx[i] ); /* Q10 */
- Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 */
- Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /* Q15 */
- Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16*/
- exc_fx[i + i_subfr_fx] = round_fx_sat( Ltmp ); /* Q0 */
+ /* During core transition, when the temporal correlation is non existent */
+ rem_offset( xn_fx, xn_fx, L_SUBFR );
+ rem_offset( cn_fx, cn_fx, L_SUBFR );
}
}
- /*-----------------------------------------------------------------*
- * Prepare TBE excitation
- *-----------------------------------------------------------------*/
-
- prep_tbe_exc_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx,
- &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q10, Q_new,
- T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate,
- st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
-
- /*-----------------------------------------------------------------*
- * Synthesize speech to update mem_syn[].
- * Update A(z) filters
- *-----------------------------------------------------------------*/
-
- Syn_filt_s( 1, p_Aq_fx, M, &exc_fx[i_subfr_fx], &syn_fx[i_subfr_fx], L_SUBFR, hLPDmem->mem_syn, 1 );
-
- p_Aw_fx += ( M + 1 );
- p_Aq_fx += ( M + 1 );
- pt_pitch_fx++;
- }
-
- /* write reserved bits */
- WHILE( unbits_PI_fx > 0 )
- {
- i = s_min( unbits_PI_fx, 16 );
- push_indice( hBstr, IND_UNUSED, 0, i );
- unbits_PI_fx -= i;
- }
- IF( st_fx->Opt_SC_VBR )
- {
- /* SC-VBR */
- hSC_VBR->prev_ppp_gain_pit_fx = gain_pit_fx; /* Q14 */
- move16();
- hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */
- move16();
- }
-
- return;
-}
-
-
-void encod_gen_voic_ivas_fx(
- Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech Qnew -1 */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
- const Word16 *res_fx, /* i : residual signal Q_new*/
- Word16 *syn_fx, /* i/o: core synthesis Q_new - 1*/
- Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
- Word16 *exc2_fx, /* i/o: current enhanced excitation Q_new*/
- Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
- Word16 *voice_factors_fx, /* o : voicing factors Q15*/
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/
- Word16 *unbits_fx, /* i/o: number of unused bits Q0*/
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
- const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
- Word16 shift,
- Word16 Q_new )
-{
- Word16 xn_fx[L_SUBFR]; /* Target vector for pitch search */
- Word16 xn2_fx[L_SUBFR]; /* Target vector for codebook search */
- Word16 cn_fx[L_SUBFR]; /* Target vector in residual domain */
- Word16 h1_fx[L_SUBFR + ( M + 1 )]; /* Impulse response vector */
- Word16 h2_fx[L_SUBFR + ( M + 1 )]; /* Impulse response vector */
- Word16 code_fx[L_SUBFR]; /* Fixed codebook excitation */
- Word16 y1_fx[L_SUBFR] = { 0 }; /* Filtered adaptive excitation */
- Word16 y2_fx[L_SUBFR]; /* Filtered algebraic excitation */
- Word16 gain_pit_fx = 0; /* Pitch gain */
- move16();
- Word16 voice_fac_fx; /* Voicing factor */
- Word32 gain_code_fx = 0; /* Gain of code */
- Word16 gain_inov_fx = 0; /* inovation gain */
- move32();
- move16();
- Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
- Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes*/
- Word16 i, i_subfr_fx; /* tmp variables */
- Word16 T0_fx = 0, T0_frac_fx = 0; /* close loop integer pitch and fractional part */
- move16();
- move16();
- Word16 T0_min_fx, T0_max_fx; /* pitch variables */
- Word16 *pt_pitch_fx; /* pointer to floating pitch buffer */
- Word16 g_corr_fx[10]; /* ACELP correl, values + gain pitch */
- Word16 clip_gain_fx; /* LSF clip gain */
- const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector*/
- Word16 error_fx = 0;
- Word16 gain_preQ_fx = 0; /* Gain of prequantizer excitation */
- move16();
- move16();
- Word16 code_preQ_fx[L_SUBFR]; /* Prequantizer excitation */
- Word16 unbits_PI_fx = 0; /* number of unused bits for PI */
- Word32 norm_gain_code_fx = 0;
- move16();
- move32();
- Word16 pitch_limit_flag;
- Word16 gcode16;
- Word32 Ltmp;
- Word32 Ltmp1;
- Word32 Lgcode;
- Word16 tmp1_fx;
- Word16 shift_wsp;
- Word16 harm_flag_acelp;
- Word16 lp_select, lp_flag, L_frame;
- Word16 q_h1;
- SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
- BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
- LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
-
- /*------------------------------------------------------------------*
- * Initializations
- *------------------------------------------------------------------*/
-
- gain_pit_fx = 0;
- move16();
- gain_code_fx = L_deposit_l( 0 );
- gain_preQ_fx = 0;
- move16();
- unbits_PI_fx = 0;
- move16();
- error_fx = 0;
- move16();
- L_frame = st_fx->L_frame;
- move16();
-
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- T0_max_fx = PIT_MAX;
- move16();
- T0_min_fx = PIT_MIN;
- move16();
- }
- ELSE /* L_frame == L_FRAME16k */
- {
- T0_max_fx = PIT16k_MAX;
- move16();
- T0_min_fx = PIT16k_MIN;
- move16();
- }
- lp_flag = st_fx->acelp_cfg.ltf_mode;
- move16();
-
- *unbits_fx = 0;
- move16();
-
- p_Aw_fx = Aw_fx; /*Q12*/
- p_Aq_fx = Aq_fx; /*Q12*/
- pt_pitch_fx = pitch_buf_fx; /*Q6*/
- gain_preQ_fx = 0;
- move16();
- set16_fx( code_preQ_fx, 0, L_SUBFR );
-
- shift_wsp = add( Q_new, shift );
- if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) )
- {
- shift_wsp = sub( shift_wsp, 1 );
- }
-
- /* set and write harmonicity flag */
- harm_flag_acelp = 0;
- move16();
-
- test();
- test();
- IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && EQ_16( st_fx->coder_type, GENERIC ) )
- {
- if ( GT_16( st_fx->last_harm_flag_acelp, 2 ) )
- {
- harm_flag_acelp = 1;
- move16();
- }
-
- push_indice( hBstr, IND_HARM_FLAG_ACELP, harm_flag_acelp, 1 );
- }
-
- /*------------------------------------------------------------------*
- * ACELP subframe loop
- *------------------------------------------------------------------*/
-
- FOR( i_subfr_fx = 0; i_subfr_fx < L_frame; i_subfr_fx += L_SUBFR )
- {
-
- /*----------------------------------------------------------------*
- * Find the the excitation search target "xn" and innovation
- * target in residual domain "cn"
- * Compute impulse response, h1[], of weighted synthesis filter
- *----------------------------------------------------------------*/
-
- Copy( &res_fx[i_subfr_fx], &exc_fx[i_subfr_fx], L_SUBFR ); /*Q_new*/
-
- find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx,
- res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx );
-
- q_h1 = sub( 14, norm_s( h1_fx[0] ) );
- Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/
- Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/
- /* scaling of xn[] to limit dynamic at 12 bits */
- Scale_sig( xn_fx, L_SUBFR, shift );
- test();
- test();
- IF( Es_pred_fx < 0 && LE_16( i_subfr_fx, L_SUBFR ) && NE_16( st_fx->last_core, ACELP_CORE ) )
- {
- /* During core transition, when the temporal correlation is non existent */
- rem_offset( xn_fx, xn_fx, L_SUBFR );
- rem_offset( cn_fx, cn_fx, L_SUBFR );
- }
-
/*----------------------------------------------------------------*
* Close-loop pitch search and quantization
*----------------------------------------------------------------*/
@@ -612,13 +270,20 @@ void encod_gen_voic_ivas_fx(
L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, st_fx->element_mode, Q_new ); /* Q6 */
move16();
- tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag );
+ tbe_celp_exc_fx( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag );
/*-----------------------------------------------------------------*
* Find adaptive exitation
*-----------------------------------------------------------------*/
- pred_lt4_ivas_fx( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
+ ELSE
+ {
+ pred_lt4_ivas_fx( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
/*-----------------------------------------------------------------*
* Gain clipping test to avoid unstable synthesis on frame erasure
@@ -645,6 +310,9 @@ void encod_gen_voic_ivas_fx(
push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 );
}
+ /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/
+ st_fx->hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, st_fx->hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/
+
/*-----------------------------------------------------------------*
* Transform domain contribution encoding - active frames
*-----------------------------------------------------------------*/
@@ -652,17 +320,16 @@ void encod_gen_voic_ivas_fx(
test();
IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && NE_16( st_fx->coder_type, INACTIVE ) )
{
- transf_cdbk_enc_ivas_fx( st_fx, harm_flag_acelp, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx,
- xn2_fx, y1_fx, y2_fx, Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift );
+ transf_cdbk_enc_fx( st_fx, harm_flag_acelp, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx,
+ xn2_fx, y1_fx, y2_fx, Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift );
}
/*-----------------------------------------------------------------*
* Innovation encoding
*-----------------------------------------------------------------*/
- inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame,
- st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx,
- gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift, Q_new );
+ inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx,
+ gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift, Q_new );
/*-----------------------------------------------------------------*
* Gain encoding
@@ -698,7 +365,14 @@ void encod_gen_voic_ivas_fx(
Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/
gcode16 = round_fx_sat( Lgcode );
- hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, Q_new, L_SUBFR, 0 ); /* Q15 */
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, Lgcode, &voice_fac_fx, shift ); /* Q15 */
+ }
+ ELSE
+ {
+ hLPDmem->tilt_code = est_tilt_fx( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, Q_new, L_SUBFR ); /* Q15 */
+ }
move16();
/*-----------------------------------------------------------------*
@@ -708,38 +382,53 @@ void encod_gen_voic_ivas_fx(
test();
IF( !st_fx->inactive_coder_type_flag && EQ_16( st_fx->coder_type, INACTIVE ) )
{
- transf_cdbk_enc_ivas_fx( st_fx, 0, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx,
- Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift );
+ transf_cdbk_enc_fx( st_fx, 0, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx,
+ Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift );
}
/*-----------------------------------------------------------------*
* Update memory of the weighting filter
*-----------------------------------------------------------------*/
- /*At this point
- xn has to be in Qnew
- yn has to be in Qnew
- y2_fx has to be in Q9
- gcode16 in Q_new
- gain_pit_fx in Q14
- */
- Scale_sig( xn_fx, L_SUBFR, 1 );
- Scale_sig( y1_fx, L_SUBFR, 1 );
- /* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */
- Ltmp = L_mult0( gcode16, y2_fx[L_SUBFR - 1] );
- Ltmp = L_shl( Ltmp, add( 5, shift ) );
- Ltmp = L_negate( Ltmp );
- Word32 Ltmp2 = L_mult0( xn_fx[L_SUBFR - 1], 16384 );
- Ltmp = L_add( Ltmp, Ltmp2 );
- Word32 Ltmp3 = L_mult0( y1_fx[L_SUBFR - 1], gain_pit_fx );
- Ltmp = L_sub( Ltmp, Ltmp3 );
-
- /*Ltmp is in Q14 + Qnew here
- We need memWo in Qnew -1 */
-
- Ltmp = L_shl( Ltmp, sub( 1, shift ) ); // Q14 + Qnew + 1
- hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
- move16();
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ /* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */
+ Ltmp = L_mult( gcode16, y2_fx[L_SUBFR - 1] ); /*Q10*/
+ Ltmp = L_shl( Ltmp, add( 5, shift ) ); /*Q15+shift*/
+ Ltmp = L_negate( Ltmp );
+ Ltmp = L_mac( Ltmp, xn_fx[L_SUBFR - 1], 16384 /*Q14*/ ); /* Q_new-1+shift+14+1 */
+ Ltmp = L_msu( Ltmp, y1_fx[L_SUBFR - 1], gain_pit_fx /*Q14*/ ); /* Q_new-1+shift+14+1 */
+ Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* 15 + Q_new */
+ hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
+ }
+ ELSE
+ {
+ /*At this point
+ xn has to be in Qnew
+ yn has to be in Qnew
+ y2_fx has to be in Q9
+ gcode16 in Q_new
+ gain_pit_fx in Q14
+ */
+ Scale_sig( xn_fx, L_SUBFR, 1 );
+ Scale_sig( y1_fx, L_SUBFR, 1 );
+ /* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */
+ Ltmp = L_mult0( gcode16, y2_fx[L_SUBFR - 1] );
+ Ltmp = L_shl( Ltmp, add( 5, shift ) );
+ Ltmp = L_negate( Ltmp );
+ Word32 Ltmp2 = L_mult0( xn_fx[L_SUBFR - 1], 16384 );
+ Ltmp = L_add( Ltmp, Ltmp2 );
+ Word32 Ltmp3 = L_mult0( y1_fx[L_SUBFR - 1], gain_pit_fx );
+ Ltmp = L_sub( Ltmp, Ltmp3 );
+
+ /*Ltmp is in Q14 + Qnew here
+ We need memWo in Qnew -1 */
+
+ Ltmp = L_shl( Ltmp, sub( 1, shift ) ); // Q14 + Qnew + 1
+ hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
+ move16();
+ }
+
IF( gain_preQ_fx != 0 )
{
tmp1_fx = add( 16 - ( 2 + Q_AVQ_OUT_DEC + 1 ), Q_new );
@@ -756,10 +445,10 @@ void encod_gen_voic_ivas_fx(
move16();
/* code in Q9, gain_pit in Q14 */
- Ltmp = L_mult( gcode16, code_fx[i] ); /*Qnew + 9 + 1 */
- Ltmp = L_shl( Ltmp, 5 ); /*Qnew + 9+ 1+5 */
- Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Qnew + 14 + 1*/
- Ltmp = L_shl_sat( Ltmp, 1 ); /*Qnew + 14 + 1 +1 */ /* saturation can occur here Q16*/
+ Ltmp = L_mult( gcode16, code_fx[i] ); /*Q10 / Qnew + 9 + 1 */
+ Ltmp = L_shl( Ltmp, 5 ); /*Q15 / Qnew + 9+ 1+5 */
+ Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Q15 / Qnew + 14 + 1*/
+ Ltmp = L_shl_sat( Ltmp, 1 ); /*Q15 / Qnew + 14 + 1 +1 */
exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) );
move16();
}
@@ -775,10 +464,10 @@ void encod_gen_voic_ivas_fx(
{
/* code in Q9, gain_pit in Q14 */
/*gcode16 in Qnew*/
- Ltmp = L_mult( gcode16, code_fx[i] ); /*Qnew + 9 + 1 */
- Ltmp = L_shl_sat( Ltmp, 5 ); /*Qnew + 9+ 1+5 */
- Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Qnew + 14 + 1*/
- Ltmp = L_shl_sat( Ltmp, 1 ); /*Qnew + 14 + 1 +1 */
+ Ltmp = L_mult( gcode16, code_fx[i] ); /*Q10 / Qnew + 9 + 1 */
+ Ltmp = L_shl_sat( Ltmp, 5 ); /*Q15 / Qnew + 9+ 1+5 */
+ Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Q15 / Qnew + 14 + 1*/
+ Ltmp = L_shl_sat( Ltmp, 1 ); /*Q15 / Qnew + 14 + 1 +1 */
exc_fx[i + i_subfr_fx] = round_fx_sat( Ltmp );
}
}
@@ -797,7 +486,14 @@ void encod_gen_voic_ivas_fx(
* Update A(z) filters
*-----------------------------------------------------------------*/
- syn_filt_fx( 1, p_Aq_fx, M, &exc_fx[i_subfr_fx], &syn_fx[i_subfr_fx], L_SUBFR, hLPDmem->mem_syn, 1 );
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ Syn_filt_s( 1, p_Aq_fx, M, &exc_fx[i_subfr_fx], &syn_fx[i_subfr_fx], L_SUBFR, hLPDmem->mem_syn, 1 );
+ }
+ ELSE
+ {
+ syn_filt_fx( 1, p_Aq_fx, M, &exc_fx[i_subfr_fx], &syn_fx[i_subfr_fx], L_SUBFR, hLPDmem->mem_syn, 1 );
+ }
p_Aw_fx += ( M + 1 );
p_Aq_fx += ( M + 1 );
@@ -811,6 +507,7 @@ void encod_gen_voic_ivas_fx(
push_indice( hBstr, IND_UNUSED, 0, i );
unbits_PI_fx -= i;
}
+
IF( st_fx->Opt_SC_VBR )
{
/* SC-VBR */
diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c
index 82296aa4ad975fb14cbef71e8efb3c2410ae8f78..24bf48838bdb9584f095f79c2f889e114930026f 100644
--- a/lib_enc/enc_higher_acelp_fx.c
+++ b/lib_enc/enc_higher_acelp_fx.c
@@ -22,6 +22,7 @@ static void find_cn_fx( const Word16 xn[], const Word16 Ap[], const Word16 *p_Aq
*-----------------------------------------------------------------*/
#define Q_MINUS 4
+
void transf_cdbk_enc_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/
@@ -74,7 +75,7 @@ void transf_cdbk_enc_fx(
Nsv = 8;
move16();
- nBits = st_fx->acelp_cfg.AVQ_cdk_bits[shr( i_subfr, 6 )]; /* Q0 */
+ nBits = st_fx->acelp_cfg.AVQ_cdk_bits[i_subfr >> 6]; /* Q0 */
move16();
/* increase # of AVQ allocated bits by unused bits from the previous subframe */
@@ -99,7 +100,6 @@ void transf_cdbk_enc_fx(
Ltmp = L_msu( Ltmp, y1[i], *gain_pit ); /* Q_new + 14 + shift */
Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */
x_tran[i] = round_fx_sat( Ltmp ); /*Q_new-1 */
- move16();
}
find_cn_fx( x_tran, Ap, p_Aq, x_in );
}
@@ -136,362 +136,15 @@ void transf_cdbk_enc_fx(
* Split algebraic vector quantizer based on RE8 lattice
*--------------------------------------------------------------*/
- AVQ_cod_fx( x_tran, x_norm, nBits, Nsv, 0 );
-
- /*--------------------------------------------------------------*
- * Find prequantizer excitation gain
- * Quantize the gain
- *--------------------------------------------------------------*/
-
- L_corr = L_deposit_l( 0 );
- L_ener = L_deposit_l( 0 );
- FOR( i = 0; i < Nsv * 8; i++ )
- {
- /*fcorr += fx_tran[i]*(float)ix_norm[i];*/
- /*fener += (float)ix_norm[i]*(float)ix_norm[i];*/
- stmp = shl_sat( x_norm[i], Q_AVQ_OUT );
- L_corr = L_mac_sat( L_corr, x_tran[i], stmp );
- L_ener = L_mac_sat( L_ener, stmp, stmp );
- }
- L_ener = L_max( L_ener, 1 );
-
- /* No negative gains allowed in the quantizer*/
- L_corr = L_max( L_corr, 0 );
-
- e_corr = norm_l( L_corr );
- m_corr = extract_h( L_shl( L_corr, e_corr ) );
- e_corr = sub( 30, add( e_corr, sub( Qdct, Q_AVQ_OUT ) ) );
- e_ener = norm_l( L_ener );
- m_ener = extract_h( L_shl( L_ener, e_ener ) );
- e_ener = sub( 30, e_ener );
-
- IF( GT_16( m_corr, m_ener ) )
- {
- m_corr = shr( m_corr, 1 );
- e_corr = add( e_corr, 1 );
- }
- m_corr = div_s( m_corr, m_ener ); /* e_corr - e_ener */
- e_corr = sub( e_corr, e_ener );
- Ltmp = L_shl_sat( m_corr, s_min( add( e_corr, 1 ), 31 ) ); /* Lgain in Q16 */
- IF( EQ_16( st_fx->coder_type, INACTIVE ) )
- {
- Ltmp1 = L_max( gain_code, 1 );
- e_den = norm_l( Ltmp1 );
- m_den = extract_h( L_shl_sat( Ltmp1, e_den ) );
- /* ensure m_corr < m_den */
- test();
- IF( m_corr > 0 && m_den > 0 )
- {
- m_corr = div_s( 16384, m_den );
- e_corr = sub( 14 + 4, e_den );
- Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /*Q12*/
- stmp = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12 */
- }
- ELSE
- {
- stmp = 0;
- move16();
- }
- IF( GT_32( st_fx->core_brate, 56000 ) )
- {
- index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_64k_Q12, G_AVQ_DELTA_INACT_64k_Q12 >> 1, ( 1 << G_AVQ_BITS ) ); /* Q0 */
- }
- ELSE IF( GT_32( st_fx->core_brate, 42000 ) )
- {
- index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_48k_Q12, G_AVQ_DELTA_INACT_48k_Q12 >> 1, ( 1 << G_AVQ_BITS ) ); /* Q0 */
- }
- ELSE
- {
- index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_Q12, G_AVQ_DELTA_INACT_Q12 >> 1, ( 1 << G_AVQ_BITS ) ); /* Q0 */
- }
- Ltmp = Mult_32_16( gain_code, stmp ); /* Q16 * Q12 - 15 -> Q13*/
- Ltmp = L_shl_sat( Ltmp, 5 ); /* Q13 -> Q18*/
- *gain_preQ = round_fx_sat( Ltmp ); /* Q2*/
- }
- ELSE
- {
- IF( Es_pred < 0 )
- {
- Es_pred_loc = shr( negate( Es_pred ), 2 ); /* Q8 */
- }
- ELSE
- {
- Es_pred_loc = Es_pred; /* Q8 */
- move16();
- }
-
- e_den = norm_s( Es_pred_loc );
- m_den = shl( Es_pred_loc, e_den );
- /* ensure m_corr < m_den */
- test();
- IF( m_corr > 0 && m_den > 0 )
- {
- m_corr = div_s( 16384, m_den ); /* 14 - 8 - e_den */
- e_corr = sub( 14 - 8, e_den );
- Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /* Q18 */
- }
- ELSE
- {
- Ltmp = L_deposit_l( 0 );
- }
- test();
- IF( LE_32( st_fx->core_brate, 42000 ) && GT_32( st_fx->core_brate, ACELP_24k40 ) )
- {
- index = gain_quant_fx( &Ltmp, &stmp, LG10_G_AVQ_MIN_32kbps_Q14, LG10_G_AVQ_MAX_Q13, G_AVQ_BITS, &e_den ); /* Q0 */
- }
- ELSE
- {
- index = gain_quant_fx( &Ltmp, &stmp, LG10_G_AVQ_MIN_Q14, LG10_G_AVQ_MAX_Q13, G_AVQ_BITS, &e_den ); /* Q0 */
- }
- Ltmp = L_mult( stmp, Es_pred_loc ); /* Q0*Q8 -> Q9*/
- Ltmp = L_shl( Ltmp, add( e_den, 9 ) ); /* Q18*/
- *gain_preQ = round_fx( Ltmp ); /* Q2*/
- }
- push_indice( st_fx->hBstr, IND_AVQ_GAIN, index, G_AVQ_BITS );
-
- /*--------------------------------------------------------------*
- * Encode and multiplex subvectors into bit-stream
- *--------------------------------------------------------------*/
-
- trgtSvPos = Nsv - 1;
- move16();
- test();
- test();
- test();
- test();
- test();
- IF( avq_bit_sFlag && GT_16( nBits, 85 ) && !harm_flag_acelp && ( EQ_16( st_fx->coder_type, GENERIC ) || EQ_16( st_fx->coder_type, TRANSITION ) || EQ_16( st_fx->coder_type, INACTIVE ) ) )
+ IF( st_fx->element_mode == EVS_MONO )
{
- trgtSvPos = 2;
- avq_bit_sFlag = 2;
- move16();
- move16();
- }
-
- AVQ_encmux_fx( st_fx->hBstr, -1, x_norm, &nBits, Nsv, nq, avq_bit_sFlag, trgtSvPos );
-
- /* save # of AVQ unused bits for next subframe */
- *unbits = nBits; /* Q0 */
- move16();
-
- /* at the last subframe, write AVQ unused bits */
- test();
- test();
- IF( EQ_16( i_subfr, 4 * L_SUBFR ) && NE_16( st_fx->extl, SWB_BWE_HIGHRATE ) && NE_16( st_fx->extl, FB_BWE_HIGHRATE ) )
- {
- WHILE( *unbits > 0 )
- {
- i = s_min( *unbits, 16 );
- push_indice( st_fx->hBstr, IND_UNUSED, 0, i );
- *unbits -= i;
- }
- }
-
- /*--------------------------------------------------------------*
- * DCT transform
- *--------------------------------------------------------------*/
-
- FOR( i = 0; i < Nsv * WIDTH_BAND; i++ )
- {
- x_tran[i] = shl_sat( x_norm[i], Q_AVQ_OUT_DEC );
- move16();
- }
-
- test();
- test();
- test();
- IF( NE_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && !harm_flag_acelp )
- {
- Copy( x_tran, code_preQ, L_SUBFR ); /* Q_AVQ_OUT_DEC */
+ AVQ_cod_fx( x_tran, x_norm, nBits, Nsv, 0 );
}
ELSE
{
- Qdct = 0;
- move16();
- edct2_fx( L_SUBFR, 1, x_tran, out32, &Qdct, ip_edct2_64, w_edct2_64_fx );
- /*qdct = sub(Q_AVQ_OUT_DEC,qdct+Q_AVQ_OUT_DEC);*/
- Qdct = negate( Qdct );
- Copy_Scale_sig_32_16( out32, code_preQ, L_SUBFR, Qdct ); /* Output in Q_AVQ_OUT_DEC */
- /*qdct = Q_AVQ_OUT_DEC;*/
+ AVQ_cod_fx( x_tran, x_norm, nBits, Nsv, Qdct );
}
- /*--------------------------------------------------------------*
- * Preemphasise
- *--------------------------------------------------------------*/
-
- /* in extreme cases at subframe boundaries, lower the preemphasis memory to avoid a saturation */
- test();
- if ( ( nq[7] != 0 ) && ( GT_16( sub( st_fx->last_nq_preQ, nq[0] ), 7 ) ) )
- {
- /* *mem_preemp /= 16; */
- st_fx->mem_preemp_preQ_fx = shr( st_fx->mem_preemp_preQ_fx, 4 );
- move16();
- }
- st_fx->last_nq_preQ = nq[7];
- move16();
-
- PREEMPH_FX( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &( st_fx->mem_preemp_preQ_fx ) );
-
- /*--------------------------------------------------------------*
- * For inactive segments
- * - Zero-memory filtered pre-filter excitation
- * - Update of targets and gain_pit
- * For inactive segments
- * - Update xn[L_subfr-1] for updating the memory of the weighting filter
- *--------------------------------------------------------------*/
-
- IF( EQ_16( st_fx->coder_type, INACTIVE ) )
- {
- /*ftemp = fcode_preQ[0] *fh1[L_SUBFR-1];*/
- Ltmp = L_mult( code_preQ[0], h1[L_SUBFR - 1] ); /*1+14+shift + Q_AVQ_OUT */
- FOR( i = 1; i < L_SUBFR; i++ )
- {
- /*ftemp += fcode_preQ[i] * fh1[L_SUBFR-1-i];*/
- Ltmp = L_mac( Ltmp, code_preQ[i], h1[L_SUBFR - 1 - i] );
- }
- /*fxn[L_SUBFR-1] -= *fgain_preQ * ftemp;*/
- Ltmp = L_shr( Mult_32_16( Ltmp, *gain_preQ ), sub( add( Q_AVQ_OUT_DEC, 2 ), Q_new ) ); /* (2 + 1 + 14 +shift+Q_AVQ_OUT)-(Q_AVQ_OUT+2-Q_new) = 15 + Q_new + shift */
- xn[L_SUBFR - 1] = round_fx( L_sub( L_mult( xn[L_SUBFR - 1], 32767 ), Ltmp ) ); /* -> Q_new + shift -1 */
- }
- ELSE
- {
- conv_fx( code_preQ, h1, x_tran, L_SUBFR );
- updt_tar_HR_fx( cn, cn, code_preQ, *gain_preQ, sub( Q_new, add( -15 + 2, Q_AVQ_OUT_DEC ) ), L_SUBFR );
-
- updt_tar_HR_fx( xn, xn, x_tran, *gain_preQ, sub( Q_new, add( -15 + 2, Q_AVQ_OUT_DEC ) ), L_SUBFR );
- *gain_pit = corr_xy1_fx( xn, y1, g_corr, L_SUBFR, 0, &Overflow ); /* Q14 */
- /* clip gain if necessary to avoid problems at decoder */
- test();
- if ( EQ_16( clip_gain, 1 ) && GT_16( *gain_pit, 15565 ) )
- {
- *gain_pit = 15565; /* 0.95 in Q15 */
- move16();
- }
- updt_tar_fx( xn, xn2, y1, *gain_pit, L_SUBFR );
- }
-
- st_fx->use_acelp_preq = 1;
- move16();
-
- return;
-}
-
-
-void transf_cdbk_enc_ivas_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/
- const Word16 i_subfr, /* i : subframe index Q0*/
- Word16 cn[], /* i/o: target vector in residual domain Q_new*/
- Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/
- const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/
- const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/
- const Word16 h1[], /* i : weighted filter input response Q15*/
- Word16 xn[], /* i/o: target vector Q_new + shift -1*/
- Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/
- Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/
- const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/
- const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/
- Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/
- const Word32 gain_code, /* i : innovative excitation gain Q16*/
- Word16 g_corr[], /* o : ACELP correlation values Q15*/
- const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/
- Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/
- Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/
- Word16 *unbits, /* o : number of AVQ unused bits Q0*/
- const Word16 Q_new, /* i : Current frame scaling */
- const Word16 shift /* i : shifting applied to y1, xn,... */
-)
-{
- Word16 i, index, nBits, Nsv, Es_pred_loc;
- Word16 x_in[L_SUBFR], x_tran[L_SUBFR], gcode16, stmp;
- Word16 e_corr, m_corr, e_ener, m_ener, m_den, e_den;
- Word16 x_norm[L_SUBFR + L_SUBFR / WIDTH_BAND];
- Word32 L_corr, L_ener, Ltmp, Ltmp1;
- Word16 nq[L_SUBFR / WIDTH_BAND];
- Word32 out32[L_SUBFR];
- Word16 Qdct;
- Word16 avq_bit_sFlag;
- Word16 trgtSvPos;
- Flag Overflow = 0;
- move32();
-
- avq_bit_sFlag = 0;
- move16();
- if ( st_fx->element_mode > EVS_MONO )
- {
- avq_bit_sFlag = 1;
- move16();
- }
-
- /*--------------------------------------------------------------*
- * Set bit-allocation
- *--------------------------------------------------------------*/
-
- Nsv = 8;
- move16();
- nBits = st_fx->acelp_cfg.AVQ_cdk_bits[i_subfr >> 6]; /* Q0 */
- move16();
-
- /* increase # of AVQ allocated bits by unused bits from the previous subframe */
- nBits = add( nBits, *unbits );
-
- /*--------------------------------------------------------------*
- * Compute/Update target
- * For inactive frame, find target in residual domain
- * Deemphasis
- *--------------------------------------------------------------*/
-
- IF( EQ_16( st_fx->coder_type, INACTIVE ) )
- {
- gcode16 = round_fx_sat( L_shl_sat( gain_code, Q_new ) );
- FOR( i = 0; i < L_SUBFR; i++ )
- {
- /*x_tran[i] = xn[i] - *gain_pit * y1[i] - gain_code * y2[i];*/
- Ltmp = L_mult( gcode16, y2[i] );
- Ltmp = L_shl( Ltmp, add( 5, shift ) );
- Ltmp = L_negate( Ltmp );
- Ltmp = L_mac( Ltmp, xn[i], 16384 );
- Ltmp = L_msu( Ltmp, y1[i], *gain_pit ); /* Q_new + 14 + shift */
- Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */
- x_tran[i] = round_fx_sat( Ltmp ); /*Q_new-1 */
- }
- find_cn_fx( x_tran, Ap, p_Aq, x_in );
- }
- ELSE
- {
- updt_tar_fx( cn, x_in, &exc[i_subfr], *gain_pit, L_SUBFR );
- }
- Deemph2( x_in, FAC_PRE_AVQ_FX, L_SUBFR, &( st_fx->mem_deemp_preQ_fx ) );
-
- /*--------------------------------------------------------------*
- * DCT-II
- *--------------------------------------------------------------*/
-
- test();
- test();
- test();
- IF( NE_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && !harm_flag_acelp )
- {
- Copy_Scale_sig( x_in, x_tran, L_SUBFR, -Q_MINUS + 1 ); /*Q_new-1 -> Q_new-4*/
- /*Copy( x_in, x_tran, L_SUBFR );*/
- Qdct = sub( Q_new, Q_MINUS );
- }
- ELSE
- {
- Qdct = 0;
- move16();
- edct2_fx( L_SUBFR, -1, x_in, out32, &Qdct, ip_edct2_64, w_edct2_64_fx );
- Qdct = negate( Qdct );
- Copy_Scale_sig_32_16( out32, x_tran, L_SUBFR, sub( Qdct, Q_MINUS - 1 ) ); /* Output in Q_new-4 */
- Qdct = sub( Q_new, Q_MINUS );
- }
-
- /*--------------------------------------------------------------*
- * Split algebraic vector quantizer based on RE8 lattice
- *--------------------------------------------------------------*/
-
- AVQ_cod_fx( x_tran, x_norm, nBits, Nsv, Qdct );
-
/*--------------------------------------------------------------*
* Find prequantizer excitation gain
* Quantize the gain
@@ -710,7 +363,7 @@ void transf_cdbk_enc_ivas_fx(
st_fx->last_code_preq = shr( code_preQ[L_SUBFR - 1], 9 ); // Q0
move16();
- PREEMPH_FX( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &( st_fx->mem_preemp_preQ_fx ) );
+ preemph_fx( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &( st_fx->mem_preemp_preQ_fx ) );
/*--------------------------------------------------------------*
* For inactive segments
@@ -775,7 +428,7 @@ static void find_cn_fx(
Copy( xn, tmp_fl + M, L_SUBFR ); /* Qx */
tmp = 0;
move16();
- PREEMPH_FX( tmp_fl + M, PREEMPH_FAC_16k, L_SUBFR, &tmp );
+ preemph_fx( tmp_fl + M, PREEMPH_FAC_16k, L_SUBFR, &tmp );
syn_filt_s_lc_fx( 0, Ap, tmp_fl + M, tmp_fl + M, L_SUBFR );
Residu3_lc_fx( p_Aq, M, tmp_fl + M, cn, L_SUBFR, 1 );
diff --git a/lib_enc/enc_nelp_fx.c b/lib_enc/enc_nelp_fx.c
index 30756d19d6abcbf03857c417d4caaa5555cdb62d..5181a08ffc86760cf387885ed8b0953bc65bdbc7 100644
--- a/lib_enc/enc_nelp_fx.c
+++ b/lib_enc/enc_nelp_fx.c
@@ -171,143 +171,3 @@ void encod_nelp_fx(
return;
}
-
-void encod_nelp_ivas_fx(
- Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *speech_fx,
- /* i : input speech */ /* Q_new-1 */
- const Word16 Aw_fx[],
- /* i : weighted A(z) unquantized for subframes */ /*exp(norm_s(Aw_fx[0])+1)*/
- const Word16 Aq_fx[],
- /* i : 12k8 Lp coefficient */ /*exp(norm_s(Aw_fx[0])+1)*/
- Word16 *res_fx,
- /* o : residual signal */ /* Q_new */
- Word16 *synth_fx,
- /* o : core synthesis */ /* Q_new */
- Word16 *tmp_noise_fx,
- /* o : long-term noise energy */ /* Q8 */
- Word16 *exc_fx,
- /* i/o: current non-enhanced excitation */ /* Q_new */
- Word16 *exc2_fx,
- /* i/o: current enhanced excitation */ /* Q_new */
- Word16 *pitch_buf_fx,
- /* o : floating pitch values for each subframe */ /* Q6 */
- Word16 *voice_factors_fx,
- /* o : voicing factors */ /* Q15 */
- Word16 *bwe_exc_fx,
- /* o : excitation for SWB TBE */ /* Q_new */
- Word16 Q_new,
- Word16 shift )
-{
- Word16 xn_fx[L_SUBFR]; /* Target vector for pitch search */
- Word16 h1_fx[L_SUBFR]; /* Impulse response vector */
- Word16 exc_nelp_fx[L_FRAME];
-
- Word16 i_subfr, j;
-
- const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector */
- Word16 saved_Q_new = Q_new;
- move16();
-
- Word16 reduce_gains = 0;
- move16();
- LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
- SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
-
- test();
- IF( EQ_16( st_fx->bwidth, NB ) && GE_32( st_fx->input_Fs, 16000 ) )
- {
- IF( hSC_VBR->last_nelp_mode == 0 )
- {
- set16_fx( hSC_VBR->nelp_lp_fit_mem, 0, NELP_LP_ORDER * 2 );
- }
- Scale_sig( hSC_VBR->nelp_lp_fit_mem, NELP_LP_ORDER * 2, sub( Q_new, st_fx->prev_Q_new ) ); /* Q_new */
-
- pz_filter_sp_fx( num_nelp_lp_fx, den_nelp_lp_fx, res_fx, res_fx, hSC_VBR->nelp_lp_fit_mem, NELP_LP_ORDER, NELP_LP_ORDER, L_FRAME, 3 ); /*16-Q of filter coeff*/
- }
-
- p_Aw_fx = Aw_fx;
- p_Aq_fx = Aq_fx;
-
-
- FOR( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR )
- {
- /*----------------------------------------------------------------*
- * - Bandwidth expansion of A(z) filter coefficients
- * - Find the excitation search target "xn" and innovation
- * target in residual domain "cn"
- * - Compute impulse response, h1[], of weighted synthesis filter
- *----------------------------------------------------------------*/
- Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */
-
- find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx,
- res_fx, L_SUBFR, p_Aw_fx, TILT_FAC_FX, xn_fx, NULL, h1_fx );
-
- /* scale xn[] and h1[] to avoid overflow in dot_product12() */
- Scale_sig( xn_fx, L_SUBFR, shift ); /* scaling of xn[] to limit dynamic at 12 bits Q_new-1+shift */
-
- IF( i_subfr == 0 )
- {
- test();
- IF( EQ_16( hSC_VBR->Local_VAD, 1 ) && EQ_16( st_fx->bwidth, NB ) )
- {
- reduce_gains = 1;
- move16();
- }
-
- nelp_encoder_ivas_fx( st_fx, res_fx, exc_nelp_fx, &Q_new, reduce_gains );
-
- Scale_sig( exc_nelp_fx, L_FRAME, ( saved_Q_new - Q_new ) ); /* saved_Q_new */
- }
-
-
- *tmp_noise_fx = 0;
- move16();
-
- /*-----------------------------------------------------------------*
- * Synthesize speech to update mem_syn[].
- * Update A(z) filters
- *-----------------------------------------------------------------*/
- Syn_filt_s( 1, p_Aq_fx, M, &exc_nelp_fx[i_subfr], &synth_fx[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 );
-
- p_Aw_fx += ( M + 1 );
- p_Aq_fx += ( M + 1 );
- *pitch_buf_fx = L_SUBFR_Q6; /* Q6 */
- move16();
-
- pitch_buf_fx++;
- }
-
- Copy( exc_nelp_fx, exc_fx, L_FRAME ); /* Q_new */
-
- /*-----------------------------------------------------------------*
- * Updates: last value of new target is stored in mem_w0
- *-----------------------------------------------------------------*/
-
- hLPDmem->mem_w0 = sub_sat( shr_sat( xn_fx[L_SUBFR - 1], shift ), shr( exc_fx[L_FRAME - 1], 1 ) );
- move16(); /*Q_new-1 */
- hLPDmem->tilt_code = 0;
- move16(); /* purely unvoiced */
- hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code;
- move16();
-
- Copy( exc_fx, exc2_fx, L_FRAME ); /* Q_new */
-
- hSC_VBR->prev_ppp_gain_pit_fx = 0;
- move16();
-
- hLPDmem->dm_fx.prev_state = 0;
- move16();
- hLPDmem->dm_fx.prev_gain_pit[0] = hSC_VBR->prev_ppp_gain_pit_fx; /* Q14 */
- move16();
-
- FOR( j = 1; j < 5; j++ )
- {
- hLPDmem->dm_fx.prev_gain_pit[j] = hLPDmem->dm_fx.prev_gain_pit[j - 1]; /* Q14 */
- move16();
- }
- interp_code_5over2_fx( exc2_fx, bwe_exc_fx, L_FRAME );
- set16_fx( voice_factors_fx, 0, NB_SUBFR16k );
-
- return;
-}
diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c
index 200c22a1a1f61c5469a8bdaa6b8d6e580ccd925a..00095a89dd3b7b178705be19cba4d4e4eea986f1 100644
--- a/lib_enc/enc_pit_exc_fx.c
+++ b/lib_enc/enc_pit_exc_fx.c
@@ -63,8 +63,8 @@ void enc_pit_exc_fx(
Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/
const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
- Word16 Q_new,
- Word16 shift )
+ const Word16 Q_new,
+ const Word16 shift )
{
Word16 xn[PIT_EXC_L_SUBFR]; /* Target vector for pitch search */
Word16 xn2[PIT_EXC_L_SUBFR]; /* Target vector for codebook search */
@@ -81,8 +81,12 @@ void enc_pit_exc_fx(
Word16 g_corr[10]; /* ACELP correlation values + gain pitch */
Word16 clip_gain, i; /* LSF clip gain and LP flag */
const Word16 *p_Aw, *p_Aq; /* pointer to LP filter coefficient vector */
- Word16 cn1[L_SUBFR], *cn; /* (Used only when L_subfr == L_SUBFR) Target vector in residual domain */
- Word16 *pt_pitch; /* pointer to floating pitch */
+#ifdef FIX_1904_HARM_GSC_ENC
+ Word16 cn[PIT_EXC_L_SUBFR]; /* (Used only when L_subfr == L_SUBFR) Target vector in residual domain */
+#else
+ Word16 cn1[L_SUBFR], *cn; /* (Used only when L_subfr == L_SUBFR) Target vector in residual domain */
+#endif
+ Word16 *pt_pitch; /* pointer to floating pitch */
Word16 L_subfr;
Word16 cum_gpit, gpit_tmp;
Word32 Local_BR, Pitch_BR;
@@ -103,6 +107,10 @@ void enc_pit_exc_fx(
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc;
LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
+#ifdef FIX_1904_HARM_GSC_ENC
+ Word16 q_h1 = 0;
+ move16();
+#endif
/*------------------------------------------------------------------*
* Initialization
@@ -225,17 +233,27 @@ void enc_pit_exc_fx(
* ACELP subframe loop
*------------------------------------------------------------------*/
+#ifdef FIX_1904_HARM_GSC_ENC
+ set16_fx( cn, 0, PIT_EXC_L_SUBFR );
+#else
cn = NULL;
if ( EQ_16( L_subfr, L_SUBFR ) )
{
cn = cn1;
move16();
}
+#endif
p_Aw = Aw;
p_Aq = Aq;
pt_pitch = pitch_buf; /* pointer to the pitch buffer */
shift_wsp = add( Q_new, shift );
+#ifdef FIX_1904_HARM_GSC_ENC
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ shift_wsp = sub( shift_wsp, 1 );
+ }
+#endif
FOR( i_subfr = 0; i_subfr < st_fx->L_frame; i_subfr += L_subfr )
{
@@ -249,10 +267,23 @@ void enc_pit_exc_fx(
Copy( &res[i_subfr], &exc[i_subfr], L_subfr ); /* Q_new */
/* condition on target (compared to float) has been put outside the loop */
- find_targets_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq,
- res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
- Copy_Scale_sig( h1, h2, L_subfr, -2 ); /* Q13 */
- Scale_sig( h1, L_subfr, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
+#ifdef FIX_1904_HARM_GSC_ENC
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ find_targets_ivas_fx( speech, hGSCEnc->mem_syn_tmp_fx, i_subfr, &hGSCEnc->mem_w0_tmp_fx, p_Aq,
+ res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
+
+ q_h1 = sub( 14, norm_s( h1[0] ) );
+ Copy_Scale_sig( h1, h2, L_subfr, sub( 11, q_h1 ) ); /*Q11*/
+ }
+ ELSE
+#endif
+ {
+ find_targets_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq,
+ res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
+ Copy_Scale_sig( h1, h2, L_subfr, -2 ); /* Q13 */
+ Scale_sig( h1, L_subfr, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
+ }
/* scaling of xn[] to limit dynamic at 12 bits */
Scale_sig( xn, L_subfr, shift ); /* Q_new - 1 + shift */
@@ -265,12 +296,27 @@ void enc_pit_exc_fx(
*pt_pitch = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, Pitch_BR, 0, st_fx->L_frame, Pitch_CT, &pitch_limit_flag, i_subfr, exc,
L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, st_fx->element_mode, Q_new ); /* Q6 */
+#ifdef FIX_1904_HARM_GSC_ENC
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ Scale_sig( h1, L_subfr, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ // TVTODO to be check if it would still be BE when moved above
+ }
+#endif
/*-----------------------------------------------------------------*
* Find adaptive exitation
*-----------------------------------------------------------------*/
- pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+#ifdef FIX_1904_HARM_GSC_ENC
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
+ ELSE
+#endif
+ {
+ pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
/*-----------------------------------------------------------------*
* Gain clipping test to avoid unstable synthesis on frame erasure
@@ -292,7 +338,16 @@ void enc_pit_exc_fx(
}
/*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit;*/
- hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/
+#ifdef FIX_1904_HARM_GSC_ENC
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ hSpMusClas->lowrate_pitchGain = mac_r_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 3277, gain_pit ); /* Q14*Q16(0.1) + Q15 -> Q15 Q14*Q15 + Q14 -> Q14 lowrate_pitchGain is compared to Q14 in sp_music_classif */
+ }
+ ELSE
+#endif
+ {
+ hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/
+ }
gpit_tmp = gain_pit;
move16(); /*Q14*/
@@ -324,14 +379,13 @@ void enc_pit_exc_fx(
*-----------------------------------------------------------------*/
inov_encode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq,
- gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift );
+ gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift, Q_new );
/*-----------------------------------------------------------------*
* Gain encoding
*-----------------------------------------------------------------*/
- gain_enc_lbr_fx( st_fx->hBstr, st_fx->acelp_cfg.gains_mode, GENERIC, i_subfr, xn, y1, shift_wsp, y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR,
- st_fx->element_mode );
+ gain_enc_lbr_fx( st_fx->hBstr, st_fx->acelp_cfg.gains_mode, GENERIC, i_subfr, xn, y1, shift_wsp, y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR, st_fx->element_mode );
}
ELSE
{
@@ -340,23 +394,38 @@ void enc_pit_exc_fx(
*-----------------------------------------------------------------*/
inov_encode_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq,
- gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift );
+ gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new );
/*-----------------------------------------------------------------*
* Gain encoding
*-----------------------------------------------------------------*/
+#ifdef FIX_1904_HARM_GSC_ENC
+ gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, st_fx->L_frame, i_subfr, -1, xn, y1, shift_wsp, y2, code, Es_pred,
+ &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain );
+#else
gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_FRAME, i_subfr, -1, xn, y1, shift_wsp, y2, code, Es_pred,
&gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain );
+#endif
}
gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx );
Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/
gcode16 = round_fx_sat( Lgcode );
+
IF( use_fcb != 0 )
{
- hLPDmem->tilt_code = Est_tilt2( &exc[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */
+#ifdef FIX_1904_HARM_GSC_ENC
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ hLPDmem->tilt_code = est_tilt_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr ); /* Q15 */
+ }
+ ELSE
+#endif
+ {
+ hLPDmem->tilt_code = Est_tilt2( &exc[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */
+ }
move16();
}
ELSE
@@ -371,13 +440,31 @@ void enc_pit_exc_fx(
IF( use_fcb != 0 )
{
- Ltmp = L_mult( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */
+#ifdef FIX_1904_HARM_GSC_ENC
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ Ltmp = L_mult0( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */
+ }
+ ELSE
+#endif
+ {
+ Ltmp = L_mult( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */
+ }
Ltmp = L_shl_sat( Ltmp, add( 5, shift ) ); /* Q15 + Q_new + shift */
Ltmp = L_negate( Ltmp );
Ltmp = L_mac_sat( Ltmp, xn[L_subfr - 1], 16384 ); /* Q_new + Q15 + shift */
Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); /* Q_new + Q15 + shift */
Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */
- hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
+#ifdef FIX_1904_HARM_GSC_ENC
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1 */
+ }
+ ELSE
+#endif
+ {
+ hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
+ }
move16();
}
ELSE
@@ -385,7 +472,16 @@ void enc_pit_exc_fx(
Ltmp = L_mult( xn[L_subfr - 1], 16384 ); /* Q_new + 14 -shift */
Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); /* Q_new + 14 -shift */
Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */
- hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
+#ifdef FIX_1904_HARM_GSC_ENC
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1 */
+ }
+ ELSE
+#endif
+ {
+ hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */
+ }
move16();
}
@@ -532,7 +628,7 @@ void enc_pit_exc_fx(
return;
}
-
+#ifndef FIX_1904_HARM_GSC_ENC
void enc_pit_exc_ivas_fx(
Encoder_State *st_fx, /* i/o: State structure */
const Word16 *speech, /* i : Input speech Q_new-1*/
@@ -1013,3 +1109,4 @@ void enc_pit_exc_ivas_fx(
return;
}
+#endif
diff --git a/lib_enc/enc_ppp_fx.c b/lib_enc/enc_ppp_fx.c
index 70360f9d2c281e2c988ab6e82ac103f5d98dd708..5f097660449be0efb6aa925ba1995735af12dbf4 100644
--- a/lib_enc/enc_ppp_fx.c
+++ b/lib_enc/enc_ppp_fx.c
@@ -1,17 +1,15 @@
/*====================================================================================
EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0
====================================================================================*/
+
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-//#include "prot_fx.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Common constants */
#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h" /* Function prototypes */
-/*Temporary location to be move in prot* when merge is done */
-void E_LPC_f_lsp_a_conversion( const Word16 *lsp, Word16 *a, const Word16 m );
/*=======================================================================================*/
/* FUNCTION : encod_ppp_fx() */
@@ -51,6 +49,7 @@ void E_LPC_f_lsp_a_conversion( const Word16 *lsp, Word16 *a, const Word16 m );
/*---------------------------------------------------------------------------------------*/
/* CALLED FROM : TX */
/*=======================================================================================*/
+
ivas_error encod_ppp_fx(
Encoder_State *st_fx, /* i/o: state structure */
const Word16 speech_fx[], /* i : input speech Q_new*/
@@ -63,8 +62,9 @@ ivas_error encod_ppp_fx(
Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
Word16 *voice_factors, /* o : voicing factors Q15*/
Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/
- Word16 Q_new,
- Word16 shift )
+ const Word16 Q_new, /* i : Scaling factor */
+ const Word16 shift /* i : Shift needed to obtain 12 bits vectors */
+)
{
Word16 xn_fx[L_SUBFR]; /* Target vector for pitch search */
Word16 h1_fx[L_SUBFR + ( M + 1 )]; /* Impulse response vector */
@@ -233,185 +233,3 @@ ivas_error encod_ppp_fx(
return error;
}
-
-ivas_error encod_ppp_ivas_fx(
- Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech Q_new*/
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
- Word16 *res_fx, /* i : residual signal Q_new*/
- Word16 *synth_fx, /* o : core synthesis Q-1*/
- Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
- Word16 *exc2_fx, /* o : current enhanced excitation Q0*/
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
- Word16 *voice_factors, /* o : voicing factors Q15*/
- Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/
- Word16 Q_new,
- Word16 shift )
-{
- Word16 xn_fx[L_SUBFR]; /* Target vector for pitch search */
- Word16 h1_fx[L_SUBFR + ( M + 1 )]; /* Impulse response vector */
- Word16 i_subfr; /* tmp variables */
- const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector*/
-
- Word16 k;
- Word16 p_Aq_old_fx[M + 1], excQ_ppp_fx[L_FRAME], p_Aq_curr_fx[M], pitch_fx[NB_SUBFR];
- Word16 LPC_de_old_fx[M + 1], LPC_de_curr_fx[M + 1];
- Word16 shift_wsp = add( Q_new, shift );
- Word16 rate_ctrl_fx;
- Word16 saved_Q_new = Q_new;
- move16();
- LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
- SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
- BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
- ivas_error error;
-
- error = IVAS_ERR_OK;
- move16();
- rate_ctrl_fx = hSC_VBR->rate_control;
- move16();
-
- /*------------------------------------------------------------------*
- * ACELP subframe loop
- *------------------------------------------------------------------*/
- p_Aw_fx = Aw_fx;
- p_Aq_fx = Aq_fx;
- FOR( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR )
- {
- /*----------------------------------------------------------------*
- * Bandwidth expansion of A(z) filter coefficients
- * Find the the excitation search target "xn" and innovation
- * target in residual domain "cn"
- * Compute impulse response, h1[], of weighted synthesis filter
- *----------------------------------------------------------------*/
-
- Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */
-
- find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx,
- res_fx, L_SUBFR, p_Aw_fx, TILT_FAC_FX, xn_fx, NULL, h1_fx );
-
- /* scale xn[] and h1[] to avoid overflow in dot_product12() */
- Scale_sig( xn_fx, L_SUBFR, shift ); /* scaling of xn[] to limit dynamic at 12 bits */
-
- /* call voiced encoder at this point */
- IF( i_subfr == 0 ) /* generate the L_FRAME exc */
- {
- FOR( k = 0; k < M; k++ )
- {
- p_Aq_curr_fx[k] = p_Aq_fx[k + ( 3 * ( M + 1 ) ) + 1]; /* Q12 */
- move16();
- }
-
- E_LPC_f_lsp_a_conversion( st_fx->lsp_old_fx, p_Aq_old_fx, M );
- deemph_lpc_fx( p_Aq_curr_fx, p_Aq_old_fx, LPC_de_curr_fx, LPC_de_old_fx, 1 );
- /* both outputs LPC_de_curr_fx and LPC_de_old_fx are in Q12 */
-
-
- /* last frame-end lpc and curr frame-end lpc */
- IF( ( error = ppp_voiced_encoder_fx( hBstr, hSC_VBR, st_fx->bwidth, st_fx->last_coder_type_raw, st_fx->old_pitch_buf_fx, res_fx,
- excQ_ppp_fx, st_fx->pitch[1], LPC_de_old_fx, LPC_de_curr_fx, exc_fx, pitch_fx, Q_new ) ) != IVAS_ERR_OK )
- {
- return error;
- }
-
- Scale_sig( exc_fx, L_FRAME, sub( saved_Q_new, Q_new ) ); /* saved_Q_new */
- if ( EQ_16( hSC_VBR->bump_up, 1 ) )
- {
- i_subfr = L_FRAME;
- move16();
- }
- }
-
- IF( NE_16( hSC_VBR->bump_up, 1 ) )
- {
- /*-----------------------------------------------------------------*
- * Gain clipping test to avoid unstable synthesis on frame erasure
- * or in case of floating point encoder & fixed p. decoder
- *-----------------------------------------------------------------*/
- gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, st_fx->coder_type, xn_fx, st_fx->clip_var_fx, sub( shift_wsp, 1 ) );
-
-
- /* run the above to maintain gain clipping memories */
- gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, hSC_VBR->prev_ppp_gain_pit_fx, st_fx->clip_var_fx );
-
-
- /*-----------------------------------------------------------------*
- * Synthesize speech to update mem_syn[].
- * Update A(z) filters
- *-----------------------------------------------------------------*/
-
- Syn_filt_s( 1, p_Aq_fx, M, &excQ_ppp_fx[i_subfr], &synth_fx[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 );
-
-
- p_Aw_fx += ( M + 1 );
- p_Aq_fx += ( M + 1 );
- }
-
- } /* end of subframe loop */
-
- IF( hSC_VBR->bump_up )
- {
- /* PPP failed, bump up */
- hSC_VBR->ppp_mode = 0;
- move16();
- st_fx->core_brate = ACELP_7k20;
- move16();
- hSC_VBR->pppcountE = 0;
- move16();
-
- IF( hSC_VBR->set_ppp_generic )
- {
- st_fx->coder_type = GENERIC;
- move16();
- }
- ELSE
- {
- st_fx->coder_type = VOICED;
- move16();
- }
-
- /* We write signalling indices again only in case of bump_up */
- /* delete previous indices */
- reset_indices_enc_fx( hBstr, hBstr->nb_ind_tot );
- /* signalling matrix (writing of signalling bits) */
- signalling_enc_fx( st_fx );
- }
- ELSE
- {
- Copy( excQ_ppp_fx, exc_fx, L_FRAME ); /* Q_new */
-
- /*-----------------------------------------------------------------*
- * Updates: last value of new target is stored in mem_w0
- *-----------------------------------------------------------------*/
-
- hLPDmem->mem_w0 = sub( shr( xn_fx[L_SUBFR - 1], shift ), shr( exc_fx[L_FRAME - 1], 1 ) ); /*Q_new-1 */
-
- Copy( exc_fx, exc2_fx, L_FRAME ); /* Q_new */
-
- hLPDmem->dm_fx.prev_state = 2;
- move16(); /*Q0 dispMem index 0 */
- hLPDmem->dm_fx.prev_gain_pit[0] = hSC_VBR->prev_ppp_gain_pit_fx;
- move16(); /*Q14 dispMem index 2 */
-
- FOR( k = 1; k < 5; k++ )
- {
- hLPDmem->dm_fx.prev_gain_pit[k] = hLPDmem->dm_fx.prev_gain_pit[k - 1]; /* Q14 */
- move16();
- }
-
- hLPDmem->tilt_code = hSC_VBR->prev_tilt_code_fx; /* Q15 */
- move16();
- Copy( pitch_fx, pitch_buf_fx, NB_SUBFR );
- pitch_buf_fx[NB_SUBFR16k - 1] = pitch_fx[NB_SUBFR - 1];
-
- interp_code_5over2_fx( exc2_fx, bwe_exc, L_FRAME );
- set16_fx( voice_factors, 0, NB_SUBFR16k );
- }
-
- hSC_VBR->rate_control = rate_ctrl_fx; /* Q0 */
- move16();
-
- set16_fx( hSC_VBR->nelp_lp_fit_mem, 0, NELP_LP_ORDER * 2 );
-
- return error;
-}
diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c
index 6a861b8aff23a5fe0ad63888449f9b3eccfb3a97..e28dd0bf99392be34f6c528b1a6fc31db9afd3c2 100644
--- a/lib_enc/enc_prm_fx.c
+++ b/lib_enc/enc_prm_fx.c
@@ -23,7 +23,6 @@ static void enc_prm_hm(
Word8 flag;
BSTR_ENC_HANDLE hBstr = st->hBstr;
-
/* Disable HM for non-GC,VC modes */
test();
IF( NE_16( st->hTcxCfg->coder_type, VOICED ) && NE_16( st->hTcxCfg->coder_type, GENERIC ) )
@@ -93,184 +92,14 @@ static void enc_prm_hm_ivas_fx(
}
}
+
/*-----------------------------------------------------------------*
- * Function enc_prm_rf_fx() *
+ * Function enc_prm_rf_fx() *
* ~~~~~~~~~~~~~~~~~~~~~~ *
* *
* encode RF parameters for ACELP and TCX partial copy *
*-----------------------------------------------------------------*/
-void enc_prm_rf_ivas_fx(
- Encoder_State *st,
- const Word16 rf_frame_type, /* Q0 */
- const Word16 fec_offset /* Q0 */
-)
-{
- Word16 sfr, nb_subfr, n, index;
- Word16 ltp_mode, ltf_mode, gains_mode;
- RF_ENC_HANDLE hRF = st->hRF;
- TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;
- BSTR_ENC_HANDLE hBstr = st->hBstr;
-
-
- nb_subfr = st->nb_subfr; /* Q0 */
- move16();
- /* partial copy bitstream writing */
- test();
- IF( GE_16( rf_frame_type, RF_TCXFD ) && LE_16( rf_frame_type, RF_TCXTD2 ) )
- {
- /* TCX frames partial copy write */
-
- /* LSF indices */
- IF( EQ_16( rf_frame_type, RF_TCXFD ) )
- {
- push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][0], lsf_numbits[0] ); /* VQ 1 */
- push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][1], lsf_numbits[1] ); /* VQ 2 */
- push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][2], lsf_numbits[2] ); /* VQ 3 */
- }
-
- /* classification */
- test();
- IF( EQ_16( hRF->rf_clas[fec_offset], UNVOICED_CLAS ) )
- {
- index = 0;
- move16();
- }
- ELSE IF( ( EQ_16( hRF->rf_clas[fec_offset], VOICED_TRANSITION ) ) || ( EQ_16( hRF->rf_clas[fec_offset], UNVOICED_TRANSITION ) ) )
- {
- index = 1;
- move16();
- }
- ELSE IF( EQ_16( hRF->rf_clas[fec_offset], VOICED_CLAS ) )
- {
- index = 2;
- move16();
- }
- ELSE
- {
- index = 3;
- move16();
- }
- push_next_indice( hBstr, index, 2 );
-
- IF( EQ_16( rf_frame_type, RF_TCXFD ) )
- {
- /* TCX global gain = 7 bits */
- push_next_indice( hBstr, hRF->rf_gain_tcx[fec_offset], 7 );
- /*window info
- 1 bit for long overlap
- 2 if minimum or half overlap*/
- }
- ELSE
- {
- /*gains adapt
- gains inov*/
-
- /*LPC on full rate -> excitation */
- /* pitch and gain */
- /* LTP data */
- test();
- test();
- IF( ( EQ_16( rf_frame_type, RF_TCXTD1 ) || EQ_16( rf_frame_type, RF_TCXTD2 ) ) && hTcxEnc->tcxltp != 0 )
- {
- push_next_indice( hBstr, hRF->rf_tcxltp_param[fec_offset], 9 );
- }
- }
- }
- ELSE IF( EQ_16( rf_frame_type, 7 ) ) /* NELP bitstream writing */
- {
- /* LSF indices */
- push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][0], 8 ); /* VQ 1 */
- push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][1], 8 ); /* VQ 2 */
-
- /* NELP gain indices */
- push_next_indice( hBstr, hRF->rf_indx_nelp_iG1[fec_offset], 5 );
- push_next_indice( hBstr, hRF->rf_indx_nelp_iG2[fec_offset][0], 6 );
- push_next_indice( hBstr, hRF->rf_indx_nelp_iG2[fec_offset][1], 6 );
-
- /* NELP filter selection index */
- push_next_indice( hBstr, hRF->rf_indx_nelp_fid[fec_offset], 2 );
-
- /* tbe gainFr */
- push_next_indice( hBstr, hRF->rf_indx_tbeGainFr[fec_offset], 5 );
- }
- ELSE IF( GE_16( rf_frame_type, 4 ) ) /* rf_frame_type ALL_PRED: 4, NO_PRED: 5, GEN_PRED: 6 */
- {
- /* LSF indices */
- push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][0], 8 ); /* VQ 1 */
- push_next_indice( hBstr, hRF->rf_indx_lsf[fec_offset][1], 8 ); /* VQ 2 */
-
- /* ES pred */
- push_next_indice( hBstr, hRF->rf_indx_EsPred[fec_offset], 3 );
-
- ltp_mode = ACELP_LTP_MODE[1][1][rf_frame_type];
- ltf_mode = ACELP_LTF_MODE[1][1][rf_frame_type];
- gains_mode = ACELP_GAINS_MODE[1][1][rf_frame_type];
- move16();
- move16();
- move16();
- /* Subframe parameters */
- FOR( sfr = 0; sfr < nb_subfr; sfr++ )
- {
- /* Pitch lag (5, or 8 bits) */
- n = ACELP_LTP_BITS_SFR[ltp_mode][sfr];
- move16();
- IF( n != 0 )
- {
- push_next_indice( hBstr, hRF->rf_indx_pitch[fec_offset][sfr], n );
- }
-
- /* Adaptive codebook filtering (1 bit) */
- IF( EQ_16( ltf_mode, 2 ) )
- {
- push_next_indice( hBstr, hRF->rf_indx_ltfMode[fec_offset][sfr], 1 );
- }
-
- /*Innovative codebook*/
- test();
- test();
- test();
- IF( ( EQ_16( rf_frame_type, RF_NOPRED ) ) ||
- ( EQ_16( rf_frame_type, RF_GENPRED ) &&
- ( sfr == 0 || EQ_16( sfr, 2 ) ) ) )
- {
- push_next_indice( hBstr, hRF->rf_indx_fcb[fec_offset][sfr], 7 );
- }
-
- /* Gains (5b, 6b or 7b / subfr) */
- test();
- IF( sfr == 0 || EQ_16( sfr, 2 ) )
- {
- n = ACELP_GAINS_BITS[gains_mode];
- move16();
- push_next_indice( hBstr, hRF->rf_indx_gain[fec_offset][sfr], n );
- }
- }
- /* tbe gainFr */
- push_next_indice( hBstr, hRF->rf_indx_tbeGainFr[fec_offset], 2 );
- }
-
- /***************/
- /*IMPORTANT: The last three bits are always the rf_frame_type in the bitstream (for both acelp and tcx partial copy);
- the rf_frame_type indicates the length of the partial copy payload at the decoder.
- The 2 bits before the rf_frame_type contains the fec_offset */
-
- /***************/
- /* write FEC offset just before the rf_frame_type */
- test();
- test();
- IF( EQ_16( fec_offset, 2 ) )
- {
- push_next_indice( hBstr, 0, 2 );
- }
- ELSE IF( EQ_16( fec_offset, 3 ) || EQ_16( fec_offset, 5 ) || EQ_16( fec_offset, 7 ) )
- {
- push_next_indice( hBstr, shr( sub( fec_offset, 1 ), 1 ), 2 );
- }
-
- /* write RF frame type last in the bitstream */
- push_next_indice( hBstr, rf_frame_type, 3 );
-}
void enc_prm_rf_fx(
Encoder_State *st,
const Word16 rf_frame_type, /* Q0 */
@@ -449,14 +278,14 @@ void enc_prm_rf_fx(
*-----------------------------------------------------------------*/
void enc_prm_fx(
- const Word16 coder_type, /* (i) : coding type */
- Word16 param[], /* (i) : parameters Q0*/
- Word16 param_lpc[], /* (i) : LPC parameters Q0*/
- Encoder_State *st, /* i/o : quantization Analysis values */
- Word16 L_frame, /* Q0 */
+ const Word16 coder_type, /* (i) : coding type */
+ Word16 param[], /* (i) : parameters Q0*/
+ const Word16 param_lpc[], /* (i) : LPC parameters Q0*/
+ Encoder_State *st, /* i/o : quantization Analysis values */
+ const Word16 L_frame, /* Q0 */
CONTEXT_HM_CONFIG hm_cfg[],
- Word16 *bits_param_lpc, /* Q0 */
- Word16 no_param_lpc /* Q0 */
+ Word16 *bits_param_lpc, /* Q0 */
+ const Word16 no_param_lpc /* Q0 */
)
{
Word16 j, k, n, sfr, core, last_core, *prm, tmp;
@@ -1108,15 +937,12 @@ void enc_prm_fx(
} /* k, window index */
}
-
/*--------------------------------------------------------------------------------*
* END
*--------------------------------------------------------------------------------*/
-
total_nbbits = sub( hBstr->nb_bits_tot, nbits_start ); /* Q0 */
-
/* Check if total encoded bits does not exceed CBR target bits (->this must never happen) */
if ( st->bits_frame_core && ( total_nbbits > st->bits_frame_core ) )
{
@@ -1149,7 +975,7 @@ void writeLPCparam_fx(
IF( st->enableTcxLpc && st->core != ACELP_CORE )
{
/* Encode the indices */
- *nbits_lpc = enc_lsf_tcxlpc_ivas_fx( ¶m_lpc, hBstr ); /* Q0 */
+ *nbits_lpc = enc_lsf_tcxlpc_fx( ¶m_lpc, hBstr ); /* Q0 */
move16();
}
ELSE
@@ -1168,7 +994,7 @@ void writeLPCparam_fx(
move16();
}
- *nbits_lpc = encode_lpc_avq_ivas_fx( hBstr, numlpc, param_lpc, st->core, st->element_mode ); /* Q0 */
+ *nbits_lpc = encode_lpc_avq_fx( hBstr, numlpc, param_lpc, st->core, st->element_mode ); /* Q0 */
move16();
}
ELSE IF( EQ_16( st->lpcQuantization, 1 ) )
@@ -1178,13 +1004,12 @@ void writeLPCparam_fx(
IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( st->coder_type, VOICED ) && EQ_16( st->core, ACELP_CORE ) )
{
assert( st->element_mode == EVS_MONO );
-
- *nbits_lpc = lsf_bctcvq_encprm_ivas_fx( hBstr, param_lpc, bits_param_lpc, no_param_lpc ); /* Q0 */
+ *nbits_lpc = lsf_bctcvq_encprm_fx( hBstr, param_lpc, bits_param_lpc, no_param_lpc ); /* Q0 */
move16();
}
ELSE
{
- *nbits_lpc = lsf_msvq_ma_encprm_ivas_fx( hBstr, param_lpc, st->core, st->coder_type, st->acelp_cfg.midLpc, bits_param_lpc, no_param_lpc ); /* Q0 */
+ *nbits_lpc = lsf_msvq_ma_encprm_fx( hBstr, param_lpc, st->core, st->coder_type, st->acelp_cfg.midLpc, bits_param_lpc, no_param_lpc ); /* Q0 */
move16();
}
}
diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c
index 879ed6dd038b6eb099713e169b84888e116fe48d..10e458fb5710a073f8c2f61cbd3b433e3e228791 100644
--- a/lib_enc/enc_tran_fx.c
+++ b/lib_enc/enc_tran_fx.c
@@ -60,7 +60,7 @@ Word16 encod_tran_fx(
Word16 tc_subfr, /* i/o: TC subframe classification Q0*/
Word16 position, /* i : maximum of residual signal index Q0*/
Word16 *unbits, /* i/o: number of unused bits Q0*/
- const Word16 shift, /* i : Scaling to get 12 bits */
+ const Word16 shift_r, /* i : Scaling to get 12 bits */
const Word16 Q_new /* i : Input scaling */
)
{
@@ -93,10 +93,15 @@ Word16 encod_tran_fx(
Word16 L_frame_fx;
Word16 shift_wsp;
Word32 L_tmp;
+ Word16 q_h1;
+ Word16 shift, tmp;
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
+ shift = shift_r; /* for IVAS, shift_r is always 0 */
+ /* will be reusing the EVS shift strategy later on to allow of H1 overshoot */
+ move16();
L_frame_fx = st_fx->L_frame;
move16();
@@ -134,13 +139,18 @@ Word16 encod_tran_fx(
*unbits = 0;
move16();
- p_Aw = Aw_fx; /* Q12 */
- p_Aq = Aq_fx; /* Q12 */
- pt_pitch = pitch_buf_fx; /* Q6 */
+ p_Aw = Aw_fx; /* Q12 */
+ p_Aq = Aq_fx; /* Q12 */
+ pt_pitch = pitch_buf_fx;
gain_preQ = 0;
move16();
set16_fx( code_preQ, 0, L_SUBFR );
shift_wsp = add( Q_new, shift );
+ test();
+ if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && NE_32( st_fx->element_mode, EVS_MONO ) )
+ {
+ shift_wsp = sub( shift_wsp, 1 );
+ }
/*----------------------------------------------------------------*
* ACELP subframe loop
@@ -156,11 +166,30 @@ Word16 encod_tran_fx(
Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */
- find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq,
- res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq,
+ res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
+
+ Copy_Scale_sig( h1, h2_fx, L_SUBFR, -2 );
+ Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
+ }
+ ELSE
+ {
+ find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq,
+ res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
- Copy_Scale_sig( h1, h2_fx, L_SUBFR, -2 );
- Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
+ q_h1 = sub( 14, norm_s( h1[0] ) );
+ tmp = sub( 14, norm_arr( h1, L_SUBFR ) );
+ shift = sub( q_h1, tmp ); /* shift is initialized to shift_r ( to 0) at the beginning of the scope, re-compute shift_wsp in case it has changed */
+ shift_wsp = add( Q_new, shift );
+ if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) )
+ {
+ shift_wsp = sub( shift_wsp, 1 );
+ }
+ Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/
+ Scale_sig( h1, L_SUBFR, add( sub( 14, q_h1 ), shift ) );
+ }
/* scaling of xn[] to limit dynamic at 12 bits */
Scale_sig( xn, L_SUBFR, shift );
@@ -188,7 +217,7 @@ Word16 encod_tran_fx(
*-----------------------------------------------------------------*/
inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag,
- i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift );
+ i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new );
test();
test();
@@ -230,408 +259,30 @@ Word16 encod_tran_fx(
Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/
gcode16 = round_fx_sat( Lgcode );
- hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */
-
- /*-----------------------------------------------------------------*
- * Update memory of the weighting filter
- *-----------------------------------------------------------------*/
- /*st->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]);*/
- L_tmp = L_mult( gcode16, y2[L_SUBFR - 1] ); /* Q10 + Q_new */
- L_tmp = L_shl( L_tmp, add( 5, shift ) ); /* Q15 + Q_new + shift */
- L_tmp = L_negate( L_tmp );
- L_tmp = L_mac( L_tmp, xn[L_SUBFR - 1], 16384 );
- L_tmp = L_msu( L_tmp, y1[L_SUBFR - 1], gain_pit );
- L_tmp = L_shl_sat( L_tmp, sub( 1, shift ) ); /* Q_new + 15 */
- hLPDmem->mem_w0 = round_fx_sat( L_tmp ); /*Q_new-1*/
-
- /*-----------------------------------------------------------------*
- * Construct adaptive part of the excitation
- * Save the non-enhanced excitation for FEC_exc
- *-----------------------------------------------------------------*/
-
- /* Here, all these conditions have one purpose: to use */
- /* the most efficient loop (the one with the least ops) */
- /* This is done by upscaling gain_pit_fx and/or gain_code16 */
- /* when they don't use all 16 bits of precision */
-
- /* exc Q_exc, gpit Q14, code Q12, gcode Q0 */
- IF( norm_s( gain_pit ) == 0 )
+ IF( st_fx->element_mode == EVS_MONO )
{
- FOR( i = 0; i < L_SUBFR; i++ )
- {
- exc2_fx[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult_sat( gain_pit, exc_fx[i + i_subfr] ), 1 ) ); /* Q_new */
- }
+ hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */
}
ELSE
{
- Gain_pitX2 = shl( gain_pit, 1 ); /* Q15 */
- FOR( i = 0; i < L_SUBFR; i++ )
- {
- exc2_fx[i + i_subfr] = mult_r( Gain_pitX2, exc_fx[i + i_subfr] ); /* Q_new */
- }
- }
-
- /*-----------------------------------------------------------------*
- * Construct adaptive part of the excitation
- * Save the non-enhanced excitation for FEC_exc
- *-----------------------------------------------------------------*/
- FOR( i = 0; i < L_SUBFR; i++ )
- {
- /* code in Q9, gain_pit in Q14 */
- L_tmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */
- L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 + Q_new */
- L_tmp = L_mac_sat( L_tmp, exc_fx[i + i_subfr], gain_pit ); /* Q15 + Q_new */
- L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q16 + Q_new */
- exc_fx[i + i_subfr] = round_fx_sat( L_tmp ); /* Q_new */
- }
-
- /*-----------------------------------------------------------------*
- * Add the ACELP pre-quantizer contribution
- *-----------------------------------------------------------------*/
-
- IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) )
- {
- tmp1_fx = add( 16 - ( 2 + Q_AVQ_OUT_DEC + 1 ), Q_new );
- FOR( i = 0; i < L_SUBFR; i++ )
- {
- L_tmp = L_mult( gain_preQ, code_preQ[i] ); /* Q2 + Q10 -> Q13*/
- L_tmp = L_shl_sat( L_tmp, tmp1_fx ); /* Q16 + Q_exc */
- tmp_fx = round_fx_sat( L_tmp );
- exc2_fx[i + i_subfr] = add_sat( exc2_fx[i + i_subfr], tmp_fx ); /* Q_exc */
- move16();
- exc_fx[i + i_subfr] = add_sat( exc_fx[i + i_subfr], tmp_fx ); /* Q_exc */
- move16();
- }
- }
-
- /*-----------------------------------------------------------------*
- * Prepare TBE excitation
- *-----------------------------------------------------------------*/
-
- prep_tbe_exc_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR],
- bwe_exc_fx, gain_preQ, code_preQ, Q10, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate, st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag );
-
- /*-----------------------------------------------------------------*
- * Synthesize speech to update mem_syn[].
- * Update A(z) filters
- *-----------------------------------------------------------------*/
-
- Syn_filt_s( 1, p_Aq, M, &exc_fx[i_subfr], &syn_fx[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 );
-
- p_Aw += ( M + 1 );
- p_Aq += ( M + 1 );
- pt_pitch++;
- }
-
- /* write reserved bits */
- WHILE( unbits_PI > 0 )
- {
- i = s_min( unbits_PI, 16 );
- push_indice( hBstr, IND_UNUSED, 0, i );
- unbits_PI -= i;
- }
-
- /* write TC configuration */
- IF( EQ_16( L_frame_fx, L_FRAME ) )
- {
- IF( EQ_16( tc_subfr, TC_0_0 ) )
- {
- push_indice( hBstr, IND_TC_SUBFR, 1, 1 );
- }
- ELSE IF( EQ_16( tc_subfr, TC_0_64 ) )
- {
- push_indice( hBstr, IND_TC_SUBFR, 0, 1 );
- push_indice( hBstr, IND_TC_SUBFR, 1, 1 );
- push_indice( hBstr, IND_TC_SUBFR, 0, 1 );
- push_indice( hBstr, IND_TC_SUBFR, 1, 1 );
- }
- ELSE IF( EQ_16( tc_subfr, TC_0_128 ) )
- {
- push_indice( hBstr, IND_TC_SUBFR, 0, 1 );
- push_indice( hBstr, IND_TC_SUBFR, 1, 1 );
- push_indice( hBstr, IND_TC_SUBFR, 0, 1 );
- push_indice( hBstr, IND_TC_SUBFR, 0, 1 );
- }
- ELSE IF( EQ_16( tc_subfr, TC_0_192 ) )
- {
- push_indice( hBstr, IND_TC_SUBFR, 0, 1 );
- push_indice( hBstr, IND_TC_SUBFR, 1, 1 );
- push_indice( hBstr, IND_TC_SUBFR, 1, 1 );
- }
- ELSE IF( EQ_16( tc_subfr, L_SUBFR ) )
- {
- push_indice( hBstr, IND_TC_SUBFR, 0, 1 );
- push_indice( hBstr, IND_TC_SUBFR, 0, 1 );
- push_indice( hBstr, IND_TC_SUBFR, 1, 1 );
- }
- ELSE IF( EQ_16( tc_subfr, 2 * L_SUBFR ) )
- {
- push_indice( hBstr, IND_TC_SUBFR, 0, 1 );
- push_indice( hBstr, IND_TC_SUBFR, 0, 1 );
- push_indice( hBstr, IND_TC_SUBFR, 0, 1 );
- push_indice( hBstr, IND_TC_SUBFR, 1, 1 );
- }
- ELSE IF( EQ_16( tc_subfr, 3 * L_SUBFR ) )
- {
- push_indice( hBstr, IND_TC_SUBFR, 0, 1 );
- push_indice( hBstr, IND_TC_SUBFR, 0, 1 );
- push_indice( hBstr, IND_TC_SUBFR, 0, 1 );
- push_indice( hBstr, IND_TC_SUBFR, 0, 1 );
- }
- }
- ELSE /* L_frame == L_FRAME16k */
- {
- IF( tc_subfr == 0 )
- {
- push_indice( hBstr, IND_TC_SUBFR, 0, 2 );
- }
- ELSE IF( EQ_16( tc_subfr, L_SUBFR ) )
- {
- push_indice( hBstr, IND_TC_SUBFR, 1, 2 );
+ hLPDmem->tilt_code = est_tilt_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR ); // Q15
}
- ELSE IF( EQ_16( tc_subfr, 2 * L_SUBFR ) )
- {
- push_indice( hBstr, IND_TC_SUBFR, 2, 2 );
- }
- ELSE IF( EQ_16( tc_subfr, 3 * L_SUBFR ) )
- {
- push_indice( hBstr, IND_TC_SUBFR, 3, 2 );
- push_indice( hBstr, IND_TC_SUBFR, 0, 1 );
- }
- ELSE IF( EQ_16( tc_subfr, 4 * L_SUBFR ) )
- {
- push_indice( hBstr, IND_TC_SUBFR, 3, 2 );
- push_indice( hBstr, IND_TC_SUBFR, 1, 1 );
- }
- }
-
- IF( st_fx->Opt_SC_VBR )
- {
- /* SC-VBR */
- hSC_VBR->prev_ppp_gain_pit_fx = gain_pit; /* Q14 */
move16();
- hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */
- move16();
- }
-
- return tc_subfr;
-}
-
-
-Word16 encod_tran_ivas_fx(
- Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech Q0*/
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
- const Word16 *res_fx, /* i : residual signal Q_new*/
- Word16 *syn_fx, /* i/o: core synthesis Q_new*/
- Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/
- Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/
- Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
- Word16 *voice_factors, /* o : voicing factors Q15*/
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q0*/
- Word16 tc_subfr, /* i/o: TC subframe classification Q0*/
- Word16 position, /* i : maximum of residual signal index Q0*/
- Word16 *unbits, /* i/o: number of unused bits Q0*/
- const Word16 shift_r, /* i : Scaling to get 12 bits */
- const Word16 Q_new /* i : Input scaling */
-)
-{
- Word16 xn[L_SUBFR]; /* Target vector for pitch search */
- Word16 xn2[L_SUBFR]; /* Target vector for codebook search */
- Word16 cn[L_SUBFR]; /* Target vector in residual domain */
- Word16 h1[L_SUBFR + ( M + 1 )]; /* Impulse response vector */
- Word16 h2_fx[L_SUBFR + ( M + 1 )]; /* Impulse response vector */
- Word16 code[L_SUBFR]; /* Fixed codebook excitation */
- Word16 y1[L_SUBFR]; /* Filtered adaptive excitation */
- Word16 y2[L_SUBFR]; /* Filtered algebraic excitation */
- Word16 gain_pit = 0, Gain_pitX2, gcode16; /* Pitch gain */
- Word16 voice_fac; /* Voicing factor */
- Word32 gain_code = 0; /* Gain of code */
- Word32 Lgcode;
- Word16 gain_inov = 0; /* inovation gain */
- Word16 i, i_subfr, tmp1_fx, tmp_fx; /* tmp variables */
- Word16 unbits_ACELP;
- Word16 T0_min, T0_max; /* pitch and TC variables */
- Word16 T0, T0_frac; /* close loop integer pitch and fractional part */
- Word16 *pt_pitch; /* pointer to floating pitch buffer */
- Word16 g_corr[10]; /* ACELP correlation values and gain pitch */
- Word16 clip_gain; /* LSF clip gain */
- const Word16 *p_Aw, *p_Aq; /* pointer to LP filter coefficient vector */
- Word16 gain_preQ = 0; /* Gain of prequantizer excitation */
- Word16 code_preQ[L_SUBFR]; /* Prequantizer excitation */
- Word16 Jopt_flag; /* joint optimization flag */
- Word16 unbits_PI = 0; /* saved bits for PI */
- Word32 norm_gain_code = 0;
- Word16 L_frame_fx;
- Word16 shift_wsp;
- Word32 L_tmp;
- Word16 q_h1;
- Word16 shift, tmp;
- BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
- SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
- LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
-
- shift = shift_r; /* for IVAS, shift_r is always 0 */
- /* will be reusing the EVS shift strategy later on to allow of H1 overshoot */
- move16();
- L_frame_fx = st_fx->L_frame;
- move16();
-
- set16_fx( h1, 0, L_SUBFR + ( M + 1 ) );
-
- /*------------------------------------------------------------------*
- * Initializations
- *------------------------------------------------------------------*/
-
- gain_pit = 0;
- move16();
- gain_code = L_deposit_l( 0 );
- gain_preQ = 0;
- move16();
- unbits_PI = 0;
- move16();
- IF( EQ_16( L_frame_fx, L_FRAME ) )
- {
- T0_max = PIT_MAX;
- move16();
- T0_min = PIT_MIN;
- move16();
- }
- ELSE /* L_frame == L_FRAME16k */
- {
- T0_max = PIT16k_MAX;
- move16();
- T0_min = PIT16k_MIN;
- move16();
- }
-
- /**unbits = 0;move16();*/
- Jopt_flag = 0;
- move16();
- unbits_ACELP = *unbits; /* Q0 */
- move16();
- *unbits = 0;
- move16();
-
- p_Aw = Aw_fx; /* Q12 */
- p_Aq = Aq_fx; /* Q12 */
- pt_pitch = pitch_buf_fx;
- gain_preQ = 0;
- move16();
- set16_fx( code_preQ, 0, L_SUBFR );
- shift_wsp = add( Q_new, shift );
- if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) )
- {
- shift_wsp = sub( shift_wsp, 1 );
- }
-
- /*----------------------------------------------------------------*
- * ACELP subframe loop
- *----------------------------------------------------------------*/
-
- FOR( i_subfr = 0; i_subfr < L_frame_fx; i_subfr += L_SUBFR )
- {
- /*----------------------------------------------------------------*
- * Find the the excitation search target "xn" and innovation
- * target in residual domain "cn"
- * Compute impulse response, h1[], of weighted synthesis filter
- *----------------------------------------------------------------*/
-
- Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */
-
-
- find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq,
- res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
-
- q_h1 = sub( 14, norm_s( h1[0] ) );
- tmp = sub( 14, norm_arr( h1, L_SUBFR ) );
- shift = sub( q_h1, tmp ); /* shift is initialized to shift_r ( to 0) at the beginning of the scope, re-compute shift_wsp in case it has changed */
- shift_wsp = add( Q_new, shift );
- if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) )
- {
- shift_wsp = sub( shift_wsp, 1 );
- }
- Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/
- Scale_sig( h1, L_SUBFR, add( sub( 14, q_h1 ), shift ) );
- /* scaling of xn[] to limit dynamic at 12 bits */
- Scale_sig( xn, L_SUBFR, shift );
/*-----------------------------------------------------------------*
- * TC: subframe determination &
- * adaptive/glottal part of excitation construction
- *-----------------------------------------------------------------*/
-
- transition_enc_ivas_fx( st_fx, i_subfr, &tc_subfr, &Jopt_flag, &position, &T0, &T0_frac, &T0_min, &T0_max, exc_fx, y1,
- h1, xn, xn2, st_fx->clip_var_fx, &gain_pit, g_corr, &clip_gain, &pt_pitch, bwe_exc_fx, &unbits_ACELP, Q_new, shift );
-
- /*-----------------------------------------------------------------*
- * Transform domain contribution encoding - active frames
- *-----------------------------------------------------------------*/
-
- IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) )
- {
- transf_cdbk_enc_ivas_fx( st_fx, 0, i_subfr, cn, exc_fx, p_Aq, Aw_fx, h1, xn, xn2, y1, y2, Es_pred_fx,
- &gain_pit, gain_code, g_corr, clip_gain, &gain_preQ, code_preQ, unbits, Q_new, shift );
- }
-
- /*-----------------------------------------------------------------*
- * ACELP codebook search + pitch sharpening
- *-----------------------------------------------------------------*/
-
- inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag,
- i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new );
-
- test();
- test();
- test();
- if ( ( EQ_16( st_fx->L_frame, L_FRAME16k ) ) && ( tc_subfr == 0 ) && ( EQ_16( i_subfr, L_SUBFR ) ) && ( EQ_16( T0, 2 * L_SUBFR ) ) )
- {
- Jopt_flag = 1;
- move16();
- }
-
- /*-----------------------------------------------------------------*
- * Quantize the gains
- * Test quantized gain of pitch for pitch clipping algorithm
- * Update tilt of code: 0.0 (unvoiced) to 0.5 (voiced)
+ * Update memory of the weighting filter
*-----------------------------------------------------------------*/
- IF( Jopt_flag == 0 )
+ /*st->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]);*/
+ IF( st_fx->element_mode == EVS_MONO )
{
- /* SQ gain_code */
- gain_enc_tc_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y2, code, Es_pred_fx,
- &gain_pit, &gain_code, &gain_inov, &norm_gain_code, shift_wsp );
+ L_tmp = L_mult( gcode16, y2[L_SUBFR - 1] ); /* Q10 + Q_new */
}
ELSE
{
- IF( GT_32( st_fx->core_brate, ACELP_32k ) )
- {
- /* SQ gain_pit and gain_code */
- gain_enc_SQ_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y1, y2, code, Es_pred_fx,
- &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain, shift_wsp );
- }
- ELSE
- {
- /* VQ gain_pit and gain_code */
- gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame_fx, i_subfr, tc_subfr, xn, y1, shift_wsp, y2, code, Es_pred_fx,
- &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain );
- }
+ L_tmp = L_mult0( gcode16, y2[L_SUBFR - 1] );
}
- gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx );
-
- Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/
- gcode16 = round_fx_sat( Lgcode );
- hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); // Q15
-
- /*-----------------------------------------------------------------*
- * Update memory of the weighting filter
- *-----------------------------------------------------------------*/
-
- /*st->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]);*/
- L_tmp = L_mult0( gcode16, y2[L_SUBFR - 1] );
L_tmp = L_shl( L_tmp, add( 5, shift ) ); // Q_new+14+shift
L_tmp = L_negate( L_tmp );
L_tmp = L_mac( L_tmp, xn[L_SUBFR - 1], 16384 ); // Q_new-1+15+shift
@@ -654,7 +305,7 @@ Word16 encod_tran_ivas_fx(
{
FOR( i = 0; i < L_SUBFR; i++ )
{
- exc2_fx[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult_sat( gain_pit, exc_fx[i + i_subfr] ), 1 ) ); /* Q_exc */
+ exc2_fx[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult_sat( gain_pit, exc_fx[i + i_subfr] ), 1 ) ); /* Q_new / Q_exc */
}
}
ELSE
@@ -662,7 +313,7 @@ Word16 encod_tran_ivas_fx(
Gain_pitX2 = shl( gain_pit, 1 );
FOR( i = 0; i < L_SUBFR; i++ )
{
- exc2_fx[i + i_subfr] = mult_r( Gain_pitX2, exc_fx[i + i_subfr] ); /* Q_exc */
+ exc2_fx[i + i_subfr] = mult_r( Gain_pitX2, exc_fx[i + i_subfr] ); /* Q_new / Q_exc */
}
}
diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c
index eb614935941d19c4b4c467a5fd05438dc2e914db..160814bc07d2e3c1c319d16d9ca90ebd9b80386c 100644
--- a/lib_enc/enc_uv_fx.c
+++ b/lib_enc/enc_uv_fx.c
@@ -25,17 +25,19 @@ void encod_unvoiced_fx(
const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/
const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC Q0*/
const Word16 *res_fx, /* i : residual signal Q_new*/
- Word16 *syn_fx, /* o : core synthesis Q_new -1 */
+ Word16 *syn_fx, /* o : core synthesis Q_new-1 (EVS) / Qnew*/
Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/
Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
Word16 *voice_factors_fx, /* o : voicing factors Q15*/
Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/
- const Word16 Q_new,
- const Word16 shift )
+ const Word16 Q_new, /* i : Scaling factor */
+ const Word16 shift /* i : Shift needed to obtain 12 bits vectors */
+)
{
Word16 xn_fx[L_SUBFR]; /* Target vector for pitch search */
Word16 h1_fx[L_SUBFR]; /* Impulse response vector */
+ Word16 h2_fx[L_SUBFR]; /* Impulse response vector */
Word16 code_fx[L_SUBFR]; /* Fixed codebook excitation */
Word16 y2_fx[L_SUBFR]; /* Filtered algebraic excitation */
Word16 *pt_pitch_fx; /* pointer to floating pitch buffer */
@@ -56,6 +58,8 @@ void encod_unvoiced_fx(
Word32 gain_code_vect[2], Ltmp, Ltmp2;
Word16 i_subfr, Q_xn, Q_new_p5, tmp2, j, i;
Word16 index, i_subfr_idx;
+ Word16 unbits_PI;
+ Word16 q_h1;
acelp_cfg = &( st_fx->acelp_cfg );
SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
@@ -63,6 +67,7 @@ void encod_unvoiced_fx(
/*------------------------------------------------------------------*
* Initializations
*------------------------------------------------------------------*/
+
gain_pit_fx = 0;
move16();
@@ -79,7 +84,6 @@ void encod_unvoiced_fx(
p_Aw_fx = Aw_fx;
p_Aq_fx = Aq_fx;
pt_pitch_fx = pitch_buf_fx;
- move16();
Q_xn = add( sub( Q_new, 1 ), shift );
Q_new_p5 = add( Q_new, 5 );
@@ -94,248 +98,24 @@ void encod_unvoiced_fx(
i_subfr_idx = shr( i_subfr, 6 );
Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */
- find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx,
- res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx );
-
- /*Copy_Scale_sig(h1_fx, h2_fx, L_SUBFR, -2);*/
- Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
-
- /* scaling of xn[] to limit dynamic at 12 bits */
- Scale_sig( xn_fx, L_SUBFR, shift );
-
- /*----------------------------------------------------------------*
- * Unvoiced subframe processing
- *----------------------------------------------------------------*/
-
- IF( !uc_two_stage_flag )
+ IF( st_fx->element_mode == EVS_MONO )
{
- *pt_pitch_fx = gaus_encode_fx( st_fx, i_subfr, h1_fx, xn_fx, exc_fx, &hLPDmem->mem_w0, st_fx->clip_var_fx,
- &hLPDmem->tilt_code, code_fx, &L_gain_code_fx, y2_fx, &gain_inov_fx,
- &voice_fac_fx, &gain_pit_fx, Q_new, shift, &norm_gain_code_fx ); /* Q0 */
+ find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx,
+ res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx );
+
+ /*Copy_Scale_sig(h1_fx, h2_fx, L_SUBFR, -2);*/
+ Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
}
ELSE
{
- /*----------------------------------------------------------------*
- * Unvoiced subframe processing in two stages
- *----------------------------------------------------------------*/
-
- /* No adaptive codebook (UC) */
- set16_fx( y1, 0, L_SUBFR );
- set16_fx( exc_fx + i_subfr, 0, L_SUBFR );
-
- /*-----------------------------------------------------------------*
- * Gain clipping test to avoid unstable synthesis on frame erasure
- * or in case of floating point encoder & fixed p. decoder
- *-----------------------------------------------------------------*/
-
- Mode2_gp_clip_fx( st_fx->voicing_fx, i_subfr, st_fx->coder_type, xn_fx, st_fx->clip_var_fx, L_SUBFR, Q_xn );
- *pt_pitch_fx = L_SUBFR;
- move16();
-
- /*----------------------------------------------------------------------*
- * Encode the algebraic innovation *
- *----------------------------------------------------------------------*/
-
- E_ACELP_innovative_codebook_fx( exc_fx, *pt_pitch_fx, 0, 1, gain_pit_fx, hLPDmem->tilt_code, acelp_cfg, i_subfr, p_Aq_fx, h1_fx, xn_fx, cn_fx, y1, y2_fx, (Word8) st_fx->acelp_autocorr, &prm, code_fx, shift, st_fx->L_frame, st_fx->last_L_frame, st_fx->total_brate );
-
- E_ACELP_xy2_corr( xn_fx, y1, y2_fx, &g_corr, L_SUBFR, Q_xn );
-
- g_corr.y2y2_e = sub( g_corr.y2y2_e, 18 ); /* -18 (y2*y2: Q9*Q9) */
- g_corr.xy2_e = sub( g_corr.xy2_e, add( Q_xn, 9 ) ); /* -(Q_xn+9) (xn: Q_xn y2: Q9) */
- g_corr.y1y2_e = sub( g_corr.y1y2_e, add( Q_xn, 9 ) ); /* -(Q_xn+9) (y1: Q_xn y2: Q9) */
- g_corr.xx_e = sub( g_corr.xx_e, add( Q_xn, Q_xn ) ); /* -(Q_xn+Q_xn) (xn: Q_xn) */
-
- assert( gain_pit_fx == 0 );
- gauss_L2_fx( h1_fx, code2, y2_fx, y22, &gain_code2, &g_corr, gain_pit_fx, hLPDmem->tilt_code, p_Aq_fx, acelp_cfg->formant_enh_num, &( st_fx->seed_acelp ), shift );
-
- /*----------------------------------------------------------*
- * - Compute the fixed codebook gain *
- * - quantize fixed codebook gain *
- *----------------------------------------------------------*/
-
- index = gain_enc_uv_fx( code_fx, code2, L_SUBFR, &gain_pit_fx, &L_gain_code_fx, &gain_code2,
- st_fx->flag_noisy_speech_snr, &g_corr, Es_pred, &norm_gain_code_fx, &gain_inov_fx, FUNC_GAIN_ENC_GACELP_UV ); /* Q0 */
-
-#ifdef DEBUGGING
- assert( st_fx->acelp_cfg.gains_mode[i_subfr_idx] == 7 && "Error: UC two-stage, only 5+2 gain Q is supported" );
-#endif
- push_indice( st_fx->hBstr, IND_GAIN, index, st_fx->acelp_cfg.gains_mode[i_subfr_idx] );
-
- gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit_fx, st_fx->clip_var_fx );
-
- gain_code_vect[0] = L_gain_code_fx;
- move32();
- gain_code_vect[1] = L_gain_code_fx;
- move32();
-
- /*----------------------------------------------------------*
- * - voice factor (for pitch enhancement) *
- *----------------------------------------------------------*/
-
- E_UTIL_voice_factor( exc_fx, i_subfr, code_fx, gain_pit_fx, L_gain_code_fx, &voice_fac_fx, &( hLPDmem->tilt_code ), L_SUBFR, acelp_cfg->voice_tilt, Q_new, shift );
-
- IF( st_fx->Opt_RF_ON )
- {
- st_fx->hRF->rf_tilt_buf[i_subfr_idx] = hLPDmem->tilt_code;
- }
-
- /*-----------------------------------------------------------------*
- * Update memory of the weighting filter
- *-----------------------------------------------------------------*/
+ find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx,
+ res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx );
- /* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */
- Ltmp = Mpy_32_16_1( L_gain_code_fx, y2_fx[L_SUBFR - 1] ); /* Q10 */
- Ltmp = L_shl( Ltmp, add( 5, Q_xn ) ); /* Q15 + Q_xn */
- Ltmp = L_mac( Ltmp, y1[L_SUBFR - 1], gain_pit_fx ); /* Q15 + Q_xn */
- /* Add Gaussian contribution*/
- Ltmp2 = Mpy_32_16_1( gain_code2, y22[L_SUBFR - 1] ); /* Q10 */
- Ltmp2 = L_shl( Ltmp2, add( 5, Q_xn ) ); /* Q15 + Q_xn */
- Ltmp = L_add( Ltmp, Ltmp2 ); /* Q15 + Q_xn */
- hLPDmem->mem_w0 = sub( xn_fx[L_SUBFR - 1], round_fx( L_shl( Ltmp, 1 ) ) ); /* Q_xn */
- move16();
- BASOP_SATURATE_WARNING_OFF_EVS;
- hLPDmem->mem_w0 = shr_sat( hLPDmem->mem_w0, shift ); /*Qnew-1*/
- BASOP_SATURATE_WARNING_ON_EVS;
-
- /*-------------------------------------------------------*
- * - Find the total excitation. *
- *-------------------------------------------------------*/
-
- tmp2 = shr( L_SUBFR, 1 );
- FOR( j = 0; j < 2; j++ )
- {
- FOR( i = sub( tmp2, shr( L_SUBFR, 1 ) ); i < tmp2; i++ )
- {
- /* code in Q9, gain_pit in Q14; exc Q_new */
- Ltmp = Mpy_32_16_1( gain_code2, code2[i] ); /* Q10 */
- Ltmp = L_shl( Ltmp, Q_new_p5 ); /* Q15 + Q_new */
- Ltmp = L_mac( Ltmp, gain_pit_fx, exc_fx[i + i_subfr] ); /* Q_new + Q15 */
- Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code_fx[i] ); /* Q10 */
- Ltmp2 = L_shl( Ltmp2, Q_new_p5 ); /* Q15 + Q_new */
- Ltmp = L_add( Ltmp, Ltmp2 ); /* Q15 + Q_new */
- Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */
- exc_fx[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */
- }
- tmp2 = L_SUBFR;
- move16();
- }
+ q_h1 = sub( 14, norm_s( h1_fx[0] ) );
+ Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) );
+ Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) );
}
- *tmp_noise_fx = extract_h( norm_gain_code_fx ); /* Q0 */
- voice_factors_fx[i_subfr / L_SUBFR] = 0;
- move16();
-
- interp_code_5over2_fx( &exc_fx[i_subfr], &bwe_exc_fx[i_subfr * HIBND_ACB_L_FAC], L_SUBFR );
-
- /*-----------------------------------------------------------------*
- * Synthesize speech to update mem_syn[].
- * Update A(z) filters
- *-----------------------------------------------------------------*/
-
- Syn_filt_s( 1, p_Aq_fx, M, &exc_fx[i_subfr], &syn_fx[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 );
-
- p_Aw_fx += ( M + 1 );
- p_Aq_fx += ( M + 1 );
- pt_pitch_fx++;
- }
-
- /* SC-VBR */
- hSC_VBR->prev_ppp_gain_pit_fx = gain_pit_fx; /* Q14 */
- move16();
- hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */
- move16();
-
- return;
-}
-
-
-void encod_unvoiced_ivas_fx(
- Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *speech_fx, /* i : Input speech Q_new*/
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
- const Word16 *Aq_fx, /* i : 12k8 Lp coefficient Q12*/
- const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/
- const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC Q0*/
- const Word16 *res_fx, /* i : residual signal Q_new*/
- Word16 *syn_fx, /* o : core synthesis Q_new*/
- Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/
- Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
- Word16 *voice_factors_fx, /* o : voicing factors Q15*/
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/
- const Word16 Q_new,
- const Word16 shift )
-{
- Word16 xn_fx[L_SUBFR]; /* Target vector for pitch search */
- Word16 h1_fx[L_SUBFR]; /* Impulse response vector */
- Word16 h2_fx[L_SUBFR]; /* Impulse response vector */
- Word16 code_fx[L_SUBFR]; /* Fixed codebook excitation */
- Word16 y2_fx[L_SUBFR]; /* Filtered algebraic excitation */
- Word16 *pt_pitch_fx; /* pointer to floating pitch buffer */
- Word16 gain_pit_fx; /* Pitch gain */
- Word16 voice_fac_fx; /* Voicing factor */
- Word32 L_gain_code_fx; /* gain of code */
- Word16 gain_inov_fx; /* inovative gain */
- Word16 cn_fx[L_SUBFR]; /* Target vector in residual domain */
- Word16 y1[L_SUBFR]; /* Filtered adaptive excitation */
- Word16 code2[L_SUBFR]; /* Gaussian excitation */
- Word16 y22[L_SUBFR]; /* Filtered Gaussian excitation */
- // Word16 prm_t[2 * NPRM_DIV], *prm = prm_t;
- const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector */
- Word32 norm_gain_code_fx;
- ACELP_config *acelp_cfg;
- ACELP_CbkCorr g_corr;
- Word32 gain_code2;
- Word32 gain_code_vect[2], Ltmp, Ltmp2;
- Word16 i_subfr, Q_xn, Q_new_p5, tmp2, j, i;
- Word16 index, i_subfr_idx;
- Word16 unbits_PI;
- Word16 q_h1;
- acelp_cfg = &( st_fx->acelp_cfg );
- SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
- LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
-
- /*------------------------------------------------------------------*
- * Initializations
- *------------------------------------------------------------------*/
-
- gain_pit_fx = 0;
- move16();
-
- test();
- test();
- test();
- IF( st_fx->Opt_SC_VBR && st_fx->vad_flag == 0 && ( EQ_16( hSC_VBR->last_ppp_mode, 1 ) || EQ_16( hSC_VBR->last_nelp_mode, 1 ) ) )
- {
- /* SC_VBR - reset the encoder, to avoid memory not updated issue for the
- case when UNVOICED mode is used to code inactive speech */
- CNG_reset_enc_fx( st_fx, hLPDmem, pitch_buf_fx, voice_factors_fx, 1 );
- }
-
- p_Aw_fx = Aw_fx;
- p_Aq_fx = Aq_fx;
- pt_pitch_fx = pitch_buf_fx;
- Q_xn = add( sub( Q_new, 1 ), shift );
- Q_new_p5 = add( Q_new, 5 );
-
- FOR( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR )
- {
- /*----------------------------------------------------------------*
- * Bandwidth expansion of A(z) filter coefficients
- * Find the excitation search target "xn" and innovation target in residual domain "cn"
- * Compute impulse response, h1[], of weighted synthesis filter
- *----------------------------------------------------------------*/
-
- i_subfr_idx = shr( i_subfr, 6 );
- Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */
-
- find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx,
- res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx );
-
- q_h1 = sub( 14, norm_s( h1_fx[0] ) );
- Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) );
- Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) );
-
/* scaling of xn[] to limit dynamic at 12 bits */
Scale_sig( xn_fx, L_SUBFR, shift ); // Q_new - 1 + shift
@@ -366,16 +146,28 @@ void encod_unvoiced_ivas_fx(
*-----------------------------------------------------------------*/
Mode2_gp_clip_fx( st_fx->voicing_fx, i_subfr, st_fx->coder_type, xn_fx, st_fx->clip_var_fx, L_SUBFR, Q_xn );
+
*pt_pitch_fx = L_SUBFR << 6;
move16();
+ if ( st_fx->element_mode == EVS_MONO )
+ {
+ *pt_pitch_fx = L_SUBFR;
+ move16();
+ }
/*----------------------------------------------------------------------*
* Encode the algebraic innovation *
*----------------------------------------------------------------------*/
- inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame,
- UNVOICED, st_fx->bwidth, 1, i_subfr, -1, p_Aq_fx,
- gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift, Q_new );
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ E_ACELP_innovative_codebook_fx( exc_fx, *pt_pitch_fx, 0, 1, gain_pit_fx, hLPDmem->tilt_code, acelp_cfg, i_subfr, p_Aq_fx, h1_fx, xn_fx, cn_fx, y1, y2_fx, (Word8) st_fx->acelp_autocorr, &prm, code_fx, shift, st_fx->L_frame, st_fx->last_L_frame, st_fx->total_brate );
+ }
+ ELSE
+ {
+ inov_encode_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, 1, i_subfr, -1, p_Aq_fx,
+ gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift, Q_new );
+ }
E_ACELP_xy2_corr( xn_fx, y1, y2_fx, &g_corr, L_SUBFR, Q_xn );
@@ -389,7 +181,14 @@ void encod_unvoiced_ivas_fx(
move16();
assert( gain_pit_fx == 0 );
- gauss_L2_ivas_fx( h1_fx, code2, y2_fx, y22, &gain_code2, &g_corr, gain_pit_fx, hLPDmem->tilt_code, p_Aq_fx, acelp_cfg->formant_enh_num, &( st_fx->seed_acelp ), shift );
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ gauss_L2_fx( h1_fx, code2, y2_fx, y22, &gain_code2, &g_corr, gain_pit_fx, hLPDmem->tilt_code, p_Aq_fx, acelp_cfg->formant_enh_num, &( st_fx->seed_acelp ), shift );
+ }
+ ELSE
+ {
+ gauss_L2_ivas_fx( h1_fx, code2, y2_fx, y22, &gain_code2, &g_corr, gain_pit_fx, hLPDmem->tilt_code, p_Aq_fx, acelp_cfg->formant_enh_num, &( st_fx->seed_acelp ), shift );
+ }
/*----------------------------------------------------------*
* - Compute the fixed codebook gain *
diff --git a/lib_enc/eval_pit_contr_fx.c b/lib_enc/eval_pit_contr_fx.c
index 33b35f0ccb1d91602065c2f701ed351ede04b744..dae547e35456e4dd0c35e24426621ba2c87234ad 100644
--- a/lib_enc/eval_pit_contr_fx.c
+++ b/lib_enc/eval_pit_contr_fx.c
@@ -89,7 +89,17 @@ Word16 Pit_exc_contribution_len_fx(
move16();
}
- minimum_fx( pitch_buf, nb_subfr, &low_pit );
+#ifdef FIX_1904_HARM_GSC_ENC
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ minimum_fx( pitch_buf, shr( st_fx->L_frame, 6 ), &low_pit ); // This should be the only version if #2253 is included in #1292
+ }
+ ELSE
+#endif
+ {
+ minimum_fx( pitch_buf, nb_subfr, &low_pit );
+ }
+
exp1 = norm_s( low_pit );
tmp = shl( low_pit, exp1 );
tmp_dec = 12800;
@@ -381,13 +391,18 @@ Word16 Pit_exc_contribution_len_fx(
set16_fx( pitch_buf, shl( L_SUBFR, 6 ), NB_SUBFR16k );
/* pitch contribution useless - delete all previously written indices belonging to pitch contribution */
+#ifdef FIX_1904_HARM_GSC_ENC
+ FOR( i = TAG_ACELP_SUBFR_LOOP_START; i < TAG_ACELP_SUBFR_LOOP_END; i++ )
+#else
for ( i = TAG_ACELP_SUBFR_LOOP_START; i < TAG_ACELP_SUBFR_LOOP_END; i++ )
+#endif
{
delete_indice( hBstr, i );
}
delete_indice( hBstr, IND_ES_PRED );
}
+
IF( LT_32( st_fx->core_brate, CFREQ_BITRATE ) )
{
IF( LT_32( st_fx->core_brate, ACELP_9k60 ) )
@@ -416,7 +431,7 @@ Word16 Pit_exc_contribution_len_fx(
return last_pit_bin;
}
-
+#ifndef FIX_1904_HARM_GSC_ENC
Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin where pitch contribution is significant */
Encoder_State *st_fx, /* i/o: state structure */
const Word16 *dct_res, /* i : DCT of residual Q_new*/
@@ -778,3 +793,4 @@ Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin wher
return last_pit_bin;
}
+#endif
diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c
index 416c2f4e974134a63139b6f4cb74cd4dc16b3a02..45e58c5e8b622451cb208e309a3087eb75cdc9be 100644
--- a/lib_enc/evs_enc_fx.c
+++ b/lib_enc/evs_enc_fx.c
@@ -79,9 +79,6 @@ ivas_error evs_enc_fx(
#endif
ivas_error error;
SC_VBR_ENC_HANDLE hSC_VBR = st->hSC_VBR;
- // NOISE_EST_HANDLE hNoiseEst = st->hNoiseEst;
- // VAD_HANDLE hVAD = st->hVAD;
- // DTX_ENC_HANDLE hDtxEnc = st->hDtxEnc;
TD_CNG_ENC_HANDLE hTdCngEnc = st->hTdCngEnc;
LPD_state_HANDLE hLPDmem = st->hLPDmem;
TD_BWE_ENC_HANDLE hBWE_TD = st->hBWE_TD;
@@ -95,7 +92,6 @@ ivas_error evs_enc_fx(
Q_shb_spch = 0;
move16(); /* to avoid compiler warnings */
-
/*------------------------------------------------------------------*
* Initializiation
*-----------------------------------------------------------------*/
@@ -176,19 +172,19 @@ ivas_error evs_enc_fx(
/*---------------------------------------------------------------------*
* Pre-processing
*---------------------------------------------------------------------*/
+
#ifdef FIX_I4_OL_PITCH
- pre_proc( st, input_frame, old_inp_12k8, old_inp_16k, &inp, fr_bands, &Etot, &ener, A, Aw, epsP, lsp_new, lsp_mid, &vad_hover_flag, &attack_flag, new_inp_resamp16k, &Voicing_flag, realBuffer, imagBuffer, &hq_core_type );
+ pre_proc_fx( st, input_frame, old_inp_12k8, old_inp_16k, &inp, fr_bands, &Etot, &ener, A, Aw, epsP_h, epsP_l, epsP, lsp_new, lsp_mid, &vad_hover_flag,
+ &attack_flag, new_inp_resamp16k, &Voicing_flag, realBuffer, imagBuffer, &cldfbScale, hLPDmem->old_exc, &hq_core_type, &Q_new, &shift, Q_r );
#else
pre_proc_fx( st, input_frame, old_inp_12k8, old_inp_16k, &inp, fr_bands, &Etot, &ener,
pitch_orig, A, Aw, epsP_h, epsP_l, epsP, lsp_new, lsp_mid, &vad_hover_flag,
&attack_flag, new_inp_resamp16k, &Voicing_flag, realBuffer, imagBuffer, &cldfbScale, hLPDmem->old_exc,
&hq_core_type, &Q_new, &shift, Q_r );
#endif
- // st->sharpFlag = sharpFlag;
IF( EQ_16( st->mdct_sw, MODE2 ) )
{
-
Mpy_32_16_ss( st->total_brate, 5243, &L_tmp, &lsb ); /* 5243 is 1/50 in Q18. (0+18-15=3) */
st->bits_frame_nominal = extract_l( L_shr( L_tmp, 3 ) ); /* Q0 */
@@ -260,7 +256,7 @@ ivas_error evs_enc_fx(
* Preprocessing (preparing) for ACELP/HQ core switching
*---------------------------------------------------------------------*/
- core_switching_pre_enc_fx( st, old_inp_12k8, old_inp_16k, 0, 0 );
+ core_switching_pre_enc_fx( st, old_inp_12k8, 0, old_inp_16k, 0, 0, 0 );
/*---------------------------------------------------------------------*
* ACELP core encoding
@@ -271,6 +267,7 @@ ivas_error evs_enc_fx(
acelp_core_enc_fx( st, inp, ener, A, Aw, epsP_h, epsP_l, lsp_new, lsp_mid, vad_hover_flag,
attack_flag, bwe_exc_extended, voice_factors, old_syn_12k8_16k, pitch_buf, &unbits, NULL, Q_new, shift );
}
+
/*---------------------------------------------------------------------*
* HQ core encoding
*---------------------------------------------------------------------*/
@@ -283,6 +280,7 @@ ivas_error evs_enc_fx(
/*---------------------------------------------------------------------*
* Postprocessing for ACELP/HQ core switching
*---------------------------------------------------------------------*/
+
core_switching_post_enc_fx( st, old_inp_12k8, old_inp_16k, A, shift, Q_new, st->Q_syn2, &Q_synth );
#ifndef FIX_I4_OL_PITCH
IF( EQ_16( st->core, HQ_CORE ) )
@@ -427,8 +425,11 @@ ivas_error evs_enc_fx(
IF( EQ_16( st->extl, WB_TBE ) )
{
/* WB TBE encoder */
+#ifdef HARMONIZE_TBE
+ wb_tbe_enc_fx( st, hb_speech, bwe_exc_extended, Q_new, voice_factors, pitch_buf );
+#else
wb_tbe_enc_fx( st, st->coder_type, hb_speech, bwe_exc_extended, Q_new, voice_factors, pitch_buf, st->voicing_fx );
-
+#endif
IF( EQ_16( st->codec_mode, MODE2 ) )
{
tbe_write_bitstream_fx( st );
@@ -444,6 +445,7 @@ ivas_error evs_enc_fx(
* SWB(FB) TBE encoding
* SWB BWE encoding
*---------------------------------------------------------------------*/
+
test();
IF( !st->Opt_SC_VBR && GE_32( st->input_Fs, 32000 ) )
{
@@ -473,7 +475,11 @@ ivas_error evs_enc_fx(
IF( EQ_16( st->extl, FB_TBE ) )
{
/* FB TBE encoder */
+#ifdef HARMONIZE_TBE
+ fb_tbe_enc_fx( st, st->input_fx, fb_exc, Q_fb_exc, 0 );
+#else
fb_tbe_enc_fx( st, st->input_fx, fb_exc, Q_fb_exc );
+#endif
}
IF( EQ_16( st->codec_mode, MODE2 ) )
@@ -531,9 +537,13 @@ ivas_error evs_enc_fx(
* Channel-aware mode - write signaling information into the bitstream
*---------------------------------------------------------------------*/
- signalling_enc_rf_fx( st );
+ signaling_enc_rf_fx( st );
+
+ /*---------------------------------------------------------------------*
+ * Updates
+ *---------------------------------------------------------------------*/
- updt_enc_common_fx( st, Etot, Q_new );
+ updt_enc_common_fx( st, Q_new );
if ( EQ_16( st->mdct_sw, MODE1 ) )
{
@@ -642,9 +652,11 @@ static void initFrameHeader_loc( Encoder_State *st )
*
* Write MODE2 frame header
*-------------------------------------------------------------------*/
-static void writeFrameHeader_loc( Encoder_State *st )
-{
+static void writeFrameHeader_loc(
+ Encoder_State *st /* i/o: encoder state structure */
+)
+{
BSTR_ENC_HANDLE hBstr = st->hBstr;
IF( NE_32( st->core_brate, FRAME_NO_DATA ) )
diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c
index c3958e543691816892627449daaefde7c8b388bf..33181714765ea239bdf078dacdcc47392a934156 100644
--- a/lib_enc/ext_sig_ana_fx.c
+++ b/lib_enc/ext_sig_ana_fx.c
@@ -424,7 +424,7 @@ void core_signal_analysis_high_bitrate_fx(
interleaveBuf[2 * i + 1] = spectrum[frameno][tcx5SizeFB + i]; /* exp(spectrum_e) */
move32();
}
- MVR2R_WORD32( interleaveBuf, spectrum[frameno], tcx10SizeFB );
+ Copy32( interleaveBuf, spectrum[frameno], tcx10SizeFB );
}
/*--------------------------------------------------------------*
@@ -454,7 +454,7 @@ void core_signal_analysis_high_bitrate_fx(
}
/* Copy memory */
- MVR2R_WORD16( lsp_new, st->lspold_enc_fx, M ); /* Q15 */
+ Copy( lsp_new, st->lspold_enc_fx, M ); /* Q15 */
}
}
@@ -599,7 +599,7 @@ void core_signal_analysis_high_bitrate_ivas_fx(
{
Copy( st->speech_enc + st->encoderLookahead_enc, st->new_speech_enc_pe, L_frame ); // Assuming both exp_buf_speech_enc_pe and exp_buf_speech_enc are same
- PREEMPH_FX( st->new_speech_enc_pe, st->preemph_fac, L_frame, &( st->mem_preemph_enc ) ); // using this to keep values alligned in Q-1
+ preemph_fx( st->new_speech_enc_pe, st->preemph_fac, L_frame, &( st->mem_preemph_enc ) ); // using this to keep values alligned in Q-1
}
/* Rescale Memory */
@@ -1132,7 +1132,7 @@ void core_signal_analysis_high_bitrate_ivas_fx(
IF( EQ_16( transform_type[frameno], TCX_20 ) && NE_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) )
{
Word16 Q;
- Copy_Scale_sig_16_32_no_sat( mdstWin, L_tmpbuf, N_MAX + L_MDCT_OVLP_MAX, 16 );
+ Copy_Scale_sig_16_32_no_sat( mdstWin, L_tmpbuf, L_subframe, 16 );
Q = add( q_mdstWin, 16 );
move16();
@@ -1221,7 +1221,7 @@ void core_signal_analysis_high_bitrate_ivas_fx(
interleaveBuf[2 * i + 1] = hTcxEnc->spectrum_fx[frameno][tcx5SizeFB + i]; /* hTcxEnc->spectrum_e */
move32();
}
- MVR2R_WORD32( interleaveBuf, hTcxEnc->spectrum_fx[frameno], tcx10SizeFB );
+ Copy32( interleaveBuf, hTcxEnc->spectrum_fx[frameno], tcx10SizeFB );
}
/*--------------------------------------------------------------*
@@ -1259,7 +1259,7 @@ void core_signal_analysis_high_bitrate_ivas_fx(
IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
/* Copy memory */
- MVR2R_WORD16( lsp_new, st->lspold_enc_fx, M );
+ Copy( lsp_new, st->lspold_enc_fx, M );
}
return;
diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c
index 5b3ab4792a05a9c77c52a5183f23f976b7a2f5bd..9a236731f51865204b2cfdcd8f9a5b65b6aec7fe 100644
--- a/lib_enc/find_tar_fx.c
+++ b/lib_enc/find_tar_fx.c
@@ -173,7 +173,8 @@ void find_targets_ivas_fx(
{
Word16 i;
Word16 temp[M + 6 * L_SUBFR]; /* error of quantization */
- Word16 scale, scaleq, j, d, s, s2, tmp;
+ Word16 scale, scaleq, j, d, s, tmp;
+ Word32 s2;
Word16 Aqs[M + 1];
Word32 h1_32[6 * L_SUBFR];
Word16 sf;
@@ -233,44 +234,44 @@ void find_targets_ivas_fx(
{
Copy( p_Aq, Aqs, M + 1 ); /* Q12 */
s = add( scaleq, 1 );
- s2 = shr( 16384, d );
+ s2 = L_shr( ( 16384 << 16 ), d );
}
ELSE
{
Copy_Scale_sig( p_Aq, Aqs, M + 1, d ); /* Q12 */
s = add( scale, 1 );
- s2 = 16384;
- move16();
+ s2 = ( 16384 << 16 );
+ move32();
}
set32_fx( h1_32, 0, L_subfr );
FOR( i = 0; i < M; i++ )
{
- Ltmp64 = W_mult_16_16( Ap[i], s2 ); /* Q27 */
+ Ltmp64 = W_mult_32_16( s2, Ap[i] ); /* Q27 */
FOR( j = 1; j <= i; j++ )
{
- Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */
+ Ltmp64 = W_msu_32_16( Ltmp64, L_shl_sat( h1_32[i - j], s ), Aqs[j] ); /* Q27 */
}
- h1_32[i] = W_extract_l( Ltmp64 ); /* Q27 */
+ h1_32[i] = W_sat_m( Ltmp64 ); /* Q27 */
move32();
}
- Ltmp64 = W_mult_16_16( Ap[i], s2 ); /* Q27 */
+ Ltmp64 = W_mult_32_16( s2, Ap[i] ); /* Q27 */
FOR( j = 1; j <= M; j++ )
{
- Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */
+ Ltmp64 = W_msu_32_16( Ltmp64, L_shl_sat( h1_32[i - j], s ), Aqs[j] ); /* Q27 */
}
- h1_32[M] = W_extract_l( Ltmp64 ); /* Q27 */
+ h1_32[M] = W_sat_m( Ltmp64 ); /* Q27 */
move32();
FOR( i = M + 1; i < L_subfr; i++ )
{
- Ltmp64 = W_msu_16_16( 0, Aqs[1], extract_h( L_shl_sat( h1_32[i - 1], s ) ) ); /* Q27 */
+ Ltmp64 = W_msu_32_16( 0, L_shl_sat( h1_32[i - 1], s ), Aqs[1] ); /* Q27 */
FOR( j = 2; j <= M; j++ )
{
- Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */
+ Ltmp64 = W_msu_32_16( Ltmp64, L_shl_sat( h1_32[i - j], s ), Aqs[j] ); /* Q27 */
}
- h1_32[i] = W_extract_l( Ltmp64 ); /* Q27 */
+ h1_32[i] = W_sat_m( Ltmp64 ); /* Q27 */
move32();
}
diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c
index a0fa4dbbd163b2de097f81659d929125cf00aaf7..063989affe6fee9784922d101ecaa172c316fd8c 100644
--- a/lib_enc/find_uv_fx.c
+++ b/lib_enc/find_uv_fx.c
@@ -1,14 +1,15 @@
/*====================================================================================
EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0
====================================================================================*/
+
#include
-#include "options.h" /* Compilation switches */
-#include "cnst.h" /* Common constants */
-//#include "prot_fx.h" /* Function prototypes */
+#include "options.h" /* Compilation switches */
+#include "cnst.h" /* Common constants */
#include "rom_com.h" /* Function prototypes */
#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
+
/*-------------------------------------------------------------------*
* Local constants
*-------------------------------------------------------------------*/
@@ -23,9 +24,10 @@
* energy is trailing off after a spike
*-------------------------------------------------------------------*/
-static Word16 find_ener_decrease_fx( /* o : maximum energy ratio Q10*/
- const Word16 ind_deltaMax, /* i : index of the beginning of maximum energy search Q0*/
- const Word32 *pt_enr_ssf /* i : Pointer to the energy buffer Qx*/
+/*! r: maximum energy ratio Q10*/
+static Word16 find_ener_decrease_fx(
+ const Word16 ind_deltaMax, /* i : index of the beginning of maximum energy search Q0*/
+ const Word32 *pt_enr_ssf /* i : Pointer to the energy buffer Qx*/
)
{
Word16 i, j, end, flag;
@@ -65,7 +67,6 @@ static Word16 find_ener_decrease_fx( /* o : maximum
minEnr = L_min( minEnr, pt_enr_ssf[i] ); /* Qx */
}
-
minEnr = L_add_sat( minEnr, 100000 );
exp0 = norm_l( minEnr );
wtmp0 = extract_h( L_shl( minEnr, exp0 ) );
@@ -77,27 +78,31 @@ static Word16 find_ener_decrease_fx( /* o : maximum
return dE2;
}
+
/*-------------------------------------------------------------------*
* find_uv_fx()
*
* Decision about coder type
*-------------------------------------------------------------------*/
-Word16 find_uv_fx( /* o : coding type */
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/
- const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/
- const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/
- const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/
- const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/
- const Word16 relE, /* i : relative frame energy Q8*/
- const Word16 Etot, /* i : total energy Q8*/
- const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE*/
- const Word16 Q_new,
- Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/
- const Word16 shift,
- const Word16 last_core_orig /* i : original last core Q0*/
-)
+/*! r: coder type */
+Word16 find_uv_fx(
+ Encoder_State *st_fx, /* i/o: encoder state structure */
+ const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/
+ const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/
+ const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/
+ const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/
+ Word32 *dE1X, /* o : sudden energy increase for S/M classifier Q13*/
+ const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/
+ const Word16 relE, /* i : relative frame energy Q8*/
+ const Word16 Etot, /* i : total energy Q8*/
+ const Word32 hp_E[], /* i : energy in HF q_hp_E*/
+ Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/
+ const Word16 last_core_orig, /* i : original last core Q0*/
+ STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */
+ const Word16 Q_new,
+ const Word16 shift,
+ const Word16 q_hp_E )
{
Word16 coder_type, i;
Word32 mean_ee, dE1, fac_32;
@@ -106,7 +111,7 @@ Word16 find_uv_fx( /* o : coding type
Word16 dE2;
Word16 ind_deltaMax, tmp_offset_flag;
Word32 Ltmp0, *pt_enr_ssf, *pt_enr_ssf1, dE2_th;
- Word16 exp0, exp1, Q_in;
+ Word16 exp0, exp1;
Word16 wtmp0, wtmp1;
Word16 fac, mean_voi3, dE3;
Word16 relE_thres;
@@ -117,497 +122,16 @@ Word16 find_uv_fx( /* o : coding type
SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
Word16 Last_Resort;
Word16 vadnoise;
+ Word16 Q_in, loc_lp_noise;
- IF( hSC_VBR != NULL )
- {
- Last_Resort = hSC_VBR->Last_Resort; /* Q0 */
- vadnoise = hSC_VBR->vadnoise_fx;
- move16();
- move16();
- }
- ELSE
- {
- Last_Resort = 0;
- vadnoise = 0;
- move16();
- move16();
- }
-
- Q_in = sub( Q_new, 1 );
-
- /*-----------------------------------------------------------------*
- * Detect sudden energy increases to catch voice and music
- * temporal events (dE1)
- *
- * - Find maximum energy per short subblocks.
- * Two subblock sets are used shifted by half the subblock length
- * - Find maximum energy ratio between adjacent subblocks
- *-----------------------------------------------------------------*/
-
- /* Find maximum energy per short subblocks */
- pt_speech = speech - SSF; /* Q_new */
- pt_enr_ssf = enr_ssf + 2 * NB_SSF;
- FOR( i = 0; i < 2 * ( NB_SSF + 1 ); i++ )
- {
- emaximum_fx( Q_in, pt_speech, SSF, pt_enr_ssf );
- pt_speech += ( SSF / 2 );
- pt_enr_ssf++;
- }
-
- dE1 = 0;
- move16();
- ind_deltaMax = 0;
- move16();
- pt_enr_ssf = enr_ssf + 2 * NB_SSF;
- pt_enr_ssf1 = pt_enr_ssf + 2;
-
- /* Test on energy increase between adjacent sub-subframes */
- exp1 = 0;
- move16();
- FOR( i = 0; i < 2 * NB_SSF; i++ )
- {
- /*fac = *pt_enr_ssf1 / (*pt_enr_ssf + 1);*/
- Ltmp0 = L_max( *pt_enr_ssf, 1 );
- exp0 = norm_l( Ltmp0 );
- wtmp0 = extract_h( L_shl( Ltmp0, exp0 ) );
- exp1 = sub( norm_l( *pt_enr_ssf1 ), 1 );
- wtmp1 = extract_h( L_shl( *pt_enr_ssf1, exp1 ) );
- fac = div_s( wtmp1, wtmp0 );
- fac_32 = L_shr_sat( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ) ); /* fac32 in Q13*/
-
- if ( GT_32( fac_32, dE1 ) )
- {
- ind_deltaMax = i;
- move16();
- }
-
- dE1 = L_max( dE1, fac_32 ); /* Q13 */
-
- pt_enr_ssf++;
- pt_enr_ssf1++;
- }
-
- /*-----------------------------------------------------------------*
- * Average spectral tilt
- * Average voicing (normalized correlation)
- *-----------------------------------------------------------------*/
-
- /*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */
- mean_ee = L_add_sat( L_add_sat( st_fx->ee_old_fx, ee[0] ), ee[1] ); /* Q6 */
- mean_ee = Mult_32_16( mean_ee, 10923 /* 1/3 in Q15 */ ); /*Q6*/
-
- /* mean_voi3 = 1.0f/3.0f * (voicing[0] + voicing[1] + voicing[2]);*/
- Ltmp0 = L_mult( st_fx->voicing_fx[0], 10923 /* 1/3 in Q15 */ ); /* Q31 */
- Ltmp0 = L_mac( Ltmp0, st_fx->voicing_fx[1], 10923 /* 1/3 in Q15 */ ); /* Q31 */
- mean_voi3 = mac_r_sat( Ltmp0, st_fx->voicing_fx[2], 10923 /* 1/3 in Q15 */ ); /*Q15*/
- /*-----------------------------------------------------------------*
- * Total frame energy difference (dE3)
- *-----------------------------------------------------------------*/
-
- dE3 = sub( Etot, hNoiseEst->Etot_last_fx ); /*Q8*/
-
- /*-----------------------------------------------------------------*
- * Energy decrease after spike (dE2)
- *-----------------------------------------------------------------*/
-
- /* set different thresholds and conditions for NB and WB input */
- dE2_th = 30 << 10;
- move32();
- nb_cond = 1;
- move16(); /* no additional condition for WB input */
- IF( EQ_16( st_fx->input_bwidth, NB ) )
- {
- dE2_th = 21 << 10;
- move32();
- if ( GE_16( add_sat( mean_voi3, corr_shift ), 22282 /* 0.68 in Q15 */ ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/
- {
- nb_cond = 0;
- move16();
- }
- }
-
- /* calcualte maximum energy decrease */
- dE2 = 0;
- move16(); /* Test on energy decrease after an energy spike */
- pt_enr_ssf = enr_ssf + 2 * NB_SSF;
-
- test();
- IF( GT_32( dE1, 30 << 13 ) && nb_cond ) /*>30 Q13*/
- {
- IF( LT_16( sub( shl( NB_SSF, 1 ), ind_deltaMax ), L_ENR ) )
- {
- st_fx->old_ind_deltaMax = ind_deltaMax; /* Q0 */
- move16();
- Copy32( pt_enr_ssf, st_fx->old_enr_ssf_fx, 2 * NB_SSF ); /* Qx */
- }
- ELSE
- {
- st_fx->old_ind_deltaMax = -1;
- move16();
- dE2 = find_ener_decrease_fx( ind_deltaMax, pt_enr_ssf ); /*Q10*/
-
- if ( GT_32( dE2, dE2_th ) )
- {
- st_fx->spike_hyst = 0;
- move16();
- }
- }
- }
- ELSE
- {
- IF( st_fx->old_ind_deltaMax >= 0 )
- {
- Copy32( st_fx->old_enr_ssf_fx, enr_ssf, 2 * NB_SSF ); /* Qx */
- dE2 = find_ener_decrease_fx( st_fx->old_ind_deltaMax, enr_ssf ); /* Q10 */
-
- if ( GT_32( dE2, dE2_th ) )
- {
- st_fx->spike_hyst = 1;
- move16();
- }
- }
-
- st_fx->old_ind_deltaMax = -1;
- move16();
- }
-
- /*-----------------------------------------------------------------*
- * Detection of voiced offsets (tmp_offset_flag)
- *-----------------------------------------------------------------*/
-
- tmp_offset_flag = 1;
+ Q_in = Q_new;
move16();
- IF( NE_16( st_fx->input_bwidth, NB ) )
- {
- ee0_th = 154; /*2.4 in Q6 */
- move16();
- voi_th = 24248; /*0.74f Q15 */
- move16();
- }
- ELSE
- {
- ee0_th = 627; /*9.8f Q6 */
- move16();
- voi_th = 24904; /*0.76f Q15*/
- move16();
- }
-
- test();
- test();
- test();
- if ( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */
- ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], L_shl( E_MIN_FX, Q_new ) ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */
- ( LT_16( add_sat( st_fx->voicing_fx[0], corr_shift ), voi_th ) ) ) ) /* normalized correlation is low */
- {
- tmp_offset_flag = 0;
- move16();
- }
-
- /*-----------------------------------------------------------------*
- * Decision about UC
- *-----------------------------------------------------------------*/
-
- /* SC-VBR - set additional parameters and thresholds for SC-VBR */
- mean_voi3_offset = 0;
- move16();
- flag_low_relE = 0;
- move16();
- ee1_th = 608; /*9.5 Q6*/
- move16();
- IF( st_fx->Opt_SC_VBR || ( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) ) /* Allow the low energy flag for the secondary channel */
+ if ( st_fx->element_mode == EVS_MONO )
{
- ee1_th = 544; /*8.5f Q6*/
- move16();
-
- /* SC-VBR - determine the threshold on relative energy as a function of lp_noise */
- IF( NE_16( st_fx->input_bwidth, NB ) )
- {
- /*relE_thres = 0.700f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16) */
- L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 22938 /* 0.7 in Q15 */, st_fx->lp_noise_fx ); // Q24
- if ( Last_Resort == 0 )
- {
- /*relE_thres = 0.650f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16)*/
- L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 21299 /* 0.650f in Q15 */, st_fx->lp_noise_fx ); // Q24
- }
- relE_thres = round_fx( L_tmp );
- }
- ELSE
- {
-
- /*relE_thres = 0.60f * st->lp_noise - 28.2f; (lp_noise in Q8, constant Q8<<16)*/
- L_tmp = L_mac( -473117491 /* 28.2f in Q24 */, 19661 /* 0.6f in Q15 */, st_fx->lp_noise_fx ); // Q24
- relE_thres = round_fx( L_tmp );
- }
- relE_thres = s_max( relE_thres, -6400 /* -25.0f in Q8 */ ); /* Q8 */
-
- /* SC-VBR = set flag on low relative energy */
- if ( LT_16( relE, relE_thres ) )
- {
- flag_low_relE = 1;
- move16();
- }
-
- /* SC-VBR - correction of voicing threshold for NB inputs (important only in noisy conditions) */
- test();
- if ( EQ_16( st_fx->input_bwidth, NB ) && LT_16( vadnoise, 20 << 8 ) ) /* vadnoise in Q8, constant Q0<<8 */
- {
- mean_voi3_offset = 1638; /*0.05f Q15*/
- move16();
- }
+ Q_in = sub( Q_new, 1 );
}
- /* make decision whether frame is unvoiced */
- E_min_th = L_shl( E_MIN_FX, Q_new );
- coder_type = GENERIC;
- move16();
- IF( EQ_16( st_fx->input_bwidth, NB ) )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */
- ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */
- ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */
- ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */
- ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */
- /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */
- ( LE_32( dE1, 237568 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */
- ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */
- ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */
- flag_low_relE ) /* low relative frame energy (only for SC-VBR) */
- {
- coder_type = UNVOICED;
- move16();
- }
- }
- ELSE
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */
- ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.8 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */
- ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */
- ( LT_32( ee[1], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */
- ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */
- /*( st_fx->music_hysteresis_fx == 0 ) && */ /* ... and in segment after AUDIO frames */
- ( LE_32( dE1, 245760 /* 30.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */
- ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) && /* + one frame hysteresis */
- ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */
- || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) ) ) /* low relative frame energy (only for SC-VBR) */
- {
- coder_type = UNVOICED;
- move16();
- }
- }
-
- /*-----------------------------------------------------------------*
- * Decision about VC
- *-----------------------------------------------------------------*/
- if ( st_fx->Opt_SC_VBR )
- {
- hSC_VBR->set_ppp_generic = 0;
- }
- move16();
-
- test();
- test();
- IF( EQ_16( st_fx->localVAD, 1 ) && EQ_16( coder_type, GENERIC ) && NE_16( last_core_orig, AMR_WB_CORE ) )
- {
- dpit1 = abs_s( sub( T_op_fr[1], T_op_fr[0] ) ); // Q6
- dpit2 = abs_s( sub( T_op_fr[2], T_op_fr[1] ) ); // Q6
- dpit3 = abs_s( sub( T_op_fr[3], T_op_fr[2] ) ); // Q6
-
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( ( GT_16( voicing_fr[0], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 1st sf. */
- ( GT_16( voicing_fr[1], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 2st sf. */
- ( GT_16( voicing_fr[2], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 3st sf. */
- ( GT_16( voicing_fr[3], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 4st sf. */
- ( GT_32( mean_ee, 256 /* 4.0f in Q6 */ ) ) && /* energy concentrated in low frequencies */
- ( LT_16( dpit1, 3 << 6 ) ) &&
- ( LT_16( dpit2, 3 << 6 ) ) &&
- ( LT_16( dpit3, 3 << 6 ) ) )
- {
- coder_type = VOICED;
- move16();
- }
- ELSE IF( st_fx->Opt_SC_VBR && EQ_16( st_fx->input_bwidth, NB ) && LT_16( vadnoise, 20 << 8 ) )
- {
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- IF( GT_16( voicing_fr[0], 8192 /* 0.25 in Q15 */ ) && /* normalized correlation high in 1st sf. */
- ( GT_16( voicing_fr[1], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 2st sf. */
- ( GT_16( voicing_fr[2], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 3st sf. */
- ( GT_16( voicing_fr[3], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 4st sf. */
- ( GT_32( mean_ee, 64 ) ) && /* energy concentrated in low frequencies */
- ( LT_16( dpit1, 5 << 6 ) ) &&
- ( LT_16( dpit2, 5 << 6 ) ) &&
- ( LT_16( dpit3, 5 << 6 ) ) )
- {
- hSC_VBR->set_ppp_generic = 1;
- move16();
- coder_type = VOICED;
- move16();
- }
- }
-
- /* set VOICED mode for frames with very stable pitch and high correlation
- and avoid to switch to AUDIO/MUSIC later */
- voicing_m = mac_r( L_mac( L_mac( L_mult( voicing_fr[3], 8192 /* 0.25 in Q15 */ ), voicing_fr[2], 8192 /* 0.25 in Q15 */ ), voicing_fr[1], 8192 /* 0.25 in Q15 */ ), voicing_fr[0], 8192 /* 0.25 in Q15 */ );
- test();
- test();
- test();
- test();
- test();
- IF( *flag_spitch || ( LE_16( dpit1, 3 << 6 ) && LE_16( dpit2, 3 << 6 ) && LE_16( dpit3, 3 << 6 ) &&
- GT_16( voicing_m, 31130 /* 0.95f in Q15 */ ) && GT_16( st_fx->voicing_sm_fx, 31785 /* 0.97f in Q15 */ ) ) )
- {
- coder_type = VOICED;
- move16();
- *flag_spitch = 1;
- move16(); /*to avoid switch to AUDIO/MUSIC later*/
- }
- }
-
- /*-----------------------------------------------------------------*
- * Channel-aware mode - set RF mode and total bitrate
- *-----------------------------------------------------------------*/
-
- st_fx->rf_mode = st_fx->Opt_RF_ON; /* Q0 */
- move16();
-
- IF( EQ_16( coder_type, GENERIC ) )
- {
- test();
- test();
- test();
- test();
- IF( ( LT_16( voicing_fr[0], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 2st sf. */
- ( LT_16( voicing_fr[1], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 2st sf. */
- ( LT_16( voicing_fr[2], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 3rd sf. */
- ( LT_16( voicing_fr[3], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 4th sf. */
- ( GT_16( vadnoise, 25 << 8 ) ) ) /* when speech is clean */
-
- {
- st_fx->rf_mode = 0;
- move16();
- /* Current frame cannot be compressed to pack the partial redundancy;*/
-
- if ( st_fx->rf_mode != st_fx->Opt_RF_ON )
- {
- core_coder_mode_switch_fx( st_fx, st_fx->last_total_brate, 0, shift );
- }
- }
- }
-
- /*-----------------------------------------------------------------*
- * Updates
- *-----------------------------------------------------------------*/
-
- /* update spike hysteresis parameters */
- test();
- if ( st_fx->spike_hyst >= 0 && LT_16( st_fx->spike_hyst, 2 ) )
- {
- st_fx->spike_hyst = add( st_fx->spike_hyst, 1 ); /* Q0 */
- }
-
- /* reset spike hysteresis */
- test();
- test();
- test();
- if ( ( GT_16( st_fx->spike_hyst, 1 ) ) &&
- ( GT_16( dE3, 5 << 8 ) || /* energy increases */
- ( GT_16( relE, -3328 ) && ( GT_16( add_sat( mean_voi3, corr_shift ), 22774 ) ) ) ) ) /* normalized correlation is high */
- {
- st_fx->spike_hyst = -1;
- move16();
- }
-
- /* update tilt parameters */
- st_fx->ee_old_fx = ee[1];
- move32(); /*Q6*/
- st_fx->old_dE1_fx = dE1;
- move32(); /*Q13*/
-
- /* save the raw coder_type for various modules later in the codec (the reason is that e.g. UNVOICED is lost at higher rates) */
- st_fx->coder_type_raw = coder_type;
- move16();
-
- return coder_type;
-}
-
-/*-------------------------------------------------------------------*
- * find_uv()
- *
- * Decision about coder type
- *-------------------------------------------------------------------*/
-Word16 find_uv_ivas_fx( /* o : coding type */
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/
- const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/
- const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/
- const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/
- Word32 *dE1X, /* o : sudden energy increase for S/M classifier Q13*/
- const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/
- const Word16 relE, /* i : relative frame energy Q8*/
- const Word16 Etot, /* i : total energy Q8*/
- const Word32 hp_E[], /* i : energy in HF q_hp_E*/
- Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/
- const Word16 last_core_orig, /* i : original last core Q0*/
- STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */
- const Word16 Q_new,
- const Word16 q_hp_E )
-{
- Word16 coder_type, i;
- Word32 mean_ee, dE1, fac_32;
- const Word16 *pt_speech;
- Word32 L_tmp, enr_ssf[2 * NB_SSF + 2 * NB_SSF + 2], E_min_th;
- Word16 dE2;
- Word16 ind_deltaMax, tmp_offset_flag;
- Word32 Ltmp0, *pt_enr_ssf, *pt_enr_ssf1, dE2_th;
- Word16 exp0, exp1;
- Word16 wtmp0, wtmp1;
- Word16 fac, mean_voi3, dE3;
- Word16 relE_thres;
- Word16 mean_voi3_offset;
- Word16 voicing_m, dpit1, dpit2, dpit3;
- Word16 ee0_th, ee1_th, voi_th, nb_cond, flag_low_relE;
- NOISE_EST_HANDLE hNoiseEst = st_fx->hNoiseEst;
- SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
- Word16 Last_Resort;
- Word16 vadnoise;
-
IF( hSC_VBR != NULL )
{
Last_Resort = hSC_VBR->Last_Resort; /* Q0 */
@@ -637,7 +161,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
pt_enr_ssf = enr_ssf + 2 * NB_SSF;
FOR( i = 0; i < 2 * ( NB_SSF + 1 ); i++ )
{
- emaximum_fx( Q_new, pt_speech, SSF, pt_enr_ssf );
+ emaximum_fx( Q_in, pt_speech, SSF, pt_enr_ssf );
pt_speech += ( SSF / 2 );
pt_enr_ssf++;
}
@@ -675,7 +199,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
pt_enr_ssf1++;
}
- IF( hStereoClassif != NULL )
+ IF( hStereoClassif != NULL ) /* IVAS only */
{
IF( st_fx->idchan == 0 )
{
@@ -712,11 +236,19 @@ Word16 find_uv_ivas_fx( /* o : coding typ
Ltmp0 = L_mult( st_fx->voicing_fx[0], 10923 /* 1/3 in Q15 */ ); /* Q31 */
Ltmp0 = L_mac( Ltmp0, st_fx->voicing_fx[1], 10923 /* 1/3 in Q15 */ ); /* Q31 */
mean_voi3 = mac_r_sat( Ltmp0, st_fx->voicing_fx[2], 10923 /* 1/3 in Q15 */ ); /*Q15*/
+
/*-----------------------------------------------------------------*
* Total frame energy difference (dE3)
*-----------------------------------------------------------------*/
- dE3 = sub( Etot, extract_h( hNoiseEst->Etot_last_32fx ) ); /*Q8*/
+ IF( st_fx->element_mode == EVS_MONO ) /* Overwrite dE3 in case of EVS */
+ {
+ dE3 = sub( Etot, hNoiseEst->Etot_last_fx ); /*Q8*/
+ }
+ ELSE
+ {
+ dE3 = sub( Etot, extract_h( hNoiseEst->Etot_last_32fx ) ); /*Q8*/
+ }
/*-----------------------------------------------------------------*
* Energy decrease after spike (dE2)
@@ -806,6 +338,10 @@ Word16 find_uv_ivas_fx( /* o : coding typ
}
E_min_th = L_shl( E_MIN_IVAS_FX_Q31, sub( q_hp_E, Q31 ) );
+ if ( st_fx->element_mode == EVS_MONO ) /* Overwrite E_min_th in case of EVS */
+ {
+ E_min_th = L_shl( E_MIN_FX, Q_new );
+ }
test();
test();
@@ -830,6 +366,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
move16();
ee1_th = 608; /*9.5 Q6*/
move16();
+
test();
test();
IF( st_fx->Opt_SC_VBR || ( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) ) /* Allow the low energy flag for the secondary channel */
@@ -837,15 +374,24 @@ Word16 find_uv_ivas_fx( /* o : coding typ
ee1_th = 544; /*8.5f Q6*/
move16();
+ IF( st_fx->element_mode == EVS_MONO ) /* Overwrite E_min_th in case of EVS */
+ {
+ loc_lp_noise = st_fx->lp_noise_fx;
+ }
+ ELSE
+ {
+ loc_lp_noise = extract_h( st_fx->lp_noise_32fx );
+ }
+
/* SC-VBR - determine the threshold on relative energy as a function of lp_noise */
IF( st_fx->input_bwidth != NB )
{
/*relE_thres = 0.700f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16) */
- L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 22938 /* 0.7 in Q15 */, extract_h( st_fx->lp_noise_32fx ) ); // Q24
+ L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 22938 /* 0.7 in Q15 */, loc_lp_noise ); // Q24
IF( Last_Resort == 0 )
{
/*relE_thres = 0.650f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16)*/
- L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 21299 /* 0.650f in Q15 */, extract_h( st_fx->lp_noise_32fx ) ); // Q24
+ L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 21299 /* 0.650f in Q15 */, loc_lp_noise ); // Q24
}
relE_thres = round_fx( L_tmp );
}
@@ -853,7 +399,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
{
/*relE_thres = 0.60f * st->lp_noise - 28.2f; (lp_noise in Q8, constant Q8<<16)*/
- L_tmp = L_mac( -473117491 /* 28.2f in Q24 */, 19661 /* 0.6f in Q15 */, extract_h( st_fx->lp_noise_32fx ) ); // Q24
+ L_tmp = L_mac( -473117491 /* 28.2f in Q24 */, 19661 /* 0.6f in Q15 */, loc_lp_noise ); // Q24
relE_thres = round_fx( L_tmp );
}
relE_thres = s_max( relE_thres, -6400 /* -25.0f in Q8 */ ); /* Q8 */
@@ -889,22 +435,39 @@ Word16 find_uv_ivas_fx( /* o : coding typ
test();
test();
test();
- IF( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */
- ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */
- ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */
- ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */
- ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */
- /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */
- ( LE_32( dE1, 237568 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */
- ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */
- ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */
- flag_low_relE )
+ if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */
+ ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */
+ ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */
+ ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */
+ ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */
+ /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */
+ ( LE_32( dE1, 237568 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */
+ ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */
+ ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */
+ flag_low_relE )
/* low relative frame energy (only for SC-VBR) */
{
coder_type = UNVOICED;
move16();
}
}
+ ELSE IF( st_fx->element_mode == EVS_MONO )
+ {
+ if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */
+ ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.8 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */
+ ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */
+ ( LT_32( ee[1], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */
+ ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */
+ /*( st_fx->music_hysteresis_fx == 0 ) && */ /* ... and in segment after AUDIO frames */
+ ( LE_32( dE1, 245760 /* 30.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */
+ ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) && /* + one frame hysteresis */
+ ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */
+ || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) ) ) /* low relative frame energy (only for SC-VBR) */
+ {
+ coder_type = UNVOICED;
+ move16();
+ }
+ }
ELSE
{
test();
@@ -917,7 +480,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
test();
test();
if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */
- /*( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 ) ) && */ /* normalized correlation low on look-ahead - onset detection */
+ /* ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 ) ) && */ /* normalized correlation low on look-ahead - onset detection */
( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */
( LT_32( ee[1], 397 /* 6.2f in Q16 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */
( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */
@@ -935,6 +498,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
/*-----------------------------------------------------------------*
* Decision about VC
*-----------------------------------------------------------------*/
+
if ( st_fx->Opt_SC_VBR )
{
hSC_VBR->set_ppp_generic = 0;
@@ -1035,11 +599,11 @@ Word16 find_uv_ivas_fx( /* o : coding typ
{
st_fx->rf_mode = 0;
move16();
- /* Current frame cannot be compressed to pack the partial redundancy;*/
- IF( NE_16( st_fx->rf_mode, st_fx->Opt_RF_ON ) )
+ /* Current frame cannot be compressed to pack the partial redundancy */
+ IF( NE_16( st_fx->rf_mode, st_fx->Opt_RF_ON ) ) /* can happen only for EVS format */
{
- core_coder_mode_switch_ivas_fx( st_fx, st_fx->last_total_brate, 0 );
+ core_coder_mode_switch_fx( st_fx, st_fx->last_total_brate, 0, shift );
}
}
}
diff --git a/lib_enc/find_wsp_fx.c b/lib_enc/find_wsp_fx.c
index 6e75c36c2ce874ceb10b13e29c04967fdf12dc7f..e2353c45513fdada3288c965d678ed9ac089c22a 100644
--- a/lib_enc/find_wsp_fx.c
+++ b/lib_enc/find_wsp_fx.c
@@ -77,7 +77,7 @@ void find_wsp_fx(
deemph_fx( &wsp[L_frame], preemph_fac, lookahead, &wtmp );
}
}
-
+#ifndef FIX_2363_FIND_WSP
/*-------------------------------------------------------------------*
* ivas_find_wsp_fx()
*
@@ -134,3 +134,4 @@ void ivas_find_wsp_fx(
deemph_fx( &wsp_fx[L_frame], tilt_fact, L_look, &tmp_fx );
return;
}
+#endif
diff --git a/lib_enc/gp_clip_fx.c b/lib_enc/gp_clip_fx.c
index d565fea0cac33f830efc20e7992439704c43dfad..11f5fe90c065742fa8f21e9ab0ae3bd667d88a5f 100644
--- a/lib_enc/gp_clip_fx.c
+++ b/lib_enc/gp_clip_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c
index 19d7f599c1c3396a83a1370819289e6ad463c16d..4037aaa5eb262286c4465ec5887d352a44a0eecf 100644
--- a/lib_enc/gs_enc_fx.c
+++ b/lib_enc/gs_enc_fx.c
@@ -14,7 +14,7 @@
* Local function prototypes
*-------------------------------------------------------------------*/
-static Word16 edyn_fx( const Word16 *vec, const Word16 lvec, Word16 Qnew );
+static Word16 edyn_fx( const Word16 *vec, const Word16 lvec, const Word16 Qnew );
/*-------------------------------------------------------------------*
@@ -39,8 +39,9 @@ void encod_audio_fx(
Word16 *tmp_noise, /* o : noise energy Q2 */
const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0 */
const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6 */
- Word16 Q_new,
- Word16 shift )
+ const Word16 Q_new, /* i : Scaling factor */
+ const Word16 shift /* i : Shift needed to obtain 12 bits vectors */
+)
{
const Word16 *p_Aq;
Word16 i, i_subfr, nb_subfr, last_pit_bin;
@@ -60,6 +61,9 @@ void encod_audio_fx(
GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc;
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
+#ifdef FIX_1904_HARM_GSC_ENC
+ Word16 Q_exc;
+#endif
m_mean = 0;
move16();
@@ -70,9 +74,21 @@ void encod_audio_fx(
move16();
T0_frac_tmp = 0;
move16();
- Copy( hLPDmem->mem_syn, hGSCEnc->mem_syn_tmp_fx, M ); /* hLPDmem->q_mem_syn */
- hGSCEnc->mem_w0_tmp_fx = hLPDmem->mem_w0;
- move16();
+
+#ifdef FIX_1904_HARM_GSC_ENC
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ Copy_Scale_sig( hLPDmem->mem_syn, hGSCEnc->mem_syn_tmp_fx, M, sub( sub( Q_new, 1 ), hLPDmem->q_mem_syn ) );
+ Copy_Scale_sig( &hLPDmem->mem_w0, &hGSCEnc->mem_w0_tmp_fx, 1, sub( sub( Q_new, 1 ), hLPDmem->q_mem_syn ) );
+ }
+ ELSE
+#endif
+ {
+ Copy( hLPDmem->mem_syn, hGSCEnc->mem_syn_tmp_fx, M ); /* hLPDmem->q_mem_syn */
+ hGSCEnc->mem_w0_tmp_fx = hLPDmem->mem_w0;
+ move16();
+ }
+
Es_pred = 0;
move16();
@@ -82,6 +98,14 @@ void encod_audio_fx(
* Encode GSC SWB speech flag
*---------------------------------------------------------------*/
+#ifdef FIX_1904_HARM_GSC_ENC
+ test();
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) && st_fx->idchan == 0 )
+ {
+ push_indice( hBstr, IND_GSC_IVAS_SP, st_fx->GSC_IVAS_mode, 2 );
+ }
+#endif
+
IF( attack_flag > 0 )
{
push_indice( hBstr, IND_GSC_ATTACK, 1, 1 );
@@ -91,7 +115,6 @@ void encod_audio_fx(
push_indice( hBstr, IND_GSC_ATTACK, 0, 1 );
}
-
test();
test();
test();
@@ -104,9 +127,11 @@ void encod_audio_fx(
{
push_indice( hBstr, IND_GSC_SWB_SPEECH, st_fx->GSC_noisy_speech, 1 );
}
+
/*---------------------------------------------------------------*
* Find and encode the number of subframes
*---------------------------------------------------------------*/
+
test();
IF( GE_32( st_fx->core_brate, ACELP_9k60 ) && LE_32( st_fx->core_brate, ACELP_13k20 ) )
{
@@ -120,6 +145,7 @@ void encod_audio_fx(
}
}
}
+
test();
test();
test();
@@ -190,6 +216,7 @@ void encod_audio_fx(
push_indice( hBstr, IND_HF_NOISE, nb_subfr_flag, 1 );
}
}
+
test();
if ( EQ_16( st_fx->L_frame, L_FRAME16k ) && EQ_16( nb_subfr, NB_SUBFR ) )
{
@@ -233,11 +260,14 @@ void encod_audio_fx(
/*---------------------------------------------------------------*
* DCT transform
*---------------------------------------------------------------*/
+
edct_16fx( exc, dct_epit, st_fx->L_frame, 7, st_fx->element_mode );
edct_16fx( res, dct_res, st_fx->L_frame, 7, st_fx->element_mode );
+
/*---------------------------------------------------------------*
* Calculate energy dynamics
*---------------------------------------------------------------*/
+
Lm_mean = L_deposit_l( 0 );
FOR( i = 7; i < 15; i++ )
{
@@ -325,12 +355,12 @@ void encod_audio_fx(
tmp_nb_bits_tot = hBstr->nb_bits_tot;
move16();
-
if ( st_fx->extl_brate > 0 )
{
/* subtract 1 bit for TBE/BWE BWE flag (bit counted in extl_brate) */
tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 );
}
+
test();
test();
if ( EQ_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->idchan == 0 )
@@ -339,7 +369,14 @@ void encod_audio_fx(
tmp_nb_bits_tot = add( tmp_nb_bits_tot, 5 );
}
+#ifdef FIX_1904_HARM_GSC_ENC
+ Q_exc = Q_new;
+ move16();
+
+ gsc_enc_fx( st_fx, dct_res, dct_epit, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf, tmp_noise, &Q_exc );
+#else
gsc_enc_fx( st_fx, dct_res, dct_epit, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf, tmp_noise, Q_new );
+#endif
/*--------------------------------------------------------------------------------------*
* iDCT transform
@@ -347,15 +384,29 @@ void encod_audio_fx(
edct_16fx( dct_epit, exc, st_fx->L_frame, 7, st_fx->element_mode );
edct_16fx( exc_wo_nf, exc_wo_nf, st_fx->L_frame, 7, st_fx->element_mode );
+
+#ifdef FIX_1904_HARM_GSC_ENC
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ Scale_sig( exc, st_fx->L_frame, sub( Q_new, Q_exc ) ); /* TV This could probably be removed, but won't be BE */
+ Scale_sig( exc_wo_nf, st_fx->L_frame, sub( Q_new, Q_exc ) );
+ }
+#endif
+
/*--------------------------------------------------------------------------------------*
* Remove potential pre-echo in case an onset has been detected
*--------------------------------------------------------------------------------------*/
+#ifdef FIX_1904_HARM_GSC_ENC
+ pre_echo_att_fx( &hGSCEnc->Last_frame_ener_fx, exc, attack_flag, Q_new, st_fx->last_coder_type, st_fx->L_frame, st_fx->element_mode );
+#else
pre_echo_att_fx( &hGSCEnc->Last_frame_ener_fx, exc, attack_flag, Q_new, st_fx->last_coder_type, st_fx->L_frame );
+#endif
/*--------------------------------------------------------------------------------------*
* Update BWE excitation
*--------------------------------------------------------------------------------------*/
+
IF( st_fx->hBWE_TD != NULL )
{
IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
@@ -369,6 +420,7 @@ void encod_audio_fx(
interp_code_5over2_fx( exc, bwe_exc, L_FRAME );
}
}
+
/*--------------------------------------------------------------------------------------*
* Synthesis
*--------------------------------------------------------------------------------------*/
@@ -384,13 +436,25 @@ void encod_audio_fx(
* Updates
*--------------------------------------------------------------------------------------*/
- hLPDmem->mem_w0 = hGSCEnc->mem_w0_tmp_fx;
- move16();
+#ifdef FIX_1904_HARM_GSC_ENC
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) )
+ {
+ Copy_Scale_sig( &hGSCEnc->mem_w0_tmp_fx, &hLPDmem->mem_w0, 1, sub( hLPDmem->q_mem_syn, sub( Q_new, 1 ) ) );
+ }
+ ELSE
+#endif
+ {
+ hLPDmem->mem_w0 = hGSCEnc->mem_w0_tmp_fx;
+ move16();
+ }
+
Copy( exc_wo_nf, exc, st_fx->L_frame );
return;
}
+
+#ifndef FIX_1904_HARM_GSC_ENC
void encod_audio_ivas_fx(
Encoder_State *st_fx, /* i/o: State structure */
const Word16 speech[], /* i : input speech Q_new */
@@ -599,10 +663,13 @@ void encod_audio_ivas_fx(
Es_pred_enc_fx( &Es_pred, &indice, st_fx->L_frame, res, st_fx->voicing_fx, nb_bits, 0, Q_new );
push_indice( hBstr, IND_ES_PRED, indice, nb_bits );
}
-
+#ifdef FIX_1904_HARM_GSC_ENC
+ enc_pit_exc_fx( st_fx, speech, Aw, Aq, Es_pred, res, synth, exc, &T0_tmp,
+ &T0_frac_tmp, pitch_buf, nb_subfr, &hGSCEnc->lt_gpitch_fx, &saved_bit_pos, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new, shift );
+#else
enc_pit_exc_ivas_fx( st_fx, speech, Aw, Aq, Es_pred, res, synth, exc, &T0_tmp,
&T0_frac_tmp, pitch_buf, nb_subfr, &hGSCEnc->lt_gpitch_fx, &saved_bit_pos, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new, shift );
-
+#endif
/*---------------------------------------------------------------*
* DCT transform
*---------------------------------------------------------------*/
@@ -674,8 +741,11 @@ void encod_audio_ivas_fx(
/*---------------------------------------------------------------*
* Find and encode the last band where the adaptive (pitch) contribution is significant
*---------------------------------------------------------------*/
-
+#ifdef FIX_1904_HARM_GSC_ENC
+ last_pit_bin = Pit_exc_contribution_len_fx( st_fx, dct_res, dct_epit, pitch_buf, nb_subfr, &hGSCEnc->pit_exc_hangover, Q_new );
+#else
last_pit_bin = Pit_exc_contribution_len_ivas_fx( st_fx, dct_res, dct_epit, pitch_buf, &hGSCEnc->pit_exc_hangover, Q_new );
+#endif
IF( last_pit_bin == 0 )
{
@@ -712,8 +782,11 @@ void encod_audio_ivas_fx(
Word16 Q_exc = Q_new;
move16();
+#ifdef FIX_1904_HARM_GSC_ENC
+ gsc_enc_fx( st_fx, dct_res, dct_epit, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf, tmp_noise, &Q_exc );
+#else
gsc_enc_ivas_fx( st_fx, dct_res, dct_epit, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf, tmp_noise, &Q_exc );
-
+#endif
/*--------------------------------------------------------------------------------------*
* iDCT transform
*--------------------------------------------------------------------------------------*/
@@ -768,8 +841,9 @@ void encod_audio_ivas_fx(
return;
}
+#endif
/*================================================================================*/
-/* FUNCTION : void gsc_enc_fx () */
+/* FUNCTION : void gsc_enc_fx() */
/*--------------------------------------------------------------------------------*/
/* PURPOSE : Generic audio signal encoder */
/*--------------------------------------------------------------------------------*/
@@ -785,25 +859,33 @@ void encod_audio_ivas_fx(
/* _ None */
/*--------------------------------------------------------------------------------*/
/* INPUT/OUTPUT ARGUMENTS : */
-/* Encoder_State *st_fx:Encoder State Structure */
+/* Encoder_State *st_fx:Encoder State Structure */
/* _ (Word16[]) exc_dct_in : dctof pitch-only excitation / total excitation Q_exc */
/*--------------------------------------------------------------------------------*/
/* RETURN ARGUMENTS : */
/* _None */
/*================================================================================*/
-
void gsc_enc_fx(
- Encoder_State *st_fx, /* i/o: State structure */
- Word16 res_dct_in[], /* i : dct of residual signal Q_exc*/
+ Encoder_State *st_fx, /* i/o: State structure */
+ Word16 res_dct_in[], /* i : dct of residual signal Q_exc*/
Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/
const Word16 Diff_len,
const Word16 bits_used,
const Word16 nb_subfr,
- Word16 *lsf_new, /* i : ISFs at the end of the frame Qx2.56*/
+#ifndef FIX_1904_HARM_GSC_ENC
+ Word16 *lsf_new, /* i : ISFs at the end of the frame Qx2.56*/
+#else
+ const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx2.56*/
+#endif
Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/
Word16 *tmp_noise, /* o : noise energy Q2*/
- Word16 Q_exc )
+#ifndef FIX_1904_HARM_GSC_ENC
+ Word16 Q_exc
+#else
+ Word16 *Q_exc
+#endif
+)
{
Word16 y2_filt[L_FRAME16k];
Word16 exc_diffQ[L_FRAME16k];
@@ -816,7 +898,11 @@ void gsc_enc_fx(
Word16 concat_in[L_FRAME16k];
Word16 concat_out[L_FRAME16k];
Word16 max_ener_band[MBANDS_GN_BITALLOC16k], j;
+#ifndef FIX_1904_HARM_GSC_ENC
Word16 Ener_per_bd_iQ[MBANDS_GN_BITALLOC16k];
+#else
+ Word16 Ener_per_bd_iQ[MBANDS_GN16k];
+#endif
Word16 last_bin, mean_gain;
Word16 bitallocation_band[MBANDS_GN_BITALLOC16k];
Word16 bitallocation_exc[2];
@@ -827,6 +913,13 @@ void gsc_enc_fx(
Word16 seed_init;
GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc;
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
+#ifdef FIX_1904_HARM_GSC_ENC
+ Word32 L_tmp;
+ Word16 max_eq = 0;
+ Word16 Q_concat = Q_PVQ_OUT;
+ move16();
+ move16();
+#endif
set16_fx( inpulses_fx, 0, NB_SFM );
set16_fx( imaxpulse_fx, 0, NB_SFM );
@@ -862,6 +955,7 @@ void gsc_enc_fx(
* This improves the stability of the differnece spectrum since the spectral shape of the
* residual signal is less suseptible to rapid changes than the difference spectrum
*--------------------------------------------------------------------------------------*/
+
IF( Diff_len == 0 )
{
tmp_band = 0;
@@ -873,11 +967,16 @@ void gsc_enc_fx(
move16();
}
+#ifndef FIX_1904_HARM_GSC_ENC
Ener_per_band_comp_fx( exc_diff, Ener_per_bd_iQ, Q_exc, MBANDS_GN, 1 /*, st_fx->L_frame IVAS_CODE*/ );
+#else
+ Ener_per_band_comp_fx( exc_diff, Ener_per_bd_iQ, *Q_exc, MBANDS_GN, 1, st_fx->L_frame );
+#endif
/*--------------------------------------------------------------------------------------*
* Gain quantizaion
*--------------------------------------------------------------------------------------*/
+
i = 0;
move16();
WHILE( LT_16( i, SIZE_BRATE_INTERMED_TBL ) )
@@ -898,8 +997,7 @@ void gsc_enc_fx(
i--;
}
- mean_gain = gsc_gainQ_fx( hBstr, /*st_fX->element_mode, st_fx->idchan,IVAS_CODE*/ Ener_per_bd_iQ, Ener_per_bd_iQ, brate_intermed_tbl[i], st_fx->coder_type, st_fx->bwidth /*, st_fx->L_frame, st_fx->tdm_LRTD_flag, st_fx->core_brate*/ );
-
+ mean_gain = gsc_gainQ_fx( hBstr, st_fx->idchan, Ener_per_bd_iQ, Ener_per_bd_iQ, brate_intermed_tbl[i], st_fx->coder_type, st_fx->bwidth, st_fx->L_frame, st_fx->tdm_LRTD_flag, st_fx->core_brate );
*tmp_noise = mult_r( 320, mean_gain ); /*10 in Q5 lp_gainc in Q3 */
move16();
@@ -907,23 +1005,42 @@ void gsc_enc_fx(
* Frequency encoder
*--------------------------------------------------------------------------------------*/
+#ifndef FIX_1904_HARM_GSC_ENC
bands_and_bit_alloc_fx( hGSCEnc->cor_strong_limit, hGSCEnc->noise_lev, st_fx->core_brate, Diff_len, bit, &bit, Ener_per_bd_iQ,
max_ener_band, bits_per_bands, &nb_subbands, exc_diff, concat_in, &pvq_len, st_fx->coder_type, st_fx->bwidth,
st_fx->GSC_noisy_speech, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode );
-
Q_tmp = Q_exc;
+#else
+ bands_and_bit_alloc_ivas_fx( hGSCEnc->cor_strong_limit, hGSCEnc->noise_lev, st_fx->core_brate, Diff_len, bit, &bit, Ener_per_bd_iQ, max_ener_band, bits_per_bands, &nb_subbands, exc_diff, concat_in, &pvq_len,
+ st_fx->coder_type, st_fx->bwidth, st_fx->GSC_noisy_speech, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode );
+ Q_tmp = *Q_exc;
+#endif
move16();
+
IF( bit == 0 )
{
set16_fx( concat_out, 0, L_FRAME16k );
}
ELSE
{
- tmp = pvq_core_enc_fx( hBstr, concat_in, concat_out, &Q_tmp, bit, nb_subbands, gsc_sfm_start, gsc_sfm_end,
- gsc_sfm_size, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE );
- Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */
- bit = sub( bit, tmp );
+#ifdef FIX_1904_HARM_GSC_ENC
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could probably be harmonized */
+ {
+ Q_concat = Q12;
+ move16();
+ bit = sub( bit, pvq_core_enc_ivas_fx( hBstr, concat_in, concat_out, &Q_concat, bit, nb_subbands, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE ) );
+ }
+ ELSE
+#endif
+ {
+ tmp = pvq_core_enc_fx( hBstr, concat_in, concat_out, &Q_tmp, bit, nb_subbands, gsc_sfm_start, gsc_sfm_end,
+ gsc_sfm_size, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE );
+
+ Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_concat, Q_tmp ) ); /* Q_PVQ_OUT */
+ bit = sub( bit, tmp );
+ }
}
+
/* write unused bits */
WHILE( bit > 0 )
{
@@ -931,6 +1048,7 @@ void gsc_enc_fx(
push_indice( hBstr, IND_UNUSED, 0, i );
bit = sub( bit, i );
}
+
/* Reorder Q bands */
seed_init = 0;
move16();
@@ -938,6 +1056,32 @@ void gsc_enc_fx(
move16();
set16_fx( bitallocation_band, 0, MBANDS_GN_BITALLOC16k );
+#ifdef FIX_1904_HARM_GSC_ENC
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could be harmonized, but won't be mathematically BE */
+ {
+ max_eq = 0;
+ move16();
+
+ test();
+ test();
+ test();
+ test();
+ IF( ( ( ( LT_32( st_fx->core_brate, ACELP_7k20 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) ) || LT_32( st_fx->core_brate, 6000 ) ) && LE_16( st_fx->coder_type, UNVOICED ) ) || GE_16( st_fx->GSC_IVAS_mode, 1 ) )
+ {
+ j = emaximum_fx( Q12, concat_out, shl( nb_subbands, 4 ), &L_tmp );
+ IF( LE_16( add( abs_s( concat_out[j] ), 41 /* 0.01f in Q12 */ ), ONE_IN_Q12 ) )
+ {
+ max_eq = 32767; /* Q15 */
+ move16();
+ }
+ ELSE
+ {
+ max_eq = div_s( ONE_IN_Q12, add( abs_s( concat_out[j] ), 41 /* 0.01f in Q12 */ ) ); /* Q15 */
+ }
+ }
+ }
+#endif
+
FOR( j = 0; j < nb_subbands; j++ )
{
Copy( concat_out + j * 16, exc_diffQ + max_ener_band[j] * 16, 16 ); /*Q12*/
@@ -994,17 +1138,65 @@ void gsc_enc_fx(
* Gain is based on the inter-correlation gain between the pulses found and residual signal
*--------------------------------------------------------------------------------------*/
+#ifdef FIX_1904_HARM_GSC_ENC
+ test();
+ test();
+ test();
+ IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) )
{
- freq_dnw_scaling_fx( hGSCEnc->cor_strong_limit, st_fx->coder_type, hGSCEnc->noise_lev, st_fx->core_brate, exc_diffQ, Q_PVQ_OUT, st_fx->L_frame );
+ FOR( i = 64; i < st_fx->L_frame; i++ )
+ {
+ exc_diffQ[i] = mult( exc_diffQ[i], max_eq ); /* Q12 */
+ move16();
+ }
}
+ ELSE IF( LT_32( st_fx->core_brate, ACELP_7k20 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) && LE_16( st_fx->coder_type, UNVOICED ) )
+ {
+ FOR( i = 0; i < L_FRAME; i++ )
+ {
+ exc_diffQ[i] = mult( exc_diffQ[i], max_eq ); /* Q12 */
+ move16();
+ }
+ }
+ ELSE
+#endif
+ {
+ freq_dnw_scaling_fx( hGSCEnc->cor_strong_limit, st_fx->coder_type, hGSCEnc->noise_lev, st_fx->core_brate, exc_diffQ, Q_concat /*Q12 or Q10*/, st_fx->L_frame );
+ }
+
+#ifdef FIX_1904_HARM_GSC_ENC
+ IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could be harmonized, but won't be BE */
+ {
+ Word16 Q_exc_new = s_min( *Q_exc, hGSCEnc->Q_last_exc_dct_in );
+ IF( NE_16( Q_exc_new, hGSCEnc->Q_last_exc_dct_in ) )
+ {
+ Scale_sig( hGSCEnc->last_exc_dct_in_fx, st_fx->L_frame, sub( Q_exc_new, hGSCEnc->Q_last_exc_dct_in ) ); /* Q_exc_new */
+ hGSCEnc->Q_last_exc_dct_in = Q_exc_new;
+ move16();
+ }
+ ELSE
+ {
+ Scale_sig( exc_dct_in, st_fx->L_frame, sub( Q_exc_new, *Q_exc ) ); /* Q_exc_new */
+ *Q_exc = Q_exc_new;
+ move16();
+ }
+ }
+#endif
+
/*--------------------------------------------------------------------------------------*
* Estimate noise level
*--------------------------------------------------------------------------------------*/
+#ifdef FIX_1904_HARM_GSC_ENC
+ highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ /* Q12 */, &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in /* Q_exc */,
+ st_fx->last_coder_type, bitallocation_band, lsf_new /* x2.56 */, hGSCEnc->last_exc_dct_in_fx /* Q_exc */, &hGSCEnc->last_ener_fx /* Q0 */, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type,
+ st_fx->bwidth, exc_wo_nf, Q_concat, Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode );
+#else
highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ,
&hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new,
hGSCEnc->last_exc_dct_in_fx, &hGSCEnc->last_ener_fx, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type,
st_fx->bwidth, exc_wo_nf, Q_PVQ_OUT, Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode );
+#endif
exc_dct_in[0] = 0;
move16();
@@ -1012,7 +1204,7 @@ void gsc_enc_fx(
return;
}
-
+#ifndef FIX_1904_HARM_GSC_ENC
void gsc_enc_ivas_fx(
Encoder_State *st, /* i/o: State structure */
Word16 res_dct_in_fx[],
@@ -1098,9 +1290,11 @@ void gsc_enc_ivas_fx(
tmp_band = hGSCEnc->mem_last_pit_band;
}
move16();
-
+#ifdef FIX_1904_HARM_GSC_ENC
+ Ener_per_band_comp_fx( exc_diff_fx, Ener_per_bd_iQ_fx, *Q_exc, MBANDS_GN, 1, st->L_frame );
+#else
Ener_per_band_comp_ivas_fx( exc_diff_fx, Ener_per_bd_iQ_fx, *Q_exc, MBANDS_GN, 1, st->L_frame );
-
+#endif
/*--------------------------------------------------------------------------------------*
* Gain quantizaion
*--------------------------------------------------------------------------------------*/
@@ -1300,6 +1494,8 @@ void gsc_enc_ivas_fx(
return;
}
+#endif
+
/*======================================================================*/
/* FUNCTION : edyn_fx() */
@@ -1322,10 +1518,11 @@ void gsc_enc_ivas_fx(
/* _ None */
/*=======================================================================*/
-static Word16 edyn_fx( /* o : ratio of max to mean */
- const Word16 *vec, /* i : input vector Qnew*/
- const Word16 lvec, /* i : length of input vector */
- Word16 Qnew )
+/* o : ratio of max to mean */
+static Word16 edyn_fx(
+ const Word16 *vec, /* i : input vector Qnew*/
+ const Word16 lvec, /* i : length of input vector */
+ const Word16 Qnew )
{
Word16 j = 0;
Word16 dyn;
@@ -1371,6 +1568,7 @@ static Word16 edyn_fx( /* o : ratio of max to mean */
dyn = 1280; /* 10.0f in Q7 */
move16();
}
+
return dyn; /* Q7 */
}
@@ -1416,6 +1614,5 @@ void GSC_enc_init_fx(
hGSCEnc->past_dyn_dec = 0;
move16();
-
return;
}
diff --git a/lib_enc/hq_core_enc_fx.c b/lib_enc/hq_core_enc_fx.c
index 1966a4256d90814ef52592010c1f6d0f313b5ca7..6c4aa6bf4ab9bd8f7398d3d8e6d7807be77d7bf3 100644
--- a/lib_enc/hq_core_enc_fx.c
+++ b/lib_enc/hq_core_enc_fx.c
@@ -505,8 +505,7 @@ void hq_core_enc_ivas_fx(
move16();
IF( EQ_16( hq_core_type, LOW_RATE_HQ_CORE ) )
{
-
- hq_lr_enc_ivas_fx( st, t_audio_fx, inner_frame, &num_bits, is_transient );
+ /* this cannot happen in IVAS */
}
ELSE
{
diff --git a/lib_enc/hq_hr_enc_fx.c b/lib_enc/hq_hr_enc_fx.c
index 7f18bd48acb52566672112ce1bcd3cb09c5be3fb..7c5a7884c757ea1d20486bd3448ccba0261f3a83 100644
--- a/lib_enc/hq_hr_enc_fx.c
+++ b/lib_enc/hq_hr_enc_fx.c
@@ -337,7 +337,7 @@ void hq_hr_enc_ivas_fx(
test();
IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) )
{
- calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag );
+ calculate_hangover_attenuation_gain_fx( st, &att_fx, vad_hover_flag );
v_multc_att32( t_audio_fx, att_fx, t_audio_fx, sfm_end[( num_sfm - 1 )] ); /* Q12 */
}
@@ -477,7 +477,7 @@ void hq_hr_enc_ivas_fx(
ivas_de_interleave_spectrum_fx( t_audio_q_fx, length );
}
- MVR2R_WORD32( t_audio_q_fx, t_audio_fx, length );
+ Copy32( t_audio_q_fx, t_audio_fx, length );
return;
}
diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c
index 48b3edc383944273200df8743edd40630a2f06fc..74a3a15dfe24a4ef7a0d5b1530454c8f28e7ccc9 100644
--- a/lib_enc/hq_lr_enc_fx.c
+++ b/lib_enc/hq_lr_enc_fx.c
@@ -23,32 +23,6 @@ static Word16 p2a_threshold_quant_fx( BSTR_ENC_HANDLE hBstr, const Word32 *L_t_a
static void mdct_spectrum_fine_gain_enc_fx( Encoder_State *st_fx, const Word32 L_ybuf[] /*Q12*/, Word32 L_y2[] /*Q12*/, const Word16 band_start[], const Word16 band_end[], const Word16 k_sort[], const Word16 bands, const Word32 L_qint /*Q29*/, const Word16 Ngq, const Word16 gqlevs, const Word16 gqbits );
-static Word16 p2a_threshold_quant_ivas_fx( BSTR_ENC_HANDLE hBstr, const Word32 *L_t_audio /*Q12*/, const Word16 band_start[], const Word16 band_end[], const Word16 band_width[], const Word16 bands, const Word16 p2a_bands, const Word16 p2a_th /*Q11*/, Word16 *p2a_flags );
-static void mdct_spectrum_fine_gain_enc_ivas_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word32 L_ybuf[], /* i : Q12 : input spectrum */
- Word32 L_y2[], /* i/o: Q12 : decoded spectrum */
- const Word16 band_start[], /* i : Q0 : table of start freq for every subband */
- const Word16 band_end[], /* i : Q0 : table of end freq for every subband */
- const Word16 k_sort[], /* i : Q0 : sort table by band_energy */
- const Word16 bands, /* i : Q0 : nubmber of subbands */
- const Word32 L_qint, /* i : Q29 : */
- const Word16 Ngq, /* i : Q0 : */
- const Word16 gqlevs, /* i : Q0 : quantized level */
- const Word16 gqbits /* i : Q0 : quantized bits */
-);
-
-static Word16 band_energy_quant_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word32 *L_t_audio, /* Q12 */
- const Word16 band_start[], /* Q0 */
- const Word16 band_end[], /* Q0 */
- Word32 L_band_energy[], /* Q14 */
- const Word16 bands_fx, /* Q0 */
- const Word32 L_qint, /* Q29 */
- const Word16 eref_fx, /* Q10 */
- const Word16 is_transient /* Q0 */ );
-
/*--------------------------------------------------------------------------*
* spt_shorten_domain_set()
*
@@ -126,77 +100,6 @@ static void spt_shorten_domain_set_fx(
return;
}
-static void spt_shorten_domain_set_ivas_fx(
- Encoder_State *st_fx, /* i: encoder state structure */
- const Word32 L_t_audio[], /* i: input spectrum Q12*/
- const Word16 p2a_flags[], /* i: p2a anlysis information Q0*/
- const Word16 new_band_start[], /* i: new band start position Q0*/
- const Word16 new_band_end[], /* i: new band end position Q0*/
- const Word16 new_band_width[], /* i: new subband band width Q0*/
- const Word16 bands, /* i: total number of subbands Q0*/
- Word16 band_start[], /* i/o: band start position Q0*/
- Word16 band_end[], /* i/o: band end position Q0*/
- Word16 band_width[], /* i: sub band band width Q0*/
- Word16 *bit_budget /* i/o: bit budget Q0*/
-)
-{
- Word16 i, j, k;
- Word16 kpos;
- Word32 L_max_y2;
- Word16 max_y2_pos;
- Word16 spt_shorten_flag[SPT_SHORTEN_SBNUM];
- HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core;
-
- kpos = 0;
- j = 0;
- move16();
- move16();
- FOR( k = ( bands - SPT_SHORTEN_SBNUM ); k < bands; k++ )
- {
- IF( EQ_16( p2a_flags[k], 1 ) )
- {
- spt_shorten_flag[j] = 0;
- move16();
- IF( hHQ_core->prev_SWB_peak_pos[kpos] != 0 )
- {
- L_max_y2 = L_deposit_l( 0 );
- max_y2_pos = 0;
- move16();
- FOR( i = band_start[k]; i <= band_end[k]; i++ )
- {
- IF( LT_32( L_max_y2, L_abs( L_t_audio[i] ) ) )
- {
- L_max_y2 = L_abs( L_t_audio[i] ); /* Q12 */
- move32();
- max_y2_pos = i;
- move16();
- }
- }
- test();
- IF( GE_16( max_y2_pos, new_band_start[j] ) && LE_16( max_y2_pos, new_band_end[j] ) )
- {
- band_start[k] = new_band_start[j]; /* Q0 */
- move16();
- band_end[k] = new_band_end[j]; /* Q0 */
- move16();
- band_width[k] = new_band_width[j]; /* Q0 */
- move16();
- spt_shorten_flag[j] = 1;
- move16();
- }
- }
- push_indice( st_fx->hBstr, IND_HQ2_SPT_SHORTEN, spt_shorten_flag[j], 1 );
- *bit_budget = sub( *bit_budget, 1 ); /* Q0 */
- move16();
- }
-
- kpos += 1;
- j += 1;
- }
-
- return;
-}
-
/*--------------------------------------------------------------------------*
* hq_lr_enc_fx()
@@ -1097,1398 +1000,107 @@ void hq_lr_enc_fx(
return;
}
-void hq_lr_enc_ivas_fx(
- Encoder_State *st, /* i/o: encoder state structure */
- Word32 L_t_audio[], /* i/o: transform-domain coefs. Q12*/
- const Word16 inner_frame, /* i : inner frame length Q0*/
- Word16 *num_bits, /* i/o: number of available bits Q0*/
- const Word16 is_transient /* i : transient flag Q0*/
-)
-{
- Word16 i;
- Word16 bit_budget, pbits;
- Word16 bands, length, ni_seed, gqlevs, gqbits, Ngq, p2a_bands;
- Word16 p2a_flags[BANDS_MAX];
- Word16 band_start[BANDS_MAX], band_end[BANDS_MAX], band_width[BANDS_MAX];
- Word32 L_band_energy[BANDS_MAX];
- Word16 ebits_fx;
-
- Word32 Rk_fx[BANDS_MAX];
- Word16 k1_step_fx, k2_step_fx;
- Word16 k1_fx, k2_fx;
-
- Word32 L_qint; /* Q29 */
- Word16 eref_fx; /* Q10 */
- Word16 bit_alloc_weight_fx; /* Q13 */
- Word16 k_sort[BANDS_MAX];
- Word16 npulses[BANDS_MAX];
- Word32 inp_vector[L_FRAME48k];
-
- Word16 ld_slope_fx /*, Qldslope=15*/;
- Word16 p2a_th_fx /*, Qp2ath=11*/;
- Word16 pd_thresh_fx /*, Qpdth=15*/;
- Word16 ni_coef_fx /*, Qnicoef=14*/;
-
- Word32 L_y2[L_FRAME48k];
- Word32 L_y2_ni[L_FRAME48k];
-
- Word16 hqswb_clas;
- Word16 lowlength;
- Word16 highlength;
- Word16 exp_norm;
- Word32 L_m[L_FRAME32k];
-
- Word16 har_bands;
-
- Word16 lowband, highband, bw_low = 0, bw_high = 20;
- move16();
- move16();
-
- Word32 bwe_br;
- Word16 trans_bit, p2a_flags_tmp[BANDS_MAX];
- Word16 adjustFlag = 0;
- move16();
- Word16 prev_SWB_peak_pos_tmp[SPT_SHORTEN_SBNUM];
- Word16 k, j;
- Word16 flag_spt;
- Word16 org_band_start[SPT_SHORTEN_SBNUM];
- Word16 org_band_end[SPT_SHORTEN_SBNUM];
- Word16 org_band_width[SPT_SHORTEN_SBNUM];
- Word16 new_band_start[SPT_SHORTEN_SBNUM];
- Word16 new_band_end[SPT_SHORTEN_SBNUM];
- Word16 new_band_width[SPT_SHORTEN_SBNUM];
- Word16 bws_cnt = 0;
- move16();
- Word32 L_tmp, L_tmp2, L_tmp3;
- Word16 exp, tmp, exp2, tmp1, tmp2, tmp3, alpha_fx, frac1;
- Word32 enerH_fx;
- Word32 enerL_fx;
- Word32 Ep_fx[BANDS_MAX];
- Word32 Ep_avrg_fx, Ep_vari_fx;
- Word32 Ep_avrgL_fx;
- Word32 Ep_peak_fx;
- Word32 Ep_tmp_fx[BANDS_MAX];
- Word16 gama_fx; /*Q15 0.85f; */
- Word16 beta_fx; /*Q14 1.05f; */
- Word32 L_band_energy_tmp[BANDS_MAX];
- UWord16 lo;
- Word16 Q_band_energy;
- BSTR_ENC_HANDLE hBstr = st->hBstr;
- HQ_ENC_HANDLE hHQ_core = st->hHQ_core;
- set32_fx( L_y2, 0x0L, L_FRAME48k );
- set32_fx( inp_vector, 0, inner_frame );
- flag_spt = 0;
- move16();
- set16_fx( prev_SWB_peak_pos_tmp, 0, SPT_SHORTEN_SBNUM );
- adjustFlag = 0;
- move16();
- bw_low = 0;
- move16();
- bw_high = 20;
- move16();
- enerL_fx = L_deposit_l( 0 );
- enerH_fx = L_deposit_l( 0 );
+/*--------------------------------------------------------------------------*
+ * small_symbol_enc_tran()
+ *
+ * Huffman encoding of differential energies, estimating or packing bits
+ * if flag_pack = 0, LC mode info. is output else LC mode info. is input
+ * if flag_pack = 0, estimatng else packing bits
+ *--------------------------------------------------------------------------*/
+static Word16 small_symbol_enc_tran_fx( /* o : bits */
+ BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */
+ const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/
+ const Word16 BANDS, /* i : number of bands Q0*/
+ Word16 *hLCmode, /* i/o: LC mode info Q0*/
+ const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/
+ const Word16 is_transient /* Q0 */ )
+{
+ Word16 i, bits;
+ Word16 difidx[BANDS_MAX];
- bwe_br = st->core_brate;
- hqswb_clas = HQ_NORMAL;
- move16();
+ FOR( i = 0; i < BANDS; i++ )
+ {
+ difidx[i] = add( qbidx[i], LRMDCT_BE_OFFSET ); /* Q0 */
+ move16();
+ }
- test();
- test();
- IF( EQ_16( st->bwidth, SWB ) && ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) )
+ FOR( i = 0; i < BANDS; ++i )
{
- IF( EQ_16( is_transient, 1 ) )
- {
- hqswb_clas = HQ_TRANSIENT; /* Q0 */
- move16();
- }
- ELSE
+ test();
+ IF( GT_16( difidx[i], LRMDCT_BE_LIMIT ) || difidx[i] < 0 )
{
- hqswb_clas = peak_avrg_ratio_fx( st->total_brate, L_t_audio, NUMC_N, &hHQ_core->mode_count, &hHQ_core->mode_count1, SWB_BWE_LR_Qs ); /* Q0 */
+ /* Huffman cannot encode this vector */
+ return -1;
}
+ }
- /* write the classification information into the bitstream */
- push_indice( hBstr, IND_HQ2_SWB_CLAS, hqswb_clas, 2 );
- ( *num_bits ) = sub( *num_bits, 2 );
- move16();
- IF( EQ_16( hqswb_clas, HQ_NORMAL ) )
- {
- flag_spt = 1;
- move16();
- }
+ /* Preparing lossless coding input */
+ IF( flag_pack == 0 )
+ {
+ /* estimating # of bits */
+ bits = encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient ); /* Q0 */
+ bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies */
}
ELSE
{
- /* write the transient bit into the bitstream */
- push_indice( st->hBstr, IND_HQ2_SWB_CLAS, is_transient, 1 );
-
- /* subtract one bit for the transient flag */
- ( *num_bits ) = sub( *num_bits, 1 );
+ bits = 0;
move16();
+ encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient );
}
- /* Configure encoder for different bandwidths, bitrates, etc. */
+ return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/
+}
+
- hq2_core_configure_fx( inner_frame, *num_bits, is_transient, &bands, &length, band_width, band_start, band_end,
- &L_qint, &eref_fx, &bit_alloc_weight_fx, &gqlevs, &Ngq, &p2a_bands, &p2a_th_fx, &pd_thresh_fx, &ld_slope_fx, &ni_coef_fx, bwe_br );
+/*--------------------------------------------------------------------------*
+ * small_symbol_enc()
+ *
+ * Huffman encoding of differential energies, estimating or packing bits
+ * if flag_pack = 0, LC mode info. is output else LC mode info. is input
+ * if flag_pack = 0, estimatng else packing bits
+ *--------------------------------------------------------------------------*/
+/* o : bits */
+static Word16 small_symbol_enc_fx(
+ BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */
+ const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/
+ const Word16 BANDS, /* i : number of bands Q0*/
+ Word16 *hLCmode, /* i/o: LC mode info Q0*/
+ const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/
+ const Word16 is_transient /* Q0 */ )
+{
+ Word16 i, bits;
+ Word16 difidx[BANDS_MAX], LSB[BANDS_MAX];
- highlength = band_end[( bands - 1 )]; /* Q0 */
- move16();
- har_bands = bands; /* Q0 */
+ /* Preparing lossless coding input */
+ difidx[0] = add( qbidx[0], DE_OFFSET0 ); /* Q0 */
move16();
-
- test();
- test();
- test();
- IF( EQ_16( st->bwidth, SWB ) && is_transient == 0 && ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) )
+ FOR( i = 1; i < BANDS; ++i )
{
- /* reserve bits for HQ_NORMAL2 and HQ_HARMONIC modes */
- test();
- IF( EQ_16( hqswb_clas, HQ_NORMAL ) || EQ_16( hqswb_clas, HQ_HARMONIC ) )
- {
- ( *num_bits ) = sub( *num_bits, get_usebit_npswb_fx( hqswb_clas ) );
- move16();
- }
+ difidx[i] = add( qbidx[i], DE_OFFSET1 ); /* Q0 */
+ move16();
}
- test();
- test();
- IF( ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) && EQ_16( st->bwidth, SWB ) )
+ FOR( i = 0; i < BANDS; ++i )
{
- IF( NE_16( hHQ_core->prev_hqswb_clas, HQ_NORMAL ) )
+ test();
+ IF( GE_16( difidx[i], DE_LIMIT ) || difidx[i] < 0 )
{
- j = 0;
- move16();
- FOR( k = ( bands - SPT_SHORTEN_SBNUM ); k < bands; k++ )
- {
- hHQ_core->prev_SWB_peak_pos[j] = 0;
- move16();
- j += 1;
- }
+ /* Huffman cannot encode this vector */
+ return -1;
}
}
- test();
- IF( GT_16( inner_frame, length ) && is_transient )
+ /* splitting MSB and LSB */
+ FOR( i = 0; i < BANDS; ++i )
{
- /* If so, collapse transient frame (4 short transforms) to remove uncoded coefficients */
-
- k1_step_fx = shr( length, 2 ); /* k1 = length/NUM_TIME_SWITCHING_BLOCKS Q0*/
- k2_step_fx = shr( inner_frame, 2 ); /* k2 = inner_frame/NUM_TIME_SWITCHING_BLOCKS Q0*/
- k1_fx = k1_step_fx; /* Q0 */
- k2_fx = k2_step_fx; /* Q0 */
+ LSB[i] = s_and( difidx[i], 1 ); /* Q0 */
move16();
+ difidx[i] = shr( difidx[i], 1 ); /* Q0 */
move16();
- FOR( i = 1; i < NUM_TIME_SWITCHING_BLOCKS; i++ )
- {
- /*k1 = i*length/NUM_TIME_SWITCHING_BLOCKS; */
- /*k2 = i*inner_frame/NUM_TIME_SWITCHING_BLOCKS; */
-
- Copy32( &L_t_audio[k2_fx], &L_t_audio[k1_fx], k1_step_fx ); /* Q12 */
-
- k1_fx = add( k1_fx, k1_step_fx );
- k2_fx = add( k2_fx, k2_step_fx );
- }
- }
-
- /* Spectral energy calculation/quantization */
-
- ebits_fx = band_energy_quant_ivas_fx( hBstr, L_t_audio, band_start, band_end, L_band_energy, bands,
- L_qint, eref_fx, is_transient ); /* Q0 */
-
- /* First pass bit budget for TCQ of spectral band information */
- exp_norm = norm_s( gqlevs ); /* gqbits_fx = (short int) log2_f ((float) gqlevs_fx); */
- gqbits = sub( 14, exp_norm );
-
- bit_budget = sub( sub( *num_bits, ebits_fx ), round_fx( L_shl( L_mult( Ngq, gqbits ), 15 ) ) ); /* (*num_bits) - (short) ceil (ebits) - Ngq * gqbits; Q0*/
-
-
- pbits = 0;
- move16();
-
- test();
- test();
- IF( EQ_16( st->bwidth, SWB ) && ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) )
- {
- IF( EQ_16( hqswb_clas, HQ_HARMONIC ) )
- {
- set16_fx( p2a_flags, 1, har_bands );
- }
- ELSE
- {
- /* High band tonality detector based on per band peak-to-average ratio */
- pbits = p2a_threshold_quant_ivas_fx( hBstr, L_t_audio, band_start, band_end, band_width, bands, p2a_bands, p2a_th_fx, p2a_flags ); /* Q0 */
- bit_budget = sub( bit_budget, pbits );
-
- IF( EQ_16( hqswb_clas, HQ_NORMAL ) )
- {
- return_bits_normal2_fx( &bit_budget, p2a_flags, bands, bits_lagIndices_modeNormal );
- }
- }
- }
- ELSE
- {
- /* High band tonality detector based on per band peak-to-average ratio */
- pbits = p2a_threshold_quant_ivas_fx( hBstr, L_t_audio, band_start, band_end, band_width, bands, p2a_bands, p2a_th_fx, p2a_flags ); /* Q0 */
- bit_budget = sub( bit_budget, pbits );
- }
-
- IF( EQ_16( flag_spt, 1 ) )
- {
- /* initialize the desired parameters for SPT */
- spt_shorten_domain_band_save_fx( bands, band_start, band_end, band_width, org_band_start, org_band_end, org_band_width );
- spt_shorten_domain_pre_fx( band_start, band_end, hHQ_core->prev_SWB_peak_pos, bands, bwe_br, new_band_start, new_band_end, new_band_width );
- spt_shorten_domain_set_ivas_fx( st, L_t_audio, p2a_flags, new_band_start, new_band_end, new_band_width, bands, band_start, band_end, band_width, &bit_budget );
- }
-
-#define WMC_TOOL_SKIP
- /* Estimate number of bits per band */
- Q_band_energy = SWB_BWE_LR_Qbe;
- move16();
- FOR( i = 0; i < bands; i++ )
- {
- L_tmp = L_shl( L_band_energy[i], sub( 16, Q_band_energy ) ); /*Q16 */
-
- frac1 = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */
- L_tmp = Pow2( 30, frac1 );
- exp = sub( exp, 30 );
- Ep_fx[i] = L_shl( L_tmp, sub( exp, 6 ) ); /* Q -6 */
- move32();
- }
-
- FOR( i = 0; i < bands; i++ )
- {
- L_tmp2 = Ep_fx[i]; /* Q -6 */
- L_tmp = L_max( 1, L_tmp2 );
- exp = norm_l( L_tmp );
- tmp = extract_h( L_shl( L_tmp, exp ) ); /* Q -6 + exp - 16 */
-
- L_tmp3 = L_deposit_l( band_width[i] ); /* Q0 */
- exp2 = norm_l( L_tmp3 );
- tmp2 = extract_h( L_shl( L_tmp3, exp2 ) ); /* exp2 - 16 */
-
- exp2 = sub( exp, exp2 ); /* Denormalize and substract */
-
- tmp3 = sub( tmp2, tmp );
- IF( tmp3 > 0 )
- {
- tmp2 = shr( tmp2, 1 );
- }
- IF( tmp3 > 0 )
- {
- exp2 = add( exp2, 1 );
- }
- tmp = div_s( tmp2, tmp ); /* Q15 */
- L_tmp = L_deposit_h( tmp ); /* Q31 */
- L_tmp = Isqrt_lc1( L_tmp, &exp2 ); /*Q(31-exp2) */
- move32();
- Ep_tmp_fx[i] = L_shr( L_tmp, sub( 15, exp2 ) ); /*Q16 */
- move32();
- }
-#undef WMC_TOOL_SKIP
-
- test();
- test();
- test();
- test();
- test();
- test();
- IF( is_transient == 0 && EQ_16( inner_frame, L_FRAME8k ) && LE_32( st->core_brate, ACELP_13k20 ) )
- {
-#define WMC_TOOL_SKIP
- lowband = 6;
- move16();
- trans_bit = 2;
- move16();
- bit_budget = sub( bit_budget, trans_bit );
- gama_fx = 27852; /*Q15 0.85f */
- beta_fx = 17203; /*Q14 1.05f */
- move16();
- move16();
- set_s( &p2a_flags_tmp[bands - trans_bit], 0, 2 );
-
- IF( EQ_32( st->core_brate, ACELP_13k20 ) )
- {
- beta_fx = 13107; /* Q14 1.25f */
- move16();
- gama_fx = 31130; /* 0.95f Q15 */
- move16();
- mvs2s( &p2a_flags[( bands - trans_bit )], &p2a_flags_tmp[( bands - trans_bit )], trans_bit );
- }
-
- /* calculate the the low band/high band energy and the variance/avrage of the envelopes */
- Ep_vari_fx = 0;
- move32();
- Ep_avrg_fx = 0;
- move32();
- Ep_avrgL_fx = 0;
- move32();
- Ep_peak_fx = 0;
- move32();
- FOR( i = 0; i < bands; i++ )
- {
- IF( sub( i, lowband ) >= 0 )
- {
- Ep_vari_fx = L_add( Ep_vari_fx, L_abs( L_sub( Ep_tmp_fx[i], Ep_tmp_fx[( i - 1 )] ) ) ); /*Q15 */
- Ep_avrg_fx = L_add( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */
- }
- ELSE
- {
- Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */
- IF( L_sub( Ep_tmp_fx[i], Ep_peak_fx ) > 0 )
- {
- Ep_peak_fx = Ep_tmp_fx[i]; /*Q15 */
- move32();
- }
- }
- }
- /* modify the last p2a_bands subbands band_energies */
- k = bands;
- move16();
- mvl2l( L_band_energy, L_band_energy_tmp, k ); /*Q_band_energy */
- Mpy_32_16_ss( Ep_peak_fx, 24576, &L_tmp, &lo );
- Mpy_32_16_ss( Ep_peak_fx, shl( sub( bands, lowband ), 9 ), &L_tmp2, &lo );
- Mpy_32_16_ss( Ep_avrg_fx, 1126, &L_tmp3, &lo );
-
- test();
- test();
- test();
- IF( ( ( L_sub( L_tmp, L_shr( Ep_avrgL_fx, 1 ) ) < 0 && EQ_32( st->core_brate, ACELP_13k20 ) ) || LT_32( st->core_brate, ACELP_13k20 ) ) &&
- L_sub( L_tmp2, L_tmp3 ) < 0 && L_sub( L_tmp2, L_shr( Ep_avrg_fx, 7 ) ) > 0 )
- {
- FOR( i = lowband; i < bands; i++ )
- {
- Mpy_32_16_ss( Ep_avrg_fx, 24576, &L_tmp, &lo );
- IF( L_sub( L_shr( Ep_tmp_fx[i], 1 ), L_tmp ) < 0 )
- {
- Mpy_32_16_ss( Ep_peak_fx, sub( bands, lowband ), &L_tmp, &lo );
- tmp = extract_h( L_shl( L_tmp, 14 ) ); /*Q-4 */
- IF( tmp != 0 )
- {
- exp = norm_s( tmp );
- tmp = shl( tmp, exp ); /*Q(exp) */
- tmp = div_s( 16384, tmp ); /*Q(15+14-exp=29-exp) */
- exp = sub( 29, exp );
- }
- ELSE
- {
- /*when the divisor is zero, happens rarely*/
- tmp = 0x7fff;
- move16();
- exp = 0;
- move16();
- }
- Mpy_32_16_ss( Ep_avrg_fx, tmp, &L_tmp, &lo );
- L_tmp = L_shl( L_tmp, sub( 13, exp ) ); /*Q(13+exp-15 +13-exp +4 = 15) */
- L_tmp2 = L_add( L_tmp, 13107 ); /*15 */
- tmp2 = extract_l( L_min( L_max( L_tmp2, 16384 ), gama_fx ) ); /*15 = 15 */
- Mpy_32_16_ss( L_band_energy_tmp[i], tmp2, &L_band_energy_tmp[i], &lo );
- }
- }
- }
- ELSE
- {
- j = 0;
- move16();
- FOR( i = ( bands - trans_bit ); i < bands; i++ )
- {
- alpha_fx = 16384; /*Q14 */
- move16();
- IF( sub( p2a_flags_tmp[i], 1 ) == 0 )
- {
- Mpy_32_16_ss( Ep_tmp_fx[i], sub( bands, lowband ), &L_tmp, &lo );
- tmp = extract_h( L_shl( L_tmp, 14 ) ); /*Q-4 */
- IF( tmp != 0 )
- {
- exp = norm_s( tmp );
- tmp = shl( tmp, exp ); /*Q(exp) */
- tmp = div_s( 16384, tmp ); /*Q(15+14-exp=29-exp) */
- exp = sub( 29, exp );
- }
- ELSE
- {
- /*when the divisor is zero, happens rarely*/
- tmp = 0x7fff;
- move16();
- exp = 0;
- move16();
- }
- Mpy_32_16_ss( Ep_vari_fx, 3277, &L_tmp, &lo );
- Mpy_32_16_ss( L_tmp, tmp, &L_tmp, &lo );
- L_tmp = L_shl( L_tmp, sub( 12, exp ) ); /*Q(13+exp-15 +12-exp +4 = 14) */
-
- tmp2 = extract_h( Ep_avrg_fx ); /*Q13-16=-3 */
- IF( tmp2 != 0 )
- {
- exp = norm_s( tmp2 );
- tmp2 = shl( tmp2, exp ); /*Q(exp) */
- tmp2 = div_s( 16384, tmp2 ); /*Q(15+14-exp=29-exp) */
- exp = sub( 29, exp );
- }
- ELSE
- {
- tmp2 = 0x7fff;
- move16();
- exp = 0;
- move16();
- }
- Mpy_32_16_ss( Ep_vari_fx, 6554, &L_tmp2, &lo );
- Mpy_32_16_ss( L_tmp2, tmp2, &L_tmp2, &lo );
- L_tmp2 = L_shl( L_tmp2, sub( 13, exp ) ); /*Q(13+exp-15 +13-exp +3 = 14) */
- L_tmp = L_min( L_tmp, L_tmp2 ); /*14 */
- tmp = extract_l( L_min( L_tmp, 13107 ) ); /*14 */
- alpha_fx = add( 16384, tmp ); /* Q14 */
- }
- IF( sub( hHQ_core->last_bitalloc_max_band[j++], 1 ) == 0 )
- {
- Mpy_32_16_ss( Ep_tmp_fx[i], sub( bands, lowband ), &L_tmp, &lo );
- tmp = extract_h( L_shl( L_tmp, 14 ) ); /*Q-2 */
- IF( tmp != 0 )
- {
- exp = norm_s( tmp );
- tmp = shl( tmp, exp ); /*Q(exp) */
- tmp = div_s( 16384, tmp ); /*Q(15+14-exp=29-exp) */
- exp = sub( 29, exp );
- }
- ELSE
- {
- tmp = 0x7fff;
- move16();
- exp = 0;
- move16();
- }
- Mpy_32_16_ss( Ep_avrg_fx, tmp, &L_tmp, &lo );
- L_tmp = L_shl_sat( L_tmp, sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */
- L_tmp = L_max( L_tmp, 16384 ); /*14 */
- tmp = extract_l( L_min( L_tmp, beta_fx ) ); /*14 */
- alpha_fx = shl( mult( alpha_fx, tmp ), 1 ); /*14+14-15 +1=14 */
- }
- ELSE
- {
- tmp2 = extract_h( Ep_avrg_fx ); /*13 -16 =-3 */
- IF( tmp2 != 0 )
- {
- exp = norm_s( tmp2 );
- tmp2 = shl( tmp2, exp ); /*Q(exp) */
- tmp2 = div_s( 16384, tmp2 ); /*Q(15+14-exp=29-exp) */
- exp = sub( 29, exp );
- }
- ELSE
- {
- /*when the divisor is zero, happens rarely*/
- tmp2 = 0x7fff;
- move16();
- exp = 0;
- move16();
- }
- Mpy_32_16_ss( Ep_tmp_fx[i], tmp2, &L_tmp, &lo );
- L_tmp = L_shl( L_tmp, sub( 19, exp ) ); /*Q(13+exp-15 +19-exp +3 = 20) */
- Mpy_32_16_ss( L_tmp, shl( sub( bands, lowband ), 9 ), &L_tmp, &lo );
- L_tmp = L_max( L_tmp, 13926 ); /*14 */
- tmp2 = extract_l( L_min( L_tmp, 16384 ) ); /*14 */
- alpha_fx = shl( mult( alpha_fx, tmp2 ), 1 ); /*14+14-15+1 =14 */
- }
- Mpy_32_16_ss( L_band_energy_tmp[i], alpha_fx, &L_tmp, &lo );
- L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q(Q_band_energy+14-15 +1= Q_band_energy) */
- move32();
- }
- }
- lowband = 3;
- move16();
- Ep_avrg_fx = 0;
- move32();
- Ep_avrgL_fx = 0;
- move32();
- Ep_peak_fx = 0;
- move32();
- FOR( i = 0; i < bands; i++ )
- {
- IF( sub( i, lowband ) >= 0 )
- {
- Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */
- }
- ELSE
- {
- Ep_avrgL_fx = L_add( Ep_avrgL_fx, L_shr( Ep_tmp_fx[i], 1 ) ); /*Q12 */
- IF( L_sub( Ep_tmp_fx[i], Ep_peak_fx ) > 0 )
- {
- Ep_peak_fx = Ep_tmp_fx[i]; /*Q13 */
- move32();
- }
- }
- }
- Mpy_32_16_ss( Ep_peak_fx, 28262, &L_tmp, &lo );
- Mpy_32_16_ss( Ep_avrgL_fx, 24576, &L_tmp2, &lo );
-
- test();
- test();
- IF( L_sub( L_shr( Ep_avrg_fx, 2 ), L_tmp2 ) > 0 && L_sub( L_shr( Ep_avrg_fx, 4 ), L_tmp2 ) < 0 && L_sub( L_tmp, Ep_avrgL_fx ) > 0 )
- {
- adjustFlag = 1;
- move16();
- FOR( i = 0; i < lowband; i++ )
- {
- tmp = extract_h( Ep_avrgL_fx ); /*Q-4 */
- IF( tmp != 0 )
- {
- exp = norm_s( tmp );
- tmp = shl( tmp, exp ); /*Q(exp) */
- tmp = div_s( 16384, tmp ); /*Q(15+14-exp=29-exp) */
- exp = sub( 29, exp );
- }
- ELSE
- {
- /*when the divisor is zero, happens rarely*/
- tmp = 0x7fff;
- move16();
- exp = 0;
- move16();
- }
- Mpy_32_16_ss( Ep_peak_fx, tmp, &L_tmp, &lo );
- Mpy_32_16_ss( L_tmp, lowband, &L_tmp, &lo );
- Mpy_32_16_ss( L_tmp, 18842, &L_tmp, &lo );
- L_tmp = L_shl_sat( L_tmp, sub( 27, exp ) ); /*Q14 0.5 */
- tmp2 = extract_l( L_min( L_tmp, 19661 ) ); /*14 */
- Mpy_32_16_ss( L_band_energy_tmp[i], tmp2, &L_tmp, &lo );
- L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q_band_energy */
- move32();
- }
- }
-#undef WMC_TOOL_SKIP
-
-
- hq2_bit_alloc_fx( L_band_energy_tmp, bands, Rk_fx, &bit_budget, p2a_flags, bit_alloc_weight_fx, band_width, *num_bits, hqswb_clas, st->bwidth, is_transient );
-
- /* encode the last p2a_bands-1 subbands bit-allocation index of the previous frame */
- FOR( i = 0; i < 2; i++ )
- {
- push_indice( hBstr, IND_HQ2_LAST_BA_MAX_BAND, hHQ_core->last_bitalloc_max_band[i], 1 );
- }
- }
- ELSE IF( is_transient == 0 && EQ_16( inner_frame, L_FRAME16k ) )
- {
-#define WMC_TOOL_SKIP
- bit_budget = sub( bit_budget, 2 ); /* bits in high bands to indicate the last 2 subbands is allocated bits or not */
- FOR( i = 0; i < bands; i++ )
- {
- Ep_tmp_fx[i] = L_shl_sat( Ep_tmp_fx[i], 2 ); /* Q15 */
- move32();
- }
- IF( EQ_32( st->core_brate, ACELP_13k20 ) )
- {
- lowband = 8;
- move16();
- highband = 15;
- move16();
- bw_low = sub( band_start[highband], band_start[lowband] ); /* Q0 */
- bw_high = sub( add( band_end[( bands - 1 )], 1 ), band_start[highband] ); /* Q0 */
- }
- ELSE
- {
- lowband = 8;
- move16();
- highband = 16;
- move16();
- bw_low = sub( band_start[highband], band_start[lowband] ); /* Q0 */
- bw_high = sub( add( band_end[( bands - 1 )], 1 ), band_start[highband] ); /* Q0 */
- }
- /* calculate the the low band/high band energy and the variance/avrage of the envelopes */
- enerL_fx = 0;
- move32();
- enerH_fx = 0;
- move32();
- Ep_vari_fx = 0;
- move32();
- Ep_avrg_fx = 0;
- move32();
- FOR( i = 0; i < bands; i++ )
- {
- test();
- IF( sub( i, lowband ) >= 0 && add( sub( i, bands ), p2a_bands ) < 0 )
- {
- Ep_vari_fx = L_add( Ep_vari_fx, L_abs( L_sub( Ep_tmp_fx[i], Ep_tmp_fx[sub( i, 1 )] ) ) ); /*Q15 */
- Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */
- }
-
- IF( sub( i, highband ) >= 0 )
- {
- enerH_fx = L_add( enerH_fx, L_shl( Ep_fx[i], 2 ) ); /*Q0 */
- }
- ELSE IF( sub( i, lowband ) >= 0 )
- {
- enerL_fx = L_add( enerL_fx, L_shl( Ep_fx[i], 2 ) ); /*Q0 */
- }
- }
- /* modify the last p2a_bands subbands band_energies */
- k = bands;
- move16();
- mvl2l( L_band_energy, L_band_energy_tmp, k ); /*Q_band_energy */
-
- L_tmp = L_max( enerH_fx, enerL_fx );
- tmp = s_max( bw_low, bw_high );
- i = norm_l( L_tmp );
- j = norm_s( tmp );
- Mpy_32_16_ss( L_shl( enerH_fx, i ), shl( bw_low, j ), &L_tmp, &lo );
- Mpy_32_16_ss( L_shl( enerL_fx, i ), shl( bw_high, j ), &L_tmp2, &lo );
- L_tmp2 = L_sub( L_tmp, L_tmp2 );
-
- FOR( i = ( bands - p2a_bands ); i < bands; i++ )
- {
- test();
- IF( sub( p2a_flags[i], 1 ) == 0 || L_tmp2 > 0 )
- {
- tmp = sub( bands, p2a_bands );
- tmp = sub( tmp, lowband ); /*Q0 */
-
- tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */
- IF( tmp1 != 0 )
- {
- exp = norm_s( tmp1 );
- tmp1 = shl( tmp1, exp ); /*Q(exp) */
- tmp1 = div_s( 16384, tmp1 ); /*Q(15+14-exp = 29-exp) */
- exp = sub( 29, exp );
- }
- ELSE
- {
- tmp1 = 0x7fff;
- move16();
- exp = 0;
- move16();
- }
- Mpy_32_16_ss( Ep_tmp_fx[i], tmp1, &L_tmp, &lo );
- Mpy_32_16_ss( L_tmp, tmp, &L_tmp, &lo );
- Mpy_32_16_ss( L_tmp, 16384, &L_tmp, &lo );
- L_tmp = L_shl( L_tmp, sub( 32, exp ) ); /*Q15 */
- tmp = extract_l( L_min( L_tmp, 6554 ) ); /*Q15 */
- Mpy_32_16_ss( Ep_vari_fx, tmp1, &L_tmp, &lo );
- Mpy_32_16_ss( L_tmp, tmp, &L_tmp, &lo );
- L_tmp = L_shl( L_tmp, sub( 15, exp ) ); /*Q15 */
- tmp = extract_l( L_shr( L_min( L_tmp, 13107 ), 1 ) ); /*Q14 */
- alpha_fx = add( tmp, 16384 ); /*Q14 */
- }
- ELSE
- {
- alpha_fx = 16384; /* Q14 */
- move16();
- }
-
- IF( add( sub( i, bands ), p2a_bands ) > 0 )
- {
- tmp = sub( bands, p2a_bands );
- IF( sub( hHQ_core->last_bitalloc_max_band[( i - ( tmp + 1 ) )], 1 ) == 0 )
- {
- tmp = sub( tmp, lowband );
- Mpy_32_16_ss( Ep_tmp_fx[i], tmp, &L_tmp, &lo );
- tmp = extract_h( L_shl_sat( L_tmp, 16 ) ); /*Q0 */
- IF( tmp != 0 )
- {
- exp = norm_s( tmp );
- tmp = shl( tmp, exp ); /*Q(exp) */
- tmp = div_s( 16384, tmp ); /*Q(15+14-exp=29-exp) */
- exp = sub( 29, exp );
- }
- ELSE
- {
- tmp = 0x7fff;
- move16();
- exp = 0;
- move16();
- }
- Mpy_32_16_ss( Ep_avrg_fx, tmp, &L_tmp, &lo );
- L_tmp = L_shl( L_tmp, sub( 14, exp ) ); /*Q14 */
- tmp = extract_l( L_min( L_max( L_tmp, 16384 ), 20480 ) ); /*Q14 */
- L_tmp = L_mult( alpha_fx, tmp ); /*Q(14+14+1=29) */
- alpha_fx = extract_l( L_shr( L_tmp, 15 ) ); /*Q14*/
- }
- ELSE
- {
- tmp = sub( tmp, lowband );
- tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */
- IF( tmp1 != 0 )
- {
- exp = norm_s( tmp1 );
- tmp1 = shl( tmp1, exp ); /*Q(exp) */
- tmp1 = div_s( 16384, tmp1 ); /*Q(15+14-exp=29-exp) */
- exp = sub( 29, exp );
- }
- ELSE
- {
- tmp1 = 0x7fff;
- move16();
- exp = 0;
- move16();
- }
- Mpy_32_16_ss( Ep_tmp_fx[i], tmp1, &L_tmp, &lo );
- Mpy_32_16_ss( L_tmp, tmp, &L_tmp, &lo );
- L_tmp = L_shl( L_tmp, sub( 29, exp ) ); /*Q14 */
- tmp = extract_l( L_min( L_max( L_tmp, 13926 ), 16384 ) ); /*Q14 */
- L_tmp = L_mult( alpha_fx, tmp ); /*Q(14+14+1=29) */
- alpha_fx = extract_l( L_shr( L_tmp, 15 ) ); /*Q14 */
- }
- }
- Mpy_32_16_ss( L_band_energy_tmp[i], alpha_fx, &L_tmp, &lo );
- L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q Q_band_energy */
- move32();
- }
- lowband = 6;
- move16();
- Ep_avrg_fx = 0;
- move32();
- Ep_avrgL_fx = 0;
- move32();
- Ep_peak_fx = 0;
- move32();
- FOR( i = 0; i < bands; i++ )
- {
- IF( sub( i, lowband ) >= 0 )
- {
- Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */
- }
- ELSE
- {
- Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */
- IF( L_sub( Ep_tmp_fx[i], Ep_peak_fx ) > 0 )
- {
- Ep_peak_fx = Ep_tmp_fx[i]; /* Q15 */
- move32();
- }
- }
- }
-
- Mpy_32_16_ss( Ep_peak_fx, 24576, &L_tmp, &lo );
- Mpy_32_16_ss( Ep_peak_fx, 19661, &L_tmp2, &lo );
- Mpy_32_16_ss( Ep_avrgL_fx, 24576, &L_tmp3, &lo );
-
- test();
- test();
- test();
- test();
- test();
- IF( ( L_sub( L_shr( Ep_avrgL_fx, 1 ), Ep_avrg_fx ) > 0 && L_sub( L_tmp, L_shr( Ep_avrgL_fx, 2 ) ) > 0 && L_sub( L_shr( Ep_avrgL_fx, 1 ), L_tmp2 ) < 0 ) ||
- ( L_sub( L_shr( Ep_avrg_fx, 1 ), Ep_avrgL_fx ) > 0 && L_sub( L_shr( Ep_avrg_fx, 3 ), L_tmp3 ) < 0 && L_sub( L_tmp, L_shr( Ep_avrgL_fx, 2 ) ) > 0 ) )
- {
- adjustFlag = 1;
- move16();
- FOR( i = 0; i < lowband; i++ )
- {
- tmp = extract_h( L_shl_sat( Ep_avrgL_fx, 1 ) ); /*Q0 */
- IF( tmp != 0 )
- {
- exp = norm_s( tmp );
- tmp = shl( tmp, exp ); /*Q(exp) */
- tmp = div_s( 16384, tmp ); /*Q(15+14-exp=29-exp) */
- exp = sub( 29, exp );
- }
- ELSE
- {
- tmp = 0x7fff;
- move16();
- exp = 0;
- move16();
- }
- Mpy_32_16_ss( Ep_peak_fx, tmp, &L_tmp, &lo );
- Mpy_32_16_ss( L_tmp, lowband, &L_tmp, &lo );
- L_tmp = L_shl( L_tmp, sub( 28, exp ) ); /*Q14 0.5 */
- tmp = extract_l( L_min( L_tmp, 19661 ) ); /*Q14 */
- Mpy_32_16_ss( L_band_energy_tmp[i], tmp, &L_tmp, &lo );
- L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q_band_energy */
- move32();
- }
- }
-#undef WMC_TOOL_SKIP
-
- hq2_bit_alloc_fx( L_band_energy_tmp, bands, Rk_fx, &bit_budget, p2a_flags, bit_alloc_weight_fx, band_width, *num_bits, hqswb_clas, st->bwidth, is_transient );
-
- /* encode the last p2a_bands-1 subbands bit-allocation index of the previous frame */
- FOR( i = 0; i < 2; i++ )
- {
- push_indice( hBstr, IND_HQ2_LAST_BA_MAX_BAND, hHQ_core->last_bitalloc_max_band[i], 1 );
- }
- }
- ELSE IF( EQ_16( st->bwidth, SWB ) && EQ_16( hqswb_clas, HQ_HARMONIC ) && ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) )
- {
- /* bit allocation for harmonic mode */
- hq2_bit_alloc_har_fx( L_band_energy, bit_budget, bands, Rk_fx, p2a_bands, bwe_br, p2a_flags, band_width );
- }
- ELSE
- {
-
- /* estimate number of bits per band */
- hq2_bit_alloc_fx( L_band_energy, bands, Rk_fx, &bit_budget, p2a_flags, bit_alloc_weight_fx, band_width, *num_bits, hqswb_clas, st->bwidth, is_transient );
- }
-
- tcq_core_LR_enc_ivas_fx( hBstr, inp_vector, L_t_audio, L_y2, bit_budget, bands, band_start, band_end, band_width, Rk_fx, npulses, k_sort, p2a_flags, p2a_bands, hHQ_core->last_bitalloc_max_band, inner_frame, adjustFlag, is_transient );
-
- test();
- test();
- IF( ( EQ_16( inner_frame, L_FRAME8k ) && LE_32( st->core_brate, ACELP_13k20 ) ) || EQ_16( inner_frame, L_FRAME16k ) )
- {
- j = 0;
- FOR( i = 2; i > 0; i-- )
- {
- IF( npulses[bands - i] > 0 )
- {
- hHQ_core->last_bitalloc_max_band[j] = 1;
- move16();
- }
- ELSE
- {
- hHQ_core->last_bitalloc_max_band[j] = 0;
- move16();
- }
- j++;
- }
- }
-
- /* Denormalize the coded MDCT spectrum */
- mdct_spectrum_denorm_ivas_fx( inp_vector, L_y2, band_start, band_end, band_width, L_band_energy, npulses, bands, ld_slope_fx, pd_thresh_fx );
-
- /* Apply fine gain quantization to denormalized coded spectrum */
- mdct_spectrum_fine_gain_enc_ivas_fx( st, L_t_audio, L_y2, band_start, band_end, k_sort, bands, L_qint, Ngq, gqlevs, gqbits );
-
- /* reStore the subband information*/
- IF( EQ_16( flag_spt, 1 ) )
- {
- spt_shorten_domain_band_restore_fx( bands, band_start, band_end, band_width, org_band_start, org_band_end, org_band_width );
- }
-
- /* Inject noise into components having relatively low pulse energy per band */
- ni_seed = add( add( add( npulses[0], npulses[1] ), npulses[2] ), npulses[3] ); /* Q0 */
-
- Copy32( L_y2, L_y2_ni, band_end[bands - 1] + 1 ); /* Q12 */
- test();
- test();
- IF( EQ_16( st->bwidth, SWB ) && ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) )
- {
- test();
- IF( EQ_16( hqswb_clas, HQ_NORMAL ) || EQ_16( hqswb_clas, HQ_HARMONIC ) )
- {
- preset_hq2_swb_fx( hqswb_clas, band_end, &har_bands, p2a_bands, length, bands, &lowlength, &highlength, L_m );
-
- swb_bwe_enc_lr_ivas_fx( st, L_y2, SWB_BWE_LR_Qs, L_t_audio, L_m, bwe_br,
- bands, band_start, band_end, L_band_energy, SWB_BWE_LR_Qbe, p2a_flags, hqswb_clas, lowlength, highlength,
- hHQ_core->prev_frm_index, har_bands, &hHQ_core->prev_frm_hfe2, &hHQ_core->prev_stab_hfe2, band_width, L_y2_ni, &ni_seed );
-
- post_hq2_swb_fx( L_m, lowlength, highlength, hqswb_clas, har_bands, bands, p2a_flags, band_start, band_end, L_y2, npulses );
-
- IF( EQ_16( hqswb_clas, HQ_NORMAL ) )
- {
- spt_swb_peakpos_tmp_save_fx( L_y2, bands, band_start, band_end, prev_SWB_peak_pos_tmp );
- FOR( k = 0; k < SPT_SHORTEN_SBNUM; k++ )
- {
- test();
- IF( p2a_flags[bands - SPT_SHORTEN_SBNUM + k] == 0 || npulses[bands - SPT_SHORTEN_SBNUM + k] == 0 )
- {
- prev_SWB_peak_pos_tmp[k] = 0;
- move16();
- }
- }
- }
- Copy32( L_y2_ni, L_y2, lowlength ); /* Q12 */
- }
- ELSE
- {
- Copy32( L_y2_ni, L_y2, band_end[bands - 1] + 1 ); /* HQ_TRANSIENT Q12*/
- }
- }
- ELSE
- {
- Copy32( L_y2_ni, L_y2, band_end[bands - 1] + 1 ); /* NB, WB Q12*/
- }
-
- updat_prev_frm_fx( L_y2, L_t_audio, bwe_br, length, inner_frame, bands, st->bwidth, is_transient, hqswb_clas, &hHQ_core->prev_hqswb_clas, hHQ_core->prev_SWB_peak_pos, prev_SWB_peak_pos_tmp, &hHQ_core->prev_frm_hfe2, &hHQ_core->prev_stab_hfe2, bws_cnt );
-
- IF( NE_16( st->bwidth, SWB ) )
- {
- /* reset HQ classifier memories */
- hHQ_core->mode_count = 0;
- move16();
- hHQ_core->mode_count1 = 0;
- move16();
- }
-
-
- test();
- test();
- test();
- IF( NE_16( hqswb_clas, HQ_HARMONIC ) && ( EQ_32( bwe_br, HQ_16k40 ) || EQ_32( bwe_br, HQ_13k20 ) ) && EQ_16( st->bwidth, SWB ) )
- {
- hHQ_core->prev_frm_index[0] = -1;
- move16();
- hHQ_core->prev_frm_index[1] = -1;
- move16();
- }
-
- /* update number of unused bits */
- *num_bits = 0;
- move16();
-
- hHQ_core->hvq_hangover = 0;
- move16();
-
- return;
-}
-
-
-/*--------------------------------------------------------------------------*
- * small_symbol_enc_tran()
- *
- * Huffman encoding of differential energies, estimating or packing bits
- * if flag_pack = 0, LC mode info. is output else LC mode info. is input
- * if flag_pack = 0, estimatng else packing bits
- *--------------------------------------------------------------------------*/
-
-static Word16 small_symbol_enc_tran_fx( /* o : bits */
- BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */
- const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/
- const Word16 BANDS, /* i : number of bands Q0*/
- Word16 *hLCmode, /* i/o: LC mode info Q0*/
- const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/
- const Word16 is_transient /* Q0 */ )
-{
- Word16 i, bits;
- Word16 difidx[BANDS_MAX];
-
- FOR( i = 0; i < BANDS; i++ )
- {
- difidx[i] = add( qbidx[i], LRMDCT_BE_OFFSET ); /* Q0 */
- move16();
- }
-
- FOR( i = 0; i < BANDS; ++i )
- {
- test();
- IF( GT_16( difidx[i], LRMDCT_BE_LIMIT ) || difidx[i] < 0 )
- {
- /* Huffman cannot encode this vector */
- return -1;
- }
- }
-
- /* Preparing lossless coding input */
- IF( flag_pack == 0 )
- {
- /* estimating # of bits */
- bits = encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient ); /* Q0 */
- bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies */
- }
- ELSE
- {
- bits = 0;
- move16();
- encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient );
- }
-
- return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/
-}
-
-
-static Word16 small_symbol_enc_tran_ivas_fx( /* o : bits */
- BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */
- const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/
- const Word16 BANDS, /* i : number of bands Q0*/
- Word16 *hLCmode, /* i/o: LC mode info Q0*/
- const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/
- const Word16 is_transient /* Q0 */ )
-{
- Word16 i, bits;
- Word16 difidx[BANDS_MAX];
-
- FOR( i = 0; i < BANDS; i++ )
- {
- difidx[i] = add( qbidx[i], LRMDCT_BE_OFFSET ); /* Q0 */
- move16();
- }
-
- FOR( i = 0; i < BANDS; ++i )
- {
- test();
- IF( GT_16( difidx[i], LRMDCT_BE_LIMIT ) || difidx[i] < 0 )
- {
- /* Huffman cannot encode this vector */
- return -1;
- }
- }
-
- /* Preparing lossless coding input */
- IF( flag_pack == 0 )
- {
- /* estimating # of bits */
- bits = encode_envelope_indices_ivas_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient ); /* Q0 */
- bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies */
- }
- ELSE
- {
- bits = 0;
- move16();
- encode_envelope_indices_ivas_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE_TRAN, is_transient );
- }
-
- return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/
-}
-
-
-/*--------------------------------------------------------------------------*
- * small_symbol_enc()
- *
- * Huffman encoding of differential energies, estimating or packing bits
- * if flag_pack = 0, LC mode info. is output else LC mode info. is input
- * if flag_pack = 0, estimatng else packing bits
- *--------------------------------------------------------------------------*/
-
-/* o : bits */
-static Word16 small_symbol_enc_fx(
- BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */
- const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/
- const Word16 BANDS, /* i : number of bands Q0*/
- Word16 *hLCmode, /* i/o: LC mode info Q0*/
- const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/
- const Word16 is_transient /* Q0 */ )
-{
- Word16 i, bits;
- Word16 difidx[BANDS_MAX], LSB[BANDS_MAX];
-
- /* Preparing lossless coding input */
- difidx[0] = add( qbidx[0], DE_OFFSET0 ); /* Q0 */
- move16();
-
- FOR( i = 1; i < BANDS; ++i )
- {
- difidx[i] = add( qbidx[i], DE_OFFSET1 ); /* Q0 */
- move16();
- }
-
- FOR( i = 0; i < BANDS; ++i )
- {
- test();
- IF( GE_16( difidx[i], DE_LIMIT ) || difidx[i] < 0 )
- {
- /* Huffman cannot encode this vector */
- return -1;
- }
- }
-
- /* splitting MSB and LSB */
- FOR( i = 0; i < BANDS; ++i )
- {
- LSB[i] = s_and( difidx[i], 1 ); /* Q0 */
- move16();
- difidx[i] = shr( difidx[i], 1 ); /* Q0 */
- move16();
- }
-
- /* Preparing lossless coding input */
- IF( flag_pack == 0 )
- {
- /* estimating # of bits */
- /* Encoding MSB bits */
- bits = encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE, is_transient ); /* Q0 */
- bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies */
-
- /* Encoding LSB bit packing */
- bits = add( bits, BANDS ); /* Q0 */
- }
- ELSE
- {
- /* Encoding MSB bits */
- bits = 0;
- move16();
- encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE, is_transient );
-
- /* Encoding LSB bit packing */
- FOR( i = 0; i < BANDS; ++i )
- {
- push_indice( hBstr, IND_HQ2_DIFF_ENERGY, LSB[i], BITS_DE_LSB );
- }
- }
-
- return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/
-}
-
-static Word16 small_symbol_enc_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/
- const Word16 BANDS, /* i : number of bands Q0*/
- Word16 *hLCmode, /* i/o: LC mode info Q0*/
- const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/
- const Word16 is_transient /* Q0 */ )
-{
- Word16 i, bits;
- Word16 difidx[BANDS_MAX], LSB[BANDS_MAX];
-
- /* Preparing lossless coding input */
- difidx[0] = add( qbidx[0], DE_OFFSET0 ); /* Q0 */
- move16();
-
- FOR( i = 1; i < BANDS; ++i )
- {
- difidx[i] = add( qbidx[i], DE_OFFSET1 ); /* Q0 */
- move16();
- }
-
- FOR( i = 0; i < BANDS; ++i )
- {
- test();
- IF( GE_16( difidx[i], DE_LIMIT ) || difidx[i] < 0 )
- {
- /* Huffman cannot encode this vector */
- return -1;
- }
- }
-
- /* splitting MSB and LSB */
- FOR( i = 0; i < BANDS; ++i )
- {
- LSB[i] = s_and( difidx[i], 1 ); /* Q0 */
- move16();
- difidx[i] = shr( difidx[i], 1 ); /* Q0 */
- move16();
- }
-
- /* Preparing lossless coding input */
- IF( flag_pack == 0 )
- {
- /* estimating # of bits */
- /* Encoding MSB bits */
- bits = encode_envelope_indices_ivas_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE, is_transient ); /* Q0 */
- bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies Q0*/
-
- /* Encoding LSB bit packing */
- bits = add( bits, BANDS ); /* Q0 */
- }
- ELSE
- {
- /* Encoding MSB bits */
- bits = 0;
- move16();
- encode_envelope_indices_ivas_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE, is_transient );
-
- /* Encoding LSB bit packing */
- FOR( i = 0; i < BANDS; ++i )
- {
- push_indice( hBstr, IND_HQ2_DIFF_ENERGY, LSB[i], BITS_DE_LSB );
- }
- }
-
- return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/
-}
-
-
-/* o : bits Q0 */
-static Word16 large_symbol_enc_fx(
- BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */
- Word16 *qbidx, /* i : input of dequantized differential energy Q0*/
- const Word16 BANDS, /* i : number of bands Q0*/
- Word16 *hLCmode0, /* i/o: LC mode info Q0*/
- const Word16 flag_pack /* i : indicator of packing or estimating bits Q0*/
-)
-{
- Word16 i, bits, tmp;
- Word16 LSB1[BANDS_MAX];
- Word16 min_q, max_q, offset0;
- Word16 min_bits, min_bits_pos;
- Word16 tdifidx0[BANDS_MAX], tdifidx1[BANDS_MAX];
- Word16 basic_shift;
- Word16 bitsmode0, bitsmode1;
- Word16 lsbdepth1;
- Word16 cnt_outlyer, pos_outlyer, cnt_outlyer0;
-
- min_q = 513; /* Q0 */
- move16();
- max_q = -1;
- move16();
-
- cnt_outlyer0 = 0;
- move16();
- cnt_outlyer = 0;
- move16();
- bitsmode0 = 0;
- move16();
- bitsmode1 = 0;
- move16();
- pos_outlyer = 0;
- move16();
- lsbdepth1 = 0;
- move16();
-
- test();
- test();
- IF( flag_pack == 0 || ( EQ_16( flag_pack, 1 ) && *hLCmode0 == 0 ) )
- {
- test();
- test();
- IF( GT_16( qbidx[0], sub( ABS_ENG_OFFSET, 1 ) ) || LT_16( qbidx[0], -ABS_ENG_OFFSET ) )
- {
- cnt_outlyer0 = 2;
- move16();
- }
- ELSE IF( GT_16( qbidx[0], 3 ) || LT_16( qbidx[0], -4 ) )
- {
- cnt_outlyer0 = 1;
- move16();
- }
- ELSE
- {
- cnt_outlyer0 = 0;
- move16();
- }
-
- cnt_outlyer = 0;
- move16();
- pos_outlyer = -1;
- move16();
- FOR( i = 1; i < BANDS; ++i )
- {
- test();
- IF( GT_16( qbidx[i], 3 ) || LT_16( qbidx[i], -4 ) )
- {
- cnt_outlyer = add( cnt_outlyer, 1 ); /* Q0 */
- pos_outlyer = i;
- move16();
- }
-
- test();
- IF( GT_16( qbidx[i], ( ABS_ENG_OFFSET - 1 ) ) || LT_16( qbidx[i], -ABS_ENG_OFFSET ) )
- {
- cnt_outlyer = add( cnt_outlyer, 1 ); /* Q0 */
- }
- }
-
- test();
- test();
- IF( cnt_outlyer0 == 0 && LE_16( cnt_outlyer, 1 ) )
- {
- bitsmode0 = ( BITS_DE_8SMODE + BITS_DE_8SMODE_N0 ) + BITS_DE_8SMODE_N1; /* Q0 */
- move16();
- IF( EQ_16( cnt_outlyer, 1 ) )
- {
- /* 01 */
- bitsmode0 = add( bitsmode0, ( BITS_DE_8SPOS + BITS_ABS_ENG ) ); /* Q0 */
- }
-
- FOR( i = 0; i < pos_outlyer; ++i )
- {
- tdifidx0[i] = qbidx[i]; /* Q0 */
- move16();
- bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */
- }
-
- FOR( i = add( pos_outlyer, 1 ); i < BANDS; ++i )
- {
- tdifidx0[i] = qbidx[i]; /* Q0 */
- move16();
- bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */
- }
- }
- ELSE IF( EQ_16( cnt_outlyer0, 1 ) && LE_16( cnt_outlyer, 1 ) )
- {
- bitsmode0 = ( BITS_DE_8SMODE + BITS_DE_8SMODE_N0 ) + BITS_DE_8SMODE_N1; /* Q0 */
- move16();
- tdifidx0[0] = qbidx[0]; /* Q0 */
- move16();
- bitsmode0 = add( bitsmode0, BITS_ABS_ENG );
- IF( EQ_16( cnt_outlyer, 1 ) )
- {
- /* 11 */
- bitsmode0 = add( bitsmode0, ( BITS_DE_8SPOS + BITS_ABS_ENG ) ); /* Q0 */
- }
- ELSE
- {
- pos_outlyer = 0;
- move16();
- }
-
- FOR( i = 1; i < pos_outlyer; ++i )
- {
- tdifidx0[i] = qbidx[i]; /* Q0 */
- move16();
- bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */
- }
-
- FOR( i = add( pos_outlyer, 1 ); i < BANDS; ++i )
- {
- tdifidx0[i] = qbidx[i]; /* Q0 */
- move16();
- bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */
- }
- }
- ELSE
- {
- bitsmode0 = 20000;
- move16();
- }
- }
-
- test();
- IF( flag_pack == 0 || EQ_16( *hLCmode0, 1 ) )
- {
- /* components 0 range : -256~255 */
- max_q = MINIMUM_ENERGY_LOWBRATE;
- move16();
- min_q = MAXIMUM_ENERGY_LOWBRATE;
- move16();
- FOR( i = 0; i < BANDS; ++i )
- {
- max_q = s_max( qbidx[i], max_q );
- min_q = s_min( qbidx[i], min_q );
- }
-
- /* Counting bits for transmitting all components using same method */
- FOR( i = 0;; ++i )
- {
- /*if (max_q <= ((2<<(i+1))-1) && min_q >= -(2<<(i+1))) */
- test();
- IF( LE_16( max_q, sub( shl( 2, add( i, 1 ) ), 1 ) ) && GE_16( min_q, -shl( 2, add( i, 1 ) ) ) )
- {
- BREAK;
- }
- }
- basic_shift = i;
- move16();
-
- min_bits = 1000; /* Q0 */
- move16();
- min_bits_pos = basic_shift; /* Q0 */
- move16();
- tmp = add( basic_shift, 3 );
- FOR( offset0 = basic_shift; offset0 < tmp; offset0++ )
- {
- max_q = MINIMUM_ENERGY_LOWBRATE;
- move16();
- min_q = MAXIMUM_ENERGY_LOWBRATE;
- move16();
-
- bitsmode1 = add( BITS_DE_8SMODE, BITS_MAX_DEPTH ); /* Q0 */
- FOR( i = 0; i < BANDS; ++i )
- {
- bitsmode1 = add( bitsmode1, add( hessize[( ( qbidx[i] >> offset0 ) + 4 )], offset0 ) );
- }
-
- IF( GT_16( min_bits, bitsmode1 ) )
- {
- min_bits_pos = offset0; /* Q0 */
- move16();
- min_bits = bitsmode1; /* Q0 */
- move16();
- }
- }
-
- bitsmode1 = min_bits;
- move16();
- lsbdepth1 = min_bits_pos;
- move16();
-
- FOR( i = 0; i < BANDS; ++i )
- {
- LSB1[i] = s_and( qbidx[i], sub( shl( 1, lsbdepth1 ), 1 ) );
- tdifidx1[i] = shr( qbidx[i], lsbdepth1 );
- move16();
- move16();
- }
}
/* Preparing lossless coding input */
@@ -2496,128 +1108,33 @@ static Word16 large_symbol_enc_fx(
{
/* estimating # of bits */
/* Encoding MSB bits */
- IF( LT_16( bitsmode0, bitsmode1 ) )
- {
- bits = bitsmode0; /* Q0 */
- move16();
- *hLCmode0 = 0;
- move16();
- }
- ELSE
- {
- bits = bitsmode1; /* Q0 */
- move16();
- *hLCmode0 = 1;
- move16();
- }
- }
- ELSE
- {
- /* Encoding MSB bits */
- IF( *hLCmode0 == 0 )
- {
- push_indice( hBstr, IND_HQ2_DENG_8SMODE, 0, BITS_DE_8SMODE );
- bits = BITS_DE_8SMODE;
- move16();
- IF( cnt_outlyer0 == 0 )
- {
- push_indice( hBstr, IND_HQ2_DENG_8SMODE_N0, 0, BITS_DE_8SMODE_N0 );
- bits = add( bits, BITS_DE_8SMODE_N0 );
- IF( EQ_16( cnt_outlyer, 1 ) )
- {
- /* 01 */
- push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 1, BITS_DE_8SMODE_N1 );
- bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */
- push_indice( hBstr, IND_HQ2_DENG_8SPOS, pos_outlyer, BITS_DE_8SPOS );
- bits = add( bits, BITS_DE_8SPOS );
- push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[pos_outlyer] + ABS_ENG_OFFSET, BITS_ABS_ENG );
- bits = add( bits, BITS_ABS_ENG );
- }
- ELSE
- {
- /* 00 */
- push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 0, BITS_DE_8SMODE_N1 );
- bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */
- }
-
- FOR( i = 0; i < pos_outlyer; ++i )
- {
- push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] );
- bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */
- }
-
- FOR( i = ( pos_outlyer + 1 ); i < BANDS; ++i )
- {
- push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] );
- bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */
- }
- }
- ELSE IF( EQ_16( cnt_outlyer0, 1 ) )
- {
- push_indice( hBstr, IND_HQ2_DENG_8SMODE_N0, 1, BITS_DE_8SMODE_N0 );
- bits = add( bits, BITS_DE_8SMODE_N0 );
- IF( EQ_16( cnt_outlyer, 1 ) )
- {
- push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 1, BITS_DE_8SMODE_N1 );
- bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */
- push_indice( hBstr, IND_HQ2_DENG_8SPOS, pos_outlyer, BITS_DE_8SPOS );
- bits = add( bits, BITS_DE_8SPOS );
- push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG );
- bits = add( bits, BITS_ABS_ENG );
- push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[pos_outlyer] + ABS_ENG_OFFSET, BITS_ABS_ENG );
- bits = add( bits, BITS_ABS_ENG );
- }
- ELSE
- {
- push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 0, BITS_DE_8SMODE_N1 );
- bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */
- push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG );
- bits = add( bits, BITS_ABS_ENG ); /* Q0 */
- }
-
- FOR( i = 1; i < pos_outlyer; ++i )
- {
- push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] );
- bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */
- }
-
- FOR( i = pos_outlyer + 1; i < BANDS; ++i )
- {
- push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] );
- bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */
- }
- }
- }
- ELSE
- {
- bits = add( BITS_DE_8SMODE, BITS_MAX_DEPTH ); /* Q0 */
- push_indice( hBstr, IND_HQ2_DENG_8SMODE, 1, BITS_DE_8SMODE );
- push_indice( hBstr, IND_HQ2_DENG_8SDEPTH, lsbdepth1, BITS_MAX_DEPTH );
+ bits = encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE, is_transient ); /* Q0 */
+ bits = add( bits, BITS_DE_FCOMP ); /* xx bits for diff. energies + BITS_DE_FCOMP bits for first energies */
- FOR( i = 0; i < BANDS; ++i )
- {
- push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx1[i] + 4], hessize[tdifidx1[i] + 4] );
- bits = add( bits, hessize[tdifidx1[i] + 4] ); /* Q0 */
- }
+ /* Encoding LSB bit packing */
+ bits = add( bits, BANDS ); /* Q0 */
+ }
+ ELSE
+ {
+ /* Encoding MSB bits */
+ bits = 0;
+ move16();
+ encode_envelope_indices_fx( hBstr, BANDS, -1, difidx, hLCmode, flag_pack, LOW_RATE_HQ_CORE, is_transient );
- IF( lsbdepth1 > 0 )
- {
- FOR( i = 0; i < BANDS; ++i )
- {
- push_indice( hBstr, IND_HQ2_DIFF_ENERGY, LSB1[i], lsbdepth1 );
- }
- /*bits += BANDS * lsbdepth1; */
- bits = add( bits, extract_h( L_shl( L_mult( BANDS, lsbdepth1 ), 15 ) ) ); /* Q0 */
- }
+ /* Encoding LSB bit packing */
+ FOR( i = 0; i < BANDS; ++i )
+ {
+ push_indice( hBstr, IND_HQ2_DIFF_ENERGY, LSB[i], BITS_DE_LSB );
}
}
- return bits; /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/
+ return add( bits, BITS_DE_HMODE ); /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/
}
-static Word16 large_symbol_enc_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+/* o : bits Q0 */
+static Word16 large_symbol_enc_fx(
+ BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */
Word16 *qbidx, /* i : input of dequantized differential energy Q0*/
const Word16 BANDS, /* i : number of bands Q0*/
Word16 *hLCmode0, /* i/o: LC mode info Q0*/
@@ -2704,7 +1221,7 @@ static Word16 large_symbol_enc_ivas_fx(
IF( EQ_16( cnt_outlyer, 1 ) )
{
/* 01 */
- bitsmode0 = add( bitsmode0, add( BITS_DE_8SPOS, BITS_ABS_ENG ) ); /* Q0 */
+ bitsmode0 = add( bitsmode0, ( BITS_DE_8SPOS + BITS_ABS_ENG ) ); /* Q0 */
}
FOR( i = 0; i < pos_outlyer; ++i )
@@ -2714,7 +1231,7 @@ static Word16 large_symbol_enc_ivas_fx(
bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */
}
- FOR( i = ( pos_outlyer + 1 ); i < BANDS; ++i )
+ FOR( i = add( pos_outlyer, 1 ); i < BANDS; ++i )
{
tdifidx0[i] = qbidx[i]; /* Q0 */
move16();
@@ -2727,7 +1244,7 @@ static Word16 large_symbol_enc_ivas_fx(
move16();
tdifidx0[0] = qbidx[0]; /* Q0 */
move16();
- bitsmode0 = add( bitsmode0, BITS_ABS_ENG ); /* Q0 */
+ bitsmode0 = add( bitsmode0, BITS_ABS_ENG );
IF( EQ_16( cnt_outlyer, 1 ) )
{
/* 11 */
@@ -2746,7 +1263,7 @@ static Word16 large_symbol_enc_ivas_fx(
bitsmode0 = add( bitsmode0, hessize[tdifidx0[i] + 4] ); /* Q0 */
}
- FOR( i = ( pos_outlyer + 1 ); i < BANDS; ++i )
+ FOR( i = add( pos_outlyer, 1 ); i < BANDS; ++i )
{
tdifidx0[i] = qbidx[i]; /* Q0 */
move16();
@@ -2755,7 +1272,7 @@ static Word16 large_symbol_enc_ivas_fx(
}
ELSE
{
- bitsmode0 = 20000; /* Q0 */
+ bitsmode0 = 20000;
move16();
}
}
@@ -2799,11 +1316,10 @@ static Word16 large_symbol_enc_ivas_fx(
min_q = MAXIMUM_ENERGY_LOWBRATE;
move16();
- bitsmode1 = ( BITS_DE_8SMODE + BITS_MAX_DEPTH ); /* Q0 */
- move16();
+ bitsmode1 = add( BITS_DE_8SMODE, BITS_MAX_DEPTH ); /* Q0 */
FOR( i = 0; i < BANDS; ++i )
{
- bitsmode1 = add( bitsmode1, add( hessize[( ( qbidx[i] >> offset0 ) + 4 )], offset0 ) ); /* Q0 */
+ bitsmode1 = add( bitsmode1, add( hessize[( ( qbidx[i] >> offset0 ) + 4 )], offset0 ) );
}
IF( GT_16( min_bits, bitsmode1 ) )
@@ -2815,9 +1331,9 @@ static Word16 large_symbol_enc_ivas_fx(
}
}
- bitsmode1 = min_bits; /* Q0 */
+ bitsmode1 = min_bits;
move16();
- lsbdepth1 = min_bits_pos; /* Q0 */
+ lsbdepth1 = min_bits_pos;
move16();
FOR( i = 0; i < BANDS; ++i )
@@ -2892,286 +1408,93 @@ static Word16 large_symbol_enc_ivas_fx(
}
ELSE IF( EQ_16( cnt_outlyer0, 1 ) )
{
- push_indice( hBstr, IND_HQ2_DENG_8SMODE_N0, 1, BITS_DE_8SMODE_N0 );
- bits = add( bits, BITS_DE_8SMODE_N0 ); /* Q0 */
- IF( EQ_16( cnt_outlyer, 1 ) )
- {
- push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 1, BITS_DE_8SMODE_N1 );
- bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */
- push_indice( hBstr, IND_HQ2_DENG_8SPOS, pos_outlyer, BITS_DE_8SPOS );
- bits = add( bits, BITS_DE_8SPOS );
- push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG );
- bits = add( bits, BITS_ABS_ENG );
- push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[pos_outlyer] + ABS_ENG_OFFSET, BITS_ABS_ENG );
- bits = add( bits, BITS_ABS_ENG );
- }
- ELSE
- {
- push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 0, BITS_DE_8SMODE_N1 );
- bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */
- push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG );
- bits = add( bits, BITS_ABS_ENG ); /* Q0 */
- }
-
- FOR( i = 1; i < pos_outlyer; ++i )
- {
- push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] );
- bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */
- }
-
- FOR( i = pos_outlyer + 1; i < BANDS; ++i )
- {
- push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] );
- bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */
- }
- }
- }
- ELSE
- {
- bits = add( BITS_DE_8SMODE, BITS_MAX_DEPTH );
- push_indice( hBstr, IND_HQ2_DENG_8SMODE, 1, BITS_DE_8SMODE );
- push_indice( hBstr, IND_HQ2_DENG_8SDEPTH, lsbdepth1, BITS_MAX_DEPTH );
-
- FOR( i = 0; i < BANDS; ++i )
- {
- push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx1[i] + 4], hessize[tdifidx1[i] + 4] );
- bits = add( bits, hessize[tdifidx1[i] + 4] ); /* Q0 */
- }
-
- IF( lsbdepth1 > 0 )
- {
- FOR( i = 0; i < BANDS; ++i )
- {
- push_indice( hBstr, IND_HQ2_DIFF_ENERGY, LSB1[i], lsbdepth1 );
- }
- /*bits += BANDS * lsbdepth1; */
- bits = add( bits, extract_h( L_shl( L_mult( BANDS, lsbdepth1 ), 15 ) ) ); /* Q0 */
- }
- }
- }
-
- return bits; /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/
-}
-
-/*-------------------------------------------------------------------*
- * band_energy_quant()
- *
- *
- *-------------------------------------------------------------------*/
-
-static Word16 band_energy_quant_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word32 *L_t_audio, /* i : Q12 : input MDCT signal (Qs) */
- const Word16 band_start[], /* i : Q0 : band start table */
- const Word16 band_end[], /* i : Q0 : band end table */
- Word32 L_band_energy[], /* i : Q14 : band energy (Qbe) */
- const Word16 bands_fx, /* i : Q0 : number of bands */
- const Word32 L_qint, /* i : Q29 */
- const Word16 eref_fx, /* i : Q10 */
- const Word16 is_transient_fx /* i : Q0 : indicator for HQ_TRANSIENT */
-)
-{
- Word16 i, k;
- Word16 ebits;
- Word16 hLCmode0, hLCmode1, deng_bits;
- Word16 deng_cmode = 0;
- Word16 hbits;
- move16();
-
- Word32 L_E;
- Word16 QE;
-
- Word16 rev_qint_fx; /* 1/qint */
- Word16 Qrev_qint; /* Q value for 1/qint */
-
- Word16 bq0_fx;
- Word16 bq1_fx[BANDS_MAX];
- Word16 bq2_fx[BANDS_MAX];
-
- Word16 bq1_temp_fx[BANDS_MAX];
- Word16 bq2_temp_fx[BANDS_MAX];
-
- Word32 L_tmp;
- Word16 temp_fx;
- Word16 frac, exp;
- Word16 exp_safe;
- Word16 exp_norm;
- Word16 exp_norm2;
- Word16 exp_normd;
-
- /* Calculate the band energies */
- exp_safe = 4;
- move16(); /* 4: never overflow happen at L_E */
- FOR( k = 0; k < bands_fx; k++ )
- {
- L_tmp = L_deposit_l( 1295 ); /* 1295 = sqrt(0.1) (Qs) */
- FOR( i = band_start[k]; i <= band_end[k]; i++ )
- {
- L_tmp = L_or( L_tmp, L_abs( L_t_audio[i] ) ); /* Qs */
- }
- exp_norm = norm_l( L_tmp );
- exp_norm = sub( exp_norm, exp_safe ); /* safe_shift */
-
- QE = add( shl( sub( add( SWB_BWE_LR_Qs, exp_norm ), 16 ), 1 ), 1 );
- L_E = L_shl( 590L, sub( QE, 15 ) ); /* 590 0.018f(Q15 -> QE) */
- FOR( i = band_start[k]; i <= band_end[k]; i++ )
- {
- /*E += yos[i] * yos[i]; */
- temp_fx = round_fx( L_shl( L_t_audio[i], exp_norm ) ); /* Qs+exp_norm-16 */
- L_E = L_mac( L_E, temp_fx, temp_fx ); /* (Qs+exp_norm-16)*2+1 */
- }
-
- /*band_energy[k] = (float) log2_f (E + 1.0e-1f); */
- exp_norm2 = norm_l( L_E );
- exp = add( add( shl( sub( add( SWB_BWE_LR_Qs, exp_norm ), 16 ), 1 ), 1 ), exp_norm2 );
- L_E = L_shl( L_E, exp_norm2 ); /* (Qs+exp_norm-16)*2 + 1 + exp_norm2 */
- frac = Log2_norm_lc( L_E );
- exp = sub( 30, exp );
- L_tmp = L_Comp( exp, frac );
- L_band_energy[k] = L_shr( L_tmp, 2 ); /* Q16->Qbe(Q14) */
- move32();
- }
-
- IF( is_transient_fx )
- {
- reverse_transient_frame_energies_fx( L_band_energy, bands_fx );
- }
-
-
- /* Quantize the reference and band energies */
- exp_normd = norm_l( L_qint );
- rev_qint_fx = div_s( 0x4000, round_fx( L_shl( L_qint, exp_normd ) ) ); /* Q14-(29+exp_normd-16)+15 */
- Qrev_qint = sub( 14 - ( 29 - 16 ) + 15, exp_normd );
-
- bq0_fx = round_fx( L_shl( L_mult( eref_fx, rev_qint_fx ), sub( 5, Qrev_qint ) ) ); /* 16-(10+Qrev_qint+1) */
- FOR( k = 0; k < bands_fx; k++ )
- {
- /*bq1[k] = round_f (band_energy[k] / qint); */
- L_tmp = Mpy_32_16_1( L_band_energy[k], rev_qint_fx ); /* Q14+Qrev_qint-15 */
- bq1_fx[k] = round_fx( L_shl( L_tmp, sub( 17, Qrev_qint ) ) ); /* Q0 */
- move16();
- }
-
- IF( is_transient_fx )
- {
-
- Copy( bq1_fx, bq1_temp_fx, bands_fx ); /* Q0 */
-
- /* Calculate the differential energies */
- diffcod_lrmdct_fx( bands_fx, bq0_fx, bq1_temp_fx, bq2_temp_fx, is_transient_fx );
- }
-
- /* Calculate the differential energies */
- bq2_fx[0] = sub( bq1_fx[0], bq0_fx ); /* Q0 */
- move16();
- FOR( k = 1; k < bands_fx; k++ )
- {
- bq2_fx[k] = sub( bq1_fx[k], bq1_fx[k - 1] ); /* Q0 */
- move16();
- }
-
- /* Modifying qbidx to be located in the range -256~255 */
- FOR( i = 0; i < bands_fx; ++i )
- {
- IF( GT_16( bq2_fx[i], MAXIMUM_ENERGY_LOWBRATE ) )
- {
- bq2_fx[i] = MAXIMUM_ENERGY_LOWBRATE; /* Q0 */
- move16();
- }
- IF( LT_16( bq2_fx[i], MINIMUM_ENERGY_LOWBRATE ) )
- {
- bq2_fx[i] = MINIMUM_ENERGY_LOWBRATE; /* Q0 */
- move16();
- }
- }
-
- /* Get number of bits by Huffman0 coding */
- ebits = large_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode0, 0 ); /* Q0 */
-
- IF( is_transient_fx )
- {
- /* Get number of bits by Huffman coding */
- hbits = small_symbol_enc_tran_fx( hBstr, bq2_temp_fx, bands_fx, &hLCmode1, 0, is_transient_fx ); /* Q0 */
- }
- ELSE
- {
- /* Get number of bits by Huffman coding */
- hbits = small_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode1, 0, is_transient_fx ); /* Q0 */
- }
-
- /* comparing used bits */
- test();
- IF( LT_16( ebits, hbits ) || EQ_16( hbits, -1 ) )
- {
- deng_cmode = 0;
- move16();
- push_indice( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE );
- large_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode0, 1 );
- deng_bits = add( ebits, BITS_DE_CMODE ); /* Q0 */
- }
- ELSE
- {
- /* setting energy difference coding mode and storing it */
- deng_cmode = 1;
- move16();
- push_indice( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE );
+ push_indice( hBstr, IND_HQ2_DENG_8SMODE_N0, 1, BITS_DE_8SMODE_N0 );
+ bits = add( bits, BITS_DE_8SMODE_N0 );
+ IF( EQ_16( cnt_outlyer, 1 ) )
+ {
+ push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 1, BITS_DE_8SMODE_N1 );
+ bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */
+ push_indice( hBstr, IND_HQ2_DENG_8SPOS, pos_outlyer, BITS_DE_8SPOS );
+ bits = add( bits, BITS_DE_8SPOS );
+ push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG );
+ bits = add( bits, BITS_ABS_ENG );
+ push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[pos_outlyer] + ABS_ENG_OFFSET, BITS_ABS_ENG );
+ bits = add( bits, BITS_ABS_ENG );
+ }
+ ELSE
+ {
+ push_indice( hBstr, IND_HQ2_DENG_8SMODE_N1, 0, BITS_DE_8SMODE_N1 );
+ bits = add( bits, BITS_DE_8SMODE_N1 ); /* Q0 */
+ push_indice( hBstr, IND_HQ2_DIFF_ENERGY, qbidx[0] + ABS_ENG_OFFSET, BITS_ABS_ENG );
+ bits = add( bits, BITS_ABS_ENG ); /* Q0 */
+ }
- deng_bits = add( hbits, BITS_DE_CMODE ); /* Q0 */
+ FOR( i = 1; i < pos_outlyer; ++i )
+ {
+ push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] );
+ bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */
+ }
- /* packing indice */
- IF( is_transient_fx )
- {
- Copy( bq2_temp_fx, bq2_fx, bands_fx ); /* Q0 */
- small_symbol_enc_tran_fx( hBstr, bq2_fx, bands_fx, &hLCmode1, 1, is_transient_fx );
+ FOR( i = pos_outlyer + 1; i < BANDS; ++i )
+ {
+ push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx0[i] + 4], hessize[tdifidx0[i] + 4] );
+ bits = add( bits, hessize[tdifidx0[i] + 4] ); /* Q0 */
+ }
+ }
}
ELSE
{
- small_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode1, 1, is_transient_fx );
- }
- }
-
- /* Reconstruct quantized spectrum */
- bq1_fx[0] = add( bq2_fx[0], bq0_fx ); /* Q0 */
- move16();
- FOR( k = 1; k < bands_fx; k++ )
- {
- bq1_fx[k] = add( bq2_fx[k], bq1_fx[k - 1] ); /* Q0 */
- move16();
- }
+ bits = add( BITS_DE_8SMODE, BITS_MAX_DEPTH ); /* Q0 */
+ push_indice( hBstr, IND_HQ2_DENG_8SMODE, 1, BITS_DE_8SMODE );
+ push_indice( hBstr, IND_HQ2_DENG_8SDEPTH, lsbdepth1, BITS_MAX_DEPTH );
- FOR( k = 0; k < bands_fx; k++ )
- {
- L_band_energy[k] = Mpy_32_16_1( L_qint, bq1_fx[k] ); /* 29+0-15 -> Qbe(Q14) */
- move32();
- }
+ FOR( i = 0; i < BANDS; ++i )
+ {
+ push_indice( hBstr, IND_HQ2_DIFF_ENERGY, hescode[tdifidx1[i] + 4], hessize[tdifidx1[i] + 4] );
+ bits = add( bits, hessize[tdifidx1[i] + 4] ); /* Q0 */
+ }
- IF( is_transient_fx )
- {
- reverse_transient_frame_energies_fx( L_band_energy, bands_fx );
+ IF( lsbdepth1 > 0 )
+ {
+ FOR( i = 0; i < BANDS; ++i )
+ {
+ push_indice( hBstr, IND_HQ2_DIFF_ENERGY, LSB1[i], lsbdepth1 );
+ }
+ /*bits += BANDS * lsbdepth1; */
+ bits = add( bits, extract_h( L_shl( L_mult( BANDS, lsbdepth1 ), 15 ) ) ); /* Q0 */
+ }
+ }
}
- return ( deng_bits ); /* Q0 */
+ return bits; /* xx bits for diff. energies + 1 bit for LC coding mode Q0*/
}
-static Word16 band_energy_quant_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word32 *L_t_audio, /* i : Q12 : input MDCT signal (Qs) */
- const Word16 band_start[], /* i : Q0 : band start table */
- const Word16 band_end[], /* i : Q0 : band end table */
- Word32 L_band_energy[], /* i : Q14 : band energy (Qbe) */
- const Word16 bands, /* i : Q0 : number of bands */
- const Word32 L_qint, /* i : Q29 */
- const Word16 eref_fx, /* i : Q10 */
- const Word16 is_transient /* i : Q0 : indicator for HQ_TRANSIENT */
+/*-------------------------------------------------------------------*
+ * band_energy_quant()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
+static Word16 band_energy_quant_fx(
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ const Word32 *L_t_audio, /* i : Q12 : input MDCT signal (Qs) */
+ const Word16 band_start[], /* i : Q0 : band start table */
+ const Word16 band_end[], /* i : Q0 : band end table */
+ Word32 L_band_energy[], /* i : Q14 : band energy (Qbe) */
+ const Word16 bands_fx, /* i : Q0 : number of bands */
+ const Word32 L_qint, /* i : Q29 */
+ const Word16 eref_fx, /* i : Q10 */
+ const Word16 is_transient_fx /* i : Q0 : indicator for HQ_TRANSIENT */
)
{
Word16 i, k;
Word16 ebits;
Word16 hLCmode0, hLCmode1, deng_bits;
Word16 deng_cmode = 0;
- move16();
Word16 hbits;
+ move16();
+
Word32 L_E;
Word16 QE;
@@ -3191,13 +1514,12 @@ static Word16 band_energy_quant_ivas_fx(
Word16 exp_safe;
Word16 exp_norm;
Word16 exp_norm2;
-
Word16 exp_normd;
- /* Calculate the band energies */
+
/* Calculate the band energies */
exp_safe = 4;
move16(); /* 4: never overflow happen at L_E */
- FOR( k = 0; k < bands; k++ )
+ FOR( k = 0; k < bands_fx; k++ )
{
L_tmp = L_deposit_l( 1295 ); /* 1295 = sqrt(0.1) (Qs) */
FOR( i = band_start[k]; i <= band_end[k]; i++ )
@@ -3227,253 +1549,135 @@ static Word16 band_energy_quant_ivas_fx(
move32();
}
- IF( is_transient )
+ IF( is_transient_fx )
{
- reverse_transient_frame_energies_fx( L_band_energy, bands );
+ reverse_transient_frame_energies_fx( L_band_energy, bands_fx );
}
-#define WMC_TOOL_SKIP
+
+ /* Quantize the reference and band energies */
exp_normd = norm_l( L_qint );
rev_qint_fx = div_s( 0x4000, round_fx( L_shl( L_qint, exp_normd ) ) ); /* Q14-(29+exp_normd-16)+15 */
Qrev_qint = sub( 14 - ( 29 - 16 ) + 15, exp_normd );
bq0_fx = round_fx( L_shl( L_mult( eref_fx, rev_qint_fx ), sub( 5, Qrev_qint ) ) ); /* 16-(10+Qrev_qint+1) */
- FOR( k = 0; k < bands; k++ )
+ FOR( k = 0; k < bands_fx; k++ )
{
/*bq1[k] = round_f (band_energy[k] / qint); */
- L_tmp = L_mls( L_band_energy[k], rev_qint_fx ); /* Q14+Qrev_qint-15 */
+ L_tmp = Mpy_32_16_1( L_band_energy[k], rev_qint_fx ); /* Q14+Qrev_qint-15 */
bq1_fx[k] = round_fx( L_shl( L_tmp, sub( 17, Qrev_qint ) ) ); /* Q0 */
move16();
}
-#undef WMC_TOOL_SKIP
- IF( is_transient )
+ IF( is_transient_fx )
{
- Copy( bq1_fx, bq1_temp_fx, bands ); /* Q0 */
+ Copy( bq1_fx, bq1_temp_fx, bands_fx ); /* Q0 */
/* Calculate the differential energies */
- diffcod_lrmdct_fx( bands, bq0_fx, bq1_temp_fx, bq2_temp_fx, is_transient ); /* Q0 */
+ diffcod_lrmdct_fx( bands_fx, bq0_fx, bq1_temp_fx, bq2_temp_fx, is_transient_fx );
}
/* Calculate the differential energies */
bq2_fx[0] = sub( bq1_fx[0], bq0_fx ); /* Q0 */
move16();
- FOR( k = 1; k < bands; k++ )
+ FOR( k = 1; k < bands_fx; k++ )
{
bq2_fx[k] = sub( bq1_fx[k], bq1_fx[k - 1] ); /* Q0 */
move16();
}
-
/* Modifying qbidx to be located in the range -256~255 */
- FOR( i = 0; i < bands; ++i )
+ FOR( i = 0; i < bands_fx; ++i )
{
IF( GT_16( bq2_fx[i], MAXIMUM_ENERGY_LOWBRATE ) )
{
- bq2_fx[i] = MAXIMUM_ENERGY_LOWBRATE; /* Q0 */
- move16();
- }
- IF( LT_16( bq2_fx[i], MINIMUM_ENERGY_LOWBRATE ) )
- {
- bq2_fx[i] = MINIMUM_ENERGY_LOWBRATE; /* Q0 */
- move16();
- }
- }
-
- /* Get number of bits by Huffman0 coding */
- ebits = large_symbol_enc_ivas_fx( hBstr, bq2_fx, bands, &hLCmode0, 0 ); /* Q0 */
-
- IF( is_transient )
- {
- /* Get number of bits by Huffman coding */
- hbits = small_symbol_enc_tran_ivas_fx( hBstr, bq2_temp_fx, bands, &hLCmode1, 0, is_transient ); /* Q0 */
- }
- ELSE
- {
- /* Get number of bits by Huffman coding */
- hbits = small_symbol_enc_ivas_fx( hBstr, bq2_fx, bands, &hLCmode1, 0, is_transient ); /* Q0 */
- }
-
- test();
- IF( LT_16( ebits, hbits ) || EQ_16( hbits, -1 ) )
- {
- deng_cmode = 0;
- move16();
- push_indice( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE );
- large_symbol_enc_ivas_fx( hBstr, bq2_fx, bands, &hLCmode0, 1 );
- deng_bits = add( ebits, BITS_DE_CMODE ); /* Q0 */
- }
- ELSE
- {
- /* setting energy difference coding mode and storing it */
- deng_cmode = 1;
- move16();
- push_indice( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE );
-
- deng_bits = add( hbits, BITS_DE_CMODE ); /* Q0 */
-
- /* packing indice */
- IF( is_transient )
- {
- Copy( bq2_temp_fx, bq2_fx, bands ); /* Q0 */
- small_symbol_enc_tran_ivas_fx( hBstr, bq2_fx, bands, &hLCmode1, 1, is_transient );
- }
- ELSE
- {
- small_symbol_enc_ivas_fx( hBstr, bq2_fx, bands, &hLCmode1, 1, is_transient );
- }
- }
-
- /* Reconstruct quantized spectrum */
- bq1_fx[0] = add( bq2_fx[0], bq0_fx ); /* Q0 */
- move16();
- FOR( k = 1; k < bands; k++ )
- {
- bq1_fx[k] = add( bq2_fx[k], bq1_fx[k - 1] ); /* Q0 */
- move16();
- }
-
- FOR( k = 0; k < bands; k++ )
- {
-#define WMC_TOOL_SKIP
- L_band_energy[k] = L_mls( L_qint, (Word16) bq1_fx[k] ); /* 29+0-15 -> Qbe(Q14) */
- move32();
-#undef WMC_TOOL_SKIP
- }
-
- IF( is_transient )
- {
- reverse_transient_frame_energies_fx( L_band_energy, bands );
- }
-
- return ( deng_bits ); /* Q0 */
-}
-
-
-/*-------------------------------------------------------------------*
- * p2a_threshold_quant()
- *
- *
- *-------------------------------------------------------------------*/
-
-static Word16 p2a_threshold_quant_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: : bit stream */
- const Word32 *L_t_audio, /* i : Q12 : input spectrum */
- const Word16 band_start[], /* i : Q0 : table of start freq for every subband */
- const Word16 band_end[], /* i : Q0 : table of end freq for every subband */
- const Word16 band_width[], /* i : Q0 : table of bandwidth for every subband */
- const Word16 bands, /* i : Q0 : number of subbands */
- const Word16 p2a_bands, /* i : Q0 : tonality indicator */
- const Word16 p2a_th_fx, /* i : Q11 : threshold tonal or not */
- Word16 *p2a_flags_fx /* i/o: Q0 : tonality flag */
-)
-{
- Word16 i, j, k;
- Word32 L_a, L_p, L_e;
- Word16 Qa;
- Word32 L_tmp;
- Word16 temp_fx;
- Word16 exp_norm;
- Word16 exp_safe;
- Word16 exp_normn, exp_normd;
-
- Word16 norm_a_fx, Qnorm_a;
- Word16 pa_fx, Qpa;
-
- Word16 exp, frac;
-
- Word32 L_p2a;
- Word16 p2a_fx;
-
- exp_safe = 4; /* never happen overflow. */
- move16();
-
- set16_fx( p2a_flags_fx, 1, bands );
- move16();
-
- j = 0;
- move16();
- FOR( k = ( bands - p2a_bands ); k < bands; k++ )
- {
- L_a = L_deposit_l( 0 );
- L_p = L_deposit_l( 0 );
-
- L_tmp = L_deposit_l( 0 );
- FOR( i = band_start[k]; i <= band_end[k]; i++ )
- {
- L_tmp = L_or( L_tmp, L_abs( L_t_audio[i] ) ); /* Q12 */
- }
- exp_norm = norm_l( L_tmp );
- exp_norm = sub( exp_norm, exp_safe );
-
- FOR( i = band_start[k]; i <= band_end[k]; i++ )
- {
- temp_fx = round_fx( L_shl( L_t_audio[i], exp_norm ) ); /* Q12+exp_norm-16 -> exp_norm-4 */
- L_e = L_mult( temp_fx, temp_fx ); /* 2*(exp_norm-4)+1 */
-
- IF( GT_32( L_e, L_p ) )
- {
- L_p = L_add( L_e, 0 );
- }
- L_a = L_add( L_a, L_e );
- }
- Qa = sub( shl( exp_norm, 1 ), 7 ); /* (exp_norm-4)*2+1 */
-
- IF( L_a > 0x0L )
- {
- /* a /= band_width[k]; */
- exp_normn = norm_l( L_a );
- exp_normn = sub( exp_normn, 1 );
- exp_normd = norm_s( band_width[k] );
- norm_a_fx = div_l( L_shl( L_a, exp_normn ), shl( band_width[k], exp_normd ) ); /* (Qa+exp_normn)-exp_normd-1); */
- Qnorm_a = sub( sub( add( Qa, exp_normn ), exp_normd ), 1 );
-
- /*p2a = 10.0f * (float) log10 (p / a); */
- p2a_fx = 0;
+ bq2_fx[i] = MAXIMUM_ENERGY_LOWBRATE; /* Q0 */
move16();
- IF( norm_a_fx > 0 )
- {
- exp_normn = norm_l( L_p );
- exp_normn = sub( exp_normn, 1 );
- exp_normd = norm_s( norm_a_fx );
- pa_fx = div_l( L_shl( L_p, exp_normn ), shl( norm_a_fx, exp_normd ) ); /* Qpa + exp_normn + Qnorm_a + exp_normd - 1 */
- Qpa = sub( sub( add( Qa, exp_normn ), add( Qnorm_a, exp_normd ) ), 1 );
+ }
+ IF( LT_16( bq2_fx[i], MINIMUM_ENERGY_LOWBRATE ) )
+ {
+ bq2_fx[i] = MINIMUM_ENERGY_LOWBRATE; /* Q0 */
+ move16();
+ }
+ }
- L_tmp = L_deposit_h( pa_fx );
- Qpa = add( Qpa, 16 );
- exp = norm_l( L_tmp );
- frac = Log2_norm_lc( L_shl( L_tmp, exp ) );
- exp = sub( 30, exp );
- exp = sub( exp, Qpa );
- L_tmp = L_Comp( exp, frac );
+ /* Get number of bits by Huffman0 coding */
+ ebits = large_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode0, 0 ); /* Q0 */
- /* 10/( log(10)/log(2) ) = 3.01029995663981195211 24660(Q13) */
- L_p2a = Mpy_32_16_1( L_tmp, 24660 ); /* 16+13-15 -> Q14 */
+ IF( is_transient_fx )
+ {
+ /* Get number of bits by Huffman coding */
+ hbits = small_symbol_enc_tran_fx( hBstr, bq2_temp_fx, bands_fx, &hLCmode1, 0, is_transient_fx ); /* Q0 */
+ }
+ ELSE
+ {
+ /* Get number of bits by Huffman coding */
+ hbits = small_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode1, 0, is_transient_fx ); /* Q0 */
+ }
- p2a_fx = round_fx_sat( L_shl_sat( L_p2a, 13 ) ); /* 27 -16 -> 11 */
- }
+ /* comparing used bits */
+ test();
+ IF( LT_16( ebits, hbits ) || EQ_16( hbits, -1 ) )
+ {
+ deng_cmode = 0;
+ move16();
+ push_indice( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE );
+ large_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode0, 1 );
+ deng_bits = add( ebits, BITS_DE_CMODE ); /* Q0 */
+ }
+ ELSE
+ {
+ /* setting energy difference coding mode and storing it */
+ deng_cmode = 1;
+ move16();
+ push_indice( hBstr, IND_HQ2_DENG_MODE, deng_cmode, BITS_DE_CMODE );
- IF( LE_16( p2a_fx, p2a_th_fx ) )
- {
- p2a_flags_fx[k] = 0;
- move16();
- }
+ deng_bits = add( hbits, BITS_DE_CMODE ); /* Q0 */
+
+ /* packing indice */
+ IF( is_transient_fx )
+ {
+ Copy( bq2_temp_fx, bq2_fx, bands_fx ); /* Q0 */
+ small_symbol_enc_tran_fx( hBstr, bq2_fx, bands_fx, &hLCmode1, 1, is_transient_fx );
}
ELSE
{
- p2a_flags_fx[k] = 0;
- move16();
+ small_symbol_enc_fx( hBstr, bq2_fx, bands_fx, &hLCmode1, 1, is_transient_fx );
}
+ }
- push_indice( hBstr, IND_HQ2_P2A_FLAGS, p2a_flags_fx[k], 1 );
- j = add( j, 1 );
+ /* Reconstruct quantized spectrum */
+ bq1_fx[0] = add( bq2_fx[0], bq0_fx ); /* Q0 */
+ move16();
+ FOR( k = 1; k < bands_fx; k++ )
+ {
+ bq1_fx[k] = add( bq2_fx[k], bq1_fx[k - 1] ); /* Q0 */
+ move16();
}
- return ( j ); /* Q0 */
+ FOR( k = 0; k < bands_fx; k++ )
+ {
+ L_band_energy[k] = Mpy_32_16_1( L_qint, bq1_fx[k] ); /* 29+0-15 -> Qbe(Q14) */
+ move32();
+ }
+
+ IF( is_transient_fx )
+ {
+ reverse_transient_frame_energies_fx( L_band_energy, bands_fx );
+ }
+
+ return ( deng_bits ); /* Q0 */
}
-static Word16 p2a_threshold_quant_ivas_fx(
+
+/*-------------------------------------------------------------------*
+ * p2a_threshold_quant()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
+static Word16 p2a_threshold_quant_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: : bit stream */
const Word32 *L_t_audio, /* i : Q12 : input spectrum */
const Word16 band_start[], /* i : Q0 : table of start freq for every subband */
@@ -3506,6 +1710,7 @@ static Word16 p2a_threshold_quant_ivas_fx(
move16();
set16_fx( p2a_flags_fx, 1, bands );
+ move16();
j = 0;
move16();
@@ -3525,7 +1730,7 @@ static Word16 p2a_threshold_quant_ivas_fx(
FOR( i = band_start[k]; i <= band_end[k]; i++ )
{
temp_fx = round_fx( L_shl( L_t_audio[i], exp_norm ) ); /* Q12+exp_norm-16 -> exp_norm-4 */
- L_e = L_mult( temp_fx, temp_fx ); /* (exp_norm-4)*2 + 1 */
+ L_e = L_mult( temp_fx, temp_fx ); /* 2*(exp_norm-4)+1 */
IF( GT_32( L_e, L_p ) )
{
@@ -3752,161 +1957,3 @@ static void mdct_spectrum_fine_gain_enc_fx(
return;
}
-
-static void mdct_spectrum_fine_gain_enc_ivas_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word32 L_ybuf[], /* i : Q12 : input spectrum */
- Word32 L_y2[], /* i/o: Q12 : decoded spectrum */
- const Word16 band_start[], /* i : Q0 : table of start freq for every subband */
- const Word16 band_end[], /* i : Q0 : table of end freq for every subband */
- const Word16 k_sort[], /* i : Q0 : sort table by band_energy */
- const Word16 bands, /* i : Q0 : nubmber of subbands */
- const Word32 L_qint, /* i : Q29 : */
- const Word16 Ngq, /* i : Q0 : */
- const Word16 gqlevs, /* i : Q0 : quantized level */
- const Word16 gqbits /* i : Q0 : quantized bits */
-)
-{
- Word16 i, k;
-
- Word16 delta_fx, Qdelta;
- Word32 L_delta;
- Word32 L_q;
-
- Word16 gain_table_fx[MAX_GQLEVS];
- Word16 Qgt;
- Word16 gamma_fx;
- Word16 Qgamma;
-
- Word16 exp_safe;
- Word16 exp_normn, exp_normd;
- Word16 exp_norm;
-
- Word32 L_temp;
- Word16 temp_lo_fx, temp_hi_fx, temp_fx, temp2_fx;
-
- Word32 L_Eyy, L_Exy;
- /*Word16 QE; */
-
- Word16 d_fx;
- Word16 dmin_fx;
- Word16 imin_fx;
-
- /* Fine gain quantization on only the most significant energy bands */
-
- /*delta = qint / gqlevs; */
- exp_normn = norm_l( L_qint );
- exp_normn = sub( exp_normn, 1 );
- exp_normd = norm_s( gqlevs );
- delta_fx = div_l( L_shl( L_qint, exp_normn ), shl( gqlevs, exp_normd ) );
- Qdelta = add( sub( exp_normn, exp_normd ), 28 ); /* 29+exp_normn-(exp_normd)-1; */
- L_delta = L_shl( L_deposit_h( delta_fx ), sub( 13, Qdelta ) ); /* Q29 */
- /*q = (-qint + delta) / 2.0f; */
- L_q = L_shr( L_sub( L_delta, L_qint ), 1 ); /* Q29 */
-
- FOR( i = 0; i < gqlevs; i++ )
- {
- /*gain_table[i] = (float) pow (2.0f, q * 0.5f); */
- L_temp = L_shr( L_shr( L_q, 1 ), sub( 29, 16 ) ); /* Q16 */
- temp_lo_fx = L_Extract_lc( L_temp, &temp_hi_fx );
- Qgt = sub( 14, temp_hi_fx );
- gain_table_fx[i] = extract_l( Pow2( 14, temp_lo_fx ) ); /* Qgt */
- move16();
-
- /*q += delta; */
- L_q = L_add( L_q, L_delta );
- gain_table_fx[i] = shl( gain_table_fx[i], sub( 14, Qgt ) ); /* Qgt -> Q14 */
- move16();
- }
-
- FOR( k = sub( bands, Ngq ); k < bands; k++ )
- {
- /*Eyy = 0.0f; */
- /*Exy = 0.0f; */
- /*for (i = band_start[k_sort[k]]; i <= band_end[k_sort[k]]; i++) */
- /*{ */
- /* Eyy += y2[i] * y2[i]; */
- /* Exy += ybuf[i] * y2[i]; */
- /*} */
- exp_safe = 4;
- move16(); /* 4 is too large. but never happen overflow */
- L_temp = L_deposit_l( 0 );
- FOR( i = band_start[k_sort[k]]; i <= band_end[k_sort[k]]; i++ )
- {
- L_temp = L_or( L_temp, L_abs( L_y2[i] ) ); /* Q12 */
- L_temp = L_or( L_temp, L_abs( L_ybuf[i] ) ); /* Q12 */
- }
- exp_norm = norm_l( L_temp );
- exp_norm = sub( exp_norm, exp_safe ); /* safe_shift */
-
- L_Eyy = L_deposit_l( 0 );
- L_Exy = L_deposit_l( 0 );
- /*QE = add(shl(add(Qs-16, exp_norm), 1), 1); //(Qs+exp_norm-16)*2+1; */
- FOR( i = band_start[k_sort[k]]; i <= band_end[k_sort[k]]; i++ )
- {
- /*Eyy += y2[i] * y2[i]; */
- temp_fx = round_fx( L_shl( L_y2[i], exp_norm ) ); /* Q12 + exp_norm - 16 */
- L_Eyy = L_mac( L_Eyy, temp_fx, temp_fx ); /* (Q12 + exp_norm - 16)*2 + 1 */
-
- /*Exy += ybuf[i] * y2[i]; */
- temp2_fx = round_fx( L_shl( L_ybuf[i], exp_norm ) ); /* Q12 + exp_norm - 16 */
- L_Exy = L_mac( L_Exy, temp2_fx, temp_fx ); /* (Q12 + exp_norm - 16)*2 + 1 */
- }
-
- test();
- IF( L_Eyy > 0x0L && L_Exy > 0x0L )
- {
- /*gamma = Exy / Eyy; */
- exp_normn = norm_l( L_Exy );
- exp_normn = sub( exp_normn, 1 );
- exp_normd = norm_l( L_Eyy );
- gamma_fx = div_l( L_shl( L_Exy, exp_normn ), round_fx_sat( L_shl( L_Eyy, exp_normd ) ) ); /* Qgamma */
- Qgamma = add( sub( exp_normn, exp_normd ), 15 ); /* exp_normn - (exp_normd-16) - 1; */
- gamma_fx = shl( gamma_fx, sub( 14, Qgamma ) ); /* Qgamma -> Q14 */
-
- dmin_fx = 32767;
- move16();
- imin_fx = -1;
- move16();
- FOR( i = 0; i < gqlevs; i++ )
- {
- d_fx = abs_s( sub( gamma_fx, gain_table_fx[i] ) ); /* Q14 */
- IF( LT_16( d_fx, dmin_fx ) )
- {
- dmin_fx = d_fx; /* Q14 */
- move16();
- imin_fx = i; /* Q0 */
- move16();
- }
- }
-
- gamma_fx = gain_table_fx[imin_fx]; /* Q14 */
- move16();
-
- FOR( i = band_start[k_sort[k]]; i <= band_end[k_sort[k]]; i++ )
- {
- /*y2[i] *= gamma; */
- /* This IF statement for keeping same mantissa evenif y2 is plus or minus */
- IF( L_y2[i] >= 0x0 )
- {
- L_y2[i] = L_shl( Mpy_32_16_1( L_y2[i], gamma_fx ), 1 ); /* Q12 */
- move32();
- }
- ELSE
- {
- L_y2[i] = L_negate( L_shl( Mpy_32_16_1( L_abs( L_y2[i] ), gamma_fx ), 1 ) ); /* Q12 */
- move32();
- }
- }
- }
- ELSE
- {
- imin_fx = 0;
- move16();
- }
-
- push_indice( st_fx->hBstr, IND_HQ2_SUBBAND_GAIN, imin_fx, gqbits );
- }
-
- return;
-}
diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c
index 6c55e8b3114e4c40832bca74d7fe64226985b5fc..deed347b32a9f41063d9c8a734806a8016cefb5a 100755
--- a/lib_enc/igf_enc_fx.c
+++ b/lib_enc/igf_enc_fx.c
@@ -3320,9 +3320,13 @@ static void IGF_Whitening_ivas_fx(
FOR( sb = hGrid->tile[p]; sb < hGrid->tile[p + 1]; sb++ )
{
IF( LT_32( powerSpectrum[sb], 1 ) )
- hPrivateData->logSpec[sb] = 0; /* max(0,FLT_MIN_EXP=-125 )*/
+ {
+ hPrivateData->logSpec[sb] = 0; /* max(0,FLT_MIN_EXP=-125 )*/
+ }
ELSE
+ {
hPrivateData->logSpec[sb] = extract_l( L_max( 0, L_shr( L_add( BASOP_Util_Log2( powerSpectrum[sb] ), L_shl( powerSpectrum_e[sb], Q25 ) ), Q25 ) ) );
+ }
move16();
}
}
@@ -4137,7 +4141,7 @@ void IGFEncApplyMono_ivas_fx(
test();
IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) )
{
- calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag );
+ calculate_hangover_attenuation_gain_fx( st, &att_fx, vad_hover_flag );
}
IGF_CalculateEnvelope_ivas_fx( st->hIGFEnc, pMDCTSpectrum_fx, e_mdct, pPowerSpectrumParameter_fx, pPowerSpectrumParameter_exp, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, st->element_mode, att_fx );
@@ -4267,6 +4271,10 @@ void IGFEncApplyStereo_fx(
{
pPowerSpectrumParameter_fx[0] = NULL;
pPowerSpectrumParameter_fx[1] = NULL;
+#ifdef FIX_2355_IGF_EXP_POWERSPEC
+ exp_pPowerSpectrumParameter_fx[0] = NULL;
+ exp_pPowerSpectrumParameter_fx[1] = NULL;
+#endif
pPowerSpectrumParameterMsInv_fx[0] = NULL;
pPowerSpectrumParameterMsInv_fx[1] = NULL;
q_pPowerSpectrumParameterMsInv_fx[0] = NULL;
@@ -4289,6 +4297,9 @@ void IGFEncApplyStereo_fx(
ELSE
{
pPowerSpectrumParameter_fx[ch] = NULL;
+#ifdef FIX_2355_IGF_EXP_POWERSPEC
+ exp_pPowerSpectrumParameter_fx[ch] = NULL;
+#endif
}
IGF_Whitening_ivas_fx( hIGFEnc[ch], pPowerSpectrumParameter_fx[ch], exp_pPowerSpectrumParameter_fx[ch], igfGridIdx, sts[ch]->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, ( sts[0]->hTcxEnc->fUseTns[frameno] || sts[1]->hTcxEnc->fUseTns[frameno] ), sp_aud_decision0, element_brate, sts[ch]->element_mode );
diff --git a/lib_enc/igf_scf_enc.c b/lib_enc/igf_scf_enc.c
index 16f2560d1e4a858f0c52b217bf2a956aaa1f7876..c9a549e5a383a37e05cae2b9700969e77afd7784 100644
--- a/lib_enc/igf_scf_enc.c
+++ b/lib_enc/igf_scf_enc.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c
index 7c29b4e06757134f1092b24d5013ee6ce1b86719..b30b95806d16aa905b59b4d26b8aeafe91ba10da 100644
--- a/lib_enc/init_enc_fx.c
+++ b/lib_enc/init_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -686,14 +686,7 @@ ivas_error init_encoder_fx(
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) );
}
- IF( st->element_mode == EVS_MONO )
- {
- td_cng_enc_init_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth );
- }
- ELSE
- {
- td_cng_enc_init_ivas_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth );
- }
+ td_cng_enc_init_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth );
}
ELSE
{
@@ -849,8 +842,9 @@ ivas_error init_encoder_fx(
{
return error;
}
-
+#ifndef HARMONIZE_TBE
InitSWBencBuffer_fx( st->hBWE_TD );
+#endif
}
ELSE
{
@@ -858,9 +852,13 @@ ivas_error init_encoder_fx(
{
return error;
}
-
+#ifndef HARMONIZE_TBE
InitSWBencBuffer_ivas_fx( st->hBWE_TD );
+#endif
}
+#ifdef HARMONIZE_TBE
+ InitSWBencBuffer_fx( st->element_mode, st->hBWE_TD );
+#endif
ResetSHBbuffer_Enc_fx( st->hBWE_TD );
}
ELSE
diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c
index 81b9ba49e904333c5881cfc372e0e98dfe11db49..0efcf795b2369c00a81ab0d120095893cf4166db 100644
--- a/lib_enc/inov_enc_fx.c
+++ b/lib_enc/inov_enc_fx.c
@@ -78,16 +78,18 @@ Word16 inov_encode_fx(
Word16 *y2, /* o : zero-memory filtered algebraic excitation Q9*/
Word16 *unbits, /* o : number of unused bits for PI */
const Word16 L_subfr, /* i : subframe length */
- Word16 shift )
+ const Word16 shift,
+ Word16 Q_new )
{
- Word16 dn[2 * L_SUBFR];
+ Word16 dn[2 * L_SUBFR], Qdn, Qcn, Qh2;
Word16 nBits, cmpl_flag;
Word16 stack_pulses;
Word16 g1, g2;
Word16 Rw[L_SUBFR];
Word16 acelpautoc;
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
- (void) last_L_frame;
+ Word16 i, k;
+ Word16 Qxn, max_xn2;
stack_pulses = 0;
move16();
@@ -106,304 +108,31 @@ Word16 inov_encode_fx(
move16();
}
- /*----------------------------------------------------------------*
- * Update target vector for codebook search in residual domain
- * Preemphasize the impulse response and include fixed-gain pitch contribution into impulse resp. h1[] (pitch sharpenning)
- * Correlation between target xn2[] and impulse response h1[]
- *----------------------------------------------------------------*/
-
- test();
- test();
- IF( GT_32( core_brate, ACELP_13k20 ) && !Opt_AMR_WB && EQ_16( L_subfr, L_SUBFR ) )
- {
- acelpautoc = 1;
- move16();
-
- cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, h2, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_SUBFR );
- /* h2: Q11, Rw: (Rw_e)Q */
- /* Rw_e = */ E_ACELP_hh_corr( h2, Rw, L_SUBFR, 3 );
-
- E_ACELP_conv( xn2, h2, cn );
-
- /* dn_e -> Rw_e*Q_xn */
- /*dn_e = */ E_ACELP_toeplitz_mul_fx( Rw, cn, dn, L_SUBFR, 1 );
- }
- ELSE
- {
- acelpautoc = 0;
- move16();
- updt_tar_fx( cn, cn, &exc[i_subfr], gain_pit, L_subfr );
- /* scaling of cn[] to limit dynamic at 12 bits */
- Scale_sig( cn, L_subfr, shift );
-
- cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, h2, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr );
- corr_xh_fx( xn2, dn, h2 );
- }
-
- /*-----------------------------------------------------------------*
- * Set complexity reduction flag to limit the number of iterations
- * in algebraic innovation search
- *-----------------------------------------------------------------*/
- cmpl_flag = 0;
- move16();
- test();
- IF( st_fx->acelp_cfg.fcb_mode )
- {
- /* set number of iterations in TD stereo, secondary channel */
- test();
- if ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) )
- {
- cmpl_flag = 1;
- move16();
- }
- }
- ELSE IF( EQ_16( L_frame, L_FRAME ) && EQ_16( coder_type, TRANSITION ) )
+ IF( NE_32( st_fx->element_mode, EVS_MONO ) )
{
- test();
- test();
- if ( EQ_32( core_brate, ACELP_8k00 ) && i_subfr == 0 && LT_16( tc_subfr, L_SUBFR ) )
- {
- cmpl_flag = 3;
- move16();
- }
- test();
- test();
- test();
- test();
- test();
- if ( EQ_32( core_brate, ACELP_11k60 ) && ( ( i_subfr == 0 && LT_16( tc_subfr, L_SUBFR ) ) || EQ_16( tc_subfr, TC_0_0 ) || ( EQ_16( i_subfr, 3 * L_SUBFR ) && EQ_16( tc_subfr, TC_0_64 ) ) ) )
- {
- cmpl_flag = 3;
- move16();
- }
- test();
- test();
- test();
- test();
- if ( ( EQ_32( core_brate, ACELP_13k20 ) || EQ_32( core_brate, ACELP_12k15 ) ) && ( ( i_subfr == 0 && LT_16( tc_subfr, L_SUBFR ) ) || LE_16( tc_subfr, TC_0_64 ) ) )
- {
- cmpl_flag = 3;
- move16();
- }
- }
-
- IF( EQ_16( L_frame, L_FRAME16k ) )
- {
- IF( LE_32( core_brate, ACELP_32k ) )
- {
- cmpl_flag = 4;
- move16();
-
- test();
- IF( EQ_16( coder_type, TRANSITION ) && GT_16( bwidth, WB ) )
- {
- IF( LE_16( i_subfr, L_SUBFR ) )
- {
- cmpl_flag = sub( cmpl_flag, 1 );
- }
- ELSE
- {
- cmpl_flag = sub( cmpl_flag, 2 );
- }
- }
- }
- ELSE IF( LE_32( core_brate, ACELP_48k ) )
- {
- cmpl_flag = 3;
- move16();
-
- IF( EQ_16( coder_type, TRANSITION ) )
- {
- IF( LE_16( i_subfr, L_SUBFR ) )
- {
- cmpl_flag = sub( cmpl_flag, 1 );
- }
- ELSE
- {
- cmpl_flag = sub( cmpl_flag, 2 );
- }
- }
- }
- ELSE
- {
- cmpl_flag = 4;
- move16();
-
- IF( EQ_16( coder_type, TRANSITION ) )
- {
- IF( LE_16( i_subfr, L_SUBFR ) )
- {
- cmpl_flag = sub( cmpl_flag, 1 );
- }
- ELSE
- {
- cmpl_flag = sub( cmpl_flag, 2 );
- }
- }
-
- if ( coder_type == INACTIVE )
- {
- cmpl_flag = 4;
- move16();
- }
- }
- }
-
- test();
- test();
- test();
- IF( NE_16( L_frame, st_fx->last_L_frame ) && GT_32( core_brate, ACELP_13k20 ) && ( LT_32( core_brate, ACELP_32k ) || EQ_16( bwidth, WB ) ) )
- {
- if ( GT_16( cmpl_flag, 1 ) )
- {
- cmpl_flag = sub( cmpl_flag, 1 );
- }
- }
-
- /*-----------------------------------------------------------------*
- * Find and encode the algebraic innovation
- *-----------------------------------------------------------------*/
-
- set16_fx( y2, 0, L_SUBFR );
-
- IF( !Opt_AMR_WB )
- {
- IF( st_fx->acelp_cfg.fcb_mode )
+ maximum_abs_16_fx( xn2, L_subfr, &max_xn2 );
+ IF( max_xn2 )
{
+ Qxn = add( sub( Q_new, 1 ), shift );
}
ELSE
{
- nBits = st_fx->acelp_cfg.fixed_cdk_index[shr( i_subfr, 6 )];
+ Qxn = 0;
move16();
-
-
- IF( EQ_16( nBits, 7 ) )
- {
- acelp_1t64_fx( hBstr, dn, h2, code, y2, L_SUBFR );
- }
- ELSE IF( EQ_16( nBits, 12 ) )
- {
- acelp_2t32_fx( hBstr, dn, h2, code, y2 );
- }
- ELSE
- {
- *unbits = add( *unbits, acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, nBits, cmpl_flag, Opt_AMR_WB, st_fx->element_mode ) );
- move16();
- }
- }
- }
- ELSE
- {
- IF( EQ_32( core_brate, ACELP_6k60 ) )
- {
- acelp_2t32_fx( hBstr, dn, h2, code, y2 );
- }
- ELSE IF( ( EQ_32( core_brate, ACELP_8k85 ) ) )
- {
- acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 20, cmpl_flag, Opt_AMR_WB, st_fx->element_mode );
- }
- ELSE IF( EQ_32( core_brate, ACELP_12k65 ) )
- {
- acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 36, cmpl_flag, Opt_AMR_WB, st_fx->element_mode );
- }
- ELSE IF( EQ_32( core_brate, ACELP_14k25 ) )
- {
- acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 44, cmpl_flag, Opt_AMR_WB, st_fx->element_mode );
- }
- ELSE IF( EQ_32( core_brate, ACELP_15k85 ) )
- {
- acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 52, cmpl_flag, Opt_AMR_WB, st_fx->element_mode );
- }
- ELSE IF( EQ_32( core_brate, ACELP_18k25 ) )
- {
- acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 64, cmpl_flag, Opt_AMR_WB, st_fx->element_mode );
- }
- ELSE IF( EQ_32( core_brate, ACELP_19k85 ) )
- {
- acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 72, cmpl_flag, Opt_AMR_WB, st_fx->element_mode );
- }
- ELSE IF( EQ_32( core_brate, ACELP_23k05 ) )
- {
- acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 88, cmpl_flag, Opt_AMR_WB, st_fx->element_mode );
}
- ELSE IF( EQ_32( core_brate, ACELP_23k85 ) )
- {
- acelp_4t64_fx( hBstr, dn, cn, h2, Rw, acelpautoc, code, y2, 88, 1, Opt_AMR_WB, st_fx->element_mode );
- }
- }
-
- /*----------------------------------------------------------------*
- * Pitch sharpening
- *----------------------------------------------------------------*/
- cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, code, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr );
-
- return stack_pulses;
-}
-
-
-Word16 inov_encode_ivas_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 last_L_frame, /* i : length of the last frame */
- const Word16 coder_type, /* i : coding type */
- const Word16 bwidth, /* i : input signal bandwidth */
- const Word16 sharpFlag, /* i : formant sharpening flag */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 tc_subfr, /* i : TC subframe index */
- const Word16 *p_Aq, /* i : LP filter coefficients Q12*/
- const Word16 gain_pit, /* i : adaptive excitation gain Q14*/
- Word16 *cn, /* i/o: target vector in residual domain Q_new*/
- const Word16 *exc, /* i : pointer to excitation signal frame Q_new*/
- Word16 *h2, /* i/o: weighted filter input response Q12*/
- const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15*/
- const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/
- const Word16 *xn2, /* i : target vector for innovation search Q_new-1+shift*/
- Word16 *code, /* o : algebraic excitation Q9*/
- Word16 *y2, /* o : zero-memory filtered algebraic excitation Q9*/
- Word16 *unbits, /* o : number of unused bits for PI */
- const Word16 L_subfr, /* i : subframe length */
- Word16 shift,
- Word16 Q_new )
-{
- Word16 dn[2 * L_SUBFR], Qdn, Qcn, Qh2;
- Word16 nBits, cmpl_flag;
- Word16 stack_pulses;
- Word16 g1, g2;
- Word16 Rw[L_SUBFR];
- Word16 acelpautoc;
- BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
- Word16 i, k;
- Word16 Qxn, max_xn2;
- stack_pulses = 0;
- move16();
-
- IF( EQ_16( L_frame, L_FRAME ) )
- {
- g1 = FORMANT_SHARPENING_G1;
- move16();
- g2 = FORMANT_SHARPENING_G2;
+ Qcn = Q_new;
move16();
}
ELSE
{
- g1 = FORMANT_SHARPENING_G1_16k;
- move16();
- g2 = FORMANT_SHARPENING_G2_16k;
+ Q_new = 0;
move16();
- }
- maximum_abs_16_fx( xn2, L_subfr, &max_xn2 );
- IF( max_xn2 )
- {
- Qxn = add( sub( Q_new, 1 ), shift );
- }
- ELSE
- {
Qxn = 0;
move16();
+ Qcn = 0;
+ move16();
}
/*----------------------------------------------------------------*
@@ -414,8 +143,6 @@ Word16 inov_encode_ivas_fx(
test();
test();
- Qcn = Q_new;
- move16();
IF( GT_32( core_brate, ACELP_13k20 ) && !Opt_AMR_WB && EQ_16( L_subfr, L_SUBFR ) )
{
acelpautoc = 1;
@@ -436,23 +163,40 @@ Word16 inov_encode_ivas_fx(
acelpautoc = 0;
move16();
updt_tar_fx( cn, cn, &exc[i_subfr], gain_pit, L_subfr );
+
/* scaling of cn[] to limit dynamic at 12 bits */
Scale_sig( cn, L_subfr, shift );
- Word16 q_h1 = sub( 14, norm_s( h2[0] ) );
- Scale_sig( h2, L_SUBFR, sub( 11, q_h1 ) ); /* set h2[] in Q11*/
- cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, h2, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr );
- corr_xh_ivas_fx( xn2, Qxn, dn, &Qdn, h2, L_subfr ); // Q(dn) = Q_new+1
- IF( LT_16( Qdn, Qcn ) )
+
+ IF( st_fx->element_mode == EVS_MONO )
{
- scale_sig( cn, L_subfr, sub( Qdn, Qcn ) );
- Qcn = Qdn;
+ cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, h2, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr );
+
+ corr_xh_fx( xn2, dn, h2 );
+
+ Qdn = 0;
move16();
}
ELSE
{
- scale_sig( dn, L_subfr, sub( Qcn, Qdn ) );
- Qdn = Qcn;
- move16();
+ Word16 q_h1 = sub( 14, norm_s( h2[0] ) );
+ Scale_sig( h2, L_SUBFR, sub( 11, q_h1 ) ); /* set h2[] in Q11*/
+
+ cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, h2, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr );
+
+ corr_xh_ivas_fx( xn2, Qxn, dn, &Qdn, h2, L_subfr ); // Q(dn) = Q_new+1
+
+ IF( LT_16( Qdn, Qcn ) )
+ {
+ scale_sig( cn, L_subfr, sub( Qdn, Qcn ) );
+ Qcn = Qdn;
+ move16();
+ }
+ ELSE
+ {
+ scale_sig( dn, L_subfr, sub( Qcn, Qdn ) );
+ Qdn = Qcn;
+ move16();
+ }
}
}
@@ -584,8 +328,11 @@ Word16 inov_encode_ivas_fx(
set16_fx( y2, 0, L_SUBFR );
- Qh2 = sub( 14, norm_s( h2[0] ) );
- Scale_sig( h2, L_SUBFR, sub( Q12, Qh2 ) );
+ IF( NE_32( st_fx->element_mode, EVS_MONO ) )
+ {
+ Qh2 = sub( 14, norm_s( h2[0] ) );
+ Scale_sig( h2, L_SUBFR, sub( Q12, Qh2 ) );
+ }
IF( !Opt_AMR_WB )
{
@@ -683,7 +430,7 @@ Word16 inov_encode_ivas_fx(
}
ELSE
{
- nBits = st_fx->acelp_cfg.fixed_cdk_index[i_subfr >> 6];
+ nBits = st_fx->acelp_cfg.fixed_cdk_index[shr( i_subfr, 6 )];
move16();
diff --git a/lib_enc/isf_enc_amr_wb_fx.c b/lib_enc/isf_enc_amr_wb_fx.c
index d58998565bdb404e232a6b7b8c5e0318eae1c3a4..bbb734f9c38d29ccc72586a203f5544c9537160d 100644
--- a/lib_enc/isf_enc_amr_wb_fx.c
+++ b/lib_enc/isf_enc_amr_wb_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_agc_enc_fx.c b/lib_enc/ivas_agc_enc_fx.c
index e5af93e39f2e1af6eac36e3085b4594a2e3fa837..52e5fbea5e8ef01b0d96bfb7a6bab2bfdd9a3b87 100644
--- a/lib_enc/ivas_agc_enc_fx.c
+++ b/lib_enc/ivas_agc_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c
index 2ee800325cef8975c0e7de509bf72419d0120ab9..2880c054a181ce3141b4ab48ef06ea9c36f7394b 100644
--- a/lib_enc/ivas_core_enc_fx.c
+++ b/lib_enc/ivas_core_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -87,12 +87,16 @@ ivas_error ivas_core_enc_fx(
STEREO_ICBWE_ENC_HANDLE hStereoICBWE;
STEREO_TD_ENC_DATA_HANDLE hStereoTD;
Word16 voice_factors_fx[CPE_CHANNELS][NB_SUBFR16k]; /* Q15 */
+#ifndef REMOVE_SCALING_SHB_SPEECH
Word32 shb_speech_fx32[L_FRAME16k];
Word32 *new_swb_speech_fx;
+#endif
Word16 *inp_fx[CPE_CHANNELS];
Word16 *shb_speech_fx;
+#ifndef REMOVE_SCALING_SHB_SPEECH
Word16 Q_shb_spch;
Word32 new_swb_speech_buffer_fx[L_FRAME48k + STEREO_DFT_OVL_MAX];
+#endif
Word16 new_inp_resamp16k_fx[CPE_CHANNELS][L_FRAME16k]; /* new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */
Word16 *hb_speech_fx;
Word32 bwe_exc_extended_fx[CPE_CHANNELS][L_FRAME32k + NL_BUFF_OFFSET]; /* 2 * Q_new */
@@ -110,12 +114,14 @@ ivas_error ivas_core_enc_fx(
Word16 max_num_indices_BWE;
Word16 i, shift, Q_min;
+#ifndef REMOVE_SCALING_SHB_SPEECH
set32_fx( new_swb_speech_buffer_fx, 0, L_FRAME48k + STEREO_DFT_OVL_MAX );
-
+#endif
FOR( i = 0; i < CPE_CHANNELS; i++ )
{
set_zero_fx( bwe_exc_extended_fx[i], L_FRAME32k + NL_BUFF_OFFSET );
set16_fx( old_syn_12k8_16k_fx[i], 0, L_FRAME16k );
+ set16_fx( voice_factors_fx[i], 0, NB_SUBFR16k );
}
push_wmops( "ivas_core_enc" );
@@ -123,9 +129,10 @@ ivas_error ivas_core_enc_fx(
error = IVAS_ERR_OK;
move32();
+#ifndef REMOVE_SCALING_SHB_SPEECH
Q_shb_spch = 0;
move16();
-
+#endif
/*------------------------------------------------------------------*
* General initialization
*-----------------------------------------------------------------*/
@@ -222,29 +229,21 @@ ivas_error ivas_core_enc_fx(
// fft_buff_fx_exp = add(fft_buff_fx_exp,1);
FOR( i = 0; i < st->nb_subfr; i++ )
{
- Scale_sig( &A_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( A_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12
Scale_sig( &Aw_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( Aw_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12
}
+
+ Word32 last_element_brate_tmp = element_brate;
+ move32();
IF( EQ_32( ivas_format, SBA_FORMAT ) )
{
- IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, last_element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */,
- &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n],
- vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ),
- IVAS_ERR_OK ) )
- {
- return error;
- }
- }
- ELSE
- {
- IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */,
- &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n],
- vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ),
- IVAS_ERR_OK ) )
- {
- return error;
- }
+ last_element_brate_tmp = last_element_brate;
+ move32();
}
+
+ pre_proc_ivas_fx( st, last_element_mode, element_brate, last_element_brate_tmp, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */,
+ &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n],
+ vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] );
+
test();
IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) || EQ_16( st->element_mode, IVAS_SCE ) )
{
@@ -306,7 +305,7 @@ ivas_error ivas_core_enc_fx(
* Preprocessing (preparing) for ACELP/HQ core switching
*---------------------------------------------------------------------*/
- core_switching_pre_enc_ivas_fx( st, old_inp_12k8_fx[n], sub( Q_new[n], 1 ), old_inp_16k_fx[n], sub( Q_new[n], 1 ), sts[0]->active_cnt, last_element_mode );
+ core_switching_pre_enc_fx( st, old_inp_12k8_fx[n], sub( Q_new[n], 1 ), old_inp_16k_fx[n], sub( Q_new[n], 1 ), sts[0]->active_cnt, last_element_mode );
/*---------------------------------------------------------------------*
* ACELP core encoding
@@ -330,10 +329,6 @@ ivas_error ivas_core_enc_fx(
test();
IF( ( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
- FOR( i = 0; i < st->nb_subfr; i++ )
- {
- Scale_sig( &Aw_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( Aw_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12
- }
TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;
Word16 Q_spec_old, L_spec;
@@ -616,8 +611,9 @@ ivas_error ivas_core_enc_fx(
* Postprocessing, BWEs and Updates
*---------------------------------------------------------------------*/
+#ifndef FIX_2370_UNUSED_BUFFERS_CORE_ENC
Word16 tmp_input_fx[L_FRAME48k], tmp_old_input_fx[L_FRAME48k], q_inp[2];
-
+#endif
FOR( n = 0; n < n_CoreChannels; n++ )
{
st = sts[n];
@@ -632,22 +628,23 @@ ivas_error ivas_core_enc_fx(
move16();
}
+#ifndef FIX_2370_UNUSED_BUFFERS_CORE_ENC
Copy( st->input_fx - input_frame, tmp_old_input_fx, input_frame );
Copy( st->input_fx, tmp_input_fx, input_frame );
q_inp[0] = st->q_old_inp;
q_inp[1] = st->q_inp;
- Scale_sig( st->input_fx - input_frame, 2 * input_frame, sub( -1, st->q_inp ) );
+ Scale_sig( st->input_fx - input_frame, shl( input_frame, 1 ), sub( -1, st->q_inp ) );
st->q_inp = -1;
move16();
st->q_old_inp = -1;
move16();
-
+#endif
/*---------------------------------------------------------------------*
* Postprocessing for ACELP/HQ core switching
*---------------------------------------------------------------------*/
- core_switching_post_enc_ivas_fx( st, old_inp_12k8_fx[n], old_inp_16k_fx[n], A_fx[n], Q_new[n] );
+ core_switching_post_enc_fx( st, NULL, NULL, NULL, 0, 0, 0, NULL );
/*---------------------------------------------------------------------*
* WB TBE encoding
@@ -669,7 +666,11 @@ ivas_error ivas_core_enc_fx(
IF( EQ_16( st->extl, WB_TBE ) )
{
/* WB TBE encoder */
+#ifdef HARMONIZE_TBE
+ wb_tbe_enc_fx( st, hb_speech_fx, bwe_exc_extended_fx[n], Q_new[n], voice_factors_fx[n], pitch_buf_fx[n] );
+#else
wb_tbe_enc_ivas_fx( st, hb_speech_fx, bwe_exc_extended_fx[n], Q_new[n], voice_factors_fx[n], pitch_buf_fx[n] );
+#endif
}
ELSE IF( EQ_16( st->extl, WB_BWE ) && n == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
@@ -682,7 +683,24 @@ ivas_error ivas_core_enc_fx(
* SWB(FB) BWE encoding
*---------------------------------------------------------------------*/
+#ifdef FIX_2370_UNUSED_BUFFERS_CORE_ENC
+ Word16 q_inp_orig;
+ q_inp_orig = st->q_inp;
+ move16();
+ test();
+ IF( GE_32( input_Fs, 32000 ) && st->hBWE_TD != NULL )
+ {
+ st->q_inp = -1;
+ st->q_old_inp = -1;
+ move16();
+ move16();
+ Scale_sig( st->input_fx - input_frame, shl( input_frame, 1 ), sub( st->q_inp, q_inp_orig ) );
+ }
+#endif
+
+#ifndef REMOVE_SCALING_SHB_SPEECH
new_swb_speech_fx = new_swb_speech_buffer_fx + STEREO_DFT_OVL_MAX;
+#endif
new_swb_speech_fx_16 = new_swb_speech_buffer_fx_16 + STEREO_DFT_OVL_MAX;
set16_fx( new_swb_speech_buffer_fx_16, 0, L_FRAME48k + STEREO_DFT_OVL_MAX );
shb_speech_fx = new_inp_resamp16k_fx[n]; /* reuse existing buffer: shb_speech[L_FRAME16k] */
@@ -715,7 +733,11 @@ ivas_error ivas_core_enc_fx(
st->cldfbSynTd->Q_cldfb_state = sub( q_re_im_buf[n], 1 );
}
+#ifdef REMOVE_SCALING_SHB_SPEECH
+ swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, shb_speech_fx, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE );
+#else
swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, new_swb_speech_fx, shb_speech_fx, &Q_shb_spch, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE );
+#endif
st->cldfbSynTd->Q_cldfb_state = sub( q_re_im_buf[n], 1 );
}
@@ -727,19 +749,26 @@ ivas_error ivas_core_enc_fx(
}
}
+#ifndef REMOVE_SCALING_SHB_SPEECH
Word16 Q_shb_spch_16 = Q_shb_spch;
move16();
- shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 );
- Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch
- Q_shb_spch = add( Q_shb_spch, shift );
-
- IF( st->hBWE_FD )
+ IF( st->tcxonly == 0 || hStereoICBWE != NULL || st->core == ACELP_CORE ) // temp. fix to keep BE until #1504 (FLP) is solved, then it will become:
+ // IF( st->tcxonly == 0 )
{
- shift = getScaleFactor16( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k );
- st->Q_old_wtda = add( st->Q_old_wtda, shift );
- move16();
- Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, shift ); // st->Q_old_wtda
+ shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 );
+ Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch
+ Q_shb_spch = add( Q_shb_spch, shift );
+#endif
+ IF( st->hBWE_FD )
+ {
+ shift = getScaleFactor16( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k );
+ st->Q_old_wtda = add( st->Q_old_wtda, shift );
+ move16();
+ Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, shift ); // st->Q_old_wtda
+ }
+#ifndef REMOVE_SCALING_SHB_SPEECH
}
+#endif
/* SWB TBE encoder */
test();
@@ -752,24 +781,47 @@ ivas_error ivas_core_enc_fx(
Word16 Q_fb_exc;
Word16 fb_exc_fx[L_FRAME16k];
+#ifdef REMOVE_SCALING_SHB_SPEECH
+ swb_tbe_enc_ivas_fx( st, hStereoICBWE, shb_speech_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], fb_exc_fx, &Q_fb_exc, Q_new[n], 0, st->voicing_fx, pitch_buf_fx[n] );
+#else
swb_tbe_enc_ivas_fx( st, hStereoICBWE, shb_speech_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], fb_exc_fx, &Q_fb_exc, Q_new[n], Q_shb_spch_16, st->voicing_fx, pitch_buf_fx[n] );
+#endif
IF( EQ_16( st->extl, FB_TBE ) )
{
/* FB TBE encoder */
+#ifdef HARMONIZE_TBE
+ fb_tbe_enc_fx( st, st->input_fx, fb_exc_fx, Q_fb_exc, st->q_inp );
+#else
fb_tbe_enc_ivas_fx( st, st->input_fx, fb_exc_fx, Q_fb_exc, st->q_inp );
+#endif
}
}
}
ELSE IF( EQ_16( st->extl, SWB_BWE ) || EQ_16( st->extl, FB_BWE ) )
{
+#ifndef REMOVE_SCALING_SHB_SPEECH
Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, -Q16 ); // Q_shb_spch - 16
+#endif
/* SWB(FB) BWE encoder */
+#ifdef REMOVE_SCALING_SHB_SPEECH
+ swb_bwe_enc_ivas_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, st->q_inp, shb_speech_fx, sub( Q_new[n], 1 ) );
+#else
swb_bwe_enc_ivas_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, st->q_inp, shb_speech_fx, sub( Q_shb_spch, Q16 ), sub( Q_new[n], 1 ) );
+#endif
}
Scale_sig( old_syn_12k8_16k_fx[n], L_FRAME16k, sub( Q1, Q_new[n] ) ); // Q0
+#ifdef FIX_2370_UNUSED_BUFFERS_CORE_ENC
+ IF( GE_32( input_Fs, 32000 ) && st->hBWE_TD != NULL )
+ {
+ Scale_sig( st->input_fx, input_frame, sub( q_inp_orig, st->q_inp ) );
+ st->q_inp = q_inp_orig;
+ move16();
+ }
+
+#endif
/*---------------------------------------------------------------------*
* SWB DTX/CNG encoding
*---------------------------------------------------------------------*/
@@ -780,30 +832,43 @@ ivas_error ivas_core_enc_fx(
IF( st->hTdCngEnc != NULL && st->Opt_DTX_ON && ( GE_16( input_frame, L_FRAME32k ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) )
{
/* SHB DTX/CNG encoder */
+#ifndef REMOVE_SCALING_SHB_SPEECH
Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, negate( Q_shb_spch ) ); // Q0
- swb_CNG_enc_ivas_fx( st, shb_speech_fx /* Unmodified */, old_syn_12k8_16k_fx[n] );
+#endif
+ swb_CNG_enc_fx( st, shb_speech_fx, old_syn_12k8_16k_fx[n] );
}
/*-------------------------------------------------------------------*
* Inter-channel BWE encoding
*-------------------------------------------------------------------*/
+#ifndef FIX_2367_REMOVE_CODE_ICBWE
Word16 q_new_swb_speech_buffer = getScaleFactor16( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX );
Scale_sig( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX, q_new_swb_speech_buffer ); // st->q_inp+q_new_swb_speech_buffer
q_new_swb_speech_buffer = add( st->q_inp, q_new_swb_speech_buffer );
+#endif
test();
test();
IF( n == 0 && GE_32( input_Fs, 32000 ) && hStereoICBWE != NULL )
{
+#ifndef FIX_2367_REMOVE_CODE_ICBWE
+#ifdef FIX_2367_REMOVE_CODE_ICBWE
+ Word16 q_new_swb_speech_buffer = st->q_inp;
+#endif
Word32 voice_factors_fx32[CPE_CHANNELS][NB_SUBFR16k];
stereo_icBWE_preproc_fx( hCPE, input_frame, new_swb_speech_buffer_fx_16 /*tmp buffer*/, q_new_swb_speech_buffer );
- q_new_swb_speech_buffer = add( q_new_swb_speech_buffer, 16 );
+ q_new_swb_speech_buffer = add( q_new_swb_speech_buffer, Q16 );
Copy_Scale_sig_16_32_no_sat( new_swb_speech_buffer_fx_16, new_swb_speech_buffer_fx, L_FRAME48k + STEREO_DFT_OVL_MAX, Q16 ); // q_new_swb_speech_buffer+st->q_inp - 16 - > q_new_swb_speech_buffer+st->q_inp
Copy_Scale_sig_16_32_no_sat( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31
- stereo_icBWE_enc_ivas_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx32[0] );
+ stereo_icBWE_enc_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx32[0] );
+#else
+ stereo_icBWE_preproc_fx( hCPE, input_frame, new_swb_speech_buffer_fx_16 /*tmp buffer*/, st->q_inp );
+ stereo_icBWE_enc_fx( hCPE, shb_speech_fx, new_swb_speech_buffer_fx_16, st->q_inp, voice_factors_fx[0] );
+#endif
+#ifndef FIX_2367_REMOVE_CODE_ICBWE
IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) )
{
test();
@@ -818,8 +883,10 @@ ivas_error ivas_core_enc_fx(
move32();
}
}
+#endif
}
+#ifndef FIX_2370_UNUSED_BUFFERS_CORE_ENC
Copy( tmp_old_input_fx, st->input_fx - input_frame, input_frame );
Copy( tmp_input_fx, st->input_fx, input_frame );
st->q_old_inp = q_inp[0];
@@ -827,19 +894,14 @@ ivas_error ivas_core_enc_fx(
st->q_inp = q_inp[1];
move16();
- /*---------------------------------------------------------------------*
- * Channel-aware mode - write signaling information into the bitstream
- *---------------------------------------------------------------------*/
-
- signaling_enc_rf_fx( st );
-
+#endif
/*---------------------------------------------------------------------*
* Common updates
*---------------------------------------------------------------------*/
IF( !MCT_flag ) /* for MCT do this later, otherwise there can be a problem because TCX quant happens later and might get the wrong last_core on a bit rate switch */
{
- updt_enc_common_ivas_fx( st, Q_new[n] );
+ updt_enc_common_fx( st, Q_new[n] );
}
IF( st->hBWE_FD != NULL )
diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c
index f6aa5e904c6fdf12012cee93b4f2f7688a1681a0..8541b3fd9f4134151535894ee2319b61a04dfb43 100644
--- a/lib_enc/ivas_core_pre_proc_front_fx.c
+++ b/lib_enc/ivas_core_pre_proc_front_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -50,15 +50,13 @@
#define SCE_SMC_THR 16000
-static void calculate_energy_buffer_ivas_fx( CPE_ENC_HANDLE hCPE, Word32 enerBuffer_dft[], const Word16 no_channels, const Word32 input_Fs, Word16 enerBuffer_dft_e[] );
-
/*-------------------------------------------------------------------*
- * pre_proc_front_ivas()
- *
- * Front Pre-processing for IVAS
- * (resampling, spectral analysis, LP analysis, VAD, OL pitch calculation, classification)
+ * Local function prototypes
*--------------------------------------------------------------------*/
-static Word16 get_zero_flag( Word32 arr[], Word16 len )
+
+static void calculate_energy_buffer_ivas_fx( CPE_ENC_HANDLE hCPE, Word32 enerBuffer_dft[], const Word16 no_channels, const Word32 input_Fs, Word16 enerBuffer_dft_e[] );
+
+static Word16 get_zero_flag( const Word32 arr[], const Word16 len )
{
FOR( Word16 j = 0; j < len; j++ )
{
@@ -70,76 +68,71 @@ static Word16 get_zero_flag( Word32 arr[], Word16 len )
return 0;
}
-ivas_error pre_proc_front_ivas_fx(
- SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/
- const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/
- const Word16 input_frame, /* i : frame length Q0*/
- const Word16 n, /* i : channel number Q0*/
- Word16 old_inp_12k8_fx[], /* o : buffer of old input signal (st->Q_inp until preemph, then Q_new, then Q_new-1 towards the end)*/
- Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q_new-1*/
- Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/
- Word16 *relE_fx, /* o : frame relative energy Q8*/
- Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12*/
- Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12*/
- Word32 epsP_fx[M + 1], /* o : LP prediction errors epsP_fx_q*/
- Word16 *epsP_fx_q,
- Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15*/
- Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15*/
- Word16 *vad_hover_flag, /* o : VAD hangover flag Q0*/
- Word16 *attack_flag, /* o : flag signaling attack Q0*/
- Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer Q(q_re_im_buf)*/
- Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer Q(q_re_im_buf)*/
- Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */
- Word16 old_wsp_fx[], /* o : weighted input signal buffer q_old_wsp*/
- Word16 *q_old_wsp,
- Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6*/
- Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15*/
- Word16 *loc_harm, /* o : harmonicity flag Q0*/
- Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8*/
- Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO Q0*/
- Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/
- Word16 *enerBuffer_fx_exp, /* o : energy buffer */
- Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer fft_buff_fx_q*/
- Word16 *fft_buff_fx_q, /* o : FFT buffer */
- const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12*/
- const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15*/
- const Word32 currFlatness_fx, /* i : flatness parameter Q21*/
- const Word16 tdm_ratio_idx, /* i : Current Ratio_L index Q0*/
- Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) fr_bands_LR_fx_q*/
- Word16 fr_bands_LR_fx_q[CPE_CHANNELS],
- const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/
- Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q)*/
- Word16 lf_E_LR_fx_q,
- const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/
- Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q)*/
- Word16 band_energies_LR_fx_q,
- const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
- const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/
- const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/
- const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision Q0*/
- const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
- const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/
- const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/
- Word16 *Q_new
-#ifdef DEBUG_MODE_INFO
- ,
- const Word16 ch_idx
-#endif
+
+/*-------------------------------------------------------------------*
+ * pre_proc_front_ivas()
+ *
+ * Front Pre-processing for IVAS
+ * (resampling, spectral analysis, LP analysis, VAD, OL pitch calculation, classification)
+ *--------------------------------------------------------------------*/
+
+void pre_proc_front_ivas_fx(
+ SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */
+ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
+ const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/
+ const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/
+ const Word16 input_frame, /* i : frame length Q0*/
+ const Word16 n, /* i : channel number Q0*/
+ Word16 old_inp_12k8_fx[], /* o : buffer of old input signal (st->Q_inp until preemph, then Q_new, then Q_new-1 towards the end)*/
+ Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q_new-1*/
+ Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/
+ Word16 *relE_fx, /* o : frame relative energy Q8*/
+ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12*/
+ Word32 epsP_fx[M + 1], /* o : LP prediction errors epsP_fx_q*/
+ Word16 *epsP_fx_q, /* o : Q factor of LP prediction errors */
+ Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15*/
+ Word16 *vad_hover_flag, /* o : VAD hangover flag Q0*/
+ Word16 *attack_flag, /* o : flag signaling attack Q0*/
+ Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer Q(q_re_im_buf)*/
+ Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer Q(q_re_im_buf)*/
+ Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */
+ Word16 old_wsp_fx[], /* o : weighted input signal buffer q_old_wsp*/
+ Word16 *q_old_wsp, /* o : Q factor of weighted input signal buffer */
+ Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6*/
+ Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15*/
+ Word16 *loc_harm, /* o : harmonicity flag Q0*/
+ Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8*/
+ Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO Q0*/
+ Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/
+ Word16 *enerBuffer_fx_exp, /* o : energy buffer */
+ Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer fft_buff_fx_q*/
+ Word16 *fft_buff_fx_q, /* o : FFT buffer */
+ const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12*/
+ const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15*/
+ const Word32 currFlatness_fx, /* i : flatness parameter Q21*/
+ const Word16 tdm_ratio_idx, /* i : Current Ratio_L index Q0*/
+ Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands fr_bands_LR_fx_q*/
+ Word16 fr_bands_LR_fx_q[CPE_CHANNELS], /* i : Q factors of energy in frequency bands */
+ const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/
+ Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels lf_E_LR_fx_q*/
+ const Word16 lf_E_LR_fx_q, /* i : Q factor of per bin spectrum energy in lf, LR channels */
+ const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/
+ Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN band_energies_LR_fx_q*/
+ const Word16 band_energies_LR_fx_q, /* o : Q factors of energy in critical bands without minimum noise floor */
+ const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
+ const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/
+ const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/
+ const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision Q0*/
+ const IVAS_FORMAT ivas_format, /* i : IVAS format */
+ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
+ const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/
+ const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/
+ Word16 *Q_new /* i/o : Q factor of speech buffers */
)
{
Encoder_State *st;
- IF( hSCE != NULL )
- {
- st = hSCE->hCoreCoder[n];
- }
- ELSE
- {
- st = hCPE->hCoreCoder[n];
- }
-
Word16 q_tmpN_LR[CPE_CHANNELS];
Word16 q_tmpE_LR[CPE_CHANNELS];
Word16 q_tmpN;
@@ -164,23 +157,18 @@ ivas_error pre_proc_front_ivas_fx(
STEREO_CLASSIF_HANDLE hStereoClassif;
Word16 old_pitch1; /* previous frame OL pitch[1] @12.8 kHz */
Word16 LR_localVAD;
- ivas_error error;
-
- push_wmops( "pre_proc_front" );
-
Word16 *signal_in_fx;
Word32 *signal32_in_fx;
Word16 *inp_12k8_fx, *new_inp_12k8_fx; /* pointers to current frame and new data */
CLDFB_SCALE_FACTOR cldfbScale;
- Word16 *temp1F_icatdmResampBuf_fx;
- Word16 *mem_decim_dummy_fx; /* dummy decimation filter memory */
+ Word16 temp1F_icatdmResampBuf_fx[L_FILT_MAX]; /* temp buffers for ICA TDM resamplers */
+ Word16 mem_decim_dummy_fx[2 * L_FILT_MAX]; /* dummy decimation filter memory */
Word32 tmpF_fx[STEREO_DFT_BAND_MAX];
Word32 *res_cod_SNR_M_fx;
Word16 snr_sum_he_fx; /* HE SAD parameters */
Word16 new_inp_out_size;
Word16 Q_new_inp;
Word16 mem_decim_size;
-
Word16 dummy_fx;
Word16 ncharX_fx;
Word16 ncharX_LR_fx; /* noise character for sp/mus classifier */
@@ -214,77 +202,22 @@ ivas_error pre_proc_front_ivas_fx(
Word16 Qfact_PS, q_lf_E_fx;
Word16 enerBuffer_fx_exp_buf[CLDFB_NO_CHANNELS_MAX];
Word32 bckr_temp[NB_BANDS];
-#ifdef DEBUG_MODE_INFO
- Word32 *in_buff_temp;
- Word16 in_q_temp;
-#endif
-
- mem_decim_dummy_fx = (Word16 *) malloc( 90 * sizeof( Word16 * ) );
- temp1F_icatdmResampBuf_fx = (Word16 *) malloc( 45 * sizeof( Word16 * ) );
- set16_fx( fft_buff_fx, 0, 512 );
-
- Word16 Q_min = add( sub( 15, st->exp_old_inp_12k8 ), norm_arr( st->old_inp_12k8_fx, L_INP_MEM ) );
- Word16 input_frame_full = shl( input_frame, 1 ); //(old frame input length + new frame input length)
- Q_min = s_min( Q_min, sub( add( getScaleFactor32( st->input32_fx - input_frame, input_frame_full ), st->q_inp32 ), 16 ) );
- Q_min = s_max( -2, Q_min );
- Copy_Scale_sig_32_16( st->input32_fx - input_frame, st->input_fx - input_frame, input_frame_full, sub( Q_min, st->q_inp32 ) ); // Q_min
- st->q_inp = Q_min;
- move16();
- st->q_old_inp = Q_min;
- move16();
-
-#ifdef DEBUG_MODE_INFO
- IF( hSCE != NULL )
- {
- in_buff_temp = hSCE->hCoreCoder[n]->input32_fx;
- in_q_temp = hSCE->hCoreCoder[n]->q_inp32;
- }
- ELSE
- {
- in_buff_temp = hCPE->hCoreCoder[n]->input32_fx;
- in_q_temp = hCPE->hCoreCoder[n]->q_inp32;
- }
-#endif
-
-
-#ifdef DEBUG_MODE_INFO
- if ( !( hCPE != NULL && hCPE->hStereoTD != NULL && ch_idx > 0 ) )
- {
- /* for TD stereo only write out first channel. The existence of a second channel can vary, this is just easier to handle */
- int16_t tmpF[L_FRAME48k];
- for ( int16_t isample = 0; isample < input_frame; isample++ )
- {
- tmpF[isample] = (int16_t) ( (float) in_buff_temp[isample - NS2SA( st->input_Fs, ACELP_LOOK_NS )] / ( (float) ( 1 << in_q_temp ) ) );
- }
- dbgwrite( &tmpF, sizeof( int16_t ), input_frame, 1, strcat( fname( debug_dir, "ivas_input_dmx", 0, ch_idx + 1, ENC ), ".pcm" ) );
- }
-#endif
-
- FOR( Word16 k = 0; k < CLDFB_NO_COL_MAX; k++ )
- {
- set32_fx( realBuffer_fx[k], 0, CLDFB_NO_CHANNELS_MAX );
- set32_fx( imagBuffer_fx[k], 0, CLDFB_NO_CHANNELS_MAX );
- }
+ Word16 Q_min;
+ Word16 input_frame_full;
Word16 sf_energySum[CLDFB_NO_CHANNELS_MAX];
-
Word16 Q_inp_const = -1;
move16();
- Word16 headroom = 0, preemp_len = 0, inp_max = 0;
- move16();
- move16();
- move16();
+ Word16 headroom, preemp_len, inp_max;
Word16 *preemp_start_idx = NULL;
- Word32 sig_out[960], max_32;
+ Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k /* = max( L_FRAME16k + STEREO_DFT_OVL_16k, L_FRAME16k + L_FILT16k + lMemRecalc_16k ) */], max_32;
+ push_wmops( "pre_proc_front" );
/*------------------------------------------------------------------*
* Initialization
*------------------------------------------------------------------*/
- error = IVAS_ERR_OK;
- move32();
-
- cldfbScale.lb_scale = 31;
- cldfbScale.hb_scale = 31;
+ cldfbScale.lb_scale = Q31;
+ cldfbScale.hb_scale = Q31;
move16();
move16();
@@ -297,12 +230,6 @@ ivas_error pre_proc_front_ivas_fx(
LR_localVAD = 0;
move16();
- IF( st->cldfbAnaEnc != NULL )
- {
- scale_sig32( st->cldfbAnaEnc->cldfb_state_fx, sub( sub( st->cldfbAnaEnc->p_filter_length, st->cldfbAnaEnc->no_channels ), st->cldfbAnaEnc->zeros ), sub( Q11, st->cldfbAnaEnc->Q_cldfb_state ) ); /* Q11 */
- st->cldfbAnaEnc->Q_cldfb_state = Q11;
- move16();
- }
IF( hSCE != NULL )
{
@@ -413,6 +340,16 @@ ivas_error pre_proc_front_ivas_fx(
move16();
}
+ Q_min = add( sub( 15, st->exp_old_inp_12k8 ), norm_arr( st->old_inp_12k8_fx, L_INP_MEM ) );
+ input_frame_full = shl( input_frame, 1 ); //(old frame input length + new frame input length)
+ Q_min = s_min( Q_min, sub( add( getScaleFactor32( st->input32_fx - input_frame, input_frame_full ), st->q_inp32 ), 16 ) );
+ Q_min = s_max( -2, Q_min );
+ Copy_Scale_sig_32_16( st->input32_fx - input_frame, st->input_fx - input_frame, input_frame_full, sub( Q_min, st->q_inp32 ) ); // Q_min
+ st->q_inp = Q_min;
+ move16();
+ st->q_old_inp = Q_min;
+ move16();
+
L_look = L_LOOK_12k8; /* lookahead at 12.8kHz */
move16();
@@ -448,6 +385,13 @@ ivas_error pre_proc_front_ivas_fx(
last_core_orig = st->last_core; /* Q0 */
move16();
+ IF( st->cldfbAnaEnc != NULL )
+ {
+ scale_sig32( st->cldfbAnaEnc->cldfb_state_fx, sub( sub( st->cldfbAnaEnc->p_filter_length, st->cldfbAnaEnc->no_channels ), st->cldfbAnaEnc->zeros ), sub( Q11, st->cldfbAnaEnc->Q_cldfb_state ) ); /* Q11 */
+ st->cldfbAnaEnc->Q_cldfb_state = Q11;
+ move16();
+ }
+
/*--------------------------------------------------------------*
* energy analysis
*---------------------------------------------------------------*/
@@ -490,6 +434,7 @@ ivas_error pre_proc_front_ivas_fx(
* Change the sampling frequency to 12.8 kHz
* (if not available from downsampled DMX)
*----------------------------------------------------------------*/
+
Scale_sig( st->mem_decim_fx_q_inp, 2 * L_FILT_MAX, sub( st->q_inp, st->mem_q ) ); /* st->q_inp */
test();
@@ -501,8 +446,8 @@ ivas_error pre_proc_front_ivas_fx(
move16();
Copy( st->mem_decim_fx_q_inp, mem_decim_dummy_fx, 2 * L_FILT_MAX ); /* Q(-1) */
set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX );
- new_inp_out_size = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size ); /* st->q_inp */
- Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/
+ new_inp_out_size = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size ); /* st->q_inp */
+ Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/
}
ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_MDCT ) )
{
@@ -575,17 +520,16 @@ ivas_error pre_proc_front_ivas_fx(
* Perform fixed preemphasis (12.8 kHz signal) through 1 - g*z^-1
*-----------------------------------------------------------------*/
- *Q_new = 0;
- move16();
- set32_fx( sig_out, 0, 960 );
-
headroom = 2;
move16();
+ preemp_len = 0;
+ move16();
st->mem_preemph_fx_q_inp = shl_sat( st->mem_preemph_fx_q_inp, sub( st->q_inp, st->mem_preemph_q ) ); /*st->q_inp*/
move16();
st->mem_preemph_DFT_fx_q_inp = shl_sat( st->mem_preemph_DFT_fx_q_inp, sub( st->q_inp, st->mem_preemph_q ) ); /*st->q_inp*/
move16();
+
test();
IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
{
@@ -596,13 +540,11 @@ ivas_error pre_proc_front_ivas_fx(
st->mem_preemph_DFT_fx_q_inp = old_inp_12k8_fx[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1]; /* st->q_inp */
move16();
- // PREEMPH_FX( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx );
- PREEMPH_32FX( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, sig_out, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx_q_inp );
+ preemph_copy_32fx2( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, sig_out, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx_q_inp );
dummy_fx = st->mem_preemph_fx_q_inp;
move16();
- // PREEMPH_FX( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, PREEMPH_FAC, STEREO_DFT_OVL_12k8, &dummy_fx );
- PREEMPH_32FX( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, sig_out + L_FRAME, PREEMPH_FAC, STEREO_DFT_OVL_12k8, &dummy_fx );
+ preemph_copy_32fx2( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, sig_out + L_FRAME, PREEMPH_FAC, STEREO_DFT_OVL_12k8, &dummy_fx );
preemp_start_idx = new_inp_12k8_fx - STEREO_DFT_OVL_12k8;
move16();
preemp_len = STEREO_DFT_OVL_12k8 + L_FRAME;
@@ -617,8 +559,7 @@ ivas_error pre_proc_front_ivas_fx(
st->mem_preemph_fx_q_inp = st->mem_preemph_DFT_fx_q_inp; /* st->q_inp */
move16();
Copy_Scale_sig( st->inp_12k8_mem_stereo_sw_fx, new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, sub( st->q_inp, Q_inp_const ) ); /* st->q_inp */
- // PREEMPH_FX( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), PREEMPH_FAC, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph_fx );
- PREEMPH_32FX( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), sig_out, PREEMPH_FAC, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph_fx_q_inp );
+ preemph_copy_32fx2( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), sig_out, PREEMPH_FAC, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph_fx_q_inp );
preemp_start_idx = new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT );
move16();
preemp_len = STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT;
@@ -635,19 +576,16 @@ ivas_error pre_proc_front_ivas_fx(
{
Word16 length_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_SCH_NS );
move16();
- // PREEMPH_FX( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, PREEMPH_FAC, length_12k8, &st->mem_preemph_fx );
- PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, sig_out, PREEMPH_FAC, length_12k8, &st->mem_preemph_fx_q_inp );
+ preemph_copy_32fx2( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, sig_out, PREEMPH_FAC, length_12k8, &st->mem_preemph_fx_q_inp );
preemp_start_idx = new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8;
preemp_len = length_12k8;
move16();
}
- // PREEMPH_FX( new_inp_12k8_fx - lMemRecalc_12k8, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx );
- PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8, sig_out + preemp_len, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx_q_inp );
+ preemph_copy_32fx2( new_inp_12k8_fx - lMemRecalc_12k8, sig_out + preemp_len, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx_q_inp );
dummy_fx = st->mem_preemph_fx_q_inp; /* st->q_inp */
move16();
- // PREEMPH_FX( new_inp_12k8_fx - lMemRecalc_12k8 + L_FRAME, PREEMPH_FAC, lMemRecalc_12k8 + L_FILT, &dummy_fx );
- PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8 + L_FRAME, sig_out + preemp_len + L_FRAME, PREEMPH_FAC, lMemRecalc_12k8 + L_FILT, &dummy_fx );
+ preemph_copy_32fx2( new_inp_12k8_fx - lMemRecalc_12k8 + L_FRAME, sig_out + preemp_len + L_FRAME, PREEMPH_FAC, lMemRecalc_12k8 + L_FILT, &dummy_fx );
test();
IF( preemp_start_idx && preemp_len )
@@ -664,16 +602,15 @@ ivas_error pre_proc_front_ivas_fx(
}
ELSE /* IVAS_SCE or IVAS_CPE_MDCT */
{
- // PREEMPH_FX( new_inp_12k8_fx, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx );
- PREEMPH_32FX( new_inp_12k8_fx, sig_out, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx_q_inp );
+ preemph_copy_32fx2( new_inp_12k8_fx, sig_out, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx_q_inp );
dummy_fx = st->mem_preemph_fx_q_inp;
move16();
- // PREEMPH_FX( new_inp_12k8_fx + L_FRAME, PREEMPH_FAC, L_FILT, &dummy_fx );
- PREEMPH_32FX( new_inp_12k8_fx + L_FRAME, sig_out + L_FRAME, PREEMPH_FAC, L_FILT, &dummy_fx );
+ preemph_copy_32fx2( new_inp_12k8_fx + L_FRAME, sig_out + L_FRAME, PREEMPH_FAC, L_FILT, &dummy_fx );
preemp_start_idx = new_inp_12k8_fx;
preemp_len = L_FRAME + L_FILT;
move16();
}
+
st->mem_preemph_fx = shl_sat( st->mem_preemph_fx_q_inp, sub( -1, st->q_inp ) ); /*Q(-1) saturation added as float value goes above 65536 for +10 dB test (ltv48_MC512.wav and ltv48_MC51.wav) */
move16();
st->mem_preemph_DFT_fx = shl_sat( st->mem_preemph_DFT_fx_q_inp, sub( -1, st->q_inp ) ); /*Q(-1)*/
@@ -773,16 +710,6 @@ ivas_error pre_proc_front_ivas_fx(
st->vad_flag = wb_vad_ivas_fx( st, fr_bands_fx, fr_bands_fx_q, &i, &i, &i, &snr_sum_he_fx, &localVAD_HE_SAD,
&( st->flag_noisy_speech_snr ), NULL, NULL, -MAX_16, -MAX_16 ); //-100000f == max 16bit float
move16();
-#ifdef DEBUG_FORCE_DIR
- if ( st->force_dir[0] != '\0' )
- {
- dbgread( &st->vad_flag, sizeof( int16_t ), 1, fname( st->force_dir, "force_vad_flag.enf", -1, -1, -1 ) );
- }
- else
- {
- dbgwrite( &st->vad_flag, sizeof( int16_t ), 1, 1, "res/force_vad_flag.enf" );
- }
-#endif
test();
IF( EQ_16( force_front_vad, 1 ) || EQ_16( front_vad_flag, 1 ) )
@@ -798,7 +725,7 @@ ivas_error pre_proc_front_ivas_fx(
test();
IF( ( hCPE != NULL && !( lr_vad_enabled && st->idchan == 0 ) ) || hSCE != NULL )
{
- *vad_flag_dtx = ivas_dtx_hangover_addition_fx( st, st->vad_flag, extract_h( L_sub( st->lp_speech_32fx, st->lp_noise_32fx ) ), 0, vad_hover_flag, NULL, NULL, NULL ); /* Q0 */
+ *vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, extract_h( L_sub( st->lp_speech_32fx, st->lp_noise_32fx ) ), 0, vad_hover_flag, NULL, NULL, NULL ); /* Q0 */
move16();
}
ELSE
@@ -809,7 +736,6 @@ ivas_error pre_proc_front_ivas_fx(
*vad_flag_dtx = *vad_flag_dtx || st->vad_flag; /* Q0 */
move16();
-
/* Determine hangover flag status based on LR localVAD and downmix localVAD */
test();
test();
@@ -866,7 +792,6 @@ ivas_error pre_proc_front_ivas_fx(
set_bw_fx( element_mode, element_brate, st, MODE1 );
}
-
/* set the BW of the TD secondary channel in LRTD mode same as BW of the primary channel (only at higher bitrates) */
test();
test();
@@ -877,18 +802,6 @@ ivas_error pre_proc_front_ivas_fx(
move16();
}
-#ifdef DEBUG_FORCE_DIR
- if ( st->force_dir[0] != '\0' )
- {
- dbgread( &st->bwidth, sizeof( int16_t ), 1, fname( st->force_dir, "force_bwidth.enf", -1, -1, -1 ) );
- }
- else
- {
- dbgwrite( &st->bwidth, sizeof( int16_t ), 1, 1, "res/force_bwidth.enf" );
- }
-#endif
-
-
/*----------------------------------------------------------------*
* Noise energy down-ward update and total noise energy estimation
* Long-term energies and relative frame energy updates
@@ -915,6 +828,7 @@ ivas_error pre_proc_front_ivas_fx(
/*----------------------------------------------------------------*
* FD-CNG Noise Estimator
*----------------------------------------------------------------*/
+
IF( st->hFdCngEnc != NULL )
{
resetFdCngEnc_fx( st );
@@ -966,6 +880,7 @@ ivas_error pre_proc_front_ivas_fx(
/*-----------------------------------------------------------------*
* Select SID or FRAME_NO_DATA frame if DTX enabled
*-----------------------------------------------------------------*/
+
test();
test();
if ( hCPE != NULL && NE_16( element_mode, IVAS_CPE_DFT ) && NE_16( element_mode, IVAS_CPE_MDCT ) )
@@ -984,7 +899,7 @@ ivas_error pre_proc_front_ivas_fx(
move16();
}
- dtx_ivas_fx( st, last_ivas_total_brate, ivas_total_brate, *vad_flag_dtx, inp_12k8_fx, *Q_new );
+ dtx_fx( st, last_ivas_total_brate, ivas_total_brate, *vad_flag_dtx, inp_12k8_fx, *Q_new );
test();
test();
@@ -998,6 +913,7 @@ ivas_error pre_proc_front_ivas_fx(
/*----------------------------------------------------------------*
* Adjust FD-CNG Noise Estimator
*----------------------------------------------------------------*/
+
test();
test();
test();
@@ -1014,7 +930,9 @@ ivas_error pre_proc_front_ivas_fx(
{
total_brate = imult3216( FRAMES_PER_SEC, st->bits_frame_nominal ); /* Q0 */
}
+
configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), total_brate );
+
IF( hCPE != NULL )
{
st->hFdCngEnc->hFdCngCom->CngBitrate = L_sub( hCPE->element_brate, 1 ); /* Q0 */
@@ -1071,6 +989,7 @@ ivas_error pre_proc_front_ivas_fx(
/*----------------------------------------------------------------*
* LP analysis
*----------------------------------------------------------------*/
+
Word16 stab_fac_fx;
Word16 Q_r[2];
set16_fx( Q_r, 0, 2 );
@@ -1119,6 +1038,7 @@ ivas_error pre_proc_front_ivas_fx(
* Comparison of the LP coefficents to determine if it is possible
* to reuse the primary channel LP coefficients in the secondary channel
*----------------------------------------------------------------*/
+
Word32 speech_buff[L_FRAME + M];
Copy_Scale_sig_16_32_DEPREC( inp_12k8_fx - M, speech_buff, L_FRAME + M, Q12 ); /* Q_new + 12 */
hCPE->hStereoTD->tdm_lp_reuse_flag = tdm_lp_comparison_fx( hCPE->hStereoTD, hCPE->hStereoClassif, st, &speech_buff[0], tdm_A_PCh_fx, A_fx, M, tdm_lsp_new_PCh_fx, lsp_new_fx, L_FRAME, L_sub( element_brate, imult3216( FRAMES_PER_SEC, nb_bits_metadata ) ), add( *Q_new, 12 ) ); /* Q0 */
@@ -1137,7 +1057,11 @@ ivas_error pre_proc_front_ivas_fx(
move16();
move16();
+#ifndef FIX_2363_FIND_WSP
ivas_find_wsp_fx( L_FRAME, L_SUBFR, NB_SUBFR, A_fx, Aw_fx, inp_12k8_fx, TILT_FAC_FX, wsp_fx, &st->mem_wsp_fx, GAMMA1, L_LOOK_12k8 );
+#else
+ find_wsp_fx( A_fx, inp_12k8_fx, wsp_fx, &st->mem_wsp_fx, TILT_FAC_FX, L_FRAME, L_LOOK_12k8, L_SUBFR, Aw_fx, GAMMA1, NB_SUBFR );
+#endif
Word16 Q_wsp = *Q_new;
move16();
@@ -1171,6 +1095,7 @@ ivas_error pre_proc_front_ivas_fx(
pitch_ol_ivas_fx( st->pitch, st->voicing_fx, &st->old_pitch, &st->old_corr_fx, corr_shift_fx, &st->old_thres_fx,
&st->delta_pit, st->old_wsp2_fx, wsp_fx, st->mem_decim2_fx, *relE_fx, st->clas, st->input_bwidth, st->Opt_SC_VBR, Q_wsp );
+
/* Updates for adaptive lag window memory */
st->old_pitch_la = st->pitch[2]; /* Q0 */
move16();
@@ -1184,8 +1109,9 @@ ivas_error pre_proc_front_ivas_fx(
move16();
Copy_Scale_sig_32_16( st->Bin_E_fx, st->lgBin_E_fx, L_FFT / 2, sub( Q7, st->q_Bin_E ) ); /* Q7 */
+
/* Detection of very short stable pitch period */
- StableHighPitchDetect_ivas_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, *q_old_wsp, st->lgBin_E_fx );
+ StableHighPitchDetect_fx( element_mode, &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, *q_old_wsp, st->lgBin_E_fx );
/* 1/4 pitch precision improvement */
IF( LE_32( element_brate, IVAS_32k ) )
@@ -1220,6 +1146,7 @@ ivas_error pre_proc_front_ivas_fx(
/*------------------------------------------------------------------*
* Update estimated noise energy and voicing cut-off frequency
*-----------------------------------------------------------------*/
+
Word16 scale = s_min( Q31, add( st->hNoiseEst->ave_enr_q, s_min( L_norm_arr( st->hNoiseEst->ave_enr_fx, NB_BANDS ), L_norm_arr( st->hNoiseEst->ave_enr2_fx, NB_BANDS ) ) ) );
scale = s_min( scale, add( q_tmpE, L_norm_arr( tmpE_fx, NB_BANDS ) ) );
scale = sub( scale, 1 ); // guard bits
@@ -1289,6 +1216,7 @@ ivas_error pre_proc_front_ivas_fx(
/*------------------------------------------------------------------*
* Update parameters used in the VAD and DTX
*-----------------------------------------------------------------*/
+
vad_param_updt_fx( st, old_pitch1, corr_shift_fx, corr_shift_fx, A_fx, NULL, 1 );
test();
@@ -1296,6 +1224,7 @@ ivas_error pre_proc_front_ivas_fx(
{
vad_param_updt_fx( st, old_pitch1, corr_shiftL_fx, corr_shiftR_fx, A_fx, &hCPE->hFrontVad[0], CPE_CHANNELS );
}
+
/*-----------------------------------------------------------------*
* Find spectral tilt
* UC and VC frame selection
@@ -1310,23 +1239,10 @@ ivas_error pre_proc_front_ivas_fx(
find_tilt_ivas_fx( fr_bands_fx, fr_bands_fx_q, bckr_temp, scale, ee_fx, st->pitch, st->voicing_fx, lf_E_fx, q_lf_E_fx,
corr_shift_fx, st->input_bwidth, st->max_band, hp_E_fx, MODE1, &( st->bckr_tilt_lt ), st->Opt_SC_VBR );
- st->coder_type = find_uv_ivas_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, *relE_fx, extract_h( Etot_fx ), hp_E_fx,
- &flag_spitch, last_core_orig, hStereoClassif, *Q_new /*q_inp_12k8*/, fr_bands_fx_q ); // Q0
- Copy_Scale_sig_16_32_no_sat( st->lgBin_E_fx, st->Bin_E_fx, L_FFT / 2, sub( st->q_Bin_E, Q7 ) );
-
-#ifdef DEBUG_FORCE_DIR
- if ( st->force_dir[0] != '\0' )
- {
- dbgread( &st->coder_type, sizeof( int16_t ), 1, fname( st->force_dir, "force_coder_type.enf", -1, -1, -1 ) );
- dbgread( &st->coder_type_raw, sizeof( int16_t ), 1, fname( st->force_dir, "force_coder_type_raw.enf", -1, -1, -1 ) );
- }
- else
- {
- dbgwrite( &st->coder_type, sizeof( int16_t ), 1, 1, "res/force_coder_type.enf" );
- dbgwrite( &st->coder_type_raw, sizeof( int16_t ), 1, 1, "res/force_coder_type_raw.enf" );
- }
-#endif
+ st->coder_type = find_uv_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, *relE_fx, extract_h( Etot_fx ), hp_E_fx,
+ &flag_spitch, last_core_orig, hStereoClassif, *Q_new, 0, fr_bands_fx_q ); // Q0
+ Copy_Scale_sig_16_32_no_sat( st->lgBin_E_fx, st->Bin_E_fx, L_FFT / 2, sub( st->q_Bin_E, Q7 ) );
/*-----------------------------------------------------------------*
* channel aware mode configuration *
@@ -1356,6 +1272,7 @@ ivas_error pre_proc_front_ivas_fx(
/*-----------------------------------------------------------------*
* Collect stereo classifier features
*-----------------------------------------------------------------*/
+
IF( hStereoClassif != NULL )
{
Word16 max_e_Etot;
@@ -1370,6 +1287,7 @@ ivas_error pre_proc_front_ivas_fx(
move16();
move16();
move16();
+
stereo_classifier_features_ivas_fx( hStereoClassif, st->idchan, element_mode, localVAD_HE_SAD, lsf_new_fx, epsP_fx,
st->pitch, st->voicing_fx, *cor_map_sum_fx, non_staX_fx, sp_div_fx,
st->clas, sub( 31, *epsP_fx_q ), ( 31 - Q8 ) /* exp of cor_map_sum */, ( 31 - Q20 ) /* exp of non_staX_fx */, sub( 15, q_sp_div ) );
@@ -1379,23 +1297,11 @@ ivas_error pre_proc_front_ivas_fx(
* 1st stage speech/music classification (GMM model)
*----------------------------------------------------------------*/
- SP_MUS_CLAS_HANDLE hSpMusClas = st->hSpMusClas;
shift = getScaleFactor32( PS_fx, 128 );
scale_sig32( PS_fx, 128, shift );
Qfact_PS = add( Qfact_PS, shift );
- smc_dec = ivas_smc_gmm_fx( st, hStereoClassif, localVAD_HE_SAD, extract_h( Etot_fx ), lsp_new_fx, *cor_map_sum_fx /*Q8*/, epsP_fx, PS_fx, non_staX_fx, *relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, *epsP_fx_q, hSpMusClas->past_PS_Q ); /* Q0 */
-
-#ifdef DEBUG_FORCE_DIR
- if ( st->force_dir[0] != '\0' )
- {
- dbgread( &smc_dec, sizeof( int16_t ), 1, fname( st->force_dir, "force_smc_dec_loc1.enf", -1, -1, -1 ) );
- }
- else
- {
- dbgwrite( &smc_dec, sizeof( int16_t ), 1, 1, "res/force_smc_dec_loc1.enf" );
- }
-#endif
+ smc_dec = ivas_smc_gmm_fx( st, hStereoClassif, localVAD_HE_SAD, extract_h( Etot_fx ), lsp_new_fx, *cor_map_sum_fx /*Q8*/, epsP_fx, PS_fx, non_staX_fx, *relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, *epsP_fx_q, st->hSpMusClas->past_PS_Q ); /* Q0 */
#ifdef DEBUGGING
if ( st->idchan == 0 )
@@ -1444,6 +1350,7 @@ ivas_error pre_proc_front_ivas_fx(
st->GSC_IVAS_mode = 0;
move16();
+
test();
IF( EQ_16( st->idchan, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) )
{
@@ -1500,6 +1407,7 @@ ivas_error pre_proc_front_ivas_fx(
move16();
st->hTcxEnc->spectrum_e[1] = 16;
move16();
+
IF( flag_16k_smc )
{
Word16 Q_old_inp_16k = -1;
@@ -1533,15 +1441,10 @@ ivas_error pre_proc_front_ivas_fx(
Word16 Q_old_inp_12k8 = *Q_new;
move16();
+
/* Compute core-coder buffers at internal sampling rate */
- error = ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx,
- A_fx, Aw_fx,
- epsP_fx,
- lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new );
- IF( NE_32( error, IVAS_ERR_OK ) )
- {
- return error;
- }
+ ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx, A_fx, Aw_fx, epsP_fx, lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new );
+
*epsP_fx_q = add( Q_r[0], 1 );
move16();
@@ -1602,23 +1505,6 @@ ivas_error pre_proc_front_ivas_fx(
ivas_smc_mode_selection_fx( st, element_brate, smc_dec, *relE_fx, extract_h( Etot_fx ), attack_flag, inp_12k8_fx, *Q_new, S_map_fx, flag_spitch );
}
-#ifdef DEBUG_FORCE_DIR
- if ( st->force_dir[0] != '\0' )
- {
- dbgread( &smc_dec, sizeof( int16_t ), 1, fname( st->force_dir, "force_smc_dec_loc2.enf", -1, -1, -1 ) );
- dbgread( &st->sp_aud_decision0, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision0.enf", -1, -1, -1 ) );
- dbgread( &st->sp_aud_decision1, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision1.enf", -1, -1, -1 ) );
- dbgread( &st->sp_aud_decision2, sizeof( int16_t ), 1, fname( st->force_dir, "force_sp_aud_decision2.enf", -1, -1, -1 ) );
- }
- else
- {
- dbgwrite( &smc_dec, sizeof( int16_t ), 1, 1, "res/force_smc_dec_loc2.enf" );
- dbgwrite( &st->sp_aud_decision0, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision0.enf" );
- dbgwrite( &st->sp_aud_decision1, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision1.enf" );
- dbgwrite( &st->sp_aud_decision2, sizeof( int16_t ), 1, 1, "res/force_sp_aud_decision2.enf" );
- }
-#endif
-
/*----------------------------------------------------------------*
* Final VAD correction (when HE-SAD is used instead of the normal VAD,
* rewrite the VAD flag by VAD flag with DTX hangover for further processing)
@@ -1634,26 +1520,26 @@ ivas_error pre_proc_front_ivas_fx(
/*-----------------------------------------------------------------*
* Update old input signal buffer
*-----------------------------------------------------------------*/
+
shift = getScaleFactor16( &old_inp_12k8_fx[L_FRAME], L_INP_MEM );
Copy_Scale_sig( &old_inp_12k8_fx[L_FRAME], st->old_inp_12k8_fx, L_INP_MEM, shift ); /* Q_new + shift */
st->exp_old_inp_12k8 = sub( Q15, add( *Q_new, shift ) );
move16();
-
*Q_new = sub( *Q_new, Q_inp_const ); // ivas_core_enc will assume inp signal (12k8 and 16k) in Q_new - 1
move16();
- free( mem_decim_dummy_fx );
- free( temp1F_icatdmResampBuf_fx );
pop_wmops();
- return error;
+ return;
}
+
/*-------------------------------------------------------------------*
* calculate_energy_buffer()
*
* calculate DFT-based energies
*--------------------------------------------------------------------*/
+
static void calculate_energy_buffer_ivas_fx(
CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */
Word32 enerBuffer_dft_fx[], /* o : energy buffer() exp(enerBuffer_dft_e)*/
@@ -1723,5 +1609,6 @@ static void calculate_energy_buffer_ivas_fx(
enerBuffer_dft_e[i] = 0;
move16();
}
+
return;
}
diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c
index 7ba122dbd3cc9a5332a60166bf29f17f8d9f54d7..e83973437cfbbb2478041afa7aa458d0749b5d95 100644
--- a/lib_enc/ivas_core_pre_proc_fx.c
+++ b/lib_enc/ivas_core_pre_proc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -45,48 +45,46 @@
* Pre-processing (Selection of internal Fs, classification, SC VBR decision,
* Decision matrix, Preprocessing at other Fs, core switching decision, ...)
*--------------------------------------------------------------------*/
-ivas_error pre_proc_ivas_fx(
- Encoder_State *st, /* i/o: encoder state structure */
- const Word16 last_element_mode, /* i : last element mode Q0*/
- const Word32 element_brate, /* i : element bitrate Q0*/
- const Word32 last_element_brate, /* i : last element bitrate Q0*/
- const Word16 input_frame, /* i : frame length Q0*/
- Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal Q_new-1 */
- Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz Q_new-1 */
- Word16 **inp_fx, /* o : ptr. to inp. signal in the current frame Q_new*/
- Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/
- Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes Q12*/
- Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes Q14*/
- Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q*/
- Word16 *epsP_fx_q, /* i : LP prediction errors */
- Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/
- Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/
- Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_new-1*/
- Word16 *Voicing_flag, /* o : voicing flag for HQ FEC Q0*/
- Word16 old_wsp_fx[], /* i : weighted input signal buffer e_old_wsp*/
- Word16 e_old_wsp,
- const Word16 loc_harm, /* i : harmonicity flag Q0*/
- const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO Q0*/
- const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
- const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
- const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
- Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* e_enerBuffer */
- Word16 e_enerBuffer,
- Word16 fft_buff_fx[2 * L_FFT], /* Qx */
- Word16 cor_map_sum_fx, /* Q8 */
- Word16 *Q_new )
+
+void pre_proc_ivas_fx(
+ Encoder_State *st, /* i/o: encoder state structure */
+ const Word16 last_element_mode, /* i : last element mode Q0*/
+ const Word32 element_brate, /* i : element bitrate Q0*/
+ const Word32 last_element_brate, /* i : last element bitrate Q0*/
+ const Word16 input_frame, /* i : frame length Q0*/
+ Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal Q_new-1 */
+ Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz Q_new-1 */
+ Word16 **inp_fx, /* o : ptr. to inp. signal in the current frame Q_new*/
+ Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/
+ Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes Q12*/
+ Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes Q14*/
+ Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q*/
+ Word16 *epsP_fx_q, /* i : LP prediction errors */
+ Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/
+ Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/
+ Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_new-1*/
+ Word16 *Voicing_flag, /* o : voicing flag for HQ FEC Q0*/
+ Word16 old_wsp_fx[], /* i : weighted input signal buffer e_old_wsp*/
+ const Word16 e_old_wsp, /* i : Q value of weighted input signal buffer */
+ const Word16 loc_harm, /* i : harmonicity flag Q0*/
+ const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO Q0*/
+ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/
+ const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/
+ const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/
+ Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* i : energy buffer e_enerBuffer */
+ const Word16 e_enerBuffer, /* i : Q value of energy buffer */
+ Word16 fft_buff_fx[2 * L_FFT], /* i : FFT buffer Qx*/
+ const Word16 cor_map_sum_fx, /* i : speech/music clasif. parameter Q8*/
+ Word16 *Q_new /* i/o: Q factor of speech buffers */
+)
{
Word16 L_look, element_mode, lMemRecalc_12k8;
Word16 *inp_16k_fx, *new_inp_12k8_fx, *inp_12k8_fx; /* pointers to current frame and new data */
Word16 *wsp_fx; /* weighted input signal buffer */
Word32 sr_core_tmp, total_brate_tmp;
- ivas_error error;
push_wmops( "pre_proc" );
- error = IVAS_ERR_OK;
- move32();
-
/*----------------------------------------------------------------*
* Initialization
*----------------------------------------------------------------*/
@@ -111,6 +109,7 @@ ivas_error pre_proc_ivas_fx(
lMemRecalc_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_NS );
move16();
}
+
/*----------------------------------------------------------------*
* Selection of internal ACELP Fs (12.8 kHz or 16 kHz)
*----------------------------------------------------------------*/
@@ -163,24 +162,23 @@ ivas_error pre_proc_ivas_fx(
move16();
}
- test();
- test();
- test();
- Word16 flag_1 = 0;
- move16();
IF( EQ_16( st->L_frame, L_FRAME16k ) )
{
- flag_1 = ACELP_16k40;
+ total_brate_tmp = ACELP_16k40;
move16();
}
ELSE
{
- flag_1 = ACELP_9k60;
+ total_brate_tmp = ACELP_9k60;
move16();
}
+
+ test();
+ test();
+ test();
IF( st->hFdCngEnc != NULL && NE_16( st->element_mode, IVAS_CPE_MDCT ) && ( ( NE_16( st->hFdCngEnc->hFdCngCom->frameSize, st->L_frame ) ) || ( NE_16( st->hFdCngEnc->hFdCngCom->CngBandwidth, st->input_bwidth ) ) ) )
{
- configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), flag_1 );
+ configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), total_brate_tmp );
}
if ( st->ini_frame == 0 )
@@ -224,6 +222,7 @@ ivas_error pre_proc_ivas_fx(
* IC frames selection
* enforce TC frames in case of switching
*-----------------------------------------------------------------*/
+
test();
test();
test();
@@ -284,7 +283,6 @@ ivas_error pre_proc_ivas_fx(
move16();
}
-
/*---------------------------------------------------------------------*
* Decision matrix (selection of technologies)
*---------------------------------------------------------------------*/
@@ -305,6 +303,7 @@ ivas_error pre_proc_ivas_fx(
/* core selection */
ivas_decision_matrix_enc_fx( st, element_brate, fft_buff_fx, enerBuffer_fx, e_enerBuffer, last_element_mode );
+
test();
test();
if ( EQ_16( st->L_frame, L_FRAME16k ) && ( EQ_16( st->coder_type, VOICED ) || EQ_16( st->coder_type, UNVOICED ) ) ) /* VOICED and UNVOICED are not supported in ACELP@16k */
@@ -396,14 +395,14 @@ ivas_error pre_proc_ivas_fx(
}
}
-
/*-----------------------------------------------------------------*
* Update of ACELP harmonicity counter (used in ACELP transform codebook @32kbps)
*-----------------------------------------------------------------*/
+
test();
test();
test();
- IF( EQ_16( loc_harm, 1 ) && GT_16( cor_map_sum_fx, 50 << 8 ) && EQ_16( st->clas, VOICED_CLAS ) && EQ_16( st->coder_type, GENERIC ) )
+ IF( EQ_16( loc_harm, 1 ) && GT_16( cor_map_sum_fx, 50 << Q8 ) && EQ_16( st->clas, VOICED_CLAS ) && EQ_16( st->coder_type, GENERIC ) )
{
st->last_harm_flag_acelp = add( st->last_harm_flag_acelp, 1 ); /* Q0 */
move16();
@@ -471,15 +470,6 @@ ivas_error pre_proc_ivas_fx(
}
}
- /* channel-aware mode - due to lack of signaling bit, sharpFlag is 1 always in RF mode */
- test();
- test();
- if ( st->rf_mode && ( EQ_16( st->coder_type, VOICED ) || EQ_16( st->coder_type, GENERIC ) ) )
- {
- st->sharpFlag = 1;
- move16();
- }
-
/* TD stereo, secondary channel - due to lack of signaling bits, sharpFlag is always 1 */
test();
IF( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) )
@@ -514,6 +504,7 @@ ivas_error pre_proc_ivas_fx(
/*-----------------------------------------------------------------*
* Compute core-coder buffers at internal sampling rate
*-----------------------------------------------------------------*/
+
IF( st->tcxonly == 0 )
{
sr_core_tmp = INT_FS_16k;
@@ -567,16 +558,15 @@ ivas_error pre_proc_ivas_fx(
move16();
st->exp_buf_wspeech_enc = sub( Q15, Q_old_inp_16k );
move16();
- Word16 Q_inp_12k8 = *Q_new;
- move16();
- Word16 Q_inp_16k = *Q_new;
- move16();
+
IF( !flag_16k_smc )
{
- error = ivas_compute_core_buffers_fx( st, &inp_16k_fx, old_inp_16k_fx, new_inp_resamp16k_fx, input_frame, last_element_mode, sr_core_tmp, ener_fx,
- A_fx, Aw_fx,
- epsP_fx,
- lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, &Q_inp_16k );
+ Word16 Q_inp_12k8 = *Q_new;
+ move16();
+ Word16 Q_inp_16k;
+
+ ivas_compute_core_buffers_fx( st, &inp_16k_fx, old_inp_16k_fx, new_inp_resamp16k_fx, input_frame, last_element_mode, sr_core_tmp, ener_fx, A_fx, Aw_fx, epsP_fx, lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, &Q_inp_16k );
+
IF( GT_16( Q_inp_16k, Q_inp_12k8 ) )
{
Scale_sig( old_inp_16k_fx, L_INP, sub( Q_inp_12k8, Q_inp_16k ) );
@@ -589,11 +579,6 @@ ivas_error pre_proc_ivas_fx(
}
move16();
- IF( error != IVAS_ERR_OK )
- {
- return error;
- }
-
test();
IF( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) )
{
@@ -601,6 +586,7 @@ ivas_error pre_proc_ivas_fx(
move16();
}
}
+
test();
IF( !( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) )
{
@@ -678,15 +664,17 @@ ivas_error pre_proc_ivas_fx(
}
pop_wmops();
- return error;
+ return;
}
+
/*-------------------------------------------------------------------*
* ivas_compute_core_buffers()
*
* Compute core-coder buffers at internal sampling rate
*--------------------------------------------------------------------*/
-ivas_error ivas_compute_core_buffers_fx(
+
+void ivas_compute_core_buffers_fx(
Encoder_State *st, /* i/o: encoder state structure */
Word16 **inp16k_out_fx, /* o : ptr. to inp. signal in the current frame Q_new-1*/
Word16 *old_inp_16k_fx, /* i/o: buffer of old input signal @ 16kHz Q_new-1*/
@@ -700,7 +688,7 @@ ivas_error ivas_compute_core_buffers_fx(
Word32 epsP_fx[M + 1], /* i/o: LP prediction errors Q_r*/
Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/
Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/
- Word16 Q_old_inp_16k,
+ const Word16 Q_old_inp_16k,
Word16 Q_r[2],
Word16 *Q_new )
{
@@ -716,18 +704,14 @@ ivas_error ivas_compute_core_buffers_fx(
Word16 Q_tmp, mem_decim16k_size, size_modified;
Word16 epsP_h[M + 1];
Word16 epsP_l[M + 1];
-
- Word16 headroom = 1, preemp_len = 0, inp_max = 0;
- move16();
- move16();
- move16();
+ Word16 i, shift, Q_min;
+ Word16 preemp_len, inp_max;
Word16 *preemp_start_idx = NULL;
- Word32 sig_out[960], max_32;
- /*Word16 Q_exp, Q_wsp_exp*/;
- set16_fx( new_inp_resamp16k_fx, 0, L_FRAME16k );
- set16_fx( epsP_h, 0, M + 1 );
- set16_fx( epsP_l, 0, M + 1 );
- set16_fx( input_buf_fx, 0, L_FRAME48k * 2 );
+#ifdef FIX_2376_FIX_USAN_PRE_PROC
+ Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k + L_FILT16k], max_32;
+#else
+ Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k /* = max( L_FRAME16k + STEREO_DFT_OVL_16k, L_FRAME16k + L_FILT16k + lMemRecalc_16k ) */], max_32;
+#endif
Copy_Scale_sig( st->input_fx - input_frame, input_buf_fx, input_frame, sub( -1, st->q_old_inp ) );
Copy_Scale_sig( st->input_fx, input_buf_fx + input_frame, input_frame, sub( -1, st->q_inp ) );
@@ -754,9 +738,9 @@ ivas_error ivas_compute_core_buffers_fx(
/*---------------------------------------------------------------*
* Preprocessing at other sampling frequency rate (16/25.6/32kHz)
*----------------------------------------------------------------*/
+
IF( st->tcxonly == 0 )
{
-
L_frame_tmp = L_FRAME16k;
move16();
}
@@ -845,14 +829,14 @@ ivas_error ivas_compute_core_buffers_fx(
Scale_sig( new_inp_16k_fx - lMemRecalc_16k - length_16k, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
}
- size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */
- Scale_sig( new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
+ size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_16k_fx - lMemRecalc_16k, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */
+ Scale_sig( new_inp_16k_fx - lMemRecalc_16k, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
Copy( st->mem_decim16k_fx, mem_decim16k_dummy_fx, 2 * L_FILT_MAX );
IF( lMemRecalc > 0 )
{
- size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc + input_frame, lMemRecalc, input_Fs, new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */
- Scale_sig( new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
+ size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc + input_frame, lMemRecalc, input_Fs, new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - lMemRecalc_16k, sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */
+ Scale_sig( new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - lMemRecalc_16k, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */
}
set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX );
@@ -936,22 +920,15 @@ ivas_error ivas_compute_core_buffers_fx(
move16();
}
- test();
- test();
-
*Q_new = 0;
move16();
- set32_fx( sig_out, 0, 960 );
- test();
- test();
- if ( ( ( st->bwidth == NB ) || ( st->max_bwidth == NB ) ) && ( GT_32( st->input_Fs, 8000 ) ) )
- {
- headroom = add( headroom, 1 );
- }
- test();
+
test();
- IF( GT_32( input_Fs, 8000 ) && EQ_32( sr_core, INT_FS_16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) )
+ IF( EQ_32( sr_core, INT_FS_16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) )
{
+ preemp_len = 0;
+ move16();
+
IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
{
Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, st->inp_16k_mem_stereo_sw_fx, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); /* update for TD/DFT stereo switching Q(-1) */
@@ -965,13 +942,11 @@ ivas_error ivas_compute_core_buffers_fx(
{
Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k, st->buf_speech_enc + L_FRAME16k - STEREO_DFT_OVL_16k, L_FRAME16k + STEREO_DFT_OVL_16k ); /* Q(-1) */
}
- // PREEMPH_FX(new_inp_16k_fx - STEREO_DFT_OVL_16k, PREEMPH_FAC_16k, L_FRAME16k, &(st->mem_preemph16k_fx));
- PREEMPH_32FX( new_inp_16k_fx - STEREO_DFT_OVL_16k, sig_out, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */
+ preemph_copy_32fx2( new_inp_16k_fx - STEREO_DFT_OVL_16k, sig_out, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */
tmp_fx = st->mem_preemph16k_fx;
move16();
- // PREEMPH_FX(new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k, &tmp_fx);
- PREEMPH_32FX( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, sig_out + L_FRAME16k, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k, &tmp_fx ); /* Q(-1) */
+ preemph_copy_32fx2( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, sig_out + L_FRAME16k, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k, &tmp_fx ); /* Q(-1) */
preemp_start_idx = new_inp_16k_fx - STEREO_DFT_OVL_16k;
move16();
preemp_len = STEREO_DFT_OVL_16k + L_FRAME16k;
@@ -983,9 +958,8 @@ ivas_error ivas_compute_core_buffers_fx(
{
st->mem_preemph16k_fx = st->mem_preemph16k_DFT_fx;
move16();
- Copy( st->inp_16k_mem_stereo_sw_fx, new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); /* Q(-1) */
- // PREEMPH_FX(new_inp_16k_fx - L_MEM_RECALC_16K - (STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k), PREEMPH_FAC_16k, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, &st->mem_preemph16k_fx);
- PREEMPH_32FX( new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), sig_out, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, &st->mem_preemph16k_fx ); /* Q(-1) */
+ Copy( st->inp_16k_mem_stereo_sw_fx, new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); /* Q(-1) */
+ preemph_copy_32fx2( new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), sig_out, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, &st->mem_preemph16k_fx ); /* Q(-1) */
preemp_start_idx = new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k );
move16();
preemp_len = STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k;
@@ -1001,8 +975,7 @@ ivas_error ivas_compute_core_buffers_fx(
Word16 length_16k = NS2SA( INT_FS_16k, L_MEM_RECALC_SCH_NS - DELAY_FIR_RESAMPL_NS );
move16();
- // PREEMPH_FX(new_inp_16k_fx - lMemRecalc_16k - length_16k, PREEMPH_FAC, length_16k, &st->mem_preemph16k_fx);
- PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k - length_16k, sig_out, PREEMPH_FAC, length_16k, &st->mem_preemph16k_fx ); /* Q(-1) */
+ preemph_copy_32fx2( new_inp_16k_fx - lMemRecalc_16k - length_16k, sig_out, PREEMPH_FAC, length_16k, &st->mem_preemph16k_fx ); /* Q(-1) */
preemp_start_idx = new_inp_16k_fx - lMemRecalc_16k - length_16k;
preemp_len = length_16k;
move16();
@@ -1012,12 +985,10 @@ ivas_error ivas_compute_core_buffers_fx(
{
Copy( new_inp_16k_fx - lMemRecalc_16k, st->buf_speech_enc + sub( L_FRAME16k - L_FILT16k, lMemRecalc_16k ), add( lMemRecalc_16k, L_FRAME16k + L_FILT16k ) ); /* Q_new - 1 */
}
- // PREEMPH_FX(new_inp_16k_fx - lMemRecalc_16k, PREEMPH_FAC_16k, L_FRAME16k, &(st->mem_preemph16k_fx));
- PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k, sig_out + preemp_len, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */
+ preemph_copy_32fx2( new_inp_16k_fx - lMemRecalc_16k, sig_out + preemp_len, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */
tmp_fx = st->mem_preemph16k_fx;
move16();
- // PREEMPH_FX(new_inp_16k_fx - lMemRecalc_16k + L_FRAME16k, PREEMPH_FAC_16k, lMemRecalc_16k + L_FILT16k, &tmp_fx);
- PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k + L_FRAME16k, sig_out + preemp_len + L_FRAME16k, PREEMPH_FAC_16k, lMemRecalc_16k + L_FILT16k, &tmp_fx ); /* Q(-1) */
+ preemph_copy_32fx2( new_inp_16k_fx - lMemRecalc_16k + L_FRAME16k, sig_out + preemp_len + L_FRAME16k, PREEMPH_FAC_16k, lMemRecalc_16k + L_FILT16k, &tmp_fx ); /* Q(-1) */
IF( preemp_start_idx && preemp_len )
{
preemp_len = add( preemp_len, add( L_FRAME16k + L_FILT16k, lMemRecalc_16k ) );
@@ -1032,12 +1003,10 @@ ivas_error ivas_compute_core_buffers_fx(
}
ELSE IF( EQ_16( element_mode, IVAS_SCE ) )
{
- // PREEMPH_FX(new_inp_16k_fx, PREEMPH_FAC_16k, L_FRAME16k, &(st->mem_preemph16k_fx));
- PREEMPH_32FX( new_inp_16k_fx, sig_out, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */
+ preemph_copy_32fx2( new_inp_16k_fx, sig_out, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */
tmp_fx = st->mem_preemph16k_fx;
move16();
- // PREEMPH_FX(new_inp_16k_fx + L_FRAME16k, PREEMPH_FAC_16k, L_FILT16k, &tmp_fx);
- PREEMPH_32FX( new_inp_16k_fx + L_FRAME16k, sig_out + L_FRAME16k, PREEMPH_FAC_16k, L_FILT16k, &tmp_fx ); /* Q(-1) */
+ preemph_copy_32fx2( new_inp_16k_fx + L_FRAME16k, sig_out + L_FRAME16k, PREEMPH_FAC_16k, L_FILT16k, &tmp_fx ); /* Q(-1) */
preemp_start_idx = new_inp_16k_fx;
preemp_len = L_FRAME16k + L_FILT16k;
move16();
@@ -1045,8 +1014,7 @@ ivas_error ivas_compute_core_buffers_fx(
maximum_abs_32_fx( sig_out, preemp_len, &max_32 );
inp_max = s_max( extract_h( max_32 ), 1 );
- Word16 shift = sub( norm_s( inp_max ), headroom );
- Word16 Q_min, i;
+ shift = sub( norm_s( inp_max ), 1 /* headroom */ );
shift = s_max( shift, 0 );
shift = s_min( shift, Q_MAX );
minimum_fx( st->Q_max_16k, L_Q_MEM, &Q_min );
@@ -1071,19 +1039,9 @@ ivas_error ivas_compute_core_buffers_fx(
Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, add( *Q_new, 1 ) );
Scale_sig( old_inp_16k_fx, (Word16) ( preemp_start_idx - old_inp_16k_fx ), *Q_new );
}
- ELSE IF( GT_32( input_Fs, 8000 ) ) /* keep memory up-to-date in case of bitrate switching */
+ ELSE /* keep memory up-to-date in case of bitrate switching */
{
- IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
- {
- st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - STEREO_DFT_OVL_16k - 1]; /* Q_new - 1 */
- move16();
- }
- ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) )
- {
- st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - lMemRecalc_16k - 1]; /* Q_new - 1 */
- move16();
- }
- ELSE IF( EQ_16( element_mode, IVAS_CPE_MDCT ) )
+ IF( EQ_16( element_mode, IVAS_CPE_MDCT ) )
{
st->mem_preemph16k_fx = 0;
move16();
@@ -1106,7 +1064,6 @@ ivas_error ivas_compute_core_buffers_fx(
IF( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) )
{
/* update signal buffers */
- Word16 shift;
shift = negate( *Q_new );
move16();
IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
@@ -1142,11 +1099,21 @@ ivas_error ivas_compute_core_buffers_fx(
analy_lp_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, -1, Q_r );
}
+ FOR( i = 0; i < M + 1; i++ )
+ {
+ epsP_fx[i] = L_Comp( epsP_h[i], epsP_l[i] );
+ move32();
+ }
+
/*--------------------------------------------------------------*
* Compute Weighted Input
*---------------------------------------------------------------*/
+#ifndef FIX_2363_FIND_WSP
ivas_find_wsp_fx( L_FRAME16k, L_SUBFR, NB_SUBFR16k, A_fx, Aw_fx, st->speech_enc_pe, PREEMPH_FAC_16k, st->wspeech_enc, &st->mem_wsp_enc, st->gamma, L_LOOK_16k );
+#else
+ find_wsp_fx( A_fx, st->speech_enc_pe, st->wspeech_enc, &st->mem_wsp_enc, PREEMPH_FAC_16k, L_FRAME16k, L_LOOK_16k, L_SUBFR, Aw_fx, st->gamma, NB_SUBFR16k );
+#endif
}
/*-----------------------------------------------------------------*
@@ -1156,20 +1123,19 @@ ivas_error ivas_compute_core_buffers_fx(
/* update old input signal @16kHz buffer */
test();
test();
- test();
IF( ( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) || EQ_16( element_mode, IVAS_CPE_MDCT ) )
{
set16_fx( st->old_inp_16k_fx, 0, L_INP_MEM );
st->exp_old_inp_16k = 0;
move16();
}
- ELSE IF( GT_32( input_Fs, 8000 ) && EQ_32( sr_core, INT_FS_16k ) )
+ ELSE IF( EQ_32( sr_core, INT_FS_16k ) )
{
Copy( &old_inp_16k_fx[L_frame_tmp], st->old_inp_16k_fx, L_INP_MEM );
st->exp_old_inp_16k = sub( Q16, *Q_new ); //(*Q_new - 1)
move16();
}
- ELSE IF( GT_32( input_Fs, 8000 ) )
+ ELSE
{
lerp( st->old_inp_12k8_fx + L_INP_MEM - L_INP_MEM * 4 / 5, st->old_inp_16k_fx, L_INP_MEM, L_INP_MEM * 4 / 5 );
Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( -1 /* Q st->old_inp_16k_fx = -1 */, sub( 15, st->exp_old_inp_12k8 ) ) );
@@ -1186,15 +1152,6 @@ ivas_error ivas_compute_core_buffers_fx(
{
Copy( new_inp_resamp16k_fx, new_inp_resamp16k_out_fx, L_FRAME16k );
}
- test();
- IF( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) )
- {
- FOR( Word16 i = 0; i < M + 1; i++ )
- {
- epsP_fx[i] = L_Comp( epsP_h[i], epsP_l[i] );
- move32();
- }
- }
- return IVAS_ERR_OK;
+ return;
}
diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c
index 2efae00e2752c4c7100add8f563723bd078a33e3..9c845eb400fa2b3c81e21df8ec80810198f2917a 100644
--- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c
+++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -236,8 +236,8 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp, shift );
move16();
q_com_sce = s_min( q_com_sce, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp );
- shift = sub( getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 );
- scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */
+ shift = sub( getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, input_frame ), Q1 );
+ scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, input_frame, shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */
st_ivas->hSCE[k]->hCoreCoder[0]->q_inp = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_inp, shift );
move16();
q_com_sce = s_min( q_com_sce, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp );
@@ -247,8 +247,8 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32 = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32, shift );
move16();
q_com_sce32 = s_min( q_com_sce32, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32 );
- shift = sub( getScaleFactor32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 );
- scale_sig32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */
+ shift = sub( getScaleFactor32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, input_frame ), Q1 );
+ scale_sig32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, input_frame, shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */
st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32 = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32, shift );
move16();
q_com_sce32 = s_min( q_com_sce32, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32 );
@@ -267,8 +267,8 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp, shift );
move16();
q_com_cpe = s_min( q_com_cpe, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp );
- shift = sub( getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 );
- scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */
+ shift = sub( getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, input_frame ), Q1 );
+ scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, input_frame, shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp, shift );
move16();
q_com_cpe = s_min( q_com_cpe, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp );
@@ -278,8 +278,8 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32, shift );
move16();
q_com_cpe32 = s_min( q_com_cpe32, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 );
- shift = sub( getScaleFactor32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 );
- scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */
+ shift = sub( getScaleFactor32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, input_frame ), Q1 );
+ scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, input_frame, shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32, shift );
move16();
q_com_cpe32 = s_min( q_com_cpe32, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 );
@@ -294,10 +294,10 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame, sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp ) ); /* q_com */
st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp = q_com;
move16();
- scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ) ); /* q_com */
+ scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, input_frame, sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ) ); /* q_com */
st_ivas->hSCE[k]->hCoreCoder[0]->q_inp = q_com;
move16();
- Copy_Scale_sig_16_32_DEPREC( st_ivas->hSCE[k]->hCoreCoder[0]->input_buff_fx, st_ivas->hSCE[k]->hCoreCoder[0]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 ); /* Q6 + q_com */
+ Copy_Scale_sig_16_32_DEPREC( st_ivas->hSCE[k]->hCoreCoder[0]->input_buff_fx, st_ivas->hSCE[k]->hCoreCoder[0]->input_buff32_fx, shl( input_frame, 1 ), Q6 ); /* Q6 + q_com */
st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32 = add( Q6, q_com );
st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32 = add( Q6, q_com );
move16();
@@ -314,10 +314,10 @@ ivas_error ivas_corecoder_enc_reconfig_fx(
scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp ) ); /* q_com */
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp = q_com;
move16();
- scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ) ); /* q_com */
+ scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, input_frame, sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ) ); /* q_com */
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp = q_com;
move16();
- Copy_Scale_sig_16_32_DEPREC( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff_fx, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 ); /* Q6 + q_com */
+ Copy_Scale_sig_16_32_DEPREC( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff_fx, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, shl( input_frame, 1 ), Q6 ); /* Q6 + q_com */
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 = add( Q6, q_com );
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 = add( Q6, q_com );
move16();
diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c
index a610d0dfce90d3badb8540dbb3b50a3e8cf3efd9..be1caae8320de6582080ec6b5cebfd1181d5ba63 100644
--- a/lib_enc/ivas_cpe_enc_fx.c
+++ b/lib_enc/ivas_cpe_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -127,12 +127,11 @@ ivas_error ivas_cpe_enc_fx(
Word16 old_wsp_fx[CPE_CHANNELS][L_WSP];
Word16 e_old_wsp[CPE_CHANNELS], q_old_wsp;
Word16 Q_new[CPE_CHANNELS] = { 0 };
-#ifdef FIX_1461_CNG_BW_SWITCHING
Word16 NFFT_inner;
-#endif
move16();
move16();
- Word16 q_com, shift, q_min, gb;
+ Word16 input_frame_2;
+ Word16 i, j, q_com, shift, q_min, gb;
error = IVAS_ERR_OK;
move32();
@@ -158,6 +157,7 @@ ivas_error ivas_cpe_enc_fx(
* Initialization - general
*-----------------------------------------------------------------*/
+ input_frame_2 = shl( input_frame, 1 );
set16_fx( q_re_im_buf, 0, CPE_CHANNELS );
tdm_SM_or_LRTD_Pri = 0;
@@ -180,7 +180,7 @@ ivas_error ivas_cpe_enc_fx(
set16_fx( voicing_fr_fx[0], 0, NB_SUBFR );
set16_fx( voicing_fr_fx[1], 0, NB_SUBFR );
- FOR( Word16 i = 0; i < CPE_CHANNELS; i++ )
+ FOR( i = 0; i < CPE_CHANNELS; i++ )
{
set16_zero_fx( fft_buff_fx[i], 2 * L_FFT );
set16_zero_fx( old_inp_16k_16fx[i], L_INP );
@@ -254,9 +254,9 @@ ivas_error ivas_cpe_enc_fx(
move16();
}
- FOR( Word16 i = 0; i < CPE_CHANNELS; i++ )
+ FOR( i = 0; i < CPE_CHANNELS; i++ )
{
- FOR( Word16 j = 0; j < CLDFB_NO_COL_MAX; j++ )
+ FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ )
{
set_zero_fx( realBuffer_fx[i][j], CLDFB_NO_CHANNELS_MAX );
set_zero_fx( imagBuffer_fx[i][j], CLDFB_NO_CHANNELS_MAX );
@@ -336,6 +336,12 @@ ivas_error ivas_cpe_enc_fx(
Word16 q_band_energies_LR;
Word16 q_fr_bands[2], q_lf_E[2];
+ q_band_energies_LR = 0;
+ q_lf_E[0] = 0;
+ q_lf_E[1] = 0;
+ move16();
+ move16();
+ move16();
IF( NE_32( ( error = front_vad_fx( hCPE, NULL, hEncoderConfig, &hCPE->hFrontVad[0], st_ivas->hMCT != NULL, input_frame, vad_flag_dtx,
fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, q_lf_E, localVAD_HE_SAD, vad_hover_flag, band_energies_LR_fx,
&q_band_energies_LR, NULL, NULL, NULL, Q_inp, Q_buffer, Q_add, &front_create_flag ) ),
@@ -402,8 +408,8 @@ ivas_error ivas_cpe_enc_fx(
IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
{
gb = find_guarded_bits_fx( sts[0]->encoderLookahead_FB );
- shift = L_norm_arr( sts[1]->old_input_signal32_fx, shl( input_frame, 1 ) );
- shift = s_min( shift, L_norm_arr( sts[0]->old_input_signal32_fx, shl( input_frame, 1 ) ) );
+ shift = L_norm_arr( sts[1]->old_input_signal32_fx, input_frame_2 );
+ shift = s_min( shift, L_norm_arr( sts[0]->old_input_signal32_fx, input_frame_2 ) );
IF( LT_16( shift, gb ) )
{
@@ -429,10 +435,10 @@ ivas_error ivas_cpe_enc_fx(
* Temporal inter-channel alignment, stereo adjustment
*----------------------------------------------------------------*/
- shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) );
+ shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, input_frame_2 ), L_norm_arr( sts[1]->input_buff32_fx, input_frame_2 ) );
q_min = add( sts[0]->q_inp32, sub( shift, find_guarded_bits_fx( input_frame ) ) );
- scale_sig32( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( q_min, sts[1]->q_inp32 ) ); /* q_min */
- scale_sig32( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( q_min, sts[0]->q_inp32 ) ); /* q_min */
+ scale_sig32( sts[1]->input_buff32_fx, input_frame_2, sub( q_min, sts[1]->q_inp32 ) ); /* q_min */
+ scale_sig32( sts[0]->input_buff32_fx, input_frame_2, sub( q_min, sts[0]->q_inp32 ) ); /* q_min */
sts[0]->q_inp32 = sts[1]->q_inp32 = sts[0]->q_old_inp32 = sts[1]->q_old_inp32 = q_min;
move16();
move16();
@@ -441,11 +447,10 @@ ivas_error ivas_cpe_enc_fx(
stereo_tca_enc_fx( hCPE, input_frame );
- shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[0]->q_inp32 ), 16 );
- shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[1]->q_inp32 ), 16 ) );
- Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( add( Q16, shift ), sts[0]->q_inp32 ) ); // shift
- Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( add( Q16, shift ), sts[1]->q_inp32 ) ); // shift
-
+ shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, input_frame_2 ), sts[0]->q_inp32 ), 16 );
+ shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, input_frame_2 ), sts[1]->q_inp32 ), 16 ) );
+ Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, input_frame_2, sub( add( Q16, shift ), sts[0]->q_inp32 ) ); // shift
+ Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, input_frame_2, sub( add( Q16, shift ), sts[1]->q_inp32 ) ); // shift
sts[0]->q_inp = sts[1]->q_inp = sts[0]->q_old_inp = sts[1]->q_old_inp = shift;
move16();
move16();
@@ -602,7 +607,13 @@ ivas_error ivas_cpe_enc_fx(
{
sts[n]->bits_frame_nominal = extract_l( Mpy_32_32_r( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* Q0 */
sts[n]->bits_frame_channel = idiv1616( extract_l( Mpy_32_32_r( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ), n_CoreChannels ); /* Q0 */
- sts[n]->total_brate = L_shl( div_l( hCPE->element_brate, n_CoreChannels ), 1 ); /* Q0 */
+ /* sts[n]->total_brate = hCPE->element_brate / n_CoreChannels; */
+ assert( n_CoreChannels == 1 || n_CoreChannels == 2 );
+ sts[n]->total_brate = hCPE->element_brate;
+ if ( n_CoreChannels == 2 )
+ {
+ sts[n]->total_brate = L_shr( hCPE->element_brate, 1 );
+ }
move32();
move16();
move16();
@@ -709,12 +720,9 @@ ivas_error ivas_cpe_enc_fx(
move16();
/* Determine the energy ratio between the 2 channels */
- tdm_ratio_idx = stereo_tdm_ener_analysis_fx(
- ivas_format,
- hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM ); /* Q0 */
+ tdm_ratio_idx = stereo_tdm_ener_analysis_fx( ivas_format, hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM ); /* Q0 */
/* Compute the downmix signal based on the ratio index */
-
Word16 tdm_SM_flag;
IF( hCPE->hStereoTD->tdm_LRTD_flag == 0 )
{
@@ -836,11 +844,11 @@ ivas_error ivas_cpe_enc_fx(
// Normalise the input buffer from Q15
Word16 input_norm, q_inp; //, common_q, fir_delay_len;
- input_norm = L_norm_arr( sts[0]->input32_fx - input_frame, shl( input_frame, 1 ) );
+ input_norm = L_norm_arr( sts[0]->input32_fx - input_frame, input_frame_2 );
q_inp = sub( add( Q15, input_norm ), 16 );
// Rescale the old input, input and FIR delay section of input buffer
- Copy_Scale_sig32_16( sts[0]->input32_fx - input_frame, sts[0]->input_fx - input_frame, shl( input_frame, 1 ), sub( add( Q16, q_inp ), Q15 ) ); // Q15 -> q_inp
+ Copy_Scale_sig32_16( sts[0]->input32_fx - input_frame, sts[0]->input_fx - input_frame, input_frame_2, sub( add( Q16, q_inp ), Q15 ) ); // Q15 -> q_inp
// Update the Q-factors
sts[0]->q_inp = q_inp;
@@ -912,23 +920,16 @@ ivas_error ivas_cpe_enc_fx(
{
front_vad_flag = 0;
}
+ move16();
+
+ pre_proc_front_ivas_fx( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8_16fx[n], old_inp_16k_16fx[n],
+ &ener_fx[n], &relE_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], &vad_hover_flag[n], &attack_flag[n],
+ realBuffer_fx[n], imagBuffer_fx[n], &q_re_im_buf[n], old_wsp_fx[n], &q_old_wsp, pitch_fr_fx[n], voicing_fr_fx[n], &loc_harm[n], &cor_map_sum_fx[n], &vad_flag_dtx[n], enerBuffer_fx[n], &enerBuffer_fx_exp[n],
+ fft_buff_fx[n], &fft_buff_fx_q[n], A_fx[0], lsp_new_fx[0], currFlatness_fx[n], tdm_ratio_idx, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, q_lf_E[n], localVAD_HE_SAD,
+ band_energies_LR_fx, q_band_energies_LR, 0, front_vad_flag, 0, 0, ivas_format, st_ivas->hMCT != NULL, st_ivas->hEncoderConfig->last_ivas_total_brate, ivas_total_brate, &Q_new[n] );
- error = pre_proc_front_ivas_fx( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8_16fx[n], old_inp_16k_16fx[n],
- &ener_fx[n], &relE_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], &vad_hover_flag[n], &attack_flag[n],
- realBuffer_fx[n], imagBuffer_fx[n], &q_re_im_buf[n], old_wsp_fx[n], &q_old_wsp, pitch_fr_fx[n], voicing_fr_fx[n], &loc_harm[n], &cor_map_sum_fx[n], &vad_flag_dtx[n], enerBuffer_fx[n], &enerBuffer_fx_exp[n],
- fft_buff_fx[n], &fft_buff_fx_q[n], A_fx[0], lsp_new_fx[0], currFlatness_fx[n], tdm_ratio_idx, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, q_lf_E[n], localVAD_HE_SAD,
- band_energies_LR_fx, q_band_energies_LR, 0, front_vad_flag, 0, 0, ivas_format, st_ivas->hMCT != NULL, st_ivas->hEncoderConfig->last_ivas_total_brate, ivas_total_brate, &Q_new[n]
-#ifdef DEBUG_MODE_INFO
- ,
- ( st_ivas->nSCE + ( cpe_id * CPE_CHANNELS ) + n )
-#endif
- );
e_old_wsp[n] = sub( Q15, q_old_wsp );
move16();
- IF( error != IVAS_ERR_OK )
- {
- return error;
- }
}
/*making Q common*/
@@ -1096,7 +1097,7 @@ ivas_error ivas_cpe_enc_fx(
IF( ( NE_16( hCPE->element_mode, IVAS_CPE_DFT ) && NE_16( hCPE->element_mode, IVAS_CPE_TD ) ) || n == 0 ) /* modify coder_type of primary channel */
{
/* limit coder_type depending on the bitrate */
- coder_type_modif_ivas_fx( sts[n], relE_fx[n] );
+ coder_type_modif_fx( sts[n], relE_fx[n] );
}
}
@@ -1124,12 +1125,10 @@ ivas_error ivas_cpe_enc_fx(
IF( EQ_32( sts[0]->core_brate, SID_2k40 ) || sts[0]->core_brate == FRAME_NO_DATA )
{
/* Reconfigure DFT Stereo for inactive frames */
-#ifdef FIX_1461_CNG_BW_SWITCHING
/* -- nbands may need to be updated here in case the bandwidth was changed due to inactive frames */
NFFT_inner = shl( inner_frame_tbl[sts[0]->bwidth], 1 );
hCPE->hStereoDft->nbands = stereo_dft_band_config_fx( hCPE->hStereoDft->band_limits, hCPE->hStereoDft->hConfig->band_res, NFFT_inner, ENC );
move16();
-#endif
IF( EQ_32( sts[0]->core_brate, SID_2k40 ) )
{
stereo_dft_config_fx( hConfigDft, IVAS_SID_5k2, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
@@ -1190,7 +1189,7 @@ ivas_error ivas_cpe_enc_fx(
}
}
- FOR( Word16 i = 0; i < CPE_CHANNELS; i++ )
+ FOR( i = 0; i < CPE_CHANNELS; i++ )
{
Copy_Scale_sig_16_32_no_sat( old_inp_12k8_16fx[i], old_inp_12k8_fx[i], L_INP_12k8, Q16 ); // Q(-1) -> Q15
}
diff --git a/lib_enc/ivas_decision_matrix_enc_fx.c b/lib_enc/ivas_decision_matrix_enc_fx.c
index 17704e9bf604df17326cac07512bd874ce7012cb..79448bd19be0fd79461feb378067270014c7b822 100644
--- a/lib_enc/ivas_decision_matrix_enc_fx.c
+++ b/lib_enc/ivas_decision_matrix_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c
index e9fd937238db6cc1919d3cc0c01842807d3f0243..16934822576d785bb3402878939bafc2b3400403 100644
--- a/lib_enc/ivas_dirac_enc_fx.c
+++ b/lib_enc/ivas_dirac_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -231,7 +231,7 @@ ivas_error ivas_dirac_enc_reconfigure(
}
ELSE
{
- MVR2R_WORD16( DirAC_block_grouping_5ms_MDFT, hDirAC->block_grouping, MAX_PARAM_SPATIAL_SUBFRAMES + 1 );
+ Copy( DirAC_block_grouping_5ms_MDFT, hDirAC->block_grouping, MAX_PARAM_SPATIAL_SUBFRAMES + 1 );
}
return error;
@@ -1574,9 +1574,9 @@ void computeDiffuseness_mdft_fx(
set_zero_fx( intensity_slow, i_mult( DIRAC_NUM_DIMS, MASA_FREQUENCY_BANDS ) );
set16_fx( intensity_slow_e, 0, i_mult( DIRAC_NUM_DIMS, MASA_FREQUENCY_BANDS ) );
set_zero_fx( intensity_slow_abs, MASA_FREQUENCY_BANDS );
- set16_fx( intensity_slow_abs_e, 0, no_col_avg_diff );
+ set16_fx( intensity_slow_abs_e, 0, MASA_FREQUENCY_BANDS );
set_zero_fx( energy_slow, MASA_FREQUENCY_BANDS );
- set16_fx( energy_slow_e, 0, no_col_avg_diff );
+ set16_fx( energy_slow_e, 0, MASA_FREQUENCY_BANDS );
FOR( i = 0; i < no_col_avg_diff; ++i )
{
diff --git a/lib_enc/ivas_enc_cov_handler_fx.c b/lib_enc/ivas_enc_cov_handler_fx.c
index 32360fd41724fee407902034120f7dc671a4cab8..2d652a68329b8a1aee4036f44c05b92b2f8cee9b 100644
--- a/lib_enc/ivas_enc_cov_handler_fx.c
+++ b/lib_enc/ivas_enc_cov_handler_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_enc_fx.c b/lib_enc/ivas_enc_fx.c
index b206d8f8d338cb99a094ae8838200b6fc205df60..cde2237841f4cff1954f3cbf5a36ce257ca7af3c 100644
--- a/lib_enc/ivas_enc_fx.c
+++ b/lib_enc/ivas_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -137,7 +137,7 @@ ivas_error ivas_enc_fx(
}
ELSE IF( EQ_32( ivas_format, SBA_ISM_FORMAT ) )
{
- IF( ( error = ivas_osba_enc_reconfig( st_ivas ) ) != IVAS_ERR_OK )
+ IF( ( error = ivas_osba_enc_reconfig_fx( st_ivas ) ) != IVAS_ERR_OK )
{
return error;
}
diff --git a/lib_enc/ivas_entropy_coder_fx.c b/lib_enc/ivas_entropy_coder_fx.c
index ddd4df2de366405d8c491885750d5f06f600ea17..eb4b00cf8e52b405193c9ffed143d7efd1ec32d7 100644
--- a/lib_enc/ivas_entropy_coder_fx.c
+++ b/lib_enc/ivas_entropy_coder_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c
index 6f1f7f5bfe08574448462ad21f9bb0e2a437de20..b4447f2a16260b259a7f4fa5664e73dc8ae754f8 100644
--- a/lib_enc/ivas_front_vad_fx.c
+++ b/lib_enc/ivas_front_vad_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -221,7 +221,7 @@ ivas_error front_vad_fx(
/* Move previous frame 12k8 signal */
- MVR2R_WORD16( hFrontVad->buffer_12k8_fx + L_FFT, hFrontVad->buffer_12k8_fx, L_FFT / 2 );
+ Copy( hFrontVad->buffer_12k8_fx + L_FFT, hFrontVad->buffer_12k8_fx, L_FFT / 2 );
/* Resample to 12k8 */
modify_Fs_ivas_fx( sts[n]->input_fx, input_frame, sts[0]->input_Fs, hFrontVad->buffer_12k8_fx + L_FFT / 2, INT_FS_12k8, hFrontVad->mem_decim_fx, ( sts[0]->max_bwidth == NB ), &Qband, &mem_decim_size );
@@ -232,7 +232,7 @@ ivas_error front_vad_fx(
hFrontVad->q_mem_preemph_fx = add( Q_inp, Qband );
move16();
- PREEMPH_FX( hFrontVad->buffer_12k8_fx + L_FFT / 2, PREEMPH_FAC, L_FRAME, &hFrontVad->mem_preemph_fx );
+ preemph_fx( hFrontVad->buffer_12k8_fx + L_FFT / 2, PREEMPH_FAC, L_FRAME, &hFrontVad->mem_preemph_fx );
Q_new = s_min( add( add( Q_inp, Qband ), Q_add ), Q_buffer[n] );
scale_sig( hFrontVad->buffer_12k8_fx, L_FFT / 2, sub( Q_new, Q_buffer[n] ) ); /* Q_new */
@@ -286,7 +286,8 @@ ivas_error front_vad_fx(
sts[1]->last_coder_type = sts[0]->last_coder_type; /* Q0 */
move16();
}
- vad_flag_dtx[n] = ivas_dtx_hangover_addition_fx( sts[n], hFrontVad->hVAD->vad_flag, sub( hFrontVad->lp_speech_fx, hFrontVad->lp_noise_fx ), 0 /* <- no cldfb addition */, &vad_hover_flag[n], hFrontVad->hVAD, hFrontVad->hNoiseEst, &hFrontVads[n]->rem_dtx_ho ); /* Q0 */
+
+ vad_flag_dtx[n] = dtx_hangover_addition_fx( sts[n], hFrontVad->hVAD->vad_flag, sub( hFrontVad->lp_speech_fx, hFrontVad->lp_noise_fx ), 0 /* <- no cldfb addition */, &vad_hover_flag[n], hFrontVad->hVAD, hFrontVad->hNoiseEst, &hFrontVads[n]->rem_dtx_ho ); /* Q0 */
move16();
if ( EQ_16( n_chan, 1 ) )
@@ -339,13 +340,12 @@ ivas_error front_vad_fx(
IF( PS_out_fx != NULL )
{
- MVR2R_WORD32( PS_fx, PS_out_fx, L_FRAME / 2 );
+ Copy32( PS_fx, PS_out_fx, L_FRAME / 2 );
}
IF( Bin_E_out_fx != NULL )
{
-
- MVR2R_WORD16( lgBin_E_fx, Bin_E_out_fx, L_FRAME / 2 );
+ Copy( lgBin_E_fx, Bin_E_out_fx, L_FRAME / 2 );
}
pop_wmops();
@@ -528,7 +528,7 @@ ivas_error front_vad_spar_fx(
inp_12k8_fx = hFrontVad->buffer_12k8_fx;
- MVR2R_WORD16( st->old_wsp_fx, old_wsp_fx, L_WSP_MEM );
+ Copy( st->old_wsp_fx, old_wsp_fx, L_WSP_MEM );
wsp_fx = old_wsp_fx + L_WSP_MEM;
st->core_brate = -1; /* updated in dtx() */
@@ -600,7 +600,7 @@ ivas_error front_vad_spar_fx(
corr_shift_fx = correlation_shift_fx( extract_h( hFrontVad->hNoiseEst->totalNoise_32fx ) ); /* Q15 */
- dtx_ivas_fx( st, hEncoderConfig->last_ivas_total_brate, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 );
+ dtx_fx( st, hEncoderConfig->last_ivas_total_brate, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 );
/* linear prediction analysis */
alw_pitch_lag_12k8[0] = st->old_pitch_la; /* Q0 */
@@ -631,12 +631,15 @@ ivas_error front_vad_spar_fx(
}
relE_fx = sub( Etot_fx[0], extract_h( st->lp_speech_32fx ) );
- Scale_sig( A_fx, ( L_FRAME / L_SUBFR ) * ( M + 1 ), -2 ); // Q12
-
st->mem_wsp_fx = (Word16) shl_sat( st->mem_wsp_fx, Q_inp_12k8 - st->mem_wsp_q ); /* Q_inp_12k8 */
st->mem_wsp_q = Q_inp_12k8;
move16();
+
+#ifndef FIX_2363_FIND_WSP
ivas_find_wsp_fx( L_FRAME, L_SUBFR, NB_SUBFR, A_fx, Aw_fx, inp_12k8_fx, TILT_FAC_FX, wsp_fx, &st->mem_wsp_fx, GAMMA1, L_LOOK_12k8 );
+#else
+ find_wsp_fx( A_fx, inp_12k8_fx, wsp_fx, &st->mem_wsp_fx, TILT_FAC_FX, L_FRAME, L_LOOK_12k8, L_SUBFR, Aw_fx, GAMMA1, NB_SUBFR );
+#endif
IF( st->vad_flag == 0 )
{
@@ -684,7 +687,8 @@ ivas_error front_vad_spar_fx(
st->old_pitch_la = st->pitch[2]; /* Q0 */
move16();
- StableHighPitchDetect_ivas_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, Q_wsp, st->lgBin_E_fx );
+ StableHighPitchDetect_fx( IVAS_SCE /* needs to be other than EVS_MONO */, &flag_spitch, st->pitch, st->voicing_fx, wsp_fx, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx, &st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, Q_wsp, st->lgBin_E_fx );
+
IF( st->hSpMusClas != NULL )
{
Word16 dummy_int;
@@ -699,7 +703,11 @@ ivas_error front_vad_spar_fx(
{
cor_strong_limit = &dummy_int;
}
+#ifndef FIX_2364_HARM_MULT_HARM
loc_harm = multi_harm_fx( st->lgBin_E_fx, hFrontVad->hNoiseEst->old_S_fx, hFrontVad->hNoiseEst->cor_map_fx, &hFrontVad->hNoiseEst->multi_harm_limit_fx, st->total_brate, st->bwidth, cor_strong_limit, &st->hSpMusClas->mean_avr_dyn_fx, &st->hSpMusClas->last_sw_dyn_fx, &cor_map_sum_fx, &dummy_fx, S_map_fx ); /* Q0 */
+#else
+ loc_harm = multi_harm_fx( EVS_MONO, st->lgBin_E_fx, hFrontVad->hNoiseEst->old_S_fx, hFrontVad->hNoiseEst->cor_map_fx, &hFrontVad->hNoiseEst->multi_harm_limit_fx, st->total_brate, st->bwidth, cor_strong_limit, &st->hSpMusClas->mean_avr_dyn_fx, &st->hSpMusClas->last_sw_dyn_fx, &cor_map_sum_fx, &dummy_fx, S_map_fx ); /* Q0 */
+#endif
}
scale = getScaleFactor32( epsP_fx, M + 1 );
@@ -730,8 +738,9 @@ ivas_error front_vad_spar_fx(
lf_E_fx[0], q_lf_E[0], &hFrontVad->hNoiseEst->harm_cor_cnt, extract_h( hFrontVad->hNoiseEst->Etot_l_lp_32fx ), hFrontVad->hNoiseEst->Etot_v_h2_32fx,
&hFrontVad->hNoiseEst->bg_cnt, st->lgBin_E_fx, &sp_floor, S_map_fx, NULL, hFrontVad, hFrontVad->ini_frame );
- MVR2R_WORD16( st->pitch, st->pitch, 3 );
+ Copy( st->pitch, st->pitch, 3 );
vad_param_updt_fx( st, st->pitch[1], corr_shift_fx, corr_shift_fx, A_fx, &hFrontVad, 1 );
+
/* 1st stage speech/music classification (GMM model) */
/* run only to get 'high_lpn_flag' parameter */
SP_MUS_CLAS_HANDLE hSpMusClas = st->hSpMusClas;
diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c
index e4d8b13ee3d71872f758b8aae47d167edecf3ccf..06df36fe5b260a211c6ed3829042b8a9f7ad2669 100644
--- a/lib_enc/ivas_init_enc_fx.c
+++ b/lib_enc/ivas_init_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_ism_dtx_enc_fx.c b/lib_enc/ivas_ism_dtx_enc_fx.c
index 72f362fd709140f94a7bd8d223cdd60484a0b0af..940cf63f8f09e228c326ea80eaa047578dc3596f 100644
--- a/lib_enc/ivas_ism_dtx_enc_fx.c
+++ b/lib_enc/ivas_ism_dtx_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c
index ea509dd1020653f78a9ad5a0835f270b027a92fe..94548ad2f9bfa812196d7d9890ac0cd3febd0396 100644
--- a/lib_enc/ivas_ism_enc_fx.c
+++ b/lib_enc/ivas_ism_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -238,31 +238,19 @@ ivas_error ivas_ism_enc_fx(
/*----------------------------------------------------------------*
* Front Pre-processing
*----------------------------------------------------------------*/
- FOR( i = 0; i < hSCE->hCoreCoder[0]->nb_subfr; i++ )
- {
- Scale_sig( &A_fx[sce_id][0][i * ( M + 1 )], M + 1, sub( norm_s( A_fx[sce_id][0][i * ( M + 1 )] ), 2 ) ); // scaling to Q12
- }
set16_fx( old_wsp_fx[sce_id][0], 0, L_WSP );
q_old_wsp = Q15;
move16();
Word16 q_fr_bands[2];
- error = pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8_fx[sce_id][0], old_inp_16k_fx[sce_id][0],
- &ener_fx[sce_id][0], &relE_fx[sce_id][0], A_fx[sce_id][0], Aw_fx[sce_id][0], epsP_fx[sce_id][0], &epsP_fx_q[sce_id][0], lsp_new_fx[sce_id][0], lsp_mid_fx[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0],
- realBuffer_fx[sce_id][0], imagBuffer_fx[sce_id][0], &q_re_im_buf[sce_id], old_wsp_fx[sce_id][0], &q_old_wsp, pitch_fr_fx[sce_id][0], voicing_fr_fx[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum_fx[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer_fx[sce_id][0], &enerBuffer_fx_exp[sce_id][0],
- fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[sce_id][0]
-#ifdef DEBUG_MODE_INFO
- ,
- st->id_element
-#endif
- );
+ pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8_fx[sce_id][0], old_inp_16k_fx[sce_id][0],
+ &ener_fx[sce_id][0], &relE_fx[sce_id][0], A_fx[sce_id][0], Aw_fx[sce_id][0], epsP_fx[sce_id][0], &epsP_fx_q[sce_id][0], lsp_new_fx[sce_id][0], lsp_mid_fx[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0],
+ realBuffer_fx[sce_id][0], imagBuffer_fx[sce_id][0], &q_re_im_buf[sce_id], old_wsp_fx[sce_id][0], &q_old_wsp, pitch_fr_fx[sce_id][0], voicing_fr_fx[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum_fx[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer_fx[sce_id][0], &enerBuffer_fx_exp[sce_id][0],
+ fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[sce_id][0] );
+
e_old_wsp[sce_id][0] = sub( Q15, q_old_wsp );
move16();
- IF( error != IVAS_ERR_OK )
- {
- return error;
- }
IF( st_ivas->hEncoderConfig->Opt_DTX_ON )
{
@@ -450,8 +438,7 @@ ivas_error ivas_ism_enc_fx(
}
/* modify the coder_type depending on the total_brate per channel */
- coder_type_modif_ivas_fx( st, relE_fx[sce_id][0] );
-
+ coder_type_modif_fx( st, relE_fx[sce_id][0] );
/*----------------------------------------------------------------*
* Encoder
*----------------------------------------------------------------*/
diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c
index f13b24b63937d3f487eec7619b570f1da159b5cd..f4866c7f3646cc40a7038015354f92b41e4ec313 100644
--- a/lib_enc/ivas_ism_metadata_enc_fx.c
+++ b/lib_enc/ivas_ism_metadata_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -1074,7 +1074,7 @@ static void encode_radius_fx(
nbits_diff_radius = 1;
move16();
}
- ELSE IF( LE_16( ABSVAL( diff ), ISM_MAX_RADIUS_DIFF_IDX ) )
+ ELSE IF( LE_16( abs_s( diff ), ISM_MAX_RADIUS_DIFF_IDX ) )
{
idx_radius = 2; // shl( 1, 1 );
move16();
diff --git a/lib_enc/ivas_ism_param_enc_fx.c b/lib_enc/ivas_ism_param_enc_fx.c
index f293131479c0ae019e8123c6fcd5c1e778401481..2d149d030af4f91ae78853ccb0387c4ec7f327ee 100644
--- a/lib_enc/ivas_ism_param_enc_fx.c
+++ b/lib_enc/ivas_ism_param_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -292,11 +292,7 @@ void ivas_param_ism_stereo_dmx_fx(
{
tmp = L_add( tmp, 2 * EVS_PI_FX );
}
-#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE
cardioid_left[i] = mac_r( L_mult( alpha, 16384 ), sub( ONE_IN_Q15 - 1, alpha ), getCosWord16( extract_l( tmp ) ) ); // Q14
-#else
- cardioid_left[i] = add( shr( alpha, 1 ), mult( sub( ONE_IN_Q15 - 1, alpha ), getCosWord16( extract_l( tmp ) ) ) ); // Q14
-#endif
move16();
IF( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 0 )
@@ -304,11 +300,7 @@ void ivas_param_ism_stereo_dmx_fx(
Word16 last_cardioid_right;
last_cardioid_right = sub( ONE_IN_Q14 /* 1.0f in Q14 */, last_cardioid_left );
/* Smoothing */
-#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE
cardioid_left[i] = mac_r( L_mult( 24576 /* 0.75f in Q15 */, cardioid_left[i] ), 8192 /* 0.25f in Q15 */, last_cardioid_left ); // Q14
-#else
- cardioid_left[i] = add( mult( 24576 /* 0.75f in Q15 */, cardioid_left[i] ), mult( 8192 /* 0.25f in Q15 */, last_cardioid_left ) ); // Q14
-#endif
move16();
Word32 grad_32 = L_mult( sub( cardioid_left[i], last_cardioid_left ), shl( one_by_input_frame, 1 ) /* 2.0f / (float) input_frame*/ ); /* Q14+Q16 = Q30 */ /* for the right cardioid, multiply with -1 */
/* Cardioids sum up to 1 */
diff --git a/lib_enc/ivas_lfe_enc_fx.c b/lib_enc/ivas_lfe_enc_fx.c
index 9d05dbfc4bf3f69c90d3d7ad741df7cbd8a15e68..a76db70a1ce806bf03fb557648bc01d8470a9c86 100644
--- a/lib_enc/ivas_lfe_enc_fx.c
+++ b/lib_enc/ivas_lfe_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -684,11 +684,7 @@ void ivas_lfe_lpf_enc_apply_fx(
const Word16 input_frame /* i : input frame length per channel */
)
{
-#ifdef NONBE_OPT_2239_IVAS_FILTER_PROCESS
ivas_filter_process_fx32( hLfeLpf, data_lfe_ch, input_frame );
-#else
- ivas_filter_process_fx( hLfeLpf, data_lfe_ch, input_frame, (Word16) Q11 );
-#endif
return;
}
diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c
index cb3b6e563b9c9f7e80642f4602afce5f54bd78fc..6bfea1f19540db98ecc8ea5190a0d3f2ba23bd60 100644
--- a/lib_enc/ivas_masa_enc_fx.c
+++ b/lib_enc/ivas_masa_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -1800,33 +1800,37 @@ void ivas_masa_combine_directions_fx(
}
}
- /* Estimate the importance of having two directions instead of one */
- /* Reduced precision of importance_fx intentionally to Q13 to maintatin 0.0001f resolution */
- FOR( i = 0; i < numCodingBands; i++ )
+ IF( GT_16( hMasa->config.numTwoDirBands, 0 ) )
{
- importance_fx[i] = 0;
- move32();
- FOR( j = 0; j < numSf; j++ )
+ /* Estimate the importance of having two directions instead of one */
+ /* Reduced precision of importance_fx intentionally to Q13 to maintatin 0.0001f resolution */
+ FOR( i = 0; i < numCodingBands; i++ )
{
- tempImportance_fx = L_shr( L_add( hMeta->directional_meta[0].energy_ratio_fx[j][i], hMeta->directional_meta[1].energy_ratio_fx[j][i] ), Q30 - Q13 ); // Q13
- tempImportance_fx = L_sub( tempImportance_fx, L_shr( sumVecLen_fx[j][i], sub( sub( Q31, exp_sumVecLen ), Q13 ) ) ); // Q13
- importance_fx[i] = L_add( importance_fx[i], tempImportance_fx ); // Q13
+ importance_fx[i] = 0;
move32();
- }
+ FOR( j = 0; j < numSf; j++ )
+ {
+ tempImportance_fx = L_shr( L_add( hMeta->directional_meta[0].energy_ratio_fx[j][i], hMeta->directional_meta[1].energy_ratio_fx[j][i] ), Q30 - Q13 ); // Q13
+ tempImportance_fx = L_sub( tempImportance_fx, L_shr( sumVecLen_fx[j][i], sub( sub( Q31, exp_sumVecLen ), Q13 ) ) ); // Q13
+ importance_fx[i] = L_add( importance_fx[i], tempImportance_fx ); // Q13
+ move32();
+ }
- IF( NE_16( numSf, 1 ) )
- {
- importance_fx[i] = L_shr( importance_fx[i], 2 ); // Q13
+ IF( NE_16( numSf, 1 ) )
+ {
+ importance_fx[i] = L_shr( importance_fx[i], 2 ); // Q13
+ move32();
+ }
+ importance_fx[i] = Mpy_32_32( importance_fx[i], hMasa->data.importanceWeight_fx[i] ); //(Q13, Q30) -> Q12
move32();
}
- importance_fx[i] = Mpy_32_32( importance_fx[i], hMasa->data.importanceWeight_fx[i] ); //(Q13, Q30) -> Q12
- move32();
+ exp_importance = Q31 - Q12;
+ move16();
+
+ /* Determine bands where to use two directions */
+ find_n_largest_fx( importance_fx, exp_importance, indicesOfLargest, numCodingBands, hMasa->config.numTwoDirBands );
}
- exp_importance = Q31 - Q12;
- move16();
- /* Determine bands where to use two directions */
- find_n_largest_fx( importance_fx, exp_importance, indicesOfLargest, numCodingBands, hMasa->config.numTwoDirBands );
FOR( i = 0; i < numCodingBands; i++ )
{
diff --git a/lib_enc/ivas_mc_param_enc_fx.c b/lib_enc/ivas_mc_param_enc_fx.c
index 0c4073fc0b8f9e746e6a5fdd945f4790aab78098..f17bee69a9b53c0e65ed8094f6cd7a69de915a87 100644
--- a/lib_enc/ivas_mc_param_enc_fx.c
+++ b/lib_enc/ivas_mc_param_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_mc_paramupmix_enc_fx.c b/lib_enc/ivas_mc_paramupmix_enc_fx.c
index 7e9af16a369c5fabc7b4d40a98ab58eafc2021ed..2776799ed37158dfbc44c3ad607f1ef8b46d34a0 100644
--- a/lib_enc/ivas_mc_paramupmix_enc_fx.c
+++ b/lib_enc/ivas_mc_paramupmix_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c
index 98451f773b5b605786f9eb1feaf7ac1d13b898cc..2507d6a0dbd6e1502235a206b44e499180448a4f 100644
--- a/lib_enc/ivas_mcmasa_enc_fx.c
+++ b/lib_enc/ivas_mcmasa_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -69,7 +69,6 @@ static void ivas_mcmasa_dmx_fx(
const Word16 nchan_transport,
const Word16 nchan_inp );
-#ifdef BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST
/* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */
static void compute_cov_mtx_fx(
Word32 sr[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, real, s[ch][freq] (inp_exp) */
@@ -79,16 +78,6 @@ static void compute_cov_mtx_fx(
CovarianceMatrix pCOVls[MASA_FREQUENCY_BANDS], /* o : Output matrix, contains upper part of cov mtx */
Word16 inp_exp, /*Stores exponent for temp*/
Word16 *band_grouping );
-#else
-static void compute_cov_mtx_fx(
- Word32 sr[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, real, s[ch][freq] */
- Word32 si[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, imag, s[ch][freq] */
- const Word16 freq, /* i : Freq to process */
- const Word16 N, /* i : Number of channels */
- CovarianceMatrix *COVls, /* o : Output matrix, contains upper part of cov mtx */
- Word16 inp_exp /*Stores exponent for temp*/
-);
-#endif
static void computeIntensityVector_enc_fx(
const Word16 *band_grouping,
@@ -928,11 +917,7 @@ void ivas_mcmasa_param_est_enc_fx(
Word32 renormalization_factor_diff_fx[MASA_FREQUENCY_BANDS]; // renormalization_factor_diff_e
Word16 renormalization_factor_diff_e[MASA_FREQUENCY_BANDS];
Word32 norm_tmp_fx;
-#ifdef BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST
Word16 mrange[2];
-#else
- Word16 mrange[2], brange[2];
-#endif
Word16 numSubFramesForRatio;
CovarianceMatrix COVls[MASA_FREQUENCY_BANDS];
Word32 absCOVls_fx[MCMASA_MAX_ANA_CHANS][MCMASA_MAX_ANA_CHANS];
@@ -1036,6 +1021,12 @@ void ivas_mcmasa_param_est_enc_fx(
move32();
hMcMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx] = 0;
move32();
+ hMcMasa->direction_vector_e[0][block_m_idx][band_m_idx] = 0;
+ move16();
+ hMcMasa->direction_vector_e[1][block_m_idx][band_m_idx] = 0;
+ move16();
+ hMcMasa->direction_vector_e[2][block_m_idx][band_m_idx] = 0;
+ move16();
}
/* Reset variable */
@@ -1077,7 +1068,6 @@ void ivas_mcmasa_param_est_enc_fx(
}
inp_q = add( inp_q, sf );
-#ifdef BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST
/* Compute covariance matrix */
assert( mrange[1] - mrange[0] == 1 );
@@ -1099,28 +1089,6 @@ void ivas_mcmasa_param_est_enc_fx(
hMasa->data.energy_fx[block_m_idx][i] = BASOP_Util_Add_Mant32Exp( hMasa->data.energy_fx[block_m_idx][i], hMasa->data.energy_e[block_m_idx][i], COVls[i].xr_fx[j][j], COVls[i].xr_e[j][j], &hMasa->data.energy_e[block_m_idx][i] );
}
}
-#else
- /* Compute covariance matrix */
- FOR( i = 0; i < num_freq_bands; i++ )
- {
- brange[0] = hMcMasa->band_grouping[i];
- move16();
- brange[1] = hMcMasa->band_grouping[i + 1];
- move16();
- FOR( j = brange[0]; j < brange[1]; j++ )
- {
- compute_cov_mtx_fx( Chnl_RealBuffer_fx, Chnl_ImagBuffer_fx, j, numAnalysisChannels, &( COVls[i] ), sub( 31, inp_q ) );
- }
-
-
- /* Store energies for guiding metadata encoding */
- FOR( j = 0; j < numAnalysisChannels; j++ )
- {
- move32();
- hMasa->data.energy_fx[block_m_idx][i] = BASOP_Util_Add_Mant32Exp( hMasa->data.energy_fx[block_m_idx][i], hMasa->data.energy_e[block_m_idx][i], COVls[i].xr_fx[j][j], COVls[i].xr_e[j][j], &hMasa->data.energy_e[block_m_idx][i] );
- }
- }
-#endif
IF( !hMcMasa->separateChannelEnabled )
{
@@ -2126,7 +2094,6 @@ static void ivas_mcmasa_dmx_fx(
return;
}
-#ifdef BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST
/* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */
static void compute_cov_mtx_fx(
@@ -2192,55 +2159,6 @@ static void compute_cov_mtx_fx(
}
-#else
-/* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */
-static void compute_cov_mtx_fx(
- Word32 sr[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, real, s[ch][freq] (inp_exp) */
- Word32 si[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, imag, s[ch][freq] (inp_exp) */
- const Word16 freq, /* i : Freq to process */
- const Word16 N, /* i : Number of channels */
- CovarianceMatrix *COVls, /* o : Output matrix, contains upper part of cov mtx */
- Word16 inp_exp /*Stores exponent for temp*/
-)
-{
- Word16 i, j;
- Word64 temp64_1, temp64_2;
- Word16 tmp_16, max_exp;
- Word16 temp_exp = shl( inp_exp, 1 );
- FOR( i = 0; i < N; i++ )
- {
- FOR( j = i; j < N; j++ )
- {
- temp64_1 = W_mac_32_32( W_mult_32_32( sr[i][freq], sr[j][freq] ), si[i][freq], si[j][freq] ); // exp:2*inp_exp
- temp64_2 = W_deposit32_h( COVls->xr_fx[i][j] ); // exp:COVls->xr_e[i][j]
- max_exp = s_max( COVls->xr_e[i][j], temp_exp );
- temp64_2 = W_shl( temp64_2, sub( COVls->xr_e[i][j], max_exp ) ); // exp:max_exp
- temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp ) ); // exp:max_exp
- temp64_1 = W_add( temp64_1, temp64_2 ); // exp:max_exp
- tmp_16 = W_norm( temp64_1 );
-
- COVls->xr_fx[i][j] = W_extract_h( W_shl( temp64_1, tmp_16 ) ); // exp:max_exp-tmp_16
- COVls->xr_e[i][j] = sub( max_exp, tmp_16 );
- move32();
- move16();
-
- temp64_1 = W_sub( W_mult_32_32( si[i][freq], sr[j][freq] ), W_mult_32_32( sr[i][freq], si[j][freq] ) ); // exp :2*inp_exp
- temp64_2 = W_deposit32_h( COVls->xi_fx[i][j] ); // exp:COVls->xi_e[i][j]
- max_exp = s_max( COVls->xi_e[i][j], temp_exp );
- temp64_2 = W_shl( temp64_2, sub( COVls->xi_e[i][j], max_exp ) ); // exp:max_exp
- temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp ) ); // exp:max_exp
- temp64_1 = W_add( temp64_1, temp64_2 ); // exp:max_exp
- tmp_16 = W_norm( temp64_1 );
-
- COVls->xi_fx[i][j] = W_extract_h( W_shl( temp64_1, tmp_16 ) ); // exp:max_exp-tmp_16
- COVls->xi_e[i][j] = sub( max_exp, tmp_16 );
- move32();
- }
- }
- return;
-}
-#endif
-
static void computeIntensityVector_enc_fx(
const Word16 *band_grouping,
Word32 Cldfb_RealBuffer[FOA_CHANNELS][DIRAC_NO_FB_BANDS_MAX], /*inp_q*/
diff --git a/lib_enc/ivas_mct_core_enc_fx.c b/lib_enc/ivas_mct_core_enc_fx.c
index d4fd50dbf1c919f7b55c1deee5c85a602756b8c6..2ab37c67e9adc210497d3394028de3024905a5ce 100644
--- a/lib_enc/ivas_mct_core_enc_fx.c
+++ b/lib_enc/ivas_mct_core_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_mct_enc_fx.c b/lib_enc/ivas_mct_enc_fx.c
index 88e88a865b62de4d5faa6b037977603a83f519d9..091b8c6b28f56579288fe4690ed858b4702897f8 100644
--- a/lib_enc/ivas_mct_enc_fx.c
+++ b/lib_enc/ivas_mct_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -482,9 +482,9 @@ ivas_error ivas_mct_enc_fx(
Copy32( hCPE->hCoreCoder[n]->input32_fx, hCPE->hCoreCoder[n]->old_input_signal32_fx, input_frame );
hCPE->hCoreCoder[n]->q_old_inp32 = hCPE->hCoreCoder[n]->q_inp32;
move16();
- /* common encoder updates */
- updt_enc_common_ivas_fx( hCPE->hCoreCoder[n], Q_new_out[cpe_id][n] );
+ /* common encoder updates */
+ updt_enc_common_fx( hCPE->hCoreCoder[n], Q_new_out[cpe_id][n] );
}
}
diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c
index de906bde1797f3dc1c52b87ad4fcde1c827430c9..84bc74dd98149b30521d9403528b1111879a78bb 100644
--- a/lib_enc/ivas_mct_enc_mct_fx.c
+++ b/lib_enc/ivas_mct_enc_mct_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -88,19 +88,33 @@ void getChannelEnergies_fx(
gb = find_guarded_bits_fx( (Word32) L_subframe );
+#ifndef FIX_2356_GET_CHAN_ENERGIES
sum2_e = st->hTcxEnc->spectrum_e[0];
move16();
+#endif
nrg[ch] = 0;
move32();
+#ifdef FIX_2356_GET_CHAN_ENERGIES
+ nrg_e[ch] = 0; /* if the mantissa is 0, the exponent gets set to sum2_e inside BASOP_Util_Add_Mant32Exp() */
+ move16();
+#endif
+
FOR( n = 0; n < nSubframes; n++ )
{
+#ifdef FIX_2356_GET_CHAN_ENERGIES
+ sum2_e = st->hTcxEnc->spectrum_e[n];
+ move16();
+
+#endif
sum2 = sum2_32_exp_fx( st->hTcxEnc->spectrum_fx[n], L_subframe, &sum2_e, gb ); // 31 - sum2_e
nrg[ch] = BASOP_Util_Add_Mant32Exp( nrg[ch], nrg_e[ch], sum2, sum2_e, &nrg_e[ch] );
move32();
+#ifndef FIX_2356_GET_CHAN_ENERGIES
sum2_e = st->hTcxEnc->spectrum_e[0];
move16();
+#endif
}
nrg[ch] = Sqrt32( nrg[ch], &nrg_e[ch] ); // nrg_e
diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c
index 81d8757e094da671c72d52683107926f204c1ee8..560cd81bd4b542e53725da58e0a8d9c5ecb556d0 100644
--- a/lib_enc/ivas_mdct_core_enc_fx.c
+++ b/lib_enc/ivas_mdct_core_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -2445,14 +2445,13 @@ void ivas_mdct_core_whitening_enc_fx(
}
}
- encode_lpc_avq_ivas_fx( hBstr, num_sns, param_lpc[ch], st->core, st->element_mode );
+ encode_lpc_avq_fx( hBstr, num_sns, param_lpc[ch], st->core, st->element_mode );
st->side_bits_frame_channel = add( st->side_bits_frame_channel, sub( hBstr->nb_bits_tot, nbits_start_sns ) );
move16();
}
}
-
/*update pitch buffer*/
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
@@ -2474,6 +2473,8 @@ void ivas_mdct_core_whitening_enc_fx(
pop_wmops();
return;
}
+
+
void ivas_mdct_quant_coder_fx(
CPE_ENC_HANDLE hCPE, /* i/o: Encoder CPE handle */
Word16 tnsBits[CPE_CHANNELS][NB_DIV], /* i : bits needed for TNS parameters */
diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c
index 49418c8fc35d5c845eb483bae2ff664d3918d409..f49e9ebbc984da60aeb5c08fd0ada843eac7b34a 100644
--- a/lib_enc/ivas_omasa_enc_fx.c
+++ b/lib_enc/ivas_omasa_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -1541,12 +1541,8 @@ static void ivas_omasa_dmx_fx(
{
g1 = interpolator[k];
move16();
- g2 = sub( MAX_WORD16, g1 ); /*q15*/
-#ifdef FIX_2254_IMPROV_COMPLEXITY_BE
+ g2 = sub( MAX_WORD16, g1 ); /*q15*/
data_out[j][k] = L_add( data_out[j][k], Mpy_32_32( L_mac( L_mult( g1, gains[j] ), g2, prev_gains[i][j] ) /*q31*/, data_in[i][k] ) ); /*Qx*/
-#else
- data_out[j][k] = L_add( data_out[j][k], Mpy_32_32( L_add( L_mult( g1, gains[j] ), L_mult( g2, prev_gains[i][j] ) ) /*q31*/, data_in[i][k] ) ); /*Qx*/
-#endif
move32();
}
}
diff --git a/lib_enc/ivas_osba_enc_fx.c b/lib_enc/ivas_osba_enc_fx.c
index 5f0ec331941e39284232c4a1aa8c995c1300634d..1f19fa21d47bec73cb81253e7eedbef5fc3a2dcc 100644
--- a/lib_enc/ivas_osba_enc_fx.c
+++ b/lib_enc/ivas_osba_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -44,6 +44,7 @@
/*-------------------------------------------------------------------------
* Local function prototypes
*------------------------------------------------------------------------*/
+
static void ivas_osba_render_ism_to_sba_fx(
Word32 *data_in_fx[],
Word32 data_out_fx[][L_FRAME48k],
@@ -54,11 +55,13 @@ static void ivas_osba_render_ism_to_sba_fx(
Word32 prev_gains_fx[][MAX_INPUT_CHANNELS],
const Word32 interpolator_fx[L_FRAME48k],
Word16 *Q_data );
+
/*-------------------------------------------------------------------*
* ivas_merge_sba_transports()
*
* Merge SBA transport channels
*-------------------------------------------------------------------*/
+
static void ivas_merge_sba_transports_fx(
Word32 data_in_f1[][L_FRAME48k], // Q_f1
Word32 *data_in_f2[], // Q_f2
@@ -81,13 +84,17 @@ static void ivas_merge_sba_transports_fx(
}
}
*Q_out = sub( Q_f1, 1 );
+
return;
}
+
+
/*--------------------------------------------------------------------------*
* ivas_osba_enc_open()
*
* Allocate and initialize OMASA handle
*--------------------------------------------------------------------------*/
+
ivas_error ivas_osba_enc_open_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
)
@@ -138,11 +145,13 @@ ivas_error ivas_osba_enc_open_fx(
return error;
}
+
/*--------------------------------------------------------------------------*
* ivas_omasa_enc_close()
*
* Close OMASA handle
*--------------------------------------------------------------------------*/
+
void ivas_osba_enc_close_fx(
OSBA_ENC_HANDLE *hOSba /* i/o: encoder OSBA handle */
)
@@ -167,12 +176,14 @@ void ivas_osba_enc_close_fx(
return;
}
+
/*--------------------------------------------------------------------------*
* ivas_osba_enc_reconfig()
*
* oSBA encoder reconfiguration
*--------------------------------------------------------------------------*/
-ivas_error ivas_osba_enc_reconfig(
+
+ivas_error ivas_osba_enc_reconfig_fx(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
)
{
@@ -386,6 +397,8 @@ ivas_error ivas_osba_enc_reconfig(
return error;
}
+
+
/*--------------------------------------------------------------------------*
* ivas_osba_enc()
*
@@ -395,7 +408,7 @@ ivas_error ivas_osba_enc_reconfig(
void ivas_osba_enc_fx(
OSBA_ENC_HANDLE hOSba, /* i/o: OSBA encoder handle */
ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handle */
- Word32 *data_in_fx[], /* i/o: Input / transport audio signals q_data*/
+ Word32 *data_in_fx[], /* i/o: Input / transport audio signals q_data*/
const Word16 input_frame, /* i : Input frame size */
const Word16 nchan_ism, /* i : Number of objects for parameter analysis */
const ISM_MODE ism_mode, /* i : ISM mode */
@@ -414,7 +427,7 @@ void ivas_osba_enc_fx(
/*keep the delay buffer up to date*/
FOR( n = 0; n < nchan_ism; n++ )
{
- MVR2R_WORD32( &data_in_fx[n][input_frame - delay_s], hOSba->input_data_mem_fx[n], delay_s ); // Q_data
+ Copy32( &data_in_fx[n][input_frame - delay_s], hOSba->input_data_mem_fx[n], delay_s ); // Q_data
}
/* Convert ISM to SBA */
diff --git a/lib_enc/ivas_pca_enc_fx.c b/lib_enc/ivas_pca_enc_fx.c
index e9fbfac46c4d20092bfa3b1cd924ade1f8f39f4a..7228d134e5157f78944584fe048128d57b06f8dc 100644
--- a/lib_enc/ivas_pca_enc_fx.c
+++ b/lib_enc/ivas_pca_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c
index 4753e5276f51f34644e69b2c03248b5854abab5e..7bc4560cfe9bdd4a19f62435dd67921c9bd27a32 100644
--- a/lib_enc/ivas_qmetadata_enc_fx.c
+++ b/lib_enc/ivas_qmetadata_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_qspherical_enc_fx.c b/lib_enc/ivas_qspherical_enc_fx.c
index 09d61c6102e2c9beb332d777981d53cce8f21315..5a9c3bb4f3ce83b3e7ff54f9709b812068ad853d 100644
--- a/lib_enc/ivas_qspherical_enc_fx.c
+++ b/lib_enc/ivas_qspherical_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_range_uni_enc_fx.c b/lib_enc/ivas_range_uni_enc_fx.c
index 949625722de05a1889375fb246877336268cf13a..2efcf8f23243746735aff4a98aa96c2f8c146cbc 100644
--- a/lib_enc/ivas_range_uni_enc_fx.c
+++ b/lib_enc/ivas_range_uni_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_rom_enc.h b/lib_enc/ivas_rom_enc.h
index d1e644a93e45e0ffb4ef355a64c6eb3308e3fc9c..cd296fa140467f90180a9b65c1ce700f5faa8e5c 100644
--- a/lib_enc/ivas_rom_enc.h
+++ b/lib_enc/ivas_rom_enc.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_rom_enc_fx.c b/lib_enc/ivas_rom_enc_fx.c
index 671e20a001473a6d88d56c5d439e7b1415f6dd91..6829a16ce35006c46f3b578b8eab47c815d25f9f 100644
--- a/lib_enc/ivas_rom_enc_fx.c
+++ b/lib_enc/ivas_rom_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_sba_enc_fx.c b/lib_enc/ivas_sba_enc_fx.c
index 574d10f966682a705c27b3301f7242bd9d58529a..c2a63a2e03e89315b6e9d3faa3287b5820b0fedf 100644
--- a/lib_enc/ivas_sba_enc_fx.c
+++ b/lib_enc/ivas_sba_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c
index 2457fef6eaecb5a07271b118889a33d89a4fdf15..3e62c720eab51e3a7fce1bd9a0da5055c5c06482 100644
--- a/lib_enc/ivas_sce_enc_fx.c
+++ b/lib_enc/ivas_sce_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -245,27 +245,36 @@ ivas_error ivas_sce_enc_fx(
/*----------------------------------------------------------------*
* Front Pre-processing
*----------------------------------------------------------------*/
+
set16_fx( old_wsp_fx[0], 0, L_WSP );
q_old_wsp = Q15;
move16();
Word16 q_fr_bands[2];
- error = pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata, input_frame, 0, old_inp_12k8_fx[0], old_inp_16k_fx[0],
- &ener_fx[0], &relE_fx[0], A_fx[0], Aw_fx[0], epsP_fx[0], &epsP_fx_q[0], lsp_new_fx[0], lsp_mid_fx[0], &vad_hover_flag[0], &attack_flag[0],
- realBuffer_fx[0], imagBuffer_fx[0], &q_re_im_buf, old_wsp_fx[0], &q_old_wsp, pitch_fr_fx[0], voicing_fr_fx[0], &loc_harm[0], &cor_map_sum_fx[0], &vad_flag_dtx[0], enerBuffer_fx[0], &enerBuffer_fx_exp[0],
- fft_buff_fx[0], &fft_buff_fx_q[0], A_fx[0], lsp_new_fx[0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, flag_16k_smc,
- st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, ivas_format, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[0]
-#ifdef DEBUG_MODE_INFO
- ,
- st->id_element
-#endif
- );
- e_old_wsp[0] = sub( Q15, q_old_wsp );
- move16();
- IF( NE_32( error, IVAS_ERR_OK ) )
+ Word16 front_vad_flag, force_front_vad, front_vad_dtx_flag;
+ IF( st_ivas->hSpar != NULL )
{
- return error;
+ front_vad_flag = st_ivas->hSpar->front_vad_flag;
+ force_front_vad = st_ivas->hSpar->force_front_vad;
+ front_vad_dtx_flag = st_ivas->hSpar->front_vad_dtx_flag;
+ }
+ ELSE
+ {
+ front_vad_flag = 0;
+ force_front_vad = 0;
+ front_vad_dtx_flag = 0;
}
+ move16();
+ move16();
+ move16();
+
+ pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata, input_frame, 0, old_inp_12k8_fx[0], old_inp_16k_fx[0],
+ &ener_fx[0], &relE_fx[0], A_fx[0], Aw_fx[0], epsP_fx[0], &epsP_fx_q[0], lsp_new_fx[0], lsp_mid_fx[0], &vad_hover_flag[0], &attack_flag[0],
+ realBuffer_fx[0], imagBuffer_fx[0], &q_re_im_buf, old_wsp_fx[0], &q_old_wsp, pitch_fr_fx[0], voicing_fr_fx[0], &loc_harm[0], &cor_map_sum_fx[0], &vad_flag_dtx[0], enerBuffer_fx[0], &enerBuffer_fx_exp[0],
+ fft_buff_fx[0], &fft_buff_fx_q[0], A_fx[0], lsp_new_fx[0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, flag_16k_smc,
+ front_vad_flag, force_front_vad, front_vad_dtx_flag, ivas_format, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[0] );
+ e_old_wsp[0] = sub( Q15, q_old_wsp );
+ move16();
/* sanity check -> DTX not supported for more than one SCEs/CPEs */
IF( sub( add( st_ivas->nSCE, st_ivas->nCPE ), 1 ) > 0 )
@@ -343,8 +352,7 @@ ivas_error ivas_sce_enc_fx(
move16();
/* modify the coder_type depending on the total_brate per channel */
- coder_type_modif_ivas_fx( st, relE_fx[0] );
-
+ coder_type_modif_fx( st, relE_fx[0] );
/*----------------------------------------------------------------*
* Encoder
*----------------------------------------------------------------*/
@@ -465,6 +473,10 @@ ivas_error create_sce_enc_fx(
}
st->total_brate = hSCE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
+#ifdef FIX_1283_STEREO_DFT_COLLAPSE
+ st->element_brate = -1;
+ move32();
+#endif
st->mct_chan_mode = MCT_CHAN_MODE_REGULAR;
move32();
move32();
diff --git a/lib_enc/ivas_sns_enc_fx.c b/lib_enc/ivas_sns_enc_fx.c
index 0beb13759652c16f736a796bea6b6f172ff7796a..01ff6b24ee6e5e67ff3c5ac2c3668fbef659c9a8 100644
--- a/lib_enc/ivas_sns_enc_fx.c
+++ b/lib_enc/ivas_sns_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_spar_encoder_fx.c b/lib_enc/ivas_spar_encoder_fx.c
index d23d69a20306e0e831cf9dc2fae9dafda6dd9c7b..3b65bc4389750420ec2a638fc222c3da263fcd24 100644
--- a/lib_enc/ivas_spar_encoder_fx.c
+++ b/lib_enc/ivas_spar_encoder_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_spar_md_enc_fx.c b/lib_enc/ivas_spar_md_enc_fx.c
index f5cc2ba8000856f43e00a17ded721113f4d2fef2..2d68dc00b6cb70b2ade4e6498b9ece49c35041ee 100644
--- a/lib_enc/ivas_spar_md_enc_fx.c
+++ b/lib_enc/ivas_spar_md_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h
index 7096198a92d2ebe676848e52bc9f52dd2de1e7e1..c984a5ea3e8cda6c2497881c073645de12cbf687 100644
--- a/lib_enc/ivas_stat_enc.h
+++ b/lib_enc/ivas_stat_enc.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_stereo_adapt_GR_enc_fx.c b/lib_enc/ivas_stereo_adapt_GR_enc_fx.c
index 3e4a5040dc006f73e6d1533d131d4222fe1d9d6d..bf54b690137c6f15191664fa0faca5e502bc125a 100644
--- a/lib_enc/ivas_stereo_adapt_GR_enc_fx.c
+++ b/lib_enc/ivas_stereo_adapt_GR_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_stereo_classifier_fx.c b/lib_enc/ivas_stereo_classifier_fx.c
index 88469e8182c8f04f2c75233c6e403279bd519f5d..9538302fab4ef171ab7b8c3aad90a2437f8a7733 100644
--- a/lib_enc/ivas_stereo_classifier_fx.c
+++ b/lib_enc/ivas_stereo_classifier_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_stereo_cng_enc_fx.c b/lib_enc/ivas_stereo_cng_enc_fx.c
index 929d35b91d39dadfab3751eda40d38bc2e75f8ac..c9f4fe9a1b5b06ff1510853bc0180f5a15c78699 100644
--- a/lib_enc/ivas_stereo_cng_enc_fx.c
+++ b/lib_enc/ivas_stereo_cng_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_stereo_dft_enc_fx.c b/lib_enc/ivas_stereo_dft_enc_fx.c
index 56dd1bab9db6ce88c16a1cbf68c1ff41009f9e24..d6af9caf00693ac59a08ae9190ba44f4fab199fe 100644
--- a/lib_enc/ivas_stereo_dft_enc_fx.c
+++ b/lib_enc/ivas_stereo_dft_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -3849,7 +3849,6 @@ static void stereo_dft_enc_compute_prm_fx(
hStereoDft->nrg_past_pos = ( pos + 1 ) % STEREO_DFT_NRG_PAST_LEN;
move16();
-#ifdef FIX_1461_CNG_BW_SWITCHING
/* Replicate last band for remaining bands in case the bandwidth is higher after SID/NODATA is considered */
FOR( i = hStereoDft->nbands; i < STEREO_DFT_BAND_MAX; i++ )
{
@@ -3858,7 +3857,6 @@ static void stereo_dft_enc_compute_prm_fx(
pSideGain[i] = pSideGain[i - 1];
move32();
}
-#endif
/*------------------------------------------------------------------*
@@ -3955,10 +3953,16 @@ static void stereo_dft_enc_compute_prm_fx(
* Compute Side gains
*-----------------------------------------------------------------*/
+#ifdef FIX_BASOP_2317_UNINIT_VALUE_IN_STEREO_CNG
+ Copy32( pSideGain, hStereoDft->sidSideGain_fx, STEREO_DFT_BAND_MAX ); /* Copy all sideGain values since BW change may be reverted during CNG */
+#endif
+
FOR( b = 0; b < hStereoDft->nbands; b++ )
{
+#ifndef FIX_BASOP_2317_UNINIT_VALUE_IN_STEREO_CNG
hStereoDft->sidSideGain_fx[b] = *( pSideGain + b );
move32();
+#endif
/* Quantization */
IF( flag_quant )
diff --git a/lib_enc/ivas_stereo_dft_enc_itd_fx.c b/lib_enc/ivas_stereo_dft_enc_itd_fx.c
index 09d5f0c91dd3dac7f1f4a11d4913d45881beb5e2..b1f709bd9024c9d8b3a4f677b0bd8de5b8891c22 100644
--- a/lib_enc/ivas_stereo_dft_enc_itd_fx.c
+++ b/lib_enc/ivas_stereo_dft_enc_itd_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_stereo_dft_td_itd_fx.c b/lib_enc/ivas_stereo_dft_td_itd_fx.c
index 94a57b036412eba63005d00fae7964fc7985f6f2..ac42b9679ffcd3cd12e216ddaa8561ae13b85b51 100644
--- a/lib_enc/ivas_stereo_dft_td_itd_fx.c
+++ b/lib_enc/ivas_stereo_dft_td_itd_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c
index f04f65b13a4c20976f9f1ed96c086c9a0136fe19..e7d359059daf2528a54fc74ca2c0e459458795e6 100644
--- a/lib_enc/ivas_stereo_dmx_evs_fx.c
+++ b/lib_enc/ivas_stereo_dmx_evs_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_stereo_eclvq_enc_fx.c b/lib_enc/ivas_stereo_eclvq_enc_fx.c
index 05f9dc80d367a56ac6557607e4f56d3b4d7891cf..bdc9be253eec64a11e70e9f1a0df508d66af46e9 100644
--- a/lib_enc/ivas_stereo_eclvq_enc_fx.c
+++ b/lib_enc/ivas_stereo_eclvq_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_stereo_ica_enc_fx.c b/lib_enc/ivas_stereo_ica_enc_fx.c
index 32d70a8b7159f96d03a80bc5488d321083a97f14..c50ea4c0c8c457f8d6d660994b03571ac2e46da2 100644
--- a/lib_enc/ivas_stereo_ica_enc_fx.c
+++ b/lib_enc/ivas_stereo_ica_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c
index 2d6c17d9f84004d786d687199be8edc8c4a65b29..366b93c26eb1bcf487247623ee4adcff1537e633 100644
--- a/lib_enc/ivas_stereo_icbwe_enc_fx.c
+++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -39,6 +39,7 @@
#include "ivas_rom_com.h"
#include "ivas_prot_fx.h"
+
/*-------------------------------------------------------------------*
* ic_bwe_enc_reset()
*
@@ -90,21 +91,24 @@ static void ic_bwe_enc_reset_fx(
return;
}
+
/*--------------------------------------------------------------------------*
* ic_bwe_specMapping()
*
* Encode and apply the spectral shape mapping of ref to the non-ref channel
*---------------------------------------------------------------------------*/
-static Word16 ic_bwe_enc_specMapping_ivas_fx(
- const Word32 *shb_frame_target_fx, /* i : target shb Q31-shb_frame_target_e*/
- Word16 shb_frame_target_e,
- Word32 *shb_synth_nonref_fx, /* o : non-ref shb synth Q31-shb_synth_nonref_e*/
- Word16 *shb_synth_nonref_e,
- Word32 *specMapping_fx, /* i/o: current frame's mapping Qx*/
- Word32 *memShbSpecMapping_fx, /* i/o: current frame's mapping Q31-memShbSpecMapping_e*/
- Word16 *memShbSpecMapping_e,
- Word32 *memShbSpecXcorr_fx, /* i/o: ic bwe spec mapping scorr memory Q31-memShbSpecXcorr_e*/
- Word16 *memShbSpecXcorr_e )
+
+static Word16 ic_bwe_enc_specMapping_fx(
+ const Word32 *shb_frame_target_fx, /* i : target shb Q31-shb_frame_target_e*/
+ const Word16 shb_frame_target_e, /* i : Q value shb_frame_target_fx */
+ Word32 *shb_synth_nonref_fx, /* o : non-ref shb synth Q31-shb_synth_nonref_e*/
+ Word16 *shb_synth_nonref_e, /* i/o: Q value shb_synth_nonref_fx */
+ Word32 *specMapping_fx, /* i/o: current frame's mapping Qx*/
+ Word32 *memShbSpecMapping_fx, /* i/o: current frame's mapping Q31-memShbSpecMapping_e*/
+ Word16 *memShbSpecMapping_e, /* i/o: Q value memShbSpecMapping_fx */
+ Word32 *memShbSpecXcorr_fx, /* i/o: ic bwe spec mapping scorr memory Q31-memShbSpecXcorr_e*/
+ Word16 *memShbSpecXcorr_e /* i/o: Q value memShbSpecMapping_fx */
+)
{
Word16 idx;
Word16 max_exp;
@@ -129,7 +133,6 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx(
move16();
/* Calculate rxx(1)/rxx(0) of the non ref target */
-
temp00_fx = dotp_fx_ivas_fx( shb_frame_target_fx, shb_frame_target_e, shb_frame_target_fx, shb_frame_target_e, L_FRAME16k - 1, &temp00_exp ); /* Q31-temp0_exp */
temp11_fx = dotp_fx_ivas_fx( shb_frame_target_fx, shb_frame_target_e, shb_frame_target_fx + 1, shb_frame_target_e, L_FRAME16k - 1, &temp11_exp ); /* Q31-temp1_exp */
@@ -149,7 +152,6 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx(
temp3_fx = L_shr( temp3_fx, sub( exp, temp3_exp ) );
/* Smoothing */
-
FOR( Word16 i = 0; i < 6; i++ )
{
memShbSpecXcorr_fx[i] = L_shl( memShbSpecXcorr_fx[i], sub( *memShbSpecXcorr_e, exp ) );
@@ -175,7 +177,6 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx(
T_nonref_target_fx = BASOP_Util_Divide3232_Scale( temp11_fx, temp00_fx, &T_nonref_target_e );
}
-
memShbSpecXcorr_fx[0] = temp00_fx;
move32();
memShbSpecXcorr_fx[1] = temp11_fx;
@@ -189,7 +190,6 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx(
memShbSpecXcorr_fx[5] = temp3_fx; /* Q31-exp */
move32();
-
IF( temp0_fx != 0 )
{
Txx1_fx = BASOP_Util_Divide3232_Scale( temp1_fx, temp0_fx, &Txx1_e ); /* Q31-Txx1_e */
@@ -215,9 +215,7 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx(
u_fx = extract_l( *specMapping_fx );
-
/* while performing (-32768)*(-32768), overflow occurs because the result comes out as 32768 after mult. This is the only case for mult where overflow happens. In order to avoid this scenario mult_sat is used */
-
tmp = mult_sat( b_fx, b_fx ); // b_e + b_e;
tmp1 = mult_sat( a_fx, c_fx ); // a_e + c_e + 2
@@ -314,14 +312,7 @@ static Word16 ic_bwe_enc_specMapping_ivas_fx(
*-----------------------------------------------------------------------*/
/*! r: return quant. index value */
-/*----------------------------------------------------------------------*
- * ic_bwe_gsMapping()
- *
- * Encode and apply the gain shape mapping of ref to the non-ref channel
- *-----------------------------------------------------------------------*/
-
-/*! r: return quant. index value */
-static Word16 ic_bwe_enc_gsMapping_ivas_fx(
+static Word16 ic_bwe_enc_gsMapping_fx(
const Word32 relG_targ_fx, /* i : gDes, rel gain target Q31-relG_targ_e*/
Word16 relG_targ_e,
const Word16 *shbSynth_fx, /* i : ref synth signal Q15-shbSynth_e*/
@@ -416,8 +407,10 @@ static Word16 ic_bwe_enc_gsMapping_ivas_fx(
move16();
idx = squant_fx( temp2_fx, &gsMapping_fx16, icbwe_gsMappingDFT_tbl_fx, ( 1 << STEREO_ICBWE_GSBITS_DFT ) ); // Q12
}
+
*gsMapping_fx = L_deposit_h( gsMapping_fx16 ); // Q28
move32();
+
Word16 e;
L_mult = Mult_32_16( *gsMapping_fx, 27213 /*=log2(10)*2^13*/ ); // Q28 + Q13 - Q15 -> Q26
*gsMapping_fx = BASOP_util_Pow2( L_mult, 5, &e ); /* Q31-e */
@@ -425,15 +418,18 @@ static Word16 ic_bwe_enc_gsMapping_ivas_fx(
*gsMapping_e = e; // Q31
move16();
+
return idx;
}
+
/*----------------------------------------------------------------------*
* icbwe_dft_stereo_param()
*
* Estimate ICBWE parameters in DFT stereo
*-----------------------------------------------------------------------*/
-static void icbwe_dft_stereo_param_ivas_fx(
+
+static void icbwe_dft_stereo_param_fx(
STEREO_ICBWE_ENC_HANDLE hStereoICBWE, /* i/o: */
STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i : */
Encoder_State *st, /* i/o: */
@@ -486,7 +482,6 @@ static void icbwe_dft_stereo_param_ivas_fx(
move16();
/* refChanIndex_bwe refinement */
-
test();
test();
test();
@@ -563,7 +558,6 @@ static void icbwe_dft_stereo_param_ivas_fx(
}
/* gsMapping estimate */
-
Word16 exp;
IF( hStereoICBWE->refChanIndx_bwe == L_CH_INDX )
{
@@ -592,7 +586,7 @@ static void icbwe_dft_stereo_param_ivas_fx(
move32();
move16();
- gsIndx = ic_bwe_enc_gsMapping_ivas_fx( hStereoICBWE->gDes_pastFrame_fx, hStereoICBWE->gDes_pastFrame_e, hStereoICBWE->shbSynthRef_fx, hStereoICBWE->shbSynthRef_e, shb_synth_nonref_fx, shb_synth_nonref_e, &( hStereoICBWE->prevgsMapping_fx ), &( hStereoICBWE->prevgsMapping_e ), hStereoICBWE->memGsEnerMap_fx, &hStereoICBWE->memGsEnerMap_e, st->element_mode ); /* Q0 */
+ gsIndx = ic_bwe_enc_gsMapping_fx( hStereoICBWE->gDes_pastFrame_fx, hStereoICBWE->gDes_pastFrame_e, hStereoICBWE->shbSynthRef_fx, hStereoICBWE->shbSynthRef_e, shb_synth_nonref_fx, shb_synth_nonref_e, &( hStereoICBWE->prevgsMapping_fx ), &( hStereoICBWE->prevgsMapping_e ), hStereoICBWE->memGsEnerMap_fx, &hStereoICBWE->memGsEnerMap_e, st->element_mode ); /* Q0 */
hStereoICBWE->gDes_pastFrame_fx = L_deposit_h( gDes_fx ); /* Q31-exp */
hStereoICBWE->gDes_pastFrame_e = exp;
@@ -611,13 +605,28 @@ static void icbwe_dft_stereo_param_ivas_fx(
return;
}
-void stereo_icBWE_enc_ivas_fx(
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- const Word32 shb_speech_ref_fx[], /* i : SHB speech ref channel Q31-shb_speech_ref_e*/
+/*-------------------------------------------------------------------*
+ * stereo_icBWE_enc()
+ *
+ * Encode the spatial mapping of reference to the non-reference channels in HB
+ *-------------------------------------------------------------------*/
+
+void stereo_icBWE_enc_fx(
+ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
+#ifdef REMOVE_SCALING_SHB_SPEECH
+ const Word16 shb_speech_ref_fx16[], /* i : SHB speech ref channel Q0*/
+ Word16 shb_speech_nonref_fx_16[], /* i/o: SHB speech non-ref channel shb_speech_nonref_e*/
+#else
+ const Word32 shb_speech_ref_fx[], /* i : SHB speech ref channel shb_speech_ref_e*/
const Word16 shb_speech_ref_e, /* i : SHB speech ref channel */
Word32 shb_speech_nonref_fx[], /* i/o: SHB speech non-ref channel Q31-shb_speech_nonref_e*/
- Word16 shb_speech_nonref_e, /* i/o: SHB speech non-ref channel */
+#endif
+ Word16 shb_speech_nonref_e, /* i/o: SHB speech non-ref channel */
+#ifdef REMOVE_SCALING_SHB_SPEECH
+ const Word16 *voice_factors_fx16 /* i : voicing factors Q15 */
+#else
const Word32 *voice_factors_fx /* i : voicing factors Q31 */
+#endif
)
{
Word16 i, j, k, nbSubFr;
@@ -641,6 +650,20 @@ void stereo_icBWE_enc_ivas_fx(
Word32 temp1_fx, temp2_fx;
Word16 temp1_e, temp2_e, shb_frame_ref_e, shb_frame_nonref_e, gDes_e, tmp, exp;
+#ifdef REMOVE_SCALING_SHB_SPEECH
+ Word32 shb_speech_ref_fx[L_FRAME16k];
+ Word16 shb_speech_ref_e;
+ Word32 shb_speech_nonref_fx[L_FRAME48k + STEREO_DFT_OVL_MAX];
+ Word32 voice_factors_fx[NB_SUBFR16k];
+
+ shb_speech_ref_e = add( getScaleFactor16( shb_speech_ref_fx16, L_FRAME16k ), Q16 );
+ Copy_Scale_sig_16_32_no_sat( shb_speech_ref_fx16, shb_speech_ref_fx, L_FRAME16k, shb_speech_ref_e );
+ shb_speech_ref_e = Q31 - shb_speech_ref_e;
+
+ shb_speech_nonref_e = Q15 - shb_speech_nonref_e;
+ Copy_Scale_sig_16_32_no_sat( shb_speech_nonref_fx_16, shb_speech_nonref_fx, L_FRAME48k + STEREO_DFT_OVL_MAX, Q16 ); // q_new_swb_speech_buffer+st->q_inp - 16 - > q_new_swb_speech_buffer+st->q_inp
+ Copy_Scale_sig_16_32_no_sat( voice_factors_fx16, voice_factors_fx, NB_SUBFR16k, Q16 ); // Q31
+#endif
/* initialization */
hStereoDft = hCPE->hStereoDft;
@@ -702,7 +725,6 @@ void stereo_icBWE_enc_ivas_fx(
move32();
/* SHB frame buffer offsets for TBE processing << re-adjust check >>*/
-
max_e = s_max( hStereoICBWE->mem_shb_speech_ref_e, shb_speech_ref_e );
Copy_Scale_sig( hStereoICBWE->mem_shb_speech_ref_fx, hStereoICBWE->mem_shb_speech_ref_fx, L_LOOK_16k, negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ) ); // mem_shb_speech_ref_e
@@ -722,7 +744,6 @@ void stereo_icBWE_enc_ivas_fx(
Copy_Scale_sig32( shb_speech_ref_fx, shb_frame_ref_fx + L_LOOK_16k - refMemLen, L_FRAME16k, negate( sub( max_e, shb_speech_ref_e ) ) ); /* shb_speech_ref_e */
Copy_Scale_sig_32_16( shb_frame_ref_fx + L_FRAME16k, hStereoICBWE->mem_shb_speech_ref_fx, L_LOOK_16k, negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ) - Q16 ); // mem_shb_speech_ref_e
-
test();
test();
IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && EQ_16( st->flag_ACELP16k, 1 ) )
@@ -798,8 +819,8 @@ void stereo_icBWE_enc_ivas_fx(
excSHB_nonref_fx[j] = L_shr( excSHB_nonref_fx[j], sub( max_e, exp_buf[j] ) ); /* Q31-max_e */
move32();
}
- /* LP synthesis */
+ /* LP synthesis */
Copy_Scale_sig32( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, hStereoICBWE->mem_lpc_shbsynth_nonref_fx, LPC_SHB_ORDER, sub( hStereoICBWE->mem_lpc_shbsynth_nonref_e, s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ) ) ); /* Q31-tmp_e */
Copy_Scale_sig32( excSHB_nonref_fx, excSHB_nonref_fx, L_FRAME16k, sub( max_e, s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ) ) ); /* Q31-tmp_e */
max_e = s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e );
@@ -820,11 +841,10 @@ void stereo_icBWE_enc_ivas_fx(
move16();
}
- icbwe_dft_stereo_param_ivas_fx( hStereoICBWE, hStereoDft, st, shb_synth_nonref_fx, &shb_synth_nonref_e );
+ icbwe_dft_stereo_param_fx( hStereoICBWE, hStereoDft, st, shb_synth_nonref_fx, &shb_synth_nonref_e );
}
ELSE
{
-
max_e = s_max( hStereoICBWE->mem_shb_speech_ref_e, shb_speech_ref_e );
Copy_Scale_sig( hStereoICBWE->mem_shb_speech_ref_fx, hStereoICBWE->mem_shb_speech_ref_fx, L_LOOK_16k, negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ) ); // mem_shb_speech_ref_e
@@ -900,7 +920,6 @@ void stereo_icBWE_enc_ivas_fx(
/*temp1 = 0.8f*hStereoICBWE->prevNonRefEner + 0.2f*temp1;*/
/*temp2 = 0.8f*hStereoICBWE->prevRefEner + 0.2f*temp2;*/
-
IF( temp2_fx == 0 )
{
gDes_fx = 1073741824; /* 1.0 in Q30 */
@@ -1012,6 +1031,7 @@ void stereo_icBWE_enc_ivas_fx(
excSHB_nonref_fx[j] = L_shr( excSHB_nonref_fx[j], sub( max_e, exp_buf[j] ) ); /* Q31-max_e */
move32();
}
+
/* LP synthesis */
Copy_Scale_sig32( hStereoICBWE->mem_lpc_shbsynth_nonref_fx, hStereoICBWE->mem_lpc_shbsynth_nonref_fx, LPC_SHB_ORDER, sub( hStereoICBWE->mem_lpc_shbsynth_nonref_e, s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ) ) ); /* Q31-tmp_e */
Copy_Scale_sig32( excSHB_nonref_fx, excSHB_nonref_fx, L_FRAME16k, sub( max_e, s_max( hStereoICBWE->mem_lpc_shbsynth_nonref_e, max_e ) ) ); /* Q31-tmp_e */
@@ -1039,7 +1059,7 @@ void stereo_icBWE_enc_ivas_fx(
IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && EQ_16( st->flag_ACELP16k, 1 ) )
{
/* IC BWE spectral mapping */
- spIndx = ic_bwe_enc_specMapping_ivas_fx( shb_frame_nonref_fx, shb_frame_nonref_e, shb_synth_nonref_fx, &shb_synth_nonref_e, &( hStereoICBWE->prevSpecMapping_fx ), &( hStereoICBWE->memShbSpecMapping_fx ), &( hStereoICBWE->memShbSpecMapping_e ), hStereoICBWE->memShbSpecXcorr_fx, &( hStereoICBWE->memShbSpecXcorr_e ) ); /* Q0 */
+ spIndx = ic_bwe_enc_specMapping_fx( shb_frame_nonref_fx, shb_frame_nonref_e, shb_synth_nonref_fx, &shb_synth_nonref_e, &( hStereoICBWE->prevSpecMapping_fx ), &( hStereoICBWE->memShbSpecMapping_fx ), &( hStereoICBWE->memShbSpecMapping_e ), hStereoICBWE->memShbSpecXcorr_fx, &( hStereoICBWE->memShbSpecXcorr_e ) ); /* Q0 */
}
ELSE
{
@@ -1063,7 +1083,7 @@ void stereo_icBWE_enc_ivas_fx(
/* IC BWE GS mapping */
- gsIndx = ic_bwe_enc_gsMapping_ivas_fx( hStereoICBWE->gDes_pastFrame_fx, hStereoICBWE->gDes_pastFrame_e, hStereoICBWE->shbSynthRef_fx, hStereoICBWE->shbSynthRef_e, shb_synth_nonref_fx, &shb_synth_nonref_e, &( hStereoICBWE->prevgsMapping_fx ), &( hStereoICBWE->prevgsMapping_e ), hStereoICBWE->memGsEnerMap_fx, &hStereoICBWE->memGsEnerMap_e, st->element_mode ); /* Q0 */
+ gsIndx = ic_bwe_enc_gsMapping_fx( hStereoICBWE->gDes_pastFrame_fx, hStereoICBWE->gDes_pastFrame_e, hStereoICBWE->shbSynthRef_fx, hStereoICBWE->shbSynthRef_e, shb_synth_nonref_fx, &shb_synth_nonref_e, &( hStereoICBWE->prevgsMapping_fx ), &( hStereoICBWE->prevgsMapping_e ), hStereoICBWE->memGsEnerMap_fx, &hStereoICBWE->memGsEnerMap_e, st->element_mode ); /* Q0 */
hStereoICBWE->gDes_pastFrame_fx = gDes_fx; /* Q31-hStereoICBWE->gDes_pastFrame_e */
hStereoICBWE->gDes_pastFrame_e = gDes_e;
@@ -1085,6 +1105,7 @@ void stereo_icBWE_enc_ivas_fx(
*
* Stereo (inter-channel) BWE mapping - encoder initialization
*-------------------------------------------------------------------*/
+
void stereo_icBWE_init_enc_fx(
STEREO_ICBWE_ENC_HANDLE hStereoICBWE /* i/o: Stereo inter-channel BWE handle */
)
@@ -1173,11 +1194,14 @@ void stereo_icBWE_init_enc_fx(
return;
}
+
+
/*-------------------------------------------------------------------*
* findRefChanBWE()
*
* Inter-channel BWE pre-proc of the non-ref channel
*-------------------------------------------------------------------*/
+
static void findRefChanBWE_fx(
const Word16 *input0_fx, /* i/o : input 0 Qx q_dataChan_fx*/
const Word16 *input1_fx, /* i/o : input 1 Qx q_dataChan_fx*/
@@ -1219,6 +1243,7 @@ static void findRefChanBWE_fx(
*
* Inter-channel BWE pre-proc of the non-ref channel
*-------------------------------------------------------------------*/
+
void stereo_icBWE_preproc_fx(
CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
const Word16 input_frame, /* i : input frame length Q0*/
diff --git a/lib_enc/ivas_stereo_mdct_core_enc_fx.c b/lib_enc/ivas_stereo_mdct_core_enc_fx.c
index e764649df8fd6a67d409b5185f0cb3fb8e977b91..705635d887e22490a1c1272d93d120d28835caec 100644
--- a/lib_enc/ivas_stereo_mdct_core_enc_fx.c
+++ b/lib_enc/ivas_stereo_mdct_core_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_stereo_mdct_igf_enc_fx.c b/lib_enc/ivas_stereo_mdct_igf_enc_fx.c
index 39f4f41494a3059231d215869c12d81abf31b59a..397d72c32386b2ac36c5e0bcf153e19e3b0e0106 100644
--- a/lib_enc/ivas_stereo_mdct_igf_enc_fx.c
+++ b/lib_enc/ivas_stereo_mdct_igf_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c
index 055e22593242ee6869447b4636d4f9c887ddf567..31f33752132e875ed91d924dc5080ef5f9d3f911 100644
--- a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c
+++ b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c
index 107fb9681e09f49eea06b087308350d856ef8d6d..a4a3080a7aaa36ca452b57667da919a5493033ee 100644
--- a/lib_enc/ivas_stereo_switching_enc_fx.c
+++ b/lib_enc/ivas_stereo_switching_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -385,7 +385,7 @@ ivas_error stereo_memory_enc_fx(
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) );
}
- td_cng_enc_init_ivas_fx( hCPE->hCoreCoder[0]->hTdCngEnc, hCPE->hCoreCoder[0]->Opt_DTX_ON, hCPE->hCoreCoder[0]->max_bwidth );
+ td_cng_enc_init_fx( hCPE->hCoreCoder[0]->hTdCngEnc, hCPE->hCoreCoder[0]->Opt_DTX_ON, hCPE->hCoreCoder[0]->max_bwidth );
}
/* allocate TCA data structure */
@@ -434,7 +434,11 @@ ivas_error stereo_memory_enc_fx(
}
}
+#ifdef HARMONIZE_TBE
+ InitSWBencBuffer_fx( st->element_mode, st->hBWE_TD );
+#else
InitSWBencBuffer_ivas_fx( st->hBWE_TD );
+#endif
ResetSHBbuffer_Enc_fx( st->hBWE_TD );
IF( ( st->hBWE_FD = (FD_BWE_ENC_HANDLE) malloc( sizeof( FD_BWE_ENC_DATA ) ) ) == NULL )
diff --git a/lib_enc/ivas_stereo_td_analysis_fx.c b/lib_enc/ivas_stereo_td_analysis_fx.c
index 1eff3cd9e6aa17b991f185acc8186231bf9b7e8a..e9a6cd843f63d886af9abbbd18b9c1e704845808 100644
--- a/lib_enc/ivas_stereo_td_analysis_fx.c
+++ b/lib_enc/ivas_stereo_td_analysis_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c
index b26b688dc538948ad4b83c1e8bf6e1c547e80ff1..4e3b5fdd1528b01b8ad3d7f45e1963da9559f6b1 100644
--- a/lib_enc/ivas_stereo_td_enc_fx.c
+++ b/lib_enc/ivas_stereo_td_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -325,7 +325,11 @@ ivas_error stereo_set_tdm_fx(
return error;
}
+#ifdef HARMONIZE_TBE
+ InitSWBencBuffer_fx( st->element_mode, st->hBWE_TD );
+#else
InitSWBencBuffer_ivas_fx( st->hBWE_TD );
+#endif
ResetSHBbuffer_Enc_fx( st->hBWE_TD );
IF( ( st->hBWE_FD = (FD_BWE_ENC_HANDLE) malloc( sizeof( FD_BWE_ENC_DATA ) ) ) == NULL )
@@ -396,15 +400,9 @@ void tdm_configure_enc_fx(
hStereoTD->tdm_use_IAWB_Ave_lpc = 0; /* Flag initialisation */
move16();
-#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE
sts[0]->hSpMusClas->tdm_lt_Etot_fx = mac_r( L_mult( 3277 /*0.1f in Q15*/, Etot_last_fx[0] ), 29491 /* 0.9f*/, sts[0]->hSpMusClas->tdm_lt_Etot_fx );
move16();
sts[1]->hSpMusClas->tdm_lt_Etot_fx = mac_r( L_mult( 3277 /*0.1f in Q15*/, Etot_last_fx[1] ), 29491 /* 0.9f*/, sts[1]->hSpMusClas->tdm_lt_Etot_fx );
-#else
- sts[0]->hSpMusClas->tdm_lt_Etot_fx = add( mult( 3277 /*0.1f in Q15*/, Etot_last_fx[0] ), mult( 29491 /* 0.9f*/, sts[0]->hSpMusClas->tdm_lt_Etot_fx ) );
- move16();
- sts[1]->hSpMusClas->tdm_lt_Etot_fx = add( mult( 3277 /*0.1f in Q15*/, Etot_last_fx[1] ), mult( 29491 /* 0.9f*/, sts[1]->hSpMusClas->tdm_lt_Etot_fx ) );
-#endif
move16();
test();
@@ -801,21 +799,14 @@ static void tdm_downmix_plain_ivas_fx(
)
{
Word16 i;
-#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE
Word16 One_m_Ratio_fx16, ratio_L_fx16;
One_m_Ratio_fx16 = extract_h( One_m_Ratio_fx );
ratio_L_fx16 = extract_h( ratio_L_fx );
-#endif
FOR( i = start_index; i < end_index; i++ )
{
-#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE
FR_Y_fx[i] = mac_r( L_mult( Right_in_fx[i], One_m_Ratio_fx16 ), Left_in_fx[i], ratio_L_fx16 );
LR_X_fx[i] = msu_r( L_mult( Left_in_fx[i], One_m_Ratio_fx16 ), Right_in_fx[i], ratio_L_fx16 );
-#else
- FR_Y_fx[i] = add( mult( Right_in_fx[i], extract_h( One_m_Ratio_fx ) ), mult( Left_in_fx[i], extract_h( ratio_L_fx ) ) );
- LR_X_fx[i] = sub( mult( Left_in_fx[i], extract_h( One_m_Ratio_fx ) ), mult( Right_in_fx[i], extract_h( ratio_L_fx ) ) );
-#endif
move16();
move16();
}
diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c
index 95e52bc694249b1e1adf0fd8769b0991fac17c52..709e17ef716a3ea4c82c7824624b342d35933d24 100644
--- a/lib_enc/ivas_tcx_core_enc_fx.c
+++ b/lib_enc/ivas_tcx_core_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -420,8 +420,8 @@ void stereo_tcx_core_enc(
move16();
}
- lpc_quantization_ivas_fx( st, lsp_new_fx, lsp_mid_fx, lsp_q_fx, lsf_q_fx, lspmid_q_fx, AUDIO, 0, /*No acelp->no need to compute any mid-LPC*/
- param_lpc, nbits_lpc, bits_param_lpc, &no_param_lpc, Q_ener );
+ lpc_quantization_fx( st, lsp_new_fx, lsp_mid_fx, lsp_q_fx, lsf_q_fx, lspmid_q_fx, NULL, st->clip_var_fx, AUDIO, 0, /*No acelp->no need to compute any mid-LPC*/
+ param_lpc, nbits_lpc, bits_param_lpc, &no_param_lpc, Q_ener );
/*--------------------------------------------------------------*
* Rate switching
@@ -629,17 +629,15 @@ void stereo_tcx_core_enc(
E_LPC_a_lsp_conversion( A_fx, lsptmp_fx, lsp_new_fx, M );
Residu3_fx( A_fx, buf_fx + L_LP - L_FRAME, res_fx, L_FRAME, 0 );
- cng_params_upd_ivas_fx( lsptmp_fx, res_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size,
- st->hTdCngEnc->ho_lsp_circ_fx, Q_r, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode,
- st->hFdCngEnc->hFdCngCom->CngBandwidth );
+ cng_params_upd_fx( lsptmp_fx, res_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx,
+ Q_r, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth );
Q_exc = Q_r;
move16();
}
ELSE
{
- cng_params_upd_ivas_fx( lsp_new_fx, st->hLPDmem->old_exc + L_EXC_MEM - st->L_frame, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size,
- st->hTdCngEnc->ho_lsp_circ_fx, st->hLPDmem->q_lpd_old_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode,
- st->hFdCngEnc->hFdCngCom->CngBandwidth );
+ cng_params_upd_fx( lsp_new_fx, st->hLPDmem->old_exc + L_EXC_MEM - st->L_frame, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx,
+ st->hLPDmem->q_lpd_old_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth );
}
IF( EQ_16( st->L_frame, L_FRAME ) )
diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c
index 05fabedfed7a11d7a76ee3fc3c551ab2cba2dae5..b14a2d27d890283d1c19c59e2f72cc13f00153a7 100644
--- a/lib_enc/ivas_td_low_rate_enc_fx.c
+++ b/lib_enc/ivas_td_low_rate_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -47,20 +47,20 @@
* Encode secondary channel of TD Stereo with a low-bitrate encoder
*-------------------------------------------------------------------*/
-void tdm_low_rate_enc(
- Encoder_State *st, /* i/o: State structure */
- const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/
- const Word16 *res, /* i : residual signal Q_new*/
- Word16 *synth, /* i/o: core synthesis Q_new*/
- Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
- Word16 *pitch_buf,
- /* i/o: floating pitch values for each subframe */ // Q6
- Word16 *voice_factors, /* o : voicing factors Q15*/
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/
- const Word16 attack_flag, /* i : GSC attack flag Q0*/
- const Word16 *lsf_new, /* i : current frame ISF vector Qx2.56*/
- Word16 *tmp_noise, /* o : long-term noise energy Q11*/
- Word16 Q_new )
+void tdm_low_rate_enc_fx(
+ Encoder_State *st, /* i/o: State structure */
+ const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/
+ const Word16 *res, /* i : residual signal Q_new*/
+ Word16 *synth, /* i/o: core synthesis Q_new*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6 */
+ Word16 *voice_factors, /* o : voicing factors Q15*/
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/
+ const Word16 attack_flag, /* i : GSC attack flag Q0*/
+ const Word16 *lsf_new, /* i : current frame ISF vector Qx2.56*/
+ Word16 *tmp_noise, /* o : long-term noise energy Q11*/
+ const Word16 Q_new /* i : Scaling factor */
+)
{
const Word16 *p_Aq;
Word16 i_subfr, nb_subfr, last_pit_bin;
@@ -112,7 +112,12 @@ void tdm_low_rate_enc(
Word16 Q_exc = Q_new;
move16();
+
+#ifdef FIX_1904_HARM_GSC_ENC
+ gsc_enc_fx( st, dct_res_fx, dct_epit_fx, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf_fx, tmp_noise, &Q_exc );
+#else
gsc_enc_ivas_fx( st, dct_res_fx, dct_epit_fx, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf_fx, tmp_noise, &Q_exc );
+#endif
/*--------------------------------------------------------------------------------------*
* iDCT transform
@@ -126,7 +131,11 @@ void tdm_low_rate_enc(
* Remove potential pre-echo in case an onset has been detected
*--------------------------------------------------------------------------------------*/
+#ifdef FIX_1904_HARM_GSC_ENC
+ pre_echo_att_fx( &st->hGSCEnc->Last_frame_ener_fx, exc_fx, attack_flag, Q_exc, st->last_coder_type, st->L_frame, st->element_mode );
+#else
pre_echo_att_ivas_fx( &st->hGSCEnc->Last_frame_ener_fx, exc_fx, attack_flag, Q_exc, st->last_coder_type, st->L_frame );
+#endif
/*--------------------------------------------------------------------------------------*
* Update BWE excitation
@@ -174,8 +183,8 @@ void tdm_low_rate_enc(
* Encode GC, 2 subframes mode
*-------------------------------------------------------------------*/
-void encod_gen_2sbfr(
- Encoder_State *st, /* i/o: state structure */
+void encod_gen_2sbfr_fx(
+ Encoder_State *st, /* i/o: state structure */
const Word16 speech[], /* i : input speech Q_new-1 */
const Word16 Aw[], /* i : weighted A(z) unquantized for subframes e(norm_s(Aw[0]+1)*/
const Word16 Aq[], /* i : LP coefficients e(norm_s(Aw[0]+1)*/
@@ -186,10 +195,11 @@ void encod_gen_2sbfr(
Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6 */
Word16 *voice_factors, /* o : voicing factors Q15 */
Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
const Word16 tdm_Pri_pitch_buf[], /* i : pitch values for primary channel Q4 */
- Word16 Q_new,
- Word16 shift )
+ const Word16 Q_new, /* i : Scaling factor */
+ const Word16 shift /* i : Shift needed to obtain 12 bits vectors */
+)
{
Word16 xn[2 * L_SUBFR]; /* Target vector for pitch search */
Word16 xn2[2 * L_SUBFR]; /* Target vector for codebook search */
@@ -279,7 +289,7 @@ void encod_gen_2sbfr(
Scale_sig( h1, 2 * L_SUBFR, sub( 13, q_h1 ) ); // Q13
- tbe_celp_exc_ivas( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, st->tdm_LRTD_flag );
+ tbe_celp_exc_fx( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, st->tdm_LRTD_flag );
/*-----------------------------------------------------------------*
* Find adaptive exitation
@@ -302,25 +312,20 @@ void encod_gen_2sbfr(
lp_filt_exc_enc_fx( MODE1, coder_type, i_subfr, exc, h1, xn, y1, xn2, 2 * L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &st->acelp_cfg.ltf_mode );
/* update long-term pitch gain for speech/music classifier */
-#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE
st->hSpMusClas->lowrate_pitchGain = mac_r( L_mult( 29491, st->hSpMusClas->lowrate_pitchGain ), 3277 /*Q15*/, gain_pit ); // Q14
-#else
- st->hSpMusClas->lowrate_pitchGain = add( mult( 29491, st->hSpMusClas->lowrate_pitchGain ), mult( 3277 /*Q15*/, gain_pit ) ); // Q14
-#endif
move16();
/*-----------------------------------------------------------------*
* Innovation encoding
*-----------------------------------------------------------------*/
- inov_encode_ivas_fx( st, st->core_brate, 0, L_frame, st->last_L_frame, coder_type, st->bwidth, st->sharpFlag, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &i, 2 * L_SUBFR, shift, Q_new );
+ inov_encode_fx( st, st->core_brate, 0, L_frame, st->last_L_frame, coder_type, st->bwidth, st->sharpFlag, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &i, 2 * L_SUBFR, shift, Q_new );
/*-----------------------------------------------------------------*
* Gain encoding
*-----------------------------------------------------------------*/
- gain_enc_lbr_fx( st->hBstr, st->acelp_cfg.gains_mode, coder_type, i_subfr, xn, y1, add( sub( Q_new, 1 ), shift ), y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR,
- st->element_mode );
+ gain_enc_lbr_fx( st->hBstr, st->acelp_cfg.gains_mode, coder_type, i_subfr, xn, y1, add( sub( Q_new, 1 ), shift ), y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR, st->element_mode );
IF( st->Opt_SC_VBR )
{
@@ -338,9 +343,10 @@ void encod_gen_2sbfr(
gp_clip_test_gain_pit_fx( st->element_mode, st->core_brate, gain_pit, st->clip_var_fx );
- Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/
- gcode16 = round_fx_sat( Lgcode ); /*Q0*/
- hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR, 0 ); /* Q15 */
+ Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/
+ gcode16 = round_fx_sat( Lgcode ); /*Q0*/
+
+ hLPDmem->tilt_code = est_tilt_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR ); /* Q15 */
move16();
/*-----------------------------------------------------------------*
diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h
index 8cf6be1cd0e6ca1385d5c7ec3588583ea115ac20..c5f124e57f154024c33b7688f7cc47e7529ab49c 100644
--- a/lib_enc/lib_enc.h
+++ b/lib_enc/lib_enc.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/lib_enc_fx.c b/lib_enc/lib_enc_fx.c
index fdadb6695a22ddba295b0bc5b337624d0d48b13d..3c6baff395c7e4df02b65aa2ba3dff41244226c0 100644
--- a/lib_enc/lib_enc_fx.c
+++ b/lib_enc/lib_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/long_enr_fx.c b/lib_enc/long_enr_fx.c
index 0228b6cbeacab739bc3cc11f9ae6a6f67cfc300e..46e455617ff6f55a18575767f80f4300671c1f13 100644
--- a/lib_enc/long_enr_fx.c
+++ b/lib_enc/long_enr_fx.c
@@ -145,9 +145,6 @@ void ivas_long_enr_fx(
move32();
}
- /*-----------------------------------------------------------------*
- * Initialize parameters for energy tracking and signal dynamics
- *-----------------------------------------------------------------*/
return;
}
@@ -168,52 +165,50 @@ void long_enr_fx(
* and total active speech energy
*-----------------------------------------------------------------*/
+ IF( LT_16( st_fx->ini_frame, 4 ) )
{
- IF( LT_16( st_fx->ini_frame, 4 ) )
+ st_fx->lp_noise_fx = hNoiseEst->totalNoise_fx; /* Q8 */
+ move16();
+ tmp = add( st_fx->lp_noise_fx, 2560 ); /*10.0 in Q8*/
+ st_fx->lp_speech_fx = s_max( st_fx->lp_speech_fx, tmp ); /* Q8 */
+ move16();
+ }
+ ELSE
+ {
+ /* if ( st->ini_frame < 150 ) {
+ st->lp_noise = 0.95f * st->lp_noise + 0.05f * st->totalNoise;
+ } else {
+ st->lp_noise = 0.98f * st->lp_noise + 0.02f * st->totalNoise;
+ } */
+ alpha = 655; /* 0.02 Q15 */
+ move16();
+ if ( LT_16( st_fx->ini_frame, 150 ) ) /* should match HE_LT_CNT_INIT_FX */
{
- st_fx->lp_noise_fx = hNoiseEst->totalNoise_fx; /* Q8 */
- move16();
- tmp = add( st_fx->lp_noise_fx, 2560 ); /*10.0 in Q8*/
- st_fx->lp_speech_fx = s_max( st_fx->lp_speech_fx, tmp ); /* Q8 */
+ alpha = 1638; /* 0.05 Q15 */
move16();
}
- ELSE
+ st_fx->lp_noise_fx = noise_est_AR1_Qx( hNoiseEst->totalNoise_fx, st_fx->lp_noise_fx, alpha ); /* Q8 state, alpha in Q15 */
+ move16();
+
+ test();
+ IF( ( localVAD_HE_SAD != 0 ) && ( high_lpn_flag == 0 ) )
{
- /* if ( st->ini_frame < 150 ) {
- st->lp_noise = 0.95f * st->lp_noise + 0.05f * st->totalNoise;
- } else {
- st->lp_noise = 0.98f * st->lp_noise + 0.02f * st->totalNoise;
- } */
- alpha = 655; /* 0.02 Q15 */
- move16();
- if ( LT_16( st_fx->ini_frame, 150 ) ) /* should match HE_LT_CNT_INIT_FX */
+ IF( LT_16( sub( st_fx->lp_speech_fx, Etot ), 10 * 256 ) ) /* 10.0 in Q8 */
{
- alpha = 1638; /* 0.05 Q15 */
+ /* st->lp_speech = 0.98f * st->lp_speech + 0.02f * Etot; */
+ st_fx->lp_speech_fx = noise_est_AR1_Qx( Etot, st_fx->lp_speech_fx, 655 ); /* Q8 state, 0.02 in Q15 */
move16();
}
- st_fx->lp_noise_fx = noise_est_AR1_Qx( hNoiseEst->totalNoise_fx, st_fx->lp_noise_fx, alpha ); /* Q8 state, alpha in Q15 */
- move16();
-
- test();
- IF( ( localVAD_HE_SAD != 0 ) && ( high_lpn_flag == 0 ) )
+ ELSE
{
- IF( LT_16( sub( st_fx->lp_speech_fx, Etot ), 10 * 256 ) ) /* 10.0 in Q8 */
- {
- /* st->lp_speech = 0.98f * st->lp_speech + 0.02f * Etot; */
- st_fx->lp_speech_fx = noise_est_AR1_Qx( Etot, st_fx->lp_speech_fx, 655 ); /* Q8 state, 0.02 in Q15 */
- move16();
- }
- ELSE
- {
- st_fx->lp_speech_fx = sub( st_fx->lp_speech_fx, 13 ); /* st->lp_speech = st->lp_speech - 0.05f; linear decay*/
- move16();
- }
+ st_fx->lp_speech_fx = sub( st_fx->lp_speech_fx, 13 ); /* st->lp_speech = st->lp_speech - 0.05f; linear decay*/
+ move16();
}
}
}
- /*-----------------------------------------------------------------*
- * Initialize parameters for energy tracking and signal dynamics
- *-----------------------------------------------------------------*/
+ /* Update */
+ st_fx->hNoiseEst->Etot_last_fx = Etot;
+
return;
}
diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c
index d62b97f1db7151d0069de760c28b827077d2d2d5..bc1f4cb3a979d6ec7b864bbe8a8505f500d48877 100644
--- a/lib_enc/lsf_enc_fx.c
+++ b/lib_enc/lsf_enc_fx.c
@@ -24,15 +24,13 @@
* Local function prototypes
*---------------------------------------------------------------------*/
-static void lsfq_CNG_fx( BSTR_ENC_HANDLE hBstr, const Word16 *lsf, const Word16 *wghts, Word16 *qlsf, Word32 *p_offset_scale1, Word32 *p_offset_scale2, Word16 *p_no_scales );
+static void lsfq_CNG_fx( const Word16 element_mode, BSTR_ENC_HANDLE hBstr, const Word16 *lsf, const Word16 *wghts, Word16 *qlsf, Word32 *p_offset_scale1, Word32 *p_offset_scale2, Word16 *p_no_scales );
static Word32 vq_lvq_lsf_enc( Word16 pred_flag, Word16 mode, Word16 u[], Word16 *levels, Word16 stages, Word16 w[], Word16 Idx[], const Word16 *lsf, const Word16 *pred, Word32 p_offset_scale1[][MAX_NO_SCALES + 1], Word32 p_offset_scale2[][MAX_NO_SCALES + 1], Word16 p_no_scales[][2], Word16 *resq, Word16 *lsfq );
static Word32 vq_lvq_lsf_enc_ivas_fx( Word16 pred_flag, Word16 mode, Word16 u[], Word16 *levels, Word16 stages, Word16 w[], Word16 Idx[], const Word16 *lsf, const Word16 *pred, Word16 *resq, Word16 *lsfq );
-static void lsf_mid_enc_fx( BSTR_ENC_HANDLE hBstr, Word16 nb_bits, const Word16 int_fs, const Word16 qlsp0[], const Word16 qlsp1[], Word16 lsp[], const Word16 coder_type, const Word16 bwidth, Word32 Bin_Ener_old[], Word32 Bin_Ener[], Word16 Q_ener, Word16 ppp_mode, Word16 nelp_mode );
-
-static void lsf_mid_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, Word16 nb_bits, const Word32 int_fs, const Word16 qlsp0[], const Word16 qlsp1[], Word16 lsp[], const Word16 coder_type, const Word16 bwidth, Word32 Bin_Ener_old[], Word16 Q_ener, Word16 ppp_mode, Word16 nelp_mode );
+static void lsf_mid_enc_fx( const Word16 element_mode, BSTR_ENC_HANDLE hBstr, Word16 nb_bits, const Word16 int_fs, const Word16 qlsp0[], const Word16 qlsp1[], Word16 lsp[], const Word16 coder_type, const Word16 bwidth, Word32 Bin_Ener_old[], Word32 Bin_Ener[], Word16 Q_ener, Word16 ppp_mode, Word16 nelp_mode );
/*===========================================================================*/
@@ -62,15 +60,16 @@ static void lsf_mid_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, Word16 nb_bits, const Wo
/* RETURN ARGUMENTS : */
/* _ None */
/*===========================================================================*/
+
void lsf_enc_fx(
- Encoder_State *st_fx, /* i/o: state structure */
- Word16 *lsf_new, /* o : quantized LSF vector */
- Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */
- Word16 *lsp_mid, /* i/o : mid-frame LSP vector */
- Word16 *Aq, /* o : quantized A(z) for 4 subframes */
- const Word16 Nb_ACELP_frames,
+ Encoder_State *st_fx, /* i/o: state structure */
+ Word16 *lsf_new, /* o : quantized LSF vector */
+ Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */
+ Word16 *lsp_mid, /* i/o : mid-frame LSP vector */
+ Word16 *Aq, /* o : quantized A(z) for 4 subframes */
const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */
+ const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */
const Word16 Q_new )
{
Word16 nBits = 0;
@@ -78,6 +77,8 @@ void lsf_enc_fx(
Word16 int_fs;
Word16 force_sf = 0;
move16();
+ Word16 no_param_lpc;
+ Word16 param_lpc[NPRM_LPC_NEW];
Word16 fec_lsf[M], stab, i;
Word32 L_tmp;
Word16 coder_type, ppp_mode, nelp_mode;
@@ -101,6 +102,7 @@ void lsf_enc_fx(
move16();
}
+ no_param_lpc = 0;
move16();
IF( st_fx->Opt_SC_VBR )
@@ -122,11 +124,20 @@ void lsf_enc_fx(
assert( st_fx->sr_core <= 32000 );
int_fs = extract_l( st_fx->sr_core );
move32();
+
/* convert LSPs to LSFs */
lsp2lsf_fx( lsp_new, lsf_new, M, int_fs );
/* check resonance for pitch clipping algorithm */
- gp_clip_test_lsf_fx( st_fx->element_mode, lsf_new, st_fx->clip_var_fx, 0 );
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ gp_clip_test_lsf_fx( st_fx->element_mode, lsf_new, st_fx->clip_var_fx, 0 );
+ }
+ ELSE
+ {
+ gp_clip_test_lsf_ivas_fx( st_fx->element_mode, st_fx->core_brate, lsf_new, st_fx->clip_var_fx, 0 );
+ }
+
/* Find the number of bits for LSF quantization */
nBits = 0;
@@ -161,12 +172,13 @@ void lsf_enc_fx(
move16();
}
}
+
force_sf = 0;
move16();
- /* first three ACELP frames after an HQ frame shall be processed only with safety-net quantizer */
test();
- if ( LT_16( Nb_ACELP_frames, 3 ) && NE_32( st_fx->core_brate, SID_2k40 ) )
+ if ( LT_16( st_fx->Nb_ACELP_frames, 3 ) && NE_32( st_fx->core_brate, SID_2k40 ) )
{
+ /* first three ACELP frames after an HQ frame shall be processed only with safety-net quantizer */
force_sf = 1;
move16();
}
@@ -185,7 +197,7 @@ void lsf_enc_fx(
*-------------------------------------------------------------------------------------*/
lsf_end_enc_fx( st_fx, lsf_new, lsf_new, nBits, coder_type, Q_new + QSCALE - 2,
- force_sf, NULL, NULL, NULL, st_fx->coder_type_raw );
+ force_sf, param_lpc, &no_param_lpc, NULL, st_fx->coder_type_raw, tdm_lsfQ_PCh );
/* convert quantized LSFs back to LSPs */
lsf2lsp_fx( lsf_new, lsp_new, M, int_fs );
@@ -196,7 +208,21 @@ void lsf_enc_fx(
/* don't use old LSF values if this is the first ACELP frame after HQ frames */
Copy( lsf_new, st_fx->lsf_old_fx, M );
}
+
/* set seed_acelp used in UC mode */
+ test();
+ IF( EQ_16( coder_type, UNVOICED ) && ( st_fx->element_mode > EVS_MONO ) )
+ {
+ st_fx->seed_acelp = 0;
+ move16();
+ FOR( i = no_param_lpc - 1; i >= 0; i-- )
+ {
+ /* rightshift before *seed_acelp+param_lpc[i] to avoid overflows*/
+ st_fx->seed_acelp = add( i_mult( add( shr( st_fx->seed_acelp, 1 ), param_lpc[i] ), 31821 ), 13849 );
+ move16();
+ }
+ }
+
IF( EQ_32( st_fx->core_brate, SID_2k40 ) )
{
/* return if SID frame (conversion to A(z) done in the calling function) */
@@ -218,7 +244,14 @@ void lsf_enc_fx(
FEC_lsf_estim_enc_fx( st_fx, fec_lsf );
/* in case of FEC in decoder - calculate LSF stability */
- stab = lsf_stab_fx( lsf_new, fec_lsf, 0, st_fx->L_frame ); // Q15
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ stab = lsf_stab_fx( lsf_new, fec_lsf, 0, st_fx->L_frame ); // Q15
+ }
+ ELSE
+ {
+ stab = lsf_stab_ivas_fx( lsf_new, fec_lsf, 0, st_fx->L_frame ); // Q15
+ }
test();
test();
@@ -249,19 +282,20 @@ void lsf_enc_fx(
Copy( st_fx->lsfoldbfi0_fx, st_fx->lsfoldbfi1_fx, M );
Copy( lsf_new, st_fx->lsfoldbfi0_fx, M );
-
/*-------------------------------------------------------------------------------------*
* Mid-frame LSF encoding
* LSP interpolation and conversion of LSPs to A(z)
*-------------------------------------------------------------------------------------*/
- if ( st_fx->rate_switching_reset )
+
+ IF( st_fx->rate_switching_reset )
{
/*extrapolation in case of unstable LSF convert*/
Copy( lsp_new, st_fx->lsp_old_fx, M ); // Q15
Copy( lsf_new, st_fx->lsf_old_fx, M ); // Q15
}
+
/* Mid-frame LSF encoding */
- lsf_mid_enc_fx( st_fx->hBstr, st_fx->acelp_cfg.mid_lsf_bits, int_fs, st_fx->lsp_old_fx, lsp_new, lsp_mid, coder_type, st_fx->bwidth, st_fx->Bin_E_old_fx, st_fx->Bin_E_fx, Q_new + QSCALE - 2, ppp_mode, nelp_mode );
+ lsf_mid_enc_fx( st_fx->element_mode, st_fx->hBstr, st_fx->acelp_cfg.mid_lsf_bits, int_fs, st_fx->lsp_old_fx, lsp_new, lsp_mid, coder_type, st_fx->bwidth, st_fx->Bin_E_old_fx, st_fx->Bin_E_fx, Q_new + QSCALE - 2, ppp_mode, nelp_mode );
test();
IF( EQ_16( st_fx->last_core, HQ_CORE ) && EQ_16( st_fx->core, ACELP_CORE ) )
@@ -296,265 +330,20 @@ void lsf_enc_fx(
IF( NE_32( st_fx->core_brate, SID_2k40 ) )
{
- st_fx->stab_fac_fx = lsf_stab_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame );
- }
-
- return;
-}
-
-void lsf_enc_ivas_fx(
- Encoder_State *st, /* i/o: state structure */
- Word16 *lsf_new, /* o : quantized LSF vector Q(x2.56)*/
- Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized Q15*/
- Word16 *lsp_mid, /* i/o : mid-frame LSP vector Q15*/
- Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/
- const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
- const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */
- const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */
- const Word16 Q_new )
-{
- Word16 nBits;
- Word16 force_sf;
- Word16 fec_lsf[M], stab, i;
- Word16 no_param_lpc;
-
- Word16 param_lpc[NPRM_LPC_NEW];
- Word32 L_tmp;
- Word16 coder_type, ppp_mode, nelp_mode;
-
- nBits = 0;
- force_sf = 0;
- move16();
- move16();
-
- test();
- IF( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, SID_1k75 ) )
- {
- coder_type = INACTIVE;
- move16();
- }
- ELSE
- {
- coder_type = st->coder_type;
- move16();
- }
-
- test();
- if ( EQ_16( coder_type, AUDIO ) && GSC_IVAS_mode > 0 )
- {
- coder_type = GENERIC;
- move16();
- }
-
- no_param_lpc = 0;
- move16();
-
- IF( st->Opt_SC_VBR )
- {
- ppp_mode = st->hSC_VBR->ppp_mode;
- nelp_mode = st->hSC_VBR->nelp_mode;
- move16();
- move16();
- }
- ELSE
- {
- ppp_mode = 0;
- nelp_mode = 0;
- move16();
- move16();
- }
-
- /* convert LSPs to LSFs */
- lsp2lsf_fx( lsp_new, lsf_new, M, st->sr_core );
-
- /* check resonance for pitch clipping algorithm */
- gp_clip_test_lsf_ivas_fx( st->element_mode, st->core_brate, lsf_new, st->clip_var_fx, 0 );
-
- /* Find the number of bits for LSF quantization */
- nBits = 0;
- move16();
- IF( EQ_32( st->core_brate, SID_2k40 ) )
- {
- nBits = LSF_BITS_CNG;
- move16();
- }
- ELSE
- {
- test();
- IF( ( nelp_mode == 0 ) && ( ppp_mode == 0 ) )
- {
- nBits = st->acelp_cfg.lsf_bits;
- move16();
- }
- ELSE IF( EQ_16( nelp_mode, 1 ) )
- {
- IF( st->bwidth == NB )
- {
- nBits = 32;
- move16();
- }
- ELSE IF( EQ_16( st->bwidth, WB ) )
- {
- nBits = 30;
- move16();
- }
- }
- ELSE IF( EQ_16( ppp_mode, 1 ) )
+ IF( st_fx->element_mode == EVS_MONO )
{
- nBits = 26;
- move16();
+ st_fx->stab_fac_fx = lsf_stab_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame );
}
- }
- force_sf = 0;
- move16();
- /* first three ACELP frames after an HQ frame shall be processed only with safety-net quantizer */
- test();
- if ( LT_16( st->Nb_ACELP_frames, 3 ) && NE_32( st->core_brate, SID_2k40 ) )
- {
- force_sf = 1;
- move16();
- }
-
- /* in case of unstable filter in decoder FEC, choose safety-net to help FEC */
- IF( EQ_16( st->next_force_safety_net, 1 ) )
- {
- force_sf = 1;
- move16();
- st->next_force_safety_net = 0;
- move16();
- }
-
- /*-------------------------------------------------------------------------------------*
- * Frame end LSF quantization
- *-------------------------------------------------------------------------------------*/
- lsf_end_enc_ivas_fx( st, lsf_new, lsf_new, nBits, coder_type, Q_new + QSCALE - 2,
- force_sf, param_lpc, &no_param_lpc, NULL, st->coder_type_raw, tdm_lsfQ_PCh );
-
- /* convert quantized LSFs back to LSPs */
- lsf2lsp_fx( lsf_new, lsp_new, M, st->sr_core );
-
- test();
- IF( EQ_16( st->last_core, HQ_CORE ) && ( st->core == ACELP_CORE ) )
- {
- /* don't use old LSF values if this is the first ACELP frame after HQ frames */
- Copy( lsf_new, st->lsf_old_fx, M );
- }
- /* set seed_acelp used in UC mode */
-
- test();
- IF( EQ_16( coder_type, UNVOICED ) && ( st->element_mode > EVS_MONO ) )
- {
- st->seed_acelp = 0;
- move16();
- FOR( i = no_param_lpc - 1; i >= 0; i-- )
+ ELSE
{
- /* rightshift before *seed_acelp+param_lpc[i] to avoid overflows*/
- st->seed_acelp = add( i_mult( add( shr( st->seed_acelp, 1 ), param_lpc[i] ), 31821 ), 13849 );
- move16();
+ st_fx->stab_fac_fx = lsf_stab_ivas_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame ); // Q15
}
}
- IF( EQ_32( st->core_brate, SID_2k40 ) )
- {
- /* return if SID frame (conversion to A(z) done in the calling function) */
- return;
- }
-
- /*-------------------------------------------------------------------------------------*
- * FEC - enforce safety-net in the next frame in case of unstable filter
- *-------------------------------------------------------------------------------------*/
-
- IF( NE_16( st->last_L_frame, st->L_frame ) )
- {
- /* FEC - in case of core switching, use old LSFs */
- Copy( st->lsf_old_fx, st->lsfoldbfi1_fx, M ); // Q15
- Copy( st->lsf_old_fx, st->lsfoldbfi0_fx, M ); // Q15
- Copy( st->lsf_old_fx, st->lsf_adaptive_mean_fx, M ); // Q15
- }
-
- FEC_lsf_estim_enc_fx( st, fec_lsf );
-
- /* in case of FEC in decoder - calculate LSF stability */
- stab = lsf_stab_ivas_fx( lsf_new, fec_lsf, 0, st->L_frame ); // Q15
-
- test();
- test();
- test();
- /* If decoder FEC frame may be unstable force safety-net usage */
- IF( ( EQ_16( st->L_frame, L_FRAME16k ) ) && ( LT_16( stab, STAB_FAC_LIMIT_FX ) ) && ( EQ_16( coder_type, GENERIC ) ) )
- {
- st->next_force_safety_net = 1;
- move16();
- }
- ELSE IF( ( LT_16( stab, STAB_FAC_LIMIT_FX ) ) && ( EQ_16( st->clas, VOICED_CLAS ) || ( LT_16( st->clas, VOICED_CLAS ) && EQ_16( coder_type, AUDIO ) ) ) )
- {
- st->next_force_safety_net = 1;
- move16();
- }
-
-
- /* FEC - update adaptive LSF mean vector */
- FOR( i = 0; i < M; i++ )
- {
- L_tmp = L_mult( lsf_new[i], 10922 ); /*Q(x2.56+16)*/
- L_tmp = L_mac( L_tmp, st->lsfoldbfi1_fx[i], 10922 ); /*Q(x2.56+16)*/
- L_tmp = L_mac( L_tmp, st->lsfoldbfi0_fx[i], 10922 ); /*Q(x2.56+16)*/
- st->lsf_adaptive_mean_fx[i] = extract_h( L_tmp ); /*Q(x2.56)*/
- }
-
- /* FEC - update LSF memories */
- Copy( st->lsfoldbfi0_fx, st->lsfoldbfi1_fx, M );
- Copy( lsf_new, st->lsfoldbfi0_fx, M );
-
-
- /*-------------------------------------------------------------------------------------*
- * Mid-frame LSF encoding
- * LSP interpolation and conversion of LSPs to A(z)
- *-------------------------------------------------------------------------------------*/
- IF( st->rate_switching_reset )
- {
- /*extrapolation in case of unstable LSF convert*/
- Copy( lsp_new, st->lsp_old_fx, M ); // Q15
- Copy( lsf_new, st->lsf_old_fx, M ); // Q15
- }
- /* Mid-frame LSF encoding */
- lsf_mid_enc_ivas_fx( st->hBstr, st->acelp_cfg.mid_lsf_bits, st->sr_core, st->lsp_old_fx, lsp_new, lsp_mid, coder_type, st->bwidth, st->Bin_E_old_fx, Q_new + QSCALE - 2, ppp_mode, nelp_mode );
-
- test();
- IF( EQ_16( st->last_core, HQ_CORE ) && EQ_16( st->core, ACELP_CORE ) )
- {
- /* don't use old LSP/LSF values if this is the first ACELP frame after HQ frames */
- Copy( lsp_mid, st->lsp_old_fx, M );
- lsp2lsf_fx( lsp_mid, st->lsf_old_fx, M, st->sr_core );
- }
-
- /* LSP interpolation and conversion of LSPs to A(z) */
- test();
- IF( EQ_16( tdm_low_rate_mode, 1 ) && GT_16( coder_type, UNVOICED ) )
- {
- IF( EQ_16( st->active_cnt, 1 ) )
- {
- Copy( lsp_mid, st->lsp_old_fx, M ); // Q15
- lsp2lsf_fx( lsp_mid, st->lsf_old_fx, M, st->sr_core );
- Copy( lsp_new, lsp_mid, M ); // Q15
- }
-
- /* LSP interpolation and conversion of LSPs to A(z) - two-subframe mode */
- int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, Aq, M, -2 );
- }
- ELSE
- {
- int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid, lsp_new, Aq, M, 0 );
- }
- /*------------------------------------------------------------------*
- * Check LSF stability (distance between old LSFs and current LSFs)
- *------------------------------------------------------------------*/
- IF( NE_32( st->core_brate, SID_2k40 ) )
- {
- st->stab_fac_fx = lsf_stab_ivas_fx( lsf_new, st->lsf_old_fx, 0, st->L_frame ); // Q15
- }
return;
}
+
+
/*-------------------------------------------------------------------*
* lsfq_CNG_fx()
*
@@ -567,10 +356,11 @@ void lsf_enc_ivas_fx(
*-------------------------------------------------------------------*/
static void lsfq_CNG_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 *lsf, /*x2.56 unquantized LSF vector */
- const Word16 *wghts, /*Q10 LSF weights */
- Word16 *qlsf, /*x2.56 quantized LSF vecotor */
+ const Word16 element_mode, /* i : element mode */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle*/
+ const Word16 *lsf, /*x2.56 unquantized LSF vector */
+ const Word16 *wghts, /*Q10 LSF weights */
+ Word16 *qlsf, /*x2.56 quantized LSF vecotor */
Word32 *p_offset_scale1,
Word32 *p_offset_scale2,
Word16 *p_no_scales )
@@ -610,7 +400,6 @@ static void lsfq_CNG_fx(
move16();
}
-
min_dist = L_add( MAXINT32, 0 );
FOR( i = first_cb; i < last_cb; i++ )
{
@@ -643,10 +432,20 @@ static void lsfq_CNG_fx(
/* quantize the difference with LVQ */
/* MSVQ_ROM to be updated */
- mslvq_cng_fx( idx_cv, dd, qlsf, ddq, idx_lead_cng, idx_scale_cng, wghts, p_no_scales );
+ IF( element_mode == EVS_MONO )
+ {
+ mslvq_cng_fx( idx_cv, dd, qlsf, ddq, idx_lead_cng, idx_scale_cng, wghts, p_no_scales );
+
+ index_lvq_fx( ddq, idx_lead_cng, idx_scale_cng, START_CNG + idx_cv, idx_lvq,
+ p_offset_scale1, p_offset_scale2, p_no_scales );
+ }
+ ELSE
+ {
+ mslvq_cng_ivas_fx( idx_cv, dd, qlsf, ddq, idx_lead_cng, idx_scale_cng, wghts );
+
+ index_lvq_ivas_fx( ddq, idx_lead_cng, idx_scale_cng, START_CNG_IVAS + idx_cv, idx_lvq, 0 );
+ }
- index_lvq_fx( ddq, idx_lead_cng, idx_scale_cng, START_CNG + idx_cv, idx_lvq,
- p_offset_scale1, p_offset_scale2, p_no_scales );
Vr_add( qlsf, &CNG_SN1_fx[idx_cv * M], qlsf, M );
/* write the VQ index to the bitstream */
@@ -659,113 +458,24 @@ static void lsfq_CNG_fx(
return;
}
-static void lsfq_CNG_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 *lsf, /*x2.56 unquantized LSF vector */
- const Word16 *wghts, /*Q10 LSF weights */
- Word16 *qlsf /*x2.56 quantized LSF vecotor */
+
+/*-------------------------------------------------------------------*
+ * qlsf_Mode_Select_fx()
+ *
+ * Mode selection for LSF quantizer
+ *-------------------------------------------------------------------*/
+
+static Word16 qlsf_Mode_Select_fx(
+ const Word16 *w, /* i : weighting vector Q8 */
+ const Word16 *pred1, /* i : prediction vector x2.56 */
+ const Word16 streaklimit, /* i : predictive streak limit Q15 */
+ const Word32 op_loop_thr /* i : Open-loop Threshold */
)
{
- Word16 i, j, idx_cv, idx_lvq[3];
- Word32 min_dist, dist;
- Word16 dd[M], ddq[M];
- const Word16 *p_cb;
- Word16 first_cb, last_cb;
- Word16 idx_lead_cng[2], idx_scale_cng[2];
- Word16 tmp;
-
- idx_cv = 0;
- move16();
-
- /* quantize first stage with 4 bits
- The sampling frequency of the LP-CNG frame can be determined by checking the value of the highest order LSF
- coefficient (last coefficient of lsf). If the last LSF coefficient (lsf[M-1]) is larger than 6350
- the decoded frame is WB2 with sampling rate of 16 kHz, otherwise it is sampled at 12.8kHz and contains
- either NB or WB LSF data. */
- IF( GT_16( lsf[M - 1], WB_LIMIT_LSF_FX ) ) /* 16kHz sampled LSF vector*/
- {
- p_cb = &CNG_SN1_fx[0];
- move16();
- first_cb = 0;
- move16();
- last_cb = 6;
- move16();
- }
- ELSE /* 12.8kHz sampled LSF vector*/
- {
- p_cb = &CNG_SN1_fx[6 * M];
- move16();
- first_cb = 6;
- move16();
- last_cb = M;
- move16();
- }
-
-
- min_dist = L_add( MAXINT32, 0 );
- FOR( i = first_cb; i < last_cb; i++ )
- {
- tmp = sub( *p_cb, shl( lsf[0], 1 ) ); /*x2.56 */
- dist = Mult_32_16( L_mult0( wghts[0], *p_cb ), tmp ); /*Q8 + x2.56 -Q15 + x2.56 = Q-7 + x2.56+x.256 */
- p_cb++;
- FOR( j = 1; j < M; j++ )
- {
- tmp = sub( *p_cb, lsf[j] );
- tmp = sub( tmp, lsf[j] );
-
- dist = L_add( dist, Mult_32_16( L_mult0( wghts[j], *p_cb ), tmp ) );
- p_cb++;
- }
- IF( LT_32( dist, min_dist ) )
- {
- min_dist = dist;
- move16(); /*Q-4 */
- idx_cv = i;
- move16();
- }
- }
-
- /* calculate difference */
- FOR( i = 0; i < M; i++ )
- {
- dd[i] = sub( lsf[i], CNG_SN1_fx[idx_cv * M + i] ); /*x2.56 */
- move16();
- }
-
- /* quantize the difference with LVQ */
- /* MSVQ_ROM to be updated */
- mslvq_cng_ivas_fx( idx_cv, dd, qlsf, ddq, idx_lead_cng, idx_scale_cng, wghts );
-
- index_lvq_ivas_fx( ddq, idx_lead_cng, idx_scale_cng, START_CNG_IVAS + idx_cv, idx_lvq, 0 );
- Vr_add( qlsf, &CNG_SN1_fx[idx_cv * M], qlsf, M );
-
- /* write the VQ index to the bitstream */
- push_indice( hBstr, IND_ISF_0_0, idx_cv, 4 );
-
- /* write the LVQ index to the bitstream */
- push_indice( hBstr, IND_ISF_0_1, idx_lvq[0], LEN_INDICE );
- push_indice( hBstr, IND_ISF_0_1, idx_lvq[1], LSF_BITS_CNG - 4 - LEN_INDICE );
-
- return;
-}
-/*-------------------------------------------------------------------*
- * qlsf_Mode_Select_fx()
- *
- * Mode selection for LSF quantizer
- *-------------------------------------------------------------------*/
-
-
-static Word16 qlsf_Mode_Select_fx(
- const Word16 *w, /* i : weighting vector Q8 */
- const Word16 *pred1, /* i : prediction vector x2.56 */
- const Word16 streaklimit, /* i : predictive streak limit Q15 */
- const Word32 op_loop_thr /* i : Open-loop Threshold */
-)
-{
- Word16 pred_pow2[M];
- Word32 temp32, En = 0;
- Word16 safety_net;
- Word16 i, cs, cl;
+ Word16 pred_pow2[M];
+ Word32 temp32, En = 0;
+ Word16 safety_net;
+ Word16 i, cs, cl;
/* calculate the prediction residual */
cl = 0;
@@ -801,579 +511,73 @@ static Word16 qlsf_Mode_Select_fx(
safety_net = 0;
move16();
}
- return safety_net;
-}
-
-
-/*========================================================================*/
-/* FUNCTION : lsf_end_enc_fx() */
-/*------------------------------------------------------------------------*/
-/* PURPOSE : Quantization of LSF parameters */
-/*------------------------------------------------------------------------*/
-/* INPUT ARGUMENTS : */
-/* _ (Word16*) lsf : LSF in the frequency domain (0..6400) x2.56 */
-/* _ (Word16) coder_type : coding type */
-/* _ (Word16) bwidth : input signal bandwidth */
-/* _ (Word16) nBits : number of bits used for ISF quantization */
-/* _ (Word16*) stable_isp : most recent stable ISP (can be */
-/* removed after passing to LSF) Q15 */
-/* _ (Word16*) stable_lsp : most recent stable LSP Q15 */
-/* _ (Word32*) grid : Table of 100 grid points for evaluating */
-/* Chebyshev polynomials Q31 */
-/* _ (Word16) int_fs : sampling frequency */
-/* _ (Word32) core_brate : Coding Bit Rate */
-/* _ (Word16) force_sf : Force safety-net usage if possible */
-/* _ (Word32*) Bin_Ener : FFT Bin energy 128 *2 sets Q_ener */
-/* _ (Word16) Q_ener : Q format of Bin_Ener */
-/* _ (Word32*) offset_scale1: offsets for LSF LVQ structure 1st */
-/* 8-dim subvector Q0 */
-/* _ (Word32*) offset_scale2: offsets for LSF LVQ structure 2nd */
-/* 8-dim subvector Q0 */
-/* _ (Word32*) offset_scale1_p: offsets for LSF LVQ structure, pred. */
-/* case, 1st 8-dim subvector Q0 */
-/* _ (Word32*) offset_scale2_p: offsets for LSF LVQ structure, */
-/* pred. case, 2nd 8-dim subvector Q0 */
-/* _ (Word16*) no_scales : LSF LVQ structure Q0 */
-/* _ (Word16*) no_scales_p : LSF LVQ structure Q0 */
-/*------------------------------------------------------------------------*/
-/* INPUT/OUTPUT ARGUMENTS : */
-/* _ (Word16*) mem_AR : quantizer memory for AR model x2.56 */
-/*------------------------------------------------------------------------*/
-/* OUTPUT ARGUMENTS : */
-/* _ (Word16*) qlsf : quantized LSFs in the cosine domain x2.56 */
-/*------------------------------------------------------------------------*/
-
-/*------------------------------------------------------------------------*/
-/* RETURN ARGUMENTS : */
-/* _ None */
-/*========================================================================*/
-void lsf_end_enc_fx(
- Encoder_State *st, /* i/o: encoder state structure */
- const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) x2.56*/
- Word16 *qlsf, /* o : quantized LSF x2.56*/
- const Word16 nBits_in, /* i : number of bits to spend on ISF quantization */
- const Word16 coder_type_org, /* i : coding type */
- Word16 Q_ener, /* i : Q valuen for Bin_Ener */
- Word16 force_sf, /* i : Force safety-net usage if coding type supports */
- Word16 *lpc_param,
- Word16 *no_indices,
- Word16 *bits_param_lpc,
- Word16 coder_type_raw /* i : Coder type (LSF coder_type have some special cases)*/
-)
-{
- Word16 i;
- Word16 Idx0[MAX_VQ_STAGES + 3]; /* Optimal codebook indices for safety-net quantizer */
- Word16 Idx1[MAX_VQ_STAGES + 3]; /* Optimal codebook indices for predictive quantizer */
- Word16 indice[MAX_VQ_STAGES + 3]; /* Temp. array of indice for vector de-quantizer */
- Word16 mode_lvq = 0, mode_lvq_p = 0; /* LVQ mode and predictive LVQ mode */
- Word16 bits0[MAX_VQ_STAGES], bits1[MAX_VQ_STAGES];
- const Word16 *Bit_alloc1 = NULL;
- Word32 Err[2]; /* Quantization error for safety-net(0) and predictive(1) quantizers */
- Word16 Tmp[M]; /* Temporary target vector (mean and prediction removed) */
- Word16 pred0[M]; /* Prediction for the safety-net quantizer (usually mean) */
- Word16 pred1[M]; /* Prediction for the predictive quantizer */
- Word16 pred2[M]; /* Prediction for the predictive quantizer */
- Word16 wghts[M]; /* Weighting used for quantizer (currently GSM based) */
- Word16 stages0; /* Amount of stages used by safety-net quantizer */
- Word16 stages1; /* Amount of stages used by predictive quantizer */
- Word16 levels0[MAX_VQ_STAGES]; /* Sizes of different codebook stages for safety-net quantizer */
- Word16 levels1[MAX_VQ_STAGES]; /* Sizes of different codebook stages for predictive quantizer */
- Word16 predmode; /* 0: safety-net only, 1: predictive only, 2: best of the two */
- Word16 safety_net, cumleft, num_bits;
- Word16 *Idx, stages, *bits;
- Word16 Tmp2[M], Tmp1[M];
- Word32 abs_threshold; /* Absolute threshold depending on signal bandwidth, that indicates
- very good perceptual LSF quantization performance */
- Word16 lsfq[M * 2], resq[M * 2];
- Word16 coder_type; /* coder type (from LSF quantizer point of view) */
- Word16 nBits; /* Number of bits */
- Word16 TCQIdx0[M + 2]; /* Optimal codebook indices for VQ-TCQ quantizer */
- Word16 *TCQIdx;
- Word16 tmp;
- Word16 flag_1bit_gran;
- BSTR_ENC_HANDLE hBstr = st->hBstr;
-
- flag_1bit_gran = (Word16) GT_16( st->element_mode, EVS_MONO );
-
- nBits = nBits_in;
- move16();
- /* Update LSF coder_type for LSF quantizer for some special cases */
- test();
- test();
- test();
- IF( EQ_16( coder_type_org, GENERIC ) && EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( st->codec_mode, MODE1 ) )
- {
- IF( EQ_16( coder_type_raw, VOICED ) )
- {
- coder_type = VOICED;
- move16(); /* Reflect Inactive mode */
- if ( EQ_16( flag_1bit_gran, 1 ) )
- {
- nBits = sub( nBits, 1 ); /* This is for real Generic*/
- }
- }
- ELSE
- {
- nBits = sub( nBits, 1 ); /* This is for real Generic*/
- coder_type = coder_type_org;
- move16();
- }
- }
- ELSE
- {
- coder_type = coder_type_org;
- move16();
- }
-
- /*----------------------------------------------------------------------------------- -*
- * Calculate the number of stages and levels for each stage based on allowed bit budget
- * Set absolute threshold for codebook-type decision logic depending on signal bandwidth
- *------------------------------------------------------------------------------------ -*/
- IF( EQ_16( st->bwidth, NB ) )
- {
- abs_threshold = L_add( SFNETLOWLIMIT_NB, 0 );
- }
- ELSE
- {
- abs_threshold = L_add( SFNETLOWLIMIT_WB, 0 );
- }
- /* Calculate LSF weighting coefficients */
- Unified_weighting_fx( &st->Bin_E_fx[L_FFT / 2], Q_ener, lsf, wghts, (Word16) EQ_16( st->bwidth, NB ), (Word16) EQ_16( coder_type, UNVOICED ), st->sr_core, M );
-
- /*--------------------------------------------------------------------------------*
- * LSF quantization of SID frames
- *--------------------------------------------------------------------------------*/
- IF( EQ_32( st->core_brate, SID_2k40 ) )
- {
- lsfq_CNG_fx( hBstr, lsf, wghts, qlsf, &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->no_scales_fx[0][0] );
- sort_fx( qlsf, 0, M - 1 );
- reorder_lsf_fx( qlsf, MODE1_LSF_GAP_FX, M, st->sr_core );
-
- return;
- }
- /* Find allowed predictor mode for current coder_type. (SN only (0), SN/AR switched (2) or MA predictive (1) */
- find_pred_mode( &predmode, coder_type, st->bwidth, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate );
-
- /*----------------------------------------------------------------*
- * Calculate number of stages and levels for each stage based on the allowed bit allocation
- * (subtract one bit for LSF predictor selection)
- *----------------------------------------------------------------*/
- lsf_allocate_fx( sub( nBits, shr( predmode, 1 ) ), mode_lvq, mode_lvq_p, &stages0, &stages1, levels0, levels1, bits0, bits1 );
-
-
- /*--------------------------------------------------------------------------------*
- * LSF quantization of all other frames but SID frames
- * Select safety-net or predictive mode
- *--------------------------------------------------------------------------------*/
-
- Err[0] = MAXINT32;
- move32();
- Err[1] = MAXINT32;
- move32();
- /* for mem_MA update */
- FOR( i = 0; i < M; i++ )
- {
- pred1[i] = add( ModeMeans_fx[mode_lvq][i], mult_r( MU_MA_FX, st->mem_MA_fx[i] ) );
- move16();
- }
-
- IF( predmode == 0 )
- {
- /* Subtract only mean */
- Copy( ModeMeans_fx[mode_lvq], pred0, M );
- Vr_subt( lsf, pred0, Tmp, M );
-
- /* LVQ quantization (safety-net only) */
- Err[0] = vq_lvq_lsf_enc( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0,
- st->offset_scale1_fx, st->offset_scale2_fx, st->no_scales_fx, resq, lsfq );
- safety_net = 1;
- move16();
- st->pstreaklen = 0;
- move16(); /* predictive LSF quantizer streak is ended with safety-net */
- }
- ELSE IF( EQ_16( predmode, 1 ) ) /* only MA prediction */
- {
- Vr_subt( lsf, pred1, Tmp1, M );
- Err[1] = vq_lvq_lsf_enc( 2, mode_lvq_p, Tmp1, levels1, stages1, wghts, Idx1, lsf, pred1,
- st->offset_scale1_p_fx, st->offset_scale2_p_fx, st->no_scales_p_fx, resq, lsfq );
-
- safety_net = 0;
- move16();
- }
- ELSE
- {
- /* Adaptive scaling factor (multiplier) is updated in order to reduce the amount of consecutive predictive frames in
- case of possible frame erasure. AR-predictive usage for VOICED mode is allowed to be higher than other modes. */
- test();
- test();
- test();
- IF( ( ( GT_16( st->pstreaklen, ( STREAKLEN + 3 ) ) ) && ( EQ_16( coder_type, VOICED ) ) ) || ( ( GT_16( st->pstreaklen, ( STREAKLEN ) ) ) && ( NE_16( coder_type, VOICED ) ) ) )
- {
- /* update the adaptive scaling factor to become smaller with increasing number of concecutive predictive frames. */
- st->streaklimit_fx = mult( st->streaklimit_fx, STREAKMULT_FX ); // Q15
- move16();
- }
-
- IF( st->pstreaklen == 0 )
- {
- /* reset the consecutive AR-predictor multiplier */
- st->streaklimit_fx = 32767; /*1.0 in Q15 */
- move16();
- }
-
- /* VOICED_WB@16kHz */
- test();
- IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( coder_type, VOICED ) && flag_1bit_gran == 0 )
- {
- /* Subtract mean and AR prediction */
- Copy( ModeMeans_fx[mode_lvq], pred0, M );
- /* subtract only mean */
- Vr_subt( lsf, pred0, Tmp, M );
-
- FOR( i = 0; i < M; i++ )
- {
- /* subtract mean and AR prediction */
- pred2[i] = mult( Predictors_fx[mode_lvq_p][i], sub( st->mem_AR_fx[i], pred0[i] ) );
- Tmp2[i] = sub( Tmp[i], pred2[i] );
- pred2[i] = add( pred2[i], pred0[i] );
- }
-
- /* select safety_net or predictive */
- safety_net = qlsf_Mode_Select_fx( wghts, Tmp2, st->streaklimit_fx, OP_LOOP_THR_HVO );
- IF( EQ_16( force_sf, 1 ) )
- {
- safety_net = 1;
- move16();
- }
-
- IF( safety_net )
- {
- /* Safety-net - BC-TCQ quantization : SN */
- Err[0] = qlsf_ARSN_tcvq_Enc_16k_fx( Tmp, lsfq, TCQIdx0, wghts, sub( nBits, 1 ), safety_net );
- st->pstreaklen = 0;
- move16();
- }
- ELSE
- {
- /* predictive - BC-TCQ quantization : AR */
- Err[1] = qlsf_ARSN_tcvq_Enc_16k_fx( Tmp2, lsfq, TCQIdx0, wghts, sub( nBits, 1 ), safety_net );
- st->pstreaklen = add( st->pstreaklen, 1 );
- }
- }
- /* all other frames (not VOICED@16kHz) */
- ELSE
- {
- /* Subtract mean and AR prediction */
- Copy( ModeMeans_fx[mode_lvq], pred0, M );
- /* subtract only mean */
- Vr_subt( lsf, pred0, Tmp, M );
-
- FOR( i = 0; i < M; i++ )
- {
- /* subtract mean and AR prediction */
- pred2[i] = add( pred0[i], mult( Predictors_fx[mode_lvq_p][i], sub( st->mem_AR_fx[i], pred0[i] ) ) );
- Tmp2[i] = sub( lsf[i], pred2[i] );
- }
-
- /* safety-net */
- Err[0] = vq_lvq_lsf_enc( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, st->offset_scale1_fx, st->offset_scale2_fx, st->no_scales_fx, resq, lsfq );
- /* Predictive quantizer is calculated only if it can be selected */
- test();
- IF( !force_sf || GT_32( Err[0], abs_threshold ) )
- {
- Err[1] = vq_lvq_lsf_enc( 2, mode_lvq_p, Tmp2, levels1, stages1, wghts, Idx1, lsf, pred2,
- st->offset_scale1_p_fx, st->offset_scale2_p_fx, st->no_scales_p_fx, &resq[M], &lsfq[M] );
- }
- test();
- test();
- /* Select whether to use safety-net (non-predictive) or predictive LSF quantizer. The decision is based on following:
- if the non-predictive (safety-net) quantization error (Err[0]) is low enough (spectral distortion is low) it is selected
- or if the predictively quantized error (Err[1]) is by at least adaptive margin smaller than non-predictive quantizer.
- or if the in case of frame erasure the resulting concealed predictive LSF would be unstable safety-net is selected */
- IF( force_sf || LT_32( Mult_32_16( Err[0], ( st->streaklimit_fx ) ), L_add( Err[1], Mult_32_16( Err[1], PREFERSFNET_FX ) ) ) || LT_32( Err[0], abs_threshold ) )
- {
- safety_net = 1;
- move16();
- st->pstreaklen = 0;
- move16(); /* Reset the consecutive predictive frame counter */
- }
- ELSE
- {
- safety_net = 0;
- move16(); /* Increase the consecutive predictive frame counter by one */
- st->pstreaklen = add( st->pstreaklen, 1 );
- }
- }
- }
-
- /*--------------------------------------------------------------------------* \
- * Write indices to array \
- *--------------------------------------------------------------------------*/
-
- IF( EQ_16( st->codec_mode, MODE1 ) && EQ_16( st->core, ACELP_CORE ) )
- {
- /* write coder_type bit for VOICED@16kHz or GENERIC@16kHz */
- test();
- IF( EQ_16( coder_type_org, GENERIC ) && EQ_32( st->sr_core, INT_FS_16k ) )
- {
- /* VOICED =2 and GENERIC=3, so "coder_type-2" means VOICED =0 and GENERIC=1*/
- push_indice( hBstr, IND_LSF_PREDICTOR_SELECT_BIT, sub( coder_type, 2 ), 1 );
- }
-
- /* write predictor selection bit */
- IF( EQ_16( predmode, 2 ) )
- {
- push_indice( st->hBstr, IND_LSF_PREDICTOR_SELECT_BIT, safety_net, 1 );
- }
-
- test();
- IF( EQ_16( coder_type, VOICED ) && EQ_32( st->sr_core, INT_FS_16k ) && flag_1bit_gran == 0 )
- {
- /* BC-TCVQ (only for VOICED@16kHz) */
- TCQIdx = &TCQIdx0[1];
- Bit_alloc1 = &BC_TCVQ_BIT_ALLOC_40B[1];
- FOR( i = 0; i < ( M / 2 ) + 3; i++ )
- {
- push_indice( hBstr, IND_LSF, TCQIdx[i], Bit_alloc1[i] );
- }
- }
- ELSE
- {
- cumleft = nBits;
- move16();
- IF( EQ_16( predmode, 2 ) )
- {
- /* subtract predictor selection bit */
- cumleft = sub( nBits, 1 );
- }
-
- IF( safety_net )
- {
- stages = stages0;
- move16();
- Idx = Idx0;
- move16();
- bits = bits0;
- move16();
- }
- ELSE
- {
- stages = stages1;
- move16();
- Idx = Idx1;
- move16();
- bits = bits1;
- move16();
- }
-
- tmp = sub( stages, 1 );
- FOR( i = 0; i < tmp; i++ )
- {
- indice[i] = Idx[i];
- move16();
- num_bits = bits[i];
- move16();
- cumleft -= num_bits;
- move16();
- push_indice( hBstr, IND_LSF, indice[i], num_bits );
- }
-
- WHILE( cumleft > 0 )
- {
- indice[i] = Idx[i];
- move16();
-
- IF( GT_16( cumleft, LEN_INDICE ) )
- {
- num_bits = LEN_INDICE;
- move16();
- }
- ELSE
- {
- num_bits = cumleft;
- move16();
- }
-
- cumleft = sub( cumleft, num_bits );
- push_indice( hBstr, IND_LSF, indice[i], num_bits );
- i = add( i, 1 );
- }
- }
- }
- ELSE
- {
- test();
- IF( EQ_16( coder_type, VOICED ) && EQ_32( st->sr_core, INT_FS_16k ) )
- {
- /* BC-TCVQ (only for VOICED@16kHz) */
- /* Number of quantization indices */
- *no_indices = 10;
- move16();
- FOR( i = 0; i < *no_indices; i++ )
- {
- lpc_param[i] = TCQIdx0[i];
- move16();
- bits_param_lpc[i] = BC_TCVQ_BIT_ALLOC_40B[i]; // Q0
- move16();
- }
- }
- ELSE
- {
- /* Number of quantization indices */
-
- /* there are 31 bits */
- IF( EQ_16( safety_net, 1 ) )
- {
- Idx = Idx0;
- move16();
- *no_indices = add( stages0, 1 );
- FOR( i = 0; i < stages0; i++ )
- {
- lpc_param[i] = Idx[i];
- move16();
- indice[i] = Idx[i];
- move16();
- bits_param_lpc[i] = bits0[i];
- move16();
- }
- lpc_param[stages0] = Idx[stages0];
- move16();
- indice[stages0] = Idx[stages0];
- move16();
- tmp = sub( stages0, 1 );
- bits_param_lpc[tmp] = LEN_INDICE;
- move16();
- bits_param_lpc[stages0] = sub( bits0[tmp], LEN_INDICE );
- }
- ELSE
- {
- *no_indices = add( stages1, 1 );
- Idx = Idx1;
- move16();
- FOR( i = 0; i < stages1; i++ )
- {
- lpc_param[i] = ( Idx[i] );
- move16();
- indice[i] = Idx[i];
- move16();
- bits_param_lpc[i] = bits1[i];
- move16();
- }
- lpc_param[stages1] = ( Idx[stages1] );
- move16();
- indice[stages1] = Idx[stages1];
- move16();
- tmp = sub( stages1, 1 );
- bits_param_lpc[tmp] = LEN_INDICE;
- move16();
- bits_param_lpc[stages1] = sub( bits1[tmp], LEN_INDICE );
- }
- IF( EQ_16( predmode, 2 ) )
- {
- FOR( i = *no_indices; i > 0; i-- )
- {
- tmp = sub( i, 1 );
- lpc_param[i] = lpc_param[tmp];
- move16();
- bits_param_lpc[i] = bits_param_lpc[tmp];
- move16();
- }
- lpc_param[0] = safety_net;
- move16(); /* put the safety net info on the last param */
- bits_param_lpc[0] = 1;
- move16();
- *no_indices = add( *no_indices, 1 );
- }
- }
- }
-
-
- /*--------------------------------------------------------------------------*
- * De-quantize encoded LSF vector
- *--------------------------------------------------------------------------*/
-
- IF( safety_net )
- {
- /* Safety-net */
- test();
- IF( EQ_16( coder_type, VOICED ) && EQ_32( st->sr_core, INT_FS_16k ) && flag_1bit_gran == 0 )
- {
- /* BC-TCQ */
- Copy( lsfq, st->mem_MA_fx, M );
- Vr_add( lsfq, pred0, qlsf, M );
- }
- ELSE
- {
- {
- vq_dec_lvq_fx( 1, qlsf, &indice[0], stages0, M, mode_lvq, levels0[stages0 - 1],
- &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->offset_scale1_p_fx[0][0], &st->offset_scale2_p_fx[0][0],
- &st->no_scales_fx[0][0], &st->no_scales_p_fx[0][0] );
- Vr_add( qlsf, pred0, qlsf, M );
- Vr_subt( qlsf, pred1, st->mem_MA_fx, M );
- }
- }
- }
- ELSE
- {
- test();
- IF( EQ_16( coder_type, VOICED ) && EQ_32( st->sr_core, INT_FS_16k ) && flag_1bit_gran == 0 )
- {
- /* BC-TCVQ */
- Copy( lsfq, st->mem_MA_fx, M );
- Vr_add( lsfq, pred2, qlsf, M );
- }
- ELSE
- {
- /* LVQ */
- vq_dec_lvq_fx( 0, qlsf, &indice[0], stages1, M, mode_lvq_p, levels1[stages1 - 1],
- &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->offset_scale1_p_fx[0][0],
- &st->offset_scale2_p_fx[0][0], &st->no_scales_fx[0][0], &st->no_scales_p_fx[0][0] );
- IF( EQ_16( predmode, 1 ) )
- {
- Copy( qlsf, st->mem_MA_fx, M );
- Vr_add( qlsf, pred1, qlsf, M );
- }
- ELSE
- {
- Vr_add( qlsf, pred2, qlsf, M );
- Vr_subt( qlsf, pred1, st->mem_MA_fx, M );
- }
- }
- }
-
- /* Sort the quantized vector to ascending order */
- sort_fx( qlsf, 0, M - 1 );
-
- /* Verify stability by adding minimum separation */
- reorder_lsf_fx( qlsf, MODE1_LSF_GAP_FX, M, st->sr_core );
+ return safety_net;
+}
- /* Update AR-predictor memories */
- Copy( qlsf, st->mem_AR_fx, M );
- return;
-}
+/*========================================================================*/
+/* FUNCTION : lsf_end_enc_fx() */
+/*------------------------------------------------------------------------*/
+/* PURPOSE : Quantization of LSF parameters */
+/*------------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Word16*) lsf : LSF in the frequency domain (0..6400) x2.56 */
+/* _ (Word16) coder_type : coding type */
+/* _ (Word16) bwidth : input signal bandwidth */
+/* _ (Word16) nBits : number of bits used for ISF quantization */
+/* _ (Word16*) stable_isp : most recent stable ISP (can be */
+/* removed after passing to LSF) Q15 */
+/* _ (Word16*) stable_lsp : most recent stable LSP Q15 */
+/* _ (Word32*) grid : Table of 100 grid points for evaluating */
+/* Chebyshev polynomials Q31 */
+/* _ (Word16) int_fs : sampling frequency */
+/* _ (Word32) core_brate : Coding Bit Rate */
+/* _ (Word16) force_sf : Force safety-net usage if possible */
+/* _ (Word32*) Bin_Ener : FFT Bin energy 128 *2 sets Q_ener */
+/* _ (Word16) Q_ener : Q format of Bin_Ener */
+/* _ (Word32*) offset_scale1: offsets for LSF LVQ structure 1st */
+/* 8-dim subvector Q0 */
+/* _ (Word32*) offset_scale2: offsets for LSF LVQ structure 2nd */
+/* 8-dim subvector Q0 */
+/* _ (Word32*) offset_scale1_p: offsets for LSF LVQ structure, pred. */
+/* case, 1st 8-dim subvector Q0 */
+/* _ (Word32*) offset_scale2_p: offsets for LSF LVQ structure, */
+/* pred. case, 2nd 8-dim subvector Q0 */
+/* _ (Word16*) no_scales : LSF LVQ structure Q0 */
+/* _ (Word16*) no_scales_p : LSF LVQ structure Q0 */
+/*------------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ (Word16*) mem_AR : quantizer memory for AR model x2.56 */
+/*------------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16*) qlsf : quantized LSFs in the cosine domain x2.56 */
+/*------------------------------------------------------------------------*/
+/*------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*========================================================================*/
-void lsf_end_enc_ivas_fx(
+void lsf_end_enc_fx(
Encoder_State *st, /* i/o: encoder state structure */
- const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) x2.56*/
- Word16 *qlsf, /* o : quantized LSF x2.56*/
+ const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) x2.56*/
+ Word16 *qlsf, /* o : quantized LSF x2.56*/
const Word16 nBits_in, /* i : number of bits to spend on ISF quantization */
- const Word16 coder_type_org, /* i : coding type */
- Word16 Q_ener, /* i : Q valuen for Bin_Ener */
- Word16 force_sf, /* i : Force safety-net usage if coding type supports */
+ const Word16 coder_type_org, /* i : coding type */
+ const Word16 Q_ener, /* i : Q value for Bin_Ener */
+ const Word16 force_sf, /* i : Force safety-net usage if coding type supports */
Word16 *lpc_param,
Word16 *no_indices,
Word16 *bits_param_lpc,
- Word16 coder_type_raw, /* i : Coder type (LSF coder_type have some special cases)*/
- const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */
+ const Word16 coder_type_raw, /* i : Coder type (LSF coder_type have some special cases) */
+ const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */
)
{
Word16 i;
Word16 Idx0[MAX_VQ_STAGES + 3]; /* Optimal codebook indices for safety-net quantizer */
Word16 Idx1[MAX_VQ_STAGES + 3]; /* Optimal codebook indices for predictive quantizer */
Word16 indice[MAX_VQ_STAGES + 3]; /* Temp. array of indice for vector de-quantizer */
- Word16 mode_lvq = 0, mode_lvq_p = 0; /* LVQ mode and predictive LVQ mode */
+ Word16 mode_lvq = 0, mode_lvq_p = 0; /* LVQ mode and predictive LVQ mode */
Word16 bits0[MAX_VQ_STAGES], bits1[MAX_VQ_STAGES];
const Word16 *Bit_alloc1 = NULL;
Word32 Err[2]; /* Quantization error for safety-net(0) and predictive(1) quantizers */
@@ -1403,15 +607,21 @@ void lsf_end_enc_ivas_fx(
Word16 pred3[M];
Word16 dummy, dummy_v[5];
- flag_1bit_gran = (Word16) GT_16( st->element_mode, EVS_MONO );
+ flag_1bit_gran = 0;
+ move16();
+ if ( GT_16( st->element_mode, EVS_MONO ) )
+ {
+ flag_1bit_gran = 1;
+ move16();
+ }
nBits = nBits_in;
move16();
+
/* Update LSF coder_type for LSF quantizer for some special cases */
test();
test();
test();
-
IF( EQ_16( coder_type_org, GENERIC ) && EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( st->codec_mode, MODE1 ) && ( st->idchan == 0 ) ) /* this bit is used only for primary channel or mono */
{
IF( EQ_16( coder_type_raw, VOICED ) )
@@ -1443,14 +653,13 @@ void lsf_end_enc_ivas_fx(
IF( st->bwidth == NB )
{
- abs_threshold = SFNETLOWLIMIT_NB / 2;
- move32();
+ abs_threshold = L_add( SFNETLOWLIMIT_NB, 0 );
}
ELSE
{
- abs_threshold = SFNETLOWLIMIT_WB / 2;
- move32();
+ abs_threshold = L_add( SFNETLOWLIMIT_WB, 0 );
}
+
/* Calculate LSF weighting coefficients */
Unified_weighting_fx( &st->Bin_E_fx[L_FFT / 2], Q_ener, lsf, wghts, (Word16) EQ_16( st->bwidth, NB ), (Word16) EQ_16( coder_type, UNVOICED ), st->sr_core, M );
@@ -1460,12 +669,13 @@ void lsf_end_enc_ivas_fx(
IF( EQ_32( st->core_brate, SID_2k40 ) )
{
- lsfq_CNG_ivas_fx( hBstr, lsf, wghts, qlsf );
+ lsfq_CNG_fx( st->element_mode, hBstr, lsf, wghts, qlsf, &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->no_scales_fx[0][0] );
sort_fx( qlsf, 0, M - 1 );
reorder_lsf_fx( qlsf, MODE1_LSF_GAP_FX, M, st->sr_core );
return;
}
+
/* Find allowed predictor mode for current coder_type. (SN only (0), SN/AR switched (2) or MA predictive (1) */
find_pred_mode( &predmode, coder_type, st->bwidth, st->sr_core, &mode_lvq, &mode_lvq_p, st->total_brate );
@@ -1510,7 +720,16 @@ void lsf_end_enc_ivas_fx(
Vr_subt( lsf, pred0, Tmp, M );
/* LVQ quantization (safety-net only) */
- Err[0] = vq_lvq_lsf_enc_ivas_fx( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, resq, lsfq );
+ IF( flag_1bit_gran == 0 )
+ {
+ Err[0] = vq_lvq_lsf_enc( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0,
+ st->offset_scale1_fx, st->offset_scale2_fx, st->no_scales_fx, resq, lsfq );
+ }
+ ELSE
+ {
+ Err[0] = vq_lvq_lsf_enc_ivas_fx( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, resq, lsfq );
+ }
+
safety_net = 1;
move16();
st->pstreaklen = 0;
@@ -1519,12 +738,21 @@ void lsf_end_enc_ivas_fx(
ELSE IF( EQ_16( predmode, 1 ) ) /* only MA prediction */
{
Vr_subt( lsf, pred1, Tmp1, M );
- Err[1] = vq_lvq_lsf_enc_ivas_fx( 2, mode_lvq_p, Tmp1, levels1, stages1, wghts, Idx1, lsf, pred1, resq, lsfq );
+
+ IF( flag_1bit_gran == 0 )
+ {
+ Err[1] = vq_lvq_lsf_enc( 2, mode_lvq_p, Tmp1, levels1, stages1, wghts, Idx1, lsf, pred1,
+ st->offset_scale1_p_fx, st->offset_scale2_p_fx, st->no_scales_p_fx, resq, lsfq );
+ }
+ ELSE
+ {
+ Err[1] = vq_lvq_lsf_enc_ivas_fx( 2, mode_lvq_p, Tmp1, levels1, stages1, wghts, Idx1, lsf, pred1, resq, lsfq );
+ }
safety_net = 0;
move16();
}
- ELSE
+ ELSE /* Switched Safety-Net/AR prediction */
{
IF( EQ_16( predmode, 2 ) )
{
@@ -1590,15 +818,31 @@ void lsf_end_enc_ivas_fx(
/* all other frames (not VOICED@16kHz) */
ELSE
{
- /* safety-net */
+ /* Switched Safety-Net/AR prediction */
+ IF( flag_1bit_gran == 0 )
+ {
+ Err[0] = vq_lvq_lsf_enc( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, st->offset_scale1_fx, st->offset_scale2_fx, st->no_scales_fx, resq, lsfq );
+ }
+ ELSE
+ {
+ Err[0] = vq_lvq_lsf_enc_ivas_fx( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, resq, lsfq );
+ }
- Err[0] = vq_lvq_lsf_enc_ivas_fx( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, resq, lsfq );
/* Predictive quantizer is calculated only if it can be selected */
test();
IF( !force_sf || GT_32( Err[0], abs_threshold ) )
{
- Err[1] = vq_lvq_lsf_enc_ivas_fx( 2, mode_lvq_p, Tmp2, levels1, stages1, wghts, Idx1, lsf, pred2, &resq[M], &lsfq[M] );
+ IF( flag_1bit_gran == 0 )
+ {
+ Err[1] = vq_lvq_lsf_enc( 2, mode_lvq_p, Tmp2, levels1, stages1, wghts, Idx1, lsf, pred2,
+ st->offset_scale1_p_fx, st->offset_scale2_p_fx, st->no_scales_p_fx, &resq[M], &lsfq[M] );
+ }
+ ELSE
+ {
+ Err[1] = vq_lvq_lsf_enc_ivas_fx( 2, mode_lvq_p, Tmp2, levels1, stages1, wghts, Idx1, lsf, pred2, &resq[M], &lsfq[M] );
+ }
}
+
test();
test();
/* Select whether to use safety-net (non-predictive) or predictive LSF quantizer. The decision is based on following:
@@ -1899,7 +1143,17 @@ void lsf_end_enc_ivas_fx(
}
ELSE
{
- vq_dec_lvq_ivas_fx( 1, qlsf, &indice[0], stages0, M, mode_lvq, levels0[stages0 - 1] );
+ IF( flag_1bit_gran == 0 )
+ {
+ vq_dec_lvq_fx( 1, qlsf, &indice[0], stages0, M, mode_lvq, levels0[stages0 - 1],
+ &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->offset_scale1_p_fx[0][0], &st->offset_scale2_p_fx[0][0],
+ &st->no_scales_fx[0][0], &st->no_scales_p_fx[0][0] );
+ }
+ ELSE
+ {
+ vq_dec_lvq_ivas_fx( 1, qlsf, &indice[0], stages0, M, mode_lvq, levels0[stages0 - 1] );
+ }
+
Vr_add( qlsf, pred0, qlsf, M );
Vr_subt( qlsf, pred1, st->mem_MA_fx, M );
}
@@ -1917,7 +1171,17 @@ void lsf_end_enc_ivas_fx(
ELSE
{
/* LVQ */
- vq_dec_lvq_ivas_fx( 0, qlsf, &indice[0], stages1, M, mode_lvq_p, levels1[stages1 - 1] );
+ IF( flag_1bit_gran == 0 )
+ {
+ vq_dec_lvq_fx( 0, qlsf, &indice[0], stages1, M, mode_lvq_p, levels1[stages1 - 1],
+ &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->offset_scale1_p_fx[0][0],
+ &st->offset_scale2_p_fx[0][0], &st->no_scales_fx[0][0], &st->no_scales_p_fx[0][0] );
+ }
+ ELSE
+ {
+ vq_dec_lvq_ivas_fx( 0, qlsf, &indice[0], stages1, M, mode_lvq_p, levels1[stages1 - 1] );
+ }
+
IF( EQ_16( predmode, 1 ) )
{
Copy( qlsf, st->mem_MA_fx, M );
@@ -2419,12 +1683,12 @@ static Word32 vq_lvq_lsf_enc(
diff[j] = shl_sat( diff[j], 4 );
move16();
}
- L_tmp = L_mult( mult( diff[0], shl_sat( w[0], 1 ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */
+ L_tmp = L_mult( mult( diff[0], shl_sat( w[0], 1 ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q4 */
FOR( j = 1; j < M; j++ )
{
- L_tmp = L_mac( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */
+ L_tmp = L_mac( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q4 */
}
- e[i] = L_tmp; /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */
+ e[i] = L_tmp; /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q4 */
move32();
}
@@ -2476,14 +1740,13 @@ static Word32 vq_lvq_lsf_enc_ivas_fx(
IF( pred_flag == 0 ) /* safety net*/
{
cb = &Quantizers_fx[CB_lsf[mode]];
+ move16();
IF( LT_16( mode, 6 ) )
{
- move16();
mode_glb = add( offset_lvq_modes_SN[mode], offset_in_lvq_mode_SN[mode][( levels[stagesVQ] - min_lat_bits_SN[mode] )] );
}
ELSE
{
- move16();
mode_glb = add( offset_lvq_modes_SN[mode], levels[stagesVQ] - min_lat_bits_SN[mode] );
}
}
@@ -2539,10 +1802,10 @@ static Word32 vq_lvq_lsf_enc_ivas_fx(
diff[j] = shl_sat( diff[j], 4 );
move16();
}
- L_tmp = L_mult( mult( diff[0], shl_sat( w[0], 1 ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */
+ L_tmp = L_mult( mult( diff[0], shl_sat( w[0], 1 ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q4 */
FOR( j = 1; j < M; j++ )
{
- L_tmp = L_mac_sat( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */
+ L_tmp = L_mac_sat( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q4 */
}
e[i] = L_tmp;
move32();
@@ -3460,17 +2723,18 @@ static void FFT_Mid_Interpol_16k_fx(
static void lsf_mid_enc_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- Word16 nb_bits, /* i : number of bits */
- const Word16 int_fs, /* i : internal (ACELP) sampling frequency*/
- const Word16 qlsp0[], /* i : quantized LSPs from frame beginning*/
- const Word16 qlsp1[], /* i : quantized LSPs from frame end */
- Word16 lsp[], /* i/o: mid-frame LSP */
- const Word16 coder_type, /* i : coding type */
- const Word16 bwidth, /* i : input signal bandwidth */
- Word32 Bin_Ener_old[], /* i/o: per bin old log energy spectrum */
- Word32 Bin_Ener[], /* i : per bin log energy spectrum */
- Word16 Q_ener, /* i : Q value of Bin_ener */
+ const Word16 element_mode, /* i : element mode */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ Word16 nb_bits, /* i : number of bits */
+ const Word16 int_fs, /* i : internal (ACELP) sampling frequency*/
+ const Word16 qlsp0[], /* i : quantized LSPs from frame beginning*/
+ const Word16 qlsp1[], /* i : quantized LSPs from frame end */
+ Word16 lsp[], /* i/o: mid-frame LSP */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 bwidth, /* i : input signal bandwidth */
+ Word32 Bin_Ener_old[], /* i/o: per bin old log energy spectrum */
+ Word32 Bin_Ener[], /* i : per bin log energy spectrum */
+ Word16 Q_ener, /* i : Q value of Bin_ener */
Word16 ppp_mode,
Word16 nelp_mode )
{
@@ -3487,183 +2751,21 @@ static void lsf_mid_enc_fx(
lsp2lsf_fx( qlsp0, qlsf0, M, int_fs );
lsp2lsf_fx( qlsp1, qlsf1, M, int_fs );
- /* calculate weights */
- FFT_Mid_Interpol_16k_fx( Bin_Ener_old, &Bin_Ener[L_FFT / 2], Bin_Ener_mid );
-
- /* LSF weighting */
- Unified_weighting_fx( Bin_Ener_mid, Q_ener, lsf, wghts, (Word16) EQ_16( bwidth, NB ), (Word16) EQ_16( coder_type, UNVOICED ), int_fs, M );
- move16();
- /* codebook selection, number of bits, size of the codebook */
- test();
- IF( ppp_mode == 0 && nelp_mode == 0 )
+ IF( element_mode == EVS_MONO )
{
- /* codebook selection */
- IF( EQ_16( coder_type, VOICED ) )
- {
- SWITCH( nb_bits )
- {
- case 5:
- {
- ratio = tbl_mid_voi_wb_5b_fx;
- move16();
- BREAK;
- }
- case 4:
- {
- ratio = tbl_mid_voi_wb_4b_fx;
- move16();
- BREAK;
- }
- }
- }
- ELSE IF( EQ_16( coder_type, UNVOICED ) )
- {
- ratio = tbl_mid_unv_wb_5b_fx;
- }
- ELSE
- {
- /* GENERIC, TRANSITION, AUDIO and INACTIVE */
- SWITCH( nb_bits )
- {
- case 5:
- {
- ratio = tbl_mid_gen_wb_5b_fx;
- move16();
- BREAK;
- }
- case 2:
- {
- ratio = tbl_mid_gen_wb_2b_fx;
- move16();
- BREAK;
- }
- }
- }
+ /* calculate weights */
+ FFT_Mid_Interpol_16k_fx( Bin_Ener_old, &Bin_Ener[L_FFT / 2], Bin_Ener_mid );
- size = (Word16) pow2[nb_bits];
- move16();
- }
- ELSE IF( EQ_16( ppp_mode, 1 ) )
- {
- ratio = tbl_mid_voi_wb_1b_fx;
- move16();
- nb_bits = 1;
- move16();
- size = 2;
- move16();
- }
- ELSE IF( EQ_16( nelp_mode, 1 ) )
- {
- ratio = tbl_mid_unv_wb_4b_fx;
- move16();
- nb_bits = 4;
- move16();
- size = 16;
+ /* LSF weighting */
+ Unified_weighting_fx( Bin_Ener_mid, Q_ener, lsf, wghts, (Word16) EQ_16( bwidth, NB ), (Word16) EQ_16( coder_type, UNVOICED ), int_fs, M );
move16();
}
-
- /* loop over codevectors */
- err_min = MAXINT32;
- move16();
- idx = 0;
- move16();
- k1 = 0;
- move16();
- FOR( k = 0; k < size; k++ )
+ ELSE
{
- err = L_deposit_l( 0 );
-
- FOR( j = 0; j < M; j++ )
- {
- /* qlsf[j] = (1.0f - ratio[k*M+j]) * qlsf0[j] + ratio[k*M+j] * qlsf1[j]; */
- L_tmp = L_mult( sub( 0x2000, ratio[k1 + j] ), qlsf0[j] );
- L_tmp = L_mac( L_tmp, ratio[k1 + j], qlsf1[j] );
- qlsf[j] = round_fx( L_shl( L_tmp, 2 ) );
-
- test();
- test();
- IF( j > 0 && LT_16( j, M ) && LT_16( qlsf[j], add( qlsf[j - 1], LSF_GAP_MID_FX ) ) )
- {
- qlsf[j] = add( qlsf[j - 1], LSF_GAP_MID_FX );
- move16();
- }
-
- tmp = sub( lsf[j], qlsf[j] );
- /* err += wghts[j] * ftemp * ftemp; */
- /* tmp is usually very small, we can have some extra precision with very rare saturation */
- tmp = shl_sat( tmp, 4 );
- tmp = mult_r_sat( tmp, tmp );
- err = L_mac_sat( err, tmp, shl_sat( wghts[j], 2 ) );
- }
- /* err = L_shl(err,Wscale); */
- err = Mult_32_16( err, LSF_1_OVER_256SQ );
- /* err = Mult_32_16(err,Wmult); */
-
- IF( LT_32( err, err_min ) )
- {
- err_min = L_add( err, 0 );
- idx = k;
- move16();
- }
- k1 += M;
+ Unified_weighting_fx( Bin_Ener_old, Q_ener, lsf, wghts, (Word16) EQ_16( bwidth, NB ), (Word16) EQ_16( coder_type, UNVOICED ), int_fs, M );
move16();
}
- /* calculate the quantized LSF vector */
- FOR( j = 0; j < M; j++ )
- {
- /* qlsf[j] = (1.0f - ratio[idx*M+j]) * qlsf0[j] + ratio[idx*M+j] * qlsf1[j]; */
- L_tmp = L_mult( sub( 0x2000, ratio[idx * M + j] ), qlsf0[j] );
- L_tmp = L_mac( L_tmp, ratio[idx * M + j], qlsf1[j] );
- qlsf[j] = round_fx( L_shl( L_tmp, 2 ) );
-
- test();
- test();
- IF( j > 0 && LT_16( j, M ) && LT_16( qlsf[j], add( qlsf[j - 1], LSF_GAP_MID_FX ) ) )
- {
- qlsf[j] = add( qlsf[j - 1], LSF_GAP_MID_FX );
- move16();
- }
- }
-
- reorder_lsf_fx( qlsf, LSF_GAP_MID_FX, M, int_fs );
-
- /* convert LSFs back to LSPs */
- lsf2lsp_fx( qlsf, lsp, M, int_fs );
- push_indice( hBstr, IND_MID_FRAME_LSF_INDEX, idx, nb_bits );
-
- return;
-}
-
-static void lsf_mid_enc_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- Word16 nb_bits, /* i : number of bits */
- const Word32 int_fs, /* i : internal (ACELP) sampling frequency*/
- const Word16 qlsp0[], /* i : quantized LSPs from frame beginning Q15*/
- const Word16 qlsp1[], /* i : quantized LSPs from frame end Q15*/
- Word16 lsp[], /* i/o: mid-frame LSP Q15*/
- const Word16 coder_type, /* i : coding type */
- const Word16 bwidth, /* i : input signal bandwidth */
- Word32 Bin_Ener[], /* i : per bin log energy spectrum Q_ener*/
- Word16 Q_ener, /* i : Q value of Bin_ener */
- Word16 ppp_mode,
- Word16 nelp_mode )
-{
- Word16 lsf[M], qlsf[M], qlsf1[M], qlsf0[M], wghts[M];
- Word32 err, err_min;
- Word16 j, k, idx, size = 0;
- Word32 L_tmp;
- Word16 tmp, k1;
- const Word16 *ratio = NULL;
-
- /* convert LSPs to LSFs */
- lsp2lsf_fx( lsp, lsf, M, int_fs );
- lsp2lsf_fx( qlsp0, qlsf0, M, int_fs );
- lsp2lsf_fx( qlsp1, qlsf1, M, int_fs );
-
- /* LSF weighting */
- Unified_weighting_fx( Bin_Ener, Q_ener, lsf, wghts, (Word16) EQ_16( bwidth, NB ), (Word16) EQ_16( coder_type, UNVOICED ), int_fs, M );
- move16();
/* codebook selection, number of bits, size of the codebook */
test();
IF( ppp_mode == 0 && nelp_mode == 0 )
@@ -3675,13 +2777,13 @@ static void lsf_mid_enc_ivas_fx(
{
case 5:
{
- ratio = tbl_mid_voi_wb_5b_fx; // Q13
+ ratio = tbl_mid_voi_wb_5b_fx;
move16();
BREAK;
}
case 4:
{
- ratio = tbl_mid_voi_wb_4b_fx; // Q13
+ ratio = tbl_mid_voi_wb_4b_fx;
move16();
BREAK;
}
@@ -3695,7 +2797,7 @@ static void lsf_mid_enc_ivas_fx(
}
ELSE IF( EQ_16( coder_type, UNVOICED ) )
{
- ratio = tbl_mid_unv_wb_5b_fx; // Q13
+ ratio = tbl_mid_unv_wb_5b_fx;
}
ELSE
{
@@ -3704,7 +2806,7 @@ static void lsf_mid_enc_ivas_fx(
{
case 5:
{
- ratio = tbl_mid_gen_wb_5b_fx; // Q13
+ ratio = tbl_mid_gen_wb_5b_fx;
move16();
BREAK;
}
@@ -3716,7 +2818,7 @@ static void lsf_mid_enc_ivas_fx(
}
case 2:
{
- ratio = tbl_mid_gen_wb_2b_fx; // Q13
+ ratio = tbl_mid_gen_wb_2b_fx;
move16();
BREAK;
}
@@ -3728,7 +2830,7 @@ static void lsf_mid_enc_ivas_fx(
}
ELSE IF( EQ_16( ppp_mode, 1 ) )
{
- ratio = tbl_mid_voi_wb_1b_fx; // Q13
+ ratio = tbl_mid_voi_wb_1b_fx;
move16();
nb_bits = 1;
move16();
@@ -3737,7 +2839,7 @@ static void lsf_mid_enc_ivas_fx(
}
ELSE IF( EQ_16( nelp_mode, 1 ) )
{
- ratio = tbl_mid_unv_wb_4b_fx; // Q13
+ ratio = tbl_mid_unv_wb_4b_fx;
move16();
nb_bits = 4;
move16();
diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c
index b7909991136d965b27a7104cc959f05dad605dc7..2f9f2b7c7a87fe1557a842fd5001e1c9eda70836 100644
--- a/lib_enc/lsf_msvq_ma_enc_fx.c
+++ b/lib_enc/lsf_msvq_ma_enc_fx.c
@@ -1466,7 +1466,6 @@ excludes the waveform contributions at pos 21,22,23 to the MSE, important to kee
/*mvi2i (indices[1]+c2*stages, Idx, stages);*/
Copy( indices[1] + c2 * stages, Idx, stages );
-
return;
}
@@ -1478,45 +1477,6 @@ excludes the waveform contributions at pos 21,22,23 to the MSE, important to kee
*--------------------------------------------------------------------------*/
Word16 lsf_msvq_ma_encprm_fx(
- BSTR_ENC_HANDLE hBstr,
- Word16 *param_lpc, // Q0
- Word16 core,
- Word16 acelp_mode,
- Word16 acelp_midLpc,
- Word16 *bits_param_lpc,
- Word16 no_indices )
-{
- Word16 i, nbits_lpc;
- Word16 bits_midlpc;
-
- bits_midlpc = MIDLSF_NBITS;
- move16();
- nbits_lpc = 0;
- move16();
-
- FOR( i = 0; i < no_indices; i++ )
- {
-
- push_next_indice( hBstr, *param_lpc, bits_param_lpc[i] );
- param_lpc++;
- nbits_lpc = add( nbits_lpc, bits_param_lpc[i] );
- }
- IF( NE_16( acelp_mode, VOICED ) )
- {
- test();
- IF( ( core == ACELP_CORE ) && acelp_midLpc )
- {
-
- push_next_indice( hBstr, *param_lpc, bits_midlpc );
- nbits_lpc = add( nbits_lpc, bits_midlpc );
- }
- }
-
- return nbits_lpc;
-}
-
-
-Word16 lsf_msvq_ma_encprm_ivas_fx(
BSTR_ENC_HANDLE hBstr,
const Word16 *param_lpc, // Q0
const Word16 core,
@@ -1535,7 +1495,6 @@ Word16 lsf_msvq_ma_encprm_ivas_fx(
FOR( i = 0; i < no_indices; i++ )
{
-
push_next_indice( hBstr, *param_lpc, bits_param_lpc[i] );
param_lpc++;
nbits_lpc = add( nbits_lpc, bits_param_lpc[i] );
@@ -1545,7 +1504,6 @@ Word16 lsf_msvq_ma_encprm_ivas_fx(
test();
IF( ( core == ACELP_CORE ) && acelp_midLpc )
{
-
push_next_indice( hBstr, *param_lpc, bits_midlpc );
nbits_lpc = add( nbits_lpc, bits_midlpc );
}
@@ -1962,42 +1920,7 @@ Word16 Q_lsf_tcxlpc_ivas_fx(
*--------------------------------------------------------------------------*/
Word16 enc_lsf_tcxlpc_fx(
- Word16 **indices, /* i : Ptr to VQ indices */
- BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */
-)
-{
- Word16 i, NumBits;
-
- Word16 flag;
-
- /* Read flag */
- flag = ( *indices )[0];
- move16();
- ++*indices;
-
- NumBits = TCXLPC_NUMBITS;
- move16();
- FOR( i = 0; i < TCXLPC_NUMSTAGES; ++i )
- {
- push_next_indice( hBstr, **indices, lsf_numbits[i] );
- ++*indices;
- }
-
- IF( flag )
- {
- NumBits = add( NumBits, TCXLPC_IND_NUMBITS );
- FOR( i = 0; i < TCXLPC_IND_NUMSTAGES; ++i )
- {
- push_next_indice( hBstr, **indices, lsf_ind_numbits[i] );
- ++*indices;
- }
- }
- return NumBits;
-}
-
-
-Word16 enc_lsf_tcxlpc_ivas_fx(
- const Word16 **indices, /* i : Ptr to VQ indices */
+ const Word16 **indices, /* i : Ptr to VQ indices */
BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */
)
{
@@ -2038,27 +1961,6 @@ Word16 enc_lsf_tcxlpc_ivas_fx(
*--------------------------------------------------------------------------*/
Word16 lsf_bctcvq_encprm_fx(
- BSTR_ENC_HANDLE hBstr,
- Word16 *param_lpc, // Q0
- Word16 *bits_param_lpc,
- Word16 no_indices )
-{
- Word16 i, nbits_lpc;
-
- nbits_lpc = 0;
-
- FOR( i = 0; i < no_indices; i++ )
- {
- push_next_indice( hBstr, *param_lpc, bits_param_lpc[i] );
- param_lpc++;
- nbits_lpc = add( nbits_lpc, bits_param_lpc[i] );
- }
-
- return nbits_lpc;
-}
-
-
-Word16 lsf_bctcvq_encprm_ivas_fx(
BSTR_ENC_HANDLE hBstr,
const Word16 *param_lpc, // Q0
const Word16 *bits_param_lpc,
@@ -2067,7 +1969,6 @@ Word16 lsf_bctcvq_encprm_ivas_fx(
Word16 i, nbits_lpc;
nbits_lpc = 0;
- move16();
FOR( i = 0; i < no_indices; i++ )
{
diff --git a/lib_enc/multi_harm_fx.c b/lib_enc/multi_harm_fx.c
index 76b465777b13d649fd7d2be99e7eb48933a1085b..79a2efca6b57134e49fb0dc2c6259bbb21cfe885 100644
--- a/lib_enc/multi_harm_fx.c
+++ b/lib_enc/multi_harm_fx.c
@@ -9,11 +9,17 @@
#include "prot_fx_enc.h" /* Function prototypes */
#include "basop_util.h"
+
+/*-----------------------------------------------------------------*
+ * Local constants
+ *-----------------------------------------------------------------*/
+
#define THR_CORR_FX ( 56 << 15 ) /* 56 in Q15 starting threshold of multi-harm. correlation */
#define THR_CORR_MAX_FX 30720 /* 60 in Q9 upper threshold of multi-harm. correlation */
#define THR_CORR_MIN_FX 25088 /* 49 in Q9 lower threshold of multi-harm. correlation */
#define THR_CORR_STEP_FX 102 /* 0.2 in Q9 step for the threshold of multi-harm. correlation */
+
/*---------------------------------------------------------------------*
* multi_harm()
*
@@ -22,7 +28,9 @@
/* o : frame multi-harmonicity (1-harmonic, 0-not) */
Word16 multi_harm_fx(
-
+#ifdef FIX_2364_HARM_MULT_HARM
+ const Word16 element_mode, /* i : IVAS element_mode Q0 */
+#endif
const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */
Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */
Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */
@@ -43,6 +51,9 @@ Word16 multi_harm_fx(
Word32 L_acc;
Word32 Lcorx2, Lcory2, Lcorxy, Lcor_map_LT_sum;
Word16 mean_dyn;
+#ifdef FIX_2364_HARM_MULT_HARM
+ Word32 tmp2_32;
+#endif
/*------------------------------------------------------------------*
* initialization
@@ -121,34 +132,65 @@ Word16 multi_harm_fx(
step = 0;
move16();
- FOR( i = ind_mins[0]; i < ind_mins[N_mins]; i++ )
+#ifdef FIX_2364_HARM_MULT_HARM
+ IF( element_mode != EVS_MONO )
{
- /* we are at the end of the next minimum */
- IF( EQ_16( i, *pt_mins ) )
+ FOR( i = ind_mins[0]; i < ind_mins[N_mins]; i++ )
{
- pt_mins++;
- flor = Bin_E[i];
- move16(); /*Q7*/
- /* calculate the new step */
- /*step = (Bin_E[*pt_mins] - Bin_E[i]) / (*pt_mins-i);*/
- tmp16 = sub( *pt_mins, i );
- tmpdB = sub( Bin_E[*pt_mins], Bin_E[i] );
- sign_fx = shr( tmpdB, 15 ); /* 0 if positive else -1 */
- ExpdB = sub( norm_s( tmpdB ), 1 );
- tmpdB = abs_s( shl( tmpdB, ExpdB ) );
- ExpInd = norm_s( tmp16 );
- tmp16 = shl( tmp16, ExpInd );
- tmp16 = div_s( tmpdB, tmp16 );
- tmp16 = sub( s_xor( tmp16, sign_fx ), sign_fx );
- step = shr( tmp16, add( sub( ExpdB, ExpInd ), 15 ) ); /* Q7 */
+ /* we are at the end of the next minimum */
+ IF( EQ_16( i, *pt_mins ) )
+ {
+ pt_mins++;
+ flor = Bin_E[i];
+ move16(); /*Q7*/
+
+ /* calculate the new step */
+ /*step = (Bin_E[*pt_mins] - Bin_E[i]) / (*pt_mins-i);*/
+
+ tmp16 = div_s( 1, sub( *pt_mins, i ) ); // Q15
+ step = msu_r( L_mult( Bin_E[*pt_mins], tmp16 ), Bin_E[i], tmp16 ); // Q7 (15+7+1-16)
+ }
+
+ /* subtract the floor */
+ S[i] = s_max( sub_sat( Bin_E[i], flor ), 0 );
+ move16();
+
+ /* update the floor */
+ flor = add( flor, step ); /*Q7*/
}
+ }
+ ELSE
+#endif
+ {
+ FOR( i = ind_mins[0]; i < ind_mins[N_mins]; i++ )
+ {
+ /* we are at the end of the next minimum */
+ IF( EQ_16( i, *pt_mins ) )
+ {
+ pt_mins++;
+ flor = Bin_E[i];
+ move16(); /*Q7*/
+ /* calculate the new step */
+ /*step = (Bin_E[*pt_mins] - Bin_E[i]) / (*pt_mins-i);*/
+ tmp16 = sub( *pt_mins, i );
+ tmpdB = sub( Bin_E[*pt_mins], Bin_E[i] );
+ sign_fx = shr( tmpdB, 15 ); /* 0 if positive else -1 */
+ ExpdB = sub( norm_s( tmpdB ), 1 );
+ tmpdB = abs_s( shl( tmpdB, ExpdB ) );
+ ExpInd = norm_s( tmp16 );
+ tmp16 = shl( tmp16, ExpInd );
+ tmp16 = div_s( tmpdB, tmp16 );
+ tmp16 = sub( s_xor( tmp16, sign_fx ), sign_fx );
+ step = shr( tmp16, add( sub( ExpdB, ExpInd ), 15 ) ); /* Q7 */
+ }
- /* subtract the floor */
- S[i] = s_max( sub_sat( Bin_E[i], flor ), 0 );
- move16();
+ /* subtract the floor */
+ S[i] = s_max( sub_sat( Bin_E[i], flor ), 0 );
+ move16();
- /* update the floor */
- flor = add( flor, step ); /*Q7*/
+ /* update the floor */
+ flor = add( flor, step ); /*Q7*/
+ }
}
}
@@ -180,6 +222,7 @@ Word16 multi_harm_fx(
*cor_strong_limit = 1;
move16();
}
+
test();
if ( LT_32( total_brate, ACELP_9k60 ) || GT_32( total_brate, ACELP_16k40 ) )
{
@@ -285,33 +328,67 @@ Word16 multi_harm_fx(
Lcor_map_LT_sum = L_deposit_l( 0 );
tmp2 = 0;
move16();
-
+#ifdef FIX_2364_HARM_MULT_HARM
+ tmp2_32 = 0;
+ move32();
+#endif
cor_strong = 0;
move16();
pt1 = cor_map_LT; // Q15
move16();
pt2 = cor_map;
move16();
- FOR( i = 0; i < L; i++ )
+
+#ifdef FIX_2364_HARM_MULT_HARM
+ IF( element_mode != EVS_MONO )
{
- /* tmp2 += S[i]; */
- tmp2 = add( tmp2, shl( S[i], 1 ) ); /* tmp2 in Q8; max value is 128) */
+ FOR( i = 0; i < L; i++ )
+ {
+ /* tmp2 += S[i]; */
+ tmp2_32 = L_add( tmp2_32, cor_map[i] ); /* tmp2_32 in Q15; max value is 128) */
- /* *pt1 = M_ALPHA_FX * *pt1 + (1-M_ALPHA_FX) * *pt2++ */
- *pt1 = mac_r( L_mult( ONE_MINUS_M_ALPHA, *pt2 ), M_ALPHA_FX, *pt1 );
- move16();
+ /* *pt1 = M_ALPHA_FX * *pt1 + (1-M_ALPHA_FX) * *pt2++ */
+ *pt1 = mac_r( L_mult( ONE_MINUS_M_ALPHA, *pt2 ), M_ALPHA_FX, *pt1 );
+ move16();
- /* cor_map_LT_sum += *pt1 */
- Lcor_map_LT_sum = L_add( Lcor_map_LT_sum, *pt1 ); /* cor_map_LT_sum in Q15; max value is 128) */
+ /* cor_map_LT_sum += *pt1 */
+ Lcor_map_LT_sum = L_add( Lcor_map_LT_sum, *pt1 ); /* cor_map_LT_sum in Q15; max value is 128) */
+
+ if ( GT_16( *pt1, 31130 ) /*0.95f*/ )
+ {
+ cor_strong = 1;
+ move16();
+ }
- if ( GT_16( *pt1, 31130 ) /*0.95f.Q15*/ )
+ pt1++;
+ pt2++;
+ }
+ tmp2 = extract_l( L_shr_sat( tmp2_32, 7 ) ); // q15-> q8
+ }
+ ELSE
+#endif
+ {
+ FOR( i = 0; i < L; i++ )
{
- cor_strong = 1;
+ /* tmp2 += S[i]; */
+ tmp2 = add( tmp2, shl( S[i], 1 ) ); /* tmp2 in Q8; max value is 128) */
+
+ /* *pt1 = M_ALPHA_FX * *pt1 + (1-M_ALPHA_FX) * *pt2++ */
+ *pt1 = mac_r( L_mult( ONE_MINUS_M_ALPHA, *pt2 ), M_ALPHA_FX, *pt1 );
move16();
- }
- pt1++;
- pt2++;
+ /* cor_map_LT_sum += *pt1 */
+ Lcor_map_LT_sum = L_add( Lcor_map_LT_sum, *pt1 ); /* cor_map_LT_sum in Q15; max value is 128) */
+
+ if ( GT_16( *pt1, 31130 ) /*0.95f.Q15*/ )
+ {
+ cor_strong = 1;
+ move16();
+ }
+
+ pt1++;
+ pt2++;
+ }
}
IF( ( bwidth == NB ) )
@@ -357,10 +434,10 @@ Word16 multi_harm_fx(
{
Copy( S, S_map, L );
}
+
return harm;
}
-
-
+#ifndef FIX_2364_HARM_MULT_HARM
/* o : frame multi-harmonicity (1-harmonic, 0-not) */
Word16 multi_harm_ivas_fx(
const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */
@@ -695,3 +772,4 @@ Word16 multi_harm_ivas_fx(
}
return harm;
}
+#endif
diff --git a/lib_enc/nelp_enc_fx.c b/lib_enc/nelp_enc_fx.c
index 9122be431e58c675afd23259c8c2f78f30d5892e..45e132898b21a395c22f71a0631eb12eb1443a66 100644
--- a/lib_enc/nelp_enc_fx.c
+++ b/lib_enc/nelp_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -1032,737 +1032,3 @@ void nelp_encoder_fx(
return;
}
-
-void nelp_encoder_ivas_fx(
- Encoder_State *st_fx, /* i/o: encoder state */
- Word16 *in_fx, /* i : residual signal */
- Word16 *exc_fx, /* o : NELP quantized excitation signal */
- Word16 *qIn1,
- Word16 reduce_gains )
-{
- Word16 i, j;
- Word16 *ptr_fx = exc_fx;
- Word16 lag = 25; /* to cover 25*9 + 31 */
- move16();
- Word16 sqrt_inv_lag = 6554; /* sqrt(1/lag) in Q15 */
- move16();
- Word16 sqrt_inv_lframe_lag = 5885; /* sqrt(1/(L_FRAME-lag*9)) */
- move16();
- Word16 Gains_fx[10], gain_fac_fx;
- Word16 iG1_fx, iG2_fx[2];
- Word16 fid;
- Word16 fdbck_fx;
- Word32 var_dB_fx;
- Word32 E1_fx = 0, EL1_fx = 0, EH1_fx = 0, E2_fx = 0, E3_fx = 0, EL2_fx = 0, EH2_fx = 0;
- move32();
- move32();
- move32();
- move32();
- move32();
- move32();
- move32();
- Word32 RL_fx = 0, RH_fx = 0;
- move32();
- move32();
- Word16 R_fx = 0;
- move16();
- Word16 filtRes_fx[L_FRAME];
- Word16 ptr_tmp_fx[L_FRAME];
-
- Word16 qE1 = 0, qE2 = 0, qE3 = 0, qEL1 = 0, qEL2 = 0, qEH1 = 0, qEH2 = 0;
- move16();
- move16();
- move16();
- move16();
- move16();
- move16();
- move16();
- Word16 qIn = 0, qGain = 0, qf = 0, qf1 = 0, qNelpGain = 0;
- move16();
- move16();
- move16();
- move16();
- move16();
- Word16 exp1, exp2, tmp1, tmp2;
- Word16 f_Noise, etmp, e_Noise;
- Word16 max1 = 0;
- move16();
- Word32 l_nelp_gain_mem;
- Word32 Ltemp = 0, Ltemp1 = 0, L_tmp = 0, L_const_1;
- move32();
- move32();
- move32();
- Word16 BP1_ORDER;
- Word16 rf_flag;
- SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
- BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
- RF_ENC_HANDLE hRF = st_fx->hRF;
-
- rf_flag = st_fx->rf_mode;
- move16();
-
- test();
- if ( EQ_16( hSC_VBR->last_nelp_mode, 1 ) && NE_16( st_fx->bwidth, st_fx->last_bwidth ) )
- {
- hSC_VBR->last_nelp_mode = 0;
- move16();
- }
-
- qIn = *qIn1;
- move16();
- test();
- IF( EQ_16( st_fx->bwidth, NB ) )
- {
- IF( hSC_VBR->last_nelp_mode != 1 )
- {
- BP1_ORDER = 7;
- move16();
- set32_fx( hSC_VBR->bp1_filt_mem_nb_fx, 0, BP1_ORDER * 2 );
- hSC_VBR->qprevGain_fx = 0;
- move16();
- }
- }
- ELSE IF( EQ_16( st_fx->bwidth, WB ) || EQ_16( st_fx->bwidth, SWB ) )
- {
- IF( hSC_VBR->last_nelp_mode != 1 )
- {
- BP1_ORDER = 4;
- move16();
- set16_fx( hSC_VBR->bp1_filt_mem_wb_fx, 0, i_mult( BP1_ORDER, 2 ) );
- }
- }
-
- IF( NE_16( hSC_VBR->last_nelp_mode, 1 ) )
- {
- test();
- IF( EQ_16( st_fx->bwidth, WB ) || EQ_16( st_fx->bwidth, SWB ) )
- {
- set16_fx( hSC_VBR->shape1_filt_mem_fx, 0, 10 );
- set16_fx( hSC_VBR->shape2_filt_mem_fx, 0, 10 );
- set16_fx( hSC_VBR->shape3_filt_mem_fx, 0, 10 );
- set16_fx( hSC_VBR->txlpf1_filt1_mem_fx, 0, 10 );
- set16_fx( hSC_VBR->txlpf1_filt2_mem_fx, 0, 10 );
- set16_fx( hSC_VBR->txhpf1_filt1_mem_fx, 0, 10 );
- set16_fx( hSC_VBR->txhpf1_filt2_mem_fx, 0, 10 );
- hSC_VBR->qprevIn_fx = 0;
- move16();
- hSC_VBR->qprevGain_fx = 0;
- move16();
- }
- }
-
- /* Start Unvoiced/NELP Processing */
- test();
- IF( EQ_16( st_fx->bwidth, WB ) || EQ_16( st_fx->bwidth, SWB ) )
- {
- qE1 = qIn;
- move16();
- E1_fx = L_deposit_l( 0 );
- FOR( i = 0; i < L_FRAME; i++ )
- {
- E1_fx = L_mac0_sat( E1_fx, in_fx[i], in_fx[i] ); /*Q(qE1+qE1) */
- }
-
- qE1 = shl( qE1, 1 );
-
- qf = qIn;
- move16();
- Scale_sig( hSC_VBR->txlpf1_filt1_mem_fx, 10, ( qf - hSC_VBR->qprevIn_fx ) );
- pz_filter_sp_fx( txlpf1_num_coef_fx, txlpf1_den_coef_fx, in_fx, filtRes_fx, hSC_VBR->txlpf1_filt1_mem_fx, 10, 10, L_FRAME, 3 ); /*1 = (16-qformat of shape1 cofficient) */
-
- qEL1 = qf;
- move16();
- EL1_fx = L_deposit_l( 0 );
- FOR( i = 0; i < L_FRAME; i++ )
- {
- EL1_fx = L_mac0_sat( EL1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qIn) */
- }
- qEL1 = shl( qEL1, 1 );
-
- qf = qIn;
- move16();
- Scale_sig( hSC_VBR->txhpf1_filt1_mem_fx, 10, qf - hSC_VBR->qprevIn_fx );
- pz_filter_sp_fx( txhpf1_num_coef_fx, txhpf1_den_coef_fx, in_fx, filtRes_fx, hSC_VBR->txhpf1_filt1_mem_fx, 10, 10, L_FRAME, 3 ); /*1 = (16-qformat of shape1 cofficient) */
- hSC_VBR->qprevIn_fx = qf;
- move16();
-
- qEH1 = qf;
- move16();
- EH1_fx = L_deposit_l( 0 );
- FOR( i = 0; i < L_FRAME; i++ )
- {
- EH1_fx = L_mac0_sat( EH1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH1) */
- }
- qEH1 = shl( qEH1, 1 );
- move16();
- }
-
- qGain = qIn;
- move16();
- qGain = shl( qGain, 1 );
-
- FOR( i = 0; i < 9; i++ )
- {
- Ltemp = L_deposit_l( 0 );
- FOR( j = (Word16) ( i * lag ); j < (Word16) ( ( i + 1 ) * lag ); j++ )
- {
- Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */
- }
-
- /*Gains[i] = (float) sqrt(Gains[i]/lag); */
- IF( Ltemp != 0 )
- {
- exp1 = norm_l( Ltemp );
- tmp1 = extract_h( L_shl( Ltemp, exp1 ) ); /*2*qGain+exp1-16 */
- exp1 = sub( exp1, 30 - qGain ); /* */
-
- tmp1 = div_s( 16384, tmp1 ); /*14-2*qGain-exp1+16 */
- L_tmp = L_deposit_h( tmp1 );
- L_tmp = Isqrt_lc( L_tmp, &exp1 );
- L_tmp = Mult_32_16( L_tmp, sqrt_inv_lag );
- Ltemp = L_shl_sat( L_tmp, sub( exp1, 12 ) ); /*Q3 */
- }
- Gains_fx[i] = round_fx_sat( Ltemp );
- move16();
- }
-
-
- Ltemp = L_deposit_l( 0 );
- FOR( j = i_mult( i, lag ); j < L_FRAME; j++ )
- {
- Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */
- }
-
- /*Gains[i] = (float) sqrt(Gains[i]/(L_FRAME-(lag*i))); */
- IF( Ltemp != 0 )
- {
- exp1 = norm_l( Ltemp );
- tmp1 = extract_h( L_shl( Ltemp, exp1 ) );
- exp1 = sub( exp1, 30 - qGain ); /* */
-
- tmp1 = div_s( 16384, tmp1 );
- L_tmp = L_deposit_h( tmp1 );
- L_tmp = Isqrt_lc( L_tmp, &exp1 );
- L_tmp = Mult_32_16( L_tmp, sqrt_inv_lframe_lag );
- Ltemp = L_shl_sat( L_tmp, sub( exp1, 12 ) );
- }
-
- Gains_fx[i] = round_fx_sat( Ltemp );
- move16();
-
- IF( EQ_16( reduce_gains, 1 ) )
- {
- FOR( i = 0; i < 10; i++ )
- {
- Gains_fx[i] = mult( Gains_fx[i], 19661 );
- move16();
- }
- }
-
-
- qGain = 3;
- move16();
- IF( NE_16( hSC_VBR->last_nelp_mode, 1 ) ) /* if prev frame was not NELP then init mem*/
- {
- hSC_VBR->nelp_gain_mem_fx = Gains_fx[0];
- move16();
- qNelpGain = qGain;
- move16();
- }
-
- /* tmp = (float) (20.0 * (log10 (Gains[0]) - log10 (st->nelp_gain_mem) ) ); */
- /* var_dB = tmp * tmp; */
- L_tmp = L_deposit_l( Gains_fx[0] );
- L_tmp = L_max( L_tmp, 1 );
- exp2 = norm_l( L_tmp );
- L_tmp = L_shl( L_tmp, exp2 ); /*15+qEL1-qEL2-exp1+exp2 */
- exp2 = sub( sub( 30, exp2 ), qGain );
- tmp1 = Log2_norm_lc( L_tmp );
- Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*log(2) in Q13 format = Q0 format */
- /*tmp1 = round_fx(L_shl(Ltemp,12)); Q12 */
-
- L_tmp = L_deposit_l( hSC_VBR->nelp_gain_mem_fx ); /*Q0 */
- L_tmp = L_max( L_tmp, 1 );
- exp2 = norm_l( L_tmp );
- L_tmp = L_shl( L_tmp, exp2 ); /*15+qEL1-qEL2-exp1+exp2 */
- exp2 = sub( sub( 30, exp2 ), qNelpGain );
- tmp2 = Log2_norm_lc( L_tmp );
- Ltemp1 = Mpy_32_16( exp2, tmp2, 9864 ); /*log(2) in Q13 format = Q0 format */
- Ltemp1 = L_sub( Ltemp, Ltemp1 ); /*Q16 */
- Ltemp = Mult_32_16( Ltemp1, 20480 ); /*Q11 (20 in Q10) */
- L_tmp = L_shl( Ltemp, 12 ); /*Q23 */
- var_dB_fx = Mult_32_32( L_tmp, L_tmp ); /*Q15 */
-
- FOR( i = 1; i < 10; i++ )
- {
- L_tmp = L_deposit_l( Gains_fx[i] );
- L_tmp = L_max( L_tmp, 1 );
- exp2 = norm_l( L_tmp );
- L_tmp = L_shl( L_tmp, exp2 ); /*15+qEL1-qEL2-exp1+exp2 */
- exp2 = sub( sub( 30, exp2 ), qGain );
- tmp1 = Log2_norm_lc( L_tmp );
- Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*log(2) in Q13 format = Q0 format */
-
- L_tmp = L_deposit_l( Gains_fx[i - 1] ); /*Q0 */
- L_tmp = L_max( L_tmp, 1 );
- exp2 = norm_l( L_tmp );
- L_tmp = L_shl( L_tmp, exp2 ); /*15+qEL1-qEL2-exp1+exp2 */
- exp2 = sub( sub( 30, exp2 ), qGain );
- tmp2 = Log2_norm_lc( L_tmp );
- Ltemp1 = Mpy_32_16( exp2, tmp2, 9864 ); /*log(2) in Q13 format = Q0 format */
- Ltemp1 = L_sub( Ltemp, Ltemp1 ); /*Q16 */
- Ltemp = Mult_32_16( Ltemp1, 20480 ); /*Q11 (20 in Q10) */
- L_tmp = L_shl( Ltemp, 12 ); /*Q23 */
- L_tmp = Mult_32_32( L_tmp, L_tmp ); /*Q15 */
- var_dB_fx = L_add( L_tmp, var_dB_fx ); /*Q15 */
- }
-
- IF( NE_16( hSC_VBR->last_nelp_mode, 1 ) )
- {
- /*var_dB *= 0.111f; */
- var_dB_fx = Mult_32_16( var_dB_fx, 3637 ); /*0.111 in Q15 */
- }
- ELSE
- {
- /*var_dB *= 0.1f; */
- var_dB_fx = Mult_32_16( var_dB_fx, 3277 ); /*0.1 in Q15 */
- }
-
- max1 = 0;
- move16();
- FOR( i = 0; i < 10; i++ )
- {
- max1 = s_max( max1, abs_s( Gains_fx[i] ) );
- }
-
- qf = norm_s( max1 );
- test();
- IF( ( qf == 0 ) && ( max1 == 0 ) )
- {
- qf = 15;
- move16();
- }
- qf = sub( qf, 1 );
- qGain = add( qGain, qf );
-
- Scale_sig( Gains_fx, 10, qf );
-
- L_tmp = L_sub( var_dB_fx, 655360 ); /* 20 in Q15 */
- Ltemp = L_shr_r( L_tmp, 2 ); /*Q15 */
- {
- /*exp = pow(2, x*log2(e)) */
- L_tmp = Mult_32_16( Ltemp, 23637 ); /*15 + 14 -15 ->Q14 */
- L_tmp = L_shl( L_tmp, 2 ); /*Q16 */
- f_Noise = L_Extract_lc( L_tmp, &e_Noise ); /*Q16 */
- etmp = extract_l( Pow2( 14, f_Noise ) ); /* Put 14 as exponent */
- e_Noise = sub( e_Noise, 14 ); /* Retreive exponent of etmp */
-
-
- IF( e_Noise > 0 )
- {
- L_tmp = L_shl_sat( etmp, e_Noise ); /* Result in Q30 */
- L_tmp = L_add_sat( 1, L_tmp );
-
-
- exp1 = norm_l( L_tmp );
- tmp1 = extract_h( L_shl( L_tmp, exp1 ) ); /*exp1-16 */
- tmp1 = div_s( 16384, tmp1 ); /*14-(exp1-16)-> 30+15-exp1 */
- fdbck_fx = mult( 26870, tmp1 ); /*45-exp1+15-15=>45-exp1 */
- fdbck_fx = shr_r( fdbck_fx, 14 );
- exp1 = sub( 31, exp1 );
- }
- ELSE
- {
- L_tmp = L_shl( etmp, add( e_Noise, 14 ) ); /* Result in Q30 */
- L_tmp = L_add( 16384, L_tmp );
-
- exp1 = norm_l( L_tmp );
- tmp1 = extract_h( L_shl( L_tmp, exp1 ) ); /*14+exp1-16 */
- tmp1 = div_s( 16384, tmp1 ); /*14-(14+exp1-16)-> 16+15-exp1 */
- fdbck_fx = mult( 26870, tmp1 ); /*31-exp1+15-15=>31-exp1 */
- exp1 = sub( 31, exp1 );
- }
- }
-
- IF( EQ_16( exp1, 31 ) )
- {
- L_const_1 = 0x7fffffff;
- move32();
- }
- ELSE
- {
- L_const_1 = L_shl( 1, exp1 );
- }
-
- l_nelp_gain_mem = L_deposit_l( hSC_VBR->nelp_gain_mem_fx );
- IF( NE_16( qNelpGain, qGain ) )
- {
- l_nelp_gain_mem = L_shl( l_nelp_gain_mem, sub( qGain, qNelpGain ) );
- }
-
- FOR( i = 0; i < 10; i++ )
- {
- /*Gains[i] = (float)((1.0f - fdbck) * Gains[i] + fdbck * st->nelp_gain_mem); */
- L_tmp = L_sub( L_const_1, L_deposit_l( fdbck_fx ) ); /*31-exp1 */
- L_tmp = Mult_32_16( L_tmp, Gains_fx[i] ); /*exp1+qGain-15=>exp1-15+qGain */
- Ltemp1 = Mult_32_16( l_nelp_gain_mem, fdbck_fx ); /*exp1+qGain-15 */
- L_tmp = L_add( L_tmp, Ltemp1 );
- L_tmp = L_shr_r( L_tmp, ( exp1 - 15 ) );
- Gains_fx[i] = round_fx_sat( L_shl_sat( L_tmp, 16 ) );
- move16();
- l_nelp_gain_mem = L_tmp;
- }
-
- hSC_VBR->nelp_gain_mem_fx = round_fx( L_shl( l_nelp_gain_mem, 16 ) );
- move16();
-
- Scale_sig( &hSC_VBR->nelp_gain_mem_fx, 1, -qGain );
- Scale_sig( Gains_fx, 10, -qGain );
- qGain = 0;
- move16();
-
- quantize_uvg_fx( Gains_fx, &iG1_fx, iG2_fx, Gains_fx, st_fx->bwidth );
-
- IF( EQ_16( rf_flag, 1 ) )
- {
- hRF->rf_indx_nelp_iG1[0] = iG1_fx;
- move16();
- hRF->rf_indx_nelp_iG2[0][0] = iG2_fx[0];
- move16();
- hRF->rf_indx_nelp_iG2[0][1] = iG2_fx[1];
- move16();
- }
- ELSE
- {
- push_indice( hBstr, IND_IG1, iG1_fx, 5 );
- push_indice( hBstr, IND_IG2A, iG2_fx[0], 6 );
- push_indice( hBstr, IND_IG2B, iG2_fx[1], 6 );
- }
-
- test();
- IF( EQ_16( st_fx->bwidth, WB ) || EQ_16( st_fx->bwidth, SWB ) )
- {
- gain_fac_fx = 19005;
- move16(); /* 1.16f in Q14 */
- }
- ELSE
- {
- gain_fac_fx = 22446;
- move16(); /* 1.37f in Q14 */
- }
-
- /* Normalize Gains_fx[10] with headroom 4 */
- /* This fills up qGain with some new value */
- normalize_arr( Gains_fx, &qGain, 10, 4 );
-
- generate_nelp_excitation_fx( &( hSC_VBR->nelp_enc_seed ), Gains_fx, ptr_fx, gain_fac_fx );
- test();
- IF( EQ_16( st_fx->bwidth, WB ) || EQ_16( st_fx->bwidth, SWB ) )
- {
- BP1_ORDER = 4;
- move16();
- Scale_sig( hSC_VBR->bp1_filt_mem_wb_fx, BP1_ORDER * 2, qGain - hSC_VBR->qprevGain_fx ); /*qf-qAdj */
- pz_filter_sp_fx( bp1_num_coef_wb_fx, bp1_den_coef_wb_fx, ptr_fx, ptr_tmp_fx, hSC_VBR->bp1_filt_mem_wb_fx, BP1_ORDER, BP1_ORDER, L_FRAME, 2 );
- Copy( ptr_tmp_fx, ptr_fx, L_FRAME );
- }
- ELSE IF( EQ_16( st_fx->bwidth, NB ) )
- {
- BP1_ORDER = 7;
- move16();
- Scale_sig32( hSC_VBR->bp1_filt_mem_nb_fx, BP1_ORDER * 2, ( qGain - hSC_VBR->qprevGain_fx ) );
- pz_filter_dp_fx( bp1_num_coef_nb_fx_order7, bp1_den_coef_nb_fx_order7, ptr_fx, ptr_tmp_fx, hSC_VBR->bp1_filt_mem_nb_fx, BP1_ORDER, BP1_ORDER, L_FRAME, ( sub( 16, BP1_COEF_NB_QF_ORDER7 ) ) );
- Copy( ptr_tmp_fx, ptr_fx, L_FRAME );
-
- Scale_sig( ptr_fx, L_FRAME, -1 ); /* bring exc to qgain-1 */
- *qIn1 = sub( qGain, 1 ); /* use this temp only in the parent */
- }
-
- E3_fx = L_deposit_l( 0 );
- FOR( i = 0; i < L_FRAME; i++ )
- {
- E3_fx = L_mac_sat( E3_fx, ptr_fx[i], ptr_fx[i] ); /*Q1 */
- }
- qE3 = add( shl( qGain, 1 ), 1 );
-
- test();
- IF( EQ_16( st_fx->bwidth, WB ) || EQ_16( st_fx->bwidth, SWB ) )
- {
- Scale_sig( hSC_VBR->shape1_filt_mem_fx, 10, ( qGain - hSC_VBR->qprevGain_fx ) );
- pz_filter_sp_fx( shape1_num_coef_fx, shape1_den_coef_fx, ptr_fx, ptr_tmp_fx, hSC_VBR->shape1_filt_mem_fx, 10, 10, L_FRAME, 1 ); /*1 = (16-qformat of shape1 cofficient) */
- Copy( ptr_tmp_fx, ptr_fx, L_FRAME );
-
- qf = qGain;
- move16();
- E2_fx = L_deposit_l( 0 );
- FOR( i = 0; i < L_FRAME; i++ )
- {
- Ltemp = L_mult0( ptr_fx[i], ptr_fx[i] ); /*Q(2*qE2+1) */
- Ltemp = L_shr_r( Ltemp, 4 );
- E2_fx = L_add( E2_fx, Ltemp );
- }
- qE2 = sub( shl( qf, 1 ), 4 );
-
- test();
- IF( E1_fx == 0 )
- {
- R_fx = 0;
- move16();
- }
- ELSE IF( ( E2_fx == 0 ) && ( E1_fx != 0 ) )
- {
- exp1 = norm_l( E1_fx );
- tmp1 = extract_h( L_shl( E1_fx, exp1 ) ); /*qE1+exp1-16 */
- tmp1 = div_s( 16384, tmp1 ); /*14-(qE1+exp1-16)-> 30-qE1-exp1 */
- exp1 = sub( exp1, 30 - qE1 );
-
- L_tmp = L_deposit_h( tmp1 );
- L_tmp = Isqrt_lc( L_tmp, &exp1 );
- Ltemp = L_shl( L_tmp, sub( exp1, 12 ) );
- R_fx = round_fx( Ltemp );
- }
- ELSE
- {
- exp1 = norm_l( E1_fx );
- tmp1 = extract_h( L_shl( E1_fx, exp1 ) ); /*qE1+exp1-16 */
- tmp1 = div_s( 16384, tmp1 ); /*14-(qE1+exp1-16)-> 30-qE1-exp1 */
- L_tmp = Mult_32_16( E2_fx, tmp1 ); /*qE2+30-qE1-exp1-15=>15+qE2-qE1-exp1 */
-
- exp2 = norm_l( L_tmp );
- L_tmp = L_shl( L_tmp, exp2 ); /*15+qE2-qE1-exp1+exp2 */
- exp2 = add( 15, add( sub( sub( qE2, qE1 ), exp1 ), exp2 ) );
- L_tmp = Isqrt_lc( L_tmp, &exp2 ); /*Q(31+exp2) */
- R_fx = round_fx( L_tmp );
- exp1 = sub( 8, exp2 );
- }
-
- FOR( i = 0; i < L_FRAME; i++ )
- {
- Ltemp = L_mult0( R_fx, ptr_fx[i] );
- Ltemp = L_shr_r( Ltemp, exp1 );
- filtRes_fx[i] = round_fx_sat( L_shl_sat( Ltemp, 16 ) );
- move16();
- }
-
- qf1 = qGain;
- move16();
- Scale_sig( hSC_VBR->txlpf1_filt2_mem_fx, 10, ( qf1 - hSC_VBR->qprevGain_fx ) );
-
- pz_filter_sp_fx( txlpf1_num_coef_fx, txlpf1_den_coef_fx, filtRes_fx, ptr_tmp_fx, hSC_VBR->txlpf1_filt2_mem_fx, 10, 10, L_FRAME, 3 ); /*1 = (16-qformat of shape1 cofficient) */
- Copy( ptr_tmp_fx, filtRes_fx, L_FRAME );
-
- qEL2 = qf1;
- move16();
- EL2_fx = L_deposit_l( 0 );
- FOR( i = 0; i < L_FRAME; i++ )
- {
- EL2_fx = L_mac0_sat( EL2_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEL2) */
- }
- qEL2 = shl( qEL2, 1 );
-
- FOR( i = 0; i < L_FRAME; i++ )
- {
- Ltemp = L_mult0( R_fx, ptr_fx[i] );
- Ltemp = L_shr_r( Ltemp, exp1 );
- filtRes_fx[i] = round_fx_sat( L_shl_sat( Ltemp, 16 ) );
- move16();
- }
-
- qf = qGain;
- move16();
- Scale_sig( hSC_VBR->txhpf1_filt2_mem_fx, 10, ( qf - hSC_VBR->qprevGain_fx ) );
- pz_filter_sp_fx( txhpf1_num_coef_fx, txhpf1_den_coef_fx, filtRes_fx, ptr_tmp_fx, hSC_VBR->txhpf1_filt2_mem_fx, 10, 10, L_FRAME, 3 ); /*1 = (16-qformat of shape1 cofficient) */
-
- Copy( ptr_tmp_fx, filtRes_fx, L_FRAME );
-
- qEH2 = qf;
- move16();
- EH2_fx = L_deposit_l( 0 );
- FOR( i = 0; i < L_FRAME; i++ )
- {
- EH2_fx = L_mac0_sat( EH2_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH2) */
- }
- qEH2 = shl( qEH2, 1 );
- IF( EL2_fx == 0 )
- {
- exp2 = norm_l( EL1_fx );
- L_tmp = L_shl( EL1_fx, exp2 );
- exp2 = sub( sub( 30, exp2 ), qEL1 );
- tmp1 = Log2_norm_lc( L_tmp );
- Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q15 format = Q0 format */
- tmp1 = round_fx_sat( L_shl_sat( Ltemp, 12 ) ); /* Q12 */
- RL_fx = L_mult0( tmp1, 10 );
- }
- ELSE
- {
- exp1 = norm_l( EL2_fx );
- tmp1 = extract_h( L_shl( EL2_fx, exp1 ) ); /*qEL2+exp1-16 */
- tmp1 = div_s( 16384, tmp1 ); /*14-(qEL2+exp1-16)-> 30-qEL2-exp1 */
- L_tmp = Mult_32_16( EL1_fx, tmp1 ); /*qEL1+30-qEL2-exp1-15=>15+qE1-qEL2-exp1 */
-
- exp2 = norm_l( L_tmp );
- L_tmp = L_shl( L_tmp, exp2 ); /*15+qEL1-qEL2-exp1+exp2 */
- exp2 = sub( 30, add( sub( sub( add( 30, qEL1 ), qEL2 ), exp1 ), exp2 ) );
- tmp1 = Log2_norm_lc( L_tmp );
- Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q15 format = Q0 format */
- tmp1 = round_fx_sat( L_shl_sat( Ltemp, 12 ) ); /* Q12 */
- RL_fx = L_mult0( tmp1, 10 );
- }
-
- IF( EH2_fx == 0 )
- {
- exp2 = norm_l( EH2_fx );
- L_tmp = L_shl( EH2_fx, exp2 );
- exp2 = sub( sub( 30, exp2 ), qEH2 );
- tmp1 = Log2_norm_lc( L_tmp );
- Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q13 format = Q0 format */
- tmp1 = round_fx_sat( L_shl_sat( Ltemp, 12 ) ); /* Q12 */
- RH_fx = L_mult0( tmp1, 10 );
- }
- ELSE
- {
- exp1 = norm_l( EH2_fx );
- tmp1 = extract_h( L_shl( EH2_fx, exp1 ) ); /*qEH2+exp1-16 */
- tmp1 = div_s( 16384, tmp1 ); /*14-(qEH2+exp1-16)-> 30-qEH2-exp1 */
- L_tmp = Mult_32_16( EH1_fx, tmp1 ); /*15+qEH1-qEH2-exp1 */
-
- exp2 = norm_l( L_tmp );
- L_tmp = L_shl( L_tmp, exp2 ); /*15+qEH1-qEH2-exp1+exp2 */
- exp2 = sub( 30, add( 30, add( sub( sub( qEH1, qEH2 ), exp1 ), exp2 ) ) );
- tmp1 = Log2_norm_lc( L_tmp );
- Ltemp = Mpy_32_16( exp2, tmp1, 9864 ); /*10*log(2) in Q13 format = Q0 format */
- tmp1 = round_fx_sat( L_shl_sat( Ltemp, 12 ) ); /* Q12 */
- RH_fx = L_mult0( tmp1, 10 );
- }
-
- fid = 0;
- move16();
- IF( LT_32( RL_fx, -12288 ) ) /* -3 in Q12 */
- {
- fid = 1;
- move16();
- }
- ELSE IF( LT_32( RH_fx, -12288 ) ) /* -3 in Q12 */
- {
- fid = 2;
- move16();
- }
-
- IF( rf_flag == 0 )
- {
-
- SWITCH( fid )
- {
- case 1:
- /* Update other filter memory */
- Scale_sig( hSC_VBR->shape3_filt_mem_fx, 10, ( qGain - hSC_VBR->qprevGain_fx ) );
- pz_filter_sp_fx( shape3_num_coef_fx, shape3_den_coef_fx, ptr_fx, filtRes_fx, hSC_VBR->shape3_filt_mem_fx, 10, 10, L_FRAME, 1 ); /*1 = (16-qformat of shape1 cofficient) */
-
- /* filter the residual to desired shape */
- Scale_sig( hSC_VBR->shape2_filt_mem_fx, 10, ( qGain - hSC_VBR->qprevGain_fx ) );
- pz_filter_sp_fx( shape2_num_coef_fx, shape2_den_coef_fx, ptr_fx, ptr_tmp_fx, hSC_VBR->shape2_filt_mem_fx, 10, 10, L_FRAME, 1 ); /*1 = (16-qformat of shape1 cofficient) */
- Copy( ptr_tmp_fx, ptr_fx, L_FRAME );
-
- BREAK;
- case 2:
- /* Update other filter memory */
- Scale_sig( hSC_VBR->shape2_filt_mem_fx, 10, ( qGain - hSC_VBR->qprevGain_fx ) );
- pz_filter_sp_fx( shape2_num_coef_fx, shape2_den_coef_fx, ptr_fx, filtRes_fx, hSC_VBR->shape2_filt_mem_fx, 10, 10, L_FRAME, 1 ); /*1 = (16-qformat of shape1 cofficient) */
-
- /* filter the residual to desired shape */
- Scale_sig( hSC_VBR->shape3_filt_mem_fx, 10, ( qGain - hSC_VBR->qprevGain_fx ) );
- pz_filter_sp_fx( shape3_num_coef_fx, shape3_den_coef_fx, ptr_fx, ptr_tmp_fx, hSC_VBR->shape3_filt_mem_fx, 10, 10, L_FRAME, 1 ); /*1 = (16-qformat of shape1 cofficient) */
-
- Copy( ptr_tmp_fx, ptr_fx, L_FRAME );
-
- BREAK;
- default:
- Scale_sig( hSC_VBR->shape2_filt_mem_fx, 10, ( qGain - hSC_VBR->qprevGain_fx ) );
- pz_filter_sp_fx( shape2_num_coef_fx, shape2_den_coef_fx, ptr_fx, filtRes_fx, hSC_VBR->shape2_filt_mem_fx, 10, 10, L_FRAME, 1 ); /*1 = (16-qformat of shape1 cofficient) */
-
- Scale_sig( hSC_VBR->shape3_filt_mem_fx, 10, ( qGain - hSC_VBR->qprevGain_fx ) );
- pz_filter_sp_fx( shape3_num_coef_fx, shape3_den_coef_fx, ptr_fx, filtRes_fx, hSC_VBR->shape3_filt_mem_fx, 10, 10, L_FRAME, 1 ); /*1 = (16-qformat of shape1 cofficient) */
-
- BREAK;
- }
-
- qE2 = qGain;
- move16();
-
- E2_fx = L_deposit_l( 0 );
- FOR( i = 0; i < L_FRAME; i++ )
- {
- Ltemp = L_mult0( ptr_fx[i], ptr_fx[i] ); /*Q(2*qE2+1) */
- Ltemp = L_shr_r( Ltemp, 4 );
- E2_fx = L_add( E2_fx, Ltemp );
- }
- qE2 = sub( shl( qE2, 1 ), 4 );
-
- test();
- IF( E3_fx == 0 )
- {
- R_fx = 0;
- move16();
- }
- ELSE IF( ( E2_fx == 0 ) && ( E3_fx != 0 ) )
- {
- exp1 = norm_l( E3_fx );
- tmp1 = extract_h( L_shl( E3_fx, exp1 ) ); /*qE3+exp1-16 */
- tmp1 = div_s( 16384, tmp1 ); /*14-(qE3+exp1-16)-> 30-qE3-exp1 */
- exp1 = sub( exp1, 30 - qE3 );
-
- L_tmp = L_deposit_h( tmp1 );
- L_tmp = Isqrt_lc( L_tmp, &exp1 );
- Ltemp = L_shl( L_tmp, sub( exp1, 12 ) );
- R_fx = round_fx( Ltemp );
- }
- ELSE
- {
- exp1 = norm_l( E3_fx );
- tmp1 = extract_h( L_shl( E3_fx, exp1 ) ); /*qE3+exp1-16 */
- tmp1 = div_s( 16384, tmp1 ); /*14-(qE3+exp1-16)-> 30-qE3-exp1 */
- L_tmp = Mult_32_16( E2_fx, tmp1 ); /*qE2+30-qE3-exp1-15=>15+qE2-qE3-exp1 */
-
- exp2 = norm_l( L_tmp );
- L_tmp = L_shl( L_tmp, exp2 ); /*15+qE2-qE3-exp1+exp2 */
- exp2 = sub( 30, add( sub( sub( add( 15, qE2 ), qE3 ), exp1 ), exp2 ) );
- L_tmp = Isqrt_lc( L_tmp, &exp2 ); /*Q(31+exp2) */
- R_fx = round_fx( L_tmp );
- exp1 = sub( sub( sub( 31, exp2 ), 16 ), 7 );
- }
-
- FOR( i = 0; i < L_FRAME; i++ )
- {
- L_tmp = L_mult0( R_fx, ptr_fx[i] );
- L_tmp = L_shr_r( L_tmp, exp1 + 1 );
- ptr_fx[i] = round_fx( L_shl( L_tmp, 16 ) );
- move16();
- }
- *qIn1 = sub( qGain, 1 );
- move16();
- }
-
- IF( EQ_16( rf_flag, 1 ) )
- {
- hRF->rf_indx_nelp_fid[0] = fid;
- move16();
- }
- ELSE
- {
- push_indice( hBstr, IND_NELP_FID, fid, 2 );
- }
- }
-
- hSC_VBR->qprevGain_fx = qGain;
- move16();
-
- IF( rf_flag == 0 )
- {
- FOR( i = 0; i < L_FRAME; i++ )
- {
- exc_fx[i] = ptr_fx[i];
- move16();
- }
- }
-
- return;
-}
diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c
index 41078054cea37891352a3551c8538cc8db507a13..67e7fbf35dddd61109c4a0aab264c4e2831091a4 100644
--- a/lib_enc/nois_est_fx.c
+++ b/lib_enc/nois_est_fx.c
@@ -62,10 +62,11 @@
* y(n)(Qx) = alpha(Q15) * x(Qx) + (1.0f-alpha)* y(n-1) (Qx)
*-----------------------------------------------------------------*/
-Word16 noise_est_AR1_Qx( /* o : Qx y(n) */
- Word16 x, /* i : Qx x(n) */
- Word16 y, /* i : Qx y(n-1) */
- Word16 alpha /*i : Q15 scaling of driving x(n) */
+/* o : Qx y(n) */
+Word16 noise_est_AR1_Qx(
+ Word16 x, /* i : Qx x(n) */
+ Word16 y, /* i : Qx y(n-1) */
+ Word16 alpha /*i : Q15 scaling of driving x(n) */
)
{
Word16 alpham1;
@@ -75,10 +76,11 @@ Word16 noise_est_AR1_Qx( /* o : Qx y(n) */
return mac_r( L_mult( y, alpham1 ), x, alpha );
}
-Word32 noise_est_AR1_Qx_32( /* o : Qx y(n) */
- Word32 x, /* i : Qx x(n) */
- Word32 y, /* i : Qx y(n-1) */
- Word32 alpha /*i : Q15 scaling of driving x(n) */
+/* o : Qx y(n) */
+Word32 noise_est_AR1_Qx_32(
+ Word32 x, /* i : Qx x(n) */
+ Word32 y, /* i : Qx y(n-1) */
+ Word32 alpha /*i : Q15 scaling of driving x(n) */
)
{
Word32 alpham1;
@@ -89,6 +91,7 @@ Word32 noise_est_AR1_Qx_32( /* o : Qx y(n) */
return Madd_32_32( Mpy_32_32( y, alpham1 ), x, alpha );
}
+
/*-----------------------------------------------------------------*
* noise_est_ln_q8_fx()
*
@@ -126,12 +129,13 @@ static Word16 noise_est_ln_q8_fx(
*
*-----------------------------------------------------------------*/
-static Word32 eps_quota_fx( /* o: eps_num/eps_den in q_out */
- Word16 eps_num_h, /* num high ,*/
- Word16 eps_num_l, /* num low (signed) ,*/
- Word16 eps_den_h, /* den low */
- Word16 eps_den_l, /* den low (signed),*/
- Word16 q_out /* range 15...0 , tested with 11 and 12 */
+/* o: eps_num/eps_den in q_out */
+static Word32 eps_quota_fx(
+ Word16 eps_num_h, /* num high ,*/
+ Word16 eps_num_l, /* num low (signed) ,*/
+ Word16 eps_den_h, /* den low */
+ Word16 eps_den_l, /* den low (signed),*/
+ Word16 q_out /* range 15...0 , tested with 11 and 12 */
)
{
Word32 L_tmp_num, L_tmp_den;
@@ -139,7 +143,6 @@ static Word32 eps_quota_fx( /* o: eps_num/eps_den in q_out
Word16 m_num, m_den;
Word16 num_shift;
-
L_tmp_num = L_Comp( eps_num_h, eps_num_l );
L_tmp_den = L_Comp( eps_den_h, eps_den_l );
@@ -166,11 +169,13 @@ static Word32 eps_quota_fx( /* o: eps_num/eps_den in q_out
return L_shr( m_num, num_shift );
}
+
/*-----------------------------------------------------------------*
* noise_est_init_fx()
*
* Initialization of Noise estimator
*-----------------------------------------------------------------*/
+
void noise_est_init_fx(
NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */
)
@@ -385,6 +390,8 @@ void noise_est_init_ivas_fx(
return;
}
+
+
/*-----------------------------------------------------------------*
* noise_est_pre_fx()
*
@@ -432,7 +439,6 @@ void noise_est_pre_fx(
hNoiseEst->Etot_l_fx = add( hNoiseEst->Etot_l_fx, 20 );
move16(); /* 20 = .08 in Q8 */
-
/* Could even be higher but it also delays first entry to DTX */
IF( GT_16( hNoiseEst->harm_cor_cnt, HE_LT_CNT_PRE_FX ) )
{
@@ -611,6 +617,8 @@ void noise_est_pre_32fx(
return;
}
+
+
/*==================================================================================*/
/* FUNCTION : noise_est_down_fx() */
/*----------------------------------------------------------------------------------*/
@@ -638,7 +646,6 @@ void noise_est_pre_32fx(
/* _ (Word32[]) tmpN_he1 : temporary noise update 1 Q_new+QSCALE */
/*----------------------------------------------------------------------------------*/
-
void noise_est_down_fx(
const Word32 fr_bands[], /* i : per band input energy (contains 2 vectors) */
Word32 bckr[], /* i/o: per band background noise energy estimate */
@@ -650,7 +657,7 @@ void noise_est_down_fx(
Word16 Etot, /* i : Energy of current frame */
Word16 *Etot_last, /* i/o: Energy of last frame Q8 */
Word16 *Etot_v_h2, /* i/o: Energy variations of noise frames Q8 */
- Word16 Q_new,
+ const Word16 Q_new,
const Word32 e_min /* i : minimum energy scaled Q_new + QSCALE */
)
@@ -689,6 +696,7 @@ void noise_est_down_fx(
Ltmp = Mpy_32_16( e_Noise, f_Noise, LG10 );
*totalNoise = round_fx( L_shl( Ltmp, 10 ) ); /*Q8*/
move16();
+
/*-----------------------------------------------------------------*
* Average energy per frame for each frequency band
*-----------------------------------------------------------------*/
@@ -836,6 +844,7 @@ void noise_est_down_ivas_fx(
/*-----------------------------------------------------------------*
* Background noise energy update
*-----------------------------------------------------------------*/
+
FOR( i = 0; i < NB_BANDS; i++ )
{
/* tmpN[i] = (1-ALPHA) * bckr[i] + ALPHA * enr[i]; */
@@ -896,9 +905,11 @@ void noise_est_down_ivas_fx(
move16();
move16();
move16();
+
/*------------------------------------------------------------------*
* Energy variation update
*------------------------------------------------------------------*/
+
/*Etot_v = (float) fabs(*Etot_last - Etot);*/
L_Etot_v = L_abs( L_sub( L_Etot_last, L_Etot ) ); /* Q24 */
@@ -914,11 +925,13 @@ void noise_est_down_ivas_fx(
return;
}
+
/*-----------------------------------------------------------------*
* noise_est_fx()
*
* Noise energy estimation (noise energy is updated in case of noise-only frame)
*-----------------------------------------------------------------*/
+
void noise_est_fx(
Encoder_State *st_fx, /* i/o: state structure */
const Word16 old_pitch1, /* i : previous frame OL pitch[1] */
@@ -995,6 +1008,7 @@ void noise_est_fx(
/*-----------------------------------------------------------------*
* Initialization
*-----------------------------------------------------------------*/
+
vad_bwidth_fx = st_fx->input_bwidth;
move16();
@@ -1105,8 +1119,14 @@ void noise_est_fx(
{
i = 0;
move16();
+#ifndef FIX_2364_HARM_MULT_HARM
*loc_harm = multi_harm_fx( EspecdB, hNoiseEst->old_S_fx, hNoiseEst->cor_map_fx, &hNoiseEst->multi_harm_limit_fx, st_fx->total_brate,
st_fx->bwidth, ( st_fx->hGSCEnc != NULL ) ? &hGSCEnc->cor_strong_limit : &i, &hSpMusClas->mean_avr_dyn_fx, &hSpMusClas->last_sw_dyn_fx, cor_map_sum, sp_floor, S_map );
+#else
+ test();
+ *loc_harm = multi_harm_fx( EVS_MONO, EspecdB, hNoiseEst->old_S_fx, hNoiseEst->cor_map_fx, &hNoiseEst->multi_harm_limit_fx, st_fx->total_brate,
+ st_fx->bwidth, ( st_fx->hGSCEnc != NULL ) ? &hGSCEnc->cor_strong_limit : &i, &hSpMusClas->mean_avr_dyn_fx, &hSpMusClas->last_sw_dyn_fx, cor_map_sum, sp_floor, S_map );
+#endif
move16();
}
@@ -1157,7 +1177,6 @@ void noise_est_fx(
}
Lsum_den = L_shr( Lsum_den, tmpExp );
-
/* calculation of spectral diversity */
/* THR_SPDIV_FX = 5 , 1/5 Q15 = 6554 */
spec_div = 0;
@@ -1219,7 +1238,6 @@ void noise_est_fx(
/* *st_noise_char = M_ALPHA * *st_noise_char + (1-M_ALPHA) * noise_chartmp */
hNoiseEst->noise_char_fx = mac_r( L_mult( M_ALPHA_FX, hNoiseEst->noise_char_fx ), ONE_MINUS_M_ALPHA, noise_chartmp );
-
nchar_thr = THR_NCHAR_WB_FX;
move16(); /* 1.0 Q11 */
if ( vad_bwidth_fx == NB )
@@ -1258,6 +1276,7 @@ void noise_est_fx(
/*if( alpha > 0.999f { alpha = 0.999f;} */
alpha = s_min( alpha, 32735 ); /*.999 in Q15*/
alpham1 = negate( add( -32768, alpha ) ); /* 1.0 - alpha */
+
/*--------------------------------------------------------------*
* during significant attacks, replace the LT energy by the
* current energy this will cause non_sta2 failures to occur in
@@ -1369,6 +1388,7 @@ void noise_est_fx(
move16();
}
}
+
test();
IF( GE_16( i, 2 ) && LE_16( i, 16 ) )
{
@@ -1437,11 +1457,15 @@ void noise_est_fx(
test();
*st_harm_cor_cnt = add( *st_harm_cor_cnt, 1 );
move16();
+
+ test();
+ test();
if ( ( Etot > 0 ) && ( ( *loc_harm > 0 ) || ( GT_16( round_fx( Ltmp ), COR_MAX_NNE_FX ) ) ) )
{
*st_harm_cor_cnt = 0;
move16();
}
+
test();
test();
test();
@@ -1452,6 +1476,7 @@ void noise_est_fx(
{
*st_harm_cor_cnt = 1;
}
+
test();
test();
if ( GT_16( *st_harm_cor_cnt, 1 ) &&
@@ -1465,10 +1490,10 @@ void noise_est_fx(
move16();
}
-
/*-----------------------------------------------------------------*
* Energy based pause length counter
*-----------------------------------------------------------------*/
+
test();
IF( ( *bg_cnt >= 0 ) && ( GT_16( sub( Etot, Etot_l_lp ), 1280 ) /*5.0 in Q8*/ ) )
{
@@ -1486,6 +1511,7 @@ void noise_est_fx(
move16();
}
}
+
if ( *bg_cnt >= 0 )
{
*bg_cnt = add( *bg_cnt, 1 );
@@ -1506,7 +1532,6 @@ void noise_est_fx(
epsP_0_2 = s_max( 0, epsP_0_2 ); /* min value is 0 , Q12 */
-
/* st->epsP_0_2_lp = 0.15f * epsP_0_2 + (1.0f-0.15f) * st->epsP_0_2_lp; */
alpha = 4915;
move16(); /*0.15 in Q15 */
@@ -1531,7 +1556,6 @@ void noise_est_fx(
/* epsP_0_2_ad_lp_max = max(epsP_0_2_ad,st->epsP_0_2_ad_lp);*/
epsP_0_2_ad_lp_max = s_max( epsP_0_2_ad, hNoiseEst->epsP_0_2_ad_lp_fx ); /* Q12 */
-
/*-----------------------------------------------------------------*
* Linear predition efficiency 2 to 16 order
*-----------------------------------------------------------------*/
@@ -1546,7 +1570,6 @@ void noise_est_fx(
epsP_2_16 = s_max( 0, epsP_2_16 ); /* min value is 0 , Q12 */
-
/* if (epsP_2_16 > st->epsP_2_16_lp){
st->epsP_2_16_lp = 0.2f * epsP_2_16 + (1.0f-0.2f) * st->epsP_2_16_lp;
} else {
@@ -1568,7 +1591,6 @@ void noise_est_fx(
move16();
epsP_2_16_dlp = sub( hNoiseEst->epsP_2_16_lp_fx, hNoiseEst->epsP_2_16_lp2_fx );
-
/* if (epsP_2_16_dlp < st->epsP_2_16_dlp_lp2 ) {
st->epsP_2_16_dlp_lp2 = 0.02f * epsP_2_16_dlp + (1.0f-0.02f) * st->epsP_2_16_dlp_lp2;
} else {
@@ -1639,7 +1661,6 @@ void noise_est_fx(
hNoiseEst->low_tn_track_cnt = tmp;
move16();
-
/* update of the long-term non-stationarity measure (between 0 and 1) */
/* if ( (non_sta > th_sta) || (*loc_harm > 0) ) {
st->act_pred = M_GAMMA * st->act_pred + (1-M_GAMMA) * 1;
@@ -1657,10 +1678,10 @@ void noise_est_fx(
hNoiseEst->act_pred_fx = tmp;
move16();
-
/*-----------------------------------------------------------------*
* Background noise adaptation enable flag
*-----------------------------------------------------------------*/
+
Ltmp = L_mult( st_fx->voicing_fx[0], 16384 );
Ltmp = L_mac( Ltmp, st_fx->voicing_fx[1], 16384 );
cor_tmp = mac_r_sat( Ltmp, corr_shift, MAX_16 );
@@ -1724,17 +1745,14 @@ void noise_est_fx(
}
hNoiseEst->aEn = add( hNoiseEst->aEn, tmp );
-
hNoiseEst->aEn = s_min( hNoiseEst->aEn, 6 );
hNoiseEst->aEn = s_max( hNoiseEst->aEn, 0 );
/* Additional NNE detectors */
-
/* comb_ahc_epsP = max(max(st->act_pred, st->lt_haco_ev), epsP_2_16_dlp); */
/* Q15 Q15 Q12 */
comb_ahc_epsP = s_max( s_max( shr( hNoiseEst->act_pred_fx, 15 - 12 ), shr( hNoiseEst->lt_haco_ev_fx, 15 - 12 ) ), epsP_2_16_dlp ); /* Q12 */
-
/* comb_hcm_epsP = max(max(st->lt_haco_ev,epsP_2_16_dlp_max),epsP_0_2_ad_lp_max); */
/* Q15 Q12 Q12 */
comb_hcm_epsP = s_max( s_max( shr( hNoiseEst->lt_haco_ev_fx, 15 - 12 ), epsP_2_16_dlp_max ), epsP_0_2_ad_lp_max ); /* Q12 */
@@ -1788,7 +1806,6 @@ void noise_est_fx(
move16(); /* Q0 */
}
-
/* ns_mask = non_sta < 1e5f; */
ns_mask = 0;
move16();
@@ -1798,7 +1815,6 @@ void noise_est_fx(
move16(); /* Q0 */
}
-
/* lt_haco_mask = st->lt_haco_ev < 0.5f; */
lt_haco_mask = 0;
move16();
@@ -1817,7 +1833,6 @@ void noise_est_fx(
move16(); /* Q0 */
}
-
/* SD_1 = ( (epsP_0_2_ad > 0.5f) && (epsP_0_2 > 7.95f) ); */
SD_1 = 0;
move16();
@@ -1917,7 +1932,6 @@ void noise_est_fx(
tmp = s_and( tmp, SD_1_inv );
PAU = s_or( PAU, s_and( tmp, s_or( s_and( PD_3, s_or( PD_1, PD_2 ) ), s_or( PD_4, PD_5 ) ) ) );
-
/* NEW_POS_BG = (PAU | BG_1) & bg_bgd3; note bitwise logic in float */
NEW_POS_BG = s_and( s_or( PAU, BG_1 ), bg_bgd3 );
@@ -1931,7 +1945,6 @@ void noise_est_fx(
move16();
}
-
/* When the signal dynamics is high and the energy is close to the background estimate */
/* sd1_bgd = (st->sign_dyn_lp > 15)
&& (Etot - st->Etot_l_lp ) < 2*st->Etot_v_h2
@@ -2182,11 +2195,13 @@ void noise_est_fx(
return;
}
+
/*-----------------------------------------------------------------*
* noise_est_fx()
*
* Noise energy estimation (noise energy is updated in case of noise-only frame)
*-----------------------------------------------------------------*/
+
void noise_est_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
const Word16 old_pitch1, /* i : previous frame OL pitch[1] */
@@ -2279,10 +2294,10 @@ void noise_est_ivas_fx(
/*-----------------------------------------------------------------*
* Initialization
*-----------------------------------------------------------------*/
+
vad_bwidth_fx = st_fx->input_bwidth;
move16();
-
/*st_fx->ener_RAT = 10.0f * (float)log10( mean(lf_E, 8));*/
temp = 0;
move64();
@@ -2336,6 +2351,7 @@ void noise_est_ivas_fx(
}
}
}
+
/*-----------------------------------------------------------------*
* Set the threshold for eps & non_sta based on input sampling rate
* The reason is that in case of 8kHz sampling input, there is nothing
@@ -2389,25 +2405,31 @@ void noise_est_ivas_fx(
move16(); /* low correlation -> probably inactive signal */
}
- /* Update */
-
/*-----------------------------------------------------------------*
* Multi-harmonic analysis
*-----------------------------------------------------------------*/
+
IF( hFrontVad == NULL )
{
IF( st_fx->hSpMusClas != NULL )
{
i = 0;
move16();
+#ifndef FIX_2364_HARM_MULT_HARM
*loc_harm = multi_harm_ivas_fx( EspecdB, hNoiseEst->old_S_fx, hNoiseEst->cor_map_fx, &hNoiseEst->multi_harm_limit_fx, st_fx->total_brate,
st_fx->bwidth, ( st_fx->hGSCEnc != NULL ) ? &hGSCEnc->cor_strong_limit : &i, &hSpMusClas->mean_avr_dyn_fx, &hSpMusClas->last_sw_dyn_fx, cor_map_sum, sp_floor, S_map );
+#else
+ *loc_harm = multi_harm_fx( st_fx->element_mode, EspecdB, hNoiseEst->old_S_fx, hNoiseEst->cor_map_fx, &hNoiseEst->multi_harm_limit_fx, st_fx->total_brate,
+ st_fx->bwidth, ( st_fx->hGSCEnc != NULL ) ? &hGSCEnc->cor_strong_limit : &i, &hSpMusClas->mean_avr_dyn_fx, &hSpMusClas->last_sw_dyn_fx, cor_map_sum, sp_floor, S_map );
+#endif
move16();
}
}
+
/*-----------------------------------------------------------------*
* Detection of frames with non-stationary spectral content
*-----------------------------------------------------------------*/
+
/* weighted sum of spectral changes per critical bands */
w_sum_num = 0;
move64();
@@ -2419,6 +2441,7 @@ void noise_est_ivas_fx(
Word16 exp, exp2;
w_sum_den = 0;
move64();
+
FOR( i = 10; i <= st_fx->max_band; i++ )
{
Lnum = L_max( *pt1, *pt2 );
@@ -2431,7 +2454,6 @@ void noise_est_ivas_fx(
num = extract_h( Mpy_32_32( Lnum, Lnum ) ); // 2*(q_fr_bands+exp)-31-16
ExpNum = add( sub( shl( q_fr_bands, 1 ), 47 ), shl( exp, 1 ) );
-
den = E_MIN_FXQ31 >> 8; // 29360, 0.0035f in Q23
ExpDen = Q23;
move32();
@@ -2596,6 +2618,7 @@ void noise_est_ivas_fx(
/*if( alpha > 0.999f { alpha = 0.999f;} */
alpha = s_min( alpha, 32735 ); /*.999 in Q15*/
alpham1 = negate( add( -32768, alpha ) ); /* 1.0 - alpha */
+
/*--------------------------------------------------------------*
* during significant attacks, replace the LT energy by the
* current energy this will cause non_sta2 failures to occur in
@@ -2770,7 +2793,8 @@ void noise_est_ivas_fx(
}
}
- } /* end of band loop FOR( i = st_fx->min_band; i <= st_fx->max_band; i++ ) */
+ } /* end of band loop FOR( i = st_fx->min_band; i <= st_fx->max_band; i++ ) */
+
*non_staX = L_shl( *non_staX, 12 ); // Q20
move32();
IF( LT_16( Etot, -1280 /* -5.0f in Q8 */ ) )
@@ -2804,6 +2828,7 @@ void noise_est_ivas_fx(
Word16 exp_tmp;
st_E_var_est_fx = BASOP_Util_Add_Mant32Exp( hNoiseEst->L_Etot_sq_st_est_fx, Q15, L_negate( Mpy_32_32( hNoiseEst->L_Etot_st_est_fx, hNoiseEst->L_Etot_st_est_fx ) ), Q16, &exp_tmp ); // exp(exp_tmp)
+
/*-----------------------------------------------------------------*
* Count frames since last correlation or harmonic event
*-----------------------------------------------------------------*/
@@ -2813,6 +2838,7 @@ void noise_est_ivas_fx(
*st_harm_cor_cnt = add( *st_harm_cor_cnt, 1 );
move16();
+
test();
test();
if ( ( Etot > 0 ) && ( ( *loc_harm > 0 ) || ( GT_32( Ltmp, 1825361101 /* 0.85 in Q31 */ ) ) ) )
@@ -2831,6 +2857,7 @@ void noise_est_ivas_fx(
*st_harm_cor_cnt = 1;
move16();
}
+
test();
test();
IF( GT_16( *st_harm_cor_cnt, 1 ) && GT_16( Etot, 7680 /* 30.0f in Q8 */ ) && EQ_16( BASOP_Util_Cmp_Mant32Exp( st_E_var_est_fx, exp_tmp, 524288 /* 8.0f in Q16 */, Q15 ), 1 ) )
@@ -2840,7 +2867,6 @@ void noise_est_ivas_fx(
move16();
}
-
/*-----------------------------------------------------------------*
* Energy based pause length counter
*-----------------------------------------------------------------*/
@@ -2993,7 +3019,6 @@ void noise_est_ivas_fx(
hNoiseEst->lt_Ellp_dist_fx = mac_r( L_mult( tmp, 983 /* 0.03 in Q15*/ ), hNoiseEst->lt_Ellp_dist_fx, 31785 /* 0.97 in Q15*/ ); // Q8
move16();
-
/* if (st->harm_cor_cnt == 0) {
st->lt_haco_ev = 0.03f*1.0 + 0.97f*st->lt_haco_ev;
} else {
@@ -3047,6 +3072,7 @@ void noise_est_ivas_fx(
/*-----------------------------------------------------------------*
* Background noise adaptation enable flag
*-----------------------------------------------------------------*/
+
/*
if( ( (*st_harm_cor_cnt < 3*HC_CNT_SLOW )
&& ( ( non_sta > th_sta ) ||
@@ -3078,7 +3104,6 @@ void noise_est_ivas_fx(
LepsP = extract_l( div_s( num, den ) ); // Q15+exp-exp2
LepsP = L_shr( LepsP, add( sub( exp, exp2 ), 4 ) ); // Q11
-
test();
test();
test();
@@ -3118,9 +3143,11 @@ void noise_est_ivas_fx(
move16();
move16();
}
+
/*-----------------------------------------------------------------*
* Stereo classifier - save raw aEn
*-----------------------------------------------------------------*/
+
IF( hStereoClassif != NULL )
{
/*
@@ -3151,14 +3178,11 @@ void noise_est_ivas_fx(
move16();
}
-
/* Additional NNE detectors */
-
/* comb_ahc_epsP = max(max(st->act_pred, st->lt_haco_ev), epsP_2_16_dlp); */
/* Q15 Q15 Q12 */
comb_ahc_epsP = s_max( shr( s_max( hNoiseEst->act_pred_fx, hNoiseEst->lt_haco_ev_fx ), 15 - 12 ), epsP_2_16_dlp ); /* Q12 */
-
/* comb_hcm_epsP = max(max(st->lt_haco_ev,epsP_2_16_dlp_max),epsP_0_2_ad_lp_max); */
/* Q15 Q12 Q12 */
comb_hcm_epsP = s_max( s_max( shr( hNoiseEst->lt_haco_ev_fx, 15 - 12 ), epsP_2_16_dlp_max ), epsP_0_2_ad_lp_max ); /* Q12 */
@@ -3212,7 +3236,6 @@ void noise_est_ivas_fx(
move16(); /* Q0 */
}
-
/* ns_mask = non_sta < 1e5f; */
ns_mask = 0;
move16();
@@ -3222,7 +3245,6 @@ void noise_est_ivas_fx(
move16(); /* Q0 */
}
-
/* lt_haco_mask = st->lt_haco_ev < 0.5f; */
lt_haco_mask = 0;
move16();
@@ -3241,7 +3263,6 @@ void noise_est_ivas_fx(
move16(); /* Q0 */
}
-
/* SD_1 = ( (epsP_0_2_ad > 0.5f) && (epsP_0_2 > 7.95f) ); */
SD_1 = 0;
move16();
@@ -3578,6 +3599,7 @@ void noise_est_ivas_fx(
}
}
}
+
/*st->lt_aEn_zero = 0.2f * (st->aEn==0) + (1-0.2f) *st->lt_aEn_zero;*/
/* y(n+1)= alpha*tmp + (1-alpha)*y(n) */
L_tmp = 0;
diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c
index b812bd6fc2c3bdc2edbffdd8fd7ccb77e203c857..1fff579055698c31cf92d70aabf0511db6b6e993 100644
--- a/lib_enc/pit_enc_fx.c
+++ b/lib_enc/pit_enc_fx.c
@@ -762,6 +762,7 @@ Word16 pitch_fr4_fx(
Word16 corr_v[15 + 2 * L_INTERPOL1 + 1]; /* Total length = t0_max-t0_min+1+2*L_inter */
Word16 pit_min;
Word16 cor_max;
+ Word16 corr_off;
/* initialization */
IF( limit_flag == 0 )
@@ -805,34 +806,38 @@ Word16 pitch_fr4_fx(
t_min = sub( t0_min, L_INTERPOL1 );
t_max = add( t0_max, L_INTERPOL1 );
- corr = &corr_v[-t_min];
+
+ corr = corr_v;
+ corr_off = -t_min;
+ move16();
+
/* corr[t_min..t_max] */
if ( element_mode > EVS_MONO )
{
- norm_corr_ivas_fx( exc, xn, h, t_min, t_max, corr, L_subfr, Q_new );
+ norm_corr_ivas_fx( exc, xn, h, t_min, t_max, corr + corr_off, L_subfr, Q_new );
}
else
{
- norm_corr_fx( exc, xn, h, t_min, t_max, corr, L_subfr );
+ norm_corr_fx( exc, xn, h, t_min, t_max, corr + corr_off, L_subfr );
}
/*-----------------------------------------------------------------*
* Find integer pitch
*-----------------------------------------------------------------*/
- max_val = corr[t0_min];
+ max_val = corr[t0_min + corr_off];
move16();
t0 = t0_min;
move16();
FOR( i = t0_min + 1; i <= t0_max; i++ )
{
- if ( GE_16( corr[i], max_val ) )
+ if ( GE_16( corr[i + corr_off], max_val ) )
{
t0 = i;
move16();
}
- max_val = s_max( corr[i], max_val );
+ max_val = s_max( corr[i + corr_off], max_val );
}
IF( EQ_16( t0_fr1, pit_min ) )
@@ -846,7 +851,7 @@ Word16 pitch_fr4_fx(
{
i = sub( i, 2 );
}
- IF( GT_16( corr[i], corr[i + 2] ) )
+ IF( GT_16( corr[i + corr_off], corr[i + 2 + corr_off] ) )
{
t0 = i;
move16();
@@ -897,15 +902,15 @@ Word16 pitch_fr4_fx(
{
fraction = 0;
move16();
- cor_max = Interpol_4( &corr[t0], fraction );
+ cor_max = Interpol_4( &corr[t0 + corr_off], fraction );
}
ELSE
{
t0 = sub( t0, 1 );
- cor_max = Interpol_4( &corr[t0], fraction );
+ cor_max = Interpol_4( &corr[t0 + corr_off], fraction );
FOR( i = fraction + step; i <= 3; i = ( i + step ) )
{
- temp = Interpol_4( &corr[t0], i );
+ temp = Interpol_4( &corr[t0 + corr_off], i );
IF( GT_16( temp, cor_max ) )
{
cor_max = temp;
@@ -918,7 +923,7 @@ Word16 pitch_fr4_fx(
FOR( i = 0; i <= 3; i = ( i + step ) )
{
- temp = Interpol_4( &corr[t1], i );
+ temp = Interpol_4( &corr[t1 + corr_off], i );
IF( GT_16( temp, cor_max ) )
{
cor_max = temp;
diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c
index c28c4c5aa6507323e306d9875822eca570a98663..ff9a2ab647e30dc356085c49b1001c88d7bcf716 100644
--- a/lib_enc/pitch_ol2_fx.c
+++ b/lib_enc/pitch_ol2_fx.c
@@ -26,6 +26,7 @@
* The pitch is searched in the interval vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), cldfb_addition, vad_hover_flag, hVAD, hNoiseEst );
+ vad_flag_dtx = dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), cldfb_addition, vad_hover_flag, hVAD, hNoiseEst, NULL );
/*----------------------------------------------------------------*
* NB/WB/SWB/FB bandwidth detector
@@ -325,17 +325,19 @@ void pre_proc_fx(
*----------------------------------------------------------------*/
resetFdCngEnc_fx( st );
+
perform_noise_estimation_enc_fx( st->band_energies, st->band_energies_exp, enerBuffer, enerBuffer_exp, st->hFdCngEnc );
/*-----------------------------------------------------------------*
* Select SID or FRAME_NO_DATA frame if DTX enabled
*-----------------------------------------------------------------*/
- dtx_fx( st, vad_flag_dtx, inp_12k8, *Q_new );
+ dtx_fx( st, -1, -1, vad_flag_dtx, inp_12k8, *Q_new );
/*----------------------------------------------------------------*
* Adjust FD-CNG Noise Estimator
*----------------------------------------------------------------*/
+
test();
IF( ( NE_32( st->last_total_brate, st->total_brate ) ) || ( NE_16( st->last_bwidth, st->bwidth ) ) )
{
@@ -349,6 +351,7 @@ void pre_proc_fx(
}
configureFdCngEnc_fx( st->hFdCngEnc, st->bwidth, L_tmp );
}
+
test();
IF( st->hFdCngEnc != NULL && st->Opt_DTX_ON )
{
@@ -447,7 +450,7 @@ void pre_proc_fx(
move16();
/* Detection of very short stable st->pitch period (MODE1 bit-rates) */
- StableHighPitchDetect_fx( &flag_spitch, st->pitch, st->voicing_fx, wsp, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx,
+ StableHighPitchDetect_fx( EVS_MONO, &flag_spitch, st->pitch, st->voicing_fx, wsp, st->localVAD, &st->voicing_sm_fx, &st->voicing0_sm_fx,
&st->LF_EnergyRatio_sm_fx, &st->predecision_flag, &st->diff_sm_fx, &st->energy_sm_fx, *Q_new, st->lgBin_E_fx );
/* 1/4 pitch precision improvement */
@@ -493,6 +496,7 @@ void pre_proc_fx(
/*------------------------------------------------------------------*
* Update parameters used in the VAD and DTX
*-----------------------------------------------------------------*/
+
vad_param_updt_fx( st, old_pitch1, corr_shift, corr_shift, A, NULL, 1 );
/*-----------------------------------------------------------------*
@@ -503,12 +507,13 @@ void pre_proc_fx(
find_tilt_fx( fr_bands, hNoiseEst->bckr_fx, ee, st->pitch, st->voicing_fx, lf_E, corr_shift, st->input_bwidth,
st->max_band, hp_E, st->codec_mode, *Q_new, &( st->bckr_tilt_lt ), st->Opt_SC_VBR );
- st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee,
- corr_shift, relE, *Etot, hp_E, *Q_new, &flag_spitch, *shift, last_core_orig );
+ st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee, 0L, corr_shift, relE, *Etot, hp_E,
+ &flag_spitch, last_core_orig, NULL, *Q_new, *shift, 31 ); // Q0
- /*----------------------------------------------------------------*
+ /*-----------------------------------------------------------------*
* channel aware mode configuration *
*-----------------------------------------------------------------*/
+
test();
test();
IF( !st->Opt_RF_ON )
@@ -562,6 +567,7 @@ void pre_proc_fx(
hSC_VBR->Local_VAD = st->localVAD;
move16();
}
+
/*----------------------------------------------------------------*
* Speech/music classification
* AC frame selection
@@ -769,6 +775,7 @@ void pre_proc_fx(
/*---------------------------------------------------------------------*
* Decision matrix (selection of technologies)
*---------------------------------------------------------------------*/
+
IF( EQ_16( st->codec_mode, MODE1 ) )
{
diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h
index 85465d0c51a001cb21fe9e4370f9b05e710df8b7..49c438515789aae8dc382a315f2a91474c67ab8c 100644
--- a/lib_enc/prot_fx_enc.h
+++ b/lib_enc/prot_fx_enc.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -78,7 +78,7 @@ void analy_lp_fx(
const Word32 Core_sr, /* i :(q0) Internal core sampling rate */
const Word16 element_mode, /* i : element mode */
const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */
- Word16 Q_new, /* i : stores Q for speech */
+ const Word16 Q_new, /* i : stores Q for speech */
Word16 *Q_r /*stores q for ener*/
);
@@ -118,16 +118,18 @@ void core_switching_post_enc_fx(
const Word16 inp12k8[], /* i : i signal @12.8 kHz Qinp*/
const Word16 inp16k[], /* i : i signal @16 kHz Qinp*/
const Word16 A[], /* i : unquant. LP filter coefs. (Q12) */
- Word16 Qshift,
- Word16 Q_new,
+ const Word16 Qshift,
+ const Word16 Q_new,
const Word16 Qsp, /* i/o : Q from acelp synthsis */
Word16 *Qmus /* i/o : Q from mdct synthsis / Q of output synthesis */
);
void core_switching_pre_enc_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 *old_inp_12k8, /* i : old i signal @12.8kHz Qx*/
+ const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz Qx*/
+ const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */
const Word16 *old_inp_16k, /* i : old i signal @16kHz Qx*/
+ const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */
const Word16 active_cnt, /* i : active frame counter Q0*/
const Word16 last_element_mode /* i : last_element_mode Q0*/
);
@@ -138,32 +140,15 @@ Word16 correlation_shift_fx(
);
void dtx_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 vad, /* i : vad flag Q0*/
- const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/
- Word16 Q_speech /* i : Q factor for speech */
-);
-
-void dtx_ivas_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/
const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/
const Word16 vad, /* i : vad flag for DTX Q0*/
const Word16 speech[], /* i : Pointer to the speech frame Q_speech*/
- Word16 Q_speech /* i : Q factor for speech */
+ const Word16 Q_speech /* i : Q factor for speech */
);
Word16 dtx_hangover_addition_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 vad_flag, /* i Q0 */
- const Word16 lp_snr, /* i Q8 */
- const Word16 cldfb_subtraction, /* i Q0 number of DTX-HO frames CLDFB wants to reduce */
- Word16 *vad_hover_flag_ptr,
- VAD_HANDLE hVAD, /* i/o: VAD data handle */
- NOISE_EST_HANDLE hNoiseEst /* i : Noise estimation handle */
-);
-
-Word16 ivas_dtx_hangover_addition_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
const Word16 vad_flag, /* i Q0 */
const Word16 lp_snr, /* i Q8 */
@@ -174,17 +159,19 @@ Word16 ivas_dtx_hangover_addition_fx(
Word16 *rem_dtx_ho );
void fb_tbe_enc_fx(
+#ifndef HARMONIZE_TBE
Encoder_State *st, /* i/o: encoder state structure */
const Word16 new_input[], /* i : i speech at 48 kHz sample rate */
const Word16 fb_exc[], /* i : FB excitation from the SWB part */
- Word16 Q_fb_exc );
+ const Word16 Q_fb_exc );
void fb_tbe_enc_ivas_fx(
- Encoder_State *st, /* i/o: encoder state structure */
- const Word16 new_input[], /* i : i speech at 48 kHz sample rate Q_new_input*/
- const Word16 fb_exc[], /* i : FB excitation from the SWB part Q_fb_exc*/
- Word16 Q_fb_exc,
- Word16 Q_new_input );
+#endif
+ Encoder_State *st, /* i/o: encoder state structure */
+ const Word16 new_input[], /* i : i speech at 48 kHz sample rate Q_new_input*/
+ const Word16 fb_exc[], /* i : FB excitation from the SWB part Q_fb_exc*/
+ const Word16 Q_fb_exc,
+ const Word16 Q_new_input );
void fb_tbe_reset_enc_fx(
Word32 elliptic_bpf_2_48k_mem_fx[][4],
@@ -232,8 +219,8 @@ void find_tilt_fx(
Word16 Opt_vbr_mode /* Q0 */
);
-/* o : coding type */
-Word16 find_uv_ivas_fx(
+/*! r: coder type */
+Word16 find_uv_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/
const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/
@@ -248,24 +235,8 @@ Word16 find_uv_ivas_fx(
const Word16 last_core_orig, /* i : original last core Q0*/
STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */
const Word16 Q_new,
- const Word16 q_hp_E );
-
-/* o : coding type */
-Word16 find_uv_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/
- const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/
- const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/
- const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/
- const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/
- const Word16 relE, /* i : relative frame energy Q8*/
- const Word16 Etot, /* i : total energy Q8*/
- const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE*/
- const Word16 Q_new,
- Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/
const Word16 shift,
- const Word16 last_core_orig /* i : original last core Q0*/
-);
+ const Word16 q_hp_E );
void fine_gain_quant_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
@@ -322,7 +293,7 @@ void noise_est_down_fx(
Word16 Etot, /* i : Energy of current frame */
Word16 *Etot_last, /* i/o: Energy of last frame Q8 */
Word16 *Etot_v_h2, /* i/o: Energy variations of noise frames Q8 */
- Word16 Q_new,
+ const Word16 Q_new,
const Word32 e_min /* i : minimum energy scaled Q_new + QSCALE */
);
@@ -571,10 +542,11 @@ void speech_music_classif_fx(
);
void StableHighPitchDetect_fx(
- Word16 *flag_spitch, /* o : flag to indicate very short stable pitch*/
- Word16 pitch[], /* i/o: OL pitch buffer */
- const Word16 voicing[], /* i : OL pitch gains */
- const Word16 wsp[], /* i : weighted speech */
+ const Word16 element_mode, /* i : element mode */
+ Word16 *flag_spitch, /* o : flag to indicate very short stable pitch*/
+ Word16 pitch[], /* i/o: OL pitch buffer */
+ const Word16 voicing[], /* i : OL pitch gains */
+ const Word16 wsp[], /* i : weighted speech */
const Word16 localVAD,
Word16 *voicing_sm, /* i/o: smoothed open-loop pitch gains */
Word16 *voicing0_sm, /* i/o: smoothed high pitch gains */
@@ -585,22 +557,6 @@ void StableHighPitchDetect_fx(
Word16 Q_new,
Word16 EspecdB[] );
-void StableHighPitchDetect_ivas_fx(
- Word16 *flag_spitch, /* o : flag to indicate very short stable pitch */
- Word16 pitch[], /* i/o: OL pitch buffer Q0 */
- const Word16 voicing[], /* i : OL pitch gains Q15 */
- const Word16 wsp[], /* i : weighted speech Qx */
- const Word16 localVAD,
- Word16 *voicing_sm, /* i/o: smoothed open-loop pitch gains Q15 */
- Word16 *voicing0_sm, /* i/o: smoothed high pitch gains Q15 */
- Word16 *LF_EnergyRatio_sm, /* i/o: smoothed [0, 300Hz] relative peak energy Q7 */
- Word16 *predecision_flag, /* i/o: predecision flag */
- Word32 *diff_sm, /* i/o: smoothed pitch frequency difference Q7 */
- Word32 *energy_sm, /* i/o: smoothed energy around pitch frequency Q7 */
- Word16 Q_new,
- Word16 EspecdB[] /* Q7 */
-);
-
void swb_bwe_enc_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
Word16 *old_input_12k8_fx, /* i : i signal @12.8kHz for SWB BWE */
@@ -620,20 +576,20 @@ void swb_bwe_enc_ivas_fx(
const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz */
const Word16 *new_swb_speech_fx, /* i : original input signal at 32kHz */
const Word16 Q_new_swb_speech, /* i : Q for new_swb_speech_fx */
- Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */
+#ifdef REMOVE_SCALING_SHB_SPEECH
+ Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */
+ const Word16 Q_slb_speech
+#else
+ Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */
Word16 Q_shb_speech,
- Word16 Q_slb_speech );
-
-void swb_CNG_enc_fx(
- Encoder_State *st_fx, /* i/o: State structure */
- const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */
- const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz */
+ Word16 Q_slb_speech
+#endif
);
-void swb_CNG_enc_ivas_fx(
- Encoder_State *st, /* i/o: State structure */
- const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */
- const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */
+void swb_CNG_enc_fx(
+ Encoder_State *st_fx, /* i/o: State structure */
+ const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */
+ const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz */
);
void swb_pre_proc_fx(
@@ -669,7 +625,7 @@ void swb_tbe_enc_fx(
void swb_tbe_enc_ivas_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
STEREO_ICBWE_ENC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */
- Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q_shb */
+ Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */
Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation 2 * Q_new */
const Word16 voice_factors_fx[], /* i : voicing factors Q15 */
Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE Q_white_exc */
@@ -744,6 +700,7 @@ void wb_pre_proc_ivas_fx(
);
void wb_tbe_enc_fx(
+#ifndef HARMONIZE_TBE
Encoder_State *st_fx, /* i/o: encoder state structure */
const Word16 coder_type, /* i : coding type */
const Word16 *hb_speech, /* i : HB target signal (6-8kHz) at 16kHz */
@@ -755,6 +712,7 @@ void wb_tbe_enc_fx(
);
void wb_tbe_enc_ivas_fx(
+#endif
Encoder_State *st_fx, /* i/o: encoder state structure */
const Word16 *hb_speech, /* i : HB target signal (6-8kHz) at 16kHz Q(-1) */
const Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation Q(2*Q_new) */
@@ -812,7 +770,6 @@ void sc_vbr_enc_init_fx(
void updt_enc_common_fx(
Encoder_State *st, /* i/o: encoder state structure */
- const Word16 Etot, /* i : total energy */
const Word16 Q_new /* i : CUrrent frame scaling */
);
@@ -859,11 +816,21 @@ void gsc_enc_fx(
const Word16 Diff_len,
const Word16 bits_used,
const Word16 nb_subfr,
- Word16 *lsf_new, /* i : ISFs at the end of the frame */
+#ifndef FIX_1904_HARM_GSC_ENC
+ Word16 *lsf_new, /* i : ISFs at the end of the frame */
+#else
+ const Word16 *lsf_new, /* i : ISFs at the end of the frame */
+#endif
Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill */
Word16 *tmp_noise, /* o : noise energy */
- Word16 Q_exc );
+#ifndef FIX_1904_HARM_GSC_ENC
+ Word16 Q_exc
+#else
+ Word16 *Q_exc
+#endif
+);
+#ifndef FIX_1904_HARM_GSC_ENC
void gsc_enc_ivas_fx(
Encoder_State *st, /* i/o: State structure */
Word16 res_dct_in_fx[], /* i : dct of residual signal */
@@ -875,7 +842,7 @@ void gsc_enc_ivas_fx(
Word16 *exc_wo_nf_fx, /* o : excitation (in f domain) without noisefill */
Word16 *tmp_noise_fx, /* o : long-term noise energy */
Word16 *Q_exc );
-
+#endif
void LPDmem_enc_init_fx(
LPD_state_HANDLE hLPDmem /* i/o: LP memories */
);
@@ -886,26 +853,12 @@ void lsf_end_enc_fx(
Word16 *qlsf, /* o : quantized LSF */
const Word16 nBits_in, /* i : number of bits to spend on ISF quantization */
const Word16 coder_type_org, /* i : coding type */
- Word16 Q_ener, /* i : Q valuen for Bin_Ener */
- Word16 force_sf, /* i : Force safety-net usage if coding type supports */
- Word16 *lpc_param,
- Word16 *no_indices,
- Word16 *bits_param_lpc,
- Word16 coder_type_raw /* i : Coder type (LSF coder_type have some special cases)*/
-);
-
-void lsf_end_enc_ivas_fx(
- Encoder_State *st, /* i/o: encoder state structure */
- const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) */
- Word16 *qlsf, /* o : quantized LSF */
- const Word16 nBits_in, /* i : number of bits to spend on ISF quantization */
- const Word16 coder_type_org, /* i : coding type */
- Word16 Q_ener, /* i : Q valuen for Bin_Ener */
- Word16 force_sf, /* i : Force safety-net usage if coding type supports */
+ const Word16 Q_ener, /* i : Q value for Bin_Ener */
+ const Word16 force_sf, /* i : Force safety-net usage if coding type supports */
Word16 *lpc_param,
Word16 *no_indices,
Word16 *bits_param_lpc,
- Word16 coder_type_raw, /* i : Coder type (LSF coder_type have some special cases)*/
+ const Word16 coder_type_raw, /* i : Coder type (LSF coder_type have some special cases)*/
const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */
);
@@ -1161,12 +1114,6 @@ void td_cng_enc_init_fx(
const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/
);
-void td_cng_enc_init_ivas_fx(
- TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */
- const Word16 Opt_DTX_ON, /* i : flag indicating DTX operation Q0*/
- const Word16 max_bwidth /* i : maximum encoded bandwidth Q0*/
-);
-
void dtx_enc_init_fx(
Encoder_State *st, /* i : Encoder state handle */
const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate Q0*/
@@ -1184,11 +1131,6 @@ void coder_type_modif_fx(
const Word16 relE /* i : frame relative E to the long term average */
);
-void coder_type_modif_ivas_fx(
- Encoder_State *st, /* i/o: encoder state structure */
- const Word16 relE /* i : frame relative E to the long term average */
-);
-
void speech_music_clas_init_fx(
SP_MUS_CLAS_HANDLE hSpMusClas /* i/o: speech/music classifier handle */
);
@@ -1520,21 +1462,6 @@ void lpc_quantization_fx(
Word16 *no_param_lpc, /* Q0 */
const Word16 Q_ener );
-void lpc_quantization_ivas_fx(
- Encoder_State *st,
- const Word16 lsp[], /* Q15 */
- const Word16 lspmid[], /* Q15 */
- Word16 lsp_q[], /* Q15 */
- Word16 lsf_q[], /* 14Q1*1.28 */
- Word16 lspmid_q[], /* Q15 */
- const Word16 coder_type, /* Q0 */
- const Word16 acelp_midLpc, /* Q0 */
- Word16 param_lpc[], /* Q0 */
- Word16 nbits_lpc[], /* Q0 */
- Word16 *bits_param_lpc, /* Q0 */
- Word16 *no_param_lpc, /* Q0 */
- const Word16 Q_ener );
-
void Mode2_pit_encode_fx(
const Word16 coder_type, /* i : coding model */
const Word16 i_subfr, /* i : subframe index */
@@ -1748,23 +1675,9 @@ void reset_rf_indices_fx(
);
void CNG_enc_fx(
- Encoder_State *st_fx, /* i/o: State structure */
- Word16 Aq[], /* o : LP coefficients Q12 */
- const Word16 *speech, /* i : pointer to current frame i speech buffer Q_new */
- Word32 L_enr, /* i : residual energy from Levinson-Durbin Q6 */
- const Word16 *lsp_mid, /* i : mid frame LSPs Q15 */
- Word16 *lsp_new, /* i/o: current frame ISPs Q15 */
- Word16 *lsf_new, /* i/o: current frame ISFs Qlog2(2.56) */
- Word16 *allow_cn_step, /* o : allow CN step Q0 */
- Word16 Q_new, /* i : Q value of speech */
- Word32 *q_env,
- Word16 *sid_bw );
-
-void CNG_enc_ivas_fx(
- Encoder_State *st_fx, /* i/o: State structure */
- Word16 Aq[], /* o : LP coefficients Q12 */
- const Word16 *speech, /* i : pointer to current frame i speech buffer Q_new */
- // Word32 L_enr, /* i : residual energy from Levinson-Durbin Q6 */
+ Encoder_State *st_fx, /* i/o: State structure */
+ Word16 Aq[], /* o : LP coefficients Q12 */
+ const Word16 *speech, /* i : pointer to current frame i speech buffer Q_new */
const Word16 *lsp_mid, /* i : mid frame LSPs Q15 */
Word16 *lsp_new, /* i/o: current frame ISPs Q15 */
Word16 *lsf_new, /* i/o: current frame ISFs Qlog2(2.56) */
@@ -1805,25 +1718,14 @@ void CNG_reset_enc_fx(
);
void lsf_enc_fx(
- Encoder_State *st_fx, /* i/o: state structure */
- Word16 *lsf_new, /* o : quantized LSF vector */
- Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */
- Word16 *lsp_mid, /* i/o : mid-frame LSP vector */
- Word16 *Aq, /* o : quantized A(z) for 4 subframes */
- const Word16 Nb_ACELP_frames,
- const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
- const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */
- const Word16 Q_new );
-
-void lsf_enc_ivas_fx(
- Encoder_State *st, /* i/o: state structure */
+ Encoder_State *st_fx, /* i/o: state structure */
Word16 *lsf_new, /* o : quantized LSF vector */
Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */
Word16 *lsp_mid, /* i/o : mid-frame LSP vector */
Word16 *Aq, /* o : quantized A(z) for 4 subframes */
const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */
- const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */
- const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */
+ const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */
+ const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */
const Word16 Q_new );
void Es_pred_enc_fx(
@@ -1853,22 +1755,6 @@ void encod_nelp_fx(
Word16 Q_new,
Word16 shift );
-void encod_nelp_ivas_fx(
- Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *speech_fx, /* i : input speech Q_new-1 */
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes exp(norm_s(Aw_fx[0])+1)*/
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient exp(norm_s(Aw_fx[0])+1)*/
- Word16 *res_fx, /* o : residual signal Q_new */
- Word16 *synth_fx, /* o : core synthesis Q_new */
- Word16 *tmp_noise_fx, /* o : long-term noise energy Q8 */
- Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new */
- Word16 *exc2_fx, /* i/o: current enhanced excitation Q_new */
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6 */
- Word16 *voice_factors_fx, /* o : voicing factors Q15 */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new */
- Word16 Q_new,
- Word16 shift );
-
Word16 encod_tran_fx(
Encoder_State *st_fx, /* i/o: state structure */
const Word16 speech_fx[], /* i : input speech Q0*/
@@ -1889,26 +1775,6 @@ Word16 encod_tran_fx(
const Word16 Q_new /* i : Input scaling */
);
-Word16 encod_tran_ivas_fx(
- Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech Q0*/
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
- const Word16 *res_fx, /* i : residual signal Q_new*/
- Word16 *syn_fx, /* i/o: core synthesis Q_new*/
- Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/
- Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/
- Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
- Word16 *voice_factors, /* o : voicing factors Q15*/
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q0*/
- Word16 tc_subfr, /* i/o: TC subframe classification Q0*/
- Word16 position, /* i : maximum of residual signal index Q0*/
- Word16 *unbits, /* i/o: number of unused bits Q0*/
- const Word16 shift, /* i : Scaling to get 12 bits */
- const Word16 Q_new /* i : Input scaling */
-);
-
void coder_acelp_rf_fx(
ACELP_config *acelp_cfg_rf, /*i/o : configuration of the ACELP coding */
const Word16 coder_type, /* input: coding type Q0*/
@@ -1997,26 +1863,10 @@ void encod_unvoiced_fx(
Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
Word16 *voice_factors_fx, /* o : voicing factors Q15*/
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/
- const Word16 Q_new,
- const Word16 shift );
-
-void encod_unvoiced_ivas_fx(
- Encoder_State *st_fx, /* i/o: state structure */
- const Word16 *speech_fx, /* i : Input speech Q_new*/
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
- const Word16 *Aq_fx, /* i : 12k8 Lp coefficient Q12*/
- const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/
- const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC Q0*/
- const Word16 *res_fx, /* i : residual signal Q_new*/
- Word16 *syn_fx, /* o : core synthesis Q_new - 1*/
- Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/
- Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
- Word16 *voice_factors_fx, /* o : voicing factors Q15*/
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/
- const Word16 Q_new,
- const Word16 shift );
+ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/
+ const Word16 Q_new, /* i : Scaling factor */
+ const Word16 shift /* i : Shift needed to obtain 12 bits vectors */
+);
void enc_acelp_tcx_main_fx(
const Word16 new_samples[], /* i : new samples Q15*/
@@ -2037,50 +1887,17 @@ ivas_error encod_ppp_fx(
const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q14*/
Word16 *res_fx, /* i : residual signal Q_new*/
- Word16 *synth_fx, /* o : core synthesis Q-1*/
+ Word16 *synth_fx, /* o : core synthesis Q-1*/
Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
Word16 *exc2_fx, /* o : current enhanced excitation Q0*/
Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
Word16 *voice_factors, /* o : voicing factors Q15*/
- Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/
- Word16 Q_new,
- Word16 shift );
-
-ivas_error encod_ppp_ivas_fx(
- Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : input speech Q_new*/
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
- Word16 *res_fx, /* i : residual signal Q_new*/
- Word16 *synth_fx, /* o : core synthesis Q-1*/
- Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
- Word16 *exc2_fx, /* o : current enhanced excitation Q0*/
- Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/
- Word16 *voice_factors, /* o : voicing factors Q15*/
- Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/
- Word16 Q_new,
- Word16 shift );
+ Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/
+ const Word16 Q_new, /* i : Scaling factor */
+ const Word16 shift /* i : Shift needed to obtain 12 bits vectors */
+);
void encod_gen_voic_fx(
- Encoder_State *st_fx, /* i/o: state structure */
- const Word16 speech_fx[], /* i : i speech Q0*/
- const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
- const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/
- const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/
- const Word16 *res_fx, /* i : residual signal Q_new*/
- Word16 *syn_fx, /* i/o: core synthesis Q_new*/
- Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0*/
- Word16 *exc2_fx, /* i/o: current enhanced excitation Q0*/
- Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/
- Word16 *voice_factors_fx, /* o : voicing factors Q15*/
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/
- Word16 *unbits_fx, /* i/o: number of unused bits Q0*/
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
- const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
- Word16 shift,
- Word16 Q_new );
-
-void encod_gen_voic_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
const Word16 speech_fx[], /* i : input speech Q0*/
const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/
@@ -2094,31 +1911,13 @@ void encod_gen_voic_ivas_fx(
Word16 *voice_factors_fx, /* o : voicing factors Q15*/
Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/
Word16 *unbits_fx, /* i/o: number of unused bits Q0*/
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
- const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
- Word16 shift,
- Word16 Q_new );
+ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
+ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
+ const Word16 shift, /* i : Shift needed to obtain 12 bits vectors */
+ const Word16 Q_new /* i : Scaling factor */
+);
void encod_audio_fx(
- Encoder_State *st_fx, /* i/o: State structure */
- const Word16 speech[], /* i : i speech Q_new */
- const Word16 Aw[], /* i : weighted A(z) unquantized for subframes */
- const Word16 Aq[], /* i : 12k8 Lp coefficient */
- const Word16 *res, /* i : residual signal Q_new */
- Word16 *synth, /* i/o: core synthesis Q-1 */
- Word16 *exc, /* i/o: current non-enhanced excitation Q_new */
- Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6 */
- Word16 *voice_factors, /* o : voicing factors Q15 */
- Word16 *bwe_exc, /* o : excitation for SWB TBE Q0 */
- const Word16 attack_flag, /* i : Flag that point to an attack coded with AC mode (GSC)*/
- Word16 *lsf_new, /* i : current frame ISF vector */
- Word16 *tmp_noise, /* o : noise energy */
- const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
- const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */
- Word16 Q_new,
- Word16 shift );
-
-void encod_audio_ivas_fx(
Encoder_State *st_fx, /* i/o: State structure */
const Word16 speech[], /* i : input speech Q_new */
const Word16 Aw[], /* i : weighted A(z) unquantized for subframes */
@@ -2128,14 +1927,15 @@ void encod_audio_ivas_fx(
Word16 *exc, /* i/o: current non-enhanced excitation Q_new */
Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6 */
Word16 *voice_factors, /* o : voicing factors Q15 */
- Word16 *bwe_exc, /* o : excitation for SWB TBE Q0 */
+ Word16 *bwe_exc, /* o : excitation for SWB TBE Q0 */
const Word16 attack_flag, /* i : Flag that point to an attack coded with AC mode (GSC)*/
Word16 *lsf_new, /* i : current frame ISF vector */
Word16 *tmp_noise, /* o : noise energy */
const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */
const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */
- Word16 Q_new,
- Word16 shift );
+ const Word16 Q_new, /* i : Scaling factor */
+ const Word16 shift /* i : Shift needed to obtain 12 bits vectors */
+);
void stat_noise_uv_enc_fx(
Encoder_State *st_fx, /* i/o: state structure */
@@ -2548,8 +2348,8 @@ void coder_tcx_post_fx(
const Word16 *A,
const Word16 *Ai,
Word16 *wsig,
- Word16 Q_new,
- Word16 shift );
+ const Word16 Q_new,
+ const Word16 shift );
void coder_tcx_post_ivas_fx(
Encoder_State *st,
@@ -2562,14 +2362,14 @@ void coder_tcx_post_ivas_fx(
Word16 Q_new );
void enc_prm_fx(
- const Word16 coder_type, /* i : coding type */
- Word16 param[], /* i : parameters */
- Word16 param_lpc[], /* i : LPC parameters */
- Encoder_State *st, /* i/o: quantization Analysis values */
- Word16 L_Frame,
+ const Word16 coder_type, /* i : coding type */
+ Word16 param[], /* i : parameters */
+ const Word16 param_lpc[], /* i : LPC parameters */
+ Encoder_State *st, /* i/o: quantization Analysis values */
+ const Word16 L_Frame,
CONTEXT_HM_CONFIG hm_cfg[],
Word16 *bits_param_lpc,
- Word16 no_param_lpc );
+ const Word16 no_param_lpc );
void IGFEncSetMode_fx(
const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */
@@ -2755,11 +2555,6 @@ void enc_prm_rf_fx(
const Word16 rf_frame_type,
const Word16 fec_offset );
-void enc_prm_rf_ivas_fx(
- Encoder_State *st,
- const Word16 rf_frame_type,
- const Word16 fec_offset );
-
void E_ACELP_pulsesign(
const Word16 cn[] /*Q_xn*/,
Word16 dn[] /*Qdn*/,
@@ -2866,14 +2661,8 @@ void enc_prm_side_Info_fx(
/* Returns: number of bits written */
Word16 enc_lsf_tcxlpc_fx(
- Word16 **indices, /* i : Ptr to VQ indices */
- BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */
-);
-
-/* Returns: number of bits written */
-Word16 enc_lsf_tcxlpc_ivas_fx(
- const Word16 **indices, /* i : Ptr to VQ indices */
- BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */
+ const Word16 **indices, /* i : Ptr to VQ indices */
+ BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */
);
Word16 encode_lpc_avq_fx(
@@ -2884,36 +2673,13 @@ Word16 encode_lpc_avq_fx(
const Word16 element_mode /* i : element mode - decides between SNS and LPC coding Q0*/
);
-Word16 encode_lpc_avq_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const Word16 numlpc, /* i : Number of sets of lpc Q0*/
- const Word16 *param_lpc, /* i : lpc parameters Q0*/
- const Word16 core, /* i : core Q0*/
- const Word16 element_mode /* i : element mode - decides between SNS and LPC coding Q0*/
-);
-
Word16 lsf_bctcvq_encprm_fx(
- BSTR_ENC_HANDLE hBstr,
- Word16 *param_lpc,
- Word16 *bits_param_lpc,
- Word16 no_indices );
-
-Word16 lsf_bctcvq_encprm_ivas_fx(
BSTR_ENC_HANDLE hBstr,
const Word16 *param_lpc,
const Word16 *bits_param_lpc,
const Word16 no_indices );
Word16 lsf_msvq_ma_encprm_fx(
- BSTR_ENC_HANDLE hBstr,
- Word16 *param_lpc,
- Word16 core,
- Word16 acelp_mode,
- Word16 acelp_midLpc,
- Word16 *bits_param_lpc,
- Word16 no_indices );
-
-Word16 lsf_msvq_ma_encprm_ivas_fx(
BSTR_ENC_HANDLE hBstr,
const Word16 *param_lpc,
const Word16 core,
@@ -2956,10 +2722,6 @@ void signaling_enc_rf_fx(
Encoder_State *st /* i : encoder state structure */
);
-void signalling_enc_rf_fx(
- Encoder_State *st /* i : encoder state structure */
-);
-
void IGFEncResetTCX10BitCounter_fx(
const IGF_ENC_INSTANCE_HANDLE hInstance /**< in: | instance handle of IGF Encoder */
);
@@ -3503,31 +3265,6 @@ Word16 lp_filt_exc_enc_fx(
);
Word16 inov_encode_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word32 core_brate, /* i : core bitrate */
- const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
- const Word16 L_frame, /* i : length of the frame */
- const Word16 last_L_frame, /* i : length of the last frame */
- const Word16 coder_type, /* i : coding type */
- const Word16 bwidth, /* i : i signal bandwidth */
- const Word16 sharpFlag, /* i : formant sharpening flag */
- const Word16 i_subfr, /* i : subframe index */
- const Word16 tc_subfr, /* i : TC subframe index */
- const Word16 *p_Aq, /* i : LP filter coefficients Q12*/
- const Word16 gain_pit, /* i : adaptive excitation gain Q14*/
- Word16 *cn, /* i/o: target vector in residual domain Q_new*/
- const Word16 *exc, /* i : pointer to excitation signal frame Q_new*/
- Word16 *h2, /* i/o: weighted filter i response Q12*/
- const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15*/
- const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/
- const Word16 *xn2, /* i : target vector for innovation search Q_new-1+shift*/
- Word16 *code, /* o : algebraic excitation Q9*/
- Word16 *y2, /* o : zero-memory filtered algebraic excitation Q9*/
- Word16 *unbits, /* o : number of unused bits for PI */
- const Word16 L_subfr, /* i : subframe length */
- Word16 shift );
-
-Word16 inov_encode_ivas_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
const Word32 core_brate, /* i : core bitrate */
const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
@@ -3550,7 +3287,7 @@ Word16 inov_encode_ivas_fx(
Word16 *y2, /* o : zero-memory filtered algebraic excitation Q9*/
Word16 *unbits, /* o : number of unused bits for PI */
const Word16 L_subfr, /* i : subframe length */
- Word16 shift,
+ const Word16 shift,
Word16 Q_new );
void gain_enc_mless_fx(
@@ -3598,7 +3335,7 @@ void analy_lp_AMR_WB_fx(
Word16 isf_new[], /* o : current frame ISPs Q15*/
Word16 Top, /* i : open loop pitch lag Q0*/
Word16 Tnc, /* i : open loop pitch gain Qx*/
- Word16 Q_new,
+ const Word16 Q_new,
Word16 *Q_r );
void encod_amr_wb_fx(
@@ -3613,8 +3350,8 @@ void encod_amr_wb_fx(
Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6*/
Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain Q0*/
const Word16 *speech16k_fx, /* i : i speech @16kHz Qx*/
- Word16 shift,
- Word16 Q_new );
+ const Word16 shift,
+ const Word16 Q_new );
void re8_cod_fx(
Word16 x[], /* i : point in RE8 (8-dimensional integer vector) Q0*/
@@ -3634,16 +3371,8 @@ void acelp_core_switch_enc_fx(
const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */
const Word16 inp16k[], /* i : i signal @16 kHz Q0 */
const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */
- Word16 shift,
- Word16 Q_new );
-
-void acelp_core_switch_enc_ivas_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */
- const Word16 inp16k[], /* i : i signal @16 kHz Q0 */
- const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */
- Word16 shift,
- Word16 Q_new );
+ const Word16 shift,
+ const Word16 Q_new );
void gain_enc_amr_wb_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
@@ -3704,31 +3433,6 @@ void transf_cdbk_enc_fx(
const Word16 shift /* i : shifting applied to y1, xn,... */
);
-void transf_cdbk_enc_ivas_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/
- const Word16 i_subfr, /* i : subframe index Q0*/
- Word16 cn[], /* i/o: target vector in residual domain Q_new*/
- Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/
- const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/
- const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/
- const Word16 h1[], /* i : weighted filter input response Q15*/
- Word16 xn[], /* i/o: target vector Q_new + shift -1*/
- Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/
- Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/
- const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/
- const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/
- Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/
- const Word32 gain_code, /* i : innovative excitation gain Q16*/
- Word16 g_corr[], /* o : ACELP correlation values Q15*/
- const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/
- Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/
- Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/
- Word16 *unbits, /* o : number of AVQ unused bits Q0*/
- const Word16 Q_new, /* i : Current frame scaling */
- const Word16 shift /* i : shifting applied to y1, xn,... */
-);
-
void gain_enc_lbr_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
const Word16 gains_mode[], /* i : gain bits Q0*/
@@ -3838,32 +3542,6 @@ void transition_enc_fx(
Word16 shift /* i : downscaling needs for 12 bits convolutions */
);
-void transition_enc_ivas_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 i_subfr, /* i : subframe index */
- Word16 *tc_subfr, /* i/o: TC subframe index */
- Word16 *Jopt_flag, /* i : joint optimization flag */
- Word16 *position, /* i/o: maximum of residual signal index */
- Word16 *T0, /* i/o: close loop integer pitch Q0*/
- Word16 *T0_frac, /* i/o: close loop fractional part of the pitch Q0*/
- Word16 *T0_min, /* i/o: lower limit for close-loop search Q0*/
- Word16 *T0_max, /* i/o: higher limit for close-loop search Q0*/
- Word16 *exc_fx, /* i/o: pointer to excitation signal frame Q_new*/
- Word16 *y1_fx, /* o : zero-memory filtered adaptive excitation Q_new-1+shift*/
- const Word16 *h1_fx, /* i : weighted filter input response Q(14+shift)*/
- const Word16 *xn_fx, /* i : target vector Q_new-1+shift*/
- Word16 *xn2_fx, /* o : target vector for innovation search Q_new-1+shift*/
- Word16 *gp_cl_fx, /* i/o: memory of gain of pitch clipping algorithm */
- Word16 *gain_pit_fx, /* o : adaptive excitation gain Q14*/
- Word16 *g_corr_fx, /* o : ACELP correlation values */
- Word16 *clip_gain, /* i/o: adaptive gain clipping flag */
- Word16 **pt_pitch_fx, /* o : floating pitch values */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/
- Word16 *unbits_ACELP, /* i/o: unused bits */
- Word16 Q_new, /* i : Current scaling */
- Word16 shift /* i : downscaling needs for 12 bits convolutions */
-);
-
void gain_enc_tc_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
const Word16 gains_mode[], /* i : gain bits Q0*/
@@ -3879,21 +3557,6 @@ void gain_enc_tc_fx(
const Word16 Q_xn /* i : xn and y1 scaling */
);
-void gain_enc_tc_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- const Word16 gains_mode[], /* i : gain bits Q0*/
- const Word16 i_subfr, /* i : subframe index Q0*/
- const Word16 xn_fx[], /* i : target vector Q_xn*/
- const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation Q_xn*/
- const Word16 code_fx[], /* i : algebraic excitation Q9*/
- const Word16 Es_pred_fx, /* i : predicted scaled innovation energy Q8*/
- Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain Q14*/
- Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/
- Word16 *gain_inov_fx, /* o : innovation gain Q12*/
- Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q6*/
- const Word16 Q_xn /* i : xn and y1 scaling */
-);
-
Word16 gaus_encode_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
const Word16 i_subfr, /* i : subframe index Q0*/
@@ -3914,26 +3577,6 @@ Word16 gaus_encode_fx(
Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/
);
-Word16 gaus_encode_ivas_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 i_subfr, /* i : subframe index Q0*/
- const Word16 *h1, /* i : weighted filter input response Q14*/
- const Word16 *xn, /* i : target vector Q12*/
- Word16 *exc, /* o : pointer to excitation signal frame Q_new*/
- Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/
- Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/
- Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/
- Word16 *code, /* o : algebraic excitation Q9*/
- Word32 *gain_code, /* o : Code gain. Q16*/
- Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/
- Word16 *gain_inov, /* o : innovation gain Q12*/
- Word16 *voice_fac, /* o : voicing factor Q15*/
- Word16 *gain_pit, /* o : adaptive excitation gain Q14*/
- const Word16 Q_new, /* i : scaling factor */
- const Word16 shift, /* i : scaling factor */
- Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/
-);
-
void pre_proc_fx(
Encoder_State *st, /* i/o: encoder state structure */
const Word16 input_frame, /* i : frame length */
@@ -4000,9 +3643,9 @@ void enc_pit_exc_fx(
Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/
const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
- Word16 Q_new,
- Word16 shift );
-
+ const Word16 Q_new,
+ const Word16 shift );
+#ifndef FIX_1904_HARM_GSC_ENC
void enc_pit_exc_ivas_fx(
Encoder_State *st_fx, /* i/o: State structure */
const Word16 *speech, /* i : Input speech Q_new-1*/
@@ -4022,6 +3665,7 @@ void enc_pit_exc_ivas_fx(
const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/
Word16 Q_new,
Word16 shift );
+#endif
/* o : bin where pitch contribution is significant */
Word16 Pit_exc_contribution_len_fx(
@@ -4032,7 +3676,7 @@ Word16 Pit_exc_contribution_len_fx(
const Word16 nb_subfr, /* i : Number of subframe considered Q0*/
Word16 *hangover, /* i : hangover for the time contribution switching Q0*/
Word16 Qnew );
-
+#ifndef FIX_1904_HARM_GSC_ENC
/* o : bin where pitch contribution is significant */
Word16 Pit_exc_contribution_len_ivas_fx(
Encoder_State *st_fx, /* i/o: state structure */
@@ -4041,6 +3685,7 @@ Word16 Pit_exc_contribution_len_ivas_fx(
Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/
Word16 *hangover, /* i : hangover for the time contribution switching Q0*/
Word16 Qnew );
+#endif
Word16 pvq_core_enc_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
@@ -4090,14 +3735,6 @@ void hq_lr_enc_fx(
const Word16 is_transient_fx /* i : Q0 : transient flag */
);
-void hq_lr_enc_ivas_fx(
- Encoder_State *st_fx, /* i/o: : encoder state structure */
- Word32 L_t_audio[], /* i/o: Q12 : transform-domain coefs. */
- const Word16 inner_frame_fx, /* i : Q0 : inner frame length */
- Word16 *num_bits_fx, /* i/o: Q0 : number of available bits */
- const Word16 is_transient_fx /* i : Q0 : transient flag */
-);
-
void hq_hr_enc_fx(
Encoder_State *st_fx, /* i/o: encoder state structure fx */
Word32 *t_audio, /* i/o: transform-domain coefficients Q12 */
@@ -4273,26 +3910,6 @@ ivas_error tcq_core_LR_enc_fx(
const Word16 adjustFlag,
const Word16 is_transient );
-ivas_error tcq_core_LR_enc_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- Word32 inp_vector[],
- const Word32 coefs_norm_fx[],
- Word32 coefs_quant_fx[],
- const Word16 bit_budget, /* number of bits */
- const Word16 BANDS,
- const Word16 *sfm_start,
- const Word16 *sfm_end,
- const Word16 *sfmsize,
- Word32 *Rk_fx,
- Word16 *npulses,
- Word16 *k_sort,
- const Word16 *p2a_flags,
- const Word16 p2a_bands,
- const Word16 *last_bitalloc,
- const Word16 input_frame,
- const Word16 adjustFlag,
- const Word16 is_transient );
-
/* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */
Word16 encode_envelope_indices_fx(
BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */
@@ -4354,13 +3971,17 @@ void noise_est_init_ivas_fx(
);
void InitSWBencBuffer_fx(
+#ifdef HARMONIZE_TBE
+ const Word16 element_mode, /* i : element mode */
+#endif
TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */
);
+#ifndef HARMONIZE_TBE
void InitSWBencBuffer_ivas_fx(
TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */
);
-
+#endif
void ResetSHBbuffer_Enc_fx(
TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */
);
@@ -4486,6 +4107,9 @@ Word32 mslvq_fx(
/* o : frame multi-harmonicity (1-harmonic, 0-not) */
Word16 multi_harm_fx(
+#ifdef FIX_2364_HARM_MULT_HARM
+ const Word16 element_mode, /* i : IVAS element_mode Q0 */
+#endif
const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */
Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */
Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */
@@ -4500,6 +4124,7 @@ Word16 multi_harm_fx(
Word16 S_map[] /* o : short-term correlation map Q7 */
);
+#ifndef FIX_2364_HARM_MULT_HARM
/* o : frame multi-harmonicity (1-harmonic, 0-not) */
Word16 multi_harm_ivas_fx(
const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */
@@ -4515,6 +4140,7 @@ Word16 multi_harm_ivas_fx(
Word16 *sp_floor, /* o: noise floor estimate Q7 */
Word16 S_map[] /* o : short-term correlation map Q7 */
);
+#endif
void pvq_encode_frame_fx(
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
diff --git a/lib_enc/qlpc_avq_fx.c b/lib_enc/qlpc_avq_fx.c
index 67b481ea03c203f6a55ab87978a5ed64efc7ae08..5d4d93fdfaf6d1aa6859cb40eb5f9a3835058d7c 100644
--- a/lib_enc/qlpc_avq_fx.c
+++ b/lib_enc/qlpc_avq_fx.c
@@ -123,36 +123,14 @@ void qlpc_avq_fx(
return;
}
+
/*-------------------------------------------------------------------*
* unary_code()
*
*
*--------------------------------------------------------------------*/
-static Word16 unary_code(
- Word16 ind, /* Q0 */
- BSTR_ENC_HANDLE hBstr )
-{
- Word16 nb_bits;
-
- move16();
- nb_bits = 1;
-
- /* Index bits */
- ind = sub( ind, 1 );
-
- FOR( ; ind > 0; ind-- )
- {
- push_next_indice( hBstr, 1, 1 );
- nb_bits = add( nb_bits, 1 ); // Q0
- }
-
- /* Stop bit */
- push_next_indice( hBstr, 0, 1 );
-
- return ( nb_bits );
-}
-static Word16 unary_code_ivas_fx(
+static Word16 unary_code_fx(
Word16 ind, /* Q0 */
BSTR_ENC_HANDLE hBstr )
{
@@ -181,41 +159,14 @@ static Word16 unary_code_ivas_fx(
return ( nb_bits );
}
+
/*-------------------------------------------------------------------*
* unpack4bits()
*
*
*--------------------------------------------------------------------*/
-static Word16 unpack4bits(
- Word16 nbits, /* Q0 */
- const Word16 *prm, /* Q0 */
- BSTR_ENC_HANDLE hBstr )
-{
- Word16 i;
-
- IF( nbits == 0 )
- {
- push_next_indice( hBstr, 0, 0 );
- i = 1;
- move16();
- }
- ELSE
- {
- move16();
- i = 0;
-
- FOR( ; nbits > 4; nbits -= 4 )
- {
- push_next_indice( hBstr, prm[i], 4 );
- i = add( i, 1 );
- }
- push_next_indice( hBstr, prm[i], nbits );
- i = add( i, 1 );
- }
- return ( i );
-}
-static Word16 unpack4bits_ivas_fx(
+static Word16 unpack4bits_fx(
Word16 nbits, /* Q0 */
const Word16 *prm, /* Q0 */
BSTR_ENC_HANDLE hBstr )
@@ -251,7 +202,7 @@ static Word16 unpack4bits_ivas_fx(
*--------------------------------------------------------------------*/
Word16 encode_lpc_avq_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
+ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
const Word16 numlpc, /* i : Number of sets of lpc Q0*/
const Word16 *param_lpc, /* i : lpc parameters Q0*/
const Word16 core, /* i : core Q0*/
@@ -284,215 +235,6 @@ Word16 encode_lpc_avq_fx(
FOR( k = 0; k < numlpc; k++ )
{
/* Retrieve quantizer type */
-
-
- move16();
- q_type = 0;
- if ( k != 0 )
- {
- move16();
- q_type = param_lpc[j]; // Q0
- j = add( j, 1 );
- }
- test();
- if ( EQ_16( element_mode, IVAS_CPE_MDCT ) && k == 0 )
- {
- stereo_mode = param_lpc[j]; // Q0
- move16();
- j = add( j, 1 );
- }
- /* Determine number of AVQ indices */
- move16();
- nb_ind = 0;
-
- if ( q_type == 0 )
- {
- move16();
- st1 = param_lpc[j++]; // Q0
- }
- move16();
- move16();
- qn1 = param_lpc[j++]; // Q0
- qn2 = param_lpc[j++]; // Q0
- IF( EQ_16( qn1, SNS_LOW_BR_MODE ) )
- {
- nb_ind = add( qn1, qn2 );
- }
-
- test();
- test();
- IF( k == 0 || ( EQ_16( k, 1 ) && NE_16( core, TCX_20_CORE ) ) )
- {
- /* Encode quantizer type */
- move16();
- nb = 0;
- IF( k != 0 )
- {
- nb = 1;
- move16();
- push_next_indice( hBstr, q_type, nb );
- }
- nb_bits = add( nb_bits, nb ); // Q0
-
- /* Encode quantizer data */
- test();
- test();
- test();
- test();
- IF( ( ( q_type == 0 ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) || ( ( q_type == 0 ) && ( GE_16( st1, 0 ) ) && EQ_16( element_mode, IVAS_CPE_MDCT ) ) )
- {
- /* Absolute quantizer with 1st stage stochastic codebook */
- push_next_indice( hBstr, st1, bits_for_abs_quant );
- nb_bits = add( nb_bits, bits_for_abs_quant ); // Q0
- }
-
- test();
- test();
- IF( EQ_16( element_mode, IVAS_CPE_MDCT ) && EQ_16( stereo_mode, 3 ) && st1 < 0 )
- {
- push_next_indice( hBstr, add( st1, 2 ), 1 );
- nb_bits = add( nb_bits, 1 ); // Q0
- }
-
- test();
- test();
- IF( NE_16( element_mode, IVAS_CPE_MDCT ) || ( NE_16( st1, -2 ) && NE_16( qn1, SNS_LOW_BR_MODE ) ) )
- {
-
- /* 2 bits to specify Q2,Q3,Q4,ext */
- nb_bits = add( nb_bits, 4 ); // Q0
- i = sub( qn1, 2 );
-
- if ( s_or( i < 0, (Word16) GT_16( i, 3 ) ) )
- {
- move16();
- i = 3;
- }
- push_next_indice( hBstr, i, 2 );
-
- i = sub( qn2, 2 );
-
- if ( s_or( i < 0, (Word16) GT_16( i, 3 ) ) )
- {
- move16();
- i = 3;
- }
- push_next_indice( hBstr, i, 2 );
-
- /* Unary code for abs and rel LPC0/LPC2 */
- /* Q5 = 0, Q6=10, Q0=110, Q7=1110, ... */
- move16();
- nb = qn1;
-
- IF( GT_16( nb, 6 ) )
- {
- nb = sub( nb, 3 );
- }
- ELSE IF( GT_16( nb, 4 ) )
- {
- nb = sub( nb, 4 );
- }
- ELSE IF( nb == 0 )
- {
- move16();
- nb = 3;
- }
- ELSE
- {
- move16();
- nb = 0;
- }
-
- IF( nb > 0 )
- {
- unary_code( nb, hBstr );
- }
- nb_bits = add( nb_bits, nb ); // Q0
-
- move16();
- nb = qn2;
-
- IF( GT_16( nb, 6 ) )
- {
- nb = sub( nb, 3 ); // Q0
- }
- ELSE IF( GT_16( nb, 4 ) )
- {
- nb = sub( nb, 4 ); // Q0
- }
- ELSE IF( nb == 0 )
- {
- move16();
- nb = 3;
- }
- ELSE
- {
- move16();
- nb = 0;
- }
-
- IF( nb > 0 )
- {
- unary_code( nb, hBstr );
- }
- nb_bits = add( nb_bits, nb ); // Q0
-
- avqBits = shl( qn1, 2 );
- unpack4bits( avqBits, ¶m_lpc[j], hBstr );
- j = add( j, qn1 );
- nb_bits = add( nb_bits, avqBits ); // Q0
-
- avqBits = shl( qn2, 2 );
- unpack4bits( avqBits, ¶m_lpc[j], hBstr );
- j = add( j, qn2 );
- nb_bits = add( nb_bits, avqBits ); // Q0
- }
- }
- ELSE
- {
- j = add( j, nb_ind );
- }
- }
-
- return ( nb_bits );
-}
-
-Word16 encode_lpc_avq_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
- const Word16 numlpc, /* i : Number of sets of lpc Q0*/
- const Word16 *param_lpc, /* i : lpc parameters Q0*/
- const Word16 core, /* i : core Q0*/
- const Word16 element_mode /* i : element mode - decides between SNS and LPC coding Q0*/
-)
-{
- Word16 k, j;
- Word16 q_type, nb_ind;
- Word16 i, qn1, qn2, nb, avqBits, st1;
- Word16 nb_bits;
- Word16 stereo_mode, bits_for_abs_quant;
-
- stereo_mode = 0;
- move16();
- bits_for_abs_quant = LPC_ABS_QUANT_BITS;
- move16();
- if ( EQ_16( element_mode, IVAS_CPE_MDCT ) )
- {
- bits_for_abs_quant = SNS_ABS_QUANT_BITS;
- move16();
- }
-
- move16();
- move16();
- move16();
- st1 = 0;
- j = 0;
- nb_bits = 0;
-
- FOR( k = 0; k < numlpc; k++ )
- {
- /* Retrieve quantizer type */
-
-
move16();
q_type = 0;
IF( k != 0 )
@@ -508,6 +250,7 @@ Word16 encode_lpc_avq_ivas_fx(
move16();
j = add( j, 1 );
}
+
/* Determine number of AVQ indices */
move16();
nb_ind = 0;
@@ -615,7 +358,7 @@ Word16 encode_lpc_avq_ivas_fx(
IF( nb > 0 )
{
- unary_code_ivas_fx( nb, hBstr );
+ unary_code_fx( nb, hBstr );
}
nb_bits = add( nb_bits, nb );
@@ -643,17 +386,17 @@ Word16 encode_lpc_avq_ivas_fx(
IF( nb > 0 )
{
- unary_code_ivas_fx( nb, hBstr );
+ unary_code_fx( nb, hBstr );
}
nb_bits = add( nb_bits, nb );
avqBits = shl( qn1, 2 );
- unpack4bits_ivas_fx( avqBits, ¶m_lpc[j], hBstr );
+ unpack4bits_fx( avqBits, ¶m_lpc[j], hBstr );
j = add( j, qn1 );
nb_bits = add( nb_bits, avqBits ); // Q0
avqBits = shl( qn2, 2 );
- unpack4bits_ivas_fx( avqBits, ¶m_lpc[j], hBstr );
+ unpack4bits_fx( avqBits, ¶m_lpc[j], hBstr );
j = add( j, qn2 );
nb_bits = add( nb_bits, avqBits ); // Q0
}
diff --git a/lib_enc/qlpc_stoch_fx.c b/lib_enc/qlpc_stoch_fx.c
index 0964d7421b26fa9036127c67b2dc4e23b6cf6094..0d02d4742be1a1f2e475fe14e829aec7fb01ae32 100644
--- a/lib_enc/qlpc_stoch_fx.c
+++ b/lib_enc/qlpc_stoch_fx.c
@@ -25,6 +25,7 @@
*
*
*--------------------------------------------------------------------*/
+
void lpc_quantization_fx(
Encoder_State *st,
const Word16 lsp[], /* Q15 */
@@ -117,7 +118,7 @@ void lpc_quantization_fx(
IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( coder_type, UNVOICED ) )
{
lsf_end_enc_fx( st, lsf, lsf_q, ENDLSF_NBITS, GENERIC, Q_ener,
- force_sf, param_lpc, no_param_lpc, bits_param_lpc, GENERIC );
+ force_sf, param_lpc, no_param_lpc, bits_param_lpc, GENERIC, NULL );
nb_indices = *no_param_lpc; // Q0
move16();
@@ -125,19 +126,17 @@ void lpc_quantization_fx(
ELSE
{
lsf_end_enc_fx( st, lsf, lsf_q, ENDLSF_NBITS, coder_type, Q_ener,
- force_sf, param_lpc, no_param_lpc, bits_param_lpc, coder_type );
+ force_sf, param_lpc, no_param_lpc, bits_param_lpc, coder_type, NULL );
nb_indices = *no_param_lpc; // Q0
move16();
}
-
FEC_lsf_estim_enc_fx( st, fec_lsf );
/* FEC - calculate LSF stability */
stab = lsf_stab_fx( lsf_q, fec_lsf, 0, st->L_frame ); /*Q15*/
-
test();
test();
test();
@@ -172,11 +171,9 @@ void lpc_quantization_fx(
}
/* Mid-frame LPC quantization */
-
test();
IF( st->lpcQuantization && acelp_midLpc )
{
-
IF( st->rate_switching_reset == 0 )
{
lsp2lsf_fx( lspmid, lsfmid, M, extract_l( st->sr_core ) );
@@ -196,169 +193,6 @@ void lpc_quantization_fx(
}
}
-
- return;
-}
-
-void lpc_quantization_ivas_fx(
- Encoder_State *st,
- const Word16 lsp[], /* Q15 */
- const Word16 lspmid[], /* Q15 */
- Word16 lsp_q[], /* Q15 */
- Word16 lsf_q[], /* 14Q1*1.28 */
- Word16 lspmid_q[], /* Q15 */
- const Word16 coder_type, /* Q0 */
- const Word16 acelp_midLpc, /* Q0 */
- Word16 param_lpc[], /* Q0 */
- Word16 nbits_lpc[], /* Q0 */
- Word16 *bits_param_lpc, /* Q0 */
- Word16 *no_param_lpc, /* Q0 */
- const Word16 Q_ener )
-{
- Word16 nb_indices;
- Word16 lsfmid_q[M]; /* 14Q1*1.28 */
- Word16 lsfmid_idx;
- Word16 i, force_sf;
- Word16 lsf[M], lsfmid[M];
- Word16 fec_lsf[M], stab;
-
- nb_indices = 0;
- move16();
-
- /****** High-rate LPC quantizer *******/
-
- IF( st->lpcQuantization == 0 )
- {
- E_LPC_lsp_lsf_conversion( lsp, lsf, M );
-
- IF( ( EQ_16( st->core, TCX_10_CORE ) ) )
- {
- E_LPC_lsp_lsf_conversion( lspmid, lsfmid, M );
- }
-
- /* LPC quantizer */
- qlpc_avq_fx( lsf, lsfmid, lsf_q, lsfmid_q, param_lpc, &nb_indices, nbits_lpc, st->core, st->sr_core );
-
- E_LPC_lsf_lsp_conversion( lsf_q, lsp_q, M );
-
- IF( EQ_16( st->core, TCX_10_CORE ) )
- {
- E_LPC_lsf_lsp_conversion( lsfmid_q, lspmid_q, M );
- }
-
- assert( nb_indices <= NPRM_LPC_NEW );
- }
-
- /****** Low-rate LPC quantizer *******/
-
- ELSE IF( EQ_16( st->lpcQuantization, 1 ) )
- {
-
- lsp2lsf_fx( lsp, lsf, M, extract_l( st->sr_core ) );
-
- force_sf = 0;
- move16();
- /*Force safety net when possible in case of transitions*/
- test();
- test();
- IF( GE_32( st->tc_cnt, 1 ) || LE_32( st->last_core_brate, SID_2k40 ) || ( EQ_16( st->next_force_safety_net, 1 ) ) )
- {
- force_sf = 1;
- move16();
- st->next_force_safety_net = 0;
- move16();
- }
-
- test();
- IF( EQ_16( st->next_force_safety_net, 1 ) && EQ_16( st->Opt_RF_ON, 1 ) )
- {
- force_sf = 1;
- st->next_force_safety_net = 0;
- move16();
- move16();
- }
-
- test();
- IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( coder_type, UNVOICED ) )
- {
- lsf_end_enc_ivas_fx( st, lsf, lsf_q, ENDLSF_NBITS, GENERIC, Q_ener,
- force_sf, param_lpc, no_param_lpc, bits_param_lpc, GENERIC, NULL );
-
- nb_indices = *no_param_lpc; // Q0
- move16();
- }
- ELSE
- {
- lsf_end_enc_ivas_fx( st, lsf, lsf_q, ENDLSF_NBITS, coder_type, Q_ener,
- force_sf, param_lpc, no_param_lpc, bits_param_lpc, coder_type, NULL );
-
- nb_indices = *no_param_lpc; // Q0
- move16();
- }
-
-
- FEC_lsf_estim_enc_fx( st, fec_lsf );
-
- /* FEC - calculate LSF stability */
- stab = lsf_stab_fx( lsf_q, fec_lsf, 0, st->L_frame ); /*Q15*/
-
-
- test();
- test();
- test();
- IF( LT_16( stab, add( STAB_FAC_LIMIT_FX, 6553 /* =0.2 in Q15*/ ) ) &&
- ( EQ_16( coder_type, VOICED ) || EQ_16( coder_type, GENERIC ) ) && EQ_16( st->Opt_RF_ON, 1 ) )
- {
- st->next_force_safety_net = 1;
- move16();
- }
-
- lsf2lsp_fx( lsf_q, lsp_q, M, st->sr_core );
-
- *nbits_lpc = ENDLSF_NBITS;
- move16();
- }
- ELSE
- {
- assert( 0 );
- }
-
- st->seed_acelp = 0;
- move16();
- FOR( i = nb_indices - 1; i >= 0; i-- )
- {
- st->seed_acelp = extract_l( L_mac0( L_mac0( 13849, shr( st->seed_acelp, 1 ), 31821 ), param_lpc[i], 31821 ) ); // Q0
- move16();
- }
-
- /* Mid-frame LPC quantization */
-
- test();
- IF( st->lpcQuantization && acelp_midLpc )
- {
-
- IF( st->rate_switching_reset == 0 )
- {
- lsp2lsf_fx( lspmid, lsfmid, M, extract_l( st->sr_core ) );
-
- midlsf_enc_fx( st->lsf_old_fx, lsf_q, lsfmid, &lsfmid_idx, M, st->Bin_E_old_fx, Q_ener, (Word8) st->narrowBand, st->sr_core, coder_type );
- param_lpc[nb_indices] = lsfmid_idx; // Q0
- move16();
- nb_indices = add( nb_indices, 1 );
- midlsf_dec( st->lsf_old_fx, lsf_q, lsfmid_idx, lsfmid_q, coder_type, NULL, 0, 1 );
-
- reorder_lsf_fx( lsfmid_q, LSF_GAP_MID_FX, M, st->sr_core );
- lsf2lsp_fx( lsfmid_q, lspmid_q, M, st->sr_core );
- }
- ELSE
- {
- param_lpc[nb_indices] = 0;
- move16();
- nb_indices = add( nb_indices, 1 ); // Q0
- }
- }
-
-
return;
}
diff --git a/lib_enc/rom_enc.h b/lib_enc/rom_enc.h
index f92243a5ab15987662be04399979d1d03fb820c9..526136e698c0d952e185dbb9bee1d919ac0adff6 100644
--- a/lib_enc/rom_enc.h
+++ b/lib_enc/rom_enc.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/rom_enc_fx.c b/lib_enc/rom_enc_fx.c
index 4af957800648f7314f145808d5cb17dd1c888e60..9c7f3f53e02b6a5358e89469fcc57a30f494fef0 100644
--- a/lib_enc/rom_enc_fx.c
+++ b/lib_enc/rom_enc_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/sig_clas_fx.c b/lib_enc/sig_clas_fx.c
index 990fad0db6851a9f6e6b3358c594b1c1058ffcd9..ccc1e38e918d12836208aaf80b8bed6869d526cc 100644
--- a/lib_enc/sig_clas_fx.c
+++ b/lib_enc/sig_clas_fx.c
@@ -545,10 +545,9 @@ void select_TC_fx(
*
* Coder type modification
*-------------------------------------------------------------------*/
-
void coder_type_modif_fx(
Encoder_State *st, /* i/o: encoder state structure */
- const Word16 relE /* i : frame relative E to the long term average Q8*/
+ const Word16 relE /* i : frame relative E to the long term average */
)
{
Word16 unmod_coder_type, vbr_generic_ho;
@@ -620,9 +619,7 @@ void coder_type_modif_fx(
move16();
}
- test();
- test();
- IF( EQ_16( st->Opt_SC_VBR, 1 ) )
+ if ( EQ_16( st->Opt_SC_VBR, 1 ) )
{
test();
if ( EQ_16( st->coder_type, GENERIC ) && EQ_16( unmod_coder_type, UNVOICED ) )
@@ -636,145 +633,20 @@ void coder_type_modif_fx(
hSC_VBR->vbr_generic_ho = 0;
move16();
}
- }
- hSC_VBR->last_7k2_coder_type = st->coder_type;
- move16();
- test();
- if ( st->localVAD == 0 && EQ_16( st->coder_type, UNVOICED ) )
- {
- hSC_VBR->last_7k2_coder_type = GENERIC;
- move16();
- }
-
- IF( st->element_mode == 0 )
- {
- /* At higher rates and with 16kHz core, allow only GC and TC coder type */
- test();
- test();
- // test();
- if ( GT_32( st->total_brate, ACELP_16k40 ) && NE_16( st->coder_type, GENERIC ) && NE_16( st->coder_type, TRANSITION ) )
- {
- /* onset/transition frame is always coded using GC mode */
- st->coder_type = GENERIC;
- move16();
- }
- }
- ELSE /*IVAS*/
- {
- /* At higher bitrates, disable UC and VC coder type; note that IC coder type is classified later */
- test();
- test();
- test();
- if ( ( GT_32( st->total_brate, MAX_VOICED_BRATE ) && EQ_16( st->coder_type, VOICED ) ) ||
- ( GT_32( st->total_brate, MAX_UNVOICED_BRATE ) && EQ_16( st->coder_type, UNVOICED ) ) )
+ IF( NE_16( st->element_mode, EVS_MONO ) )
{
- st->coder_type = GENERIC;
+ hSC_VBR->last_7k2_coder_type = st->coder_type;
move16();
+ test();
+ if ( st->localVAD == 0 && EQ_16( st->coder_type, UNVOICED ) )
+ {
+ hSC_VBR->last_7k2_coder_type = GENERIC;
+ move16();
+ }
}
}
-
- /* Patch for certain low-level signals for which the gain quantizer sometimes goes out of its dynamic range */
- test();
- test();
- test();
- if ( EQ_16( st->coder_type, VOICED ) && st->input_bwidth == 0 && LT_16( relE, -2560 ) && LE_32( st->total_brate, ACELP_8k00 ) )
- {
- st->coder_type = GENERIC;
- move16();
- }
- }
-
- return;
-}
-void coder_type_modif_ivas_fx(
- Encoder_State *st, /* i/o: encoder state structure */
- const Word16 relE /* i : frame relative E to the long term average */
-)
-{
- Word16 unmod_coder_type, vbr_generic_ho;
-
- SC_VBR_ENC_HANDLE hSC_VBR = st->hSC_VBR;
-
-
- IF( st->Opt_SC_VBR )
- {
- vbr_generic_ho = hSC_VBR->vbr_generic_ho;
- move16();
- }
- ELSE
- {
- vbr_generic_ho = -1;
- move16();
- }
-
- IF( EQ_16( st->codec_mode, MODE1 ) )
- {
- /*---------------------------------------------------------------------*
- * Coder type modification
- *
- * Prevent UC coder type in certain conditions
- * Prevent VC coder type in certain conditions
- * Select TC coder type in appropriate frames
- *---------------------------------------------------------------------*/
-
- /* At higher rates, use GC coding instead of UC coding to improve quality */
- test();
- test();
- test();
- test();
- test();
- if ( ( st->element_mode == 0 && GT_32( st->total_brate, ACELP_9k60 ) && EQ_16( st->coder_type, UNVOICED ) ) ||
- ( st->element_mode > 0 && GT_32( st->total_brate, MAX_UNVOICED_BRATE ) && EQ_16( st->coder_type, UNVOICED ) ) )
- {
- st->coder_type = GENERIC;
- move16();
- }
-
- /* Prevent UC coding on mixed content at 9.6 kb/s */
- test();
- test();
- if ( GE_32( st->total_brate, ACELP_9k60 ) && EQ_16( st->coder_type, UNVOICED ) && st->audio_frame_cnt != 0 )
- {
- st->coder_type = GENERIC;
- move16();
- }
-
- unmod_coder_type = st->coder_type;
- move16();
-
- /* Enforce GC coder type on inactive signal (this can be later overwritten to INACTIVE) */
- test();
- test();
- test();
- test();
- test();
- test();
- test();
- if ( st->localVAD == 0 && ( (
- EQ_16( st->coder_type, UNVOICED ) && ( ( st->Opt_SC_VBR == 0 ) || ( ( EQ_16( st->Opt_SC_VBR, 1 ) ) && vbr_generic_ho == 0 && GT_16( st->last_coder_type, UNVOICED ) ) ) ) ||
- EQ_16( st->coder_type, TRANSITION ) || EQ_16( st->coder_type, VOICED ) )
-
- )
- {
- st->coder_type = GENERIC;
- move16();
- }
-
- if ( EQ_16( st->Opt_SC_VBR, 1 ) )
+ IF( EQ_16( st->element_mode, EVS_MONO ) )
{
- test();
- if ( EQ_16( st->coder_type, GENERIC ) && EQ_16( unmod_coder_type, UNVOICED ) )
- {
- hSC_VBR->vbr_generic_ho = 1;
- move16();
- }
-
- if ( GT_16( st->coder_type, UNVOICED ) )
- {
- hSC_VBR->vbr_generic_ho = 0;
- move16();
- }
-
hSC_VBR->last_7k2_coder_type = st->coder_type;
move16();
test();
diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c
index b1e9751e8f4e60eb63ea92daa0a92cd0dd1a836f..a60539047bfb4baccf1a50c7a65c14c62f64ed44 100644
--- a/lib_enc/speech_music_classif_fx.c
+++ b/lib_enc/speech_music_classif_fx.c
@@ -2003,7 +2003,7 @@ Word16 ivas_smc_gmm_fx(
temp32_log = Mpy_32_32( temp32_log, 1488522239 ); /*logf(x) = log2(x)*logf(2)*/
*pFV_fx++ = L_shr( temp32_log, Q5 ); // logf( ps_sta + 1e-5f );
move32();
- MVR2R_WORD32( &PS_norm_fx[LOWEST_FBIN], hSpMusClas->past_PS_fx, HIGHEST_FBIN - LOWEST_FBIN );
+ Copy32( &PS_norm_fx[LOWEST_FBIN], hSpMusClas->past_PS_fx, HIGHEST_FBIN - LOWEST_FBIN );
/* save ps_diff and ps_sta features for XTALK and UNCLR classifier */
IF( hStereoClassif != NULL )
@@ -2108,7 +2108,8 @@ Word16 ivas_smc_gmm_fx(
}
/* update */
- MVR2R_WORD32( FV_fx, hSpMusClas->prev_FV_fx, N_SMC_FEATURES );
+ Copy32( FV_fx, hSpMusClas->prev_FV_fx, N_SMC_FEATURES );
+
/*------------------------------------------------------------------*
* Non-linear power transformation (boxcox) on certain features
*------------------------------------------------------------------*/
diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h
index bcd7ed72cc1b9ced61ed6a65a5d2497184c9bea9..be38f731c6a0473550fe1f3e774f5b23c7851c85 100644
--- a/lib_enc/stat_enc.h
+++ b/lib_enc/stat_enc.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c
index 6e4e8b391b18c386157accd005f101464f2bfe68..e07f797771aa552fd80693a46c09249649d68479 100644
--- a/lib_enc/swb_bwe_enc_fx.c
+++ b/lib_enc/swb_bwe_enc_fx.c
@@ -262,6 +262,7 @@ void wb_bwe_enc_ivas_fx(
*
* SWB BWE encoder (only for 32kHz signals)
*-------------------------------------------------------------------*/
+
void swb_bwe_enc_ivas_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
const Word16 last_element_mode, /* i : last element mode */
@@ -270,9 +271,15 @@ void swb_bwe_enc_ivas_fx(
const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz */
const Word16 *new_swb_speech_fx, /* i : original input signal at 32kHz */
const Word16 Q_new_swb_speech, /* i : Q for new_swb_speech_fx */
- Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */
+#ifdef REMOVE_SCALING_SHB_SPEECH
+ Word16 *shb_speech_fx_Q0, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */
+ const Word16 Q_slb_speech
+#else
+ Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */
Word16 Q_shb_speech,
- Word16 Q_slb_speech )
+ Word16 Q_slb_speech
+#endif
+)
{
Word16 i;
Word16 *new_input_fx;
@@ -304,14 +311,23 @@ void swb_bwe_enc_ivas_fx(
move16();
Word16 fb_band_begin;
Word16 q_new_input_hp;
+#ifdef REMOVE_SCALING_SHB_SPEECH
+ Word16 shb_speech_fx[L_FRAME16k];
+ Word16 Q_shb_speech;
+#endif
FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD;
TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD;
+#ifdef REMOVE_SCALING_SHB_SPEECH
+ Q_shb_speech = getScaleFactor16( shb_speech_fx_Q0, L_FRAME16k );
+ Copy_Scale_sig( shb_speech_fx_Q0, shb_speech_fx, L_FRAME16k, Q_shb_speech ); // Q0 -> Q_shb_spch
+#endif
/*---------------------------------------------------------------------*
* Delay the original input signal to be synchronized with ACELP core synthesis
*---------------------------------------------------------------------*/
+
IF( EQ_16( st_fx->extl, FB_BWE ) )
{
inner_frame = L_FRAME48k;
diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c
index 7d31b853227d173efe2dc852d87cb0d33b3d8369..843efcf49bbea3b798e082f1cba583ae184e685d 100644
--- a/lib_enc/swb_bwe_enc_lr_fx.c
+++ b/lib_enc/swb_bwe_enc_lr_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -1024,203 +1024,7 @@ static void EncodeSWBSubbands_fx(
return;
}
-static void EncodeSWBSubbands_ivas_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- Word32 *L_spectra, /* i/o: MDCT domain spectrum */
- Word16 QsL, /* i : Q value for L_spectra */
- const Word16 fLenLow_fx, /* i : lowband length */
- const Word16 fLenHigh_fx, /* i : highband length */
- const Word16 nBands_fx, /* i : number of subbands */
- const Word16 nBands_search_fx, /* i : number of subbands to be searched for BWE */
- const Word16 *sbWidth_fx, /* i : subband lengths */
- const Word16 *subband_offsets_fx, /* i : Subband offset for BWE */
- Word16 *lagIndices_fx, /* o : lowband index for each subband */
- const Word16 BANDS_fx, /* i : noise estimate from WB part */
- const Word16 *band_start_fx, /* i : Number subbands/Frame */
- const Word16 *band_end_fx, /* i : Band Start of each SB */
- Word32 *L_band_energy, /* i : Band end of each SB, :Qbe */
- Word16 Qbe, /* i : Q value of band energy */
- const Word16 *p2a_flags_fx, /* i : BAnd energy of each SB */
- const Word16 hqswb_clas_fx, /* i : lowband synthesis */
- Word16 *prev_frm_index_fx, /* i : clas information */
- const Word16 har_bands_fx, /* i/o: Index of the previous Frame */
- const Word16 *subband_search_offset_fx, /* i : Number of harmonic LF bands */
- Word16 *prev_frm_hfe2, /* i/o: */
- Word16 *prev_stab_hfe2, /* i/o: */
- const Word16 band_width_fx[], /* i : band width */
- const Word32 L_spectra_ni[], /* i : Qs noise injected spectra */
- Word16 *ni_seed_fx /* i/o: random seed */
-)
-{
- Word16 i, k;
- Word16 sspectra_fx[L_FRAME32k];
- Word16 sspectra_ni_fx[L_FRAME32k];
- Word16 sspectra_diff_fx[L_FRAME32k];
- Word16 Qss; /* Q value of Smoothed Spectrum low-subband */
- Word32 L_be_tonal[SWB_HAR_RAN1]; /* Q */
- Word16 ss_min_fx; /* Qss */
- Word32 L_th_g[NB_SWB_SUBBANDS];
- Word16 QbeL;
- GainItem_fx pk_sf_fx[(NB_SWB_SUBBANDS) *8];
- Word16 pul_res_fx[NB_SWB_SUBBANDS];
-
- GainItem_fx Nbiggest_fx[NB_SWB_SUBBANDS * N_NBIGGEST_PULSEARCH];
-
- Word32 L_xSynth_har[L_FRAME32k]; /* Qs */
-
- Word16 lagGains_fx[NB_SWB_SUBBANDS];
- Word16 QlagGains[NB_SWB_SUBBANDS];
- Word16 har_freq_est1, har_freq_est2;
- Word16 flag_dis;
- Word16 pos_max_hfe2;
- HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core;
- har_freq_est1 = 0;
- move16();
- har_freq_est2 = 0;
- move16();
- flag_dis = 1;
- move16();
- pos_max_hfe2 = 0;
- move16();
-
- set16_fx( sspectra_fx, 0, fLenLow_fx );
- set16_fx( sspectra_ni_fx, 0, fLenLow_fx );
- set32_fx( L_xSynth_har, 0, L_FRAME32k );
- set16_fx( pul_res_fx, 0, NB_SWB_SUBBANDS );
-
-
- IF( EQ_16( hqswb_clas_fx, HQ_HARMONIC ) )
- {
- pos_max_hfe2 = har_est_fx( L_spectra, fLenLow_fx, &har_freq_est1, &har_freq_est2, &flag_dis, prev_frm_hfe2, subband_search_offset_fx, sbWidth_fx, prev_stab_hfe2 );
- noise_extr_corcod_fx( L_spectra, L_spectra_ni, sspectra_fx, sspectra_diff_fx, sspectra_ni_fx, fLenLow_fx, hHQ_core->prev_hqswb_clas, &hHQ_core->prev_ni_ratio_fx, &Qss );
- /* Find best indices for each group */
- getswbindices_har_fx(
- L_spectra,
- QsL, sspectra_ni_fx,
- nBands_search_fx, lagIndices_fx, prev_frm_index_fx, fLenLow_fx, subband_offsets_fx, sbWidth_fx, subband_search_offset_fx );
-
- /* Write the indices into the bitstream */
- FOR( k = 0; k < nBands_search_fx; k++ )
- {
- push_indice( st_fx->hBstr, IND_LAGINDICES, lagIndices_fx[k], bits_lagIndices_mode0_Har[k] );
- }
-
- IF( flag_dis == 0 )
- {
- test();
- IF( NE_16( har_freq_est2, SWB_HAR_RAN1 ) || NE_16( har_freq_est2, *prev_frm_hfe2 ) )
- {
- har_freq_est2 = add( har_freq_est2, lagIndices_fx[0] );
- move16();
- }
- }
-
- gethar_noisegn_fx( st_fx->hBstr, L_spectra, QsL, sspectra_diff_fx, Qss, L_xSynth_har,
- sbWidth_fx, lagIndices_fx, BANDS_fx, har_bands_fx, fLenLow_fx, fLenHigh_fx,
- subband_offsets_fx, subband_search_offset_fx, band_start_fx, band_end_fx, band_width_fx,
- L_band_energy, Qbe, L_be_tonal, &QbeL, sspectra_fx,
- har_freq_est2, pos_max_hfe2, pul_res_fx, pk_sf_fx );
-
-
- Gettonl_scalfact_fx( L_xSynth_har, QsL, L_spectra_ni, fLenLow_fx, fLenHigh_fx, har_bands_fx, BANDS_fx, L_band_energy, Qbe, band_start_fx, band_end_fx,
- p2a_flags_fx, L_be_tonal, QbeL, pk_sf_fx, Qss, pul_res_fx );
-
- IF( flag_dis == 0 )
- {
- *prev_frm_hfe2 = 0;
- move16();
- }
- ELSE
- {
- *prev_frm_hfe2 = har_freq_est2;
- move16();
- }
-
- FOR( k = BANDS_fx - NB_SWB_SUBBANDS; k < BANDS_fx; k++ )
- {
- FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ )
- {
- L_spectra[i] = L_xSynth_har[i - fLenLow_fx];
- move32(); /* QsL */
- }
- }
- }
- ELSE
- {
- ss_min_fx = spectrumsmooth_noiseton_fx( L_spectra, /*QsL,*/ L_spectra_ni, sspectra_fx, sspectra_diff_fx, sspectra_ni_fx, &Qss, fLenLow_fx, ni_seed_fx );
-
- /* Get lag indices */
- GetSWBIndices_fx( sspectra_fx, /*Qss,*/ L_spectra + fLenLow_fx, QsL, nBands_fx, sbWidth_fx, lagIndices_fx, fLenLow_fx,
- Nbiggest_fx, subband_offsets_fx, sspectra_fx );
-
- /* Bitstream operations */
- FOR( k = 0; k < nBands_fx; k++ )
- {
- IF( EQ_16( p2a_flags_fx[BANDS_fx - NB_SWB_SUBBANDS + k], 1 ) )
- {
- lagIndices_fx[k] = 0;
- move16();
- lagGains_fx[k] = 0;
- move16();
- QlagGains[k] = 15;
- move16();
- }
- ELSE
- {
- push_indice( st_fx->hBstr, IND_LAGINDICES, lagIndices_fx[k], bits_lagIndices_modeNormal[k] );
- }
- }
-
- convert_lagIndices_pls2smp_fx( lagIndices_fx, nBands_fx, lagIndices_fx, sspectra_fx, sbWidth_fx, fLenLow_fx );
-
- GetlagGains_fx( sspectra_ni_fx, Qss, &L_band_energy[BANDS_fx - NB_SWB_SUBBANDS], Qbe, nBands_fx, sbWidth_fx, lagIndices_fx, fLenLow_fx, lagGains_fx, QlagGains );
- FOR( k = 0; k < NB_SWB_SUBBANDS; k++ )
- {
- lagGains_fx[k] = mult_r( lagGains_fx[k], 29491 ); /* lagGains[k]*0.9f; */
- move16();
- }
-
- FOR( k = 0; k < NB_SWB_SUBBANDS; k++ )
- {
- L_th_g[k] = L_deposit_l( 0 );
- move32();
- IF( p2a_flags_fx[BANDS_fx - NB_SWB_SUBBANDS + k] == 0 )
- {
- L_th_g[k] = L_shl( L_mult( lagGains_fx[k], ss_min_fx ), sub( QsL, add( add( QlagGains[k], Qss ), 1 ) ) ); /* QlagGain+Qss -> QsL */
- move32();
- }
- }
-
- GetSynthesizedSpecThinOut_fx( sspectra_ni_fx, Qss, L_xSynth_har, QsL, nBands_fx, sbWidth_fx, lagIndices_fx, lagGains_fx, QlagGains, fLenLow_fx );
-
- /*Level adjustment for the missing bands*/
- noiseinj_hf_fx( L_xSynth_har, QsL, L_th_g, L_band_energy, Qbe, hHQ_core->prev_En_sb_fx, p2a_flags_fx, BANDS_fx, band_start_fx, band_end_fx, fLenLow_fx, fLenHigh_fx );
-
-
- FOR( k = BANDS_fx - NB_SWB_SUBBANDS; k < BANDS_fx; k++ )
- {
- IF( p2a_flags_fx[k] == 0 )
- {
- FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ )
- {
- L_spectra[i] = L_xSynth_har[i - fLenLow_fx];
- move32(); /* Qob */
- }
- }
- ELSE
- {
- FOR( i = band_start_fx[k]; i <= band_end_fx[k]; i++ )
- {
- L_spectra[i] = L_spectra_ni[i];
- move32();
- }
- }
- }
- }
-
- return;
-}
/*--------------------------------------------------------------------------*
* swb_bwe_enc_lr()
*
@@ -1309,87 +1113,3 @@ void swb_bwe_enc_lr_fx(
return;
}
-
-void swb_bwe_enc_lr_ivas_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word32 L_m_core[], /* i : lowband synthesis */
- Word16 QsL, /* i : Q value */
- const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */
- Word32 L_m[], /* o : highband synthesis with lowband zeroed */
- const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */
- Word16 BANDS_fx, /* i : Total number of Subbands in a frame */
- Word16 *band_start_fx, /* i : band start of each SB */
- Word16 *band_end_fx, /* i : band end of each SB */
- Word32 *L_band_energy, /* i : band_energy of each SB */
- Word16 Qbe, /* i : Q value of band energy */
- Word16 *p2a_flags_fx, /* i : HF tonal indicator */
- const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */
- Word16 lowlength_fx, /* i : lowband length */
- Word16 highlength_fx, /* i : highband length */
- Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */
- const Word16 har_bands_fx, /* i : Number of LF harmonic bands */
- Word16 *prev_frm_hfe2, /* i/o: */
- Word16 *prev_stab_hfe2, /* i/o: */
- const Word16 band_width_fx[], /* i : band_width information */
- const Word32 L_y2_ni[], /* i : band_width information */
- Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */
-)
-{
- Word16 k;
- Word16 nBands_fx;
- Word16 nBands_search_fx;
- Word16 wBands_fx[NB_SWB_SUBBANDS];
- Word16 lagIndices_fx[NB_SWB_SUBBANDS];
- Word16 swb_lowband_fx, swb_highband_fx, allband_fx;
-
- const Word16 *subband_offsets_fx;
- const Word16 *subband_search_offset_fx;
-
- Word32 *p_L_m;
-
- subband_search_offset_fx = subband_search_offsets_13p2kbps_Har;
- subband_offsets_fx = subband_offsets_sub5_13p2kbps_Har;
-
- hf_parinitiz_fx( L_total_brate, hqswb_clas_fx, lowlength_fx, highlength_fx, wBands_fx, &subband_search_offset_fx, &subband_offsets_fx, &nBands_fx, &nBands_search_fx, &swb_lowband_fx, &swb_highband_fx );
- allband_fx = add( swb_lowband_fx, swb_highband_fx );
- move16();
-
- /* Prepare m[], low part from WB core, high part from 32k input */
- Copy32( L_m_core, L_m, swb_lowband_fx );
- Copy32( &L_m_orig[swb_lowband_fx], &L_m[swb_lowband_fx], swb_highband_fx );
-
- EncodeSWBSubbands_ivas_fx(
- st_fx,
- L_m, QsL,
- swb_lowband_fx, swb_highband_fx, nBands_fx, nBands_search_fx, wBands_fx, subband_offsets_fx,
- lagIndices_fx,
- BANDS_fx, band_start_fx, band_end_fx,
- L_band_energy, Qbe,
- p2a_flags_fx,
- hqswb_clas_fx, prev_frm_index_fx, har_bands_fx, subband_search_offset_fx,
- prev_frm_hfe2, prev_stab_hfe2,
- band_width_fx, L_y2_ni, ni_seed_fx );
-
- p_L_m = &L_m[sub( allband_fx, 1 )];
- *p_L_m = Mult_32_16( *p_L_m, 2028 );
- move32();
- p_L_m--; /* 0.0625 = 2028 (Q15) */
- *p_L_m = Mult_32_16( *p_L_m, 4096 );
- move32();
- p_L_m--; /* 0.125 = 4096 (Q15) */
- *p_L_m = Mult_32_16( *p_L_m, 8192 );
- move32();
- p_L_m--; /* 0.25 = 8192 (Q15) */
- *p_L_m = Mult_32_16( *p_L_m, 16384 );
- move32();
- p_L_m--; /* 0.5 = 16384 (Q15) */
-
- /* set low frequencies to zero */
- FOR( k = 0; k < swb_lowband_fx; k++ )
- {
- L_m[k] = L_deposit_l( 0 );
- move32();
- }
-
- return;
-}
diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c
index ffdb1d454df4797d99cf2995e24cfa0ad814d1bd..107d85ccd7661b939825158e26446fd5fc2eda3b 100644
--- a/lib_enc/swb_pre_proc_fx.c
+++ b/lib_enc/swb_pre_proc_fx.c
@@ -771,17 +771,20 @@ void swb_pre_proc_fx(
* - Common SWB TBE and SWB BWE pre-processing
*-------------------------------------------------------------------*/
-/*full implementation pending*/
void swb_pre_proc_ivas_fx(
- Encoder_State *st, /* i/o: encoder state structure */
- Word16 *new_swb_speech, /* o : original input signal at 32kHz - st->q_inp */
+ Encoder_State *st, /* i/o: encoder state structure */
+ Word16 *new_swb_speech, /* o : original input signal at 32kHz - st->q_inp */
+#ifndef REMOVE_SCALING_SHB_SPEECH
Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q - q_reImBuffer */
- Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz- Q(Q_shb_spch) */
+#endif
+ Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz - Q0 */
+#ifndef REMOVE_SCALING_SHB_SPEECH
Word16 *Q_shb_spch,
- Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */
- Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */
- Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers */
- CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */
+#endif
+ Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */
+ Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */
+ Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers */
+ CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */
)
{
Word16 Sample_Delay_SWB_BWE, inner_frame, delay;
@@ -1063,6 +1066,12 @@ void swb_pre_proc_ivas_fx(
ELSE /* IVAS_CPE_DFT */
{
Word16 out_start_ind, out_end_ind;
+#ifdef REMOVE_SCALING_SHB_SPEECH
+ Word32 new_swb_speech_buffer_fx[L_FRAME48k + STEREO_DFT_OVL_MAX];
+ Word32 *new_swb_speech_fx;
+ set32_fx( new_swb_speech_buffer_fx, 0, L_FRAME48k + STEREO_DFT_OVL_MAX );
+ new_swb_speech_fx = new_swb_speech_buffer_fx + STEREO_DFT_OVL_MAX;
+#endif
stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, new_swb_speech_fx, &out_start_ind, &out_end_ind, st->idchan, input_Fs, 32000, 0, NULL );
Copy_Scale_sig32_16( new_swb_speech_fx - STEREO_DFT_OVL_MAX, new_swb_speech - STEREO_DFT_OVL_MAX, L_FRAME48k + STEREO_DFT_OVL_MAX, add( st->q_inp, add( q_reImBuffer, 1 ) ) ); // st->q_inp
@@ -1125,9 +1134,7 @@ void swb_pre_proc_ivas_fx(
CldfbHB_fx = EPSILON_FX;
move32();
}
-#ifdef FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC
exp = norm_l( CldfbHB_fx );
-#endif
CldfbHB_fx = L_shl( CldfbHB_fx, exp ); /* CldfbHB_ener = CldfbHB_fl*2^(exp) */
Cldfbtemp1 = Log2_norm_lc( CldfbHB_fx ); /* Log2_norm_lc(t) = 2^15*(log2(t/2^30)) */
Cldfbtemp1 = sub( shr( Cldfbtemp1, 6 ), shl( add( sub( Q31 - Q30, CldfbHB_fx_e ), exp ), 9 ) );
@@ -1274,9 +1281,11 @@ void swb_pre_proc_ivas_fx(
regV = icbwe_regressionValuesTDM_fx;
cldfbSynthesis_ivas_fx( realBufferFlipped, imagBufferFlipped, shb_speech_fx_32, -1, 0, 0, st->cldfbSynTd );
- Copy_Scale_sig_32_16( shb_speech_fx_32, shb_speech, L_FRAME16k, negate( sub( q_reImBuffer, 1 ) ) );
+ Copy_Scale_sig_32_16( shb_speech_fx_32, shb_speech, L_FRAME16k, negate( sub( q_reImBuffer, 1 ) ) ); // Q0
+#ifndef REMOVE_SCALING_SHB_SPEECH
*Q_shb_spch = 0;
move16();
+#endif
}
IF( GE_16( st->element_mode, IVAS_CPE_DFT ) && hCPE->hStereoICBWE != NULL )
diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c
index 6df7696bf172352d36d0903fb4ffa78635774d64..d6fe953257eac236750b68945cad5c705ddada2e 100644
--- a/lib_enc/swb_tbe_enc_fx.c
+++ b/lib_enc/swb_tbe_enc_fx.c
@@ -8,7 +8,6 @@
#include "rom_com.h"
#include "prot_fx.h" /* Function prototypes */
#include "prot_fx_enc.h" /* Function prototypes */
-#include "stl.h"
#include "ivas_prot_fx.h"
@@ -19,6 +18,7 @@
#define ENVSHBRES_ACORR_MIN 40 /* minimum lag for calculating autocorrelation function on SHB residual TD envelope */
#define ENVSHBRES_ACORR_MAX 80 /* maximum lag for calculating autocorrelation function on SHB residual TD envelope */
+
/*-----------------------------------------------------------------*
* Local functions
*-----------------------------------------------------------------*/
@@ -30,34 +30,43 @@ static void singlevectortest_gain_fx( const Word32 *inp, const Word16 dimen, con
static void determine_gain_weights_fx( const Word32 *gain, Word16 *weights, const Word16 dims );
static void QuantizeSHBsubgains_fx( Encoder_State *st_fx, Word16 *subgains, const Word16 extl );
-
+#ifndef HARMONIZE_TBE
static void QuantizeSHBsubgains_ivas_fx( Encoder_State *st_fx, Word16 subgains[], const Word16 extl );
+#endif
+#ifdef HARMONIZE_TBE
+static void QuantizeSHBframegain_fx( Encoder_State *st_fx, Word32 *GainFrame, const Word16 extl, Word32 extl_brate, Word16 *rf_gainFrame_ind, const Word16 flag_conservative );
+#else
static void QuantizeSHBframegain_fx( Encoder_State *st_fx, Word32 *GainFrame, const Word16 extl, Word32 extl_brate, Word16 *rf_gainFrame_ind );
static void QuantizeSHBframegain_ivas_fx( Encoder_State *st_fx, Word32 *GainFrame, const Word16 extl, Word32 extl_brate, Word16 *rf_gainFrame_ind, const Word16 flag_conservative );
+#endif
static Word16 closest_centroid_fx( const Word16 *data, const Word16 *weights, const Word16 *quantizer, const Word16 centroids, const Word16 length );
static Word16 closest_centroid_lc_fx( const Word16 *data, const Word16 *quantizer, const Word16 centroids );
+#ifdef HARMONIZE_TBE
+static void EstimateSHBFrameGain_fx( const Word16 element_mode, const Word16 length, const Word16 *oriSHB, const Word16 Q_oriSHB, const Word16 *synSHB, const Word16 Q_synSHB, Word16 *subgain, Word32 *GainFrame, const Word16 *win_shb, const Word16 *subwin_shb, const Word16 n_subfr_saturation );
+#else
static void EstimateSHBFrameGain_fx( const Word16 length, const Word16 *oriSHB, const Word16 Q_oriSHB, const Word16 *synSHB, const Word16 Q_synSHB, Word16 *subgain, Word32 *GainFrame, const Word16 *win_shb, const Word16 *subwin_shb, const Word16 n_subfr_saturation );
static void EstimateSHBFrameGain_ivas_fx( const Word16 length, const Word16 *oriSHB, const Word16 Q_oriSHB, const Word16 *synSHB, const Word16 Q_synSHB, Word16 *subgain, Word32 *GainFrame, const Word16 *win_shb, const Word16 *subwin_shb, const Word16 n_subfr_saturation );
+#endif
static void EstimateSHBGainShape_fx( const Word16 length, const Word16 *oriSHB, const Word16 Q_oriSHB, const Word16 *synSHB, const Word16 Q_synSHB, Word16 *subgain, const Word16 *subwin, Word16 *n_subfr_saturation, const Flag limit_min_gain );
-static Word32 pow_off_pk_fx( Word16 a[], Word16 len, Word16 step );
+static Word32 pow_off_pk_fx( const Word16 a[], const Word16 len, const Word16 step );
-static Word32 pow_off_pk_corrected_fx( Word16 a[], Word16 len, Word16 step );
+static Word32 pow_off_pk_corrected_fx( const Word16 a[], const Word16 len, const Word16 step );
static void find_max_mem_enc( Encoder_State *st_fx, Word16 *n_mem, Word16 *n_mem2 );
-static void rescale_genSHB_mem_enc( Encoder_State *st_fx, Word16 sf );
+static void rescale_genSHB_mem_enc( Encoder_State *st_fx, const Word16 sf );
static void find_max_mem_wb_enc( Encoder_State *st_fx, Word16 *n_mem );
-static void rescale_genWB_mem_enc( Encoder_State *st_fx, Word16 sf );
+static void rescale_genWB_mem_enc( Encoder_State *st_fx, const Word16 sf );
static void Quant_lower_LSF_fx( const Word16 lsf[], Word16 lsf_q[], Word16 lsf_idx[] );
@@ -65,6 +74,15 @@ static Word16 Quant_mirror_point_fx( const Word16 lsf[], const Word16 lsf_q[], W
static Word16 Find_LSF_grid_fx( const Word16 lsf[], Word16 lsf_q[], const Word16 m );
+#ifdef HARMONIZE_TBE
+static void Quant_BWE_LSF_fx( BSTR_ENC_HANDLE hBstr, TD_BWE_ENC_HANDLE hBWE_TD, const Word16 codec_mode, const Word16 lsf_shb_fx[], Word16 Q_lsfs_fx[], const Word32 extl_brate );
+
+static void Quant_shb_ener_sf_fx( Encoder_State *st_fx, Word32 *shb_ener_sf_Q31, const Word16 Q_ener );
+
+static void Quant_shb_res_gshape_fx( Encoder_State *st, Word16 shb_res_gshape_fx[] );
+
+static void gainFrSmooth_En_fx( Encoder_State *st_fx, Word16 *shb_frame_fx /* Q_in */, const Word16 *lpc_shb_fx /* Q12 */, const Word16 *lsp_shb_fx /* Q15 */, Word16 *MA_lsp_shb_spacing /* Q15 */, Word16 *frGainAttenuate /* Q0 */, Word16 *frGainSmoothEn /* Q0 */ );
+#else
static void Quant_BWE_LSF_fx( Encoder_State *st_fx, const Word16 lsp_shb[], Word16 Q_lsfs[] );
static void Quant_BWE_LSF_ivas_fx( BSTR_ENC_HANDLE hBstr, TD_BWE_ENC_HANDLE hBWE_TD, const Word16 codec_mode, const Word16 lsf_shb_fx[], Word16 Q_lsfs_fx[], const Word32 extl_brate );
@@ -80,6 +98,7 @@ static void Quant_shb_res_gshape_ivas_fx( Encoder_State *st, Word16 shb_res_gsha
static void gainFrSmooth_En_fx( Encoder_State *st_fx, Word16 *shb_frame_fx, const Word16 *lpc_shb_fx, const Word16 *lsp_shb_fx, Word16 *MA_lsp_shb_spacing, Word16 *frGainAttenuate, Word16 *frGainSmoothEn );
static void gainFrSmooth_En_ivas_fx( Encoder_State *st_fx, Word16 *shb_frame_fx /* Q_in */, const Word16 *lpc_shb_fx /* Q12 */, const Word16 *lsp_shb_fx /* Q15 */, Word16 *MA_lsp_shb_spacing /* Q15 */, Word16 *frGainAttenuate /* Q0 */, Word16 *frGainSmoothEn /* Q0 */ );
+#endif
/*-------------------------------------------------------------------*
@@ -204,9 +223,9 @@ void find_max_mem_enc(
* Rescale genSHB memories
*-------------------------------------------------------------------*/
-void rescale_genSHB_mem_enc(
+static void rescale_genSHB_mem_enc(
Encoder_State *st_fx,
- Word16 sf )
+ const Word16 sf )
{
Word16 i;
TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD;
@@ -246,9 +265,14 @@ void rescale_genSHB_mem_enc(
move16();
hBWE_TD->tbe_premph_fx = shl_r( hBWE_TD->tbe_premph_fx, sf );
move16();
+
+ return;
}
-void find_max_mem_wb_enc( Encoder_State *st_fx, Word16 *n_mem )
+
+static void find_max_mem_wb_enc(
+ Encoder_State *st_fx,
+ Word16 *n_mem )
{
Word16 i;
Word16 n_mem_32;
@@ -323,9 +347,14 @@ void find_max_mem_wb_enc( Encoder_State *st_fx, Word16 *n_mem )
move16();
*n_mem = s_max( *n_mem, 0 );
move16();
+
+ return;
}
-void rescale_genWB_mem_enc( Encoder_State *st_fx, Word16 sf )
+
+static void rescale_genWB_mem_enc(
+ Encoder_State *st_fx,
+ const Word16 sf )
{
Word16 i;
TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD;
@@ -371,6 +400,8 @@ void rescale_genWB_mem_enc( Encoder_State *st_fx, Word16 sf )
hBWE_TD->mem_csfilt_fx[i] = L_shl( hBWE_TD->mem_csfilt_fx[i], sf );
move32();
}
+
+ return;
}
@@ -381,8 +412,12 @@ void rescale_genWB_mem_enc( Encoder_State *st_fx, Word16 sf )
*-------------------------------------------------------------------*/
void InitSWBencBuffer_fx(
+#ifdef HARMONIZE_TBE
+ const Word16 element_mode, /* i : element mode */
+#endif
TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */
)
+#ifndef HARMONIZE_TBE
{
Word16 i;
@@ -480,6 +515,7 @@ void InitSWBencBuffer_fx(
void InitSWBencBuffer_ivas_fx(
TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */
)
+#endif
{
Word16 i;
@@ -561,10 +597,23 @@ void InitSWBencBuffer_ivas_fx(
hBWE_TD->prev_fb_energy_fx_Q = 0;
move16();
- hBWE_TD->prev_Q_bwe_exc = 15;
- move16();
- hBWE_TD->prev_Q_bwe_syn = 15;
- move16();
+#ifdef HARMONIZE_TBE
+ IF( element_mode == EVS_MONO )
+ {
+ hBWE_TD->prev_Q_bwe_exc = 31;
+ move16();
+ hBWE_TD->prev_Q_bwe_syn = 31;
+ move16();
+ }
+ ELSE
+#endif
+ {
+ hBWE_TD->prev_Q_bwe_exc = 15;
+ move16();
+ hBWE_TD->prev_Q_bwe_syn = 15;
+ move16();
+ }
+
set16_fx( hBWE_TD->prev_lsp_wb_fx, 0, 6 );
set16_fx( hBWE_TD->prev_lsp_wb_temp_fx, 0, 6 );
set16_fx( hBWE_TD->prev_lpc_wb_fx, 0, LPC_SHB_ORDER_WB );
@@ -644,6 +693,7 @@ void ResetSHBbuffer_Enc_fx(
#define WBTBE_LPCWIN_LENGTH ( L_LOOK_12k8 + L_SUBFR + L_FRAME ) * 5 / 16 - 1
void wb_tbe_enc_fx(
+#ifndef HARMONIZE_TBE
Encoder_State *st_fx, /* i/o: encoder state structure */
const Word16 coder_type, /* i : coding type */
const Word16 *hb_speech, /* i : HB target signal (6-8kHz) at 16kHz at Q-1 */
@@ -1122,8 +1172,13 @@ void wb_tbe_enc_fx(
p2m_out = pow_off_pk_fx( GainShape, NUM_SHB_SUBFR / 2, 2 );
/* Estimate the gain parameter */
+#ifdef HARMONIZE_TBE
+ EstimateSHBFrameGain_fx( st_fx->element_mode, SHB_OVERLAP_LEN / 2, hb_frame, Q_ns, shaped_wb_excitation, Q_bwe_exc_ext, GainShape,
+ &GainFrame, window_wb_fx, subwin_wb_fx, 0 );
+#else
EstimateSHBFrameGain_fx( SHB_OVERLAP_LEN / 2, hb_frame, Q_ns, shaped_wb_excitation, Q_bwe_exc_ext, GainShape,
&GainFrame, window_wb_fx, subwin_wb_fx, 0 );
+#endif
/* If there's a big difference in the power of gains away from the peak gain */
/* due to poor quantization then suppress energy of the high band. */
@@ -1196,7 +1251,11 @@ void wb_tbe_enc_fx(
}
/* Quantization of the frame gain parameter */
+#ifdef HARMONIZE_TBE
+ QuantizeSHBframegain_fx( st_fx, &GainFrame, st_fx->extl, st_fx->extl_brate, &hRF->RF_bwe_gainFr_ind, 0 );
+#else
QuantizeSHBframegain_fx( st_fx, &GainFrame, st_fx->extl, st_fx->extl_brate, &hRF->RF_bwe_gainFr_ind );
+#endif
/* Adjust the subframe and frame gain of the synthesized SHB signal */
/* Scale the shaped excitation*/
@@ -1235,6 +1294,7 @@ void wb_tbe_enc_fx(
/*==========================================================================*/
void wb_tbe_enc_ivas_fx(
+#endif
Encoder_State *st_fx, /* i/o: encoder state structure */
const Word16 *hb_speech, /* i : HB target signal (6-8kHz) at 16kHz Q(-1) */
const Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation Q(2*Q_new) */
@@ -1264,10 +1324,7 @@ void wb_tbe_enc_ivas_fx(
Word32 LepsP[LPC_SHB_ORDER_WB + 1];
Word32 prev_pow, curr_pow, Lscale;
- /* Word16 scale; */
- /*Word16 ramp_flag;*/
Word32 p2m_in, p2m_out;
- /*Word16 cnt, max =0;*/
Word16 n_mem, Q_bwe_exc, Q_bwe_exc_ext, exp_out, Q_cur_pow, Q_prev_pow; /* Q_hb_frame; */
Word32 L_tmp, Lmax;
Word16 tmp, exp, Q_out, sc;
@@ -1287,7 +1344,6 @@ void wb_tbe_enc_ivas_fx(
TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD;
move16();
- /*Word16 att = 32767;*/
set16_fx( bwe_exc_extended_16, 0, L_FRAME32k + NL_BUFF_OFFSET );
hb_new_speech = hb_old_speech + WBTBE_LOOK_LSUFBR_5_OVER_16;
hb_frame = hb_old_speech + WBTBE_LSUBFR_5_OVER_16 + WBTBE_ANA_ALIGNDELAY;
@@ -1312,34 +1368,73 @@ void wb_tbe_enc_ivas_fx(
k = 0;
move16();
- FOR( j = 0; j < L_SUBFR16k; j = j + 4 )
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
{
- L_tmp = L_mult( hb_old_speech[i], ola_win_shb_switch_fold_fx[j] );
- hb_old_speech[i] = mac_r_sat( L_tmp, hb_speech[k], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j] );
- move16();
- i--;
- k++;
+ FOR( j = 0; j < L_SUBFR16k; j = j + 4 )
+ {
+ L_tmp = L_mult( hb_old_speech[i], ola_win_shb_switch_fold_fx[j] );
+ hb_old_speech[i] = mac_r( L_tmp, hb_speech[j], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j] );
+ move16();
+ i--;
+ }
+ }
+ ELSE
+#endif
+ {
+ FOR( j = 0; j < L_SUBFR16k; j = j + 4 )
+ {
+ L_tmp = L_mult( hb_old_speech[i], ola_win_shb_switch_fold_fx[j] );
+ hb_old_speech[i] = mac_r_sat( L_tmp, hb_speech[k], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j] );
+ move16();
+ i--;
+ k++;
+ }
}
}
- autocorr_fx( hb_old_speech, LPC_SHB_ORDER_WB + 1, R_h, R_l, &Q_R, ( ( NS2SA( INT_FS_12k8, 5000000L ) + L_SUBFR + L_FRAME ) * 5 / 16 ), win_lpc_hb_wb_ivas_fx, 0, 1 );
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ autocorr_fx( hb_old_speech, LPC_SHB_ORDER_WB + 1, R_h, R_l, &Q_R, WBTBE_LPCWIN_LENGTH, win_lpc_hb_wb_fx, 0, 1 );
+ }
+ ELSE
+#endif
+ {
+ autocorr_fx( hb_old_speech, LPC_SHB_ORDER_WB + 1, R_h, R_l, &Q_R, ( ( NS2SA( INT_FS_12k8, 5000000L ) + L_SUBFR + L_FRAME ) * 5 / 16 ), win_lpc_hb_wb_ivas_fx, 0, 1 );
- /* Ensure R[0] isn't zero when entering Levinson-Durbin */
- R_l[0] = s_max( R_l[0], 1 );
- move16();
+ /* Ensure R[0] isn't zero when entering Levinson-Durbin */
+ R_l[0] = s_max( R_l[0], 1 );
+ move16();
+ }
E_LPC_lev_dur( R_h, R_l, lpc_wb_temp_fx, LepsP, LPC_SHB_ORDER_WB, NULL ); // Since 0th index will be 1 in floating point buffer, in fixed point one has to take norm of 0th index to identify the Q-factor
Copy_Scale_sig( lpc_wb_temp_fx, lpc_wb_temp_fx, LPC_SHB_ORDER_WB + 1, sub( norm_s( lpc_wb_temp_fx[0] ), 2 ) ); // Q12
- /* convert into lsps and calculate weights */
- FOR( i = 0; i <= LPC_SHB_ORDER_WB; i++ )
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
{
- lpc_wb_32_fx[i] = L_negate( L_deposit_h( shr( lpc_wb_temp_fx[i], 1 ) ) ); // Q27
- move32();
- }
+ /* convert into lsps and calculate weights */
+ FOR( i = 0; i <= LPC_SHB_ORDER_WB; i++ )
+ {
+ lpc_wb_32_fx[i] = L_negate( L_shr( L_deposit_h( lpc_wb_temp_fx[i] ), 1 ) );
+ move32();
+ }
- lpc2lsp_ivas_fx( &lpc_wb_32_fx[1], lsp_wb_temp_fx, hBWE_TD->prev_lsp_wb_temp_fx, LPC_SHB_ORDER_WB );
+ lpc2lsp_fx( &lpc_wb_32_fx[1], lsp_wb_temp_fx, hBWE_TD->prev_lsp_wb_temp_fx, LPC_SHB_ORDER_WB );
+ }
+ ELSE
+#endif
+ {
+ /* convert into lsps and calculate weights */
+ FOR( i = 0; i <= LPC_SHB_ORDER_WB; i++ )
+ {
+ lpc_wb_32_fx[i] = L_negate( L_deposit_h( shr( lpc_wb_temp_fx[i], 1 ) ) ); // Q27
+ move32();
+ }
+ lpc2lsp_ivas_fx( &lpc_wb_32_fx[1], lsp_wb_temp_fx, hBWE_TD->prev_lsp_wb_temp_fx, LPC_SHB_ORDER_WB );
+ }
FOR( i = 0; i < LPC_SHB_ORDER_WB; i++ )
{
@@ -1347,20 +1442,11 @@ void wb_tbe_enc_ivas_fx(
move16();
}
- /* lsp_spacing_fx = 16384; move16(); */
lsp_spacing_fx = lsp_wb_temp_fx[0];
move16();
FOR( i = 1; i < LPC_SHB_ORDER_WB; i++ )
{
- /*if ( i == 0 )
- {
- tmp = lsp_wb_temp_fx[0]; move16();
- }
- else
- {*/
tmp = sub( lsp_wb_temp_fx[i], lsp_wb_temp_fx[i - 1] );
- /*} */
-
lsp_spacing_fx = s_min( lsp_spacing_fx, tmp );
}
@@ -1465,7 +1551,17 @@ void wb_tbe_enc_ivas_fx(
/* Quantization of LSFs */
i = closest_centroid_fx( lsp_wb, weights_lsp, wb_bwe_lsfvq_cbook_8bit_fx, 256, LPC_SHB_ORDER_WB ); /*move16(); */
- push_indice( st_fx->hBstr, IND_SHB_LSF, i, NUM_BITS_WB_LSF );
+#ifdef HARMONIZE_TBE
+ IF( EQ_16( st_fx->codec_mode, MODE2 ) )
+ {
+ hBWE_TD->lsf_WB = i;
+ move16();
+ }
+ ELSE
+#endif
+ {
+ push_indice( st_fx->hBstr, IND_SHB_LSF, i, NUM_BITS_WB_LSF );
+ }
Copy( wb_bwe_lsfvq_cbook_8bit_fx + i * LPC_SHB_ORDER_WB, lsp_wb, LPC_SHB_ORDER_WB );
lsp2lpc_fx( &lpc_wb[1], lsp_wb, hBWE_TD->prev_lpc_wb_fx, LPC_SHB_ORDER_WB );
@@ -1543,43 +1639,63 @@ void wb_tbe_enc_ivas_fx(
prev_pow = 0;
move32();
- Q_prev_pow = norm_arr( hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD / 4 );
- /* Compare with the guard bits needed in the subsequent operations.
- * Guard bits for L_SHB_LAHEAD / 4 (expression evaluates to 5) is 3.
- */
- IF( LT_16( Q_prev_pow, 3 ) )
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
{
FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ )
{
- shaped_wb_exc_scale[i] = shr( hBWE_TD->state_syn_shbexc_fx[i], 3 );
- move16();
+ prev_pow = L_mac0( prev_pow, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /* Q(2*st_fx->prev_Q_bwe_exc) */
}
- Q_prev_pow = shl_r( sub( sub( hBWE_TD->prev_Q_bwe_exc, 16 ), 3 ), 1 );
- move16();
+
+ Q_prev_pow = 0;
+ move32();
}
ELSE
+#endif
{
- FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ )
+ Q_prev_pow = norm_arr( hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD / 4 );
+ /* Compare with the guard bits needed in the subsequent operations.
+ * Guard bits for L_SHB_LAHEAD / 4 (expression evaluates to 5) is 3.
+ */
+ IF( LT_16( Q_prev_pow, 3 ) )
+ {
+ FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ )
+ {
+ shaped_wb_exc_scale[i] = shr( hBWE_TD->state_syn_shbexc_fx[i], 3 );
+ move16();
+ }
+ Q_prev_pow = shl_r( sub( sub( hBWE_TD->prev_Q_bwe_exc, 16 ), 3 ), 1 );
+ move16();
+ }
+ ELSE
{
- shaped_wb_exc_scale[i] = hBWE_TD->state_syn_shbexc_fx[i];
+ FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ )
+ {
+ shaped_wb_exc_scale[i] = hBWE_TD->state_syn_shbexc_fx[i];
+ move16();
+ }
+ Q_prev_pow = shl_r( sub( hBWE_TD->prev_Q_bwe_exc, 16 ), 1 );
move16();
}
- Q_prev_pow = shl_r( sub( hBWE_TD->prev_Q_bwe_exc, 16 ), 1 );
- move16();
- }
- IF( st_fx->element_mode > EVS_MONO )
- {
tmp = sub( Q_prev_pow, 31 + 16 );
prev_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q_prev_pow*/
- }
- FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ )
- {
- prev_pow = L_mac0( prev_pow, shaped_wb_exc_scale[i], shaped_wb_exc_scale[i] ); /* Q_prev_pow */
+
+ FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ )
+ {
+ prev_pow = L_mac0( prev_pow, shaped_wb_exc_scale[i], shaped_wb_exc_scale[i] ); /* Q_prev_pow */
+ }
}
rescale_genWB_mem_enc( st_fx, sub( Q_bwe_exc, hBWE_TD->prev_Q_bwe_exc ) );
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ Copy( hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_16, NL_BUFF_OFFSET );
+ }
+#endif
+
sc = sub( Q_bwe_exc, add( Q_new, Q_new ) );
FOR( i = 0; i < L_FRAME32k; i++ )
{
@@ -1587,69 +1703,117 @@ void wb_tbe_enc_ivas_fx(
move16();
}
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ Copy( bwe_exc_extended_16 + L_FRAME32k, hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET );
+ }
+#endif
Copy( hBWE_TD->state_syn_shbexc_fx, shaped_wb_excitation, L_SHB_LAHEAD / 4 );
Q_bwe_exc_ext = sub( Q_bwe_exc, 16 );
- GenShapedWBExcitation_ivas_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx,
- hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx,
- hBWE_TD->state_lpc_syn_fx, st_fx->coder_type, st_fx->element_mode, bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed,
- vf_modified_fx, uv_flag, st_fx->igf );
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ GenShapedWBExcitation_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx,
+ hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx,
+ hBWE_TD->state_lpc_syn_fx, st_fx->coder_type, st_fx->element_mode, bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed,
+ vf_modified_fx, uv_flag, st_fx->igf );
+ }
+ ELSE
+#endif
+ {
+ GenShapedWBExcitation_ivas_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx,
+ hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx,
+ hBWE_TD->state_lpc_syn_fx, st_fx->coder_type, st_fx->element_mode, bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed,
+ vf_modified_fx, uv_flag, st_fx->igf );
+ }
curr_pow = 0;
move32();
- Q_cur_pow = norm_arr( &shaped_wb_excitation[L_SHB_LAHEAD / 4], L_SHB_LAHEAD / 4 );
- /* Compare with the guard bits needed in the subsequent operations.
- * Guard bits for L_SHB_LAHEAD / 4 (expression evaluates to 5) is 3.
- */
- IF( LT_16( Q_cur_pow, 3 ) )
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
{
FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ )
{
- shaped_wb_exc_scale[i] = shr( shaped_wb_excitation[i + L_SHB_LAHEAD / 4], 3 );
+ curr_pow = L_mac0( curr_pow, shaped_wb_excitation[i + L_SHB_LAHEAD / 4], shaped_wb_excitation[i + L_SHB_LAHEAD / 4] ); /* Q(2*Q_bwe_exc_ext) */
+ }
+
+ IF( GT_16( voice_factors[0], 24576 ) )
+ {
+ curr_pow = L_shr( curr_pow, 2 ); /* Q(2*Q_bwe_exc_ext) */
+ }
+
+ Lscale = root_a_over_b_fx( curr_pow, shl_r( Q_bwe_exc_ext, 1 ), prev_pow, shl_r( sub( hBWE_TD->prev_Q_bwe_exc, 16 ), 1 ), &exp );
+
+ FOR( i = 0; i < L_SHB_LAHEAD / 4 - 1; i++ )
+ {
+ L_tmp = Mult_32_16( Lscale, shaped_wb_excitation[i] ); /* Q(16-exp+Q_bwe_exc_ext) */
+ shaped_wb_excitation[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc_ext */
move16();
}
- Q_cur_pow = shl_r( sub( Q_bwe_exc_ext, 3 ), 1 );
+
+ Lscale = root_a_fx( Lscale, 31 - exp, &exp );
+ L_tmp = Mult_32_16( Lscale, shaped_wb_excitation[L_SHB_LAHEAD / 4 - 1] ); /* Q(16-exp+Q_bwe_exc_ext) */
+ shaped_wb_excitation[L_SHB_LAHEAD / 4 - 1] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc_ext */
move16();
}
ELSE
+#endif
{
- FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ )
+ Q_cur_pow = norm_arr( &shaped_wb_excitation[L_SHB_LAHEAD / 4], L_SHB_LAHEAD / 4 );
+ /* Compare with the guard bits needed in the subsequent operations.
+ * Guard bits for L_SHB_LAHEAD / 4 (expression evaluates to 5) is 3.
+ */
+ IF( LT_16( Q_cur_pow, 3 ) )
{
- shaped_wb_exc_scale[i] = shaped_wb_excitation[i + L_SHB_LAHEAD / 4];
+ FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ )
+ {
+ shaped_wb_exc_scale[i] = shr( shaped_wb_excitation[i + L_SHB_LAHEAD / 4], 3 );
+ move16();
+ }
+ Q_cur_pow = shl_r( sub( Q_bwe_exc_ext, 3 ), 1 );
move16();
}
- Q_cur_pow = shl_r( Q_bwe_exc_ext, 1 );
- move16();
- }
- IF( st_fx->element_mode > EVS_MONO )
- {
+ ELSE
+ {
+ FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ )
+ {
+ shaped_wb_exc_scale[i] = shaped_wb_excitation[i + L_SHB_LAHEAD / 4];
+ move16();
+ }
+ Q_cur_pow = shl_r( Q_bwe_exc_ext, 1 );
+ move16();
+ }
+
tmp = sub( Q_cur_pow, 31 + 16 );
curr_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(Q_cur_pow)*/
- }
- FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ )
- {
- curr_pow = L_mac0( curr_pow, shaped_wb_exc_scale[i], shaped_wb_exc_scale[i] ); /* Q(Q_cur_pow) */
- }
- IF( GT_16( voice_factors[0], 24576 ) )
- {
- curr_pow = L_shr( curr_pow, 2 ); /* Q(Q_pow) */
- }
+ FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ )
+ {
+ curr_pow = L_mac0( curr_pow, shaped_wb_exc_scale[i], shaped_wb_exc_scale[i] ); /* Q(Q_cur_pow) */
+ }
- Lscale = root_a_over_b_fx( curr_pow, Q_cur_pow, prev_pow, Q_prev_pow, &exp );
+ IF( GT_16( voice_factors[0], 24576 ) )
+ {
+ curr_pow = L_shr( curr_pow, 2 ); /* Q(Q_pow) */
+ }
- FOR( i = 0; i < L_SHB_LAHEAD / 4 - 1; i++ )
- {
- L_tmp = Mpy_32_16_1( Lscale, shaped_wb_excitation[i] ); /* Q(16-exp+Q_bwe_exc_ext) */
- shaped_wb_excitation[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc_ext */
+ Lscale = root_a_over_b_fx( curr_pow, Q_cur_pow, prev_pow, Q_prev_pow, &exp );
+
+ FOR( i = 0; i < L_SHB_LAHEAD / 4 - 1; i++ )
+ {
+ L_tmp = Mpy_32_16_1( Lscale, shaped_wb_excitation[i] ); /* Q(16-exp+Q_bwe_exc_ext) */
+ shaped_wb_excitation[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc_ext */
+ move16();
+ }
+
+ Lscale = root_a_fx( Lscale, sub( 31, exp ), &exp );
+ L_tmp = Mpy_32_16_1( Lscale, shaped_wb_excitation[L_SHB_LAHEAD / 4 - 1] ); /* Q(16-exp+Q_bwe_exc_ext) */
+ shaped_wb_excitation[L_SHB_LAHEAD / 4 - 1] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc_ext */
move16();
}
- Lscale = root_a_fx( Lscale, sub( 31, exp ), &exp );
- L_tmp = Mpy_32_16_1( Lscale, shaped_wb_excitation[L_SHB_LAHEAD / 4 - 1] ); /* Q(16-exp+Q_bwe_exc_ext) */
- shaped_wb_excitation[L_SHB_LAHEAD / 4 - 1] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc_ext */
- move16();
-
/* Update WB excitation */
Copy( shaped_wb_excitation + L_FRAME16k / 4, hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD / 4 );
@@ -1675,6 +1839,7 @@ void wb_tbe_enc_ivas_fx(
temp_wb_fac_fx = 0;
move16();
}
+
L_feedback = L_mult0( temp_wb_fac_fx, temp_wb_fac_fx );
FOR( i = 1; i < NUM_SHB_SUBFR / 4; i++ )
{
@@ -1753,7 +1918,11 @@ void wb_tbe_enc_ivas_fx(
push_indice( st_fx->hBstr, IND_UV_FLAG, uv_flag, 1 );
/* Quantization of the subframe gain parameter */
+#ifdef HARMONIZE_TBE
+ QuantizeSHBsubgains_fx( st_fx, GainShape, st_fx->extl );
+#else
QuantizeSHBsubgains_ivas_fx( st_fx, GainShape, st_fx->extl );
+#endif
}
/* Compute the power of gains away from the peak gain after quantization */
@@ -1767,9 +1936,13 @@ void wb_tbe_enc_ivas_fx(
}
/* Estimate the gain parameter */
+#ifdef HARMONIZE_TBE
+ EstimateSHBFrameGain_fx( st_fx->element_mode, SHB_OVERLAP_LEN / 2, hb_frame, Q_ns, shaped_wb_excitation, Q_bwe_exc_ext, GainShape,
+ &GainFrame, window_wb_fx, subwin_wb_fx, 0 );
+#else
EstimateSHBFrameGain_ivas_fx( SHB_OVERLAP_LEN / 2, hb_frame, Q_ns, shaped_wb_excitation, Q_bwe_exc_ext, GainShape,
&GainFrame, window_wb_fx, subwin_wb_fx, 0 );
-
+#endif
/* If there's a big difference in the power of gains away from the peak gain */
/* due to poor quantization then suppress energy of the high band. */
@@ -1777,7 +1950,16 @@ void wb_tbe_enc_ivas_fx(
IF( GT_32( p2m_out, L_shl( p2m_in, 1 ) ) )
{
L_tmp = root_a_over_b_fx( L_shl( p2m_in, 1 ), 29, p2m_out, 29, &exp_out );
- GainFrame = L_shl( Mpy_32_32( GainFrame, L_tmp ), exp_out ); /* Q18 */
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ GainFrame = L_shl( Mult_32_32( GainFrame, L_tmp ), exp_out ); /* Q18 */
+ }
+ ELSE
+#endif
+ {
+ GainFrame = L_shl( Mpy_32_32( GainFrame, L_tmp ), exp_out ); /* Q18 */
+ }
}
pitBufAvg_fx = 0;
@@ -1806,11 +1988,29 @@ void wb_tbe_enc_ivas_fx(
}
tmp = s_max( s_min( tmp, 32767 ), 22938 ); /* Q15 */
- GainFrame = Mpy_32_16_1( GainFrame, tmp ); /* Q18 */
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ GainFrame = Mult_32_16( GainFrame, tmp ); /* Q18 */
+ }
+ ELSE
+#endif
+ {
+ GainFrame = Mpy_32_16_1( GainFrame, tmp ); /* Q18 */
+ }
IF( LT_16( lsp_spacing_fx, 328 ) && lsp_spacing_fx )
{
- GainFrame = Mpy_32_16_1( GainFrame, 21299 ); /* Q18 */
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ GainFrame = Mult_32_16( GainFrame, 21299 ); /* Q18 */
+ }
+ ELSE
+#endif
+ {
+ GainFrame = Mpy_32_16_1( GainFrame, 21299 ); /* Q18 */
+ }
}
/*0.25f*sum_f(voice_factors, NB_SUBFR)*/
@@ -1826,33 +2026,70 @@ void wb_tbe_enc_ivas_fx(
IF( st_fx->igf != 0 && EQ_16( st_fx->coder_type, VOICED ) )
{
/*GainFrame *= 0.5f;*/
- GainFrame = Mpy_32_16_1( GainFrame, 16384 );
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ GainFrame = Mult_32_16( GainFrame, 16384 );
+ }
+ ELSE
+#endif
+ {
+ GainFrame = Mpy_32_16_1( GainFrame, 16384 );
+ }
}
ELSE IF( st_fx->igf != 0 && GT_16( avg_voice_fac, 11469 ) ) /*Q15 -> 0.35f*/
{
/*GainFrame *= 0.75f;*/
- GainFrame = Mpy_32_16_1( GainFrame, 24576 );
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ GainFrame = Mult_32_16( GainFrame, 24576 );
+ }
+ ELSE
+#endif
+ {
+ GainFrame = Mpy_32_16_1( GainFrame, 24576 );
+ }
}
/* Quantization of the frame gain parameter */
IF( st_fx->rf_mode )
{
+#ifdef HARMONIZE_TBE
+ QuantizeSHBframegain_fx( st_fx, &GainFrame, st_fx->extl, st_fx->extl_brate, &st_fx->hRF->RF_bwe_gainFr_ind, 0 );
+#else
QuantizeSHBframegain_ivas_fx( st_fx, &GainFrame, st_fx->extl, st_fx->extl_brate, &st_fx->hRF->RF_bwe_gainFr_ind, 0 );
+#endif
}
ELSE
{
+#ifdef HARMONIZE_TBE
+ QuantizeSHBframegain_fx( st_fx, &GainFrame, st_fx->extl, st_fx->extl_brate, NULL, 0 );
+#else
QuantizeSHBframegain_ivas_fx( st_fx, &GainFrame, st_fx->extl, st_fx->extl_brate, NULL, 0 );
+#endif
}
/* Adjust the subframe and frame gain of the synthesized SHB signal */
/* Scale the shaped excitation*/
- scale_sig( shaped_wb_excitation, ( L_FRAME16k + L_SHB_LAHEAD ) / 4, -1 );
- scale_sig( hBWE_TD->syn_overlap_fx, L_SHB_LAHEAD, -1 );
- Q_bwe_exc_ext = sub( Q_bwe_exc_ext, 1 );
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode > EVS_MONO )
+#endif
+ {
+ scale_sig( shaped_wb_excitation, ( L_FRAME16k + L_SHB_LAHEAD ) / 4, -1 );
+ scale_sig( hBWE_TD->syn_overlap_fx, L_SHB_LAHEAD, -1 );
+ Q_bwe_exc_ext = sub( Q_bwe_exc_ext, 1 );
+ }
+
ScaleShapedSHB_fx( SHB_OVERLAP_LEN / 2, shaped_wb_excitation, hBWE_TD->syn_overlap_fx, GainShape, GainFrame, window_wb_fx, subwin_wb_fx,
&Q_bwe_exc_ext, &dummy, dummy, dummy );
- Scale_sig( hBWE_TD->syn_overlap_fx, L_SHB_LAHEAD, 1 );
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode > EVS_MONO )
+#endif
+ {
+ Scale_sig( hBWE_TD->syn_overlap_fx, L_SHB_LAHEAD, 1 );
+ }
hBWE_TD->prev_Q_bwe_exc = Q_bwe_exc;
move16();
@@ -1860,6 +2097,12 @@ void wb_tbe_enc_ivas_fx(
}
+/*-------------------------------------------------------------------*
+ * fb_tbe_reset_enc()
+ *
+ * Reset the extra parameters needed for FB TBE encoding
+ *-------------------------------------------------------------------*/
+
void fb_tbe_reset_enc_fx(
Word32 elliptic_bpf_2_48k_mem_fx[][4],
Word32 *prev_fb_energy_fx,
@@ -2098,7 +2341,11 @@ void swb_tbe_enc_fx(
ELSE
{
/* LSF quantization (21 bits) */
+#ifdef HARMONIZE_TBE
+ Quant_BWE_LSF_fx( st_fx->hBstr, hBWE_TD, st_fx->codec_mode, lsf_shb_fx, lsf_shb_fx, st_fx->extl );
+#else
Quant_BWE_LSF_fx( st_fx, lsf_shb_fx, lsf_shb_fx );
+#endif
}
/* space the lsfs to assert a minimum distance */
@@ -2634,8 +2881,13 @@ void swb_tbe_enc_fx(
p2m_out_fx = pow_off_pk_fx( GainShape_fx, NUM_SHB_SUBFR, 4 );
/* Estimate the gain parameter */
+#ifdef HARMONIZE_TBE
+ EstimateSHBFrameGain_fx( st_fx->element_mode, SHB_OVERLAP_LEN, shb_frame_fx, Q_shb, shaped_shb_excitation_fx, Q_bwe_exc,
+ GainShape_fx, &GainFrame_fx, window_shb_fx, subwin_shb_fx, n_subfr_saturation );
+#else
EstimateSHBFrameGain_fx( SHB_OVERLAP_LEN, shb_frame_fx, Q_shb, shaped_shb_excitation_fx, Q_bwe_exc,
GainShape_fx, &GainFrame_fx, window_shb_fx, subwin_shb_fx, n_subfr_saturation );
+#endif
IF( EQ_16( st_fx->tec_tfa, 1 ) )
{
@@ -2744,7 +2996,11 @@ void swb_tbe_enc_fx(
}
/* Quantization of the frame gain parameter */
+#ifdef HARMONIZE_TBE
+ QuantizeSHBframegain_fx( st_fx, &GainFrame_fx, st_fx->extl, 0, &hRF->RF_bwe_gainFr_ind, 0 );
+#else
QuantizeSHBframegain_fx( st_fx, &GainFrame_fx, st_fx->extl, 0, &hRF->RF_bwe_gainFr_ind );
+#endif
/* Adjust the subframe and frame gain of the synthesized SHB signal */
/* Scale the shaped excitation */
@@ -2823,9 +3079,9 @@ void swb_tbe_enc_fx(
/*======================================================================================*/
void swb_tbe_enc_ivas_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
+ Encoder_State *st_fx, /* i/o: encoder state structure */
STEREO_ICBWE_ENC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */
- Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q_shb */
+ Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */
Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation 2 * Q_new */
const Word16 voice_factors_fx[], /* i : voicing factors Q15 */
Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE Q_white_exc */
@@ -2933,7 +3189,9 @@ void swb_tbe_enc_ivas_fx(
move16();
TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD;
+#ifndef HARMONIZE_TBE
RF_ENC_HANDLE hRF = st_fx->hRF;
+#endif
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
/* init and buffers set up */
@@ -3104,7 +3362,11 @@ void swb_tbe_enc_ivas_fx(
/* Input signal filtering in case of tonal sounds in the high band
gain Frame smoothing and attenuation control */
+#ifdef HARMONIZE_TBE
+ gainFrSmooth_En_fx( st_fx, shb_frame_fx, lpc_shb_fx, lsf_shb_fx, &MA_lsp_shb_spacing, &frGainAttenuate, &frGainSmoothEn );
+#else
gainFrSmooth_En_ivas_fx( st_fx, shb_frame_fx, lpc_shb_fx, lsf_shb_fx, &MA_lsp_shb_spacing, &frGainAttenuate, &frGainSmoothEn );
+#endif
test();
test();
@@ -3138,7 +3400,11 @@ void swb_tbe_enc_ivas_fx(
ELSE
{
/* LSF quantization (21 bits) */
+#ifdef HARMONIZE_TBE
+ Quant_BWE_LSF_fx( hBstr, st_fx->hBWE_TD, st_fx->codec_mode, lsf_shb_fx, lsf_shb_fx, st_fx->extl_brate );
+#else
Quant_BWE_LSF_ivas_fx( hBstr, st_fx->hBWE_TD, st_fx->codec_mode, lsf_shb_fx, lsf_shb_fx, st_fx->extl_brate );
+#endif
}
/* space the lsfs to assert a minimum distance */
@@ -3312,7 +3578,11 @@ void swb_tbe_enc_ivas_fx(
}
shb_ener_sf_Q31 = Mult_32_16( shb_ener_sf_Q31, 102 /*0.003125f Q15*/ );
shb_ener_sf_Q31 = L_add( 1l /*1 Q0*/, shb_ener_sf_Q31 );
+#ifdef HARMONIZE_TBE
+ Quant_shb_ener_sf_fx( st_fx, &shb_ener_sf_Q31, shl( Q_shb, 1 ) );
+#else
Quant_shb_ener_sf_ivas_fx( st_fx, &shb_ener_sf_Q31, shl( Q_shb, 1 ) );
+#endif
/* -------- calculate the residuals using the FOUR subframe LPCs -------- */
set16_fx( shb_res_fx, 0, L_FRAME16k );
@@ -3359,7 +3629,11 @@ void swb_tbe_enc_ivas_fx(
move16();
}
+#ifdef HARMONIZE_TBE
+ Quant_shb_res_gshape_fx( st_fx, shb_res_gshape_fx );
+#else
Quant_shb_res_gshape_ivas_fx( st_fx, shb_res_gshape_fx );
+#endif
}
ELSE IF( EQ_32( st_fx->extl_brate, SWB_TBE_1k10 ) || EQ_32( st_fx->extl_brate, SWB_TBE_1k75 ) )
{
@@ -3986,11 +4260,7 @@ void swb_tbe_enc_ivas_fx(
FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ )
{
// GainShape[i] = ( 1 - feedback ) * GainShape[i] + feedback * GainShape_Interp[i];
-#ifdef FIX_2254_IMPROV_COMPLEXITY_BE
GainShape_fx[i] = extract_h( L_mac( L_mult( sub( MAX16B, feedback ), GainShape_fx[i] ), feedback, GainShape_Interp_fx[i] ) );
-#else
- GainShape_fx[i] = extract_h( L_add( L_mult( sub( MAX16B, feedback ), GainShape_fx[i] ), L_mult( feedback, GainShape_Interp_fx[i] ) ) );
-#endif
move16();
}
}
@@ -4071,7 +4341,11 @@ void swb_tbe_enc_ivas_fx(
}
/* Quantization of the gain shape parameter */
+#ifdef HARMONIZE_TBE
+ QuantizeSHBsubgains_fx( st_fx, GainShape_fx, st_fx->extl );
+#else
QuantizeSHBsubgains_ivas_fx( st_fx, GainShape_fx, st_fx->extl );
+#endif
/* Compute the power of gains away from the peak gain after quantization */
IF( st_fx->element_mode > EVS_MONO )
@@ -4104,11 +4378,7 @@ void swb_tbe_enc_ivas_fx(
FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ )
{
// GainShape[i] = ( 1 - feedback ) * GainShape[i * NUM_SHB_SUBGAINS] + feedback * GainShape_Interp[i];
-#ifdef FIX_2254_IMPROV_COMPLEXITY_BE
GainShape_fx[i] = extract_h( L_mac( L_mult( sub( MAX16B, feedback ), GainShape_fx[i * NUM_SHB_SUBGAINS] ), feedback, GainShape_Interp_fx[i] ) ); // Q15
-#else
- GainShape_fx[i] = extract_h( L_add( L_mult( sub( MAX16B, feedback ), GainShape_fx[i * NUM_SHB_SUBGAINS] ), L_mult( feedback, GainShape_Interp_fx[i] ) ) ); // Q15
-#endif
move16();
}
@@ -4121,8 +4391,13 @@ void swb_tbe_enc_ivas_fx(
}
/* Estimate the gain parameter */
+#ifdef HARMONIZE_TBE
+ EstimateSHBFrameGain_fx( st_fx->element_mode, SHB_OVERLAP_LEN, shb_frame_fx, Q_shb, shaped_shb_excitation_fx, Q_bwe_exc,
+ GainShape_fx, &GainFrame_fx, window_shb_fx, subwin_shb_fx, n_subfr_saturation );
+#else
EstimateSHBFrameGain_ivas_fx( SHB_OVERLAP_LEN, shb_frame_fx, Q_shb, shaped_shb_excitation_fx, Q_bwe_exc,
GainShape_fx, &GainFrame_fx, window_shb_fx, subwin_shb_fx, n_subfr_saturation );
+#endif
IF( EQ_16( st_fx->tec_tfa, 1 ) )
{
@@ -4367,6 +4642,9 @@ void swb_tbe_enc_ivas_fx(
}
/* Quantization of the frame gain parameter */
+#ifdef HARMONIZE_TBE
+ QuantizeSHBframegain_fx( st_fx, &GainFrame_fx, st_fx->extl, 0, NULL, ( EQ_32( st_fx->extl_brate, SWB_TBE_1k10 ) || EQ_32( st_fx->extl_brate, SWB_TBE_1k75 ) ) ? 1 : 0 );
+#else
IF( st_fx->rf_mode )
{
QuantizeSHBframegain_ivas_fx( st_fx, &GainFrame_fx, st_fx->extl, 0, &hRF->RF_bwe_gainFr_ind, 0 );
@@ -4375,6 +4653,7 @@ void swb_tbe_enc_ivas_fx(
{
QuantizeSHBframegain_ivas_fx( st_fx, &GainFrame_fx, st_fx->extl, 0, NULL, ( EQ_32( st_fx->extl_brate, SWB_TBE_1k10 ) || EQ_32( st_fx->extl_brate, SWB_TBE_1k75 ) ) ? 1 : 0 );
}
+#endif
IF( hStereoICBWE != NULL )
{
@@ -4470,7 +4749,11 @@ void swb_tbe_enc_ivas_fx(
/* RETURN ARGUMENTS : */
/* _ None */
/*--------------------------------------------------------------------------*/
+
static void EstimateSHBFrameGain_fx(
+#ifdef HARMONIZE_TBE
+ const Word16 element_mode, /* i : element mode */
+#endif
const Word16 length, /* i : SHB overlap length */
const Word16 *oriSHB, /* i : target original SHB frame Q(Q_oriSHB) */
const Word16 Q_oriSHB, /* i : Q of arget original SHB frame */
@@ -4482,6 +4765,7 @@ static void EstimateSHBFrameGain_fx(
const Word16 *subwin_shb_local, /* i : SHB subframe window Q15 */
const Word16 n_subfr_saturation /* i : Number of subframes which saturated in GainShape oriNrg calculation */
)
+#ifndef HARMONIZE_TBE
{
const Word16 *skip;
Word16 i, j, k, l_shb_lahead, l_frame;
@@ -4666,6 +4950,7 @@ static void EstimateSHBFrameGain_ivas_fx(
const Word16 *subwin_shb_local, /* i : SHB subframe window Q15 */
const Word16 n_subfr_saturation /* i : Number of subframes which saturated in GainShape oriNrg calculation */
)
+#endif
{
const Word16 *skip;
Word16 i, j, k, l_shb_lahead, l_frame;
@@ -4705,34 +4990,70 @@ static void EstimateSHBFrameGain_ivas_fx(
move16();
j = skip[0];
move16();
- FOR( k = 0; k < length / 2; k++ )
- {
- sum_gain = mult_r( subwin_shb_local[2 * k + 2], subgain[0] ); /* Q15 */
- mod_syn[j + k] = L_mult0( synSHB[j + k], sum_gain );
- move32(); /* Q(16+Q_synSHB) */
- mod_syn[j + k + length / 2] = L_mult0( synSHB[j + k + length / 2], subgain[0] );
- move32(); /* Q(16+Q_synSHB) */
- }
- FOR( i = 1; i < NUM_SHB_SUBFR / 2; i++ )
+#ifdef HARMONIZE_TBE
+ IF( element_mode == EVS_MONO )
{
- j = skip[i];
- move16();
- FOR( k = 0; k < length; k++ )
+ FOR( k = 0; k < length / 2; k++ )
{
- L_tmp = L_mult0( subwin_shb_local[k + 1], subgain[i] ); /* Q30 */
- sum_gain = round_fx( L_mac0( L_tmp, subwin_shb_local[length - k - 1], subgain[i - 1] ) ); /* Q14 */
- mod_syn[j + k] = L_mult( sum_gain, synSHB[j + k] );
+ sum_gain = mult_r( subwin_shb_local[2 * k + 2], subgain[0] ); /* Q15 */
+ mod_syn[j + k] = L_mult( synSHB[j + k], sum_gain );
+ move32(); /* Q(16+Q_synSHB) */
+ mod_syn[j + k + length / 2] = L_mult( synSHB[j + k + length / 2], subgain[0] );
+ move32(); /* Q(16+Q_synSHB) */
+ }
+ FOR( i = 1; i < NUM_SHB_SUBFR / 2; i++ )
+ {
+ j = skip[i];
+ move16();
+ FOR( k = 0; k < length; k++ )
+ {
+ L_tmp = L_mult0( subwin_shb_local[k + 1], subgain[i] ); /* Q30 */
+ sum_gain = round_fx( L_mac0( L_tmp, subwin_shb_local[length - k - 1], subgain[i - 1] ) ); /* Q14 */
+ mod_syn[j + k] = L_shl( L_mult( sum_gain, synSHB[j + k] ), 1 );
+ move32(); /* Q(16+Q_synSHB) */
+ }
+ }
+ FOR( k = 0; k < length / 2; k++ )
+ {
+ j = skip[i];
+ move16();
+ sum_gain = mult_r( subwin_shb_fx[length - 2 * k - 2], subgain[i - 1] ); /* Q15 */
+ mod_syn[j + k] = L_mult( synSHB[j + k], sum_gain );
move32(); /* Q(16+Q_synSHB) */
}
}
- FOR( k = 0; k < length / 2; k++ )
+ ELSE
+#endif
{
- j = skip[i];
- move16();
- sum_gain = mult_r( subwin_shb_fx[length - 2 * k - 2], subgain[i - 1] ); /* Q15 */
- mod_syn[j + k] = L_mult0( synSHB[j + k], sum_gain );
- move32(); /* Q(16+Q_synSHB) */
+ FOR( k = 0; k < length / 2; k++ )
+ {
+ sum_gain = mult_r( subwin_shb_local[2 * k + 2], subgain[0] ); /* Q15 */
+ mod_syn[j + k] = L_mult0( synSHB[j + k], sum_gain );
+ move32(); /* Q(16+Q_synSHB) */
+ mod_syn[j + k + length / 2] = L_mult0( synSHB[j + k + length / 2], subgain[0] );
+ move32(); /* Q(16+Q_synSHB) */
+ }
+ FOR( i = 1; i < NUM_SHB_SUBFR / 2; i++ )
+ {
+ j = skip[i];
+ move16();
+ FOR( k = 0; k < length; k++ )
+ {
+ L_tmp = L_mult0( subwin_shb_local[k + 1], subgain[i] ); /* Q30 */
+ sum_gain = round_fx( L_mac0( L_tmp, subwin_shb_local[length - k - 1], subgain[i - 1] ) ); /* Q14 */
+ mod_syn[j + k] = L_mult( sum_gain, synSHB[j + k] );
+ move32(); /* Q(16+Q_synSHB) */
+ }
+ }
+ FOR( k = 0; k < length / 2; k++ )
+ {
+ j = skip[i];
+ move16();
+ sum_gain = mult_r( subwin_shb_fx[length - 2 * k - 2], subgain[i - 1] ); /* Q15 */
+ mod_syn[j + k] = L_mult0( synSHB[j + k], sum_gain );
+ move32(); /* Q(16+Q_synSHB) */
+ }
}
}
ELSE
@@ -4742,45 +5063,93 @@ static void EstimateSHBFrameGain_ivas_fx(
join_length = i_mult2( num_join, length );
j = 0;
move16();
- FOR( k = 0; k < length; k++ )
- {
- sum_gain = mult_r( subwin_shb_local[k + 1], subgain[0] ); /* Q15 */
- mod_syn[j] = L_mult0( synSHB[j], sum_gain );
- move32(); /* Q(16+Q_synSHB) */
- j++;
- }
- FOR( i = 0; i < NUM_SHB_SUBGAINS - 1; i++ )
+
+#ifdef HARMONIZE_TBE
+ IF( element_mode == EVS_MONO )
{
- FOR( k = 0; k < join_length - length; k++ )
+ FOR( k = 0; k < length; k++ )
{
- mod_syn[j] = L_mult0( synSHB[j], subgain[i * num_join] );
+ sum_gain = mult_r( subwin_shb_local[k + 1], subgain[0] ); /* Q15 */
+ mod_syn[j] = L_mult( synSHB[j], sum_gain );
move32(); /* Q(16+Q_synSHB) */
j++;
}
+ FOR( i = 0; i < NUM_SHB_SUBGAINS - 1; i++ )
+ {
+ FOR( k = 0; k < join_length - length; k++ )
+ {
+ mod_syn[j] = L_mult( synSHB[j], subgain[i * num_join] );
+ move32(); /* Q(16+Q_synSHB) */
+ j++;
+ }
+ FOR( k = 0; k < length; k++ )
+ {
+ L_tmp = L_mult0( subwin_shb_local[length - k - 1], subgain[i * num_join] );
+ tmp = round_fx( L_mac0( L_tmp, subwin_shb_local[k + 1], subgain[( i + 1 ) * num_join] ) ); /* Q14 */
+ mod_syn[j] = L_shl( L_mult( tmp, synSHB[j] ), 1 );
+ move32(); /* Q(16+Q_synSHB) */
+ j++;
+ }
+ }
+ FOR( k = 0; k < join_length - length; k++ )
+ {
+ mod_syn[j] = L_mult( synSHB[j], subgain[( NUM_SHB_SUBGAINS - 1 ) * num_join] );
+ move32(); /* Q(16+Q_synSHB)*/
+ j++;
+ }
FOR( k = 0; k < length; k++ )
{
- L_tmp = L_mult0( subwin_shb_local[length - k - 1], subgain[i * num_join] );
- tmp = round_fx( L_mac0( L_tmp, subwin_shb_local[k + 1], subgain[( i + 1 ) * num_join] ) ); /* Q14 */
+ tmp = mult_r( subwin_shb_local[length - k - 1], subgain[( NUM_SHB_SUBGAINS - 1 ) * num_join] ); /* Q15 */
mod_syn[j] = L_mult( tmp, synSHB[j] );
- move32(); /* Q(16+Q_synSHB) */
+ move32(); /* Q(16+Q_synSHB ) */
j++;
}
}
- FOR( k = 0; k < join_length - length; k++ )
- {
- mod_syn[j] = L_mult0( synSHB[j], subgain[( NUM_SHB_SUBGAINS - 1 ) * num_join] );
- move32(); /* Q(16+Q_synSHB)*/
- j++;
- }
- FOR( k = 0; k < length; k++ )
+ ELSE
+#endif
{
- tmp = mult_r( subwin_shb_local[length - k - 1], subgain[( NUM_SHB_SUBGAINS - 1 ) * num_join] ); /* Q15 */
- mod_syn[j] = L_mult0( tmp, synSHB[j] );
- move32(); /* Q(16+Q_synSHB ) */
- j++;
+ FOR( k = 0; k < length; k++ )
+ {
+ sum_gain = mult_r( subwin_shb_local[k + 1], subgain[0] ); /* Q15 */
+ mod_syn[j] = L_mult0( synSHB[j], sum_gain );
+ move32(); /* Q(16+Q_synSHB) */
+ j++;
+ }
+ FOR( i = 0; i < NUM_SHB_SUBGAINS - 1; i++ )
+ {
+ FOR( k = 0; k < join_length - length; k++ )
+ {
+ mod_syn[j] = L_mult0( synSHB[j], subgain[i * num_join] );
+ move32(); /* Q(16+Q_synSHB) */
+ j++;
+ }
+
+ FOR( k = 0; k < length; k++ )
+ {
+ L_tmp = L_mult0( subwin_shb_local[length - k - 1], subgain[i * num_join] );
+ tmp = round_fx( L_mac0( L_tmp, subwin_shb_local[k + 1], subgain[( i + 1 ) * num_join] ) ); /* Q14 */
+ mod_syn[j] = L_mult( tmp, synSHB[j] );
+ move32(); /* Q(16+Q_synSHB) */
+ j++;
+ }
+ }
+ FOR( k = 0; k < join_length - length; k++ )
+ {
+ mod_syn[j] = L_mult0( synSHB[j], subgain[( NUM_SHB_SUBGAINS - 1 ) * num_join] );
+ move32(); /* Q(16+Q_synSHB)*/
+ j++;
+ }
+ FOR( k = 0; k < length; k++ )
+ {
+ tmp = mult_r( subwin_shb_local[length - k - 1], subgain[( NUM_SHB_SUBGAINS - 1 ) * num_join] ); /* Q15 */
+ mod_syn[j] = L_mult0( tmp, synSHB[j] );
+ move32(); /* Q(16+Q_synSHB ) */
+ j++;
+ }
}
}
+
/* adjust frame energy */
oriNrg = L_deposit_l( 0 );
synNrg = L_deposit_l( 0 );
@@ -4790,14 +5159,14 @@ static void EstimateSHBFrameGain_ivas_fx(
sig = mult_r_sat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */
oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/
sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */
- synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB - 2*/
+ synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB / 2*Q_synSHB - 2*/
}
FOR( ; i < l_frame; i++ )
{
oriNrg = L_mac0_sat( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */
sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */
- synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/
+ synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB / 2*Q_oriSHB - 2*/
}
tmp = add( l_frame, l_shb_lahead );
@@ -4806,7 +5175,7 @@ static void EstimateSHBFrameGain_ivas_fx(
sig = mult_r_sat( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */
oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB */
sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */
- synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/
+ synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB / 2*Q_oriSHB - 2*/
}
IF( EQ_32( oriNrg, MAX_32 ) )
{
@@ -4829,7 +5198,17 @@ static void EstimateSHBFrameGain_ivas_fx(
oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */
}
}
- L_tmp = root_a_over_b_fx( oriNrg, shl( Q_oriSHB, 1 ), synNrg, sub( shl( Q_synSHB, 1 ), 2 ), &exp_out );
+
+#ifdef HARMONIZE_TBE
+ IF( element_mode == EVS_MONO )
+ {
+ L_tmp = root_a_over_b_fx( oriNrg, shl( Q_oriSHB, 1 ), synNrg, shl( Q_synSHB, 1 ), &exp_out );
+ }
+ ELSE
+#endif
+ {
+ L_tmp = root_a_over_b_fx( oriNrg, shl( Q_oriSHB, 1 ), synNrg, sub( shl( Q_synSHB, 1 ), 2 ), &exp_out );
+ }
exp_out = sub( exp_out, scaling );
frame_gain = L_shl_sat( L_tmp, sub( exp_out, 13 ) ); /* Q18 */
*GainFrame = frame_gain;
@@ -4839,7 +5218,10 @@ static void EstimateSHBFrameGain_ivas_fx(
}
-static Word32 pow_off_pk_fx( Word16 a[], Word16 len, Word16 step )
+static Word32 pow_off_pk_fx(
+ const Word16 a[],
+ const Word16 len,
+ const Word16 step )
{
Word16 i, j;
Word32 sum, L_tmp;
@@ -4865,7 +5247,10 @@ static Word32 pow_off_pk_fx( Word16 a[], Word16 len, Word16 step )
}
-static Word32 pow_off_pk_corrected_fx( Word16 a[], Word16 len, Word16 step )
+static Word32 pow_off_pk_corrected_fx(
+ const Word16 a[],
+ const Word16 len,
+ const Word16 step )
{
Word16 i, j;
Word32 sum, L_tmp;
@@ -5177,6 +5562,7 @@ static void EstimateSHBGainShape_fx(
/* RETURN ARGUMENTS : */
/* _ Word16 : index Q0 */
/*--------------------------------------------------------------------------*/
+
static Word16 closest_centroid_fx(
const Word16 *data, /* i : input data Qx*/
const Word16 *weights, /* i : weights */
@@ -5222,6 +5608,7 @@ static Word16 closest_centroid_fx(
/* PURPOSE : Determine a set of closest VQ centroids for a given input */
/* Gain shape is 4 dimensional */
/*--------------------------------------------------------------------------*/
+
static Word16 closest_centroid_lc_fx(
const Word16 *data, /* i : input data Qx*/
const Word16 *quantizer, /* i : quantizer table Qx*/
@@ -5401,7 +5788,7 @@ static void QuantizeSHBsubgains_fx(
return;
}
-
+#ifndef HARMONIZE_TBE
/*============================================================*/
/* FUNCTION : static void QuantizeSHBsubgains_ivas_fx() */
/*------------------------------------------------------------*/
@@ -5538,7 +5925,7 @@ static void QuantizeSHBsubgains_ivas_fx(
return;
}
-
+#endif
/*-------------------------------------------------------------------*
* Quant_shb_ener_sf_fx_fx()
@@ -5547,6 +5934,7 @@ static void QuantizeSHBsubgains_ivas_fx(
*-------------------------------------------------------------------*/
static void Quant_shb_ener_sf_fx(
+#ifndef HARMONIZE_TBE
Encoder_State *st_fx, /* i/o: encoder state structure */
Word32 *shb_ener_sf_Q31, /* i/o: super highband subframe energies */
Word16 Q_ener )
@@ -5603,9 +5991,10 @@ static void Quant_shb_ener_sf_fx(
*-------------------------------------------------------------------*/
static void Quant_shb_ener_sf_ivas_fx(
+#endif
Encoder_State *st_fx, /* i/o: encoder state structure */
Word32 *shb_ener_sf_Q31, /* i/o: super highband subframe energies Q_ener */
- Word16 Q_ener )
+ const Word16 Q_ener )
{
Word16 idxSubEner_fx;
Word16 temp_shb_ener_sf_fx;
@@ -5613,6 +6002,9 @@ static void Quant_shb_ener_sf_ivas_fx(
Word32 L_tmp1, L_tmp;
Word32 sum;
Word16 tmp;
+#ifdef HARMONIZE_TBE
+ Word16 Q_fac;
+#endif
TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD;
/* shb_ener_sf_fx[0] = log10(0.003125*shb_ener_sf[0:319]); */
@@ -5621,21 +6013,48 @@ static void Quant_shb_ener_sf_ivas_fx(
exp = norm_l( sum );
frac = Log2_norm_lc( L_shl( sum, exp ) );
- exp = sub( 30, add( exp, Q_ener ) ); /* 30-(exp+Q_ener ) */
- L_tmp1 = Mpy_32_16( exp, frac, 308 ); /* 308=LOG10(2) in Q10, so answer Ltmp in Q11 */
+ exp = sub( 30, add( exp, Q_ener ) ); /* 30-(exp+Q_ener ) */
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ L_tmp1 = Mpy_32_16( exp, frac, 617 ); /* 2466=LOG10(2) in Q11, so answer Ltmp in Q12 */
- tmp = extract_l( L_tmp1 ); /* tmp in Q11 */
+ tmp = round_fx( L_shl( L_tmp1, 30 - 14 ) ); /* tmp in Q12 */
- temp_shb_ener_sf_fx = 0;
- move16();
- idxSubEner_fx = usquant_fx( tmp, &temp_shb_ener_sf_fx, 0, 43, 1 << NUM_BITS_SHB_ENER_SF ); /* 43 = 0.042f in Q10 = Qin-1 */
- /* o: temp_shb_ener_sf_fx in Q11 */
+ temp_shb_ener_sf_fx = 0;
+ move16();
+ idxSubEner_fx = usquant_fx( tmp, &temp_shb_ener_sf_fx, 0, 86, shl( 1, NUM_BITS_SHB_ENER_SF ) ); /* 86 = 0.042f in Q11 = Qin-1 */
+ /* o: temp_shb_ener_sf_fx in Q12 */
+
+ Q_fac = -Q10;
+ move16();
+ }
+ ELSE
+#endif
+ {
+ L_tmp1 = Mpy_32_16( exp, frac, 308 ); /* 308=LOG10(2) in Q10, so answer Ltmp in Q11 */
+
+ tmp = extract_l( L_tmp1 ); /* tmp in Q11 */
+
+ temp_shb_ener_sf_fx = 0;
+ move16();
+ idxSubEner_fx = usquant_fx( tmp, &temp_shb_ener_sf_fx, 0, 43, 1 << NUM_BITS_SHB_ENER_SF ); /* 43 = 0.042f in Q10 = Qin-1 */
+ /* o: temp_shb_ener_sf_fx in Q11 */
+#ifdef HARMONIZE_TBE
+ Q_fac = -Q9;
+ move16();
+#endif
+ }
/* shb_ener_sf_fx[0] = pow(10.0, temp_shb_ener_sf_fx ); */
/* = pow(2, 3.321928*temp_shb_ener_sf_fx) */
- L_tmp = L_mult( temp_shb_ener_sf_fx, 27213 ); /* 3.321928 in Q13 -> L_tmp in Q11+Q13+1 = Q25 */
- L_tmp = L_shl( L_tmp, -9 ); /* bring L_tmp from Q25 to Q16 */
- frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent */
+ L_tmp = L_mult( temp_shb_ener_sf_fx, 27213 ); /* 3.321928 in Q13 -> L_tmp in Q12/Q11+Q13+1 = Q26/Q25 */
+#ifdef HARMONIZE_TBE
+ L_tmp = L_shl( L_tmp, Q_fac ); /* bring L_tmp from Q26/Q25 to Q16 */
+#else
+ L_tmp = L_shl( L_tmp, -9 ); /* bring L_tmp from Q25 to Q16 */
+#endif
+ frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent */
L_tmp = Pow2( 14, frac );
*shb_ener_sf_Q31 = L_shl( L_tmp, add( sub( exp, 14 ), Q_ener ) ); /* In Q_ener */
move32();
@@ -5658,6 +6077,7 @@ static void Quant_shb_ener_sf_ivas_fx(
*-------------------------------------------------------------------*/
static void Quant_shb_res_gshape_fx(
+#ifndef HARMONIZE_TBE
Encoder_State *st_fx, /* i/o: encoder state structure */
Word16 shb_res_gshape_fx[] /* i/o: super highband gain shapes Q14 */
)
@@ -5685,7 +6105,6 @@ static void Quant_shb_res_gshape_fx(
return;
}
-
/*-------------------------------------------------------------------*
* Quant_shb_res_gshape_ivas_fx()
*
@@ -5693,6 +6112,7 @@ static void Quant_shb_res_gshape_fx(
*-------------------------------------------------------------------*/
static void Quant_shb_res_gshape_ivas_fx(
+#endif
Encoder_State *st, /* i/o: encoder state structure */
Word16 shb_res_gshape_fx[] /* i/o: super highband gain shapes Q14 */
)
@@ -5745,6 +6165,7 @@ static void Quant_shb_res_gshape_ivas_fx(
/*==========================================================================*/
static void QuantizeSHBframegain_fx(
+#ifndef HARMONIZE_TBE
Encoder_State *st_fx, /* i/o: encoder state structure */
Word32 *GainFrame, /* i/o: Gain Q18 */
const Word16 extl, /* i : extension layer */
@@ -5912,6 +6333,7 @@ return;
/*==========================================================================*/
static void QuantizeSHBframegain_ivas_fx(
+#endif
Encoder_State *st_fx, /* i/o: encoder state structure */
Word32 *GainFrame, /* i/o: Gain Q18 */
const Word16 extl, /* i : extension layer */
@@ -5940,11 +6362,25 @@ static void QuantizeSHBframegain_ivas_fx(
singlevectortest_gain_fx( GainFrame, 1,
1 << NUM_BITS_SHB_FrameGain_LBR_WB, &idxFrameGain,
&Q_GainFrame, SHBCB_FrameGain16_fx );
- test();
- IF( GT_64( W_deposit32_l( Q_GainFrame ), W_shl( W_mult_32_16( *GainFrame, 17367 ), 15 ) ) && idxFrameGain > 0 ) /* 1.06 = +0.5 dB */
+
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
{
- idxFrameGain--;
- Q_GainFrame = L_add( SHBCB_FrameGain16_fx[idxFrameGain], 0 ); /* Q18 */
+ IF( GT_32( Q_GainFrame, L_shl( Mult_32_16( *GainFrame, 17367 ), 1 ) ) && idxFrameGain > 0 ) /* 1.06 = +0.5 dB */
+ {
+ idxFrameGain--;
+ Q_GainFrame = L_add( SHBCB_FrameGain16_fx[idxFrameGain], 0 ); /* Q18 */
+ }
+ }
+ ELSE
+#endif
+ {
+ test();
+ IF( GT_64( W_deposit32_l( Q_GainFrame ), W_shl( W_mult_32_16( *GainFrame, 17367 ), 15 ) ) && idxFrameGain > 0 ) /* 1.06 = +0.5 dB */
+ {
+ idxFrameGain--;
+ Q_GainFrame = L_add( SHBCB_FrameGain16_fx[idxFrameGain], 0 ); /* Q18 */
+ }
}
IF( EQ_16( st_fx->codec_mode, MODE2 ) )
@@ -6150,6 +6586,7 @@ return;
/* RETURN ARGUMENTS : */
/* _ None */
/*------------------------------------------------------------*/
+
static void determine_gain_weights_fx(
const Word32 *gain, /* i : Gain parameter Q18 */
Word16 *weights, /* o : gain weights Q12/Q6*/
@@ -6214,6 +6651,7 @@ static void determine_gain_weights_fx(
/* RETURN ARGUMENTS : */
/* _ None */
/*------------------------------------------------------------------------------*/
+
static void singlevectortest_gain_fx(
const Word32 *inp, /* i : input gain vector Q18*/
const Word16 dimen, /* i : dimension of the input vector */
@@ -6282,6 +6720,7 @@ static void singlevectortest_gain_fx(
/* RETURN ARGUMENTS : */
/* _ None */
/*------------------------------------------------------------------------------*/
+
static void return_M_Least_fx_GainFrame(
const Word32 *inp, /* i: input Q18*/
const Word32 *codebook, /* i: codebook Q18*/
@@ -6518,6 +6957,7 @@ static Word16 Find_LSF_grid_fx(
*
* Gain frame smoothing and attenuation control
*-------------------------------------------------------------------*/
+#ifndef HARMONIZE_TBE
static void gainFrSmooth_En_fx( Encoder_State *st_fx,
Word16 *shb_frame_fx,
const Word16 *lpc_shb_fx,
@@ -6640,13 +7080,20 @@ static void gainFrSmooth_En_fx( Encoder_State *st_fx,
*
* Gain frame smoothing and attenuation control
*-------------------------------------------------------------------*/
-static void gainFrSmooth_En_ivas_fx( Encoder_State *st_fx,
- Word16 *shb_frame_fx /* Q_in */,
- const Word16 *lpc_shb_fx /* Q12 */,
- const Word16 *lsp_shb_fx /* Q15 */,
- Word16 *MA_lsp_shb_spacing /* Q15 */,
- Word16 *frGainAttenuate /* Q0 */,
- Word16 *frGainSmoothEn /* Q0 */ )
+#endif
+
+#ifdef HARMONIZE_TBE
+static void gainFrSmooth_En_fx(
+#else
+static void gainFrSmooth_En_ivas_fx(
+#endif
+ Encoder_State *st_fx,
+ Word16 *shb_frame_fx /* Q_in */,
+ const Word16 *lpc_shb_fx /* Q12 */,
+ const Word16 *lsp_shb_fx /* Q15 */,
+ Word16 *MA_lsp_shb_spacing /* Q15 */,
+ Word16 *frGainAttenuate /* Q0 */,
+ Word16 *frGainSmoothEn /* Q0 */ )
{
Word16 temp_shb_frame[L_FRAME16k + L_SHB_LAHEAD];
Word32 lsp_slow_evol_rate, lsp_fast_evol_rate;
@@ -6694,8 +7141,18 @@ static void gainFrSmooth_En_ivas_fx( Encoder_State *st_fx,
/* estimate the mean square error in lsps from current frame to past frames */
tempQ15_1 = sub( lsp_shb_fx[i], hBWE_TD->lsp_shb_slow_interpl_fx[i] );
tempQ15_2 = sub( lsp_shb_fx[i], hBWE_TD->lsp_shb_fast_interpl_fx[i] );
- lsp_slow_evol_rate = BASOP_Util_Add_Mant32Exp( lsp_slow_evol_rate, lsp_slow_evol_rate_e, L_mult( tempQ15_1, tempQ15_1 ), 0, &lsp_slow_evol_rate_e );
- lsp_fast_evol_rate = BASOP_Util_Add_Mant32Exp( lsp_fast_evol_rate, lsp_fast_evol_rate_e, L_mult( tempQ15_2, tempQ15_2 ), 0, &lsp_fast_evol_rate_e );
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO )
+ {
+ lsp_slow_evol_rate = L_mac( lsp_slow_evol_rate, tempQ15_1, tempQ15_1 );
+ lsp_fast_evol_rate = L_mac( lsp_fast_evol_rate, tempQ15_2, tempQ15_2 );
+ }
+ ELSE
+#endif
+ {
+ lsp_slow_evol_rate = BASOP_Util_Add_Mant32Exp( lsp_slow_evol_rate, lsp_slow_evol_rate_e, L_mult( tempQ15_1, tempQ15_1 ), 0, &lsp_slow_evol_rate_e );
+ lsp_fast_evol_rate = BASOP_Util_Add_Mant32Exp( lsp_fast_evol_rate, lsp_fast_evol_rate_e, L_mult( tempQ15_2, tempQ15_2 ), 0, &lsp_fast_evol_rate_e );
+ }
/* update the slow and fast interpolation lsps for next frame */
tempQ31 = L_mult( hBWE_TD->lsp_shb_slow_interpl_fx[i], 22937 /* 0.7f in Q15 */ );
@@ -6754,12 +7211,25 @@ static void gainFrSmooth_En_ivas_fx( Encoder_State *st_fx,
}
test();
- if ( ( BASOP_Util_Cmp_Mant32Exp( lsp_slow_evol_rate, lsp_slow_evol_rate_e, INV_1000_Q31, 0 ) < 0 ) && ( BASOP_Util_Cmp_Mant32Exp( lsp_fast_evol_rate, lsp_fast_evol_rate_e, 2147484l /*0.001f in Q31*/, 0 ) < 0 ) )
+#ifdef HARMONIZE_TBE
+ IF( st_fx->element_mode == EVS_MONO && LT_32( lsp_slow_evol_rate, INV_1000_Q31 ) && LT_32( lsp_fast_evol_rate, 2147484l /*0.001f Q31*/ ) )
{
*frGainSmoothEn = 1;
move16();
}
+ ELSE IF( st_fx->element_mode > EVS_MONO )
+#endif
+ {
+ test();
+ if ( ( BASOP_Util_Cmp_Mant32Exp( lsp_slow_evol_rate, lsp_slow_evol_rate_e, INV_1000_Q31, 0 ) < 0 ) && ( BASOP_Util_Cmp_Mant32Exp( lsp_fast_evol_rate, lsp_fast_evol_rate_e, 2147484l /*0.001f in Q31*/, 0 ) < 0 ) )
+ {
+ *frGainSmoothEn = 1;
+ move16();
+ }
+ }
}
+
+ return;
}
#define MAXINT32 MAX_32
@@ -7131,7 +7601,7 @@ static void LVQQuant_BWE_LSF_fx(
*
* Quantize super highband spectral envolope
*-------------------------------------------------------------------*/
-
+#ifndef HARMONIZE_TBE
static void Quant_BWE_LSF_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
@@ -7195,9 +7665,14 @@ static void Quant_BWE_LSF_fx(
return;
}
+#endif
+#ifdef HARMONIZE_TBE
+static void Quant_BWE_LSF_fx(
+#else
static void Quant_BWE_LSF_ivas_fx(
+#endif
BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
const Word16 codec_mode, /* i : codec mode */
@@ -7281,10 +7756,11 @@ static void Quant_BWE_LSF_ivas_fx(
*-------------------------------------------------------------------*/
void fb_tbe_enc_fx(
+#ifndef HARMONIZE_TBE
Encoder_State *st, /* i/o: encoder state structure */
const Word16 new_input[], /* i : input speech at 48 kHz sample rate */
const Word16 fb_exc[], /* i : FB excitation from the SWB part */
- Word16 Q_fb_exc )
+ const Word16 Q_fb_exc )
{
Word16 ratio;
Word16 tmp_vec[L_FRAME48k];
@@ -7313,10 +7789,7 @@ void fb_tbe_enc_fx(
Copy_Scale_sig( new_input, input_fhb, L_FRAME48k, exp_temp );
- elliptic_bpf_48k_generic_fx(
- st->element_mode,
- 0, // IsUpsampled3
- input_fhb, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx );
+ elliptic_bpf_48k_generic_fx( st->element_mode, 0, /* IsUpsampled3 */ input_fhb, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx );
Sample_Delay_HP = NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) - L_FRAME48k / 2;
IF( NE_16( st->last_extl, FB_TBE ) )
@@ -7405,11 +7878,12 @@ void fb_tbe_enc_fx(
}
void fb_tbe_enc_ivas_fx(
+#endif
Encoder_State *st, /* i/o: encoder state structure */
const Word16 new_input[], /* i : input speech at 48 kHz sample rate Q_new_input */
const Word16 fb_exc[], /* i : FB excitation from the SWB part Q_fb_exc */
- Word16 Q_fb_exc,
- Word16 Q_new_input )
+ const Word16 Q_fb_exc,
+ const Word16 Q_new_input )
{
Word16 ratio;
Word16 tmp_vec[L_FRAME48k];
@@ -7424,13 +7898,30 @@ void fb_tbe_enc_ivas_fx(
TD_BWE_ENC_HANDLE hBWE_TD = st->hBWE_TD;
Word16 q_diff, q_input_fhb;
Word64 temp1, temp2;
+#ifdef HARMONIZE_TBE
+ Word16 offset;
+
+ offset = 0;
+ move16();
+ if ( st->element_mode > EVS_MONO )
+ {
+ offset = NS2SA( 48000, DELAY_FIR_RESAMPL_NS );
+ }
+#endif
s_max_value = 0;
move16();
+#ifdef HARMONIZE_TBE
+ FOR( i = 0; i < add( L_FRAME48k, offset ); i++ )
+ {
+ s_max_value = s_max( s_max_value, abs_s( new_input[i - offset] ) );
+ }
+#else
FOR( i = 0; i < L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ); i++ )
{
s_max_value = s_max( s_max_value, abs_s( new_input[i - NS2SA( 48000, DELAY_FIR_RESAMPL_NS )] ) );
}
+#endif
exp_temp = norm_s( s_max_value );
if ( s_max_value == 0 )
{
@@ -7438,27 +7929,36 @@ void fb_tbe_enc_ivas_fx(
move16();
}
+#ifdef HARMONIZE_TBE
+ if ( st->element_mode == EVS_MONO )
+ {
+ exp_temp = sub( exp_temp, 1 );
+ }
+#endif
+
+#ifdef HARMONIZE_TBE
+ Copy_Scale_sig( new_input - offset, input_fhb_new, add( L_FRAME48k, offset ), exp_temp );
+#else
Copy_Scale_sig( new_input - NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_fhb_new, L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), exp_temp );
+#endif
exp_temp = add( exp_temp, Q_new_input );
+
IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) )
{
- elliptic_bpf_48k_generic_fx(
- st->element_mode,
- 0, // IsUpsampled3
- input_fhb_new, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx );
+ elliptic_bpf_48k_generic_fx( st->element_mode, 0, /* IsUpsampled3 */ input_fhb_new, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx );
}
ELSE
{
- elliptic_bpf_48k_generic_fx(
- st->element_mode,
- 0, // IsUpsampled3
- input_fhb_new + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx );
+#ifdef HARMONIZE_TBE
+ elliptic_bpf_48k_generic_fx( st->element_mode, 0, /* IsUpsampled3 */ input_fhb_new + offset, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx );
+#else
+ elliptic_bpf_48k_generic_fx( st->element_mode, 0, /* IsUpsampled3 */ input_fhb_new + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx );
+#endif
}
test();
IF( GT_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_SCE ) )
{
-
IF( EQ_16( st->L_frame, L_FRAME ) )
{
Sample_Delay_HP = NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ) - L_FRAME48k / 2;
@@ -7481,71 +7981,144 @@ void fb_tbe_enc_ivas_fx(
set16_fx( tmp_vec, 0, L_FRAME16k );
}
- q_diff = sub( exp_temp, hBWE_TD->old_input_fhb_fx_Q );
- Copy( hBWE_TD->old_input_fhb_fx, input_fhb, Sample_Delay_HP ); // hBWE_TD->old_input_fhb_fx_Q
- Copy( tmp_vec, input_fhb + Sample_Delay_HP, sub( L_FRAME48k, Sample_Delay_HP ) ); // exp_temp
- IF( q_diff > 0 )
+#ifdef HARMONIZE_TBE
+ IF( st->element_mode == EVS_MONO )
{
- scale_sig( input_fhb + Sample_Delay_HP, sub( L_FRAME48k, Sample_Delay_HP ), negate( q_diff ) ); // hBWE_TD->old_input_fhb_fx_Q
- q_input_fhb = hBWE_TD->old_input_fhb_fx_Q;
+ Word32 L_tmp, temp32, fb_exc_energy32;
+ Word16 tmp1;
+
+ Copy_Scale_sig( hBWE_TD->old_input_fhb_fx, hBWE_TD->old_input_fhb_fx, Sample_Delay_HP, sub( exp_temp, hBWE_TD->old_input_fhb_fx_Q ) );
+ hBWE_TD->old_input_fhb_fx_Q = exp_temp;
+ Copy( hBWE_TD->old_input_fhb_fx, input_fhb, Sample_Delay_HP );
+ Copy( tmp_vec, input_fhb + Sample_Delay_HP, L_FRAME48k - Sample_Delay_HP );
+ Copy( tmp_vec + L_FRAME48k - Sample_Delay_HP, hBWE_TD->old_input_fhb_fx, Sample_Delay_HP );
+ temp32 = sum2_fx_mod( input_fhb, L_FRAME48k / 2 ); /* Q11 */
+ temp32 = L_add_sat( temp32, L_shl_sat( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ) ) ); /* Q11 */
+ hBWE_TD->prev_fb_energy_fx = sum2_fx_mod( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); /*Q11*/
+ hBWE_TD->prev_fb_energy_fx_Q = sub( add( exp_temp, exp_temp ), 6 );
+ fb_exc_energy32 = sum2_fx_mod( fb_exc, L_FRAME16k ); /* Q(2*Q_fb_exc+1 -7) */
+
+ /*ratio = (float) sqrt( temp32 / fb_exc_energy );*/
+ L_tmp = L_max( 1, temp32 ); /*Q6*/
+ exp = norm_l( L_tmp );
+ tmp = extract_h( L_shl( L_tmp, exp ) );
+ exp = sub( sub( 31, sub( add( exp_temp, exp_temp ), 8 ) ), exp ); /* in Q15 (L_tmp in Q6)*/
+
+ exp2 = norm_l( fb_exc_energy32 );
+ tmp2 = extract_h( L_shl( fb_exc_energy32, exp2 ) );
+ tmp1 = sub( add( Q_fb_exc, Q_fb_exc ), 8 ); /*1 - 9*/
+ exp2 = sub( sub( 31, tmp1 ), exp2 ); /* in Q15 (L_tmp in Q6)*/
+
+ exp = sub( exp2, exp ); /* Denormalize and substract */
+ IF( GT_16( tmp2, tmp ) )
+ {
+ tmp2 = shr( tmp2, 1 );
+ exp = add( exp, 1 );
+ }
+ IF( 0 != tmp )
+ {
+ tmp = div_s( tmp2, tmp );
+ L_tmp = L_deposit_h( tmp );
+ L_tmp = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp)*/
+ L_tmp = L_max( L_shr_sat( L_tmp, sub( 31, exp ) ), 0x1 ); /* Q0 */
+ }
+ ELSE
+ {
+ L_tmp = 0;
+ }
+
+ /* idxGain = (short)( log2_f ((float)ratio) + 0.5f );
+ idxGain = max( 0, min(15,idxGain) ); */
+ ratio = 0;
move16();
+ IF( GE_32( L_tmp, 32768 ) )
+ {
+ idxGain = 15;
+ move16();
+ }
+ ELSE
+ {
+ ratio = extract_l( L_tmp );
+ idxGain = sub( 14, norm_s( ratio ) );
+ idxGain = s_max( 0, idxGain );
+ }
+
+ test();
+ test();
+ IF( GT_16( idxGain, 2 ) && LT_16( idxGain, 15 ) && GT_16( ratio, add( shl( 2, sub( idxGain, 1 ) ), shl( 2, sub( idxGain, 2 ) ) ) ) )
+ {
+ idxGain = add( idxGain, 1 );
+ }
}
ELSE
+#endif
{
- scale_sig( input_fhb, Sample_Delay_HP, q_diff ); // exp_temp
- q_input_fhb = exp_temp;
+ q_diff = sub( exp_temp, hBWE_TD->old_input_fhb_fx_Q );
+ Copy( hBWE_TD->old_input_fhb_fx, input_fhb, Sample_Delay_HP ); // hBWE_TD->old_input_fhb_fx_Q
+ Copy( tmp_vec, input_fhb + Sample_Delay_HP, sub( L_FRAME48k, Sample_Delay_HP ) ); // exp_temp
+ IF( q_diff > 0 )
+ {
+ scale_sig( input_fhb + Sample_Delay_HP, sub( L_FRAME48k, Sample_Delay_HP ), negate( q_diff ) ); // hBWE_TD->old_input_fhb_fx_Q
+ q_input_fhb = hBWE_TD->old_input_fhb_fx_Q;
+ move16();
+ }
+ ELSE
+ {
+ scale_sig( input_fhb, Sample_Delay_HP, q_diff ); // exp_temp
+ q_input_fhb = exp_temp;
+ move16();
+ }
+ Copy( tmp_vec + L_FRAME48k - Sample_Delay_HP, hBWE_TD->old_input_fhb_fx, Sample_Delay_HP );
+ hBWE_TD->old_input_fhb_fx_Q = exp_temp;
move16();
- }
- Copy( tmp_vec + L_FRAME48k - Sample_Delay_HP, hBWE_TD->old_input_fhb_fx, Sample_Delay_HP );
- hBWE_TD->old_input_fhb_fx_Q = exp_temp;
- move16();
- temp2 = sum2_fx_no_sat( input_fhb, L_FRAME48k / 2 ); // 2*q_input_fhb /* Q(2*Q_input_fhb-8) */
- temp2 = W_add( temp2, W_shl( hBWE_TD->prev_fb_energy_fx, sub( shl( q_input_fhb, 1 ), hBWE_TD->prev_fb_energy_fx_Q ) ) ); // 2*q_input_fhb
+ temp2 = sum2_fx_no_sat( input_fhb, L_FRAME48k / 2 ); // 2*q_input_fhb /* Q(2*Q_input_fhb-8) */
+ temp2 = W_add( temp2, W_shl( hBWE_TD->prev_fb_energy_fx, sub( shl( q_input_fhb, 1 ), hBWE_TD->prev_fb_energy_fx_Q ) ) ); // 2*q_input_fhb
- temp1 = sum2_fx_no_sat( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); // 2*q_input_fhb
- exp = W_norm( temp1 );
- temp1 = W_shl( temp1, exp ); // 2*q_input_fhb+exp
- hBWE_TD->prev_fb_energy_fx = W_extract_h( temp1 ); // 2*q_input_fhb+exp-32
- move32();
- hBWE_TD->prev_fb_energy_fx_Q = sub( add( shl( q_input_fhb, 1 ), exp ), 32 );
- move16();
+ temp1 = sum2_fx_no_sat( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); // 2*q_input_fhb
+ exp = W_norm( temp1 );
+ temp1 = W_shl( temp1, exp ); // 2*q_input_fhb+exp
+ hBWE_TD->prev_fb_energy_fx = W_extract_h( temp1 ); // 2*q_input_fhb+exp-32
+ move32();
+ hBWE_TD->prev_fb_energy_fx_Q = sub( add( shl( q_input_fhb, 1 ), exp ), 32 );
+ move16();
- fb_exc_energy = sum2_fx_no_sat( fb_exc, L_FRAME16k ); // 2*Q_fb_exc
+ fb_exc_energy = sum2_fx_no_sat( fb_exc, L_FRAME16k ); // 2*Q_fb_exc
- /*ratio = (float) sqrt( temp2 / fb_exc_energy );*/
- exp = sub( W_norm( temp2 ), 1 );
- tmp = extract_h( W_extract_h( W_shl( temp2, exp ) ) ); // 2*q_input_fhb+exp-48
- exp = sub( 63, add( shl( q_input_fhb, 1 ), exp ) ); // 15-(2*q_input_fhb+exp-48)
+ /*ratio = (float) sqrt( temp2 / fb_exc_energy );*/
+ exp = sub( W_norm( temp2 ), 1 );
+ tmp = extract_h( W_extract_h( W_shl( temp2, exp ) ) ); // 2*q_input_fhb+exp-48
+ exp = sub( 63, add( shl( q_input_fhb, 1 ), exp ) ); // 15-(2*q_input_fhb+exp-48)
- exp2 = W_norm( fb_exc_energy );
- tmp2 = extract_h( W_extract_h( W_shl( fb_exc_energy, exp2 ) ) ); // 2*Q_fb_exc+exp2-48
- exp2 = sub( 63, add( shl( Q_fb_exc, 1 ), exp2 ) ); // 15-(2*Q_fb_exc+exp2-48)
+ exp2 = W_norm( fb_exc_energy );
+ tmp2 = extract_h( W_extract_h( W_shl( fb_exc_energy, exp2 ) ) ); // 2*Q_fb_exc+exp2-48
+ exp2 = sub( 63, add( shl( Q_fb_exc, 1 ), exp2 ) ); // 15-(2*Q_fb_exc+exp2-48)
- ratio = 0;
- idxGain = 0;
- move16();
- move16();
- test();
- IF( tmp != 0 && tmp2 != 0 )
- {
- ratio = div_s( tmp, tmp2 ); // exp: exp-exp2
- exp = sub( exp, exp2 );
- /* ratio = (float) sqrt( temp2 / fb_exc_energy );
- idxGain = (short)( log2_f ((float)ratio) + 0.5f );
+ ratio = 0;
+ idxGain = 0;
+ move16();
+ move16();
+ test();
+ IF( tmp != 0 && tmp2 != 0 )
+ {
+ ratio = div_s( tmp, tmp2 ); // exp: exp-exp2
+ exp = sub( exp, exp2 );
+ /* ratio = (float) sqrt( temp2 / fb_exc_energy );
+ idxGain = (short)( log2_f ((float)ratio) + 0.5f );
- => idxGain = (short)( log2_f (sqrt( temp2 / fb_exc_energy )) + 0.5f )
- = (short)(log2f(sqrt(temp2 / fb_exc_energy)) + log2f(sqrt(2)))
- = (short)log2f(sqrt(2 * (temp2 / fb_exc_energy)))
- increase the exp of division result by one, two accommodate the multiplication with 2 in sqrt
- */
- exp = add( exp, 1 );
- ratio = Sqrt16( ratio, &exp );
- /* Since ratio always lie betwwen 16384 and 32767, subtract the Q of sqrt result from 14 to get the integral part of log value */
- idxGain = sub( exp, 1 ); // 14 - (15-exp)
+ => idxGain = (short)( log2_f (sqrt( temp2 / fb_exc_energy )) + 0.5f )
+ = (short)(log2f(sqrt(temp2 / fb_exc_energy)) + log2f(sqrt(2)))
+ = (short)log2f(sqrt(2 * (temp2 / fb_exc_energy)))
+ increase the exp of division result by one, two accommodate the multiplication with 2 in sqrt
+ */
+ exp = add( exp, 1 );
+ ratio = Sqrt16( ratio, &exp );
+ /* Since ratio always lie betwwen 16384 and 32767, subtract the Q of sqrt result from 14 to get the integral part of log value */
+ idxGain = sub( exp, 1 ); // 14 - (15-exp)
- /* idxGain = max( 0, min( 15, idxGain ) ); */
- idxGain = s_max( 0, s_min( 15, idxGain ) );
+ /* idxGain = max( 0, min( 15, idxGain ) ); */
+ idxGain = s_max( 0, s_min( 15, idxGain ) );
+ }
}
/* ratio = (float)(1 << idxGain);*/
@@ -7558,8 +8131,17 @@ void fb_tbe_enc_ivas_fx(
{
push_indice( st->hBstr, IND_FB_SLOPE, idxGain, 4 );
}
+
return;
}
+
+
+/*---------------------------------------------------------------------*
+ * tbe_write_bitstream()
+ *
+ * Write TBE bitstream.
+ *---------------------------------------------------------------------*/
+
void tbe_write_bitstream_fx(
Encoder_State *st_fx /* i/o: encoder state structure */
)
@@ -7586,7 +8168,6 @@ void tbe_write_bitstream_fx(
( ( EQ_16( st_fx->bwidth, SWB ) ) || ( EQ_16( st_fx->bwidth, FB ) ) ) )
{
/* LSF coefficients */
-
test();
IF( ( EQ_16( st_fx->rf_mode, 1 ) ) || EQ_32( st_fx->total_brate, ACELP_9k60 ) )
{
@@ -7643,6 +8224,12 @@ void tbe_write_bitstream_fx(
}
+/*---------------------------------------------------------------------*
+ * TBEreset_enc()
+ *
+ *
+ *---------------------------------------------------------------------*/
+
void TBEreset_enc_fx(
TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
const Word16 last_core, /* i : last core */
diff --git a/lib_enc/tcq_core_enc_fx.c b/lib_enc/tcq_core_enc_fx.c
index a3d355a2da492724869d59daabca37cbac2ba4db..517c1c0b49400fc77ded750bf8cb4924be12033e 100644
--- a/lib_enc/tcq_core_enc_fx.c
+++ b/lib_enc/tcq_core_enc_fx.c
@@ -491,489 +491,5 @@ ivas_error tcq_core_LR_enc_fx(
}
- return error;
-}
-
-ivas_error tcq_core_LR_enc_ivas_fx(
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- Word32 inp_vector_fx[], /* x5 */
- const Word32 coefs_norm_fx[], /* Q12 */
- Word32 coefs_quant_fx[], /* Q12 */
- const Word16 bit_budget, /* number of bits */
- const Word16 BANDS,
- const Word16 *sfm_start,
- const Word16 *sfm_end,
- const Word16 *sfmsize,
- Word32 *R_fx, /* Q16 */
- Word16 *npulses,
- Word16 *k_sort,
- const Word16 *p2a_flags,
- const Word16 p2a_bands,
- const Word16 *last_bitalloc,
- const Word16 input_frame,
- const Word16 adjustFlag,
- const Word16 is_transient )
-{
- Word16 i, j, k, size, nb_bytes;
-
- Word16 USQ_TCQ[NB_SFM]; /* TCQ is selected by default*/
- Word16 coefs_norm_dec_fx[L_FRAME32k]; /* New output buffer (TCQ+USQ)*/
- Word32 savedstates[TCQ_MAX_BAND_SIZE];
- ARCODEC arenc_fx, *parenc_fx;
- TCQ_BITSTREAM bs_fx, *pbs_fx;
- Word16 k_num[2];
- Word32 bit_surplus_fx[2];
-
- Word16 flag_wbnb = 0;
- Word16 lsbtcq_bits = TCQ_AMP;
- Word16 tcq_arbits = 2;
- Word16 nzb = 0;
- Word16 nzbands = 0;
- Word16 bcount = 0;
- Word32 bsub_fx = 0;
- move16();
- move16();
- move16();
- move16();
- move16();
- move16();
- move32();
- Word32 abuffer_fx[MAX_PULSES];
- Word16 mbuffer_fx[MAX_PULSES];
- Word32 sbuffer_fx[MAX_PULSES];
- Word16 dpath[280];
- Word32 Rk_sort_fx[NB_SFM];
- Word32 step_scale_fx[NB_SFM];
- Word16 pulses_fx, nzp_fx;
-
- Word32 gain_fx, crosscorr_fx, selfcorr_fx;
- Word16 hi, lo, exp;
- Word32 surplus_fx, delta_fx, est_frame_bits_fx;
-
- Word32 leftbits = 0;
- Word32 sepbits = 0;
- Word32 divider = 0;
- move32();
- move32();
- move32();
- ivas_error error;
-
- error = IVAS_ERR_OK;
- move16();
- set16_fx( dpath, 0, 280 );
- set32_fx( abuffer_fx, 0, MAX_PULSES );
- set32_fx( sbuffer_fx, 0, MAX_PULSES );
- set16_fx( mbuffer_fx, 0, MAX_PULSES );
- /* initialization */
- set32_fx( Rk_sort_fx, 0, NB_SFM );
- set16_fx( USQ_TCQ, 0, NB_SFM );
- set16_fx( coefs_norm_dec_fx, 0, L_FRAME32k );
-
- InitLSBTCQ_fx( &bcount );
-
- test();
- test();
- IF( LE_16( input_frame, L_FRAME16k ) && adjustFlag == 0 && is_transient == 0 )
- {
- flag_wbnb = 1;
- move16();
- lsbtcq_bits = 0;
- move16();
- tcq_arbits = 0;
- move16();
- }
-
- /* TCQ Index initialize */
- parenc_fx = &arenc_fx;
- pbs_fx = &bs_fx;
-
- pbs_fx->curPos = 7;
- move16();
- pbs_fx->numbits = L_deposit_l( 0 );
- pbs_fx->numByte = L_deposit_l( 0 );
- move32();
- move32();
- FOR( i = 0; i < MAX_SIZEBUF_PBITSTREAM; i++ )
- {
- pbs_fx->buf[i] = 0;
- move16();
- }
- ar_encoder_start_fx( parenc_fx, pbs_fx, L_deposit_l( bit_budget ) );
-
- /* Bits distribution analysis */
- FOR( i = 0; i < BANDS; i++ )
- {
- IF( GE_32( ar_div( R_fx[i], sfmsize[i] ), 49152 ) )
- {
- /* USQ used for high importance bands*/
- USQ_TCQ[i] = 1;
- move16();
- }
- ELSE
- {
- /* TCQ used for usual bands */
- USQ_TCQ[i] = 0;
- move16();
- }
-
- IF( R_fx[i] > 0 )
- {
- /* nzbands++; */
- nzbands = add( nzbands, 1 );
- }
- }
-
- FOR( j = 0; j < BANDS; j++ )
- {
- IF( R_fx[j] > 0 )
- {
- nzb = add( nzb, 1 );
- }
- }
-
- bsub_fx = L_shl( add( tcq_arbits, lsbtcq_bits ), 16 ); /* Q16 */
- IF( bsub_fx > 0 )
- {
- bsub_fx = L_add( bsub_fx, 2048 );
- }
- FOR( j = BANDS - 1; j >= 0; j-- )
- {
- IF( R_fx[j] > 0 )
- {
- R_fx[j] = L_sub( R_fx[j], ar_div( bsub_fx, nzb ) );
- move32();
-
- IF( R_fx[j] < 0 )
- {
- bsub_fx = L_sub( bsub_fx, L_add( ar_div( bsub_fx, nzb ), R_fx[j] ) );
- R_fx[j] = L_deposit_l( 0 );
- move32();
- }
- ELSE
- {
- bsub_fx = L_sub( bsub_fx, ar_div( bsub_fx, nzb ) );
- }
- /* nzb--; */
- nzb = sub( nzb, 1 );
- }
- }
-
- /* Sort the bit allocation table (R) in ascending order, figure out number of pulses per band */
- srt_vec_ind_fx( R_fx, Rk_sort_fx, k_sort, BANDS );
-
- /* Quantize spectral band shapes using TCQ */
- /* Select ISC */
- set32_fx( coefs_quant_fx, 0, add( sfm_end[BANDS - 1], 1 ) );
- Copy32( coefs_norm_fx, coefs_quant_fx, add( sfm_end[BANDS - 1], 1 ) );
-
- delta_fx = L_deposit_l( 0 );
- est_frame_bits_fx = L_deposit_l( 0 );
-
- test();
- test();
- IF( LE_16( input_frame, L_FRAME16k ) && adjustFlag == 0 && is_transient == 0 )
- {
- surplus_fx = -131072;
- move32();
- bit_allocation_second_fx( R_fx, Rk_sort_fx, BANDS, sfmsize, k_sort, k_num, p2a_flags, p2a_bands, last_bitalloc, input_frame );
-
- nzbands = 0;
- move16();
- FOR( j = 0; j < BANDS; j++ )
- {
- test();
- IF( NE_16( j, k_num[0] ) && NE_16( j, k_num[1] ) )
- {
- leftbits = L_add( leftbits, R_fx[k_sort[j]] );
- IF( R_fx[k_sort[j]] > 0 )
- {
- nzbands = add( nzbands, 1 );
- }
- }
- ELSE
- {
- sepbits = L_add( sepbits, R_fx[k_sort[j]] );
- }
- }
- /* Separate the position information from the input signal(coefs_norm) */
- /* Gather the NZ coefficients*/
- FOR( k = 0; k < BANDS; k++ ) /* Loop through non-zero blocks */
- {
- test();
- IF( NE_16( k, k_num[0] ) && NE_16( k, k_num[1] ) )
- {
- test();
- test();
- IF( R_fx[k_sort[k]] > 0 && USQ_TCQ[k_sort[k]] == 0 ) /* Then have non-zero block AND WILL BE ENCODED BY TCQ */
- {
- /* Encode Position Info, NZ Info, Signs */
- size = sfmsize[k_sort[k]];
- move16();
-
- /* Determine scale step, ISC and TCQ quantizer */
- GetISCScale_fx( &coefs_quant_fx[sfm_start[k_sort[k]]], size,
- L_add( R_fx[k_sort[k]], delta_fx ),
- /* R_fx[k_sort[k]], */
- &coefs_norm_dec_fx[sfm_start[k_sort[k]]], &step_scale_fx[k_sort[k]], &surplus_fx, &pulses_fx, savedstates, 0, &nzp_fx, 0, 0, 0, 0 );
- leftbits = L_sub( leftbits, L_add( R_fx[k_sort[k]], delta_fx ) );
- npulses[k_sort[k]] = pulses_fx;
- move16();
-
- encode_position_ari_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, &est_frame_bits_fx );
- encode_magnitude_tcq_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, npulses[k_sort[k]], nzp_fx, savedstates, &est_frame_bits_fx );
- encode_signs_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, nzp_fx, &est_frame_bits_fx );
- nzbands = sub( nzbands, 1 );
- }
- /* Have USQ coded band */
- ELSE IF( R_fx[k_sort[k]] > 0 && EQ_16( USQ_TCQ[k_sort[k]], 1 ) )
- {
- size = sfmsize[k_sort[k]];
- move16();
-
- GetISCScale_fx( &coefs_quant_fx[sfm_start[k_sort[k]]], size,
- L_add( R_fx[k_sort[k]], delta_fx ),
- /* R_fx[k_sort[k]], */
- &coefs_norm_dec_fx[sfm_start[k_sort[k]]], &step_scale_fx[k_sort[k]], &surplus_fx, &pulses_fx, savedstates, 1, &nzp_fx, 0, 0, 0, 0 );
- leftbits = L_sub( leftbits, L_add( R_fx[k_sort[k]], delta_fx ) );
- npulses[k_sort[k]] = pulses_fx;
- move16();
-
- encode_position_ari_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, &est_frame_bits_fx );
- encode_magnitude_usq_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, npulses[k_sort[k]], nzp_fx, &est_frame_bits_fx );
- encode_signs_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, nzp_fx, &est_frame_bits_fx );
- nzbands = sub( nzbands, 1 );
- }
- ELSE /* Then have zero block */
- {
- npulses[k_sort[k]] = 0;
- move16();
- size = sfmsize[k_sort[k]];
- move16();
- }
-
- delta_fx = L_deposit_l( 0 );
- test();
- IF( R_fx[k_sort[k]] > 0 && surplus_fx < 0 )
- {
- /* delta_fx = L_deposit_h( div_l( surplus_fx, nzbands ) ); */
- IF( LE_16( nzbands, 1 ) )
- {
- divider = 0;
- move32();
- }
- ELSE
- {
- divider = 2;
- move32();
- }
-
- IF( L_add( L_add( surplus_fx, sepbits ), ar_div( leftbits, divider ) ) < 0 )
- {
- /* Overflow possible => start to distribute negative surplus */
- delta_fx = ar_div( surplus_fx + sepbits, nzbands );
- }
- ELSE
- {
- delta_fx = 0;
- move32();
- }
- surplus_fx = L_sub( surplus_fx, delta_fx );
- }
- }
- }
-
- test();
- test();
- test();
- IF( ( GT_32( surplus_fx, 524288 ) && EQ_16( input_frame, L_FRAME8k ) ) || ( GT_32( surplus_fx, 786432 ) && EQ_16( input_frame, L_FRAME16k ) ) )
- {
- bit_surplus_fx[0] = Mult_32_16( surplus_fx, 24576 ); /* Q16 */
- move32();
- bit_surplus_fx[1] = Mult_32_16( surplus_fx, 8192 ); /* Q16 */
- move32();
- }
- ELSE
- {
- bit_surplus_fx[0] = surplus_fx;
- move32();
- bit_surplus_fx[1] = L_deposit_l( 0 );
- move32();
- }
-
- FOR( k = 0; k < BANDS; k++ )
- {
- FOR( j = 0; j < 2; j++ )
- {
- IF( EQ_16( k, k_num[j] ) )
- {
- R_fx[k_sort[k]] = L_add( R_fx[k_sort[k]], bit_surplus_fx[j] );
- move32();
-
- test();
- test();
- IF( R_fx[k_sort[k]] > 0 && USQ_TCQ[k_sort[k]] == 0 ) /* Then have non-zero block AND WILL BE ENCODED BY TCQ */
- {
- /* Encode Position Info, NZ Info, Signs */
- size = sfmsize[k_sort[k]];
- move16();
-
- /* Determine scale step, ISC and TCQ quantizer */
- GetISCScale_fx( &coefs_quant_fx[sfm_start[k_sort[k]]], size, R_fx[k_sort[k]], &coefs_norm_dec_fx[sfm_start[k_sort[k]]], &step_scale_fx[k_sort[k]], &surplus_fx, &pulses_fx, savedstates, 0, &nzp_fx, 0, 0, 0, 0 );
-
- npulses[k_sort[k]] = pulses_fx;
- move16();
-
- encode_position_ari_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, &est_frame_bits_fx );
- encode_magnitude_tcq_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, npulses[k_sort[k]], nzp_fx, savedstates, &est_frame_bits_fx );
- encode_signs_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, nzp_fx, &est_frame_bits_fx );
- }
- /* Have USQ coded band */
- ELSE IF( R_fx[k_sort[k]] > 0 && EQ_16( USQ_TCQ[k_sort[k]], 1 ) )
- {
- size = sfmsize[k_sort[k]];
- move16();
-
- GetISCScale_fx( &coefs_quant_fx[sfm_start[k_sort[k]]], size, R_fx[k_sort[k]], &coefs_norm_dec_fx[sfm_start[k_sort[k]]], &step_scale_fx[k_sort[k]], &surplus_fx, &pulses_fx, savedstates, 1, &nzp_fx, 0, 0, 0, 0 );
-
- npulses[k_sort[k]] = pulses_fx;
- move16();
-
- encode_position_ari_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, &est_frame_bits_fx );
- encode_magnitude_usq_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, npulses[k_sort[k]], nzp_fx, &est_frame_bits_fx );
- encode_signs_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, nzp_fx, &est_frame_bits_fx );
- }
- ELSE /* Then have zero block */
- {
- npulses[k_sort[k]] = 0;
- move16();
- size = sfmsize[k_sort[k]];
- move16();
- }
- }
- }
- }
- }
- ELSE
- {
- surplus_fx = L_deposit_l( 0 );
-
- /* Separate the position information from the input signal(coefs_norm) */
- /* Gather the NZ coefficients*/
- FOR( k = 0; k < BANDS; k++ ) /* Loop through non-zero blocks */
- {
- IF( R_fx[k_sort[k]] > 0 )
- {
- size = sfmsize[k_sort[k]];
- move16();
- GetISCScale_fx( &coefs_quant_fx[sfm_start[k_sort[k]]], size, R_fx[k_sort[k]] + delta_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], &step_scale_fx[k_sort[k]], &surplus_fx, &pulses_fx, savedstates, 1, &nzp_fx, &bcount, abuffer_fx, mbuffer_fx, sbuffer_fx );
-
- npulses[k_sort[k]] = pulses_fx;
- move16();
- encode_position_ari_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, &est_frame_bits_fx );
- encode_magnitude_usq_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, npulses[k_sort[k]], nzp_fx, &est_frame_bits_fx );
- encode_signs_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, nzp_fx, &est_frame_bits_fx );
-
- /* nzbands--; */
- nzbands = sub( nzbands, 1 );
- }
- ELSE /* Then have zero block */
- {
- npulses[k_sort[k]] = 0;
- move16();
- size = sfmsize[k_sort[k]];
- move16();
- }
-
- /* Surplus distribution */
- /* if( surplus > 0.0f && nzbands > 0 ) */
- test();
- IF( surplus_fx > 0 && nzbands > 0 )
- {
- /* delta = surplus / nzbands;
- surplus -= delta; */
-
- delta_fx = ar_div( surplus_fx, nzbands );
- surplus_fx = L_sub( surplus_fx, delta_fx );
- }
- }
- }
-
- TCQLSB_fx( bcount, /*abuffer, */ abuffer_fx, /*mbuffer, */ mbuffer_fx, /*sbuffer, */ sbuffer_fx, dpath );
-
- /* Save TCQ path to bitstream */
- SaveTCQdata_fx( parenc_fx, dpath, lsbtcq_bits );
-
- /* Add tcq sequence to decoding buffer */
- InitLSBTCQ_fx( &bcount );
-
- ar_encoder_done_fx( parenc_fx );
-
- /* Loop through non-zero blocks */
- FOR( i = 0; i < L_FRAME32k; i++ )
- {
- coefs_norm_dec_fx[i] = extract_l( L_mult0( coefs_norm_dec_fx[i], 5 ) );
- move16();
- }
-
- IF( !flag_wbnb )
- {
- FOR( k = 0; k < BANDS; k++ )
- {
- IF( R_fx[k_sort[k]] > 0 )
- {
- size = sfmsize[k_sort[k]];
- move16();
- RestoreTCQ_fx( &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, &bcount, mbuffer_fx );
- }
- }
- }
-
- nb_bytes = shr( bit_budget, 3 );
-
- j = sub( bit_budget, shl( nb_bytes, 3 ) );
- FOR( i = 0; i < nb_bytes; i++ )
- {
- push_indice( hBstr, IND_HQ2_SUBBAND_TCQ, pbs_fx->buf[i], 8 );
- }
- IF( j > 0 )
- {
- push_indice( hBstr, IND_HQ2_SUBBAND_TCQ, shr( pbs_fx->buf[nb_bytes], sub( 8, j ) ), j );
- }
- /* Clear decoding buffer */
- set32_fx( coefs_quant_fx, 0, sfm_end[BANDS - 1] + 1 );
-
- /* New analysis of decoded frame */
- FOR( i = 0; i < BANDS; i++ )
- {
- IF( R_fx[k_sort[i]] > 0 )
- {
- gain_fx = L_deposit_l( 0 );
-
- crosscorr_fx = L_deposit_l( 0 );
- selfcorr_fx = L_deposit_l( 0 );
-
- FOR( j = 0; j < sfmsize[k_sort[i]]; j++ )
- {
- crosscorr_fx = L_add( crosscorr_fx, Mult_32_16( coefs_norm_fx[sfm_start[k_sort[i]] + j], shl( coefs_norm_dec_fx[sfm_start[k_sort[i]] + j], 2 ) ) ); /*1 */
- selfcorr_fx = L_mac0( selfcorr_fx, coefs_norm_dec_fx[sfm_start[k_sort[i]] + j], coefs_norm_dec_fx[sfm_start[k_sort[i]] + j] );
- }
-
- exp = sub( norm_l( crosscorr_fx ), 1 );
- gain_fx = ar_div( L_shl( crosscorr_fx, exp ), selfcorr_fx ); /* 1 + exp */
- gain_fx = L_shl_sat( gain_fx, sub( 16, 1 + exp ) + 2 ); /* 0.2 * Q16 */
- lo = L_Extract_lc( gain_fx, &hi );
- /* Use optimal gain */
- FOR( j = 0; j < sfmsize[k_sort[i]]; j++ )
- {
- inp_vector_fx[sfm_start[k_sort[i]] + j] = coefs_norm_dec_fx[sfm_start[k_sort[i]] + j];
- move32();
- coefs_quant_fx[sfm_start[k_sort[i]] + j] = L_add( L_shl( L_mult0( hi, coefs_norm_dec_fx[sfm_start[k_sort[i]] + j] ), 12 ),
- L_shr( L_mult0( lo, coefs_norm_dec_fx[sfm_start[k_sort[i]] + j] ), 3 ) ); /* Q12 */
- move32();
- }
- }
- }
-
-
return error;
}
diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c
index 012d6fa0260cd2cc1886c848bf04930652dd80df..7650516cb3898086ace272f3966f4e47db1a2d00 100644
--- a/lib_enc/tcx_ltp_enc_fx.c
+++ b/lib_enc/tcx_ltp_enc_fx.c
@@ -4,7 +4,7 @@
#include
#include "options.h"
-//#include "prot_fx.h"
+// #include "prot_fx.h"
#include "stl.h"
#include "cnst.h"
#include "basop_util.h"
@@ -89,6 +89,7 @@ static void tcx_ltp_pitch_search(
Word16 pitres )
{
Word16 i, t, t0, t1, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp;
+ Word16 cor_idx_ini, cor_idx;
Word32 cor_max, cor[256], *pt_cor, temp;
Word16 wsp2[L_FRAME_PLUS + PIT_MAX_MAX + L_INTERPOL1];
@@ -203,7 +204,7 @@ static void tcx_ltp_pitch_search(
* the interpolated normalized correlation.
*-----------------------------------------------------------------*/
- pt_cor = cor + sub( L_INTERPOL1, t0_min );
+ cor_idx_ini = sub( L_INTERPOL1, t0_min );
t0 = t1;
move16();
@@ -219,18 +220,20 @@ static void tcx_ltp_pitch_search(
IF( EQ_16( t0, t0_min ) ) /* Limit case */
{
+ cor_idx = add( cor_idx_ini, t0 );
fraction = 0;
move16();
- cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres );
+ cor_max = interpolate_corr( &cor[cor_idx], fraction, pitres );
}
ELSE /* Process negative fractions */
{
t0 = sub( t0, 1 );
- cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres );
+ cor_idx = add( cor_idx_ini, t0 );
+ cor_max = interpolate_corr( &cor[cor_idx], fraction, pitres );
FOR( i = fraction + step; i < pitres; i += step )
{
- temp = interpolate_corr( &pt_cor[t0], i, pitres );
+ temp = interpolate_corr( &cor[cor_idx], i, pitres );
IF( GT_32( temp, cor_max ) )
{
@@ -241,11 +244,10 @@ static void tcx_ltp_pitch_search(
}
}
- i = 0;
- move16();
+ cor_idx = add( cor_idx_ini, t1 );
FOR( i = 0; i < pitres; i += step ) /* Process positive fractions */
{
- temp = interpolate_corr( &pt_cor[t1], i, pitres );
+ temp = interpolate_corr( &cor[cor_idx], i, pitres );
IF( GT_32( temp, cor_max ) )
{
@@ -293,6 +295,7 @@ static void tcx_ltp_pitch_search_ivas_fx(
Word16 *border_case )
{
Word16 i, t, t0, t1, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp;
+ Word16 cor_idx_ini, cor_idx;
Word32 cor_max, cor[256], *pt_cor, temp;
Word16 wsp2[L_FRAME_PLUS + PIT_MAX_MAX + L_INTERPOL1];
@@ -418,8 +421,7 @@ static void tcx_ltp_pitch_search_ivas_fx(
* search the fractions around t0 and choose the one which maximizes
* the interpolated normalized correlation.
*-----------------------------------------------------------------*/
-
- pt_cor = cor + sub( L_INTERPOL1, t0_min );
+ cor_idx_ini = sub( L_INTERPOL1, t0_min );
t0 = t1;
move16();
@@ -435,18 +437,20 @@ static void tcx_ltp_pitch_search_ivas_fx(
IF( EQ_16( t0, t0_min ) ) /* Limit case */
{
+ cor_idx = add( cor_idx_ini, t0 );
fraction = 0;
move16();
- cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres );
+ cor_max = interpolate_corr( &cor[cor_idx], fraction, pitres );
}
ELSE /* Process negative fractions */
{
t0 = sub( t0, 1 );
- cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres );
+ cor_idx = add( cor_idx_ini, t0 );
+ cor_max = interpolate_corr( &cor[cor_idx], fraction, pitres );
FOR( i = fraction + step; i < pitres; i += step )
{
- temp = interpolate_corr( &pt_cor[t0], i, pitres );
+ temp = interpolate_corr( &cor[cor_idx], i, pitres );
IF( GT_32( temp, cor_max ) )
{
@@ -457,9 +461,10 @@ static void tcx_ltp_pitch_search_ivas_fx(
}
}
+ cor_idx = add( cor_idx_ini, t1 );
FOR( i = 0; i < pitres; i += step ) /* Process positive fractions */
{
- temp = interpolate_corr( &pt_cor[t1], i, pitres );
+ temp = interpolate_corr( &cor[cor_idx], i, pitres );
IF( GT_32( temp, cor_max ) )
{
diff --git a/lib_enc/tns_base_enc_fx.c b/lib_enc/tns_base_enc_fx.c
index d8e5899da1124e8c1744c354533115af3d07153e..30def3e2ef7f2e707de6626f9913ed4d92b69d89 100644
--- a/lib_enc/tns_base_enc_fx.c
+++ b/lib_enc/tns_base_enc_fx.c
@@ -791,32 +791,33 @@ Word16 WriteTnsData_ivas_fx( STnsConfig const *pTnsConfig, Word16 const *stream,
{
IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) )
{
- WriteToBitstream_ivas_fx( &tnsEnabledOnWhiteSWBTCX10BitMap, 1, &stream, pnSize, hBstr, pnBits );
+ WriteToBitstream_fx( &tnsEnabledOnWhiteSWBTCX10BitMap, 1, &stream, pnSize, hBstr, pnBits );
}
ELSE
{
- WriteToBitstream_ivas_fx( &tnsEnabledOnWhiteSWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits );
+ WriteToBitstream_fx( &tnsEnabledOnWhiteSWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits );
}
}
ELSE
{
IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) )
{
- WriteToBitstream_ivas_fx( &tnsEnabledSWBTCX10BitMap, 1, &stream, pnSize, hBstr, pnBits );
+ WriteToBitstream_fx( &tnsEnabledSWBTCX10BitMap, 1, &stream, pnSize, hBstr, pnBits );
}
ELSE
{
- WriteToBitstream_ivas_fx( &tnsEnabledSWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits );
+ WriteToBitstream_fx( &tnsEnabledSWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits );
}
}
}
ELSE
{
- WriteToBitstream_ivas_fx( &tnsEnabledWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits );
+ WriteToBitstream_fx( &tnsEnabledWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits );
}
return TNS_NO_ERROR;
}
+
/*********************************************************************************************/
/* Definitions of functions used in the mapping between TNS parameters and a bitstream. */
/*********************************************************************************************/
diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c
index 547502eab143cc2523cafebe01e169a2474fb28d..00e047e16e6bfbc4f53e4b7b1fa9dc03710ef5e4 100644
--- a/lib_enc/transition_enc_fx.c
+++ b/lib_enc/transition_enc_fx.c
@@ -16,7 +16,6 @@
static void gain_trans_enc_fx( Word32 gain_trans32, Word16 exc[], Word16 *quant_index, Word16 *quant_sign, Word16 Q_new );
static void tc_enc_fx( Encoder_State *st_fx, const Word16 i_subfr, Word16 *tc_subfr, Word16 *position, const Word16 *h1_fx, const Word16 *xn_fx, Word16 *exc_fx, Word16 *yy1_fx, Word16 *T0_min, Word16 *T0_max, Word16 *T0, Word16 *T0_frac, Word16 *gain_pit_fx, Word16 g_corr_fx[], Word16 *bwe_exc_fx, Word16 Q_new );
-static void tc_enc_ivas_fx( Encoder_State *st_fx, const Word16 i_subfr, Word16 *tc_subfr, Word16 *position, const Word16 *h1_fx, const Word16 *xn_fx, Word16 *exc_fx, Word16 *yy1_fx, Word16 *T0_min, Word16 *T0_max, Word16 *T0, Word16 *T0_frac, Word16 *gain_pit_fx, Word16 g_corr_fx[], Word16 *bwe_exc_fx, Word16 Q_new );
/*==========================================================================*/
@@ -163,14 +162,27 @@ void transition_enc_fx(
move16();
*clip_gain = 0;
move16();
- g_corr_fx[0] = 16384;
- move16();
- g_corr_fx[1] = add( shl( sub( shift_wsp, 1 ), 1 ), 1 );
- move16();
- g_corr_fx[2] = -16384;
- move16();
- g_corr_fx[3] = shl( sub( shift_wsp, 1 ), 1 );
- move16();
+ IF( NE_32( st_fx->element_mode, EVS_MONO ) )
+ {
+ g_corr_fx[0] = MAX16B /* 1.0f in Q15 */;
+ move16();
+ g_corr_fx[1] = 0;
+ move16();
+ g_corr_fx[2] = MAX16B /* 1.0f in Q15 */;
+ move16();
+ g_corr_fx[3] = 0;
+ }
+ ELSE
+ {
+ g_corr_fx[0] = 16384;
+ move16();
+ g_corr_fx[1] = add( shl( sub( shift_wsp, 1 ), 1 ), 1 );
+ move16();
+ g_corr_fx[2] = -16384;
+ move16();
+ g_corr_fx[3] = shl( sub( shift_wsp, 1 ), 1 );
+ move16();
+ }
set16_fx( &exc_fx[i_subfr], 0, L_SUBFR ); /* set excitation for current subrame to 0 */
@@ -197,6 +209,7 @@ void transition_enc_fx(
/*-----------------------------------------------------------------*
* glottal codebook contribution construction
*-----------------------------------------------------------------*/
+
ELSE IF( EQ_16( *tc_subfr, i_subfr ) )
{
IF( EQ_16( st_fx->L_frame, L_FRAME ) )
@@ -395,7 +408,14 @@ void transition_enc_fx(
push_indice( hBstr, IND_PITCH, index, nBits );
/* Find the adaptive codebook vector - ACELP long-term prediction */
- pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ IF( NE_32( st_fx->element_mode, EVS_MONO ) )
+ {
+ pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
+ ELSE
+ {
+ pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame );
@@ -443,11 +463,17 @@ void transition_enc_fx(
push_indice( hBstr, IND_PITCH, index, nBits );
/* Find the adaptive codebook vector - ACELP long-term prediction */
- pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ IF( NE_32( st_fx->element_mode, EVS_MONO ) )
+ {
+ pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
+ ELSE
+ {
+ pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame );
-
FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ )
{
bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset];
@@ -508,7 +534,14 @@ void transition_enc_fx(
push_indice( hBstr, IND_PITCH, index, nBits );
/* Find the adaptive codebook vector - ACELP long-term prediction */
- pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ IF( NE_32( st_fx->element_mode, EVS_MONO ) )
+ {
+ pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
+ ELSE
+ {
+ pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame );
@@ -533,11 +566,17 @@ void transition_enc_fx(
push_indice( hBstr, IND_PITCH, index, nBits );
/* Find the adaptive codebook vector - ACELP long-term prediction */
- pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ IF( NE_32( st_fx->element_mode, EVS_MONO ) )
+ {
+ pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
+ ELSE
+ {
+ pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame );
-
FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ )
{
bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset];
@@ -571,7 +610,14 @@ void transition_enc_fx(
pit_Q_enc_fx( hBstr, 0, nBits, 8, pit_flag, limit_flag, *T0, *T0_frac, T0_min, T0_max );
/* Find the adaptive codebook vector - ACELP long-term prediction */
- pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ IF( NE_32( st_fx->element_mode, EVS_MONO ) )
+ {
+ pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
+ ELSE
+ {
+ pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame );
@@ -807,10 +853,24 @@ void transition_enc_fx(
move16();
*clip_gain = 0;
move16();
- g_corr_fx[0] = 0;
- move16();
- g_corr_fx[1] = 0;
- move16();
+ IF( NE_32( st_fx->element_mode, EVS_MONO ) )
+ {
+ g_corr_fx[0] = 328 /* 0.01f in Q15 */;
+ move16();
+ g_corr_fx[1] = 0;
+ move16();
+ g_corr_fx[2] = 328 /* 0.01f in Q15 */;
+ move16();
+ g_corr_fx[3] = 0;
+ move16();
+ }
+ ELSE
+ {
+ g_corr_fx[0] = 0;
+ move16();
+ g_corr_fx[1] = 0;
+ move16();
+ }
*Jopt_flag = 0;
move16();
@@ -824,7 +884,15 @@ void transition_enc_fx(
ELSE
{
/* Find the adaptive codebook vector - ACELP long-term prediction */
- pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ IF( NE_32( st_fx->element_mode, EVS_MONO ) )
+ {
+ pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
+ ELSE
+ {
+ pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
+ }
+
offset = L_deposit_l( 0 );
tmp = extract_l( L_mult( *T0_frac, 32 ) ); /*Q8, 0.25 in Q7*/
@@ -889,939 +957,110 @@ void transition_enc_fx(
return;
}
-void transition_enc_ivas_fx(
+
+/*-------------------------------------------------------------------------------------------*
+ * tc_enc()
+ *
+ * Principal function for transition coding (TC) in encoder.
+ * Glottal codebook contribution part:
+ *
+ * |----| |----| xn
+ * imp_pos->|| | imp_shape->| g1 | |
+ * | | | | g2 | ---- exc |---| y1 ---- |
+ * | | |-------------| |----|gain|-------| h |------|gain|----(-)---> xn2
+ * | || | gn | ---- |---| ----
+ * |----| |----|
+ * codebook excitation gain_trans h_orig gain_pit
+ *
+ *-------------------------------------------------------------------------------------------*/
+
+static void tc_enc_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 i_subfr, /* i : subframe index */
- Word16 *tc_subfr, /* i/o: TC subframe index */
- Word16 *Jopt_flag, /* i : joint optimization flag */
- Word16 *position, /* i/o: maximum of residual signal index */
- Word16 *T0, /* i/o: close loop integer pitch Q0*/
- Word16 *T0_frac, /* i/o: close loop fractional part of the pitch Q0*/
- Word16 *T0_min, /* i/o: lower limit for close-loop search Q0*/
- Word16 *T0_max, /* i/o: higher limit for close-loop search Q0*/
- Word16 *exc_fx, /* i/o: pointer to excitation signal frame Q_new*/
- Word16 *y1_fx, /* o : zero-memory filtered adaptive excitation Q_new-1+shift*/
- const Word16 *h1_fx, /* i : weighted filter input response Q(14+shift)*/
- const Word16 *xn_fx, /* i : target vector Q_new-1+shift*/
- Word16 *xn2_fx, /* o : target vector for innovation search Q_new-1+shift*/
- Word16 *gp_cl_fx, /* i/o: memory of gain of pitch clipping algorithm */
- Word16 *gain_pit_fx, /* o : adaptive excitation gain Q14*/
- Word16 *g_corr_fx, /* o : ACELP correlation values */
- Word16 *clip_gain, /* i/o: adaptive gain clipping flag */
- Word16 **pt_pitch_fx, /* o : floating pitch values */
- Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/
- Word16 *unbits_ACELP, /* i/o: unused bits */
- Word16 Q_new, /* i : Current scaling */
- Word16 shift /* i : downscaling needs for 12 bits convolutions */
+ const Word16 i_subfr, /* i : subrame index */
+ Word16 *tc_subfr, /* i/o: TC subframe index */
+ Word16 *position, /* i/o: index of the residual signal maximum */
+ const Word16 *h1_fx, /* i : weighted filter input response Q(14+shift)*/
+ const Word16 *xn_fx, /* i : target signal Q_new-1+shift*/
+ Word16 *exc_fx, /* o : glottal codebook contribution Q_new*/
+ Word16 *yy1_fx, /* o : filtered glottal codebook contribution */
+ Word16 *T0_min, /* o : lower pitch limit Q0*/
+ Word16 *T0_max, /* o : higher pitch limit Q0*/
+ Word16 *T0, /* o : close loop integer pitch Q0*/
+ Word16 *T0_frac, /* o : close loop fractional part of the pitch Q0*/
+ Word16 *gain_pit_fx, /* o : pitch gain (0..GAIN_PIT_MAX) Q14*/
+ Word16 g_corr_fx[], /* o : correlations and -2 */
+ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_new*/
+ Word16 Q_new /* i : input scaling */
)
{
- Word16 pit_flag, pit_start, pit_limit, index, nBits;
- Word16 tmp, tmp1, i;
- Word32 offset;
- Word16 shift_wsp;
- Word16 limit_flag, mult_Top, lp_select, lp_flag;
- Word16 T_op[2]; /* values for two half-frames */
+ Word16 i, imp_shape, imp_pos, index, nBits, h1_tmp_fx[L_SUBFR];
+ Word16 pitch_index, pitch_sign_fx;
+ Word32 gain_trans32;
BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
-
- /* set limit_flag to 0 for restrained limits, and 1 for extended limits */
- limit_flag = 0;
- move16();
- pit_start = PIT_MIN;
- move16();
-
- /*----------------------------------------------------------------*
- * convert pitch values to 16kHz domain
- *----------------------------------------------------------------*/
-
- IF( EQ_16( st_fx->L_frame, L_FRAME ) /*|| (tdm_Pri_pitch_buf != NULL && tdm_Pri_pitch_buf[0] < 0)*/ )
- {
- Copy( st_fx->pitch, T_op, 2 );
- }
- ELSE /* L_frame == L_FRAME16k */
+ Flag Overflow = 0;
+ move32();
+ imp_pos = sub( *position, i_subfr );
+ FOR( i = 0; i < L_SUBFR; i++ )
{
- /*T_op[0] = (int16_t)(pitch[0] * 1.25f + 0.5f);
- T_op[1] = (int16_t)(pitch[1] * 1.25f + 0.5f);*/
- T_op[0] = add( st_fx->pitch[0], mult_r( st_fx->pitch[0], 8192 /*0.25f Q15*/ ) );
- move16();
- T_op[1] = add( st_fx->pitch[1], mult_r( st_fx->pitch[1], 8192 /*0.25f Q15*/ ) );
+ h1_tmp_fx[i] = h1_fx[i];
move16();
}
- shift_wsp = add( Q_new, shift );
+ /*-----------------------------------------------------------------*
+ * get number of bits for pitch encoding
+ *-----------------------------------------------------------------*/
- lp_flag = st_fx->acelp_cfg.ltf_mode;
+ nBits = st_fx->acelp_cfg.pitch_bits[shr( i_subfr, 6 )];
move16();
- /*-----------------------------------------------------------------*
- * TC: subrame determination for glottal shape search
- * -------------------------------------------------------
- * tc_subfr == 0 - TC in 1st subframe
- * tc_subfr == TC_0_0 - TC in 1st subframe + information about T0
- * tc_subfr == L_SUBFR - TC in 2nd subframe
- * tc_subfr == 2*L_SUBFR - TC in 3rd subframe
- * tc_subfr == 3*L_SUBFR - TC in 4th subframe
- *-----------------------------------------------------------------*/
+ /*--------------------------------------------------------------*
+ * Closed loop pitch search
+ *--------------------------------------------------------------*/
- IF( i_subfr == 0 )
+ *T0_frac = 0;
+ move16();
+
+ IF( EQ_16( st_fx->L_frame, L_FRAME ) )
{
- mult_Top = 1;
- move16();
- IF( limit_flag == 0 )
+ test();
+ IF( ( LE_16( *T0_min, L_SUBFR ) ) || ( EQ_16( *tc_subfr, 3 * L_SUBFR ) ) )
{
- test();
- IF( EQ_16( st_fx->L_frame, L_FRAME ) && LT_16( T_op[1], PIT_MIN ) )
+ IF( EQ_16( nBits, 9 ) )
{
- mult_Top = 2;
+ *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
move16();
}
- test();
- if ( EQ_16( st_fx->L_frame, L_FRAME16k ) && LT_16( T_op[1], PIT16k_MIN ) )
+ ELSE IF( EQ_16( nBits, 6 ) )
{
- mult_Top = 2;
+ *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MIN, L_SUBFR, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
+ move16();
+ }
+ ELSE
+ {
+ *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MAX, PIT_MIN, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
move16();
}
- }
-
- limit_T0_fx( st_fx->L_frame, 8, 0, limit_flag, mult_Top * T_op[1], 0, T0_min, T0_max );
- }
-
- /*-----------------------------------------------------------------*
- * zero adaptive excitation signal construction
- *-----------------------------------------------------------------*/
-
- IF( GT_16( *tc_subfr, i_subfr ) )
- {
- *gain_pit_fx = 0;
- move16();
- *clip_gain = 0;
- move16();
- g_corr_fx[0] = MAX16B /* 1.0f in Q15 */;
- move16();
- g_corr_fx[1] = 0;
- move16();
- g_corr_fx[2] = MAX16B /* 1.0f in Q15 */;
- move16();
- g_corr_fx[3] = 0;
- move16();
-
- set16_fx( &exc_fx[i_subfr], 0, L_SUBFR ); /* set excitation for current subrame to 0 */
-
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
- {
- set16_fx( &bwe_exc_fx[i_subfr * HIBND_ACB_L_FAC], 0, (Word16) ( L_SUBFR * HIBND_ACB_L_FAC ) ); /* set past excitation buffer to 0 */
}
ELSE
{
- set16_fx( &bwe_exc_fx[i_subfr * 2], 0, L_SUBFR * 2 ); /* set past excitation buffer to 0 */
+ *T0 = L_SUBFR;
+ move16();
}
- set16_fx( y1_fx, 0, L_SUBFR ); /* set filtered adaptive excitation to 0 */
- Copy( xn_fx, xn2_fx, L_SUBFR ); /* target vector for codebook search */
- *T0 = L_SUBFR;
- move16();
- *T0_frac = 0;
- move16();
-
- **pt_pitch_fx = shl( add( shl( *T0, 2 ), *T0_frac ), 4 );
- move16(); /* save subframe pitch values Q6 */
+ test();
+ if ( EQ_16( *tc_subfr, L_SUBFR ) && LT_16( *T0, L_SUBFR ) )
+ {
+ *T0 = L_SUBFR;
+ move16();
+ }
}
-
- /*-----------------------------------------------------------------*
- * glottal codebook contribution construction
- *-----------------------------------------------------------------*/
-
- ELSE IF( EQ_16( *tc_subfr, i_subfr ) )
+ ELSE /* st_fx->L_frame == L_FRAME16k */
{
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
+ IF( EQ_16( nBits, 10 ) )
{
- set16_fx( bwe_exc_fx - PIT_MAX * HIBND_ACB_L_FAC, 0, PIT_MAX * HIBND_ACB_L_FAC ); /* set past excitation buffer to 0 */
+ *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 1, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, L_FRAME16k, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
+ move16();
}
- ELSE
- {
- set16_fx( bwe_exc_fx - PIT16k_MAX * 2, 0, PIT16k_MAX * 2 ); /* set past excitation buffer to 0 */
- }
-
- tc_enc_ivas_fx( st_fx, i_subfr, tc_subfr, position, h1_fx, xn_fx, exc_fx,
- y1_fx, T0_min, T0_max, T0, T0_frac, gain_pit_fx, g_corr_fx, bwe_exc_fx, Q_new );
-
- IF( EQ_16( *tc_subfr, TC_0_0 ) )
- {
- /* this is called only to compute unused bits */
- config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ );
- }
-
- *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, sub( shift_wsp, 1 ) );
- move16();
- updt_tar_fx( xn_fx, xn2_fx, y1_fx, *gain_pit_fx, L_SUBFR );
-
- **pt_pitch_fx = shl( add( shl( *T0, 2 ), *T0_frac ), 4 );
- move16();
- *Jopt_flag = 1;
- move16();
- }
-
- /*--------------------------------------------------------------*
- * other subframes -> GENERIC encoding type,
- * standard adaptive excitation contribution
- * - exemption only in case when first glottal impulse is
- * in the 1st subframe and the second one in 2nd subframe
- * and later
- *--------------------------------------------------------------*/
-
- ELSE IF( LT_16( *tc_subfr, i_subfr ) )
- {
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
- {
- *Jopt_flag = 1;
- move16();
- /* pit_flag for T0 bits number coding determination */
- test();
- IF( ( EQ_16( sub( i_subfr, *tc_subfr ), L_SUBFR ) ) || ( EQ_16( sub( i_subfr, *tc_subfr ), L_SUBFR - TC_0_0 ) ) )
- {
- pit_flag = 0;
- move16();
- }
- ELSE
- {
- pit_flag = L_SUBFR;
- move16();
- }
-
- IF( EQ_16( *tc_subfr, TC_0_0 ) )
- {
- IF( EQ_16( i_subfr, L_SUBFR ) )
- {
- limit_T0_fx( L_FRAME, 8, pit_flag, limit_flag, *T0, 0, T0_min, T0_max );
- }
- pit_flag = 1;
- move16();
- }
-
- /*----------------------------------------------------------*
- * if tc_subfr==0, change tc_subfr corresponding to the
- * second glot. impulse position
- *----------------------------------------------------------*/
-
- test();
- IF( ( *tc_subfr == 0 ) && ( EQ_16( i_subfr, L_SUBFR ) ) )
- {
- IF( GT_16( PIT_MIN, ( *position ) ) )
- {
- pit_start = sub( L_SUBFR, ( *position ) );
- }
- ELSE
- {
- pit_start = PIT_MIN;
- move16();
- }
- pit_start = s_max( pit_start, PIT_MIN );
-
- pit_limit = add( shl( pit_start, 1 ), *position );
-
- /* Find the closed loop pitch period */
- *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, pit_start, pit_limit, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
- move16();
-
- offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame );
-
- FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ )
- {
- bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset];
- move16();
- }
-
- test();
- IF( GT_16( ( *T0 ), sub( 2 * L_SUBFR, ( *position ) ) ) )
- {
- IF( GE_16( add( ( *T0 ), ( *position ) ), 3 * L_SUBFR ) )
- {
- /* second glottal impulse is in the 4th subframe */
- *tc_subfr = TC_0_192;
- move16();
- }
- ELSE
- {
- /* second glottal impulse is in the 3rd subframe */
- *tc_subfr = TC_0_128;
- move16();
- }
- }
- ELSE IF( ( *tc_subfr == 0 ) && ( EQ_16( i_subfr, L_SUBFR ) ) )
- {
- /* second glottal impulse is in the 2nd subframe */
- *tc_subfr = TC_0_64;
- move16();
- }
- }
-
- IF( LE_16( sub( i_subfr, *tc_subfr ), L_SUBFR ) )
- {
- config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL, unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ );
- }
-
- /*-----------------------------------------------------------------*
- * get number of bits for pitch encoding
- *-----------------------------------------------------------------*/
-
- nBits = st_fx->acelp_cfg.pitch_bits[shr( i_subfr, 6 )];
- move16();
-
- /*-----------------------------------------------------------------*
- * Find adaptive part of excitation, encode pitch period
- *-----------------------------------------------------------------*/
-
- test();
- test();
- test();
- test();
- test();
- test();
- /* first glottal impulse is in the 1st subrame */
- IF( ( EQ_16( i_subfr, L_SUBFR ) ) && ( GE_16( *tc_subfr, TC_0_128 ) ) )
- {
- /*--------------------------------------------------------*
- * second glottal impulse is in the 3rd or 4th subframe
- * - build exc[] in 2nd subframe
- *--------------------------------------------------------*/
-
- *T0 = 2 * L_SUBFR;
- move16();
- *T0_frac = 0;
- move16();
- *Jopt_flag = 0;
- move16();
- set16_fx( &exc_fx[i_subfr], 0, (Word16) ( L_SUBFR + 1 ) );
- set16_fx( &bwe_exc_fx[i_subfr * HIBND_ACB_L_FAC], 0, (Word16) ( L_SUBFR * HIBND_ACB_L_FAC ) );
- }
- ELSE IF( ( EQ_16( i_subfr, L_SUBFR ) ) && ( EQ_16( *tc_subfr, TC_0_64 ) ) )
- {
- /*--------------------------------------------------------*
- * second glottal impulse is in the 2nd subframe,
- * - build exc[] in 2nd subframe
- *--------------------------------------------------------*/
-
- IF( LT_16( add( *T0, *position ), L_SUBFR ) )
- {
- /* impulse must be in the 2nd subframe (not in 1st) */
- *T0 = sub( L_SUBFR, ( *position ) );
- move16();
- *T0_frac = 0;
- move16();
- }
- IF( GE_16( add( *T0, *position ), 2 * L_SUBFR ) )
- {
- /* impulse must be in the 2nd subframe (not in 3rd) */
- *T0 = sub( 2 * L_SUBFR - 1, ( *position ) );
- move16();
- *T0_frac = 2;
- move16();
- }
-
- limit_T0_fx( L_FRAME, 8, pit_flag, limit_flag, *T0, 0, T0_min, T0_max ); /* find T0_min and T0_max for delta search */
-
- /* 7bit ENCODER */
- /* index = (*T0-pit_start)*2 + *T0_frac/2;*/
- index = add( shl( sub( *T0, pit_start ), 1 ), shr( *T0_frac, 1 ) );
- push_indice( hBstr, IND_PITCH, index, nBits );
-
- /* Find the adaptive codebook vector - ACELP long-term prediction */
- pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
-
-
- offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame );
-
- FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ )
- {
- bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset];
- move16();
- }
- }
- ELSE IF( ( EQ_16( i_subfr, 2 * L_SUBFR ) ) && ( EQ_16( *tc_subfr, TC_0_128 ) ) )
- {
- /*--------------------------------------------------------*
- * second glottal impulse is in the 3rd subframe
- * - build exc[] in 3rd subframe
- *--------------------------------------------------------*/
-
- pit_start = sub( 2 * L_SUBFR, ( *position ) );
- pit_flag = 0;
- move16();
-
- *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, pit_start, 3 * L_SUBFR, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
- move16();
-
- IF( LT_16( add( ( *T0 ), ( *position ) ), 2 * L_SUBFR ) )
- {
- /* impulse must be in the 3rd subframe (not in 2nd) */
- *T0 = sub( 2 * L_SUBFR, ( *position ) );
- move16();
- *T0_frac = 0;
- move16();
- }
-
- IF( GE_16( add( ( *T0 ), ( *position ) ), 3 * L_SUBFR ) )
- {
- /* impulse must be in the 3rd subframe (not in 4th) */
- *T0 = sub( 3 * L_SUBFR - 1, ( *position ) );
- move16();
- *T0_frac = 2;
- move16();
- }
-
- limit_T0_fx( L_FRAME, 8, pit_flag, limit_flag, *T0, 0, T0_min, T0_max ); /* find T0_min and T0_max for delta search */
-
- index = add( shl( sub( *T0, pit_start ), 1 ), shr( *T0_frac, 1 ) );
- push_indice( hBstr, IND_PITCH, index, nBits );
-
- /* Find the adaptive codebook vector - ACELP long-term prediction */
- pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
-
- offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame );
-
-
- FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ )
- {
- bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset];
- move16();
- }
- }
- ELSE IF( ( EQ_16( i_subfr, 2 * L_SUBFR ) ) && ( EQ_16( *tc_subfr, TC_0_192 ) ) )
- {
- /*--------------------------------------------------------*
- * second glottal impulse is in the 4th subframe
- * - build exc[] in 3rd subframe
- *--------------------------------------------------------*/
-
- *T0 = 4 * L_SUBFR;
- move16();
- *T0_frac = 0;
- move16();
- *Jopt_flag = 0;
- move16();
- set16_fx( &exc_fx[i_subfr], 0, (Word16) ( L_SUBFR + 1 ) );
- set16_fx( &bwe_exc_fx[i_subfr * HIBND_ACB_L_FAC], 0, (Word16) ( L_SUBFR * HIBND_ACB_L_FAC ) );
- }
- ELSE IF( ( EQ_16( i_subfr, 3 * L_SUBFR ) ) && ( EQ_16( *tc_subfr, TC_0_192 ) ) )
- {
- /*--------------------------------------------------------*
- * second glottal impulse is in the 4th subframe
- * - build exc[] in 4th subframe
- *--------------------------------------------------------*/
-
- /* always T0_frac = 0 */
- pit_flag = 0;
- move16();
-
- *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
- move16();
-
- IF( LT_16( add( *T0, *position ), 3 * L_SUBFR ) )
- {
- /* impulse must be in the 4th subframe (not in 3rd) */
- *T0 = sub( 3 * L_SUBFR, ( *position ) );
- move16();
- *T0_frac = 0;
- move16();
- }
-
- pit_start = sub( 3 * L_SUBFR, ( *position ) );
- pit_limit = sub( 2 * L_FRAME - PIT_MAX - 2, shl( *position, 1 ) );
-
- IF( LT_16( ( *T0 ), pit_limit ) )
- {
- index = add( shl( sub( *T0, pit_start ), 1 ), shr( *T0_frac, 1 ) );
- }
- ELSE
- {
- index = add( sub( *T0, pit_limit ), shl( sub( pit_limit, pit_start ), 1 ) );
- *T0_frac = 0;
- move16();
- }
- push_indice( hBstr, IND_PITCH, index, nBits );
-
- /* Find the adaptive codebook vector - ACELP long-term prediction */
- pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
-
- offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame );
-
- FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ )
- {
- bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset];
- move16();
- }
- }
- ELSE IF( ( EQ_16( i_subfr, 3 * L_SUBFR ) ) && ( EQ_16( *tc_subfr, TC_0_128 ) ) )
- {
- /*--------------------------------------------------------*
- * second glottal impulse in the 3rd subframe
- * build exc[] in 4th subframe
- *--------------------------------------------------------*/
-
- pit_flag = L_SUBFR;
- move16();
-
- *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
- move16();
- index = delta_pit_enc_fx( 2, *T0, *T0_frac, *T0_min );
- push_indice( hBstr, IND_PITCH, index, nBits );
-
- /* Find the adaptive codebook vector - ACELP long-term prediction */
- pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
-
- offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame );
-
- FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ )
- {
- bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset];
- move16();
- }
- }
-
- /*------------------------------------------------------------*
- * first glottal impulse is NOT in the 1st subframe,
- * or two impulses are in the 1st subframe
- *------------------------------------------------------------*/
-
- ELSE
- {
- test();
- IF( EQ_16( nBits, 8 ) || EQ_16( nBits, 5 ) )
- {
- test();
- IF( !( ( *tc_subfr == 0 ) && ( EQ_16( i_subfr, L_SUBFR ) ) ) )
- {
- *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
- move16();
- }
- }
- ELSE
- {
- *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, pit_flag, limit_flag, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
- move16();
- }
- pit_Q_enc_fx( hBstr, 0, nBits, 8, pit_flag, limit_flag, *T0, *T0_frac, T0_min, T0_max );
- /* Find the adaptive codebook vector - ACELP long-term prediction */
- pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
-
- offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame );
-
- FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ )
- {
- bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset];
- move16();
- }
- }
-
- /*-----------------------------------------------------------------*
- * - gain clipping test to avoid unstable synthesis
- * - LP filtering of the adaptive excitation (if non-zero)
- * - codebook target computation
- *-----------------------------------------------------------------*/
-
- IF( *Jopt_flag == 0 )
- {
- /* adaptive/TC excitation is zero */
- Copy( xn_fx, xn2_fx, L_SUBFR );
- g_corr_fx[0] = 0;
- move16();
- g_corr_fx[1] = 0;
- move16();
- g_corr_fx[2] = 0;
- move16();
- g_corr_fx[3] = 0;
- move16();
- *clip_gain = 0;
- move16();
- }
- ELSE
- {
- *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, ( Q_new + shift - 1 ) );
- move16();
-
- lp_select = lp_filt_exc_enc_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx,
- xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag );
- IF( EQ_16( lp_flag, NORMAL_OPERATION ) )
- {
- push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 );
- }
- }
-
- **pt_pitch_fx = shl( add( shl( *T0, 2 ), *T0_frac ), 4 );
- move16();
-
- /*---------------------------------------------------------------------*
- * fill the pitch buffer - needed for post-processing
- *---------------------------------------------------------------------*/
-
- test();
- test();
- test();
- test();
- test();
- IF( ( *tc_subfr >= 2 * L_SUBFR ) && ( i_subfr == 3 * L_SUBFR ) )
- {
- tmp = shl( add( shl( *T0, 2 ), *T0_frac ), 4 );
- ( *pt_pitch_fx ) -= 3;
- move16();
- **pt_pitch_fx = tmp;
- move16();
- ( *pt_pitch_fx )++;
- move16();
- **pt_pitch_fx = tmp;
- move16();
- ( *pt_pitch_fx )++;
- move16();
- **pt_pitch_fx = tmp;
- move16();
- ( *pt_pitch_fx )++;
- move16();
- }
- ELSE IF( ( *tc_subfr == L_SUBFR ) && ( i_subfr == 2 * L_SUBFR ) )
- {
- tmp = shl( add( shl( *T0, 2 ), *T0_frac ), 4 );
- ( *pt_pitch_fx ) -= 2;
- move16();
- **pt_pitch_fx = tmp;
- move16();
- ( *pt_pitch_fx )++;
- move16();
- **pt_pitch_fx = tmp;
- move16();
- ( *pt_pitch_fx )++;
- move16();
- }
- ELSE IF( ( *tc_subfr == TC_0_64 ) && ( i_subfr == L_SUBFR ) )
- {
- tmp = shl( add( shl( *T0, 2 ), *T0_frac ), 4 );
- ( *pt_pitch_fx ) -= 1;
- move16();
- **pt_pitch_fx = tmp;
- move16();
- ( *pt_pitch_fx )++;
- move16();
- }
- ELSE IF( ( *tc_subfr == TC_0_128 ) && ( i_subfr == 2 * L_SUBFR ) )
- {
- tmp = shl( add( shl( *T0, 2 ), *T0_frac ), 4 );
- ( *pt_pitch_fx ) -= 2;
- move16();
- **pt_pitch_fx = tmp;
- move16();
- ( *pt_pitch_fx )++;
- move16();
- **pt_pitch_fx = tmp;
- move16();
- ( *pt_pitch_fx )++;
- move16();
- }
- ELSE IF( ( *tc_subfr == TC_0_192 ) && ( i_subfr == 3 * L_SUBFR ) )
- {
- tmp = shl( add( shl( *T0, 2 ), *T0_frac ), 4 );
- ( *pt_pitch_fx ) -= 3;
- move16();
- **pt_pitch_fx = tmp;
- move16();
- ( *pt_pitch_fx )++;
- move16();
- **pt_pitch_fx = tmp;
- move16();
- ( *pt_pitch_fx )++;
- move16();
- **pt_pitch_fx = tmp;
- move16();
- ( *pt_pitch_fx )++;
- move16();
- }
- }
- ELSE /* L_frame == L_FRAME16k */
- {
- if ( GE_16( i_subfr, 2 * L_SUBFR ) )
- {
- limit_flag = 1;
- move16();
- }
- IF( LE_16( i_subfr, 2 * L_SUBFR ) )
- {
- IF( LT_16( i_subfr, 2 * L_SUBFR ) )
- {
- mult_Top = 1;
- move16();
- if ( LT_16( T_op[0], PIT16k_MIN ) )
- {
- mult_Top = 2;
- move16();
- }
-
- limit_T0_fx( L_FRAME16k, 8, 0, limit_flag, mult_Top * T_op[0], 0, T0_min, T0_max ); /* TC0 second subfr. */
- }
- ELSE
- {
- limit_T0_fx( L_FRAME16k, 8, 0, limit_flag, T_op[1], 0, T0_min, T0_max ); /* TC0 third subfr., or TC64 third subfr. */
- }
- }
-
- /*-----------------------------------------------------------------*
- * get number of bits for pitch encoding
- *-----------------------------------------------------------------*/
-
- nBits = st_fx->acelp_cfg.pitch_bits[shr( i_subfr, 6 )];
- move16();
-
- /*-----------------------------------------------------------------*
- * Find adaptive part of excitation, encode pitch period
- *-----------------------------------------------------------------*/
-
- IF( EQ_16( nBits, 10 ) )
- {
- *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, limit_flag, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, st_fx->L_frame, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
- move16();
- pit16k_Q_enc_fx( hBstr, nBits, limit_flag, *T0, *T0_frac, T0_min, T0_max );
- }
- ELSE IF( EQ_16( nBits, 8 ) ) /* tc_subfr==0 && i_subfr==L_SUBFR */
- {
- /*-----------------------------------------------------------------------------*
- * The pitch range is encoded absolutely with 8 bits and is divided as follows:
- * PIT16k_MIN to PIT16k_FR2_TC0_2SUBFR-1 resolution 1/4 (frac = 0,1,2 or 3)
- * PIT16k_FR2_TC0_2SUBFR to 2*L_SUBFR resolution 1/2 (frac = 0 or 2)
- *-----------------------------------------------------------------------------*/
-
- *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, limit_flag, PIT16k_FR2_TC0_2SUBFR, 2 * L_SUBFR, st_fx->L_frame, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
- move16();
-
- IF( GT_16( *T0_max, 2 * L_SUBFR ) )
- {
- *T0 = 2 * L_SUBFR;
- move16();
- *T0_frac = 0;
- move16();
- }
-
- IF( LT_16( *T0, PIT16k_FR2_TC0_2SUBFR ) )
- {
- /*index = (*T0)*4 + (*T0_frac) - (PIT16k_MIN*4);*/
- index = add( shl( *T0, 2 ), sub( *T0_frac, PIT16k_MIN * 4 ) );
- }
- ELSE
- {
- /*index = (*T0)*2 + ((*T0_frac)>>1) - (PIT16k_FR2_TC0_2SUBFR*2) + ((PIT16k_FR2_TC0_2SUBFR-PIT16k_MIN)*4);*/
- index = add( sub( add( shl( *T0, 1 ), shr( *T0_frac, 1 ) ), ( PIT16k_FR2_TC0_2SUBFR * 2 ) ), ( PIT16k_FR2_TC0_2SUBFR - PIT16k_MIN ) * 4 );
- }
- push_indice( hBstr, IND_PITCH, index, nBits );
- }
- ELSE IF( EQ_16( nBits, 6 ) )
- {
- /* delta search */
- *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, L_SUBFR, limit_flag, PIT16k_FR2_EXTEND_9b, PIT16k_FR1_EXTEND_9b, st_fx->L_frame, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
- move16();
-
- index = delta_pit_enc_fx( 4, *T0, *T0_frac, *T0_min );
- push_indice( hBstr, IND_PITCH, index, nBits );
- }
-
- IF( EQ_16( nBits, 6 ) )
- {
- limit_T0_fx( L_FRAME16k, 8, L_SUBFR, limit_flag, *T0, *T0_frac, T0_min, T0_max );
- }
-
- /*-----------------------------------------------------------------*
- * - gain clipping test to avoid unstable synthesis
- * - LP filtering of the adaptive excitation
- * - codebook target computation
- *-----------------------------------------------------------------*/
- test();
- IF( ( EQ_16( i_subfr, L_SUBFR ) ) && ( EQ_16( *T0, 2 * L_SUBFR ) ) )
- {
- *gain_pit_fx = 0;
- move16();
- *clip_gain = 0;
- move16();
- g_corr_fx[0] = 328 /* 0.01f in Q15 */;
- move16();
- g_corr_fx[1] = 0;
- move16();
- g_corr_fx[2] = 328 /* 0.01f in Q15 */;
- move16();
- g_corr_fx[3] = 0;
- move16();
- *Jopt_flag = 0;
- move16();
-
- set16_fx( &exc_fx[i_subfr], 0, L_SUBFR + 1 ); /* set excitation for current subrame to 0 */
- push_indice( hBstr, IND_LP_FILT_SELECT, 0, 1 ); /* this bit is actually not needed */
-
- Copy( xn_fx, xn2_fx, L_SUBFR ); /* target vector for codebook search */
- set16_fx( y1_fx, 0, L_SUBFR ); /* set filtered adaptive excitation to 0 */
- set16_fx( &bwe_exc_fx[i_subfr * 2], 0, L_SUBFR * 2 );
- }
- ELSE
- {
- /* Find the adaptive codebook vector - ACELP long-term prediction */
- pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
- offset = L_deposit_l( 0 );
-
- tmp = extract_l( L_mult( *T0_frac, 32 ) ); /*Q8, 0.25 in Q7*/
- tmp = add( 512, tmp ); /*Q8; 2 in Q8*/
- tmp = mult_r( tmp, 256 ); /*Q16->Q0; 2 in Q7*/
-
- tmp1 = sub( *T0, 2 ); /*Q0*/
- tmp1 = shl( tmp1, 1 ); /*Q0 */
-
- offset = add( tmp, tmp1 ); /*Q0*/
- FOR( i = 0; i < L_SUBFR * 2; i++ )
- {
- /* bwe_exc_fx[i + i_subfr * 2] = bwe_exc_fx[i + i_subfr * 2 - *T0 * 2 - (int) ((float) *T0_frac * 0.5f + 4 + 0.5f) + 4];move16();*/
- bwe_exc_fx[i + i_subfr * 2] = bwe_exc_fx[i + i_subfr * 2 - offset + 4];
- move16();
- }
-
- *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, Q_new );
- move16();
-
- lp_select = lp_filt_exc_enc_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx,
- xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag );
- IF( EQ_16( lp_flag, NORMAL_OPERATION ) )
- {
- push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 );
- }
-
- *Jopt_flag = 1;
- move16();
- }
-
- /***pt_pitch = (float)(*T0) + (float)(*T0_frac)/4.0f;*/ /* save subframe pitch value */
- /***pt_pitch_fx = shl(add(*T0,shr(*T0_frac,2)),4); move16();*/
- tmp = shl( add( shl( *T0, 2 ), *T0_frac ), 4 );
- **pt_pitch_fx = tmp;
- move16();
-
- /*---------------------------------------------------------------------*
- * fill the pitch buffer - needed for post-processing
- *---------------------------------------------------------------------*/
- test();
- test();
- IF( ( EQ_16( sub( i_subfr, *tc_subfr ), L_SUBFR ) ) || ( *tc_subfr == 0 && EQ_16( i_subfr, 2 * L_SUBFR ) ) )
- {
- index = shr( i_subfr, 6 );
- ( *pt_pitch_fx ) -= index;
- move16();
-
- FOR( i = 0; i < index; i++ )
- {
- **pt_pitch_fx = tmp;
- move16();
- ( *pt_pitch_fx )++;
- move16();
- }
- }
- }
- }
-
- return;
-}
-
-
-/*-------------------------------------------------------------------------------------------*
- * tc_enc()
- *
- * Principal function for transition coding (TC) in encoder.
- * Glottal codebook contribution part:
- *
- * |----| |----| xn
- * imp_pos->|| | imp_shape->| g1 | |
- * | | | | g2 | ---- exc |---| y1 ---- |
- * | | |-------------| |----|gain|-------| h |------|gain|----(-)---> xn2
- * | || | gn | ---- |---| ----
- * |----| |----|
- * codebook excitation gain_trans h_orig gain_pit
- *
- *-------------------------------------------------------------------------------------------*/
-
-static void tc_enc_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 i_subfr, /* i : subrame index */
- Word16 *tc_subfr, /* i/o: TC subframe index */
- Word16 *position, /* i/o: index of the residual signal maximum */
- const Word16 *h1_fx, /* i : weighted filter input response Q(14+shift)*/
- const Word16 *xn_fx, /* i : target signal Q_new-1+shift*/
- Word16 *exc_fx, /* o : glottal codebook contribution Q_new*/
- Word16 *yy1_fx, /* o : filtered glottal codebook contribution */
- Word16 *T0_min, /* o : lower pitch limit Q0*/
- Word16 *T0_max, /* o : higher pitch limit Q0*/
- Word16 *T0, /* o : close loop integer pitch Q0*/
- Word16 *T0_frac, /* o : close loop fractional part of the pitch Q0*/
- Word16 *gain_pit_fx, /* o : pitch gain (0..GAIN_PIT_MAX) Q14*/
- Word16 g_corr_fx[], /* o : correlations and -2 */
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_new*/
- Word16 Q_new /* i : input scaling */
-)
-{
- Word16 i, imp_shape, imp_pos, index, nBits, h1_tmp_fx[L_SUBFR];
- Word16 pitch_index, pitch_sign_fx;
- Word32 gain_trans32;
- BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
- Flag Overflow = 0;
- move32();
- imp_pos = sub( *position, i_subfr );
- FOR( i = 0; i < L_SUBFR; i++ )
- {
- h1_tmp_fx[i] = h1_fx[i];
- move16();
- }
- /*-----------------------------------------------------------------*
- * get number of bits for pitch encoding
- *-----------------------------------------------------------------*/
-
- nBits = st_fx->acelp_cfg.pitch_bits[shr( i_subfr, 6 )];
- move16();
-
- /*--------------------------------------------------------------*
- * Closed loop pitch search
- *--------------------------------------------------------------*/
-
- *T0_frac = 0;
- move16();
-
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
- {
- test();
- IF( ( LE_16( *T0_min, L_SUBFR ) ) || ( EQ_16( *tc_subfr, 3 * L_SUBFR ) ) )
- {
- IF( EQ_16( nBits, 9 ) )
- {
- *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
- move16();
- }
- ELSE IF( EQ_16( nBits, 6 ) )
- {
- *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MIN, L_SUBFR, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
- move16();
- }
- ELSE
- {
- *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MAX, PIT_MIN, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
- move16();
- }
- }
- ELSE
- {
- *T0 = L_SUBFR;
- move16();
- }
-
- test();
- if ( EQ_16( *tc_subfr, L_SUBFR ) && LT_16( *T0, L_SUBFR ) )
- {
- *T0 = L_SUBFR;
- move16();
- }
- }
- ELSE /* st_fx->L_frame == L_FRAME16k */
- {
- IF( EQ_16( nBits, 10 ) )
- {
- *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 1, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, L_FRAME16k, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
- move16();
- }
- ELSE IF( EQ_16( nBits, 6 ) )
+ ELSE IF( EQ_16( nBits, 6 ) )
{
/* T0_frac with 1/2 sample resolution */
*T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1_fx, *T0_min, *T0_max, T0_frac, 0, 0, PIT16k_MIN, L_SUBFR, L_FRAME16k, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
@@ -1960,228 +1199,6 @@ static void tc_enc_fx(
}
-static void tc_enc_ivas_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 i_subfr, /* i : subrame index */
- Word16 *tc_subfr, /* i/o: TC subframe index */
- Word16 *position, /* i/o: index of the residual signal maximum */
- const Word16 *h1, /* i : weighted filter input response Q(14+shift)*/
- const Word16 *xn_fx, /* i : target signal Q_new-1+shift*/
- Word16 *exc_fx, /* o : glottal codebook contribution Q_new*/
- Word16 *yy1_fx, /* o : filtered glottal codebook contribution */
- Word16 *T0_min, /* o : lower pitch limit Q0*/
- Word16 *T0_max, /* o : higher pitch limit Q0*/
- Word16 *T0, /* o : close loop integer pitch Q0*/
- Word16 *T0_frac, /* o : close loop fractional part of the pitch Q0*/
- Word16 *gain_pit_fx, /* o : pitch gain (0..GAIN_PIT_MAX) Q14*/
- Word16 g_corr_fx[], /* o : correlations and -2 */
- Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_new*/
- Word16 Q_new /* i : input scaling */
-)
-{
-
- Word16 h1_fx[L_SUBFR + ( M + 1 )];
- Word16 imp_shape, imp_pos, index, nBits;
- Word16 pitch_index, pitch_sign_fx;
- Word32 gain_trans32;
- BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
- Flag Overflow = 0;
- move32();
- imp_pos = sub( *position, i_subfr );
- /*-----------------------------------------------------------------*
- * get number of bits for pitch encoding
- *-----------------------------------------------------------------*/
-
- nBits = st_fx->acelp_cfg.pitch_bits[shr( i_subfr, 6 )];
- move16();
-
- /*--------------------------------------------------------------*
- * Closed loop pitch search
- *--------------------------------------------------------------*/
-
- *T0_frac = 0;
- move16();
-
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
- {
- test();
- IF( ( LE_16( *T0_min, L_SUBFR ) ) || ( EQ_16( *tc_subfr, 3 * L_SUBFR ) ) )
- {
- IF( EQ_16( nBits, 9 ) )
- {
- *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT_FR2_9b, PIT_FR1_9b, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
- move16();
- }
- ELSE IF( EQ_16( nBits, 6 ) )
- {
- *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MIN, L_SUBFR, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
- move16();
- }
- ELSE
- {
- *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT_MAX, PIT_MIN, L_FRAME, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
- move16();
- }
- }
- ELSE
- {
- *T0 = L_SUBFR;
- move16();
- }
-
- test();
- if ( EQ_16( *tc_subfr, L_SUBFR ) && LT_16( *T0, L_SUBFR ) )
- {
- *T0 = L_SUBFR;
- move16();
- }
- }
- ELSE /* st_fx->L_frame == L_FRAME16k */
- {
- IF( EQ_16( nBits, 10 ) )
- {
- *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 1, PIT16k_FR2_EXTEND_10b, PIT16k_MAX, L_FRAME16k, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
- move16();
- }
- ELSE IF( EQ_16( nBits, 6 ) )
- {
- /* T0_frac with 1/2 sample resolution */
- *T0 = pitch_fr4_fx( &exc_fx[i_subfr], xn_fx, h1, *T0_min, *T0_max, T0_frac, 0, 0, PIT16k_MIN, L_SUBFR, L_FRAME16k, L_SUBFR, 0 /*st_fx->element_mode*/, Q_new );
- move16();
-
- IF( *T0 > L_SUBFR )
- {
- *T0 = L_SUBFR;
- move16();
- *T0_frac = 0;
- move16();
- }
- }
- }
-
- /* set tc_subfr to TC_0_0 */
- test();
- test();
- test();
- if ( i_subfr == 0 && EQ_16( st_fx->L_frame, L_FRAME ) && ( LT_16( *T0, L_SUBFR ) || EQ_16( *tc_subfr, 3 * L_SUBFR ) ) )
- {
- *tc_subfr = TC_0_0;
- move16();
- }
-
- /*--------------------------------------------------------------*
- * Builds glottal codebook contribution
- *--------------------------------------------------------------*/
-
- set_impulse_fx( xn_fx, h1, &exc_fx[i_subfr], yy1_fx, &imp_shape, &imp_pos, &gain_trans32, Q_new );
-
- /*--------------------------------------------------------------*
- * quantize gain_trans and scale glottal codebook contribution
- *--------------------------------------------------------------*/
-
- gain_trans_enc_fx( gain_trans32, &exc_fx[i_subfr], &pitch_index, &pitch_sign_fx, Q_new );
-
- /* set past excitation buffer to zeros */
- set16_fx( exc_fx - L_EXC_MEM, 0, L_EXC_MEM );
-
- /*--------------------------------------------------------------*
- * adapt. search of the second impulse in the same subframe
- * (when appears)
- *--------------------------------------------------------------*/
-
- pred_lt4_tc_fx( exc_fx, *T0, *T0_frac, inter4_2_fx, imp_pos, i_subfr );
-
- IF( st_fx->hBWE_TD != NULL )
- {
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
- {
- interp_code_5over2_fx( &exc_fx[i_subfr], &bwe_exc_fx[i_subfr * HIBND_ACB_L_FAC], L_SUBFR );
- }
- ELSE
- {
- interp_code_4over2_fx( &exc_fx[i_subfr], &bwe_exc_fx[i_subfr * 2], L_SUBFR );
- }
- }
-
- /*--------------------------------------------------------------*
- * compute glottal-shape codebook excitation
- *--------------------------------------------------------------*/
-
- Copy( h1, h1_fx, L_SUBFR + ( M + 1 ) );
- /* create filtered glottal codebook contribution */
- conv_fx( &exc_fx[i_subfr], h1_fx, yy1_fx, L_SUBFR );
-
- /* gain_pit computation */
- *gain_pit_fx = corr_xy1_fx( xn_fx, yy1_fx, g_corr_fx, L_SUBFR, 0, &Overflow );
- move16();
-
- /*--------------------------------------------------------------*
- * Encode parameters and write indices
- *--------------------------------------------------------------*/
- IF( EQ_16( st_fx->L_frame, L_FRAME ) )
- {
- test();
- test();
- IF( ( ( i_subfr != 0 ) || ( EQ_16( *tc_subfr, TC_0_0 ) ) ) && ( NE_16( *tc_subfr, L_SUBFR ) ) )
- {
- test();
- /* write pitch index */
- IF( ( GE_16( *T0, L_SUBFR ) ) && ( NE_16( *tc_subfr, 3 * L_SUBFR ) ) )
- {
- push_indice( hBstr, IND_PITCH, 0, nBits );
- }
- ELSE IF( EQ_16( *tc_subfr, 3 * L_SUBFR ) )
- {
- IF( EQ_16( nBits, 9 ) )
- {
- index = abs_pit_enc_fx( 4, 0, *T0, *T0_frac );
- }
- ELSE
- {
- index = abs_pit_enc_fx( 2, 0, *T0, *T0_frac );
- }
- push_indice( hBstr, IND_PITCH, index, nBits );
-
- limit_T0_fx( L_FRAME, 8, 0, 0, *T0, 0, T0_min, T0_max );
- }
- ELSE
- {
- IF( EQ_16( nBits, 6 ) )
- {
- index = delta_pit_enc_fx( 2, *T0, *T0_frac, PIT_MIN - 1 );
- push_indice( hBstr, IND_PITCH, index, nBits );
- }
- ELSE
- {
- index = delta_pit_enc_fx( 0, *T0, *T0_frac, PIT_MIN - 1 );
- push_indice( hBstr, IND_PITCH, index, nBits );
- }
- }
- }
- }
- ELSE /* st_fx->L_frame == L_FRAME16k */
- {
- IF( EQ_16( nBits, 10 ) )
- {
- pit16k_Q_enc_fx( hBstr, nBits, 1, *T0, *T0_frac, T0_min, T0_max );
- }
- ELSE IF( EQ_16( nBits, 6 ) )
- {
- index = add( shl( sub( *T0, PIT16k_MIN ), 1 ), shr( *T0_frac, 1 ) );
- push_indice( hBstr, IND_PITCH, index, nBits );
- }
- }
- push_indice( hBstr, IND_TC_IMP_SHAPE, imp_shape, 3 );
- push_indice( hBstr, IND_TC_IMP_POS, imp_pos, 6 );
- push_indice( hBstr, IND_TC_IMP_SIGN, pitch_sign_fx, 1 );
- push_indice( hBstr, IND_TC_IMP_GAIN, pitch_index, 3 );
-
- *position = add( imp_pos, i_subfr );
- move16();
- return;
-}
-
-
/*-----------------------------------------------------------------*
* gain_trans_enc()
*
diff --git a/lib_enc/updt_enc_fx.c b/lib_enc/updt_enc_fx.c
index 62af228a0c75fac8ba24e23c64a406ec0c29b2d5..d0826c42953b0177216ddcdaf36b23e0abf1ab90 100644
--- a/lib_enc/updt_enc_fx.c
+++ b/lib_enc/updt_enc_fx.c
@@ -141,6 +141,7 @@ void updt_enc_fx(
}
/* core switching updates */
Copy( &Aq[( st->L_frame / L_SUBFR - 1 ) * ( M + 1 )], st->old_Aq_12_8_fx, M + 1 );
+
st->old_Es_pred_fx = Es_pred;
move16();
@@ -193,11 +194,13 @@ void updt_IO_switch_enc_fx(
hTdCngEnc->old_enr_index = s_min( mult( shl( hTdCngEnc->old_enr_index, 1 ), 32459 ), 127 ); /*32459 = 2/(STEP_SID/STEP_AMR_WB_SID)*/
move16();
}
+
/* Perform preemphasis of the old input signal @16kHz */
st->mem_preemph16k_fx = 0;
move16();
- PREEMPH_FX( st->old_inp_16k_fx, PREEMPH_FAC_16k, L_INP_MEM, &( st->mem_preemph16k_fx ) );
+ preemph_fx( st->old_inp_16k_fx, PREEMPH_FAC_16k, L_INP_MEM, &( st->mem_preemph16k_fx ) );
Scale_sig( st->old_inp_16k_fx, L_INP_MEM, st->prev_Q_new );
+
/* reset TD BWE buffers */
set16_fx( hBWE_TD->old_speech_shb_fx, 0, L_LOOK_16k + L_SUBFR16k );
set16_fx( hBWE_TD->old_speech_wb_fx, 0, ( L_LOOK_12k8 + L_SUBFR ) * 5 / 16 );
@@ -295,6 +298,7 @@ void updt_IO_switch_enc_fx(
return;
}
+
/*-------------------------------------------------------------------*
* updt_enc_common_fx()
*
@@ -302,230 +306,6 @@ void updt_IO_switch_enc_fx(
*-------------------------------------------------------------------*/
void updt_enc_common_fx(
- Encoder_State *st, /* i/o: encoder state structure */
- const Word16 Etot, /* i : total energy */
- const Word16 Q_new /* i : CUrrent frame scaling */
-)
-{
- /*---------------------------------------------------------------------*
- * Updates - main main codec parameters
- *---------------------------------------------------------------------*/
-
- st->last_sr_core = st->sr_core;
- move32();
- st->last_codec_mode = st->codec_mode;
- move16();
- st->last_L_frame = st->L_frame;
- move16();
- st->last_core = st->core;
- move16();
-
- st->last_core_brate = st->core_brate;
- move32();
- st->last_total_brate = st->total_brate;
- move32();
- st->last_extl = st->extl;
- move16();
- st->last_input_bwidth = st->input_bwidth;
- move16();
- st->last_bwidth = st->bwidth;
- move16();
- IF( GT_16( st->element_mode, EVS_MONO ) )
- {
- st->hNoiseEst->Etot_last_32fx = L_deposit_h( Etot );
- }
- ELSE
- {
- st->hNoiseEst->Etot_last_fx = Etot;
- }
- move16();
- st->last_coder_type_raw = st->coder_type_raw;
- move16();
-
- st->prev_Q_new = Q_new;
- move16();
-
- test();
- IF( GT_32( st->core_brate, SID_2k40 ) && st->hDtxEnc != NULL )
- {
- st->hDtxEnc->last_active_brate = st->total_brate;
- move32();
- }
-
- IF( st->hBWE_TD != NULL )
- {
- st->hBWE_TD->prev_coder_type = st->coder_type;
- move16();
- IF( EQ_16( st->core, HQ_CORE ) )
- {
- /* in the HQ core, coder_type is not used so it could have been set to anything */
- st->hBWE_TD->prev_coder_type = GENERIC;
- move16();
- }
- }
-
- test();
- IF( st->Opt_DTX_ON && st->hTdCngEnc != NULL )
- {
- IF( GT_32( st->core_brate, SID_2k40 ) )
- {
- IF( EQ_16( st->hDtxEnc->first_CNG, 1 ) )
- {
- IF( GE_16( st->hTdCngEnc->act_cnt, BUF_DEC_RATE ) )
- {
- st->hTdCngEnc->act_cnt = 0;
- move16();
- }
- st->hTdCngEnc->act_cnt = add( st->hTdCngEnc->act_cnt, 1 );
- move16();
-
- test();
- IF( EQ_16( st->hTdCngEnc->act_cnt, BUF_DEC_RATE ) && st->hTdCngEnc->ho_hist_size > 0 )
- {
- st->hTdCngEnc->ho_hist_size = sub( st->hTdCngEnc->ho_hist_size, 1 );
- move16();
- }
- }
-
- test();
- test();
- test();
- IF( EQ_16( st->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->hDtxEnc->first_CNG, 1 ) )
- {
- st->hTdCngEnc->act_cnt2 = add( st->hTdCngEnc->act_cnt2, 1 );
- st->hTdCngEnc->act_cnt2 = s_min( st->hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD );
- move16();
- move16();
-
- test();
- test();
- test();
- IF( ( EQ_16( st->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && GE_16( st->hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) )
- {
- }
- }
- }
-
- test();
- test();
- test();
- IF( ( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, FRAME_NO_DATA ) ) && st->hDtxEnc->first_CNG == 0 && EQ_16( st->cng_type, LP_CNG ) )
- {
- st->hDtxEnc->first_CNG = 1;
- move16();
- }
- }
-
- /*-----------------------------------------------------------------*
- * Increase the counter of initialization frames
- * Limit the max number of init. frames
- *-----------------------------------------------------------------*/
-
- if ( LT_16( st->ini_frame, MAX_FRAME_COUNTER ) )
- {
- st->ini_frame = add( st->ini_frame, 1 );
- move16();
- }
-
- /* synchronisation of CNG seeds */
- test();
- test();
- test();
- IF( st->hTdCngEnc != NULL && NE_32( st->core_brate, FRAME_NO_DATA ) && NE_32( st->core_brate, SID_2k40 ) && NE_16( st->core, AMR_WB_CORE ) )
- {
- Random( &( st->hTdCngEnc->cng_seed ) );
- Random( &( st->hTdCngEnc->cng_ener_seed ) );
- }
-
- /*---------------------------------------------------------------------*
- * Updates - MODE2
- *---------------------------------------------------------------------*/
-
- IF( EQ_16( st->element_mode, EVS_MONO ) && EQ_16( st->mdct_sw, MODE2 ) )
- {
- st->codec_mode = MODE2;
- move16();
-
- st->sr_core = getCoreSamplerateMode2( EVS_MONO, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, 0 );
- move32();
-
- // st->L_frame = extract_l(Mult_32_16(st->sr_core, INV_FRAME_PER_SEC_Q15)); /*(int16_t)(st->sr_core / FRAMES_PER_SEC);*/
-
- IF( EQ_32( st->sr_core, INT_FS_12k8 ) )
- {
- st->preemph_fac = PREEMPH_FAC;
- st->gamma = GAMMA1;
- st->L_frame = L_FRAME;
- move16();
- move16();
- move16();
- }
- ELSE
- {
- st->preemph_fac = PREEMPH_FAC_16k;
- st->gamma = GAMMA16k;
- st->L_frame = L_FRAME16k;
- move16();
- move16();
- move16();
- }
-
- st->igf = getIgfPresent_fx( EVS_MONO, st->total_brate, st->bwidth, st->rf_mode );
- move16();
- }
-
- /* update FER clas */
- IF( NE_16( st->core, AMR_WB_CORE ) )
- {
- st->last_clas = st->clas;
- move16();
- }
-
- /* Update Core */
- core_encode_update_fx( st );
-
- /*---------------------------------------------------------------------*
- * RF mode updates
- *---------------------------------------------------------------------*/
-
- IF( st->rf_mode )
- {
- IF( st->hSC_VBR != NULL )
- {
- st->hSC_VBR->last_nelp_mode = 0;
- move16();
- IF( EQ_16( st->hRF->rf_frame_type, RF_NELP ) )
- {
- st->hSC_VBR->last_nelp_mode = 1;
- move16();
- }
- }
- }
-
- st->rf_mode_last = st->rf_mode;
- move16();
-
- IF( st->Opt_RF_ON )
- {
- st->L_frame = L_FRAME;
- st->rf_mode = 1;
- move16();
- move16();
- }
-
- /*---------------------------------------------------------------------*
- * Other updates
- *---------------------------------------------------------------------*/
-
- test();
- IF( GT_16( st->element_mode, EVS_MONO ) && st->hTcxEnc != NULL )
- {
- }
- return;
-}
-
-
-void updt_enc_common_ivas_fx(
Encoder_State *st, /* i/o: encoder state structure */
const Word16 Q_new /* i : CUrrent frame scaling */
)
@@ -703,7 +483,7 @@ void updt_enc_common_ivas_fx(
}
/* Update Core */
- core_encode_update_ivas_fx( st );
+ core_encode_update_fx( st );
/*---------------------------------------------------------------------*
* RF mode updates
diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c
index 4335225cac66e2b1e65e986785a76cbebd14ab0e..7c541478058975c0b623e303c7d9a8833b7e8a7f 100644
--- a/lib_enc/vad_fx.c
+++ b/lib_enc/vad_fx.c
@@ -229,202 +229,6 @@ static void sign_thr_snr_acc_fx(
*-----------------------------------------------------------------*/
Word16 dtx_hangover_addition_fx(
- Encoder_State *st_fx, /* i/o: encoder state structure */
- const Word16 vad_flag, /* i Q0 */
- const Word16 lp_snr, /* i Q8 */
- const Word16 cldfb_subtraction, /* i Q0 number of DTX-HO frames CLDFB wants to reduce */
- Word16 *vad_hover_flag_ptr,
- VAD_HANDLE hVAD, /* i/o: VAD data handle */
- NOISE_EST_HANDLE hNoiseEst /* i : Noise estimation handle */
-)
-{
- Word16 hangover_short_dtx; /* Q0 */
- Word16 flag_dtx; /* Q0 */
- Word16 tmp; /* Q0 */
- if ( hNoiseEst == NULL )
- {
- hNoiseEst = st_fx->hNoiseEst;
- move16();
- }
-
- if ( hVAD == NULL )
- {
- move16();
- hVAD = st_fx->hVAD;
- }
-
-
- flag_dtx = 0;
- move16();
-
- /* Determine initial hangover length */
- hangover_short_dtx = 2;
- move16();
-
- test();
- test();
- if ( ( ( LT_16( lp_snr, ( 16 * 256 ) ) ) && ( st_fx->input_bwidth != NB ) ) || ( GT_16( hVAD->prim_act_he_fx, 31130 ) ) ) /*.95*Q15*/
- {
- hangover_short_dtx = 3;
- move16();
- }
-
- /* Adjust hangover according to activity history */
- IF( GT_16( hVAD->vad_prim_cnt_16, 12 ) ) /* 12 requires roughly > 80% primary activity */
- {
- hangover_short_dtx = add( hangover_short_dtx, 2 );
- }
-
- IF( GT_16( hVAD->vad_flag_cnt_50, 40 ) ) /* 40 requires roughtly > 80% flag activity */
- {
- hangover_short_dtx = add( hangover_short_dtx, 5 );
- }
-
- /* Keep hangover_short lower than maximum hangover count */
- if ( GT_16( hangover_short_dtx, HANGOVER_LONG_FX - 1 ) )
- {
- hangover_short_dtx = ( HANGOVER_LONG_FX - 1 );
- move16();
- }
-
- /* Only allow short HO if not sufficient active frames in clean speech*/
-
- tmp = 3;
- move16(); /* default for EVS*/
- if ( EQ_16( st_fx->core, AMR_WB_CORE ) )
- {
- tmp = 2;
- move16(); /* default for AMRWBIO*/
- }
-
- /* need to be a bit stricter with the DTXHO in very clean WB, SWB cond for EVS12k8VAD section */
- test();
- test();
- if ( ( NE_16( st_fx->input_bwidth, NB ) ) /* WB or SWB or FB */
- && ( NE_16( st_fx->core, AMR_WB_CORE ) ) && ( GT_16( lp_snr, 25 * 256 ) ) )
- {
- tmp = 2;
- move16();
- }
-
- /* limit dtx hangover addition up to "tmp" frames in clean cond */
- IF( tmp != 0 )
- {
- test();
- test();
- test();
- if ( ( GT_16( hangover_short_dtx, tmp ) ) && ( ( LT_16( hVAD->vad_prim_cnt_16, 7 ) ) || ( ( GT_16( lp_snr, ( 16 * 256 ) ) ) && ( LT_16( hVAD->prim_act_he_fx, 27853 ) ) /*0.85f*2^15 */
- ) ) )
- {
- hangover_short_dtx = tmp;
- move16();
- }
- }
-
-
- /* hangover adjustment from combined FFT+CLDFBVAD */
- IF( NE_16( st_fx->core, AMR_WB_CORE ) )
- {
- hangover_short_dtx = sub( hangover_short_dtx, cldfb_subtraction ); /* Q0 */
- hangover_short_dtx = s_max( hangover_short_dtx, 0 );
- }
-
- IF( vad_flag != 0 ) /* Speech present */
- {
- flag_dtx = 1;
- move16();
-
- /* Add hangover after sufficient # of active frames or sufficient activity during last second */
- test();
- if ( ( GE_16( hVAD->nb_active_frames, ACTIVE_FRAMES_FX ) ) || ( GT_16( hVAD->vad_flag_cnt_50, 45 ) ) ) /* 45 requires roughly > 90% flag activity */
- {
- hVAD->hangover_cnt_dtx = 0;
- move16();
- }
-
- /* inside HO period */
- test();
- IF( ( LT_16( hVAD->hangover_cnt_dtx, HANGOVER_LONG_FX ) ) && ( hVAD->hangover_cnt_dtx != 0 ) )
- {
- hVAD->hangover_cnt_dtx = add( hVAD->hangover_cnt_dtx, 1 ); /* Q0 */
- move16();
- }
- hVAD->hangover_terminate_flag = 0;
- move16(); /* float fix FIX_HO_TERMINATE */
-
- /* Music hangover when music detected */
- test();
- test();
- test();
- if ( ( GT_16( hVAD->prim_act_he_fx, 31129 ) ) && ( GT_16( hNoiseEst->Etot_lp_fx, 40 * 256 ) ) && ( GT_16( hVAD->vad_prim_cnt_16, 14 ) ) && ( GT_16( hVAD->vad_flag_cnt_50, 48 ) ) ) /* 45 requires roughly > 95% flag activity */
- {
- hVAD->hangover_cnt_music = 0;
- move16();
- }
-
- /* inside Music HO period */
- test();
- IF( ( LT_16( hVAD->hangover_cnt_music, HANGOVER_LONG_MUSIC_FX ) ) && ( hVAD->hangover_cnt_music != 0 ) )
- {
- hVAD->hangover_cnt_music = add( hVAD->hangover_cnt_music, 1 );
- move16();
- }
- }
- ELSE
- {
- /* Reset the counter of speech frames necessary to start hangover algorithm */
- IF( LT_16( hVAD->hangover_cnt_dtx, HANGOVER_LONG_FX ) ) /* inside HO period */
- {
- hVAD->hangover_cnt_dtx = add( hVAD->hangover_cnt_dtx, 1 );
- move16();
- }
- IF( LT_16( hVAD->hangover_cnt_music, HANGOVER_LONG_MUSIC_FX ) ) /* inside HO period */
- {
- hVAD->hangover_cnt_music = add( hVAD->hangover_cnt_music, 1 );
- move16();
- }
-
- /* fast terminate DTX hangover if st->hangover_terminate_flag is set */
- IF( hVAD->hangover_terminate_flag != 0 )
- {
- hVAD->hangover_cnt = HANGOVER_LONG_FX;
- move16();
- hVAD->hangover_cnt_dtx = HANGOVER_LONG_FX;
- move16();
- hVAD->hangover_terminate_flag = 0;
- move16();
- /* Only shorten music hangover when low energy frames */
- if ( LT_16( hNoiseEst->Etot_lp_fx, 20 * 256 ) )
- {
- hVAD->hangover_cnt_music = HANGOVER_LONG_MUSIC_FX;
- move16();
- }
- }
-
- if ( LE_16( hVAD->hangover_cnt_dtx, hangover_short_dtx ) ) /* "hard" hangover */
- {
- flag_dtx = 1;
- move16();
- }
-
- if ( LE_16( hVAD->hangover_cnt_music, 15 ) ) /* "hard" hangover music */
- {
- flag_dtx = 1;
- move16();
- }
- }
-
-
- test();
- if ( flag_dtx != 0 && st_fx->localVAD == 0 )
- {
- *vad_hover_flag_ptr = 1;
- move16();
- }
-
- return flag_dtx;
-}
-Word16 ivas_dtx_hangover_addition_fx(
Encoder_State *st_fx, /* i/o: encoder state structure */
const Word16 vad_flag, /* i Q0 */
const Word16 lp_snr, /* i Q8 */
@@ -437,6 +241,7 @@ Word16 ivas_dtx_hangover_addition_fx(
Word16 hangover_short_dtx; /* Q0 */
Word16 flag_dtx; /* Q0 */
Word16 tmp; /* Q0 */
+
if ( hNoiseEst == NULL )
{
hNoiseEst = st_fx->hNoiseEst;
@@ -449,7 +254,6 @@ Word16 ivas_dtx_hangover_addition_fx(
hVAD = st_fx->hVAD;
}
-
flag_dtx = 0;
move16();
@@ -484,7 +288,6 @@ Word16 ivas_dtx_hangover_addition_fx(
}
/* Only allow short HO if not sufficient active frames in clean speech*/
-
tmp = 3;
move16(); /* default for EVS*/
if ( EQ_16( st_fx->core, AMR_WB_CORE ) )
@@ -503,7 +306,7 @@ Word16 ivas_dtx_hangover_addition_fx(
move16();
}
- /* limit dtx hangover addition up to "tmp" frames in clean cond */
+ /* limit dtx hangover addition up to "tmp" frames in clean cond */
IF( tmp != 0 )
{
test();
@@ -517,13 +320,13 @@ Word16 ivas_dtx_hangover_addition_fx(
}
}
-
/* hangover adjustment from combined FFT+CLDFBVAD */
IF( NE_16( st_fx->core, AMR_WB_CORE ) )
{
hangover_short_dtx = sub( hangover_short_dtx, cldfb_subtraction ); /*Q0*/
hangover_short_dtx = s_max( hangover_short_dtx, 0 );
}
+
IF( vad_flag != 0 ) /* Speech present */
{
flag_dtx = 1;
@@ -551,10 +354,24 @@ Word16 ivas_dtx_hangover_addition_fx(
test();
test();
test();
- if ( ( GT_16( hVAD->prim_act_he_fx, 32113 ) ) && ( GT_16( hNoiseEst->Etot_lp_fx, 40 * 256 ) ) && ( GT_16( hVAD->vad_prim_cnt_16, 14 ) ) && ( GT_16( hVAD->vad_flag_cnt_50, 48 ) ) ) /* 45 requires roughly > 95% flag activity */
+ IF( st_fx->element_mode == EVS_MONO )
{
- hVAD->hangover_cnt_music = 0;
- move16();
+ if ( ( GT_16( hVAD->prim_act_he_fx, 31129 ) ) && ( GT_16( hNoiseEst->Etot_lp_fx, 40 * 256 ) ) && ( GT_16( hVAD->vad_prim_cnt_16, 14 ) ) && ( GT_16( hVAD->vad_flag_cnt_50, 48 ) ) ) /* 45 requires roughly > 95% flag activity */
+ {
+ hVAD->hangover_cnt_music = 0;
+ move16();
+ }
+ }
+ ELSE
+ {
+ test();
+ test();
+ test();
+ if ( ( GT_16( hVAD->prim_act_he_fx, 32113 ) ) && ( GT_16( hNoiseEst->Etot_lp_fx, 40 * 256 ) ) && ( GT_16( hVAD->vad_prim_cnt_16, 14 ) ) && ( GT_16( hVAD->vad_flag_cnt_50, 48 ) ) ) /* 45 requires roughly > 95% flag activity */
+ {
+ hVAD->hangover_cnt_music = 0;
+ move16();
+ }
}
/* inside Music HO period */
@@ -609,9 +426,7 @@ Word16 ivas_dtx_hangover_addition_fx(
}
}
-
test();
-
IF( flag_dtx != 0 && st_fx->localVAD == 0 )
{
*vad_hover_flag_ptr = 1;
@@ -625,6 +440,8 @@ Word16 ivas_dtx_hangover_addition_fx(
return flag_dtx;
}
+
+
/*-----------------------------------------------------------------*
* wb_vad()
*
@@ -745,8 +562,7 @@ Word16 wb_vad_fx(
st_fx->max_band = 19;
move16();
}
-
- IF( 1 ) // st_fx->Opt_SC_VBR ) /* this keep 26.444 BE */
+ IF( st_fx->Opt_SC_VBR || ( !st_fx->Opt_SC_VBR && st_fx->element_mode == EVS_MONO ) ) /* this keep 26.444 BE */
{
last_7k2_coder_type = st_fx->hSC_VBR->last_7k2_coder_type;
move16();
diff --git a/lib_isar/isar_MSPred.c b/lib_isar/isar_MSPred.c
index aaa26903b5bb6700c23542d1a0d2d9953a41dcc1..6698a12b35500a5ddd0c661119547186b1e8aa6f 100644
--- a/lib_isar/isar_MSPred.c
+++ b/lib_isar/isar_MSPred.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_isar/isar_NoiseGen.c b/lib_isar/isar_NoiseGen.c
deleted file mode 100644
index c0b5d16edc2d89a30fa8091019a00d60263cd639..0000000000000000000000000000000000000000
--- a/lib_isar/isar_NoiseGen.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-#include
-#include "options.h"
-#include "prot_fx.h"
-#include "isar_lcld_prot.h"
-#include "wmc_auto.h"
-
-
-/*------------------------------------------------------------------------------------------*
- * Function DeleteNoiseGen()
- *
- *
- *------------------------------------------------------------------------------------------*/
-
-void DeleteNoiseGen( NoiseGen *psNoiseGen )
-{
- free( psNoiseGen->pfNoiseBuffer );
- free( psNoiseGen );
-
- return;
-}
-
-extern Word32 GetNoise_fx( NoiseGen *psNoiseGen );
diff --git a/lib_isar/isar_PerceptualModel.c b/lib_isar/isar_PerceptualModel.c
index 54265bc5ee5e06f9c14e79296fa5db35f42cb592..cbc878b7c8dc9439af2c3aae0217579474bbe93e 100644
--- a/lib_isar/isar_PerceptualModel.c
+++ b/lib_isar/isar_PerceptualModel.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -83,6 +83,7 @@ static inline Word16 LogAdd_fx(
return iRetVal;
}
+#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS
/*------------------------------------------------------------------------------------------*
* Function LogAdd()
@@ -112,6 +113,7 @@ static inline Word32 LogAdd(
return iRetVal;
}
+#endif
/*------------------------------------------------------------------------------------------*
* Function PerceptualModel()
@@ -175,6 +177,9 @@ void PerceptualModel_fx(
return;
}
+
+#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS
+
/*------------------------------------------------------------------------------------------*
* Function PerceptualModel()
*
@@ -232,6 +237,8 @@ void PerceptualModel(
return;
}
+#endif
+
/*------------------------------------------------------------------------------------------*
* Function PerceptualModelStereo()
@@ -239,6 +246,8 @@ void PerceptualModel(
*
*------------------------------------------------------------------------------------------*/
+#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS
+
void PerceptualModelStereo(
const Word32 iMaxQuantBands,
const Word32 *piMSFlags,
@@ -348,6 +357,9 @@ void PerceptualModelStereo(
return;
}
+
+#endif
+
void PerceptualModelStereo_fx(
const Word32 iMaxQuantBands,
const Word32 *piMSFlags,
diff --git a/lib_isar/isar_PredDecoder.c b/lib_isar/isar_PredDecoder.c
index 5e68d90c90ff621b83c5498e0ef082567874be4a..9023009efb32c18addd79bfaee446d3f4b9eacd6 100644
--- a/lib_isar/isar_PredDecoder.c
+++ b/lib_isar/isar_PredDecoder.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -359,7 +359,7 @@ Word16 ReadPredictors_fx(
return iBitsRead;
}
-
+#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS
/* PLC_IMPROVEMENT */
void SetDecodingPassed(
PredictionDecoder *psPredictionDecoder )
@@ -376,6 +376,7 @@ void SetDecodingPassed(
return;
}
+#endif
Word32 AnyDecodingUnresolved(
diff --git a/lib_isar/isar_PredEncoder.c b/lib_isar/isar_PredEncoder.c
index c933e7f36e926fc85681c343801e09958f5e1486..1cad13a8c85e3598d77135c4d097abe6ff30a741 100644
--- a/lib_isar/isar_PredEncoder.c
+++ b/lib_isar/isar_PredEncoder.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -464,7 +464,7 @@ void ComputePredictors_fx(
Word16 w_norm3 = W_norm( W_temp2 );
W_temp2 = W_shr( W_temp2, 32 - w_norm3 );
pfRxxImag_fx[1] = W_extract_l( W_temp2 );
- Word16 final_w_norm = min( w_norm1, min( w_norm2, w_norm3 ) );
+ Word16 final_w_norm = s_min( w_norm1, s_min( w_norm2, w_norm3 ) );
pfRxxReal_fx[0] = L_shr( pfRxxReal_fx[0], w_norm1 - final_w_norm ); // Q8 + final_w_norm
pfRxxReal_fx[1] = L_shr( pfRxxReal_fx[1], w_norm2 - final_w_norm ); // Q8 + final_w_norm
pfRxxImag_fx[1] = L_shr( pfRxxImag_fx[1], w_norm3 - final_w_norm ); // Q8 + final_w_norm
@@ -541,7 +541,7 @@ void ComputePredictors_fx(
// fGain_fx = sub(sub(32767, extract_h(Mpy_32_32(fA1Real_fx, fA1Real_fx))), extract_h(Mpy_32_32(fA1Imag_fx, fA1Imag_fx)));
// fGain_fx = extract_l(L_shl(L_temp, 2*sf_r));
fGain_fx = extract_l( L_temp );
- fGain_fx = max( 1, fGain_fx );
+ fGain_fx = L_max( 1, fGain_fx );
fGain_fx = Inv16( extract_l( fGain_fx ), &exp ); // Q15 - exp
// fGain_fx = L_shl(fGain_fx, exp); //Q15
// fBitGain = 0.65f * log2f(fGain) * (float)(iNumBlocksPerPredCoef)-(float)(PRED_QUNAT_FILTER_MAG_BITS + PRED_QUANT_FILTER_PHASE_BITS); // Wrong fix (iNumBlocks-1)
diff --git a/lib_isar/isar_RMSEnvGrouping.c b/lib_isar/isar_RMSEnvGrouping.c
index 28685b23e62190c15218172be872a01e7f981923..ab6237a5395da32f9392ece1f9dec1de41285aab 100644
--- a/lib_isar/isar_RMSEnvGrouping.c
+++ b/lib_isar/isar_RMSEnvGrouping.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -49,7 +49,7 @@
*
*-------------------------------------------------------------------*/
-Word32 Inv_grp_length[17] = {
+static const Word32 Inv_grp_length[17] = {
// Q31
0,
2147483647,
@@ -867,8 +867,8 @@ static void LimitRMSEnvelope(
IF( GT_32( iDelta, iRMSDeltaMax ) )
{
-#ifdef DEBUG_VERBOSE
- printf( "WARNING RMS envelope delta limited\n" );
+#ifdef DEBUGGING
+ printf( "Warning: RMS envelope delta limited!\n" );
#endif
piRMSEnvelope[iBand] = L_add( L_sub( iDelta, iRMSDeltaMax ), piRMSEnvelope[iBand] );
}
@@ -887,8 +887,8 @@ static void LimitRMSEnvelope(
IF( LT_32( iDelta, iRMSDeltaMin ) )
{
-#ifdef DEBUG_VERBOSE
- printf( "WARNING RMS envelope delta limited\n" );
+#ifdef DEBUGGING
+ printf( "Warning: RMS envelope delta limited!\n" );
#endif
piRMSEnvelope[iBand] = L_add( piRMSEnvelope[iBand], L_sub( iRMSDeltaMin, iDelta ) );
}
diff --git a/lib_isar/isar_cnst.h b/lib_isar/isar_cnst.h
index f666b453e8543423494b9603d6b496b800684f5a..449577f4374b17b1b64bbc5088af007af5b30c27 100644
--- a/lib_isar/isar_cnst.h
+++ b/lib_isar/isar_cnst.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_isar/isar_lc3plus_common.c b/lib_isar/isar_lc3plus_common.c
index f7fe0db32ebeba38eeec378a57c47154a8031046..68e160538c27e69f4db5a640a746eb8a6a273a2b 100644
--- a/lib_isar/isar_lc3plus_common.c
+++ b/lib_isar/isar_lc3plus_common.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_isar/isar_lc3plus_common.h b/lib_isar/isar_lc3plus_common.h
index 3b52e5b3f15c0ce29c25f7d640140530db05afb6..5af4f80a81a1ac696ac05e97d2b963d9d18ca7b0 100644
--- a/lib_isar/isar_lc3plus_common.h
+++ b/lib_isar/isar_lc3plus_common.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_isar/isar_lc3plus_dec.c b/lib_isar/isar_lc3plus_dec.c
index 2ac21e4d3670fa1542c9e0752ef448eefa0b8933..7f158cc04c686e2c9831bab394256461a9d7d7c5 100644
--- a/lib_isar/isar_lc3plus_dec.c
+++ b/lib_isar/isar_lc3plus_dec.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_isar/isar_lc3plus_dec.h b/lib_isar/isar_lc3plus_dec.h
index 8328b1fa767274db5be43ed4a8bcdc64d4a79cee..461e15dc8cdfc24c55b7f45d2fe03ad566b286e5 100644
--- a/lib_isar/isar_lc3plus_dec.h
+++ b/lib_isar/isar_lc3plus_dec.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_isar/isar_lc3plus_enc.c b/lib_isar/isar_lc3plus_enc.c
index 60121a11f7e96c8bbb219bfdf1897513d0f1575f..9795833a341296110660fef758086aaa4fc3556a 100644
--- a/lib_isar/isar_lc3plus_enc.c
+++ b/lib_isar/isar_lc3plus_enc.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -48,11 +48,11 @@ static int32_t limit_per_channel_bitrate( LC3PLUS_CONFIG config,
switch ( config.lc3plus_frame_duration_us )
{
case 10000:
- return min( per_channel_bitrate, 500000 );
+ return L_min( per_channel_bitrate, 500000 );
case 5000:
- return min( per_channel_bitrate, 600000 );
+ return L_min( per_channel_bitrate, 600000 );
case 2500:
- return min( per_channel_bitrate, 672000 );
+ return L_min( per_channel_bitrate, 672000 );
default:
assert( false && "unreachable" );
}
@@ -62,13 +62,13 @@ static int32_t limit_per_channel_bitrate( LC3PLUS_CONFIG config,
{
case 48000:
case 32000:
- return min( per_channel_bitrate, 320000 );
+ return L_min( per_channel_bitrate, 320000 );
case 24000:
- return min( per_channel_bitrate, 314400 );
+ return L_min( per_channel_bitrate, 314400 );
case 16000:
- return min( per_channel_bitrate, 221600 );
+ return L_min( per_channel_bitrate, 221600 );
case 8000:
- return min( per_channel_bitrate, 114400 );
+ return L_min( per_channel_bitrate, 114400 );
default:
assert( false && "unreachable" );
}
@@ -558,7 +558,7 @@ ivas_error ISAR_LC3PLUS_ENC_Encode(
FOR( UWord32 iSampleInt16 = 0; iSampleInt16 < numSamplesPerLC3plusChannel; iSampleInt16++ )
{
ivasSampleIndex = iSampleInt16 + iMediaTime * numSamplesPerLC3plusChannel;
- handle->pcm_conversion_buffer[iSampleInt16] = (Word16) max( INT16_MIN, min( L_shr( pcm_in[iEnc][ivasSampleIndex], q_in[iEnc] ), INT16_MAX ) );
+ handle->pcm_conversion_buffer[iSampleInt16] = (Word16) L_max( INT16_MIN, L_min( L_shr( pcm_in[iEnc][ivasSampleIndex], q_in[iEnc] ), INT16_MAX ) );
}
ftdIndex = iMediaTime * handle->num_encs + iEnc;
diff --git a/lib_isar/isar_lc3plus_enc.h b/lib_isar/isar_lc3plus_enc.h
index 6dd08733fa2deeae01a83473ffa1854e65009713..793da7b9fba9404e05dfaec15cd1a8b85bd1b055 100644
--- a/lib_isar/isar_lc3plus_enc.h
+++ b/lib_isar/isar_lc3plus_enc.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_isar/isar_lc3plus_payload.c b/lib_isar/isar_lc3plus_payload.c
index 2493aa6a30eb9ca3ab8f493dc1dad4e057666b98..0a201b0743e29d7120afce088699f244c882e8d4 100644
--- a/lib_isar/isar_lc3plus_payload.c
+++ b/lib_isar/isar_lc3plus_payload.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_isar/isar_lc3plus_payload.h b/lib_isar/isar_lc3plus_payload.h
index 580a58ca651defe96eeb84229b8f07b3407a756c..7ebdb33426d0dbac4246e4c146703876e9404eb7 100644
--- a/lib_isar/isar_lc3plus_payload.h
+++ b/lib_isar/isar_lc3plus_payload.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c
index 8bb931e3f7e6f23e1d26a6b8b2370691942ae692..d4d6074f8f9ac193e3ec122bc05d036a94cf5f27 100644
--- a/lib_isar/isar_lcld_decoder.c
+++ b/lib_isar/isar_lcld_decoder.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -105,9 +105,6 @@ struct LCLD_DECODER
Word32 ***pppiQLCLDImag;
PredictionDecoder *psPredictionDecoder;
-
-
- NoiseGen *psNoiseGen;
};
static void CreateDecodeTable( LCLDDecoder *psLCLDDecoder, Word32 num, const UWord16 ( *ppuiEncTable )[2], Word32 iSize, Word32 iReadLength, UWord32 *iTables );
@@ -604,7 +601,6 @@ ivas_error CreateLCLDDecoder(
{
return error;
}
- psLCLDDecoder->psNoiseGen = NULL; /* CreateNoiseGen(); No noise fill for now*/
*psLCLDDecoder_out = psLCLDDecoder;
return IVAS_ERR_OK;
@@ -766,10 +762,6 @@ void DeleteLCLDDecoder(
psLCLDDecoder->psPredictionDecoder = NULL;
}
- IF( psLCLDDecoder->psNoiseGen != NULL )
- {
- DeleteNoiseGen( psLCLDDecoder->psNoiseGen );
- }
free( psLCLDDecoder );
}
@@ -788,7 +780,7 @@ static void ApplyRMSEnvelope_fx( const Word32 iNumBands, const Word32 *piBandwid
static void ReplaceSign_fx( const Word32 iNumBlocks, const Word32 iNumLCLDBands, Word32 **ppiSignReal, Word32 **ppiSignImag, Word32 **ppfReal, Word32 **ppfImag, const Word32 *piBandwidths );
-static void InvQuantizeSpectrum_fx( const Word32 iNumGroups, const Word32 *piGroupLengths, const Word32 iNumBands, const Word32 *piBandwidths, Word32 **ppiAlloc, Word32 **ppiQReal, Word32 **ppiQImag, Word32 **ppfReal, Word32 **ppfImag, NoiseGen *psNoiseGen );
+static void InvQuantizeSpectrum_fx( const Word32 iNumGroups, const Word32 *piGroupLengths, const Word32 iNumBands, const Word32 *piBandwidths, Word32 **ppiAlloc, Word32 **ppiQReal, Word32 **ppiQImag, Word32 **ppfReal, Word32 **ppfImag );
static void InvMSCoding_fx( const Word32 iNumBlocks, const Word32 iNumBands, const Word32 *piBandwidths, const Word32 iMSMode, const Word32 *piMSFlags, const Word32 *piLRPhaseDiffs, const Word32 *piMSPredCoefs, Word32 ***pppfReal, Word32 ***pppfImag );
@@ -1010,8 +1002,7 @@ Word32 DecodeLCLDFrame(
psLCLDDecoder->pppiAlloc[n],
psLCLDDecoder->pppiQLCLDReal[n],
psLCLDDecoder->pppiQLCLDImag[n],
- pppfLCLDReal_fx[n], pppfLCLDImag_fx[n],
- psLCLDDecoder->psNoiseGen );
+ pppfLCLDReal_fx[n], pppfLCLDImag_fx[n] );
ReplaceSign_fx( psLCLDDecoder->iNumBlocks, psLCLDDecoder->iNumBands,
psLCLDDecoder->pppiLCLDSignReal[n],
@@ -1100,7 +1091,7 @@ Word32 DecodeLCLDFrame(
}
IF( NE_32( real_max, 0 ) || NE_32( imag_max, 0 ) )
{
- exp = min( exp2, exp1 );
+ exp = s_min( exp2, exp1 );
*Q_out = add( *Q_out, sub( exp, 3 ) );
FOR( n = 0; n < psLCLDDecoder->iChannels; n++ )
{
@@ -1281,9 +1272,7 @@ static void InvQuantizeSpectrum_fx(
Word32 **ppiQReal,
Word32 **ppiQImag,
Word32 **ppfReal,
- Word32 **ppfImag,
- NoiseGen *psNoiseGen /* Pass in NULL to switch off noise gen */
-)
+ Word32 **ppfImag )
{
Word32 b, k, n;
Word32 iBlockOffest, iFBOffset;
@@ -1322,17 +1311,6 @@ static void InvQuantizeSpectrum_fx(
iFBOffset++;
}
}
- ELSE IF( psNoiseGen != NULL )
- {
- FOR( m = 0; m < piBandwidths[b]; m++ )
- {
- ppfReal[iBlockOffest][iFBOffset] = Mpy_32_16_1( GetNoise_fx( psNoiseGen ), 22938 ); // Q(14 + 15 -15 )=Q14
- move32();
- ppfImag[iBlockOffest][iFBOffset] = Mpy_32_16_1( GetNoise_fx( psNoiseGen ), 22938 ); // Q(14+ 15 -15 )=Q14
- move32();
- iFBOffset++;
- }
- }
ELSE
{
iFBOffset = L_add( iFBOffset, piBandwidths[b] );
@@ -1585,7 +1563,7 @@ static Word32 ReadMSInformation(
}
ELSE
{
- printf( "ERROR UNSUPPORTED MS MODE\n" );
+ printf( "Error in ReadMSInformation() - unsupported MS mode information!\n" );
}
return iBitsRead;
diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c
index 760d653f5dff68f9ecaedd19fb23be97711ccbb1..8f6ed398315a4e87bd5934513bc0d29971268057 100644
--- a/lib_isar/isar_lcld_encoder.c
+++ b/lib_isar/isar_lcld_encoder.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -135,7 +135,8 @@ static Word32 UnQuantize_fx(
}
return fVal_fx;
}
-static void PackReal(
+
+static void PackReal_fx(
const Word32 iChannels,
const Word32 iNumBlocks,
Word32 ***pppfReal,
@@ -159,6 +160,7 @@ static void PackReal(
}
}
}
+
/*------------------------------------------------------------------------------------------*
* Function CreateLCLDEncoder()
*
@@ -589,7 +591,7 @@ Word32 EncodeLCLDFrame(
assert( available_bits <= pBits->buf_len * 8 );
IF( EQ_32( psLCLDEncoder->iRealOnlyOut, 1 ) )
{
- PackReal( psLCLDEncoder->iChannels, psLCLDEncoder->iNumBlocks * 2, pppfLCLDReal_fx, pppfLCLDImag_fx );
+ PackReal_fx( psLCLDEncoder->iChannels, psLCLDEncoder->iNumBlocks * 2, pppfLCLDReal_fx, pppfLCLDImag_fx );
}
/* Do MS calc here */
IF( EQ_32( psLCLDEncoder->iChannels, 2 ) )
@@ -770,6 +772,7 @@ Word32 EncodeLCLDFrame(
return 0;
}
+#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS
/*------------------------------------------------------------------------------------------*
* Function GetNumGroups()
*
@@ -780,7 +783,7 @@ Word32 GetNumGroups( LCLDEncoder *psLCLDEncoder )
{
return psLCLDEncoder->piNumGroups[0];
}
-
+#endif
/*------------------------------------------------------------------------------------------*
* Local functions
@@ -968,12 +971,12 @@ static Word32 MSModeCalculation_fx(
iFBOffset++;
}
- Q_en_tmp = min( Q_en_tmp, W_norm( fLeftEnergy_fx64 ) );
- Q_en_tmp = min( Q_en_tmp, W_norm( fRightEnergy_fx64 ) );
- Q_en_tmp = min( Q_en_tmp, W_norm( fMidEnergy_fx64 ) );
- Q_en_tmp = min( Q_en_tmp, W_norm( fSideEnergy_fx64 ) );
- Q_en_tmp = min( Q_en_tmp, W_norm( fLRCovReal_fx64 ) );
- Q_en_tmp = min( Q_en_tmp, W_norm( fLRCovImag_fx64 ) );
+ Q_en_tmp = s_min( Q_en_tmp, W_norm( fLeftEnergy_fx64 ) );
+ Q_en_tmp = s_min( Q_en_tmp, W_norm( fRightEnergy_fx64 ) );
+ Q_en_tmp = s_min( Q_en_tmp, W_norm( fMidEnergy_fx64 ) );
+ Q_en_tmp = s_min( Q_en_tmp, W_norm( fSideEnergy_fx64 ) );
+ Q_en_tmp = s_min( Q_en_tmp, W_norm( fLRCovReal_fx64 ) );
+ Q_en_tmp = s_min( Q_en_tmp, W_norm( fLRCovImag_fx64 ) );
Q_en_tmp = sub( Q_en_tmp, 2 );
fLeftEnergy_fx = W_extract_h( W_shl( fLeftEnergy_fx64, Q_en_tmp ) );
fRightEnergy_fx = W_extract_h( W_shl( fRightEnergy_fx64, Q_en_tmp ) );
@@ -996,7 +999,7 @@ static Word32 MSModeCalculation_fx(
fSideEnergyPred_fx = L_add( fSideEnergy_fx,
L_sub( Mpy_32_32( Mpy_32_32( fPred_fx, fPred_fx ), fMidEnergy_fx ),
L_shr( Mpy_32_32( fPred_fx, L_sub( fLeftEnergy_fx, fRightEnergy_fx ) ), 1 ) ) );
- fSideEnergyPred_fx = max( fSideEnergyPred_fx, 0 );
+ fSideEnergyPred_fx = L_max( fSideEnergyPred_fx, 0 );
ppiMSPredCoefs[MS_PRED_ONLY][b] = iPred;
move32();
@@ -1054,7 +1057,7 @@ static Word32 MSModeCalculation_fx(
fSideEnergyPred_fx = L_add( fSideEnergyPred_fx,
L_sub( Mpy_32_32( Mpy_32_32( fPred_fx, fPred_fx ), fMidEnergyPred_fx ),
L_shr( Mpy_32_32( fPred_fx, L_sub( fLeftEnergy_fx, fRightEnergy_fx ) ), 1 ) ) );
- fSideEnergyPred_fx = max( fSideEnergyPred_fx, 0 );
+ fSideEnergyPred_fx = L_max( fSideEnergyPred_fx, 0 );
/* -= fPred * fPred * fMidEnergyPred doesn't work because fPred is quantized and does not match MS/MM exactly */
ppiMSPredCoefs[MS_PHASE_AND_PRED][b] = iPred;
move32();
@@ -1125,7 +1128,7 @@ static Word32 MSModeCalculation_fx(
{
piMsPredInfoBits[iMSPredType] = CountMSBits( iNumBands, MS_PRED, ppiMSPredFlags[iMSPredType], ppiMSPredPhase[iMSPredType], ppiMSPredCoefs[iMSPredType] );
// pfMSPredBitGain[iMSPredType] = max( pfMSPredBitGain[iMSPredType] - piMsPredInfoBits[iMSPredType], 0.0f );
- pfMSPredBitGain_fx[iMSPredType] = max( pfMSPredBitGain_fx[iMSPredType] - L_shl( piMsPredInfoBits[iMSPredType], q_pfMSPredBitGain_fx ), 0 );
+ pfMSPredBitGain_fx[iMSPredType] = L_max( pfMSPredBitGain_fx[iMSPredType] - L_shl( piMsPredInfoBits[iMSPredType], q_pfMSPredBitGain_fx ), 0 );
}
/* find the best M/S Pred type */
@@ -1850,7 +1853,7 @@ static Word32 WriteAllocInformation(
IF( LT_32( iAllocOffset, MIN_ALLOC_OFFSET ) || GT_32( iAllocOffset, MAX_ALLOC_OFFSET ) )
{
- printf( "Serious error\n" );
+ printf( "Error in WriteAllocInformation() - iAllocOffset has incorrect value: %d!\n", iAllocOffset );
}
ISAR_SPLIT_REND_BITStream_write_int32( pBits, L_sub( iAllocOffset, MIN_ALLOC_OFFSET ), ALLOC_OFFSET_BITS );
@@ -2090,10 +2093,7 @@ static Word32 ComputeAllocation(
IF( LE_32( *piAllocOffset, MIN_ALLOC_OFFSET ) && GT_32( iBitsUsed, iAvailableBits ) )
{
-#ifdef DEBUG_VERBOSE
- printf( "Frame can not be coded with the number of bits available\n" );
-#endif
- // iLastError = ENC_ERROR_STREAM_FAILURE;
+ printf( "Error in ComputeAllocation() - frame can not be coded with the number of bits available!\n" );
return -1;
}
ELSE IF( GE_32( *piAllocOffset, MAX_ALLOC_OFFSET ) && LT_32( iBitsUsed, iAvailableBits ) )
diff --git a/lib_isar/isar_lcld_prot.h b/lib_isar/isar_lcld_prot.h
index 00c1859014ae7a13afb5017d758721c0b235eef8..16acd9716f1f01405091dc0af10e5ed54ff22f1c 100644
--- a/lib_isar/isar_lcld_prot.h
+++ b/lib_isar/isar_lcld_prot.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -65,10 +65,11 @@ Word32 EncodeLCLDFrame(
Word16 *q_final
);
+#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS
Word32 GetNumGroups(
LCLDEncoder *psLCLDEncoder
);
-
+#endif
typedef struct LCLD_DECODER LCLDDecoder;
@@ -170,44 +171,19 @@ Word32 CountMSBits(
);
-/*----------------------------------------------------------------------------------*
- * NoiseGen prototypes
- *----------------------------------------------------------------------------------*/
-
-typedef struct NOISE_GEN
-{
- Word32 iNoiseBufferLength;
- Word32 iNoiseBufferMask;
- Word32 iNoiseBufferIndex;
- float *pfNoiseBuffer;
-} NoiseGen;
-
-void DeleteNoiseGen(
- NoiseGen *psNoiseGen
-);
-
-inline Word32 GetNoise_fx( NoiseGen *psNoiseGen )
-{
- Word32 fNoiseSample;
-
- fNoiseSample = (Word32) (psNoiseGen->pfNoiseBuffer[psNoiseGen->iNoiseBufferIndex]* (1<<14));
- psNoiseGen->iNoiseBufferIndex++;
- psNoiseGen->iNoiseBufferIndex &= psNoiseGen->iNoiseBufferMask;
-
- return fNoiseSample;
-}
-
/*----------------------------------------------------------------------------------*
* PereptualModel prototypes
*----------------------------------------------------------------------------------*/
+#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS
extern void PerceptualModel(
const Word32 iMaxQuantBands,
const Word32 *piRMSEnvelope,
Word32 *piExcitation,
Word32 *piSMR
);
+#endif
extern void PerceptualModel_fx(
const Word32 iMaxQuantBands,
@@ -227,6 +203,7 @@ extern void PerceptualModelStereo_fx(
Word32 *piSMR1
);
+#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS
extern void PerceptualModelStereo(
const Word32 iMaxQuantBands,
const Word32 *piMSFlags,
@@ -237,7 +214,7 @@ extern void PerceptualModelStereo(
Word32 *piSMR0,
Word32 *piSMR1
);
-
+#endif
/*----------------------------------------------------------------------------------*
* PredEncoder/PredDecoder prototypes
@@ -369,9 +346,11 @@ Word32 **GetDecodingFailedPrevStatus(
LCLDDecoder *psLCLDDecoder
);
+#ifndef FIX_2371_REMOVE_UNUSED_ISAR_FCNS
void SetDecodingPassed(
PredictionDecoder *psPredictionDecoder
);
+#endif
void UpdateDecodingUnresolved(
PredictionDecoder *psPredictionDecoder
diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h
index 10aaa6db52cdb10e25a11801839c47542a38965e..43990c55ba68b7380d0745cc1eea957a41a2063f 100644
--- a/lib_isar/isar_prot.h
+++ b/lib_isar/isar_prot.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -58,7 +58,7 @@ ivas_error split_renderer_open_lc3plus(
SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i/o: Split renderer pre-renderer handle */
const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i : Split renderer pre-renderer config */
const Word32 output_Fs, /* i : output sampling rate */
- const IVAS_RENDER_FRAMESIZE ivas_frame_size /* i : IVAS frame size */
+ const IVAS_RENDER_NUM_SUBFR render_num_subframes /* i : rendering number of subframes */
);
void isar_splitBinPreRendClose(
@@ -370,8 +370,8 @@ Word32 isar_get_split_rend_md_target_brate(
const Word16 pcm_out_flag /* i : flag to indicate PCM output */
);
-ivas_error isar_framesize_to_ms(
- const IVAS_RENDER_FRAMESIZE frame_size, /* i : frame size enum */
+ivas_error isar_num_subfr_to_ms(
+ const IVAS_RENDER_NUM_SUBFR render_num_subframes, /* i : rendering number of subframes */
Word16 *ms /* o : frame size in ms */
);
diff --git a/lib_isar/isar_rom_lcld_tables.c b/lib_isar/isar_rom_lcld_tables.c
index 5fd334447fa8e2aa60061ae8d0ef5a8add1eda91..d3b596b40ee3c8c9f212c463c372d96b53c9dc42 100644
--- a/lib_isar/isar_rom_lcld_tables.c
+++ b/lib_isar/isar_rom_lcld_tables.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_isar/isar_rom_lcld_tables.h b/lib_isar/isar_rom_lcld_tables.h
index a2cbe5f25c4888d9658a51c3e017332441981fa4..0b8a46bb630acef0a75efad1c0e88b05e38edc42 100644
--- a/lib_isar/isar_rom_lcld_tables.h
+++ b/lib_isar/isar_rom_lcld_tables.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_isar/isar_rom_post_rend.c b/lib_isar/isar_rom_post_rend.c
index 5591fbb3a47fd96c1c81594c9c149872c6808fc0..2e4bf8ab815ce0964fc5ad9e7bf4da4e138cd87c 100644
--- a/lib_isar/isar_rom_post_rend.c
+++ b/lib_isar/isar_rom_post_rend.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_isar/isar_rom_post_rend.h b/lib_isar/isar_rom_post_rend.h
index a08bb174f70461578c389b55d40f63897084cb00..b7bca73bdbea2993f209032ed0014b12a412ccca 100644
--- a/lib_isar/isar_rom_post_rend.h
+++ b/lib_isar/isar_rom_post_rend.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_isar/isar_splitRend_lcld_dec.c b/lib_isar/isar_splitRend_lcld_dec.c
index 07017803ef8f5386e1d073717afa0add91e36581..b4047a750e6abc8e3907b19d5bbd0ec75475c1cb 100644
--- a/lib_isar/isar_splitRend_lcld_dec.c
+++ b/lib_isar/isar_splitRend_lcld_dec.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_isar/isar_splitRend_lcld_enc.c b/lib_isar/isar_splitRend_lcld_enc.c
index 567cec0a4ccfda2c2f66167b0ebf3eb3fc886e32..32346f887b8928acc9911550297ff7ab33c75f5b 100644
--- a/lib_isar/isar_splitRend_lcld_enc.c
+++ b/lib_isar/isar_splitRend_lcld_enc.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_isar/isar_splitRendererPLC.c b/lib_isar/isar_splitRendererPLC.c
index 8c096da3df5bfda030153e8f49c0ae8c85000205..d29a5272298b5613e812762c05abfd16babd4a91 100644
--- a/lib_isar/isar_splitRendererPLC.c
+++ b/lib_isar/isar_splitRendererPLC.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -308,8 +308,8 @@ static void adaptive_polar_ext_plc_fx(
fac_ph_real_fx = L_deposit_h( getCosWord16R2( dth16 ) );
fac_ph_imag_fx = L_deposit_h( getSineWord16R2( dth16 ) );
///* calculate complex evolution factor */
- fac_real_fx = Mpy_32_32( min( L_shl( 1, drho_q ), drho_32 ), fac_ph_real_fx ); // Qdrho_exp
- fac_imag_fx = Mpy_32_32( min( L_shl( 1, drho_q ), drho_32 ), fac_ph_imag_fx ); // Qdrho_exp
+ fac_real_fx = Mpy_32_32( L_min( L_shl( 1, drho_q ), drho_32 ), fac_ph_real_fx ); // Qdrho_exp
+ fac_imag_fx = Mpy_32_32( L_min( L_shl( 1, drho_q ), drho_32 ), fac_ph_imag_fx ); // Qdrho_exp
#if START_VAL_AVG_LEN > 1
/* Calculate start value FOR evolution from last samples of previous frame */
fac_powj_real_fx = fac_real_fx;
@@ -488,11 +488,11 @@ static void adaptive_polar_ext_plc_fx(
IF( EQ_16( drho_q, 31 ) )
{
- abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( min( ONE_IN_Q31, drho_32 ), max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e
+ abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( L_min( ONE_IN_Q31, drho_32 ), L_max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e
}
ELSE
{
- abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( min( L_shl( 1, drho_q ), drho_32 ), max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e
+ abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( L_min( L_shl( 1, drho_q ), drho_32 ), L_max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e
}
temp_16 = sub( add( drho_q, sqrt_exp ), tmp_e );
@@ -600,11 +600,11 @@ static void adaptive_polar_ext_plc_fx(
IF( EQ_16( drho_q, 31 ) )
{
- abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( min( ONE_IN_Q31, drho_32 ), max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e
+ abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( L_min( ONE_IN_Q31, drho_32 ), L_max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e
}
ELSE
{
- abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( min( L_shl( 1, drho_q ), drho_32 ), max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e
+ abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( L_min( L_shl( 1, drho_q ), drho_32 ), L_max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e
}
temp_16 = sub( add( drho_q, sqrt_exp ), tmp_e );
rat_real_fx = W_mult_32_32( rat_real32_fx, abs2inv_fx );
diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c
index dbefc438600da70278290836b910ea43b4d38807..380b9f976a7abcd28211fe800d9fbbdd9d889c7e 100644
--- a/lib_isar/isar_splitRendererPost.c
+++ b/lib_isar/isar_splitRendererPost.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -1108,7 +1108,7 @@ static Word32 get_interp_fact_fx(
IF( LT_32( interp_fact_fx, 0 ) )
{
- d_fx = max( -( MAX_EXTRAPOLATION_ANGLE_Q22 ), ( min( ( MAX_EXTRAPOLATION_ANGLE_Q22 ), d_fx ) ) );
+ d_fx = L_max( -( MAX_EXTRAPOLATION_ANGLE_Q22 ), ( L_min( ( MAX_EXTRAPOLATION_ANGLE_Q22 ), d_fx ) ) );
move32();
n_fx = L_deposit_h( getSineWord16R2( extract_l( L_shr( Mpy_32_32( n_fx, Q31_BY_360 ), 7 ) ) ) );
move32();
@@ -1358,8 +1358,8 @@ static void interpolate_pred_matrix_fx(
{
FOR( Word16 j = 0; j < BINAURAL_CHANNELS; j++ )
{
- max_exp_re = max( max_exp_re, buff_exp_re[i][j] );
- max_exp_im = max( max_exp_im, buff_exp_im[i][j] );
+ max_exp_re = s_max( max_exp_re, buff_exp_re[i][j] );
+ max_exp_im = s_max( max_exp_im, buff_exp_im[i][j] );
}
}
FOR( Word16 i = 0; i < BINAURAL_CHANNELS; i++ )
@@ -1500,7 +1500,7 @@ static void interpolate_rend_md_fx(
Word16 exp_tmp1 = 0;
Word32 tmp1 = BASOP_Util_Add_Mant32Exp( gd1_fx, 31 - Q25, L_negate( tmp ), 6 + 31 - Q_pitch, &exp_tmp1 );
pitch_gain_l_fx = tmp1;
- pitch_gain_l_fx = max( 0, pitch_gain_l_fx );
+ pitch_gain_l_fx = L_max( 0, pitch_gain_l_fx );
exp_pitch_gain_l = exp_tmp1;
diff_fx = L_sub( gd3_fx, gd4_fx );
@@ -1512,7 +1512,7 @@ static void interpolate_rend_md_fx(
exp_tmp1 = 0;
tmp1 = BASOP_Util_Add_Mant32Exp( gd3_fx, 31 - Q25, L_negate( tmp ), 6 + 31 - Q_pitch, &exp_tmp1 );
pitch_gain_r_fx = tmp1;
- pitch_gain_r_fx = max( 0, pitch_gain_r_fx );
+ pitch_gain_r_fx = L_max( 0, pitch_gain_r_fx );
exp_pitch_gain_r = exp_tmp1;
FOR( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ )
@@ -1532,8 +1532,8 @@ static void interpolate_rend_md_fx(
{
FOR( Word16 j = 0; j < BINAURAL_CHANNELS; j++ )
{
- max_exp_re = max( max_exp_re, exp_mat_re[i][j] );
- max_exp_im = max( max_exp_im, exp_mat_im[i][j] );
+ max_exp_re = s_max( max_exp_re, exp_mat_re[i][j] );
+ max_exp_im = s_max( max_exp_im, exp_mat_im[i][j] );
}
}
@@ -1655,7 +1655,7 @@ void isar_SplitRenderer_PostRenderer(
{
index_slot = slot_idx; /* TODO: can be cleaned up */
fade_fx = fade_table_fx[slot_idx];
- fade_fx = min( fade_fx, MAX_16 );
+ fade_fx = s_min( fade_fx, MAX_16 );
FOR( b = 0; b < num_md_bands; b++ )
{
FOR( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ )
diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c
index 7255e7716cc404ca8bb3f20e8f84320214661652..f657e7d4b862a6ee51bae116964f8a1d5279ee59 100644
--- a/lib_isar/isar_splitRendererPre.c
+++ b/lib_isar/isar_splitRendererPre.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -349,7 +349,7 @@ static void ComputePredMat_fx(
{
FOR( j = 0; j < 2; j++ )
{
- max_exp = max( max_exp, buff_exp[i][j] );
+ max_exp = s_max( max_exp, buff_exp[i][j] );
}
}
@@ -637,8 +637,8 @@ static void ComputeBandedCrossCov_fx(
{
FOR( Word16 j = 0; j < num_chs; j++ )
{
- max_cov_re = max( max_cov_re, exp_buff_re[i][j] );
- max_cov_im = max( max_cov_im, exp_buff_im[i][j] );
+ max_cov_re = s_max( max_cov_re, exp_buff_re[i][j] );
+ max_cov_im = s_max( max_cov_im, exp_buff_im[i][j] );
}
}
FOR( Word16 i = 0; i < num_chs; i++ )
@@ -789,8 +789,8 @@ static void ComputeBandedCov_fx(
{
FOR( Word16 j = 0; j < BINAURAL_CHANNELS; j++ )
{
- exp_max_re = max( exp_max_re, exp_buff_re[i][j] );
- exp_max_im = max( exp_max_im, exp_buff_im[i][j] );
+ exp_max_re = s_max( exp_max_re, exp_buff_re[i][j] );
+ exp_max_im = s_max( exp_max_im, exp_buff_im[i][j] );
}
}
@@ -1101,7 +1101,7 @@ static void get_lr_gains(
Word16 max_gd_exp = MIN16B;
FOR( i = 0; i < BINAURAL_CHANNELS; i++ )
{
- max_gd_exp = max( max_gd_exp, exp_gd_tmp_buf[i] );
+ max_gd_exp = s_max( max_gd_exp, exp_gd_tmp_buf[i] );
}
exp_gd_tmp = max_gd_exp;
@@ -2705,17 +2705,18 @@ void isar_init_split_rend_handles(
*------------------------------------------------------------------------*/
ivas_error split_renderer_open_lc3plus(
- SPLIT_REND_WRAPPER *hSplitRendWrapper,
- const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig,
- const Word32 OutSampleRate,
- const IVAS_RENDER_FRAMESIZE isar_frame_size )
+ SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i/o: Split renderer pre-renderer handle */
+ const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i : Split renderer pre-renderer config */
+ const Word32 OutSampleRate, /* i : output sampling rate */
+ const IVAS_RENDER_NUM_SUBFR render_num_subframes /* i : rendering number of subframes */
+)
{
ivas_error error;
Word16 i, delayBufferLength;
LC3PLUS_CONFIG config;
Word16 isar_frame_size_ms;
- IF( ( error = isar_framesize_to_ms( isar_frame_size, &isar_frame_size_ms ) ) != IVAS_ERR_OK )
+ IF( ( error = isar_num_subfr_to_ms( render_num_subframes, &isar_frame_size_ms ) ) != IVAS_ERR_OK )
{
return error;
}
diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c
index 9aeda22896c7cb93aac12bbb6f0b4403b5a4ecdd..f8359c18f1f73c70e56c6d77a3428c405113817b 100644
--- a/lib_isar/isar_splitRenderer_utils.c
+++ b/lib_isar/isar_splitRenderer_utils.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -1278,20 +1278,27 @@ void isar_init_multi_bin_pose_data_fx_enc(
return;
}
-ivas_error isar_framesize_to_ms(
- const IVAS_RENDER_FRAMESIZE frame_size, /* i : frame size enum */
- Word16 *ms /* o : frame size in ms */
+
+/*-------------------------------------------------------------------------
+ * Function isar_num_subfr_to_ms()
+ *
+ *
+ *------------------------------------------------------------------------*/
+
+ivas_error isar_num_subfr_to_ms(
+ const IVAS_RENDER_NUM_SUBFR render_num_subframes, /* i : rendering number of subframes */
+ Word16 *ms /* o : frame size in ms */
)
{
- switch ( frame_size )
+ switch ( render_num_subframes )
{
- case IVAS_RENDER_FRAMESIZE_5MS:
+ case IVAS_RENDER_NUM_SUBFR_5MS:
*ms = 5;
break;
- case IVAS_RENDER_FRAMESIZE_10MS:
+ case IVAS_RENDER_NUM_SUBFR_10MS:
*ms = 10;
break;
- case IVAS_RENDER_FRAMESIZE_20MS:
+ case IVAS_RENDER_NUM_SUBFR_20MS:
*ms = 20;
break;
default:
diff --git a/lib_isar/isar_stat.h b/lib_isar/isar_stat.h
index e91184f4c542f79e4afb046a6abf8693f11e8acf..4849485880c01a761efc78414bf85ffc7436d430 100644
--- a/lib_isar/isar_stat.h
+++ b/lib_isar/isar_stat.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c
index 61b4c02cb53772a283f24bc7ded7b4634ae78fa0..04e80dc619d2be05d03c5a5f913bd8b82d8c4a4d 100644
--- a/lib_isar/lib_isar_post_rend.c
+++ b/lib_isar/lib_isar_post_rend.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -310,8 +310,7 @@ static Word32 limitRendererOutput_fx(
/* Apply clipping to buffer in case the limiter let through some samples > 1.0f */
FOR( i = 0; i < output_frame * num_channels; ++i )
{
-
- output[i] = min( max( L_shl( INT16_MIN, q_factor ), output[i] ), L_shl( INT16_MAX, q_factor ) );
+ output[i] = L_min( L_max( L_shl( INT16_MIN, q_factor ), output[i] ), L_shl( INT16_MAX, q_factor ) );
}
return numClipping;
@@ -490,7 +489,7 @@ static ivas_error updateSplitPostRendPanGains(
IF( GT_16( hRendCfg->codec_frame_size_ms, 0 ) )
{
iNumLCLDIterationsPerFrame = (Word16) config.isar_frame_duration_us / ( 1000 * hRendCfg->codec_frame_size_ms );
- iNumLCLDIterationsPerFrame = max( 1, iNumLCLDIterationsPerFrame );
+ iNumLCLDIterationsPerFrame = s_max( 1, iNumLCLDIterationsPerFrame );
iNumBlocksPerFrame = CLDFB_NO_COL_MAX * hRendCfg->codec_frame_size_ms / 20;
}
ELSE
@@ -774,7 +773,6 @@ ivas_error ISAR_POST_REND_SetInputGain(
IF( ( error = getInputById( hIvasRend, inputId, (void **) &inputBase ) ) != IVAS_ERR_OK )
{
- printf( "Hoo\n" );
return error;
}
@@ -1003,7 +1001,7 @@ ivas_error ISAR_POST_REND_GetDelay(
{
latency_ns += IVAS_FB_DEC_DELAY_NS;
}
- max_latency_ns = max( max_latency_ns, latency_ns );
+ max_latency_ns = L_max( max_latency_ns, latency_ns );
}
}
@@ -1063,7 +1061,6 @@ ivas_error ISAR_POST_REND_FeedInputAudio(
IF( ( error = getInputById( hIvasRend, inputId, (void **) &inputBase ) ) != IVAS_ERR_OK )
{
- printf( "Foo\n" );
return error;
}
@@ -1186,7 +1183,6 @@ ivas_error ISAR_POST_REND_FeedSplitBinauralBitstream(
IF( ( error = getInputById( hIvasRend, inputId, (void **) &inputBase ) ) != IVAS_ERR_OK )
{
- printf( "Goo\n" );
return error;
}
diff --git a/lib_isar/lib_isar_post_rend.h b/lib_isar/lib_isar_post_rend.h
index ba22fba6ab50ed2a8ae65a56477921c1e56f2f4e..d7f1cce841259ba8e34b0f3a685a3620cccbc800 100644
--- a/lib_isar/lib_isar_post_rend.h
+++ b/lib_isar/lib_isar_post_rend.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -41,8 +41,7 @@
* ISAR post-renderer constants
*---------------------------------------------------------------------*/
-#define RENDERER_MAX_ISAR_MD_INPUTS 1
-#define RENDERER_MAX_BIN_INPUTS 1
+#define RENDERER_MAX_BIN_INPUTS 1
/*---------------------------------------------------------------------*
* ISAR post-renderer structures
@@ -83,14 +82,6 @@ typedef struct ISAR_POST_REND const *ISAR_POST_REND_CONST_HANDLE;
typedef UWord16 ISAR_POST_REND_InputId;
-typedef enum _ISAR_POST_REND_COMPLEXITY_LEVEL
-{
- ISAR_POST_REND_COMPLEXITY_LEVEL_ONE = 1,
- ISAR_POST_REND_COMPLEXITY_LEVEL_TWO = 2,
- ISAR_POST_REND_COMPLEXITY_LEVEL_THREE = 3
-} ISAR_POST_REND_COMPLEXITY_LEVEL;
-
-
/* clang-format off */
/*----------------------------------------------------------------------------------*
* ISAR post-renderer function prototypes
diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c
index 61767c7702abd2b159ffbc6a033b117e8f7bfc6a..f9858f413029b12694e4c1794c21b0c992581815 100644
--- a/lib_isar/lib_isar_pre_rend.c
+++ b/lib_isar/lib_isar_pre_rend.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -51,13 +51,14 @@
*------------------------------------------------------------------------*/
ivas_error ISAR_PRE_REND_open(
- SPLIT_REND_WRAPPER *hSplitRendWrapper,
- ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig,
- const Word32 OutSampleRate,
- const Word16 cldfb_in_flag,
- const Word16 pcm_out_flag,
- const IVAS_RENDER_FRAMESIZE ivas_frame_size, /* i: IVAS frame size */
- const Word16 mixed_td_cldfb_flag )
+ SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i/o: Split renderer pre-renderer handle */
+ ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i/o: Split renderer pre-renderer config */
+ const Word32 OutSampleRate, /* i : output sampling rate */
+ const Word16 cldfb_in_flag, /* i : Flag to indicate CLDFB or time doamin input */
+ const Word16 pcm_out_flag, /* i : Flag to indicate PCM output */
+ const IVAS_RENDER_NUM_SUBFR render_num_subframes, /* i : rendering number of subframes */
+ const Word16 mixed_td_cldfb_flag /* i : Flag to indicate combined TD and CLDFB input */
+)
{
ivas_error error, ch, num_ch;
UWord8 isCldfbNeeded = 0;
@@ -67,7 +68,7 @@ ivas_error ISAR_PRE_REND_open(
&pSplitRendConfig->isar_frame_size_ms,
&pSplitRendConfig->codec_frame_size_ms,
cldfb_in_flag_local,
- pcm_out_flag, (Word16) ivas_frame_size ) ) != IVAS_ERR_OK )
+ pcm_out_flag, (Word16) render_num_subframes ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -150,7 +151,7 @@ ivas_error ISAR_PRE_REND_open(
{
IF( EQ_16( pSplitRendConfig->codec, ISAR_SPLIT_REND_CODEC_LC3PLUS ) )
{
- IF( ( error = split_renderer_open_lc3plus( hSplitRendWrapper, pSplitRendConfig, OutSampleRate, ivas_frame_size ) ) != IVAS_ERR_OK )
+ IF( ( error = split_renderer_open_lc3plus( hSplitRendWrapper, pSplitRendConfig, OutSampleRate, render_num_subframes ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -178,7 +179,7 @@ ivas_error ISAR_PRE_REND_open(
*------------------------------------------------------------------------*/
void ISAR_PRE_REND_close(
- SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */
+ SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renderer handle */
IVAS_REND_AudioBuffer *pSplitRendEncBuffer /* i/o: Split renderer data buffer */
)
{
@@ -258,7 +259,7 @@ void ISAR_PRE_REND_close(
*-------------------------------------------------------------------------*/
void ISAR_PRE_REND_GetMultiBinPoseData(
- const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renerer config */
+ const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renderer config */
MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */
const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : Rotation axis */
)
@@ -276,13 +277,13 @@ void ISAR_PRE_REND_GetMultiBinPoseData(
*------------------------------------------------------------------------*/
ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural(
- SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renerer handle */
- const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */
- const Word32 SplitRendBitRate, /* i : Split renderer bitrate */
- ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */
- const Word16 isar_frame_size_ms, /* i : ISAR framesize */
- Word16 codec_frame_size_ms, /* i/o: ISAR transport codec framesize */
- ISAR_SPLIT_REND_BITS_HANDLE pBits,
+ SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */
+ const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */
+ const Word32 SplitRendBitRate, /* i : Split renderer bitrate */
+ ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */
+ const Word16 isar_frame_size_ms, /* i : ISAR framesize */
+ Word16 codec_frame_size_ms, /* i/o: ISAR transport codec framesize */
+ ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */
Word32 *Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX], /* i/o: CLDFB real buffer */
Word32 *Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX], /* i/o: CLDFB imag buffer */
const Word16 max_bands, /* i : CLDFB bands */
@@ -298,9 +299,10 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural(
Word32 bit_len, target_md_bits, available_bits, tmp_32;
Word16 q1 = 31, q2 = 31, q_final, Q_cldfb, tmp, tmp_e;
Word16 i, j;
- error = IVAS_ERR_OK;
Word16 Q_buff_re, Q_buff_im;
+ error = IVAS_ERR_OK;
+ move16();
push_wmops( "ISAR_PRE_REND_MultiBinToSplitBinaural" );
Q_buff_re = Q_buff;
diff --git a/lib_isar/lib_isar_pre_rend.h b/lib_isar/lib_isar_pre_rend.h
index 0e1ca56724bb72b0090cca75890fc39e93396eed..e085852d18327a1af45faa77faaf3fb9b698c9ff 100644
--- a/lib_isar/lib_isar_pre_rend.h
+++ b/lib_isar/lib_isar_pre_rend.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -42,42 +42,42 @@
*----------------------------------------------------------------------------------*/
ivas_error ISAR_PRE_REND_open(
- SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */
- ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i/o: Split renderer pre-renerer config */
+ SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renderer handle */
+ ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i/o: Split renderer pre-renderer config */
const Word32 output_Fs, /* i : output sampling rate */
const Word16 cldfb_in_flag, /* i : Flag to indicate CLDFB or time doamin input */
const Word16 pcm_out_flag, /* i : Flag to indicate PCM output */
- const IVAS_RENDER_FRAMESIZE ivas_frame_size, /* i : IVAS frame size */
+ const IVAS_RENDER_NUM_SUBFR render_num_subframes, /* i : rendering number of subframes */
const Word16 mixed_td_cldfb_flag /* i : Flag to indicate combined TD and CLDFB input */
);
void ISAR_PRE_REND_close(
- SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */
+ SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renderer handle */
IVAS_REND_AudioBuffer *pSplitRendEncBuffer /* i/o: Split renderer data buffer */
);
void ISAR_PRE_REND_GetMultiBinPoseData(
- const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renerer config */
+ const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renderer config */
MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */
const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : Rotation axis */
);
ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural(
- SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renerer handle */
- const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */
- const Word32 SplitRendBitRate, /* i : Split renderer bitrate */
- ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */
- const Word16 isar_frame_size_ms, /* i : ISAR framesize */
- Word16 codec_frame_size_ms, /* i/o: Split renderer codec framesize */
- ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: Split renderer bitstream handle */
- Word32* Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX], /* i/o: CLDFB real buffer */
- Word32* Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX], /* i/o: CLDFB imag buffer */
- const Word16 max_bands, /* i : CLDFB bands */
- Word32 *pOutput_fx[], /* i : low time resolution pre-renderer flag */
- const Word16 low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */
- const Word16 cldfb_in_flag, /* i : Flag to indicate CLDFB or time doamin input */
- const Word16 pcm_out_flag, /* i : Flag to indicate PCM output */
- const Word16 ro_md_flag, /* i : Flag to indicate real only metadata for yaw */
+ SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */
+ const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */
+ const Word32 SplitRendBitRate, /* i : Split renderer bitrate */
+ ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */
+ const Word16 isar_frame_size_ms, /* i : ISAR framesize */
+ Word16 codec_frame_size_ms, /* i/o: Split renderer codec framesize */
+ ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */
+ Word32* Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX], /* i/o: CLDFB real buffer */
+ Word32* Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX], /* i/o: CLDFB imag buffer */
+ const Word16 max_bands, /* i : CLDFB bands */
+ Word32 *pOutput_fx[], /* i : low time resolution pre-renderer flag */
+ const Word16 low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */
+ const Word16 cldfb_in_flag, /* i : Flag to indicate CLDFB or time doamin input */
+ const Word16 pcm_out_flag, /* i : Flag to indicate PCM output */
+ const Word16 ro_md_flag, /* i : Flag to indicate real only metadata for yaw */
Word16 Q_buff,
Word16 *Q_out
);
diff --git a/lib_rend/ivas_allrad_dec_fx.c b/lib_rend/ivas_allrad_dec_fx.c
index a93f3092af492522705e319692149d37264176a6..34563e8c39256ed5d7bf19a7e2bf126dbb8f8c93 100644
--- a/lib_rend/ivas_allrad_dec_fx.c
+++ b/lib_rend/ivas_allrad_dec_fx.c
@@ -1,7 +1,7 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_rend/ivas_binRenderer_internal_fx.c
similarity index 99%
rename from lib_dec/ivas_binRenderer_internal_fx.c
rename to lib_rend/ivas_binRenderer_internal_fx.c
index 1ac6d5bbf2d7eebde4d4d5a3b96428792b8a520f..14818c7c399773573d38acb450f12b6f3c8a354b 100644
--- a/lib_dec/ivas_binRenderer_internal_fx.c
+++ b/lib_rend/ivas_binRenderer_internal_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_cldfb_ring_buffer.c b/lib_rend/ivas_cldfb_ring_buffer.c
index d3c18a4f9398f01bf1edcaa750a9856bf603f207..e6de5e65d475a01194c75ac882a72b95ea413ff5 100644
--- a/lib_rend/ivas_cldfb_ring_buffer.c
+++ b/lib_rend/ivas_cldfb_ring_buffer.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c
index 8459763527568ebdbfca0075f81693ea54c45115..b90b9deb8543083354c25a952de3a6fdb6d8db41 100644
--- a/lib_rend/ivas_crend_fx.c
+++ b/lib_rend/ivas_crend_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -1812,8 +1812,8 @@ void ivas_rend_closeCldfbRend(
pCldfbRend->hCldfbRend->hInputSetup = NULL;
}
+
ivas_binRenderer_close_fx( &pCldfbRend->hCldfbRend );
- ivas_binaural_hrtf_close_fx( &pCldfbRend->hHrtfFastConv );
ivas_HRTF_fastconv_binary_close_fx( &pCldfbRend->hHrtfFastConv );
return;
@@ -2046,7 +2046,7 @@ ivas_error ivas_rend_crendProcessSubframe_fx(
const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */
const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */
const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */
- DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */
+ DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: TC handle */
Word32 *input_f[], /* i : transport channels Qx */
Word32 *output[], /* i/o: input/output audio channels Qx */
const Word16 n_samples_to_render, /* i : output frame length per channel */
@@ -2269,15 +2269,15 @@ ivas_error ivas_rend_crendProcessSubframe_fx(
*-----------------------------------------------------------------------------------------*/
ivas_error ivas_rend_crendProcessSubframesSplitBin(
- const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */
- const AUDIO_CONFIG inConfig, /* i : input audio configuration */
- const AUDIO_CONFIG outConfig, /* i : output audio configuration */
- const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData,
+ const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */
+ const AUDIO_CONFIG inConfig, /* i : input audio configuration */
+ const AUDIO_CONFIG outConfig, /* i : output audio configuration */
+ const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */
const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */
const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */
const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */
const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */
- DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */
+ DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: TC handle */
Word32 *input_f[], /* i : transport channels */
Word32 *output[], /* i/o: input/output audio channels */
const Word16 n_samples_to_render, /* i : output frame length per channel */
diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c
index 52bedea05801655c7a812900dfeb783bde16df88..9bdbc987ead1728915200fae0990c3b128ce3460 100644
--- a/lib_rend/ivas_dirac_ana_fx.c
+++ b/lib_rend/ivas_dirac_ana_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c
index 0152bf465a270b99520b097404e72c8b69770fcb..f20e58c42e1ed2395e7d333ced2cdb4805831736 100644
--- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c
+++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -117,17 +117,11 @@ static void ivas_masa_ext_rend_parambin_internal_fx( MASA_EXT_REND_HANDLE hMasaE
static void formulate2x2MixingMatrix_fx( Word32 Ein1_fx /*q_Ein*/, Word32 Ein2_fx /*q_Ein*/, Word16 q_Ein, Word32 CinRe_fx /*q_Cin*/, Word32 CinIm_fx /*q_Cin*/, Word16 q_Cin, Word32 Eout1_fx /*q_Eout*/, Word32 Eout2_fx /*q_Eout*/, Word16 q_Eout, Word32 CoutRe_fx /*q_Cout*/, Word32 CoutIm_fx /*q_Cout*/, Word16 q_Cout, Word32 Q_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*Q31*/, Word32 Mre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_M*/, Word32 Mim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_M*/, Word16 *q_M, const Word16 regularizationFactor_fx /*Q14*/ );
-#ifdef OPT_2182_MATRIX_SCALE_OPS
static void matrixScale_fx( Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A );
-#endif
static void matrixMul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word16 *q_out );
-#ifdef OPT_2182_MATRIX_SCALE_OPS
static void matrixTransp2Mul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word16 *q_out );
-#else
-static void matrixTransp2Mul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, Word32 Ascale, Word32 Bscale, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word16 *q_out );
-#endif
/*-------------------------------------------------------------------------
@@ -394,9 +388,9 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx(
nchan_to_allocate = add( BINAURAL_CHANNELS, st_ivas->nchan_ism );
}
- n_samples_granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), output_Fs );
+ n_samples_granularity = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), output_Fs );
- IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ), nchan_to_allocate, nchan_to_allocate, n_samples_granularity ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, ivas_dec_get_num_tc_channels_fx( st_ivas ), nchan_to_allocate, nchan_to_allocate, n_samples_granularity ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -2235,24 +2229,14 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx(
}
/* Make matrix multiplication M*Cx*M' to determine resulting covariance matrix of processing input with M */
-#ifdef OPT_2182_MATRIX_SCALE_OPS
matrixScale_fx( Mre_fx, Mim_fx, &q_M );
matrixScale_fx( CxRe_fx, CxIm_fx, &q_Cx );
-#endif
matrixMul_fx( Mre_fx, Mim_fx, &q_M, CxRe_fx, CxIm_fx, &q_Cx, tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp );
-#ifdef OPT_2182_MATRIX_SCALE_OPS
matrixScale_fx( tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp );
matrixTransp2Mul_fx(
tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp,
Mre_fx, Mim_fx, &q_M,
resultMtxRe_fx, resultMtxIm_fx, &q_res );
-#else
- matrixTransp2Mul_fx(
- tmpMtxRe_fx, tmpMtxIm_fx, &q_tmp, Mre_fx, Mim_fx, &q_M,
- 1 /*int Ascale*/,
- 0 /*int Bscale*/,
- resultMtxRe_fx, resultMtxIm_fx, &q_res );
-#endif
/* When below the frequency limit where decorrelation is applied, we inject the decorrelated
* residual (or missing) signal component. The procedure is active when there are not enough independent
@@ -2931,21 +2915,13 @@ static void ivas_dirac_dec_binaural_process_output_fx(
{
Word16 gain;
/* Mixing using the formulated processing matrix M */
-#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE
gain = mac_r( L_mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxRePrev_fx[chA][chB][bin] ), interpVal_fx, hDiracDecBin->processMtxRe_fx[chA][chB][bin] ); // Q11
-#else
- gain = add( mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxRePrev_fx[chA][chB][bin] ), mult( interpVal_fx, hDiracDecBin->processMtxRe_fx[chA][chB][bin] ) ); // Q11
-#endif
- outSlotRe_fx[bin] = Madd_32_16( outSlotRe_fx[bin], inRe_fx[chB][slot][bin], gain ); // q_inp_mix-4//q_result
- outSlotIm_fx[bin] = Madd_32_16( outSlotIm_fx[bin], inIm_fx[chB][slot][bin], gain ); // q_inp_mix-4//q_result
+ outSlotRe_fx[bin] = Madd_32_16( outSlotRe_fx[bin], inRe_fx[chB][slot][bin], gain ); // q_inp_mix-4//q_result
+ outSlotIm_fx[bin] = Madd_32_16( outSlotIm_fx[bin], inIm_fx[chB][slot][bin], gain ); // q_inp_mix-4//q_result
move32();
move32();
-#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE
gain = mac_r( L_mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxImPrev_fx[chA][chB][bin] ), interpVal_fx, hDiracDecBin->processMtxIm_fx[chA][chB][bin] ); // Q11
-#else
- gain = add( mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxImPrev_fx[chA][chB][bin] ), mult( interpVal_fx, hDiracDecBin->processMtxIm_fx[chA][chB][bin] ) ); // Q11
-#endif
// interpVal * hDiracDecBin->processMtxIm[chA][chB][bin];
outSlotRe_fx[bin] = Msub_32_16( outSlotRe_fx[bin], inIm_fx[chB][slot][bin], gain ); // q_inp_mix-4//q_result
outSlotIm_fx[bin] = Madd_32_16( outSlotIm_fx[bin], inRe_fx[chB][slot][bin], gain ); // q_inp_mix-4//q_result
@@ -2956,11 +2932,7 @@ static void ivas_dirac_dec_binaural_process_output_fx(
test();
IF( LT_16( bin, max_band_decorr ) && LT_16( chB, 2 ) )
{
-#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE
gain = mac_r( L_mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxDecRePrev_fx[chA][chB][bin] ), interpVal_fx, hDiracDecBin->processMtxDecRe_fx[chA][chB][bin] ); // Q11
-#else
- gain = add( mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxDecRePrev_fx[chA][chB][bin] ), mult( interpVal_fx, hDiracDecBin->processMtxDecRe_fx[chA][chB][bin] ) ); // Q11
-#endif
// interpVal * hDiracDecBin->processMtxDecRe[chA][chB][bin];
outSlotRe_fx[bin] = Madd_32_16( outSlotRe_fx[bin], decSlotRePointer_fx[bin], gain ); // q_inp_mix-4//q_result
@@ -2968,13 +2940,9 @@ static void ivas_dirac_dec_binaural_process_output_fx(
move32();
move32();
-#ifdef FIX_2254_IMPROV_PRECISION_OR_COMPLEXITY_NON_BE
gain = mac_r( L_mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxDecImPrev_fx[chA][chB][bin] ), interpVal_fx, hDiracDecBin->processMtxDecIm_fx[chA][chB][bin] ); // Q11
-#else
- gain = add( mult( sub( 32767, interpVal_fx ), hDiracDecBin->processMtxDecImPrev_fx[chA][chB][bin] ), mult( interpVal_fx, hDiracDecBin->processMtxDecIm_fx[chA][chB][bin] ) ); // Q11
-#endif
- outSlotRe_fx[bin] = Msub_32_16( outSlotRe_fx[bin], decSlotImPointer_fx[bin], gain ); // q_inp_mix-4//q_result
- outSlotIm_fx[bin] = Madd_32_16( outSlotIm_fx[bin], decSlotRePointer_fx[bin], gain ); // q_inp_mix-4//q_result
+ outSlotRe_fx[bin] = Msub_32_16( outSlotRe_fx[bin], decSlotImPointer_fx[bin], gain ); // q_inp_mix-4//q_result
+ outSlotIm_fx[bin] = Madd_32_16( outSlotIm_fx[bin], decSlotRePointer_fx[bin], gain ); // q_inp_mix-4//q_result
move32();
move32();
}
@@ -3495,7 +3463,6 @@ static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked_fx(
return;
}
-#ifdef NONBE_OPT_2193_EIG2X2
static Word32 eig2x2_div_fx( Word32 num, Word32 den );
static Word32 eig2x2_div_fx( Word32 num, Word32 den )
@@ -3506,7 +3473,6 @@ static Word32 eig2x2_div_fx( Word32 num, Word32 den )
}
return div_w_newton( num, den );
}
-#endif
static void eig2x2_fx(
const Word32 E1_fx, /*q_E*/
@@ -3521,7 +3487,6 @@ static void eig2x2_fx(
Word32 D_fx[BINAURAL_CHANNELS], /*q_D*/
Word16 *q_D )
{
-#ifdef NONBE_OPT_2193_EIG2X2
Word32 pm_fx, add_fx;
Word32 tmp1, tmp2, e1, e2, c_re, c_im, c0_im, c1_im;
Word32 s0_fx, s1_fx, nval0_fx, nval1_fx;
@@ -3664,8 +3629,8 @@ static void eig2x2_fx(
// Eigenvectors
- q_diff = sub( q_e, *q_D );
- q_tmp1 = s_min( q_e, *q_D );
+ q_diff = sub( *q_D, q_e );
+ q_tmp1 = s_min( *q_D, q_e );
tmp1 = D_fx[0];
move32();
@@ -3833,374 +3798,6 @@ static void eig2x2_fx(
move32();
Uim_fx[i11][1] = Mpy_32_32( c1_im, nval1_fx );
move32();
-#else
- Word16 chA, chB, ch;
- Word32 s_fx, normVal_fx, crossSquare_fx, a_fx, pm_fx, add_fx;
- Word32 tmp1, tmp2, tmp3, e1, e2, c_re, c_im;
- Word16 q_crossSquare, q_tmp1, q_tmp2, exp_tmp3, exp, q_e, q_c, q_U_1, q_U_2;
- Word32 epsilon_mant = 1180591621;
- Word16 epsilon_exp = -39;
- move32();
- move16();
-
- pm_fx = 0;
- move32();
- add_fx = 0;
- move32();
- q_tmp2 = 0;
- move16();
-
- FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ )
- {
- FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ )
- {
- Ure_fx[chA][chB] = 0;
- move32();
- Uim_fx[chA][chB] = 0;
- move32();
- }
- }
-
- exp = sub( get_min_scalefactor( Cre_fx, Cim_fx ), 2 );
- c_re = L_shl( Cre_fx, exp );
- c_im = L_shl( Cim_fx, exp );
- q_c = add( q_C, exp );
-
- exp = sub( get_min_scalefactor( E1_fx, E2_fx ), 2 );
- e1 = L_shl( E1_fx, exp );
- e2 = L_shl( E2_fx, exp );
- q_e = add( q_E, exp );
-
- /*crossSquare_fx = (c_re * c_re) + (c_im * c_im)
- a_fx = (e1 + e2) * (e1 + e2) - 4.0f * ((e1 * e2) - crossSquare_fx) = (e1 - e2)^2 + 4 * crossSquare_fx
- pm_fx = 0.5f * sqrtf(max(0.0f, a_fx))
- add_fx = 0.5f * (e1 + e2)*/
-
- IF( L_and( c_re == 0, c_im == 0 ) )
- {
- /* if c_re = 0 and c_im = 0, then crossSquare_fx = (c_re * c_re) + (c_im * c_im) = 0
- a_fx = (E1 - E2)^2
- pm_fx = 0.5 * sqrt(max(0, a_fx)) = 0.5 * max(0, (e1 - e2)) */
- crossSquare_fx = 0;
- move32();
- q_crossSquare = Q31;
- move16();
- pm_fx = L_shr( L_max( 0, L_abs( L_sub( e1, e2 ) ) ), 1 );
- q_tmp2 = q_e;
- move16();
- }
- ELSE
- {
- crossSquare_fx = Madd_32_32( Mpy_32_32( c_re, c_re ), c_im, c_im );
- q_crossSquare = sub( add( q_c, q_c ), 31 );
- IF( EQ_32( e1, e2 ) )
- {
- /* if e1 - e2 = 0, then a_fx = 4 * crossSquare_fx
- pm_fx = 0.5 * sqrt(max(0, 4 * crossSquare_fx)) = sqrt(0, crossSquare_fx)*/
- test();
- test();
- IF( EQ_32( c_re, 0 ) || LT_32( L_abs( c_re ), ONE_IN_Q15 ) )
- {
- /* if c_re = 0, then crossSquare_fx = c_im^2 => pm_fx = max(0, c_im) */
- pm_fx = L_max( 0, L_abs( c_im ) );
- q_tmp2 = q_c;
- move16();
- }
- ELSE IF( c_im == 0 || LT_32( L_abs( c_im ), ONE_IN_Q15 ) )
- {
- /* if c_im = 0, then crossSquare_fx = c_re^2 => pm_fx = max(0, c_re) */
- pm_fx = L_max( 0, L_abs( c_re ) );
- q_tmp2 = q_c;
- move16();
- }
- ELSE
- {
- exp = sub( 31, q_crossSquare );
- pm_fx = Sqrt32( L_max( 0, crossSquare_fx ), &exp );
- q_tmp2 = sub( 31, exp );
- }
- }
- ELSE
- {
- /* if e1, e2 >> c_re, c_im then (e1 - e2)^2 ~ (e1 - e2)^2 + 4 * crossSquare_fx
- a_fx = (E1 - E2)^2
- pm_fx = 0.5 * sqrt(max(0, a_fx)) = 0.5 * max(0, (e1 - e2)) */
-
- IF( GT_16( sub( q_c, q_e ), Q15 ) )
- {
- pm_fx = L_shr( L_max( 0, L_abs( L_sub( e1, e2 ) ) ), 1 );
- q_tmp2 = q_e;
- move16();
- }
- ELSE
- {
- tmp2 = crossSquare_fx;
- move32();
- q_tmp2 = sub( q_crossSquare, 2 ); // crossSquare_fx = 4 * crossSquare_fx;
-
- tmp1 = Mpy_32_32( L_sub( e1, e2 ), L_sub( e1, e2 ) );
- q_tmp1 = sub( add( q_e, q_e ), 31 );
-
- a_fx = BASOP_Util_Add_Mant32Exp( tmp1, sub( 31, q_tmp1 ), tmp2, sub( 31, q_tmp2 ), &q_tmp2 ); // (E1 - E2)^2 + 4 * crossSquare_fx
- q_tmp2 = sub( 31, q_tmp2 );
-
- exp = sub( 31, q_tmp2 );
- pm_fx = Sqrt32( L_max( 0, L_sub( a_fx, 1 ) ), &exp );
- pm_fx = L_shr( pm_fx, 1 );
- q_tmp2 = sub( 31, exp );
- }
- }
- }
- // add_fx = 0.5 * (e1 + e2)
- add_fx = L_shr( L_add( e1, e2 ), 1 );
- q_tmp1 = q_e;
- move16();
-
- IF( LT_16( q_tmp1, q_tmp2 ) )
- {
- D_fx[0] = L_add( L_shr( add_fx, 1 ), L_shr( pm_fx, add( sub( q_tmp2, q_tmp1 ), 1 ) ) );
- move32();
- D_fx[1] = L_max( 0, L_sub( L_shr( add_fx, 1 ), L_shr( pm_fx, add( sub( q_tmp2, q_tmp1 ), 1 ) ) ) );
- move32();
- *q_D = sub( q_tmp1, 1 );
- move16();
- }
- ELSE
- {
- D_fx[0] = L_add( L_shr( add_fx, add( sub( q_tmp1, q_tmp2 ), 1 ) ), L_shr( pm_fx, 1 ) );
- move32();
- D_fx[1] = L_max( 0, L_sub( L_shr( add_fx, add( sub( q_tmp1, q_tmp2 ), 1 ) ), L_shr( pm_fx, 1 ) ) );
- move32();
- *q_D = sub( q_tmp2, 1 );
- move16();
- }
-
- /* Numeric case, when input is practically zeros */
- // IF( D_fx[0] < EPSILON_FX )
-
- IF( LT_32( L_shl_sat( D_fx[0], sub( sub( 31, *q_D ), EPSILON_EXP ) ), EPSILON_MANT ) )
- {
- Ure_fx[0][0] = ONE_IN_Q31;
- move32();
- Ure_fx[1][1] = ONE_IN_Q31;
- move32();
- *q_U = Q31;
- move16();
-
- return;
- }
-
- /* Numeric case, when input is near an identity matrix with a gain */
- tmp1 = Mpy_32_32( INV_1000_Q31, add_fx );
-
- IF( LT_16( q_tmp1, q_tmp2 ) )
- {
- IF( LT_32( L_shr( pm_fx, sub( q_tmp2, q_tmp1 ) ), tmp1 ) )
- {
- Ure_fx[0][0] = ONE_IN_Q30;
- move32();
- Ure_fx[1][1] = ONE_IN_Q30;
- move32();
- *q_U = Q30;
- move16();
-
- return;
- }
- }
- ELSE
- {
- IF( LT_32( pm_fx, L_shr( tmp1, sub( q_tmp1, q_tmp2 ) ) ) )
- {
- Ure_fx[0][0] = ONE_IN_Q30;
- move32();
- Ure_fx[1][1] = ONE_IN_Q30;
- move32();
- *q_U = Q30;
- move16();
-
- return;
- }
- }
-
- q_U_1 = 0;
- q_U_2 = 0;
- move16();
- move16();
-
- /* Eigenvectors */
- FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
- {
- Word16 q_diff = sub( q_e, *q_D );
- IF( q_diff > 0 )
- {
- tmp1 = L_sub( D_fx[ch], L_shr( e1, q_diff ) );
- tmp2 = L_sub( D_fx[ch], L_shr( e2, q_diff ) );
- q_tmp1 = *q_D;
- move16();
- }
- ELSE
- {
- tmp1 = L_sub( L_shl( D_fx[ch], q_diff ), e1 );
- tmp2 = L_sub( L_shl( D_fx[ch], q_diff ), e2 );
- q_tmp1 = q_e;
- move16();
- }
-
- IF( GT_32( L_abs( tmp2 ), L_abs( tmp1 ) ) )
- {
- s_fx = tmp2;
- move32();
- exp = sub( norm_l( s_fx ), 1 );
- tmp2 = Mpy_32_32( s_fx, s_fx );
- q_tmp2 = sub( add( q_tmp1, q_tmp1 ), 31 );
-
- tmp2 = BASOP_Util_Add_Mant32Exp( crossSquare_fx, sub( 31, q_crossSquare ), tmp2, sub( 31, q_tmp2 ), &q_tmp2 );
- q_tmp2 = sub( 31, q_tmp2 );
-
- tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 );
-
- tmp2 = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, tmp3, &exp );
- exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) );
- normVal_fx = Sqrt32( tmp2, &exp ); // q_tmp2
- q_tmp2 = sub( 31, exp );
-
- q_diff = sub( q_c, q_tmp1 );
- IF( q_diff > 0 )
- {
- c_re = L_shr( c_re, q_diff );
- c_im = L_shr( c_im, q_diff );
- q_c = q_tmp1;
- move16();
- }
- ELSE
- {
- s_fx = L_shl( s_fx, q_diff );
- q_tmp1 = q_c;
- move16();
- }
-
- Ure_fx[0][ch] = Mpy_32_32( s_fx, normVal_fx );
- move32();
- Ure_fx[1][ch] = Mpy_32_32( c_re, normVal_fx );
- move32();
- Uim_fx[1][ch] = Mpy_32_32( c_im, normVal_fx );
- move32();
- q_U_1 = sub( add( q_tmp1, q_tmp2 ), 31 );
-
- IF( q_U_2 != 0 )
- {
- q_diff = sub( q_U_2, q_U_1 );
- IF( q_diff > 0 )
- {
- Ure_fx[1][ch - 1] = L_shr( Ure_fx[1][ch - 1], q_diff );
- Ure_fx[0][ch - 1] = L_shr( Ure_fx[0][ch - 1], q_diff );
- Uim_fx[0][ch - 1] = L_shr( Uim_fx[0][ch - 1], q_diff );
- q_U_2 = q_U_1;
- move32();
- move32();
- move32();
- move16();
- }
- ELSE IF( GT_16( q_U_1, q_U_2 ) )
- {
- Ure_fx[1][ch] = L_shl( Ure_fx[1][ch], q_diff );
- Ure_fx[0][ch] = L_shl( Ure_fx[0][ch], q_diff );
- Uim_fx[1][ch] = L_shl( Uim_fx[1][ch], q_diff );
- q_U_1 = q_U_2;
- move32();
- move32();
- move32();
- move16();
- }
- }
- q_U_2 = q_U_1;
- move16();
- }
- ELSE
- {
- s_fx = tmp1;
- move32();
-
- exp = sub( norm_l( s_fx ), 1 );
- tmp2 = Mpy_32_32( s_fx, s_fx );
- q_tmp2 = sub( add( q_tmp1, q_tmp1 ), 31 );
-
- tmp2 = BASOP_Util_Add_Mant32Exp( crossSquare_fx, sub( 31, q_crossSquare ), tmp2, sub( 31, q_tmp2 ), &q_tmp2 );
- q_tmp2 = sub( 31, q_tmp2 );
-
- tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 );
-
- tmp2 = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, tmp3, &exp );
- exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) );
- normVal_fx = Sqrt32( tmp2, &exp ); // q_tmp2
- q_tmp2 = sub( 31, exp );
-
- q_diff = sub( q_c, q_tmp1 );
- IF( q_diff > 0 )
- {
- c_re = L_shr( c_re, q_diff );
- c_im = L_shr( c_im, q_diff );
- q_c = q_tmp1;
- move16();
- }
- ELSE
- {
- s_fx = L_shl( s_fx, q_diff );
- q_tmp1 = q_c;
- move16();
- }
-
- Ure_fx[1][ch] = Mpy_32_32( s_fx, normVal_fx );
- move32();
- Ure_fx[0][ch] = Mpy_32_32( c_re, normVal_fx );
- move32();
- Uim_fx[0][ch] = Mpy_32_32( L_negate( c_im ), normVal_fx );
- move32();
- q_U_2 = sub( add( q_tmp1, q_tmp2 ), 31 );
-
- IF( q_U_1 != 0 )
- {
- q_diff = sub( q_U_2, q_U_1 );
- IF( q_diff > 0 )
- {
- Ure_fx[1][ch] = L_shr( Ure_fx[1][ch], q_diff );
- Ure_fx[0][ch] = L_shr( Ure_fx[0][ch], q_diff );
- Uim_fx[0][ch] = L_shr( Uim_fx[0][ch], q_diff );
- q_U_2 = q_U_1;
- move32();
- move32();
- move32();
- move16();
- }
- ELSE IF( GT_16( q_U_1, q_U_2 ) )
- {
- Ure_fx[1][ch - 1] = L_shl( Ure_fx[1][ch - 1], q_diff );
- Ure_fx[0][ch - 1] = L_shl( Ure_fx[0][ch - 1], q_diff );
- Uim_fx[1][ch - 1] = L_shl( Uim_fx[1][ch - 1], q_diff );
- q_U_1 = q_U_2;
- move32();
- move32();
- move32();
- move16();
- }
- }
- q_U_1 = q_U_2;
- move16();
- }
- }
-
- if ( q_U_1 != 0 )
- {
- *q_U = q_U_1;
- move16();
- }
-
- if ( q_U_1 == 0 )
- {
- *q_U = q_U_2;
- move16();
- }
-#endif
return;
}
@@ -4216,9 +3813,7 @@ static void matrixDiagMul_fx(
{
Word16 chA, chB;
-#ifdef OPT_2185_MATRIX_OUT_SCALING
Word32 not_zero = 0;
-#endif
FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ )
{
@@ -4228,35 +3823,23 @@ static void matrixDiagMul_fx(
imOut_fx[chA][chB] = Mpy_32_32( imIn_fx[chA][chB], D_fx[chB] );
move32();
move32();
-#ifdef OPT_2185_MATRIX_OUT_SCALING
not_zero = L_or( not_zero, reOut_fx[chA][chB] );
not_zero = L_or( not_zero, imOut_fx[chA][chB] );
-#endif
}
}
*q_Out = sub( add( q_In, q_D ), 31 );
move16();
-#ifdef OPT_2185_MATRIX_OUT_SCALING
if ( !not_zero )
{
*q_Out = Q31;
move16();
}
-#else
- Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS );
- if ( L_and( is_zero_arr( reOut_fx[0], size ), is_zero_arr( imOut_fx[0], size ) ) )
- {
- *q_Out = Q31;
- move16();
- }
-#endif
return;
}
-#ifdef OPT_2182_MATRIX_SCALE_OPS
static void matrixScale_fx(
Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/
Word32 Aim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/
@@ -4270,7 +3853,6 @@ static void matrixScale_fx(
*q_A = add( *q_A, shift );
move16();
}
-#endif
static void matrixMul_fx(
Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/
@@ -4283,29 +3865,8 @@ static void matrixMul_fx(
Word32 outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/
Word16 *q_out )
{
-#ifdef OPT_2182_MATRIX_SCALE_OPS
Word16 chA, chB;
-#else
- Word16 chA, chB;
- Word16 min_q_shift1, min_q_shift2;
- Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS );
-
- min_q_shift1 = sub( s_min( L_norm_arr( Are_fx[0], size ), L_norm_arr( Aim_fx[0], size ) ), 1 );
- min_q_shift2 = sub( s_min( L_norm_arr( Bre_fx[0], size ), L_norm_arr( Bim_fx[0], size ) ), 1 );
-
- scale_sig32( Are_fx[0], size, min_q_shift1 );
- scale_sig32( Aim_fx[0], size, min_q_shift1 );
- scale_sig32( Bre_fx[0], size, min_q_shift2 );
- scale_sig32( Bim_fx[0], size, min_q_shift2 );
-
- *q_A = add( *q_A, min_q_shift1 );
- *q_B = add( *q_B, min_q_shift2 );
- move16();
- move16();
-#endif
-#ifdef OPT_2185_MATRIX_OUT_SCALING
Word32 not_zero = 0;
-#endif
FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ )
{
@@ -4332,31 +3893,18 @@ static void matrixMul_fx(
Are_fx[chA][1], Bim_fx[1][chB] );
move32();
#endif /* #ifdef IVAS_ENH64_CADENCE_CHANGES */
-#ifdef OPT_2185_MATRIX_OUT_SCALING
not_zero = L_or( not_zero, outRe_fx[chA][chB] );
not_zero = L_or( not_zero, outIm_fx[chA][chB] );
-#endif
}
}
*q_out = sub( add( *q_A, *q_B ), 31 );
move16();
-#ifdef OPT_2185_MATRIX_OUT_SCALING
if ( !not_zero )
{
*q_out = Q31;
move16();
}
-#else
-#ifdef OPT_2182_MATRIX_SCALE_OPS
- Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS;
-#endif
- if ( L_and( is_zero_arr( outRe_fx[0], size ), is_zero_arr( outIm_fx[0], size ) ) )
- {
- *q_out = Q31;
- move16();
- }
-#endif
return;
}
@@ -4376,25 +3924,16 @@ static void matrixTransp1Mul_fx(
Word64 tmp_outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
Word64 tmp_outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
-#ifdef OPT_2181_MATRIX_TRANSP_1_MUL
Word64 tmp64;
Word16 common_lsh, q;
q = add( add( q_A, q_B ), 1 );
common_lsh = sub( 63, q );
move16();
-#else
- Word16 q_tmp_outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
- Word16 q_tmp_outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS];
- Word64 tmp64_1, tmp64_2;
- Word16 tmp16, q_common = 63;
- move16();
-#endif
FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ )
{
FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ )
{
-#ifdef OPT_2181_MATRIX_TRANSP_1_MUL
tmp64 = W_mult_32_32( Are_fx[0][chA], Bre_fx[0][chB] );
tmp64 = W_mac_32_32( tmp64, Are_fx[1][chA], Bre_fx[1][chB] );
tmp64 = W_mac_32_32( tmp64, Aim_fx[0][chA], Bim_fx[0][chB] );
@@ -4408,82 +3947,32 @@ static void matrixTransp1Mul_fx(
tmp_outIm_fx[chA][chB] = W_mac_32_32( tmp64, Are_fx[1][chA], Bim_fx[1][chB] );
move64();
common_lsh = s_min( common_lsh, W_norm( tmp_outIm_fx[chA][chB] ) );
-#else
- tmp64_1 = W_mac_32_32( W_mult_32_32( Are_fx[0][chA], Bre_fx[0][chB] ), Are_fx[1][chA], Bre_fx[1][chB] ); // Q: add( add( q_A, q_B ), 1 )
- tmp64_2 = W_mac_32_32( W_mult_32_32( Aim_fx[0][chA], Bim_fx[0][chB] ), Aim_fx[1][chA], Bim_fx[1][chB] ); // Q: add( add( q_A, q_B ), 1 )
- tmp_outRe_fx[chA][chB] = W_add( tmp64_1, tmp64_2 ); // Q: add( add( q_A, q_B ), 1 )
- move64();
- tmp16 = W_norm( tmp_outRe_fx[chA][chB] );
- tmp_outRe_fx[chA][chB] = W_shl( tmp_outRe_fx[chA][chB], tmp16 ); // Q:add( tmp16, add( add( q_A, q_B ), 1 ) )
- move64();
- q_tmp_outRe_fx[chA][chB] = add( tmp16, add( add( q_A, q_B ), 1 ) );
- move16();
- q_common = s_min( q_tmp_outRe_fx[chA][chB], q_common );
-
-
- tmp64_1 = W_mac_32_32( W_mult_32_32( Are_fx[0][chA], Bim_fx[0][chB] ), Are_fx[1][chA], Bim_fx[1][chB] ); // Q: add( add( q_A, q_B ), 1 )
- tmp64_2 = W_mac_32_32( W_mult_32_32( Aim_fx[0][chA], Bre_fx[0][chB] ), Aim_fx[1][chA], Bre_fx[1][chB] ); // Q: add( add( q_A, q_B ), 1 )
- tmp_outIm_fx[chA][chB] = W_sub( tmp64_1, tmp64_2 ); // Q: add( add( q_A, q_B ), 1 )
- move64();
- tmp16 = W_norm( tmp_outIm_fx[chA][chB] );
- tmp_outIm_fx[chA][chB] = W_shl( tmp_outIm_fx[chA][chB], tmp16 ); // Q:add( tmp16, add( add( q_A, q_B ), 1 ) )
- move64();
- q_tmp_outIm_fx[chA][chB] = add( tmp16, add( add( q_A, q_B ), 1 ) );
- move16();
- q_common = s_min( q_tmp_outIm_fx[chA][chB], q_common );
-#endif
}
}
-#ifdef OPT_2185_MATRIX_OUT_SCALING
Word32 not_zero = 0;
-#endif
FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ )
{
FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ )
{
-#ifdef OPT_2181_MATRIX_TRANSP_1_MUL
outRe_fx[chA][chB] = W_extract_h( W_shl( tmp_outRe_fx[chA][chB], common_lsh ) );
move32();
outIm_fx[chA][chB] = W_extract_h( W_shl( tmp_outIm_fx[chA][chB], common_lsh ) );
move32();
-#else
- outRe_fx[chA][chB] = W_extract_h( W_shl( tmp_outRe_fx[chA][chB], s_max( -63, sub( q_common, q_tmp_outRe_fx[chA][chB] ) ) ) );
- move32();
- outIm_fx[chA][chB] = W_extract_h( W_shl( tmp_outIm_fx[chA][chB], s_max( -63, sub( q_common, q_tmp_outIm_fx[chA][chB] ) ) ) );
- move32();
-#endif
-#ifdef OPT_2185_MATRIX_OUT_SCALING
not_zero = L_or( not_zero, outRe_fx[chA][chB] );
not_zero = L_or( not_zero, outIm_fx[chA][chB] );
-#endif
}
}
-#ifdef OPT_2181_MATRIX_TRANSP_1_MUL
*q_out = sub( add( q, common_lsh ), 32 );
move16();
-#else
- *q_out = sub( q_common, 32 );
- move16();
-#endif
-#ifdef OPT_2185_MATRIX_OUT_SCALING
if ( !not_zero )
{
*q_out = Q31;
move16();
}
-#else
- Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS );
- if ( L_and( is_zero_arr( outRe_fx[0], size ), is_zero_arr( outIm_fx[0], size ) ) )
- {
- *q_out = Q31;
- move16();
- }
-#endif
return;
}
-#ifdef OPT_2182_MATRIX_SCALE_OPS
static void matrixTransp2Mul_fx(
Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/
Word32 Aim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/
@@ -4494,50 +3983,10 @@ static void matrixTransp2Mul_fx(
Word32 outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/
Word32 outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/
Word16 *q_out )
-#else
-static void matrixTransp2Mul_fx(
- Word32 Are_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/
- Word32 Aim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_A*/
- Word16 *q_A,
- Word32 Bre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_B*/
- Word32 Bim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_B*/
- Word16 *q_B,
- Word32 Ascale,
- Word32 Bscale,
- Word32 outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/
- Word32 outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/
- Word16 *q_out )
-#endif
{
-#ifdef OPT_2182_MATRIX_SCALE_OPS
Word16 chA, chB;
// Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS;
-#else
- Word16 chA, chB;
- Word16 min_q_shift;
- Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS;
-
- IF( Ascale == 1 )
- {
- min_q_shift = sub( s_min( L_norm_arr( Are_fx[0], size ), L_norm_arr( Aim_fx[0], size ) ), 1 );
- scale_sig32( Are_fx[0], size, min_q_shift );
- scale_sig32( Aim_fx[0], size, min_q_shift );
- *q_A = add( *q_A, min_q_shift );
- move16();
- }
-
- IF( Bscale == 1 )
- {
- min_q_shift = sub( s_min( L_norm_arr( Bre_fx[0], size ), L_norm_arr( Bim_fx[0], size ) ), 1 );
- scale_sig32( Bre_fx[0], size, min_q_shift );
- scale_sig32( Bim_fx[0], size, min_q_shift );
- *q_B = add( *q_B, min_q_shift );
- move16();
- }
-#endif
-#ifdef OPT_2185_MATRIX_OUT_SCALING
Word32 not_zero = 0;
-#endif
FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ )
{
FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ )
@@ -4563,31 +4012,18 @@ static void matrixTransp2Mul_fx(
Are_fx[chA][1], Bim_fx[chB][1] );
move32();
#endif /* #ifdef IVAS_ENH64_CADENCE_CHANGES */
-#ifdef OPT_2185_MATRIX_OUT_SCALING
not_zero = L_or( not_zero, outRe_fx[chA][chB] );
not_zero = L_or( not_zero, outIm_fx[chA][chB] );
-#endif
}
}
*q_out = sub( add( *q_A, *q_B ), 31 );
move16();
-#ifdef OPT_2185_MATRIX_OUT_SCALING
if ( !not_zero )
{
*q_out = Q31;
move16();
}
-#else
-#ifdef OPT_2182_MATRIX_SCALE_OPS
- Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS;
-#endif
- if ( L_and( is_zero_arr( outRe_fx[0], size ), is_zero_arr( outIm_fx[0], size ) ) )
- {
- *q_out = Q31;
- move16();
- }
-#endif
return;
}
@@ -5090,10 +4526,8 @@ static void formulate2x2MixingMatrix_fx(
q_temp = sub( add( q_ky, q_GhatQ ), 31 );
/* A = Ky' * G_hat * Q * Kx (see publication) */
-#ifdef OPT_2182_MATRIX_SCALE_OPS
matrixScale_fx( tmpRe_fx, tmpIm_fx, &q_temp );
matrixScale_fx( Kxre_fx, Kxim_fx, &q_Kx );
-#endif
matrixMul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Kxre_fx, Kxim_fx, &q_Kx, Are_fx, Aim_fx, &q_A );
/* Find nearest orthonormal matrix P to A = Ky' * G_hat * Q * Kx
@@ -5151,10 +4585,8 @@ static void formulate2x2MixingMatrix_fx(
div_fx[0] = L_min( div_fx[0], thresh ); // q_div
div_fx[1] = L_min( div_fx[1], thresh ); // q_div
-#ifdef OPT_2182_MATRIX_SCALE_OPS
matrixScale_fx( Are_fx, Aim_fx, &q_A );
matrixScale_fx( Ure_fx, Uim_fx, &q_U );
-#endif
matrixMul_fx( Are_fx, Aim_fx, &q_A, Ure_fx, Uim_fx, &q_U, tmpRe_fx, tmpIm_fx, &q_temp );
exp = L_norm_arr( div_fx, BINAURAL_CHANNELS );
@@ -5218,17 +4650,10 @@ static void formulate2x2MixingMatrix_fx(
}
}
-#ifdef OPT_2182_MATRIX_SCALE_OPS
matrixTransp2Mul_fx(
tmpRe_fx, tmpIm_fx, &q_temp,
Ure_fx, Uim_fx, &q_U,
Pre_fx, Pim_fx, &q_P ); /* Nearest orthonormal matrix P to matrix A formulated */
-#else
- matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Ure_fx, Uim_fx, &q_U,
- 0 /*int Ascale*/,
- 0 /*int Bscale*/,
- Pre_fx, Pim_fx, &q_P ); /* Nearest orthonormal matrix P to matrix A formulated */
-#endif
/* These are the final formulas of the JAES publication M = Ky P Kx^(-1) */
#if ( BINAURAL_CHANNELS != 2 )
@@ -5359,23 +4784,14 @@ static void formulate2x2MixingMatrix_fx(
}
}
-#ifdef OPT_2182_MATRIX_SCALE_OPS
matrixScale_fx( KyRe_fx, KyIm_fx, &q_ky );
matrixScale_fx( Pre_fx, Pim_fx, &q_P );
-#endif
matrixMul_fx( KyRe_fx, KyIm_fx, &q_ky, Pre_fx, Pim_fx, &q_P, tmpRe_fx, tmpIm_fx, &q_temp );
-#ifdef OPT_2182_MATRIX_SCALE_OPS
matrixScale_fx( tmpRe_fx, tmpIm_fx, &q_temp );
matrixTransp2Mul_fx(
tmpRe_fx, tmpIm_fx, &q_temp,
Uxre_fx, Uxim_fx, &q_Ux,
Mre_fx, Mim_fx, q_M );
-#else
- matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Uxre_fx, Uxim_fx, &q_Ux,
- 1 /*int Ascale*/,
- 0 /*int Bscale*/,
- Mre_fx, Mim_fx, q_M );
-#endif
return;
}
@@ -6574,7 +5990,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx(
IF( GT_32( totalTargetEne, 0 ) )
{
- tempDivisor = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q28, max( EPSILON_FX, totalTargetEne ), &temp_q );
+ tempDivisor = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q28, L_max( EPSILON_FX, totalTargetEne ), &temp_q );
temp_q = sub( sub( Q31, temp_q ), sub( sub( Q31, Q28 ), sub( Q31, subQ ) ) );
@@ -6607,7 +6023,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx(
IF( enableCentering )
{
temp1 = abs_s( sub( panEnesIn[ismDirIndex][0], panEnesOut[ismDirIndex][0] ) ); // 2*sub(enes) -> Q14
- centeringFactor = max( 0, sub( temp1, ONE_IN_Q14 ) ); // Q14
+ centeringFactor = s_max( 0, sub( temp1, ONE_IN_Q14 ) ); // Q14
FOR( ch = 0; ch < 2; ch++ )
{
diff --git a/lib_rend/ivas_dirac_decorr_dec_fx.c b/lib_rend/ivas_dirac_decorr_dec_fx.c
index a4f703a28fdc0344b2c5c351e53dbb496247d7c0..bd5585c088f1dc1c86f7f13130bf54bc688080c2 100644
--- a/lib_rend/ivas_dirac_decorr_dec_fx.c
+++ b/lib_rend/ivas_dirac_decorr_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_dirac_onsets_dec_fx.c b/lib_rend/ivas_dirac_onsets_dec_fx.c
index 1e105ba223cb2607df3ecc8acd35e720ed9675b5..5abc1f73e96b45ad8840b9b04505e5776aff5597 100644
--- a/lib_rend/ivas_dirac_onsets_dec_fx.c
+++ b/lib_rend/ivas_dirac_onsets_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c
index de25c56e5a6bbc074faaefc5bd2d7e103bca66ca..f2a225de365080d75c07b2260cb0691022d492ae 100644
--- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c
+++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -211,7 +211,7 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx(
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) );
}
- dirac_output_synthesis_state->cy_auto_dir_smooth_prev_len = imult1616( dirac_output_synthesis_params->max_band_decorr, hDirACRend->num_outputs_diff );
+ dirac_output_synthesis_state->cy_auto_diff_smooth_prev_len = imult1616( dirac_output_synthesis_params->max_band_decorr, hDirACRend->num_outputs_diff );
move16();
}
ELSE
diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c
index 83ce8af453f5bff58ee24f6600117c887f39e919..e242c9c085ccae575979946a8b7a8b7f579d49fe 100644
--- a/lib_rend/ivas_dirac_rend_fx.c
+++ b/lib_rend/ivas_dirac_rend_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -253,6 +253,10 @@ ivas_error ivas_spat_hSpatParamRendCom_config_fx(
move16();
hSpatParamRendCom->numIsmDirections = 0;
move16();
+#ifdef FIX_BASOP_2354_MSAN_DIFF_Q_VALUE
+ hSpatParamRendCom->q_diffuseness_vector = Q30;
+ move16();
+#endif
}
/*-----------------------------------------------------------------*
@@ -856,6 +860,9 @@ ivas_error ivas_dirac_alloc_mem_fx(
/* Prototypes */
hDirAC_mem->proto_direct_buffer_f_fx = NULL;
hDirAC_mem->proto_diffuse_buffer_f_fx = NULL;
+ hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len = 0;
+ hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len = 0;
+ hDirAC_mem->proto_diffuse_buffer_f_len = 0;
test();
test();
IF( NE_32( renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_32( renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) && NE_32( renderer_type, RENDERER_STEREO_PARAMETRIC ) )
diff --git a/lib_rend/ivas_efap_fx.c b/lib_rend/ivas_efap_fx.c
index c85d89b8570ad56859b63f31fa73d2c8394146ec..c5bbfb2ea3e5d6cbf55b4c2566eb2e9e58da93b1 100644
--- a/lib_rend/ivas_efap_fx.c
+++ b/lib_rend/ivas_efap_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c
index dee0fe052a902bb55841b54c10646c6ff79fcce7..537323af591737f9ad114e25139555b13a758d22 100644
--- a/lib_rend/ivas_hrtf_fx.c
+++ b/lib_rend/ivas_hrtf_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -33,19 +33,18 @@
#include
#include "options.h"
#include "prot_fx.h"
-#include "ivas_rom_binaural_crend_head.h"
#include "ivas_prot_rend_fx.h"
#include "ivas_error.h"
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
/*-----------------------------------------------------------------------*
- * ivas_HRTF_binary_open()
+ * ivas_HRTF_td_binary_open()
*
* Allocate HRTF binary handle for TD renderer
*-----------------------------------------------------------------------*/
-ivas_error ivas_HRTF_binary_open_fx(
+ivas_error ivas_HRTF_td_binary_open_fx(
TDREND_HRFILT_FiltSet_t **hHrtfTD )
{
/* Allocate HR filter set for headphones configuration */
@@ -60,14 +59,12 @@ ivas_error ivas_HRTF_binary_open_fx(
return IVAS_ERR_OK;
}
-
/*-------------------------------------------------------------------*
- * ivas_HRTF_binary_close()
+ * ivas_HRTF_td_binary_close_fx()
*
* Close HRTF binary handle for TD renderer
*-------------------------------------------------------------------*/
-
-void ivas_HRTF_binary_close_fx(
+void ivas_HRTF_td_binary_close_fx(
TDREND_HRFILT_FiltSet_t **hHrtfTD )
{
test();
@@ -76,6 +73,76 @@ void ivas_HRTF_binary_close_fx(
return;
}
+ Word16 i;
+ IF( ( *hHrtfTD )->ModelParams.modelROM )
+ {
+ FOR( i = 0; i < ( *hHrtfTD )->ModelParams.num_unique_azim_splines; i++ )
+ {
+ free( ( *hHrtfTD )->ModelParams.azimBsShape_dyn_fx[i] );
+ }
+ free( ( *hHrtfTD )->ModelParams.azimBsShape_dyn_fx );
+ free( (void *) ( *hHrtfTD )->ModelParams.azimBsShape_fx ); /* void* cast needed to please both gcc and Visual studio compilers. Deallocating const float** should be fine and gcc agrees, but Visual studio complains. */
+ FOR( i = 0; i < ( *hHrtfTD )->ModelParams.elevDim3; i++ )
+ {
+ free( ( *hHrtfTD )->ModelParams.azimKSeq_fx[i] );
+ }
+ free( ( *hHrtfTD )->ModelParams.azimKSeq_fx );
+ IF( ( *hHrtfTD )->ModelEval.hrfModR_fx != NULL )
+ {
+ free( ( *hHrtfTD )->ModelEval.hrfModL_fx );
+ }
+ IF( ( *hHrtfTD )->ModelEval.hrfModL_fx != NULL )
+ {
+ free( ( *hHrtfTD )->ModelEval.hrfModR_fx );
+ }
+ }
+ else
+ {
+ if ( ( *hHrtfTD )->ModelParams.UseItdModel )
+ {
+ free( ( *hHrtfTD )->ModelParamsITD.elevKSeq_dyn_fx );
+ free( ( *hHrtfTD )->ModelParamsITD.azimKSeq_dyn_fx );
+ free( ( *hHrtfTD )->ModelParamsITD.W_dyn_fx );
+ free( ( *hHrtfTD )->ModelParamsITD.azimBsShape_dyn_fx );
+ free( ( *hHrtfTD )->ModelParamsITD.elevBsShape_dyn_fx );
+ free( ( *hHrtfTD )->ModelParamsITD.azimBsLen_dyn_fx );
+ free( ( *hHrtfTD )->ModelParamsITD.azimBsStart_dyn_fx );
+ free( ( *hHrtfTD )->ModelParamsITD.elevBsLen_dyn_fx );
+ free( ( *hHrtfTD )->ModelParamsITD.elevBsStart_dyn_fx );
+ }
+ free( ( *hHrtfTD )->ModelParams.elevKSeq_dyn_fx );
+ free( ( *hHrtfTD )->ModelParams.azim_start_idx_dyn );
+ free( ( *hHrtfTD )->ModelParams.azimDim3_dyn );
+ free( ( *hHrtfTD )->ModelParams.AlphaL_dyn_fx );
+ free( ( *hHrtfTD )->ModelParams.AlphaR_dyn_fx );
+ free( ( *hHrtfTD )->ModelParams.azimSegSamples_dyn );
+
+ free( ( *hHrtfTD )->ModelParams.azimShapeIdx_dyn );
+ free( ( *hHrtfTD )->ModelParams.azimShapeSampFactor_dyn );
+ free( ( *hHrtfTD )->ModelParams.elevBsLen_dyn );
+ free( ( *hHrtfTD )->ModelParams.elevBsStart_dyn );
+ free( ( *hHrtfTD )->ModelParams.elevBsShape_dyn_fx );
+
+ for ( i = 0; i < ( *hHrtfTD )->ModelParams.num_unique_azim_splines; i++ )
+ {
+ free( ( *hHrtfTD )->ModelParams.azimBsShape_dyn_fx[i] );
+ }
+ free( ( *hHrtfTD )->ModelParams.azimBsShape_dyn_fx );
+
+ free( (void *) ( *hHrtfTD )->ModelParams.azimBsShape_fx ); /* void* cast needed to please both gcc and Visual studio compilers. Deallocating const float** should be fine and gcc agrees, but Visual studio complains. */
+ for ( i = 0; i < ( *hHrtfTD )->ModelParams.elevDim3; i++ )
+ {
+ free( ( *hHrtfTD )->ModelParams.azimKSeq_fx[i] );
+ }
+ free( ( *hHrtfTD )->ModelParams.azimKSeq_fx );
+
+ free( ( *hHrtfTD )->ModelParams.EL_dyn_fx );
+ free( ( *hHrtfTD )->ModelParams.ER_dyn_fx );
+
+ free( ( *hHrtfTD )->ModelEval.hrfModL_fx );
+ free( ( *hHrtfTD )->ModelEval.hrfModR_fx );
+ }
+
free( *hHrtfTD );
*hHrtfTD = NULL;
@@ -113,8 +180,7 @@ ivas_error ivas_HRTF_CRend_binary_open_fx(
*
* Allocate buffer with dynamic length for HRTF binary Crend handle
*-----------------------------------------------------------------------*/
-
-ivas_error ivas_HRTF_CRend_binary_open_buffers_int16(
+ivas_error ivas_HRTF_binary_open_buffers_int16(
Word16 **buffer, /* o : buffer to allocate */
const UWord32 mem_size /* i : size of buffer */
)
@@ -129,6 +195,85 @@ ivas_error ivas_HRTF_CRend_binary_open_buffers_int16(
return IVAS_ERR_OK;
}
+/*-----------------------------------------------------------------------*
+ * ivas_HRTF_binary_open_buffers_uint16()
+ *
+ * Allocate buffer with dynamic length for HRTF binary Crend handle
+ *-----------------------------------------------------------------------*/
+ivas_error ivas_HRTF_binary_open_buffers_uint16(
+ UWord16 **buffer, /* o : buffer to allocate */
+ const uint32_t mem_size /* i : size of buffer */
+)
+{
+ *buffer = (UWord16 *) malloc( mem_size );
+
+ if ( *buffer == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF binary data\n" );
+ }
+
+ return IVAS_ERR_OK;
+}
+
+/*-----------------------------------------------------------------------*
+ * ivas_HRTF_binary_open_buffers_int32()
+ *
+ * Allocate buffer with dynamic length for HRTF binary Crend handle
+ *-----------------------------------------------------------------------*/
+ivas_error ivas_HRTF_binary_open_buffers_int32(
+ Word32 **buffer, /* o : buffer to allocate */
+ const uint32_t mem_size /* i : size of buffer */
+)
+{
+ *buffer = (Word32 *) malloc( mem_size );
+
+ if ( *buffer == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF binary data\n" );
+ }
+
+ return IVAS_ERR_OK;
+}
+
+/*-----------------------------------------------------------------------*
+ * ivas_HRTF_binary_open_buffers_int32_ptr()
+ *
+ * Allocate buffer with dynamic length for HRTF binary Crend handle
+ *-----------------------------------------------------------------------*/
+ivas_error ivas_HRTF_binary_open_buffers_int32_ptr(
+ Word32 ***buffer, /* o : buffer to allocate */
+ const uint32_t mem_size /* i : size of buffer */
+)
+{
+ *buffer = (Word32 **) malloc( mem_size );
+
+ if ( *buffer == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF binary data\n" );
+ }
+
+ return IVAS_ERR_OK;
+}
+
+/*-----------------------------------------------------------------------*
+ * ivas_HRTF_binary_open_buffers_int32_ptr_const()
+ *
+ * Allocate buffer with dynamic length for HRTF binary Crend handle
+ *-----------------------------------------------------------------------*/
+ivas_error ivas_HRTF_binary_open_buffers_int32_ptr_const(
+ const Word32 ***buffer, /* o : buffer to allocate */
+ const uint32_t mem_size /* i : size of buffer */
+)
+{
+ *buffer = (const Word32 **) malloc( mem_size );
+
+ if ( *buffer == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF binary data\n" );
+ }
+
+ return IVAS_ERR_OK;
+}
/*-------------------------------------------------------------------*
* ivas_HRTF_CRend_binary_close()
@@ -224,6 +369,9 @@ void ivas_HRTF_fastconv_binary_close_fx(
return;
}
+ /* Fastconv HRTF memories */
+ ivas_binaural_hrtf_close_fx( hHrtfFastConv );
+
free( *hHrtfFastConv );
*hHrtfFastConv = NULL;
@@ -232,7 +380,7 @@ void ivas_HRTF_fastconv_binary_close_fx(
/*-----------------------------------------------------------------------*
- * ivas_HRTF_parambin_binary_open()
+ * ivas_HRTF_parambin_binary_open_fx()
*
* Allocate HRTF binary handle for parametric binauralizer
*-----------------------------------------------------------------------*/
@@ -253,7 +401,7 @@ ivas_error ivas_HRTF_parambin_binary_open_fx(
/*-----------------------------------------------------------------------*
- * ivas_HRTF_parambin_binary_close()
+ * ivas_HRTF_parambin_binary_close_fx()
*
* Close HRTF binary handle for parametric binauralizer
*-----------------------------------------------------------------------*/
@@ -288,139 +436,43 @@ ivas_error ivas_HRTF_statistics_binary_open_fx(
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for statistics HRTF tables!" );
}
+ set_c( (Word8 *) ( *hHrtfStatistics ), 0, (Word32) sizeof( HRTFS_STATISTICS ) );
return IVAS_ERR_OK;
}
-
-/*-----------------------------------------------------------------------*
- * ivas_HRTF_statistics_close()
+/*---------------------------------------------------------------------*
+ * ivas_HRTF_statistics_binary_close_fx()
*
- * Close HRTF binary handle for statistics handler
- *-----------------------------------------------------------------------*/
-
-void ivas_HRTF_statistics_close_fx(
- HRTFS_STATISTICS **hHrtfStatistics )
+ * Destroy the HRTF statistics set.
+ *---------------------------------------------------------------------*/
+void ivas_HRTF_statistics_binary_close_fx(
+ IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */
+)
{
test();
IF( hHrtfStatistics == NULL || *hHrtfStatistics == NULL )
{
return;
}
-
- free( *hHrtfStatistics );
- *hHrtfStatistics = NULL;
-
- return;
-}
-
-
-/*-----------------------------------------------------------------------*
- * ivas_HRTF_statistics_init()
- *
- * Allocates HRTF statistics handle and initializes from ROM
- *-----------------------------------------------------------------------*/
-
-ivas_error ivas_HRTF_statistics_init_fx(
- HRTFS_STATISTICS_HANDLE *hHrtfStatistics,
- const Word32 sampleRate )
-{
- HRTFS_STATISTICS *HrtfStatistics;
-
test();
- IF( hHrtfStatistics != NULL && *hHrtfStatistics != NULL )
- {
- /* Tables already loaded from file */
- return IVAS_ERR_OK;
- }
-
- /* Initialise tables from ROM */
- IF( ( HrtfStatistics = (HRTFS_STATISTICS *) malloc( sizeof( HRTFS_STATISTICS ) ) ) == NULL )
+ IF( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) )
{
- return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for statistics HRTF tables!" );
- }
-
- HrtfStatistics->average_energy_l = NULL;
- HrtfStatistics->average_energy_r = NULL;
- HrtfStatistics->inter_aural_coherence = NULL;
-
- SWITCH( sampleRate )
- {
- case 48000:
- HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) );
- IF( HrtfStatistics->average_energy_l_dyn == NULL )
- {
- return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
- }
- HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) );
- IF( HrtfStatistics->average_energy_r_dyn == NULL )
- {
- return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
- }
- HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) );
- IF( HrtfStatistics->inter_aural_coherence_dyn == NULL )
- {
- return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
- }
- Copy_Scale_sig_16_32_r( defaultHRIR_left_avg_power_48kHz_fx, HrtfStatistics->average_energy_l_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_48kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
- Copy_Scale_sig_16_32_r( defaultHRIR_right_avg_power_48kHz_fx, HrtfStatistics->average_energy_r_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_48kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
- Copy_Scale_sig_16_32_r( defaultHRIR_coherence_48kHz_fx, HrtfStatistics->inter_aural_coherence_dyn, LR_IAC_LENGTH_NR_FC, Q26 - defaultHRIR_Q_48kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
- HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn;
- HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn;
- HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn;
- BREAK;
- case 32000:
- HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) );
- IF( HrtfStatistics->average_energy_l_dyn == NULL )
- {
- return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
- }
- HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) );
- IF( HrtfStatistics->average_energy_r_dyn == NULL )
- {
- return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
- }
- HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) );
- IF( HrtfStatistics->inter_aural_coherence_dyn == NULL )
- {
- return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
- }
- Copy_Scale_sig_16_32_r( defaultHRIR_left_avg_power_32kHz_fx, HrtfStatistics->average_energy_l_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_32kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
- Copy_Scale_sig_16_32_r( defaultHRIR_right_avg_power_32kHz_fx, HrtfStatistics->average_energy_r_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_32kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
- Copy_Scale_sig_16_32_r( defaultHRIR_coherence_32kHz_fx, HrtfStatistics->inter_aural_coherence_dyn, LR_IAC_LENGTH_NR_FC, Q26 - defaultHRIR_Q_32kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
- HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn;
- HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn;
- HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn;
- BREAK;
- case 16000:
- HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) );
- IF( HrtfStatistics->average_energy_l_dyn == NULL )
- {
- return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
- }
- HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) );
- IF( HrtfStatistics->average_energy_r_dyn == NULL )
- {
- return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
- }
- HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) );
- IF( HrtfStatistics->inter_aural_coherence_dyn == NULL )
- {
- return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
- }
- Copy_Scale_sig_16_32_r( defaultHRIR_left_avg_power_16kHz_fx, HrtfStatistics->average_energy_l_dyn, LR_IAC_LENGTH_NR_FC_16KHZ, Q28 - defaultHRIR_Q_16kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
- Copy_Scale_sig_16_32_r( defaultHRIR_right_avg_power_16kHz_fx, HrtfStatistics->average_energy_r_dyn, LR_IAC_LENGTH_NR_FC_16KHZ, Q28 - defaultHRIR_Q_16kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
- Copy_Scale_sig_16_32_r( defaultHRIR_coherence_16kHz_fx, HrtfStatistics->inter_aural_coherence_dyn, LR_IAC_LENGTH_NR_FC_16KHZ, Q26 - defaultHRIR_Q_16kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
- HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn;
- HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn;
- HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn;
- BREAK;
+ if ( ( *hHrtfStatistics )->average_energy_l_dyn != NULL )
+ {
+ free( ( *hHrtfStatistics )->average_energy_l_dyn );
+ }
+ if ( ( *hHrtfStatistics )->average_energy_r_dyn != NULL )
+ {
+ free( ( *hHrtfStatistics )->average_energy_r_dyn );
+ }
+ if ( ( *hHrtfStatistics )->inter_aural_coherence_dyn != NULL )
+ {
+ free( ( *hHrtfStatistics )->inter_aural_coherence_dyn );
+ }
}
- HrtfStatistics->fromROM = TRUE;
-#ifdef FIX_1990_SANITIZER_IN_REVERB_LOAD
- HrtfStatistics->fromROM = FALSE; // TODO: temporary hack until HRTF statistics ROM tables are converted from Word16 to Word32
-#endif
- *hHrtfStatistics = HrtfStatistics;
+ free( *hHrtfStatistics );
+ *hHrtfStatistics = NULL;
- return IVAS_ERR_OK;
+ return;
}
diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c
index bb2cd94c2fdb7273e5941e7691ef9aa0f63e86dc..b645be551d16619f0bf1e643ee0c5ca87241fadb 100644
--- a/lib_rend/ivas_masa_merge_fx.c
+++ b/lib_rend/ivas_masa_merge_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c
index b2a4e0d0066593cc3fbdbe466307f6db441a84cc..8f4149171fceb11c6109c2bbcc73f506ec4c8a65 100644
--- a/lib_rend/ivas_mcmasa_ana_fx.c
+++ b/lib_rend/ivas_mcmasa_ana_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -423,14 +423,23 @@ void ivas_mcmasa_ana_close(
( *hMcMasa )->direction_vector_m_fx[i][j] = NULL;
}
+ free( ( *hMcMasa )->direction_vector_m_fx[i] );
+ ( *hMcMasa )->direction_vector_m_fx[i] = NULL;
+
+ FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ )
+ {
+ free( ( *hMcMasa )->direction_vector_e[i][j] );
+ ( *hMcMasa )->direction_vector_e[i][j] = NULL;
+ }
+
+ free( ( *hMcMasa )->direction_vector_e[i] );
+ ( *hMcMasa )->direction_vector_e[i] = NULL;
+
FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ )
{
free( ( *hMcMasa )->buffer_intensity_real_fx[i][j] );
( *hMcMasa )->buffer_intensity_real_fx[i][j] = NULL;
}
-
- free( ( *hMcMasa )->direction_vector_m_fx[i] );
- ( *hMcMasa )->direction_vector_m_fx[i] = NULL;
}
FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ )
diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c
index 6f7e7a0cfcd9c08d00d1fd5255c96bb6b1e5cd14..8ba74dad89caaecf9beabdd21775217191aae495 100644
--- a/lib_rend/ivas_objectRenderer_fx.c
+++ b/lib_rend/ivas_objectRenderer_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -434,9 +434,17 @@ ivas_error ivas_td_binaural_renderer_unwrap_fx(
{
Word16 i;
+#ifdef FIX_BASOP_2358_SCALING_OOB
+ FOR( i = 0; i < num_src; ++i )
+#else
FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i )
+#endif
{
+#ifdef FIX_BASOP_2358_SCALING_OOB
+ scale_sig32( output_fx[i], output_frame, -4 ); // Q11 - 4 = Q7
+#else
scale_sig32( output_fx[i], L_FRAME48k, -4 ); // Q11 - 4 = Q7
+#endif
}
IF( NE_32( ( error = ivas_reverb_process_fx( hReverb, transport_config, 0, output_fx, p_reverb_signal_fx, subframe_idx ) ), IVAS_ERR_OK ) ) // Q p_reverb_signal_fx = Q output_fx - 2 = 5
@@ -444,9 +452,17 @@ ivas_error ivas_td_binaural_renderer_unwrap_fx(
return error;
}
+#ifdef FIX_BASOP_2358_SCALING_OOB
+ FOR( i = 0; i < num_src; ++i )
+#else
FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i )
+#endif
{
+#ifdef FIX_BASOP_2358_SCALING_OOB
+ scale_sig32( output_fx[i], output_frame, 4 ); // Q7 + 4 = Q11
+#else
scale_sig32( output_fx[i], L_FRAME48k, 4 ); // Q7 + 4 = Q11
+#endif
}
FOR( i = 0; i < BINAURAL_CHANNELS; ++i )
diff --git a/lib_rend/ivas_objectRenderer_hrFilt_fx.c b/lib_rend/ivas_objectRenderer_hrFilt_fx.c
index 00036a8cd89d35f1316602185ca407744715534e..d5abb8fcef15b24907d0a7b442b6131da552d8b5 100644
--- a/lib_rend/ivas_objectRenderer_hrFilt_fx.c
+++ b/lib_rend/ivas_objectRenderer_hrFilt_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_objectRenderer_mix_fx.c b/lib_rend/ivas_objectRenderer_mix_fx.c
index 28ee13931346b1418d16bbc945f33fc3765e62a7..a0a57d0a2179bd51055513ff5ac2a66ebd62c4ef 100644
--- a/lib_rend/ivas_objectRenderer_mix_fx.c
+++ b/lib_rend/ivas_objectRenderer_mix_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -151,30 +151,6 @@ void TDREND_MIX_Dealloc_fx(
{
BSplineModelEvalDealloc_fx( &hBinRendererTd->HrFiltSet_p->ModelParams, &hBinRendererTd->HrFiltSet_p->ModelEval );
}
- ELSE
- {
- IF( hBinRendererTd->HrFiltSet_p->Elev_p_fx != NULL )
- {
- free( hBinRendererTd->HrFiltSet_p->Elev_p_fx );
- hBinRendererTd->HrFiltSet_p->Elev_p_fx = NULL;
- }
- IF( hBinRendererTd->HrFiltSet_p->Azim_p_fx != NULL )
- {
- free( hBinRendererTd->HrFiltSet_p->Azim_p_fx );
- hBinRendererTd->HrFiltSet_p->Azim_p_fx = NULL;
- }
- IF( hBinRendererTd->HrFiltSet_p->LeftFiltSet_p_fx != NULL )
- {
- free( hBinRendererTd->HrFiltSet_p->LeftFiltSet_p_fx );
- hBinRendererTd->HrFiltSet_p->LeftFiltSet_p_fx = NULL;
- }
- IF( hBinRendererTd->HrFiltSet_p->RightFiltSet_p_fx != NULL )
- {
- free( hBinRendererTd->HrFiltSet_p->RightFiltSet_p_fx );
- hBinRendererTd->HrFiltSet_p->RightFiltSet_p_fx = NULL;
- }
- }
-
IF( hBinRendererTd->HrFiltSet_p->ModelParams.modelROM )
{
IF( hBinRendererTd->HrFiltSet_p->ModelParams.UseItdModel )
diff --git a/lib_rend/ivas_objectRenderer_sfx_fx.c b/lib_rend/ivas_objectRenderer_sfx_fx.c
index 185cba09e42f81bfff0510c7ca37991a318890ca..1c899f95ba696e8f9ed036b5b4169c2c57b6e4bc 100644
--- a/lib_rend/ivas_objectRenderer_sfx_fx.c
+++ b/lib_rend/ivas_objectRenderer_sfx_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c
index 015d227a216074730dbae380211acc9e1235deb0..f91ed65fa86bdb5b5a5cabf58e37001f47af83e3 100644
--- a/lib_rend/ivas_objectRenderer_sources_fx.c
+++ b/lib_rend/ivas_objectRenderer_sources_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_objectRenderer_vec_fx.c b/lib_rend/ivas_objectRenderer_vec_fx.c
index ded14eb095d07107379005d5d8ff3ff660105e6a..81268e578e1e80b59cd60df7d4f8340bb432cc89 100644
--- a/lib_rend/ivas_objectRenderer_vec_fx.c
+++ b/lib_rend/ivas_objectRenderer_vec_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c
index b1405a309551dfaa568a0866f5b8f209104ee581..02af0f7fdb41a0beae11f7b2f41b25d0452c8cb2 100644
--- a/lib_rend/ivas_omasa_ana_fx.c
+++ b/lib_rend/ivas_omasa_ana_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -719,7 +719,7 @@ static void ivas_omasa_dmx_fx(
}
max_e = in_e[0];
move16();
- FOR( l = 1; l < L_FRAME48k; l++ )
+ FOR( l = 1; l < input_frame; l++ )
{
IF( LT_16( max_e, in_e[l] ) )
{
@@ -728,7 +728,7 @@ static void ivas_omasa_dmx_fx(
}
}
- FOR( l = 0; l < L_FRAME48k; l++ )
+ FOR( l = 0; l < input_frame; l++ )
{
data_out_f_fx[j][l] = L_shr( data_out_f_fx[j][l], sub( max_e, in_e[l] ) ); // exponent: max_e, Q: ( 15 - max_e )
move32();
diff --git a/lib_rend/ivas_orient_trk_fx.c b/lib_rend/ivas_orient_trk_fx.c
index 201f5a826fb1948701ecad7b0d5887ca1bd6624f..18fabc03252f67e43a4ee01e1fcfb9b8624b57b5 100644
--- a/lib_rend/ivas_orient_trk_fx.c
+++ b/lib_rend/ivas_orient_trk_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -482,11 +482,21 @@ static Word32 VectorLength_fx(
IVAS_VECTOR3 p,
Word16 *q_fact )
{
+#ifdef FIX_BASOP_2361_OTR
+ Word16 sqrt_e;
+ Word32 result_fx;
+ result_fx = Madd_32_32( Madd_32_32( Mpy_32_32( p.x_fx, p.x_fx ), p.y_fx, p.y_fx ), p.z_fx, p.z_fx );
+ sqrt_e = shl( sub( 31, p.q_fact ), 1 ); /* convert Q to E */
+
+ result_fx = Sqrt32( result_fx, &sqrt_e );
+ *q_fact = sub( 31, sqrt_e ); /* back to Q again */
+#else
Word32 result_fx = 0;
move32();
result_fx = L_add( L_add( Mpy_32_32( p.x_fx, p.x_fx ), Mpy_32_32( p.y_fx, p.y_fx ) ), Mpy_32_32( p.z_fx, p.z_fx ) ); // // Q: ( p1.q_fact + p2.q_fact ) - 31
*q_fact = sub( add( p.q_fact, p.q_fact ), 31 );
+#endif
move16();
return result_fx;
}
@@ -702,7 +712,14 @@ ivas_error ivas_orient_trk_SetReferenceRotation_fx(
Euler2Quat_fx( deg2rad_fx( refRot.x_fx ), deg2rad_fx( refRot.y_fx ), deg2rad_fx( refRot.z_fx ), &pOTR->refRot );
modify_Quat_q_fx( &pOTR->refRot, &pOTR->refRot, Q29 );
}
- pOTR->refRot = refRot;
+#ifdef FIX_BASOP_2361_OTR
+ ELSE
+ {
+#endif
+ pOTR->refRot = refRot;
+#ifdef FIX_BASOP_2361_OTR
+ }
+#endif
return IVAS_ERR_OK;
}
@@ -824,11 +841,16 @@ ivas_error ivas_orient_trk_SetReferenceVector_fx(
return IVAS_ERR_WRONG_PARAMS;
}
+#ifdef FIX_BASOP_2361_OTR
+ Word16 tmp_q;
+ acousticFrontVectorLength = VectorLength_fx( acousticFrontVector, &tmp_q );
+#else
Word16 accoustic_q = acousticFrontVector.q_fact;
move16();
acousticFrontVectorLength = VectorLength_fx( acousticFrontVector, &acousticFrontVector.q_fact );
acousticFrontVector.q_fact = accoustic_q;
move16();
+#endif
/* if the length is zero, the user has entered insensible listener and reference positions */
IF( LE_32( acousticFrontVectorLength, 0 ) )
{
@@ -889,6 +911,18 @@ ivas_error ivas_orient_trk_Process_fx(
/* Reset average orientation */
pOTR->absAvgRot = absRot;
+#ifdef FIX_BASOP_2361_OTR
+ Word16 scale_e;
+ Word16 tmp;
+ tmp = BASOP_Util_Divide3232_Scale( PI2_C_ADP_RATE_Q31, updateRate_fx, &scale_e );
+ scale_e = add( scale_e, 23 - 31 ); /* updateRate_fx is hardcoded in caller to Q23 */
+
+ /* sin(x) is approx x for small x */
+ pOTR->alpha_fx = L_deposit_h( tmp );
+ move32();
+ pOTR->Q_alpha = sub( Q31, scale_e );
+ move16();
+#else
Word16 scale_e;
Word32 div;
div = L_deposit_h( BASOP_Util_Divide3232_Scale( pOTR->centerAdaptationRate_fx, updateRate_fx, &scale_e ) );
@@ -897,6 +931,7 @@ ivas_error ivas_orient_trk_Process_fx(
// here div value is less so we can use sandwitch rule of sine//
pOTR->alpha_fx = div;
move32();
+#endif
/* Compute relative orientation = (absolute orientation) - (reference orientation) */
QuaternionInverse_fx( pOTR->refRot, &pOTR->trkRot );
QuaternionProduct_fx( pOTR->trkRot, absRot, &pOTR->trkRot );
@@ -950,6 +985,8 @@ ivas_error ivas_orient_trk_Process_fx(
cutoff_prod = L_shl( cutoff_prod, temp_diff );
/* Compute adaptivity cutoff frequency: interpolate between minimum (center) and maximum (off-center) values */
cutoffFrequency_fx = L_add( pOTR->centerAdaptationRate_fx, cutoff_prod ); // Q31
+
+ /* Compute filter coefficient corresponding to desired cutoff frequency */
cutoff_prod = Mpy_32_32( cutoffFrequency_fx, PI2_C_Q28 );
q_cutoff_prod = ( ( 31 + 28 ) - 31 );
temp_result = BASOP_Util_Divide3232_Scale( cutoff_prod, updateRate_fx, &result_e );
diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c
index 053cb43c1e4ee0083dd07e708cd709cc14e3fd99..ec279e1686178635bcf3aa33f8030d71abe10913 100644
--- a/lib_rend/ivas_output_init_fx.c
+++ b/lib_rend/ivas_output_init_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -387,7 +387,7 @@ Word16 ivas_get_nchan_buffers_dec_fx(
}
ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) )
{
- nchan_out_buff = max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport );
+ nchan_out_buff = s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport );
IF( st_ivas->hOutSetup.separateChannelEnabled )
{
@@ -408,7 +408,7 @@ Word16 ivas_get_nchan_buffers_dec_fx(
test();
IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
{
- nchan_out_buff = max( nchan_out_buff, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS );
+ nchan_out_buff = s_max( nchan_out_buff, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS );
}
return nchan_out_buff;
@@ -446,7 +446,7 @@ ivas_error ivas_output_buff_dec_fx(
if ( Opt_tsm )
{
/* JBM decoding: output audio buffers are shared with audio buffers from 'hTcBuffer->tc[]' */
- nchan_tc_jbm = s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full );
+ nchan_tc_jbm = s_max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full );
}
test();
@@ -615,11 +615,11 @@ ivas_error get_channel_config(
}
ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) )
{
- strcpy( (char *) str, "BINAURAL_SPLIT_CODED" );
+ strcpy( (char *) str, "Binaural: split-rendering mode with encoded output in an intermediate format" );
}
ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
{
- strcpy( (char *) str, "Binaural_Split_PCM" );
+ strcpy( (char *) str, "Binaural: split-rendering mode with separate PCM binaural output and metadata bitstream output" );
}
ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h
index 5f37622a80dc15b243b5a0deb027bb450ce0cbb8..b393971b7bcbda183494ad2150363e12bce87520 100644
--- a/lib_rend/ivas_prot_rend_fx.h
+++ b/lib_rend/ivas_prot_rend_fx.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -578,12 +578,11 @@ void ivas_masa_ext_dirac_render_fx(
/*----------------------------------------------------------------------------------*
* HRTF
*----------------------------------------------------------------------------------*/
-
-ivas_error ivas_HRTF_binary_open_fx(
+ivas_error ivas_HRTF_td_binary_open_fx(
TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */
);
-void ivas_HRTF_binary_close_fx(
+void ivas_HRTF_td_binary_close_fx(
TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */
);
@@ -607,24 +606,38 @@ ivas_error ivas_HRTF_CRend_binary_open_fx(
HRTFS_CREND_DATA **hHrtfCrend /* i/o: Crend HRTF handle */
);
-ivas_error ivas_HRTF_CRend_binary_open_buffers_int16(
- Word16 **buffer, /* o : buffer to allocate */
+ivas_error ivas_HRTF_binary_open_buffers_uint16(
+ uint16_t **buffer, /* o : buffer to allocate */
const uint32_t mem_size /* i : size of buffer */
);
-void ivas_HRTF_CRend_binary_close_fx(
- HRTFS_CREND_DATA **hHrtfCrend /* i/o: Crend HRTF handle */
+ivas_error ivas_HRTF_binary_open_buffers_int16(
+ int16_t **buffer, /* o : buffer to allocate */
+ const uint32_t mem_size /* i : size of buffer */
);
-ivas_error ivas_HRTF_statistics_init_fx(
- HRTFS_STATISTICS_HANDLE *hHrtfStatistics, /* i/o: HRTF statistics structure */
- const Word32 sampleRate /* i : Sample rate */
+ivas_error ivas_HRTF_binary_open_buffers_int32(
+ int32_t **buffer, /* o : buffer to allocate */
+ const uint32_t mem_size /* i : size of buffer */
);
-void ivas_HRTF_statistics_close_fx(
- HRTFS_STATISTICS **hHrtfStatistics /* i/o: HRTF statistics structure */
+ivas_error ivas_HRTF_binary_open_buffers_int32_ptr(
+ int32_t ***buffer, /* o : buffer to allocate */
+ const uint32_t mem_size /* i : size of buffer */
+);
+
+ivas_error ivas_HRTF_binary_open_buffers_int32_ptr_const(
+ const int32_t ***buffer, /* o : buffer to allocate */
+ const uint32_t mem_size /* i : size of buffer */
+);
+
+void ivas_HRTF_CRend_binary_close_fx(
+ HRTFS_CREND_DATA **hHrtfCrend /* i/o: Crend HRTF handle */
);
+void ivas_HRTF_statistics_binary_close_fx(
+ HRTFS_STATISTICS **hHrtfStatistics ); /* i/o: HRTF statistics structure */
+
ivas_error ivas_HRTF_statistics_binary_open_fx(
HRTFS_STATISTICS **hHrtfStatistics /* i/o: HRTF statistics structure */
);
@@ -914,7 +927,7 @@ ivas_error ivas_rend_crendProcessSubframe_fx(
const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */
const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */
const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */
- DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */
+ DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: TC handle */
Word32 *input_f[], /* i : transport channels */
Word32 *output[], /* i/o: input/output audio channels */
const Word16 n_samples_to_render, /* i : output frame length per channel */
@@ -953,6 +966,11 @@ void ivas_binaural_reverb_processSubframe_fx(
Word32 outImag[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /* o : output CLDFB data imag */
);
+ivas_error ivas_reverb_HRTF_statistics_open_fx(
+ HRTFS_STATISTICS_HANDLE *hHrtfStatistics, /* o : HRTF statistics handle */
+ const Word32 output_Fs /* i : output sampling rate */
+);
+
ivas_error ivas_reverb_open_fx(
REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */
const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */
@@ -1555,12 +1573,12 @@ ivas_error ivas_rend_crendProcessSubframesSplitBin(
const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */
const AUDIO_CONFIG inConfig, /* i : input audio configuration */
const AUDIO_CONFIG outConfig, /* i : output audio configuration */
- const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData,
+ const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */
const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */
const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */
const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */
const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */
- DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */
+ DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: TC handle */
Word32 *input_f[], /* i : transport channels */
Word32 *output[], /* i/o: input/output audio channels */
const Word16 n_samples_to_render, /* i : output frame length per channel */
diff --git a/lib_rend/ivas_reflections_fx.c b/lib_rend/ivas_reflections_fx.c
index c342d5ca29660dc52269aa7b2ca6034ef4ca8b7f..22a332ab1f5a91e4ccf2eff5695a9755726cf04a 100644
--- a/lib_rend/ivas_reflections_fx.c
+++ b/lib_rend/ivas_reflections_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_render_config_fx.c b/lib_rend/ivas_render_config_fx.c
index 9a6f79fea2823261123f4e7e1beaa45f995f516b..81f66bf60af8e61e1eac8098d2204cde18c0265f 100644
--- a/lib_rend/ivas_render_config_fx.c
+++ b/lib_rend/ivas_render_config_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_reverb_delay_line_fx.c b/lib_rend/ivas_reverb_delay_line_fx.c
index 5e7b206c8d8cb22a0f8cd6bf367393e26065c634..d3a0f5bb257ba069ab317abfd3a7841b330e1bbf 100644
--- a/lib_rend/ivas_reverb_delay_line_fx.c
+++ b/lib_rend/ivas_reverb_delay_line_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_reverb_fft_filter_fx.c b/lib_rend/ivas_reverb_fft_filter_fx.c
index 6453b32d7a4ab42d0714d8cf433f9b313643934f..dcf13c15345f125a0ee3f2fba9f8ca7f4c187e80 100644
--- a/lib_rend/ivas_reverb_fft_filter_fx.c
+++ b/lib_rend/ivas_reverb_fft_filter_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_reverb_filter_design_fx.c b/lib_rend/ivas_reverb_filter_design_fx.c
index 3b896a137de40fce2f883d5d070cacc59cbb1250..6d23b0053af7223a7c745b64214f868deb3164b5 100644
--- a/lib_rend/ivas_reverb_filter_design_fx.c
+++ b/lib_rend/ivas_reverb_filter_design_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c
index ba4159ba8271d76af1f572c15086821321fdf3c3..9ffd743227f9e0621bf4b8692f93b95634fa0e66 100644
--- a/lib_rend/ivas_reverb_fx.c
+++ b/lib_rend/ivas_reverb_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -34,6 +34,7 @@
#include "options.h"
#include "prot_fx.h"
#include "ivas_prot_rend_fx.h"
+#include "ivas_rom_binaural_crend_head.h"
#include "ivas_cnst.h"
#include "ivas_rom_rend.h"
#include
@@ -131,6 +132,117 @@ typedef struct ivas_reverb_params_t
static ivas_error calc_jot_t60_coeffs_fx( Word16 *pH_dB_fx, Word16 pH_dB_exp, const UWord16 nrFrequencies, Word16 *pFrequencies_fx, Word16 *pCoeffA_fx, Word16 *pCoeffB_fx, const Word16 fNyquist_fx );
+/*-------------------------------------------------------------------------
+ * ivas_reverb_HRTF_statistics_open()
+ *
+ * Open and initialize HRTF statistics handle from ROM tables
+ *------------------------------------------------------------------------*/
+
+ivas_error ivas_reverb_HRTF_statistics_open_fx(
+ HRTFS_STATISTICS_HANDLE *hHrtfStatistics, /* o : HRTF statistics handle */
+ const Word32 output_Fs /* i : output sampling rate */
+)
+{
+ if ( *hHrtfStatistics != NULL )
+ {
+ if ( ( *hHrtfStatistics )->fromROM == TRUE )
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL, "HRTF statistics allocated but not initialized from binary file!\n" );
+ }
+
+ /* HRTF statistics loaded from binary file */
+ return IVAS_ERR_OK;
+ }
+
+ if ( ( *hHrtfStatistics = (HRTFS_STATISTICS *) malloc( sizeof( HRTFS_STATISTICS ) ) ) == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for statistics HRTF tables!" );
+ }
+
+ SWITCH( output_Fs )
+ {
+ case 48000:
+ ( *hHrtfStatistics )->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) );
+ IF( ( *hHrtfStatistics )->average_energy_l_dyn == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
+ }
+ ( *hHrtfStatistics )->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) );
+ IF( ( *hHrtfStatistics )->average_energy_r_dyn == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
+ }
+ ( *hHrtfStatistics )->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) );
+ IF( ( *hHrtfStatistics )->inter_aural_coherence_dyn == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
+ }
+ Copy_Scale_sig_16_32_r( defaultHRIR_left_avg_power_48kHz_fx, ( *hHrtfStatistics )->average_energy_l_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_48kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
+ Copy_Scale_sig_16_32_r( defaultHRIR_right_avg_power_48kHz_fx, ( *hHrtfStatistics )->average_energy_r_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_48kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
+ Copy_Scale_sig_16_32_r( defaultHRIR_coherence_48kHz_fx, ( *hHrtfStatistics )->inter_aural_coherence_dyn, LR_IAC_LENGTH_NR_FC, Q26 - defaultHRIR_Q_48kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
+ ( *hHrtfStatistics )->average_energy_l = (const Word32 *) ( *hHrtfStatistics )->average_energy_l_dyn;
+ ( *hHrtfStatistics )->average_energy_r = (const Word32 *) ( *hHrtfStatistics )->average_energy_r_dyn;
+ ( *hHrtfStatistics )->inter_aural_coherence = (const Word32 *) ( *hHrtfStatistics )->inter_aural_coherence_dyn;
+ BREAK;
+ case 32000:
+ ( *hHrtfStatistics )->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) );
+ IF( ( *hHrtfStatistics )->average_energy_l_dyn == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
+ }
+ ( *hHrtfStatistics )->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) );
+ IF( ( *hHrtfStatistics )->average_energy_r_dyn == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
+ }
+ ( *hHrtfStatistics )->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) );
+ IF( ( *hHrtfStatistics )->inter_aural_coherence_dyn == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
+ }
+ Copy_Scale_sig_16_32_r( defaultHRIR_left_avg_power_32kHz_fx, ( *hHrtfStatistics )->average_energy_l_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_32kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
+ Copy_Scale_sig_16_32_r( defaultHRIR_right_avg_power_32kHz_fx, ( *hHrtfStatistics )->average_energy_r_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_32kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
+ Copy_Scale_sig_16_32_r( defaultHRIR_coherence_32kHz_fx, ( *hHrtfStatistics )->inter_aural_coherence_dyn, LR_IAC_LENGTH_NR_FC, Q26 - defaultHRIR_Q_32kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
+ ( *hHrtfStatistics )->average_energy_l = (const Word32 *) ( *hHrtfStatistics )->average_energy_l_dyn;
+ ( *hHrtfStatistics )->average_energy_r = (const Word32 *) ( *hHrtfStatistics )->average_energy_r_dyn;
+ ( *hHrtfStatistics )->inter_aural_coherence = (const Word32 *) ( *hHrtfStatistics )->inter_aural_coherence_dyn;
+ BREAK;
+ case 16000:
+ ( *hHrtfStatistics )->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) );
+ IF( ( *hHrtfStatistics )->average_energy_l_dyn == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
+ }
+ ( *hHrtfStatistics )->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) );
+ IF( ( *hHrtfStatistics )->average_energy_r_dyn == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
+ }
+ ( *hHrtfStatistics )->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) );
+ IF( ( *hHrtfStatistics )->inter_aural_coherence_dyn == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
+ }
+ Copy_Scale_sig_16_32_r( defaultHRIR_left_avg_power_16kHz_fx, ( *hHrtfStatistics )->average_energy_l_dyn, LR_IAC_LENGTH_NR_FC_16KHZ, Q28 - defaultHRIR_Q_16kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
+ Copy_Scale_sig_16_32_r( defaultHRIR_right_avg_power_16kHz_fx, ( *hHrtfStatistics )->average_energy_r_dyn, LR_IAC_LENGTH_NR_FC_16KHZ, Q28 - defaultHRIR_Q_16kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
+ Copy_Scale_sig_16_32_r( defaultHRIR_coherence_16kHz_fx, ( *hHrtfStatistics )->inter_aural_coherence_dyn, LR_IAC_LENGTH_NR_FC_16KHZ, Q26 - defaultHRIR_Q_16kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */
+ ( *hHrtfStatistics )->average_energy_l = (const Word32 *) ( *hHrtfStatistics )->average_energy_l_dyn;
+ ( *hHrtfStatistics )->average_energy_r = (const Word32 *) ( *hHrtfStatistics )->average_energy_r_dyn;
+ ( *hHrtfStatistics )->inter_aural_coherence = (const Word32 *) ( *hHrtfStatistics )->inter_aural_coherence_dyn;
+ BREAK;
+ default:
+ ( *hHrtfStatistics )->average_energy_l = NULL;
+ ( *hHrtfStatistics )->average_energy_r = NULL;
+ ( *hHrtfStatistics )->inter_aural_coherence = NULL;
+ BREAK;
+ }
+ ( *hHrtfStatistics )->fromROM = TRUE;
+#ifdef FIX_1990_SANITIZER_IN_REVERB_LOAD
+ ( *hHrtfStatistics )->fromROM = FALSE; // TODO: temporary hack until HRTF statistics ROM tables are converted from Word16 to Word32
+#endif
+ return IVAS_ERR_OK;
+}
+
/*-------------------------------------------------------------------------
* wrap_rad_fx()
*
diff --git a/lib_rend/ivas_reverb_iir_filter_fx.c b/lib_rend/ivas_reverb_iir_filter_fx.c
index f4f0cf51629086fb0e98f3194be49a07502caf5c..e4ce77b6583d25d6c49e000dcb134ed2a4536e5e 100644
--- a/lib_rend/ivas_reverb_iir_filter_fx.c
+++ b/lib_rend/ivas_reverb_iir_filter_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c
index 52cb0f1306b0060bf96c5a022aef3417a7832edc..05b3f8af64bb6b5f0d96c1925dfb071c53f7b971 100644
--- a/lib_rend/ivas_reverb_utils_fx.c
+++ b/lib_rend/ivas_reverb_utils_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_rom_TdBinauralRenderer.h b/lib_rend/ivas_rom_TdBinauralRenderer.h
index f3d675a99248ccb534ab3349ee01b6061eb0e5d7..176dc1f3eb8864f7c1664fa9e4eb3fba54e83645 100644
--- a/lib_rend/ivas_rom_TdBinauralRenderer.h
+++ b/lib_rend/ivas_rom_TdBinauralRenderer.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_rom_TdBinauralRenderer_fx.c b/lib_rend/ivas_rom_TdBinauralRenderer_fx.c
index 954ae2759f6dd71316afa07963dc5fb8d85bced0..980b692420e95b8086049bf8b8ec8da55087e323 100644
--- a/lib_rend/ivas_rom_TdBinauralRenderer_fx.c
+++ b/lib_rend/ivas_rom_TdBinauralRenderer_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_rom_binauralRenderer.h b/lib_rend/ivas_rom_binauralRenderer.h
index 30746b3d87b02a9c1f54d5a2e4466e29afd7b04d..178a50b7ce0457a425a09a16061da83652569e3a 100644
--- a/lib_rend/ivas_rom_binauralRenderer.h
+++ b/lib_rend/ivas_rom_binauralRenderer.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_rom_binauralRenderer_fx.c b/lib_rend/ivas_rom_binauralRenderer_fx.c
index 3c090f204bc6164868918aa7dbb2f1b79a53b5bb..37b472fc976803e9070de012b6ed6bfbc3acd798 100644
--- a/lib_rend/ivas_rom_binauralRenderer_fx.c
+++ b/lib_rend/ivas_rom_binauralRenderer_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_rom_binaural_crend_head.h b/lib_rend/ivas_rom_binaural_crend_head.h
index ae97fc0feddcb92e1aca13577804a22338f56bea..a0f13e471db22bf61998bf0f477181ba79a7e228 100644
--- a/lib_rend/ivas_rom_binaural_crend_head.h
+++ b/lib_rend/ivas_rom_binaural_crend_head.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_rom_binaural_crend_head_fx.c b/lib_rend/ivas_rom_binaural_crend_head_fx.c
index 9be532b7961d4f3976de3633f36a96c16c48af75..28ebb28e09f481b09e20f0387583144a751eefaf 100644
--- a/lib_rend/ivas_rom_binaural_crend_head_fx.c
+++ b/lib_rend/ivas_rom_binaural_crend_head_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h
index d52ade0dbc47dfa5e220319520e4e75035ce65a7..7a1cf897135fe1f2082df259e3369c33ddc2180d 100644
--- a/lib_rend/ivas_rom_rend.h
+++ b/lib_rend/ivas_rom_rend.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_rom_rend_fx.c b/lib_rend/ivas_rom_rend_fx.c
index c8114e0be9ee3aa072c4274302da99623ea8adba..18c018f293a94db497482b3a2b3ad83502f1de83 100644
--- a/lib_rend/ivas_rom_rend_fx.c
+++ b/lib_rend/ivas_rom_rend_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c
index 5e82d304efa8bc125766249f10f63b131d71963b..50b0b0f84eb630ddcbf210679455ddda3b1a3eb3 100644
--- a/lib_rend/ivas_rotation_fx.c
+++ b/lib_rend/ivas_rotation_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_sba_rendering_fx.c b/lib_rend/ivas_sba_rendering_fx.c
index c60e68090ed680ab388028c91352c585b1d59760..f4fab9d6e8d82702d65e64d9db2e97f475816cc1 100644
--- a/lib_rend/ivas_sba_rendering_fx.c
+++ b/lib_rend/ivas_sba_rendering_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_shoebox_fx.c b/lib_rend/ivas_shoebox_fx.c
index 631e5351e2cd01a72e3463b7893ad0e6e3df0b81..e6def409e649a8272bf31a719eaa4e159dbed0a3 100644
--- a/lib_rend/ivas_shoebox_fx.c
+++ b/lib_rend/ivas_shoebox_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h
index a113298e809dc345fb96ae24e6ce8f6e3ad6e9f8..1a6e33e728359c5acd5aa526c8bf20e07e22f034 100644
--- a/lib_rend/ivas_stat_rend.h
+++ b/lib_rend/ivas_stat_rend.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -1163,16 +1163,7 @@ typedef struct
typedef struct ivas_hrtf_TDREND_HRFILT_FiltSet_struct
{
Word32 SampleRate; /* Sample rate of the HR filter */
- Word16 NumPos;
- Word16 NumElev;
- Word32 Dist_fx;
- Word32 *ItdSet_p_fx;
Word16 FiltLength;
- Word16 *Azim_p_fx;
- Word16 *Elev_p_fx;
- Word16 *ItdSetNominal_p_fx;
- Word16 *LeftFiltSet_p_fx;
- Word16 *RightFiltSet_p_fx;
ModelParams_t ModelParams;
ModelEval_t ModelEval;
ModelParamsITD_t ModelParamsITD;
diff --git a/lib_rend/ivas_td_decorr_fx.c b/lib_rend/ivas_td_decorr_fx.c
index 4f51a8b5f9dce089de95ace0a0de5eb72db1f5f1..d2ebd34d8086ef1b8d4c8f726115341f04d4a0f5 100644
--- a/lib_rend/ivas_td_decorr_fx.c
+++ b/lib_rend/ivas_td_decorr_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_td_ring_buffer_fx.c b/lib_rend/ivas_td_ring_buffer_fx.c
index 78fde65d8e18a4dc4bd87f38bb1cd586236b7046..98905d25e328f543dd958fd8ac51e98db3645df1 100644
--- a/lib_rend/ivas_td_ring_buffer_fx.c
+++ b/lib_rend/ivas_td_ring_buffer_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/ivas_vbap_fx.c b/lib_rend/ivas_vbap_fx.c
index fdbd4f530274a9f4e83feb05b871101bead1ba76..19b4b1f5631cdcfc39da35f29233850d9d695c67 100644
--- a/lib_rend/ivas_vbap_fx.c
+++ b/lib_rend/ivas_vbap_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h
index 5e202001aad1ab4fcbbfc244c05d4afc98fe725a..1cb3077905f4367f6f36a5846511371779615585 100644
--- a/lib_rend/lib_rend.h
+++ b/lib_rend/lib_rend.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -344,9 +344,6 @@ ivas_error IVAS_REND_SetReferenceVector(
const IVAS_VECTOR3 refPos /* i : Reference position */
);
-ivas_error IVAS_REND_SetSplitRendBFI(
- IVAS_REND_HANDLE hIvasRend,
- const Word16 bfi);
ivas_error IVAS_REND_SetExternalOrientation(
IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */
diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c
index a7bd4a9265d6406892c49e8f030163b16e367e69..4dcad96324eb41efd8cfc43d65dab9ce1aaf84c0 100644
--- a/lib_rend/lib_rend_fx.c
+++ b/lib_rend/lib_rend_fx.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -94,7 +94,6 @@ typedef struct
const EFAP_WRAPPER *pEfapOutWrapper;
IVAS_REND_HeadRotData *pHeadRotData; // for now removing the const qualifier TODO: will modify later
const RENDER_CONFIG_HANDLE *hhRendererConfig;
- const Word16 *pSplitRendBFI;
const SPLIT_REND_WRAPPER *pSplitRendWrapper;
const COMBINED_ORIENTATION_HANDLE *pCombinedOrientationData;
const IVAS_DefaultReverbSize *pSelectedRoomReverbSize;
@@ -216,7 +215,6 @@ struct IVAS_REND
EFAP_WRAPPER efapOutWrapper;
IVAS_LSSETUP_CUSTOM_STRUCT customLsOut;
- Word16 splitRendBFI;
SPLIT_REND_WRAPPER *splitRendWrapper;
IVAS_REND_AudioBuffer splitRendEncBuffer;
IVAS_REND_HeadRotData headRotData;
@@ -1365,7 +1363,6 @@ static rendering_context getRendCtx(
ctx.pEfapOutWrapper = &hIvasRend->efapOutWrapper;
ctx.pHeadRotData = &hIvasRend->headRotData;
ctx.hhRendererConfig = &hIvasRend->hRendererConfig;
- ctx.pSplitRendBFI = &hIvasRend->splitRendBFI;
ctx.pSplitRendWrapper = hIvasRend->splitRendWrapper;
ctx.pCombinedOrientationData = &hIvasRend->hCombinedOrientationData;
ctx.pSelectedRoomReverbSize = &hIvasRend->selectedRoomReverbSize;
@@ -1392,10 +1389,17 @@ static bool isIoConfigPairSupported(
const AUDIO_CONFIG inConfig,
const AUDIO_CONFIG outConfig )
{
- /* Rendering mono or stereo to binaural is not supported */
+ /* input config cannot be binaural */
test();
test();
- IF( ( EQ_32( inConfig, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( inConfig, IVAS_AUDIO_CONFIG_STEREO ) ) && EQ_32( getAudioConfigType( outConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) )
+ IF( EQ_32( getAudioConfigType( inConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) &&
+ NE_32( inConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( inConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
+ {
+ return false;
+ }
+
+ /* output config cannot be object based */
+ IF( EQ_32( getAudioConfigType( outConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED ) )
{
return false;
}
@@ -2568,15 +2572,45 @@ static ivas_error updateMcPanGainsForAmbiOut(
{
Word16 ch_in, ch_out, lfeIdx, i;
Word16 numNonLfeInChannels, outAmbiOrder;
+ AUDIO_CONFIG inConfig;
const Word32 *spkAzi_fx, *spkEle_fx; /* Q22 */
ivas_error error;
+ inConfig = inputMc->base.inConfig;
+ move32();
+
IF( NE_32( ( error = getAmbisonicsOrder_fx( outConfig, &outAmbiOrder ) ), IVAS_ERR_OK ) )
{
return error;
}
- IF( NE_32( inputMc->base.inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
+ test();
+ IF( EQ_32( inConfig, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( inConfig, IVAS_AUDIO_CONFIG_STEREO ) )
+ {
+ setZeroPanMatrix_fx( inputMc->panGains_fx );
+ IF( EQ_32( inConfig, IVAS_AUDIO_CONFIG_MONO ) )
+ {
+ /* W = Mono */
+ inputMc->panGains_fx[0][0] = ONE_IN_Q31;
+ move32();
+ }
+ ELSE
+ {
+ /* W = 0.5 * ( L + R ) */
+ inputMc->panGains_fx[0][0] = ONE_IN_Q30 /* 0.5f in Q31 */;
+ inputMc->panGains_fx[0][1] = ONE_IN_Q30 /* 0.5f in Q31 */;
+ move32();
+ move32();
+ /* Y = 0.5 * ( L - R ) */
+ inputMc->panGains_fx[1][0] = ONE_IN_Q30 /* 0.5f in Q31 */;
+ inputMc->panGains_fx[1][1] = -ONE_IN_Q30 /* -0.5f in Q31 */;
+ move32();
+ move32();
+ }
+
+ return IVAS_ERR_OK;
+ }
+ ELSE IF( NE_32( inputMc->base.inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
{
IF( NE_32( ( error = getNumNonLfeChannelsInSpeakerLayout( inputMc->base.inConfig, &numNonLfeInChannels ) ), IVAS_ERR_OK ) )
{
@@ -2687,6 +2721,37 @@ static ivas_error updateMcPanGainsForAmbiOut(
return IVAS_ERR_OK;
}
+
+static ivas_error updateMcPanGainsForBinauralOut(
+ input_mc *inputMc )
+{
+ setZeroPanMatrix_fx( inputMc->panGains_fx );
+ IF( inputMc->base.inConfig == IVAS_AUDIO_CONFIG_MONO )
+ {
+ IF( EQ_32( inputMc->nonDiegeticPanGain_fx, ONE_IN_Q31 ) )
+ {
+ inputMc->panGains_fx[0][0] = ONE_IN_Q31;
+ }
+ ELSE
+ {
+ inputMc->panGains_fx[0][0] = L_add( L_shr( inputMc->nonDiegeticPanGain_fx, 1 ), ONE_IN_Q30 /* 0.5f in Q31 */ ); /* Q31 */
+ }
+ move32();
+ inputMc->panGains_fx[0][1] = L_sub( ONE_IN_Q31, inputMc->panGains_fx[0][0] );
+ move32();
+ }
+ ELSE
+ {
+ /* stereo passthrough */
+ inputMc->panGains_fx[0][0] = ONE_IN_Q31;
+ inputMc->panGains_fx[1][1] = ONE_IN_Q31;
+ move32();
+ move32();
+ }
+
+ return IVAS_ERR_OK;
+}
+
static ivas_error updateMcPanGains(
input_mc *inputMc,
const AUDIO_CONFIG outConfig )
@@ -2708,6 +2773,14 @@ static ivas_error updateMcPanGains(
error = updateMcPanGainsForAmbiOut( inputMc, outConfig );
BREAK;
case IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL:
+ test();
+ IF( EQ_32( inputMc->base.inConfig, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( inputMc->base.inConfig, IVAS_AUDIO_CONFIG_STEREO ) )
+ {
+ error = updateMcPanGainsForBinauralOut( inputMc );
+ BREAK;
+ }
+
+ /* not mono or stereo */
SWITCH( outConfig )
{
case IVAS_AUDIO_CONFIG_BINAURAL:
@@ -2766,6 +2839,12 @@ static ivas_error initMcBinauralRendering(
Word8 useTDRend;
Word16 i;
+ test();
+ IF( EQ_32( inputMc->base.inConfig, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( inputMc->base.inConfig, IVAS_AUDIO_CONFIG_STEREO ) )
+ {
+ return IVAS_ERR_OK;
+ }
+
/* Allocate TD binaural renderer for custom loudspeaker layouts (regardless of headrotation)
or planar MC layouts with headrotation, CREND for the rest */
useTDRend = FALSE;
@@ -3791,7 +3870,7 @@ ivas_error IVAS_REND_Open(
IF( asHrtfBinary )
{
- IF( NE_32( ( error = ivas_HRTF_binary_open_fx( &( hIvasRend->hHrtfs.hHrtfTD ) ) ), IVAS_ERR_OK ) )
+ IF( NE_32( ( error = ivas_HRTF_td_binary_open_fx( &( hIvasRend->hHrtfs.hHrtfTD ) ) ), IVAS_ERR_OK ) )
{
return error;
}
@@ -3815,7 +3894,14 @@ ivas_error IVAS_REND_Open(
IF( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
{
- IF( NE_32( ( error = ivas_HRTF_statistics_init_fx( &( hIvasRend->hHrtfs.hHrtfStatistics ), hIvasRend->sampleRateOut ) ), IVAS_ERR_OK ) )
+ if ( hIvasRend->hHrtfs.hHrtfStatistics == NULL )
+ {
+ /* Allocate and init HRTF statistics */
+ IF( NE_32( ( error = ivas_reverb_HRTF_statistics_open_fx( &( hIvasRend->hHrtfs.hHrtfStatistics ), hIvasRend->sampleRateOut ) ), IVAS_ERR_OK ) )
+ {
+ return error;
+ }
+ }
{
return error;
}
@@ -5640,23 +5726,6 @@ ivas_error IVAS_REND_DisableHeadRotation(
}
-/*-------------------------------------------------------------------*
- * IVAS_REND_SetSplitRendBFI()
- *
- *
- *-------------------------------------------------------------------*/
-
-ivas_error IVAS_REND_SetSplitRendBFI(
- IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */
- const Word16 bfi /* i : Bad Frame Indicator */
-)
-{
- hIvasRend->splitRendBFI = bfi;
-
- return IVAS_ERR_OK;
-}
-
-
/*-------------------------------------------------------------------*
* IVAS_REND_SetOrientationTrackingMode()
*
@@ -6266,7 +6335,7 @@ static ivas_error rotateFrameMc_fx(
/* move gains to gains_prev */
FOR( i = 0; i < nchan; i++ )
{
- MVR2R_WORD32( gains[i], gains_prev[i], nchan );
+ Copy32( gains[i], gains_prev[i], nchan );
}
}
@@ -6423,9 +6492,9 @@ static ivas_error renderIsmToBinaural(
ism_md_subframe_update_ext = extract_l( Mpy_32_32( ismInput->ism_metadata_delay_ms_fx, ONE_BY_SUBFRAME_LEN_MS_Q31 ) );
copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpTDRendBuffer );
- FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i )
+ FOR( i = 0; i < ismInput->base.inputBuffer.config.numChannels; ++i )
{
- Scale_sig32( tmpTDRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */
+ Scale_sig32( tmpTDRendBuffer[i], ismInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */
}
IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, ism_md_subframe_update_ext,
@@ -6435,9 +6504,9 @@ static ivas_error renderIsmToBinaural(
return error;
}
- FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i )
+ FOR( i = 0; i < outAudio.config.numChannels; ++i )
{
- Scale_sig32( tmpTDRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */
+ Scale_sig32( tmpTDRendBuffer[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */
}
IF( ismInput->hReverb != NULL )
@@ -6700,9 +6769,9 @@ static ivas_error renderIsmToBinauralReverb(
ism_md_subframe_update_ext = extract_l( Mpy_32_32( ismInput->ism_metadata_delay_ms_fx, ONE_BY_SUBFRAME_LEN_MS_Q31 ) );
copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpRendBuffer_fx );
- FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i )
+ FOR( i = 0; i < ismInput->base.inputBuffer.config.numChannels; ++i )
{
- Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */
+ Scale_sig32( tmpRendBuffer_fx[i], ismInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */
}
IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, ism_md_subframe_update_ext, *ismInput->base.ctx.pOutSampleRate, outAudio.config.numSamplesPerChannel, tmpRendBuffer_fx, &exp ) ), IVAS_ERR_OK ) )
@@ -6710,9 +6779,9 @@ static ivas_error renderIsmToBinauralReverb(
return error;
}
- FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i )
+ FOR( i = 0; i < outAudio.config.numChannels; ++i )
{
- Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, negate( sub( 11, exp ) ) ); /* Q(exp) */
+ Scale_sig32( tmpRendBuffer_fx[i], outAudio.config.numSamplesPerChannel, negate( sub( 11, exp ) ) ); /* Q(exp) */
}
IF( ismInput->hReverb != NULL )
@@ -6864,6 +6933,8 @@ static ivas_error renderIsmToSba(
error = IVAS_ERR_OK;
move32();
+ set32_fx( currentPanGains_fx, 0, MAX_OUTPUT_CHANNELS );
+
ismInput->currentPos.azimuth_fx = L_shl( L_shr( L_add( ismInput->currentPos.azimuth_fx, ONE_IN_Q21 ), Q22 ), Q22 );
ismInput->currentPos.elevation_fx = L_shl( L_shr( L_add( ismInput->currentPos.elevation_fx, ONE_IN_Q21 ), Q22 ), Q22 );
ismInput->previousPos.azimuth_fx = L_shl( L_shr( L_add( ismInput->previousPos.azimuth_fx, ONE_IN_Q21 ), Q22 ), Q22 );
@@ -7011,9 +7082,9 @@ static ivas_error renderIsmToSplitBinaural(
}
- FOR( i = 0; i < MAX_NUM_OBJECTS; ++i )
+ FOR( i = 0; i < ismInput->base.inputBuffer.config.numChannels; ++i )
{
- Scale_sig32( tmpProcessing[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */
+ Scale_sig32( tmpProcessing[i], ismInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */
}
/* Render */
@@ -7025,7 +7096,7 @@ static ivas_error renderIsmToSplitBinaural(
FOR( i = 0; i < BINAURAL_CHANNELS; ++i )
{
- Scale_sig32( tmpProcessing[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */
+ Scale_sig32( tmpProcessing[i], output_frame, negate( sub( Q11, exp ) ) ); /* Q(exp) */
}
IF( ismInput->hReverb != NULL )
@@ -7263,6 +7334,27 @@ static ivas_error renderActiveInputsIsm(
return IVAS_ERR_OK;
}
+static void renderMonoStereoToBinaural(
+ const input_mc *mcInput,
+ IVAS_REND_AudioBuffer outAudio )
+{
+ Word16 i;
+ IVAS_REND_AudioBuffer inAudio;
+
+ push_wmops( "renderMonoStereoToBinaural" );
+ inAudio = mcInput->base.inputBuffer;
+
+ FOR( i = 0; i < inAudio.config.numChannels; ++i )
+ {
+ renderBufferChannel_fx( inAudio, i, mcInput->panGains_fx[i], outAudio );
+ }
+
+ pop_wmops();
+
+ return;
+}
+
+
static ivas_error renderLfeToBinaural_fx(
const input_mc *mcInput,
const AUDIO_CONFIG outConfig,
@@ -7320,7 +7412,7 @@ static ivas_error renderLfeToBinaural_fx(
v_multc_fx( lfeInput, gain_fx, tmpLfeBuffer + num_cpy_smpl_prev_frame, num_cpy_smpl_cur_frame ); /* Qx - 1 */
/* Save remaining LFE samples of current frame for next frame */
- MVR2R_WORD32( lfeInput + num_cpy_smpl_cur_frame, mcInput->lfeDelayBuffer_fx, num_cpy_smpl_prev_frame );
+ Copy32( lfeInput + num_cpy_smpl_cur_frame, mcInput->lfeDelayBuffer_fx, num_cpy_smpl_prev_frame );
r_shift = sub( sub( in_q, 1 ), out_q );
IF( r_shift != 0 )
@@ -7407,9 +7499,9 @@ static ivas_error renderMcToBinaural(
{
copyBufferTo2dArray_fx( mcInput->base.inputBuffer, tmpRendBuffer_fx );
- FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i )
+ FOR( i = 0; i < mcInput->base.inputBuffer.config.numChannels; ++i )
{
- Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */
+ Scale_sig32( tmpRendBuffer_fx[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */
}
IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pCombinedOrientationData, NULL, mcInput->hReverb,
0, *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer_fx, &exp ) ),
@@ -7418,9 +7510,9 @@ static ivas_error renderMcToBinaural(
return error;
}
- FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i )
+ FOR( i = 0; i < outAudio.config.numChannels; ++i )
{
- Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */
+ Scale_sig32( tmpRendBuffer_fx[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */
}
}
ELSE
@@ -7530,9 +7622,9 @@ static ivas_error renderMcToBinauralRoom(
{
copyBufferTo2dArray_fx( mcInput->base.inputBuffer, tmpRendBuffer );
- FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i )
+ FOR( i = 0; i < mcInput->base.inputBuffer.config.numChannels; ++i )
{
- Scale_sig32( tmpRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */
+ Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */
}
IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pCombinedOrientationData, NULL, mcInput->hReverb,
@@ -7542,9 +7634,9 @@ static ivas_error renderMcToBinauralRoom(
return error;
}
- FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i )
+ FOR( i = 0; i < outAudio.config.numChannels; ++i )
{
- Scale_sig32( tmpRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */
+ Scale_sig32( tmpRendBuffer[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */
}
}
ELSE
@@ -7887,9 +7979,9 @@ static ivas_error renderMcToSplitBinaural(
/* perform rotation in source format to tmpRotBuffer */
pCombinedOrientationDataLocal = &combinedOrientationDataLocal;
- FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i )
+ FOR( i = 0; i < mcInput->base.inputBuffer.config.numChannels; ++i )
{
- Scale_sig32( tmpRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */
+ Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */
}
/* Render */
IF( ( error = ivas_td_binaural_renderer_ext_fx( ( pos_idx == 0 ) ? &mcInput->tdRendWrapper : &mcInput->splitTdRendWrappers[pos_idx - 1], mcInput->base.inConfig, &mcInput->customLsInput, &pCombinedOrientationDataLocal, NULL, mcInput->hReverb, 0, /* Ism Audio Metadata Delay Sync in ms for External Renderer */ *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer, &exp ) ) != IVAS_ERR_OK )
@@ -7898,7 +7990,7 @@ static ivas_error renderMcToSplitBinaural(
}
FOR( i = 0; i < BINAURAL_CHANNELS; ++i )
{
- Scale_sig32( tmpRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */
+ Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */
}
/* Copy rendered audio to tmp storage buffer. Copying directly to output would
@@ -8016,6 +8108,14 @@ static ivas_error renderInputMc(
renderMcToSba( mcInput, outAudio );
BREAK;
case IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL:
+ test();
+ IF( EQ_32( mcInput->base.inConfig, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( mcInput->base.inConfig, IVAS_AUDIO_CONFIG_STEREO ) )
+ {
+ renderMonoStereoToBinaural( mcInput, outAudio );
+ BREAK;
+ }
+
+ /* not mono or stereo */
SWITCH( outConfig )
{
case IVAS_AUDIO_CONFIG_BINAURAL:
@@ -8990,8 +9090,10 @@ static ivas_error renderInputMasa(
}
copyMasaMetadataToDiracRenderer_fx( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin );
- Scale_sig32( tmpBuffer_buff_fx[0], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */
- Scale_sig32( tmpBuffer_buff_fx[1], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */
+ FOR( ch = 0; ch < inAudio.config.numChannels; ch++ )
+ {
+ Scale_sig32( tmpBuffer_buff_fx[ch], inAudio.config.numSamplesPerChannel, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */
+ }
// scale_sig32( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ), sub( Q11, *outAudio.pq_fact ) );
ivas_masa_ext_rend_parambin_render_fx( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer_fx, num_subframes, masaInput->base.ctx.pSplitRendWrapper, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural );
@@ -9015,9 +9117,9 @@ static ivas_error renderInputMasa(
masaInput->hMasaExtRend->cldfbAnaRend[0]->Q_cldfb_state = Q11;
move16();
}
- FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ )
+ FOR( ch = 0; ch < inAudio.config.numChannels; ch++ )
{
- Scale_sig32( tmpBuffer_buff_fx[ch], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */
+ Scale_sig32( tmpBuffer_buff_fx[ch], inAudio.config.numSamplesPerChannel, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */
}
scale_sig32( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ), sub( Q11, *outAudio.pq_fact ) ); /* Q11 */
@@ -9042,8 +9144,10 @@ static ivas_error renderInputMasa(
copyMasaMetadataToDiracRenderer_fx( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin );
- Scale_sig32( tmpBuffer_buff_fx[0], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */
- Scale_sig32( tmpBuffer_buff_fx[1], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */
+ FOR( ch = 0; ch < inAudio.config.numChannels; ch++ )
+ {
+ Scale_sig32( tmpBuffer_buff_fx[ch], inAudio.config.numSamplesPerChannel, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */
+ }
scale_sig32( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ), sub( Q11, *outAudio.pq_fact ) );
@@ -9811,15 +9915,13 @@ void IVAS_REND_Close(
ivas_external_orientation_close_fx( &hIvasRend->hExternalOrientationData );
ivas_combined_orientation_close_fx( &hIvasRend->hCombinedOrientationData );
- /* Fastconv HRTF memories */
- ivas_binaural_hrtf_close_fx( &hIvasRend->hHrtfs.hHrtfFastConv );
/* Parametric binauralizer HRTF filters */
- ivas_HRTF_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfTD ) );
+ ivas_HRTF_td_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfTD ) );
ivas_HRTF_CRend_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfCrend ) );
ivas_HRTF_fastconv_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfFastConv ) );
ivas_HRTF_parambin_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfParambin ) );
- ivas_HRTF_statistics_close_fx( &( hIvasRend->hHrtfs.hHrtfStatistics ) );
+ ivas_HRTF_statistics_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfStatistics ) );
free( hIvasRend );
*phIvasRend = NULL;
@@ -11012,24 +11114,15 @@ static void intermidiate_ext_dirac_render(
IF( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx )
{
- Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, imult1616( hDirACRend->num_outputs_dir, hSpatParamRendCom->num_freq_bands ) );
+ Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_len );
scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_len, shift ); /* Q(hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth + shift) */
hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth, shift );
move16();
}
- Word16 num_channels_dir = hDirACRend->num_outputs_dir;
- move16();
-
- IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ) )
- {
- num_channels_dir = hDirACRend->hOutSetup.nchan_out_woLFE;
- move16();
- }
-
IF( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx )
{
- tmp = L_norm_arr( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ) );
+ tmp = L_norm_arr( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len );
scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len, tmp ); /* Q(h_dirac_output_synthesis_state->q_cy_auto_diff_smooth + tmp) */
h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, tmp );
move16();
@@ -11051,7 +11144,7 @@ static void intermidiate_ext_dirac_render(
move16();
IF( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx )
{
- Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) );
+ Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_len );
scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_len, shift ); /* Q(hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev + shift) */
hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev, shift );
move16();
@@ -11065,7 +11158,7 @@ static void intermidiate_ext_dirac_render(
move16();
}
- IF( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len > 0 )
+ IF( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx )
{
Word16 shift, norm1, norm2;
Word32 tmp1, tmp2;
@@ -11110,8 +11203,6 @@ static void intermidiate_ext_dirac_render(
move16();
}
}
- hDirACRend->proto_frame_dec_f_q = sub( 31, hDirACRend->proto_frame_dec_f_q );
- move16();
IF( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx )
{
@@ -11208,7 +11299,7 @@ static ivas_error printConfigInfo_rend(
)
{
ivas_error error;
- Word8 config_str[50];
+ Word8 config_str[200];
/*-----------------------------------------------------------------*
* Print output audio configuration
@@ -11242,7 +11333,7 @@ static ivas_error printConfigInfo_rend(
EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ||
EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
{
- fprintf( stdout, "Render framesize: %dms\n", i_mult( hIvasRend->num_subframes, 5 ) );
+ fprintf( stdout, "Render framesize: %dms\n", i_mult( hIvasRend->num_subframes, BINAURAL_RENDERING_FRAME_SIZE_MS ) );
}
return IVAS_ERR_OK;
@@ -11259,7 +11350,7 @@ void IVAS_REND_PrintInputConfig(
const IVAS_AUDIO_CONFIG inputConfig /* i : input audio configuration */
)
{
- Word8 config_str[50];
+ Word8 config_str[200];
get_channel_config( inputConfig, &config_str[0] );
fprintf( stdout, "Input configuration: %s\n", config_str );
diff --git a/lib_util/aeid_file_reader.c b/lib_util/aeid_file_reader.c
index 6f877452e5c1021124bfeb16e88b1f91dc84d562..4433ced8de4b580336d1b76eaba2184f19935c0b 100644
--- a/lib_util/aeid_file_reader.c
+++ b/lib_util/aeid_file_reader.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/aeid_file_reader.h b/lib_util/aeid_file_reader.h
index 55a141284c4f202bc7c9426e9036f2b6475a7d83..789b166f49e6536800a69df9aee14b3321a3aa8a 100644
--- a/lib_util/aeid_file_reader.h
+++ b/lib_util/aeid_file_reader.h
@@ -1,7 +1,7 @@
#pragma once
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c
index 713e88f605dd45ed52b53bcdaa9c1ca6b8a5012f..08572b883c62d28098c28d13d54beff7006daab9 100644
--- a/lib_util/ambi_convert.c
+++ b/lib_util/ambi_convert.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h
index 95a447f151a6b54f8eff93424fa29548a77a050d..eb8d094f8416cca6893582c0a7d2e74c194ffb54 100644
--- a/lib_util/ambi_convert.h
+++ b/lib_util/ambi_convert.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/audio_file_reader.c b/lib_util/audio_file_reader.c
index 0b6e44660de1d29b008868b1d847522f052bc56a..f342c64c41474c94748e41fdf78dc7d8811d77cd 100644
--- a/lib_util/audio_file_reader.c
+++ b/lib_util/audio_file_reader.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/audio_file_reader.h b/lib_util/audio_file_reader.h
index 571c1e765637e1cb30ac9afa9cb49b45127886b7..376b649b8b6c36d47e0caa661cfe3e5496c69d1b 100644
--- a/lib_util/audio_file_reader.h
+++ b/lib_util/audio_file_reader.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/audio_file_writer.c b/lib_util/audio_file_writer.c
index eb93018341780d232df13483268f295577e21cae..e008aa88699f8a6910b64fabb899349505ce1a62 100644
--- a/lib_util/audio_file_writer.c
+++ b/lib_util/audio_file_writer.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/audio_file_writer.h b/lib_util/audio_file_writer.h
index 2622992cecbbb4875a6aa5d7440492bc0d9ccb86..62c74f1a883d2d6b20e9f197e7e80b8878570896 100644
--- a/lib_util/audio_file_writer.h
+++ b/lib_util/audio_file_writer.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/bitstream_reader.c b/lib_util/bitstream_reader.c
index 6d40260b56dc5b21d8834c16f6e988175d89892a..2a452abb6a70ec1b4d4c74b3a6308014ea8c51f5 100644
--- a/lib_util/bitstream_reader.c
+++ b/lib_util/bitstream_reader.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/bitstream_reader.h b/lib_util/bitstream_reader.h
index fb6f9f9b9dac7304cd1bf029cdf2c2822991f62c..51159dd5b870d24b95ebf359a0e73f50be50fb76 100644
--- a/lib_util/bitstream_reader.h
+++ b/lib_util/bitstream_reader.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/bitstream_writer.c b/lib_util/bitstream_writer.c
index bff9f461b15992ed3c953a83a19f2c22cc496ed6..13981bd0102637680a8ce589099000be602d309e 100644
--- a/lib_util/bitstream_writer.c
+++ b/lib_util/bitstream_writer.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/bitstream_writer.h b/lib_util/bitstream_writer.h
index f3efd4ddf2ec85beea05af186ffa68cbed225b2f..0d7d4747251067e35473effbc933327b632698bb 100644
--- a/lib_util/bitstream_writer.h
+++ b/lib_util/bitstream_writer.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/cmdl_tools.c b/lib_util/cmdl_tools.c
index 945bda07de0918d6784d1edfddfa415040029485..504228a7338761147bbba887c7c3b66e95f782b9 100644
--- a/lib_util/cmdl_tools.c
+++ b/lib_util/cmdl_tools.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -226,3 +226,28 @@ bool isEmptyString(
{
return str[0] == '\0';
}
+
+
+/*---------------------------------------------------------------------*
+ * strLength()
+ *
+ * Get the length of a string up to a maximum length.
+ *
+ * Equivalent to strnlen, which is not part of the C standard and only provided by POSIX.
+ *
+ *---------------------------------------------------------------------*/
+
+int32_t strLength(
+ const char *str,
+ int32_t maxlen )
+{
+ int32_t len;
+
+ len = 0;
+ while ( len < maxlen && str[len] != '\0' )
+ {
+ len++;
+ }
+
+ return len;
+}
diff --git a/lib_util/cmdl_tools.h b/lib_util/cmdl_tools.h
index 327acb93d0b1d528874de8ef018a36686379b778..605c06d07c937c85b94f755977fe325271c20107 100644
--- a/lib_util/cmdl_tools.h
+++ b/lib_util/cmdl_tools.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -50,4 +50,6 @@ void clearString( char *str );
bool isEmptyString( const char *str );
+int32_t strLength( const char *str, int32_t maxlen );
+
#endif /* CMDL_TOOLS_H */
diff --git a/lib_util/cmdln_parser.c b/lib_util/cmdln_parser.c
index 1b9eb7a92899f1b62df0e925fc7f3882c2512012..6df8cacde7c72bf8842d02bc39f45dbf18800237 100644
--- a/lib_util/cmdln_parser.c
+++ b/lib_util/cmdln_parser.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -36,19 +36,30 @@
#include
#include
#include
+#include
+#include
-#define MAX_SUPPORTED_OPTS ( 1024 )
-#define MAX_OPTION_LENGTH ( 1024 )
+#define MAX_SUPPORTED_OPTS ( 1024 )
+#define MAX_OPTION_MATCH_LENGTH ( 30 )
+#define MAX_OPTION_LENGTH ( MAX_OPTION_MATCH_LENGTH + 2 )
typedef CmdLnParser_Option OptionProps;
typedef struct
{
OptionProps props;
- int8_t hasBeenParsed;
+ bool hasBeenParsed;
} Option;
-static int16_t validateNoDuplicateIds(
+/* Error enum for internal use */
+typedef enum
+{
+ CMDLN_PARSER_ERR_OK = 0,
+ CMDLN_PARSER_ERR_FAILED_PARSING = -1,
+ CMDLN_PARSER_ERR_MISCONFIGURED = -2,
+} CmdLnParserError;
+
+static CmdLnParserError validateNoDuplicateIds(
const OptionProps *props,
int32_t numOpts )
{
@@ -59,121 +70,136 @@ static int16_t validateNoDuplicateIds(
if ( props[i].id == props[j].id )
{
fprintf( stderr, "[dev] Duplicate ID == %d between options %s and %s\n", props[i].id, props[i].match, props[j].match );
- return -1;
+ return CMDLN_PARSER_ERR_MISCONFIGURED;
}
}
}
- return 0;
+ return CMDLN_PARSER_ERR_OK;
}
-static int16_t validateOptionProps(
+static CmdLnParserError validateOptionProps(
OptionProps props )
{
/* Check required properties */
if ( props.match == NULL )
{
- /* TODO(sgi): Don't print out usage after this - props.match is used there */
- fprintf( stderr, "[dev] Option with ID == %d - missing required property \"match\"\n", props.id );
- return -1;
+ fprintf( stderr, "[dev] Option with ID %d - missing required property \"match\"\n", props.id );
+ return CMDLN_PARSER_ERR_MISCONFIGURED;
}
if ( props.id == 0 )
{
fprintf( stderr, "[dev] Invalid ID for option %s. ID == %d is reserved.\n", props.match, props.id );
- return -1;
+ return CMDLN_PARSER_ERR_MISCONFIGURED;
}
- return 0;
+ /* Check match string length */
+ if ( strLength( props.match, MAX_OPTION_MATCH_LENGTH + 1 ) > MAX_OPTION_MATCH_LENGTH )
+ {
+ fprintf( stderr, "[dev] Option with ID %d - match string exceeds limit of %d characters.\n", props.id, MAX_OPTION_MATCH_LENGTH );
+ return CMDLN_PARSER_ERR_MISCONFIGURED;
+ }
+ if ( props.matchShort != NULL && strLength( props.matchShort, MAX_OPTION_MATCH_LENGTH + 1 ) > MAX_OPTION_MATCH_LENGTH )
+ {
+ fprintf( stderr, "[dev] Option with ID %d - matchShort string exceeds limit of %d characters.\n", props.id, MAX_OPTION_MATCH_LENGTH );
+ return CMDLN_PARSER_ERR_MISCONFIGURED;
+ }
+
+ return CMDLN_PARSER_ERR_OK;
}
/* Validate given OptionProps and use them to initialize array of Options */
-static int16_t initOpts(
+static CmdLnParserError initOpts(
const OptionProps *options,
const int32_t numOpts,
Option *opts )
{
+ CmdLnParserError error;
+
+ if ( numOpts > MAX_SUPPORTED_OPTS )
+ {
+ fprintf( stderr, "[dev] Number of defined options (%d) exceeds limit (%d).\n", numOpts, MAX_SUPPORTED_OPTS );
+ return CMDLN_PARSER_ERR_MISCONFIGURED;
+ }
+
+ /* Check for duplicate IDs */
+ if ( ( error = validateNoDuplicateIds( options, numOpts ) ) != 0 )
+ {
+ return error;
+ }
+
for ( int32_t i = 0; i < numOpts; ++i )
{
- if ( validateOptionProps( options[i] ) != 0 )
+ if ( ( error = validateOptionProps( options[i] ) ) != CMDLN_PARSER_ERR_OK )
{
- return -1;
+ return error;
}
Option tmp = {
- .hasBeenParsed = 0
+ .hasBeenParsed = false
};
tmp.props = options[i]; /* Cannot assign in aggregate initializer above - causes Visual Studio warning */
opts[i] = tmp;
}
- /* Check for duplicate IDs */
- if ( validateNoDuplicateIds( options, numOpts ) != 0 )
- {
- return -1;
- }
-
- return 0;
-}
-
-static int8_t stringLooksLikeOption(
- const char *str )
-{
- if ( ( str[0] == '-' ) && is_number( str ) == false )
- {
- return 1;
- }
-
return 0;
}
-static const char *stringToOptionName(
+static bool stringLooksLikeOption(
const char *str )
{
- while ( ( *str == '-' ) && ( ( str[1] != '0' ) || ( str[1] != '1' ) ) )
+ if ( ( str[0] == '-' ) && !is_number( str ) )
{
- ++str;
+ return true;
}
- return str;
+ return false;
}
-static int8_t optionMatchesString(
+static bool optionMatchesString(
Option opt,
const char *str )
{
if ( !stringLooksLikeOption( str ) )
{
- return 0;
+ return false;
}
- const char *optionName = stringToOptionName( str );
+ if ( strLength( str, MAX_OPTION_LENGTH + 1 ) > MAX_OPTION_LENGTH )
+ {
+ /* String longer than longest possible option - not a match */
+ return false;
+ }
- char optionName_to_upper[FILENAME_MAX];
- strncpy( optionName_to_upper, optionName, sizeof( optionName_to_upper ) - 1 );
- optionName_to_upper[sizeof( optionName_to_upper ) - 1] = '\0';
- to_upper( optionName_to_upper );
+ char str_to_upper[MAX_OPTION_LENGTH + 1];
+ snprintf( str_to_upper, sizeof( str_to_upper ), "%s", str );
+ to_upper( str_to_upper );
- char match_to_upper[FILENAME_MAX];
- strncpy( match_to_upper, opt.props.match, sizeof( match_to_upper ) - 1 );
- optionName_to_upper[sizeof( match_to_upper ) - 1] = '\0';
+ char match_to_upper[MAX_OPTION_LENGTH + 1];
+ snprintf( match_to_upper, sizeof( match_to_upper ), "--%s", opt.props.match );
to_upper( match_to_upper );
+ if ( strcmp( str_to_upper, match_to_upper ) == 0 )
+ {
+ return true;
+ }
- char matchShort_to_upper[FILENAME_MAX];
- strncpy( matchShort_to_upper, opt.props.matchShort, sizeof( matchShort_to_upper ) - 1 );
- optionName_to_upper[sizeof( matchShort_to_upper ) - 1] = '\0';
- to_upper( matchShort_to_upper );
-
- if ( strncmp( optionName_to_upper, match_to_upper, MAX_OPTION_LENGTH ) == 0 || strncmp( optionName_to_upper, matchShort_to_upper, MAX_OPTION_LENGTH ) == 0 )
+ if ( opt.props.matchShort != NULL )
{
- return 1;
+ snprintf( match_to_upper, sizeof( match_to_upper ), "-%s", opt.props.matchShort );
+ to_upper( match_to_upper );
+
+ if ( strcmp( str_to_upper, match_to_upper ) == 0 )
+ {
+ return true;
+ }
}
- return 0;
+ return false;
}
-static int16_t parseOpts(
+static CmdLnParserError parseOpts(
int32_t argc,
char **argv,
Option *opts,
@@ -202,8 +228,14 @@ static int16_t parseOpts(
/* Check if already parsed */
if ( optToMatch->hasBeenParsed )
{
- fprintf( stderr, "Duplicate option: %s (%s)\n", optToMatch->props.match, optToMatch->props.matchShort );
- return -1;
+ fprintf( stderr, "Duplicate option provided: --%s", optToMatch->props.match );
+ if ( optToMatch->props.matchShort != NULL )
+ {
+ fprintf( stderr, "/-%s", optToMatch->props.matchShort );
+ }
+ fprintf( stderr, "\n" );
+
+ return CMDLN_PARSER_ERR_FAILED_PARSING;
}
break;
@@ -216,8 +248,8 @@ static int16_t parseOpts(
/* Invalid option */
if ( stringLooksLikeOption( argv[argIdx] ) )
{
- fprintf( stderr, "Unknown option `%s`\n", stringToOptionName( argv[argIdx] ) );
- return -1;
+ fprintf( stderr, "Unknown option `%s`\n", argv[argIdx] );
+ return CMDLN_PARSER_ERR_FAILED_PARSING;
}
/* Otherwise, value following current option.
@@ -229,7 +261,7 @@ static int16_t parseOpts(
else
{
fprintf( stderr, "Unexpected token `%s`\n", argv[argIdx] );
- return -1;
+ return CMDLN_PARSER_ERR_FAILED_PARSING;
}
}
@@ -238,8 +270,11 @@ static int16_t parseOpts(
{
if ( currOpt != NULL )
{
- parseOption( currOpt->props.id, &argv[currOptIdx + 1], numValues, pOutputStruct );
- currOpt->hasBeenParsed = 1;
+ if ( parseOption( currOpt->props.id, &argv[currOptIdx + 1], numValues, pOutputStruct ) != 0 )
+ {
+ return CMDLN_PARSER_ERR_FAILED_PARSING;
+ }
+ currOpt->hasBeenParsed = true;
}
currOpt = nextOpt;
@@ -253,11 +288,37 @@ static int16_t parseOpts(
/* Parse last option */
if ( currOpt != NULL )
{
- parseOption( currOpt->props.id, &argv[currOptIdx + 1], numValues, pOutputStruct );
- currOpt->hasBeenParsed = 1;
+ if ( parseOption( currOpt->props.id, &argv[currOptIdx + 1], numValues, pOutputStruct ) != 0 )
+ {
+ return CMDLN_PARSER_ERR_FAILED_PARSING;
+ }
+ currOpt->hasBeenParsed = true;
}
- return 0;
+ /* Check mandatory options */
+ bool missingMandatory = false;
+ for ( int32_t optIdx = 0; optIdx < numOpts; ++optIdx )
+ {
+ Option opt = opts[optIdx];
+
+ if ( opt.props.isMandatory && !opt.hasBeenParsed )
+ {
+ fprintf( stderr, "Missing mandatory parameter: --%s", opt.props.match );
+ if ( opt.props.matchShort != NULL )
+ {
+ fprintf( stderr, "/-%s", opt.props.matchShort );
+ }
+ fprintf( stderr, "\n" );
+
+ missingMandatory = true;
+ }
+ }
+ if ( missingMandatory )
+ {
+ return CMDLN_PARSER_ERR_FAILED_PARSING;
+ }
+
+ return CMDLN_PARSER_ERR_OK;
}
static const char *getBasename(
@@ -281,19 +342,22 @@ static const char *getBasename(
return path;
}
-static int32_t totalOptionNameLength(
+static int32_t totalNumOptChars(
const OptionProps opt )
{
- return (int32_t) ( strlen( opt.match ) + strlen( opt.matchShort ) );
-}
+ int32_t len = (int32_t) strlen( opt.match );
-static void printWhitespace(
- const int32_t n )
-{
- for ( int32_t i = 0; i < n; ++i )
+ if ( opt.matchShort != NULL )
+ {
+ len += (int32_t) strlen( opt.matchShort );
+ }
+
+ if ( opt.placeholder != NULL )
{
- fprintf( stderr, " " );
+ len += (int32_t) strlen( opt.placeholder );
}
+
+ return len;
}
static void printOptDescriptionAligned(
@@ -317,7 +381,7 @@ static void printOptDescriptionAligned(
fprintf( stderr, "%c", *descPtr );
if ( *descPtr == '\n' )
{
- printWhitespace( descriptionColumnIdx );
+ fprintf( stderr, "%*s", descriptionColumnIdx, "" );
}
++descPtr;
}
@@ -325,41 +389,114 @@ static void printOptDescriptionAligned(
return;
}
+static void printOptions(
+ const OptionProps *optionProps,
+ const int32_t numOptions,
+ const bool mandatory,
+ const int32_t maxNumOptChars )
+{
+ const int32_t descriptionColumnIdx = maxNumOptChars + 11 /* Additional chars we will print in the options column */;
+ int32_t numOptChars;
+
+ for ( int32_t i = 0; i < numOptions; ++i )
+ {
+ OptionProps opt = optionProps[i];
+
+ if ( opt.isMandatory != mandatory )
+ {
+ continue;
+ }
+
+ numOptChars = totalNumOptChars( optionProps[i] );
+
+ fprintf( stderr, " --%s", opt.match );
+ numOptChars += 4;
+
+ if ( opt.matchShort != NULL )
+ {
+ fprintf( stderr, ", -%s", opt.matchShort );
+ numOptChars += 3;
+ }
+
+ if ( opt.placeholder != NULL )
+ {
+ fprintf( stderr, " %s", opt.placeholder );
+ numOptChars += 1;
+ }
+
+ if ( opt.description != NULL )
+ {
+ /* Done printing options column, fill with whitespace until description column */
+ fprintf( stderr, "%*s", descriptionColumnIdx - numOptChars, ": " );
+ printOptDescriptionAligned( opt.description, descriptionColumnIdx );
+ }
+ else
+ {
+ fprintf( stderr, "\n" );
+ }
+ }
+}
+
static void printUsage(
const char *argv0,
const OptionProps *optionProps,
const int32_t numOptions )
{
- fprintf( stderr, "\n" );
- fprintf( stderr, "Usage: %s [options]\n", getBasename( argv0 ) );
- fprintf( stderr, "\n" );
- fprintf( stderr, "Valid options:\n" );
-
- /* Find option with longest name, used for pretty formatting */
- int32_t maxOptNameLength = 0;
+ int32_t numOptChars;
+ int32_t maxNumOptChars = 0;
+ bool hasMandatoryOptions = false;
for ( int32_t i = 0; i < numOptions; ++i )
{
- const int32_t optNameLength = totalOptionNameLength( optionProps[i] );
- if ( maxOptNameLength < optNameLength )
+ /* Find option with most characters when printed, used for pretty formatting */
+ numOptChars = totalNumOptChars( optionProps[i] );
+ if ( maxNumOptChars < numOptChars )
{
- maxOptNameLength = optNameLength;
+ maxNumOptChars = numOptChars;
+ }
+
+ /* Check if mandatory parameters should be printed separately */
+ if ( optionProps[i].isMandatory )
+ {
+ hasMandatoryOptions = true;
}
}
- const int32_t preDescriptionWhitespace = 8;
- const int32_t leftColumnAdditionalChars = 7;
+ fprintf( stderr, "\n" );
+ fprintf( stderr, "Usage: %s [options]", getBasename( argv0 ) );
for ( int32_t i = 0; i < numOptions; ++i )
{
OptionProps opt = optionProps[i];
- const int32_t optNameLength = totalOptionNameLength( optionProps[i] );
- /* TODO(sgi): make matchShort optional */
- fprintf( stderr, " --%s, -%s", opt.match, opt.matchShort );
+ if ( opt.isMandatory )
+ {
+ if ( opt.matchShort != NULL )
+ {
+ fprintf( stderr, " -%s", opt.matchShort );
+ }
+ else
+ {
+ fprintf( stderr, " --%s", opt.match );
+ }
+
+ if ( opt.placeholder != NULL )
+ {
+ fprintf( stderr, " %s", opt.placeholder );
+ }
+ }
+ }
- printWhitespace( maxOptNameLength - optNameLength + preDescriptionWhitespace );
- printOptDescriptionAligned( opt.description, maxOptNameLength + preDescriptionWhitespace + leftColumnAdditionalChars );
+ fprintf( stderr, "\n\n" );
+
+ if ( hasMandatoryOptions )
+ {
+ fprintf( stderr, "Mandatory parameters:\n---------------------\n" );
+ printOptions( optionProps, numOptions, true, maxNumOptChars );
+ fprintf( stderr, "\n" );
}
+ fprintf( stderr, "Options:\n--------\n" );
+ printOptions( optionProps, numOptions, false, maxNumOptChars );
+
return;
}
@@ -371,34 +508,64 @@ int16_t CmdLnParser_parseArgs(
void *pOutputStruct,
CmdLnParser_FnPtr_ParseOption parseOption )
{
- assert( numOptions <= MAX_SUPPORTED_OPTS );
+ CmdLnParserError error;
/* Prepare option array */
Option opts[MAX_SUPPORTED_OPTS];
- if ( initOpts( optionProps, numOptions, opts ) != 0 )
+ if ( ( error = initOpts( optionProps, numOptions, opts ) ) != CMDLN_PARSER_ERR_OK )
{
goto fail;
}
/* Iterate over argv and parse */
- if ( parseOpts( argc, argv, opts, numOptions, pOutputStruct, parseOption ) != 0 )
+ if ( ( error = parseOpts( argc, argv, opts, numOptions, pOutputStruct, parseOption ) ) != CMDLN_PARSER_ERR_OK )
{
goto fail;
}
- return 0;
-
fail:
- printUsage( argv[0], optionProps, numOptions );
- return -1;
+ switch ( error )
+ {
+ case CMDLN_PARSER_ERR_OK:
+ break;
+ case CMDLN_PARSER_ERR_MISCONFIGURED:
+ fprintf( stderr, "CmdLnParser is misconfigured.\n" );
+ break;
+ case CMDLN_PARSER_ERR_FAILED_PARSING:
+ printUsage( argv[0], optionProps, numOptions );
+ break;
+ }
+
+ return error;
}
-void CmdLnParser_printUsage(
+int16_t CmdLnParser_printUsage(
char *executableName,
const CmdLnParser_Option *options,
const int32_t numOptions )
{
+ CmdLnParserError error;
+
+ /* Re-use initOpts for validation only */
+ Option opts[MAX_SUPPORTED_OPTS];
+ if ( ( error = initOpts( options, numOptions, opts ) ) != CMDLN_PARSER_ERR_OK )
+ {
+ goto fail;
+ }
+
printUsage( executableName, options, numOptions );
- return;
+fail:
+ switch ( error )
+ {
+ case CMDLN_PARSER_ERR_OK:
+ break;
+ case CMDLN_PARSER_ERR_MISCONFIGURED:
+ fprintf( stderr, "CmdLnParser is misconfigured.\n" );
+ break;
+ case CMDLN_PARSER_ERR_FAILED_PARSING:
+ break;
+ }
+
+ return error;
}
diff --git a/lib_util/cmdln_parser.h b/lib_util/cmdln_parser.h
index 2627d556624dc0de59ca01a5f342d684d066d277..446831526a9e080a40ea864354b39523f98fd966 100644
--- a/lib_util/cmdln_parser.h
+++ b/lib_util/cmdln_parser.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -38,17 +38,21 @@
typedef struct
{
- int32_t id;
- const char *match;
- const char *matchShort;
- const char *description;
+ int32_t id; /* Unique ID for the option */
+ const char *match; /* String to match, e.g. "input" here will match "--input" on CLI */
+
+ /* Struct members below are optional and can be omitted in option definition. If omitted, C will implicitly set them to 0. */
+ const char *matchShort; /* Short version of the string to match, e.g. "i" here will match "-i" on CLI */
+ const char *placeholder; /* If not NULL, this will follow the match string in the usage printout, e.g. "" here will print "--input " on CLI */
+ const char *description; /* Description of the option for the usage printout. May contain '\n' for line breaks. */
+ bool isMandatory; /* Parsing will fail if an option with `isMandatory == true` is not given */
} CmdLnParser_Option;
/* Function for parsing option values into an output struct, to be implemented by the user */
-typedef void ( *CmdLnParser_FnPtr_ParseOption )( int32_t optionId, char **optionValues, int16_t numOptionValues, void *pOutputStruct );
+typedef int16_t ( *CmdLnParser_FnPtr_ParseOption )( int32_t optionId, char **optionValues, int16_t numOptionValues, void *pOutputStruct );
int16_t CmdLnParser_parseArgs( int32_t argc, char **argv, const CmdLnParser_Option *options, const int32_t numOptions, void *pOutputStruct, CmdLnParser_FnPtr_ParseOption parseOption );
-void CmdLnParser_printUsage( char *executableName, const CmdLnParser_Option *options, const int32_t numOptions );
+int16_t CmdLnParser_printUsage( char *executableName, const CmdLnParser_Option *options, const int32_t numOptions );
#endif /* CMDLN_PARSER_H */
diff --git a/lib_util/evs_rtp_payload.c b/lib_util/evs_rtp_payload.c
index 280ddb32391916df6d569af77ee059f8eb70516d..fef44d646afb8367e90ee5e6f5953fc9614bb26d 100644
--- a/lib_util/evs_rtp_payload.c
+++ b/lib_util/evs_rtp_payload.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/evs_rtp_payload.h b/lib_util/evs_rtp_payload.h
index f97d9b7a6f662d5aad6c45f96380316683837689..00f634574d49f84eff9428f7f88075512f2d9030 100644
--- a/lib_util/evs_rtp_payload.h
+++ b/lib_util/evs_rtp_payload.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/g192.c b/lib_util/g192.c
index 5a8ed10658bc67787e972b424c516d46214137b2..3779b417fa99f40a5cfb5a536aaf9574f82b91e1 100644
--- a/lib_util/g192.c
+++ b/lib_util/g192.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/g192.h b/lib_util/g192.h
index e6ad2b4ee9e6781c91e378df68bad36855e78374..93ba57c8e6cb478e468c7e3c9ad3b35373abc675 100644
--- a/lib_util/g192.h
+++ b/lib_util/g192.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c
index f1fe05c5fd8c65ed8ccc636cdfda7fdb34c2788c..3742459f87722595da30c69cf2e24a944169f8b4 100644
--- a/lib_util/hrtf_file_reader.c
+++ b/lib_util/hrtf_file_reader.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -51,9 +51,9 @@ struct hrtfFileReader
typedef struct ivas_hrtfs_file_header_t
{
char identifier[8];
- int32_t file_size;
- int16_t nb_hrtf;
- int32_t max_data_size;
+ Word32 file_size;
+ Word16 nb_hrtf;
+ Word32 max_data_size;
} ivas_hrtfs_file_header_t;
@@ -129,7 +129,7 @@ static ivas_error read_and_check_hrtf_binary_file_header(
ivas_hrtfs_file_header_t *hrtf_file_header,
FILE *f_hrtf )
{
- int32_t file_size;
+ Word32 file_size;
if ( hrtf_file_header == NULL || f_hrtf == NULL )
{
@@ -146,7 +146,7 @@ static ivas_error read_and_check_hrtf_binary_file_header(
file_size = ftell( f_hrtf );
fseek( f_hrtf, 0, SEEK_SET );
- if ( file_size < (int32_t) sizeof( ivas_hrtfs_file_header_t ) )
+ if ( file_size < (Word32) sizeof( ivas_hrtfs_file_header_t ) )
{
return IVAS_ERROR( IVAS_ERR_END_OF_FILE, "HRTF binary file not compliant (size of file header)" );
}
@@ -230,7 +230,7 @@ static ivas_error read_hrtf_binary_header(
/* Sampling Frequency (4 bytes) */
/* Raw data size (4 bytes) */
- if ( ( fread( &( hrtf_header->rend_type ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->input_cfg ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->frequency ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->data_size ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) )
+ if ( ( fread( &( hrtf_header->rend_type ), sizeof( Word32 ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->input_cfg ), sizeof( Word32 ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->frequency ), sizeof( Word32 ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->data_size ), sizeof( Word32 ), 1, f_hrtf ) == 1 ) )
{
return IVAS_ERR_OK;
}
@@ -296,13 +296,13 @@ static ivas_error TDREND_LoadBSplineBinaryITD(
}
fread( &modelITD->elevDim3, sizeof( Word16 ), 1, f_hrtf );
- modelITD->elevKSeq_dyn_fx = (Word32 *) malloc( ( modelITD->elevDim3 - 2 ) * sizeof( Word32 ) );
+ ivas_HRTF_binary_open_buffers_int32( &modelITD->elevKSeq_dyn_fx, ( modelITD->elevDim3 - 2 ) * sizeof( Word32 ) );
v_tmp16 = (Word16 *) malloc( ( modelITD->elevDim3 - 2 ) * sizeof( Word16 ) );
if ( modelITD->elevKSeq_dyn_fx == NULL || v_tmp16 == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
}
- fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf );
+ fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf );
fread( v_tmp16, sizeof( Word16 ), modelITD->elevDim3 - 2, f_hrtf );
for ( j = 0; j < modelITD->elevDim3 - 2; j++ )
{
@@ -311,13 +311,13 @@ static ivas_error TDREND_LoadBSplineBinaryITD(
free( v_tmp16 );
fread( &modelITD->azimDim3, sizeof( Word16 ), 1, f_hrtf );
- modelITD->azimKSeq_dyn_fx = (Word32 *) malloc( ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( Word32 ) ); /* basis functions are flipped around 180 deg, number of basis functions above/below is (N+1)/2 */
+ ivas_HRTF_binary_open_buffers_int32( &modelITD->azimKSeq_dyn_fx, ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( Word32 ) );
v_tmp16 = (Word16 *) malloc( ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( Word16 ) );
if ( modelITD->azimKSeq_dyn_fx == NULL || v_tmp16 == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
}
- fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf );
+ fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf );
fread( v_tmp16, sizeof( Word16 ), ( modelITD->azimDim3 + 1 ) / 2 - 2, f_hrtf );
for ( j = 0; j < ( modelITD->azimDim3 + 1 ) / 2 - 2; j++ )
{
@@ -326,13 +326,13 @@ static ivas_error TDREND_LoadBSplineBinaryITD(
free( v_tmp16 );
fread( &tmp, sizeof( Word16 ), 1, f_hrtf );
- modelITD->W_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) );
+ ivas_HRTF_binary_open_buffers_int32( &modelITD->W_dyn_fx, tmp * sizeof( Word32 ) );
if ( modelITD->W_dyn_fx == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
}
- fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf );
+ fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf );
v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) );
if ( v_tmp16 == NULL )
{
@@ -348,13 +348,13 @@ static ivas_error TDREND_LoadBSplineBinaryITD(
free( v_tmp16 );
/* azimuth */
- modelITD->azimBsLen_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) );
+ ivas_HRTF_binary_open_buffers_int16( &modelITD->azimBsLen_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) );
if ( modelITD->azimBsLen_dyn_fx == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
}
fread( modelITD->azimBsLen_dyn_fx, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf );
- modelITD->azimBsStart_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) );
+ ivas_HRTF_binary_open_buffers_int16( &modelITD->azimBsStart_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) );
if ( modelITD->azimBsStart_dyn_fx == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
@@ -362,13 +362,13 @@ static ivas_error TDREND_LoadBSplineBinaryITD(
fread( modelITD->azimBsStart_dyn_fx, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf );
fread( &tmp, sizeof( Word16 ), 1, f_hrtf );
- modelITD->azimBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) );
+ ivas_HRTF_binary_open_buffers_int32( &modelITD->azimBsShape_dyn_fx, tmp * sizeof( Word32 ) );
v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) );
if ( modelITD->azimBsShape_dyn_fx == NULL || v_tmp16 == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
}
- fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf );
+ fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf );
fread( v_tmp16, sizeof( Word16 ), tmp, f_hrtf );
for ( j = 0; j < tmp; j++ )
{
@@ -379,13 +379,13 @@ static ivas_error TDREND_LoadBSplineBinaryITD(
fread( &modelITD->azimSegSamples, sizeof( Word16 ), 1, f_hrtf );
/* elevation */
- modelITD->elevBsLen_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) );
+ ivas_HRTF_binary_open_buffers_int16( &modelITD->elevBsLen_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) );
if ( modelITD->elevBsLen_dyn_fx == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
}
fread( modelITD->elevBsLen_dyn_fx, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf );
- modelITD->elevBsStart_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) );
+ ivas_HRTF_binary_open_buffers_int16( &modelITD->elevBsStart_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) );
if ( modelITD->elevBsStart_dyn_fx == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
@@ -393,7 +393,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD(
fread( modelITD->elevBsStart_dyn_fx, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf );
fread( &tmp, sizeof( Word16 ), 1, f_hrtf );
- modelITD->elevBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) );
+ ivas_HRTF_binary_open_buffers_int32( &modelITD->elevBsShape_dyn_fx, tmp * sizeof( Word32 ) );
if ( modelITD->elevBsShape_dyn_fx == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
@@ -404,7 +404,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD(
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
}
- fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf );
+ fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf );
fread( v_tmp16, sizeof( Word16 ), tmp, f_hrtf );
for ( j = 0; j < tmp; j++ )
{
@@ -449,9 +449,9 @@ static ivas_error TDREND_LoadBSplineBinary(
return IVAS_ERR_UNEXPECTED_NULL_POINTER;
}
- fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf );
+ fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf );
HrFiltSet_p->latency_s_Q_fx = Q31 - factor_Q;
- fread( &HrFiltSet_p->latency_s_fx, 1, sizeof( Word32 ), f_hrtf );
+ fread( &HrFiltSet_p->latency_s_fx, sizeof( Word32 ), 1, f_hrtf );
model = &( HrFiltSet_p->ModelParams );
/* Set ROM flag for correct deallocation */
@@ -489,23 +489,23 @@ static ivas_error TDREND_LoadBSplineBinary(
fread( &model->K, sizeof( Word16 ), 1, f_hrtf );
fread( &model->elevDim3, sizeof( Word16 ), 1, f_hrtf );
- model->elevKSeq_dyn_fx = (Word32 *) malloc( ( model->elevDim3 - 2 ) * sizeof( Word32 ) );
+ ivas_HRTF_binary_open_buffers_int32( &model->elevKSeq_dyn_fx, ( model->elevDim3 - 2 ) * sizeof( Word32 ) );
v_tmp16 = (Word16 *) malloc( ( model->elevDim3 - 2 ) * sizeof( Word16 ) );
if ( model->elevKSeq_dyn_fx == NULL || v_tmp16 == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
}
- fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf );
+ fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf );
fread( v_tmp16, sizeof( Word16 ), model->elevDim3 - 2, f_hrtf );
for ( j = 0; j < model->elevDim3 - 2; j++ )
{
model->elevKSeq_dyn_fx[j] = L_shl_r( L_deposit_l( v_tmp16[j] ), Q22 - factor_Q );
}
free( v_tmp16 );
- model->azimDim3_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) );
- model->azim_start_idx_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) );
- model->azimKSeq_fx = (Word32 **) malloc( model->elevDim3 * sizeof( Word32 * ) );
+ ivas_HRTF_binary_open_buffers_int16( &model->azimDim3_dyn, model->elevDim3 * sizeof( Word16 ) );
+ ivas_HRTF_binary_open_buffers_int16( &model->azim_start_idx_dyn, model->elevDim3 * sizeof( Word16 ) );
+ ivas_HRTF_binary_open_buffers_int32_ptr( &model->azimKSeq_fx, model->elevDim3 * sizeof( float * ) );
if ( model->azimDim3_dyn == NULL || model->azim_start_idx_dyn == NULL || model->azimKSeq_fx == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
@@ -515,14 +515,14 @@ static ivas_error TDREND_LoadBSplineBinary(
{
fread( &model->azimDim3_dyn[i], sizeof( Word16 ), 1, f_hrtf );
fread( &model->azim_start_idx_dyn[i], sizeof( Word16 ), 1, f_hrtf );
- model->azimKSeq_fx[i] = (Word32 *) malloc( ( model->azimDim3_dyn[i] + 1 ) * sizeof( Word32 ) );
+ ivas_HRTF_binary_open_buffers_int32( &model->azimKSeq_fx[i], ( model->azimDim3_dyn[i] + 1 ) * sizeof( Word32 ) );
v_tmp16 = (Word16 *) malloc( ( model->azimDim3_dyn[i] + 1 ) * sizeof( Word16 ) );
if ( model->azimKSeq_fx[i] == NULL || v_tmp16 == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
}
- fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf );
+ fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf );
fread( v_tmp16, sizeof( Word16 ), ( model->azimDim3_dyn[i] + 1 ), f_hrtf );
for ( j = 0; j < model->azimDim3_dyn[i] + 1; j++ )
{
@@ -531,15 +531,14 @@ static ivas_error TDREND_LoadBSplineBinary(
free( v_tmp16 );
}
fread( &model->AlphaN, sizeof( Word16 ), 1, f_hrtf );
-
- model->AlphaL_dyn_fx = (Word32 *) malloc( model->AlphaN * model->K * sizeof( Word32 ) );
+ ivas_HRTF_binary_open_buffers_int32( &model->AlphaL_dyn_fx, model->AlphaN * model->K * sizeof( Word32 ) );
v_tmp16 = (Word16 *) malloc( model->AlphaN * model->K * sizeof( Word16 ) );
if ( model->AlphaL_dyn_fx == NULL || v_tmp16 == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
}
- fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf );
+ fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf );
model->AlphaL_e = Q15 - factor_Q;
// model->AlphaL_dyn_e = 1; /* force to 6 to be corrected */
@@ -550,7 +549,7 @@ static ivas_error TDREND_LoadBSplineBinary(
{
model->AlphaL_dyn_fx[j] = L_shl_r( L_deposit_l( v_tmp16[j] ), Q30 - factor_Q );
}
- model->AlphaR_dyn_fx = (Word32 *) malloc( model->AlphaN * model->K * sizeof( Word32 ) );
+ ivas_HRTF_binary_open_buffers_int32( &model->AlphaR_dyn_fx, model->AlphaN * model->K * sizeof( Word32 ) );
if ( model->AlphaR_dyn_fx == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
@@ -566,9 +565,9 @@ static ivas_error TDREND_LoadBSplineBinary(
/* azimuth */
fread( &model->num_unique_azim_splines, sizeof( Word16 ), 1, f_hrtf );
- model->azimBsShape_fx = (const Word32 **) malloc( model->num_unique_azim_splines * sizeof( Word32 * ) );
- model->azimBsShape_dyn_fx = (Word32 **) malloc( model->num_unique_azim_splines * sizeof( Word32 * ) );
- model->azimSegSamples_dyn = (Word16 *) malloc( model->num_unique_azim_splines * sizeof( Word16 ) );
+ ivas_HRTF_binary_open_buffers_int32_ptr_const( &model->azimBsShape_fx, model->num_unique_azim_splines * sizeof( float * ) );
+ ivas_HRTF_binary_open_buffers_int32_ptr( &model->azimBsShape_dyn_fx, model->num_unique_azim_splines * sizeof( float * ) );
+ ivas_HRTF_binary_open_buffers_int16( &model->azimSegSamples_dyn, model->num_unique_azim_splines * sizeof( Word16 ) );
if ( model->azimBsShape_fx == NULL || model->azimBsShape_dyn_fx == NULL || model->azimSegSamples_dyn == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
@@ -577,12 +576,12 @@ static ivas_error TDREND_LoadBSplineBinary(
for ( i = 0; i < model->num_unique_azim_splines; i++ )
{
fread( &tmp, sizeof( Word16 ), 1, f_hrtf );
- model->azimBsShape_dyn_fx[i] = (Word32 *) malloc( tmp * sizeof( Word32 ) );
+ ivas_HRTF_binary_open_buffers_int32( &model->azimBsShape_dyn_fx[i], tmp * sizeof( Word32 ) );
if ( model->azimBsShape_dyn_fx[i] == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
}
- fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf );
+ fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf );
v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) );
if ( v_tmp16 == NULL )
{
@@ -597,14 +596,13 @@ static ivas_error TDREND_LoadBSplineBinary(
fread( &model->azimSegSamples_dyn[i], sizeof( Word16 ), 1, f_hrtf );
free( v_tmp16 );
}
-
- model->azimShapeIdx_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) );
+ ivas_HRTF_binary_open_buffers_int16( &model->azimShapeIdx_dyn, model->elevDim3 * sizeof( Word16 ) );
if ( model->azimShapeIdx_dyn == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
}
fread( model->azimShapeIdx_dyn, sizeof( Word16 ), model->elevDim3, f_hrtf );
- model->azimShapeSampFactor_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) );
+ ivas_HRTF_binary_open_buffers_int16( &model->azimShapeSampFactor_dyn, model->elevDim3 * sizeof( Word16 ) );
if ( model->azimShapeSampFactor_dyn == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
@@ -612,13 +610,13 @@ static ivas_error TDREND_LoadBSplineBinary(
fread( model->azimShapeSampFactor_dyn, sizeof( Word16 ), model->elevDim3, f_hrtf );
/* elevation */
- model->elevBsLen_dyn = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) );
+ ivas_HRTF_binary_open_buffers_int16( &model->elevBsLen_dyn, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) );
if ( model->elevBsLen_dyn == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
}
fread( model->elevBsLen_dyn, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf );
- model->elevBsStart_dyn = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) );
+ ivas_HRTF_binary_open_buffers_int16( &model->elevBsStart_dyn, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) );
if ( model->elevBsStart_dyn == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
@@ -627,13 +625,13 @@ static ivas_error TDREND_LoadBSplineBinary(
fread( &tmp, sizeof( Word16 ), 1, f_hrtf );
v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) );
- model->elevBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) );
+ ivas_HRTF_binary_open_buffers_int32( &model->elevBsShape_dyn_fx, tmp * sizeof( Word32 ) );
if ( model->elevBsShape_dyn_fx == NULL || v_tmp16 == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
}
- fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf );
+ fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf );
fread( v_tmp16, sizeof( Word16 ), tmp, f_hrtf );
for ( j = 0; j < tmp; j++ )
{
@@ -643,19 +641,19 @@ static ivas_error TDREND_LoadBSplineBinary(
fread( &model->elevSegSamples, sizeof( Word16 ), 1, f_hrtf );
- model->EL_dyn_fx = (Word32 *) malloc( model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( Word32 ) );
+ ivas_HRTF_binary_open_buffers_int32( &model->EL_dyn_fx, model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( Word32 ) );
if ( model->EL_dyn_fx == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
}
- fread( &factor_Q, 1, sizeof( Word16 ), f_hrtf );
+ fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf );
model->EL_e = Q31 - factor_Q;
model->ER_e = model->EL_e;
fread( (Word32 *) model->EL_dyn_fx, sizeof( Word32 ), model->AlphaN * HRTF_MODEL_N_SECTIONS, f_hrtf );
- model->ER_dyn_fx = (Word32 *) malloc( model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( Word32 ) );
+ ivas_HRTF_binary_open_buffers_int32( &model->ER_dyn_fx, model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( Word32 ) );
if ( model->ER_dyn_fx == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
@@ -685,8 +683,8 @@ static ivas_error TDREND_LoadBSplineBinary(
HRTF_model_precalc( model );
HrFiltSet_p->FiltLength = HrFiltSet_p->ModelParams.K;
- HrFiltSet_p->ModelEval.hrfModL_fx = (Word32 *) malloc( model->K * sizeof( Word32 ) );
- HrFiltSet_p->ModelEval.hrfModR_fx = (Word32 *) malloc( model->K * sizeof( Word32 ) );
+ ivas_HRTF_binary_open_buffers_int32( &HrFiltSet_p->ModelEval.hrfModL_fx, model->K * sizeof( Word32 ) );
+ ivas_HRTF_binary_open_buffers_int32( &HrFiltSet_p->ModelEval.hrfModR_fx, model->K * sizeof( Word32 ) );
if ( HrFiltSet_p->ModelEval.hrfModL_fx == NULL || HrFiltSet_p->ModelEval.hrfModR_fx == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
@@ -719,12 +717,12 @@ static ivas_error load_reverb_from_binary(
bool is_reverb;
ivas_error header_check_result;
ivas_hrtfs_file_header_t hrtfs_file_header;
- int16_t hrtf_id;
+ Word16 hrtf_id;
ivas_hrtfs_header_t hrtf_header;
- int32_t hrtf_data_size_max;
+ Word32 hrtf_data_size_max;
char *hrtf_data;
- int16_t lr_iac_len;
- int16_t ind;
+ Word16 lr_iac_len;
+ Word16 ind;
Word16 factorQ;
Word16 tmp16;
@@ -799,10 +797,9 @@ static ivas_error load_reverb_from_binary(
if ( is_reverb )
{
- hHrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) );
- hHrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) );
- hHrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) );
-
+ ivas_HRTF_binary_open_buffers_int32( &hHrtfStatistics->average_energy_l_dyn, lr_iac_len * sizeof( Word32 ) );
+ ivas_HRTF_binary_open_buffers_int32( &hHrtfStatistics->average_energy_r_dyn, lr_iac_len * sizeof( Word32 ) );
+ ivas_HRTF_binary_open_buffers_int32( &hHrtfStatistics->inter_aural_coherence_dyn, lr_iac_len * sizeof( Word32 ) );
if ( hHrtfStatistics->average_energy_l_dyn == NULL || hHrtfStatistics->average_energy_r_dyn == NULL || hHrtfStatistics->inter_aural_coherence_dyn == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
@@ -839,12 +836,12 @@ static ivas_error load_reverb_from_binary(
}
/*---------------------------------------------------------------------*
- * load_reverb_binary()
+ * load_HrtfStatistics_from_binary()
*
* Load HRTF binary data into the HRTF handle for TD and Crend renderers
*---------------------------------------------------------------------*/
-ivas_error load_reverb_binary(
+ivas_error load_HrtfStatistics_from_binary(
IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */
const Word32 sampleRate, /* i : sample rate */
const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */
@@ -873,13 +870,13 @@ static ivas_error TDREND_MIX_LoadHRTF(
IVAS_DEC_HRTF_TD_HANDLE HrFiltSet_p /* o : Loaded HR filter set */
)
{
- int16_t tmp;
+ Word16 tmp;
bool is_tdrend;
ivas_error header_check_result;
ivas_hrtfs_file_header_t hrtfs_file_header;
- int16_t hrtf_id;
+ Word16 hrtf_id;
ivas_hrtfs_header_t hrtf_header;
- int32_t hrtf_data_size_max;
+ Word32 hrtf_data_size_max;
char *hrtf_data;
if ( f_hrtf == NULL )
@@ -894,7 +891,7 @@ static ivas_error TDREND_MIX_LoadHRTF(
/* try if it is old format for BE tests*/
fseek( f_hrtf, 0, SEEK_SET );
- if ( fread( &tmp, 1, sizeof( int16_t ), f_hrtf ) == 0 )
+ if ( fread( &tmp, sizeof( Word16 ), 1, f_hrtf ) == 0 )
{
header_check_result = IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" );
}
@@ -966,7 +963,7 @@ static ivas_error TDREND_MIX_LoadHRTF(
if ( is_tdrend )
{
- if ( fread( &tmp, 1, sizeof( int16_t ), f_hrtf ) == 0 )
+ if ( fread( &tmp, sizeof( Word16 ), 1, f_hrtf ) == 0 )
{
return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" );
}
@@ -999,7 +996,7 @@ static ivas_error TDREND_MIX_LoadHRTF(
ivas_error load_TDrend_HRTF_binary(
IVAS_DEC_HRTF_TD_HANDLE hHrtf, /* i/o: TD rend. HRTF handle */
- const int32_t sampleRate, /* i : sample rate */
+ const Word32 sampleRate, /* i : sample rate */
const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */
)
{
@@ -1013,7 +1010,6 @@ ivas_error load_TDrend_HRTF_binary(
return TDREND_MIX_LoadHRTF( hrtfReader->file, sampleRate, hHrtf );
}
-
/*---------------------------------------------------------------------*
* destroy_td_hrtf()
*
@@ -1024,61 +1020,9 @@ void destroy_td_hrtf(
IVAS_DEC_HRTF_TD_HANDLE *hHrtf /* i/o: TD rend. HRTF handle */
)
{
- int16_t i;
-
- if ( ( hHrtf == NULL ) || ( *hHrtf == NULL ) )
- {
- return;
- }
-
- if ( !( *hHrtf )->ModelParams.modelROM )
- {
- if ( ( *hHrtf )->ModelParams.UseItdModel )
- {
- free( ( *hHrtf )->ModelParamsITD.elevKSeq_dyn_fx );
- free( ( *hHrtf )->ModelParamsITD.azimKSeq_dyn_fx );
- free( ( *hHrtf )->ModelParamsITD.W_dyn_fx );
- free( ( *hHrtf )->ModelParamsITD.azimBsShape_dyn_fx );
- free( ( *hHrtf )->ModelParamsITD.elevBsShape_dyn_fx );
- free( ( *hHrtf )->ModelParamsITD.azimBsLen_dyn_fx );
- free( ( *hHrtf )->ModelParamsITD.azimBsStart_dyn_fx );
- free( ( *hHrtf )->ModelParamsITD.elevBsLen_dyn_fx );
- free( ( *hHrtf )->ModelParamsITD.elevBsStart_dyn_fx );
- }
- free( ( *hHrtf )->ModelParams.elevKSeq_dyn_fx );
- free( ( *hHrtf )->ModelParams.azim_start_idx_dyn );
- free( ( *hHrtf )->ModelParams.azimDim3_dyn );
- free( ( *hHrtf )->ModelParams.AlphaL_dyn_fx );
- free( ( *hHrtf )->ModelParams.AlphaR_dyn_fx );
- free( ( *hHrtf )->ModelParams.azimSegSamples_dyn );
-
- free( ( *hHrtf )->ModelParams.azimShapeIdx_dyn );
- free( ( *hHrtf )->ModelParams.azimShapeSampFactor_dyn );
- free( ( *hHrtf )->ModelParams.elevBsLen_dyn );
- free( ( *hHrtf )->ModelParams.elevBsStart_dyn );
- free( ( *hHrtf )->ModelParams.elevBsShape_dyn_fx );
-
- for ( i = 0; i < ( *hHrtf )->ModelParams.num_unique_azim_splines; i++ )
- {
- free( ( *hHrtf )->ModelParams.azimBsShape_dyn_fx[i] );
- }
- free( ( *hHrtf )->ModelParams.azimBsShape_dyn_fx );
- free( (void *) ( *hHrtf )->ModelParams.azimBsShape_fx ); /* void* cast needed to please both gcc and Visual studio compilers. Deallocating const float** should be fine and gcc agrees, but Visual studio complains. */
- for ( i = 0; i < ( *hHrtf )->ModelParams.elevDim3; i++ )
- {
- free( ( *hHrtf )->ModelParams.azimKSeq_fx[i] );
- }
- free( ( *hHrtf )->ModelParams.azimKSeq_fx );
+ ivas_HRTF_td_binary_close_fx( hHrtf );
- free( ( *hHrtf )->ModelParams.EL_dyn_fx );
- free( ( *hHrtf )->ModelParams.ER_dyn_fx );
-
- free( ( *hHrtf )->ModelEval.hrfModL_fx );
- free( ( *hHrtf )->ModelEval.hrfModR_fx );
- }
-
- ivas_HRTF_binary_close_fx( hHrtf );
return;
}
@@ -1150,7 +1094,7 @@ static ivas_error create_Crend_HRTF_from_rawdata(
{
for ( j = 0; j < BINAURAL_CHANNELS; j++ )
{
- if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pIndex_frequency_max_dyn_fx[i][j], mem_size ) ) != IVAS_ERR_OK )
+ if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pIndex_frequency_max_dyn_fx[i][j], mem_size ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1176,8 +1120,8 @@ static ivas_error create_Crend_HRTF_from_rawdata(
/* pIndex_frequency_max_diffuse (the size depends on num_iterations_diffuse) */
for ( j = 0; j < BINAURAL_CHANNELS; j++ )
{
- mem_size = ( *hHRTF )->num_iterations_diffuse[j] * sizeof( uint16_t );
- if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pIndex_frequency_max_diffuse_dyn_fx[j], mem_size ) ) != IVAS_ERR_OK )
+ mem_size = ( *hHRTF )->num_iterations_diffuse[j] * sizeof( UWord16 );
+ if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pIndex_frequency_max_diffuse_dyn_fx[j], mem_size ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1189,7 +1133,7 @@ static ivas_error create_Crend_HRTF_from_rawdata(
/* index_frequency_max_diffuse */
( *hHRTF )->index_frequency_max_diffuse = *( (Word16 *) ( hrtf_data_rptr ) );
- hrtf_data_rptr += sizeof( uint16_t );
+ hrtf_data_rptr += sizeof( UWord16 );
/* inv_diffuse_weight Q factor*/
( *hHRTF )->factor_Q_inv_diffuse_weight = Q15 - *( (Word16 *) ( hrtf_data_rptr ) );
@@ -1220,7 +1164,7 @@ static ivas_error create_Crend_HRTF_from_rawdata(
{
for ( j = 0; j < BINAURAL_CHANNELS; j++ )
{
- if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_re_dyn_fx[i][j], mem_size_buf ) ) != IVAS_ERR_OK )
+ if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_re_dyn_fx[i][j], mem_size_buf ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1247,7 +1191,7 @@ static ivas_error create_Crend_HRTF_from_rawdata(
{
for ( j = 0; j < BINAURAL_CHANNELS; j++ )
{
- if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_im_dyn_fx[i][j], mem_size_buf ) ) != IVAS_ERR_OK )
+ if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_im_dyn_fx[i][j], mem_size_buf ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1270,8 +1214,8 @@ static ivas_error create_Crend_HRTF_from_rawdata(
}
/* max_total_num_fsamp_per_iteration_diff */
- max_total_num_fsamp_per_iteration_diff = *( (uint32_t *) ( hrtf_data_rptr ) );
- hrtf_data_rptr += sizeof( uint32_t );
+ max_total_num_fsamp_per_iteration_diff = *( (UWord32 *) ( hrtf_data_rptr ) );
+ hrtf_data_rptr += sizeof( UWord32 );
mem_size_buf = max_total_num_fsamp_per_iteration_diff * sizeof( Word16 );
@@ -1282,7 +1226,7 @@ static ivas_error create_Crend_HRTF_from_rawdata(
/* coeff_diffuse_re : The size depends on pIndex_frequency_max_diffuse */
for ( j = 0; j < BINAURAL_CHANNELS; j++ )
{
- if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_diffuse_re_dyn_fx[j], mem_size_buf ) ) != IVAS_ERR_OK )
+ if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_diffuse_re_dyn_fx[j], mem_size_buf ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1306,7 +1250,7 @@ static ivas_error create_Crend_HRTF_from_rawdata(
/* coeff_diffuse_im : The size depends on pIndex_frequency_max_diffuse */
for ( j = 0; j < BINAURAL_CHANNELS; j++ )
{
- if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_diffuse_im_dyn_fx[j], mem_size_buf ) ) != IVAS_ERR_OK )
+ if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_diffuse_im_dyn_fx[j], mem_size_buf ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1370,17 +1314,17 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
latency_s = *( (Word32 *) ( hrtf_data_rptr ) );
hrtf_data_rptr += sizeof( Word32 );
- if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) )
+ if ( BINAURAL_CONVBANDS != *( (UWord16 *) ( hrtf_data_rptr ) ) )
{
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" );
}
- hrtf_data_rptr += sizeof( uint16_t );
+ hrtf_data_rptr += sizeof( UWord16 );
- nbchan = *( (uint16_t *) ( hrtf_data_rptr ) );
- hrtf_data_rptr += sizeof( uint16_t );
+ nbchan = *( (UWord16 *) ( hrtf_data_rptr ) );
+ hrtf_data_rptr += sizeof( UWord16 );
- ntaps = *( (uint16_t *) ( hrtf_data_rptr ) );
- hrtf_data_rptr += sizeof( uint16_t );
+ ntaps = *( (UWord16 *) ( hrtf_data_rptr ) );
+ hrtf_data_rptr += sizeof( UWord16 );
( *hHRTF )->ntaps = ntaps;
( *hHRTF )->FASTCONV_latency_s_Q_fx = Q31 - factorQ;
@@ -1546,11 +1490,11 @@ static ivas_error create_parambin_HRTF_from_rawdata(
char *hrtf_data /* i : pointer to binary file */
)
{
- int16_t i, j, k;
+ Word16 i, j, k;
char *hrtf_data_rptr;
- uint32_t data_size_tmp;
+ UWord32 data_size_tmp;
Word16 factorQ;
- int16_t *ptW16;
+ Word16 *ptW16;
if ( hrtf_data == NULL )
{
@@ -1560,30 +1504,30 @@ static ivas_error create_parambin_HRTF_from_rawdata(
hrtf_data_rptr = hrtf_data;
/* HRTF_SH_CHANNELS */
- if ( HRTF_SH_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) )
+ if ( HRTF_SH_CHANNELS != *( (UWord16 *) ( hrtf_data_rptr ) ) )
{
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_SH_CHANNELS)" );
}
- hrtf_data_rptr += sizeof( uint16_t );
+ hrtf_data_rptr += sizeof( UWord16 );
/* HRTF_NUM_BINS */
- if ( HRTF_NUM_BINS != *( (uint16_t *) ( hrtf_data_rptr ) ) )
+ if ( HRTF_NUM_BINS != *( (UWord16 *) ( hrtf_data_rptr ) ) )
{
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_NUM_BINS)" );
}
- hrtf_data_rptr += sizeof( uint16_t );
+ hrtf_data_rptr += sizeof( UWord16 );
/* HRTF */
/* Q factor*/
factorQ = *( (Word16 *) ( hrtf_data_rptr ) );
hrtf_data_rptr += sizeof( Word16 );
- data_size_tmp = HRTF_NUM_BINS * sizeof( int16_t );
+ data_size_tmp = HRTF_NUM_BINS * sizeof( Word16 );
for ( i = 0; i < BINAURAL_CHANNELS; i++ )
{
for ( j = 0; j < HRTF_SH_CHANNELS; j++ )
{
- ptW16 = (int16_t *) hrtf_data_rptr;
+ ptW16 = (Word16 *) hrtf_data_rptr;
for ( k = 0; k < HRTF_NUM_BINS; k++ )
{
@@ -1596,7 +1540,7 @@ static ivas_error create_parambin_HRTF_from_rawdata(
{
for ( j = 0; j < HRTF_SH_CHANNELS; j++ )
{
- ptW16 = (int16_t *) hrtf_data_rptr;
+ ptW16 = (Word16 *) hrtf_data_rptr;
for ( k = 0; k < HRTF_NUM_BINS; k++ )
{
( *hHRTF )->hrtfShCoeffsIm_fx[i][j][k] = shl_r( ptW16[k], Q14 - factorQ );
@@ -1606,44 +1550,44 @@ static ivas_error create_parambin_HRTF_from_rawdata(
}
/* Reverb Parameters */
- if ( CLDFB_NO_CHANNELS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) )
+ if ( CLDFB_NO_CHANNELS_MAX != *( (UWord16 *) ( hrtf_data_rptr ) ) )
{
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (CLDFB_NO_CHANNELS_MAX)" );
}
- hrtf_data_rptr += sizeof( uint16_t );
+ hrtf_data_rptr += sizeof( UWord16 );
/* Q factor*/
factorQ = *( (Word16 *) ( hrtf_data_rptr ) );
hrtf_data_rptr += sizeof( Word16 );
- ptW16 = (int16_t *) hrtf_data_rptr;
+ ptW16 = (Word16 *) hrtf_data_rptr;
for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
{
( *hHRTF )->parametricReverberationTimes_fx[j] = L_shl_r( L_deposit_l( ptW16[j] ), Q26 - factorQ );
}
- hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t );
+ hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( Word16 );
/* Q factor*/
factorQ = *( (Word16 *) ( hrtf_data_rptr ) );
hrtf_data_rptr += sizeof( Word16 );
- ptW16 = (int16_t *) hrtf_data_rptr;
+ ptW16 = (Word16 *) hrtf_data_rptr;
for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
{
( *hHRTF )->parametricReverberationEneCorrections_fx[j] = L_shl_r( L_deposit_l( ptW16[j] ), Q31 - factorQ );
}
- hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t );
+ hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( Word16 );
/* Q factor*/
factorQ = *( (Word16 *) ( hrtf_data_rptr ) );
hrtf_data_rptr += sizeof( Word16 );
- ptW16 = (int16_t *) hrtf_data_rptr;
+ ptW16 = (Word16 *) hrtf_data_rptr;
for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ )
{
( *hHRTF )->parametricEarlyPartEneCorrection_fx[j] = L_shl_r( L_deposit_l( ptW16[j] ), Q28 - factorQ );
}
- hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t );
+ hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( Word16 );
return IVAS_ERR_OK;
}
@@ -1663,13 +1607,13 @@ ivas_error load_fastconv_HRTF_from_binary(
)
{
FILE *f_hrtf;
- int32_t hrtf_data_size_max;
+ Word32 hrtf_data_size_max;
char *hrtf_data;
ivas_hrtfs_header_t hrtf_header;
ivas_error header_check_result;
ivas_hrtfs_file_header_t hrtfs_file_header;
- int16_t hrtf_id;
- int16_t asFastconv = 0;
+ Word16 hrtf_id;
+ Word16 asFastconv = 0;
bool load = false;
BINAURAL_INPUT_AUDIO_CONFIG hrtf_set_binaural_cfg;
@@ -1775,13 +1719,13 @@ ivas_error load_parambin_HRTF_from_binary(
)
{
FILE *f_hrtf;
- int32_t hrtf_data_size_max;
+ Word32 hrtf_data_size_max;
char *hrtf_data;
ivas_hrtfs_header_t hrtf_header;
ivas_error header_check_result;
ivas_hrtfs_file_header_t hrtfs_file_header;
- int16_t hrtf_id;
- int16_t asParam = 0;
+ Word16 hrtf_id;
+ Word16 asParam = 0;
if ( hrtfReader == NULL || hrtfReader->file == NULL )
{
@@ -1873,18 +1817,18 @@ ivas_error load_Crend_HRTF_from_binary(
const hrtfFileReader *hrtfReader, /* i : pointer to hrtfFileReader handle */
const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */
const IVAS_AUDIO_CONFIG hrtf_set_audio_cfg, /* i : HRTF set audio config. */
- const int32_t sampleRate /* i : sample rate */
+ const Word32 sampleRate /* i : sample rate */
)
{
FILE *f_hrtf;
- int32_t hrtf_data_size_max;
+ Word32 hrtf_data_size_max;
char *hrtf_data;
ivas_hrtfs_header_t hrtf_header;
ivas_error header_check_result;
ivas_hrtfs_file_header_t hrtfs_file_header;
- int16_t hrtf_id;
+ Word16 hrtf_id;
bool load = false;
- int16_t asCrend = 0;
+ Word16 asCrend = 0;
BINAURAL_INPUT_AUDIO_CONFIG hrtf_set_binaural_cfg;
/* convert audio config. to HRTF binaural config */
@@ -1992,47 +1936,7 @@ void destroy_crend_hrtf(
IVAS_DEC_HRTF_CREND_HANDLE *hHrtfCrend /* i/o: Crend HRTF handle */
)
{
- uint16_t i, j;
-
- test();
- if ( *hHrtfCrend != NULL && hHrtfCrend != NULL )
- {
- for ( i = 0; i < MAX_INTERN_CHANNELS; i++ )
- {
- for ( j = 0; j < BINAURAL_CHANNELS; j++ )
- {
- if ( ( *hHrtfCrend )->pIndex_frequency_max[i][j] != NULL )
- {
- free( ( *hHrtfCrend )->pIndex_frequency_max_dyn_fx[i][j] );
- }
- if ( ( *hHrtfCrend )->pOut_to_bin_re_fx[i][j] != NULL )
- {
- free( ( *hHrtfCrend )->pOut_to_bin_re_dyn_fx[i][j] );
- }
- if ( ( *hHrtfCrend )->pOut_to_bin_im_fx[i][j] != NULL )
- {
- free( ( *hHrtfCrend )->pOut_to_bin_im_dyn_fx[i][j] );
- }
- }
- }
- for ( j = 0; j < BINAURAL_CHANNELS; j++ )
- {
- if ( ( *hHrtfCrend )->pIndex_frequency_max_diffuse[j] != NULL )
- {
- free( ( *hHrtfCrend )->pIndex_frequency_max_diffuse_dyn_fx[j] );
- }
- if ( ( *hHrtfCrend )->pOut_to_bin_diffuse_re_fx[j] != NULL )
- {
- free( ( *hHrtfCrend )->pOut_to_bin_diffuse_re_dyn_fx[j] );
- }
- if ( ( *hHrtfCrend )->pOut_to_bin_diffuse_im_fx[j] != NULL )
- {
- free( ( *hHrtfCrend )->pOut_to_bin_diffuse_im_dyn_fx[j] );
- }
- }
- free( *hHrtfCrend );
- *hHrtfCrend = NULL;
- }
+ ivas_HRTF_CRend_binary_close_fx( hHrtfCrend );
return;
}
@@ -2048,9 +1952,6 @@ void destroy_fastconv_hrtf(
IVAS_DEC_HRTF_FASTCONV_HANDLE *hHrtfFastConv /* i/o: FastConv HRTF handle */
)
{
- /* Fastconv HRTF memories */
- ivas_binaural_hrtf_close_fx( hHrtfFastConv );
-
/* Fastconv HRTF filters */
ivas_HRTF_fastconv_binary_close_fx( hHrtfFastConv );
@@ -2083,23 +1984,7 @@ void destroy_hrtf_statistics(
IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */
)
{
- if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) )
- {
- if ( ( *hHrtfStatistics )->average_energy_l_dyn != NULL )
- {
- free( ( *hHrtfStatistics )->average_energy_l_dyn );
- }
- if ( ( *hHrtfStatistics )->average_energy_r_dyn != NULL )
- {
- free( ( *hHrtfStatistics )->average_energy_r_dyn );
- }
- if ( ( *hHrtfStatistics )->inter_aural_coherence_dyn != NULL )
- {
- free( ( *hHrtfStatistics )->inter_aural_coherence_dyn );
- }
- }
-
- ivas_HRTF_statistics_close_fx( hHrtfStatistics );
+ ivas_HRTF_statistics_binary_close_fx( hHrtfStatistics );
return;
}
diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h
index d1f97a191bf8fb499fd125813d350a653a8f4c2b..d404395e0b9dbdf105590f5c3ee2069e5eb24b77 100644
--- a/lib_util/hrtf_file_reader.h
+++ b/lib_util/hrtf_file_reader.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -106,12 +106,12 @@ ivas_error load_TDrend_HRTF_binary(
);
/*---------------------------------------------------------------------*
- * load_reverb_binary()
+ * load_HrtfStatistics_from_binary()
*
* Load reverb binary data into the HRTF handle
*---------------------------------------------------------------------*/
-ivas_error load_reverb_binary(
+ivas_error load_HrtfStatistics_from_binary(
IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */
const Word32 sampleRate, /* i : sample rate */
const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */
diff --git a/lib_util/ism_file_reader.c b/lib_util/ism_file_reader.c
index d0caaa889fa26cecebe2af98608f171e161f44ba..ce4b6fd3b2d1c27b8dfbc91bcc21e5bd2066d2cd 100644
--- a/lib_util/ism_file_reader.c
+++ b/lib_util/ism_file_reader.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/ism_file_reader.h b/lib_util/ism_file_reader.h
index c785cc294bde7cbd4c37e9bfb76856f9b172f5c8..561eba40f4797202c731247d1c83a329fb520ae2 100644
--- a/lib_util/ism_file_reader.h
+++ b/lib_util/ism_file_reader.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/ism_file_writer.c b/lib_util/ism_file_writer.c
index ed098c601cb1a861f47eb7b9c9cbc8ffc0632334..acbd7ec59352d39b82b60c2fdbd12762554233c6 100644
--- a/lib_util/ism_file_writer.c
+++ b/lib_util/ism_file_writer.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/ism_file_writer.h b/lib_util/ism_file_writer.h
index 6bf1a3e3171dc2f63a598554a88415a3335d425b..dbebe1bad134b7689367876e4af035686bc37bfd 100644
--- a/lib_util/ism_file_writer.h
+++ b/lib_util/ism_file_writer.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/ivas_bpool.c b/lib_util/ivas_bpool.c
index 9db909f535e17a2911ab7e809c3a27caaf277edd..0ba94528f2830f2c6db3742f6326b49c242d3b78 100644
--- a/lib_util/ivas_bpool.c
+++ b/lib_util/ivas_bpool.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/ivas_bpool.h b/lib_util/ivas_bpool.h
index 30cf4962b5198fd2a22a522061e8ce4cff2be915..06281b453614a1929371064d6c4264a5c904f984 100644
--- a/lib_util/ivas_bpool.h
+++ b/lib_util/ivas_bpool.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/ivas_queue.c b/lib_util/ivas_queue.c
index b17cf3e21a6e0222b439ba0826780dd031551670..7c8be93af9f73d4434f9f59676e282860cbd8c33 100644
--- a/lib_util/ivas_queue.c
+++ b/lib_util/ivas_queue.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/ivas_queue.h b/lib_util/ivas_queue.h
index 1c6b77504e501b6f0ec680839cd52f3f10b04ca8..a1df80035ee90a53d0b4c5f1b4890693c948ee50 100644
--- a/lib_util/ivas_queue.h
+++ b/lib_util/ivas_queue.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/ivas_rtp_api.h b/lib_util/ivas_rtp_api.h
index a697087ab63fe887c9106cb3f456584add4ab404..f196539fbbb22c65adabdc2e3b609f89a60a7f7d 100644
--- a/lib_util/ivas_rtp_api.h
+++ b/lib_util/ivas_rtp_api.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c
index d694463a6ae593b9e8b04593b39cf714874e343c..37d03a385e2474a9d169c638609fb80b2ce63c2e 100644
--- a/lib_util/ivas_rtp_file.c
+++ b/lib_util/ivas_rtp_file.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/ivas_rtp_file.h b/lib_util/ivas_rtp_file.h
index f5c5dc70e3a68e2a07123baa827563e6304fa44f..a3742c6c81ad277a5d96f851a7bf6e660279f017 100644
--- a/lib_util/ivas_rtp_file.h
+++ b/lib_util/ivas_rtp_file.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/ivas_rtp_internal.h b/lib_util/ivas_rtp_internal.h
index c373304a83dfde52a5488ed3ed60b68494f48a41..afa4c3c6010ecbe95c9641949cf9ec6b601df2b7 100644
--- a/lib_util/ivas_rtp_internal.h
+++ b/lib_util/ivas_rtp_internal.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/ivas_rtp_payload.c b/lib_util/ivas_rtp_payload.c
index 8f28e38d27e2232b25538de64288867e20ec07fe..137c44119e9caeb85127be5bc74a75ab9124051c 100644
--- a/lib_util/ivas_rtp_payload.c
+++ b/lib_util/ivas_rtp_payload.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c
index 6d93dc1f86d0dec13857f758f0b4ba49a705ae12..b533d07c284194e88202dce64512ac06c86575af 100644
--- a/lib_util/ivas_rtp_pi_data.c
+++ b/lib_util/ivas_rtp_pi_data.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -41,11 +41,6 @@
#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) )
#endif
-#ifndef max
-#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) )
-#endif
-
-
/* Generic PI data packing/unpacking functions */
typedef ivas_error ( *PACK_PI_FN )( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten );
typedef ivas_error ( *UNPACK_PI_FN )( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData );
diff --git a/lib_util/ivas_rtp_pi_data.h b/lib_util/ivas_rtp_pi_data.h
index efdbde2eb5e1b32d41950191500c9586962052bb..4f156a9defe729157620134f738e1c7ec0649d3c 100644
--- a/lib_util/ivas_rtp_pi_data.h
+++ b/lib_util/ivas_rtp_pi_data.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/jbm_file_reader.c b/lib_util/jbm_file_reader.c
index 68caf5ae73fc93637fbe3f08d7a4b1513bd284bc..556d8cd674dba3f13d9f19d4e7b8c14698c0f45b 100644
--- a/lib_util/jbm_file_reader.c
+++ b/lib_util/jbm_file_reader.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/jbm_file_reader.h b/lib_util/jbm_file_reader.h
index e824e1eee9f00bbb821664a0515a69f1ce987d38..f6ecee961bfb746ed0d8aa51b9349ec7ca653239 100644
--- a/lib_util/jbm_file_reader.h
+++ b/lib_util/jbm_file_reader.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/jbm_file_writer.c b/lib_util/jbm_file_writer.c
index 9d11dad90490e74e44a1f8afc25e70e8fc196493..da27b218cf434050d7d883c98ecac099155959e9 100644
--- a/lib_util/jbm_file_writer.c
+++ b/lib_util/jbm_file_writer.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/jbm_file_writer.h b/lib_util/jbm_file_writer.h
index aca768a1a0e75c88dd01910bf00854cabc0dc2f2..7dd339ad31156f08a377c1c616f0627b00a3c386 100644
--- a/lib_util/jbm_file_writer.h
+++ b/lib_util/jbm_file_writer.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/ls_custom_file_reader.c b/lib_util/ls_custom_file_reader.c
index 5c1ac6ae041709cb0c7f84642afab48efc2a8c7f..38e76642bc54b5aa15329c4d25d1aa35288a4f02 100644
--- a/lib_util/ls_custom_file_reader.c
+++ b/lib_util/ls_custom_file_reader.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/ls_custom_file_reader.h b/lib_util/ls_custom_file_reader.h
index 46b20a4ff013827acf56198b2b6f917952f21201..d5ead2841fcacb0a7dfb6842ee4d6b14ad30d66e 100644
--- a/lib_util/ls_custom_file_reader.h
+++ b/lib_util/ls_custom_file_reader.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/masa_file_reader.c b/lib_util/masa_file_reader.c
index d782cdfd06d5ec6d6fd7005dba134ad11d3ee210..a7253ecd2d1db5a1b29bc4cd745849378415cca4 100644
--- a/lib_util/masa_file_reader.c
+++ b/lib_util/masa_file_reader.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/masa_file_reader.h b/lib_util/masa_file_reader.h
index 7510598c3bf16a9690be159e7da3fd1187fc6d1d..d430a9194b8e7a86fa9385007faa10657050112e 100644
--- a/lib_util/masa_file_reader.h
+++ b/lib_util/masa_file_reader.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/masa_file_writer.c b/lib_util/masa_file_writer.c
index a1c4d7054757b068aa1dec5e8a6e9da35c11ce29..371fb201e66660273fc9296b7a8138b6120ef995 100644
--- a/lib_util/masa_file_writer.c
+++ b/lib_util/masa_file_writer.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/masa_file_writer.h b/lib_util/masa_file_writer.h
index 74d098388c0e5acf03f777d75d6868f496bf3c6e..c2d51d3945783d65ddc34102e17c5adff968d89b 100644
--- a/lib_util/masa_file_writer.h
+++ b/lib_util/masa_file_writer.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/mime_io.c b/lib_util/mime_io.c
index 3e837ca45df96aeaae64cd5f344f72578e048699..9b20aaeb5c0c9fcbbcc1a83ab577f1727d894080 100644
--- a/lib_util/mime_io.c
+++ b/lib_util/mime_io.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/mime_io.h b/lib_util/mime_io.h
index dbd21c9c79d2fd67d834b4e3364b0f714546bc36..d3b0d7a58b0e15bb7e241794be73adbdb8601b57 100644
--- a/lib_util/mime_io.h
+++ b/lib_util/mime_io.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/mutex.h b/lib_util/mutex.h
index 82094b61c823e909f22282f982413abe037489f6..64f5d2c58397152ef66437b7955410ac00679070 100644
--- a/lib_util/mutex.h
+++ b/lib_util/mutex.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/obj_edit_file_reader.c b/lib_util/obj_edit_file_reader.c
index 2d9a2fd6e084f7e07daa8feda60efe4bb8a4386b..22163d23dbc35a912cc0b51a2f6bb88074fa3bc8 100644
--- a/lib_util/obj_edit_file_reader.c
+++ b/lib_util/obj_edit_file_reader.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
-(C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+(C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -33,9 +33,16 @@ the United Nations Convention on Contracts on the International Sales of Goods.
#include
#include
#include "obj_edit_file_reader.h"
-#include "prot_fx.h"
+#ifndef min
+#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) )
+#endif
+
+#ifndef max
+#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) )
+#endif
+
/*-----------------------------------------------------------------------*
* ObjectEditFileReader_open()
*
diff --git a/lib_util/obj_edit_file_reader.h b/lib_util/obj_edit_file_reader.h
index 016425c2ec704caf45dfe0a794ec49291cd77f57..352202ef56a7865bd2eba33c67f9ac76a83a00e3 100644
--- a/lib_util/obj_edit_file_reader.h
+++ b/lib_util/obj_edit_file_reader.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
-(C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+(C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c
index 89fd65058725495b633e47079c60dc3c4943cca0..2875298ff6e746547dec997676c6d5a8010fe466 100644
--- a/lib_util/render_config_reader.c
+++ b/lib_util/render_config_reader.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -87,14 +87,6 @@
#define FALSE 0
#endif
-#ifndef min
-#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) )
-#endif
-
-#ifndef max
-#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) )
-#endif
-
/*------------------------------------------------------------------------------------------*
* Local Type definitions
@@ -661,8 +653,14 @@ static ivas_error read_bin_code_word(
/* First read minLen bits, then add one bit per iteration to find the correct value */
for ( n = 0; n < size; n++ )
{
- minLen = min( minLen, pLengths[n] );
- maxLen = max( maxLen, pLengths[n] );
+ if ( minLen < pLengths[n] )
+ {
+ minLen = pLengths[n];
+ }
+ if ( pLengths[n] > maxLen )
+ {
+ maxLen = pLengths[n];
+ }
}
for ( len = minLen; len <= maxLen; len++ )
{
@@ -1999,7 +1997,9 @@ ivas_error RenderConfigReader_read(
pTemp = (char *) calloc( file_size + 1, sizeof( char ) );
acIdx = 0;
roomAcHasFgCount = roomAcHasAcEnvCount = FALSE;
+#ifdef _MSC_VER
setvbuf( pRenderConfigReader->pConfigFile, pConfig_str, _IONBF, sizeof( char ) ); /* Work-around for VS bug that gives incorrect ftell for UNIX-style line endings */
+#endif
/* read file line by line */
while ( fgets( pConfig_str, file_size, pRenderConfigReader->pConfigFile ) != NULL )
diff --git a/lib_util/render_config_reader.h b/lib_util/render_config_reader.h
index 3a7ee101744b2c7b1e5ec1868c661dd65d0de41d..c533f1393eec98edbb92fb304757515f37b7a61b 100644
--- a/lib_util/render_config_reader.h
+++ b/lib_util/render_config_reader.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/rotation_file_reader.c b/lib_util/rotation_file_reader.c
index 4385a9f831cb63e632620295e765060f6e67afd3..5530371b090f41232163ea275c94296668c4c540 100644
--- a/lib_util/rotation_file_reader.c
+++ b/lib_util/rotation_file_reader.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/rotation_file_reader.h b/lib_util/rotation_file_reader.h
index 8d6206bd6331744bb16e22a24ba0205c0a4ac4ca..4cb9e5f6a7814289e92e6bdea2b9da2d98e2d8b8 100644
--- a/lib_util/rotation_file_reader.h
+++ b/lib_util/rotation_file_reader.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/rtpdump.c b/lib_util/rtpdump.c
index 0b818ee193ba0df8be3742b12f691f57255a2f6e..df51a197290b3bb0c86cac70e4ba61e41492fdb4 100644
--- a/lib_util/rtpdump.c
+++ b/lib_util/rtpdump.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/rtpdump.h b/lib_util/rtpdump.h
index 366f95d57dc5432b806e88119e7639fb51ee1bbc..8ddfde7504d18da1bda83ba84845c5bf196dfafc 100644
--- a/lib_util/rtpdump.h
+++ b/lib_util/rtpdump.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/split_rend_bfi_file_reader.c b/lib_util/split_rend_bfi_file_reader.c
index 6a86738e026d04149cf714d2b5b99e830a883b83..ec9755019be9ea60b262d09150b1f0a70bded0db 100644
--- a/lib_util/split_rend_bfi_file_reader.c
+++ b/lib_util/split_rend_bfi_file_reader.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/split_rend_bfi_file_reader.h b/lib_util/split_rend_bfi_file_reader.h
index 0956b6b3ddcecc0b8fd58f0f13a26b15b8e4c5a0..57e6294f8f93202b3ca56b37fe840801d8e367e5 100644
--- a/lib_util/split_rend_bfi_file_reader.h
+++ b/lib_util/split_rend_bfi_file_reader.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c
index 75fd30d88a9ecc824d43afdb13ed99122e9645cc..2fcc70dfb4b9edfd280f595d1d24f1ef251d0889 100644
--- a/lib_util/split_render_file_read_write.c
+++ b/lib_util/split_render_file_read_write.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -71,18 +71,19 @@ ivas_error split_rend_reader_open(
{
SplitFileReadWrite *hSplitRendFileReadWrite;
size_t header_len, h;
+ int32_t tmp;
char header[SPLIT_RENDERER_FRAME_HEADER_LEN] = "MAIN_SPLITH";
char header_read[SPLIT_RENDERER_FRAME_HEADER_LEN];
if ( ( hSplitRendFileReadWrite = (SplitFileReadWrite *) malloc( sizeof( SplitFileReadWrite ) ) ) == NULL )
{
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for split rendering writer\n" ) );
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for split rendering reader\n" ) );
}
hSplitRendFileReadWrite->file = fopen( filename, "rb" );
if ( hSplitRendFileReadWrite->file == NULL )
{
- return ( IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "\nCould not open split rend metadata file %s\n", filename ) );
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "\nCould not open file %s\n", filename ) );
}
header_len = strlen( header );
@@ -98,22 +99,25 @@ ivas_error split_rend_reader_open(
if ( strncmp( header_read, header, header_len ) )
{
- return ( IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "\nError split rend bitstream main header mismatch\n" ) );
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "\nSplit rendering bitstream main header mismatch\n" ) );
}
fread( &hSplitRendFileReadWrite->delay_ns, sizeof( uint32_t ), 1, hSplitRendFileReadWrite->file );
/* read codec signalling */
- if ( fread( codec, sizeof( *codec ), 1, hSplitRendFileReadWrite->file ) != 1 )
+ if ( fread( &tmp, sizeof( int32_t ), 1, hSplitRendFileReadWrite->file ) != 1 )
{
return IVAS_ERR_FAILED_FILE_READ;
}
+ *codec = (ISAR_SPLIT_REND_CODEC) tmp;
/* read pose correction signalling */
- if ( fread( poseCorrection, sizeof( *poseCorrection ), 1, hSplitRendFileReadWrite->file ) != 1 )
+ if ( fread( &tmp, sizeof( int32_t ), 1, hSplitRendFileReadWrite->file ) != 1 )
{
return IVAS_ERR_FAILED_FILE_READ;
}
+ *poseCorrection = (ISAR_SPLIT_REND_POSE_CORRECTION_MODE) tmp;
+
/* read transport codec frame size signalling */
if ( fread( codec_frame_size_ms, sizeof( *codec_frame_size_ms ), 1, hSplitRendFileReadWrite->file ) != 1 )
{
@@ -161,6 +165,7 @@ ivas_error split_rend_writer_open(
{
SplitFileReadWrite *hSplitRendFileReadWrite;
size_t header_len, h;
+ int32_t tmp;
char header[SPLIT_RENDERER_FRAME_HEADER_LEN] = "MAIN_SPLITH";
if ( filename == NULL )
@@ -193,13 +198,15 @@ ivas_error split_rend_writer_open(
fwrite( &hSplitRendFileReadWrite->delay_ns, sizeof( int32_t ), 1, hSplitRendFileReadWrite->file );
/* Write codec signalling */
- if ( fwrite( &codec, sizeof( codec ), 1, hSplitRendFileReadWrite->file ) != 1 )
+ tmp = (int32_t) codec;
+ if ( fwrite( &tmp, sizeof( int32_t ), 1, hSplitRendFileReadWrite->file ) != 1 )
{
return IVAS_ERR_FAILED_FILE_WRITE;
}
/* Write pose correction signalling */
- if ( fwrite( &poseCorrection, sizeof( poseCorrection ), 1, hSplitRendFileReadWrite->file ) != 1 )
+ tmp = (int32_t) poseCorrection;
+ if ( fwrite( &tmp, sizeof( int32_t ), 1, hSplitRendFileReadWrite->file ) != 1 )
{
return IVAS_ERR_FAILED_FILE_WRITE;
}
diff --git a/lib_util/split_render_file_read_write.h b/lib_util/split_render_file_read_write.h
index 0ea113e899d9cf0920c7978c52d11ebfbe1c536b..bfb0a191c58fbd882b58ea30006ba152d97af473 100644
--- a/lib_util/split_render_file_read_write.h
+++ b/lib_util/split_render_file_read_write.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/tinywavein_c.h b/lib_util/tinywavein_c.h
index 1ff6f26bb78438b2fbb835e483f99c1d46128dce..6e0e69beb978d509b37c96a68d5bb47b09e90d8b 100644
--- a/lib_util/tinywavein_c.h
+++ b/lib_util/tinywavein_c.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/tinywaveout_c.h b/lib_util/tinywaveout_c.h
index a3982ba19cdda311fea397ad5fb6b139c8d83c0e..bbb97c6030e63f8a17269dbc7026f81281351798 100644
--- a/lib_util/tinywaveout_c.h
+++ b/lib_util/tinywaveout_c.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/lib_util/vector3_pair_file_reader.c b/lib_util/vector3_pair_file_reader.c
index 737ef91af135e8ad834d85a2d66a1a8dea0c3e8b..27a21d21e8904a62acf01681ec8da719f0ab268d 100644
--- a/lib_util/vector3_pair_file_reader.c
+++ b/lib_util/vector3_pair_file_reader.c
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -114,8 +114,13 @@ ivas_error Vector3PairFileReader_read(
pSecond->y = y2;
pSecond->z = z2;
+#ifdef FIX_BASOP_2361_OTR
+ pFirst->q_fact = 27; // Q27
+ pSecond->q_fact = 27; // Q27
+#else
pFirst->q_fact = 29; // Q29
pSecond->q_fact = 29; // Q29
+#endif
pFirst->x_fx = floatToFixed_32( pFirst->x, pFirst->q_fact );
pFirst->y_fx = floatToFixed_32( pFirst->y, pFirst->q_fact );
pFirst->z_fx = floatToFixed_32( pFirst->z, pFirst->q_fact );
diff --git a/lib_util/vector3_pair_file_reader.h b/lib_util/vector3_pair_file_reader.h
index 6515d32d58f68c5088204f7fa1aae667ad3140cb..af4a6c99106098651008243cb530de84268c6411 100644
--- a/lib_util/vector3_pair_file_reader.h
+++ b/lib_util/vector3_pair_file_reader.h
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
diff --git a/readme.txt b/readme.txt
index f2c21eab2eb7b32769a4efef8ed9394c4af6c4ff..1db279fc514619aba5a4329975b173c138b3b537 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,6 +1,6 @@
/******************************************************************************************************
- (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
@@ -242,7 +242,7 @@ EVS mono is default, for IVAS choose one of the following: -stereo, -ism, -sba,
-dtx D : Activate DTX mode, D = (0, 3-100) is the SID update rate
where 0 = adaptive, 3-100 = fixed in number of frames, default is deactivated
-dtx : Activate DTX mode with a SID update rate of 8 frames
- Note: DTX is supported in EVS, stereo, ISM, MASA, and SBA up to 80kbps
+ Note: DTX is supported on all bitrates for EVS, stereo, ISM, and MASA, and up to 80 kbps for SBA.
-rf p o : Activate channel-aware mode in EVS for WB and SWB signal at 13.2kbps,
where FEC indicator, p: LO or HI, and FEC offset, o: 2, 3, 5, or 7 in number of frames.
Alternatively p and o can be replaced by a rf configuration file with each line
@@ -385,16 +385,26 @@ Options:
The usage of the "ISAR_post_rend" program is as follows:
--------------------------------------------------------
-Usage: ISAR_post_rend [options]
-
-Options:
---------
--i File : Input File (input file is bitstream if format is BINAURAL_SPLIT_CODED, or PCM/WAV file if format is BINAURAL_SPLIT_PCM)
--if Format : Input Format of input (BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM)
--im File : Coded metadata File for BINAURAL_SPLIT_PCM input format
--o File : Output Audio File in BINAURAL format
--fs : Input sampling rate in kHz (48)
--prbfi File : BFI File
+Usage: ISAR_post_rend [options] -i -if -o
+
+Mandatory parameters:
+---------------------
+-i File : Path to the input File (WAV or raw PCM for BINAURAL_SPLIT_PCM format, or encoded intermediate-format data for BINAURAL_SPLIT_CODED format)
+-if Format : Audio format of input File (BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM or RTPDUMP)
+-o File : Path to the output File
+
+Options :
+------- -
+-im File : Path to the coded metadata File (mandatory for BINAURAL_SPLIT_PCM format)
+-fs : Input sampling rate in kHz (16, 32, 48) (mandatory for raw PCM input Files)
+-T File : Head rotation trajectory File for simulation of head tracking
+-prbfi File : Split rendering BFI (Bad Frame Indicator) File
+-no_delay_cmp : Turn off delay compensation
+-q : Quiet mode - limit printouts to terminal
+-l : List supported audio formats of input File
+-fr L : Render frame size in ms L=(5, 10, 20), default is 20
+-s File : Path to the split rendering SDP init params File (mandatory for RTPDUMP format)
+-h : Show this help message and exit
The usage of the "ambi_converter" program is as follows: