Loading apps/decoder.c +100 −6 Original line number Diff line number Diff line Loading @@ -163,6 +163,7 @@ static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS 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_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 updateOnFormatSwitching( IVAS_DEC_HANDLE hIvasDec, IVAS_DEC_BS_FORMAT *pBsFormat, const char *outputWavFilename, MasaFileWriter **ppMasaWriter, IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS], int16_t *pNumOutChannels, uint16_t *pNumObj, const bool delayCompensationEnabled ); /*------------------------------------------------------------------------------------------* Loading Loading @@ -203,7 +204,6 @@ int main( reset_mem( USE_BYTES ); #endif splitRendBits.bits_buf = splitRendBitsBuf; /*------------------------------------------------------------------------------------------* Loading Loading @@ -453,7 +453,6 @@ int main( } } /*-------------------------------------------------------------------* * Load renderer configuration from file *--------------------------------------------------------------------*/ Loading Loading @@ -538,6 +537,7 @@ int main( 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] ); goto cleanup; } if ( ( error = RenderConfigReader_getDistanceAttenuation( renderConfigReader, renderConfig.distAtt_fx ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Failed to get Distance Attenuation \n\n" ); Loading Loading @@ -608,6 +608,7 @@ int main( hLsCustomData.azimuth_fx[i] = (Word32) ( hLsCustomData.azimuth[i] * ( 1u << 22 ) ); hLsCustomData.elevation_fx[i] = (Word32) ( hLsCustomData.elevation[i] * ( 1u << 22 ) ); } if ( ( error = IVAS_DEC_FeedCustomLsData( hIvasDec, hLsCustomData ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_FeedCustomLsData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); Loading Loading @@ -686,7 +687,6 @@ int main( goto cleanup; } /*------------------------------------------------------------------------------------------* * Close files and deallocate resources *------------------------------------------------------------------------------------------*/ Loading Loading @@ -734,7 +734,6 @@ cleanup: print_wmops(); print_mem( NULL ); #endif if ( !arg.quietModeEnabled ) { printf( "\n" ); Loading Loading @@ -2026,7 +2025,7 @@ static ivas_error decodeG192( int16_t isSplitRend, isSplitCoded; IVAS_RENDER_CONFIG_DATA renderConfig; RenderConfigReader *renderConfigReader = NULL; bool restartNeeded; bool restartNeeded = false; #ifdef VARIABLE_SPEED_DECODING if ( arg.tsmEnabled ) Loading Loading @@ -2117,6 +2116,7 @@ static ivas_error decodeG192( fprintf( stderr, "\nError getting render frame size in samples\n" ); return error; } if ( ( error = IVAS_DEC_GetReferencesUpdateFrequency( hIvasDec, &vec_pos_len ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError getting render frame size in samples\n" ); Loading Loading @@ -2412,6 +2412,16 @@ static ivas_error decodeG192( } } /* Output writing update in case of format switching and EXTERNAL output */ if ( restartNeeded && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL ) { if ( ( error = updateOnFormatSwitching( hIvasDec, &bsFormat, arg.outputWavFilename, &masaWriter, ismWriters, &nOutChannels, &numObj, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error in updateOnFormatSwitching(): %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } } /* Write current frame */ if ( decodedGoodFrame ) { Loading Loading @@ -2805,7 +2815,7 @@ static ivas_error decodeVoIP( int16_t i; IVAS_DEC_HANDLE hIvasDec = *phIvasDec; bool restartNeeded; bool restartNeeded = false; IVAS_RTP ivasRtp = { 0 }; IVAS_RTP srRtp = { 0 }; IVAS_RTP_SR_INFO srInfo = { true, false, 0, 20, IVAS_SR_TRANSPORT_LCLD }; Loading Loading @@ -3292,6 +3302,16 @@ static ivas_error decodeVoIP( } } /* Output writing update in case of format switching and EXTERNAL output */ if ( restartNeeded && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL ) { if ( ( error = updateOnFormatSwitching( hIvasDec, &bsFormat, arg.outputWavFilename, &masaWriter, ismWriters, &nOutChannels, &numObj, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error in updateOnFormatSwitching(): %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } } /* Write current frame */ if ( !srRtp.hPack && decodedGoodFrame ) { Loading Loading @@ -3900,4 +3920,78 @@ static ivas_error load_hrtf_from_file( return IVAS_ERR_OK; } /*---------------------------------------------------------------------* * updateOnFormatSwitching() * * In case of IVAS format switching and EXTERNAL output, * update decoder wrt. output writing *---------------------------------------------------------------------*/ static ivas_error updateOnFormatSwitching( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_DEC_BS_FORMAT *pBsFormat, /* o : format of currently decoded bitstream */ const char *outputWavFilename, /* i : name of the output audio file */ MasaFileWriter **ppMasaWriter, /* o : MasaFileWriter handle */ IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS], /* o : 1-4 ismWriters handles */ int16_t *pNumOutChannels, /* o : number of output channels */ uint16_t *pNumObj, /* o : number of ISM objects */ const bool delayCompensationEnabled /* i : is delay compensation enabled */ ) { ivas_error error; /* in case of EXT output, the number of output audio channels can change */ if ( ( error = IVAS_DEC_GetNumOutputChannels( hIvasDec, pNumOutChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetNumOutputChannels, code: %d\n", error ); return error; } /* Get the format of currently decoded bitstream */ if ( ( error = IVAS_DEC_GetFormat( hIvasDec, pBsFormat ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetFormat, code: %d\n", error ); return error; } *pNumObj = 0; if ( *pBsFormat == IVAS_DEC_BS_OBJ || *pBsFormat == IVAS_DEC_BS_MASA_ISM || *pBsFormat == IVAS_DEC_BS_SBA_ISM ) { if ( ( error = IVAS_DEC_GetNumObjects( hIvasDec, pNumObj ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetNumObjects: %s\n", IVAS_DEC_GetErrorMessage( error ) ); return error; } /* If outputting ISM/OMASA/OSBA, ensure the output metadata files are opened */ for ( int16_t i = 0; i < *pNumObj; ++i ) { if ( ismWriters[i] == NULL ) { if ( ( error = IsmFileWriter_open( outputWavFilename, i, &ismWriters[i] ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError: Error opening ISM decoded metadata file %s\n", IsmFileWriter_getFilePath( ismWriters[i] ) ); return error; } } } } /* If outputting MASA, ensure the output file metadata is opened */ if ( *pBsFormat == IVAS_DEC_BS_MASA || *pBsFormat == IVAS_DEC_BS_MASA_ISM ) { if ( ppMasaWriter != NULL ) { if ( ( error = MasaFileWriter_open( outputWavFilename, delayCompensationEnabled, ppMasaWriter ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError: Error opening MASA decoded metadata file %s\n", MasaFileWriter_getFilePath( *ppMasaWriter ) ); return error; } } } return IVAS_ERR_OK; } #undef WMC_TOOL_SKIP lib_com/basop_util.c +37 −3 Original line number Diff line number Diff line Loading @@ -2720,25 +2720,59 @@ Word32 dotWord32_16_Mant32Exp( const Word32 *bufX32, /* i: 32-bit buffer with un const Word16 *bufY16, /* i: 16-bit buffer quite right-aligned */ Word16 bufY16_exp, /* i: exponent of buffer bufY16 */ Word16 len, /* i: buffer len to process */ #ifdef FIX_BASOP_1765_MASA1TC_CNG_MISMATCH Word16 *exp, /* o: result exponent */ const Word16 is_ivas ) /* i: flag indicating IVAS to maintain EVS BE */ #else Word16 *exp ) /* o: result exponent */ #endif { Word32 L_sum; Word16 shift, shift1, i; shift = getScaleFactor32( bufX32, len ); /* current available headroom */ #ifdef FIX_BASOP_1765_MASA1TC_CNG_MISMATCH IF( EQ_16( is_ivas, 1 ) ) { shift = sub( shift, sub( 15, norm_s( len ) ) ); /* reduced required headroom */ } ELSE { shift = sub( shift, sub( 14, norm_s( len ) ) ); /* reduced required headroom */ } #else shift = sub( shift, sub( 14, norm_s( len ) ) ); /* reduced required headroom */ #endif L_sum = 0; /* Clear accu */ move32(); FOR( i = 0; i < len; i++ ) { #ifdef FIX_BASOP_1765_MASA1TC_CNG_MISMATCH IF( EQ_16( is_ivas, 1 ) ) { L_sum = L_add( L_sum, Mpy_32_16_1( L_shl( bufX32[i], shift ), bufY16[i] ) ); } ELSE { L_sum = L_mac0( L_sum, round_fx( L_shl( bufX32[i], shift ) ), bufY16[i] ); } #else L_sum = L_mac0( L_sum, round_fx( L_shl( bufX32[i], shift ) ), bufY16[i] ); #endif } shift1 = norm_l( L_sum ); L_sum = L_shl( L_sum, shift1 ); /* return value */ shift = sub( add( bufX32_exp, bufY16_exp ), add( shift, shift1 ) ); #ifdef FIX_BASOP_1765_MASA1TC_CNG_MISMATCH IF( EQ_16( is_ivas, 0 ) ) { shift = add( shift, 1 ); /* compensate for factor of 2 introduced by L_mac0 */ } #else shift = add( shift, 1 ); /* compensate for factor of 2 introduced by L_mac0 */ #endif /* In case of NULL result, we want to have a 0 exponent too */ if ( L_sum == 0 ) shift = 0; Loading lib_com/basop_util.h +6 −1 Original line number Diff line number Diff line Loading @@ -864,7 +864,12 @@ Word32 dotWord32_16_Mant32Exp( const Word32 *bufX32, /* i: 32-bit buffer with un const Word16 *bufY16, /* i: 16-bit buffer quite right-aligned */ Word16 bufY16_exp, /* i: exponent of buffer bufY16 */ Word16 len, /* i: buffer len to process */ #ifdef FIX_BASOP_1765_MASA1TC_CNG_MISMATCH Word16 *exp, /* o: result exponent */ const Word16 is_ivas ); /* i: flag indicating IVAS to maintain EVS BE */ #else Word16 *exp ); /* o: result exponent */ #endif /*!********************************************************************** \brief Converts linear factor or energy to Decibel Loading lib_com/core_com_config_fx.c +2 −164 Original line number Diff line number Diff line Loading @@ -825,11 +825,7 @@ Word16 getTcxLpcShapedAri( * Initialization of TCX *-----------------------------------------------------------------------*/ #ifdef HARMONIZE_2567_init_functions void init_tcx_cfg_fx( #else void init_tcx_cfg_ivas_fx( #endif TCX_CONFIG_HANDLE hTcxCfg, const Word32 total_brate, /*Q0*/ const Word32 sr_core, /*Q0*/ Loading @@ -845,12 +841,8 @@ void init_tcx_cfg_ivas_fx( const Word16 infoIGFStopFreq, /*Q0*/ const Word16 element_mode, /*Q0*/ const Word16 ini_frame, /*Q0*/ #ifdef HARMONIZE_2567_init_functions const Word16 MCT_flag, /*Q0*/ const Word16 fscaleFB /*Q0*/ ) #else const Word16 MCT_flag /*Q0*/ ) #endif { Word16 i; Word16 mdctWindowLength; Loading @@ -868,11 +860,7 @@ void init_tcx_cfg_ivas_fx( hTcxCfg->tcx_mdct_window_length_old = hTcxCfg->tcx_mdct_window_length; /*Q0*/ move16(); mdctWindowLength = getMdctWindowLength_fx( fscale ); /*Q0*/ #ifdef HARMONIZE_2567_init_functions mdctWindowLengthFB = getMdctWindowLength_fx( fscaleFB ); /*Q0*/ /* this replaces (int16_t) ( mdctWindowLength * input_Fs / sr_core ) as used in float */ #else mdctWindowLengthFB = (Word16) ( mdctWindowLength * input_Fs / sr_core ); #endif init_tcx_window_cfg_fx( hTcxCfg, sr_core, input_Fs, L_frame, L_frameTCX, mdctWindowLength, mdctWindowLengthFB, element_mode ); /* SQ deadzone & memory quantization*/ Loading Loading @@ -1092,153 +1080,3 @@ void init_tcx_window_cfg_fx( return; } #ifndef HARMONIZE_2567_init_functions void init_tcx_cfg_fx( TCX_CONFIG_HANDLE hTcxCfg, const Word32 total_brate, /*Q0*/ const Word32 sr_core, /*Q0*/ const Word32 input_Fs, /*Q0*/ const Word16 L_frame, /*Q0*/ const Word16 bwidth, /*Q0*/ const Word16 L_frameTCX, /*Q0*/ const Word16 fscale, /*Q0*/ const Word16 preemph_fac, /*Q15*/ const Word16 tcxonly, /*Q0*/ const Word16 rf_mode, /*Q0*/ const Word16 igf, /*Q0*/ const Word16 infoIGFStopFreq, /*Q0*/ const Word16 element_mode, /*Q0*/ const Word16 ini_frame, /*Q0*/ const Word16 MCT_flag, /*Q0*/ const Word16 fscaleFB /*Q0*/ ) { Word16 i; Word16 mdctWindowLength; Word16 mdctWindowLengthFB; Word16 na_scale_bwidth; hTcxCfg->preemph_fac = preemph_fac; move16(); hTcxCfg->tcx5Size = shr( L_frame, 2 ); /* Always 5 ms Q0*/ hTcxCfg->tcx5SizeFB = shr( L_frameTCX, 2 ); /* Always 5 ms Q0*/ move16(); move16(); hTcxCfg->tcx_mdct_window_length_old = hTcxCfg->tcx_mdct_window_length; /*Q0*/ move16(); mdctWindowLength = getMdctWindowLength_fx( fscale ); /*Q0*/ mdctWindowLengthFB = getMdctWindowLength_fx( fscaleFB ); /*Q0*/ init_tcx_window_cfg_fx( hTcxCfg, sr_core, input_Fs, L_frame, L_frameTCX, mdctWindowLength, mdctWindowLengthFB, element_mode ); /* SQ deadzone & memory quantization*/ hTcxCfg->sq_rounding = 12288 /*0.375f Q15*/; /*deadzone of 1.25->rounding=1-1.25/2 (No deadzone=0.5)*/ move16(); /* TCX rate loop */ hTcxCfg->tcxRateLoopOpt = 0; move16(); if ( tcxonly != 0 ) { hTcxCfg->tcxRateLoopOpt = 2; move16(); } if ( EQ_16( element_mode, IVAS_CPE_MDCT ) ) { hTcxCfg->tcxRateLoopOpt = 3; move16(); } hTcxCfg->bandwidth = getTcxBandwidth( bwidth ); /*Q15*/ move16(); /* set number of coded lines */ hTcxCfg->tcx_coded_lines = getNumTcxCodedLines( bwidth ); /*Q0*/ move16(); /* TNS in TCX */ hTcxCfg->pCurrentTnsConfig = NULL; hTcxCfg->fIsTNSAllowed = getTnsAllowed( total_brate, igf, element_mode ); /*Q0*/ move16(); IF( hTcxCfg->fIsTNSAllowed ) { InitTnsConfigs_fx( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, MCT_flag ); SetAllowTnsOnWhite( hTcxCfg->tnsConfig, (Word8) EQ_16( element_mode, IVAS_CPE_MDCT ) ); } IF( ini_frame == 0 ) { hTcxCfg->tcx_curr_overlap_mode = hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW; hTcxCfg->last_aldo = 1; move16(); move16(); move16(); } /* Context HM*/ hTcxCfg->ctx_hm = getCtxHm( element_mode, total_brate, rf_mode ); /*Q0*/ move16(); /* Residual Coding*/ hTcxCfg->resq = getResq( total_brate ); /*Q0*/ move16(); test(); if ( hTcxCfg->resq && !tcxonly ) { hTcxCfg->tcxRateLoopOpt = 1; move16(); } /*Set bandwidth scale*/ IF( EQ_16( bwidth, NB ) ) { na_scale_bwidth = NB; } ELSE IF( LE_32( sr_core, INT_FS_16k ) ) { na_scale_bwidth = WB; } ELSE { na_scale_bwidth = SWB; } move16(); hTcxCfg->na_scale = 32767 /*1.0f Q15*/; move16(); test(); IF( LT_16( na_scale_bwidth, SWB ) && !tcxonly ) { FOR( i = 0; i < SIZE_SCALE_TABLE_TCX; i++ ) { test(); test(); IF( ( EQ_16( na_scale_bwidth, scaleTcxTable[i].bwmode ) ) && ( GE_32( total_brate, scaleTcxTable[i].bitrateFrom ) ) && ( LT_32( total_brate, scaleTcxTable[i].bitrateTo ) ) ) { if ( rf_mode ) { i = sub( i, 1 ); } hTcxCfg->na_scale = scaleTcxTable[i].scale; /*Q15*/ move16(); BREAK; } } } IF( tcxonly ) { InitPsychLPC_fx( sr_core, L_frame, hTcxCfg ); } ELSE { hTcxCfg->psychParamsCurrent = NULL; } return; } #endif lib_com/ivas_stereo_td_bit_alloc_fx.c +1 −1 Original line number Diff line number Diff line Loading @@ -718,7 +718,7 @@ void tdm_SCh_LSF_intra_pred_fx( fixed_beta = 30801; // 0.94f in Q15 move16(); } ELSE IF( element_brate <= IVAS_24k4 ) ELSE IF( LE_32( element_brate, IVAS_24k4 ) ) { fixed_beta = 29818; // 0.91f in Q15 move16(); Loading Loading
apps/decoder.c +100 −6 Original line number Diff line number Diff line Loading @@ -163,6 +163,7 @@ static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS 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_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 updateOnFormatSwitching( IVAS_DEC_HANDLE hIvasDec, IVAS_DEC_BS_FORMAT *pBsFormat, const char *outputWavFilename, MasaFileWriter **ppMasaWriter, IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS], int16_t *pNumOutChannels, uint16_t *pNumObj, const bool delayCompensationEnabled ); /*------------------------------------------------------------------------------------------* Loading Loading @@ -203,7 +204,6 @@ int main( reset_mem( USE_BYTES ); #endif splitRendBits.bits_buf = splitRendBitsBuf; /*------------------------------------------------------------------------------------------* Loading Loading @@ -453,7 +453,6 @@ int main( } } /*-------------------------------------------------------------------* * Load renderer configuration from file *--------------------------------------------------------------------*/ Loading Loading @@ -538,6 +537,7 @@ int main( 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] ); goto cleanup; } if ( ( error = RenderConfigReader_getDistanceAttenuation( renderConfigReader, renderConfig.distAtt_fx ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Failed to get Distance Attenuation \n\n" ); Loading Loading @@ -608,6 +608,7 @@ int main( hLsCustomData.azimuth_fx[i] = (Word32) ( hLsCustomData.azimuth[i] * ( 1u << 22 ) ); hLsCustomData.elevation_fx[i] = (Word32) ( hLsCustomData.elevation[i] * ( 1u << 22 ) ); } if ( ( error = IVAS_DEC_FeedCustomLsData( hIvasDec, hLsCustomData ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_FeedCustomLsData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); Loading Loading @@ -686,7 +687,6 @@ int main( goto cleanup; } /*------------------------------------------------------------------------------------------* * Close files and deallocate resources *------------------------------------------------------------------------------------------*/ Loading Loading @@ -734,7 +734,6 @@ cleanup: print_wmops(); print_mem( NULL ); #endif if ( !arg.quietModeEnabled ) { printf( "\n" ); Loading Loading @@ -2026,7 +2025,7 @@ static ivas_error decodeG192( int16_t isSplitRend, isSplitCoded; IVAS_RENDER_CONFIG_DATA renderConfig; RenderConfigReader *renderConfigReader = NULL; bool restartNeeded; bool restartNeeded = false; #ifdef VARIABLE_SPEED_DECODING if ( arg.tsmEnabled ) Loading Loading @@ -2117,6 +2116,7 @@ static ivas_error decodeG192( fprintf( stderr, "\nError getting render frame size in samples\n" ); return error; } if ( ( error = IVAS_DEC_GetReferencesUpdateFrequency( hIvasDec, &vec_pos_len ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError getting render frame size in samples\n" ); Loading Loading @@ -2412,6 +2412,16 @@ static ivas_error decodeG192( } } /* Output writing update in case of format switching and EXTERNAL output */ if ( restartNeeded && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL ) { if ( ( error = updateOnFormatSwitching( hIvasDec, &bsFormat, arg.outputWavFilename, &masaWriter, ismWriters, &nOutChannels, &numObj, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error in updateOnFormatSwitching(): %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } } /* Write current frame */ if ( decodedGoodFrame ) { Loading Loading @@ -2805,7 +2815,7 @@ static ivas_error decodeVoIP( int16_t i; IVAS_DEC_HANDLE hIvasDec = *phIvasDec; bool restartNeeded; bool restartNeeded = false; IVAS_RTP ivasRtp = { 0 }; IVAS_RTP srRtp = { 0 }; IVAS_RTP_SR_INFO srInfo = { true, false, 0, 20, IVAS_SR_TRANSPORT_LCLD }; Loading Loading @@ -3292,6 +3302,16 @@ static ivas_error decodeVoIP( } } /* Output writing update in case of format switching and EXTERNAL output */ if ( restartNeeded && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL ) { if ( ( error = updateOnFormatSwitching( hIvasDec, &bsFormat, arg.outputWavFilename, &masaWriter, ismWriters, &nOutChannels, &numObj, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error in updateOnFormatSwitching(): %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } } /* Write current frame */ if ( !srRtp.hPack && decodedGoodFrame ) { Loading Loading @@ -3900,4 +3920,78 @@ static ivas_error load_hrtf_from_file( return IVAS_ERR_OK; } /*---------------------------------------------------------------------* * updateOnFormatSwitching() * * In case of IVAS format switching and EXTERNAL output, * update decoder wrt. output writing *---------------------------------------------------------------------*/ static ivas_error updateOnFormatSwitching( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_DEC_BS_FORMAT *pBsFormat, /* o : format of currently decoded bitstream */ const char *outputWavFilename, /* i : name of the output audio file */ MasaFileWriter **ppMasaWriter, /* o : MasaFileWriter handle */ IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS], /* o : 1-4 ismWriters handles */ int16_t *pNumOutChannels, /* o : number of output channels */ uint16_t *pNumObj, /* o : number of ISM objects */ const bool delayCompensationEnabled /* i : is delay compensation enabled */ ) { ivas_error error; /* in case of EXT output, the number of output audio channels can change */ if ( ( error = IVAS_DEC_GetNumOutputChannels( hIvasDec, pNumOutChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetNumOutputChannels, code: %d\n", error ); return error; } /* Get the format of currently decoded bitstream */ if ( ( error = IVAS_DEC_GetFormat( hIvasDec, pBsFormat ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetFormat, code: %d\n", error ); return error; } *pNumObj = 0; if ( *pBsFormat == IVAS_DEC_BS_OBJ || *pBsFormat == IVAS_DEC_BS_MASA_ISM || *pBsFormat == IVAS_DEC_BS_SBA_ISM ) { if ( ( error = IVAS_DEC_GetNumObjects( hIvasDec, pNumObj ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetNumObjects: %s\n", IVAS_DEC_GetErrorMessage( error ) ); return error; } /* If outputting ISM/OMASA/OSBA, ensure the output metadata files are opened */ for ( int16_t i = 0; i < *pNumObj; ++i ) { if ( ismWriters[i] == NULL ) { if ( ( error = IsmFileWriter_open( outputWavFilename, i, &ismWriters[i] ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError: Error opening ISM decoded metadata file %s\n", IsmFileWriter_getFilePath( ismWriters[i] ) ); return error; } } } } /* If outputting MASA, ensure the output file metadata is opened */ if ( *pBsFormat == IVAS_DEC_BS_MASA || *pBsFormat == IVAS_DEC_BS_MASA_ISM ) { if ( ppMasaWriter != NULL ) { if ( ( error = MasaFileWriter_open( outputWavFilename, delayCompensationEnabled, ppMasaWriter ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError: Error opening MASA decoded metadata file %s\n", MasaFileWriter_getFilePath( *ppMasaWriter ) ); return error; } } } return IVAS_ERR_OK; } #undef WMC_TOOL_SKIP
lib_com/basop_util.c +37 −3 Original line number Diff line number Diff line Loading @@ -2720,25 +2720,59 @@ Word32 dotWord32_16_Mant32Exp( const Word32 *bufX32, /* i: 32-bit buffer with un const Word16 *bufY16, /* i: 16-bit buffer quite right-aligned */ Word16 bufY16_exp, /* i: exponent of buffer bufY16 */ Word16 len, /* i: buffer len to process */ #ifdef FIX_BASOP_1765_MASA1TC_CNG_MISMATCH Word16 *exp, /* o: result exponent */ const Word16 is_ivas ) /* i: flag indicating IVAS to maintain EVS BE */ #else Word16 *exp ) /* o: result exponent */ #endif { Word32 L_sum; Word16 shift, shift1, i; shift = getScaleFactor32( bufX32, len ); /* current available headroom */ #ifdef FIX_BASOP_1765_MASA1TC_CNG_MISMATCH IF( EQ_16( is_ivas, 1 ) ) { shift = sub( shift, sub( 15, norm_s( len ) ) ); /* reduced required headroom */ } ELSE { shift = sub( shift, sub( 14, norm_s( len ) ) ); /* reduced required headroom */ } #else shift = sub( shift, sub( 14, norm_s( len ) ) ); /* reduced required headroom */ #endif L_sum = 0; /* Clear accu */ move32(); FOR( i = 0; i < len; i++ ) { #ifdef FIX_BASOP_1765_MASA1TC_CNG_MISMATCH IF( EQ_16( is_ivas, 1 ) ) { L_sum = L_add( L_sum, Mpy_32_16_1( L_shl( bufX32[i], shift ), bufY16[i] ) ); } ELSE { L_sum = L_mac0( L_sum, round_fx( L_shl( bufX32[i], shift ) ), bufY16[i] ); } #else L_sum = L_mac0( L_sum, round_fx( L_shl( bufX32[i], shift ) ), bufY16[i] ); #endif } shift1 = norm_l( L_sum ); L_sum = L_shl( L_sum, shift1 ); /* return value */ shift = sub( add( bufX32_exp, bufY16_exp ), add( shift, shift1 ) ); #ifdef FIX_BASOP_1765_MASA1TC_CNG_MISMATCH IF( EQ_16( is_ivas, 0 ) ) { shift = add( shift, 1 ); /* compensate for factor of 2 introduced by L_mac0 */ } #else shift = add( shift, 1 ); /* compensate for factor of 2 introduced by L_mac0 */ #endif /* In case of NULL result, we want to have a 0 exponent too */ if ( L_sum == 0 ) shift = 0; Loading
lib_com/basop_util.h +6 −1 Original line number Diff line number Diff line Loading @@ -864,7 +864,12 @@ Word32 dotWord32_16_Mant32Exp( const Word32 *bufX32, /* i: 32-bit buffer with un const Word16 *bufY16, /* i: 16-bit buffer quite right-aligned */ Word16 bufY16_exp, /* i: exponent of buffer bufY16 */ Word16 len, /* i: buffer len to process */ #ifdef FIX_BASOP_1765_MASA1TC_CNG_MISMATCH Word16 *exp, /* o: result exponent */ const Word16 is_ivas ); /* i: flag indicating IVAS to maintain EVS BE */ #else Word16 *exp ); /* o: result exponent */ #endif /*!********************************************************************** \brief Converts linear factor or energy to Decibel Loading
lib_com/core_com_config_fx.c +2 −164 Original line number Diff line number Diff line Loading @@ -825,11 +825,7 @@ Word16 getTcxLpcShapedAri( * Initialization of TCX *-----------------------------------------------------------------------*/ #ifdef HARMONIZE_2567_init_functions void init_tcx_cfg_fx( #else void init_tcx_cfg_ivas_fx( #endif TCX_CONFIG_HANDLE hTcxCfg, const Word32 total_brate, /*Q0*/ const Word32 sr_core, /*Q0*/ Loading @@ -845,12 +841,8 @@ void init_tcx_cfg_ivas_fx( const Word16 infoIGFStopFreq, /*Q0*/ const Word16 element_mode, /*Q0*/ const Word16 ini_frame, /*Q0*/ #ifdef HARMONIZE_2567_init_functions const Word16 MCT_flag, /*Q0*/ const Word16 fscaleFB /*Q0*/ ) #else const Word16 MCT_flag /*Q0*/ ) #endif { Word16 i; Word16 mdctWindowLength; Loading @@ -868,11 +860,7 @@ void init_tcx_cfg_ivas_fx( hTcxCfg->tcx_mdct_window_length_old = hTcxCfg->tcx_mdct_window_length; /*Q0*/ move16(); mdctWindowLength = getMdctWindowLength_fx( fscale ); /*Q0*/ #ifdef HARMONIZE_2567_init_functions mdctWindowLengthFB = getMdctWindowLength_fx( fscaleFB ); /*Q0*/ /* this replaces (int16_t) ( mdctWindowLength * input_Fs / sr_core ) as used in float */ #else mdctWindowLengthFB = (Word16) ( mdctWindowLength * input_Fs / sr_core ); #endif init_tcx_window_cfg_fx( hTcxCfg, sr_core, input_Fs, L_frame, L_frameTCX, mdctWindowLength, mdctWindowLengthFB, element_mode ); /* SQ deadzone & memory quantization*/ Loading Loading @@ -1092,153 +1080,3 @@ void init_tcx_window_cfg_fx( return; } #ifndef HARMONIZE_2567_init_functions void init_tcx_cfg_fx( TCX_CONFIG_HANDLE hTcxCfg, const Word32 total_brate, /*Q0*/ const Word32 sr_core, /*Q0*/ const Word32 input_Fs, /*Q0*/ const Word16 L_frame, /*Q0*/ const Word16 bwidth, /*Q0*/ const Word16 L_frameTCX, /*Q0*/ const Word16 fscale, /*Q0*/ const Word16 preemph_fac, /*Q15*/ const Word16 tcxonly, /*Q0*/ const Word16 rf_mode, /*Q0*/ const Word16 igf, /*Q0*/ const Word16 infoIGFStopFreq, /*Q0*/ const Word16 element_mode, /*Q0*/ const Word16 ini_frame, /*Q0*/ const Word16 MCT_flag, /*Q0*/ const Word16 fscaleFB /*Q0*/ ) { Word16 i; Word16 mdctWindowLength; Word16 mdctWindowLengthFB; Word16 na_scale_bwidth; hTcxCfg->preemph_fac = preemph_fac; move16(); hTcxCfg->tcx5Size = shr( L_frame, 2 ); /* Always 5 ms Q0*/ hTcxCfg->tcx5SizeFB = shr( L_frameTCX, 2 ); /* Always 5 ms Q0*/ move16(); move16(); hTcxCfg->tcx_mdct_window_length_old = hTcxCfg->tcx_mdct_window_length; /*Q0*/ move16(); mdctWindowLength = getMdctWindowLength_fx( fscale ); /*Q0*/ mdctWindowLengthFB = getMdctWindowLength_fx( fscaleFB ); /*Q0*/ init_tcx_window_cfg_fx( hTcxCfg, sr_core, input_Fs, L_frame, L_frameTCX, mdctWindowLength, mdctWindowLengthFB, element_mode ); /* SQ deadzone & memory quantization*/ hTcxCfg->sq_rounding = 12288 /*0.375f Q15*/; /*deadzone of 1.25->rounding=1-1.25/2 (No deadzone=0.5)*/ move16(); /* TCX rate loop */ hTcxCfg->tcxRateLoopOpt = 0; move16(); if ( tcxonly != 0 ) { hTcxCfg->tcxRateLoopOpt = 2; move16(); } if ( EQ_16( element_mode, IVAS_CPE_MDCT ) ) { hTcxCfg->tcxRateLoopOpt = 3; move16(); } hTcxCfg->bandwidth = getTcxBandwidth( bwidth ); /*Q15*/ move16(); /* set number of coded lines */ hTcxCfg->tcx_coded_lines = getNumTcxCodedLines( bwidth ); /*Q0*/ move16(); /* TNS in TCX */ hTcxCfg->pCurrentTnsConfig = NULL; hTcxCfg->fIsTNSAllowed = getTnsAllowed( total_brate, igf, element_mode ); /*Q0*/ move16(); IF( hTcxCfg->fIsTNSAllowed ) { InitTnsConfigs_fx( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, MCT_flag ); SetAllowTnsOnWhite( hTcxCfg->tnsConfig, (Word8) EQ_16( element_mode, IVAS_CPE_MDCT ) ); } IF( ini_frame == 0 ) { hTcxCfg->tcx_curr_overlap_mode = hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW; hTcxCfg->last_aldo = 1; move16(); move16(); move16(); } /* Context HM*/ hTcxCfg->ctx_hm = getCtxHm( element_mode, total_brate, rf_mode ); /*Q0*/ move16(); /* Residual Coding*/ hTcxCfg->resq = getResq( total_brate ); /*Q0*/ move16(); test(); if ( hTcxCfg->resq && !tcxonly ) { hTcxCfg->tcxRateLoopOpt = 1; move16(); } /*Set bandwidth scale*/ IF( EQ_16( bwidth, NB ) ) { na_scale_bwidth = NB; } ELSE IF( LE_32( sr_core, INT_FS_16k ) ) { na_scale_bwidth = WB; } ELSE { na_scale_bwidth = SWB; } move16(); hTcxCfg->na_scale = 32767 /*1.0f Q15*/; move16(); test(); IF( LT_16( na_scale_bwidth, SWB ) && !tcxonly ) { FOR( i = 0; i < SIZE_SCALE_TABLE_TCX; i++ ) { test(); test(); IF( ( EQ_16( na_scale_bwidth, scaleTcxTable[i].bwmode ) ) && ( GE_32( total_brate, scaleTcxTable[i].bitrateFrom ) ) && ( LT_32( total_brate, scaleTcxTable[i].bitrateTo ) ) ) { if ( rf_mode ) { i = sub( i, 1 ); } hTcxCfg->na_scale = scaleTcxTable[i].scale; /*Q15*/ move16(); BREAK; } } } IF( tcxonly ) { InitPsychLPC_fx( sr_core, L_frame, hTcxCfg ); } ELSE { hTcxCfg->psychParamsCurrent = NULL; } return; } #endif
lib_com/ivas_stereo_td_bit_alloc_fx.c +1 −1 Original line number Diff line number Diff line Loading @@ -718,7 +718,7 @@ void tdm_SCh_LSF_intra_pred_fx( fixed_beta = 30801; // 0.94f in Q15 move16(); } ELSE IF( element_brate <= IVAS_24k4 ) ELSE IF( LE_32( element_brate, IVAS_24k4 ) ) { fixed_beta = 29818; // 0.91f in Q15 move16(); Loading