From 0ac7509aa2cc44817c5fa0c55fac5e13e3f78059 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 26 Apr 2024 12:34:50 +0200 Subject: [PATCH 01/26] remove Opt_Limiter flag: the handle 'hDecoderConfig' should contain only parameters that are directly derived from the command-line --- lib_dec/ivas_jbm_dec.c | 4 ++-- lib_dec/ivas_stat_dec.h | 3 --- lib_dec/lib_dec.c | 5 ----- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index db2b95c0bf..d0ce75e87d 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1504,7 +1504,7 @@ ivas_error ivas_jbm_dec_render( nchan_out_syn_output = nchan_out; } - if ( st_ivas->hDecoderConfig->Opt_Limiter ) + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) #endif { if ( st_ivas->ivas_format != MONO_FORMAT ) @@ -1784,7 +1784,7 @@ ivas_error ivas_jbm_dec_flush_renderer( /* Only write out the valid data*/ #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( st_ivas->hDecoderConfig->Opt_Limiter ) + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) #endif { if ( st_ivas->ivas_format != MONO_FORMAT ) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 38efc50126..3e6ba620e2 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1026,9 +1026,6 @@ typedef struct decoder_config_structure int16_t force_rend; /* forced TD/CLDFB binaural renderer (for ISM and MC) */ #endif int16_t Opt_tsm; /* indicates whether time scaling modification is activated */ -#ifdef SPLIT_REND_WITH_HEAD_ROT - int16_t Opt_Limiter; -#endif IVAS_RENDER_FRAMESIZE render_framesize; int16_t Opt_delay_comp; /* flag indicating delay compensation active */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 71f89ea508..866d061c9c 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -309,9 +309,6 @@ static void init_decoder_config( hDecoderConfig->Opt_non_diegetic_pan = 0; hDecoderConfig->non_diegetic_pan_gain = 0; hDecoderConfig->Opt_tsm = 0; -#ifdef SPLIT_REND_WITH_HEAD_ROT - hDecoderConfig->Opt_Limiter = 1; -#endif hDecoderConfig->Opt_delay_comp = 0; hDecoderConfig->Opt_ExternalOrientation = 0; hDecoderConfig->Opt_dpid_on = 0; @@ -550,8 +547,6 @@ ivas_error IVAS_DEC_EnableSplitRendering( hDecoderConfig->Opt_Headrotation = 1; hDecoderConfig->render_framesize = IVAS_RENDER_FRAMESIZE_20MS; - hDecoderConfig->Opt_Limiter = 0; - return error; } #endif -- GitLab From 646d7633f4b2c723928de4e9ec65a56ef765cd38 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 29 Apr 2024 14:35:36 +0200 Subject: [PATCH 02/26] formatting --- apps/decoder.c | 19 +- apps/isar_post_rend.c | 56 +++- apps/renderer.c | 9 +- lib_com/common_api_types.h | 1 + lib_com/delay_comp.c | 6 +- lib_com/ivas_prot.h | 2 +- lib_com/prot.h | 13 +- lib_dec/ivas_binRenderer_internal.c | 4 +- lib_dec/ivas_dirac_dec.c | 10 +- lib_dec/ivas_init_dec.c | 10 +- lib_dec/ivas_ism_dec.c | 20 +- lib_dec/ivas_jbm_dec.c | 7 +- lib_dec/ivas_masa_dec.c | 1 + lib_dec/ivas_mct_dec.c | 2 - lib_dec/ivas_omasa_dec.c | 8 +- lib_dec/ivas_osba_dec.c | 5 +- lib_dec/ivas_output_config.c | 6 +- lib_dec/ivas_sba_dec.c | 6 +- lib_dec/ivas_stat_dec.h | 2 +- lib_dec/lib_dec.c | 60 ++-- lib_dec/lib_dec.h | 25 +- lib_enc/lib_enc.c | 2 +- lib_isar/isar_PredDecoder.c | 59 +++- lib_isar/isar_PredEncoder.c | 21 +- lib_isar/isar_lc3plus_dec.c | 6 +- lib_isar/isar_lc3plus_dec.h | 2 +- lib_isar/isar_lcld_decoder.c | 202 ++++++++++--- lib_isar/isar_lcld_encoder.c | 31 +- lib_isar/isar_lcld_prot.h | 9 +- lib_isar/isar_prot.h | 297 +++++++++++-------- lib_isar/isar_rom_lcld_tables.c | 5 + lib_isar/isar_rom_lcld_tables.h | 8 +- lib_isar/isar_rom_post_rend.c | 2 +- lib_isar/isar_rom_post_rend.h | 2 +- lib_isar/isar_splitRend_lcld_dec.c | 16 +- lib_isar/isar_splitRend_lcld_enc.c | 10 +- lib_isar/isar_splitRendererPLC.c | 6 +- lib_isar/isar_splitRendererPost.c | 64 ++-- lib_isar/isar_splitRendererPre.c | 145 ++++----- lib_isar/isar_splitRenderer_utils.c | 97 +++--- lib_isar/isar_stat.h | 4 - lib_isar/lib_isar_post_rend.c | 72 +++-- lib_isar/lib_isar_post_rend.h | 20 +- lib_isar/lib_isar_pre_rend.c | 84 +++--- lib_isar/lib_isar_pre_rend.h | 59 ++-- lib_rend/ivas_crend.c | 173 +---------- lib_rend/ivas_dirac_dec_binaural_functions.c | 22 +- lib_rend/ivas_prot_rend.h | 22 +- lib_rend/ivas_render_config.c | 1 + lib_rend/ivas_rotation.c | 32 +- lib_rend/ivas_stat_rend.h | 23 +- lib_rend/lib_rend.c | 96 +++--- lib_rend/lib_rend.h | 15 +- lib_util/split_rend_bfi_file_reader.c | 5 +- lib_util/split_rend_bfi_file_reader.h | 3 +- lib_util/split_render_file_read_write.c | 2 +- lib_util/split_render_file_read_write.h | 10 +- 57 files changed, 1012 insertions(+), 887 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index de0dd8bca9..d9cf23f0d2 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -486,7 +486,7 @@ int main( { if ( ( error = IVAS_DEC_EnableSplitRendering( hIvasDec ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + fprintf( stderr, "\nSplit rendering configure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } @@ -662,8 +662,7 @@ int main( } #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || - arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { if ( asked_frame_size != IVAS_RENDER_FRAMESIZE_20MS && ( renderConfig.split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || @@ -1461,7 +1460,7 @@ static bool parseCmdlIVAS_dec( arg->outputMdFilename = argv[i + 1]; if ( arg->outputMdFilename[0] == '\0' ) { - fprintf( stderr, "Error: output metadata file path not specified\n\n" ); + fprintf( stderr, "Error: Split rendering output metadata file path not specified\n\n" ); usage_dec(); return false; } @@ -2258,6 +2257,7 @@ static ivas_error decodeG192( } } #endif + for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) { ismWriters[i] = NULL; @@ -2569,10 +2569,8 @@ static ivas_error decodeG192( #endif #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, IVAS_DEC_PCM_INT16, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) - #else if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) - #endif { fprintf( stderr, "\nError in IVAS_DEC_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -2917,6 +2915,7 @@ static ivas_error decodeG192( *------------------------------------------------------------------------------------------*/ memset( pcmBuf, 0, delayNumSamples_orig[0] * nOutChannels * sizeof( int16_t ) ); + #ifdef SPLIT_REND_WITH_HEAD_ROT if ( afWriter != NULL ) { @@ -3327,12 +3326,11 @@ static ivas_error decodeVoIP( for ( i = 0; i < num_subframes; i++ ) { - if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i #ifdef SPLIT_REND_WITH_HEAD_ROT - , - DEFAULT_AXIS + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i, DEFAULT_AXIS ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -3419,7 +3417,6 @@ static ivas_error decodeVoIP( /* decode and get samples */ - #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SUPPORT_JBM_TRACEFILE if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK ) diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index 9060ed9c4c..29da43e323 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 ); static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamplesPerChannel, const int16_t numChannels, int16_t *intBuffer ); + /*------------------------------------------------------------------------------------------* * Local functions *------------------------------------------------------------------------------------------*/ @@ -275,10 +276,6 @@ static int16_t getTotalNumInChannels( return totalNumInChannels; } -/*------------------------------------------------------------------------------------------* - * Local functions - *------------------------------------------------------------------------------------------*/ - static const CmdLnParser_Option *findOptionById( const int32_t id ) { @@ -440,6 +437,7 @@ static bool checkRequiredArgs( return !missingRequiredArg; } + static CmdlnArgs defaultArgs( const char *executableName ) { @@ -470,6 +468,7 @@ static CmdlnArgs defaultArgs( return args; } + static void parseOption( const int32_t optionId, char **optionValues, @@ -562,6 +561,7 @@ static void parseOption( return; } + static CmdlnArgs parseCmdlnArgs( const int argc, char **argv ) @@ -600,6 +600,7 @@ static void printSupportedAudioConfigs( void ) return; } + /*--------------------------------------------------------------------------* * convertInputBuffer() * @@ -638,6 +639,7 @@ static void convertInputBuffer( return; } + /*--------------------------------------------------------------------------* * convertOutputBuffer() * @@ -679,6 +681,7 @@ static void convertOutputBuffer( return; } + /*------------------------------------------------------------------------------------------* * main() * @@ -732,6 +735,9 @@ int main( bitsBuffer.config.poseCorrection = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; bitsBuffer.config.codec_frame_size_ms = 20; + /*------------------------------------------------------------------------------------------* + * Parse command-line arguments + *------------------------------------------------------------------------------------------*/ CmdlnArgs args = parseCmdlnArgs( argc, argv ); @@ -739,6 +745,10 @@ int main( convert_backslash( args.outputFilePath ); convert_backslash( args.headRotationFilePath ); + /*------------------------------------------------------------------------------------------* + * Open head-rotation file + *------------------------------------------------------------------------------------------*/ + if ( !isEmptyString( args.headRotationFilePath ) ) { if ( RotationFileReader_open( args.headRotationFilePath, &headRotReader ) != IVAS_ERR_OK ) @@ -748,12 +758,20 @@ int main( } } + /*------------------------------------------------------------------------------------------* + * Open BFI file + *------------------------------------------------------------------------------------------*/ + if ( !isEmptyString( args.splitRendBFIFilePath ) ) { convert_backslash( args.splitRendBFIFilePath ); SplitRendBFIFileReader_open( args.splitRendBFIFilePath, &splitRendBFIReader ); } + /*------------------------------------------------------------------------------------------* + * Open input files + *------------------------------------------------------------------------------------------*/ + strncpy( audioFilePath, args.inputFilePath, FILENAME_MAX - 1 ); hSplitRendFileReadWrite = NULL; if ( ( args.inConfig.numBinBuses > 0 ) && ( args.inConfig.binBuses[0].audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) @@ -831,6 +849,11 @@ int main( exit( -1 ); } } + + /*------------------------------------------------------------------------------------------* + * Open ISAR handle + *------------------------------------------------------------------------------------------*/ + const int16_t frameSize_smpls = (int16_t) ( ( args.render_framesize ) * args.sampleRate * 5 / ( 1000 ) ); args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_BINAURAL; if ( ( error = ISAR_POST_REND_open( &hIsarPostRend, args.sampleRate, args.outConfig.audioConfig, true, 0, 0.0, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK ) @@ -839,7 +862,10 @@ int main( exit( -1 ); } - /* === Configure === */ + /*------------------------------------------------------------------------------------------* + * Configuration + *------------------------------------------------------------------------------------------*/ + if ( ( error = ISAR_POST_REND_InitConfig( hIsarPostRend, args.outConfig.audioConfig ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error in Renderer Config Init: %s\n", ivas_error_to_string( error ) ); @@ -856,9 +882,7 @@ int main( } } - ISAR_POST_REND_InputId splitBinIds[RENDERER_MAX_BIN_INPUTS]; - for ( i = 0; i < RENDERER_MAX_BIN_INPUTS; i++ ) { splitBinIds[i] = 0u; @@ -874,7 +898,6 @@ int main( } const int16_t totalNumInChannels = getTotalNumInChannels( hIsarPostRend, splitBinIds ); - if ( inFileNumChannels != 0 /* inFileNumChannels is 0 with raw PCM input */ && totalNumInChannels != inFileNumChannels ) { fprintf( stderr, "Number of channels in input file does not match selected configuration\n" ); @@ -882,13 +905,16 @@ int main( } int16_t numOutChannels = 2; - if ( AudioFileWriter_open( &audioWriter, args.outputFilePath, args.sampleRate, numOutChannels ) != IVAS_ERR_OK ) { fprintf( stderr, "Failed to open file: %s\n", args.outputFilePath ); exit( -1 ); } + /*------------------------------------------------------------------------------------------* + * Allocate processing buffers + *------------------------------------------------------------------------------------------*/ + inBufferSize = frameSize_smpls * totalNumInChannels; outBufferSize = frameSize_smpls * numOutChannels; inpInt16Buffer = malloc( inBufferSize * sizeof( int16_t ) ); @@ -941,6 +967,13 @@ int main( fprintf( stdout, "\n\n-- Start the ISAR post renderer (quiet mode) --\n\n" ); } + /*------------------------------------------------------------------------------------------* + * Loop for every frame of data + * - Read the input data + * - Run the post-rendering + * - Write the data into output file + *------------------------------------------------------------------------------------------*/ + while ( 1 ) { int16_t num_in_channels; @@ -1171,7 +1204,10 @@ int main( } #endif - /* === Close === */ + /*------------------------------------------------------------------------------------------* + * Close files and deallocate resources + *------------------------------------------------------------------------------------------*/ + free( inpInt16Buffer ); free( inFloatBuffer ); free( outInt16Buffer ); diff --git a/apps/renderer.c b/apps/renderer.c index d6123d53ca..ae32ad47b7 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -657,6 +657,7 @@ static int16_t get_cldfb_in_flag( return cldfb_in_flag; } + static int16_t is_split_pre_rend_mode( CmdlnArgs *args ) { @@ -827,6 +828,7 @@ int main( SplitRendBFIFileReader_open( args.splitRendBFIFilePath, &splitRendBFIReader ); } #endif + if ( !isEmptyString( args.externalOrientationFilePath ) ) { if ( RotationFileReader_open( args.externalOrientationFilePath, &externalOrientationFileReader ) != IVAS_ERR_OK ) @@ -1062,7 +1064,6 @@ int main( } #endif - if ( ( error = IVAS_REND_GetRenderConfig( hIvasRend, &renderConfig ) ) != IVAS_ERR_OK ) { #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -1778,7 +1779,7 @@ int main( { if ( ( error = IVAS_REND_GetSplitBinauralBitstream( hIvasRend, outBuffer, &bitsBuffer ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + fprintf( stderr, "Error in IVAS_REND_GetSplitBinauralBitstream(): %s\n", ivas_error_to_string( error ) ); exit( -1 ); } } @@ -1788,7 +1789,7 @@ int main( if ( ( error = IVAS_REND_GetSamples( hIvasRend, outBuffer ) ) != IVAS_ERR_OK ) { #ifdef SPLIT_REND_WITH_HEAD_ROT - fprintf( stderr, "Error %s\n", ivas_error_to_string( error ) ); + fprintf( stderr, "Error inIVAS_REND_GetSamples()%s\n", ivas_error_to_string( error ) ); #else fprintf( stderr, "Error in getting samples\n" ); #endif @@ -1994,7 +1995,6 @@ int main( } #endif - 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 ) ) ); @@ -2033,6 +2033,7 @@ cleanup: free( bitsBufferData ); } #endif + #ifdef FIX_1053_REVERB_RECONFIGURATION if ( args.aeSequence.count > 0 ) { diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 1d4cde9680..f1b358fcf4 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -335,6 +335,7 @@ typedef struct #ifdef SPLIT_REND_WITH_HEAD_ROT int16_t is_cldfb; #endif + } IVAS_REND_AudioBufferConfig; typedef struct diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c index 2d62e340a8..5a286aff70 100644 --- a/lib_com/delay_comp.c +++ b/lib_com/delay_comp.c @@ -55,8 +55,8 @@ int32_t get_delay( const int32_t io_fs, /* i : input/output sampling frequency */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ #ifdef SPLIT_REND_WITH_HEAD_ROT - HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ - const AUDIO_CONFIG output_config /* i : decoder output config */ + HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ + const int16_t flag_split_rendering /* i : split rendering on/off flag */ #else HANDLE_CLDFB_FILTER_BANK hCldfb /* i : Handle of Cldfb analysis */ #endif @@ -103,7 +103,7 @@ int32_t get_delay( delay = IVAS_DEC_DELAY_NS; #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) + if ( !flag_split_rendering ) { #endif if ( hCldfb != NULL ) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index d7f4f56313..97a55f68bc 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5175,7 +5175,7 @@ void ivas_binaural_cldfb_sf( void ivas_binRenderer( BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ #endif COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle */ const int16_t numTimeSlots, /* i : number of time slots to process */ diff --git a/lib_com/prot.h b/lib_com/prot.h index 1e08bbfec1..75e781df16 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -724,13 +724,14 @@ int16_t lev_dur( /*! r: delay value in ns */ int32_t get_delay( - const int16_t enc_dec, /* i : encoder/decoder flag */ - const int32_t io_fs, /* i : input/output sampling frequency */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - HANDLE_CLDFB_FILTER_BANK hCldfb /* i : Handle of Cldfb analysis */ + const int16_t enc_dec, /* i : encoder/decoder flag */ + const int32_t io_fs, /* i : input/output sampling frequency */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ #ifdef SPLIT_REND_WITH_HEAD_ROT - , - const AUDIO_CONFIG output_config /* i : decoder output config */ + HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ + const int16_t flag_split_rendering /* i : split rendering on/off flag */ +#else + HANDLE_CLDFB_FILTER_BANK hCldfb /* i : Handle of Cldfb analysis */ #endif ); diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index b4f80c4dfd..d739214755 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -405,6 +405,7 @@ static ivas_error ivas_binRenderer_convModuleOpen( set_zero( hBinRenConvModule->filterStatesLeftReal[bandIdx][chIdx], hBinRenConvModule->numTapsArray[bandIdx] ); set_zero( hBinRenConvModule->filterStatesLeftImag[bandIdx][chIdx], hBinRenConvModule->numTapsArray[bandIdx] ); #endif + if ( isLoudspeaker ) { hBinRenConvModule->filterTapsLeftReal[bandIdx][chIdx] = hHrtf->leftBRIRReal[bandIdx][tmp]; @@ -2215,13 +2216,14 @@ void ivas_rend_CldfbMultiBinRendProcess( head_track_post.num_quaternions = 0; head_track_post.shd_rot_max_order = -1; head_track_post.Quaternions[0] = ivas_split_rend_get_sf_rot_data( pHeadRotData->headPositionsPostRend, sf_idx ); -#endif +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG ivas_binRenderer( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, MAX_PARAM_SPATIAL_SUBFRAMES, &head_track_post, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn ); #else ivas_binRenderer( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, MAX_PARAM_SPATIAL_SUBFRAMES, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn ); #endif + for ( pose_idx = 0; pose_idx < hCldfbRend->numPoses; pose_idx++ ) { for ( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 842bac31c5..5ae003f817 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -913,7 +913,6 @@ ivas_error ivas_dirac_dec_config( #else if ( !st_ivas->hDiracDecBin->useTdDecorr ) #endif - { #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params == NULL ) @@ -2358,17 +2357,16 @@ void ivas_dirac_dec_render_sf( #endif /* Perform binaural rendering */ - ivas_binRenderer( st_ivas->hBinRenderer, #ifdef SPLIT_REND_WITH_HEAD_ROT - &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, + ivas_binRenderer( st_ivas->hBinRenderer, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, hSpatParamRendCom->subframe_nbslots[subframe_idx], +#else + ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, hSpatParamRendCom->subframe_nbslots[subframe_idx], #endif - - st_ivas->hCombinedOrientationData, - hSpatParamRendCom->subframe_nbslots[subframe_idx], #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG NULL, #endif Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index db95801840..1b3c7c7505 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -236,6 +236,7 @@ static ivas_error ivas_dec_init_split_rend( } error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend.splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, (int16_t) st_ivas->hDecoderConfig->render_framesize, mixed_td_cldfb_flag ); + return error; } #endif @@ -251,8 +252,8 @@ ivas_error ivas_dec_setup( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else int16_t *data /* o : output synthesis signal */ #endif @@ -407,7 +408,6 @@ ivas_error ivas_dec_setup( #else if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - { return error; } @@ -1242,7 +1242,7 @@ ivas_error ivas_init_decoder( #ifdef SPLIT_REND_WITH_HEAD_ROT /*-----------------------------------------------------------------* - * Initialize binuaral split rendering + * Initialize binaural split rendering *-----------------------------------------------------------------*/ if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || @@ -2728,7 +2728,6 @@ void ivas_destroy_dec( #endif /* Crend handle */ - #ifdef SPLIT_REND_WITH_HEAD_ROT ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ); #else @@ -2884,6 +2883,7 @@ void ivas_init_dec_get_num_cldfb_instances( *numCldfbAnalyses = st_ivas->nchan_transport + 1; } } + #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDiracDecBin[0]->useTdDecorr ) #else diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index ef13d2463d..e82a7c516c 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -437,17 +437,15 @@ ivas_error ivas_ism_dec_config( if ( st_ivas->ini_active_frame != 0 ) { /* ISM bit-rate switching */ + if ( ( st_ivas->ism_mode != last_ism_mode ) || ( st_ivas->hDecoderConfig->ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) ) { - if ( ( st_ivas->ism_mode != last_ism_mode ) || ( st_ivas->hDecoderConfig->ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) ) - { - if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, #ifdef SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) - { - return error; - } + { + return error; } } } @@ -467,11 +465,11 @@ ivas_error ivas_ism_dec_config( /* ISM mode switching */ if ( st_ivas->ism_mode != last_ism_mode ) { - if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, #ifdef SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index d0ce75e87d..e3255df3d0 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1340,9 +1340,6 @@ ivas_error ivas_jbm_dec_render( } else { -#endif - -#if defined SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs, 0 ) ) != IVAS_ERR_OK ) #else @@ -1402,7 +1399,7 @@ ivas_error ivas_jbm_dec_render( if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) && !st_ivas->hDecoderConfig->Opt_Headrotation ) { #ifdef SPLIT_REND_WITH_HEAD_ROT - /*handled in CLDFB domain already*/ + /* handled in CLDFB domain already */ if ( output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) #endif { @@ -1564,7 +1561,7 @@ ivas_error ivas_jbm_dec_flush_renderer( uint16_t *nSamplesRendered, /* o : number of samples flushed */ #ifdef SPLIT_REND_WITH_HEAD_ROT const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ + void *data /* o : output synthesis signal */ #else int16_t *data /* o : output synthesis signal */ #endif diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 3d05c01ad4..ad7b1a10ee 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1431,6 +1431,7 @@ ivas_error ivas_masa_dec_reconfigure( /*-----------------------------------------------------------------* * TD Decorrelator *-----------------------------------------------------------------*/ + #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDiracDecBin[0] != NULL ) #else diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 368f6e76b7..09ffa2bcb0 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -687,7 +687,6 @@ ivas_error ivas_mc_dec_config( #else if ( ( error = ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - { return error; } @@ -1200,7 +1199,6 @@ static ivas_error ivas_mc_dec_reconfig( if ( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hCrend != NULL ) && ( st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV && st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV_ROOM && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD || st_ivas->hIntSetup.output_config != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) #endif { - #ifdef SPLIT_REND_WITH_HEAD_ROT ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ); #else diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 2c636cd58c..09ff993371 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -189,11 +189,11 @@ void ivas_omasa_data_close( *--------------------------------------------------------------------------*/ ivas_error ivas_omasa_dec_config( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else int16_t *data /* o : output synthesis signal */ #endif @@ -508,7 +508,6 @@ ivas_error ivas_omasa_dec_config( #else if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) #endif - { return error; } @@ -849,6 +848,7 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm( #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif + return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 37ddcd37d2..e884f2bce7 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -155,7 +155,6 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( return error; } - #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { @@ -167,10 +166,12 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( num_cldfb_bands = st_ivas->hSplitBinRend.splitrend.hCldfbHandles->cldfbAna[0]->no_channels; nchan_transport_orig = st_ivas->nchan_transport; st_ivas->nchan_transport = st_ivas->nchan_ism; + if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, output_f, *nSamplesRendered ) ) != IVAS_ERR_OK ) { return error; } + st_ivas->nchan_transport = nchan_transport_orig; cldfb_slots = *nSamplesRendered / num_cldfb_bands; @@ -196,7 +197,6 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( else { #endif - if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_sepobj, *nSamplesRendered ) ) != IVAS_ERR_OK ) { return error; @@ -213,6 +213,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif + return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 84672f3583..76acf9cce7 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -157,11 +157,11 @@ void ivas_renderer_select( { *internal_config = IVAS_AUDIO_CONFIG_HOA3; - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL #ifdef SPLIT_REND_WITH_HEAD_ROT - || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL ) #endif - ) { *renderer_type = RENDERER_BINAURAL_FASTCONV; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 1b676b2a1b..ea4e7a3766 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -194,11 +194,11 @@ ivas_error ivas_sba_dec_reconfigure( } else { - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL #ifdef SPLIT_REND_WITH_HEAD_ROT - || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL ) #endif - ) { renderer_type_new = RENDERER_BINAURAL_FASTCONV; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 3e6ba620e2..c8cc5a39d0 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1137,7 +1137,7 @@ typedef struct Decoder_Struct #ifdef SPLIT_REND_WITH_HEAD_ROT ISAR_DEC_SPLIT_REND_WRAPPER hSplitBinRend; /* ISAR split binaural rendering handle */ - BINAURAL_TD_OBJECT_RENDERER_HANDLE hTdRendHandles[MAX_HEAD_ROT_POSES - 1]; + BINAURAL_TD_OBJECT_RENDERER_HANDLE hTdRendHandles[MAX_HEAD_ROT_POSES - 1]; /* TD object renderer handles */ #endif /* JBM module */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 866d061c9c..bd439130a2 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -251,6 +251,7 @@ ivas_error IVAS_DEC_Open( return IVAS_ERR_WRONG_PARAMS; } + #ifdef SPLIT_REND_WITH_HEAD_ROT /*-------------------------------------------------------------------------* * isar_set_split_rend_setup() @@ -262,7 +263,7 @@ static ivas_error isar_set_split_rend_setup( ISAR_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, const ISAR_SPLIT_REND_CONFIG_DATA *hSplitBinConfig, const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, - ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ ) { splitRendBits->bits_read = 0; @@ -528,14 +529,10 @@ ivas_error IVAS_DEC_Configure( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_EnableSplitRendering( - IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ ) { DECODER_CONFIG_HANDLE hDecoderConfig; - ivas_error error; - - error = IVAS_ERR_OK; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { @@ -547,7 +544,7 @@ ivas_error IVAS_DEC_EnableSplitRendering( hDecoderConfig->Opt_Headrotation = 1; hDecoderConfig->render_framesize = IVAS_RENDER_FRAMESIZE_20MS; - return error; + return IVAS_ERR_OK; } #endif @@ -885,13 +882,13 @@ ivas_error IVAS_DEC_GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const int16_t nSamplesAsked, /* i : number of samples wanted by the caller */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ - void *pcmBuf, /* o : output synthesis signal */ + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf, /* o : output synthesis signal */ #else int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ #endif int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ - bool *needNewFrame /* o :indication that the decoder needs a new frame */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ ) { ivas_error error; @@ -964,7 +961,6 @@ ivas_error IVAS_DEC_GetSamples( if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { /* setup */ - #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ) ) ) != IVAS_ERR_OK ) #else @@ -1078,11 +1074,11 @@ ivas_error IVAS_DEC_GetSamples( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetSplitBinauralBitstream( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - void *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */ - ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ - int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ - bool *needNewFrame /* o : indication that the decoder needs a new frame */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + void *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ + int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ ) { Decoder_Struct *st_ivas; @@ -1151,7 +1147,6 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( } } - /* Decode and render */ if ( ( error = IVAS_DEC_GetSamples( hIvasDec, numSamplesPerChannelToDecode, IVAS_DEC_PCM_FLOAT, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) { @@ -1221,6 +1216,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( Quaternion.y = 0.0f; Quaternion.z = 0.0f; } + if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, Quaternion, st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, @@ -1424,10 +1420,10 @@ static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const uint16_t nSamplesForRendering, /* i : number of TC samples wanted from the renderer */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ - uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the renerer pipeline */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the renderer pipeline */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, - void *pcmBuf + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf /* o : output synthesis signal */ #else int16_t *pcmBuf #endif @@ -2104,6 +2100,7 @@ static ivas_error copyRendererConfigStruct( mvr2r( hRCin->roomAcoustics.pAcoustic_rt60, hRCout->roomAcoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX ); mvr2r( hRCin->roomAcoustics.pAcoustic_dsr, hRCout->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); mvr2r( hRCin->directivity, hRCout->directivity, 3 * MAX_NUM_OBJECTS ); + #ifdef SPLIT_REND_WITH_HEAD_ROT hRCout->split_rend_config.splitRendBitRate = SPLIT_REND_768k; hRCout->split_rend_config.dof = 3; @@ -2113,6 +2110,7 @@ static ivas_error copyRendererConfigStruct( hRCout->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; hRCout->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; hRCout->split_rend_config.rendererSelection = hRCin->split_rend_config.rendererSelection; + #endif hRCout->roomAcoustics.use_er = hRCin->roomAcoustics.use_er; hRCout->roomAcoustics.lowComplexity = hRCin->roomAcoustics.lowComplexity; @@ -2337,7 +2335,7 @@ ivas_error IVAS_DEC_GetDelay( hDecoderConfig = st_ivas->hDecoderConfig; #ifdef SPLIT_REND_WITH_HEAD_ROT - nSamples[1] = NS2SA( hDecoderConfig->output_Fs, get_delay( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbSynDec[0], hDecoderConfig->output_config ) ); + nSamples[1] = NS2SA( hDecoderConfig->output_Fs, get_delay( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbSynDec[0], hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ); #else nSamples[1] = NS2SA( hDecoderConfig->output_Fs, get_delay( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbSynDec[0] ) ); #endif @@ -2615,8 +2613,8 @@ ivas_error IVAS_DEC_VoIP_GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, - void *pcmBuf, + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf, /* o : output synthesis signal */ #else int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ #endif @@ -2837,8 +2835,8 @@ ivas_error IVAS_DEC_Flush( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const int16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, - void *pcmBuf, + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf, /* o : output synthesis signal */ #else int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ #endif @@ -3801,10 +3799,11 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetSplitRendBitstreamHeader( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */ - ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */ - int16_t *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ ) + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + ISAR_SPLIT_REND_CODEC *pCodec, /* o : pointer to codec setting */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o : pointer to pose correction mode */ + int16_t *pCodec_frame_size_ms /* o : pointer to codec frame size setting */ +) { if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { @@ -3814,6 +3813,7 @@ ivas_error IVAS_DEC_GetSplitRendBitstreamHeader( *pCodec = hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec; *pCodec_frame_size_ms = hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms; *poseCorrection = hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode; + return IVAS_ERR_OK; } @@ -3971,6 +3971,7 @@ PCM_RESOLUTION pcm_type_API_to_internal( * *---------------------------------------------------------------------*/ +/*! r: flag to indicate if split rendering is enabled */ int16_t IVAS_DEC_is_split_rendering_enabled( IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ ) @@ -4001,6 +4002,7 @@ int16_t IVAS_DEC_is_split_rendering_enabled( * *---------------------------------------------------------------------*/ +/*! r: flag to indicate if split rendering coded output is enabled */ int16_t IVAS_DEC_is_split_rendering_coded_out( IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ ) diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 9a2b6d4b16..58cf99d768 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -179,10 +179,10 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( /*! r: decoder error code */ ivas_error IVAS_DEC_GetSplitRendBitstreamHeader( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */ - ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */ - int16_t *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + ISAR_SPLIT_REND_CODEC *pCodec, /* o : pointer to codec setting */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o : pointer to pose correction mode */ + int16_t *pCodec_frame_size_ms /* o : pointer to codec frame size setting */ ); /*! r: decoder error code */ @@ -194,11 +194,14 @@ ivas_error IVAS_DEC_GetCldfbSamples( int16_t *nOutSamples /* o : number of samples per channel written to output buffer */ ); +/*! r: flag to indicate if split rendering is enabled */ int16_t IVAS_DEC_is_split_rendering_enabled( - IVAS_DEC_HANDLE hIvasDec /* i: IVAS decoder handle */ + IVAS_DEC_HANDLE hIvasDec /* i : IVAS decoder handle */ ); + +/*! r: flag to indicate if split rendering coded output is enabled */ int16_t IVAS_DEC_is_split_rendering_coded_out( - IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ ); #endif @@ -280,9 +283,9 @@ ivas_error IVAS_DEC_TSM_SetQuality( ivas_error IVAS_DEC_VoIP_GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ -#ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, - void *pcmBuf, +#ifdef SPLIT_REND_WITH_HEAD_ROT + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf, /* o : output synthesis signal */ #else int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ #endif @@ -297,8 +300,8 @@ ivas_error IVAS_DEC_Flush( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const int16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, - void *pcmBuf, + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf, /* o : output synthesis signal */ #else int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ #endif diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 4a4be81734..ccdc82d122 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -1058,7 +1058,7 @@ ivas_error IVAS_ENC_GetDelay( } #ifdef SPLIT_REND_WITH_HEAD_ROT - *delay = NS2SA( hEncoderConfig->input_Fs, get_delay( ENC, hEncoderConfig->input_Fs, hEncoderConfig->ivas_format, NULL, IVAS_AUDIO_CONFIG_INVALID ) ); + *delay = NS2SA( hEncoderConfig->input_Fs, get_delay( ENC, hEncoderConfig->input_Fs, hEncoderConfig->ivas_format, NULL, 0 ) ); #else *delay = NS2SA( hEncoderConfig->input_Fs, get_delay( ENC, hEncoderConfig->input_Fs, hEncoderConfig->ivas_format, NULL ) ); #endif diff --git a/lib_isar/isar_PredDecoder.c b/lib_isar/isar_PredDecoder.c index 48031a865d..bec61755c0 100644 --- a/lib_isar/isar_PredDecoder.c +++ b/lib_isar/isar_PredDecoder.c @@ -40,6 +40,7 @@ #include "isar_rom_lcld_tables.h" #include "wmc_auto.h" + /*-------------------------------------------------------------------* * Function CreatePredictionDecoder() * @@ -64,6 +65,7 @@ ivas_error CreatePredictionDecoder( psPredictionDecoder->iNumBlocks = iNumBlocks; psPredictionDecoder->iNumSubSets = LCLD_BLOCKS_PER_FRAME / psPredictionDecoder->iNumBlocks; psPredictionDecoder->iSubSetId = 0; + /* PLC_IMPROVEMENT */ if ( ( psPredictionDecoder->ppiDecodingFailedPrev = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL ) { @@ -77,6 +79,7 @@ ivas_error CreatePredictionDecoder( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); } + for ( n = 0; n < iChannels; n++ ) { int32_t k; @@ -99,6 +102,7 @@ ivas_error CreatePredictionDecoder( psPredictionDecoder->ppiDecodingFailedPrev[n][k] = 0; } } + if ( ( psPredictionDecoder->piPredChanEnable = (int32_t *) malloc( sizeof( int32_t ) * iChannels ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); @@ -241,13 +245,14 @@ void DeletePredictionDecoder( return; } + /*-------------------------------------------------------------------* * Function ReadPredictors() * * *-------------------------------------------------------------------*/ -int32_t ReadPredictors( +int16_t ReadPredictors( PredictionDecoder *psPredictionDecoder, ISAR_SPLIT_REND_BITS_HANDLE pBits ) { @@ -270,6 +275,7 @@ int32_t ReadPredictors( { psPredictionDecoder->iSubSetId = 0; } + for ( c = 0; c < psPredictionDecoder->iChannels; c++ ) { psPredictionDecoder->piPredChanEnable[c] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, psPredictionDecoder->iNumSubSets ); @@ -337,8 +343,15 @@ int32_t ReadPredictors( return iBitsRead; } -/* PLC_IMPROVEMENT */ -void SetDecodingPassed( PredictionDecoder *psPredictionDecoder ) + +/*-------------------------------------------------------------------* + * Function SetDecodingPassed() + * + * + *-------------------------------------------------------------------*/ + +void SetDecodingPassed( + PredictionDecoder *psPredictionDecoder ) { int32_t n, ch; for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) @@ -348,8 +361,19 @@ void SetDecodingPassed( PredictionDecoder *psPredictionDecoder ) psPredictionDecoder->ppiDecodingFailed[ch][n] = 0; } } + + return; } -int32_t AnyDecodingUnresolved( PredictionDecoder *psPredictionDecoder ) + + +/*-------------------------------------------------------------------* + * Function AnyDecodingUnresolved() + * + * + *-------------------------------------------------------------------*/ + +int32_t AnyDecodingUnresolved( + PredictionDecoder *psPredictionDecoder ) { int32_t n, ch; for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) @@ -365,9 +389,18 @@ int32_t AnyDecodingUnresolved( PredictionDecoder *psPredictionDecoder ) return 0; } -void UpdateDecodingFailedStatus( PredictionDecoder *psPredictionDecoder ) + +/*-------------------------------------------------------------------* + * Function UpdateDecodingFailedStatus() + * + * + *-------------------------------------------------------------------*/ + +void UpdateDecodingFailedStatus( + PredictionDecoder *psPredictionDecoder ) { int32_t n, ch; + for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) { for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) @@ -375,9 +408,19 @@ void UpdateDecodingFailedStatus( PredictionDecoder *psPredictionDecoder ) psPredictionDecoder->ppiDecodingFailedPrev[ch][n] = psPredictionDecoder->ppiDecodingFailed[ch][n]; } } + + return; } -void UpdateDecodingUnresolved( PredictionDecoder *psPredictionDecoder ) + +/*-------------------------------------------------------------------* + * Function UpdateDecodingUnresolved() + * + * + *-------------------------------------------------------------------*/ + +void UpdateDecodingUnresolved( + PredictionDecoder *psPredictionDecoder ) { int32_t n, ch; @@ -398,8 +441,11 @@ void UpdateDecodingUnresolved( PredictionDecoder *psPredictionDecoder ) } } } + + return; } + /*-------------------------------------------------------------------* * Function ApplyInversePredictors() * @@ -412,6 +458,7 @@ void ApplyInversePredictors( float ***pppfImag ) { int32_t c; + for ( c = 0; c < psPredictionDecoder->iChannels; c++ ) { if ( psPredictionDecoder->piPredChanEnable[c] > 0 ) diff --git a/lib_isar/isar_PredEncoder.c b/lib_isar/isar_PredEncoder.c index 676aa917e6..3e00c8beda 100644 --- a/lib_isar/isar_PredEncoder.c +++ b/lib_isar/isar_PredEncoder.c @@ -46,13 +46,17 @@ * * *-------------------------------------------------------------------*/ + static void activate_bit( int32_t *state, const int32_t bit_id ) { ( *state ) |= ( 1 << bit_id ); + + return; } + /*-------------------------------------------------------------------* * Function deactivate_bit() * @@ -64,16 +68,29 @@ static void deactivate_bit( const int32_t bit_id ) { ( *state ) &= ( ~( 1 << bit_id ) ); + + return; } -void UpdatePredictionSubSetId( PredictionEncoder *psPredictionEncoder ) + +/*-------------------------------------------------------------------* + * Function UpdatePredictionSubSetId() + * + * + *-------------------------------------------------------------------*/ + +void UpdatePredictionSubSetId( + PredictionEncoder *psPredictionEncoder ) { if ( ++psPredictionEncoder->iSubSetId == psPredictionEncoder->iNumSubSets ) { psPredictionEncoder->iSubSetId = 0; } + + return; } + /*-------------------------------------------------------------------* * Function CreatePredictionEncoder() * @@ -496,6 +513,8 @@ void ComputePredictors( } } } + + return; } diff --git a/lib_isar/isar_lc3plus_dec.c b/lib_isar/isar_lc3plus_dec.c index 7ca5dda48e..118a7572b6 100644 --- a/lib_isar/isar_lc3plus_dec.c +++ b/lib_isar/isar_lc3plus_dec.c @@ -69,8 +69,8 @@ static void isar_LC3PLUS_DEC_FreeSubframeDecodingMatrix( *------------------------------------------------------------------------*/ ivas_error ISAR_LC3PLUS_DEC_Open( - const LC3PLUS_CONFIG config, /* i : LC3plus decoder configuration */ - ISAR_LC3PLUS_DEC_HANDLE *handle /* o : decoder handle */ + const LC3PLUS_CONFIG config, /* i : LC3plus decoder configuration */ + ISAR_LC3PLUS_DEC_HANDLE *handle /* o : decoder handle */ ) { LC3PLUS_Error err; @@ -90,7 +90,6 @@ ivas_error ISAR_LC3PLUS_DEC_Open( } numLC3plusFramesPerIvasFrame = (int16_t) ( config.ivas_frame_duration_us / config.lc3plus_frame_duration_us ); - ( *handle )->num_decs = 0; ( *handle )->pcm_conversion_buffer = NULL; ( *handle )->handles = NULL; @@ -379,6 +378,7 @@ ivas_error ISAR_LC3PLUS_DEC_GetDelay( { return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "ISAR_LC3PLUS_DEC_HANDLE is NULL\n" ); } + if ( NULL == delayInSamples ) { return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "delayInSamples is NULL\n" ); diff --git a/lib_isar/isar_lc3plus_dec.h b/lib_isar/isar_lc3plus_dec.h index 576c576959..5e7bad33b0 100644 --- a/lib_isar/isar_lc3plus_dec.h +++ b/lib_isar/isar_lc3plus_dec.h @@ -81,7 +81,7 @@ typedef struct ISAR_LC3PLUS_DEC_HANDLE } * ISAR_LC3PLUS_DEC_HANDLE; ivas_error ISAR_LC3PLUS_DEC_Open( - const LC3PLUS_CONFIG config, /* i : decoder configuration */ + const LC3PLUS_CONFIG config, /* i : decoder configuration */ ISAR_LC3PLUS_DEC_HANDLE *handle /* o : decoder handle */ ); diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index f8d13cf7ff..499af0b783 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -60,6 +60,7 @@ typedef struct TableNode int32_t *piDifference; int32_t *piLength; } TableNode; + typedef struct TableList { TableNode *poOrderedTop; @@ -102,26 +103,41 @@ struct LCLD_DECODER PredictionDecoder *psPredictionDecoder; - NoiseGen *psNoiseGen; }; + +/*------------------------------------------------------------------------------------------* + * Local functions declarations + *------------------------------------------------------------------------------------------*/ + static void CreateDecodeTable( LCLDDecoder *psLCLDDecoder, const int32_t num, const uint16_t ( *ppuiEncTable )[2], const int32_t iSize, const int32_t iReadLength, uint32_t *iTables ); + static TableNode *CreateTableList( const int32_t iReadLength ); + static void DeleteTableList( TableList *ptable_list, int32_t iTables ); + static TableNode *GetNextTable( const int32_t iIndex, TableList *table_list, TableNode *poParent, const int32_t iReadLength, uint32_t *iTablesCreated ); + static void AddcodeTableList( TableList *ptable_list, const int32_t iLength, const int32_t iCode, const int32_t iCodeIndex, const int32_t iReadLength, uint32_t *iTables ); + static void CompleteTables( LCLDDecoder *psLCLDDecoder, const int32_t n, TableList *ptable_list, const int32_t iReadLength, const int32_t iTablesCreated ); -static TableNode *CreateTableList( const int32_t iReadLength ) + +/*------------------------------------------------------------------------------------------* + * Local functions + *------------------------------------------------------------------------------------------*/ + +static TableNode *CreateTableList( + const int32_t iReadLength ) { int32_t n; int32_t iMaxTables; TableNode *ptable_top; + iMaxTables = 1 << iReadLength; ptable_top = (TableNode *) malloc( sizeof( TableNode ) ); - ptable_top->ppoNextTable = - (TableNode **) malloc( iMaxTables * sizeof( TableNode * ) ); + ptable_top->ppoNextTable = (TableNode **) malloc( iMaxTables * sizeof( TableNode * ) ); ptable_top->piCodeIndex = (int32_t *) malloc( iMaxTables * sizeof( int32_t ) ); ptable_top->piDifference = (int32_t *) malloc( iMaxTables * sizeof( int32_t ) ); ptable_top->piLength = (int32_t *) malloc( iMaxTables * sizeof( int32_t ) ); @@ -135,15 +151,18 @@ static TableNode *CreateTableList( const int32_t iReadLength ) return ptable_top; } -static void DeleteTableList( TableList *ptable_list, int32_t iTables ) + + +static void DeleteTableList( + TableList *ptable_list, + int32_t iTables ) { TableNode *node; node = ptable_list->poOrderedTop; - while ( ( iTables ) ) + while ( iTables ) { - TableNode *node1 = node; node = node1->poOrderedNext; if ( node1->piCodeIndex != NULL ) @@ -168,12 +187,22 @@ static void DeleteTableList( TableList *ptable_list, int32_t iTables ) } iTables--; } + if ( ptable_list != NULL ) { free( ptable_list ); } + + return; } -static TableNode *GetNextTable( const int32_t iIndex, TableList *table_list, TableNode *poParent, const int32_t iReadLength, uint32_t *iTablesCreated ) + + +static TableNode *GetNextTable( + const int32_t iIndex, + TableList *table_list, + TableNode *poParent, + const int32_t iReadLength, + uint32_t *iTablesCreated ) { TableNode *poNextNode; @@ -194,16 +223,21 @@ static TableNode *GetNextTable( const int32_t iIndex, TableList *table_list, Tab return poNextNode; } -static void CompleteTables( LCLDDecoder *psLCLDDecoder, const int32_t n, TableList *ptable_list, const int32_t iReadLength, const int32_t iTablesCreated ) -{ + +static void CompleteTables( + LCLDDecoder *psLCLDDecoder, + const int32_t n, + TableList *ptable_list, + const int32_t iReadLength, + const int32_t iTablesCreated ) +{ int32_t iMaxTables; int32_t j; TableNode *poNode; iMaxTables = 1 << iReadLength; - psLCLDDecoder->c_apauiHuffDecTable_RAM[n] = - malloc( iTablesCreated * iMaxTables * sizeof( uint32_t ) ); + psLCLDDecoder->c_apauiHuffDecTable_RAM[n] = malloc( iTablesCreated * iMaxTables * sizeof( uint32_t ) ); poNode = ptable_list->poOrderedTop; for ( j = 0; j < iTablesCreated; j++ ) @@ -222,8 +256,18 @@ static void CompleteTables( LCLDDecoder *psLCLDDecoder, const int32_t n, TableLi } poNode = poNode->poOrderedNext; } + + return; } -static void AddcodeTableList( TableList *ptable_list, const int32_t iLength, const int32_t iCode, const int32_t iCodeIndex, const int32_t iReadLength, uint32_t *iTables ) + + +static void AddcodeTableList( + TableList *ptable_list, + const int32_t iLength, + const int32_t iCode, + const int32_t iCodeIndex, + const int32_t iReadLength, + uint32_t *iTables ) { int32_t iDifference; int32_t iMask; @@ -231,8 +275,8 @@ static void AddcodeTableList( TableList *ptable_list, const int32_t iLength, con int32_t iIndex; int32_t iCodeLow; int32_t iCodeHigh; - TableNode *poNode; + poNode = ptable_list->poOrderedTop; iMask = ( 1 << iReadLength ) - 1; iCurrentLength = iLength; @@ -256,19 +300,29 @@ static void AddcodeTableList( TableList *ptable_list, const int32_t iLength, con poNode->piDifference[iIndex] = iDifference; poNode->piLength[iIndex] = iLength; } + + return; } -static void CreateDecodeTable( LCLDDecoder *psLCLDDecoder, const int32_t num, const uint16_t ( *ppuiEncTable )[2], const int32_t iSize, const int32_t iReadLength, uint32_t *iTables ) + +static void CreateDecodeTable( + LCLDDecoder *psLCLDDecoder, + const int32_t num, + const uint16_t ( *ppuiEncTable )[2], + const int32_t iSize, + const int32_t iReadLength, + uint32_t *iTables ) { int32_t n; uint32_t **ppsort_enc_table; TableList *ptable_list; + ptable_list = (TableList *) malloc( sizeof( TableList ) ); ppsort_enc_table = (uint32_t **) malloc( iSize * sizeof( int32_t * ) ); + for ( n = 0; n < iSize; n++ ) { - ppsort_enc_table[n] = (uint32_t *) malloc( 3 * sizeof( int32_t ) ); ppsort_enc_table[n][0] = (uint32_t) ppuiEncTable[n][0]; ppsort_enc_table[n][1] = (uint32_t) ppuiEncTable[n][1]; @@ -322,8 +376,7 @@ static void CreateDecodeTable( LCLDDecoder *psLCLDDecoder, const int32_t num, co iLength = ppsort_enc_table[n][0]; iCode = ppsort_enc_table[n][1]; iCodeIndex = ppsort_enc_table[n][2]; - AddcodeTableList( ptable_list, iLength, iCode, iCodeIndex, iReadLength, - iTables ); + AddcodeTableList( ptable_list, iLength, iCode, iCodeIndex, iReadLength, iTables ); } CompleteTables( psLCLDDecoder, num, ptable_list, iReadLength, *iTables ); @@ -332,7 +385,10 @@ static void CreateDecodeTable( LCLDDecoder *psLCLDDecoder, const int32_t num, co { free( ppsort_enc_table[n] ); } + free( ppsort_enc_table ); + + return; } @@ -540,7 +596,8 @@ ivas_error CreateLCLDDecoder( * *------------------------------------------------------------------------------------------*/ -void DeleteLCLDDecoder( LCLDDecoder *psLCLDDecoder ) +void DeleteLCLDDecoder( + LCLDDecoder *psLCLDDecoder ) { int32_t k, n; @@ -697,6 +754,7 @@ void DeleteLCLDDecoder( LCLDDecoder *psLCLDDecoder ) } } + /*------------------------------------------------------------------------------------------* * Local function declarations * @@ -711,25 +769,35 @@ static void InvQuantizeSpectrum( const int32_t iNumGroups, const int32_t *piGrou static void InvMSCoding( const int32_t iNumBlocks, const int32_t iNumBands, const int32_t *piBandwidths, const int32_t iMSMode, const int32_t *piMSFlags, const int32_t *piLRPhaseDiffs, const int32_t *piMSPredCoefs, float ***pppfReal, float ***pppfImag ); -static int32_t ReadHeaderInformation( int32_t *piNumBands, ISAR_SPLIT_REND_BITS_HANDLE pBits ); +static int32_t ReadHeaderInformation( int32_t *piNumBands, const ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static int32_t ReadMSInformation( const int32_t iNumBands, int32_t *piMSMode, int32_t *piMSFlags, int32_t *piLRPhaseDiffs, int32_t *piMSPredCoefs, const ISAR_SPLIT_REND_BITS_HANDLE pBits ); + +static int32_t ReadGroupInformation( const int32_t iChannels, const int32_t iNumBlocks, int32_t *piCommonGrouping, int32_t *piNumGroups, int32_t **ppiGroupLengths, const ISAR_SPLIT_REND_BITS_HANDLE pBits ); -static int32_t ReadMSInformation( const int32_t iNumBands, int32_t *piMSMode, int32_t *piMSFlags, int32_t *piLRPhaseDiffs, int32_t *piMSPredCoefs, ISAR_SPLIT_REND_BITS_HANDLE pBits ); +static int32_t ReadHuff( const uint32_t ( *pauiHuffDecTable )[HUFF_DEC_TABLE_SIZE], int32_t *piSymbol, const ISAR_SPLIT_REND_BITS_HANDLE pBits ); -static int32_t ReadGroupInformation( const int32_t iChannels, const int32_t iNumBlocks, int32_t *piCommonGrouping, int32_t *piNumGroups, int32_t **ppiGroupLengths, ISAR_SPLIT_REND_BITS_HANDLE pBits ); +static int32_t ReadRMSEnvelope( const int32_t iChannels, const int32_t *piNumGroups, const int32_t iNumBands, int32_t ***pppiRMSEnvelope, const ISAR_SPLIT_REND_BITS_HANDLE pBits ); -static int32_t ReadHuff( const uint32_t ( *pauiHuffDecTable )[HUFF_DEC_TABLE_SIZE], int32_t *piSymbol, ISAR_SPLIT_REND_BITS_HANDLE pBits ); +static int32_t ReadAllocInformation( int32_t *piAllocOffset, const ISAR_SPLIT_REND_BITS_HANDLE pBits ); -static int32_t ReadRMSEnvelope( const int32_t iChannels, const int32_t *piNumGroups, const int32_t iNumBands, int32_t ***pppiRMSEnvelope, ISAR_SPLIT_REND_BITS_HANDLE pBits ); +static int32_t ReadLCLDData( const int32_t *piNumGroups, int32_t **ppiGroupLengths, const int32_t iNumBands, const int32_t iNumChannels, int32_t **ppiDecodingUnresolved, int32_t **ppiPredEnable, const int32_t iNumSubSets, const int32_t iSubSetId, int32_t ***pppiAlloc, int32_t ***pppiSignReal, int32_t ***pppiSignImag, int32_t ***pppiQReal, int32_t ***pppiQImag, int32_t **ppiDecodingFailed, const ISAR_SPLIT_REND_BITS_HANDLE pBits, uint32_t ( *c_apauiHuffDecTables[2 * ALLOC_TABLE_SIZE] )[HUFF_DEC_TABLE_SIZE] ); -static int32_t ReadAllocInformation( int32_t *piAllocOffset, ISAR_SPLIT_REND_BITS_HANDLE pBits ); -static int32_t -ReadLCLDData( const int32_t *piNumGroups, int32_t **ppiGroupLengths, const int32_t iNumBands, const int32_t iNumChannels, int32_t **ppiDecodingUnresolved, int32_t **ppiPredEnable, const int32_t iNumSubSets, const int32_t iSubSetId, int32_t ***pppiAlloc, int32_t ***pppiSignReal, int32_t ***pppiSignImag, int32_t ***pppiQReal, int32_t ***pppiQImag, int32_t **ppiDecodingFailed, ISAR_SPLIT_REND_BITS_HANDLE pBits, uint32_t ( *c_apauiHuffDecTables[2 * ALLOC_TABLE_SIZE] )[HUFF_DEC_TABLE_SIZE] ); static void ComputeAllocation( const int32_t iChannels, const int32_t *piNumGroups, const int32_t iNumBands, int32_t ***pppiSMR, const int32_t iAllocOffset, int32_t ***pppiAlloc ); -void SetDecodingUnresolved( LCLDDecoder *psLCLDDecoder ) + +/*------------------------------------------------------------------------------------------* + * function LSetDecodingUnresolved() + * + * + *------------------------------------------------------------------------------------------*/ + +void SetDecodingUnresolved( + LCLDDecoder *psLCLDDecoder ) { int32_t n, ch; PredictionDecoder *psPredictionDecoder = psLCLDDecoder->psPredictionDecoder; + for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) { for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) @@ -739,12 +807,23 @@ void SetDecodingUnresolved( LCLDDecoder *psLCLDDecoder ) psPredictionDecoder->ppiDecodingFailedPrev[ch][n] = 1; } } + + return; } -int32_t AnyDecodingFailedPrev( LCLDDecoder *psLCLDDecoder ) + +/*------------------------------------------------------------------------------------------* + * function AnyDecodingFailedPrev() + * + * + *------------------------------------------------------------------------------------------*/ + +int16_t AnyDecodingFailedPrev( + LCLDDecoder *psLCLDDecoder ) { int32_t n, ch; PredictionDecoder *psPredictionDecoder = psLCLDDecoder->psPredictionDecoder; + for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) { for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) @@ -755,13 +834,22 @@ int32_t AnyDecodingFailedPrev( LCLDDecoder *psLCLDDecoder ) } } } + return 0; } -int32_t AnyDecodingFailed( LCLDDecoder *psLCLDDecoder ) +/*------------------------------------------------------------------------------------------* + * function AnyDecodingFailed() + * + * + *------------------------------------------------------------------------------------------*/ + +int16_t AnyDecodingFailed( + LCLDDecoder *psLCLDDecoder ) { int32_t n, ch; PredictionDecoder *psPredictionDecoder = psLCLDDecoder->psPredictionDecoder; + for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) { for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) @@ -772,24 +860,53 @@ int32_t AnyDecodingFailed( LCLDDecoder *psLCLDDecoder ) } } } + return 0; } + +/*------------------------------------------------------------------------------------------* + * function GetDecodingFailedStatus() + * + * + *------------------------------------------------------------------------------------------*/ + int32_t **GetDecodingFailedStatus( LCLDDecoder *psLCLDDecoder ) { return psLCLDDecoder->psPredictionDecoder->ppiDecodingFailed; } + +/*------------------------------------------------------------------------------------------* + * function GetNumSubSets() + * + * + *------------------------------------------------------------------------------------------*/ + int16_t GetNumSubSets( LCLDDecoder *psLCLDDecoder ) { return (int16_t) psLCLDDecoder->psPredictionDecoder->iNumSubSets; } + +/*------------------------------------------------------------------------------------------* + * function GetDecodingFailedPrevStatus() + * + * + *------------------------------------------------------------------------------------------*/ + int32_t **GetDecodingFailedPrevStatus( LCLDDecoder *psLCLDDecoder ) { return psLCLDDecoder->psPredictionDecoder->ppiDecodingFailedPrev; } + +/*------------------------------------------------------------------------------------------* + * function UnpackReal() + * + * + *------------------------------------------------------------------------------------------*/ + static void UnpackReal( const int32_t iChannels, const int32_t iNumBlocks, @@ -797,6 +914,7 @@ static void UnpackReal( float ***pppfImag ) { int32_t ch, b, n; + for ( ch = 0; ch < iChannels; ch++ ) { for ( b = 0; b < LCLD_BANDS; b++ ) @@ -812,8 +930,11 @@ static void UnpackReal( } } } + + return; } + /*------------------------------------------------------------------------------------------* * Function DecodeLCLDFrame() * @@ -822,7 +943,7 @@ static void UnpackReal( int32_t DecodeLCLDFrame( LCLDDecoder *psLCLDDecoder, - ISAR_SPLIT_REND_BITS_HANDLE pBits, + const ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i : ISAR bits handle */ float ***pppfLCLDReal, float ***pppfLCLDImag ) { @@ -843,7 +964,6 @@ int32_t DecodeLCLDFrame( ReadRMSEnvelope( psLCLDDecoder->iChannels, (const int32_t *) psLCLDDecoder->piNumGroups, psLCLDDecoder->iNumBands, psLCLDDecoder->pppiRMSEnvelope, pBits ); - ReadAllocInformation( &psLCLDDecoder->iAllocOffset, pBits ); if ( psLCLDDecoder->iChannels == 2 && psLCLDDecoder->iCommonGrouping == 1 ) @@ -1001,6 +1121,7 @@ static void ApplyRMSEnvelope( return; } + static void ReplaceSign( const int32_t iNumBlocks, const int32_t iNumLCLDBands, @@ -1184,7 +1305,7 @@ static void InvMSCoding( /* Currently only the number of bands in frame */ static int32_t ReadHeaderInformation( int32_t *piNumBands, - ISAR_SPLIT_REND_BITS_HANDLE pBits ) + const ISAR_SPLIT_REND_BITS_HANDLE pBits ) { int32_t iBitsRead; @@ -1202,7 +1323,7 @@ static int32_t ReadMSInformation( int32_t *piMSFlags, int32_t *piLRPhaseDiffs, int32_t *piMSPredCoefs, - ISAR_SPLIT_REND_BITS_HANDLE pBits ) + const ISAR_SPLIT_REND_BITS_HANDLE pBits ) { int32_t iBitsRead; @@ -1322,13 +1443,14 @@ static int32_t ReadMSInformation( return iBitsRead; } + static int32_t ReadGroupInformation( const int32_t iChannels, const int32_t iNumBlocks, int32_t *piCommonGrouping, int32_t *piNumGroups, int32_t **ppiGroupLengths, - ISAR_SPLIT_REND_BITS_HANDLE pBits ) + const ISAR_SPLIT_REND_BITS_HANDLE pBits ) { int32_t c, k, iBitsRead; @@ -1439,7 +1561,7 @@ static int32_t BSForceBack( static int32_t ReadHuff( const uint32_t ( *pauiHuffDecTable )[HUFF_DEC_TABLE_SIZE], int32_t *piSymbol, - ISAR_SPLIT_REND_BITS_HANDLE pBits ) + const ISAR_SPLIT_REND_BITS_HANDLE pBits ) { int32_t iBitsRead; int32_t iSymbol; @@ -1478,7 +1600,7 @@ static int32_t ReadRMSEnvelope( const int32_t *piNumGroups, const int32_t iNumBands, int32_t ***pppiRMSEnvelope, - ISAR_SPLIT_REND_BITS_HANDLE pBits ) + const ISAR_SPLIT_REND_BITS_HANDLE pBits ) { int32_t b, k, n; int32_t iBitsRead, iLastRMSVal; @@ -1512,7 +1634,7 @@ static int32_t ReadRMSEnvelope( static int32_t ReadAllocInformation( int32_t *piAllocOffset, - ISAR_SPLIT_REND_BITS_HANDLE pBits ) + const ISAR_SPLIT_REND_BITS_HANDLE pBits ) { int32_t iBitsRead; @@ -1524,6 +1646,7 @@ static int32_t ReadAllocInformation( return iBitsRead; } + static int32_t ReadLCLDData( const int32_t *piNumGroups, int32_t **ppiGroupLengths, @@ -1539,7 +1662,7 @@ static int32_t ReadLCLDData( int32_t ***pppiQReal, int32_t ***pppiQImag, int32_t **ppiDecodingFailed, - ISAR_SPLIT_REND_BITS_HANDLE pBits, + const ISAR_SPLIT_REND_BITS_HANDLE pBits, uint32_t ( *c_apauiHuffDecTables[2 * ALLOC_TABLE_SIZE] )[HUFF_DEC_TABLE_SIZE] ) { int32_t iBitsRead; @@ -1682,6 +1805,7 @@ static int32_t ReadLCLDData( return iBitsRead; } + static void ComputeAllocation( const int32_t iChannels, const int32_t *piNumGroups, diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c index 3d110a5a30..07fd9d86a0 100644 --- a/lib_isar/isar_lcld_encoder.c +++ b/lib_isar/isar_lcld_encoder.c @@ -84,6 +84,7 @@ struct LCLD_ENCODER PredictionEncoder *psPredictionEncoder; }; + /*------------------------------------------------------------------------------------------* * Function Quantize() * @@ -112,6 +113,7 @@ static int32_t Quantize( return iVal; } + /*------------------------------------------------------------------------------------------* * Function UnQuantize() * @@ -132,9 +134,11 @@ static float UnQuantize( { fVal = -fScale * (float) iVal; } + return fVal; } + static void PackReal( const int32_t iChannels, const int32_t iNumBlocks, @@ -155,6 +159,8 @@ static void PackReal( } } } + + return; } /*------------------------------------------------------------------------------------------* @@ -252,7 +258,6 @@ ivas_error CreateLCLDEncoder( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); } - if ( ( psLCLDEncoder->pppiLCLDSignReal = (int32_t ***) malloc( psLCLDEncoder->iChannels * sizeof( int32_t ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); @@ -273,7 +278,6 @@ ivas_error CreateLCLDEncoder( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); } - for ( n = 0; n < iChannels; n++ ) { int32_t k; @@ -527,6 +531,7 @@ void DeleteLCLDEncoder( return; } + /*------------------------------------------------------------------------------------------* * Local function declarations *------------------------------------------------------------------------------------------*/ @@ -539,7 +544,7 @@ static int32_t CountLCLDBits( const int32_t iNumGroups, const int32_t *piGroupLe static int32_t WriteHeaderInformation( const int32_t iNumBands, ISAR_SPLIT_REND_BITS_HANDLE pBits ); -static int32_t WriteMSInformation( const int32_t iNumBands, const int32_t iMSMode, const int32_t *piMSFlags, const int32_t *piLRPhaseDiffs, const int32_t *piMSPredCoefs, int32_t iNumMSPredBands, ISAR_SPLIT_REND_BITS_HANDLE pBits ); +static int32_t WriteMSInformation( const int32_t iNumBands, const int32_t iMSMode, const int32_t *piMSFlags, const int32_t *piLRPhaseDiffs, const int32_t *piMSPredCoefs, const int32_t iNumMSPredBands, ISAR_SPLIT_REND_BITS_HANDLE pBits ); static int32_t WriteGroupInformation( const int32_t iChannels, const int32_t iCommonGrouping, const int32_t *piNumGroups, int32_t **ppiGroupLengths, ISAR_SPLIT_REND_BITS_HANDLE pBits ); @@ -551,6 +556,7 @@ static int32_t WriteLCLDData( const int32_t *piNumGroups, int32_t **ppiGroupLeng static int32_t ComputeAllocation( const int32_t iChannels, const int32_t *piNumGroups, int32_t **ppiGroupLengths, const int32_t iNumBands, const int32_t *piBandwidths, float ***pppfReal, float ***pppfImag, int32_t ***pppiSMR, const int32_t iAvailableBits, int32_t *piAllocOffset, int32_t ***pppiAlloc, int32_t ***pppiQReal, int32_t ***pppiQImag, int32_t ***pppiSignReal, int32_t ***pppiSignImag, PredictionEncoder *psPredictionEncoder ); + /*------------------------------------------------------------------------------------------* * Function EncodeLCLDFrame() * @@ -600,7 +606,6 @@ int32_t EncodeLCLDFrame( } } - /* Compute Grouping and RMS Envelopes */ if ( psLCLDEncoder->iChannels == 2 && psLCLDEncoder->iCommonGrouping == 1 ) { @@ -662,14 +667,12 @@ int32_t EncodeLCLDFrame( pBits ); } - iBitsWritten += WritePredictors( psLCLDEncoder->psPredictionEncoder, pBits ); iBitsWritten += WriteGroupInformation( psLCLDEncoder->iChannels, psLCLDEncoder->iCommonGrouping, (const int32_t *) psLCLDEncoder->piNumGroups, psLCLDEncoder->ppiGroupLengths, pBits ); iBitsWritten += WriteRMSEnvelope( psLCLDEncoder->iChannels, (const int32_t *) psLCLDEncoder->piNumGroups, psLCLDEncoder->iNumBands, psLCLDEncoder->pppiRMSEnvelope, pBits ); - if ( psLCLDEncoder->iChannels == 2 && psLCLDEncoder->iCommonGrouping == 1 ) { int32_t k; @@ -713,6 +716,7 @@ int32_t EncodeLCLDFrame( fprintf( fid, "%d %d\n", psLCLDEncoder->psPredictionEncoder->iSubSetId, psLCLDEncoder->psPredictionEncoder->piPredChanEnable[n] ); } #endif + iAvailableBits -= iBitsWritten; ComputeAllocation( psLCLDEncoder->iChannels, (const int32_t *) psLCLDEncoder->piNumGroups, @@ -731,8 +735,8 @@ int32_t EncodeLCLDFrame( psLCLDEncoder->pppiLCLDSignImag, psLCLDEncoder->psPredictionEncoder ); - iBitsWritten += WriteAllocInformation( psLCLDEncoder->iAllocOffset, - pBits ); + iBitsWritten += WriteAllocInformation( psLCLDEncoder->iAllocOffset, pBits ); + iAudioBitsWritten = iBitsWritten; iBitsWritten += WriteLCLDData( psLCLDEncoder->piNumGroups, psLCLDEncoder->ppiGroupLengths, @@ -1154,6 +1158,7 @@ static void RemoveRMSEnvelope( return; } + static void QuantizeSpectrumDPCM_Opt( const int32_t iNumGroups, const int32_t *piGroupLengths, @@ -1264,8 +1269,11 @@ static void QuantizeSpectrumDPCM_Opt( iFBOffset++; } /* bandwidth */ } /* bands */ + + return; } + static int32_t CountLCLDBits( const int32_t iNumGroups, const int32_t *piGroupLengths, @@ -1378,7 +1386,7 @@ static int32_t WriteMSInformation( const int32_t *piMSFlags, const int32_t *piLRPhaseDiff, const int32_t *piMSPredCoef, - int32_t iNumMSPredBands, + const int32_t iNumMSPredBands, ISAR_SPLIT_REND_BITS_HANDLE pBits ) { int32_t iBitsWritten; @@ -1422,6 +1430,7 @@ static int32_t WriteMSInformation( break; } } + ISAR_SPLIT_REND_BITStream_write_int32( pBits, anyNonZero, 1 ); iBitsWritten++; @@ -1746,6 +1755,7 @@ static int32_t WriteLCLDData( return iBitsWritten; } + static int32_t ComputeAllocation( const int32_t iChannels, const int32_t *piNumGroups, @@ -1881,13 +1891,14 @@ static int32_t ComputeAllocation( } } +#ifdef DEBUGGING /* printf("%d\n",*piAllocOffset); printf("%d\t%d\t%d\n",pppiAlloc[0][0][0],pppiAlloc[0][0][1],pppiAlloc[0][0][22]); printf("%d\t%d\t%d\t%d\n",*piAllocOffset,iAvailableBits,iBitsUsed,iAvailableBits - iBitsUsed); */ - +#endif return iBitsUsed; } #endif diff --git a/lib_isar/isar_lcld_prot.h b/lib_isar/isar_lcld_prot.h index b685ad284b..ac7e76656c 100644 --- a/lib_isar/isar_lcld_prot.h +++ b/lib_isar/isar_lcld_prot.h @@ -81,7 +81,7 @@ void DeleteLCLDDecoder( int32_t DecodeLCLDFrame( LCLDDecoder *psLCLDDecoder, - ISAR_SPLIT_REND_BITS_HANDLE pBits, + const ISAR_SPLIT_REND_BITS_HANDLE pBits, float ***pppfLCLDReal, float ***pppfLCLDImag ); @@ -249,6 +249,7 @@ typedef struct PREDICTION_ENCODER int32_t **ppiA1Mag; int32_t **ppiA1Phase; + } PredictionEncoder; ivas_error CreatePredictionEncoder( @@ -314,7 +315,7 @@ void DeletePredictionDecoder( PredictionDecoder *psPredictionDecoder ); -int32_t ReadPredictors( +int16_t ReadPredictors( PredictionDecoder *psPredictionDecoder, ISAR_SPLIT_REND_BITS_HANDLE pBits ); @@ -326,10 +327,10 @@ void UpdatePredictionSubSetId( void SetDecodingUnresolved( LCLDDecoder *psLCLDDecoder); -int32_t AnyDecodingFailedPrev( +int16_t AnyDecodingFailedPrev( LCLDDecoder *psLCLDDecoder); -int32_t AnyDecodingFailed( +int16_t AnyDecodingFailed( LCLDDecoder *psLCLDDecoder); int32_t **GetDecodingFailedStatus( diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index 3ff35ff73e..4817830c41 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -33,19 +33,22 @@ #ifndef ISAR_PROT_H #define ISAR_PROT_H - #include "isar_stat.h" - #ifdef SPLIT_REND_WITH_HEAD_ROT - #include #include "options.h" #include "ivas_error.h" #include "lib_isar_post_rend.h" + +/* clang-format off */ +/*----------------------------------------------------------------------------------* + * General ISAR prototypes + *----------------------------------------------------------------------------------*/ + ivas_error isar_splitBinPreRendOpen( - ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend, /* i/o: binaural pre-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG , const int32_t output_Fs @@ -53,58 +56,70 @@ ivas_error isar_splitBinPreRendOpen( ); ivas_error split_renderer_open_lc3plus( - SPLIT_REND_WRAPPER *hSplitRendWrapper, - const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, - const int32_t OutSampleRate, - const int16_t num_subframes ); + SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i/o: Split renderer pre-renderer handle */ + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i : Split renderer pre-renderer config */ + const int32_t output_Fs, /* i : output sampling rate */ + const int16_t num_subframes /* i : number of subframes */ +); void isar_splitBinPreRendClose( - ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend ); + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend /* i/o: binaural pre-renderer handle */ +); void lc3plusTimeAlignCldfbPoseCorr( - SPLIT_REND_WRAPPER *hSplitBin, - float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] ); + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ + float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: Binaural signals, real part */ + float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] /* i/o: Binaural signals, imag. part */ +); ivas_error splitRendLc3plusEncodeAndWrite( - SPLIT_REND_WRAPPER *hSplitBin, - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int32_t SplitRendBitRate, - float *in[] ); + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ + float *in[] +); +/*! r: parameter value */ int32_t ISAR_SPLIT_REND_BITStream_read_int32( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int32_t bits ); + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const int32_t bits /* i : number of bits to be read */ +); void ISAR_SPLIT_REND_BITStream_write_int32( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int32_t val, - const int32_t bits ); + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const int32_t val, /* i : parameter value */ + const int32_t bits /* i : number of bits to be written */ +); ivas_error isar_splitBinLCLDEncOpen( - ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc, + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc, /* o : ISAR LCLD encoder handle */ const int32_t iSampleRate, const int16_t iChannels, const int32_t iDataRate, const int16_t iNumBlocks, - const int16_t iNumIterations ); + const int16_t iNumIterations +); ivas_error isar_splitBinRendPLCOpen( - ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC, - const int16_t iNumSubSets ); + ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC, /* i/o: ISAR PLC handle */ + const int16_t iNumSubSets +); void isar_splitBinRendPLCClose( - ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC ); + ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC /* i/o: ISAR PLC handle */ +); ivas_error isar_splitBinLCLDDecOpen( - ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec, + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec, /* i/o: ISAR LCLD decoder handle */ const int32_t iSampleRate, const int16_t iChannels, const int16_t iNumBlocks, - const int16_t iNumIterations ); + const int16_t iNumIterations +); void isar_splitBinLCLDDecClose( - ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec ); + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec /* o : ISAR LCLD decoder handle */ +); void isar_splitBinRendPLCsaveState( ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC, @@ -112,7 +127,8 @@ void isar_splitBinRendPLCsaveState( float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const int16_t num_chs, const int16_t iNumBlocks, - const int16_t iNumIterations ); + const int16_t iNumIterations +); void isar_splitBinRendPLC_xf( ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC, @@ -122,7 +138,8 @@ void isar_splitBinRendPLC_xf( const int16_t iNumBlocks, const int16_t iNumIterations, int32_t **ppiDecodingFailed, - int32_t **ppiDecodingFailedPrev ); + int32_t **ppiDecodingFailedPrev +); void isar_splitBinRendPLC( ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC, @@ -131,7 +148,8 @@ void isar_splitBinRendPLC( const int16_t num_chs, const int16_t iNumBlocks, const int16_t iNumIterations, - int32_t **ppiDecodingFailed ); + int32_t **ppiDecodingFailed +); #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG void isar_log_cldfb2wav_data( @@ -143,51 +161,61 @@ void isar_log_cldfb2wav_data( const int32_t output_Fs, const int16_t start_slot_idx, const int16_t md_band_idx, - const char *filename ); -#endif + const char *filename +); +#endif void isar_splitBinLCLDDecProcess( - ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE hSplitBinLCLDDec, - ISAR_SPLIT_REND_BITS_HANDLE pBits, - float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - const int16_t bfi ); + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE hSplitBinLCLDDec, /* i/o: ISAR LCLD decoder handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, real part */ + float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, imag. part */ + const int16_t bfi /* i : BFI flag */ +); void set_fix_rotation_mat( float fix_pos_rot_mat[][BINAURAL_CHANNELS][BINAURAL_CHANNELS], - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ +); void isar_splitBinLCLDEncClose( - ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc ); + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc /* i/o: ISAR LCLD encoder handle */ +); void isar_splitBinLCLDEncProcess( - ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, /* i/o: ISAR LCLD encoder handle */ float Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const int32_t available_bits, - ISAR_SPLIT_REND_BITS_HANDLE pBits ); + ISAR_SPLIT_REND_BITS_HANDLE pBits /* i/o: ISAR bits handle */ +); void set_pose_types( - ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1], - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); + ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1],/* o : ISAR pose type */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ +); void isar_split_rend_init_huff_cfg( - ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg ); + ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg +); ivas_error isar_splitBinPostRendOpen( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const int32_t output_Fs ); + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const int32_t output_Fs /* i : output sampling rate */ +); void isar_splitBinPostRendClose( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend ); + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend /* i/o: binaural post-renderer handle */ +); void isar_SplitRenderer_getdiagdiff( int16_t in_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], int16_t out_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], const int16_t sign, const int16_t min_val, - const int16_t max_val ); + const int16_t max_val +); void isar_split_rend_get_quant_params( const int16_t num_md_bands, @@ -201,24 +229,24 @@ void isar_split_rend_get_quant_params( int16_t pred_real_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], int16_t pred_imag_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], int16_t *num_quant_strats, - int16_t *num_complex_bands ); + int16_t *num_complex_bands +); void isar_splitBinPostRendMdDec( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, + const ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i : ISAR bits handle */ + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend -#else - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData + , + BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend /* i/o: binaural pre-renderer handle */ #endif ); void Quat2EulerDegree( - const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ - float *yaw, /* o : yaw */ - float *pitch, /* o : pitch */ - float *roll /* o : roll */ + const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ + float *yaw, /* o : yaw */ + float *pitch, /* o : pitch */ + float *roll /* o : roll */ ); void isar_mat_mult_2by2_complex( @@ -227,115 +255,126 @@ void isar_mat_mult_2by2_complex( float in_re2[2][2], float in_im2[2][2], float out_re2[2][2], - float out_im2[2][2] ); + float out_im2[2][2] +); void isar_rend_CldfbSplitPostRendProcess( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const IVAS_QUATERNION QuaternionPost, float Cldfb_RealBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float Cldfb_ImagBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float output[][L_FRAME48k], - const int16_t cldfb_in_flag ); + const int16_t cldfb_in_flag +); void isar_rend_CldfbSplitPreRendProcess( - const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, - const IVAS_QUATERNION headPosition, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int32_t target_md_bits, - const int16_t low_res_pre_rend_rot, - const int16_t ro_md_flag ); + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i : binaural pre-renderer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, real part */ + float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, imag. part */ + const ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i : ISAR bits handle */ + const int32_t target_md_bits, /* i : ISAR MD bitrate */ + const int16_t low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ + const int16_t ro_md_flag /* i : real only metadata for yaw flag */ +); ivas_error isar_renderMultiTDBinToSplitBinaural( - SPLIT_REND_WRAPPER *hSplitBin, - const IVAS_QUATERNION headPosition, - const int32_t SplitRendBitRate, - const int16_t codec_frame_size_ms, - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int16_t max_bands, - float *in[], - const int16_t low_res_pre_rend_rot, - const int16_t pcm_out_flag, - const int16_t ro_md_flag ); + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ + const int16_t codec_frame_size_ms, /* i : ISAR frame length in ms */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const int16_t max_bands, /* i : CLDFB bands */ + float *in[], /* i/o: PCM in/out buffer */ + const int16_t low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ + const int16_t pcm_out_flag, /* i : flag to indicate PCM output */ + const int16_t ro_md_flag /* i : real only metadata for yaw flag */ +); void isar_init_multi_bin_pose_data( - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ +); void isar_renderSplitGetMultiBinPoseData( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const ISAR_SPLIT_REND_ROT_AXIS rot_axis ); + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renderer config */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ +); void isar_init_split_post_rend_handles( - ISAR_SPLIT_POST_REND_WRAPPER *hSplitRendWrapper ); + ISAR_SPLIT_POST_REND_WRAPPER *hSplitRendWrapper /* i/o: Split renderer post-renderer handle */ +); void isar_set_split_rend_ht_setup( - SPLIT_REND_WRAPPER *hSplitrend, - IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES], - float Rmat[MAX_PARAM_SPATIAL_SUBFRAMES][3][3] ); + SPLIT_REND_WRAPPER *hSplitrend, /* i/o: Split renderer pre-renderer handle */ + IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES], /* i/o: External orientation in quaternions */ + float Rmat[MAX_PARAM_SPATIAL_SUBFRAMES][3][3] /* o : real-space rotation matrix */ +); +/*! r: LC3plus bitrate */ int32_t isar_get_lc3plus_bitrate( - const int32_t SplitRendBitRate, - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, - const int16_t split_prerender_frame_size_ms ); + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, /* i : ISAR pose correction mode */ + const int16_t split_prerender_frame_size_ms /* i : ISAR frame length in ms */ +); ivas_error isar_split_rend_validate_config( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, - const int16_t pcm_out_flag ); + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i : Split renderer pre-renderer config */ + const int16_t pcm_out_flag /* i : flag to indicate PCM output */ +); +/*! r: LCLD codec bitrate */ int32_t isar_get_lcld_bitrate( - const int32_t SplitRendBitRate, - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode ); + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode /* i : ISAR pose correction mode */ +); +/*! r: LC3plus codec bitrate ID */ int8_t isar_get_lc3plus_bitrate_id( - const int32_t SplitRendBitRate ); + const int32_t SplitRendBitRate /* i : ISAR bitrate */ +); +/*! r: ISAR MD bitrate */ int32_t isar_get_split_rend_md_target_brate( - const int32_t SplitRendBitRate, - const int16_t pcm_out_flag ); + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ + const int16_t pcm_out_flag /* i : flag to indicate PCM output */ +); ivas_error isar_split_rend_choose_default_codec( - ISAR_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting */ - int16_t *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ - const int16_t cldfb_in_flag, /* i : flag indicating rendering in TD */ - const int16_t pcm_out_flag, /* i : flag to indicate PCM output */ - const int16_t num_subframes /* i : number of subframes */ + ISAR_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting */ + int16_t *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ + const int16_t cldfb_in_flag, /* i : flag indicating rendering in TD */ + const int16_t pcm_out_flag, /* i : flag to indicate PCM output */ + const int16_t num_subframes /* i : number of subframes */ ); -void ISAR_SPLIT_REND_BITStream_init( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int32_t buf_len_bytes, - uint8_t *pbuf ); - -void isar_split_rend_huffman_dec_init_min_max_len( - isar_split_rend_huffman_cfg_t *p_huff_cfg ); - -int16_t wrap_a( - int16_t val, - const int16_t min_val, - const int16_t max_val ); - +/*! r: LC3plus bitrate */ int32_t isar_get_lc3plus_size_from_id( const int8_t SplitRendBitRateId, - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, - const int16_t split_prerender_frame_size_ms ); + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, /* i : ISAR pose correction mode */ + const int16_t split_prerender_frame_size_ms /* i : ISAR frame length in ms */ +); void isar_renderSplitUpdateNoCorrectionPoseData( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renderer config */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ +); int32_t get_bit( const int32_t state, - const int32_t bit_id ); + const int32_t bit_id +); +/*! r: ISAR audio type */ ISAR_POST_REND_AudioConfigType isar_getAudioConfigType( - const IVAS_AUDIO_CONFIG config ); + const IVAS_AUDIO_CONFIG config /* i : audio configuration */ +); void isar_init_split_rend_handles( - SPLIT_REND_WRAPPER *hSplitRendWrapper ); + SPLIT_REND_WRAPPER *hSplitRendWrapper /* i/o: Split renderer pre-renderer handle */ +); #endif diff --git a/lib_isar/isar_rom_lcld_tables.c b/lib_isar/isar_rom_lcld_tables.c index d3bbb46e68..2274e16af5 100644 --- a/lib_isar/isar_rom_lcld_tables.c +++ b/lib_isar/isar_rom_lcld_tables.c @@ -38,6 +38,11 @@ #include "isar_lcld_prot.h" /* clang-format off */ + +/*----------------------------------------------------------------------* + * ISAR binaural rendering LCLD ROM tables + *-----------------------------------------------------------------------*/ + const int32_t c_aiNumLcldBandsPerBand[MAX_BANDS_48] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 21, 24, 27, 31, 37, 43, 50, 60 }; diff --git a/lib_isar/isar_rom_lcld_tables.h b/lib_isar/isar_rom_lcld_tables.h index cfad1b7fc3..ae9bf73480 100644 --- a/lib_isar/isar_rom_lcld_tables.h +++ b/lib_isar/isar_rom_lcld_tables.h @@ -36,11 +36,10 @@ #include #include "options.h" + #ifdef SPLIT_REND_WITH_HEAD_ROT #ifndef M_PI - #define M_PI 3.14159265358979323846264338327950288f - #endif #define LCLD_BLOCKS_PER_FRAME ( 16 ) @@ -126,6 +125,11 @@ extern const int32_t c_aaiSpreadFunction48[MAX_BANDS_48 * MAX_BANDS_48]; #define PRED_QUANT_FILTER_PHASE_MIN ( -16 ) #define PRED_QUANT_FILTER_PHASE_MAX ( 15 ) + +/*----------------------------------------------------------------------* + * ISAR binaural rendering LCLD ROM tables + *-----------------------------------------------------------------------*/ + extern const uint16_t c_aauiLCLDHuffEnc1[16][2]; extern const uint16_t c_aauiLCLDHuffEnc2[16][2]; extern const uint16_t c_aauiLCLDHuffEnc3[25][2]; diff --git a/lib_isar/isar_rom_post_rend.c b/lib_isar/isar_rom_post_rend.c index f73a2526b8..70bd87ebca 100644 --- a/lib_isar/isar_rom_post_rend.c +++ b/lib_isar/isar_rom_post_rend.c @@ -43,7 +43,7 @@ #ifdef SPLIT_REND_WITH_HEAD_ROT /*----------------------------------------------------------------------* - * Binuaral split rendering ROM tables + * ISAR binaural split post-rendering ROM tables *-----------------------------------------------------------------------*/ /* rotations in this array are relative to ref rotation */ diff --git a/lib_isar/isar_rom_post_rend.h b/lib_isar/isar_rom_post_rend.h index 043ba5b213..2f5a1a1eec 100644 --- a/lib_isar/isar_rom_post_rend.h +++ b/lib_isar/isar_rom_post_rend.h @@ -43,7 +43,7 @@ #ifdef SPLIT_REND_WITH_HEAD_ROT /*----------------------------------------------------------------------* - * Binuaral split rendering ROM tables + * ISAR binarual split post-rendering ROM tables *-----------------------------------------------------------------------*/ extern const float isar_split_rend_relative_yaw_pos_angles[SPLIT_REND_MAX_YAW_ONLY_POSES]; diff --git a/lib_isar/isar_splitRend_lcld_dec.c b/lib_isar/isar_splitRend_lcld_dec.c index 95362d50ed..993c714bdb 100644 --- a/lib_isar/isar_splitRend_lcld_dec.c +++ b/lib_isar/isar_splitRend_lcld_dec.c @@ -49,7 +49,7 @@ *------------------------------------------------------------------------*/ ivas_error isar_splitBinLCLDDecOpen( - ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec, + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec, /* i/o: ISAR LCLD decoder handle */ const int32_t iSampleRate, const int16_t iChannels, const int16_t iNumBlocks, @@ -127,7 +127,8 @@ ivas_error isar_splitBinLCLDDecOpen( *------------------------------------------------------------------------*/ void isar_splitBinLCLDDecClose( - ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec ) + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec /* o : ISAR LCLD decoder handle */ +) { int16_t n; @@ -169,11 +170,12 @@ void isar_splitBinLCLDDecClose( *------------------------------------------------------------------------*/ void isar_splitBinLCLDDecProcess( - ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE hSplitBinLCLDDec, - ISAR_SPLIT_REND_BITS_HANDLE pBits, - float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - const int16_t bfi ) + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE hSplitBinLCLDDec, /* i/o: ISAR LCLD decoder handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, real part */ + float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, imag. part */ + const int16_t bfi /* i : BFI flag */ +) { int16_t k, n; int16_t itr; diff --git a/lib_isar/isar_splitRend_lcld_enc.c b/lib_isar/isar_splitRend_lcld_enc.c index ebeaacab9c..95efee22b0 100644 --- a/lib_isar/isar_splitRend_lcld_enc.c +++ b/lib_isar/isar_splitRend_lcld_enc.c @@ -48,7 +48,7 @@ *------------------------------------------------------------------------*/ ivas_error isar_splitBinLCLDEncOpen( - ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc, + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc, /* o : ISAR LCLD handle */ const int32_t iSampleRate, const int16_t iChannels, const int32_t iDataRate, @@ -121,7 +121,8 @@ ivas_error isar_splitBinLCLDEncOpen( *------------------------------------------------------------------------*/ void isar_splitBinLCLDEncClose( - ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc ) + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc /* i/o: ISAR LCLD handle */ +) { if ( ( *hSplitBinLCLDEnc ) != NULL ) { @@ -157,11 +158,12 @@ void isar_splitBinLCLDEncClose( *------------------------------------------------------------------------*/ void isar_splitBinLCLDEncProcess( - ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, /* i/o: ISAR LCLD encoder handle */ float Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const int32_t available_bits, - ISAR_SPLIT_REND_BITS_HANDLE pBits ) + ISAR_SPLIT_REND_BITS_HANDLE pBits /* i/o: ISAR bits handle */ +) { int32_t iBitsWritten, itr, available_bits_itr, rem_itr, available_bits_local; push_wmops( "isar_splitBinLCLDEncProcess" ); diff --git a/lib_isar/isar_splitRendererPLC.c b/lib_isar/isar_splitRendererPLC.c index e781676d5f..ebf5c294b3 100644 --- a/lib_isar/isar_splitRendererPLC.c +++ b/lib_isar/isar_splitRendererPLC.c @@ -318,7 +318,7 @@ static void adaptive_polar_ext_plc( *------------------------------------------------------------------------*/ ivas_error isar_splitBinRendPLCOpen( - ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC, + ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC, /* i/o: ISAR PLC handle */ const int16_t iNumSubSets ) { ivas_error error; @@ -348,7 +348,8 @@ ivas_error isar_splitBinRendPLCOpen( *------------------------------------------------------------------------*/ void isar_splitBinRendPLCClose( - ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC ) + ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC /* i/o: ISAR PLC handle */ +) { if ( ( *phSplitRendPLC ) != NULL ) { @@ -502,7 +503,6 @@ void isar_splitBinRendPLC( } } - /* Check bf counter */ fade_start_cntr = SR_PLC_FADE_START * CLDFB_NO_COL_MAX / iNumCols; mute_cntr = SR_PLC_MUTE * CLDFB_NO_COL_MAX / iNumCols; diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index 495caee233..ce3ebda9fe 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -46,16 +46,12 @@ #endif #include "wmc_auto.h" + /*---------------------------------------------------------------------* * Local function declarations *---------------------------------------------------------------------*/ -static void isar_SplitRenderer_PostRenderer( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinPostRenderer, /* i/o: binaural renderer handle */ - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - float Cldfb_RealBuffer_Ref_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ - float Cldfb_ImagBuffer_Ref_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ - const IVAS_QUATERNION Quaternion_act ); +static void isar_SplitRenderer_PostRenderer( ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinPostRenderer, MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, float Cldfb_RealBuffer_Ref_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float Cldfb_ImagBuffer_Ref_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], const IVAS_QUATERNION Quaternion_act ); /*------------------------------------------------------------------------- @@ -65,9 +61,10 @@ static void isar_SplitRenderer_PostRenderer( *------------------------------------------------------------------------*/ ivas_error isar_splitBinPostRendOpen( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const int32_t output_Fs ) + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const int32_t output_Fs /* i : output sampling rate */ +) { ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinRend; ivas_error error; @@ -134,7 +131,8 @@ ivas_error isar_splitBinPostRendOpen( *------------------------------------------------------------------------*/ void isar_splitBinPostRendClose( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend ) + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend /* i/o: binaural post-renderer handle */ +) { int16_t ch; @@ -183,7 +181,7 @@ void isar_splitBinPostRendClose( static int16_t isar_split_rend_huffman_decode_opt( isar_split_rend_huffman_cfg_t *huff_cfg, - ISAR_SPLIT_REND_BITS_HANDLE pBits, + const ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i : ISAR bits handle */ const int16_t *idx_trav_list ) { int32_t i, ind, code, num_bits, code_b, num_bits_read; @@ -221,6 +219,7 @@ static int16_t isar_split_rend_huffman_decode_opt( return (int16_t) ind; } + /*-----------------------------------------------------------------------------------------* * Function isar_split_rend_unquant_md() * @@ -303,9 +302,9 @@ static void isar_split_rend_unquant_md( *-----------------------------------------------------------------------------------------*/ static void isar_splitBinPostRendMdBase2Dec( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const int16_t num_subframes, const int16_t pred_real_bands_yaw, const int16_t pred_imag_bands_yaw, @@ -431,9 +430,9 @@ static void isar_splitBinPostRendMdBase2Dec( *-----------------------------------------------------------------------------------------*/ static void isar_splitBinPostRendMdHuffDec( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i : ISAR bits handle */ + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const int16_t num_subframes, const int16_t pred_real_bands_yaw, const int16_t pred_imag_bands_yaw, @@ -555,9 +554,9 @@ static void isar_splitBinPostRendMdHuffDec( *-----------------------------------------------------------------------------------------*/ void isar_splitBinPostRendMdDec( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData + const ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i : ISAR bits handle */ + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG , BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend @@ -955,6 +954,7 @@ static void wrap_around_angle( { ( *a ) = ( *a ) + 360; } + return; } @@ -975,6 +975,7 @@ static void wrap_around_ypr( wrap_around_angle( &Quaternions->y ); wrap_around_angle( &Quaternions->z ); } + return; } @@ -1067,7 +1068,7 @@ static void get_nearest_pose_ind( *-----------------------------------------------------------------------------------------*/ static void get_interpolation_vars( - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const IVAS_QUATERNION *Quaternions_ref, const IVAS_QUATERNION *Quaternions_act, int16_t interp_yaw_pose_idx[2], @@ -1345,8 +1346,8 @@ static void interpolate_rend_md( *-----------------------------------------------------------------------------------------*/ static void isar_SplitRenderer_PostRenderer( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinPostRenderer, /* i/o: binaural renderer handle */ - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinPostRenderer, /* i/o: binaural renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ float Cldfb_RealBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ float Cldfb_ImagBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ const IVAS_QUATERNION Quaternion_act ) @@ -1408,7 +1409,6 @@ static void isar_SplitRenderer_PostRenderer( } } - #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES - 1; pos_idx++ ) { @@ -1445,9 +1445,6 @@ static void isar_SplitRenderer_PostRenderer( } } -#endif - -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) #else pos_idx = 0; @@ -1580,8 +1577,8 @@ static void isar_SplitRenderer_PostRenderer( fname ); } } -#endif +#endif pop_wmops(); return; } @@ -1594,8 +1591,8 @@ static void isar_SplitRenderer_PostRenderer( *-----------------------------------------------------------------------------------------*/ static void isar_rend_CldfbSplitPostRendProcessTdIn( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const IVAS_QUATERNION QuaternionPost, float output[][L_FRAME48k] ) { @@ -1645,8 +1642,8 @@ static void isar_rend_CldfbSplitPostRendProcessTdIn( *-----------------------------------------------------------------------------------------*/ void isar_rend_CldfbSplitPostRendProcess( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const IVAS_QUATERNION QuaternionPost, float Cldfb_RealBuffer_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float Cldfb_ImagBuffer_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], @@ -1695,7 +1692,8 @@ void isar_rend_CldfbSplitPostRendProcess( *-----------------------------------------------------------------------------------------*/ void isar_init_split_post_rend_handles( - ISAR_SPLIT_POST_REND_WRAPPER *hSplitRendWrapper ) + ISAR_SPLIT_POST_REND_WRAPPER *hSplitRendWrapper /* i/o: Split renderer post-renderer handle */ +) { hSplitRendWrapper->hBinHrSplitPostRend = NULL; hSplitRendWrapper->hSplitBinLCLDDec = NULL; diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 56e4b6b1e0..e2a99776cf 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -54,13 +54,8 @@ * Local function declarations *---------------------------------------------------------------------*/ -static void isar_SplitRenderer_GetRotMd( - ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i/o: binaural renderer handle */ - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - float Cldfb_RealBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Reference Binaural signals */ - float Cldfb_ImagBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Reference Binaural signals */ - const int16_t low_res, - const int16_t ro_md_flag ); +static void isar_SplitRenderer_GetRotMd( ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, float Cldfb_RealBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float Cldfb_ImagBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const int16_t low_res, const int16_t ro_md_flag ); + /*------------------------------------------------------------------------- * Local functions @@ -693,8 +688,8 @@ static void ComputeCoeffs( static void get_base2_bits( - const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i : binaural pre-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const int16_t num_subframes, const int16_t num_quant_strats, const int16_t pred_real_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], @@ -755,8 +750,8 @@ static void get_base2_bits( static void isar_SplitRenderer_code_md_base2( - const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i : binaural pre-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const int16_t num_subframes, const int16_t pred_real_bands_yaw, const int16_t pred_imag_bands_yaw, @@ -765,7 +760,8 @@ static void isar_SplitRenderer_code_md_base2( const int16_t bands_pitch, const int16_t pred_real_bands_roll, const int16_t pred_imag_bands_roll, - ISAR_SPLIT_REND_BITS_HANDLE pBits ) + const ISAR_SPLIT_REND_BITS_HANDLE pBits /* i/o: ISAR bits handle */ +) { int16_t pos_idx, b, ch1, ch2, sf_idx; int16_t min_pred_idx, min_gd_idx, min_p_gd_idx, pred_code_len, gd_code_len, p_gd_code_len, num_poses; @@ -901,8 +897,8 @@ static void isar_SplitRenderer_code_md_base2( static void isar_SplitRenderer_code_md_huff( - const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i : binaural pre-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const int16_t num_subframes, const int16_t pred_real_bands_yaw, const int16_t pred_imag_bands_yaw, @@ -911,7 +907,8 @@ static void isar_SplitRenderer_code_md_huff( const int16_t bands_pitch, const int16_t pred_real_bands_roll, const int16_t pred_imag_bands_roll, - ISAR_SPLIT_REND_BITS_HANDLE pBits ) + const ISAR_SPLIT_REND_BITS_HANDLE pBits /* i/o: ISAR bits handle */ +) { int16_t pos_idx, b, ch1, ch2, sf_idx, num_poses; int16_t sym_adj_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; @@ -1047,11 +1044,11 @@ static void isar_SplitRenderer_code_md_huff( static void isar_SplitRenderer_quant_code( - const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, - const IVAS_QUATERNION headPosition, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int16_t low_res_pre_rend_rot, + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i : binaural pre-renderer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const int16_t low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ const int32_t target_md_bits ) { int16_t num_complex_bands, q, num_subframes, sf_idx, pos_idx, b, num_quant_strats; @@ -1110,8 +1107,7 @@ static void isar_SplitRenderer_quant_code( overhead_bits = pBits->bits_written - overhead_bits + quant_strat_bits + 1; /* 1 for base2 vs huff */ get_base2_bits( hBinHrSplitPreRend, pMultiBinPoseData, num_subframes, num_quant_strats, pred_real_bands_yaw, pred_imag_bands_yaw, - pred_quant_pnts_yaw, - d_bands_yaw, bands_pitch, pred_real_bands_roll, pred_imag_bands_roll, base2bits ); + pred_quant_pnts_yaw, d_bands_yaw, bands_pitch, pred_real_bands_roll, pred_imag_bands_roll, base2bits ); for ( q = 0; q < num_quant_strats; q++ ) { @@ -1197,8 +1193,7 @@ static void isar_SplitRenderer_quant_code( ISAR_SPLIT_REND_BITStream_write_int32( pBits, q, quant_strat_bits ); isar_SplitRenderer_code_md_base2( hBinHrSplitPreRend, pMultiBinPoseData, num_subframes, pred_real_bands_yaw[q], pred_imag_bands_yaw[q], - pred_quant_pnts_yaw[q], - d_bands_yaw[q], bands_pitch[q], pred_real_bands_roll[q], pred_imag_bands_roll[q], pBits ); + pred_quant_pnts_yaw[q], d_bands_yaw[q], bands_pitch[q], pred_real_bands_roll[q], pred_imag_bands_roll[q], pBits ); } break; } @@ -1281,8 +1276,8 @@ static void isar_SplitRenderer_quant_code( } } } -#endif +#endif return; } @@ -1294,12 +1289,13 @@ static void isar_SplitRenderer_quant_code( *------------------------------------------------------------------------*/ static void isar_SplitRenderer_GetRotMd( - ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i/o: binaural renderer handle */ - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + 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 */ float Cldfb_RealBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Reference Binaural signals */ float Cldfb_ImagBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Reference Binaural signals */ const int16_t low_res, - const int16_t ro_md_flag ) + const int16_t ro_md_flag /* i : Flag to indicate real only metadata for yaw */ +) { float cov_ii_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; float cov_oo_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; @@ -1378,15 +1374,16 @@ static void isar_SplitRenderer_GetRotMd( *------------------------------------------------------------------------*/ void isar_rend_CldfbSplitPreRendProcess( - const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, - const IVAS_QUATERNION headPosition, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int32_t target_md_bits, - const int16_t low_res_pre_rend_rot, - const int16_t ro_md_flag ) + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i : binaural pre-renderer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, real part */ + float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, imag. part */ + const ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i : ISAR bits handle */ + const int32_t target_md_bits, /* i : ISAR MD bitrate */ + const int16_t low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ + const int16_t ro_md_flag /* i : real only metadata for yaw flag */ +) { push_wmops( "isar_rend_CldfbSplitPreRendProcess" ); @@ -1497,8 +1494,8 @@ void isar_rend_CldfbSplitPreRendProcess( *------------------------------------------------------------------------*/ ivas_error isar_splitBinPreRendOpen( - ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend, /* i/o: binaural pre-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* o : pose correction data handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG , const int32_t output_Fs @@ -1536,8 +1533,8 @@ ivas_error isar_splitBinPreRendOpen( } } } -#endif +#endif for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) { for ( sf_idx = 0; sf_idx < MAX_SPLIT_MD_SUBFRAMES; sf_idx++ ) @@ -1561,8 +1558,8 @@ ivas_error isar_splitBinPreRendOpen( { return error; } -#endif +#endif *hBinHrSplitPreRend = hBinRend; return IVAS_ERR_OK; @@ -1576,7 +1573,8 @@ ivas_error isar_splitBinPreRendOpen( *------------------------------------------------------------------------*/ void isar_splitBinPreRendClose( - ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend ) + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend /* i/o: binaural pre-renderer handle */ +) { if ( ( *hBinHrSplitPreRend ) != NULL ) { @@ -1615,11 +1613,13 @@ void isar_splitBinPreRendClose( *-------------------------------------------------------------------------*/ void isar_set_split_rend_ht_setup( - SPLIT_REND_WRAPPER *hSplitrend, - IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES], - float Rmat[MAX_PARAM_SPATIAL_SUBFRAMES][3][3] ) + SPLIT_REND_WRAPPER *hSplitrend, /* i/o: Split renderer pre-renderer handle */ + IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES], /* i/o: External orientation in quaternions */ + float Rmat[MAX_PARAM_SPATIAL_SUBFRAMES][3][3] /* o : real-space rotation matrix */ +) { int16_t sf, i, j; + if ( hSplitrend->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) { for ( sf = 1; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) @@ -1647,7 +1647,8 @@ void isar_set_split_rend_ht_setup( *------------------------------------------------------------------------*/ void isar_init_split_rend_handles( - SPLIT_REND_WRAPPER *hSplitRendWrapper ) + SPLIT_REND_WRAPPER *hSplitRendWrapper /* i/o: Split renderer pre-renderer handle */ +) { int16_t i; @@ -1667,6 +1668,7 @@ void isar_init_split_rend_handles( return; } + /*------------------------------------------------------------------------- * Function split_renderer_open_lc3plus() * @@ -1674,10 +1676,10 @@ void isar_init_split_rend_handles( *------------------------------------------------------------------------*/ ivas_error split_renderer_open_lc3plus( - SPLIT_REND_WRAPPER *hSplitRendWrapper, - const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, - const int32_t OutSampleRate, - const int16_t num_subframes ) + SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i/o: Split renderer pre-renderer handle */ + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i : Split renderer pre-renderer config */ + const int32_t output_Fs, /* i : output sampling rate */ + const int16_t num_subframes ) /* i : number of subframes */ { ivas_error error; int16_t i, delayBufferLength; @@ -1685,7 +1687,7 @@ ivas_error split_renderer_open_lc3plus( config.lc3plus_frame_duration_us = pSplitRendConfig->codec_frame_size_ms * 1000; config.ivas_frame_duration_us = ( pSplitRendConfig->dof == 0 ) ? config.lc3plus_frame_duration_us * num_subframes : 20000; - config.samplerate = OutSampleRate; + config.samplerate = output_Fs; config.channels = BINAURAL_CHANNELS; @@ -1703,7 +1705,7 @@ ivas_error split_renderer_open_lc3plus( /* Alocate buffers for delay compensation */ if ( pSplitRendConfig->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS ) { - delayBufferLength = (int16_t) ( OutSampleRate / (int32_t) FRAMES_PER_SECOND + hSplitRendWrapper->lc3plusDelaySamples ); + delayBufferLength = (int16_t) ( output_Fs / (int32_t) FRAMES_PER_SECOND + hSplitRendWrapper->lc3plusDelaySamples ); for ( i = 0; i < hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++i ) { if ( ( hSplitRendWrapper->lc3plusDelayBuffers[i] = malloc( delayBufferLength * sizeof( float ) ) ) == NULL ) @@ -1717,8 +1719,8 @@ ivas_error split_renderer_open_lc3plus( else { /* Delay is always expected to be exactly 2 CLDFB columns */ - assert( hSplitRendWrapper->lc3plusDelaySamples % ( OutSampleRate / FRAMES_PER_SEC / CLDFB_NO_COL_MAX ) == 0 ); - assert( hSplitRendWrapper->lc3plusDelaySamples / ( OutSampleRate / FRAMES_PER_SEC / CLDFB_NO_COL_MAX ) == 2 ); + assert( hSplitRendWrapper->lc3plusDelaySamples % ( output_Fs / FRAMES_PER_SEC / CLDFB_NO_COL_MAX ) == 0 ); + assert( hSplitRendWrapper->lc3plusDelaySamples / ( output_Fs / FRAMES_PER_SEC / CLDFB_NO_COL_MAX ) == 2 ); delayBufferLength = 2 /* Columns */ * 2 /* real and imag */ * CLDFB_NO_CHANNELS_MAX; for ( i = 0; i < hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++i ) @@ -1743,9 +1745,9 @@ ivas_error split_renderer_open_lc3plus( *------------------------------------------------------------------------*/ ivas_error splitRendLc3plusEncodeAndWrite( - SPLIT_REND_WRAPPER *hSplitBin, - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int32_t SplitRendBitRate, + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ float *in[] ) { ivas_error error; @@ -1782,6 +1784,7 @@ ivas_error splitRendLc3plusEncodeAndWrite( pBits->codec = ISAR_SPLIT_REND_CODEC_LC3PLUS; pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode; pBits->codec_frame_size_ms = (int16_t) ( hSplitBin->hLc3plusEnc->config.lc3plus_frame_duration_us / 1000 ); + return IVAS_ERR_OK; } @@ -1793,16 +1796,17 @@ ivas_error splitRendLc3plusEncodeAndWrite( *------------------------------------------------------------------------*/ ivas_error isar_renderMultiTDBinToSplitBinaural( - SPLIT_REND_WRAPPER *hSplitBin, - const IVAS_QUATERNION headPosition, - const int32_t SplitRendBitRate, - const int16_t codec_frame_size_ms, - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int16_t max_bands, - float *in[], - const int16_t low_res_pre_rend_rot, - const int16_t pcm_out_flag, - const int16_t ro_md_flag ) + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ + const int16_t codec_frame_size_ms, /* i : ISAR frame length in ms */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const int16_t max_bands, /* i : CLDFB bands */ + float *in[], /* i/o: PCM in/out buffer */ + const int16_t low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ + const int16_t pcm_out_flag, /* i : flag to indicate PCM output */ + const int16_t ro_md_flag /* i : real only metadata for yaw flag */ +) { ivas_error error; int32_t bit_len, available_bits, target_md_bits, actual_md_bits; @@ -1952,9 +1956,10 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( *------------------------------------------------------------------------*/ void lc3plusTimeAlignCldfbPoseCorr( - SPLIT_REND_WRAPPER *hSplitBin, - float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] ) + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ + float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: Binaural signals, real part */ + float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] /* ii/: Binaural signals, imag. part */ +) { float Cldfb_In_BinReal_tmp[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][2][CLDFB_NO_CHANNELS_MAX]; float Cldfb_In_BinImag_tmp[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][2][CLDFB_NO_CHANNELS_MAX]; diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c index 8d03e297d7..f6cf104b45 100644 --- a/lib_isar/isar_splitRenderer_utils.c +++ b/lib_isar/isar_splitRenderer_utils.c @@ -79,33 +79,13 @@ void isar_mat_mult_2by2_complex( } -/*------------------------------------------------------------------------- - * Function ISAR_SPLIT_REND_BITStream_init() - * - * - *------------------------------------------------------------------------*/ - -void ISAR_SPLIT_REND_BITStream_init( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int32_t buf_len_bytes, - uint8_t *pbuf ) -{ - pBits->bits_buf = pbuf; - pBits->buf_len = buf_len_bytes; - pBits->bits_read = 0; - pBits->bits_written = 0; - - return; -} - - /*------------------------------------------------------------------------- * Function isar_split_rend_huffman_dec_init_min_max_len() * * *------------------------------------------------------------------------*/ -void isar_split_rend_huffman_dec_init_min_max_len( +static void isar_split_rend_huffman_dec_init_min_max_len( isar_split_rend_huffman_cfg_t *p_huff_cfg ) { int16_t i, code_len; @@ -257,7 +237,8 @@ void isar_split_rend_init_huff_cfg( void set_fix_rotation_mat( float fix_pos_rot_mat[][BINAURAL_CHANNELS][BINAURAL_CHANNELS], - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ +) { float yaw_a, cos_yaw, sin_yaw; int16_t pos_idx; @@ -286,8 +267,9 @@ void set_fix_rotation_mat( *------------------------------------------------------------------------*/ void set_pose_types( - ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1], - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) + ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1], /* o : ISAR pose type */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i : pose correction data handle */ +) { int16_t pos_idx; @@ -317,7 +299,7 @@ void set_pose_types( * *------------------------------------------------------------------------*/ -int16_t wrap_a( +static int16_t wrap_a( int16_t val, const int16_t min_val, const int16_t max_val ) @@ -366,17 +348,19 @@ void isar_SplitRenderer_getdiagdiff( * *------------------------------------------------------------------------*/ +/*! r: parameter value */ int32_t ISAR_SPLIT_REND_BITStream_read_int32( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int32_t bits ) + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const int32_t bits /* i : number of bits to be read */ +) { int32_t val, k, bit_val; #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG assert( ( pBits->bits_written - pBits->bits_read ) >= bits ); assert( bits <= 32 ); -#endif +#endif /* write bit by bit */ val = 0; for ( k = bits - 1; k >= 0; k-- ) @@ -397,9 +381,10 @@ int32_t ISAR_SPLIT_REND_BITStream_read_int32( *------------------------------------------------------------------------*/ void ISAR_SPLIT_REND_BITStream_write_int32( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int32_t val, - const int32_t bits ) + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const int32_t val, /* i : parameter value */ + const int32_t bits /* i : number of bits to be written */ +) { int32_t mask, k; @@ -483,9 +468,11 @@ void isar_log_cldfb2wav_data( * *------------------------------------------------------------------------*/ +/*! r: ISAR MD bitrate */ int32_t isar_get_split_rend_md_target_brate( - const int32_t SplitRendBitRate, - const int16_t pcm_out_flag ) + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ + const int16_t pcm_out_flag /* i : flag to indicate PCM output */ +) { int32_t md_bitrate; @@ -529,9 +516,11 @@ int32_t isar_get_split_rend_md_target_brate( * *------------------------------------------------------------------------*/ +/*! r: LCLD codec bitrate */ int32_t isar_get_lcld_bitrate( - const int32_t SplitRendBitRate, - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode ) + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode /* i : ISAR pose correction mode */ +) { if ( poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) { @@ -570,9 +559,10 @@ int32_t isar_get_lcld_bitrate( * *------------------------------------------------------------------------*/ +/*! r: LC3plus bitrate */ int32_t isar_get_lc3plus_bitrate( - const int32_t SplitRendBitRate, - ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, /* i : ISAR pose correction mode */ const int16_t split_prerender_frame_size_ms ) { if ( poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) @@ -598,8 +588,10 @@ int32_t isar_get_lc3plus_bitrate( * *------------------------------------------------------------------------*/ +/*! r: LC3plus codec bitrate ID */ int8_t isar_get_lc3plus_bitrate_id( - const int32_t SplitRendBitRate ) + const int32_t SplitRendBitRate /* i : ISAR bitrate */ +) { switch ( SplitRendBitRate ) { @@ -639,10 +631,12 @@ int8_t isar_get_lc3plus_bitrate_id( * *------------------------------------------------------------------------*/ +/*! r: LC3plus bitrate */ int32_t isar_get_lc3plus_size_from_id( const int8_t SplitRendBitRateId, - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, - const int16_t split_prerender_frame_size_ms ) + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, /* i : ISAR pose correction mode */ + const int16_t split_prerender_frame_size_ms /* i : ISAR frame length in ms */ +) { int32_t bitrate; @@ -694,8 +688,9 @@ int32_t isar_get_lc3plus_size_from_id( *------------------------------------------------------------------------*/ ivas_error isar_split_rend_validate_config( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, - const int16_t is_pcm_out ) + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i/o: Split renderer pre-renderer config */ + const int16_t pcm_out_flag /* i : flag to indicate PCM output */ +) { /* Valid DOF range is 0-3 */ if ( pSplitRendConfig->dof < 0 || pSplitRendConfig->dof > 3 ) @@ -730,7 +725,7 @@ ivas_error isar_split_rend_validate_config( } /* Validate bitrate */ - if ( is_pcm_out == 0 ) + if ( pcm_out_flag == 0 ) { switch ( pSplitRendConfig->splitRendBitRate ) { @@ -859,9 +854,10 @@ void isar_split_rend_get_quant_params( *------------------------------------------------------------------------*/ void isar_renderSplitGetMultiBinPoseData( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const ISAR_SPLIT_REND_ROT_AXIS rot_axis ) + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renderer config */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ +) { int16_t pos_idx, num_yaw_poses, num_pitch_poses, num_roll_poses; const float *relative_yaw_angles; @@ -998,8 +994,9 @@ void isar_renderSplitGetMultiBinPoseData( *------------------------------------------------------------------------*/ void isar_renderSplitUpdateNoCorrectionPoseData( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renderer config */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ +) { pMultiBinPoseData->num_poses = 1; assert( pSplit_rend_config->dof == 0 ); @@ -1018,7 +1015,8 @@ void isar_renderSplitUpdateNoCorrectionPoseData( *------------------------------------------------------------------------*/ void isar_init_multi_bin_pose_data( - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ +) { int16_t pos_idx; @@ -1082,6 +1080,7 @@ ivas_error isar_split_rend_choose_default_codec( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------* * Function get_bit() * diff --git a/lib_isar/isar_stat.h b/lib_isar/isar_stat.h index e43ac88cce..3182dbf0f9 100644 --- a/lib_isar/isar_stat.h +++ b/lib_isar/isar_stat.h @@ -138,10 +138,6 @@ typedef struct isar_binaural_head_rot_split_pre_rendering_struct } ISAR_BIN_HR_SPLIT_PRE_REND, *ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE; -/*----------------------------------------------------------------------------------* - * Output configuration for renderer (e.g. DirAC, MASA, Binaural Renderer...) - *----------------------------------------------------------------------------------*/ - typedef struct isar_binaural_head_rot_split_rendering_lcld_enc_struct { void *pLcld_enc; diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index a36aa347c9..9899b66952 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -130,14 +130,17 @@ struct ISAR_POST_REND int16_t num_subframes; }; + /*-------------------------------------------------------------------* - * getAudioConfigType() + * ISAR_POST_REND_AudioConfigType() * * *-------------------------------------------------------------------*/ +/*! r: ISAR audio type */ ISAR_POST_REND_AudioConfigType isar_getAudioConfigType( - const AUDIO_CONFIG config ) + const AUDIO_CONFIG config /* i : audio configuration */ +) { ISAR_POST_REND_AudioConfigType type; @@ -157,10 +160,6 @@ ISAR_POST_REND_AudioConfigType isar_getAudioConfigType( } -/*-------------------------------------------------------------------* - * Local function prototypes - *-------------------------------------------------------------------*/ - /*-------------------------------------------------------------------* * Local functions *-------------------------------------------------------------------*/ @@ -178,6 +177,7 @@ static ivas_error allocateInputBaseBufferData( return IVAS_ERR_OK; } + static void freeInputBaseBufferData( float **data ) { @@ -215,6 +215,7 @@ static void convertBitsBufferToInternalBitsBuff( return; } + static void convertInternalBitsBuffToBitsBuffer( ISAR_POST_REND_BitstreamBuffer *hOutBits, const ISAR_SPLIT_REND_BITS_DATA bits ) @@ -230,6 +231,7 @@ static void convertInternalBitsBuffToBitsBuffer( return; } + static void copyBufferTo2dArray( const IVAS_REND_AudioBuffer buffer, float array[][L_FRAME48k] ) @@ -252,6 +254,7 @@ static void copyBufferTo2dArray( return; } + static void accumulate2dArrayToBuffer( float array[][L_FRAME48k], const IVAS_REND_AudioBuffer *buffer ) @@ -271,13 +274,14 @@ static void accumulate2dArrayToBuffer( return; } +#ifndef DISABLE_LIMITER + /*-------------------------------------------------------------------* * limitRendererOutput() * * In-place saturation control for multichannel buffers with adaptive release time *-------------------------------------------------------------------*/ -#ifndef DISABLE_LIMITER /*! r: number of clipped output samples */ static int32_t limitRendererOutput( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ @@ -322,8 +326,8 @@ static int32_t limitRendererOutput( return numClipping; } -#endif +#endif /*-------------------------------------------------------------------* * validateOutputSampleRate() @@ -532,8 +536,7 @@ static ivas_error updateSplitPostRendPanGains( } else if ( hRendCfg->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS ) { - if ( ( error = ISAR_LC3PLUS_DEC_Open( config, - &inputSplitPostRend->splitPostRendWrapper.hLc3plusDec ) ) != IVAS_ERR_OK ) + if ( ( error = ISAR_LC3PLUS_DEC_Open( config, &inputSplitPostRend->splitPostRendWrapper.hLc3plusDec ) ) != IVAS_ERR_OK ) { return error; } @@ -618,13 +621,13 @@ static void clearInputSplitRend( *------------------------------------------------------------------------*/ ivas_error ISAR_POST_REND_open( - ISAR_POST_REND_HANDLE *phIvasRend, /* i/o: Pointer to renderer handle */ - const int32_t outputSampleRate, /* i : output sampling rate */ - const IVAS_AUDIO_CONFIG outConfig, /* i : output audio config */ - const bool asHrtfBinary, /* i : load hrtf binary file */ - const int16_t nonDiegeticPan, /* i : non-diegetic object flag */ - const float nonDiegeticPanGain, /* i : non-diegetic panning gain */ - const int16_t num_subframes /* i : number of subframes */ + ISAR_POST_REND_HANDLE *phIvasRend, /* i/o: Pointer to renderer handle */ + const int32_t outputSampleRate, /* i : output sampling rate */ + const IVAS_AUDIO_CONFIG outConfig, /* i : output audio config */ + const bool asHrtfBinary, /* i : load hrtf binary file */ + const int16_t nonDiegeticPan, /* i : non-diegetic object flag */ + const float nonDiegeticPanGain, /* i : non-diegetic panning gain */ + const int16_t num_subframes /* i : number of subframes */ ) { int16_t i; @@ -703,8 +706,8 @@ ivas_error ISAR_POST_REND_open( *-------------------------------------------------------------------*/ ivas_error ISAR_POST_REND_NumOutChannels( - ISAR_POST_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ - int16_t *numOutChannels /* o : number of output channels */ + ISAR_POST_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ + int16_t *numOutChannels /* o : number of output channels */ ) { /* Validate function arguments */ @@ -773,6 +776,7 @@ static ivas_error getInputById( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------* * ISAR_POST_REND_SetInputGain() * @@ -805,6 +809,7 @@ ivas_error ISAR_POST_REND_SetInputGain( return IVAS_ERR_OK; } + static ivas_error getConstInputById( ISAR_POST_REND_CONST_HANDLE hIvasRend, const ISAR_POST_REND_InputId inputId, @@ -1191,6 +1196,7 @@ int16_t ISAR_POST_REND_GetRenderConfig( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------* * ISAR_POST_REND_FeedSplitBinauralBitstream() * @@ -1281,8 +1287,8 @@ ivas_error ISAR_POST_REND_SetHeadRotation( *-------------------------------------------------------------------*/ ivas_error ISAR_POST_REND_SetSplitRendBFI( - ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - const int16_t bfi /* i: BFI flag */ + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const int16_t bfi /* i : BFI flag */ ) { hIvasRend->splitRendBFI = bfi; @@ -1295,7 +1301,6 @@ ivas_error ISAR_POST_REND_SetSplitRendBFI( * Local functions *-------------------------------------------------------------------*/ - static ivas_error splitBinLc3plusDecode( ISAR_SPLIT_POST_REND_WRAPPER *hSplitBin, ISAR_SPLIT_REND_BITS_HANDLE bits, @@ -1597,6 +1602,7 @@ static ivas_error renderSplitBinauralWithPostRot( return error; } + static ivas_error renderInputSplitBin( input_split_post_rend *splitBinInput, const AUDIO_CONFIG outConfig, @@ -1628,6 +1634,7 @@ static ivas_error renderInputSplitBin( return error; } + static ivas_error renderActiveInputsSplitBin( ISAR_POST_REND_HANDLE hIvasRend, IVAS_REND_AudioBuffer outAudio ) @@ -1722,6 +1729,7 @@ ivas_error ISAR_POST_REND_getSamples( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------* * ISAR_POST_REND_GetSplitBinauralSamples() * @@ -1729,8 +1737,8 @@ ivas_error ISAR_POST_REND_getSamples( *-------------------------------------------------------------------*/ ivas_error ISAR_POST_REND_GetSplitBinauralSamples( - ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ bool *needNewFrame ) { ivas_error error; @@ -1779,20 +1787,28 @@ void ISAR_POST_REND_Close( } +/*-------------------------------------------------------------------* + * ISAR_REND_SetSplitRendBitstreamHeader() + * + * + *-------------------------------------------------------------------*/ + ivas_error ISAR_REND_SetSplitRendBitstreamHeader( - ISAR_POST_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ - const ISAR_SPLIT_REND_CODEC codec, /* o: codec setting */ - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, /* o: pose correction mode */ - const int16_t codec_frame_size_ms /* o: codec frame size setting */ + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + const ISAR_SPLIT_REND_CODEC codec, /* i : codec setting */ + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, /* i : pose correction mode */ + const int16_t codec_frame_size_ms /* i : codec frame size setting */ ) { if ( hIvasRend == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + hIvasRend->splitRenderConfig.codec = codec; hIvasRend->splitRenderConfig.codec_frame_size_ms = codec_frame_size_ms; hIvasRend->splitRenderConfig.poseCorrectionMode = poseCorrection; + return IVAS_ERR_OK; } diff --git a/lib_isar/lib_isar_post_rend.h b/lib_isar/lib_isar_post_rend.h index 61ebae2dd7..85a0488474 100644 --- a/lib_isar/lib_isar_post_rend.h +++ b/lib_isar/lib_isar_post_rend.h @@ -44,14 +44,14 @@ int32_t ISAR_POST_REND_void_func( void ); #else /*---------------------------------------------------------------------* - * Renderer constants + * ISAR post-renderer constants *---------------------------------------------------------------------*/ #define RENDERER_MAX_ISAR_MD_INPUTS 1 #define RENDERER_MAX_BIN_INPUTS 1 /*---------------------------------------------------------------------* - * Renderer structures + * ISAR post-renderer structures *---------------------------------------------------------------------*/ typedef struct @@ -97,7 +97,7 @@ typedef enum _ISAR_POST_REND_COMPLEXITY_LEVEL /* clang-format off */ /*----------------------------------------------------------------------------------* - * Renderer function prototypes + * ISAR post-renderer function prototypes *----------------------------------------------------------------------------------*/ /* Functions to be called before rendering */ @@ -183,13 +183,13 @@ ivas_error ISAR_POST_REND_SetHeadRotation( ivas_error ISAR_POST_REND_SetSplitRendBFI( ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - const int16_t bfi /* i: BFI flag */ + const int16_t bfi /* i : BFI flag */ ); ivas_error ISAR_POST_REND_getSamples( ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_REND_AudioBuffer outAudio /* i/o: buffer for output audio */ + IVAS_REND_AudioBuffer outAudio /* i/o: buffer for output audio */ ); /* Functions to be called after rendering */ @@ -200,18 +200,18 @@ void ISAR_POST_REND_Close( ivas_error ISAR_REND_SetSplitRendBitstreamHeader( ISAR_POST_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ - const ISAR_SPLIT_REND_CODEC codec, /* o: codec setting */ - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, /* o: pose correction mode */ - const int16_t codec_frame_size_ms /* o: codec frame size setting */ + const ISAR_SPLIT_REND_CODEC codec, /* i : codec setting */ + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, /* i : pose correction mode */ + const int16_t codec_frame_size_ms /* i : codec frame size setting */ ); #ifdef DEBUGGING int32_t ISAR_POST_REND_GetNoCLipping( - IVAS_REND_CONST_HANDLE hIvasRend /* i : Renderer handle */ + IVAS_REND_CONST_HANDLE hIvasRend /* i : Renderer handle */ ); int32_t ISAR_POST_REND_GetCntFramesLimited( - IVAS_REND_CONST_HANDLE hIvasRend /* i : Renderer handle */ + IVAS_REND_CONST_HANDLE hIvasRend /* i : Renderer handle */ ); #endif diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 19a7345b98..a665f2a141 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -54,22 +54,6 @@ int32_t ISAR_PRE_REND_void_func( void ) #else -/*-------------------------------------------------------------------* - * Local constants - *-------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------* - * Local types - *-------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------* - * Local function prototypes - *-------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------* - * Local functions - *-------------------------------------------------------------------*/ - /*------------------------------------------------------------------------- * Function ISAR_PRE_REND_open() * @@ -77,13 +61,13 @@ int32_t ISAR_PRE_REND_void_func( void ) *------------------------------------------------------------------------*/ ivas_error ISAR_PRE_REND_open( - SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */ - ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i/o: Split renderer pre-renerer config */ - const int32_t output_Fs, /* i: output sampling rate */ - const int16_t cldfb_in_flag, /* i: Flag to indicate CLDFB or time doamin input */ - const int16_t pcm_out_flag, /* i: Flag to indicate PCM output */ - const int16_t num_subframes, /* i: number of subframes */ - const int16_t mixed_td_cldfb_flag /* i: Flag to indicate combined TD and CLDFB input */ + SPLIT_REND_WRAPPER *hSplitBinRend, /* o : Split renderer pre-renderer handle */ + ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* o : Split renderer pre-renderer config */ + const int32_t output_Fs, /* i : output sampling rate */ + const int16_t cldfb_in_flag, /* i : Flag to indicate CLDFB or time doamin input */ + const int16_t pcm_out_flag, /* i : Flag to indicate PCM output */ + const int16_t num_subframes, /* i : number of subframes */ + const int16_t mixed_td_cldfb_flag /* i : Flag to indicate combined TD and CLDFB input */ ) { ivas_error error, ch, num_ch; @@ -142,9 +126,7 @@ ivas_error ISAR_PRE_REND_open( for ( ch = 0; ch < num_ch; ch++ ) { - if ( ( error = openCldfb( &( hSplitBinRend->hCldfbHandles->cldfbAna[ch] ), - CLDFB_ANALYSIS, - output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + if ( ( error = openCldfb( &( hSplitBinRend->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return error; } @@ -161,12 +143,11 @@ ivas_error ISAR_PRE_REND_open( if ( pSplitRendConfig->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) { - if ( ( error = isar_splitBinPreRendOpen( &hSplitBinRend->hBinHrSplitPreRend, &hSplitBinRend->multiBinPoseData #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - , - OutSampleRate + if ( ( error = isar_splitBinPreRendOpen( &hSplitBinRend->hBinHrSplitPreRend, &hSplitBinRend->multiBinPoseData, OutSampleRate ) ) != IVAS_ERR_OK ) +#else + if ( ( error = isar_splitBinPreRendOpen( &hSplitBinRend->hBinHrSplitPreRend, &hSplitBinRend->multiBinPoseData ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -196,6 +177,7 @@ ivas_error ISAR_PRE_REND_open( return IVAS_ERR_OK; } + /*------------------------------------------------------------------------- * Function ISAR_PRE_REND_close() * @@ -203,8 +185,8 @@ ivas_error ISAR_PRE_REND_open( *------------------------------------------------------------------------*/ void ISAR_PRE_REND_close( - SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */ - IVAS_REND_AudioBuffer *pSplitRendEncBuffer /* i/o: Split renderer data buffer */ + SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renderer handle */ + IVAS_REND_AudioBuffer *pSplitRendEncBuffer /* i/o: Split renderer data buffer */ ) { int16_t i; @@ -275,6 +257,7 @@ void ISAR_PRE_REND_close( return; } + /*-------------------------------------------------------------------------* * ISAR_PRE_REND_GetMultiBinPoseData() * @@ -282,14 +265,17 @@ void ISAR_PRE_REND_close( *-------------------------------------------------------------------------*/ void ISAR_PRE_REND_GetMultiBinPoseData( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i: Split renderer pre-renerer config */ - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ - const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i: Rotation axis */ + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renderer config */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : Rotation axis */ ) { isar_renderSplitGetMultiBinPoseData( pSplit_rend_config, pMultiBinPoseData, rot_axis ); + + return; } + /*------------------------------------------------------------------------- * Function ISAR_PRE_REND_MultiBinToSplitBinaural() * @@ -297,20 +283,20 @@ void ISAR_PRE_REND_GetMultiBinPoseData( *------------------------------------------------------------------------*/ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( - SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renerer handle */ - const IVAS_QUATERNION headPosition, /* i: head rotation QUATERNION */ - const int32_t SplitRendBitRate, /* i: Split renderer bitrate */ - ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */ - int16_t codec_frame_size_ms, /* i/o: Split renderer codec framesize */ - ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: Split renderer codec framesize */ - float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB real buffer */ - float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB imag buffer */ - const int16_t max_bands, /* i: CLDFB bands */ - float *output[], /* i/o: PCM in/out buffer */ - const int16_t low_res_pre_rend_rot, /* i: low time resolution pre-renderer flag */ - const int16_t cldfb_in_flag, /* i: Flag to indicate CLDFB or time doamin input */ - const int16_t pcm_out_flag, /* i: Flag to indicate PCM output */ - const int16_t ro_md_flag /* i: Flag to indicate real only metadata for yaw */ + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + const int32_t SplitRendBitRate, /* i : Split renderer bitrate */ + ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */ + const int16_t codec_frame_size_ms, /* i : Split renderer codec framesize */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB real buffer */ + float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB imag buffer */ + const int16_t max_bands, /* i : CLDFB bands */ + float *output[], /* i/o: PCM in/out buffer */ + const int16_t low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ + const int16_t cldfb_in_flag, /* i : Flag to indicate CLDFB or time doamin input */ + const int16_t pcm_out_flag, /* i : Flag to indicate PCM output */ + const int16_t ro_md_flag /* i : Flag to indicate real only metadata for yaw */ ) { ivas_error error; diff --git a/lib_isar/lib_isar_pre_rend.h b/lib_isar/lib_isar_pre_rend.h index 72169d6c35..ca0b579d66 100644 --- a/lib_isar/lib_isar_pre_rend.h +++ b/lib_isar/lib_isar_pre_rend.h @@ -42,43 +42,50 @@ int32_t ISAR_PRE_REND_void_func( void ); #else +/* clang-format off */ +/*----------------------------------------------------------------------------------* + * ISAR pre-renderer function prototypes + *----------------------------------------------------------------------------------*/ + ivas_error ISAR_PRE_REND_open( - SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */ - ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i/o: Split renderer pre-renerer config */ - const int32_t output_Fs, /* i: output sampling rate */ - const int16_t cldfb_in_flag, /* i: Flag to indicate CLDFB or time doamin input */ - const int16_t pcm_out_flag, /* i: Flag to indicate PCM output */ - const int16_t num_subframes, /* i: number of subframes */ - const int16_t mixed_td_cldfb_flag /* i: Flag to indicate combined TD and CLDFB input */ + SPLIT_REND_WRAPPER *hSplitBinRend, /* o : Split renderer pre-renderer handle */ + ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* o : Split renderer pre-renderer config */ + const int32_t output_Fs, /* i : output sampling rate */ + const int16_t cldfb_in_flag, /* i : Flag to indicate CLDFB or time doamin input */ + const int16_t pcm_out_flag, /* i : Flag to indicate PCM output */ + const int16_t num_subframes, /* i : number of subframes */ + const int16_t mixed_td_cldfb_flag /* i : Flag to indicate combined TD and CLDFB input */ ); void ISAR_PRE_REND_close( - SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */ - IVAS_REND_AudioBuffer *pSplitRendEncBuffer /* i/o: Split renderer data buffer */ + SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renderer handle */ + IVAS_REND_AudioBuffer *pSplitRendEncBuffer /* i/o: Split renderer data buffer */ ); void ISAR_PRE_REND_GetMultiBinPoseData( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i: Split renderer pre-renerer config */ - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ - const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i: Rotation axis */ + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renderer config */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : Rotation axis */ ); ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( - SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renerer handle */ - const IVAS_QUATERNION headPosition, /* i: head rotation QUATERNION */ - const int32_t SplitRendBitRate, /* i: Split renderer bitrate */ - ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */ - int16_t codec_frame_size_ms, /* i/o: Split renderer codec framesize */ - ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: Split renderer codec framesize */ - float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB real buffer */ - float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB imag buffer */ - const int16_t max_bands, /* i: CLDFB bands */ - float *output[], /* i/o: PCM in/out buffer */ - const int16_t low_res_pre_rend_rot, /* i: low time resolution pre-renderer flag */ - const int16_t cldfb_in_flag, /* i: Flag to indicate CLDFB or time doamin input */ - const int16_t pcm_out_flag, /* i: Flag to indicate PCM output */ - const int16_t ro_md_flag /* i: Flag to indicate real only metadata for yaw */ + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + const int32_t SplitRendBitRate, /* i : Split renderer bitrate */ + ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */ + const int16_t codec_frame_size_ms, /* i : Split renderer codec framesize */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB real buffer */ + float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB imag buffer */ + const int16_t max_bands, /* i : CLDFB bands */ + float *output[], /* i/o: PCM in/out buffer */ + const int16_t low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ + const int16_t cldfb_in_flag, /* i : Flag to indicate CLDFB or time doamin input */ + const int16_t pcm_out_flag, /* i : Flag to indicate PCM output */ + const int16_t ro_md_flag /* i : Flag to indicate real only metadata for yaw */ ); + +/* clang-format on */ #endif #endif /* LIB_ISAR_PRE_REND_H */ diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 0363ea645b..a7fcf60f7d 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1216,18 +1216,7 @@ ivas_error ivas_rend_openMultiBinCrend( const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, const int32_t output_Fs ) { - ivas_error error; - -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, NULL /* hHrtfStatistics */, output_Fs, pMultiBinPoseData->num_poses ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, output_Fs ) ) != IVAS_ERR_OK ) -#endif - { - return error; - } - - return error; + return ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, NULL /* hHrtfStatistics */, output_Fs, pMultiBinPoseData->num_poses ); } #endif @@ -1840,10 +1829,11 @@ ivas_error ivas_rend_crendProcessSubframe( float *input_f[], /* i : transport channels */ float *output[], /* i/o: input/output audio channels */ const int16_t n_samples_to_render, /* i : output frame length per channel */ - const int32_t output_Fs /* i : output sampling rate */ #ifdef SPLIT_REND_WITH_HEAD_ROT - , - const int16_t pos_idx + const int32_t output_Fs, /* i : output sampling rate */ + const int16_t pos_idx /* i : pose index */ +#else + const int32_t output_Fs /* i : output sampling rate */ #endif ) { @@ -1960,7 +1950,6 @@ ivas_error ivas_rend_crendProcessSubframe( if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, tc_local, p_pcm_tmp, output_Fs, 0, pos_idx ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, tc_local, p_pcm_tmp, output_Fs, 0 ) ) != IVAS_ERR_OK ) - #endif { return error; @@ -2025,149 +2014,6 @@ ivas_error ivas_rend_crendProcessSubframe( #ifdef SPLIT_REND_WITH_HEAD_ROT -/*-----------------------------------------------------------------------------------------* - * Function ivas_rend_crend_ProcessSplitBin() - * - * Process call for IVAS Crend renderer - *-----------------------------------------------------------------------------------------*/ - -ivas_error ivas_rend_crendProcessSplitBin( - const CREND_WRAPPER *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const DECODER_CONFIG_HANDLE hDecoderConfig, - const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, - const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, - EFAP_HANDLE hEFAPdata, - float *output[], - const int32_t output_Fs ) -{ - int16_t i, j; - int16_t sf; - int16_t pos_idx, output_frame; - ivas_error error; - float gain_lfe; - float tmpLfeBuffer[L_FRAME48k]; - float tmpInputBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - float *p_tmpInputBuffer[MAX_OUTPUT_CHANNELS]; - float tmpSplitBinBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - COMBINED_ORIENTATION_DATA combinedOrientationDataLocal; - COMBINED_ORIENTATION_HANDLE pCombinedOrientationDataLocal; - - output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); - - /* copy input */ - for ( i = 0; i < hIntSetup->nchan_out_woLFE; ++i ) - { - mvr2r( output[i], tmpInputBuffer[i], output_frame ); - } - - for ( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) - { - p_tmpInputBuffer[i] = tmpInputBuffer[i]; - } - - /* save current head positions */ - pCombinedOrientationDataLocal = hCombinedOrientationData; - combinedOrientationDataLocal = *pCombinedOrientationDataLocal; - if ( pMultiBinPoseData->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) - { - for ( sf = 1; sf < hCombinedOrientationData->num_subframes; ++sf ) - { - combinedOrientationDataLocal.Quaternions[sf] = combinedOrientationDataLocal.Quaternions[0]; - for ( i = 0; i < 3; i++ ) - { - for ( j = 0; j < 3; j++ ) - { - combinedOrientationDataLocal.Rmat[sf][i][j] = combinedOrientationDataLocal.Rmat[0][i][j]; - } - } - } - } - - /* copy LFE to tmpLfeBuffer and apply gain only once */ - if ( hIntSetup->num_lfe > 0 && hIntSetup->index_lfe[0] != -1 ) - { - mvr2r( output[hIntSetup->index_lfe[0]], tmpLfeBuffer, output_frame ); - gain_lfe = ( ( pCrend != NULL ) && ( pCrend->hHrtfCrend != NULL ) ) ? pCrend->hHrtfCrend->gain_lfe : GAIN_LFE; - v_multc( tmpLfeBuffer, gain_lfe, tmpLfeBuffer, output_frame ); - } - else - { - set_zero( tmpLfeBuffer, output_frame ); - } - - for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; ++pos_idx ) - { - /* Update head positions */ - - IVAS_QUATERNION Quaternions_orig[MAX_PARAM_SPATIAL_SUBFRAMES], Quaternions_abs; - for ( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) - { - Quaternions_orig[i] = combinedOrientationDataLocal.Quaternions[i]; - Quaternions_abs.w = -3.0f; - Quat2EulerDegree( combinedOrientationDataLocal.Quaternions[i], &Quaternions_abs.z, &Quaternions_abs.y, &Quaternions_abs.x ); /*order in Quat2Euler seems to be reversed ?*/ - - Quaternions_abs.x += pMultiBinPoseData->relative_head_poses[pos_idx][0]; - Quaternions_abs.y += pMultiBinPoseData->relative_head_poses[pos_idx][1]; - Quaternions_abs.z += pMultiBinPoseData->relative_head_poses[pos_idx][2]; - combinedOrientationDataLocal.Quaternions[i] = Quaternions_abs; - QuatToRotMat( combinedOrientationDataLocal.Quaternions[i], combinedOrientationDataLocal.Rmat[i] ); - } - - - /* render inplace to first two channels of tmpInputBuffer */ - pCombinedOrientationDataLocal = &combinedOrientationDataLocal; - - for ( i = 0; i < 3; i++ ) - { - mvr2r( hCombinedOrientationData->Rmat_prev[pos_idx][i], pCombinedOrientationDataLocal->Rmat_prev[0][i], 3 ); - } - - if ( ( error = ivas_rend_crendProcessSubframe( pCrend, inConfig, outConfig, hDecoderConfig, pCombinedOrientationDataLocal, hIntSetup, hEFAPdata, - NULL, p_tmpInputBuffer, p_tmpInputBuffer, output_frame, output_Fs, pos_idx ) ) != IVAS_ERR_OK ) - { - return error; - } - - for ( i = 0; i < 3; i++ ) - { - mvr2r( pCombinedOrientationDataLocal->Rmat_prev[0][i], hCombinedOrientationData->Rmat_prev[pos_idx][i], 3 ); - } - - for ( i = 0; i < BINAURAL_CHANNELS; ++i ) - { - /* accumulate LFE to output */ - v_add( tmpInputBuffer[i], tmpLfeBuffer, tmpInputBuffer[i], output_frame ); - - /* move to split bin output buffer */ - mvr2r( tmpInputBuffer[i], tmpSplitBinBuffer[pos_idx * BINAURAL_CHANNELS + i], output_frame ); - } - - /* overwrite rendered channels with input again for next iteration */ - for ( i = 0; i < hIntSetup->nchan_out_woLFE; ++i ) - { - mvr2r( output[i], tmpInputBuffer[i], output_frame ); - } - - /* restore original headrotation data */ - for ( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) - { - combinedOrientationDataLocal.Quaternions[i] = Quaternions_orig[i]; - } - } - - /* copy split binaural rendered signals to final output */ - for ( i = 0; i < BINAURAL_CHANNELS * pMultiBinPoseData->num_poses; ++i ) - { - mvr2r( tmpSplitBinBuffer[i], output[i], output_frame ); - } - - return IVAS_ERR_OK; -} - - /*-----------------------------------------------------------------------------------------* * Function ivas_rend_crend_ProcessSubframesSplitBin() * @@ -2175,10 +2021,10 @@ ivas_error ivas_rend_crendProcessSplitBin( *-----------------------------------------------------------------------------------------*/ ivas_error ivas_rend_crendProcessSubframesSplitBin( - const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ - const AUDIO_CONFIG inConfig, /* i : input audio configuration */ - const AUDIO_CONFIG outConfig, /* i : output audio configuration */ - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ @@ -2200,7 +2046,6 @@ ivas_error ivas_rend_crendProcessSubframesSplitBin( float tmpInputBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; float *p_tmpInputBuffer[MAX_OUTPUT_CHANNELS]; float tmpSplitBinBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - COMBINED_ORIENTATION_DATA combinedOrientationDataLocal; COMBINED_ORIENTATION_HANDLE pCombinedOrientationDataLocal; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index b1d682f344..6e2dc620bc 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -134,6 +134,7 @@ static void ivas_masa_ext_rend_parambin_internal( MASA_EXT_REND_HANDLE hMasaExtR static void ivas_masa_ext_rend_parambin_internal( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, float *output_f[], const int16_t subframe ); #endif + /*------------------------------------------------------------------------- * ivas_dirac_dec_init_binaural_data() * @@ -282,6 +283,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( if ( !hDiracDecBin->useTdDecorr && !( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM ) ) { ivas_dirac_dec_get_frequency_axis( frequency_axis, output_Fs, nBins ); + if ( ( error = ivas_dirac_dec_decorr_open( &( hDiracDecBin->h_freq_domain_decorr_ap_params ), &( hDiracDecBin->h_freq_domain_decorr_ap_state ), nBins, @@ -781,8 +783,8 @@ static void ivas_dirac_dec_binaural_internal( #ifndef SPLIT_REND_WITH_HEAD_ROT ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, Rmat, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, st_ivas->hMasaIsmData ); -#endif +#endif if ( config_data.ivas_format == ISM_FORMAT ) { max_band_decorr = 0; @@ -796,7 +798,6 @@ static void ivas_dirac_dec_binaural_internal( max_band_decorr = hDiracDecBin->h_freq_domain_decorr_ap_params->max_band_decorr; } - #ifdef SPLIT_REND_WITH_HEAD_ROT ivas_dirac_dec_binaural_formulate_input_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe, subFrameTotalEne, IIReneLimiter ); @@ -1147,6 +1148,7 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices( return; } + static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, @@ -2205,9 +2207,8 @@ static void ivas_dirac_dec_binaural_process_output( const int16_t max_band_decorr, const int16_t numInChannels, const int16_t processReverb, - const int16_t subframe #ifdef SPLIT_REND_WITH_HEAD_ROT - , + const int16_t subframe, float outRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float outIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float reverbRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], @@ -2215,6 +2216,8 @@ static void ivas_dirac_dec_binaural_process_output( float decorrRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float decorrIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const uint8_t recompute +#else + const int16_t subframe #endif ) { @@ -2260,6 +2263,7 @@ static void ivas_dirac_dec_binaural_process_output( { #endif ivas_dirac_dec_decorrelate_slot( hDiracDecBin, nBins, slot, inRe, inIm, decSlotRe, decSlotIm ); + #ifdef SPLIT_REND_WITH_HEAD_ROT for ( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { @@ -3501,6 +3505,7 @@ static void ivas_masa_ext_rend_parambin_internal( #ifdef SPLIT_REND_WITH_HEAD_ROT ivas_dirac_dec_binaural_formulate_input_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe, subFrameTotalEne, IIReneLimiter ); + ivas_dirac_dec_binaural_formulate_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, subFrameTotalEne, IIReneLimiter, NULL ); @@ -3617,10 +3622,11 @@ void ivas_masa_ext_rend_parambin_render( COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const int16_t num_subframes, /* i : number of subframes to render */ - const SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i : split rendering orientation data */ - float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : rendered orientations for split rend. real part of cldfb */ - float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] ) /* o : rendered orientations for split rend. imag part of cldfb */ + const int16_t num_subframes, /* i : number of subframes to render */ + const SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i : split rendering orientation data */ + float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : rendered orientations for split rend. real part of cldfb */ + float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] /* o : rendered orientations for split rend. imag part of cldfb */ +) #else const int16_t num_subframes ) /* i : number of subframes to render */ #endif diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 0434031c81..505eec518b 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -877,7 +877,7 @@ ivas_error ivas_rend_openCrend( void ivas_rend_closeCrend( #ifdef SPLIT_REND_WITH_HEAD_ROT - CREND_WRAPPER_HANDLE *pCrend , + CREND_WRAPPER_HANDLE *pCrend, const int16_t num_poses #else CREND_WRAPPER_HANDLE *pCrend @@ -909,10 +909,11 @@ ivas_error ivas_rend_crendProcessSubframe( float *input_f[], /* i : transport channels */ float *output[], /* i/o: input/output audio channels */ const int16_t n_samples_to_render, /* i : output frame length per channel */ - const int32_t output_Fs /* i : output sampling rate */ #ifdef SPLIT_REND_WITH_HEAD_ROT - , - const int16_t pos_idx + const int32_t output_Fs, /* i : output sampling rate */ + const int16_t pos_idx /* i : pose index */ +#else + const int32_t output_Fs /* i : output sampling rate */ #endif ); @@ -1530,19 +1531,6 @@ ivas_error ivas_rend_crendProcessSubframesSplitBin( const int32_t output_Fs /* i : output sampling rate */ ); -ivas_error ivas_rend_crendProcessSplitBin( - const CREND_WRAPPER *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const DECODER_CONFIG_HANDLE hDecoderConfig, - const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, - const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, - EFAP_HANDLE hEFAPdata, - float *output[], - const int32_t output_Fs -); - ivas_error ivas_rend_openMultiBinCrend( CREND_WRAPPER_HANDLE *pCrend, const AUDIO_CONFIG inConfig, diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config.c index e9c9fa749a..e39178b56b 100644 --- a/lib_rend/ivas_render_config.c +++ b/lib_rend/ivas_render_config.c @@ -131,6 +131,7 @@ ivas_error ivas_render_config_init_from_rom( ( *hRenderConfig )->directivity[i * 3 + 1] = 360.0f; /* Back cone */ ( *hRenderConfig )->directivity[i * 3 + 2] = 1.0f; /* Back attenuation */ } + #ifdef SPLIT_REND_WITH_HEAD_ROT ( *hRenderConfig )->split_rend_config.splitRendBitRate = SPLIT_REND_768k; ( *hRenderConfig )->split_rend_config.dof = 3; diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 46814b435b..79646bec96 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -49,19 +49,14 @@ * Local funtion declarations *-----------------------------------------------------------------------*/ -static ivas_error combine_external_and_head_orientations( - IVAS_QUATERNION *headRotQuaternions, - IVAS_VECTOR3 *listenerPos, + #ifdef SPLIT_REND_WITH_HEAD_ROT - ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis, /* i : split rend pose prediction axis*/ +static ivas_error combine_external_and_head_orientations( IVAS_QUATERNION *headRotQuaternions, IVAS_VECTOR3 *listenerPos, ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis, EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData ); +#else +static ivas_error combine_external_and_head_orientations( IVAS_QUATERNION *headRotQuaternions, IVAS_VECTOR3 *listenerPos, EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData ); #endif - EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData ); -static void external_target_interpolation( - EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, - const int16_t i ); +static void external_target_interpolation( EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, const int16_t i ); static bool are_orientations_same( const IVAS_QUATERNION *orientation1, const IVAS_QUATERNION *orientation2 ); @@ -922,11 +917,11 @@ ivas_error combine_external_and_head_orientations_dec( } #endif - return combine_external_and_head_orientations( pHeadRotQuaternion, listenerPos, #ifdef SPLIT_REND_WITH_HEAD_ROT - sr_pose_pred_axis, + return combine_external_and_head_orientations( pHeadRotQuaternion, listenerPos, sr_pose_pred_axis, hExtOrientationData, hCombinedOrientationData ); +#else + return combine_external_and_head_orientations( pHeadRotQuaternion, listenerPos, hExtOrientationData, hCombinedOrientationData ); #endif - hExtOrientationData, hCombinedOrientationData ); } @@ -975,11 +970,11 @@ ivas_error combine_external_and_head_orientations_rend( } } - return combine_external_and_head_orientations( headRotQuaternions, listenerPos, #ifdef SPLIT_REND_WITH_HEAD_ROT - sr_pose_pred_axis, + return combine_external_and_head_orientations( headRotQuaternions, listenerPos, sr_pose_pred_axis, hExtOrientationData, hCombinedOrientationData ); +#else + return combine_external_and_head_orientations( headRotQuaternions, listenerPos, hExtOrientationData, hCombinedOrientationData ); #endif - hExtOrientationData, hCombinedOrientationData ); } @@ -1615,9 +1610,10 @@ void ivas_combined_orientation_update_index( { if ( hCombinedOrientationData != NULL ) { - if ( hCombinedOrientationData->num_subframes == 1 #ifdef SPLIT_REND_WITH_HEAD_ROT - || hCombinedOrientationData->sr_low_res_flag + if ( hCombinedOrientationData->num_subframes == 1 || hCombinedOrientationData->sr_low_res_flag +#else + if ( hCombinedOrientationData->num_subframes == 1 ) #endif ) { diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 9bbb047ce5..13d01d40c4 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1324,6 +1324,7 @@ typedef struct ivas_hrtfs_statistics_struct int16_t fromROM; /* Flag that indicates that the pointers point to tables in ROM (controls init/dealloc).*/ } HRTFS_STATISTICS, *HRTFS_STATISTICS_HANDLE; + #ifdef SPLIT_REND_WITH_HEAD_ROT /*----------------------------------------------------------------------------------* * Binaural split rendering structures @@ -1437,6 +1438,7 @@ typedef struct float Cldfb_Prev_BinReal[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX + CLDFB_PLC_XF][CLDFB_NO_CHANNELS_MAX]; float Cldfb_Prev_BinImag[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX + CLDFB_PLC_XF][CLDFB_NO_CHANNELS_MAX]; float xf_bet[2][CLDFB_NO_CHANNELS_MAX][CLDFB_PLC_XF]; + } CLDFB_PLC, *CLDFB_PLC_HANDLE; typedef struct @@ -1464,7 +1466,6 @@ typedef struct ivas_binaural_head_rot_split_rendering_lcld_dec_struct int16_t iNumIterations; } BIN_HR_SPLIT_LCLD_DEC, *BIN_HR_SPLIT_LCLD_DEC_HANDLE; - #endif @@ -1541,8 +1542,17 @@ typedef struct ivas_LS_setup_custom } LSSETUP_CUSTOM_STRUCT, *LSSETUP_CUSTOM_HANDLE; -#ifdef SPLIT_REND_WITH_HEAD_ROT +/* Channel types in a channel-based config */ +typedef enum +{ + CHANNEL_TYPE_UNUSED = 0, + CHANNEL_TYPE_SPEAKER, + CHANNEL_TYPE_LFE + +} ChannelType; + +#ifdef SPLIT_REND_WITH_HEAD_ROT /*----------------------------------------------------------------------------------* * CLDFB renderer wrapper *----------------------------------------------------------------------------------*/ @@ -1554,17 +1564,8 @@ typedef struct HRTFS_FASTCONV_HANDLE hHrtfFastConv; } CLDFB_REND_WRAPPER; - #endif -/* Channel types in a channel-based config */ -typedef enum -{ - CHANNEL_TYPE_UNUSED = 0, - CHANNEL_TYPE_SPEAKER, - CHANNEL_TYPE_LFE - -} ChannelType; /*----------------------------------------------------------------------------------* * MASA external renderer structure diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index a0d31fa8a6..e8096739aa 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -251,17 +251,9 @@ static ivas_error initMasaExtRenderer( input_masa *inputMasa, const AUDIO_CONFIG static void freeMasaExtRenderer( MASA_EXT_REND_HANDLE *hMasaExtRendOut ); #ifdef SPLIT_REND_WITH_HEAD_ROT -static ivas_error renderSbaToMultiBinauralCldfb( - input_sba *sbaInput, - float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - const int16_t low_res_pre_rend_rot, - const int16_t num_subframes ); +static void renderSbaToMultiBinauralCldfb( input_sba *sbaInput, float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const int16_t low_res_pre_rend_rot, const int16_t num_subframes ); -static ivas_error renderSbaToMultiBinaural( - input_sba *sbaInput, - const AUDIO_CONFIG outConfig, - float out[][L_FRAME48k] ); +static ivas_error renderSbaToMultiBinaural( input_sba *sbaInput, const AUDIO_CONFIG outConfig, float out[][L_FRAME48k] ); #endif /*-------------------------------------------------------------------* @@ -644,7 +636,6 @@ static ivas_error validateOutputSampleRate( else { #endif - /* Otherwise rendering to binaural, support the same set as IVAS decoder */ switch ( sampleRate ) { @@ -3487,6 +3478,12 @@ static ivas_error findFreeInputSlot( #ifdef SPLIT_REND_WITH_HEAD_ROT +/*------------------------------------------------------------------------- + * Function getCldfbRendFlag() + * + * + *------------------------------------------------------------------------*/ + static int16_t getCldfbRendFlag( IVAS_REND_HANDLE hIvasRend, /* i : Renderer handle */ const IVAS_REND_AudioConfigType new_configType ) @@ -3590,7 +3587,6 @@ static ivas_error ivas_pre_rend_init( #endif - /*-------------------------------------------------------------------* * IVAS_REND_AddInput() * @@ -4745,8 +4741,9 @@ ivas_error IVAS_REND_DisableHeadRotation( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_SetSplitRendBFI( - IVAS_REND_HANDLE hIvasRend, - const int16_t bfi ) + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const int16_t bfi /* i : bad frame indicator */ +) { hIvasRend->splitRendBFI = bfi; @@ -5350,6 +5347,7 @@ static ivas_error renderIsmToBinaural( } #ifdef SPLIT_REND_WITH_HEAD_ROT + static int16_t getNumSubframesInBuffer( const IVAS_REND_AudioBuffer *buffer, const int32_t sampleRate ) @@ -5364,6 +5362,7 @@ static int16_t getNumSubframesInBuffer( return (int16_t) ( buffer->config.numSamplesPerChannel / ( sampleRate / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES * cldfb2tdSampleFact ) ); } + #endif static ivas_error renderIsmToBinauralRoom( @@ -5510,7 +5509,6 @@ static ivas_error renderIsmToBinauralRoom( mvr2r( currentPanGains, ismInput->prev_pan_gains, MAX_OUTPUT_CHANNELS ); } - /* render 7_1_4 with BRIRs */ #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_rend_crendProcessSubframe( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, @@ -5518,7 +5516,6 @@ static ivas_error renderIsmToBinauralRoom( #else if ( ( error = ivas_rend_crendProcessSubframe( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, ismInput->base.inputBuffer.config.numSamplesPerChannel, *ismInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) - #endif { return error; @@ -6108,7 +6105,6 @@ static ivas_error renderMcToBinaural( #else if ( ( error = renderLfeToBinaural( mcInput, outAudio ) ) != IVAS_ERR_OK ) #endif - { return error; } @@ -6174,13 +6170,11 @@ static ivas_error renderMcToBinauralRoom( tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); set_zero( tmpRotBuffer.data, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); - if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, #ifdef SPLIT_REND_WITH_HEAD_ROT - mcInput->rot_gains_prev[0], + if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev[0], mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) #else - mcInput->rot_gains_prev, + if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev, mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) #endif - mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -6268,13 +6262,11 @@ static ivas_error renderMcCustomLsToBinauralRoom( tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); set_zero( tmpRotBuffer.data, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); - if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, #ifdef SPLIT_REND_WITH_HEAD_ROT - mcInput->rot_gains_prev[0], + if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev[0], mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) #else - mcInput->rot_gains_prev, + if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev, mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) #endif - mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -6500,7 +6492,6 @@ static ivas_error renderMcToSplitBinaural( * 4. LFE mixing * 5. tmpSplitBinBuffer accumulated to outBuffer */ - /* copy input for in-place rotation */ set_zero( tmpRotBuffer.data, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); @@ -6788,7 +6779,8 @@ static ivas_error renderSbaToMultiBinaural( return IVAS_ERR_OK; } -static ivas_error renderSbaToMultiBinauralCldfb( + +static void renderSbaToMultiBinauralCldfb( input_sba *sbaInput, float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], @@ -6803,7 +6795,7 @@ static ivas_error renderSbaToMultiBinauralCldfb( ivas_rend_CldfbMultiBinRendProcess( sbaInput->cldfbRendWrapper.hCldfbRend, sbaInput->base.ctx.pCombinedOrientationData, &sbaInput->base.ctx.pSplitRendWrapper->multiBinPoseData, Cldfb_RealBuffer, Cldfb_ImagBuffer, Cldfb_Out_Real, Cldfb_Out_Imag, low_res_pre_rend_rot, num_subframes ); - return IVAS_ERR_OK; + return; } @@ -6816,26 +6808,19 @@ static ivas_error renderSbaToSplitBinaural( ivas_error error; float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - int16_t low_res_pre_rend_rot; - - low_res_pre_rend_rot = 1; push_wmops( "renderSbaToSplitBinaural" ); - error = IVAS_ERR_OK; if ( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) { - if ( ( renderSbaToMultiBinauralCldfb( sbaInput, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, low_res_pre_rend_rot, - getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) - { - return error; - } + renderSbaToMultiBinauralCldfb( sbaInput, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, 1, + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ); accumulateCLDFBArrayToBuffer( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); } else { - if ( ( renderSbaToMultiBinaural( sbaInput, outConfig, tmpCrendBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = renderSbaToMultiBinaural( sbaInput, outConfig, tmpCrendBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -6844,7 +6829,7 @@ static ivas_error renderSbaToSplitBinaural( } pop_wmops(); - return error; + return IVAS_ERR_OK; } #endif @@ -6870,11 +6855,8 @@ static ivas_error renderSbaToBinaural( float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - if ( ( error = renderSbaToMultiBinauralCldfb( sbaInput, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, 0, - getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) - { - return error; - } + renderSbaToMultiBinauralCldfb( sbaInput, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, 0, + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ); accumulateCLDFBArrayToBuffer( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); } @@ -6997,13 +6979,11 @@ static ivas_error renderSbaToBinauralRoom( mvr2r( sbaInput->base.inputBuffer.data, tmpRotBuffer.data, tmpRotBuffer.config.numChannels * tmpRotBuffer.config.numSamplesPerChannel ); if ( ( error = rotateFrameSba( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, - sbaInput->base.ctx.pCombinedOrientationData, #ifdef SPLIT_REND_WITH_HEAD_ROT - sbaInput->rot_gains_prev[0], + sbaInput->base.ctx.pCombinedOrientationData, sbaInput->rot_gains_prev[0], tmpRotBuffer ) ) != IVAS_ERR_OK ) #else - sbaInput->rot_gains_prev, + sbaInput->base.ctx.pCombinedOrientationData, sbaInput->rot_gains_prev, tmpRotBuffer ) ) != IVAS_ERR_OK ) #endif - tmpRotBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -7848,7 +7828,7 @@ static ivas_error getSamplesInternal( } if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag ) ) != IVAS_ERR_OK ) { return error; } @@ -7936,20 +7916,29 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( return getSamplesInternal( hIvasRend, outAudio, hBits ); } + +/*-------------------------------------------------------------------* + * IVAS_REND_GetSplitRendBitstreamHeader() + * + * + *-------------------------------------------------------------------*/ + 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 */ - int16_t *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ + 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 */ + int16_t *pCodec_frame_size_ms /* o : pointer to codec frame size setting */ ) { if ( hIvasRend == NULL || hIvasRend->hRendererConfig == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + *pCodec = hIvasRend->hRendererConfig->split_rend_config.codec; *pCodec_frame_size_ms = hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms; *poseCorrection = hIvasRend->hRendererConfig->split_rend_config.poseCorrectionMode; + return IVAS_ERR_OK; } @@ -8782,6 +8771,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init( #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif + /* External renderer uses constant regularization factor */ hDiracDecBin->reqularizationFactor = 0.4f; diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index e3a1bd6147..9648dda2ab 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -252,7 +252,7 @@ int16_t IVAS_REND_FeedRenderConfig( ivas_error IVAS_REND_FeedSplitBinauralBitstream( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_REND_InputId inputId, /* i : ID of the input */ - IVAS_REND_BitstreamBuffer *hBits /* i : buffer for input bitstream */ + IVAS_REND_BitstreamBuffer *hBits /* i : buffer for input bitstream */ ); ivas_error IVAS_REND_GetSplitBinauralSamples( @@ -268,10 +268,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 */ - int16_t *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ + 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 */ + int16_t *pCodec_frame_size_ms /* o : pointer to codec frame size setting */ ); #endif @@ -318,8 +318,9 @@ ivas_error IVAS_REND_SetReferenceVector( #ifdef SPLIT_REND_WITH_HEAD_ROT ivas_error IVAS_REND_SetSplitRendBFI( - IVAS_REND_HANDLE hIvasRend, - const int16_t bfi); + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const int16_t bfi /* i : bad frame indicator */ +); #endif ivas_error IVAS_REND_SetExternalOrientation( diff --git a/lib_util/split_rend_bfi_file_reader.c b/lib_util/split_rend_bfi_file_reader.c index 9ca1000770..9122201f09 100644 --- a/lib_util/split_rend_bfi_file_reader.c +++ b/lib_util/split_rend_bfi_file_reader.c @@ -98,8 +98,9 @@ ivas_error SplitRendBFIFileReader_open( *-----------------------------------------------------------------------*/ ivas_error SplitRendBFIFileReading( - SplitRendBFIFileReader *SplitRendBFIReader, /* i/o: SplitRendBFIFileReader handle */ - int16_t *bfi ) + SplitRendBFIFileReader *SplitRendBFIReader, /* i/o: SplitRendBFIFileReader handle */ + int16_t *bfi /* o : bad frame indicator */ +) { if ( SplitRendBFIReader->txtfile ? 1 != fscanf( SplitRendBFIReader->bfiFile, "%hd", bfi ) : 1 != fread( bfi, sizeof( *bfi ), 1, SplitRendBFIReader->bfiFile ) ) { diff --git a/lib_util/split_rend_bfi_file_reader.h b/lib_util/split_rend_bfi_file_reader.h index f0af652544..f993cbdfd6 100644 --- a/lib_util/split_rend_bfi_file_reader.h +++ b/lib_util/split_rend_bfi_file_reader.h @@ -45,7 +45,8 @@ ivas_error SplitRendBFIFileReader_open( ivas_error SplitRendBFIFileReading( SplitRendBFIFileReader *SplitRendBFIReader, /* i/o: SplitRendBFIFileReader handle */ - int16_t *bfi ); + int16_t *bfi /* o : bad frame indicator */ +); void SplitRendBFIFileReader_close( SplitRendBFIFileReader **SplitRendBFIReader /* i/o: SplitRendBFIFileReader handle */ diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c index 714467b118..9be3aff812 100644 --- a/lib_util/split_render_file_read_write.c +++ b/lib_util/split_render_file_read_write.c @@ -138,7 +138,7 @@ ivas_error split_rend_writer_open( const int32_t delayTimeScale, ISAR_SPLIT_REND_CODEC codec, ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, - int16_t codec_frame_size_ms ) + const int16_t codec_frame_size_ms ) { SplitFileReadWrite *hSplitRendFileReadWrite; size_t header_len, h; diff --git a/lib_util/split_render_file_read_write.h b/lib_util/split_render_file_read_write.h index 69d50c4951..0b6629c202 100644 --- a/lib_util/split_render_file_read_write.h +++ b/lib_util/split_render_file_read_write.h @@ -38,7 +38,7 @@ typedef struct SplitFileReadWrite SplitFileReadWrite; -/* Allocates and initializes a a split renderer reader instance */ +/* Allocates and initializes a a split renderer reader instance */ ivas_error split_rend_reader_open( SplitFileReadWrite **hhSplitRendFileReadWrite, char *filename, @@ -46,8 +46,7 @@ ivas_error split_rend_reader_open( ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, int16_t *codec_frame_size_ms ); - -/* Allocates and initializes a a split renderer writer instance */ +/* Allocates and initializes a a split renderer writer instance */ ivas_error split_rend_writer_open( SplitFileReadWrite **hhSplitRendFileReadWrite, char *filename, @@ -55,10 +54,9 @@ ivas_error split_rend_writer_open( const int32_t delayTimeScale, ISAR_SPLIT_REND_CODEC codec, ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, - int16_t codec_frame_size_ms ); - + const int16_t codec_frame_size_ms ); -/* Closes the split renderer reader/writer and deallocates memory */ +/* Closes the split renderer reader/writer and deallocates memory */ void split_rend_reader_writer_close( SplitFileReadWrite **hhSplitRendFileReadWrite ); -- GitLab From bbc73b1792da9cfa4462cab6bea999391e07c2ae Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 29 Apr 2024 14:47:57 +0200 Subject: [PATCH 03/26] clang-format --- apps/renderer.c | 2 +- lib_rend/lib_rend.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index ae32ad47b7..2b59efbbac 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1789,7 +1789,7 @@ int main( if ( ( error = IVAS_REND_GetSamples( hIvasRend, outBuffer ) ) != IVAS_ERR_OK ) { #ifdef SPLIT_REND_WITH_HEAD_ROT - fprintf( stderr, "Error inIVAS_REND_GetSamples()%s\n", ivas_error_to_string( error ) ); + fprintf( stderr, "Error in IVAS_REND_GetSamples()%s\n", ivas_error_to_string( error ) ); #else fprintf( stderr, "Error in getting samples\n" ); #endif diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index e8096739aa..656a0f462d 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -7828,7 +7828,7 @@ static ivas_error getSamplesInternal( } if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From b3c0971b1d0ad1b2dd59a36ffe5ac45316306158 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 29 Apr 2024 15:39:27 +0200 Subject: [PATCH 04/26] fix build + errors --- lib_dec/ivas_jbm_dec.c | 4 ++-- lib_isar/lib_isar_post_rend.c | 13 ++++++++++--- lib_isar/lib_isar_post_rend.h | 4 ++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index e3255df3d0..0d7fa6ebe5 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1501,7 +1501,7 @@ ivas_error ivas_jbm_dec_render( nchan_out_syn_output = nchan_out; } - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + if ( !( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) #endif { if ( st_ivas->ivas_format != MONO_FORMAT ) @@ -1781,7 +1781,7 @@ ivas_error ivas_jbm_dec_flush_renderer( /* Only write out the valid data*/ #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + if ( !( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) #endif { if ( st_ivas->ivas_format != MONO_FORMAT ) diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 9899b66952..1281b36fe8 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -1169,7 +1169,7 @@ int16_t ISAR_POST_REND_GetRenderConfig( } hRCin = hIvasRend->splitRenderConfig; -#ifdef DEBUGGING +#ifdef DEBUGGINGaa switch ( hRCin->renderer_type_override ) { case IVAS_RENDER_TYPE_OVERRIDE_CREND: @@ -1820,13 +1820,20 @@ ivas_error ISAR_REND_SetSplitRendBitstreamHeader( *-------------------------------------------------------------------*/ int32_t ISAR_POST_REND_GetNoCLipping( - IVAS_REND_CONST_HANDLE hIvasRend ) + ISAR_POST_REND_HANDLE hIvasRend ) { return hIvasRend->numClipping; } + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_GetCntFramesLimited() + * + * + *-------------------------------------------------------------------*/ + int32_t ISAR_POST_REND_GetCntFramesLimited( - ISAR_POST_REND_CONST_HANDLE hIvasRend ) + ISAR_POST_REND_HANDLE hIvasRend ) { if ( hIvasRend->hLimiter == NULL ) { diff --git a/lib_isar/lib_isar_post_rend.h b/lib_isar/lib_isar_post_rend.h index 85a0488474..6470cdd3db 100644 --- a/lib_isar/lib_isar_post_rend.h +++ b/lib_isar/lib_isar_post_rend.h @@ -207,11 +207,11 @@ ivas_error ISAR_REND_SetSplitRendBitstreamHeader( #ifdef DEBUGGING int32_t ISAR_POST_REND_GetNoCLipping( - IVAS_REND_CONST_HANDLE hIvasRend /* i : Renderer handle */ + ISAR_POST_REND_HANDLE hIvasRend /* i : Renderer handle */ ); int32_t ISAR_POST_REND_GetCntFramesLimited( - IVAS_REND_CONST_HANDLE hIvasRend /* i : Renderer handle */ + ISAR_POST_REND_HANDLE hIvasRend /* i : Renderer handle */ ); #endif -- GitLab From dfd6da7ad1fb5a9ae3ee817de587a676d2457063 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 2 May 2024 08:32:19 +0200 Subject: [PATCH 05/26] move ISAR handles from ivas_stat_rend.h to isar_stat.h + fix compilation when SPLIT_REND_WITH_HEAD_ROT is deactivated --- lib_isar/isar_stat.h | 97 +++++++++++++++++++++++++ lib_rend/ivas_rotation.c | 3 +- lib_rend/ivas_stat_rend.h | 144 -------------------------------------- lib_rend/lib_rend.c | 6 +- 4 files changed, 103 insertions(+), 147 deletions(-) diff --git a/lib_isar/isar_stat.h b/lib_isar/isar_stat.h index 3182dbf0f9..ec8da5e0ad 100644 --- a/lib_isar/isar_stat.h +++ b/lib_isar/isar_stat.h @@ -58,6 +58,103 @@ * ISAR post rend structs *-------------------------------------------------------------------*/ +/* binaural split rendering head rotation data structure */ +typedef struct ivas_binaural_head_rot_split_rendering_md_struct +{ + float pred_mat_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float pred_mat_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float gd; + float gd2; + int16_t pred_mat_re_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + int16_t pred_mat_im_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + int16_t gd_idx; + int16_t gd2_idx; + +} BIN_HR_SPLIT_REND_MD, *BIN_HR_SPLIT_REND_MD_HANDLE; + +typedef struct ivas_split_rend_huffman_cfg_t +{ + const int32_t *codebook; + int16_t min_len; + int16_t max_len; + int16_t sym_len; + +} ivas_split_rend_huffman_cfg_t; + +typedef struct ivas_binaural_head_rot_split_rendering_huff_struct +{ + ivas_split_rend_huffman_cfg_t pred[2]; + int16_t pred_idx_trav[2][ISAR_SPLIT_REND_PRED_63QUANT_PNTS]; + int16_t pred_base2_code_len[2]; + ivas_split_rend_huffman_cfg_t pred_roll; + int16_t pred_roll_idx_trav[ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS]; + int16_t pred_roll_base2_code_len; + ivas_split_rend_huffman_cfg_t gd; + int16_t gd_base2_code_len; + int16_t gd_idx_trav[ISAR_SPLIT_REND_D_QUANT_PNTS]; + ivas_split_rend_huffman_cfg_t p_gd; + int16_t p_gd_base2_code_len; + int16_t p_gd_idx_trav[ISAR_SPLIT_REND_D_QUANT_PNTS]; + ivas_split_rend_huffman_cfg_t p_gd_diff; + int16_t p_gd_diff_base2_code_len; + int16_t p_gd_diff_idx_trav[ISAR_SPLIT_REND_D_QUANT_PNTS]; + +} BIN_HR_SPLIT_REND_HUFF, *BIN_HR_SPLIT_REND_HUFF_HANDLE; + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG +typedef struct ivas_binaural_head_rot_split_post_rendering_struct +{ + BIN_HR_SPLIT_REND_MD rot_md[MAX_HEAD_ROT_POSES][MAX_SPLIT_MD_SUBFRAMES][MAX_SPLIT_REND_MD_BANDS]; + IVAS_QUATERNION QuaternionsPre[MAX_PARAM_SPATIAL_SUBFRAMES]; + int16_t low_Res; + + float fix_pos_rot_mat[MAX_HEAD_ROT_POSES - 1][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1]; + BIN_HR_SPLIT_REND_HUFF huff_cfg; + float mixer_mat_re[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float mixer_mat_im[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float gd_mem[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS]; + int16_t cf_flag; + HANDLE_CLDFB_FILTER_BANK cldfbAna[BINAURAL_CHANNELS]; + HANDLE_CLDFB_FILTER_BANK cldfbSyn[BINAURAL_CHANNELS]; + HANDLE_CLDFB_FILTER_BANK cldfbSynReconsBinDec[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS]; + +} BIN_HR_SPLIT_POST_REND, *BIN_HR_SPLIT_POST_REND_HANDLE; +#endif + +typedef struct ivas_binaural_head_rot_split_pre_rendering_struct +{ + BIN_HR_SPLIT_REND_MD rot_md[MAX_HEAD_ROT_POSES - 1][MAX_SPLIT_MD_SUBFRAMES][MAX_SPLIT_REND_MD_BANDS]; + float fix_pos_rot_mat[MAX_HEAD_ROT_POSES - 1][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1]; + BIN_HR_SPLIT_REND_HUFF huff_cfg; +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + HANDLE_CLDFB_FILTER_BANK cldfbSynRotBinDec[MAX_HEAD_ROT_POSES + 1][BINAURAL_CHANNELS]; +#endif + +#ifdef SPLIT_POSE_CORRECTION_DEBUG + BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend; +#endif + +} BIN_HR_SPLIT_PRE_REND, *BIN_HR_SPLIT_PRE_REND_HANDLE; + +typedef struct +{ + float Cldfb_Prev_BinReal[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX + CLDFB_PLC_XF][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_Prev_BinImag[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX + CLDFB_PLC_XF][CLDFB_NO_CHANNELS_MAX]; + float xf_bet[2][CLDFB_NO_CHANNELS_MAX][CLDFB_PLC_XF]; + +} CLDFB_PLC, *CLDFB_PLC_HANDLE; + +typedef struct +{ + CLDFB_PLC CldfbPLC_state; + int16_t prev_bfi; + int16_t bf_count; + int16_t iNumSubSets; + +} SPLIT_REND_PLC_STRUCT, *SPLIT_REND_PLC_HANDLE; + typedef struct { int8_t headRotEnabled; diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 79646bec96..487ed7ff17 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -1611,11 +1611,10 @@ void ivas_combined_orientation_update_index( if ( hCombinedOrientationData != NULL ) { #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( hCombinedOrientationData->num_subframes == 1 || hCombinedOrientationData->sr_low_res_flag + if ( hCombinedOrientationData->num_subframes == 1 || hCombinedOrientationData->sr_low_res_flag ) #else if ( hCombinedOrientationData->num_subframes == 1 ) #endif - ) { /* only one orientation available anyway or split rendering with low resolution*/ hCombinedOrientationData->subframe_idx = 0; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 13d01d40c4..d9ec4c7df7 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1325,150 +1325,6 @@ typedef struct ivas_hrtfs_statistics_struct } HRTFS_STATISTICS, *HRTFS_STATISTICS_HANDLE; -#ifdef SPLIT_REND_WITH_HEAD_ROT -/*----------------------------------------------------------------------------------* - * Binaural split rendering structures - *----------------------------------------------------------------------------------*/ - -/* binaural split rendering head rotation data structure */ -typedef struct ivas_binaural_head_rot_split_rendering_md_struct -{ - float pred_mat_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - float pred_mat_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - float gd; - float gd2; - int16_t pred_mat_re_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - int16_t pred_mat_im_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - int16_t gd_idx; - int16_t gd2_idx; - -} BIN_HR_SPLIT_REND_MD, *BIN_HR_SPLIT_REND_MD_HANDLE; - -typedef struct ivas_split_rend_huffman_cfg_t -{ - const int32_t *codebook; - int16_t min_len; - int16_t max_len; - int16_t sym_len; - -} ivas_split_rend_huffman_cfg_t; - -typedef struct ivas_binaural_head_rot_split_rendering_huff_struct -{ - ivas_split_rend_huffman_cfg_t pred[2]; - int16_t pred_idx_trav[2][ISAR_SPLIT_REND_PRED_63QUANT_PNTS]; - int16_t pred_base2_code_len[2]; - ivas_split_rend_huffman_cfg_t pred_roll; - int16_t pred_roll_idx_trav[ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS]; - int16_t pred_roll_base2_code_len; - ivas_split_rend_huffman_cfg_t gd; - int16_t gd_base2_code_len; - int16_t gd_idx_trav[ISAR_SPLIT_REND_D_QUANT_PNTS]; - ivas_split_rend_huffman_cfg_t p_gd; - int16_t p_gd_base2_code_len; - int16_t p_gd_idx_trav[ISAR_SPLIT_REND_D_QUANT_PNTS]; - ivas_split_rend_huffman_cfg_t p_gd_diff; - int16_t p_gd_diff_base2_code_len; - int16_t p_gd_diff_idx_trav[ISAR_SPLIT_REND_D_QUANT_PNTS]; - -} BIN_HR_SPLIT_REND_HUFF, *BIN_HR_SPLIT_REND_HUFF_HANDLE; - - -typedef struct ivas_binaural_head_rot_split_post_rendering_struct -{ - BIN_HR_SPLIT_REND_MD rot_md[MAX_HEAD_ROT_POSES][MAX_SPLIT_MD_SUBFRAMES][MAX_SPLIT_REND_MD_BANDS]; - IVAS_QUATERNION QuaternionsPre[MAX_PARAM_SPATIAL_SUBFRAMES]; - int16_t low_Res; - - float fix_pos_rot_mat[MAX_HEAD_ROT_POSES - 1][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1]; - BIN_HR_SPLIT_REND_HUFF huff_cfg; -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - float mixer_mat_re[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - float mixer_mat_im[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - float gd_mem[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS]; -#else - float mixer_mat_re[1][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - float mixer_mat_im[1][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - float gd_mem[1][MAX_SPLIT_REND_MD_BANDS]; -#endif - int16_t cf_flag; - HANDLE_CLDFB_FILTER_BANK cldfbAna[BINAURAL_CHANNELS]; - HANDLE_CLDFB_FILTER_BANK cldfbSyn[BINAURAL_CHANNELS]; -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - HANDLE_CLDFB_FILTER_BANK cldfbSynReconsBinDec[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS]; -#endif - -} BIN_HR_SPLIT_POST_REND, *BIN_HR_SPLIT_POST_REND_HANDLE; - -typedef struct ivas_binaural_head_rot_split_pre_rendering_struct -{ - BIN_HR_SPLIT_REND_MD rot_md[MAX_HEAD_ROT_POSES - 1][MAX_SPLIT_MD_SUBFRAMES][MAX_SPLIT_REND_MD_BANDS]; - float fix_pos_rot_mat[MAX_HEAD_ROT_POSES - 1][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1]; - BIN_HR_SPLIT_REND_HUFF huff_cfg; -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - HANDLE_CLDFB_FILTER_BANK cldfbSynRotBinDec[MAX_HEAD_ROT_POSES + 1][BINAURAL_CHANNELS]; -#endif - -#ifdef SPLIT_POSE_CORRECTION_DEBUG - BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend; -#endif - -} BIN_HR_SPLIT_PRE_REND, *BIN_HR_SPLIT_PRE_REND_HANDLE; - -typedef struct ivas_binaural_head_rot_split_rendering_lcld_enc_struct -{ - void *pLcld_enc; - int16_t iChannels; - LCLDEncoder *psLCLDEncoder; - float ***pppfLCLDReal; - float ***pppfLCLDImag; -#ifdef CLDFB_DEBUG - FILE *cldfbIn; - int16_t numFrame; -#endif - int16_t iNumIterations; - int16_t iNumBlocks; - -} BIN_HR_SPLIT_LCLD_ENC, *BIN_HR_SPLIT_LCLD_ENC_HANDLE; - -typedef struct -{ - float Cldfb_Prev_BinReal[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX + CLDFB_PLC_XF][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_Prev_BinImag[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX + CLDFB_PLC_XF][CLDFB_NO_CHANNELS_MAX]; - float xf_bet[2][CLDFB_NO_CHANNELS_MAX][CLDFB_PLC_XF]; - -} CLDFB_PLC, *CLDFB_PLC_HANDLE; - -typedef struct -{ - CLDFB_PLC CldfbPLC_state; - int16_t prev_bfi; - int16_t bf_count; - int16_t iNumSubSets; - -} SPLIT_REND_PLC_STRUCT, *SPLIT_REND_PLC_HANDLE; - -typedef struct ivas_binaural_head_rot_split_rendering_lcld_dec_struct -{ - void *pLcld_dec; - int32_t iChannels; - LCLDDecoder *psLCLDDecoder; - float ***pppfDecLCLDReal; - float ***pppfDecLCLDImag; -#ifdef CLDFB_DEBUG - FILE *cldfbOut; - int16_t numFrame; -#endif - SPLIT_REND_PLC_HANDLE hSplitRendPLC; - int16_t iNumBlocks; - int16_t iNumIterations; - -} BIN_HR_SPLIT_LCLD_DEC, *BIN_HR_SPLIT_LCLD_DEC_HANDLE; -#endif - - /*----------------------------------------------------------------------------------* * Limiter structure *----------------------------------------------------------------------------------*/ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 656a0f462d..b2d9916d78 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4458,7 +4458,11 @@ int16_t IVAS_REND_FeedRenderConfig( return error; } } +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( pIsmInput->crendWrapper != NULL && pIsmInput->crendWrapper->hCrend[0] != NULL ) +#else + if ( pIsmInput->crendWrapper != NULL && pIsmInput->crendWrapper->hCrend != NULL ) +#endif { #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_reverb_open( &pIsmInput->crendWrapper->hCrend[0]->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, hRenderConfig, *pIsmInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) @@ -7828,7 +7832,7 @@ static ivas_error getSamplesInternal( } if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From b14af3d5c679962d02348772fc54106f5387ba9b Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 2 May 2024 08:41:47 +0200 Subject: [PATCH 06/26] clang-format --- lib_rend/lib_rend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index b2d9916d78..d798a51160 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -7832,7 +7832,7 @@ static ivas_error getSamplesInternal( } if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From 996c4c0926a78b72d5e9898770efbe712c7f50db Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 May 2024 10:05:30 +0200 Subject: [PATCH 07/26] improvements around ISAR_BITSTREAM_UPDATE_LC3PLUS --- apps/decoder.c | 44 +++------ apps/renderer.c | 61 +++++-------- lib_dec/lib_dec.c | 16 ++-- lib_dec/lib_dec.h | 2 + lib_isar/isar_lc3plus_common.c | 11 ++- lib_isar/isar_lc3plus_common.h | 2 +- lib_isar/isar_lc3plus_dec.c | 9 +- lib_isar/isar_lc3plus_dec.h | 3 +- lib_isar/isar_lc3plus_enc.c | 35 ++++++-- lib_isar/isar_lc3plus_payload.c | 114 +++++++++++++++++++++--- lib_isar/isar_prot.h | 1 - lib_isar/isar_splitRendererPre.c | 15 +--- lib_isar/isar_splitRenderer_utils.c | 11 ++- lib_isar/lib_isar_post_rend.c | 41 ++++----- lib_isar/lib_isar_pre_rend.c | 64 +++++-------- lib_rend/lib_rend.c | 9 +- lib_util/split_render_file_read_write.c | 13 ++- lib_util/split_render_file_read_write.h | 5 +- 18 files changed, 265 insertions(+), 191 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index abfbaba954..33b3f913e1 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -712,6 +712,7 @@ int main( } renderConfig.roomAcoustics.override = true; } + #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /* ISAR frame size is set from command line, not renderer config file. @@ -1993,18 +1994,11 @@ static ivas_error initOnFirstGoodFrame( return error; } - if ( ( error = IVAS_DEC_GetSplitRendBitstreamHeader( hIvasDec, - &splitRendCodec, - &poseCorrection, -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - &splitRendIsarFrameSizeMs, -#endif - &splitRendCodecFrameSizeMs #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - &lc3plusHighRes + if ( ( error = IVAS_DEC_GetSplitRendBitstreamHeader( hIvasDec, &splitRendCodec, &poseCorrection, &splitRendIsarFrameSizeMs, &splitRendCodecFrameSizeMs, &lc3plusHighRes ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_GetSplitRendBitstreamHeader( hIvasDec, &splitRendCodec, &poseCorrection, &splitRendCodecFrameSizeMs ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to get split renderer bitstream header: %s\n", ivas_error_to_string( error ) ); return error; @@ -2012,20 +2006,11 @@ static ivas_error initOnFirstGoodFrame( if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) ) { - if ( ( error = split_rend_writer_open( splitRendWriter, - arg.outputWavFilename, - delayNumSamples_temp[0], - delayTimeScale_temp, - splitRendCodec, - poseCorrection, - splitRendCodecFrameSizeMs #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - splitRendIsarFrameSizeMs, - arg.output_Fs, - lc3plusHighRes + if ( ( error = split_rend_writer_open( splitRendWriter, arg.outputWavFilename, delayNumSamples_temp[0], delayTimeScale_temp, splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs, splitRendIsarFrameSizeMs, arg.output_Fs, lc3plusHighRes ) ) != IVAS_ERR_OK ) +#else + if ( ( error = split_rend_writer_open( splitRendWriter, arg.outputWavFilename, delayNumSamples_temp[0], delayTimeScale_temp, splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to open output split rendering metadata file %s\n", arg.outputWavFilename ); return error; @@ -2041,20 +2026,11 @@ static ivas_error initOnFirstGoodFrame( } #endif - if ( ( error = split_rend_writer_open( splitRendWriter, - arg.outputMdFilename, - delayNumSamples_temp[0], - delayTimeScale_temp, - splitRendCodec, - poseCorrection, - splitRendCodecFrameSizeMs #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - splitRendIsarFrameSizeMs, - arg.output_Fs, - lc3plusHighRes + if ( ( error = split_rend_writer_open( splitRendWriter, arg.outputMdFilename, delayNumSamples_temp[0], delayTimeScale_temp, splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs, splitRendIsarFrameSizeMs, arg.output_Fs, lc3plusHighRes ) ) != IVAS_ERR_OK ) +#else + if ( ( error = split_rend_writer_open( splitRendWriter, arg.outputMdFilename, delayNumSamples_temp[0], delayTimeScale_temp, splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to open output split rendering metadata file %s\n", arg.outputWavFilename ); return error; diff --git a/apps/renderer.c b/apps/renderer.c index 775b77fc74..32402c8836 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -771,6 +771,7 @@ int main( bitsBuffer.config.codec_frame_size_ms = 20; #endif #endif + for ( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i ) { lfeRoutingConfigs[i] = NULL; @@ -1380,16 +1381,15 @@ int main( if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { - - IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, - &bitsBuffer.config.codec, - &bitsBuffer.config.poseCorrection, - &bitsBuffer.config.codec_frame_size_ms #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - &bitsBuffer.config.isar_frame_size_ms + 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 ) +#else + if ( ( error = IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms ) ) != IVAS_ERR_OK ) #endif - ); + { + fprintf( stderr, "\nError in IVAS_REND_GetSplitRendBitstreamHeader()!\n" ); + exit( -1 ); + } if ( IVAS_REND_GetDelay( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) { @@ -1397,20 +1397,11 @@ int main( exit( -1 ); } - 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 #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - bitsBuffer.config.isar_frame_size_ms, - args.sampleRate, - bitsBuffer.config.lc3plus_highres + 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 ) +#else + 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 ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Could not open split rend metadata file %s\n", args.outputFilePath ); exit( -1 ); @@ -1421,16 +1412,15 @@ int main( { if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - - IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, - &bitsBuffer.config.codec, - &bitsBuffer.config.poseCorrection, - &bitsBuffer.config.codec_frame_size_ms #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - &bitsBuffer.config.isar_frame_size_ms + 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 ) +#else + if ( ( error = IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms ) ) != IVAS_ERR_OK ) #endif - ); + { + fprintf( stderr, "\nError in IVAS_REND_GetSplitRendBitstreamHeader()!\n" ); + exit( -1 ); + } if ( IVAS_REND_GetDelay( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) { @@ -1438,20 +1428,11 @@ int main( exit( -1 ); } - 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 #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - bitsBuffer.config.isar_frame_size_ms, - args.sampleRate, - bitsBuffer.config.lc3plus_highres + 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 ) +#else + 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 ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Could not open split rend metadata file %s\n", args.outMetadataFilePath ); exit( -1 ); diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index be98851d4f..b07ea90c90 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -3813,16 +3813,15 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetSplitRendBitstreamHeader( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */ - ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + ISAR_SPLIT_REND_CODEC *pCodec, /* o : pointer to codec setting */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o : pointer to pose correction mode */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - int16_t *pIsar_frame_size_ms, /* o: pointer to isar frame size setting */ -#endif + int16_t *pIsar_frame_size_ms, /* o : pointer to isar frame size setting */ + int16_t *pCodec_frame_size_ms, /* o : pointer to codec frame size setting */ + int16_t *pLc3plusHighRes /* o : pointer to LC3plus High-Res setting */ +#else int16_t *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - int16_t *pLc3plusHighRes #endif ) { @@ -3838,6 +3837,7 @@ ivas_error IVAS_DEC_GetSplitRendBitstreamHeader( *pIsar_frame_size_ms = hIvasDec->st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms; *pLc3plusHighRes = hIvasDec->st_ivas->hRenderConfig->split_rend_config.lc3plus_highres; #endif + return IVAS_ERR_OK; } diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 6095bbf213..e79ec68f06 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -186,6 +186,8 @@ ivas_error IVAS_DEC_GetSplitRendBitstreamHeader( int16_t *pIsar_frame_size_ms, /* o : pointer to isar frame size setting */ int16_t *pCodec_frame_size_ms, /* o : pointer to codec frame size setting */ int16_t *pLc3plusHighRes /* o : pointer to LC3plus High-Res setting */ +#else + int16_t *pCodec_frame_size_ms /* o : pointer to codec frame size setting */ #endif ); diff --git a/lib_isar/isar_lc3plus_common.c b/lib_isar/isar_lc3plus_common.c index 7a9010335f..d7a992274f 100644 --- a/lib_isar/isar_lc3plus_common.c +++ b/lib_isar/isar_lc3plus_common.c @@ -57,8 +57,17 @@ ivas_error ISAR_LC3PLUS_LC3plusErrToIvasErr( return IVAS_ERR_INTERNAL; } + + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS -ivas_error IVAS_LC3PLUS_LC3plusRtpErrToIvasErr( const LC3PLUS_RTP_ERR lc3PlusRtpError ) +/*-----------------------------------------------------------------------------------------* + * Function IVAS_LC3PLUS_LC3plusRtpErrToIvasErr() + * + * + *-----------------------------------------------------------------------------------------*/ + +ivas_error IVAS_LC3PLUS_LC3plusRtpErrToIvasErr( + const LC3PLUS_RTP_ERR lc3PlusRtpError ) { switch ( lc3PlusRtpError ) { diff --git a/lib_isar/isar_lc3plus_common.h b/lib_isar/isar_lc3plus_common.h index 13decaf944..6dedc8ce3c 100644 --- a/lib_isar/isar_lc3plus_common.h +++ b/lib_isar/isar_lc3plus_common.h @@ -54,7 +54,7 @@ typedef struct LC3PLUS_CONFIG int32_t samplerate; /*! number of channels */ int16_t channels; -#if defined ISAR_BITSTREAM_UPDATE_LC3PLUS || defined ISAR_BITSTREAM_UPDATE_LC3PLUS +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /*! high resolution mode enabled (1) or disabled (0)*/ int16_t high_res_mode_enabled; #endif diff --git a/lib_isar/isar_lc3plus_dec.c b/lib_isar/isar_lc3plus_dec.c index b47d42ff8f..b926d7602e 100644 --- a/lib_isar/isar_lc3plus_dec.c +++ b/lib_isar/isar_lc3plus_dec.c @@ -63,7 +63,6 @@ static void isar_LC3PLUS_DEC_FreeSubframeDecodingMatrix( } #endif - /*------------------------------------------------------------------------- * ISAR_LC3PLUS_DEC_Open() * @@ -101,7 +100,6 @@ ivas_error ISAR_LC3PLUS_DEC_Open( return IVAS_ERROR( IVAS_ERR_INIT_ERROR, "Maximum number of channels exceeds IVAS_LC3PLUS_MAX_NUM_DECODERS\n" ); } #else - if ( 0 == config.lc3plus_frame_duration_us ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid lc3plus_frame_duration_us (0)\n" ); @@ -170,6 +168,7 @@ ivas_error ISAR_LC3PLUS_DEC_Open( #else err = lc3plus_dec_init( ( *handle )->handles[iCh], config.samplerate, 1, LC3PLUS_PLC_ADVANCED, 0 ); #endif + if ( LC3PLUS_OK != err ) { ISAR_LC3PLUS_DEC_Close( handle ); @@ -215,11 +214,13 @@ ivas_error ISAR_LC3PLUS_DEC_Open( ISAR_LC3PLUS_DEC_Close( handle ); return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ( *handle )->bitstream_caches[iCh]->bitstream_cache_capacity = 400 /*LC3plus max non-HR octet count*/; #else ( *handle )->bitstream_caches[iCh]->bitstream_cache_capacity = 400 /*LC3plus max non-HR octet count*/ * numLC3plusFramesPerIvasFrame; #endif + if ( ( ( *handle )->bitstream_caches[iCh]->bitstream_cache = malloc( ( *handle )->bitstream_caches[iCh]->bitstream_cache_capacity ) ) == NULL ) { ISAR_LC3PLUS_DEC_Close( handle ); @@ -392,8 +393,8 @@ ivas_error ISAR_LC3PLUS_DEC_SetSelectiveDecodingMatrix( return IVAS_ERR_OK; } -#endif +#endif /*------------------------------------------------------------------------- * ISAR_LC3PLUS_DEC_GetDelay() @@ -773,8 +774,8 @@ static ivas_error isar_LC3PLUS_DEC_Decode_or_Conceal_internal( handle->selective_decoding_states[iDec]->frame_actions[iLc3plusFrame] = DEC_ACTION_DECODE_AND_USE; } } - #endif + return IVAS_ERR_OK; } diff --git a/lib_isar/isar_lc3plus_dec.h b/lib_isar/isar_lc3plus_dec.h index 7c7188dbe8..3c54a4d4b1 100644 --- a/lib_isar/isar_lc3plus_dec.h +++ b/lib_isar/isar_lc3plus_dec.h @@ -128,7 +128,8 @@ ivas_error ISAR_LC3PLUS_DEC_AllocateSubframeDecodingMatrix( int16_t ***subframeChannelMatrix, const uint32_t num_decs ); -void ISAR_LC3PLUS_DEC_FreeSubframeDecodingMatrix( int16_t **subframeChannelMatrix ); +void ISAR_LC3PLUS_DEC_FreeSubframeDecodingMatrix( + int16_t **subframeChannelMatrix ); #endif #endif /* SPLIT_REND_WITH_HEAD_ROT */ diff --git a/lib_isar/isar_lc3plus_enc.c b/lib_isar/isar_lc3plus_enc.c index da2c1d48f0..fbf60161ee 100644 --- a/lib_isar/isar_lc3plus_enc.c +++ b/lib_isar/isar_lc3plus_enc.c @@ -40,11 +40,10 @@ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS static const LC3PLUS_RTP_FDL s_fdl_request = LC3PLUS_RTP_FDL_NO_REQ_OR_NO_DATA; -#endif -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS -static int32_t limit_per_channel_bitrate( LC3PLUS_CONFIG config, - int32_t per_channel_bitrate ) +static int32_t limit_per_channel_bitrate( + LC3PLUS_CONFIG config, + const int32_t per_channel_bitrate ) { if ( config.high_res_mode_enabled ) { @@ -79,6 +78,7 @@ static int32_t limit_per_channel_bitrate( LC3PLUS_CONFIG config, assert( false && "unreachable" ); return -1; } + #endif #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -118,6 +118,7 @@ ivas_error ISAR_LC3PLUS_ENC_Open( { return IVAS_ERROR( IVAS_ERR_INTERNAL, "Invalid number of channels\n" ); } + #ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS bitsPerSecondPerChannel = bitsPerSecond / config.channels; #endif @@ -131,6 +132,7 @@ ivas_error ISAR_LC3PLUS_ENC_Open( return IVAS_ERROR( IVAS_ERR_INTERNAL, "Invalid isar_frame_duration_us\n" ); } #endif + encoder_size = lc3plus_enc_get_size( config.samplerate, 1 ); if ( 0 == encoder_size ) { @@ -141,6 +143,7 @@ ivas_error ISAR_LC3PLUS_ENC_Open( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus wrapper handle\n" ); } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ( *handle )->config = config; ( *handle )->frame_type_descriptors = NULL; @@ -159,6 +162,7 @@ ivas_error ISAR_LC3PLUS_ENC_Open( ( *handle )->handles[i] = NULL; } ( *handle )->num_encs = config.channels; + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS num_lc3plus_media_times_per_ivas_frame = config.isar_frame_duration_us / config.lc3plus_frame_duration_us; ( *handle )->fdl_request = s_fdl_request; @@ -196,6 +200,7 @@ ivas_error ISAR_LC3PLUS_ENC_Open( ISAR_LC3PLUS_ENC_Close( handle ); return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_enc_set_frame_dms failed\n" ); } + #ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS err = lc3plus_enc_set_bitrate( ( *handle )->handles[iCh], bitsPerSecondPerChannel ); if ( err != LC3PLUS_OK ) @@ -240,6 +245,7 @@ ivas_error ISAR_LC3PLUS_ENC_Open( } ( *handle )->frame_type_descriptors[ftd_index].frame_data_length = lc3plus_num_bytes_per_frame; #endif + if ( 0 != LC3PLUS_RTP_ftd_bwr_from_samplerate( &( *handle )->frame_type_descriptors[ftd_index].bwr, config.samplerate, config.high_res_mode_enabled ) ) { ISAR_LC3PLUS_ENC_Close( handle ); @@ -285,6 +291,7 @@ ivas_error ISAR_LC3PLUS_ENC_Open( } #endif #endif + return IVAS_ERR_OK; } @@ -331,12 +338,12 @@ ivas_error IVAS_LC3PLUS_ENC_SetBitrate( } minPayloadOverhead = fdrLength + ( numSubframes * LC3PLUS_RTP_FTD_MIN_SIZE ); targetLc3PlusBitratePerChannel = ( availableOctetsPerIsarFrame - minPayloadOverhead ) / handle->config.channels * 8 * lc3plusPacketRate / numLc3plusMediaTimesPerIvasFrame; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( targetLc3PlusBitratePerChannel <= 0 ) { return IVAS_ERROR( IVAS_ERR_LC3PLUS_INVALID_BITRATE, "available LC3plus bitrate <= 0\n" ); } -#endif + targetLc3PlusBitratePerChannel = limit_per_channel_bitrate( handle->config, targetLc3PlusBitratePerChannel ); targetLc3PlusOctetCount = targetLc3PlusBitratePerChannel / 8 / lc3plusPacketRate; /* check resulting octet count. If it requires larger than 1-byte length fields, decrease the bitrate by enough to make room for the additional length field */ @@ -359,7 +366,7 @@ ivas_error IVAS_LC3PLUS_ENC_SetBitrate( } } - // update FTD settings after bitrate change + /* update FTD settings after bitrate change */ for ( int32_t iMediaTime = 0; iMediaTime < numLc3plusMediaTimesPerIvasFrame; ++iMediaTime ) { for ( uint32_t iEnc = 0; iEnc < handle->num_encs; ++iEnc ) @@ -379,10 +386,12 @@ ivas_error IVAS_LC3PLUS_ENC_SetBitrate( { return IVAS_ERROR( IVAS_ERR_INTERNAL, "ISAR_LC3PLUS_ENC_GetOutputBitstreamSize failed\n" ); } + if ( actualOctetsPerFrame > availableOctetsPerIsarFrame ) { return IVAS_ERROR( IVAS_ERR_INTERNAL, "Bitrate reduction logic failed\n" ); } + return IVAS_ERR_OK; } #endif @@ -451,6 +460,7 @@ ivas_error ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( #else int32_t bitstreamSizeMultiplier; #endif + if ( NULL == handle ) { return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3PLUS_Enc_Wrap_Handle is NULL\n" ); @@ -472,6 +482,7 @@ ivas_error ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( num_lc3plus_media_times_per_ivas_frame = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; #endif + *bsSize = 0; #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int32_t fdl_request_length; @@ -482,14 +493,17 @@ ivas_error ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( } *bsSize += fdl_request_length; #endif + for ( uint32_t iEnc = 0; iEnc < handle->num_encs; iEnc++ ) { if ( NULL == handle->handles[iEnc] ) { return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3plus encoder handle is NULL\n" ); } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS lc3plus_frame_data_length = lc3plus_enc_get_num_bytes( handle->handles[iEnc] ); + for ( iMediaTime = 0; iMediaTime < num_lc3plus_media_times_per_ivas_frame; ++iMediaTime ) { ftd_index = iEnc + iMediaTime * handle->num_encs; @@ -538,12 +552,14 @@ void ISAR_LC3PLUS_ENC_Close( { return; } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( NULL != ( *handle )->frame_type_descriptors ) { free( ( *handle )->frame_type_descriptors ); } #endif + for ( uint32_t iEnc = 0; iEnc < ( *handle )->num_encs; iEnc++ ) { if ( NULL != ( *handle )->handles[iEnc] ) @@ -552,6 +568,7 @@ void ISAR_LC3PLUS_ENC_Close( free( ( *handle )->handles[iEnc] ); } } + if ( NULL != ( *handle )->pcm_conversion_buffer ) { free( ( *handle )->pcm_conversion_buffer ); @@ -615,6 +632,7 @@ ivas_error ISAR_LC3PLUS_ENC_Encode( { return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "isar_frame_duration_us must be equal or multiple of lc3plus_frame_duration_us \n" ); } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS num_media_times = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; numSamplesPerLC3plusChannel = handle->config.samplerate / ( 1000000 / handle->config.isar_frame_duration_us ) / num_media_times; @@ -659,14 +677,17 @@ ivas_error ISAR_LC3PLUS_ENC_Encode( err = lc3plus_enc16( handle->handles[iEnc], &handle->pcm_conversion_buffer, bitstream_out_iter, &num_bytes, NULL ); #endif pop_wmops(); + if ( err != LC3PLUS_OK ) { return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_enc16 failed\n" ); } + if ( 0 == num_bytes ) { return IVAS_ERROR( IVAS_ERR_INTERNAL, "lc3plus_enc16 did not produce output\n" ); } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( num_bytes != (int32_t) handle->frame_type_descriptors[ftdIndex].frame_data_length ) { diff --git a/lib_isar/isar_lc3plus_payload.c b/lib_isar/isar_lc3plus_payload.c index b240897655..d16ce18b88 100644 --- a/lib_isar/isar_lc3plus_payload.c +++ b/lib_isar/isar_lc3plus_payload.c @@ -36,9 +36,16 @@ #include "isar_lc3plus_payload.h" #include "options.h" + #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS -static LC3PLUS_RTP_ERR s_frame_duration_ms_from_fdi( int32_t *frame_duration_us, const LC3PLUS_RTP_FTD_FDI fdi ) +/*------------------------------------------------------------------------- + * Local functions + *------------------------------------------------------------------------*/ + +static LC3PLUS_RTP_ERR s_frame_duration_ms_from_fdi( + int32_t *frame_duration_us, + const LC3PLUS_RTP_FTD_FDI fdi ) { if ( NULL == frame_duration_us ) { @@ -59,10 +66,14 @@ static LC3PLUS_RTP_ERR s_frame_duration_ms_from_fdi( int32_t *frame_duration_us, default: return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; } + return LC3PLUS_RTP_ERR_NO_ERROR; } -static LC3PLUS_RTP_ERR s_sampling_rate_hz_from_bwr( int32_t *sample_rate_hz, const LC3PLUS_RTP_FTD_BWR bwr ) + +static LC3PLUS_RTP_ERR s_sampling_rate_hz_from_bwr( + int32_t *sample_rate_hz, + const LC3PLUS_RTP_FTD_BWR bwr ) { if ( NULL == sample_rate_hz ) { @@ -97,10 +108,14 @@ static LC3PLUS_RTP_ERR s_sampling_rate_hz_from_bwr( int32_t *sample_rate_hz, con default: return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; } + return LC3PLUS_RTP_ERR_NO_ERROR; } -static LC3PLUS_RTP_ERR s_high_resolution_flag_from_bwr( int16_t *high_resolution_flag, const LC3PLUS_RTP_FTD_BWR bwr ) + +static LC3PLUS_RTP_ERR s_high_resolution_flag_from_bwr( + int16_t *high_resolution_flag, + const LC3PLUS_RTP_FTD_BWR bwr ) { if ( NULL == high_resolution_flag ) { @@ -135,10 +150,20 @@ static LC3PLUS_RTP_ERR s_high_resolution_flag_from_bwr( int16_t *high_resolution default: return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; } + return LC3PLUS_RTP_ERR_NO_ERROR; } -LC3PLUS_RTP_ERR LC3PLUS_RTP_frame_data_length_get_size( int32_t *length, const LC3PLUS_RTP_FDL frameDataLengthValue ) + +/*------------------------------------------------------------------------- + * LC3PLUS_RTP_frame_data_length_get_size() + * + * + *------------------------------------------------------------------------*/ + +LC3PLUS_RTP_ERR LC3PLUS_RTP_frame_data_length_get_size( + int32_t *length, + const LC3PLUS_RTP_FDL frameDataLengthValue ) { if ( frameDataLengthValue == LC3PLUS_RTP_FDL_NO_REQ_OR_NO_DATA || frameDataLengthValue == LC3PLUS_RTP_FDL_SPEECH_BAD || frameDataLengthValue == LC3PLUS_RTP_FDL_SPEECH_SID ) { @@ -160,10 +185,14 @@ LC3PLUS_RTP_ERR LC3PLUS_RTP_frame_data_length_get_size( int32_t *length, const L { return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; } + return LC3PLUS_RTP_ERR_NO_ERROR; } -static LC3PLUS_RTP_ERR s_frame_data_length_pack( const LC3PLUS_RTP_FDL frameDataLengthValue, uint8_t *dst ) + +static LC3PLUS_RTP_ERR s_frame_data_length_pack( + const LC3PLUS_RTP_FDL frameDataLengthValue, + uint8_t *dst ) { int32_t frame_data_length_size; LC3PLUS_RTP_ERR err; @@ -195,41 +224,56 @@ static LC3PLUS_RTP_ERR s_frame_data_length_pack( const LC3PLUS_RTP_FDL frameData *dst++ = LC3PLUS_RTP_FDL_EXTENSION_VALUE; *dst = frameDataLengthValueToWrite >> 0 & LC3PLUS_RTP_FDL_EXTENSION_VALUE; } + return LC3PLUS_RTP_ERR_NO_ERROR; } -static int32_t s_get_size_from_fdl( const LC3PLUS_RTP_FDL fdl ) + +static int32_t s_get_size_from_fdl( + const LC3PLUS_RTP_FDL fdl ) { if ( fdl >= LC3PLUS_RTP_FDL_LENGTH_1_MIN && fdl <= LC3PLUS_RTP_FDL_LENGTH_3_MAX ) { return fdl; } + return 0; } -static bool s_fdl_is_magic_value( const LC3PLUS_RTP_FDL fdl ) + +static bool s_fdl_is_magic_value( + const LC3PLUS_RTP_FDL fdl ) { if ( fdl == LC3PLUS_RTP_FDL_NO_REQ_OR_NO_DATA || fdl == LC3PLUS_RTP_FDL_SPEECH_SID || fdl == LC3PLUS_RTP_FDL_SPEECH_BAD ) { return true; } + return false; } -static bool s_fdl_value_is_valid_request( const LC3PLUS_RTP_FDL fdl_request ) + +static bool s_fdl_value_is_valid_request( + const LC3PLUS_RTP_FDL fdl_request ) { /* LC3PLUS_RTP_FDL_SPEECH_SID && LC3PLUS_RTP_FDL_SPEECH_SID are not valid values for the FDL request */ if ( fdl_request == LC3PLUS_RTP_FDL_NO_REQ_OR_NO_DATA || ( fdl_request >= LC3PLUS_RTP_FDL_LENGTH_1_MIN && fdl_request <= LC3PLUS_RTP_FDL_LENGTH_3_MAX ) ) { return true; } + return false; } -static LC3PLUS_RTP_ERR s_frame_data_length_parse( LC3PLUS_RTP_FDL *frame_data_length_value, const uint8_t *src, const size_t remaining_capacity ) + +static LC3PLUS_RTP_ERR s_frame_data_length_parse( + LC3PLUS_RTP_FDL *frame_data_length_value, + const uint8_t *src, + const size_t remaining_capacity ) { int32_t frame_data_length_size; LC3PLUS_RTP_ERR err; + if ( NULL == src || NULL == frame_data_length_value || remaining_capacity < 1 ) { return LC3PLUS_RTP_ERR_NULL_PTR; @@ -258,14 +302,21 @@ static LC3PLUS_RTP_ERR s_frame_data_length_parse( LC3PLUS_RTP_FDL *frame_data_le { return err; } + return LC3PLUS_RTP_ERR_NO_ERROR; } -static LC3PLUS_RTP_ERR s_parse_ftd( const uint8_t *p_read, LC3PLUS_RTP_FTD *receiver_ftd, int32_t *num_bytes_read, const size_t remaining_capacity ) + +static LC3PLUS_RTP_ERR s_parse_ftd( + const uint8_t *p_read, + LC3PLUS_RTP_FTD *receiver_ftd, + int32_t *num_bytes_read, + const size_t remaining_capacity ) { int32_t frame_data_block_size; LC3PLUS_RTP_FDL fdl; LC3PLUS_RTP_ERR err; + if ( NULL == p_read || NULL == receiver_ftd || NULL == num_bytes_read || remaining_capacity < LC3PLUS_RTP_FTD_MIN_SIZE ) { return LC3PLUS_RTP_ERR_NULL_PTR; @@ -298,9 +349,17 @@ static LC3PLUS_RTP_ERR s_parse_ftd( const uint8_t *p_read, LC3PLUS_RTP_FTD *rece return err; } *num_bytes_read += length_field_size; + return LC3PLUS_RTP_ERR_NO_ERROR; } + +/*------------------------------------------------------------------------- + * LC3PLUS_RTP_payload_serialize() + * + * + *------------------------------------------------------------------------*/ + LC3PLUS_RTP_ERR LC3PLUS_RTP_payload_serialize( uint8_t *serialized_buffer, const size_t serialized_buffer_capacity, @@ -397,9 +456,11 @@ LC3PLUS_RTP_ERR LC3PLUS_RTP_payload_serialize( } *packed_buffer_actual_size = bytes_written + lc3plus_frame_size_sum; assert( *packed_buffer_actual_size <= serialized_buffer_capacity ); + return LC3PLUS_RTP_ERR_NO_ERROR; } + static LC3PLUS_RTP_ERR s_ftds_parse( LC3PLUS_RTP_FTD *receiver_ftds, const int32_t receiver_ftds_num_max, @@ -428,6 +489,7 @@ static LC3PLUS_RTP_ERR s_ftds_parse( { return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; } + { int32_t num_bytes_read_sum = 0; const int32_t min_num_bytes_per_ftd = 2; @@ -521,9 +583,17 @@ static LC3PLUS_RTP_ERR s_ftds_parse( p_read++; } } + return LC3PLUS_RTP_ERR_NO_ERROR; } + +/*------------------------------------------------------------------------- + * LC3PLUS_RTP_payload_deserialize() + * + * + *------------------------------------------------------------------------*/ + LC3PLUS_RTP_ERR LC3PLUS_RTP_payload_deserialize( LC3PLUS_RTP_PAYLOAD *payload, uint8_t *serialized_buffer, @@ -724,10 +794,21 @@ LC3PLUS_RTP_ERR LC3PLUS_RTP_payload_deserialize( { return LC3PLUS_RTP_ERR_GENERIC_ERROR; } + return LC3PLUS_RTP_ERR_NO_ERROR; } -LC3PLUS_RTP_ERR LC3PLUS_RTP_ftd_bwr_from_samplerate( LC3PLUS_RTP_FTD_BWR *bwr, const int32_t sampling_rate, const int32_t high_res_enabled ) + +/*------------------------------------------------------------------------- + * LC3PLUS_RTP_ftd_bwr_from_samplerate() + * + * + *------------------------------------------------------------------------*/ + +LC3PLUS_RTP_ERR LC3PLUS_RTP_ftd_bwr_from_samplerate( + LC3PLUS_RTP_FTD_BWR *bwr, + const int32_t sampling_rate, + const int32_t high_res_enabled ) { if ( NULL == bwr ) { @@ -795,7 +876,16 @@ LC3PLUS_RTP_ERR LC3PLUS_RTP_ftd_bwr_from_samplerate( LC3PLUS_RTP_FTD_BWR *bwr, c return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; } -LC3PLUS_RTP_ERR LC3PLUS_RTP_ftd_fdi_from_frame_duration_us( LC3PLUS_RTP_FTD_FDI *fdi, const int32_t frame_duration_us ) + +/*------------------------------------------------------------------------- + * LC3PLUS_RTP_ftd_fdi_from_frame_duration_us() + * + * + *------------------------------------------------------------------------*/ + +LC3PLUS_RTP_ERR LC3PLUS_RTP_ftd_fdi_from_frame_duration_us( + LC3PLUS_RTP_FTD_FDI *fdi, + const int32_t frame_duration_us ) { if ( NULL == fdi ) { diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index a7cbea1656..72926a9181 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -407,7 +407,6 @@ int32_t isar_get_lc3plus_size_from_id( ); #endif - void isar_renderSplitUpdateNoCorrectionPoseData( const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renderer config */ MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 80a35416fc..55a9191c12 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -1969,13 +1969,11 @@ ivas_error split_renderer_open_lc3plus( #endif config.channels = BINAURAL_CHANNELS; - if ( ( error = ISAR_LC3PLUS_ENC_Open( config, #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - isar_get_lcld_bitrate( pSplitRendConfig->splitRendBitRate, pSplitRendConfig->poseCorrectionMode ), + if ( ( error = ISAR_LC3PLUS_ENC_Open( config, isar_get_lcld_bitrate( pSplitRendConfig->splitRendBitRate, pSplitRendConfig->poseCorrectionMode ), &hSplitRendWrapper->hLc3plusEnc ) ) != IVAS_ERR_OK ) #else - isar_get_lc3plus_bitrate( pSplitRendConfig->splitRendBitRate, pSplitRendConfig->poseCorrectionMode, (int16_t) ( config.isar_frame_duration_us / 1000 ) ), + if ( ( error = ISAR_LC3PLUS_ENC_Open( config, isar_get_lc3plus_bitrate( pSplitRendConfig->splitRendBitRate, pSplitRendConfig->poseCorrectionMode, (int16_t) ( config.isar_frame_duration_us / 1000 ) ), &hSplitRendWrapper->hLc3plusEnc ) ) != IVAS_ERR_OK ) #endif - &hSplitRendWrapper->hLc3plusEnc ) ) != IVAS_ERR_OK ) { return error; } @@ -2070,8 +2068,8 @@ ivas_error splitRendLc3plusEncodeAndWrite( #ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS ISAR_SPLIT_REND_BITStream_write_int32( pBits, isar_get_lc3plus_bitrate_id( SplitRendBitRate ), 8 ); -#endif +#endif /* Write bitstream */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( ( error = ISAR_LC3PLUS_ENC_Encode( hSplitBin->hLc3plusEnc, channel_ptrs, &pBits->bits_buf[pBits->bits_written / 8], lc3plusBitstreamSize ) ) != IVAS_ERR_OK ) @@ -2203,8 +2201,8 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( #ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS actual_md_bits = pBits->bits_written; -#endif +#endif isar_rend_CldfbSplitPreRendProcess( hSplitBin->hBinHrSplitPreRend, headPosition, &hSplitBin->multiBinPoseData, Cldfb_In_BinReal, Cldfb_In_BinImag, pBits, target_md_bits, low_res_pre_rend_rot, ro_md_flag ); } @@ -2231,14 +2229,9 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( } else { -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS available_bits = ( SplitRendBitRate / FRAMES_PER_SEC ) - pBits->bits_written; if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, available_bits, in ) ) != IVAS_ERR_OK ) -#else - available_bits = ( SplitRendBitRate / FRAMES_PER_SEC ) - pBits->bits_written; - if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, in ) ) != IVAS_ERR_OK ) -#endif #else if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, SplitRendBitRate, in ) ) != IVAS_ERR_OK ) #endif diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c index 7403c1b381..426fa8baec 100644 --- a/lib_isar/isar_splitRenderer_utils.c +++ b/lib_isar/isar_splitRenderer_utils.c @@ -552,7 +552,6 @@ int32_t isar_get_lcld_bitrate( return -1; } - #ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS /*------------------------------------------------------------------------- * Function isar_get_lc3plus_bitrate() @@ -682,7 +681,6 @@ int32_t isar_get_lc3plus_size_from_id( } #endif - /*------------------------------------------------------------------------- * Function isar_split_rend_validate_config() * @@ -1191,7 +1189,14 @@ void isar_init_multi_bin_pose_data( return; } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +/*------------------------------------------------------------------------- + * Function isar_framesize_to_ms() + * + * + *------------------------------------------------------------------------*/ + ivas_error isar_framesize_to_ms( const IVAS_RENDER_FRAMESIZE frame_size, /* i : frame size enum */ int16_t *ms /* o : frame size in ms */ @@ -1261,12 +1266,14 @@ ivas_error isar_split_rend_choose_default_codec( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Unknown split codec value" ); } } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( *pIsar_frame_size_ms == 0 ) /* isar frame size hasn't been set yet - use default for current configuration */ { *pIsar_frame_size_ms = 20; } #endif + return IVAS_ERR_OK; } diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 07fbffec19..96d77effba 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -608,12 +608,11 @@ static ivas_error setRendInputActiveSplitPostRend( initRendInputBase( &inputSplitPostRend->base, inConfig, id, rendCtx, inputSplitPostRend->bufferData, MAX_CLDFB_BIN_BUFFER_LENGTH ); inputSplitPostRend->numCachedSamples = 0; - if ( ( error = updateSplitPostRendPanGains( inputSplitPostRend, outConfig, hRendCfg -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - num_subframes +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( ( error = updateSplitPostRendPanGains( inputSplitPostRend, outConfig, hRendCfg ) ) != IVAS_ERR_OK ) +#else + if ( ( error = updateSplitPostRendPanGains( inputSplitPostRend, outConfig, hRendCfg, num_subframes ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -950,12 +949,12 @@ ivas_error ISAR_POST_REND_AddInput( int32_t maxNumInputsOfType; void *inputsArray; int32_t inputStructSize; - ivas_error ( *activateInput )( void *, AUDIO_CONFIG, IVAS_REND_InputId, ISAR_SPLIT_REND_CONFIG_DATA * -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - int16_t + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ivas_error ( *activateInput )( void *, AUDIO_CONFIG, IVAS_REND_InputId, ISAR_SPLIT_REND_CONFIG_DATA * ); +#else + ivas_error ( *activateInput )( void *, AUDIO_CONFIG, IVAS_REND_InputId, ISAR_SPLIT_REND_CONFIG_DATA *, int16_t ); #endif - ); int32_t inputIndex; /* Validate function arguments */ @@ -983,12 +982,12 @@ ivas_error ISAR_POST_REND_AddInput( } *inputId = makeInputId( inConfig, inputIndex ); - if ( ( error = activateInput( (uint8_t *) inputsArray + inputStructSize * inputIndex, inConfig, *inputId, &hIvasRend->splitRenderConfig -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - hIvasRend->num_subframes + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( ( error = activateInput( (uint8_t *) inputsArray + inputStructSize * inputIndex, inConfig, *inputId, &hIvasRend->splitRenderConfig ) ) != IVAS_ERR_OK ) +#else + if ( ( error = activateInput( (uint8_t *) inputsArray + inputStructSize * inputIndex, inConfig, *inputId, &hIvasRend->splitRenderConfig, hIvasRend->num_subframes ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -1373,6 +1372,7 @@ static ivas_error splitBinLc3plusDecode( { ++bits->bits_read; } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /* Size is in bytes */ assert( ( bits->bits_written - bits->bits_read ) % 8 == 0 ); @@ -1451,8 +1451,8 @@ static ivas_error renderSplitBinauralWithPostRot( { ivas_frame_duration_us = splitBinInput->splitPostRendWrapper.hLc3plusDec->config.isar_frame_duration_us; } -#endif +#endif iNumLCLDIterationsPerFrame = 1; iNumBlocksPerFrame = CLDFB_NO_COL_MAX; if ( splitBinInput->splitPostRendWrapper.hSplitBinLCLDDec != NULL ) @@ -1496,6 +1496,7 @@ static ivas_error renderSplitBinauralWithPostRot( { isPostRendInputCldfb = 1; } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS numSamplesPerChannelCacheSize = (int16_t) ( *splitBinInput->base.ctx.pOutSampleRate * bits.isar_frame_size_ms / 1000 ) - outBufNumSamplesPerChannel; #else @@ -1545,11 +1546,11 @@ static ivas_error renderSplitBinauralWithPostRot( } else { - if ( ( error = splitBinLc3plusDecode( hSplitBin, &bits, tmpCrendBuffer, -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - bits.pose_correction, +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( ( error = splitBinLc3plusDecode( hSplitBin, &bits, tmpCrendBuffer, bits.pose_correction, SplitRendBFI ) ) != IVAS_ERR_OK ) +#else + if ( ( error = splitBinLc3plusDecode( hSplitBin, &bits, tmpCrendBuffer, SplitRendBFI ) ) != IVAS_ERR_OK ) #endif - SplitRendBFI ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index f23c0d7f9d..4bb9c01cfc 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -76,22 +76,13 @@ ivas_error ISAR_PRE_REND_open( { ivas_error error, ch, num_ch; uint8_t isCldfbNeeded = 0; - int16_t cldfb_in_flag_local = cldfb_in_flag; - if ( ( error = isar_split_rend_choose_default_codec( &( pSplitRendConfig->codec ), -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - &pSplitRendConfig->isar_frame_size_ms, -#endif - &pSplitRendConfig->codec_frame_size_ms, - cldfb_in_flag_local, - pcm_out_flag, (int16_t) #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - ivas_frame_size + if ( ( error = isar_split_rend_choose_default_codec( &( pSplitRendConfig->codec ), &pSplitRendConfig->isar_frame_size_ms, &pSplitRendConfig->codec_frame_size_ms, cldfb_in_flag_local, pcm_out_flag, (int16_t) ivas_frame_size ) ) != IVAS_ERR_OK ) #else - num_subframes + if ( ( error = isar_split_rend_choose_default_codec( &( pSplitRendConfig->codec ), &pSplitRendConfig->codec_frame_size_ms, cldfb_in_flag_local, pcm_out_flag, (int16_t) num_subframes ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -173,13 +164,11 @@ ivas_error ISAR_PRE_REND_open( { if ( pSplitRendConfig->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS ) { - if ( ( error = split_renderer_open_lc3plus( hSplitBinRend, pSplitRendConfig, output_Fs, #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - ivas_frame_size + if ( ( error = split_renderer_open_lc3plus( hSplitBinRend, pSplitRendConfig, output_Fs, ivas_frame_size ) ) != IVAS_ERR_OK ) #else - num_subframes + if ( ( error = split_renderer_open_lc3plus( hSplitBinRend, pSplitRendConfig, output_Fs, num_subframes ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -305,23 +294,23 @@ void ISAR_PRE_REND_GetMultiBinPoseData( *------------------------------------------------------------------------*/ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( - SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renerer handle */ - const IVAS_QUATERNION headPosition, /* i: head rotation QUATERNION */ - const int32_t SplitRendBitRate, /* i: Split renderer bitrate */ - ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */ + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renerer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + const int32_t SplitRendBitRate, /* i : Split renderer bitrate */ + ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - const int16_t isar_frame_size_ms, /* i: ISAR framesize */ + const int16_t isar_frame_size_ms, /* i : ISAR framesize */ #endif - int16_t codec_frame_size_ms, /* i/o: ISAR transport codec framesize */ - ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits struct handle */ - float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB real buffer */ - float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB imag buffer */ - const int16_t max_bands, /* i: CLDFB bands */ - float *output[], /* i/o: PCM in/out buffer */ - const int16_t low_res_pre_rend_rot, /* i: low time resolution pre-renderer flag */ - const int16_t cldfb_in_flag, /* i: Flag to indicate CLDFB or time doamin input */ - const int16_t pcm_out_flag, /* i: Flag to indicate PCM output */ - const int16_t ro_md_flag /* i: Flag to indicate real only metadata for yaw */ + int16_t codec_frame_size_ms, /* i/o: ISAR transport codec framesize */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits struct handle */ + float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB real buffer */ + float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB imag buffer */ + const int16_t max_bands, /* i : CLDFB bands */ + float *output[], /* i/o: PCM in/out buffer */ + const int16_t low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ + const int16_t cldfb_in_flag, /* i : Flag to indicate CLDFB or time doamin input */ + const int16_t pcm_out_flag, /* i : Flag to indicate PCM output */ + const int16_t ro_md_flag /* i : Flag to indicate real only metadata for yaw */ ) { ivas_error error; @@ -344,19 +333,11 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( { /*TD input*/ /*if CLDFB handles have been allocated then assume valid multi binaural input in out[][] buffer and perform CLDFB analysis*/ - error = isar_renderMultiTDBinToSplitBinaural( hSplitBin, - headPosition, - SplitRendBitRate, #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - isar_frame_size_ms, + error = isar_renderMultiTDBinToSplitBinaural( hSplitBin, headPosition, SplitRendBitRate, isar_frame_size_ms, codec_frame_size_ms, pBits, max_bands, output, low_res_pre_rend_rot, pcm_out_flag, ro_md_flag ); +#else + error = isar_renderMultiTDBinToSplitBinaural( hSplitBin, headPosition, SplitRendBitRate, codec_frame_size_ms, pBits, max_bands, output, low_res_pre_rend_rot, pcm_out_flag, ro_md_flag ); #endif - codec_frame_size_ms, - pBits, - max_bands, - output, - low_res_pre_rend_rot, - pcm_out_flag, - ro_md_flag ); pop_wmops(); return error; @@ -377,6 +358,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( #ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS actual_md_bits = pBits->bits_written; + #endif isar_rend_CldfbSplitPreRendProcess( hSplitBin->hBinHrSplitPreRend, headPosition, &hSplitBin->multiBinPoseData, Cldfb_In_BinReal, Cldfb_In_BinImag, pBits, target_md_bits, low_res_pre_rend_rot, ro_md_flag ); diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 6298bc0b29..1b29959599 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -7848,7 +7848,7 @@ static ivas_error getSamplesInternal( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, @@ -7952,10 +7952,11 @@ 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 */ - int16_t *pCodec_frame_size_ms /* o : pointer to codec frame size setting */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - int16_t *pIsar_frame_size_ms /* o: pointer to isar frame size setting */ + int16_t *pCodec_frame_size_ms, /* o : pointer to codec frame size setting */ + int16_t *pIsar_frame_size_ms /* o : pointer to isar frame size setting */ +#else + int16_t *pCodec_frame_size_ms /* o : pointer to codec frame size setting */ #endif ) { diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c index a1ccff06cd..69607c63cd 100644 --- a/lib_util/split_render_file_read_write.c +++ b/lib_util/split_render_file_read_write.c @@ -65,12 +65,13 @@ ivas_error split_rend_reader_open( char *filename, ISAR_SPLIT_REND_CODEC *codec, ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, - int16_t *codec_frame_size_ms #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , + int16_t *codec_frame_size_ms, int16_t *isar_frame_size_ms, int32_t *sampling_rate, int16_t *lc3plus_highres +#else + int16_t *codec_frame_size_ms #endif ) { @@ -119,22 +120,26 @@ ivas_error split_rend_reader_open( { return IVAS_ERR_FAILED_FILE_READ; } + /* read transport codec frame size signalling */ if ( fread( codec_frame_size_ms, sizeof( *codec_frame_size_ms ), 1, hSplitRendFileReadWrite->file ) != 1 ) { return IVAS_ERR_FAILED_FILE_READ; } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /* read isar bitstream frame size signalling */ if ( fread( isar_frame_size_ms, sizeof( *isar_frame_size_ms ), 1, hSplitRendFileReadWrite->file ) != 1 ) { return IVAS_ERR_FAILED_FILE_READ; } + /* read sampling rate signalling */ if ( fread( sampling_rate, sizeof( *sampling_rate ), 1, hSplitRendFileReadWrite->file ) != 1 ) { return IVAS_ERR_FAILED_FILE_READ; } + /* read LC3plus highres signalling */ if ( fread( lc3plus_highres, sizeof( *lc3plus_highres ), 1, hSplitRendFileReadWrite->file ) != 1 ) { @@ -215,22 +220,26 @@ ivas_error split_rend_writer_open( { return IVAS_ERR_FAILED_FILE_WRITE; } + /* Write transport codec frame size signalling */ if ( fwrite( &codec_frame_size_ms, sizeof( codec_frame_size_ms ), 1, hSplitRendFileReadWrite->file ) != 1 ) { return IVAS_ERR_FAILED_FILE_WRITE; } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /* Write isar bit stream frame size signalling */ if ( fwrite( &isar_frame_size_ms, sizeof( isar_frame_size_ms ), 1, hSplitRendFileReadWrite->file ) != 1 ) { return IVAS_ERR_FAILED_FILE_WRITE; } + /* Write sampling rate signalling */ if ( fwrite( &sampling_rate, sizeof( sampling_rate ), 1, hSplitRendFileReadWrite->file ) != 1 ) { return IVAS_ERR_FAILED_FILE_WRITE; } + /* Write LC3plus highres signalling */ if ( fwrite( &lc3plus_highres, sizeof( lc3plus_highres ), 1, hSplitRendFileReadWrite->file ) != 1 ) { diff --git a/lib_util/split_render_file_read_write.h b/lib_util/split_render_file_read_write.h index 5984322d58..3966c63679 100644 --- a/lib_util/split_render_file_read_write.h +++ b/lib_util/split_render_file_read_write.h @@ -44,12 +44,13 @@ ivas_error split_rend_reader_open( char *filename, ISAR_SPLIT_REND_CODEC *codec, ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, - int16_t *codec_frame_size_ms #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , + int16_t *codec_frame_size_ms, int16_t *isar_frame_size_ms, int32_t *sampling_rate, int16_t *lc3plus_highres +#else + int16_t *codec_frame_size_ms #endif ); -- GitLab From 89bda00a78711a471b732496aa257604844658cb Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 May 2024 10:12:04 +0200 Subject: [PATCH 08/26] address comments --- lib_com/delay_comp.c | 6 +++--- lib_com/prot.h | 4 ++-- lib_dec/ivas_stat_dec.h | 1 - lib_dec/lib_dec.c | 2 +- lib_isar/isar_cnst.h | 2 +- lib_rend/ivas_render_config.c | 2 +- lib_rend/lib_rend.c | 2 +- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c index 5a286aff70..fa17c75daa 100644 --- a/lib_com/delay_comp.c +++ b/lib_com/delay_comp.c @@ -55,8 +55,8 @@ int32_t get_delay( const int32_t io_fs, /* i : input/output sampling frequency */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ #ifdef SPLIT_REND_WITH_HEAD_ROT - HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ - const int16_t flag_split_rendering /* i : split rendering on/off flag */ + HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ + const int16_t flag_binaural_split_coded /* i : split rendering on/off flag */ #else HANDLE_CLDFB_FILTER_BANK hCldfb /* i : Handle of Cldfb analysis */ #endif @@ -103,7 +103,7 @@ int32_t get_delay( delay = IVAS_DEC_DELAY_NS; #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( !flag_split_rendering ) + if ( !flag_binaural_split_coded ) { #endif if ( hCldfb != NULL ) diff --git a/lib_com/prot.h b/lib_com/prot.h index 75e781df16..f9d9648575 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -728,8 +728,8 @@ int32_t get_delay( const int32_t io_fs, /* i : input/output sampling frequency */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ #ifdef SPLIT_REND_WITH_HEAD_ROT - HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ - const int16_t flag_split_rendering /* i : split rendering on/off flag */ + HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ + const int16_t flag_binaural_split_coded /* i : split rendering on/off flag */ #else HANDLE_CLDFB_FILTER_BANK hCldfb /* i : Handle of Cldfb analysis */ #endif diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index c8cc5a39d0..a5ce7ca36c 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -40,7 +40,6 @@ #include "stat_dec.h" #include "ivas_stat_com.h" #include "ivas_stat_rend.h" -#include "isar_stat.h" /*----------------------------------------------------------------------------------* diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index b07ea90c90..0b5af14771 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2111,7 +2111,7 @@ static ivas_error copyRendererConfigStruct( #ifdef SPLIT_REND_WITH_HEAD_ROT /* TODO: This seems wrong. Why set default instead of copying from hRCin? * Currently seems to work because we only ever copy from a default-initialized handle anyway */ - hRCout->split_rend_config.splitRendBitRate = SPLIT_REND_768k; + hRCout->split_rend_config.splitRendBitRate = ISAR_MAX_SPLIT_REND_BITRATE; hRCout->split_rend_config.dof = 3; hRCout->split_rend_config.hq_mode = 0; hRCout->split_rend_config.codec_delay_ms = 0; diff --git a/lib_isar/isar_cnst.h b/lib_isar/isar_cnst.h index d93f9ae39f..b1ce98001d 100644 --- a/lib_isar/isar_cnst.h +++ b/lib_isar/isar_cnst.h @@ -127,7 +127,7 @@ typedef enum #define SPLIT_REND_320k 320000 #define SPLIT_REND_384k 384000 #define SPLIT_REND_512k 512000 -#define SPLIT_REND_768k 768000 +#define SPLIT_REND_768k 768000 /* == ISAR_MAX_SPLIT_REND_BITRATE */ #endif /*SPLIT_REND_WITH_HEAD_ROT */ diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config.c index f974dd3477..0c6cfb2a75 100644 --- a/lib_rend/ivas_render_config.c +++ b/lib_rend/ivas_render_config.c @@ -133,7 +133,7 @@ ivas_error ivas_render_config_init_from_rom( } #ifdef SPLIT_REND_WITH_HEAD_ROT - ( *hRenderConfig )->split_rend_config.splitRendBitRate = SPLIT_REND_768k; + ( *hRenderConfig )->split_rend_config.splitRendBitRate = ISAR_MAX_SPLIT_REND_BITRATE; ( *hRenderConfig )->split_rend_config.dof = 3; ( *hRenderConfig )->split_rend_config.hq_mode = 0; ( *hRenderConfig )->split_rend_config.codec_delay_ms = 0; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 1b29959599..b1557f3a9e 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4370,7 +4370,7 @@ int16_t IVAS_REND_GetRenderConfig( mvr2r( hRCin->roomAcoustics.pAcoustic_dsr, hRCout->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); #ifdef SPLIT_REND_WITH_HEAD_ROT - hRCout->split_rend_config.splitRendBitRate = SPLIT_REND_768k; + hRCout->split_rend_config.splitRendBitRate = ISAR_MAX_SPLIT_REND_BITRATE; hRCout->split_rend_config.dof = 3; hRCout->split_rend_config.hq_mode = 0; hRCout->split_rend_config.codec_delay_ms = 0; -- GitLab From c3fef1cf6887524c7e9a268c34d4c32153b23d10 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 May 2024 10:16:11 +0200 Subject: [PATCH 09/26] replace isar -> ISAR --- lib_dec/lib_dec.c | 2 +- lib_dec/lib_dec.h | 2 +- lib_isar/isar_lc3plus_common.h | 2 +- lib_isar/isar_prot.h | 2 +- lib_isar/isar_splitRenderer_utils.c | 4 ++-- lib_isar/lib_isar_post_rend.c | 4 ++-- lib_isar/lib_isar_post_rend.h | 2 +- lib_rend/lib_rend.c | 2 +- lib_rend/lib_rend.h | 2 +- lib_util/split_render_file_read_write.c | 4 ++-- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 0b5af14771..4bdedeaac6 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -3817,7 +3817,7 @@ ivas_error IVAS_DEC_GetSplitRendBitstreamHeader( ISAR_SPLIT_REND_CODEC *pCodec, /* o : pointer to codec setting */ ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o : pointer to pose correction mode */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - int16_t *pIsar_frame_size_ms, /* o : pointer to isar frame size setting */ + int16_t *pIsar_frame_size_ms, /* o : pointer to ISAR frame size setting */ int16_t *pCodec_frame_size_ms, /* o : pointer to codec frame size setting */ int16_t *pLc3plusHighRes /* o : pointer to LC3plus High-Res setting */ #else diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index e79ec68f06..639ce8e658 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -183,7 +183,7 @@ ivas_error IVAS_DEC_GetSplitRendBitstreamHeader( ISAR_SPLIT_REND_CODEC *pCodec, /* o : pointer to codec setting */ ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o : pointer to pose correction mode */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - int16_t *pIsar_frame_size_ms, /* o : pointer to isar frame size setting */ + int16_t *pIsar_frame_size_ms, /* o : pointer to ISAR frame size setting */ int16_t *pCodec_frame_size_ms, /* o : pointer to codec frame size setting */ int16_t *pLc3plusHighRes /* o : pointer to LC3plus High-Res setting */ #else diff --git a/lib_isar/isar_lc3plus_common.h b/lib_isar/isar_lc3plus_common.h index 6dedc8ce3c..a9ec8c8cbd 100644 --- a/lib_isar/isar_lc3plus_common.h +++ b/lib_isar/isar_lc3plus_common.h @@ -48,7 +48,7 @@ typedef struct LC3PLUS_CONFIG { /*! frame duration in microseconds [10000, 5000, 2500] */ int16_t lc3plus_frame_duration_us; - /*! isar frame duration in microseconds [20000, 10000, 5000] */ + /*! ISAR frame duration in microseconds [20000, 10000, 5000] */ int16_t isar_frame_duration_us; /*! sampling rate*/ int32_t samplerate; diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index 72926a9181..b0de75977b 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -390,7 +390,7 @@ ivas_error isar_framesize_to_ms( ivas_error isar_split_rend_choose_default_codec( ISAR_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - int16_t *pIsar_frame_size_ms, /* i/o: pointer to isar frame size setting */ + int16_t *pIsar_frame_size_ms, /* i/o: pointer to ISAR frame size setting */ #endif int16_t *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ const int16_t cldfb_in_flag, /* i : flag indicating rendering in TD */ diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c index 426fa8baec..892db4b88c 100644 --- a/lib_isar/isar_splitRenderer_utils.c +++ b/lib_isar/isar_splitRenderer_utils.c @@ -1231,7 +1231,7 @@ ivas_error isar_framesize_to_ms( ivas_error isar_split_rend_choose_default_codec( ISAR_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - int16_t *pIsar_frame_size_ms, /* i/o: pointer to isar frame size setting */ + int16_t *pIsar_frame_size_ms, /* i/o: pointer to ISAR frame size setting */ #endif int16_t *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ const int16_t cldfb_in_flag, /* i : flag indicating rendering in TD */ @@ -1268,7 +1268,7 @@ ivas_error isar_split_rend_choose_default_codec( } #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - if ( *pIsar_frame_size_ms == 0 ) /* isar frame size hasn't been set yet - use default for current configuration */ + if ( *pIsar_frame_size_ms == 0 ) /* ISAR frame size hasn't been set yet - use default for current configuration */ { *pIsar_frame_size_ms = 20; } diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 96d77effba..aafb9f173d 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -1546,7 +1546,7 @@ static ivas_error renderSplitBinauralWithPostRot( } else { -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( ( error = splitBinLc3plusDecode( hSplitBin, &bits, tmpCrendBuffer, bits.pose_correction, SplitRendBFI ) ) != IVAS_ERR_OK ) #else if ( ( error = splitBinLc3plusDecode( hSplitBin, &bits, tmpCrendBuffer, SplitRendBFI ) ) != IVAS_ERR_OK ) @@ -1875,7 +1875,7 @@ ivas_error ISAR_REND_SetSplitRendBitstreamHeader( const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, /* o : pose correction mode */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS const int16_t codec_frame_size_ms, /* i : codec frame size setting */ - const int16_t isar_frame_size_ms, /* i : isar codec frame size setting */ + const int16_t isar_frame_size_ms, /* i : ISAR codec frame size setting */ const int16_t lc3plus_highres /* i : LC3plus Hig-Res setting. Ignored if codec is not LC3plus */ #else const int16_t codec_frame_size_ms /* i : codec frame size setting */ diff --git a/lib_isar/lib_isar_post_rend.h b/lib_isar/lib_isar_post_rend.h index ca5510bb72..f219e34075 100644 --- a/lib_isar/lib_isar_post_rend.h +++ b/lib_isar/lib_isar_post_rend.h @@ -208,7 +208,7 @@ ivas_error ISAR_REND_SetSplitRendBitstreamHeader( const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, /* o : pose correction mode */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS const int16_t codec_frame_size_ms, /* i : codec frame size setting */ - const int16_t isar_frame_size_ms, /* i : isar codec frame size setting */ + const int16_t isar_frame_size_ms, /* i : ISAR codec frame size setting */ const int16_t lc3plus_highres /* i : LC3plus Hig-Res setting. Ignored if codec is not LC3plus */ #else const int16_t codec_frame_size_ms /* i : codec frame size setting */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index b1557f3a9e..03f46af79a 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -7954,7 +7954,7 @@ ivas_error IVAS_REND_GetSplitRendBitstreamHeader( ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o : pointer to pose correction mode */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int16_t *pCodec_frame_size_ms, /* o : pointer to codec frame size setting */ - int16_t *pIsar_frame_size_ms /* o : pointer to isar frame size setting */ + int16_t *pIsar_frame_size_ms /* o : pointer to ISAR frame size setting */ #else int16_t *pCodec_frame_size_ms /* o : pointer to codec frame size setting */ #endif diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 88f323c91d..edd2b3b3c2 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -277,7 +277,7 @@ ivas_error IVAS_REND_GetSplitRendBitstreamHeader( ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o : pointer to pose correction mode */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int16_t *pCodec_frame_size_ms, /* o : pointer to codec frame size setting */ - int16_t *pIsar_frame_size_ms /* o : pointer to isar frame size setting */ + int16_t *pIsar_frame_size_ms /* o : pointer to ISAR frame size setting */ #else int16_t *pCodec_frame_size_ms /* o : pointer to codec frame size setting */ #endif diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c index 69607c63cd..6d0a3ccf24 100644 --- a/lib_util/split_render_file_read_write.c +++ b/lib_util/split_render_file_read_write.c @@ -128,7 +128,7 @@ ivas_error split_rend_reader_open( } #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - /* read isar bitstream frame size signalling */ + /* read ISAR bitstream frame size signalling */ if ( fread( isar_frame_size_ms, sizeof( *isar_frame_size_ms ), 1, hSplitRendFileReadWrite->file ) != 1 ) { return IVAS_ERR_FAILED_FILE_READ; @@ -228,7 +228,7 @@ ivas_error split_rend_writer_open( } #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - /* Write isar bit stream frame size signalling */ + /* Write ISAR bit stream frame size signalling */ if ( fwrite( &isar_frame_size_ms, sizeof( isar_frame_size_ms ), 1, hSplitRendFileReadWrite->file ) != 1 ) { return IVAS_ERR_FAILED_FILE_WRITE; -- GitLab From 3cb53f09381217889cb8ec8789779526df212592 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 May 2024 10:21:26 +0200 Subject: [PATCH 10/26] clang-format --- lib_rend/lib_rend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 03f46af79a..a44303a3ee 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -7848,7 +7848,7 @@ static ivas_error getSamplesInternal( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, -- GitLab From 1f033be2d0c3b5a2d781ed1089facd8ca628e8fe Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 28 May 2024 09:20:17 +0200 Subject: [PATCH 11/26] formatting around recent ISAR switches (LC3PLUS_LEA_COMPAT_BITRATES_48_6, SPLIT_REND_POSE_CORRECTION_UNUSED_BITS) --- lib_dec/lib_dec.c | 1 - lib_isar/isar_cnst.h | 72 ++++++++++++++--------------- lib_isar/isar_lc3plus_dec.c | 2 +- lib_isar/isar_lc3plus_enc.c | 1 + lib_isar/isar_prot.h | 10 ++-- lib_isar/isar_splitRendererPre.c | 29 +++++++++--- lib_isar/isar_splitRenderer_utils.c | 19 ++++++-- lib_isar/lib_isar_pre_rend.c | 1 + 8 files changed, 82 insertions(+), 53 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 49090e7ad7..b75d98409e 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1249,7 +1249,6 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, max_band, pOutput, 1, !td_input, pcm_out_flag, ro_md_flag ) ) != IVAS_ERR_OK ) - { return error; } diff --git a/lib_isar/isar_cnst.h b/lib_isar/isar_cnst.h index b1ce98001d..f98d0cc7ca 100644 --- a/lib_isar/isar_cnst.h +++ b/lib_isar/isar_cnst.h @@ -63,25 +63,25 @@ typedef enum } ISAR_SPLIT_REND_POSE_TYPE; -#define CLDFB_PLC_XF 2 /* Length of cross-fade into first good frame after frame loss in CLDFB cols. */ - -#define SPLIT_REND_MAX_YAW_ONLY_POSES 2 -#define SPLIT_REND_MAX_PITCH_ONLY_POSES 2 -#define SPLIT_REND_MAX_ROLL_ONLY_POSES 2 -#define SPLIT_REND_MAX_ONE_AXIS_MD_POSES 2 -#define MAX_EXTRAPOLATION_ANGLE 15.0f /* this means additional 15 degrees can be extrapolated on top of MD probing poses*/ - -#define MAX_HEAD_ROT_POSES ( 2 + SPLIT_REND_MAX_YAW_ONLY_POSES + SPLIT_REND_MAX_PITCH_ONLY_POSES + SPLIT_REND_MAX_ROLL_ONLY_POSES ) -#define MAX_SPLIT_REND_MD_BANDS 20 -#define MAX_SPLIT_MD_SUBFRAMES 1 -#define COMPLEX_MD_BAND_THRESH MAX_SPLIT_REND_MD_BANDS +#define CLDFB_PLC_XF 2 /* Length of cross-fade into first good frame after frame loss in CLDFB cols. */ + +#define SPLIT_REND_MAX_YAW_ONLY_POSES 2 +#define SPLIT_REND_MAX_PITCH_ONLY_POSES 2 +#define SPLIT_REND_MAX_ROLL_ONLY_POSES 2 +#define SPLIT_REND_MAX_ONE_AXIS_MD_POSES 2 +#define MAX_EXTRAPOLATION_ANGLE 15.0f /* this means additional 15 degrees can be extrapolated on top of MD probing poses*/ + +#define MAX_HEAD_ROT_POSES ( 2 + SPLIT_REND_MAX_YAW_ONLY_POSES + SPLIT_REND_MAX_PITCH_ONLY_POSES + SPLIT_REND_MAX_ROLL_ONLY_POSES ) +#define MAX_SPLIT_REND_MD_BANDS 20 +#define MAX_SPLIT_MD_SUBFRAMES 1 +#define COMPLEX_MD_BAND_THRESH MAX_SPLIT_REND_MD_BANDS #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS -#define COMPLEX_MD_BAND_THRESH_LOW 4 -#define COMPLEX_MD_BAND_THRESH_HIGH 10 +#define COMPLEX_MD_BAND_THRESH_LOW 4 +#define COMPLEX_MD_BAND_THRESH_HIGH 10 #else -#define COMPLEX_MD_BAND_THRESH_LOW 5 +#define COMPLEX_MD_BAND_THRESH_LOW 5 #endif -#define SPLIT_REND_RO_MD_BAND_THRESH 4 +#define SPLIT_REND_RO_MD_BAND_THRESH 4 #define ISAR_SPLIT_REND_NUM_QUANT_STRATS 4 #define ISAR_SPLIT_REND_PRED_63QUANT_PNTS 63 @@ -91,11 +91,11 @@ typedef enum #define ISAR_SPLIT_REND_PRED_MIN_VAL -1.4f #define ISAR_SPLIT_REND_PRED_MAX_VAL 1.4f -#define ISAR_SPLIT_REND_PITCH_G_MIN_VAL 0.5f -#define ISAR_SPLIT_REND_PITCH_G_MAX_VAL 1.5f -#define ISAR_SPLIT_REND_PITCH_G_QUANT_PNTS ISAR_SPLIT_REND_D_QUANT_PNTS -#define ISAR_SPLIT_REND_D_MIN_VAL 0.0f -#define ISAR_SPLIT_REND_D_MAX_VAL 1.0f +#define ISAR_SPLIT_REND_PITCH_G_MIN_VAL 0.5f +#define ISAR_SPLIT_REND_PITCH_G_MAX_VAL 1.5f +#define ISAR_SPLIT_REND_PITCH_G_QUANT_PNTS ISAR_SPLIT_REND_D_QUANT_PNTS +#define ISAR_SPLIT_REND_D_MIN_VAL 0.0f +#define ISAR_SPLIT_REND_D_MAX_VAL 1.0f #define ISAR_SPLIT_REND_PRED_ROLL_Q_STEP ( ( ISAR_SPLIT_REND_PRED_MAX_VAL - ISAR_SPLIT_REND_PRED_MIN_VAL ) / ( ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS - 1 ) ) #define ISAR_SPLIT_REND_PRED_ROLL_1BYQ_STEP ( ( ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS - 1 ) / ( ISAR_SPLIT_REND_PRED_MAX_VAL - ISAR_SPLIT_REND_PRED_MIN_VAL ) ) @@ -104,30 +104,30 @@ typedef enum #define ISAR_SPLIT_REND_PRED63_Q_STEP ( ( ISAR_SPLIT_REND_PRED_MAX_VAL - ISAR_SPLIT_REND_PRED_MIN_VAL ) / ( ISAR_SPLIT_REND_PRED_63QUANT_PNTS - 1 ) ) #define ISAR_SPLIT_REND_PRED63_1BYQ_STEP ( ( ISAR_SPLIT_REND_PRED_63QUANT_PNTS - 1 ) / ( ISAR_SPLIT_REND_PRED_MAX_VAL - ISAR_SPLIT_REND_PRED_MIN_VAL ) ) -#define ISAR_SPLIT_REND_D_Q_STEP ( ( ISAR_SPLIT_REND_D_MAX_VAL - ISAR_SPLIT_REND_D_MIN_VAL ) / ( ISAR_SPLIT_REND_D_QUANT_PNTS - 1 ) ) -#define ISAR_SPLIT_REND_D_1BYQ_STEP ( ( ISAR_SPLIT_REND_D_QUANT_PNTS - 1 ) / ( ISAR_SPLIT_REND_D_MAX_VAL - ISAR_SPLIT_REND_D_MIN_VAL ) ) -#define ISAR_SPLIT_REND_PITCH_G_Q_STEP ( ( ISAR_SPLIT_REND_PITCH_G_MAX_VAL - ISAR_SPLIT_REND_PITCH_G_MIN_VAL ) / ( ISAR_SPLIT_REND_PITCH_G_QUANT_PNTS - 1 ) ) -#define ISAR_SPLIT_REND_PITCH_G_1BYQ_STEP ( ( ISAR_SPLIT_REND_PITCH_G_QUANT_PNTS - 1 ) / ( ISAR_SPLIT_REND_PITCH_G_MAX_VAL - ISAR_SPLIT_REND_PITCH_G_MIN_VAL ) ) +#define ISAR_SPLIT_REND_D_Q_STEP ( ( ISAR_SPLIT_REND_D_MAX_VAL - ISAR_SPLIT_REND_D_MIN_VAL ) / ( ISAR_SPLIT_REND_D_QUANT_PNTS - 1 ) ) +#define ISAR_SPLIT_REND_D_1BYQ_STEP ( ( ISAR_SPLIT_REND_D_QUANT_PNTS - 1 ) / ( ISAR_SPLIT_REND_D_MAX_VAL - ISAR_SPLIT_REND_D_MIN_VAL ) ) +#define ISAR_SPLIT_REND_PITCH_G_Q_STEP ( ( ISAR_SPLIT_REND_PITCH_G_MAX_VAL - ISAR_SPLIT_REND_PITCH_G_MIN_VAL ) / ( ISAR_SPLIT_REND_PITCH_G_QUANT_PNTS - 1 ) ) +#define ISAR_SPLIT_REND_PITCH_G_1BYQ_STEP ( ( ISAR_SPLIT_REND_PITCH_G_QUANT_PNTS - 1 ) / ( ISAR_SPLIT_REND_PITCH_G_MAX_VAL - ISAR_SPLIT_REND_PITCH_G_MIN_VAL ) ) -#define ISAR_SPLIT_REND_HEAD_POSE_BITS 9 -#define ISAR_SPLIT_REND_DOF_BITS 2 -#define ISAR_SPLIT_REND_HQ_MODE_BITS 1 -#define ISAR_SPLIT_REND_ROT_AXIS_BITS 3 -#define ISAR_SPLIT_REND_RO_FLAG_BITS 1 +#define ISAR_SPLIT_REND_HEAD_POSE_BITS 9 +#define ISAR_SPLIT_REND_DOF_BITS 2 +#define ISAR_SPLIT_REND_HQ_MODE_BITS 1 +#define ISAR_SPLIT_REND_ROT_AXIS_BITS 3 +#define ISAR_SPLIT_REND_RO_FLAG_BITS 1 #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS -#define IVAS_LC3PLUS_MAX_NUM_DECODERS 2 +#define IVAS_LC3PLUS_MAX_NUM_DECODERS 2 #endif /*----------------------------------------------------------------------------------* * Split rendering bitrate constants *----------------------------------------------------------------------------------*/ -#define SPLIT_REND_256k 256000 -#define SPLIT_REND_320k 320000 -#define SPLIT_REND_384k 384000 -#define SPLIT_REND_512k 512000 -#define SPLIT_REND_768k 768000 /* == ISAR_MAX_SPLIT_REND_BITRATE */ +#define SPLIT_REND_256k 256000 +#define SPLIT_REND_320k 320000 +#define SPLIT_REND_384k 384000 +#define SPLIT_REND_512k 512000 +#define SPLIT_REND_768k 768000 /* == ISAR_MAX_SPLIT_REND_BITRATE */ #endif /*SPLIT_REND_WITH_HEAD_ROT */ diff --git a/lib_isar/isar_lc3plus_dec.c b/lib_isar/isar_lc3plus_dec.c index b926d7602e..b32d8f6e20 100644 --- a/lib_isar/isar_lc3plus_dec.c +++ b/lib_isar/isar_lc3plus_dec.c @@ -195,8 +195,8 @@ ivas_error ISAR_LC3PLUS_DEC_Open( ISAR_LC3PLUS_DEC_Close( handle ); return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); } -#endif +#endif ( *handle )->selective_decoding_states[iCh]->has_skipped_a_frame = 0; ( *handle )->selective_decoding_states[iCh]->shall_decode_cached_frame = 0; #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS diff --git a/lib_isar/isar_lc3plus_enc.c b/lib_isar/isar_lc3plus_enc.c index fbf60161ee..fdc5fbb446 100644 --- a/lib_isar/isar_lc3plus_enc.c +++ b/lib_isar/isar_lc3plus_enc.c @@ -234,6 +234,7 @@ ivas_error ISAR_LC3PLUS_ENC_Open( for ( uint32_t iEnc = 0; iEnc < ( *handle )->num_encs; ++iEnc ) { int32_t ftd_index = iEnc + iMediaTime * ( *handle )->num_encs; + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ( *handle )->frame_type_descriptors[ftd_index].frame_data_length = 0; /* will be set to the correct value in IVAS_LC3PLUS_ENC_SetBitrate */ #else diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index e06e7bd6f2..84c395d852 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -239,7 +239,6 @@ void isar_split_rend_get_quant_params( #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS const int16_t ro_flag, int16_t *num_quant_strats - #else int16_t *num_quant_strats, int16_t *num_complex_bands @@ -358,10 +357,11 @@ int32_t isar_get_lc3plus_bitrate( #endif #ifdef LC3PLUS_LEA_COMPAT_BITRATES_48_6 int32_t isar_get_lc3plus_bitrate( - const int32_t SplitRendBitRate, - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, - const int32_t nChannels, - const int32_t codecFrameDurationUs ); + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, /* i : ISAR pose correction mode */ + const int32_t nChannels, /* i : number of channels */ + const int32_t lc3plus_frame_duration_us /* i : ISAR frame length in us */ +); #endif ivas_error isar_split_rend_validate_config( diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 4805f8b3e9..21db185d3f 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -495,6 +495,7 @@ static void isar_split_rend_quant_md( { hMd->pred_mat_re[ch1][ch1] = hMd->pred_mat_re2[ch1]; } + hMd->pred_mat_re[1][0] = 0.0f; hMd->pred_mat_re[0][1] = 0.0f; @@ -572,12 +573,15 @@ static void isar_split_rend_quant_md( return; } + #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS -static void get_lr_gains( float cov_in[][BINAURAL_CHANNELS], - float cov_out[][BINAURAL_CHANNELS], - float gains[BINAURAL_CHANNELS] ) +static void get_lr_gains( + float cov_in[][BINAURAL_CHANNELS], + float cov_out[][BINAURAL_CHANNELS], + float gains[BINAURAL_CHANNELS] ) { int16_t i; + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) { gains[i] = cov_in[i][i]; @@ -591,10 +595,12 @@ static void get_lr_gains( float cov_in[][BINAURAL_CHANNELS], gains[i] = sqrtf( gains[i] ); } } + return; } #endif + static void ComputeCoeffs( float cov_ii_re[][BINAURAL_CHANNELS], float cov_ii_im[][BINAURAL_CHANNELS], @@ -617,6 +623,7 @@ static void ComputeCoeffs( if ( pose_type == PITCH_ONLY ) { float gd_tmp[BINAURAL_CHANNELS]; + #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS get_lr_gains( cov_ii_re, cov_oo_re, gd_tmp ); #else @@ -634,6 +641,7 @@ static void ComputeCoeffs( } } #endif + hMd->gd = gd_tmp[0]; hMd->gd2 = gd_tmp[1]; } @@ -642,8 +650,10 @@ static void ComputeCoeffs( if ( real_only ) { float gd_tmp[BINAURAL_CHANNELS]; + #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS get_lr_gains( cov_ii_re, cov_oo_re, gd_tmp ); + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) { hMd->pred_mat_re[i][i] = gd_tmp[i]; @@ -667,6 +677,7 @@ static void ComputeCoeffs( set_zero( hMd->pred_mat_im[i], BINAURAL_CHANNELS ); } #endif + hMd->pred_mat_re[1][0] = 0.0f; hMd->pred_mat_re[0][1] = 0.0f; } @@ -675,6 +686,7 @@ static void ComputeCoeffs( #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS get_lr_gains( cov_ii_re, cov_oo_re, hMd->pred_mat_re2 ); #endif + cov_norm_fact = GetNormFact( cov_ii_re, cov_ii_im, cov_io_re, cov_io_im, cov_oo_re ); /* normalize the covariance */ @@ -903,7 +915,6 @@ static void isar_SplitRenderer_code_md_base2( } } #else - for ( b = 0; b < pred_imag_bands_yaw; b++ ) { hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; @@ -936,6 +947,7 @@ static void isar_SplitRenderer_code_md_base2( } } #endif + for ( b = 0; b < d_bands_yaw; b++ ) { hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; @@ -1270,9 +1282,10 @@ static void isar_SplitRenderer_quant_code( const ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ const int16_t low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS - const int16_t ro_md_flag, + const int16_t ro_md_flag, /* i : real only metadata for yaw flag */ #endif - const int32_t target_md_bits ) + const int32_t target_md_bits /* i : ISAR MD bitrate */ +) { #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS int16_t q, num_subframes, sf_idx, pos_idx, b, num_quant_strats; @@ -1305,12 +1318,14 @@ static void isar_SplitRenderer_quant_code( ISAR_SPLIT_REND_BITStream_write_int32( pBits, pMultiBinPoseData->dof, ISAR_SPLIT_REND_DOF_BITS ); ISAR_SPLIT_REND_BITStream_write_int32( pBits, pMultiBinPoseData->hq_mode, ISAR_SPLIT_REND_HQ_MODE_BITS ); + #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS rot_axis_code = isar_renderSplitGetCodeFromRot_axis( pMultiBinPoseData->dof, pMultiBinPoseData->rot_axis, &num_bits ); if ( num_bits > 0 ) { ISAR_SPLIT_REND_BITStream_write_int32( pBits, (int32_t) rot_axis_code, num_bits ); } + ISAR_SPLIT_REND_BITStream_write_int32( pBits, (int32_t) ro_md_flag, ISAR_SPLIT_REND_RO_FLAG_BITS ); #else ISAR_SPLIT_REND_BITStream_write_int32( pBits, (int32_t) pMultiBinPoseData->rot_axis, ISAR_SPLIT_REND_ROT_AXIS_BITS ); @@ -1346,6 +1361,7 @@ static void isar_SplitRenderer_quant_code( pred_quant_pnts_yaw, pred_quantstep_yaw, pred_1byquantstep_yaw, d_bands_yaw, bands_pitch, pred_real_bands_roll, pred_imag_bands_roll, &num_quant_strats, &num_complex_bands ); #endif + quant_strat_bits = (int32_t) ceilf( log2f( num_quant_strats ) ); overhead_bits = pBits->bits_written - overhead_bits + quant_strat_bits + 1; /* 1 for base2 vs huff */ @@ -2246,6 +2262,7 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( #else available_bits = ( SplitRendBitRate / FRAMES_PER_SEC ) - pBits->bits_written; #endif + if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, available_bits, in ) ) != IVAS_ERR_OK ) #else if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, SplitRendBitRate, in ) ) != IVAS_ERR_OK ) diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c index 9982f702a9..15aa6cc267 100644 --- a/lib_isar/isar_splitRenderer_utils.c +++ b/lib_isar/isar_splitRenderer_utils.c @@ -552,6 +552,7 @@ int32_t isar_get_lcld_bitrate( return -1; } + #ifdef LC3PLUS_LEA_COMPAT_BITRATES_48_6 /*------------------------------------------------------------------------- * Function isar_get_lc3plus_bitrate() @@ -560,18 +561,22 @@ int32_t isar_get_lcld_bitrate( *------------------------------------------------------------------------*/ int32_t isar_get_lc3plus_bitrate( - const int32_t SplitRendBitRate, - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, - const int32_t nChannels, - const int32_t codecFrameDurationUs ) + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, /* i : ISAR pose correction mode */ + const int32_t nChannels, /* i : number of channels */ + const int32_t codecFrameDurationUs /* i : ISAR frame length in us */ +) { int32_t bitrate; + bitrate = isar_get_lcld_bitrate( SplitRendBitRate, poseCorrectionMode ); + /* Check for LC3plus LEA 48_6 LC3 compatibility mode signalling */ if ( ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE == poseCorrectionMode && bitrate == 256000 && nChannels == 2 && codecFrameDurationUs == 10000 ) { bitrate = 2 * 126000; } + return bitrate; } #endif @@ -929,6 +934,7 @@ void isar_split_rend_get_quant_params( return; } + #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS /*------------------------------------------------------------------------- * Function isar_renderSplitGetRot_axisNumBits() @@ -948,9 +954,11 @@ int16_t isar_renderSplitGetRot_axisNumBits( { num_bits = 0; } + return num_bits; } + /*------------------------------------------------------------------------- * Function isar_renderSplitGetRot_axisFromCode() * @@ -986,6 +994,7 @@ ISAR_SPLIT_REND_ROT_AXIS isar_renderSplitGetRot_axisFromCode( return rot_axis; } + /*------------------------------------------------------------------------- * Function isar_renderSplitGetCodeFromRot_axis() * @@ -998,6 +1007,7 @@ int16_t isar_renderSplitGetCodeFromRot_axis( int16_t *num_bits ) { int16_t code = 0; + if ( dof == 1 ) { code = (int16_t) rot_axis; @@ -1023,6 +1033,7 @@ int16_t isar_renderSplitGetCodeFromRot_axis( } #endif + /*------------------------------------------------------------------------- * Function isar_renderSplitGetMultiBinPoseData() * diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 87e7b16dc0..c0b5e06f6b 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -414,6 +414,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( #else available_bits = ( SplitRendBitRate / FRAMES_PER_SEC ) - pBits->bits_written; #endif + if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, available_bits, output ) ) != IVAS_ERR_OK ) #else if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, SplitRendBitRate, output ) ) != IVAS_ERR_OK ) -- GitLab From b5fac54f71b2542fc5ede81e15a6a0495b55c269 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 28 May 2024 09:46:51 +0200 Subject: [PATCH 12/26] address reviewer comments --- lib_isar/isar_lcld_decoder.c | 28 ++++++++++++++-------------- lib_isar/isar_lcld_prot.h | 2 +- lib_isar/isar_prot.h | 4 ++-- lib_isar/isar_splitRendererPost.c | 10 +++++----- lib_isar/isar_splitRendererPre.c | 8 ++++---- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index 499af0b783..d4dfd4f2de 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -769,19 +769,19 @@ static void InvQuantizeSpectrum( const int32_t iNumGroups, const int32_t *piGrou static void InvMSCoding( const int32_t iNumBlocks, const int32_t iNumBands, const int32_t *piBandwidths, const int32_t iMSMode, const int32_t *piMSFlags, const int32_t *piLRPhaseDiffs, const int32_t *piMSPredCoefs, float ***pppfReal, float ***pppfImag ); -static int32_t ReadHeaderInformation( int32_t *piNumBands, const ISAR_SPLIT_REND_BITS_HANDLE pBits ); +static int32_t ReadHeaderInformation( int32_t *piNumBands, ISAR_SPLIT_REND_BITS_HANDLE pBits ); -static int32_t ReadMSInformation( const int32_t iNumBands, int32_t *piMSMode, int32_t *piMSFlags, int32_t *piLRPhaseDiffs, int32_t *piMSPredCoefs, const ISAR_SPLIT_REND_BITS_HANDLE pBits ); +static int32_t ReadMSInformation( const int32_t iNumBands, int32_t *piMSMode, int32_t *piMSFlags, int32_t *piLRPhaseDiffs, int32_t *piMSPredCoefs, ISAR_SPLIT_REND_BITS_HANDLE pBits ); -static int32_t ReadGroupInformation( const int32_t iChannels, const int32_t iNumBlocks, int32_t *piCommonGrouping, int32_t *piNumGroups, int32_t **ppiGroupLengths, const ISAR_SPLIT_REND_BITS_HANDLE pBits ); +static int32_t ReadGroupInformation( const int32_t iChannels, const int32_t iNumBlocks, int32_t *piCommonGrouping, int32_t *piNumGroups, int32_t **ppiGroupLengths, ISAR_SPLIT_REND_BITS_HANDLE pBits ); -static int32_t ReadHuff( const uint32_t ( *pauiHuffDecTable )[HUFF_DEC_TABLE_SIZE], int32_t *piSymbol, const ISAR_SPLIT_REND_BITS_HANDLE pBits ); +static int32_t ReadHuff( const uint32_t ( *pauiHuffDecTable )[HUFF_DEC_TABLE_SIZE], int32_t *piSymbol, ISAR_SPLIT_REND_BITS_HANDLE pBits ); -static int32_t ReadRMSEnvelope( const int32_t iChannels, const int32_t *piNumGroups, const int32_t iNumBands, int32_t ***pppiRMSEnvelope, const ISAR_SPLIT_REND_BITS_HANDLE pBits ); +static int32_t ReadRMSEnvelope( const int32_t iChannels, const int32_t *piNumGroups, const int32_t iNumBands, int32_t ***pppiRMSEnvelope, ISAR_SPLIT_REND_BITS_HANDLE pBits ); static int32_t ReadAllocInformation( int32_t *piAllocOffset, const ISAR_SPLIT_REND_BITS_HANDLE pBits ); -static int32_t ReadLCLDData( const int32_t *piNumGroups, int32_t **ppiGroupLengths, const int32_t iNumBands, const int32_t iNumChannels, int32_t **ppiDecodingUnresolved, int32_t **ppiPredEnable, const int32_t iNumSubSets, const int32_t iSubSetId, int32_t ***pppiAlloc, int32_t ***pppiSignReal, int32_t ***pppiSignImag, int32_t ***pppiQReal, int32_t ***pppiQImag, int32_t **ppiDecodingFailed, const ISAR_SPLIT_REND_BITS_HANDLE pBits, uint32_t ( *c_apauiHuffDecTables[2 * ALLOC_TABLE_SIZE] )[HUFF_DEC_TABLE_SIZE] ); +static int32_t ReadLCLDData( const int32_t *piNumGroups, int32_t **ppiGroupLengths, const int32_t iNumBands, const int32_t iNumChannels, int32_t **ppiDecodingUnresolved, int32_t **ppiPredEnable, const int32_t iNumSubSets, const int32_t iSubSetId, int32_t ***pppiAlloc, int32_t ***pppiSignReal, int32_t ***pppiSignImag, int32_t ***pppiQReal, int32_t ***pppiQImag, int32_t **ppiDecodingFailed, ISAR_SPLIT_REND_BITS_HANDLE pBits, uint32_t ( *c_apauiHuffDecTables[2 * ALLOC_TABLE_SIZE] )[HUFF_DEC_TABLE_SIZE] ); static void ComputeAllocation( const int32_t iChannels, const int32_t *piNumGroups, const int32_t iNumBands, int32_t ***pppiSMR, const int32_t iAllocOffset, int32_t ***pppiAlloc ); @@ -943,7 +943,7 @@ static void UnpackReal( int32_t DecodeLCLDFrame( LCLDDecoder *psLCLDDecoder, - const ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i : ISAR bits handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ float ***pppfLCLDReal, float ***pppfLCLDImag ) { @@ -1305,7 +1305,7 @@ static void InvMSCoding( /* Currently only the number of bands in frame */ static int32_t ReadHeaderInformation( int32_t *piNumBands, - const ISAR_SPLIT_REND_BITS_HANDLE pBits ) + ISAR_SPLIT_REND_BITS_HANDLE pBits ) { int32_t iBitsRead; @@ -1323,7 +1323,7 @@ static int32_t ReadMSInformation( int32_t *piMSFlags, int32_t *piLRPhaseDiffs, int32_t *piMSPredCoefs, - const ISAR_SPLIT_REND_BITS_HANDLE pBits ) + ISAR_SPLIT_REND_BITS_HANDLE pBits ) { int32_t iBitsRead; @@ -1450,7 +1450,7 @@ static int32_t ReadGroupInformation( int32_t *piCommonGrouping, int32_t *piNumGroups, int32_t **ppiGroupLengths, - const ISAR_SPLIT_REND_BITS_HANDLE pBits ) + ISAR_SPLIT_REND_BITS_HANDLE pBits ) { int32_t c, k, iBitsRead; @@ -1561,7 +1561,7 @@ static int32_t BSForceBack( static int32_t ReadHuff( const uint32_t ( *pauiHuffDecTable )[HUFF_DEC_TABLE_SIZE], int32_t *piSymbol, - const ISAR_SPLIT_REND_BITS_HANDLE pBits ) + ISAR_SPLIT_REND_BITS_HANDLE pBits ) { int32_t iBitsRead; int32_t iSymbol; @@ -1600,7 +1600,7 @@ static int32_t ReadRMSEnvelope( const int32_t *piNumGroups, const int32_t iNumBands, int32_t ***pppiRMSEnvelope, - const ISAR_SPLIT_REND_BITS_HANDLE pBits ) + ISAR_SPLIT_REND_BITS_HANDLE pBits ) { int32_t b, k, n; int32_t iBitsRead, iLastRMSVal; @@ -1634,7 +1634,7 @@ static int32_t ReadRMSEnvelope( static int32_t ReadAllocInformation( int32_t *piAllocOffset, - const ISAR_SPLIT_REND_BITS_HANDLE pBits ) + ISAR_SPLIT_REND_BITS_HANDLE pBits ) { int32_t iBitsRead; @@ -1662,7 +1662,7 @@ static int32_t ReadLCLDData( int32_t ***pppiQReal, int32_t ***pppiQImag, int32_t **ppiDecodingFailed, - const ISAR_SPLIT_REND_BITS_HANDLE pBits, + ISAR_SPLIT_REND_BITS_HANDLE pBits, uint32_t ( *c_apauiHuffDecTables[2 * ALLOC_TABLE_SIZE] )[HUFF_DEC_TABLE_SIZE] ) { int32_t iBitsRead; diff --git a/lib_isar/isar_lcld_prot.h b/lib_isar/isar_lcld_prot.h index ac7e76656c..dd269b9a43 100644 --- a/lib_isar/isar_lcld_prot.h +++ b/lib_isar/isar_lcld_prot.h @@ -81,7 +81,7 @@ void DeleteLCLDDecoder( int32_t DecodeLCLDFrame( LCLDDecoder *psLCLDDecoder, - const ISAR_SPLIT_REND_BITS_HANDLE pBits, + ISAR_SPLIT_REND_BITS_HANDLE pBits, float ***pppfLCLDReal, float ***pppfLCLDImag ); diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index 84c395d852..cce9764aee 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -246,7 +246,7 @@ void isar_split_rend_get_quant_params( ); void isar_splitBinPostRendMdDec( - const ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i : ISAR bits handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG @@ -287,7 +287,7 @@ void isar_rend_CldfbSplitPreRendProcess( MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, real part */ float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, imag. part */ - const ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i : ISAR bits handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ const int32_t target_md_bits, /* i : ISAR MD bitrate */ const int16_t low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ const int16_t ro_md_flag /* i : real only metadata for yaw flag */ diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index 3fe3c36895..375868aa2e 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -181,7 +181,7 @@ void isar_splitBinPostRendClose( static int16_t isar_split_rend_huffman_decode_opt( isar_split_rend_huffman_cfg_t *huff_cfg, - const ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i : ISAR bits handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ const int16_t *idx_trav_list ) { int32_t i, ind, code, num_bits, code_b, num_bits_read; @@ -523,8 +523,8 @@ static void isar_splitBinPostRendMdBase2Dec( *-----------------------------------------------------------------------------------------*/ static void isar_splitBinPostRendMdHuffDec( - const ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i : ISAR bits handle */ - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const int16_t num_subframes, const int16_t pred_real_bands_yaw, @@ -718,8 +718,8 @@ static void isar_splitBinPostRendMdHuffDec( *-----------------------------------------------------------------------------------------*/ void isar_splitBinPostRendMdDec( - const ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i : ISAR bits handle */ - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG , diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 21db185d3f..dbb25e7214 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -850,7 +850,7 @@ static void isar_SplitRenderer_code_md_base2( const int16_t bands_pitch, const int16_t pred_real_bands_roll, const int16_t pred_imag_bands_roll, - const ISAR_SPLIT_REND_BITS_HANDLE pBits /* i/o: ISAR bits handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits /* i/o: ISAR bits handle */ ) { int16_t pos_idx, b, ch1, ch2, sf_idx; @@ -1065,7 +1065,7 @@ static void isar_SplitRenderer_code_md_huff( const int16_t bands_pitch, const int16_t pred_real_bands_roll, const int16_t pred_imag_bands_roll, - const ISAR_SPLIT_REND_BITS_HANDLE pBits /* i/o: ISAR bits handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits /* i/o: ISAR bits handle */ ) { int16_t pos_idx, b, ch1, ch2, sf_idx, num_poses; @@ -1279,7 +1279,7 @@ static void isar_SplitRenderer_quant_code( const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i : binaural pre-renderer handle */ const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ - const ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ const int16_t low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS const int16_t ro_md_flag, /* i : real only metadata for yaw flag */ @@ -1639,7 +1639,7 @@ void isar_rend_CldfbSplitPreRendProcess( MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, real part */ float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, imag. part */ - const ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i : ISAR bits handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ const int32_t target_md_bits, /* i : ISAR MD bitrate */ const int16_t low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ const int16_t ro_md_flag /* i : real only metadata for yaw flag */ -- GitLab From f3df19d15c53345a22817dd6aa2070c171e08ffd Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 28 May 2024 09:59:15 +0200 Subject: [PATCH 13/26] move ISAR init./reconfig. functions from ivas_init_dec.c to lib_dec.c + remove ISAR includes from ivas_init_dec.c --- lib_dec/ivas_init_dec.c | 215 ---------------------------------------- lib_dec/lib_dec.c | 208 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 208 insertions(+), 215 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 1f68efafed..94bddfd120 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -37,11 +37,6 @@ #include "ivas_rom_com.h" #include "ivas_stat_enc.h" #include "prot.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT -#include "lib_isar_pre_rend.h" -#include "isar_prot.h" -#include "isar_stat.h" -#endif #include #include #include @@ -63,187 +58,6 @@ static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas ); static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const int16_t sba_order ); #endif -#ifdef SPLIT_REND_WITH_HEAD_ROT -static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas ); - - -/*-------------------------------------------------------------------* - * ivas_dec_reconfig_split_rend() - * - * IVAS decoder split rend reconfig - *-------------------------------------------------------------------*/ - -static ivas_error ivas_dec_reconfig_split_rend( - Decoder_Struct *st_ivas /* i : IVAS decoder structure */ -) -{ - ivas_error error; - int16_t cldfb_in_flag, num_ch, ch, isCldfbNeeded, i, pcm_out_flag; - SPLIT_REND_WRAPPER *hSplitRendWrapper; - - hSplitRendWrapper = &st_ivas->hSplitBinRend->splitrend; - pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; - cldfb_in_flag = 0; - - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || - st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) - { - cldfb_in_flag = 1; - } - - ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &hSplitRendWrapper->multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); - - isCldfbNeeded = 0; - - if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) || - ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) - { - cldfb_in_flag = 0; - } - - if ( st_ivas->renderer_type != RENDERER_DISABLE ) - { - if ( cldfb_in_flag == 0 ) - { - isCldfbNeeded = 1; - } - else if ( st_ivas->hRenderConfig->split_rend_config.codec == ISAR_SPLIT_REND_CODEC_LC3PLUS && cldfb_in_flag ) - { - isCldfbNeeded = 1; - } - else if ( pcm_out_flag && cldfb_in_flag ) - { - isCldfbNeeded = 1; - } - } - else if ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) - { - isCldfbNeeded = 1; - } - - if ( isCldfbNeeded == 1 && hSplitRendWrapper->hCldfbHandles == NULL ) - { - if ( ( hSplitRendWrapper->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) ); - } - - num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; - for ( ch = 0; ch < num_ch; ch++ ) - { - hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; - } - - num_ch = hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; - - for ( ch = 0; ch < num_ch; ch++ ) - { - if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not open CLDFB handles\n" ) ); - } - } - - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - else if ( isCldfbNeeded == 0 && hSplitRendWrapper->hCldfbHandles != NULL ) - { - num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; - for ( ch = 0; ch < num_ch; ch++ ) - { - if ( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] != NULL ) - { - deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ); - hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; - } - } - - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - if ( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] != NULL ) - { - deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ); - hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] = NULL; - } - } - - free( hSplitRendWrapper->hCldfbHandles ); - hSplitRendWrapper->hCldfbHandles = NULL; - } - - if ( ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) && - ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV || st_ivas->ivas_format != SBA_ISM_FORMAT ) && - !( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) /* td-rend not needed? */ - { - for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) - { - if ( st_ivas->hTdRendHandles[i] != NULL ) - { - st_ivas->hTdRendHandles[i]->HrFiltSet_p = NULL; - ivas_td_binaural_close( &st_ivas->hTdRendHandles[i] ); - } - } - } - - return IVAS_ERR_OK; -} - - -/*-------------------------------------------------------------------* - * ivas_dec_init_split_rend() - * - * IVAS decoder split rend init - *-------------------------------------------------------------------*/ - -static ivas_error ivas_dec_init_split_rend( - Decoder_Struct *st_ivas /* i : IVAS decoder structure */ -) -{ - ivas_error error; - int16_t cldfb_in_flag, pcm_out_flag; - int16_t mixed_td_cldfb_flag; - - pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; - cldfb_in_flag = 0; - - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || - st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) - { - cldfb_in_flag = 1; - } - - ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); - - if ( cldfb_in_flag == 1 && ( 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 ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for cldfb data out buffer\n" ) ); - } - } - - mixed_td_cldfb_flag = 0; - if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) || - ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) - { - mixed_td_cldfb_flag = 1; - } - - error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, (int16_t) st_ivas->hDecoderConfig->render_framesize, mixed_td_cldfb_flag ); - - return error; -} -#endif #ifdef NONBE_FIX_1052_SBA_EXT static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const int16_t sba_order ) @@ -750,20 +564,6 @@ ivas_error ivas_dec_setup( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT - /*-----------------------------------------------------------------* - * reconfig split rendering as renderer might change after bitrate switching - *-----------------------------------------------------------------*/ - - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) - { - if ( ( error = ivas_dec_reconfig_split_rend( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } -#endif - /*----------------------------------------------------------------* * Reset bitstream pointers *----------------------------------------------------------------*/ @@ -1334,21 +1134,6 @@ ivas_error ivas_init_decoder( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT - /*-----------------------------------------------------------------* - * Initialize binaural split rendering - *-----------------------------------------------------------------*/ - - if ( st_ivas->hSplitBinRend != NULL && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || - ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) ) - { - if ( ( error = ivas_dec_init_split_rend( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } -#endif - /*-----------------------------------------------------------------* * Allocate and initialize SCE/CPE and other handles *-----------------------------------------------------------------*/ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index b75d98409e..8543dd1be7 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -128,6 +128,8 @@ static PCM_RESOLUTION pcm_type_API_to_internal( const IVAS_DEC_PCM_TYPE pcmType static void *pcm_buffer_offset( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, const int32_t offset ); static ivas_error set_pcm_buffer_to_zero( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, const int16_t nZeroSamples ); static ivas_error isar_set_split_rend_setup( ISAR_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, const ISAR_SPLIT_REND_CONFIG_DATA *hSplitBinConfig, const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, ISAR_SPLIT_REND_BITS_DATA *splitRendBits ); +static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas ); +static ivas_error ivas_dec_init_split_rend( Decoder_Struct *st_ivas ); static ivas_error ivas_create_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out ); static void ivas_destroy_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out ); #endif @@ -1346,6 +1348,34 @@ static ivas_error IVAS_DEC_Setup( *nTransportChannels = (uint8_t) st_ivas->hTcBuffer->nchan_transport_jbm; *nTcBufferGranularity = (uint16_t) st_ivas->hTcBuffer->n_samples_granularity; *nOutChannels = (uint8_t) st_ivas->hDecoderConfig->nchan_out; + + +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*-----------------------------------------------------------------* + * ISAR: + * - initialize ISAR handle at the first frame + * - reconfigure the ISAR handle in case of bitrate switching (renderer might change) + *-----------------------------------------------------------------*/ + + if ( st_ivas->ini_frame == 0 && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || + st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || + ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) ) + { + if ( ( error = ivas_dec_init_split_rend( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( ( error = ivas_dec_reconfig_split_rend( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + +#endif } return IVAS_ERR_OK; @@ -4094,6 +4124,184 @@ int16_t IVAS_DEC_is_split_rendering_enabled( } +/*-------------------------------------------------------------------* + * ivas_dec_reconfig_split_rend() + * + * IVAS decoder split rend reconfig + *-------------------------------------------------------------------*/ + +static ivas_error ivas_dec_reconfig_split_rend( + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ +) +{ + ivas_error error; + int16_t cldfb_in_flag, num_ch, ch, isCldfbNeeded, i, pcm_out_flag; + SPLIT_REND_WRAPPER *hSplitRendWrapper; + + hSplitRendWrapper = &st_ivas->hSplitBinRend->splitrend; + pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + cldfb_in_flag = 0; + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + cldfb_in_flag = 1; + } + + ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &hSplitRendWrapper->multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); + + isCldfbNeeded = 0; + + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) || + ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + { + cldfb_in_flag = 0; + } + + if ( st_ivas->renderer_type != RENDERER_DISABLE ) + { + if ( cldfb_in_flag == 0 ) + { + isCldfbNeeded = 1; + } + else if ( st_ivas->hRenderConfig->split_rend_config.codec == ISAR_SPLIT_REND_CODEC_LC3PLUS && cldfb_in_flag ) + { + isCldfbNeeded = 1; + } + else if ( pcm_out_flag && cldfb_in_flag ) + { + isCldfbNeeded = 1; + } + } + else if ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) + { + isCldfbNeeded = 1; + } + + if ( isCldfbNeeded == 1 && hSplitRendWrapper->hCldfbHandles == NULL ) + { + if ( ( hSplitRendWrapper->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) ); + } + + num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; + for ( ch = 0; ch < num_ch; ch++ ) + { + hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; + } + + num_ch = hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; + + for ( ch = 0; ch < num_ch; ch++ ) + { + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not open CLDFB handles\n" ) ); + } + } + + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + else if ( isCldfbNeeded == 0 && hSplitRendWrapper->hCldfbHandles != NULL ) + { + num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; + for ( ch = 0; ch < num_ch; ch++ ) + { + if ( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] != NULL ) + { + deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ); + hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; + } + } + + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + if ( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] != NULL ) + { + deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ); + hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] = NULL; + } + } + + free( hSplitRendWrapper->hCldfbHandles ); + hSplitRendWrapper->hCldfbHandles = NULL; + } + + if ( ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) && + ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV || st_ivas->ivas_format != SBA_ISM_FORMAT ) && + !( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) /* td-rend not needed? */ + { + for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) + { + if ( st_ivas->hTdRendHandles[i] != NULL ) + { + st_ivas->hTdRendHandles[i]->HrFiltSet_p = NULL; + ivas_td_binaural_close( &st_ivas->hTdRendHandles[i] ); + } + } + } + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * ivas_dec_init_split_rend() + * + * IVAS decoder split rend init + *-------------------------------------------------------------------*/ + +static ivas_error ivas_dec_init_split_rend( + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ +) +{ + ivas_error error; + int16_t cldfb_in_flag, pcm_out_flag; + int16_t mixed_td_cldfb_flag; + + pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + cldfb_in_flag = 0; + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + cldfb_in_flag = 1; + } + + ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); + + if ( cldfb_in_flag == 1 && ( 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 ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for cldfb data out buffer\n" ) ); + } + } + + mixed_td_cldfb_flag = 0; + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) || + ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + { + mixed_td_cldfb_flag = 1; + } + + error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, (int16_t) st_ivas->hDecoderConfig->render_framesize, mixed_td_cldfb_flag ); + + return error; +} + + /*---------------------------------------------------------------------* * IVAS_DEC_is_split_rendering_coded_out() * -- GitLab From 6144f017826b566908613778dcf048bde5a38841 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 28 May 2024 10:07:30 +0200 Subject: [PATCH 14/26] clang-format + formatting --- lib_isar/isar_lcld_decoder.c | 18 ++++++++++++++---- lib_isar/isar_lcld_encoder.c | 15 +++++++++++---- lib_rend/lib_rend.c | 2 +- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index d4dfd4f2de..a9a6257e5c 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -752,6 +752,8 @@ void DeleteLCLDDecoder( free( psLCLDDecoder ); } + + return; } @@ -779,7 +781,7 @@ static int32_t ReadHuff( const uint32_t ( *pauiHuffDecTable )[HUFF_DEC_TABLE_SIZ static int32_t ReadRMSEnvelope( const int32_t iChannels, const int32_t *piNumGroups, const int32_t iNumBands, int32_t ***pppiRMSEnvelope, ISAR_SPLIT_REND_BITS_HANDLE pBits ); -static int32_t ReadAllocInformation( int32_t *piAllocOffset, const ISAR_SPLIT_REND_BITS_HANDLE pBits ); +static int32_t ReadAllocInformation( int32_t *piAllocOffset, ISAR_SPLIT_REND_BITS_HANDLE pBits ); static int32_t ReadLCLDData( const int32_t *piNumGroups, int32_t **ppiGroupLengths, const int32_t iNumBands, const int32_t iNumChannels, int32_t **ppiDecodingUnresolved, int32_t **ppiPredEnable, const int32_t iNumSubSets, const int32_t iSubSetId, int32_t ***pppiAlloc, int32_t ***pppiSignReal, int32_t ***pppiSignImag, int32_t ***pppiQReal, int32_t ***pppiQImag, int32_t **ppiDecodingFailed, ISAR_SPLIT_REND_BITS_HANDLE pBits, uint32_t ( *c_apauiHuffDecTables[2 * ALLOC_TABLE_SIZE] )[HUFF_DEC_TABLE_SIZE] ); @@ -871,7 +873,8 @@ int16_t AnyDecodingFailed( * *------------------------------------------------------------------------------------------*/ -int32_t **GetDecodingFailedStatus( LCLDDecoder *psLCLDDecoder ) +int32_t **GetDecodingFailedStatus( + LCLDDecoder *psLCLDDecoder ) { return psLCLDDecoder->psPredictionDecoder->ppiDecodingFailed; } @@ -883,7 +886,8 @@ int32_t **GetDecodingFailedStatus( LCLDDecoder *psLCLDDecoder ) * *------------------------------------------------------------------------------------------*/ -int16_t GetNumSubSets( LCLDDecoder *psLCLDDecoder ) +int16_t GetNumSubSets( + LCLDDecoder *psLCLDDecoder ) { return (int16_t) psLCLDDecoder->psPredictionDecoder->iNumSubSets; } @@ -895,7 +899,8 @@ int16_t GetNumSubSets( LCLDDecoder *psLCLDDecoder ) * *------------------------------------------------------------------------------------------*/ -int32_t **GetDecodingFailedPrevStatus( LCLDDecoder *psLCLDDecoder ) +int32_t **GetDecodingFailedPrevStatus( + LCLDDecoder *psLCLDDecoder ) { return psLCLDDecoder->psPredictionDecoder->ppiDecodingFailedPrev; } @@ -1254,6 +1259,7 @@ static void InvMSCoding( int32_t n; int32_t phaseIdx; float fPred; + phaseIdx = piLRPhaseDiffs[bMSPred] - PHASE_MIN_VAL; fPred = dequantPred( piMSPredCoefs[bMSPred] ); for ( n = 0; n < piBandwidths[b]; n++ ) @@ -1384,7 +1390,9 @@ static int32_t ReadMSInformation( } } } + anyNonZero = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + if ( anyNonZero ) { piLRPhaseDiffs[0] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, PHASE_BAND0_BITS ); @@ -1405,7 +1413,9 @@ static int32_t ReadMSInformation( piLRPhaseDiffs[n] = 0; } } + anyNonZero = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + if ( anyNonZero ) { piMSPredCoefs[0] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, PRED_BAND0_BITS ); diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c index 07fd9d86a0..a24e11b691 100644 --- a/lib_isar/isar_lcld_encoder.c +++ b/lib_isar/isar_lcld_encoder.c @@ -80,7 +80,6 @@ struct LCLD_ENCODER int32_t ***pppiQLCLDReal; int32_t ***pppiQLCLDImag; - PredictionEncoder *psPredictionEncoder; }; @@ -98,6 +97,7 @@ static int32_t Quantize( const int32_t iMaxVal ) { int32_t iVal; + if ( fVal > 0.0f ) { iVal = (int32_t) ( fScale * fVal + 0.5f ); @@ -126,6 +126,7 @@ static float UnQuantize( const int32_t iSign ) { float fVal; + if ( iSign == 0 ) { fVal = fScale * (float) iVal; @@ -146,6 +147,7 @@ static void PackReal( float ***pppfImag ) { int32_t ch, b, n; + for ( ch = 0; ch < iChannels; ch++ ) { for ( b = 0; b < LCLD_BANDS; b++ ) @@ -214,6 +216,7 @@ ivas_error CreateLCLDEncoder( psLCLDEncoder->iNumBlocks = iNumBlocks; } psLCLDEncoder->iMSMode = 0; + if ( ( psLCLDEncoder->piMSFlags = (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); @@ -420,6 +423,7 @@ void DeleteLCLDEncoder( } free( psLCLDEncoder->ppiGroupLengths ); } + if ( psLCLDEncoder->pppiRMSEnvelope != NULL ) { for ( n = 0; n < psLCLDEncoder->iChannels; n++ ) @@ -571,7 +575,7 @@ int32_t EncodeLCLDFrame( const int32_t available_bits, ISAR_SPLIT_REND_BITS_HANDLE pBits ) { - int32_t n; + int32_t k, n; int32_t iAvailableBits, iBitsWritten; int32_t iNumMSBands = 0; int32_t iAudioBitsWritten; @@ -675,7 +679,6 @@ int32_t EncodeLCLDFrame( if ( psLCLDEncoder->iChannels == 2 && psLCLDEncoder->iCommonGrouping == 1 ) { - int32_t k; for ( k = 0; k < psLCLDEncoder->piNumGroups[0]; k++ ) { PerceptualModelStereo( psLCLDEncoder->iNumBands, @@ -692,7 +695,6 @@ int32_t EncodeLCLDFrame( { for ( n = 0; n < psLCLDEncoder->iChannels; n++ ) { - int32_t k; for ( k = 0; k < psLCLDEncoder->piNumGroups[n]; k++ ) { PerceptualModel( psLCLDEncoder->iNumBands, @@ -1040,6 +1042,7 @@ static int32_t MSModeCalculation( fprintf( fid, "%d %d %d %d %d\n", iMsInfoBits, piMsPredInfoBits[MS_PHASE_AND_PRED], piMsPredInfoBits[MS_PRED_ONLY], piMsPredInfoBits[MS_PHASE_ONLY], iActualInfoBits ); } #endif + if ( *piMSMode != MS_OFF ) { iFBOffset = 0; @@ -1306,8 +1309,10 @@ static int32_t CountLCLDBits( { const uint16_t( *pauiHuffmanTable )[2] = NULL; const uint16_t( *pauiHuffmanTableDPCM )[2] = NULL; + pauiHuffmanTable = c_apauiHuffEncTabels[iAlloc]; pauiHuffmanTableDPCM = c_apauiHuffEncTabels[ALLOC_TABLE_SIZE + iAlloc]; + for ( m = 0; m < piBandwidths[b]; m++ ) { int32_t iQuantValue1; @@ -1394,6 +1399,7 @@ static int32_t WriteMSInformation( #ifdef DEBUG_WRITE_MS_PRED int32_t iBitsWrittenTmp = 0; #endif + iBitsWritten = 0; ISAR_SPLIT_REND_BITStream_write_int32( pBits, iMSMode, 2 ); iBitsWritten += 2; @@ -1625,6 +1631,7 @@ static int32_t WriteAllocInformation( return iBitsWritten; } + static int32_t WriteLCLDData( const int32_t *piNumGroups, int32_t **ppiGroupLengths, diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 1bff325302..8ce44b42b5 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -7850,7 +7850,7 @@ static ivas_error getSamplesInternal( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, -- GitLab From 5e0db641eb83bda8f12603743c0fde4067700092 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 28 May 2024 16:48:47 +0200 Subject: [PATCH 15/26] introduce function is_split_rendering_enabled() and correct return values for IVAS_DEC_is_split_rendering_enabled() and IVAS_DEC_is_split_rendering_coded_out() --- apps/decoder.c | 42 ++++++++++++++++++++++++++++++------- lib_dec/ivas_jbm_dec.c | 7 +++---- lib_dec/lib_dec.c | 41 ++++++++++++++++++------------------ lib_dec/lib_dec.h | 14 +++++++------ lib_rend/ivas_output_init.c | 26 +++++++++++++++++++++++ lib_rend/ivas_prot_rend.h | 8 +++++++ 6 files changed, 100 insertions(+), 38 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 2531628358..f3df9118e0 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1942,6 +1942,9 @@ static ivas_error initOnFirstGoodFrame( #endif ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t isSplitRend, isSplitCoded; +#endif ivas_error error = IVAS_ERR_UNKNOWN; /* Now delay, number of output channels and frame size are known */ @@ -1952,7 +1955,19 @@ static ivas_error initOnFirstGoodFrame( } #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) ) + if ( ( error = IVAS_DEC_is_split_rendering_enabled( hIvasDec, &isSplitRend ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_enabled, code: %d\n", error ); + return error; + } + + if ( ( error = IVAS_DEC_is_split_rendering_coded_out( hIvasDec, &isSplitCoded ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_coded_out, code: %d\n", error ); + return error; + } + + if ( isSplitRend ) { pFullDelayNumSamples[0] = 0; } @@ -1979,7 +1994,7 @@ static ivas_error initOnFirstGoodFrame( } #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) ) + if ( isSplitRend ) { /* Open split rendering metadata writer */ int16_t delayNumSamples_temp[3]; @@ -2008,7 +2023,7 @@ static ivas_error initOnFirstGoodFrame( return error; } - if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) ) + if ( isSplitCoded ) { #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( ( error = split_rend_writer_open( splitRendWriter, arg.outputWavFilename, delayNumSamples_temp[0], delayTimeScale_temp, splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs, splitRendIsarFrameSizeMs, arg.output_Fs, lc3plusHighRes ) ) != IVAS_ERR_OK ) @@ -2040,7 +2055,7 @@ static ivas_error initOnFirstGoodFrame( } } - if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) == 0 ) + if ( !isSplitCoded ) { #endif /* Open audio writer and write all previously skipped bad frames now that frame size is known */ @@ -2278,6 +2293,19 @@ static ivas_error decodeG192( int16_t vec_pos_update, vec_pos_len; #ifdef SPLIT_REND_WITH_HEAD_ROT SplitFileReadWrite *splitRendWriter = NULL; + int16_t isSplitRend, isSplitCoded; + + if ( ( error = IVAS_DEC_is_split_rendering_enabled( hIvasDec, &isSplitRend ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_enabled, code: %d\n", error ); + return error; + } + + if ( ( error = IVAS_DEC_is_split_rendering_coded_out( hIvasDec, &isSplitCoded ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_coded_out, code: %d\n", error ); + return error; + } #endif #ifdef FIX_1053_REVERB_RECONFIGURATION @@ -2601,7 +2629,7 @@ static ivas_error decodeG192( } #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) ) + if ( isSplitRend ) { if ( ( error = IVAS_DEC_GetSplitBinauralBitstream( hIvasDec, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), splitRendBits, &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) { @@ -2681,7 +2709,7 @@ static ivas_error decodeG192( if ( decodedGoodFrame ) { #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) ) + if ( isSplitRend ) { if ( split_rend_write_bitstream_to_file( splitRendWriter, splitRendBits->bits_buf, &splitRendBits->bits_read, &splitRendBits->bits_written ) != IVAS_ERR_OK ) { @@ -2690,7 +2718,7 @@ static ivas_error decodeG192( } } - if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) == 0 ) + if ( !isSplitCoded ) { #endif if ( delayNumSamples < nOutSamples ) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 6da22b15f1..235aeb9156 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1827,12 +1827,11 @@ ivas_error ivas_jbm_dec_flush_renderer( #ifdef DEBUGGING st_ivas->noClipping += #endif - ivas_syn_output( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, #ifdef SPLIT_REND_WITH_HEAD_ROT - (int16_t *) + ivas_syn_output( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) data ); +#else + ivas_syn_output( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, data ); #endif - data ); - #ifdef SPLIT_REND_WITH_HEAD_ROT break; case PCM_FLOAT32: diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 8543dd1be7..19ddc360a3 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1147,7 +1147,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( numSamplesPerChannelToDecode *= (int16_t) st_ivas->hDecoderConfig->render_framesize; } - if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) == 0 ) + if ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig->split_rend_config.dof ) == 0 ) { return IVAS_ERR_WRONG_PARAMS; } @@ -3540,6 +3540,7 @@ static ivas_error evs_dec_main( st_ivas->noClipping += #endif ivas_syn_output( p_output, nOutSamples, st_ivas->hDecoderConfig->nchan_out, pcm_buf_local ); + mvs2r( pcm_buf_local, floatBuf, nOutSamples * st_ivas->hDecoderConfig->nchan_out ); } else @@ -4099,28 +4100,24 @@ static void ivas_destroy_handle_isar( * *---------------------------------------------------------------------*/ -/*! r: flag to indicate if split rendering is enabled */ -int16_t IVAS_DEC_is_split_rendering_enabled( - IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +/*! r: decoder error code */ +ivas_error IVAS_DEC_is_split_rendering_enabled( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *isSplitRend /* o : flag to indicate if split rendering is enabled */ ) { Decoder_Struct *st_ivas; - int16_t isSplitRend; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + st_ivas = hIvasDec->st_ivas; - isSplitRend = 0; - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || - ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) - { - isSplitRend = 1; - } + *isSplitRend = is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig->split_rend_config.dof ); - return isSplitRend; + return IVAS_ERR_OK; } @@ -4308,27 +4305,29 @@ static ivas_error ivas_dec_init_split_rend( * *---------------------------------------------------------------------*/ -/*! r: flag to indicate if split rendering coded output is enabled */ -int16_t IVAS_DEC_is_split_rendering_coded_out( - IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +/*! r: decoder error code */ +ivas_error IVAS_DEC_is_split_rendering_coded_out( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *isSplitCoded /* o : flag to indicate if split rendering is enabled */ ) { Decoder_Struct *st_ivas; - int16_t isSplitCoded; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + st_ivas = hIvasDec->st_ivas; - isSplitCoded = 0; + + *isSplitCoded = 0; if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) { - isSplitCoded = 1; + *isSplitCoded = 1; } - return isSplitCoded; + return IVAS_ERR_OK; } #endif diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 639ce8e658..6a0589e897 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -200,14 +200,16 @@ ivas_error IVAS_DEC_GetCldfbSamples( int16_t *nOutSamples /* o : number of samples per channel written to output buffer */ ); -/*! r: flag to indicate if split rendering is enabled */ -int16_t IVAS_DEC_is_split_rendering_enabled( - IVAS_DEC_HANDLE hIvasDec /* i : IVAS decoder handle */ +/*! r: decoder error code */ +ivas_error IVAS_DEC_is_split_rendering_enabled( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *isSplitRend /* o : flag to indicate if split rendering is enabled */ ); -/*! r: flag to indicate if split rendering coded output is enabled */ -int16_t IVAS_DEC_is_split_rendering_coded_out( - IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +/*! r: decoder error code */ +ivas_error IVAS_DEC_is_split_rendering_coded_out( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *isSplitCoded /* o : flag to indicate if split rendering is enabled */ ); #endif diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 81cf8fc884..e3515f801a 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -466,3 +466,29 @@ ivas_error ivas_output_buff_dec( return IVAS_ERR_OK; } + + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*---------------------------------------------------------------------* + * is_split_rendering_enabled() + * + * + *---------------------------------------------------------------------*/ + +/*! r: flag to indicate if split rendering is enabled */ +int16_t is_split_rendering_enabled( + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ + const int16_t dof /* i : flag to specify if pose correction is needed */ +) +{ + if ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || + ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && hDecoderConfig->Opt_non_diegetic_pan && dof == 0 ) ) + { + return 1; + } + else + { + return 0; + } +} +#endif diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index ac34b2a4e9..215a0ededc 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -77,6 +77,14 @@ int16_t ivas_get_nchan_buffers_dec( const int32_t ivas_total_brate /* i : total IVAS bitrate */ ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*! r: flag to indicate if split rendering is enabled */ +int16_t is_split_rendering_enabled( + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ + const int16_t dof /* i : flag to specify if pose correction is needed */ +); +#endif + /*----------------------------------------------------------------------------------* * TD decorr. function prototypes -- GitLab From 3e953f54f966525790c145f82aaf9817f0d8c753 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 28 May 2024 18:26:24 +0200 Subject: [PATCH 16/26] clang-format --- lib_rend/ivas_output_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index e3515f801a..a914ad225a 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -472,7 +472,7 @@ ivas_error ivas_output_buff_dec( /*---------------------------------------------------------------------* * is_split_rendering_enabled() * - * + * *---------------------------------------------------------------------*/ /*! r: flag to indicate if split rendering is enabled */ -- GitLab From 7e98df3d5752427b9ba06d92e5c8e708e94405a0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 28 May 2024 19:39:32 +0200 Subject: [PATCH 17/26] re revert check against NULL --- lib_dec/lib_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 19ddc360a3..0ff7be1c7d 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -4108,7 +4108,7 @@ ivas_error IVAS_DEC_is_split_rendering_enabled( { Decoder_Struct *st_ivas; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL ) + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } @@ -4313,7 +4313,7 @@ ivas_error IVAS_DEC_is_split_rendering_coded_out( { Decoder_Struct *st_ivas; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL ) + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -- GitLab From 4a71486cef7752200f10ada09a0214129715c26d Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 28 May 2024 22:42:37 +0200 Subject: [PATCH 18/26] fix is_split_rendering_enabled() --- lib_dec/lib_dec.c | 4 ++-- lib_rend/ivas_output_init.c | 6 +++--- lib_rend/ivas_prot_rend.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 0ff7be1c7d..65e0ce23c2 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1147,7 +1147,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( numSamplesPerChannelToDecode *= (int16_t) st_ivas->hDecoderConfig->render_framesize; } - if ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig->split_rend_config.dof ) == 0 ) + if ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) { return IVAS_ERR_WRONG_PARAMS; } @@ -4115,7 +4115,7 @@ ivas_error IVAS_DEC_is_split_rendering_enabled( st_ivas = hIvasDec->st_ivas; - *isSplitRend = is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig->split_rend_config.dof ); + *isSplitRend = is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ); return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index a914ad225a..d85f8063ff 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -477,12 +477,12 @@ ivas_error ivas_output_buff_dec( /*! r: flag to indicate if split rendering is enabled */ int16_t is_split_rendering_enabled( - const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ - const int16_t dof /* i : flag to specify if pose correction is needed */ + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ + const IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* i : Render config data structure */ ) { if ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || - ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && hDecoderConfig->Opt_non_diegetic_pan && dof == 0 ) ) + ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && hDecoderConfig->Opt_non_diegetic_pan && hRenderConfig->split_rend_config.dof == 0 ) ) { return 1; } diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 215a0ededc..9ccbc180ec 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -81,7 +81,7 @@ int16_t ivas_get_nchan_buffers_dec( /*! r: flag to indicate if split rendering is enabled */ int16_t is_split_rendering_enabled( const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ - const int16_t dof /* i : flag to specify if pose correction is needed */ + const IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* i : Render config data structure */ ); #endif -- GitLab From 4e2e483bb5fe8bf6e0e31d266efad63fb45c4340 Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 30 May 2024 18:48:12 +1000 Subject: [PATCH 19/26] using the new utility function to check if split rendering is enabled --- lib_dec/ivas_jbm_dec.c | 4 ++-- lib_dec/lib_dec.c | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 235aeb9156..c6b1c22b5b 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1505,7 +1505,7 @@ ivas_error ivas_jbm_dec_render( nchan_out_syn_output = nchan_out; } - if ( !( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + if ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) #endif { if ( st_ivas->ivas_format != MONO_FORMAT ) @@ -1808,7 +1808,7 @@ ivas_error ivas_jbm_dec_flush_renderer( /* Only write out the valid data*/ #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( !( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + if ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) #endif { if ( st_ivas->ivas_format != MONO_FORMAT ) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 65e0ce23c2..9be83e8e02 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1356,10 +1356,7 @@ static ivas_error IVAS_DEC_Setup( * - initialize ISAR handle at the first frame * - reconfigure the ISAR handle in case of bitrate switching (renderer might change) *-----------------------------------------------------------------*/ - - if ( st_ivas->ini_frame == 0 && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || - st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || - ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) ) + if ( st_ivas->ini_frame == 0 && ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) ) ) { if ( ( error = ivas_dec_init_split_rend( st_ivas ) ) != IVAS_ERR_OK ) { -- GitLab From bc70ae84276f0a46f71a9f8872b17e7c541333a2 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 31 May 2024 10:00:03 +0200 Subject: [PATCH 20/26] remove unnecessary include --- lib_rend/lib_rend.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 591a849e0c..96ba246022 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -35,9 +35,10 @@ #include "prot.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT #include "isar_prot.h" -#include "isar_stat.h" #include "lib_isar_pre_rend.h" +#endif #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_rend.h" @@ -7854,7 +7855,7 @@ static ivas_error getSamplesInternal( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, -- GitLab From 3dda59d40fcd3fcd5691ed898b19d8a5356e38fe Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 31 May 2024 10:00:37 +0200 Subject: [PATCH 21/26] address todo comment --- lib_isar/isar_lc3plus_enc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_isar/isar_lc3plus_enc.c b/lib_isar/isar_lc3plus_enc.c index fdc5fbb446..215506dc61 100644 --- a/lib_isar/isar_lc3plus_enc.c +++ b/lib_isar/isar_lc3plus_enc.c @@ -313,6 +313,7 @@ ivas_error IVAS_LC3PLUS_ENC_SetBitrate( int32_t availableOctetsPerIsarFrame; int32_t actualOctetsPerFrame; LC3PLUS_Error err; + ivas_error ivas_err; int32_t iFtd; int32_t fdrLength; int32_t lc3plusPacketRate; @@ -382,10 +383,9 @@ ivas_error IVAS_LC3PLUS_ENC_SetBitrate( } } - // TODO: remove sanity checks? - if ( ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( handle, &actualOctetsPerFrame ) != IVAS_ERR_OK ) + if ( ( ivas_err = ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( handle, &actualOctetsPerFrame ) ) != IVAS_ERR_OK ) { - return IVAS_ERROR( IVAS_ERR_INTERNAL, "ISAR_LC3PLUS_ENC_GetOutputBitstreamSize failed\n" ); + return ivas_err; } if ( actualOctetsPerFrame > availableOctetsPerIsarFrame ) -- GitLab From 1615b0a34d3da35ecb945446ac48a9106f82e4b0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 31 May 2024 10:11:35 +0200 Subject: [PATCH 22/26] remove unnecessary include + clang-format --- lib_isar/lib_isar_post_rend.c | 1 - lib_rend/lib_rend.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index aafb9f173d..bed0486cdd 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -33,7 +33,6 @@ #include "options.h" #include "lib_isar_post_rend.h" -#include "isar_stat.h" #include "isar_prot.h" #include "prot.h" #include "ivas_prot.h" diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 96ba246022..06840fbcdb 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -7855,7 +7855,7 @@ static ivas_error getSamplesInternal( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, -- GitLab From 6f9aa7f647dd5e008c4578976cd06548f80b46b9 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 31 May 2024 10:14:27 +0200 Subject: [PATCH 23/26] remove unused struct; under ISAR_BITSTREAM_UPDATE_LC3PLUS --- lib_isar/lib_isar_post_rend.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index bed0486cdd..1b322ba977 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -60,6 +60,7 @@ int32_t ISAR_POST_REND_void_func( void ) * Local types *-------------------------------------------------------------------*/ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /* EFAP wrapper to simplify writing panning gains to a vector that includes LFE channels */ typedef struct { @@ -68,6 +69,7 @@ typedef struct const LSSETUP_CUSTOM_STRUCT *pCustomLsSetup; /* Pointer to main custom LS struct from renderer handle - doesn't need freeing */ } EFAP_WRAPPER; +#endif /* Lightweight helper struct that gathers all information required for rendering * any config to any other config. Used to simplify signatures of rendering functions. * -- GitLab From 4eb391c21fc582de289ced314a724f48e09acce4 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 31 May 2024 10:44:46 +0200 Subject: [PATCH 24/26] append two structure names with "_isar" to avoid confusions coming from the same structure name at two different places --- lib_isar/lib_isar_post_rend.c | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 1b322ba977..cf17bed520 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -93,7 +93,7 @@ typedef struct #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRenderConfig; #endif -} rendering_context; +} rendering_context_isar; /* Common base for input structs */ typedef struct @@ -102,13 +102,13 @@ typedef struct ISAR_POST_REND_InputId id; IVAS_REND_AudioBuffer inputBuffer; float gain; /* Linear, not in dB */ - rendering_context ctx; + rendering_context_isar ctx; int32_t numNewSamplesPerChannel; /* Used to keep track how much new audio was fed before rendering current frame */ -} input_base; +} input_base_isar; typedef struct { - input_base base; + input_base_isar base; ISAR_SPLIT_POST_REND_WRAPPER splitPostRendWrapper; float *bufferData; int16_t numCachedSamples; /* Number of decoded samples in bufferData that have not yet been played out */ @@ -438,10 +438,10 @@ static ivas_error initHeadRotation( static void initRendInputBase( - input_base *inputBase, + input_base_isar *inputBase, const AUDIO_CONFIG inConfig, const IVAS_REND_InputId id, - const rendering_context rendCtx, + const rendering_context_isar rendCtx, float *dataBuf, const int16_t dataBufSize ) { @@ -463,10 +463,10 @@ static void initRendInputBase( } -static rendering_context getRendCtx( +static rendering_context_isar getRendCtx( ISAR_POST_REND_HANDLE hIvasRend ) { - rendering_context ctx; + rendering_context_isar ctx; /* Note: when refactoring this, always take the ADDRESS of a member of the * renderer struct, so that the context stores a POINTER to the member, even @@ -488,7 +488,7 @@ static ivas_error getRendInputNumChannels( int16_t *numInChannels ) { /* Using a void pointer for this function to be reusable for any input type (input_ism, input_mc, input_sba). - Assumptions: - input_base is always the first member in the input struct */ + Assumptions: - input_base_isar is always the first member in the input struct */ (void) rendInput; *numInChannels = 2; @@ -508,7 +508,7 @@ static ivas_error updateSplitPostRendPanGains( ) { ivas_error error; - rendering_context rendCtx; + rendering_context_isar rendCtx; LC3PLUS_CONFIG config; int16_t iNumBlocksPerFrame, iNumLCLDIterationsPerFrame; @@ -593,7 +593,7 @@ static ivas_error setRendInputActiveSplitPostRend( ) { ivas_error error; - rendering_context rendCtx; + rendering_context_isar rendCtx; AUDIO_CONFIG outConfig; input_split_post_rend *inputSplitPostRend; @@ -625,7 +625,7 @@ static ivas_error setRendInputActiveSplitPostRend( static void clearInputSplitRend( input_split_post_rend *inputSplitRend ) { - rendering_context rendCtx; + rendering_context_isar rendCtx; rendCtx = inputSplitRend->base.ctx; @@ -778,7 +778,7 @@ static ivas_error getInputById( { int32_t inputIndex; IVAS_REND_AudioConfigType configType; - input_base *pInputBase; + input_base_isar *pInputBase; /* Reverse makeInputId() */ inputIndex = ( inputId & 0xFF ) - 1; @@ -827,7 +827,7 @@ ivas_error ISAR_POST_REND_SetInputGain( const float gain /* i : linear gain (not in dB) */ ) { - input_base *inputBase; + input_base_isar *inputBase; ivas_error error; /* Validate function arguments */ @@ -855,7 +855,7 @@ static ivas_error getConstInputById( { int32_t inputIndex; IVAS_REND_AudioConfigType configType; - const input_base *pInputBase; + const input_base_isar *pInputBase; /* Reverse makeInputId() */ inputIndex = ( inputId & 0xFF ) - 1; @@ -901,21 +901,21 @@ static ivas_error findFreeInputSlot( /* Using a void pointer and a separately provided size is a hack for this function to be reusable for arrays of any input type (input_ism, input_mc, input_sba, input_masa). Assumptions: - - input_base is always the first member in the input struct + - input_base_isar is always the first member in the input struct - provided size is correct */ int32_t i; bool canAddInput; const uint8_t *pByte; - const input_base *pInputBase; + const input_base_isar *pInputBase; canAddInput = false; /* Find first unused input in array */ for ( i = 0, pByte = inputs; i < maxInputs; ++i, pByte += inputStructSize ) { - pInputBase = (const input_base *) pByte; + pInputBase = (const input_base_isar *) pByte; if ( pInputBase->inConfig == IVAS_AUDIO_CONFIG_INVALID ) { @@ -1010,7 +1010,7 @@ ivas_error ISAR_POST_REND_GetInputNumChannels( ) { ivas_error error; - const input_base *pInput; + const input_base_isar *pInput; /* Validate function arguments */ if ( hIvasRend == NULL || numChannels == NULL ) @@ -1101,7 +1101,7 @@ ivas_error ISAR_POST_REND_FeedInputAudio( ) { ivas_error error; - input_base *inputBase; + input_base_isar *inputBase; int16_t numInputChannels; int16_t cldfb2tdSampleFact; @@ -1250,7 +1250,7 @@ ivas_error ISAR_POST_REND_FeedSplitBinauralBitstream( ) { ivas_error error; - input_base *inputBase; + input_base_isar *inputBase; input_split_post_rend *inputSplitPostRend; /* Validate function arguments */ -- GitLab From f407f98d800cbd6896994ab4638b0201e9fe0626 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 31 May 2024 10:46:45 +0200 Subject: [PATCH 25/26] fix compilation switch --- lib_isar/lib_isar_post_rend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index cf17bed520..53595aa88a 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -60,7 +60,7 @@ int32_t ISAR_POST_REND_void_func( void ) * Local types *-------------------------------------------------------------------*/ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS /* EFAP wrapper to simplify writing panning gains to a vector that includes LFE channels */ typedef struct { -- GitLab From 26be296bdafde08025b6f5547a11f2883f757f6b Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 4 Jun 2024 13:58:03 +1000 Subject: [PATCH 26/26] fix remaining comments --- lib_com/common_api_types.h | 2 +- lib_dec/lib_dec.c | 20 +++----------------- lib_isar/isar_lcld_decoder.c | 1 - 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 8470eb7572..0d596030ce 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -277,7 +277,7 @@ typedef struct _ISAR_SPLIT_REND_CONFIG 2 - (2dof correction. By default YAW and PITCH correction) 3 - (3dof correction. By default YAW, PITCH and ROLL correction) */ - int16_t codec_delay_ms; /*PLACEHOLDER (currently being ignored) : look ahead delay of the codec that is used to code BIN signal output of pre-renderer*/ + int16_t codec_delay_ms; /* look ahead delay of the codec that is used to code BIN signal output of pre-renderer*/ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int16_t isar_frame_size_ms; /* ISAR bit stream frame size in milliseconds */ #endif diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 9be83e8e02..c11dcb78bc 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2151,23 +2151,9 @@ static ivas_error copyRendererConfigStruct( mvr2r( hRCin->directivity, hRCout->directivity, 3 * MAX_NUM_OBJECTS ); #ifdef SPLIT_REND_WITH_HEAD_ROT - /* TODO: This seems wrong. Why set default instead of copying from hRCin? - * Currently seems to work because we only ever copy from a default-initialized handle anyway */ - hRCout->split_rend_config.splitRendBitRate = ISAR_MAX_SPLIT_REND_BITRATE; - hRCout->split_rend_config.dof = 3; - hRCout->split_rend_config.hq_mode = 0; - hRCout->split_rend_config.codec_delay_ms = 0; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - hRCout->split_rend_config.isar_frame_size_ms = 20; -#endif - hRCout->split_rend_config.codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */ - hRCout->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; - hRCout->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; - hRCout->split_rend_config.rendererSelection = hRCin->split_rend_config.rendererSelection; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - hRCout->split_rend_config.lc3plus_highres = hRCin->split_rend_config.lc3plus_highres; -#endif + hRCout->split_rend_config = hRCin->split_rend_config; #endif + hRCout->roomAcoustics.use_er = hRCin->roomAcoustics.use_er; hRCout->roomAcoustics.lowComplexity = hRCin->roomAcoustics.lowComplexity; @@ -4232,7 +4218,7 @@ static ivas_error ivas_dec_reconfig_split_rend( if ( ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) && ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV || st_ivas->ivas_format != SBA_ISM_FORMAT ) && - !( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) /* td-rend not needed? */ + !( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) { for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) { diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index a9a6257e5c..41b00806d7 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -1308,7 +1308,6 @@ static void InvMSCoding( } -/* Currently only the number of bands in frame */ static int32_t ReadHeaderInformation( int32_t *piNumBands, ISAR_SPLIT_REND_BITS_HANDLE pBits ) -- GitLab