diff --git a/apps/decoder.c b/apps/decoder.c index c3a0a6c4b1a9cdf2d06e82cdfe5b681b18b463c6..d6b189ccf85f0ca9e7668af84572b6a53744ee5b 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -38,6 +38,7 @@ #include "bitstream_reader.h" #include "evs_rtp_payload.h" #include "ism_file_writer.h" +#include "ivas_rtp_file.h" #include "jbm_file_writer.h" #include "hrtf_file_reader.h" #include "ls_custom_file_reader.h" @@ -50,7 +51,6 @@ #include "vector3_pair_file_reader.h" #include "wmc_auto.h" #include "stl.h" -#include "ivas_rtp_file.h" #define WMC_TOOL_SKIP @@ -164,19 +164,7 @@ typedef struct static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); static void usage_dec( void ); static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); -static ivas_error decodeVoIP( - DecArguments arg, - BS_READER_HANDLE hBsReader, - IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, - RotFileReader *headRotReader, - RotFileReader *externalOrientationFileReader, - RotFileReader *refRotReader, - Vector3PairFileReader *referenceVectorReader, - ObjectEditFileReader *objectEditFileReader, - ISAR_SPLIT_REND_BITS_DATA *splitRendBits, - IVAS_RENDER_CONFIG_DATA *renderConfig, - IVAS_DEC_HANDLE *phIvasDec, - int16_t *pcmBuf ); +static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_RENDER_CONFIG_DATA *renderConfig, IVAS_DEC_HANDLE *phIvasDec, int16_t *pcmBuf ); static ivas_error load_hrtf_from_file( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, const IVAS_AUDIO_CONFIG OutputConfig, const int32_t output_Fs ); static void do_object_editing_fx( IVAS_EDITABLE_PARAMETERS *editableParameters, ObjectEditFileReader *objectEditFileReader ); static ivas_error restartDecoder( IVAS_DEC_HANDLE *phIvasDec, const IVAS_DEC_MODE decMode, DecArguments *arg, IVAS_RENDER_CONFIG_DATA *renderConfig, IVAS_CUSTOM_LS_DATA *hLsCustomData ); @@ -426,7 +414,6 @@ int main( asked_frame_size = arg.renderFramesize; 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, @@ -497,7 +484,6 @@ int main( if ( arg.renderConfigEnabled ) { - /* sanity check */ if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && @@ -564,6 +550,7 @@ int main( } } } + if ( ( error = RenderConfigReader_getDirectivity( renderConfigReader, arg.directivityPatternId, renderConfig.directivity_fx ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Failed to get directivity patterns for one or more of IDs: %d %d %d %d\n\n", arg.directivityPatternId[0], arg.directivityPatternId[1], arg.directivityPatternId[2], arg.directivityPatternId[3] ); @@ -691,11 +678,7 @@ int main( if ( arg.voipMode ) { - error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, - &splitRendBits, - &renderConfig, - &hIvasDec, - pcmBuf ); + error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, &renderConfig, &hIvasDec, pcmBuf ); } else { @@ -2796,6 +2779,7 @@ static ivas_error decodeVoIP( int32_t delayTimeScale = -1; int16_t i; IVAS_DEC_HANDLE hIvasDec = *phIvasDec; + bool restartNeeded; IVAS_RTP ivasRtp = { 0 }; IVAS_RTP srRtp = { 0 }; @@ -2876,7 +2860,6 @@ static ivas_error decodeVoIP( goto cleanup; } - #ifdef SUPPORT_JBM_TRACEFILE if ( arg.jbmTraceFilename != NULL ) { @@ -2908,7 +2891,9 @@ static ivas_error decodeVoIP( else { auPtr = au; /* might have been set to RTP packet in prev call */ + error = IVAS_RTP_ReadNextFrame( &ivasRtp, auPtr, &auSize, &rtpTimeStamp, &rtpSequenceNumber, &nextPacketRcvTime_ms, NULL, &qBit ); + initialTsOffsetSystemAndRTP = rtpTimeStamp - systemTime_ms * 16; /* For time mapping */ /* EVS RTP payload format has timescale 16000, JBM uses 1000 internally */ @@ -3105,6 +3090,7 @@ static ivas_error decodeVoIP( else { auPtr = au; /* might have been set to RTP packet in prev call */ + error = IVAS_RTP_ReadNextFrame( &ivasRtp, au, &auSize, &rtpTimeStamp, &rtpSequenceNumber, &nextPacketRcvTime_ms, NULL, &qBit ); /* IVAS RTP payload format has timescale 16000, JBM uses 1000 internally */ @@ -3294,22 +3280,8 @@ static ivas_error decodeVoIP( /* Once good frame decoded, catch up */ if ( decodedGoodFrame ) { - if ( ( error = initOnFirstGoodFrame( hIvasDec, - arg, - numInitialBadFrames, - &nOutSamples, - &vec_pos_len, - delayNumSamples_orig, - &delayNumSamples, - &delayTimeScale, - &bsFormat, - &afWriter, - &masaWriter, - ismWriters, - &nOutChannels, - &numObj, - &srRtp, - &splitRendWriter ) ) != IVAS_ERR_OK ) + if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, &vec_pos_len, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, + &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, &srRtp, &splitRendWriter ) ) != IVAS_ERR_OK ) { goto cleanup; } @@ -3411,6 +3383,7 @@ static ivas_error decodeVoIP( srInfo.bitrateKbps = splitRendBits->bits_written * 1000 / splitRendBits->codec_frame_size_ms; srInfo.codec = ( splitRendBits->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS ) ? IVAS_SR_TRANSPORT_LC3PLUS : IVAS_SR_TRANSPORT_LCLD; srInfo.codecFrameSizeMs = (uint32_t) splitRendBits->codec_frame_size_ms; + if ( ( error = IVAS_RTP_WriteNextFrame( &srRtp, splitRendBits->bits_buf, &srInfo, (int16_t) splitRendBits->bits_written, false, false ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError %s while pushing SR audio bitstream to RTP pack\n", ivas_error_to_string( error ) ); @@ -3661,7 +3634,8 @@ static void do_object_editing_fx( editableParameters->ism_metadata[obj_idx].elevation_fx = (Word32) ( readInfo->obj_ele[obj_idx] * 4194304 ); /* Q22 */ } } - /* object direction editing only for diegetic objects */ + + /* object orientation editing only for diegetic objects */ if ( readInfo->obj_yaw_edited[obj_idx] ) { if ( readInfo->obj_yaw_relative[obj_idx] ) @@ -3691,14 +3665,10 @@ static void do_object_editing_fx( { if ( readInfo->obj_radius_relative[obj_idx] ) { -/* radius: apply relative edit + saturation */ -#define SQ 9 - -#define SHIFT_DUE_TO_SQxSQ ( SQ - ( SQ + SQ + 1 - 16 ) ) /* ^shift by 6 == mult by 2^6 = 64.0 */ - - Word32 L_tmp1 = L_mult( editableParameters->ism_metadata[obj_idx].radius_fx, (Word16) ( readInfo->obj_radius[obj_idx] * ( 1L << ( SQ ) ) ) ); /*SQ*SQ*/ - Word32 L_tmp2 = L_shl_sat( L_tmp1, SHIFT_DUE_TO_SQxSQ ); /*shift back to Q(9+16)*/ - Word16 temp_radius = round_fx( L_tmp2 ); /* Q25 -> Q9 */ + /* radius: apply relative edit + saturation */ + Word32 L_tmp1 = L_mult( editableParameters->ism_metadata[obj_idx].radius_fx, (Word16) ( readInfo->obj_radius[obj_idx] * ( 1L << ( 9 ) ) ) ); /*SQ*SQ where SQ=9*/ + Word32 L_tmp2 = L_shl_sat( L_tmp1, ( 9 - ( 9 + 9 + 1 - 16 ) ) /* ^shift by 6 == mult by 2^6 = 64.0 */ ); /*shift back to Q(9+16)*/ + Word16 temp_radius = round_fx( L_tmp2 ); /* Q25 -> Q9 */ temp_radius = s_max( s_min( temp_radius, OBJ_EDIT_RADIUS_MAX_FX ), 0 ); /* L_tmp2 is in S31Q25 stored in a signed Word32 @@ -3968,9 +3938,10 @@ static ivas_error restartDecoder( hIvasDec = *phIvasDec; - uint16_t aeID = arg->aeSequence.count > 0 ? arg->aeSequence.pID[0] : 65535; + uint16_t aeID = arg->aeSequence.count > 0 ? arg->aeSequence.pID[0] : IVAS_DEFAULT_AEID; 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, 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 ) @@ -3985,7 +3956,6 @@ static ivas_error restartDecoder( goto cleanup; } - if ( arg->voipMode ) { if ( ( error = IVAS_DEC_EnableVoIP( hIvasDec, 60, arg->inputFormat ) ) != IVAS_ERR_OK ) @@ -4034,5 +4004,4 @@ cleanup: return error; } - #undef WMC_TOOL_SKIP diff --git a/apps/encoder.c b/apps/encoder.c index 1eecfdd5155450fa0cf398e5c1975da23d7f8787..1599a9db555ba1a2daa2671ebd98c689751f02c4 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -43,9 +43,10 @@ #include "ism_file_reader.h" #include "jbm_file_reader.h" #include "masa_file_reader.h" -#include "wmc_auto.h" #include "rotation_file_reader.h" #include "ivas_rtp_file.h" +#include "wmc_auto.h" + #ifdef DEBUG_FORCE_DIR /* Windows does not define the S_ISREG and S_ISDIR macros in stat.h, so we do. @@ -1867,7 +1868,6 @@ static bool parseCmdlIVAS_enc( i++; } - /*-----------------------------------------------------------------* * Option not recognized *-----------------------------------------------------------------*/ diff --git a/apps/encoder_fmtsw.c b/apps/encoder_fmtsw.c index 9ab7b017b80a2500baf8f3602ed389f454323a5f..1b0b931367741edd3023b57f1b2941bec47f2646 100644 --- a/apps/encoder_fmtsw.c +++ b/apps/encoder_fmtsw.c @@ -43,9 +43,10 @@ #include "ism_file_reader.h" #include "jbm_file_reader.h" #include "masa_file_reader.h" -#include "wmc_auto.h" #include "rotation_file_reader.h" #include "ivas_rtp_file.h" +#include "wmc_auto.h" + #ifdef DEBUG_FORCE_DIR /* Windows does not define the S_ISREG and S_ISDIR macros in stat.h, so we do. @@ -185,6 +186,7 @@ static IVAS_ENC_FORCED_MODE parseForcedMode( char *forcedModeChar ); static void str2arg( char *str, int *argc_local, char *argv_local[] ); static int encoder_main( int argc, char *argv[], IVAS_RTP *ivasRtp, int init_RtpWriter ); + /*------------------------------------------------------------------------------------------* * main() * @@ -263,6 +265,7 @@ int main( cleanup: IVAS_RTP_Term( &ivasRtp ); + if ( FmtSWFile ) { fclose( FmtSWFile ); @@ -1968,7 +1971,6 @@ static bool parseCmdlIVAS_enc( i++; } - /*-----------------------------------------------------------------* * Option not recognized *-----------------------------------------------------------------*/ diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index 63877b4e680ddbaf7d28a5b96021391dee276432..6ccf204ceb221c7c11035b9f01fb93b9c191853e 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -229,6 +229,7 @@ static IVAS_AUDIO_CONFIG parseAudioConfig( const char *configString, bool *srRtp static void convertOutputBuffer( const Word32 *fixedBuffer, Word16 q, const int16_t numSamplesPerChannel, const int16_t numChannels, int16_t *intBuffer ); + /*------------------------------------------------------------------------------------------* * Local functions *------------------------------------------------------------------------------------------*/ @@ -399,6 +400,7 @@ static IVAS_AUDIO_CONFIG parseAudioConfig( *srRtp = true; return IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED; } + return IVAS_AUDIO_CONFIG_INVALID; } @@ -456,6 +458,7 @@ static CmdlnArgs defaultArgs( clearString( args.inputFilePath ); clearString( args.outputFilePath ); clearString( args.srParamsFilePath ); + args.sampleRate = 0; args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_INVALID; @@ -561,7 +564,6 @@ static void parseOption( fprintf( stderr, "Unknown or invalid option for frame size: %s\n", optionValues[0] ); exit( -1 ); } - break; case CmdLnOptionId_srParamsFile: assert( numOptionValues == 1 ); @@ -695,6 +697,7 @@ static void convertOutputBuffer( return; } + static void trim( char *str ) { char c; @@ -712,6 +715,7 @@ static void trim( char *str ) str[w] = 0; } + static ivas_error parseSRParamsFile( const char *srParamsFilePath, const char *rtpFilePath, diff --git a/apps/renderer.c b/apps/renderer.c index 7137efd83570f6cf8da805c8c1745c1ee6805720..4f05f6f4c8382ca135f0ca8580501898412c32c5 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -228,7 +228,7 @@ typedef enum CmdLnOptionId_syncMdDelay, CmdLnOptionId_directivityPatternId, CmdLnOptionId_acousticEnvironmentId, - CmdLnOptionId_roomSize, + CmdLnOptionId_roomSize } CmdLnOptionId; static const CmdLnParser_Option cliOptions[] = { @@ -1167,8 +1167,6 @@ int main( if ( args.renderConfigFilePath[0] != '\0' ) { - - /* sanity check */ if ( ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) && @@ -1203,7 +1201,7 @@ int main( } if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - aeID = args.aeSequence.count > 0 ? args.aeSequence.pID[0] : 65535; + aeID = args.aeSequence.count > 0 ? args.aeSequence.pID[0] : IVAS_DEFAULT_AEID; if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, aeID, &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) { if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) @@ -1239,7 +1237,6 @@ int main( goto cleanup; } - /* Set reverb room size if specified */ if ( args.reverbRoomSize != IVAS_ROOM_SIZE_AUTO ) { @@ -1532,12 +1529,7 @@ int main( audioWriter = NULL; } - if ( ( error = IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, - &bitsBuffer.config.codec, - &bitsBuffer.config.poseCorrection, - &bitsBuffer.config.codec_frame_size_ms, - &bitsBuffer.config.isar_frame_size_ms, - &bitsBuffer.config.lc3plus_highres ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms, &bitsBuffer.config.isar_frame_size_ms, &bitsBuffer.config.lc3plus_highres ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_REND_GetSplitRendBitstreamHeader(): %s!\n", ivas_error_to_string( error ) ); goto cleanup; @@ -2638,7 +2630,9 @@ static bool parseAcousticEnvironmentIds( AcousticEnvironmentSequence *aeSequence ) { char config_string[RENDERER_MAX_METADATA_LINE_LENGTH]; + strncpy( config_string, value, RENDERER_MAX_METADATA_LINE_LENGTH ); + if ( !is_digits_only( config_string ) ) { aeidFileReader *aeidReader = NULL; @@ -3107,6 +3101,7 @@ void getMetadataFromFileReader( fprintf( stderr, "\nError (%s) while reading ISM metadata from: %s\n\n", ivas_error_to_string( error ), IsmFileReader_getFilePath( ismReader ) ); exit( -1 ); } + objectMetadataBuffer->positions[objIdx].azimuth_fx = ismMetadata.azimuth_fx; objectMetadataBuffer->positions[objIdx].elevation_fx = ismMetadata.elevation_fx; objectMetadataBuffer->positions[objIdx].radius_fx = ismMetadata.radius_fx; diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index b116ef6c7f94344ea0ccdab496407dcf89ef3672..fef47cf168cf0c6412f411d8974e31d7edb05d1c 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -988,7 +988,7 @@ Word32 div_w( Word32 L_num, Word32 L_den ) } -Word32 div_w_newton( Word32 num, Word32 den ); +static Word32 div_w_newton( Word32 num, Word32 den ); /* Table of 256 precalculated estimates to be used by the "div_w_newton" function using the Newton/Raphson method. @@ -1283,7 +1283,7 @@ static Word32 L_dmult( Word32 L_var1, Word32 L_var2 ) * BASOP weights: 24 (incl. L_dmult) */ -Word32 div_w_newton( Word32 num, Word32 den ) +static Word32 div_w_newton( Word32 num, Word32 den ) { Word32 x0, x1, x2, x3, diff, result; diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index 1df2c8010ef4d09756693ec42b69189f688c7c0f..c0f6df8cd0235135dedd8acc4cc59514fda978c0 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -328,7 +328,6 @@ Word16 BASOP_Util_Divide3232_Scale( Word32 x, /*!< i : Numerator*/ Word32 y, /*!< i : Denominator*/ Word16 *s ); /*!< o : Additional scalefactor difference*/ - Word32 BASOP_Util_Divide3232_Scale_newton( Word32 x, /*!< i : Numerator*/ Word32 y, /*!< i : Denominator*/ Word16 *s ); /*!< o : Additional scalefactor difference*/ diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index dfd05b70d98396864c463ac8498b42a1881dbe22..1a85899d30a2d907a195fc137833e71bed7a4e10 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -171,6 +171,8 @@ void ivas_initFdCngCom_fx( HANDLE_FD_CNG_COM hFdCngCom, Word16 scale ) return; } + + void initFdCngCom( HANDLE_FD_CNG_COM hFdCngCom, Word16 scale ) { /* Calculate CLDFB scaling factor */ diff --git a/lib_com/hp50_fx.c b/lib_com/hp50_fx.c index bef9956e43ffa27bd6121a905772340db5e598c8..382755b8eb5415c8f0d74d0ee229e54cfb0acc25 100644 --- a/lib_com/hp50_fx.c +++ b/lib_com/hp50_fx.c @@ -316,10 +316,12 @@ void hp20_fx_32_opt( prescale = s_min( prescale, diff ); prescale = sub( 1 + HP20_FX_COEFF_SCALE, prescale ); + test(); if ( EQ_16( prescale_current_frame, 1 + HP20_FX_COEFF_SCALE - 31 ) || // signal_fx buffer contains only zeros, so use the mem_fx scale_factor instead LT_16( prescale_current_frame, prescale ) ) // To avoid overflow in the subsequent shr() scaling for W_y1, W_y2, x2, and x1 calculations before the for loop. { prescale_current_frame = prescale; + move16(); } diff = sub( prescale, prescaleOld ); diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index b4411fe50febb1c360e569c988fc2b04e206c903..9274be5b4f879d45936b1005eb0cf89b8cd1bd0e 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -202,8 +202,6 @@ typedef enum #define EDIT_GAIN_MIN_Q12 258 /* Minimum allowed object gain edit with parametric modes in Q12: 0.0630957f, -24 dB */ #define EDIT_GAIN_MAX_Q12 16306 /* Maximum allowed object gain edit in Q12: 3.9810719f, +12 dB */ - - typedef enum { TC_BUFFER_MODE_RENDERER, diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index bcc0c26f1317ae58ad3b105ed34120d462456be3..092bc8df5385e897d625a28fe8b28d19c91f298b 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -132,11 +132,9 @@ extern const SpectrumWarping sw25600Hz[]; /* PsychLPC */ extern const SpectrumWarping sw32000Hz[]; /* PsychLPC */ extern const MDCTStereoBands_config mdctStereoBands_32000_640[]; - extern const Word16 mdct_stereo_dtx_coherence_bandlengths[MDCT_ST_DTX_NUM_COHERENCE_BANDS]; extern const Word16 get_next_index_4_by_15[16]; - /*----------------------------------------------------------------------------------* * Stereo DTX ROM tables *----------------------------------------------------------------------------------*/ diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c index f0ae9f8605f0da400355b3df2ce15ee083f64e3c..3878adfeae4a4cbd7c1bf04ff490a8f859a1704a 100644 --- a/lib_com/ivas_rom_com_fx.c +++ b/lib_com/ivas_rom_com_fx.c @@ -549,6 +549,7 @@ const MDCTStereoBands_config mdctStereoBands_32000_640[] = const Word16 mdct_stereo_dtx_coherence_bandlengths[MDCT_ST_DTX_NUM_COHERENCE_BANDS] = { 6, /* 8 - MDCT_ST_DTX_FIRST_BAND_OFFSET */ 8, 16, 16, 80 }; + /* dequantization table for coherence */ const Word16 get_next_index_4_by_15[16] = { 0, 2184, 4369, 6553, 8738, 10922, 13107, 15291, 17476, 19660, 21845, 24029, 26214, 28398, 30583, 32767 diff --git a/lib_com/options.h b/lib_com/options.h index 708e7f6334a83fd61299f17359b1e0e3e73a72d5..52e39ec1576f979ce2d9c9bfbcb6787e92d920b3 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -38,49 +38,65 @@ #define OPTIONS_H /* clang-format off */ + /* ################### Start compiler switches ######################## */ -/* ################### Start DEBUGGING switches ######################## */ +#define SUPPORT_JBM_TRACEFILE /* support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */ + +/* #################### End compiler switches ######################### */ -/*#define DEBUGGING*/ /* Allows debugging message to be printed out during runtime */ -#ifdef DEBUGGING -/*#define DBG_BITSTREAM_ANALYSIS*/ /* Write bitstream with annotations to a text file */ -#define DEBUG_MODE_INFO /* Define to output most important parameters to the subdirectory "res/" */ -#define DEBUG_MODE_INFO_TWEAK /* Enable command line switch to specify subdirectory for debug info output inside "./res/" */ -#define DEBUG_FORCE_MDCT_STEREO_MODE /* Force stereo mode decision for MDCT stereo: -stereo 3 1 forces L/R coding and -stereo 3 2 forces full M/S coding */ -/*#define DEBUG_FORCE_DIR*/ /* Force modes/parameters by reading from external binary files */ -/*#define DBG_WAV_WRITER*/ /* Enable dbgwrite_wav() function for generating ".wav" files */ -#define SUPPORT_FORCE_TCX10_TCX20 /* VA: Enable -force tcx10|tcx20 command-line option */ -/*#define DEBUG_MODE_JBM */ /* define to output JBM relevant parameters */ -#endif -#define SUPPORT_JBM_TRACEFILE /* Support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */ +/* ################### Start DEBUGGING switches ######################## */ -/*#define WMOPS*/ /* Activate complexity and memory counters */ -#ifdef WMOPS -#define WMOPS_PER_FRAME /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ -#define WMOPS_DETAIL /* Output detailed complexity printout for every function. Increases runtime overhead */ -#define WMOPS_WC_FRAME_ANALYSIS /* Output detailed complexity analysis for the worst-case frame */ -/*define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */ +#ifndef RELEASE +/*#define DEBUGGING*/ /* Activate debugging part of the code */ #endif +/*#define WMOPS*/ /* Activate complexity and memory counters */ +/*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ +/*#define WMOPS_DETAIL*/ /* Output detailed complexity printout for every function. Increases runtime overhead */ +/*#define WMOPS_WC_FRAME_ANALYSIS*/ /* Output detailed complexity analysis for the worst-case frame */ +/*define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */ -/*#define DISABLE_LIMITER*/ +#ifdef DEBUGGING +/*#define DBG_BITSTREAM_ANALYSIS*/ /* Write bitstream with annotations to a text file */ +#define DEBUG_MODE_INFO /* Define to output most important parameters to the subdirectory "res/" */ +#define DEBUG_MODE_INFO_TWEAK /* Enable command line switch to specify subdirectory for debug info output inside "./res/" */ +#define DEBUG_FORCE_MDCT_STEREO_MODE /* Force stereo mode decision for MDCT stereo: -stereo 3 1 forces L/R coding and -stereo 3 2 forces full M/S coding */ +/*#define DEBUG_FORCE_DIR*/ /* Force modes/parameters by reading from external binary files */ +/*#define DBG_WAV_WRITER*/ /* Enable dbgwrite_wav() function for generating ".wav" files */ +#define SUPPORT_FORCE_TCX10_TCX20 /* VA: Enable -force tcx10|tcx20 command-line option */ +/*#define DEBUG_MODE_JBM */ /* define to output JBM relevant parameters */ /*#define DEBUG_APA_SILENCE_NON_SCALED*/ /* Switch APA into mode that replaces contents of non-scaled frames with silence. Useful for identifying scaled regions in the audio output of the decoder */ -/* #################### End DEBUGGING switches ############################ */ +#endif /* DEBUGGING */ +/* #################### End DEBUGGING switches ############################ */ -/* ################### Start FIXES switches ########################### */ -/*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -#define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */ -#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.*/ +/* keep as part of options.h */ +/*#define DISABLE_LIMITER*/ -/* ################### End FIXES switches ########################### */ +/* ################### Start MAINTENANCE switches ########################### */ -/* #################### Start BASOP porting switches ############################ */ +/* ################### Start BE switches ################################# */ +/* only BE switches wrt wrt. TS 26.251 V3.0 */ +/*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ +#define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */ +#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. */ -/* #################### End BASOP porting switches ############################ */ + +/* #################### End BE switches ################################## */ + +/* #################### Start NON-BE switches ############################ */ +/* any switch which is non-be wrt. TS 26.251 V3.0 */ + + + +/* ##################### End NON-BE switches ########################### */ + +/* ################## End MAINTENANCE switches ######################### */ + +/* clang-format on */ #endif diff --git a/lib_com/preemph_fx.c b/lib_com/preemph_fx.c index 8b0657bd52cd161a5844b0c90239cada5e31473c..9631c68596fe1934049cd1badd965b0801156e87 100644 --- a/lib_com/preemph_fx.c +++ b/lib_com/preemph_fx.c @@ -39,6 +39,7 @@ void preemph_copy_fx( return; } + void preemph_copy_32fx2( const Word16 x[], /* i : input signal Qx */ Word32 y[], /* o : output signal Qx-1*/ @@ -65,6 +66,7 @@ void preemph_copy_32fx2( return; } + /*-------------------------------------------------------------* * preemph_ivas_fx() * diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 40136fe0ae5b11d60ae1925a40ccc2d3f363b1b8..bf24d493e29618fcce60ee39e5fcd9933a62dbb0 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -2689,6 +2689,7 @@ void lag_wind_32( // 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_copy_fx( const Word16 x[], /* i : i signal Qx */ Word16 y[], /* o : output signal Qx */ diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index 8e1cbb7b91c9f5c6a506ca099c40e750feb924f6..497e76ec8fc7568f18097ac25642d5a55244396e 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -2140,6 +2140,7 @@ static void ivas_subst_spec_fx( move16(); tmp = sub_sat( mult_r( re, cos_F ), mult_r( im, sin_F ) ); im = add_sat( mult_r( re, sin_F ), mult_r( im, cos_F ) ); + IF( LT_16( alpha[k], 32766 ) ) { alpha_local = mag_chg_local; diff --git a/lib_dec/TonalComponentDetection_fx.c b/lib_dec/TonalComponentDetection_fx.c index b1ffd7580f7e80d40bb92bf3996b08c2f454f696..be1245c9ec8b32dccd9694c6b0e0b5dba58da923 100644 --- a/lib_dec/TonalComponentDetection_fx.c +++ b/lib_dec/TonalComponentDetection_fx.c @@ -446,7 +446,6 @@ static void getEnvelope( assert( ( nFilterLength >= 7 ) && ( nFilterLength <= 23 ) && ( nFilterLength % 2 == 1 ) ); - sum = L_deposit_l( 0 ); level = 31089 /*LEVEL_ABOVE_ENVELOPE Q12*/; /*Q12*/ move16(); @@ -455,6 +454,7 @@ static void getEnvelope( { sum = L_add_sat( sum, powerSpec[i] ); /*powerSpec_exp*/ } + /* No need for PTR_INIT for powerSpec[i+n2] as we continue from the previous loop */ FOR( i = 0; i < n1; i++ ) { diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 0f8cec8e0f4c50a5b8295b2deb83c5fb930c21cd..2c62fd65340c904f09cf44af0e344f72e34496fa 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -3133,7 +3133,6 @@ void generate_comfort_noise_dec_ivas_fx( } } - /* Remaining FFT bins are set to zero */ set32_fx( fftBuffer + shl( hFdCngCom->stopFFTbin, 1 ), 0, sub( hFdCngCom->fftlen, shl( hFdCngCom->stopFFTbin, 1 ) ) ); set16_fx( fftBuffer_temp_exp + shl( hFdCngCom->stopFFTbin, 1 ), 0, sub( hFdCngCom->fftlen, shl( hFdCngCom->stopFFTbin, 1 ) ) ); @@ -5503,6 +5502,7 @@ void FdCngDecodeDiracMDCTStereoSID_fx( lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, sts[ch]->preemph_fac ); } + FOR( i = 0; i < MDCT_ST_DTX_NUM_COHERENCE_BANDS; i++ ) { sts[0]->hFdCngDec->hFdCngCom->coherence_fx[i] = 0; @@ -5511,7 +5511,6 @@ void FdCngDecodeDiracMDCTStereoSID_fx( move16(); } - IF( EQ_16( hCPE->nchan_out, 1 ) ) { /* create proper M noise shape in channel zero after gains have been applied */ diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 37aa3747fc9d96f7d6300e0ec52cb1f1fe3fd72f..c4014731a21f82fd02dc5f469edac7462837eaad 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -516,6 +516,12 @@ ivas_error ivas_core_dec_fx( Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, add( M, 1 ), sub( norm_s( sub( st->hFdCngDec->hFdCngCom->A_cng[0], 1 ) ), 3 ) ); // Qx } + test(); + test(); + test(); + test(); + test(); + test(); IF( ( EQ_32( st->last_core, TCX_10_CORE ) || EQ_32( st->last_core, TCX_20_CORE ) ) || // st->Q_syn_factor is set in TCX mode; otherwise, it may be uninitialized ( hCPE != NULL && ( GT_16( hCPE->element_mode, IVAS_CPE_DFT ) && EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && ( ( EQ_32( sts[0]->last_core, TCX_10_CORE ) || EQ_32( sts[0]->last_core, TCX_20_CORE ) ) ) ) ) ) // In this case, sts[1] gets its value from sts[0]. { @@ -524,6 +530,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 ) ) { return error; @@ -599,6 +606,7 @@ ivas_error ivas_core_dec_fx( } stereo_tcx_core_dec_fx( st, frameMode[n], output_16_fx[n], synth_16_fx[n], pitch_buf_fx[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hStereoCng, nchan_out, ivas_format ); + Copy_Scale_sig_16_32_DEPREC( output_16_fx[n], output_32_fx[n], output_frame, sub( Q11, st->Q_syn_factor ) ); // Q11 IF( st->hTcxDec ) diff --git a/lib_dec/ivas_decision_matrix_dec_fx.c b/lib_dec/ivas_decision_matrix_dec_fx.c index e0d9c6ac6f8a83b5e57d060b53bd16788534d8e4..4ba2a386af868d3e2704f59ad6af93f1bc593e0b 100644 --- a/lib_dec/ivas_decision_matrix_dec_fx.c +++ b/lib_dec/ivas_decision_matrix_dec_fx.c @@ -46,6 +46,7 @@ * Read ACELP signaling bits from the bitstream * Set extension layers *-----------------------------------------------------------------*/ + void ivas_decision_matrix_dec_fx( Decoder_State *st, /* i/o: decoder state structure */ Word16 *sharpFlag, /* o : formant sharpening flag */ @@ -125,6 +126,7 @@ void ivas_decision_matrix_dec_fx( { /* read channel coherence */ Word16 index; + index = get_next_indice_fx( st, 4 ); st->hFdCngDec->hFdCngCom->coherence_fx[0] = get_next_index_4_by_15[index]; move16(); diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 9ddcfe4e564a8edac2744eb5b095e1ac07dc2a4e..2e14f6b9dcbe3e31129764bc9164c5ac327b5524 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -3011,6 +3011,7 @@ void ivas_dirac_dec_render_sf_fx( /*-----------------------------------------------------------------* * Compute DirAC parameters at decoder side *-----------------------------------------------------------------*/ + IF( EQ_16( hDirAC->hConfig->dec_param_estim, TRUE ) ) { Copy( &hSpatParamRendCom->azimuth[md_idx][hDirAC->hConfig->enc_param_start_band], &azimuth[hDirAC->hConfig->enc_param_start_band], sub( hSpatParamRendCom->num_freq_bands, hDirAC->hConfig->enc_param_start_band ) ); @@ -3803,8 +3804,7 @@ void ivas_dirac_dec_render_sf_fx( } binRenderer_split_fx( st_ivas->hBinRenderer, st_ivas->hSplitBinRend, st_ivas->hCombinedOrientationData, hSpatParamRendCom->subframe_nbslots[subframe_idx], - Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, - hSpatParamRendCom->num_freq_bands, st_ivas->hDecoderConfig->nchan_out ); + Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hSpatParamRendCom->num_freq_bands, st_ivas->hDecoderConfig->nchan_out ); } ELSE { diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index de5d9e4707eb619e10ff2e38fbdc54431f34d629..64e1f817742e2b5edc035a969a8be4a3d67e9e64 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -282,6 +282,7 @@ ivas_error ivas_dec_get_format_fx( UWord8 masaRestartCandidate; masaRestartCandidate = 0; move16(); + /* read number of MASA transport channels */ k = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); IF( st_ivas->bit_stream[k - 1] ) @@ -292,6 +293,7 @@ ivas_error ivas_dec_get_format_fx( masaRestartCandidate = 1; move16(); } + st_ivas->nchan_transport = 2; move16(); element_mode_flag = 1; @@ -305,6 +307,7 @@ ivas_error ivas_dec_get_format_fx( masaRestartCandidate = 1; move16(); } + st_ivas->nchan_transport = 1; move16(); } @@ -1814,7 +1817,7 @@ ivas_error ivas_init_decoder_fx( IF( EQ_16( st_ivas->hDecoderConfig->Opt_RendConfigCustom, 0 ) ) { IVAS_DefaultReverbSize defaultReverbSize; - SWITCH( st_ivas->hDecoderConfig->Opt_RoomSize ) + SWITCH( st_ivas->hDecoderConfig->room_size ) { case IVAS_ROOM_SIZE_AUTO: SWITCH( st_ivas->ivas_format ) @@ -1897,7 +1900,6 @@ ivas_error ivas_init_decoder_fx( { st_ivas->nchan_transport = CPE_CHANNELS; move16(); - st_ivas->nSCE = 0; move16(); st_ivas->nCPE = 1; /* in stereo, there is always only one CPE */ @@ -3955,6 +3957,7 @@ static ivas_error doSanityChecks_IVAS( { return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified!" ); } + test(); test(); IF( ( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) && diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index a193cba2efce288879215194b4ab1c2b75272f97..1a29a7a2c4498c23f53ea075d02659144dd683c4 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -1259,6 +1259,7 @@ void ivas_ism_metadata_sid_dec_fx( idx = get_next_indice_fx( st0, nBits_coh ); hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx[0] = get_next_index_4_by_15[idx]; // Q15 move16(); + FOR( i = 1; i < MDCT_ST_DTX_NUM_COHERENCE_BANDS; i++ ) { hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx[i] = hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx[0]; diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index a342481a0ce8492aca79d7fe2bfdd4a66cfa32de..fadb2350d9ecff1732c31b46c3a182818e734243 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1010,7 +1010,6 @@ void ivas_ism_dec_digest_tc_fx( } ELSE { - test(); test(); test(); @@ -1036,8 +1035,8 @@ void ivas_ism_dec_digest_tc_fx( IF( st_ivas->hEFAPdata != NULL ) { - efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_azimuth_fx, elevation_fx, EFAP_MODE_EFAP ); + // TODO: align Q values properly IF( NE_32( st_ivas->hIsmMetaData[i]->edited_gain_fx, ONE_IN_Q29 ) ) { @@ -1814,7 +1813,8 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( IF( st_ivas->hISMDTX.dtx_flag ) { - Word32 energy_ratio_fx; /* Q30 */ + Word32 energy_ratio_fx; /* Q30 */ + energy_ratio_fx = L_mult0( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx[0], st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->coherence_fx[0] ); /* Q15 + Q15 -> Q30 */ hSpatParamRendCom->numSimultaneousDirections = 1; diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index c968e81b843a93e29e9f04f4a6a2977b87e34a57..5c60e89f3ca3cb93a8d4d41b6340c8673e1cea07 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1745,7 +1745,6 @@ ivas_error ivas_jbm_dec_render_fx( /* 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_SBA_LINEAR_ENC ) ) @@ -2612,6 +2611,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( { 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 ); @@ -2620,14 +2620,14 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( { 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 ) ) + + 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 @@ -4320,11 +4320,11 @@ void ivas_dec_prepare_renderer_fx( 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 ); - // TODO: check if tis is a bug in main already } } diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 8b691a2794e418f350d4b8589e264b5e9efb4fa6..af169985e1dee70ae407dc328791656961a80fb1 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -1243,6 +1243,7 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm_fx( Scale_sig32( Cldfb_ImagBuffer, num_cldfb_bands, sub( Q6, q_cldfb ) ); ivas_CLDFB_RINGBUF_GetByIdx( st_ivas->hSplitBinRend->hMultiBinCldfbData[n], &re, &im, sub( slot_idx, cldfb_slots ) ); + v_add_fx( re, Cldfb_RealBuffer, re, num_cldfb_bands ); v_add_fx( im, Cldfb_ImagBuffer, im, num_cldfb_bands ); } diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index 47eed0b127a6871ed473eeb0b10815d14b562e1f..c9a6e0d70c9d3ec33361133896f95466067ad078 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -188,6 +188,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( sub( st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n]->p_filter_length, st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n]->no_channels ), sub( q_cldfb, st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n]->Q_cldfb_state ) ); st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n]->Q_cldfb_state = q_cldfb; + FOR( slot_idx = 0; slot_idx < cldfb_slots; slot_idx++ ) { q_cldfb = q_in; @@ -197,6 +198,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( Scale_sig32( Cldfb_ImagBuffer, num_cldfb_bands, sub( Q6, q_cldfb ) ); ivas_CLDFB_RINGBUF_GetByIdx( st_ivas->hSplitBinRend->hMultiBinCldfbData[n], &re, &im, sub( slot_idx, cldfb_slots ) ); + v_add_fx( re, Cldfb_RealBuffer, re, num_cldfb_bands ); v_add_fx( im, Cldfb_ImagBuffer, im, num_cldfb_bands ); } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 16c164cc4c63d0526f89f1c979d787264fd727ac..15100622536e8915bf5662d9725672dac522a016 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1059,7 +1059,7 @@ typedef struct decoder_config_structure Word16 Opt_HRTF_binary; /* indicates whether HRTF binary file is used */ Word16 Opt_Headrotation; /* indicates whether head-rotation is used */ Word16 Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ - IVAS_ROOM_SIZE_T Opt_RoomSize; /* Selected room size */ + IVAS_ROOM_SIZE_T room_size; /* Selected room size */ IVAS_HEAD_ORIENT_TRK_T orientation_tracking; /* indicates orientation tracking type */ Word16 Opt_non_diegetic_pan; /* indicates diegetic or not */ Word16 non_diegetic_pan_gain_fx; /* non diegetic panning gain, Q15 */ diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index d721d426aead1e2c24555a9535a4c0e3c59ad0ba..6cf2d46a9e348ecd0a5f0e50ec2b85111ec9c441 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -327,11 +327,13 @@ void stereo_tcx_core_dec_fx( st->core = GetPLCModeDecision_ivas_fx( st ); /* Q0 */ move16(); } - IF( st->core != ACELP_CORE ) + + if ( st->core != ACELP_CORE ) { st->Q_syn_factor = 0; move16(); } + /*--------------------------------------------------------------------------------* * LPC envelope decoding *--------------------------------------------------------------------------------*/ @@ -570,6 +572,7 @@ void stereo_tcx_core_dec_fx( /* TCX decoder */ decoder_tcx_ivas_fx( st, prm, Aq_fx, Aind, &synth_fx[0], &synthFB_fx[0], &synth_q[0], bfi, 0, sba_dirac_stereo_flag ); + st->Q_syn_factor = sub( synth_q[0], st->Q_syn ); st->Q_syn = synth_q[0]; } @@ -629,6 +632,7 @@ void stereo_tcx_core_dec_fx( { TonalMDCTConceal_SaveTimeSignal_ivas_fx( st->hTonalMDCTConc, synthFB_fx, st->Q_syn, hTcxDec->L_frameTCX ); } + decoder_tcx_post_ivas_fx( st, synth_fx, synthFB_fx, st->Q_syn, Aq_fx, bfi, 0 ); IF( EQ_16( st->core, TCX_20_CORE ) ) diff --git a/lib_dec/jbm_pcmdsp_apa_fx.c b/lib_dec/jbm_pcmdsp_apa_fx.c index f33ca4b6610c360930c884c4a727d56aacb34b43..bdf896c115861d812953d38581eca9cd95ba85eb 100644 --- a/lib_dec/jbm_pcmdsp_apa_fx.c +++ b/lib_dec/jbm_pcmdsp_apa_fx.c @@ -127,7 +127,8 @@ struct apa_state_t UWord16 qualityred; /* quality reduction threshold */ UWord16 qualityrise; /* quality rising for adaptive quality thresholds */ - Word16 last_pitch; /* last pitch/sync position */ + Word16 last_pitch; /* last pitch/sync position */ + UWord16 bad_frame_count; /* # frames before quality threshold is lowered */ UWord16 good_frame_count; /* # scaled frames */ diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index bd0e430187c08fea79a167f718787a7d622b70dd..733aefa92f196338744c551da9e5e8c4bedcf118 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -35,8 +35,6 @@ #include "common_api_types.h" #include -#include "typedef.h" -#include "ivas_rtp_pi_data.h" /*---------------------------------------------------------------------* @@ -121,7 +119,7 @@ ivas_error IVAS_DEC_Configure( 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 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 */ @@ -339,6 +337,7 @@ ivas_error IVAS_DEC_isRestartNeeded( ); + /* Setter functions - apply changes to decoder configuration */ /*! r: error code */ @@ -520,6 +519,7 @@ ivas_error IVAS_DEC_FeedPiDataToDecoder( UWord32 numPiData /* i : number of PI data received in rtp packet */ ); + /* Utility functions */ /*! r: pointer to an error message string */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 7954afd6905c9883c97087679645df5cd5e54354..19613babc165207c5621e1766bba17deeb04e5bf 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -327,7 +327,6 @@ static ivas_error isar_set_split_rend_setup( move16(); move16(); - ISAR_PRE_REND_GetMultiBinPoseData( hSplitBinConfig, &hSplitBinRend->splitrend.multiBinPoseData, ( hCombinedOrientationData != NULL ) ? hCombinedOrientationData->sr_pose_pred_axis : DEFAULT_AXIS ); IF( hCombinedOrientationData != NULL ) @@ -356,7 +355,7 @@ static void init_decoder_config( hDecoderConfig->Opt_HRTF_binary = 0; hDecoderConfig->Opt_Headrotation = 0; hDecoderConfig->Opt_RendConfigCustom = 0; - hDecoderConfig->Opt_RoomSize = IVAS_ROOM_SIZE_AUTO; + hDecoderConfig->room_size = IVAS_ROOM_SIZE_AUTO; hDecoderConfig->orientation_tracking = IVAS_HEAD_ORIENT_TRK_NONE; hDecoderConfig->Opt_non_diegetic_pan = 0; hDecoderConfig->non_diegetic_pan_gain_fx = 0; // Q15 @@ -415,6 +414,7 @@ void IVAS_DEC_Close( /* destroy Split binaural renderer (ISAR) handle */ ivas_destroy_handle_isar( &( *phIvasDec )->st_ivas->hSplitBinRend ); + /* destroy IVAS decoder handles */ ivas_destroy_dec_fx( ( *phIvasDec )->st_ivas ); ( *phIvasDec )->st_ivas = NULL; } @@ -591,7 +591,7 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->orientation_tracking = orientation_tracking; hDecoderConfig->Opt_HRTF_binary = (Word16) hrtfReaderEnabled; hDecoderConfig->Opt_RendConfigCustom = (Word16) renderConfigEnabled; - hDecoderConfig->Opt_RoomSize = roomSize; + hDecoderConfig->room_size = roomSize; hDecoderConfig->Opt_non_diegetic_pan = (Word16) non_diegetic_pan_enabled; hDecoderConfig->non_diegetic_pan_gain_fx = non_diegetic_pan_gain_fx; // Q15 hDecoderConfig->Opt_delay_comp = (Word16) delayCompensationEnabled; @@ -790,6 +790,7 @@ static Word16 get_render_frame_size_samples( ) { Word16 tmp; + tmp = (Word16) Mpy_32_16_1( hDecoderConfig->output_Fs, INV_FR_P_S_MX_PRM_SPL_SBFR_Q15 ); IF( EQ_16( hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) @@ -824,7 +825,6 @@ ivas_error IVAS_DEC_GetRenderFramesizeSamples( Word16 *render_framesize /* o : render framesize in samples Q0 */ ) { - test(); test(); IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL || render_framesize == NULL ) @@ -4544,6 +4544,7 @@ ivas_error IVAS_DEC_SetEditableParameters( IF( GT_16( abs_s( sub( shr( extract_h( st_ivas->hIsmMetaData[obj]->edited_gain_fx ), Q1 ), shr( extract_h( hIvasEditableParameters.ism_metadata[obj].gain_fx ), Q1 ) ) ), OMASA_GAIN_EDIT_THR_Q12 ) ) // | gain_edit[obj] - gain_orig[obj] | > gain_threshold { st_ivas->hMasaIsmData->ism_gain_is_edited[obj] = 1; + /* Limit gain edit to a range of +12dB to -24dB with parametric OMASA mode */ test(); IF( GT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, EDIT_GAIN_MAX_Q29 ) ) @@ -4576,6 +4577,7 @@ ivas_error IVAS_DEC_SetEditableParameters( move32(); st_ivas->hIsmMetaData[obj]->edited_elevation_fx = hIvasEditableParameters.ism_metadata[obj].elevation_fx; move32(); + IF( EQ_16( ism_mode, ISM_MASA_MODE_DISC ) ) { st_ivas->hIsmMetaData[obj]->edited_yaw_fx = hIvasEditableParameters.ism_metadata[obj].yaw_fx; @@ -4585,6 +4587,7 @@ ivas_error IVAS_DEC_SetEditableParameters( st_ivas->hIsmMetaData[obj]->edited_radius_fx = hIvasEditableParameters.ism_metadata[obj].radius_fx; move16(); } + test(); IF( GT_32( hIvasEditableParameters.ism_metadata[obj].gain_fx, EDIT_GAIN_MAX_Q29 ) ) { @@ -4598,6 +4601,7 @@ ivas_error IVAS_DEC_SetEditableParameters( { st_ivas->hIsmMetaData[obj]->edited_gain_fx = hIvasEditableParameters.ism_metadata[obj].gain_fx; } + st_ivas->hIsmMetaData[obj]->non_diegetic_flag = hIvasEditableParameters.ism_metadata[obj].non_diegetic_flag; move16(); } @@ -4622,6 +4626,7 @@ ivas_error IVAS_DEC_SetEditableParameters( st_ivas->hMasaIsmData->gain_masa_edited_fx = shr( extract_h( hIvasEditableParameters.gain_bed_fx ), Q1 ); move16(); } + st_ivas->hMasaIsmData->masa_gain_is_edited = 1; } ELSE @@ -6313,6 +6318,7 @@ static ivas_error ivas_dec_init_split_rend( } } + test(); IF( EQ_16( cldfb_in_flag, 1 ) && ( EQ_16( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) ) { IF( ( st_ivas->hSplitBinRend->hCldfbDataOut = (ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL ) diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index acf0d322a6915ccd60eddcbe1711ebf81279401e..33e00aae1d6b6422ac3c30b6b12fb977f629615e 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -56,7 +56,6 @@ void bw_detect_fx( Word32 spect32[L_FRAME48k], in_win32[BWD_TOTAL_WIDTH]; Word16 e_tmp, f_tmp; Word32 L_tmp, sum32, L_tmp_q_shift; - Word32 L_tmp1, L_tmp2, L_tmp3; Word16 scale; Word16 ScalFac, ScalFacInv; @@ -122,6 +121,7 @@ void bw_detect_fx( cldfb_bin[0] = L_deposit_l( 1 ); move32(); } + L_tmp = BASOP_Util_Log2( cldfb_bin[0] ); /*(log2(660423549*2^(-31))/64)*2^31*/ L_tmp = Mpy_32_16_1( L_tmp, INV_LOG2_10 ); // instead of adding it to L_tmp_q_shift and then multiplying by INV_LOG2_10 ( to avoid saturation ). diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 15a412049eecf572961c0b5b787d06aabdc3847c..5075dd46cbf3b31293a9fd40614c2c047f775e38 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -2832,7 +2832,6 @@ void stereoFdCngCoherence_fx( pt_fftR += L_FFT; } - return; } @@ -3350,6 +3349,7 @@ void FdCngEncodeDiracMDCTStereoSID_fx( lpc_from_spectrum( hFdCngCom, hFdCngEnc->startBandDec, hFdCngEnc->stopFFTbinDec, sts[ch]->preemph_fac ); sts[ch]->hDtxEnc->last_CNG_L_frame = sts[ch]->L_frame; } + sts[0]->hFdCngEnc->hFdCngCom->coherence_fx[0] = 0; move16(); sts[1]->hFdCngEnc->hFdCngCom->coherence_fx[0] = 0; diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index c5eb5c67d0915dbec1a231934bb0e631b7d7ca16..033e13034c4c260f7bfc5fdec574d9a384a2bbb5 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -826,6 +826,7 @@ ivas_error ivas_cpe_enc_fx( move16(); stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, sts[0]->input32_fx, &out_start_ind, &out_end_ind, 0, input_Fs, input_Fs, 0, NULL ); + Scale_sig32( sts[0]->input32_fx - input_frame, add( out_start_ind, input_frame ), sub( Q15, sts[0]->q_old_inp32 ) ); // scaling initial part of the input buffer Scale_sig32( sts[0]->input32_fx + out_end_ind, sub( input_frame, out_end_ind ), sub( Q15, sts[0]->q_inp32 ) ); // scaling initial part of the input buffer sts[0]->q_inp32 = Q15; @@ -1048,6 +1049,7 @@ ivas_error ivas_cpe_enc_fx( } igf = getIgfPresent_fx( sts[n]->element_mode, L_mult0( sts[n]->bits_frame_nominal, FRAMES_PER_SEC ), bw, sts[n]->rf_mode ); /* Q0 */ move16(); + IF( ( error = IGF_Reconfig_fx( &sts[n]->hIGFEnc, igf, 0, L_mult0( sts[n]->bits_frame_nominal, FRAMES_PER_SEC ), bw, sts[n]->element_mode, sts[n]->rf_mode ) ) != IVAS_ERR_OK ) { diff --git a/lib_enc/ivas_spar_encoder_fx.c b/lib_enc/ivas_spar_encoder_fx.c index cb02abe16b2a64aee428d18c1deb79e6506d432b..9d5d48447ea698af47aef6754685c65616dac18c 100644 --- a/lib_enc/ivas_spar_encoder_fx.c +++ b/lib_enc/ivas_spar_encoder_fx.c @@ -929,6 +929,7 @@ static ivas_error ivas_spar_enc_process_fx( IF( hSpar->hFbMixer->fb_cfg->active_w_mixing == 0 ) { /*cross fade between new active W channels and old passive W channel*/ + test(); IF( EQ_16( dyn_active_w_flag, 1 ) || EQ_16( hSpar->hMdEnc->spar_md.prior_dyn_active_w_flag, 1 ) ) { IF( NE_16( hSpar->hMdEnc->spar_md.prior_dyn_active_w_flag, dyn_active_w_flag ) ) diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index d68976482a1c46f12c4eabeadb372a05cb60cf62..145bbeb6156b0d8b3d343ec5b02f59d12a4438fc 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -1919,6 +1919,7 @@ static void renorm_poc_fx( * * calculate energy *-------------------------------------------------------------------*/ + void calc_energy_fx( const Word32 src1_fx[], /* i : Lch input signal */ const Word32 src2_fx[], /* i : Rch input signal */ @@ -2419,6 +2420,7 @@ void stereo_dmx_evs_enc_fx( L_dmx_weight = L_deposit_h( dmx_weight ); L_tmp1 = L_deposit_l( BASOP_Util_Divide1616_Scale( hStereoDmxEVS->itd_fx, input_frame, &L_tmp1_e ) ); hPHA->phitd_fx = L_shl( L_tmp1, L_tmp1_e ); // Q15 + create_M_signal_fx( data_fx[0], data_fx[1], dmx_poc_data, L_dmx_weight, input_frame, hStereoDmxEVS->s_wnd_fx, hStereoDmxEVS->dmx_weight_fx, hStereoDmxEVS->pre_dmx_energy_fx, hStereoDmxEVS->pre_dmx_energy_fx_e, hStereoDmxEVS->aux_dmx_energy_fx, hStereoDmxEVS->aux_dmx_energy_fx_e, hPHA ); diff --git a/lib_enc/lib_enc_fx.c b/lib_enc/lib_enc_fx.c index eaf16ab5c97e028fc40c813a6299e0e10720388a..e2a63c4c750f8af41d2e61844ee06342de5d529f 100644 --- a/lib_enc/lib_enc_fx.c +++ b/lib_enc/lib_enc_fx.c @@ -540,8 +540,8 @@ ivas_error IVAS_ENC_FeedObjectMetadata( { return IVAS_ERR_INVALID_INDEX; } - error = ivas_set_ism_metadata_fx( hIvasEnc->st_ivas->hIsmMetaData[ismIndex], metadata.azimuth_fx, metadata.elevation_fx, metadata.radius_fx, metadata.yaw_fx, metadata.pitch_fx, metadata.non_diegetic_flag ); + error = ivas_set_ism_metadata_fx( hIvasEnc->st_ivas->hIsmMetaData[ismIndex], metadata.azimuth_fx, metadata.elevation_fx, metadata.radius_fx, metadata.yaw_fx, metadata.pitch_fx, metadata.non_diegetic_flag ); IF( error != IVAS_ERR_OK ) { return error; diff --git a/lib_isar/isar_splitRend_lcld_dec.c b/lib_isar/isar_splitRend_lcld_dec.c index 6f4512d9e191f3fadd9e59fd6a42c9e2d4537795..07017803ef8f5386e1d073717afa0add91e36581 100644 --- a/lib_isar/isar_splitRend_lcld_dec.c +++ b/lib_isar/isar_splitRend_lcld_dec.c @@ -230,6 +230,7 @@ void isar_splitBinLCLDDecProcess( /* continue concealing */ isar_splitBinRendPLC( hSplitBinLCLDDec->hSplitRendPLC, Cldfb_Out_Real_fx, Cldfb_Out_Imag_fx, (Word16) hSplitBinLCLDDec->iChannels, hSplitBinLCLDDec->iNumBlocks, hSplitBinLCLDDec->iNumIterations, GetDecodingFailedStatus( hSplitBinLCLDDec->psLCLDDecoder ), *Q_cldfb_final ); } + IF( AnyDecodingFailedPrev( hSplitBinLCLDDec->psLCLDDecoder ) ) { IF( GT_16( *Q_cldfb_final, hSplitBinLCLDDec->hSplitRendPLC->CldfbPLC_state.Q_Prev_Bin_fx ) ) @@ -245,8 +246,10 @@ void isar_splitBinLCLDDecProcess( } } } + *Q_cldfb_final = hSplitBinLCLDDec->hSplitRendPLC->CldfbPLC_state.Q_Prev_Bin_fx; } + /* cross-fade recovered frame into good frame */ isar_splitBinRendPLC_xf_fx( hSplitBinLCLDDec->hSplitRendPLC, Cldfb_Out_Real_fx, Cldfb_Out_Imag_fx, (Word16) hSplitBinLCLDDec->iChannels, hSplitBinLCLDDec->iNumBlocks, hSplitBinLCLDDec->iNumIterations, GetDecodingFailedStatus( hSplitBinLCLDDec->psLCLDDecoder ), GetDecodingFailedPrevStatus( hSplitBinLCLDDec->psLCLDDecoder ), *Q_cldfb_final ); } diff --git a/lib_isar/isar_splitRend_lcld_enc.c b/lib_isar/isar_splitRend_lcld_enc.c index 93e70c24f93472ab388272820dd4f7455a98bfa2..567cec0a4ccfda2c2f66167b0ebf3eb3fc886e32 100644 --- a/lib_isar/isar_splitRend_lcld_enc.c +++ b/lib_isar/isar_splitRend_lcld_enc.c @@ -39,11 +39,13 @@ #endif #include "wmc_auto.h" + /*------------------------------------------------------------------------- * Function isar_splitBinLCLDEncOpen() * * *------------------------------------------------------------------------*/ + ivas_error isar_splitBinLCLDEncOpen( ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc, const Word32 iSampleRate, @@ -145,11 +147,13 @@ void isar_splitBinLCLDEncClose( return; } + /*------------------------------------------------------------------------- * Function isar_splitBinLCLDEncProcess() * * *------------------------------------------------------------------------*/ + void isar_splitBinLCLDEncProcess( ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, Word32 *Cldfb_In_Real_fx[][CLDFB_NO_COL_MAX], /* i/o: Binaural signals, real part */ diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 2e5c0236c2febe2bf09dda804bbf641699fb1a9b..c91a4d08fa6a88b0e78bcf6adefc931dae707cf9 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -2157,6 +2157,7 @@ static void isar_SplitRenderer_quant_code( * * *------------------------------------------------------------------------*/ + static void isar_SplitRenderer_GetRotMd_fx( ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i/o: binaural renderer handle */ MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ @@ -3017,6 +3018,7 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( q_final = add( q_final, scale_factor ); Word16 exp_cldfb_re = sub( 31, q_final ); Word16 exp_cldfb_im = sub( 31, q_final ); + isar_rend_CldfbSplitPreRendProcess( hSplitBin->hBinHrSplitPreRend, headPosition, @@ -3048,6 +3050,7 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( move16(); pBits->isar_frame_size_ms = isar_frame_size_ms; move16(); + isar_splitBinLCLDEncProcess( hSplitBin->hSplitBinLCLDEnc, p_Cldfb_In_BinReal, @@ -3092,7 +3095,6 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( IF( !useLc3plus ) { // bit_len = ( SplitRendBitRate * hSplitBin->hSplitBinLCLDEnc->iNumBlocks * hSplitBin->hSplitBinLCLDEnc->iNumIterations ) / ( 16 * FRAMES_PER_SEC ); - bit_len = W_extract_l( W_mult0_32_32( SplitRendBitRate, L_mult0( hSplitBin->hSplitBinLCLDEnc->iNumBlocks, hSplitBin->hSplitBinLCLDEnc->iNumIterations ) ) ); tmp_e = 0; tmp_32 = BASOP_Util_Divide3232_Scale_newton( bit_len, L_mult0( 16, FRAMES_PER_SEC ), &tmp_e ); diff --git a/lib_isar/isar_stat.h b/lib_isar/isar_stat.h index 4b0b5ccda9a295ec7ab3d303a25e4d08798570f7..e91184f4c542f79e4afb046a6abf8693f11e8acf 100644 --- a/lib_isar/isar_stat.h +++ b/lib_isar/isar_stat.h @@ -242,7 +242,6 @@ typedef struct } ISAR_SPLIT_POST_REND_WRAPPER; - typedef struct { MULTI_BIN_REND_POSE_DATA multiBinPoseData; diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index f926b65a453f6dc78c4a8a461e56459e0851d3f9..be7c3ff1f72b1666b4ef6bc92fd7787295071c9a 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -541,7 +541,6 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( IF( splitCodec == ISAR_SPLIT_REND_CODEC_LCLD ) { // bit_len = ( SplitRendBitRate * hSplitBin->hSplitBinLCLDEnc->iNumBlocks * hSplitBin->hSplitBinLCLDEnc->iNumIterations ) / ( 16 * FRAMES_PER_SEC ); - bit_len = W_extract_l( W_mult0_32_32( SplitRendBitRate, L_mult0( hSplitBin->hSplitBinLCLDEnc->iNumBlocks, hSplitBin->hSplitBinLCLDEnc->iNumIterations ) ) ); tmp_e = 0; tmp_32 = BASOP_Util_Divide3232_Scale_newton( bit_len, L_mult0( 16, FRAMES_PER_SEC ), &tmp_e ); diff --git a/lib_rend/ivas_cldfb_ring_buffer.c b/lib_rend/ivas_cldfb_ring_buffer.c index 6a3ee58ddcbbdb7d4a5206537c25c6ddd11a3ddd..10e4be26539c611deecf1fed1ae9ef45f93e7a96 100644 --- a/lib_rend/ivas_cldfb_ring_buffer.c +++ b/lib_rend/ivas_cldfb_ring_buffer.c @@ -41,6 +41,7 @@ #endif #include "wmc_auto.h" + /*---------------------------------------------------------------------* * CLDFB ring-buffer functions needed in split-rendering outputs *---------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index b57f312be7a69650d27351fdbce66b543da2b583..c3e301530bf39704633ab6ba092f5c50e05da20c 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -1124,13 +1124,9 @@ static void ivas_dirac_dec_binaural_internal_fx( Copy( st_ivas->hDiracDecBin[0]->ChCrossRe_e, hDiracDecBin->ChCrossRe_e, hSpatParamRendCom->num_freq_bands ); Copy( st_ivas->hDiracDecBin[0]->ChCrossIm_e, hDiracDecBin->ChCrossIm_e, hSpatParamRendCom->num_freq_bands ); - ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat_local, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, - subFrameTotalEne_fx, subFrameTotalEne_e, IIReneLimiter_fx, st_ivas->hMasaIsmData ); + ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat_local, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, subFrameTotalEne_fx, subFrameTotalEne_e, IIReneLimiter_fx, st_ivas->hMasaIsmData ); - ivas_dirac_dec_binaural_determine_processing_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat_local, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, - nchanSeparateChannels, st_ivas->hMasaIsmData ); + ivas_dirac_dec_binaural_determine_processing_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat_local, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, nchanSeparateChannels, st_ivas->hMasaIsmData ); q_mat = hDiracDecBin->q_processMtx; move16(); @@ -5949,7 +5945,6 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( } } - /* Limit target energies to non-negative values */ FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -6713,6 +6708,7 @@ static void ivas_masa_ext_rend_parambin_internal_fx( move16(); move16(); move16(); + /* re-use reverb and decorr from main direction for the sides */ ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, tmp_Cldfb_out_re, tmp_Cldfb_out_im, reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, &Q_inp_mix, 0 ); diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 563e2be0548d35ee3c49a09025b09d4c78b745f1..df575fd3215118dd131621c418686f8ea6a28375 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1347,7 +1347,7 @@ ivas_error ivas_render_config_init_from_rom_fx( ivas_error ivas_render_config_change_defaults( RENDER_CONFIG_HANDLE hRenderConfig, /* i/o: Renderer config handle */ - IVAS_DefaultReverbSize reverbDefault /* i: Reverb default size */ + IVAS_DefaultReverbSize reverbDefault /* i : Reverb default size */ ); diff --git a/lib_rend/ivas_rom_rend_fx.c b/lib_rend/ivas_rom_rend_fx.c index dca4600eeedf3d1331dbe0bda60bbfad41b21652..c8114e0be9ee3aa072c4274302da99623ea8adba 100644 --- a/lib_rend/ivas_rom_rend_fx.c +++ b/lib_rend/ivas_rom_rend_fx.c @@ -242,6 +242,8 @@ const Word32 t_design_11_elevation_int[70] = //Q22 32230182, -98862600, 97758528, 296363872, -40604592, -296967968, -111972608, 201383760, -32033360, 187339088, 110320048, -186468864, 39944096, -199750464 }; + + /*----------------------------------------------------------------------* * Reverberator ROM tables *-----------------------------------------------------------------------*/ @@ -325,7 +327,7 @@ const Word32 ivas_reverb_default_large_fc_fx[IVAS_REVERB_DEFAULT_L_N_BANDS] /*Q1 }; const Word32 ivas_reverb_default_large_RT60_fx[IVAS_REVERB_DEFAULT_L_N_BANDS] /*Q26*/ = - { +{ 91415696, 97213904, 88368952, 105944760, 99092952, 93643712, 86496616, 90341952, 72202424, 69799928, 73618424, 72813120, @@ -703,6 +705,7 @@ const LS_CONVERSION_MAPPING_FX ls_conversion_mapping_fx[LS_SETUP_CONVERSION_NUM_ {IVAS_AUDIO_CONFIG_MONO, IVAS_AUDIO_CONFIG_5_1_2, ls_conversion_mono_cicpX_fx}, {IVAS_AUDIO_CONFIG_MONO, IVAS_AUDIO_CONFIG_5_1_4, ls_conversion_mono_cicpX_fx}, {IVAS_AUDIO_CONFIG_MONO, IVAS_AUDIO_CONFIG_7_1_4, ls_conversion_mono_cicpX_fx}, + {IVAS_AUDIO_CONFIG_STEREO, IVAS_AUDIO_CONFIG_5_1, NULL}, {IVAS_AUDIO_CONFIG_STEREO, IVAS_AUDIO_CONFIG_7_1, NULL}, {IVAS_AUDIO_CONFIG_STEREO, IVAS_AUDIO_CONFIG_5_1_2, NULL}, diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index 4536b7b91f6a673038fc62c8ed8bab9211d3bc68..3d810e5d419f010a8cb3616468fa804bed99a07f 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1505,6 +1505,8 @@ ivas_error ivas_combined_orientation_open_fx( return IVAS_ERR_OK; } + + /*-----------------------------------------------------------------------* * ivas_combined_orientation_close() * @@ -1936,6 +1938,7 @@ ivas_error combine_external_and_head_orientations( } } } + /* Reset the combined orientations to identity */ test(); IF( hExtOrientationData->enableHeadRotation[i] == 0 && hExtOrientationData->enableExternalOrientation[i] == 0 ) @@ -2087,7 +2090,6 @@ ivas_error combine_external_and_head_orientations( } hCombinedOrientationData->sr_pose_pred_axis = sr_pose_pred_axis; - move32(); /* Reset external orientations */ IF( hExtOrientationData != NULL ) @@ -2106,11 +2108,13 @@ ivas_error combine_external_and_head_orientations( return IVAS_ERR_OK; } + /*------------------------------------------------------------------------- * external_target_interpolation() * * *------------------------------------------------------------------------*/ + static void external_target_interpolation_fx( EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientation handle */ diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 84dc763f26476304e25890f5575e3c473989c10e..1d9ebafa6f82e48fd36750c07e9d65ba9c350d4b 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -300,10 +300,10 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( ivas_error IVAS_REND_GetSplitRendBitstreamHeader( IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ ISAR_SPLIT_REND_CODEC *pCodec, /* o : pointer to codec setting */ - ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o : pointer to pose correction mode */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o : pointer to pose correction mode */ Word16 *pCodec_frame_size_ms, /* o : pointer to codec frame size setting */ - Word16 *pIsar_frame_size_ms, /* o : pointer to ISAR frame size setting */ - Word16 *pLc3plusHighRes /* o : pointer to LC3plus High-Res setting */ + Word16 *pIsar_frame_size_ms, /* o : pointer to ISAR frame size setting */ + Word16 *pLc3plusHighRes /* o : pointer to LC3plus High-Res setting */ ); ivas_error IVAS_REND_SetHeadRotation( diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index d45c79be014aa3f2fe0a777f8556ea48ea555328..8376e40097fbd2515e4b2f0039bc11cf6f8cdb25 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -232,7 +232,6 @@ struct IVAS_REND Word8 rendererConfigEnabled; RENDER_CONFIG_DATA *hRendererConfig; /* Renderer config pointer */ IVAS_DefaultReverbSize selectedRoomReverbSize; - #ifdef DEBUGGING Word32 numClipping; /* Counter of clipped output samples */ #endif @@ -4372,6 +4371,14 @@ static ivas_error isar_pre_rend_init( return IVAS_ERR_OK; } + + +/*------------------------------------------------------------------------- + * Function getDefaultReverbSize() + * + * + *------------------------------------------------------------------------*/ + static IVAS_ROOM_SIZE_T getDefaultReverbSize( input_ism *ismInputs, input_masa *masaInputs, @@ -4464,6 +4471,7 @@ static IVAS_ROOM_SIZE_T getDefaultReverbSize( return selectedReverb; } + /*-------------------------------------------------------------------* * IVAS_REND_AddInput() * @@ -5795,18 +5803,12 @@ ivas_error IVAS_REND_CombineHeadAndExternalOrientation( } -/*---------------------------------------------------------------------* - * IVAS_REND_GetCombinedOrientation() - * - * - *---------------------------------------------------------------------*/ - - /*---------------------------------------------------------------------* * IVAS_REND_GetReverbRoomSize() * * *---------------------------------------------------------------------*/ + ivas_error IVAS_REND_GetReverbRoomSize( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ IVAS_ROOM_SIZE_T *reverbRoomSize /* o : Reverb room size */ @@ -5836,11 +5838,13 @@ ivas_error IVAS_REND_GetReverbRoomSize( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_REND_SetReverbRoomSize() * * *---------------------------------------------------------------------*/ + ivas_error IVAS_REND_SetReverbRoomSize( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_ROOM_SIZE_T reverbRoomSize /* i : Reverb room size */ @@ -9612,6 +9616,7 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( } max_bands = extract_l( Mpy_32_32( imult3216( hIvasRend->sampleRateOut, BINAURAL_MAXBANDS ), 44740 /* 1/48000 in Q31 */ ) ); + IF( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], pSplitRendConfig->splitRendBitRate, diff --git a/lib_util/aeid_file_reader.h b/lib_util/aeid_file_reader.h index 2eb38b90fec9a6ff672dc55077de548722fd1046..55a141284c4f202bc7c9426e9036f2b6475a7d83 100644 --- a/lib_util/aeid_file_reader.h +++ b/lib_util/aeid_file_reader.h @@ -84,5 +84,4 @@ const char *aeidFileReader_getFilePath( aeidFileReader *aeidReader /* i : aeidFileReader handle */ ); - #endif /* IVAS_AEID_FILE_READER_H */ diff --git a/lib_util/ism_file_reader.c b/lib_util/ism_file_reader.c index 5982229e4fdd1b61fdb9d9b2d613c038e693a82b..d0caaa889fa26cecebe2af98608f171e161f44ba 100644 --- a/lib_util/ism_file_reader.c +++ b/lib_util/ism_file_reader.c @@ -174,26 +174,32 @@ ivas_error IsmFileReader_readNextFrame( { return IVAS_ERR_ISM_INVALID_METADATA_VALUE; } + if ( ( ismMetadata->elevation_fx > DEG_90_IN_Q22 ) || ( ismMetadata->elevation_fx < -DEG_90_IN_Q22 ) ) { return IVAS_ERR_ISM_INVALID_METADATA_VALUE; } + if ( ismMetadata->radius_fx < 0 ) /* Negative radius not supported. Max quantized radius = (2^ISM_RADIUS_NBITS-1)*0.25 = 15.75 */ { return IVAS_ERR_ISM_INVALID_METADATA_VALUE; } + if ( ( ismMetadata->spread_fx > DEG_360_IN_Q22 ) || ( ismMetadata->spread_fx < 0 ) ) { return IVAS_ERR_ISM_INVALID_METADATA_VALUE; } + if ( /*( ismMetadata->gainFactor_fx > ONE_IN_Q31 ) ||*/ ( ismMetadata->gainFactor_fx < 0 ) ) { return IVAS_ERR_ISM_INVALID_METADATA_VALUE; } + if ( ( ismMetadata->yaw_fx > DEG_180_IN_Q22 ) || ( ismMetadata->yaw_fx < -DEG_180_IN_Q22 ) ) { return IVAS_ERR_ISM_INVALID_METADATA_VALUE; } + if ( ( ismMetadata->pitch_fx > DEG_90_IN_Q22 ) || ( ismMetadata->pitch_fx < -DEG_90_IN_Q22 ) ) { return IVAS_ERR_ISM_INVALID_METADATA_VALUE; diff --git a/lib_util/ism_file_writer.c b/lib_util/ism_file_writer.c index 975412b002524110b525fee6aa74826a07158ab2..ed098c601cb1a861f47eb7b9c9cbc8ffc0632334 100644 --- a/lib_util/ism_file_writer.c +++ b/lib_util/ism_file_writer.c @@ -116,6 +116,7 @@ ivas_error IsmFileWriter_writeFrame( } file = ismWriter->file; + float azimuth = fixedToFloat( ismMetadata.azimuth_fx, Q22 ); float elevation = fixedToFloat( ismMetadata.elevation_fx, Q22 ); float radius = fix16_to_float( ismMetadata.radius_fx, Q9 ); @@ -125,6 +126,7 @@ ivas_error IsmFileWriter_writeFrame( float pitch = fixedToFloat( ismMetadata.pitch_fx, Q22 ); snprintf( char_buff, sizeof( char_buff ), "%+07.2f,%+06.2f,%05.2f,%06.2f,%04.2f,%+07.2f,%+06.2f,%d\n", azimuth, elevation, radius, spread, gainFactor, yaw, pitch, ismMetadata.non_diegetic_flag ); + if ( file ) { fputs( char_buff, file ); diff --git a/lib_util/ivas_rtp_api.h b/lib_util/ivas_rtp_api.h index 6698daaeae6882ff3b3acb37ac9a3f72b34b3636..a697087ab63fe887c9106cb3f456584add4ab404 100644 --- a/lib_util/ivas_rtp_api.h +++ b/lib_util/ivas_rtp_api.h @@ -272,6 +272,7 @@ typedef struct IVAS_RTP_SR_TRANSPORT codec; /* SR Transport Codec used*/ } IVAS_RTP_SR_INFO; + /**********************************************/ /* IVAS RTP PACKER API */ /**********************************************/ diff --git a/lib_util/ivas_rtp_file.h b/lib_util/ivas_rtp_file.h index 571281086567cb17fa748acd5ff83c78024d270f..ce2cc183d08775460bac3bf62cfa6040372eb134 100644 --- a/lib_util/ivas_rtp_file.h +++ b/lib_util/ivas_rtp_file.h @@ -78,5 +78,4 @@ void IVAS_RTP_WriteExtPiData( FILE *f_piDataOut, const PIDATA_TS *piData, uint32 const char *IVAS_RTP_GetExtPiFilePath( IVAS_RTP *rtp ); uint16_t IVAS_RTP_OwnRandom( uint16_t *seed ); - #endif /* IVAS_RTP_FILE_H */ diff --git a/lib_util/ivas_rtp_internal.h b/lib_util/ivas_rtp_internal.h index b0c9e2550d75778128f12b31d40f64eaf3b48727..c373304a83dfde52a5488ed3ed60b68494f48a41 100644 --- a/lib_util/ivas_rtp_internal.h +++ b/lib_util/ivas_rtp_internal.h @@ -103,7 +103,6 @@ enum IVAS_RTP_HEADER_BITS EBYTE_CMR_T_IVAS = 0xF0, /* Initial E-byte indicating IVAS modes */ EBYTE_CMR_T_NO_REQ = 0xFF, /* If no bitrate and no CA mode requested for IVAS/EVS */ - EBYTE_BANDWIDTH_REQUEST = 0x80, /* Subsequent E-byte for Bandwidth Request */ EBYTE_FORMAT_REQUEST = 0x90, /* Subsequent E-byte for Format Request */ EBYTE_SUBFORMAT_REQUEST = 0x9F, /* Subsequent E-byte for SubFormat Request */ @@ -124,7 +123,6 @@ enum IVAS_RTP_HEADER_BITS }; - #define ERR_CHECK_RETURN( err ) \ { \ if ( ( err ) != IVAS_ERR_OK ) \ @@ -133,7 +131,6 @@ enum IVAS_RTP_HEADER_BITS } \ } - typedef struct { uint32_t size; @@ -143,5 +140,4 @@ typedef struct ivas_error PI_PackData( const IVAS_PIDATA_GENERIC *piData, PIDATA_PACKED *packed, uint8_t pmBits ); ivas_error PI_UnPackData( uint8_t piDataType, uint32_t piSize, const uint8_t *piDataBuffer, IVAS_PIDATA_GENERIC *piData ); - #endif /* IVAS_RTP_INTERNAL_H */ diff --git a/lib_util/ivas_rtp_payload.c b/lib_util/ivas_rtp_payload.c index 9f6c22508e9e75556ae82e59bba1d137bcf6c887..28e58fa6758a2430095450dd56448c2af2335aaf 100644 --- a/lib_util/ivas_rtp_payload.c +++ b/lib_util/ivas_rtp_payload.c @@ -29,12 +29,11 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ + #include #include #include #include "common_api_types.h" - - #include "ivas_rtp_internal.h" #include "ivas_bpool.h" #include "ivas_queue.h" @@ -227,6 +226,8 @@ static void InitRtpHeader( { memset( header, 0, sizeof( *header ) ); header->version = 2; + + return; } static ivas_error PackRtpHeader( @@ -797,10 +798,12 @@ static void packEBytes( uint8_t fmtEByte = ( EBYTE_FORMAT_REQUEST | ( (uint8_t) format & MASK_3BIT ) ); eByte[nByte++] = isSubFormatProvided ? EBYTE_SUBFORMAT_REQUEST : fmtEByte; } + if ( isSubFormatProvided && nByte < maxNumEBytes ) { eByte[nByte++] = ( (uint8_t) subFormat & MASK_6BIT ); /* Requested Coded subFormat */ } + /* Subsequent E-bytes - Split Renderer Configuration Request */ if ( isSRConfigProvided && nByte < maxNumEBytes ) { @@ -831,6 +834,7 @@ static ivas_error getSRToCByte( { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Unsupported codec framesize for SR provided" ); } + if ( srInfo->bitrateKbps < 256000 || srInfo->bitrateKbps > 512000 ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Unsupported bitrate for SR" ); @@ -846,6 +850,7 @@ static ivas_error getSRToCByte( return IVAS_ERR_OK; } + static void addPackedPiDataToFrame( PIDATA_FRAME *piDataFrm, const PIDATA_PACKED *packedPiData, uint32_t piDataType ) { piDataFrm->piData[piDataType].size = packedPiData->size; @@ -1348,6 +1353,7 @@ static uint32_t parseSubsequentEByte( const IVAS_DATA_BUFFER *payload, uint32_t requests[IVAS_REQUEST_SUBFORMAT].subFormatType = byte & MASK_6BIT; } } + requests[IVAS_REQUEST_FORMAT].formatType = byte & MASK_3BIT; } break; @@ -1430,6 +1436,7 @@ static ivas_error parseToCByte( const IVAS_DATA_BUFFER *payload, uint32_t *numBy { uint8_t SR_BR; static const uint8_t codecFrameSizeMap[4] = { 0, 5, 10, 20 }; + byte = payload->buffer[nBytes++]; SR_BR = ( byte >> 3 ) & MASK_2BIT; if ( SR_BR == 0 ) diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index cea96e44144b59652fc7aed3931b6e717cd4ef8f..c353997324ee6c508d48c871e44fde9a1431fdc3 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -34,6 +34,8 @@ #include "ivas_rtp_internal.h" #include #include +#include "cnst.h" + #ifndef min #define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) @@ -44,10 +46,6 @@ #endif -#include "cnst.h" -#include - - /* 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 ); @@ -76,6 +74,7 @@ static int16_t ivasPayload_convertToQ15( float value ) value = value < -32768.0f ? -32768.0f : value; return (int16_t) ( value ); } + /*-----------------------------------------------------------------------* * ivasPayload_convertToQ10() * @@ -188,7 +187,6 @@ static ivas_error unpackQuaternion( const uint8_t *buffer, IVAS_QUATERNION *orie return IVAS_ERR_OK; } - static ivas_error packUnsupportedData( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) { (void) piData; @@ -288,6 +286,7 @@ static ivas_error packISMOrientation( const IVAS_PIDATA_GENERIC *piData, uint8_t { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect PI ID in Orientation PI data" ); } + /* Orientation data is 4 bytes, header is 2 bytes */ if ( maxDataBytes < 4 * IVAS_MAX_NUM_OBJECTS + 2 ) { @@ -300,6 +299,7 @@ static ivas_error packISMOrientation( const IVAS_PIDATA_GENERIC *piData, uint8_t { nBytes += packQuaternion( orientation->orientation[n], &buffer[nBytes] ); } + *nBytesWritten = nBytes; return IVAS_ERR_OK; } @@ -316,6 +316,7 @@ static ivas_error unpackOrientation( const uint8_t *buffer, uint32_t numDataByte piData->size = sizeof( IVAS_PIDATA_ORIENTATION ); unpackQuaternion( buffer, &( orientation->orientation ) ); + return IVAS_ERR_OK; } @@ -337,6 +338,7 @@ static ivas_error unpackISMOrientation( const uint8_t *buffer, uint32_t numDataB { unpackQuaternion( &buffer[4 * n], &( ism_orientation->orientation[n] ) ); } + for ( ; n < IVAS_MAX_NUM_OBJECTS; n++ ) { ism_orientation->orientation[n].w_fx = 0; @@ -668,6 +670,7 @@ static ivas_error unpackPosition( const uint8_t *buffer, uint32_t numDataBytes, position->position.z = FLOAT_FROM_Q15( readInt16( &buffer[4] ) ) * MAX_PI_POSITION_METERS; return IVAS_ERR_OK; } + static ivas_error packPositionCompact( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) { uint32_t nBytes = 0; @@ -788,6 +791,7 @@ static ivas_error unpackISMPosition( const uint8_t *buffer, uint32_t numDataByte } return IVAS_ERR_OK; } + static ivas_error packISMPositionCompact( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) { uint32_t nBytes = 0, n; @@ -855,6 +859,7 @@ static ivas_error unpackISMPositionCompact( const uint8_t *buffer, uint32_t numD } return IVAS_ERR_OK; } + static ivas_error packDiegetic( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) { uint32_t nBytes = 0, n; @@ -931,6 +936,7 @@ static ivas_error packAudioFocusCommon( const IVAS_PIDATA_GENERIC *piData, uint8 { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Incorrect size in PI data of type Audio Focus" ); } + if ( audioFocus->availDirection && audioFocus->availLevel ) { packedSize = 5; @@ -1049,6 +1055,7 @@ static ivas_error unpackISMNum( const uint8_t *buffer, uint32_t numDataBytes, IV return IVAS_ERR_OK; } + static ivas_error packISMID( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) { uint32_t nBytes = 0, n; @@ -1278,6 +1285,7 @@ static ivas_error unpackISMDistanceAttenuation( const uint8_t *buffer, uint32_t } return IVAS_ERR_OK; } + static ivas_error packISMDirectivity( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ) { uint32_t nBytes = 0, n; @@ -1643,14 +1651,13 @@ static const PACK_PI_FN packPiDataFuntions[IVAS_PI_MAX_ID] = { packReverseISMID, /* R_ISM_ID */ packReverseISMGain, /* R_ISM_GAIN */ packOrientation, /* R_ISM_ORIENTATION */ - - packPosition, /* R_ISM_POSITION */ - packPositionCompact, /* R_ISM_POSITION_COMPACT */ - packReverseISMDirection, /* R_ISM_DIRECTION */ - packUnsupportedData, /* RESERVED27 */ - packUnsupportedData, /* RESERVED28 */ - packUnsupportedData, /* RESERVED29 */ - packNoPiData /* NO_DATA */ + packPosition, /* R_ISM_POSITION */ + packPositionCompact, /* R_ISM_POSITION_COMPACT */ + packReverseISMDirection, /* R_ISM_DIRECTION */ + packUnsupportedData, /* RESERVED27 */ + packUnsupportedData, /* RESERVED28 */ + packUnsupportedData, /* RESERVED29 */ + packNoPiData /* NO_DATA */ }; static const UNPACK_PI_FN unpackPiDataFuntions[IVAS_PI_MAX_ID] = { diff --git a/lib_util/ivas_rtp_pi_data.h b/lib_util/ivas_rtp_pi_data.h index 97519f588f7cb4d3e63aff821a9520f9fed5631a..9cbedc6a170afa45b7fef9161eb05fa6153c7917 100644 --- a/lib_util/ivas_rtp_pi_data.h +++ b/lib_util/ivas_rtp_pi_data.h @@ -217,7 +217,7 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_ID) */ uint32_t piDataType; /* IVAS_PI_ISM_ID */ - uint16_t numObjects; /* number of objects */ + uint16_t numObjects; /* number of objects */ uint8_t id[IVAS_MAX_NUM_OBJECTS]; /* 8-bit ISM id of object */ } IVAS_PIDATA_ISM_ID; @@ -226,7 +226,7 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_GAIN) */ uint32_t piDataType; /* IVAS_PI_ISM_GAIN */ - uint16_t numObjects; /* number of objects */ + uint16_t numObjects; /* number of objects */ int8_t dB[IVAS_MAX_NUM_OBJECTS]; /* ISM gain in dB per object [-96, +3] */ } IVAS_PIDATA_ISM_GAIN; @@ -235,7 +235,7 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_ORIENTATION) */ uint32_t piDataType; /* IVAS_PI_ISM_ORIENTATION */ - uint16_t numObjects; /* number of objects */ + uint16_t numObjects; /* number of objects */ IVAS_QUATERNION orientation[IVAS_MAX_NUM_OBJECTS]; /* Orientation of audio objects in ISM(s) */ } IVAS_PIDATA_ISM_ORIENTATION; @@ -244,7 +244,7 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_POSITION) */ uint32_t piDataType; /* IVAS_PI_ISM_POSITION */ - uint16_t numObjects; /* number of objects */ + uint16_t numObjects; /* number of objects */ IVAS_COORDINATE position[IVAS_MAX_NUM_OBJECTS]; /* Position of audio objects in ISM(s) */ } IVAS_PIDATA_ISM_POSITION; @@ -264,7 +264,7 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_ATTENUATION) */ uint32_t piDataType; /* IVAS_PI_ISM_DISTANCE_ATTENUATION */ - uint16_t numObjects; /* number of objects */ + uint16_t numObjects; /* number of objects */ IVAS_DIST_ATTEN distAtten[IVAS_MAX_NUM_OBJECTS]; /* Distance attenuation of audio objects */ } IVAS_PIDATA_ISM_ATTENUATION; @@ -284,7 +284,7 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_DIRECTIVITY) */ uint32_t piDataType; /* IVAS_PI_ISM_DIRECTIVITY */ - uint16_t numObjects; /* number of objects */ + uint16_t numObjects; /* number of objects */ IVAS_ISM_DIRECTIVITY directivity[IVAS_MAX_NUM_OBJECTS]; /* Directivity of audio objects */ } IVAS_PIDATA_ISM_DIRECTIVITY; @@ -349,7 +349,6 @@ typedef struct IVAS_COORDINATE position; /* Position data */ } IVAS_PIDATA_POSITION; - /* Dynamic Audio Suppression describes receiver’s preference with respect to the * type of audio content that should be enhanced and the amount of suppression to * be applied to the background noise @@ -423,7 +422,6 @@ typedef struct IVAS_QUATERNION orientation; /* orientation editing request for received ISM */ } IVAS_PIDATA_ISM_EDIT_ORIENTATION; - /* Editing request for ISM direction */ typedef struct { @@ -480,5 +478,4 @@ typedef struct pidata_ts_struct uint32_t timestamp; } PIDATA_TS; - #endif /* IVAS_RTP_PI_DATA_H */ diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 111f8d978f503cee19d67e0faf3a126dcd19876c..89fd65058725495b633e47079c60dc3c4943cca0 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -40,6 +40,7 @@ #include "prot_fx.h" #include "ivas_cnst.h" + /*------------------------------------------------------------------------------------------* * PreProc Local Macros *------------------------------------------------------------------------------------------*/ @@ -2825,11 +2826,13 @@ ivas_error RenderConfigReader_read( return IVAS_ERR_OK; } + /*------------------------------------------------------------------------------------------* * RenderConfigReader_getAcousticEnvironmentCount() * * Gets number of acoustic environments available *------------------------------------------------------------------------------------------*/ + uint32_t RenderConfigReader_getAcousticEnvironmentCount( RenderConfigReader *pRenderConfigReader /* i : RenderConfigReader handle */ ) @@ -2837,11 +2840,13 @@ uint32_t RenderConfigReader_getAcousticEnvironmentCount( return pRenderConfigReader->nAE; } + /*------------------------------------------------------------------------------------------* * RenderConfigReader_getAcousticEnvironments() * * Gets all acoustic environments *------------------------------------------------------------------------------------------*/ + ivas_error RenderConfigReader_getAcousticEnvironments( RenderConfigReader *pRenderConfigReader, /* i : RenderConfigReader handle */ IVAS_ROOM_ACOUSTICS_CONFIG_DATA **ppAcEnv /* o : Acoustic environment array pointer */ @@ -2923,6 +2928,7 @@ ivas_error RenderConfigReader_getAcousticEnvironments( return IVAS_ERR_OK; } + /*------------------------------------------------------------------------------------------* * RenderConfigReader_getAcousticEnvironment() * diff --git a/lib_util/render_config_reader.h b/lib_util/render_config_reader.h index 420e17ad607e93f953c21d31544ef3cc8615ebbe..3a7ee101744b2c7b1e5ec1868c661dd65d0de41d 100644 --- a/lib_util/render_config_reader.h +++ b/lib_util/render_config_reader.h @@ -53,7 +53,7 @@ ivas_error RenderConfigReader_open( /* Get number of acoustic environments */ uint32_t RenderConfigReader_getAcousticEnvironmentCount( - RenderConfigReader *pRenderConfigReader /* i : RenderConfigReader handle */ + RenderConfigReader *pRenderConfigReader /* i : RenderConfigReader handle */ ); /* Get all acoustic environments */