Loading apps/decoder.c +0 −61 Original line number Diff line number Diff line Loading @@ -130,7 +130,6 @@ typedef struct bool tsmEnabled; IVAS_RENDER_FRAMESIZE renderFramesize; #ifdef DEBUGGING IVAS_DEC_FORCED_REND_MODE forcedRendMode; #ifdef DEBUG_FOA_AGC FILE *agcBitstream; /* temporary */ #endif Loading Loading @@ -183,7 +182,6 @@ static ivas_error load_hrtf_from_file( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary #ifdef DEBUGGING static ivas_error printBitstreamInfoVoip( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); static int16_t app_own_random( int16_t *seed ); static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( char *forcedRendModeChar ); #endif static void do_object_editing( IVAS_EDITABLE_PARAMETERS *editableParameters, ObjectEditFileReader *objectEditFileReader ); Loading Loading @@ -540,28 +538,6 @@ int main( #endif } /*------------------------------------------------------------------------------------------* * Binaural rendering mode: set and print info *------------------------------------------------------------------------------------------*/ if ( arg.forcedRendMode != IVAS_DEC_FORCE_REND_UNFORCED ) { if ( ( error = IVAS_DEC_SetForcedRendMode( hIvasDec, arg.forcedRendMode ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError: Forcing binaural rendering mode failed (only TDREND and CLDFBREND are expected).\n\n" ); goto cleanup; } if ( arg.forcedRendMode == IVAS_DEC_FORCE_REND_TD_RENDERER ) { fprintf( stdout, "Forcing rendering to: TD renderer\n" ); } else if ( arg.forcedRendMode == IVAS_DEC_FORCE_REND_CLDFB_RENDERER ) { fprintf( stdout, "Forcing rendering to: CLDFB renderer\n" ); } } /*-----------------------------------------------------------------* * Open Error pattern file for simulation *-----------------------------------------------------------------*/ Loading Loading @@ -970,7 +946,6 @@ static bool parseCmdlIVAS_dec( #ifdef DEBUGGING float ftmp; arg->forcedRendMode = IVAS_DEC_FORCE_REND_UNFORCED; #ifdef DEBUG_FOA_AGC arg->agcBitstream = NULL; #endif Loading Loading @@ -1140,17 +1115,6 @@ static bool parseCmdlIVAS_dec( } i += 2; } else if ( strcmp( argv_to_upper, "-FORCE" ) == 0 ) { i++; if ( i < argc - 3 ) { strncpy( argv_to_upper, argv[i], sizeof( argv_to_upper ) - 1 ); argv_to_upper[sizeof( argv_to_upper ) - 1] = '\0'; arg->forcedRendMode = parseForcedRendModeDec( argv_to_upper ); i++; } } #ifdef DEBUG_MODE_INFO #ifdef DEBUG_MODE_INFO_TWEAK /* Define additional subfolder for debug info output in ./res */ Loading Loading @@ -3967,31 +3931,6 @@ static void do_object_editing( return; } #ifdef DEBUGGING /*---------------------------------------------------------------------* * parseForcedRendModeDec() * * *---------------------------------------------------------------------*/ static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( char *forcedRendModeChar ) { if ( ( strcmp( to_upper( forcedRendModeChar ), "TDREND" ) == 0 ) ) { return IVAS_DEC_FORCE_REND_TD_RENDERER; } if ( ( strcmp( to_upper( forcedRendModeChar ), "CLDFBREND" ) == 0 ) ) { return IVAS_DEC_FORCE_REND_CLDFB_RENDERER; } return IVAS_DEC_FORCE_REND_UNDEFINED; } #endif /*---------------------------------------------------------------------* * load_hrtf_from_file() Loading apps/renderer.c +63 −51 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ #include "lib_rend.h" #include <assert.h> #include <math.h> #include <stdint.h> #include <string.h> #include "audio_file_reader.h" #include "audio_file_writer.h" Loading Loading @@ -190,7 +191,7 @@ typedef struct float lfeConfigElevation; bool lfeCustomRoutingEnabled; char inLfePanningMatrixFile[RENDERER_MAX_CLI_ARG_LENGTH]; float syncMdDelay; int16_t syncMdDelay; IVAS_RENDER_FRAMESIZE render_framesize; uint16_t directivityPatternId[RENDERER_MAX_ISM_INPUTS]; AcousticEnvironmentSequence aeSequence; Loading Loading @@ -720,6 +721,7 @@ int main( SplitFileReadWrite *hSplitRendFileReadWrite; int16_t delayNumSamples_temp; int32_t delayTimeScale_temp; bool flushRendererLastFrame = false; int16_t numSamplesRead; int16_t delayNumSamples = -1; int16_t delayNumSamples_orig = 0; Loading Loading @@ -766,8 +768,11 @@ int main( CmdlnArgs args = parseCmdlnArgs( argc, argv ); if ( args.nonDiegeticPan && !( ( args.inConfig.numAudioObjects == 0 && args.inConfig.multiChannelBuses[0].audioConfig == IVAS_AUDIO_CONFIG_MONO ) || ( args.inConfig.numAudioObjects > 0 && args.inConfig.audioObjects[0].audioConfig == IVAS_AUDIO_CONFIG_OBA && args.inConfig.numAudioObjects == 1 ) ) ) if ( args.nonDiegeticPan && !( ( args.inConfig.numAudioObjects == 0 && args.inConfig.multiChannelBuses[0].audioConfig == IVAS_AUDIO_CONFIG_MONO ) || ( args.inConfig.numAudioObjects > 0 && args.inConfig.audioObjects[0].audioConfig == IVAS_AUDIO_CONFIG_OBA && args.inConfig.numAudioObjects == 1 ) ) ) { fprintf( stderr, "\ninvalid configuration - non-diegetic panning requires mono or ISM1 input\n" ); goto cleanup; Loading Loading @@ -1088,7 +1093,10 @@ int main( IVAS_RENDER_CONFIG_DATA renderConfig; #endif /* sanity check */ if ( ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) && !is_split_pre_rend_mode( &args ) ) if ( ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) && !is_split_pre_rend_mode( &args ) ) { fprintf( stderr, "\nExternal Renderer Config is supported only when binaural output configurations is used as output OR when Split pre-rendering mode is enabled. Exiting. \n" ); goto cleanup; Loading Loading @@ -1402,7 +1410,7 @@ int main( } int16_t numOutChannels; if ( ( error = IVAS_REND_NumOutChannels( hIvasRend, &numOutChannels ) ) != IVAS_ERR_OK ) if ( ( error = IVAS_REND_GetNumOutChannels( hIvasRend, &numOutChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_REND_NumOutChannels(): %s\n", ivas_error_to_string( error ) ); goto cleanup; Loading @@ -1417,31 +1425,16 @@ int main( } } if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { if ( ( error = IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms, &bitsBuffer.config.isar_frame_size_ms ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_REND_GetSplitRendBitstreamHeader()!\n" ); goto cleanup; } if ( IVAS_REND_GetDelay( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { fprintf( stderr, "\nUnable to get delay of renderer!\n" ); goto cleanup; } char *outFile = args.outMetadataFilePath; if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, args.outputFilePath, delayNumSamples_temp, delayTimeScale_temp, bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, bitsBuffer.config.codec_frame_size_ms, bitsBuffer.config.isar_frame_size_ms, args.sampleRate, bitsBuffer.config.lc3plus_highres ) ) != IVAS_ERR_OK ) if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { fprintf( stderr, "\nCould not open split rend metadata file %s\n", args.outputFilePath ); goto cleanup; } outFile = args.outputFilePath; audioWriter = NULL; } else { if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { if ( ( error = IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms, &bitsBuffer.config.isar_frame_size_ms ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_REND_GetSplitRendBitstreamHeader()!\n" ); Loading @@ -1454,13 +1447,15 @@ int main( goto cleanup; } if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, args.outMetadataFilePath, delayNumSamples_temp, delayTimeScale_temp, bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, bitsBuffer.config.codec_frame_size_ms, bitsBuffer.config.isar_frame_size_ms, args.sampleRate, bitsBuffer.config.lc3plus_highres ) ) != IVAS_ERR_OK ) if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, outFile, delayNumSamples_temp, delayTimeScale_temp, bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, bitsBuffer.config.codec_frame_size_ms, bitsBuffer.config.isar_frame_size_ms, args.sampleRate, bitsBuffer.config.lc3plus_highres ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nCould not open split rend metadata file %s\n", args.outMetadataFilePath ); fprintf( stderr, "\nCould not open split rend metadata file %s\n", outFile ); goto cleanup; } } if ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { if ( AudioFileWriter_open( &audioWriter, args.outputFilePath, args.sampleRate, numOutChannels ) != IVAS_ERR_OK ) { fprintf( stderr, "\nFailed to open file: %s\n", args.outputFilePath ); Loading Loading @@ -1590,16 +1585,23 @@ int main( if ( numSamplesRead == 0 ) { /* end of input data */ break; flushRendererLastFrame = true; } /* Convert from int to float and from interleaved to packed */ if ( !flushRendererLastFrame ) { convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer, inBuffer.config.is_cldfb, cldfbAna ); } else { memset( inBuffer.data, 0, inBuffer.config.numChannels * inBuffer.config.numSamplesPerChannel * sizeof( float ) ); } int16_t num_subframes, sf_idx; num_subframes = (int16_t) args.render_framesize; if ( isCurrentFrameMultipleOf20ms ) if ( isCurrentFrameMultipleOf20ms && !flushRendererLastFrame ) { IsmPositionProvider_getNextFrame( positionProvider, &mtdBuffer ); Loading Loading @@ -1711,7 +1713,7 @@ int main( } IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.multiChannelBuses[i].inputChannelIndex, numChannels ); if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, mcIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, mcIds[i], tmpBuffer, flushRendererLastFrame ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_REND_FeedInputAudio failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; Loading @@ -1726,7 +1728,7 @@ int main( { IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.audioObjects[i].inputChannelIndex, args.inConfig.numAudioObjects ); if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, ismIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, ismIds[i], tmpBuffer, flushRendererLastFrame ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_REND_FeedInputAudio failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; Loading @@ -1743,7 +1745,7 @@ int main( { IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.audioObjects[i].inputChannelIndex, 1 ); if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, ismIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, ismIds[i], tmpBuffer, flushRendererLastFrame ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_REND_FeedInputAudio failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; Loading @@ -1766,7 +1768,7 @@ int main( } IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.ambisonicsBuses[i].inputChannelIndex, numChannels ); if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, sbaIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, sbaIds[i], tmpBuffer, flushRendererLastFrame ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_REND_FeedInputAudio failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; Loading @@ -1782,13 +1784,13 @@ int main( } IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.masaBuses[i].inputChannelIndex, numChannels ); if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, masaIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, masaIds[i], tmpBuffer, flushRendererLastFrame ) ) != IVAS_ERR_OK ) { fprintf( stderr, "IVAS_REND_FeedInputAudio failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; } if ( isCurrentFrameMultipleOf20ms ) if ( isCurrentFrameMultipleOf20ms && !flushRendererLastFrame ) { if ( masaReaders[i] != NULL ) { Loading Loading @@ -1851,7 +1853,7 @@ int main( zeroPad = delayNumSamples; } if ( is_split_pre_rend_mode( &args ) ) if ( is_split_pre_rend_mode( &args ) && !flushRendererLastFrame ) { if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead, &bitsBuffer.config.bitsWritten ) != IVAS_ERR_OK ) Loading @@ -1861,7 +1863,7 @@ int main( } } if ( audioWriter != NULL ) if ( audioWriter != NULL && !flushRendererLastFrame ) { if ( delayNumSamples * num_out_channels < outBufferSize ) { Loading @@ -1882,7 +1884,7 @@ int main( bitsBuffer.config.bitsWritten = 0; /* Write MASA metadata for MASA outputs */ if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_MASA1 || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_MASA2 ) if ( !flushRendererLastFrame && ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_MASA1 || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_MASA2 ) ) { IVAS_REND_AudioConfigType inputType1; IVAS_REND_AudioConfigType inputType2; Loading Loading @@ -1954,7 +1956,8 @@ int main( } } if ( ( args.inConfig.numAmbisonicsBuses > 0 || args.inConfig.numMultiChannelBuses > 0 || args.inConfig.numMasaBuses > 0 ) && args.inConfig.numAudioObjects > 0 ) if ( ( args.inConfig.numAmbisonicsBuses > 0 || args.inConfig.numMultiChannelBuses > 0 || args.inConfig.numMasaBuses > 0 ) && args.inConfig.numAudioObjects > 0 ) { inputType2 = IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED; if ( ( error = IVAS_REND_MergeMasaMetadata( hIvasRend, &hMetaOutput, inputType1, inputType2 ) ) != IVAS_ERR_OK ) Loading @@ -1970,6 +1973,13 @@ int main( } } /* no new input was actually read, only delay buffers were flushed * therefore this is not a real frame */ if ( flushRendererLastFrame ) { break; } frame++; if ( !args.quietModeEnabled ) { Loading @@ -1982,12 +1992,13 @@ int main( #endif } /* add zeros at the end to have equal length of synthesized signals */ /* add zeros at the end to have equal length of synthesized signals * the output buffer will contain either leftover input samples from delay aligned inputs * or zeros for padding */ if ( audioWriter != NULL ) { for ( zeroPadToWrite = zeroPad; zeroPadToWrite > frameSize_smpls; zeroPadToWrite -= frameSize_smpls ) { memset( outInt16Buffer, 0, outBufferSize * sizeof( int16_t ) ); if ( ( error = AudioFileWriter_write( audioWriter, outInt16Buffer, outBufferSize ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nOutput audio file writer error\n" ); Loading @@ -1995,7 +2006,6 @@ int main( } } memset( outInt16Buffer, 0, zeroPadToWrite * outBuffer.config.numChannels * sizeof( int16_t ) ); if ( ( error = AudioFileWriter_write( audioWriter, outInt16Buffer, zeroPadToWrite * outBuffer.config.numChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nOutput audio file writer error\n" ); Loading @@ -2004,9 +2014,10 @@ int main( zeroPadToWrite = 0; } if ( args.inConfig.numAudioObjects != 0 && ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) if ( args.inConfig.numAudioObjects != 0 && ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { fprintf( stdout, "\n\nMetadata delayed %d subframes\n\n", (int16_t) round( args.syncMdDelay / ( 1000 / IVAS_NUM_FRAMES_PER_SEC / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); fprintf( stdout, "\n\nMetadata delayed %d subframes\n\n", (int16_t) round( args.syncMdDelay / ( (float) BINAURAL_RENDERING_FRAME_SIZE_MS ) ) ); } if ( !args.quietModeEnabled && args.delayCompensationEnabled ) Loading Loading @@ -2917,7 +2928,7 @@ static void parseOption( case CmdLnOptionId_syncMdDelay: assert( numOptionValues == 1 ); /* Metadata Delay to sync with audio delay in ms */ args->syncMdDelay = strtof( optionValues[0], NULL ); args->syncMdDelay = (int16_t) strtol( optionValues[0], NULL, 10 ); break; default: assert( 0 && "This should be unreachable - all command line options should be explicitly handled." ); Loading Loading @@ -3400,7 +3411,8 @@ static void parseObjectPosition( *positionDuration = (uint16_t) strtol( line, &endptr, 10 ); readNextMetadataChunk( line, "\n" ); read_values = (int16_t) sscanf( line, "%f,%f,%f,%f,%f,%f,%f,%f", &meta_prm[0], &meta_prm[1], &meta_prm[2], &meta_prm[3], &meta_prm[4], &meta_prm[5], &meta_prm[6], &meta_prm[7] ); read_values = (int16_t) sscanf( line, "%f,%f,%f,%f,%f,%f,%f,%f", &meta_prm[0], &meta_prm[1], &meta_prm[2], &meta_prm[3], &meta_prm[4], &meta_prm[5], &meta_prm[6], &meta_prm[7] ); if ( read_values < 2 ) { Loading lib_com/bitstream.c +2 −1 Original line number Diff line number Diff line Loading @@ -5380,7 +5380,7 @@ void evs_dec_previewFrame( return; } #ifndef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG void dtx_read_padding_bits( DEC_CORE_HANDLE st, Loading @@ -5396,3 +5396,4 @@ void dtx_read_padding_bits( return; } #endif lib_com/fd_cng_com.c +5 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 ====================================================================================*/ #include "ivas_cnst.h" #include <assert.h> #include <stdint.h> #include "options.h" Loading Loading @@ -140,7 +141,11 @@ void initFdCngCom( hFdCngCom->msMinBufferPtr = 0; set_f( hFdCngCom->msAlphaCor, 0.3f, 2 ); #ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG set_f( hFdCngCom->coherence, 0.5f, MDCT_ST_DTX_NUM_COHERENCE_BANDS ); #else hFdCngCom->coherence = 0.5f; #endif return; } Loading lib_com/ivas_cnst.h +5 −0 Original line number Diff line number Diff line Loading @@ -857,6 +857,11 @@ enum fea_names #define MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN 20 #define MDCT_ST_PLC_FADEOUT_DELAY_4_LSP_FADE 3 #ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG #define MDCT_ST_DTX_NUM_COHERENCE_BANDS 5 #define MDCT_ST_DTX_FIRST_BAND_OFFSET 2 #endif typedef enum { NOISE_GEN_MODE_UNDEF = -1, EQUAL_CORES = 0, Loading Loading
apps/decoder.c +0 −61 Original line number Diff line number Diff line Loading @@ -130,7 +130,6 @@ typedef struct bool tsmEnabled; IVAS_RENDER_FRAMESIZE renderFramesize; #ifdef DEBUGGING IVAS_DEC_FORCED_REND_MODE forcedRendMode; #ifdef DEBUG_FOA_AGC FILE *agcBitstream; /* temporary */ #endif Loading Loading @@ -183,7 +182,6 @@ static ivas_error load_hrtf_from_file( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary #ifdef DEBUGGING static ivas_error printBitstreamInfoVoip( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); static int16_t app_own_random( int16_t *seed ); static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( char *forcedRendModeChar ); #endif static void do_object_editing( IVAS_EDITABLE_PARAMETERS *editableParameters, ObjectEditFileReader *objectEditFileReader ); Loading Loading @@ -540,28 +538,6 @@ int main( #endif } /*------------------------------------------------------------------------------------------* * Binaural rendering mode: set and print info *------------------------------------------------------------------------------------------*/ if ( arg.forcedRendMode != IVAS_DEC_FORCE_REND_UNFORCED ) { if ( ( error = IVAS_DEC_SetForcedRendMode( hIvasDec, arg.forcedRendMode ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError: Forcing binaural rendering mode failed (only TDREND and CLDFBREND are expected).\n\n" ); goto cleanup; } if ( arg.forcedRendMode == IVAS_DEC_FORCE_REND_TD_RENDERER ) { fprintf( stdout, "Forcing rendering to: TD renderer\n" ); } else if ( arg.forcedRendMode == IVAS_DEC_FORCE_REND_CLDFB_RENDERER ) { fprintf( stdout, "Forcing rendering to: CLDFB renderer\n" ); } } /*-----------------------------------------------------------------* * Open Error pattern file for simulation *-----------------------------------------------------------------*/ Loading Loading @@ -970,7 +946,6 @@ static bool parseCmdlIVAS_dec( #ifdef DEBUGGING float ftmp; arg->forcedRendMode = IVAS_DEC_FORCE_REND_UNFORCED; #ifdef DEBUG_FOA_AGC arg->agcBitstream = NULL; #endif Loading Loading @@ -1140,17 +1115,6 @@ static bool parseCmdlIVAS_dec( } i += 2; } else if ( strcmp( argv_to_upper, "-FORCE" ) == 0 ) { i++; if ( i < argc - 3 ) { strncpy( argv_to_upper, argv[i], sizeof( argv_to_upper ) - 1 ); argv_to_upper[sizeof( argv_to_upper ) - 1] = '\0'; arg->forcedRendMode = parseForcedRendModeDec( argv_to_upper ); i++; } } #ifdef DEBUG_MODE_INFO #ifdef DEBUG_MODE_INFO_TWEAK /* Define additional subfolder for debug info output in ./res */ Loading Loading @@ -3967,31 +3931,6 @@ static void do_object_editing( return; } #ifdef DEBUGGING /*---------------------------------------------------------------------* * parseForcedRendModeDec() * * *---------------------------------------------------------------------*/ static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( char *forcedRendModeChar ) { if ( ( strcmp( to_upper( forcedRendModeChar ), "TDREND" ) == 0 ) ) { return IVAS_DEC_FORCE_REND_TD_RENDERER; } if ( ( strcmp( to_upper( forcedRendModeChar ), "CLDFBREND" ) == 0 ) ) { return IVAS_DEC_FORCE_REND_CLDFB_RENDERER; } return IVAS_DEC_FORCE_REND_UNDEFINED; } #endif /*---------------------------------------------------------------------* * load_hrtf_from_file() Loading
apps/renderer.c +63 −51 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ #include "lib_rend.h" #include <assert.h> #include <math.h> #include <stdint.h> #include <string.h> #include "audio_file_reader.h" #include "audio_file_writer.h" Loading Loading @@ -190,7 +191,7 @@ typedef struct float lfeConfigElevation; bool lfeCustomRoutingEnabled; char inLfePanningMatrixFile[RENDERER_MAX_CLI_ARG_LENGTH]; float syncMdDelay; int16_t syncMdDelay; IVAS_RENDER_FRAMESIZE render_framesize; uint16_t directivityPatternId[RENDERER_MAX_ISM_INPUTS]; AcousticEnvironmentSequence aeSequence; Loading Loading @@ -720,6 +721,7 @@ int main( SplitFileReadWrite *hSplitRendFileReadWrite; int16_t delayNumSamples_temp; int32_t delayTimeScale_temp; bool flushRendererLastFrame = false; int16_t numSamplesRead; int16_t delayNumSamples = -1; int16_t delayNumSamples_orig = 0; Loading Loading @@ -766,8 +768,11 @@ int main( CmdlnArgs args = parseCmdlnArgs( argc, argv ); if ( args.nonDiegeticPan && !( ( args.inConfig.numAudioObjects == 0 && args.inConfig.multiChannelBuses[0].audioConfig == IVAS_AUDIO_CONFIG_MONO ) || ( args.inConfig.numAudioObjects > 0 && args.inConfig.audioObjects[0].audioConfig == IVAS_AUDIO_CONFIG_OBA && args.inConfig.numAudioObjects == 1 ) ) ) if ( args.nonDiegeticPan && !( ( args.inConfig.numAudioObjects == 0 && args.inConfig.multiChannelBuses[0].audioConfig == IVAS_AUDIO_CONFIG_MONO ) || ( args.inConfig.numAudioObjects > 0 && args.inConfig.audioObjects[0].audioConfig == IVAS_AUDIO_CONFIG_OBA && args.inConfig.numAudioObjects == 1 ) ) ) { fprintf( stderr, "\ninvalid configuration - non-diegetic panning requires mono or ISM1 input\n" ); goto cleanup; Loading Loading @@ -1088,7 +1093,10 @@ int main( IVAS_RENDER_CONFIG_DATA renderConfig; #endif /* sanity check */ if ( ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) && !is_split_pre_rend_mode( &args ) ) if ( ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) && !is_split_pre_rend_mode( &args ) ) { fprintf( stderr, "\nExternal Renderer Config is supported only when binaural output configurations is used as output OR when Split pre-rendering mode is enabled. Exiting. \n" ); goto cleanup; Loading Loading @@ -1402,7 +1410,7 @@ int main( } int16_t numOutChannels; if ( ( error = IVAS_REND_NumOutChannels( hIvasRend, &numOutChannels ) ) != IVAS_ERR_OK ) if ( ( error = IVAS_REND_GetNumOutChannels( hIvasRend, &numOutChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_REND_NumOutChannels(): %s\n", ivas_error_to_string( error ) ); goto cleanup; Loading @@ -1417,31 +1425,16 @@ int main( } } if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { if ( ( error = IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms, &bitsBuffer.config.isar_frame_size_ms ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_REND_GetSplitRendBitstreamHeader()!\n" ); goto cleanup; } if ( IVAS_REND_GetDelay( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { fprintf( stderr, "\nUnable to get delay of renderer!\n" ); goto cleanup; } char *outFile = args.outMetadataFilePath; if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, args.outputFilePath, delayNumSamples_temp, delayTimeScale_temp, bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, bitsBuffer.config.codec_frame_size_ms, bitsBuffer.config.isar_frame_size_ms, args.sampleRate, bitsBuffer.config.lc3plus_highres ) ) != IVAS_ERR_OK ) if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { fprintf( stderr, "\nCould not open split rend metadata file %s\n", args.outputFilePath ); goto cleanup; } outFile = args.outputFilePath; audioWriter = NULL; } else { if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { if ( ( error = IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms, &bitsBuffer.config.isar_frame_size_ms ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_REND_GetSplitRendBitstreamHeader()!\n" ); Loading @@ -1454,13 +1447,15 @@ int main( goto cleanup; } if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, args.outMetadataFilePath, delayNumSamples_temp, delayTimeScale_temp, bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, bitsBuffer.config.codec_frame_size_ms, bitsBuffer.config.isar_frame_size_ms, args.sampleRate, bitsBuffer.config.lc3plus_highres ) ) != IVAS_ERR_OK ) if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, outFile, delayNumSamples_temp, delayTimeScale_temp, bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, bitsBuffer.config.codec_frame_size_ms, bitsBuffer.config.isar_frame_size_ms, args.sampleRate, bitsBuffer.config.lc3plus_highres ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nCould not open split rend metadata file %s\n", args.outMetadataFilePath ); fprintf( stderr, "\nCould not open split rend metadata file %s\n", outFile ); goto cleanup; } } if ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { if ( AudioFileWriter_open( &audioWriter, args.outputFilePath, args.sampleRate, numOutChannels ) != IVAS_ERR_OK ) { fprintf( stderr, "\nFailed to open file: %s\n", args.outputFilePath ); Loading Loading @@ -1590,16 +1585,23 @@ int main( if ( numSamplesRead == 0 ) { /* end of input data */ break; flushRendererLastFrame = true; } /* Convert from int to float and from interleaved to packed */ if ( !flushRendererLastFrame ) { convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer, inBuffer.config.is_cldfb, cldfbAna ); } else { memset( inBuffer.data, 0, inBuffer.config.numChannels * inBuffer.config.numSamplesPerChannel * sizeof( float ) ); } int16_t num_subframes, sf_idx; num_subframes = (int16_t) args.render_framesize; if ( isCurrentFrameMultipleOf20ms ) if ( isCurrentFrameMultipleOf20ms && !flushRendererLastFrame ) { IsmPositionProvider_getNextFrame( positionProvider, &mtdBuffer ); Loading Loading @@ -1711,7 +1713,7 @@ int main( } IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.multiChannelBuses[i].inputChannelIndex, numChannels ); if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, mcIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, mcIds[i], tmpBuffer, flushRendererLastFrame ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_REND_FeedInputAudio failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; Loading @@ -1726,7 +1728,7 @@ int main( { IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.audioObjects[i].inputChannelIndex, args.inConfig.numAudioObjects ); if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, ismIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, ismIds[i], tmpBuffer, flushRendererLastFrame ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_REND_FeedInputAudio failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; Loading @@ -1743,7 +1745,7 @@ int main( { IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.audioObjects[i].inputChannelIndex, 1 ); if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, ismIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, ismIds[i], tmpBuffer, flushRendererLastFrame ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_REND_FeedInputAudio failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; Loading @@ -1766,7 +1768,7 @@ int main( } IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.ambisonicsBuses[i].inputChannelIndex, numChannels ); if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, sbaIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, sbaIds[i], tmpBuffer, flushRendererLastFrame ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_REND_FeedInputAudio failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; Loading @@ -1782,13 +1784,13 @@ int main( } IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.masaBuses[i].inputChannelIndex, numChannels ); if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, masaIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, masaIds[i], tmpBuffer, flushRendererLastFrame ) ) != IVAS_ERR_OK ) { fprintf( stderr, "IVAS_REND_FeedInputAudio failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; } if ( isCurrentFrameMultipleOf20ms ) if ( isCurrentFrameMultipleOf20ms && !flushRendererLastFrame ) { if ( masaReaders[i] != NULL ) { Loading Loading @@ -1851,7 +1853,7 @@ int main( zeroPad = delayNumSamples; } if ( is_split_pre_rend_mode( &args ) ) if ( is_split_pre_rend_mode( &args ) && !flushRendererLastFrame ) { if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead, &bitsBuffer.config.bitsWritten ) != IVAS_ERR_OK ) Loading @@ -1861,7 +1863,7 @@ int main( } } if ( audioWriter != NULL ) if ( audioWriter != NULL && !flushRendererLastFrame ) { if ( delayNumSamples * num_out_channels < outBufferSize ) { Loading @@ -1882,7 +1884,7 @@ int main( bitsBuffer.config.bitsWritten = 0; /* Write MASA metadata for MASA outputs */ if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_MASA1 || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_MASA2 ) if ( !flushRendererLastFrame && ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_MASA1 || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_MASA2 ) ) { IVAS_REND_AudioConfigType inputType1; IVAS_REND_AudioConfigType inputType2; Loading Loading @@ -1954,7 +1956,8 @@ int main( } } if ( ( args.inConfig.numAmbisonicsBuses > 0 || args.inConfig.numMultiChannelBuses > 0 || args.inConfig.numMasaBuses > 0 ) && args.inConfig.numAudioObjects > 0 ) if ( ( args.inConfig.numAmbisonicsBuses > 0 || args.inConfig.numMultiChannelBuses > 0 || args.inConfig.numMasaBuses > 0 ) && args.inConfig.numAudioObjects > 0 ) { inputType2 = IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED; if ( ( error = IVAS_REND_MergeMasaMetadata( hIvasRend, &hMetaOutput, inputType1, inputType2 ) ) != IVAS_ERR_OK ) Loading @@ -1970,6 +1973,13 @@ int main( } } /* no new input was actually read, only delay buffers were flushed * therefore this is not a real frame */ if ( flushRendererLastFrame ) { break; } frame++; if ( !args.quietModeEnabled ) { Loading @@ -1982,12 +1992,13 @@ int main( #endif } /* add zeros at the end to have equal length of synthesized signals */ /* add zeros at the end to have equal length of synthesized signals * the output buffer will contain either leftover input samples from delay aligned inputs * or zeros for padding */ if ( audioWriter != NULL ) { for ( zeroPadToWrite = zeroPad; zeroPadToWrite > frameSize_smpls; zeroPadToWrite -= frameSize_smpls ) { memset( outInt16Buffer, 0, outBufferSize * sizeof( int16_t ) ); if ( ( error = AudioFileWriter_write( audioWriter, outInt16Buffer, outBufferSize ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nOutput audio file writer error\n" ); Loading @@ -1995,7 +2006,6 @@ int main( } } memset( outInt16Buffer, 0, zeroPadToWrite * outBuffer.config.numChannels * sizeof( int16_t ) ); if ( ( error = AudioFileWriter_write( audioWriter, outInt16Buffer, zeroPadToWrite * outBuffer.config.numChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nOutput audio file writer error\n" ); Loading @@ -2004,9 +2014,10 @@ int main( zeroPadToWrite = 0; } if ( args.inConfig.numAudioObjects != 0 && ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) if ( args.inConfig.numAudioObjects != 0 && ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { fprintf( stdout, "\n\nMetadata delayed %d subframes\n\n", (int16_t) round( args.syncMdDelay / ( 1000 / IVAS_NUM_FRAMES_PER_SEC / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); fprintf( stdout, "\n\nMetadata delayed %d subframes\n\n", (int16_t) round( args.syncMdDelay / ( (float) BINAURAL_RENDERING_FRAME_SIZE_MS ) ) ); } if ( !args.quietModeEnabled && args.delayCompensationEnabled ) Loading Loading @@ -2917,7 +2928,7 @@ static void parseOption( case CmdLnOptionId_syncMdDelay: assert( numOptionValues == 1 ); /* Metadata Delay to sync with audio delay in ms */ args->syncMdDelay = strtof( optionValues[0], NULL ); args->syncMdDelay = (int16_t) strtol( optionValues[0], NULL, 10 ); break; default: assert( 0 && "This should be unreachable - all command line options should be explicitly handled." ); Loading Loading @@ -3400,7 +3411,8 @@ static void parseObjectPosition( *positionDuration = (uint16_t) strtol( line, &endptr, 10 ); readNextMetadataChunk( line, "\n" ); read_values = (int16_t) sscanf( line, "%f,%f,%f,%f,%f,%f,%f,%f", &meta_prm[0], &meta_prm[1], &meta_prm[2], &meta_prm[3], &meta_prm[4], &meta_prm[5], &meta_prm[6], &meta_prm[7] ); read_values = (int16_t) sscanf( line, "%f,%f,%f,%f,%f,%f,%f,%f", &meta_prm[0], &meta_prm[1], &meta_prm[2], &meta_prm[3], &meta_prm[4], &meta_prm[5], &meta_prm[6], &meta_prm[7] ); if ( read_values < 2 ) { Loading
lib_com/bitstream.c +2 −1 Original line number Diff line number Diff line Loading @@ -5380,7 +5380,7 @@ void evs_dec_previewFrame( return; } #ifndef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG void dtx_read_padding_bits( DEC_CORE_HANDLE st, Loading @@ -5396,3 +5396,4 @@ void dtx_read_padding_bits( return; } #endif
lib_com/fd_cng_com.c +5 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 ====================================================================================*/ #include "ivas_cnst.h" #include <assert.h> #include <stdint.h> #include "options.h" Loading Loading @@ -140,7 +141,11 @@ void initFdCngCom( hFdCngCom->msMinBufferPtr = 0; set_f( hFdCngCom->msAlphaCor, 0.3f, 2 ); #ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG set_f( hFdCngCom->coherence, 0.5f, MDCT_ST_DTX_NUM_COHERENCE_BANDS ); #else hFdCngCom->coherence = 0.5f; #endif return; } Loading
lib_com/ivas_cnst.h +5 −0 Original line number Diff line number Diff line Loading @@ -857,6 +857,11 @@ enum fea_names #define MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN 20 #define MDCT_ST_PLC_FADEOUT_DELAY_4_LSP_FADE 3 #ifdef NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG #define MDCT_ST_DTX_NUM_COHERENCE_BANDS 5 #define MDCT_ST_DTX_FIRST_BAND_OFFSET 2 #endif typedef enum { NOISE_GEN_MODE_UNDEF = -1, EQUAL_CORES = 0, Loading