From 60b765fe81a44094012da7b96ab240c5327f3dbf Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 16 Aug 2023 14:00:57 +0200 Subject: [PATCH 01/13] maintenance: formatting, add error returns --- Workspace_msvc/lib_enc.vcxproj.filters | 6 +++-- apps/encoder.c | 28 +++++++---------------- lib_com/ivas_prot.h | 2 +- lib_dec/ivas_binRenderer_internal.c | 2 +- lib_dec/ivas_dec.c | 8 ++----- lib_dec/ivas_init_dec.c | 7 +++++- lib_dec/ivas_ism_dec.c | 6 +++-- lib_dec/ivas_ism_metadata_dec.c | 6 ++--- lib_dec/ivas_jbm_dec.c | 15 ++++++------- lib_dec/ivas_masa_dec.c | 23 ++++++++++--------- lib_dec/ivas_mct_core_dec.c | 9 +++----- lib_dec/ivas_mct_dec_mct.c | 9 +++----- lib_dec/ivas_sba_dec.c | 15 +++++++------ lib_dec/ivas_sba_rendering_internal.c | 3 +-- lib_dec/ivas_spar_decoder.c | 20 ++++++----------- lib_enc/ivas_cpe_enc.c | 14 ++++-------- lib_enc/ivas_enc.c | 17 +++++--------- lib_enc/ivas_init_enc.c | 3 --- lib_enc/ivas_ism_enc.c | 3 +-- lib_enc/ivas_masa_enc.c | 31 +++++++++++++++----------- lib_enc/ivas_mct_enc.c | 9 ++++++++ lib_enc/ivas_mct_enc_mct.c | 21 ++++++----------- lib_enc/ivas_osba_enc.c | 5 +++-- lib_enc/ivas_sba_enc.c | 5 +++-- lib_enc/ivas_spar_encoder.c | 3 +-- 25 files changed, 120 insertions(+), 150 deletions(-) diff --git a/Workspace_msvc/lib_enc.vcxproj.filters b/Workspace_msvc/lib_enc.vcxproj.filters index b15d61431f..e74f441c4c 100644 --- a/Workspace_msvc/lib_enc.vcxproj.filters +++ b/Workspace_msvc/lib_enc.vcxproj.filters @@ -590,10 +590,12 @@ enc_ivas_c - enc_ivas_c + + enc_ivas_c + @@ -624,4 +626,4 @@ {6cccabbe-510f-43d3-90e1-8ed5ea3837d7} - + \ No newline at end of file diff --git a/apps/encoder.c b/apps/encoder.c index 2b4016bcb8..39f2d38479 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -407,24 +407,16 @@ int main( break; case IVAS_ENC_INPUT_SBA: if ( ( error = - IVAS_ENC_ConfigureForAmbisonics( - hIvasEnc, - arg.inputFs, - totalBitrate, - arg.max_bwidth_user, - bandwidth, - arg.dtxConfig, - arg.inputFormatConfig.sba.order, - arg.inputFormatConfig.sba.isPlanar, + IVAS_ENC_ConfigureForAmbisonics( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba.order, arg.inputFormatConfig.sba.isPlanar, #ifdef DEBUG_AGC_ENCODER_CMD_OPTION - arg.agc, + arg.agc, #endif - arg.pca + arg.pca #ifdef DEBUG_SBA_AUDIO_DUMP - , - &numTransportChannels + , + &numTransportChannels #endif - ) ) != IVAS_ERR_OK ) + ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_ENC_ConfigureForAmbisonics failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); goto cleanup; @@ -445,7 +437,6 @@ int main( goto cleanup; } break; - case IVAS_ENC_INPUT_SBA_ISM: if ( ( error = IVAS_ENC_ConfigureForSBAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba_ism.numObjects, arg.inputFormatConfig.sba_ism.order, arg.inputFormatConfig.sba_ism.isPlanar, arg.pca ) ) != IVAS_ERR_OK ) { @@ -453,7 +444,6 @@ int main( exit( -1 ); } break; - case IVAS_ENC_INPUT_MASA_ISM: if ( ( error = IVAS_ENC_ConfigureForMASAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.masa_ism.numObjects, arg.inputFormatConfig.masa_ism.masaVariant ) ) != IVAS_ERR_OK ) { @@ -461,7 +451,6 @@ int main( exit( -1 ); } break; - default: fprintf( stderr, "\nInvalid input type\n\n" ); goto cleanup; @@ -512,6 +501,7 @@ int main( fprintf( stderr, "\nError: %s\n", ivas_error_to_string( error ) ); goto cleanup; } + int16_t inFileNumChannels = 0; error = AudioFileReader_getNumChannels( audioReader, &inFileNumChannels ); switch ( error ) @@ -546,9 +536,7 @@ int main( } } - const int16_t numIsmInputs = ( arg.inputFormat == IVAS_ENC_INPUT_ISM || arg.inputFormat == IVAS_ENC_INPUT_MASA_ISM || arg.inputFormat == IVAS_ENC_INPUT_SBA_ISM ) - ? arg.inputFormatConfig.ism.numObjects - : 0; + const int16_t numIsmInputs = ( arg.inputFormat == IVAS_ENC_INPUT_ISM || arg.inputFormat == IVAS_ENC_INPUT_MASA_ISM || arg.inputFormat == IVAS_ENC_INPUT_SBA_ISM ) ? arg.inputFormatConfig.ism.numObjects : 0; for ( i = 0; i < numIsmInputs; ++i ) { diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index a0d220df2a..fa0ac2f456 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4309,7 +4309,7 @@ ivas_error ivas_sba_dec_digest_tc( const int16_t nSamplesForRendering /* i : number of samples provided */ ); -void ivas_sba_dec_render( +ivas_error ivas_sba_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index d884f8f8e5..e21e6a32a3 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -740,7 +740,7 @@ ivas_error ivas_allocate_binaural_hrtf( *-------------------------------------------------------------------------*/ static ivas_error ivas_binaural_hrtf_open( - HRTFS_FASTCONV_HANDLE *hHrtfFastConv, /* i : fastconv HRTF handle */ + HRTFS_FASTCONV_HANDLE *hHrtfFastConv, /* i : fastconv HRTF handle */ const AUDIO_CONFIG input_config, /* i : output configuration */ const RENDERER_TYPE renderer_type /* i : renderer type */ ) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index ae8b1f158e..424a9f1960 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -445,9 +445,7 @@ ivas_error ivas_dec( ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, output ); } - ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, - ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, - st_ivas->last_active_ivas_total_brate ) ); + ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); } ivas_sba_dirac_stereo_dec( st_ivas, output, output_frame, st_ivas->ivas_format == MC_FORMAT ); @@ -690,9 +688,7 @@ ivas_error ivas_dec( ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &output[sba_ch_idx] ); } - ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, - ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, - st_ivas->last_active_ivas_total_brate ) ); + ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); ivas_sba_dirac_stereo_dec( st_ivas, &output[sba_ch_idx], output_frame, 0 ); } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 1f401bb420..56a82a48b4 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1069,6 +1069,10 @@ ivas_error ivas_init_decoder( hDecoderConfig->last_ivas_total_brate = ivas_total_brate; st_ivas->last_active_ivas_total_brate = ivas_total_brate; + /*-----------------------------------------------------------------* + * Set number of output channels for EXTERNAL output config. + *-----------------------------------------------------------------*/ + if ( output_config == AUDIO_CONFIG_EXTERNAL ) { if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) @@ -1152,7 +1156,6 @@ ivas_error ivas_init_decoder( } } - #ifdef SPLIT_REND_WITH_HEAD_ROT /*-----------------------------------------------------------------* * Initialize binuaral split rendering @@ -2625,6 +2628,7 @@ void ivas_destroy_dec( free( st_ivas->hMonoDmxRenderer ); st_ivas->hMonoDmxRenderer = NULL; } + /* MASA ISM structure */ ivas_masa_ism_data_close( &st_ivas->hMasaIsmData ); @@ -2654,6 +2658,7 @@ void ivas_destroy_dec( /* CRend binaural renderer handle */ ivas_HRTF_CRend_binary_close( &st_ivas->hSetOfHRTF ); + /* Fastconv HRTF memories */ ivas_binaural_hrtf_close( &st_ivas->hHrtfFastConv ); diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 073b01824d..ed072a4afa 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -78,8 +78,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( st_ivas->ism_mode = ism_mode; nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas ); - if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, - 0 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -116,7 +115,9 @@ static ivas_error ivas_ism_bitrate_switching_dec( /* select the renderer */ ivas_renderer_select( st_ivas ); + ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); + if ( ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) && ( st_ivas->ism_mode == ISM_MODE_DISC ) ) { ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->hDecoderConfig->output_config ); @@ -137,6 +138,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv render what still fits in the new granularity */ tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); + if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, MC_MODE_NONE, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index 13c8ceeb80..b14a33af27 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -568,8 +568,7 @@ ivas_error ivas_ism_metadata_dec( } } - if ( ( error = ivas_ism_config( ism_total_brate, *nchan_transport, nchan_ism, hIsmMeta, ism_extmeta_bitstream, null_metadata_flag, ism_imp, element_brate, total_brate, nb_bits_metadata, - masa_ism_flag ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_config( ism_total_brate, *nchan_transport, nchan_ism, hIsmMeta, ism_extmeta_bitstream, null_metadata_flag, ism_imp, element_brate, total_brate, nb_bits_metadata, masa_ism_flag ) ) != IVAS_ERR_OK ) { return error; } @@ -686,8 +685,7 @@ ivas_error ivas_ism_metadata_dec_create( if ( element_brate_tmp != NULL ) { - if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, n_ISms, n_ISms, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, - 0 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, n_ISms, n_ISms, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 419cd56195..14944e8589 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -264,9 +264,7 @@ ivas_error ivas_jbm_dec_tc( ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, output ); } - ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, - ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, - st_ivas->last_active_ivas_total_brate ) ); + ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); } ivas_sba_dirac_stereo_dec( st_ivas, output, output_frame, st_ivas->ivas_format == MC_FORMAT ); @@ -922,9 +920,7 @@ ivas_error ivas_jbm_dec_render( mvr2r( st_ivas->hTcBuffer->tc[n] + st_ivas->hTcBuffer->n_samples_rendered, p_output[n], *nSamplesRendered ); } - if ( ( error = ivas_sba_linear_renderer( p_output, *nSamplesRendered, nchan_remapped, - 0, - output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sba_linear_renderer( p_output, *nSamplesRendered, nchan_remapped, 0, output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) { return error; } @@ -936,7 +932,10 @@ ivas_error ivas_jbm_dec_render( } else /* SBA_MODE_SPAR */ { - ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); + if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) + { + return error; + } } } else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) @@ -947,7 +946,7 @@ ivas_error ivas_jbm_dec_render( { if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) { - if ( ( ivas_omasa_dirac_td_binaural_jbm( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_omasa_dirac_td_binaural_jbm( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 6bc88b06c8..5e12013a1c 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -76,7 +76,9 @@ static ivas_error ivas_masa_dec_config( Decoder_Struct *st_ivas ); static int16_t ivas_decode_masaism_metadata( IVAS_QMETADATA_HANDLE hQMetaData, MASA_DECODER_HANDLE hMasa, MASA_ISM_DATA_HANDLE hMasaIsmData, const int16_t nchan_ism, uint16_t *bit_stream, int16_t *next_bit_pos, const int16_t idx_separated_object, const int16_t ism_imp, const int16_t dirac_bs_md_write_idx, const int16_t dirac_md_buffer_length ); static void decode_index_slice( int16_t index, int16_t *ratio_idx_ism, const int16_t nchan_ism, const int16_t K ); + static void decode_ism_ratios( uint16_t *bit_stream, int16_t *next_bit_pos, float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], float ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], const int16_t nchan_ism, const int16_t nbands, const int16_t nblocks, const int16_t idx_separated_object ); + static void read_ism_ratio_index( int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], const int16_t nchan_ism, const int16_t numCodingBands, const int16_t sf, int16_t ratio_ism_idx_prev_sf[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], uint16_t *bit_stream, int16_t *next_bit_pos, float *masa_to_total_energy_ratio, const int16_t idx_sep_obj, int16_t *num_zeros ); @@ -404,8 +406,7 @@ ivas_error ivas_masa_decode( return error; } - ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, hQMetaData, &st_ivas->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, - st_ivas->ivas_format, st_ivas->ism_mode, 0 ); + ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, hQMetaData, &st_ivas->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, st_ivas->ivas_format, st_ivas->ism_mode, 0 ); hQMetaData->metadata_max_bits = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC; @@ -582,8 +583,7 @@ ivas_error ivas_masa_dec_open( } } - ivas_masa_set_elements( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &st_ivas->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, - st_ivas->ivas_format, st_ivas->ism_mode, ism_total_brate ); + ivas_masa_set_elements( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &st_ivas->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, st_ivas->ivas_format, st_ivas->ism_mode, ism_total_brate ); mvs2s( DirAC_block_grouping, hMasa->config.block_grouping, MAX_PARAM_SPATIAL_SUBFRAMES + 1 ); mvs2s( MASA_band_grouping_24, hMasa->config.band_grouping, MASA_FREQUENCY_BANDS + 1 ); @@ -1011,6 +1011,7 @@ static ivas_error init_lfe_synth_data( set_zero( hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio, MAX_PARAM_SPATIAL_SUBFRAMES ); hMasa->hMasaLfeSynth->lfeGainPrevIndex = 0; + if ( st_ivas->hOutSetup.separateChannelEnabled && ( output_config == AUDIO_CONFIG_5_1 || output_config == AUDIO_CONFIG_7_1 || output_config == AUDIO_CONFIG_5_1_2 || @@ -1420,12 +1421,12 @@ ivas_error ivas_masa_dec_reconfigure( { return error; } - - /*-----------------------------------------------------------------* - * Set-up MASA coding elements and bitrates - *-----------------------------------------------------------------*/ } + /*-----------------------------------------------------------------* + * Set-up MASA coding elements and bitrates + *-----------------------------------------------------------------*/ + ism_total_brate = 0; if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->nSCE > 0 && ( st_ivas->ism_mode == ISM_MASA_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) ) { @@ -1435,8 +1436,7 @@ ivas_error ivas_masa_dec_reconfigure( } } - ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &tmp, &tmp, &tmp, - st_ivas->ivas_format, st_ivas->ism_mode, ism_total_brate ); + ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &tmp, &tmp, &tmp, st_ivas->ivas_format, st_ivas->ism_mode, ism_total_brate ); if ( st_ivas->ivas_format == MASA_FORMAT ) { @@ -1599,7 +1599,6 @@ void ivas_spar_param_to_masa_param_mapping( } else { - mixer_mat_index = ( ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) == 1 ) ? 0 : ( sf - SPAR_META_DELAY_SUBFRAMES ); for ( band = 0; band < SPAR_DIRAC_SPLIT_START_BAND; band++ ) { @@ -1675,6 +1674,7 @@ void ivas_spar_param_to_masa_param_mapping( { inCovarianceMtx[0][0] = transportSignalEnergies[0][bin]; /* In case of 2TC, use actual energies */ } + /* Decorrelated channels assumed to have the same energy as the source channel */ inCovarianceMtx[1][1] = inCovarianceMtx[0][0]; inCovarianceMtx[2][2] = inCovarianceMtx[0][0]; @@ -2369,6 +2369,7 @@ static int16_t ivas_decode_masaism_metadata( /* read ISM metadata */ calculate_nbits_meta( nchan_ism, energy_ratio_ism, hMasaIsmData->masa_to_total_energy_ratio, nblocks, nbands, bits_ism, idx_separated_object, ism_imp ); + for ( obj = 0; obj < nchan_ism; obj++ ) { index = 0; diff --git a/lib_dec/ivas_mct_core_dec.c b/lib_dec/ivas_mct_core_dec.c index f7b12126ac..faffe1a1b4 100644 --- a/lib_dec/ivas_mct_core_dec.c +++ b/lib_dec/ivas_mct_core_dec.c @@ -88,8 +88,7 @@ void ivas_mct_side_bits( for ( ch = 0; ch < nChannels; ch++ ) { st = sts[ch]; - if ( - st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { continue; } @@ -115,8 +114,7 @@ void ivas_mct_side_bits( { st = sts[ch]; - if ( - st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { chBitRatios[ch] = 0; st->bits_frame_channel = 0; @@ -203,8 +201,7 @@ void ivas_mct_core_dec( for ( ch = 0, i = 0; ch < nChannels; ch++ ) { - if ( - sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { continue; } diff --git a/lib_dec/ivas_mct_dec_mct.c b/lib_dec/ivas_mct_dec_mct.c index 987a9cc72f..881c35119c 100644 --- a/lib_dec/ivas_mct_dec_mct.c +++ b/lib_dec/ivas_mct_dec_mct.c @@ -99,8 +99,7 @@ void ivas_mct_dec_mct( /*first get core and overlap info for all channels*/ for ( ch = 0; ch < nchan; ch++ ) { - if ( - hMCT->currBlockDataCnt && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) + if ( hMCT->currBlockDataCnt && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { hMCT->mc_global_ild[ch] = get_next_indice( sts[0], SMDCT_GLOBAL_ILD_BITS ); } @@ -124,8 +123,7 @@ void ivas_mct_dec_mct( for ( ch = 0; ch < nchan; ch++ ) { - if ( - sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) + if ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { nchan_active++; } @@ -305,8 +303,7 @@ void mctStereoIGF_dec( if ( sum_s( singleChEle, ( hMCT->nchan_out_woLFE ) ) != 0 ) { - for ( ch = 0; ch < ( hMCT->nchan_out_woLFE ); - ch++ ) + for ( ch = 0; ch < ( hMCT->nchan_out_woLFE ); ch++ ) { if ( singleChEle[ch] ) { diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 5a76aa885d..8c8aeced47 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -208,8 +208,7 @@ ivas_error ivas_sba_dec_reconfigure( ivas_spar_md_dec_matrix_close( st_ivas->hSpar->hMdDec, num_channels ); num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order_internal, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - if ( ( error = ivas_spar_md_dec_matrix_open( st_ivas->hSpar->hMdDec, num_channels, - num_md_sub_frames ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_spar_md_dec_matrix_open( st_ivas->hSpar->hMdDec, num_channels, num_md_sub_frames ) ) != IVAS_ERR_OK ) { return error; } @@ -628,7 +627,7 @@ ivas_error ivas_sba_dec_digest_tc( * *-------------------------------------------------------------------*/ -void ivas_sba_dec_render( +ivas_error ivas_sba_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ @@ -642,6 +641,7 @@ void ivas_sba_dec_render( SPAR_DEC_HANDLE hSpar; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; float *output_f_local[MAX_OUTPUT_CHANNELS]; + ivas_error error; hSpar = st_ivas->hSpar; hSpatParamRendCom = st_ivas->hSpatParamRendCom; @@ -686,9 +686,10 @@ void ivas_sba_dec_render( if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC ) { - ivas_sba_linear_renderer( output_f, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE, - 0, - st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); + if ( ( error = ivas_sba_linear_renderer( output_f, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE, 0, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) + { + return error; + } } if ( st_ivas->hDirAC != NULL && hSpar->slots_rendered == hSpar->num_slots ) @@ -705,5 +706,5 @@ void ivas_sba_dec_render( *nSamplesAvailable = ( hSpar->num_slots - hSpar->slots_rendered ) * slot_size; - return; + return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 15be85b04f..8016f9c27c 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -648,8 +648,7 @@ void ivas_sba_mix_matrix_determiner( /* Mixing matrix determiner */ num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; - ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, bfi, - num_md_sub_frames ); + ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, bfi, num_md_sub_frames ); return; } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index f5131535a5..a660abef08 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -72,7 +72,7 @@ ivas_error ivas_spar_dec_open( IVAS_FB_CFG *fb_cfg; int16_t i, j, b, active_w_mixing; int32_t output_Fs; - int16_t num_decor_chs; + int16_t num_decor_chs, map_idx; error = IVAS_ERR_OK; sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); @@ -114,9 +114,7 @@ ivas_error ivas_spar_dec_open( } /* MD handle */ - if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal, sba_order_internal, st_ivas->sid_format, - st_ivas->last_active_ivas_total_brate /* i : IVAS last active bitrate */ - ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal, sba_order_internal, st_ivas->sid_format, st_ivas->last_active_ivas_total_brate ) ) != IVAS_ERR_OK ) { return error; } @@ -206,13 +204,10 @@ ivas_error ivas_spar_dec_open( hSpar->num_slots = DEFAULT_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME; /* init render timeslot mapping */ + set_s( hSpar->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); + for ( map_idx = 0; map_idx < DEFAULT_JBM_CLDFB_TIMESLOTS; map_idx++ ) { - int16_t map_idx; - set_s( hSpar->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); - for ( map_idx = 0; map_idx < DEFAULT_JBM_CLDFB_TIMESLOTS; map_idx++ ) - { - hSpar->render_to_md_map[map_idx] = map_idx; - } + hSpar->render_to_md_map[map_idx] = map_idx; } /* allocate transport channels*/ @@ -235,6 +230,7 @@ ivas_error ivas_spar_dec_open( { nchan_to_allocate = 2 * BINAURAL_CHANNELS; } + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) { return error; @@ -1222,9 +1218,7 @@ void ivas_spar_dec_set_render_params( nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; - ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, st_ivas->bfi, - ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, - st_ivas->last_active_ivas_total_brate ) ); + ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); ivas_spar_dec_set_render_map( st_ivas, n_cldfb_slots ); diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index cae9119000..e737726d9f 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -279,10 +279,8 @@ ivas_error ivas_cpe_enc( } - if ( hCPE->element_mode != IVAS_CPE_MDCT && ( hCPE->element_brate != hCPE->last_element_brate || hCPE->last_element_mode != hCPE->element_mode || - sts[0]->ini_frame == 0 || - ( ivas_total_brate != st_ivas->hEncoderConfig->last_ivas_total_brate ) || - sts[0]->last_core_brate <= SID_2k40 ) ) /* If the last frame was SID or NO_DATA, we need to run stereo_dft_config here since VAD decision is not known yet */ + if ( hCPE->element_mode != IVAS_CPE_MDCT && ( hCPE->element_brate != hCPE->last_element_brate || hCPE->last_element_mode != hCPE->element_mode || sts[0]->ini_frame == 0 || + ( ivas_total_brate != st_ivas->hEncoderConfig->last_ivas_total_brate ) || sts[0]->last_core_brate <= SID_2k40 ) ) /* If the last frame was SID or NO_DATA, we need to run stereo_dft_config here since VAD decision is not known yet */ { if ( st_ivas->hQMetaData != NULL ) { @@ -559,10 +557,7 @@ ivas_error ivas_cpe_enc( { tdm_ol_pitch_comparison( hCPE, pitch_fr, voicing_fr ); - tdm_configure_enc( - ivas_format, - st_ivas->ism_mode, - hCPE, Etot_last, tdm_SM_or_LRTD_Pri, tdm_ratio_idx, tdm_ratio_idx_SM, attack_flag[0], nb_bits_metadata ); + tdm_configure_enc( ivas_format, st_ivas->ism_mode, hCPE, Etot_last, tdm_SM_or_LRTD_Pri, tdm_ratio_idx, tdm_ratio_idx_SM, attack_flag[0], nb_bits_metadata ); if ( hEncoderConfig->Opt_DTX_ON ) { @@ -900,8 +895,7 @@ ivas_error create_cpe_enc( st->total_brate = hCPE->element_brate / ( st_ivas->nCPE > 1 ? 1 : CPE_CHANNELS ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; - if ( ( error = init_encoder( st, st_ivas, n, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 0, - ISM_MODE_NONE ) ) != IVAS_ERR_OK ) + if ( ( error = init_encoder( st, st_ivas, n, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 0, ISM_MODE_NONE ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 8096199382..de70ba590f 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -182,8 +182,7 @@ ivas_error ivas_enc( ivas_param_ism_stereo_dmx( st_ivas, data_f, input_frame ); /* Core coding of Stereo DMX */ - if ( ( error = ivas_ism_enc( st_ivas, data_f, input_frame, nb_bits_metadata, - 0 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_enc( st_ivas, data_f, input_frame, nb_bits_metadata, 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -191,8 +190,7 @@ ivas_error ivas_enc( else if ( st_ivas->ism_mode == ISM_MODE_DISC ) { /* Analysis, decision about bitrates per channel & core coding */ - if ( ( error = ivas_ism_enc( st_ivas, data_f, input_frame, nb_bits_metadata, - 0 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_enc( st_ivas, data_f, input_frame, nb_bits_metadata, 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -224,7 +222,7 @@ ivas_error ivas_enc( /* SBA/MASA metadata encoding and SBA/MASA metadata bitstream writing */ hMetaData = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData : st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; - if ( st_ivas->hQMetaData != NULL && ivas_format != SBA_FORMAT ) + if ( st_ivas->hQMetaData != NULL && ivas_format == MASA_FORMAT ) { ivas_masa_estimate_energy( st_ivas->hMasa, data_f, input_frame, st_ivas->nchan_transport ); /* energy-estimation uses TF-resolution: 4x24 */ @@ -368,12 +366,10 @@ ivas_error ivas_enc( } else if ( ivas_format == SBA_ISM_FORMAT ) { - ivas_osba_enc_reconfig( st_ivas ); /* Analyze objects and determine needed audio signals */ - ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order, - hEncoderConfig->input_Fs ); + ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order, hEncoderConfig->input_Fs ); if ( st_ivas->ism_mode == ISM_MODE_NONE ) { @@ -436,7 +432,6 @@ ivas_error ivas_enc( } else { - n = hEncoderConfig->nchan_ism; st = st_ivas->hCPE[0]->hCoreCoder[0]; hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; @@ -562,9 +557,7 @@ ivas_error ivas_enc( ivas_mcmasa_enc( st_ivas->hMcMasa, st_ivas->hQMetaData, st_ivas->hMasa, data_f, input_frame, st_ivas->nchan_transport, nchan_inp ); if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, 0, -1, - ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 - - ) ) != IVAS_ERR_OK ) + ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 4a870d5977..96badab949 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -484,7 +484,6 @@ ivas_error ivas_init_encoder( return error; } - /* prepare stereo downmix for EVS */ if ( hEncoderConfig->stereo_dmx_evs == 1 ) { @@ -594,7 +593,6 @@ ivas_error ivas_init_encoder( for ( n = 0; n < CPE_CHANNELS; n++ ) { - if ( hEncoderConfig->Opt_DTX_ON ) { st_ivas->hCPE[cpe_id]->hCoreCoder[n]->cng_sba_flag = 1; @@ -736,7 +734,6 @@ ivas_error ivas_init_encoder( else { /* allocate and initialize MCT core coder */ - st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1; for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 35878e5848..a754317a7c 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -448,8 +448,7 @@ ivas_error ivas_ism_enc_config( st_ivas->nSCE = st_ivas->nchan_transport; st_ivas->nCPE = 0; - if ( ( error = ivas_ism_config( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hEncoderConfig->nchan_inp, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, - 0 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_config( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hEncoderConfig->nchan_inp, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index a98e42739b..ac8c06b79a 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -137,8 +137,7 @@ ivas_error ivas_masa_enc_open( } } - ivas_masa_set_elements( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &hEncoderConfig->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, - hEncoderConfig->ivas_format, st_ivas->ism_mode, ism_total_brate ); + ivas_masa_set_elements( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &hEncoderConfig->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, hEncoderConfig->ivas_format, st_ivas->ism_mode, ism_total_brate ); mvs2s( DirAC_block_grouping, hMasa->config.block_grouping, MAX_PARAM_SPATIAL_SUBFRAMES + 1 ); mvs2s( MASA_band_grouping_24, hMasa->config.band_grouping, MASA_FREQUENCY_BANDS + 1 ); @@ -475,8 +474,7 @@ ivas_error ivas_masa_encode( if ( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) { /* encode MASA/ISM energy ratios */ - ivas_encode_masaism_metadata( hMasa, hQMetaData, hMetaData, hIsmMetaData, nchan_ism, low_bitrate_mode, hOMasa->nCodingBands, hOMasa->nSubframes, - idx_separated_object, ism_imp ); + ivas_encode_masaism_metadata( hMasa, hQMetaData, hMetaData, hIsmMetaData, nchan_ism, low_bitrate_mode, hOMasa->nCodingBands, hOMasa->nSubframes, idx_separated_object, ism_imp ); } else { @@ -691,8 +689,8 @@ ivas_error ivas_masa_enc_config( } } - ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, hQMetaData, &st_ivas->hEncoderConfig->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, - ivas_format, st_ivas->ism_mode, ism_total_brate ); + ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, hQMetaData, &st_ivas->hEncoderConfig->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, ivas_format, st_ivas->ism_mode, ism_total_brate ); + hQMetaData->is_masa_ivas_format = 1; if ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) @@ -856,7 +854,6 @@ ivas_error ivas_masa_enc_config( set_c( (int8_t *) hMasa->data.twoDirBands, 1, hMasa->config.numCodingBands ); } - /* Transmit stereo signals using a mono downmix at lowest bitrates */ if ( ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) && st_ivas->nCPE == 1 && st_ivas->hCPE[0]->hStereoDft != NULL && st_ivas->hCPE[0]->hStereoDft->hConfig != NULL ) { @@ -974,6 +971,7 @@ static void combine_freqbands_and_subframes( } } } + if ( numCodingBands <= MAX_REDUCED_NBANDS ) { /* reduce metadata *frequency* resolution. time resolution is not touched */ @@ -1109,6 +1107,13 @@ static void combine_freqbands_and_subframes( return; } + +/*-------------------------------------------------------------------* + * ivas_masa_combine_directions() + * + * + *-------------------------------------------------------------------*/ + void ivas_masa_combine_directions( MASA_ENCODER_HANDLE hMasa ) { @@ -1467,10 +1472,7 @@ static void detect_metadata_composition( /* Check surround coherence separately if we do not have already knowledge of coherence */ if ( cohPresent == FALSE ) { - cohPresent = ivas_masa_surrcoh_signicant( hMeta->common_meta.surround_coherence, - hMeta->common_meta.diffuse_to_total_ratio, - nSubFrames, - MASA_FREQUENCY_BANDS ); + cohPresent = ivas_masa_surrcoh_signicant( hMeta->common_meta.surround_coherence, hMeta->common_meta.diffuse_to_total_ratio, nSubFrames, MASA_FREQUENCY_BANDS ); } /* Set output flags */ @@ -1982,8 +1984,7 @@ void ivas_masa_enc_reconfigure( } } - ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &tmp, &tmp, &tmp, - st_ivas->hEncoderConfig->ivas_format, st_ivas->ism_mode, ism_total_brate ); + ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &tmp, &tmp, &tmp, st_ivas->hEncoderConfig->ivas_format, st_ivas->ism_mode, ism_total_brate ); } return; @@ -2617,8 +2618,10 @@ void ivas_merge_masa_metadata( { energyTimesRatioMASA[1] = 0.0f; } + /* target is original MASA diffuseness */ total_diff_nrg = eneBand * hMeta->common_meta.diffuse_to_total_ratio[sf][band]; + /* criterion is mean of ISM ratio and new ratio */ energyTimesRatioISM = ( hOMasaMeta->directional_meta[0].energy_ratio[sf][band] + ( 1.0f - total_diff_nrg / ( EPSILON + eneBand + hMasa->data.hOmasaData->energy_ism[sf][band] ) ) ) / 2.0f * hMasa->data.hOmasaData->energy_ism[sf][band]; @@ -3605,7 +3608,9 @@ static void ivas_encode_masaism_metadata( } } } + calculate_nbits_meta( nchan_ism, hOmasaData->q_energy_ratio_ism, hOmasaData->masa_to_total_energy_ratio, numSf, numCodingBands, bits_ism, idx_separated_object, ism_imp ); + /* quantize directions */ for ( obj = 0; obj < nchan_ism; obj++ ) { diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 895e864797..ae7cb94681 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -255,6 +255,7 @@ ivas_error ivas_mct_enc( { hCPE->hCoreCoder[0]->hBstr->ind_list = st_ivas->hCPE[cpe_id - 1]->hCoreCoder[1]->hBstr->ind_list + st_ivas->hCPE[cpe_id - 1]->hCoreCoder[1]->hBstr->nb_ind_tot; } + ivas_mdct_quant_coder( hCPE, hMCT->tnsBits[cpe_id], hMCT->tnsSize[cpe_id], hMCT->p_param[cpe_id], 1 ); /* update input samples buffer (as done in ivas_cpe_enc() for other than MCT coding) */ @@ -554,6 +555,7 @@ ivas_error mct_enc_reconfigure( *-----------------------------------------------------------------*/ set_mct_enc_params( hMCT, ivas_total_brate, ivas_format, b_nchan_change ); + return IVAS_ERR_OK; } @@ -689,6 +691,7 @@ static ivas_error ivas_mc_enc_reconfig( ivas_param_mc_enc_close( &( st_ivas->hParamMC ), st_ivas->hEncoderConfig->input_Fs ); ivas_mc_paramupmix_enc_close( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs ); + /* De-allocate McMasa-related handles */ ivas_mcmasa_enc_close( &( st_ivas->hMcMasa ), st_ivas->hEncoderConfig->input_Fs ); @@ -767,7 +770,9 @@ static ivas_error ivas_mc_enc_reconfig( ivas_masa_enc_close( &( st_ivas->hMasa ) ); st_ivas->hMasa = NULL; } + ivas_mc_paramupmix_enc_close( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs ); + if ( last_mc_mode == MC_MODE_PARAMUPMIX && st_ivas->hLFE != NULL ) { /* LFE handle */ @@ -819,7 +824,9 @@ static ivas_error ivas_mc_enc_reconfig( } ivas_param_mc_enc_close( &( st_ivas->hParamMC ), st_ivas->hEncoderConfig->input_Fs ); + ivas_mc_paramupmix_enc_close( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs ); + if ( last_mc_mode == MC_MODE_PARAMUPMIX && st_ivas->hLFE != NULL ) { /* LFE handle */ @@ -887,9 +894,11 @@ static ivas_error ivas_mc_enc_reconfig( } st->igf = getIgfPresent( st->element_mode, st->total_brate, st->bwidth, st->rf_mode ); + /* set last core to TCX20 */ st->last_core = TCX_20_CORE; } + if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { ivas_mcmasa_split_brate( st_ivas->hMcMasa->separateChannelEnabled, st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &new_brate_SCE, &new_brate_CPE ); diff --git a/lib_enc/ivas_mct_enc_mct.c b/lib_enc/ivas_mct_enc_mct.c index 842007dd93..63875e5902 100755 --- a/lib_enc/ivas_mct_enc_mct.c +++ b/lib_enc/ivas_mct_enc_mct.c @@ -224,11 +224,9 @@ static void getBestCorrelation( *_ch2 = -1; *max_corr = 0.f; - for ( ch1 = 0; ch1 < ( hMCT->nchan_out_woLFE ); - ch1++ ) + for ( ch1 = 0; ch1 < ( hMCT->nchan_out_woLFE ); ch1++ ) { - for ( ch2 = ch1 + 1; ch2 < ( hMCT->nchan_out_woLFE ); - ch2++ ) + for ( ch2 = ch1 + 1; ch2 < ( hMCT->nchan_out_woLFE ); ch2++ ) { if ( fabsf( *max_corr ) < fabsf( xCorrMatrix[ch1][ch2] ) ) { @@ -309,11 +307,9 @@ static void updateCorrelationMatrix( int16_t ch1, ch2, n; /* correlation: */ - for ( ch1 = 0; ch1 < ( hMCT->nchan_out_woLFE ); - ch1++ ) + for ( ch1 = 0; ch1 < ( hMCT->nchan_out_woLFE ); ch1++ ) { - for ( ch2 = ch1; ch2 < ( hMCT->nchan_out_woLFE ); - ch2++ ) + for ( ch2 = ch1; ch2 < ( hMCT->nchan_out_woLFE ); ch2++ ) { if ( sts[ch1]->core == sts[ch2]->core && sts[ch1]->mct_chan_mode != MCT_CHAN_MODE_IGNORE && sts[ch2]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) @@ -766,8 +762,7 @@ void write_mct_bitstream( /* first write core info and overlap mode for all channels */ for ( ch = 0; ch < nchan; ch++ ) { - if ( - hMCT->currBlockDataCnt && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) + if ( hMCT->currBlockDataCnt && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { push_next_indice( hBstr, hMCT->mc_global_ild[ch], SMDCT_GLOBAL_ILD_BITS ); } @@ -777,8 +772,7 @@ void write_mct_bitstream( { for ( ch = 0; ch < nchan; ch++ ) { - if ( - sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) + if ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { push_next_indice( hBstr, hMCT->lowE_ch[ch], 1 ); } @@ -898,8 +892,7 @@ void mctStereoIGF_enc( /* channel elements that are coded separately detected */ if ( sum_s( singleChEle, ( hMCT->nchan_out_woLFE ) ) != 0 ) { - for ( ch = 0; ch < ( hMCT->nchan_out_woLFE ); - ch++ ) + for ( ch = 0; ch < ( hMCT->nchan_out_woLFE ); ch++ ) { if ( singleChEle[ch] ) { diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index 8630c97671..364764c56d 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -280,8 +280,9 @@ ivas_error ivas_osba_enc_reconfig( old_mem_hp20_in = NULL; } } - ivas_spar_config( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), - &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); + + ivas_spar_config( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); + hSpar = st_ivas->hSpar; if ( st_ivas->nchan_transport == 1 ) diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 318bc90ddd..011cb3aded 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -198,8 +198,9 @@ ivas_error ivas_sba_enc_reconfigure( old_mem_hp20_in = NULL; } } - ivas_spar_config( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), - &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); + + ivas_spar_config( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); + hSpar = st_ivas->hSpar; if ( st_ivas->nchan_transport == 1 ) diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 476a1f39c3..c61e5f9b41 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -185,8 +185,7 @@ ivas_error ivas_spar_enc_open( * Configuration - set SPAR high-level parameters *-----------------------------------------------------------------*/ - ivas_spar_config( hEncoderConfig->ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), - &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, -1 ); + ivas_spar_config( hEncoderConfig->ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, -1 ); if ( st_ivas->nchan_transport == 1 ) { -- GitLab From c5a61f67d7128820941a398666679f56fdb09e66 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 13 Sep 2023 10:58:47 +0200 Subject: [PATCH 02/13] add error returns, formatting, comments replace "#if defined XX" by "#ifdef XX" --- apps/decoder.c | 117 +++--- apps/renderer.c | 105 ++++-- lib_com/ivas_cnst.h | 2 +- lib_com/ivas_mdft_imdft.c | 4 +- lib_com/ivas_prot.h | 79 ++-- lib_dec/ivas_binRenderer_internal.c | 5 +- lib_dec/ivas_dec.c | 32 +- lib_dec/ivas_init_dec.c | 29 +- lib_dec/ivas_ism_dec.c | 16 +- lib_dec/ivas_ism_dtx_dec.c | 2 +- lib_dec/ivas_jbm_dec.c | 49 ++- lib_dec/ivas_masa_dec.c | 12 +- lib_dec/ivas_mct_dec.c | 35 +- lib_dec/ivas_omasa_dec.c | 4 +- lib_dec/ivas_qmetadata_dec.c | 1 + lib_dec/ivas_sba_dec.c | 25 +- lib_dec/lib_dec.c | 142 +++---- lib_dec/lib_dec.h | 61 ++- lib_enc/ivas_corecoder_enc_reconfig.c | 1 + lib_enc/ivas_mct_enc.c | 2 +- lib_enc/ivas_osba_enc.c | 1 + lib_rend/ivas_PredDecoder.c | 1 - lib_rend/ivas_prot_rend.h | 34 +- lib_rend/ivas_splitRendererPLC.c | 62 ++-- lib_rend/ivas_splitRendererPost.c | 71 ++-- lib_rend/ivas_splitRendererPre.c | 109 +++--- lib_rend/ivas_splitRenderer_utils.c | 40 +- lib_rend/lib_rend.c | 510 ++++++++++++-------------- lib_rend/lib_rend.h | 18 +- 29 files changed, 786 insertions(+), 783 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index be2cb2a6cc..2b4b01c9f4 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1736,7 +1736,7 @@ static ivas_error initOnFirstGoodFrame( IVAS_DEC_HANDLE hIvasDec, /* i/o: */ const DecArguments arg, /* i : */ const int16_t numInitialBadFrames, /* i : */ -#if defined( SPLIT_REND_WITH_HEAD_ROT ) +#ifdef SPLIT_REND_WITH_HEAD_ROT uint16_t *numOutSamples, /* i/o: */ int16_t *vec_pos_len, /* i/o: */ #else @@ -1864,22 +1864,18 @@ static ivas_error initOnFirstGoodFrame( else { #endif - if ( *pRemainingDelayNumSamples < -#if defined( SPLIT_REND_WITH_HEAD_ROT ) - *numOutSamples + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( *pRemainingDelayNumSamples < *numOutSamples ) #else - numOutSamples + if ( *pRemainingDelayNumSamples < numOutSamples ) #endif - ) { - if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, -#if defined( SPLIT_REND_WITH_HEAD_ROT ) - *numOutSamples +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, *numOutSamples * *pNumOutChannels - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK ) #else - numOutSamples + if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, numOutSamples * *pNumOutChannels - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK ) #endif - * *pNumOutChannels - - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nOutput audio file writer error\n" ); return error; @@ -1888,13 +1884,11 @@ static ivas_error initOnFirstGoodFrame( } else { - *pRemainingDelayNumSamples -= -#if defined( SPLIT_REND_WITH_HEAD_ROT ) - *numOutSamples +#ifdef SPLIT_REND_WITH_HEAD_ROT + *pRemainingDelayNumSamples -= *numOutSamples; #else - numOutSamples + *pRemainingDelayNumSamples -= numOutSamples; #endif - ; } #ifdef SPLIT_REND_WITH_HEAD_ROT } @@ -1984,10 +1978,9 @@ static ivas_error initOnFirstGoodFrame( } } -#if defined( SPLIT_REND_WITH_HEAD_ROT ) +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( *hSplitRendFileReadWrite != NULL ) { - int16_t enable5ms; if ( numOutSamples == NULL || vec_pos_len == NULL ) @@ -1995,7 +1988,10 @@ static ivas_error initOnFirstGoodFrame( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - IVAS_DEC_Get5msFlag( hIvasDec, &enable5ms ); + if ( ( error = IVAS_DEC_Get5msFlag( hIvasDec, &enable5ms ) ) != IVAS_ERR_OK ) + { + return error; + } /* real setting of the 5ms mode for split rendering is only known after the decoded first good frame, reset the variables needed in the main decoding loop accordingly here*/ if ( enable5ms ) @@ -2014,11 +2010,13 @@ static ivas_error initOnFirstGoodFrame( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * decodeG192() * * Read G.192 bitstream and decode in regular decoder *---------------------------------------------------------------------*/ + static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, @@ -2047,7 +2045,7 @@ static ivas_error decodeG192( int16_t nOutChannels = 0; int16_t delayNumSamples = -1; int16_t delayNumSamples_orig[3]; -#if defined( SPLIT_REND_WITH_HEAD_ROT ) +#ifdef SPLIT_REND_WITH_HEAD_ROT uint16_t nOutSamples = 0; #else int16_t nOutSamples = 0; @@ -2068,7 +2066,6 @@ static ivas_error decodeG192( IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS]; IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }; int16_t vec_pos_update, vec_pos_len; - #ifdef SPLIT_REND_WITH_HEAD_ROT IVAS_SPLIT_REND_BITS_DATA splitRendBits; SplitFileReadWrite *hSplitRendFileReadWrite; @@ -2223,8 +2220,7 @@ static ivas_error decodeG192( { if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), - RotationFileReader_getFilePath( headRotReader ) ); + fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( headRotReader ) ); goto cleanup; } } @@ -2234,12 +2230,11 @@ static ivas_error decodeG192( 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; @@ -2333,42 +2328,36 @@ static ivas_error decodeG192( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - error = IVAS_DEC_GetSplitBinauralBitstream( hIvasDec, - (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), - &splitRendBits, - &nSamplesRendered_loop, - &needNewFrame ); - nSamplesRendered += nSamplesRendered_loop; - nSamplesToRender -= nSamplesRendered_loop; - if ( error != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_GetSplitBinauralBitstream( hIvasDec, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), &splitRendBits, &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetSplitBinauralBitstream: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } + + nSamplesRendered += nSamplesRendered_loop; + nSamplesToRender -= nSamplesRendered_loop; } else { #endif - error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, -#if defined SPLIT_REND_WITH_HEAD_ROT - IVAS_DEC_PCM_INT16, - (void *) + +#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 - ( pcmBuf + nOutChannels * nSamplesRendered ), - &nSamplesRendered_loop, - &needNewFrame ); - nSamplesRendered += nSamplesRendered_loop; - nSamplesToRender -= nSamplesRendered_loop; - if ( error != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } + nSamplesRendered += nSamplesRendered_loop; + nSamplesToRender -= nSamplesRendered_loop; #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif - } while ( nSamplesRendered < nOutSamples && error == IVAS_ERR_OK ); if ( error == IVAS_ERR_END_OF_FILE ) @@ -2392,7 +2381,7 @@ static ivas_error decodeG192( hIvasDec, arg, numInitialBadFrames, -#if defined( SPLIT_REND_WITH_HEAD_ROT ) +#ifdef SPLIT_REND_WITH_HEAD_ROT &nOutSamples, &vec_pos_len, #else @@ -2593,8 +2582,6 @@ static ivas_error decodeG192( if ( arg.enableHeadRotation ) { IVAS_QUATERNION Quaternion; - - if ( ( error = HeadRotationFileReading( headRotReader, &Quaternion, &Pos[0] ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( headRotReader ) ); @@ -2616,7 +2603,7 @@ static ivas_error decodeG192( /* decode and get samples */ if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT IVAS_DEC_PCM_INT16, (void *) #endif @@ -2836,10 +2823,8 @@ static ivas_error printBitstreamInfoVoip( else { auPtr = au; /* might have been set to RTP packet in prev call */ - rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_readNextFrame( &rtpdumpDepacker, &rtpSequenceNumber, &rtpTimeStamp, - &nextPacketRcvTime_ms, - &isAMRWB_IOmode, &frameTypeIndex, &qBit, - &auPtr, (uint16_t *) &auSizeBits ); + rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_readNextFrame( &rtpdumpDepacker, &rtpSequenceNumber, &rtpTimeStamp, &nextPacketRcvTime_ms, &isAMRWB_IOmode, &frameTypeIndex, &qBit, &auPtr, (uint16_t *) &auSizeBits ); + /* EVS RTP payload format has timescale 16000, JBM uses 1000 internally */ rtpTimeStamp = rtpTimeStamp / 16; } @@ -3001,10 +2986,8 @@ static ivas_error decodeVoIP( else { auPtr = au; /* might have been set to RTP packet in prev call */ - rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_readNextFrame( &rtpdumpDepacker, &rtpSequenceNumber, &rtpTimeStamp, - &nextPacketRcvTime_ms, - &isAMRWB_IOmode, &frameTypeIndex, &qBit, - &auPtr, (uint16_t *) &auSize ); + rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_readNextFrame( &rtpdumpDepacker, &rtpSequenceNumber, &rtpTimeStamp, &nextPacketRcvTime_ms, &isAMRWB_IOmode, &frameTypeIndex, &qBit, &auPtr, (uint16_t *) &auSize ); + /* EVS RTP payload format has timescale 16000, JBM uses 1000 internally */ rtpTimeStamp = rtpTimeStamp / 16; } @@ -3039,7 +3022,7 @@ static ivas_error decodeVoIP( while ( 1 ) { -#if defined( SPLIT_REND_WITH_HEAD_ROT ) +#ifdef SPLIT_REND_WITH_HEAD_ROT uint16_t nOutSamples = 0; #else int16_t nOutSamples = 0; @@ -3049,6 +3032,7 @@ static ivas_error decodeVoIP( #else nOutSamples = (int16_t) ( arg.output_Fs / 1000 * JBM_FRONTEND_FETCH_FRAMESIZE_MS ); #endif + /* read all packets with a receive time smaller than the system time */ while ( nextPacketRcvTime_ms <= systemTime_ms ) { @@ -3101,11 +3085,10 @@ static ivas_error decodeVoIP( /* decode and get samples */ if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, -#if defined SPLIT_REND_WITH_HEAD_ROT - IVAS_DEC_PCM_INT16, - (void *) +#ifdef SPLIT_REND_WITH_HEAD_ROT + IVAS_DEC_PCM_INT16, (void *) #endif - pcmBuf, + pcmBuf, systemTime_ms #ifdef SUPPORT_JBM_TRACEFILE , @@ -3118,7 +3101,6 @@ static ivas_error decodeVoIP( goto cleanup; } - /* write JBM Offset file entry */ if ( jbmOffsetWriter != NULL ) { @@ -3150,14 +3132,14 @@ static ivas_error decodeVoIP( if ( decodedGoodFrame ) { #ifdef SPLIT_REND_WITH_HEAD_ROT - SplitFileReadWrite *hSplitRendFileReadWrite = NULL; #endif + error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, -#if defined( SPLIT_REND_WITH_HEAD_ROT ) +#ifdef SPLIT_REND_WITH_HEAD_ROT &nOutSamples, NULL, #else @@ -3192,7 +3174,6 @@ static ivas_error decodeVoIP( } } - /* Write current frame */ if ( decodedGoodFrame ) { diff --git a/apps/renderer.c b/apps/renderer.c index 51ebc4bd80..abfc4953d4 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -526,7 +526,12 @@ static int16_t getTotalNumInChannels( fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); exit( -1 ); } - IVAS_REND_GetNumAllObjects( hIvasRend, &numInputChannels ); /* In case of MASA output, modify the numInputChannels to contain all objects. Otherwise, keep the original value. */ + + /* In case of MASA output, modify the numInputChannels to contain all objects. Otherwise, keep the original value. */ + if ( ( error = IVAS_REND_GetNumAllObjects( hIvasRend, &numInputChannels ) ) != IVAS_ERR_OK ) + { + return error; + } totalNumInChannels += numInputChannels; } @@ -1104,7 +1109,8 @@ int main( if ( ( error = IVAS_REND_SetOrientationTrackingMode( hIvasRend, args.orientation_tracking ) ) != IVAS_ERR_OK ) { - return error; + fprintf( stderr, "Error in IVAS_REND_SetOrientationTrackingMode(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); } /* Set up output custom layout configuration */ @@ -1112,7 +1118,8 @@ int main( { if ( ( error = IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( hIvasRend, args.outConfig.outSetupCustom ) ) != IVAS_ERR_OK ) { - return error; + fprintf( stderr, "Error in IVAS_REND_ConfigureCustomOutputLoudspeakerLayout(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); } } @@ -1130,8 +1137,17 @@ int main( /* Set the total number of objects */ if ( args.inConfig.numAudioObjects > 0 ) { - IVAS_REND_SetTotalNumberOfObjects( hIvasRend, args.inConfig.numAudioObjects ); - IVAS_REND_SetIsmMetadataDelay( hIvasRend, args.syncMdDelay ); + if ( ( error = IVAS_REND_SetTotalNumberOfObjects( hIvasRend, args.inConfig.numAudioObjects ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in IVAS_REND_SetTotalNumberOfObjects(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + + if ( ( error = IVAS_REND_SetIsmMetadataDelay( hIvasRend, args.syncMdDelay ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in IVAS_REND_SetIsmMetadataDelay(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } } IVAS_REND_LfePanMtx lfePanMatrix; @@ -1164,7 +1180,8 @@ int main( { if ( ( error = IVAS_REND_ConfigureCustomInputLoudspeakerLayout( hIvasRend, mcIds[i], args.inConfig.inSetupCustom ) ) != IVAS_ERR_OK ) { - return error; + fprintf( stderr, "Error in IVAS_REND_ConfigureCustomInputLoudspeakerLayout(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); } } @@ -1317,21 +1334,29 @@ int main( int16_t numOutChannels; if ( ( error = IVAS_REND_NumOutChannels( hIvasRend, &numOutChannels ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + fprintf( stderr, "Error in IVAS_REND_NumOutChannels(): %s\n", ivas_error_to_string( error ) ); exit( -1 ); } #ifdef SPLIT_REND_WITH_HEAD_ROT if ( cldfb_in ) { - IVAS_REND_openCldfb( cldfbAna, cldfbSyn, totalNumInChannels, numOutChannels, args.sampleRate ); + if ( ( error = IVAS_REND_openCldfb( cldfbAna, cldfbSyn, totalNumInChannels, numOutChannels, args.sampleRate ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in IVAS_REND_openCldfb(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } } if ( args.outConfig.audioConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { - IVAS_REND_GetDelay( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ); - error = split_rend_writer_open( &hSplitRendFileReadWrite, args.outputFilePath, delayNumSamples_temp, delayTimeScale_temp ); - if ( error != IVAS_ERR_OK ) + if ( IVAS_REND_GetDelay( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to get delay of renderer!\n" ); + exit( -1 ); + } + + if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, args.outputFilePath, delayNumSamples_temp, delayTimeScale_temp ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Could not open split rend metadata file %s\n", args.outputFilePath ); exit( -1 ); @@ -1342,15 +1367,20 @@ int main( { if ( args.outConfig.audioConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - IVAS_REND_GetDelay( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ); - error = split_rend_writer_open( &hSplitRendFileReadWrite, args.outMetadataFilePath, delayNumSamples_temp, delayTimeScale_temp ); - if ( error != IVAS_ERR_OK ) + if ( IVAS_REND_GetDelay( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to get delay of renderer!\n" ); + exit( -1 ); + } + + if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, args.outMetadataFilePath, delayNumSamples_temp, delayTimeScale_temp ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Could not open split rend metadata file %s\n", args.outMetadataFilePath ); exit( -1 ); } } #endif + if ( AudioFileWriter_open( &audioWriter, args.outputFilePath, args.sampleRate, numOutChannels ) != IVAS_ERR_OK ) { fprintf( stderr, "Failed to open file: %s\n", args.outputFilePath ); @@ -1585,8 +1615,17 @@ int main( if ( splitRendBFIReader != NULL && splitBinNeedsNewFrame ) { int16_t bfi; - SplitRendBFIFileReading( splitRendBFIReader, &bfi ); - IVAS_REND_SetSplitRendBFI( hIvasRend, bfi ); + if ( ( error = SplitRendBFIFileReading( splitRendBFIReader, &bfi ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in SplitRendBFIFileReading(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + + if ( ( error = IVAS_REND_SetSplitRendBFI( hIvasRend, bfi ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in IVAS_REND_SetSplitRendBFI(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } } #endif @@ -1608,8 +1647,7 @@ int main( } for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) { - if ( ( error = IVAS_REND_SetExternalOrientation( hIvasRend, &quatBuffer[sf_idx], enableHeadRotation[sf_idx], enableExternalOrientation[sf_idx], enableRotationInterpolation[sf_idx], numFramesToTargetOrientation[sf_idx], - sf_idx ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_REND_SetExternalOrientation( hIvasRend, &quatBuffer[sf_idx], enableHeadRotation[sf_idx], enableExternalOrientation[sf_idx], enableRotationInterpolation[sf_idx], numFramesToTargetOrientation[sf_idx], sf_idx ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error setting External Orientation: %s\n", ivas_error_to_string( error ) ); exit( -1 ); @@ -1752,7 +1790,7 @@ int main( } #endif -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( args.inConfig.numBinBuses != 0 ) { if ( ( error = IVAS_REND_GetSplitBinauralSamples( hIvasRend, outBuffer, &splitBinNeedsNewFrame ) ) != IVAS_ERR_OK ) @@ -1761,8 +1799,7 @@ int main( exit( -1 ); } } - else if ( args.outConfig.audioConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || - args.outConfig.audioConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + else if ( args.outConfig.audioConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || args.outConfig.audioConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { if ( ( error = IVAS_REND_GetSplitBinauralBitstream( hIvasRend, outBuffer, &bitsBuffer ) ) != IVAS_ERR_OK ) { @@ -1782,7 +1819,7 @@ int main( #endif exit( -1 ); } -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT } #endif @@ -1908,26 +1945,42 @@ int main( if ( numInputFormats == 1 ) { - IVAS_REND_GetMasaMetadata( hIvasRend, &hMetaOutput, inputType1 ); + if ( ( error = IVAS_REND_GetMasaMetadata( hIvasRend, &hMetaOutput, inputType1 ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in IVAS_REND_GetMasaMetadata(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } } else { if ( args.inConfig.numAmbisonicsBuses > 0 && args.inConfig.numMultiChannelBuses > 0 ) { inputType2 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED; - IVAS_REND_MergeMasaMetadata( hIvasRend, &hMetaOutput, inputType1, inputType2 ); + if ( ( error = IVAS_REND_MergeMasaMetadata( hIvasRend, &hMetaOutput, inputType1, inputType2 ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in IVAS_REND_MergeMasaMetadata(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } } if ( ( args.inConfig.numAmbisonicsBuses > 0 || args.inConfig.numMultiChannelBuses > 0 ) && args.inConfig.numMasaBuses > 0 ) { inputType2 = IVAS_REND_AUDIO_CONFIG_TYPE_MASA; - IVAS_REND_MergeMasaMetadata( hIvasRend, &hMetaOutput, inputType1, inputType2 ); + if ( ( error = IVAS_REND_MergeMasaMetadata( hIvasRend, &hMetaOutput, inputType1, inputType2 ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in IVAS_REND_MergeMasaMetadata(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } } if ( ( args.inConfig.numAmbisonicsBuses > 0 || args.inConfig.numMultiChannelBuses > 0 || args.inConfig.numMasaBuses > 0 ) && args.inConfig.numAudioObjects > 0 ) { inputType2 = IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED; - IVAS_REND_MergeMasaMetadata( hIvasRend, &hMetaOutput, inputType1, inputType2 ); + if ( ( error = IVAS_REND_MergeMasaMetadata( hIvasRend, &hMetaOutput, inputType1, inputType2 ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in IVAS_REND_MergeMasaMetadata(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } } } diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index ec8674238c..cefee2f72e 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -130,7 +130,7 @@ typedef enum } ivas_renderTypeOverride; #endif -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT typedef enum { PCM_INT16, diff --git a/lib_com/ivas_mdft_imdft.c b/lib_com/ivas_mdft_imdft.c index ad9d19a910..0b03f63d90 100644 --- a/lib_com/ivas_mdft_imdft.c +++ b/lib_com/ivas_mdft_imdft.c @@ -231,10 +231,10 @@ void ivas_mdft( float im[L_FRAME48k]; int16_t j, len_by_2; const float *pTwid; + len_by_2 = mdft_length >> 1; - ivas_get_mdft_twid_factors( mdft_length, - &pTwid ); + ivas_get_mdft_twid_factors( mdft_length, &pTwid ); if ( mdft_length == input_length ) { diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 3550f7f861..e87d11fb93 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -301,9 +301,9 @@ void stereo_dmx_evs_close_encoder( ivas_error ivas_dec( Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + 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 @@ -312,11 +312,11 @@ ivas_error ivas_dec( 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) */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + 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 */ + int16_t *data /* o : output synthesis signal */ #endif ); @@ -657,11 +657,11 @@ ivas_error ivas_mc_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t idx, /* i : LS config. index */ uint16_t *nSamplesRendered, /* o : samples flushed from last frame (JBM) */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + 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 */ + int16_t *data /* o : output synthesis signal */ #endif ); @@ -777,7 +777,7 @@ ivas_error ivas_jbm_dec_render( const uint16_t nSamplesAsked, /* i : number of samples wanted */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ #else @@ -794,11 +794,11 @@ ivas_error ivas_jbm_dec_flush_renderer( const MC_MODE mc_mode_old, /* i : old MC mode */ const ISM_MODE ism_mode_old, /* i : old ISM mode */ uint16_t *nSamplesRendered, /* o : number of samples flushed */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + 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 */ + int16_t *data /* o : output synthesis signal */ #endif ); @@ -841,14 +841,15 @@ int16_t ivas_jbm_dec_get_num_tc_channels( void ivas_jbm_dec_copy_tc_no_tsm( Decoder_Struct *st_ivas, float *tc[], - const int16_t output_frame ); + const int16_t output_frame +); void ivas_jbm_dec_get_md_map_even_spacing( - const int16_t len, /* i : length of the modfied frames in metadata slots */ - const int16_t subframe_len, /* i : default length of a subframe */ - const int16_t offset, /* i : current read offset into the md buffer */ - const int16_t buf_len, /* i : length of the metadata buffer */ - int16_t *map /* o : metadata index map */ + const int16_t len, /* i : length of the modfied frames in metadata slots */ + const int16_t subframe_len, /* i : default length of a subframe */ + const int16_t offset, /* i : current read offset into the md buffer */ + const int16_t buf_len, /* i : length of the metadata buffer */ + int16_t *map /* o : metadata index map */ ); TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( @@ -860,7 +861,7 @@ int16_t ivas_jbm_dec_get_render_granularity( const RENDERER_TYPE rendererType, /* i : renderer type */ const IVAS_FORMAT ivas_format, /* i : ivas format */ const MC_MODE mc_mode, /* i : MC mode */ - const int32_t output_Fs /* i : sampling rate */ + const int32_t output_Fs /* i : sampling rate */ ); ivas_error ivas_jbm_dec_tc_buffer_open( @@ -1063,11 +1064,11 @@ ivas_error ivas_ism_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const ISM_MODE last_ism_mode, /* i/o: last ISM mode */ uint16_t *nSamplesRendered, /* o : number of samples flushed on renderer change*/ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + 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 */ + int16_t *data /* o : output synthesis signal */ #endif ); @@ -1097,10 +1098,10 @@ void ivas_param_ism_dec_digest_tc( ); void ivas_ism_param_dec_tc_gain_ajust( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamples, /* i : number of samples to be compensate */ - const uint16_t nFadeLength, /* i : length of the crossfade in samples */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamples, /* i : number of samples to be compensate */ + const uint16_t nFadeLength, /* i : length of the crossfade in samples */ + float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ ); void ivas_param_ism_dec_render( @@ -4977,11 +4978,11 @@ void ivas_masa_enc_reconfigure( ivas_error ivas_masa_dec_reconfigure( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + 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 */ + int16_t *data /* o : output synthesis signal */ #endif ); @@ -5703,11 +5704,11 @@ ivas_error ivas_omasa_enc_config( ivas_error ivas_omasa_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + 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 */ + int16_t *data /* o : output synthesis signal */ #endif ); diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index c14d3058d8..127c4a1c39 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1028,7 +1028,10 @@ ivas_error ivas_rend_openCldfbRend( hBinRenderer->hInputSetup->is_loudspeaker_setup = 0; hBinRenderer->hInputSetup->output_config = inConfig; - getAudioConfigNumChannels( inConfig, &hBinRenderer->hInputSetup->nchan_out_woLFE ); + if ( ( error = getAudioConfigNumChannels( inConfig, &hBinRenderer->hInputSetup->nchan_out_woLFE ) ) != IVAS_ERR_OK ) + { + return error; + } if ( outConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 87cd76014d..73e3550cc5 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -53,7 +53,7 @@ ivas_error ivas_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ #else @@ -73,7 +73,7 @@ ivas_error ivas_dec( float *p_output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; int16_t num_md_sub_frames; int32_t ism_total_brate; -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT int16_t nchan_out_syn_output; #endif @@ -109,7 +109,7 @@ ivas_error ivas_dec( return error; } -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { @@ -1088,7 +1088,7 @@ ivas_error ivas_dec( * - float to integer conversion *----------------------------------------------------------------*/ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses; @@ -1102,17 +1102,15 @@ ivas_error ivas_dec( #endif { #ifndef DISABLE_LIMITER - ivas_limiter_dec( st_ivas->hLimiter, p_output, -#if defined SPLIT_REND_WITH_HEAD_ROT - nchan_out_syn_output, +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out_syn_output, output_frame, st_ivas->BER_detect ); #else - nchan_out, + ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out, output_frame, st_ivas->BER_detect ); #endif - output_frame, st_ivas->BER_detect ); #endif } -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT switch ( pcm_resolution ) { case PCM_INT16: @@ -1120,18 +1118,13 @@ ivas_error ivas_dec( #ifdef DEBUGGING st_ivas->noClipping += #endif - ivas_syn_output( p_output, output_frame, -#if defined SPLIT_REND_WITH_HEAD_ROT - nchan_out_syn_output, +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_syn_output( p_output, output_frame, nchan_out_syn_output, (int16_t *) data ); #else - nchan_out, -#endif -#if defined SPLIT_REND_WITH_HEAD_ROT - (int16_t *) + ivas_syn_output( p_output, output_frame, nchan_out, data ); #endif - data ); -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT break; case PCM_FLOAT32: ivas_syn_output_f( p_output, output_frame, nchan_out_syn_output, (float *) data ); @@ -1141,6 +1134,7 @@ ivas_error ivas_dec( break; } #endif + /*----------------------------------------------------------------* * Common updates *----------------------------------------------------------------*/ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 3912f0ddfb..c62dc76c1b 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -254,6 +254,7 @@ static ivas_error ivas_dec_init_split_rend( { return error; } + #ifdef OSBA_SPLIT_RENDERING if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) { @@ -261,11 +262,8 @@ static ivas_error ivas_dec_init_split_rend( } #endif - error = ivas_split_renderer_open( &st_ivas->hSplitBinRend.splitrend, - &st_ivas->hRenderConfig->split_rend_config, - st_ivas->hDecoderConfig->output_Fs, - cldfb_in, pcm_out, - st_ivas->hDecoderConfig->Opt_5ms ); + error = ivas_split_renderer_open( &st_ivas->hSplitBinRend.splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in, pcm_out, st_ivas->hDecoderConfig->Opt_5ms ); + return error; } #endif @@ -280,9 +278,9 @@ static ivas_error ivas_dec_init_split_rend( 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) */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + 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 @@ -337,7 +335,7 @@ ivas_error ivas_dec_setup( st_ivas->nchan_ism = nchan_ism; if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_resolution, #endif data ) ) != IVAS_ERR_OK ) @@ -398,7 +396,7 @@ ivas_error ivas_dec_setup( else { if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_resolution, #endif data ) ) != IVAS_ERR_OK ) @@ -410,7 +408,7 @@ ivas_error ivas_dec_setup( else { if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_resolution, #endif data ) ) != IVAS_ERR_OK ) @@ -435,7 +433,7 @@ ivas_error ivas_dec_setup( if ( ( ivas_total_brate > IVAS_SID_5k2 && ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) || ( st_ivas->ini_active_frame == 0 ) ) { if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_resolution, #endif data ) ) != IVAS_ERR_OK ) @@ -511,10 +509,9 @@ ivas_error ivas_dec_setup( /* select MC format mode; reconfigure the MC format decoder */ ivas_mc_dec_config( st_ivas, idx, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_resolution, #endif - data ); } @@ -631,7 +628,7 @@ ivas_error ivas_dec_setup( } if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_resolution, #endif data ) ) != IVAS_ERR_OK ) @@ -1539,6 +1536,7 @@ ivas_error ivas_init_decoder( st_ivas->nchan_transport += st_ivas->nchan_ism; } #endif + if ( st_ivas->nCPE > 1 ) { if ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) @@ -1552,6 +1550,7 @@ ivas_error ivas_init_decoder( st_ivas->nchan_transport -= st_ivas->nchan_ism; } #endif + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 5bc40fb999..507c5d77b5 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -51,9 +51,9 @@ static ivas_error ivas_ism_bitrate_switching_dec( const int16_t nchan_transport_old, /* i : last number of transport channels */ const ISM_MODE last_ism_mode, /* i : last ISM mode */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + 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 @@ -147,7 +147,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, MC_MODE_NONE, last_ism_mode, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_resolution, #endif data ) ) != IVAS_ERR_OK ) @@ -428,9 +428,9 @@ ivas_error ivas_ism_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const ISM_MODE last_ism_mode, /* i/o: last ISM mode */ uint16_t *nSamplesRendered, /* o : number of samples flushed when the renderer granularity changes */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#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 @@ -473,7 +473,7 @@ ivas_error ivas_ism_dec_config( 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, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_resolution, #endif data ) ) != IVAS_ERR_OK ) @@ -500,7 +500,7 @@ ivas_error ivas_ism_dec_config( if ( st_ivas->ism_mode != last_ism_mode ) { if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_resolution, #endif data ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec.c index cf5d6311b9..80a4e1e2e5 100644 --- a/lib_dec/ivas_ism_dtx_dec.c +++ b/lib_dec/ivas_ism_dtx_dec.c @@ -97,7 +97,7 @@ ivas_error ivas_ism_dtx_dec( } if ( ( error = ivas_ism_dec_config( st_ivas, last_ism_mode, NULL, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT PCM_NOT_KNOW, #endif NULL ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 7ba2283e7d..41ee60eb59 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -771,9 +771,9 @@ ivas_error ivas_jbm_dec_render( const uint16_t nSamplesAsked, /* i : number of samples wanted */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + 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 @@ -807,7 +807,6 @@ ivas_error ivas_jbm_dec_render( output_config = st_ivas->hDecoderConfig->output_config; nSamplesAskedLocal = nSamplesAsked + st_ivas->hTcBuffer->n_samples_discard; - for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) { p_output[n] = &output[n][0]; @@ -1165,11 +1164,11 @@ ivas_error ivas_jbm_dec_render( st_ivas->hTcBuffer->n_samples_discard = 0; } -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->Opt_Limiter ) #endif { - if ( !( st_ivas->ivas_format == MONO_FORMAT ) ) + if ( st_ivas->ivas_format != MONO_FORMAT ) { #ifndef DISABLE_LIMITER ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out, *nSamplesRendered, st_ivas->BER_detect ); @@ -1177,7 +1176,7 @@ ivas_error ivas_jbm_dec_render( } } -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT switch ( pcm_resolution ) { case PCM_INT16: @@ -1185,13 +1184,13 @@ ivas_error ivas_jbm_dec_render( #ifdef DEBUGGING st_ivas->noClipping += #endif - ivas_syn_output( p_output, *nSamplesRendered, nchan_out, -#if defined SPLIT_REND_WITH_HEAD_ROT - (int16_t *) +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_syn_output( p_output, *nSamplesRendered, nchan_out, (int16_t *) data ); +#else + ivas_syn_output( p_output, *nSamplesRendered, nchan_out, data ); #endif - data ); -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT break; case PCM_FLOAT32: ivas_syn_output_f( p_output, *nSamplesRendered, nchan_out, (float *) data ); @@ -1201,7 +1200,9 @@ ivas_error ivas_jbm_dec_render( break; } #endif + *nSamplesAvailableNext = st_ivas->hTcBuffer->n_samples_available; + pop_wmops(); return error; } @@ -1222,7 +1223,7 @@ ivas_error ivas_jbm_dec_flush_renderer( const MC_MODE mc_mode_old, /* i : old MC mode */ const ISM_MODE ism_mode_old, /* i : old ISM mode */ uint16_t *nSamplesRendered, /* o : number of samples flushed */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ #else @@ -1379,7 +1380,7 @@ ivas_error ivas_jbm_dec_flush_renderer( } /* Only write out the valid data*/ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->Opt_Limiter ) #endif { @@ -1391,7 +1392,7 @@ ivas_error ivas_jbm_dec_flush_renderer( } } -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT switch ( pcm_resolution ) { case PCM_INT16: @@ -1400,12 +1401,12 @@ ivas_error ivas_jbm_dec_flush_renderer( st_ivas->noClipping += #endif ivas_syn_output( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT (int16_t *) #endif data ); -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT break; case PCM_FLOAT32: ivas_syn_output_f( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (float *) data ); @@ -1703,16 +1704,12 @@ int16_t ivas_jbm_dec_get_num_tc_channels( } if ( st_ivas->ivas_format == SBA_FORMAT ) { - if ( -#ifndef NONBE_FIX_770_PLANAR_SBA_JBM - ( st_ivas->sba_planar && num_tc >= 3 ) || - ( -#endif - num_tc == 3 -#ifndef NONBE_FIX_770_PLANAR_SBA_JBM - ) + +#ifdef NONBE_FIX_770_PLANAR_SBA_JBM + if ( num_tc == 3 ) +#else + if ( ( st_ivas->sba_planar && num_tc >= 3 ) || num_tc == 3 ) #endif - ) { num_tc++; } diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 565bce884e..1d56e4a426 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1225,11 +1225,11 @@ static int16_t decode_lfe_to_total_energy_ratio( *-------------------------------------------------------------------*/ ivas_error ivas_masa_dec_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ + 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 */ #else int16_t *data /* o : output synthesis signal */ #endif @@ -1484,7 +1484,7 @@ ivas_error ivas_masa_dec_reconfigure( if ( n_samples_granularity < st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, n_samples_granularity, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, MC_MODE_NONE, ISM_MASA_MODE_DISC, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_resolution, #endif data ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index f6c32eae31..471f9e2cf9 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -55,7 +55,7 @@ *-----------------------------------------------------------------------*/ static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas, uint16_t *nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ #else @@ -378,6 +378,7 @@ ivas_error create_mct_dec( cp_bitrate = st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport * CPE_CHANNELS; } #endif + /* indicate LFE for appropriate core-coder channel */ for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { @@ -515,6 +516,7 @@ ivas_error mct_dec_reconfigure( cp_bitrate = st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport * CPE_CHANNELS; } #endif + /* set correct nominal bitrates and igf config already here, otherwise we * run into a number of problems */ for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) @@ -657,9 +659,9 @@ ivas_error ivas_mc_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t idx, /* i : LS config. index */ uint16_t *nSamplesRendered, /* o : samples flushed from last frame (JBM) */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + 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 @@ -669,8 +671,6 @@ ivas_error ivas_mc_dec_config( MC_MODE last_mc_mode; ivas_error error; - error = IVAS_ERR_OK; - /* store last frame MC mode */ last_mc_mode = st_ivas->mc_mode; @@ -692,18 +692,21 @@ ivas_error ivas_mc_dec_config( { if ( st_ivas->hDecoderConfig->last_ivas_total_brate != st_ivas->hDecoderConfig->ivas_total_brate || st_ivas->transport_config != signaled_config || last_mc_mode != st_ivas->mc_mode ) { - ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, + if ( ( error = ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, +#ifdef SPLIT_REND_WITH_HEAD_ROT + pcm_resolution, #endif - data ); + data ) ) != IVAS_ERR_OK ) + { + return error; + } } } st_ivas->transport_config = signaled_config; } - return error; + return IVAS_ERR_OK; } @@ -716,7 +719,7 @@ ivas_error ivas_mc_dec_config( static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the last frame (JBM) */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ #else @@ -804,7 +807,7 @@ static ivas_error ivas_mc_dec_reconfig( if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_resolution, #endif data ) ) != IVAS_ERR_OK ) @@ -822,7 +825,6 @@ static ivas_error ivas_mc_dec_reconfig( } } - if ( st_ivas->mc_mode == MC_MODE_MCT ) { st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ) ); @@ -1105,7 +1107,6 @@ static ivas_error ivas_mc_dec_reconfig( } } - /*-----------------------------------------------------------------* * re-configure HP20 memories *-----------------------------------------------------------------*/ @@ -1115,10 +1116,10 @@ static ivas_error ivas_mc_dec_reconfig( return error; } - /*-----------------------------------------------------------------* * Allocate the LFE handle that is coded separately after the allocation of the core coders *-----------------------------------------------------------------*/ + if ( ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) && st_ivas->hLFE == NULL ) { int32_t binauralization_delay_ns = st_ivas->binaural_latency_ns; @@ -1263,6 +1264,7 @@ static ivas_error ivas_mc_dec_reconfig( #ifdef SPLIT_REND_WITH_HEAD_ROT st_ivas->hCrendWrapper->hCrend[0] = NULL; st_ivas->hCrendWrapper->hHrtfCrend = NULL; + if ( ( st_ivas->hCrendWrapper->hCrend[0] = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" ); @@ -1325,6 +1327,7 @@ static ivas_error ivas_mc_dec_reconfig( /*-----------------------------------------------------------------* * Reconfigure TC buffer *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) { int16_t tc_nchan_full_new; diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 1f0a432753..4b104630c2 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -154,7 +154,7 @@ void ivas_omasa_data_close( ivas_error ivas_omasa_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ #else @@ -203,7 +203,7 @@ ivas_error ivas_omasa_dec_config( st_ivas->hCPE[0]->nchan_out = 1; } else if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_resolution, #endif data ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c index f949a16dec..a003a7ae9e 100644 --- a/lib_dec/ivas_qmetadata_dec.c +++ b/lib_dec/ivas_qmetadata_dec.c @@ -3777,6 +3777,7 @@ static int16_t read_coherence_data( #ifdef NONBE_FIX_760_COHERENCE_MASA int16_t extra_cv; #endif + coding_subbands = hQMetaData->q_direction[idx_dir].cfg.nbands; #ifdef NONBE_FIX_760_COHERENCE_MASA extra_cv = (int16_t) ( coding_subbands / MASA_FACTOR_CV_COH ); diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index e9bfb8e9ec..510f974f75 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -288,12 +288,14 @@ ivas_error ivas_sba_dec_reconfigure( { ivas_binRenderer_close( &st_ivas->hBinRenderer ); } + #ifdef NONBE_FIX_736_FOA_BR_SWITCH if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK ) { return error; } #endif + #ifndef NONBE_FIX_736_FOA_BR_SWITCH if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO ) ) || ( last_ivas_total_brate > IVAS_256k && ivas_total_brate <= IVAS_256k ) || ( last_ivas_total_brate <= IVAS_256k && ivas_total_brate > IVAS_256k ) ) #else @@ -326,14 +328,6 @@ ivas_error ivas_sba_dec_reconfigure( #ifdef NONBE_FIX_736_FOA_BR_SWITCH else { -#endif -#ifndef NONBE_FIX_736_FOA_BR_SWITCH - if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif -#ifdef NONBE_FIX_736_FOA_BR_SWITCH int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1]; st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); @@ -349,6 +343,7 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); } #endif + if ( st_ivas->renderer_type == RENDERER_DISABLE ) { ivas_dirac_rend_close( &( st_ivas->hDirACRend ) ); @@ -366,6 +361,7 @@ ivas_error ivas_sba_dec_reconfigure( /*-----------------------------------------------------------------* * Allocate, initialize, and configure SCE/CPE/MCT handles *-----------------------------------------------------------------*/ + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { if ( ism_mode_old == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) @@ -392,6 +388,7 @@ ivas_error ivas_sba_dec_reconfigure( return error; } } + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { /* Allocate TD renderer for the objects in DISC mode */ @@ -403,10 +400,12 @@ ivas_error ivas_sba_dec_reconfigure( } } } + if ( ( error = ivas_masa_ism_data_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } + /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ if ( ( error = ivas_sba_ism_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) { @@ -516,6 +515,7 @@ ivas_error ivas_sba_dec_reconfigure( /*-----------------------------------------------------------------* * JBM TC buffer *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) { int16_t tc_nchan_to_allocate; @@ -588,6 +588,7 @@ ivas_error ivas_sba_dec_reconfigure( return error; } + /*-------------------------------------------------------------------* * ivas_sba_dec_digest_tc() * @@ -679,11 +680,11 @@ ivas_error ivas_sba_dec_digest_tc( *-------------------------------------------------------------------*/ ivas_error ivas_sba_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ uint16_t *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + float *output_f[] /* o : rendered time signal */ ) { int16_t slots_to_render, first_sf, last_sf, subframe_idx; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 13d2448603..b1efc21118 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -106,7 +106,7 @@ static void init_decoder_config( DECODER_CONFIG_HANDLE hDecoderConfig ); static int16_t IVAS_DEC_VoIP_GetRenderGranularity( Decoder_Struct *st_ivas ); static ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t nTransportChannels, const uint16_t l_ts ); static ivas_error IVAS_DEC_Setup( IVAS_DEC_HANDLE hIvasDec, uint16_t *nTcBufferGranularity, uint8_t *nTransportChannels, uint8_t *nOutChannels, uint16_t *nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const IVAS_DEC_PCM_TYPE pcmType, void *data #else @@ -116,7 +116,7 @@ static ivas_error IVAS_DEC_Setup( IVAS_DEC_HANDLE hIvasDec, uint16_t *nTcBufferG static ivas_error IVAS_DEC_GetTcSamples( IVAS_DEC_HANDLE hIvasDec, float *pcmBuf, int16_t *nOutSamples ); static ivas_error IVAS_DEC_RendererFeedTcSamples( IVAS_DEC_HANDLE hIvasDec, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *pcmBuf ); static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const uint16_t nSamplesForRendering, uint16_t *nSamplesRendered, uint16_t *nSamplesAvailableNext, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT IVAS_DEC_PCM_TYPE pcmType, void *pcmBuf #else @@ -125,11 +125,13 @@ static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const u #endif ); static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec, int16_t *nSamplesBuffered ); -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT 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, int32_t offset ); +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, int16_t nZeroSamples ); #endif + + /*---------------------------------------------------------------------* * IVAS_DEC_Open() * @@ -466,7 +468,8 @@ ivas_error IVAS_DEC_Configure( return error; } -#if defined( SPLIT_REND_WITH_HEAD_ROT ) + +#ifdef SPLIT_REND_WITH_HEAD_ROT /*---------------------------------------------------------------------* * IVAS_DEC_EnableSplitRendering( ) * @@ -474,7 +477,7 @@ 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; @@ -701,7 +704,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( static ivas_error _GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const PCM_RESOLUTION pcm_resolution, void *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 */ #else @@ -731,7 +734,7 @@ static ivas_error _GetSamples( #endif if ( ( error = evs_dec_main( st_ivas, *nOutSamples, NULL, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT (int16_t *) #endif pcmBuf ) ) != IVAS_ERR_OK ) @@ -743,8 +746,7 @@ static ivas_error _GetSamples( { /* run the main IVAS decoding routine */ if ( ( error = ivas_dec( st_ivas, - -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_resolution, #endif pcmBuf ) ) != IVAS_ERR_OK ) @@ -762,10 +764,12 @@ static ivas_error _GetSamples( return error; } + + 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 */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#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 @@ -825,7 +829,7 @@ ivas_error IVAS_DEC_GetSamples( { /* setup */ if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ) #else @@ -836,14 +840,15 @@ ivas_error IVAS_DEC_GetSamples( { return error; } -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT /* :TODO: change nSamplesAsked also if we are in 5ms 0dof split rendering... */ #endif } + if ( !hIvasDec->st_ivas->hDecoderConfig->Opt_5ms ) { if ( ( error = _GetSamples( hIvasDec, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_type_API_to_internal( pcmType ), #endif pcmBuf, nOutSamples ) ) != IVAS_ERR_OK ) @@ -867,10 +872,15 @@ ivas_error IVAS_DEC_GetSamples( { int16_t nResidualSamples, nSamplesTcsScaled; nSamplesRendered += nSamplesRendered_loop; + if ( nTransportChannels != hIvasDec->nTransportChannelsOld ) { - IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ); + if ( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ) != IVAS_ERR_OK ) + { + return error; + } } + /* decode TCs only */ if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) { @@ -897,8 +907,6 @@ ivas_error IVAS_DEC_GetSamples( nSamplesTcsScaled = nTimeScalerOutSamples / nTransportChannels; /* render IVAS frames */ - - if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ) ) != IVAS_ERR_OK ) { return error; @@ -914,10 +922,11 @@ ivas_error IVAS_DEC_GetSamples( } hIvasDec->hasBeenFedFrame = false; } + /* render IVAS frames directly to the output buffer */ nSamplesToRender = nSamplesAsked - nSamplesRendered; if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ) #else @@ -947,13 +956,20 @@ ivas_error IVAS_DEC_GetSamples( return error; } -#if defined SPLIT_REND_WITH_HEAD_ROT + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*---------------------------------------------------------------------* + * IVAS_DEC_GetSplitBinauralBitstream( ) + * + * + *---------------------------------------------------------------------*/ + 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 */ - IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits, /* o : bitstream output for split rendering mode*/ - int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ - bool *needNewFrame /* 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 */ + IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits, /* o : bitstream output for split rendering mode */ + int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ + bool *needNewFrame /* indication that the decoder needs a new frame */ ) { Decoder_Struct *st_ivas; @@ -983,11 +999,15 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( *needNewFrame = FALSE; hSplitBinRend = &st_ivas->hSplitBinRend; - ivas_set_split_rend_setup( hSplitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, hSplitRendBits ); + + if ( ( error = ivas_set_split_rend_setup( hSplitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, hSplitRendBits ) ) != IVAS_ERR_OK ) + { + return error; + } + numPoses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; - if ( st_ivas->hDecoderConfig->Opt_5ms && - hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && + if ( st_ivas->hDecoderConfig->Opt_5ms && hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && ( hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE || hIvasDec->st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) { @@ -997,8 +1017,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( if ( hSplitBinRend->tdDataOut == NULL ) { /* Allocate enough space to save all decoded samples that will not be split encoded directly after decoding */ - hSplitBinRend->tdDataOut = malloc( numSamplesPerChannelCacheSize * BINAURAL_CHANNELS * numPoses * sizeof( float ) ); - if ( hSplitBinRend->tdDataOut == NULL ) + if ( ( hSplitBinRend->tdDataOut = malloc( numSamplesPerChannelCacheSize * BINAURAL_CHANNELS * numPoses * sizeof( float ) ) ) == NULL ) { return IVAS_ERR_FAILED_ALLOC; } @@ -1018,14 +1037,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( if ( numSamplesPerChannelToDecode == numSamplesPerChannelToSplitEncode || hSplitBinRend->numTdSamplesPerChannelCached == 0 ) { /* Decode and render */ - error = IVAS_DEC_GetSamples( - hIvasDec, - numSamplesPerChannelToDecode, - IVAS_DEC_PCM_FLOAT, - pcmBuf, - nOutSamples, - needNewFrame ); - if ( error != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, numSamplesPerChannelToDecode, IVAS_DEC_PCM_FLOAT, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) { return error; } @@ -1089,7 +1101,6 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural, max_band, pOutput, - 1, td_input, pcm_out ); @@ -1104,25 +1115,18 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( if ( st_ivas->hDecoderConfig->Opt_5ms ) { #ifndef DISABLE_LIMITER - ivas_limiter_dec( st_ivas->hLimiter, pOutput, - st_ivas->hDecoderConfig->nchan_out, - numSamplesPerChannelToSplitEncode, st_ivas->BER_detect ); + ivas_limiter_dec( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToSplitEncode, st_ivas->BER_detect ); #endif } else { - ivas_limiter_dec( st_ivas->hLimiter, pOutput, - st_ivas->hDecoderConfig->nchan_out, - numSamplesPerChannelToSplitEncode, st_ivas->BER_detect ); + ivas_limiter_dec( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToSplitEncode, st_ivas->BER_detect ); } - #ifdef DEBUGGING st_ivas->noClipping += #endif - ivas_syn_output( pOutput, numSamplesPerChannelToSplitEncode, - st_ivas->hDecoderConfig->nchan_out, - (int16_t *) pcmBuf_out ); + ivas_syn_output( pOutput, numSamplesPerChannelToSplitEncode, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); } free( st_ivas->hSplitBinRend.hMultiBinCldfbData ); @@ -1144,7 +1148,7 @@ static ivas_error IVAS_DEC_Setup( uint8_t *nTransportChannels, /* o : number of decoded transport PCM channels */ uint8_t *nOutChannels, /* o : number of decoded out channels (PCM or CLDFB) */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the last frame */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ #else @@ -1188,7 +1192,7 @@ static ivas_error IVAS_DEC_Setup( if ( st_ivas->bfi == 0 ) { if ( ( error = ivas_dec_setup( st_ivas, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_type_API_to_internal( pcmType ), #endif data ) ) != IVAS_ERR_OK ) @@ -1304,7 +1308,7 @@ static ivas_error IVAS_DEC_GetRenderedSamples( 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 */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT IVAS_DEC_PCM_TYPE pcmType, void *pcmBuf #else @@ -1326,7 +1330,7 @@ static ivas_error IVAS_DEC_GetRenderedSamples( /* run the main IVAS decoding routine */ if ( ( error = ivas_jbm_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_type_API_to_internal( pcmType ), #endif pcmBuf ) ) != IVAS_ERR_OK ) @@ -1549,7 +1553,7 @@ ivas_error IVAS_DEC_FeedHeadTrackData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_QUATERNION orientation, /* i : head-tracking data, listener orientation */ IVAS_VECTOR3 Pos, /* i : listener position */ - const int16_t subframe_idx /*subframe index*/ + const int16_t subframe_idx /* i : subframe index */ #ifdef SPLIT_REND_WITH_HEAD_ROT , const IVAS_SPLIT_REND_ROT_AXIS rot_axis @@ -2261,7 +2265,7 @@ ivas_error IVAS_DEC_VoIP_SetScale( 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 */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT IVAS_DEC_PCM_TYPE pcmType, void *pcmBuf, #else @@ -2406,7 +2410,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( /* codec mode to use not known yet - simply output silence */ /* directly set output zero */ int16_t nSamplesToZero = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT set_pcm_buffer_to_zero( pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ), pcmType, nSamplesToZero * nOutChannels ); #else set_s( pcmBuf + nSamplesRendered * nOutChannels, 0, nSamplesToZero * nOutChannels ); @@ -2423,7 +2427,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( /* render IVAS frames directly to the output buffer */ if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ), #else @@ -2433,12 +2437,15 @@ ivas_error IVAS_DEC_VoIP_GetSamples( { return error; } + nSamplesRendered += nSamplesRendered_loop; } } + return error; } + /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_Flush( ) * @@ -2448,7 +2455,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( 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 */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const IVAS_DEC_PCM_TYPE pcmType, void *pcmBuf, #else @@ -2461,14 +2468,13 @@ ivas_error IVAS_DEC_Flush( uint16_t nSamplesToRender; uint16_t nSamplesFlushedLocal; - error = IVAS_ERR_OK; - *nSamplesFlushed = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); nSamplesToRender = (uint16_t) *nSamplesFlushed; + /* render IVAS frames */ if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcmType, #endif pcmBuf ) ) != IVAS_ERR_OK ) @@ -2476,7 +2482,7 @@ ivas_error IVAS_DEC_Flush( return error; } - return error; + return IVAS_ERR_OK; } @@ -3504,8 +3510,18 @@ ivas_error IVAS_DEC_GetCldfbSamples( } #endif -#if defined SPLIT_REND_WITH_HEAD_ROT -void *pcm_buffer_offset( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, int32_t offset ) + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*---------------------------------------------------------------------* + * pcm_buffer_offset() + * + * + *---------------------------------------------------------------------*/ + +static void *pcm_buffer_offset( + void *buffer, + const IVAS_DEC_PCM_TYPE pcmType, + const int32_t offset ) { switch ( pcmType ) { diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 80f2f46aa3..448323d219 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -74,7 +74,7 @@ typedef enum _IVAS_DEC_FORCED_REND_MODE } IVAS_DEC_FORCED_REND_MODE; #endif -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT typedef enum _IVAS_DEC_PCM_TYPE { IVAS_DEC_PCM_INT16, @@ -157,29 +157,27 @@ ivas_error IVAS_DEC_FeedFrame_Serial( /*! r: decoder error code */ 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 */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ - void *pcmBuf, /* o : output synthesis signal */ + 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 */ #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 */ + 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 /* indication that the decoder needs a new frame */ + int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ ); -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT 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 */ - IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits, /* o : bitstream output for split rendering mode */ - int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ - bool *needNewFrame /* 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 */ + IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits, /* o : bitstream output for split rendering mode */ + int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ ); -#endif -#ifdef SPLIT_REND_WITH_HEAD_ROT /*! r: decoder error code */ ivas_error IVAS_DEC_GetSplitRendBits( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ @@ -214,12 +212,12 @@ ivas_error IVAS_DEC_GetMasaMetadata( /*! r: error code */ ivas_error IVAS_DEC_FeedHeadTrackData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_QUATERNION orientation, /* i : head-tracking data, listener orientation */ - IVAS_VECTOR3 Pos, /* i : listener position */ - const int16_t subframe_idx /*subframe index*/ + IVAS_QUATERNION orientation, /* i : head-tracking data, listener orientation */ + IVAS_VECTOR3 Pos, /* i : listener position */ + const int16_t subframe_idx /* i : subframe index */ #ifdef SPLIT_REND_WITH_HEAD_ROT , - IVAS_SPLIT_REND_ROT_AXIS rot_axis /*i : external control for rotation axis for split rendering */ + IVAS_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ #endif ); @@ -238,12 +236,12 @@ ivas_error IVAS_DEC_FeedRefVectorData( /*! r: error code */ ivas_error IVAS_DEC_FeedExternalOrientationData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_QUATERNION orientation, /* i : external orientation data */ - int8_t enableHeadRotation, /* i : flag to enable head rotation for this frame */ - int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ - int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ - int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ - const int16_t subframe_idx /*i : subframe index*/ + IVAS_QUATERNION orientation, /* i : external orientation data */ + int8_t enableHeadRotation, /* i : flag to enable head rotation for this frame */ + int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ + int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ + int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ + const int16_t subframe_idx /* i : subframe index */ ); /*! r: error code */ @@ -267,11 +265,11 @@ ivas_error IVAS_DEC_VoIP_SetScale( 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 */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT IVAS_DEC_PCM_TYPE pcmType, void *pcmBuf, #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 */ + 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 const uint32_t systemTimestamp_ms /* i : current system timestamp */ #ifdef SUPPORT_JBM_TRACEFILE @@ -283,7 +281,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( 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 */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const IVAS_DEC_PCM_TYPE pcmType, void *pcmBuf, #else @@ -302,18 +300,17 @@ ivas_error IVAS_DEC_EnableVoIP( ); #ifdef SPLIT_REND_WITH_HEAD_ROT - /*! r: error code */ ivas_error IVAS_DEC_EnableSplitRendering( IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ ); #endif + ivas_error IVAS_DEC_Get5msFlag( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ int16_t *enable5ms /* o : 5ms flag */ ); - #ifdef DEBUGGING bool IVAS_DEC_GetBerDetectFlag( IVAS_DEC_HANDLE hIvasDec /* i : IVAS decoder handle */ diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c index 9a962855c7..8ea332dbf3 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig.c +++ b/lib_enc/ivas_corecoder_enc_reconfig.c @@ -96,6 +96,7 @@ ivas_error ivas_corecoder_enc_reconfig( /*-----------------------------------------------------------------* * Switching between SCE(s)/CPE(s)/MCT *-----------------------------------------------------------------*/ + #ifdef NONBE_FIX_752_OSBA_MISCONFIG_MCT if ( nchan_transport_real == nchan_transport_old_real && st_ivas->nSCE == nSCE_old && st_ivas->nCPE == nCPE_old ) /* in McMASA, nchan_transport may be the same, but nSCE/nCPE differs */ #else diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 0fde574f48..051dee05d8 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -346,13 +346,13 @@ ivas_error create_mct_enc( } cp_bitrate = ivas_total_brate / hMCT->nchan_out_woLFE * CPE_CHANNELS; - #ifdef NONBE_FIX_752_OSBA_MISCONFIG_MCT if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { cp_bitrate = ivas_total_brate / st_ivas->nchan_transport * CPE_CHANNELS; } #endif + for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { for ( n = 0; n < CPE_CHANNELS; n++ ) diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index 3502abe80e..9a1b527521 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -335,6 +335,7 @@ ivas_error ivas_osba_enc_reconfig( /*-----------------------------------------------------------------* * Allocate, initialize, and configure SCE/CPE/MCT handles *-----------------------------------------------------------------*/ + if ( old_ism_mode == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { #ifndef NONBE_FIX_752_OSBA_MISCONFIG_MCT diff --git a/lib_rend/ivas_PredDecoder.c b/lib_rend/ivas_PredDecoder.c index abc78e8940..f4540c4dfc 100644 --- a/lib_rend/ivas_PredDecoder.c +++ b/lib_rend/ivas_PredDecoder.c @@ -54,7 +54,6 @@ ivas_error CreatePredictionDecoder( const int32_t iNumBlocks ) { int16_t n; - PredictionDecoder *psPredictionDecoder = NULL; if ( ( psPredictionDecoder = (PredictionDecoder *) malloc( sizeof( PredictionDecoder ) ) ) == NULL ) diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 3e47a8225f..8b499ed547 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -1360,13 +1360,15 @@ ivas_error ivas_orient_trk_Process( ); #ifdef SPLIT_REND_WITH_HEAD_ROT -void ivas_set_split_rend_ht_setup( - IVAS_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData ); /*----------------------------------------------------------------------------------* * Split binaural renderer prototypes *----------------------------------------------------------------------------------*/ +void ivas_set_split_rend_ht_setup( + IVAS_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData +); + ivas_error ivas_set_split_rend_setup( IVAS_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, IVAS_SPLIT_REND_CONFIG_DATA *hSplitBinConfig, @@ -1384,12 +1386,11 @@ void ivas_init_split_post_rend_handles( ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitBinRend, - const IVAS_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, + const IVAS_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, const int32_t output_Fs, const int16_t is_cldfb_in, - const int16_t is_pcm_out - , - const int16_t is_5ms_frame + const int16_t is_pcm_out, + const int16_t is_5ms_frame ); void ivas_split_renderer_close( @@ -1816,8 +1817,8 @@ int32_t ivas_get_split_rend_md_target_brate( int32_t ivas_get_lc3plus_bitrate( const int32_t SplitRendBitRate, - const IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode -, int16_t split_prerender_frame_size_ms + const IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, + const int16_t split_prerender_frame_size_ms ); int8_t ivas_get_lc3plus_bitrate_id( @@ -1826,8 +1827,8 @@ int8_t ivas_get_lc3plus_bitrate_id( int32_t ivas_get_lc3plus_size_from_id( const int8_t SplitRendBitRateId, - const IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode -,int16_t split_prerender_frame_size_ms + const IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, + const int16_t split_prerender_frame_size_ms ); ivas_error ivas_split_rend_validate_config( @@ -1852,13 +1853,12 @@ void ivas_split_rend_get_quant_params( int16_t *num_complex_bands ); -ivas_error -ivas_split_rend_choose_default_codec( +ivas_error ivas_split_rend_choose_default_codec( IVAS_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting */ - int16_t *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ - int16_t isRenderingInTd, /* i : flag: is rendering done in TD? */ - int16_t pcm_out /*i : flag to indicate PCM output*/ - ); + int16_t *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ + const int16_t isRenderingInTd, /* i : flag: is rendering done in TD? */ + int16_t pcm_out /* i : flag to indicate PCM output */ +); #endif diff --git a/lib_rend/ivas_splitRendererPLC.c b/lib_rend/ivas_splitRendererPLC.c index dcdd515b6f..181744a19b 100644 --- a/lib_rend/ivas_splitRendererPLC.c +++ b/lib_rend/ivas_splitRendererPLC.c @@ -459,7 +459,6 @@ void ivas_splitBinRendPLC_xf( } } - return; } @@ -486,47 +485,50 @@ void ivas_splitBinRendPLC( /* Indicate that next transition will be from a bad frame */ hSplitRendPLC->prev_bfi = 1; - { + #if CLDFB_PLC_XF > 0 - for ( i = 0; i < CLDFB_PLC_XF; i++ ) - { - xf_alp[i] = 1.0f - ( i + 1.0f ) / ( CLDFB_PLC_XF + 1.0f ); - } + for ( i = 0; i < CLDFB_PLC_XF; i++ ) + { + xf_alp[i] = 1.0f - ( i + 1.0f ) / ( CLDFB_PLC_XF + 1.0f ); + } #endif - for ( n = 0; n < num_chs; n++ ) + for ( n = 0; n < num_chs; n++ ) + { + for ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) { - for ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + for ( k = 0; k < CLDFB_NO_COL_MAX; k++ ) { - for ( k = 0; k < CLDFB_NO_COL_MAX; k++ ) - { - prev_real[k] = hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal[n][k][i]; - prev_imag[k] = hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag[n][k][i]; - } - adaptive_polar_ext_plc( prev_real, prev_imag, rec_real, rec_imag + prev_real[k] = hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal[n][k][i]; + prev_imag[k] = hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag[n][k][i]; + } + + adaptive_polar_ext_plc( prev_real, prev_imag, rec_real, rec_imag #if CLDFB_PLC_XF > 0 - , - xf_alp, hSplitRendPLC->CldfbPLC_state.xf_bet[n][i] + , + xf_alp, hSplitRendPLC->CldfbPLC_state.xf_bet[n][i] #endif - ); - for ( k = 0; k < CLDFB_NO_COL_MAX; k++ ) - { - Cldfb_RealBuffer_Binaural[n][k][i] = rec_real[k]; - hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal[n][k][i] = rec_real[k]; - Cldfb_ImagBuffer_Binaural[n][k][i] = rec_imag[k]; - hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag[n][k][i] = rec_imag[k]; - } + ); + + for ( k = 0; k < CLDFB_NO_COL_MAX; k++ ) + { + Cldfb_RealBuffer_Binaural[n][k][i] = rec_real[k]; + hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal[n][k][i] = rec_real[k]; + Cldfb_ImagBuffer_Binaural[n][k][i] = rec_imag[k]; + hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag[n][k][i] = rec_imag[k]; + } + #if CLDFB_PLC_XF > 0 - for ( k = CLDFB_NO_COL_MAX; k < CLDFB_NO_COL_MAX + CLDFB_PLC_XF; k++ ) - { - hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal[n][k][i] = rec_real[k]; - hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag[n][k][i] = rec_imag[k]; - } -#endif + for ( k = CLDFB_NO_COL_MAX; k < CLDFB_NO_COL_MAX + CLDFB_PLC_XF; k++ ) + { + hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal[n][k][i] = rec_real[k]; + hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag[n][k][i] = rec_imag[k]; } +#endif } } + /* Check bf counter */ if ( hSplitRendPLC->bf_count++ >= SR_PLC_FADE_START ) { diff --git a/lib_rend/ivas_splitRendererPost.c b/lib_rend/ivas_splitRendererPost.c index 5d545b4156..9683b05736 100644 --- a/lib_rend/ivas_splitRendererPost.c +++ b/lib_rend/ivas_splitRendererPost.c @@ -62,7 +62,6 @@ ivas_error ivas_splitBinPostRendOpen( ivas_error error; int16_t ch; - error = IVAS_ERR_OK; if ( ( hBinRend = (BIN_HR_SPLIT_POST_REND_HANDLE) malloc( sizeof( BIN_HR_SPLIT_POST_REND ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for bin split post renderer Module \n" ) ); @@ -113,7 +112,7 @@ ivas_error ivas_splitBinPostRendOpen( ivas_split_rend_init_huff_cfg( &hBinRend->huff_cfg ); *hBinHrSplitPostRend = hBinRend; - return error; + return IVAS_ERR_OK; } @@ -279,6 +278,12 @@ static int16_t ivas_split_rend_huffman_decode( } +/*-----------------------------------------------------------------------------------------* + * Function ivas_split_rend_unquant_md() + * + * + *-----------------------------------------------------------------------------------------*/ + static void ivas_split_rend_unquant_md( BIN_HR_SPLIT_REND_MD_HANDLE hMd, IVAS_SPLIT_REND_POSE_TYPE pose_type, @@ -1130,7 +1135,8 @@ void ivas_splitBinPostRendMdDec( * *-----------------------------------------------------------------------------------------*/ -static void wrap_around_angle( float *a ) +static void wrap_around_angle( + float *a ) { if ( ( *a ) > 180.0f ) { @@ -1143,13 +1149,15 @@ static void wrap_around_angle( float *a ) return; } + /*-----------------------------------------------------------------------------------------* * Function wrap_around_angle() * * *-----------------------------------------------------------------------------------------*/ -static void wrap_around_ypr( IVAS_QUATERNION *Quaternions ) +static void wrap_around_ypr( + IVAS_QUATERNION *Quaternions ) { /*only if quat is actually yaw, pitch , roll angles*/ if ( Quaternions->w == -3.0f ) @@ -1168,9 +1176,13 @@ static void wrap_around_ypr( IVAS_QUATERNION *Quaternions ) * *-----------------------------------------------------------------------------------------*/ -static float get_interp_fact( float p[MAX_HEAD_ROT_POSES], float p_t, int16_t ind[2] ) +static float get_interp_fact( + float p[MAX_HEAD_ROT_POSES], + const float p_t, + const int16_t ind[2] ) { float n, d, interp_fact; + if ( ind[0] != ind[1] ) { n = p[ind[0]] - p[ind[1]]; @@ -1211,6 +1223,7 @@ static void get_nearest_pose_ind( ind[0] = 0; ind[1] = 0; min_diff = 360.0f; + /*find the closest pose from assumed poses*/ for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { @@ -1560,8 +1573,6 @@ static void interpolate_rend_md( idx2 = interp_roll_pose_idx[1]; if ( ( idx1 != 0 ) || ( idx2 != 0 ) ) { - - interpolate_pred_matrix( rot_md, sf_idx, band_idx, interp_roll_pose_idx, interp_roll_fact, mix_mat_re3, mix_mat_im3 ); ivas_mat_mult_2by2_complex( mix_mat_re, mix_mat_im, mix_mat_re3, mix_mat_im3, mix_mat_re1, mix_mat_im1 ); @@ -1626,15 +1637,8 @@ void ivas_SplitRenderer_PostRenderer( #endif sf_idx_md = 0; - get_interpolation_vars( pMultiBinPoseData, - &hBinPostRenderer->QuaternionsPre[sf_idx_md], - &Quaternion_act, - interp_yaw_pose_idx, - interp_pitch_pose_idx, - interp_roll_pose_idx, - &interp_yaw_fact, - &interp_pitch_fact, - &interp_roll_fact ); + get_interpolation_vars( pMultiBinPoseData, &hBinPostRenderer->QuaternionsPre[sf_idx_md], &Quaternion_act, interp_yaw_pose_idx, interp_pitch_pose_idx, interp_roll_pose_idx, &interp_yaw_fact, &interp_pitch_fact, &interp_roll_fact ); + for ( b = 0; b < num_md_bands; b++ ) { for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) @@ -1857,9 +1861,7 @@ static void ivas_rend_CldfbSplitPostRendProcessTdIn( /* Implement CLDFB analysis */ for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) { - for ( slot_idx = 0; - slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; - slot_idx++ ) + for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) { cldfbAnalysis_ts( &( output[ch_idx][num_cldfb_bands * slot_idx] ), Cldfb_RealBuffer_Binaural[ch_idx][slot_idx], @@ -1869,12 +1871,7 @@ static void ivas_rend_CldfbSplitPostRendProcessTdIn( } } - ivas_SplitRenderer_PostRenderer( - hBinHrSplitPostRend, - pMultiBinPoseData, - Cldfb_RealBuffer_Binaural, - Cldfb_ImagBuffer_Binaural, - QuaternionPost ); + ivas_SplitRenderer_PostRenderer( hBinHrSplitPostRend, pMultiBinPoseData, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, QuaternionPost ); /* Implement CLDFB synthesis */ for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) @@ -1882,17 +1879,13 @@ static void ivas_rend_CldfbSplitPostRendProcessTdIn( float *RealBuffer[CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES]; float *ImagBuffer[CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES]; - for ( slot_idx = 0; - slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; - slot_idx++ ) + for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) { RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[ch_idx][slot_idx]; ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[ch_idx][slot_idx]; } - cldfbSynthesis( RealBuffer, ImagBuffer, &( output[ch_idx][0] ), - num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, - hBinHrSplitPostRend->cldfbSyn[ch_idx] ); + cldfbSynthesis( RealBuffer, ImagBuffer, &( output[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, hBinHrSplitPostRend->cldfbSyn[ch_idx] ); } return; @@ -1922,19 +1915,12 @@ void ivas_rend_CldfbSplitPostRendProcess( if ( is_cldfb_in == 0 ) { - ivas_rend_CldfbSplitPostRendProcessTdIn( hBinHrSplitPostRend, pMultiBinPoseData, - QuaternionPost, - output ); + ivas_rend_CldfbSplitPostRendProcessTdIn( hBinHrSplitPostRend, pMultiBinPoseData, QuaternionPost, output ); pop_wmops(); return; } - ivas_SplitRenderer_PostRenderer( - hBinHrSplitPostRend, - pMultiBinPoseData, - Cldfb_RealBuffer_Binaural, - Cldfb_ImagBuffer_Binaural, - QuaternionPost ); + ivas_SplitRenderer_PostRenderer( hBinHrSplitPostRend, pMultiBinPoseData, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, QuaternionPost ); /* Implement CLDFB synthesis */ for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) @@ -1948,13 +1934,10 @@ void ivas_rend_CldfbSplitPostRendProcess( ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[ch_idx][slot_idx]; } - cldfbSynthesis( RealBuffer, ImagBuffer, &( output[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, - hBinHrSplitPostRend->cldfbSyn[ch_idx] ); + cldfbSynthesis( RealBuffer, ImagBuffer, &( output[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, hBinHrSplitPostRend->cldfbSyn[ch_idx] ); } - pop_wmops(); - return; } diff --git a/lib_rend/ivas_splitRendererPre.c b/lib_rend/ivas_splitRendererPre.c index 91cbd044ee..482edb090f 100644 --- a/lib_rend/ivas_splitRendererPre.c +++ b/lib_rend/ivas_splitRendererPre.c @@ -472,7 +472,7 @@ static void ivas_split_rend_quant_md( float fix_pos_rot_mat[][BINAURAL_CHANNELS] #ifdef SPLIT_REND_PRED_QUANT_63_PNTS , - float pred_1byquantstep + const float pred_1byquantstep #endif ) { @@ -1238,12 +1238,11 @@ static void ivas_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, + get_base2_bits( hBinHrSplitPreRend, pMultiBinPoseData, num_subframes, num_quant_strats, pred_real_bands_yaw, pred_imag_bands_yaw, #ifdef SPLIT_REND_PRED_QUANT_63_PNTS - pred_quant_pnts_yaw, + pred_quant_pnts_yaw, #endif - d_bands_yaw, bands_pitch, pred_real_bands_roll, pred_imag_bands_roll, base2bits ); + d_bands_yaw, bands_pitch, pred_real_bands_roll, pred_imag_bands_roll, base2bits ); for ( q = 0; q < num_quant_strats; q++ ) { @@ -1360,6 +1359,7 @@ static void ivas_SplitRenderer_quant_code( pred_real_bands_roll[q], pred_imag_bands_roll[q], pBits ); + huff_bits = pBits->bits_written - huff_bits; if ( ( target_md_bits >= ( base2bits[q] + overhead_bits ) ) || ( target_md_bits >= ( huff_bits + overhead_bits ) ) || ( q == ( num_quant_strats - 1 ) ) ) @@ -1484,7 +1484,6 @@ void ivas_SplitRenderer_GetRotMd( float cov_oo_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; float cov_io_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; int16_t real_only = 0; - int16_t pos_idx, b, sf_idx, start_slot_idx, num_slots, num_subframes, ch_s_idx1, ch_s_idx2; int16_t num_md_bands, num_poses; const int16_t *pBand_grouping = ivas_split_rend_band_grouping; @@ -1537,7 +1536,6 @@ void ivas_SplitRenderer_GetRotMd( } pop_wmops(); - return; } @@ -1562,13 +1560,7 @@ void ivas_rend_CldfbSplitPreRendProcess( ivas_SplitRenderer_GetRotMd( hBinHrSplitPreRend, pMultiBinPoseData, Cldfb_In_BinReal, Cldfb_In_BinImag, low_res_pre_rend_rot ); - ivas_SplitRenderer_quant_code( - hBinHrSplitPreRend, - headPosition, - pMultiBinPoseData, - pBits, - low_res_pre_rend_rot, - target_md_bits ); + ivas_SplitRenderer_quant_code( hBinHrSplitPreRend, headPosition, pMultiBinPoseData, pBits, low_res_pre_rend_rot, target_md_bits ); #ifdef SPLIT_POSE_CORRECTION_DEBUG float tmpCrendBuffer[2][L_FRAME48k], quant_val, step, minv, maxv; @@ -1663,7 +1655,6 @@ void ivas_rend_CldfbSplitPreRendProcess( #endif pop_wmops(); - return; } @@ -1684,13 +1675,12 @@ ivas_error ivas_splitBinPreRendOpen( ) { BIN_HR_SPLIT_PRE_REND_HANDLE hBinRend; - ivas_error error; #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + ivas_error error; int16_t ch; #endif int16_t pos_idx, sf_idx, bandIdx; - error = IVAS_ERR_OK; if ( ( hBinRend = (BIN_HR_SPLIT_PRE_REND_HANDLE) malloc( sizeof( BIN_HR_SPLIT_PRE_REND ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for bin split pre renderer Module \n" ) ); @@ -1735,12 +1725,15 @@ ivas_error ivas_splitBinPreRendOpen( ivas_split_rend_init_huff_cfg( &hBinRend->huff_cfg ); #ifdef SPLIT_POSE_CORRECTION_DEBUG - ivas_splitBinPostRendOpen( &hBinRend->hBinHrSplitPostRend, pMultiBinPoseData, 48000 ); + if ( ( error = ivas_splitBinPostRendOpen( &hBinRend->hBinHrSplitPostRend, pMultiBinPoseData, 48000 ) ) != IVAS_ERR_OK ) + { + return error; + } #endif *hBinHrSplitPreRend = hBinRend; - return error; + return IVAS_ERR_OK; } @@ -1782,6 +1775,13 @@ void ivas_splitBinPreRendClose( return; } + +/*-------------------------------------------------------------------------* + * ivas_set_split_rend_ht_setup() + * + * + *-------------------------------------------------------------------------*/ + void ivas_set_split_rend_ht_setup( IVAS_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData ) @@ -1802,8 +1802,11 @@ void ivas_set_split_rend_ht_setup( } } } + return; } + + /*-------------------------------------------------------------------------* * ivas_set_split_rend_setup() * @@ -1817,7 +1820,9 @@ ivas_error ivas_set_split_rend_setup( IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits ) { int16_t sf, i, j; + hSplitBinRend->hSplitRendBits = hSplitRendBits; + if ( ( hSplitBinRend->hMultiBinCldfbData = (IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE) malloc( sizeof( IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for split rendering structure" ); @@ -1877,15 +1882,18 @@ void ivas_init_split_rend_handles( return; } + /*------------------------------------------------------------------------- * Function split_renderer_open_lc3plus() * * *------------------------------------------------------------------------*/ -static ivas_error split_renderer_open_lc3plus( SPLIT_REND_WRAPPER *hSplitRendWrapper, - const IVAS_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, - const int32_t OutSampleRate, - const int16_t is_5ms_frame ) + +static ivas_error split_renderer_open_lc3plus( + SPLIT_REND_WRAPPER *hSplitRendWrapper, + const IVAS_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, + const int32_t OutSampleRate, + const int16_t is_5ms_frame ) { ivas_error error; int16_t i, delayBufferLength; @@ -1905,16 +1913,13 @@ static ivas_error split_renderer_open_lc3plus( SPLIT_REND_WRAPPER *hSplitRendWra config.channels = BINAURAL_CHANNELS; - error = IVAS_LC3PLUS_ENC_Open( config, ivas_get_lc3plus_bitrate( pSplitRendConfig->splitRendBitRate, pSplitRendConfig->poseCorrectionMode, (int16_t) ( config.ivas_frame_duration_us / 1000 ) ), - &hSplitRendWrapper->hLc3plusEnc ); - if ( error != IVAS_ERR_OK ) + if ( ( error = IVAS_LC3PLUS_ENC_Open( config, ivas_get_lc3plus_bitrate( pSplitRendConfig->splitRendBitRate, pSplitRendConfig->poseCorrectionMode, (int16_t) ( config.ivas_frame_duration_us / 1000 ) ), &hSplitRendWrapper->hLc3plusEnc ) ) != IVAS_ERR_OK ) { return error; } /* This returns delay of entire LC3plus chain (enc + dec) */ - error = IVAS_LC3PLUS_ENC_GetDelay( hSplitRendWrapper->hLc3plusEnc, &hSplitRendWrapper->lc3plusDelaySamples ); - if ( error != IVAS_ERR_OK ) + if ( ( error = IVAS_LC3PLUS_ENC_GetDelay( hSplitRendWrapper->hLc3plusEnc, &hSplitRendWrapper->lc3plusDelaySamples ) ) != IVAS_ERR_OK ) { return error; } @@ -1954,17 +1959,20 @@ static ivas_error split_renderer_open_lc3plus( SPLIT_REND_WRAPPER *hSplitRendWra return IVAS_ERR_OK; } + /*------------------------------------------------------------------------- * Function ivas_split_renderer_open() * * *------------------------------------------------------------------------*/ -ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper, - const IVAS_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, - const int32_t OutSampleRate, - const int16_t is_cldfb_in, - const int16_t is_pcm_out, - const int16_t is_5ms_frame ) + +ivas_error ivas_split_renderer_open( + SPLIT_REND_WRAPPER *hSplitRendWrapper, + const IVAS_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, + const int32_t OutSampleRate, + const int16_t is_cldfb_in, + const int16_t is_pcm_out, + const int16_t is_5ms_frame ) { ivas_error error, ch, num_ch; #ifndef OSBA_SPLIT_RENDERING @@ -1980,8 +1988,6 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper, return error; } - error = IVAS_ERR_OK; - if ( is_cldfb_in == 0 ) { isCldfbNeeded = 1; @@ -2029,7 +2035,6 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper, } #endif - num_ch = hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; for ( ch = 0; ch < num_ch; ch++ ) @@ -2049,9 +2054,7 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper, #ifdef OSBA_SPLIT_RENDERING for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), - CLDFB_SYNTHESIS, - OutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, OutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return error; } @@ -2076,9 +2079,7 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper, { if ( pSplitRendConfig->codec == IVAS_SPLIT_REND_CODEC_LC3PLUS ) { - error = split_renderer_open_lc3plus( hSplitRendWrapper, pSplitRendConfig, OutSampleRate, - is_5ms_frame ); - if ( error != IVAS_ERR_OK ) + if ( ( error = split_renderer_open_lc3plus( hSplitRendWrapper, pSplitRendConfig, OutSampleRate, is_5ms_frame ) ) != IVAS_ERR_OK ) { return error; } @@ -2092,7 +2093,7 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper, } } - return error; + return IVAS_ERR_OK; } @@ -2478,8 +2479,8 @@ ivas_error ivas_renderMultiBinToSplitBinaural( { ivas_error error; int32_t bit_len, target_md_bits, actual_md_bits, available_bits; - error = IVAS_ERR_OK; + error = IVAS_ERR_OK; push_wmops( "ivas_renderMultiBinToSplitBinaural" ); if ( hSplitBin->multiBinPoseData.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) @@ -2500,12 +2501,8 @@ ivas_error ivas_renderMultiBinToSplitBinaural( { /*TD input*/ /*if CLDFB handles have been allocated then assume valid multi binaural input in out[][] buffer and perform CLDFB analysis*/ - error = ivas_renderMultiTDBinToSplitBinaural( hSplitBin, - headPosition, - SplitRendBitRate, - codec_frame_size_ms, - pBits, max_bands, output, - low_res_pre_rend_rot, pcm_out ); + error = ivas_renderMultiTDBinToSplitBinaural( hSplitBin, headPosition, SplitRendBitRate, codec_frame_size_ms, pBits, max_bands, output, low_res_pre_rend_rot, pcm_out ); + pop_wmops(); return error; } @@ -2522,15 +2519,7 @@ ivas_error ivas_renderMultiBinToSplitBinaural( target_md_bits = ivas_get_split_rend_md_target_brate( SplitRendBitRate, pcm_out ) * L_FRAME48k / 48000; actual_md_bits = pBits->bits_written; - ivas_rend_CldfbSplitPreRendProcess( - hSplitBin->hBinHrSplitPreRend, - headPosition, - &hSplitBin->multiBinPoseData, - Cldfb_In_BinReal, - Cldfb_In_BinImag, - pBits, - target_md_bits, - low_res_pre_rend_rot ); + ivas_rend_CldfbSplitPreRendProcess( hSplitBin->hBinHrSplitPreRend, headPosition, &hSplitBin->multiBinPoseData, Cldfb_In_BinReal, Cldfb_In_BinImag, pBits, target_md_bits, low_res_pre_rend_rot ); } if ( pcm_out == 0 ) diff --git a/lib_rend/ivas_splitRenderer_utils.c b/lib_rend/ivas_splitRenderer_utils.c index af0672445b..4ff5393c9d 100644 --- a/lib_rend/ivas_splitRenderer_utils.c +++ b/lib_rend/ivas_splitRenderer_utils.c @@ -584,22 +584,28 @@ int32_t ivas_get_lcld_bitrate( { return SplitRendBitRate; } + return -1; } + /*------------------------------------------------------------------------- * Function ivas_get_lc3plus_bitrate() * * *------------------------------------------------------------------------*/ -int32_t ivas_get_lc3plus_bitrate( const int32_t SplitRendBitRate, IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, int16_t split_prerender_frame_size_ms ) + +int32_t ivas_get_lc3plus_bitrate( + const int32_t SplitRendBitRate, + IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, + const int16_t split_prerender_frame_size_ms ) { if ( poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) { - int32_t inBandMdBps = (int32_t) ( 8 * 1000 / - split_prerender_frame_size_ms ); + int32_t inBandMdBps = (int32_t) ( 8 * 1000 / split_prerender_frame_size_ms ); return ivas_get_lcld_bitrate( SplitRendBitRate, poseCorrectionMode ) - inBandMdBps; } + if ( poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) { return SplitRendBitRate; @@ -647,6 +653,7 @@ int8_t ivas_get_lc3plus_bitrate_id( break; } } + return -1; } @@ -656,7 +663,11 @@ int8_t ivas_get_lc3plus_bitrate_id( * * *------------------------------------------------------------------------*/ -int32_t ivas_get_lc3plus_size_from_id( const int8_t SplitRendBitRateId, IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, int16_t split_prerender_frame_size_ms ) + +int32_t ivas_get_lc3plus_size_from_id( + const int8_t SplitRendBitRateId, + const IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, + const int16_t split_prerender_frame_size_ms ) { int32_t bitrate; @@ -694,12 +705,10 @@ int32_t ivas_get_lc3plus_size_from_id( const int8_t SplitRendBitRateId, IVAS_SPL } } - bitrate = ivas_get_lc3plus_bitrate( bitrate, poseCorrectionMode, - split_prerender_frame_size_ms ); + bitrate = ivas_get_lc3plus_bitrate( bitrate, poseCorrectionMode, split_prerender_frame_size_ms ); /* Return size in bytes */ - return (int32_t) ( bitrate * - split_prerender_frame_size_ms / 1000 / 8 ); + return (int32_t) ( bitrate * split_prerender_frame_size_ms / 1000 / 8 ); } @@ -738,8 +747,8 @@ ivas_error ivas_split_rend_validate_config( { return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Invalid framing for LCLD codec" ); } - if ( pSplitRendConfig->codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && - ( pSplitRendConfig->codec_frame_size_ms != 5 && pSplitRendConfig->codec_frame_size_ms != 10 ) ) + + if ( pSplitRendConfig->codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && ( pSplitRendConfig->codec_frame_size_ms != 5 && pSplitRendConfig->codec_frame_size_ms != 10 ) ) { return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Invalid framing for LC3plus codec" ); } @@ -1077,11 +1086,12 @@ void ivas_init_multi_bin_pose_data( * * *------------------------------------------------------------------------*/ -ivas_error -ivas_split_rend_choose_default_codec( IVAS_SPLIT_REND_CODEC *pCodec, - int16_t *pCodec_frame_size_ms, - int16_t isRenderingInTd, - int16_t pcm_out ) + +ivas_error ivas_split_rend_choose_default_codec( + IVAS_SPLIT_REND_CODEC *pCodec, + int16_t *pCodec_frame_size_ms, + const int16_t isRenderingInTd, + int16_t pcm_out ) { if ( pcm_out == 0 ) { diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index fd40346ad7..df61d0f611 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -278,7 +278,9 @@ struct IVAS_REND * Local functions *-------------------------------------------------------------------*/ -static ivas_error allocateInputBaseBufferData( float **data, const int16_t data_size ) +static ivas_error allocateInputBaseBufferData( + float **data, + const int16_t data_size ) { *data = (float *) malloc( data_size * sizeof( float ) ); if ( *data == NULL ) @@ -289,7 +291,8 @@ static ivas_error allocateInputBaseBufferData( float **data, const int16_t data_ return IVAS_ERR_OK; } -static void freeInputBaseBufferData( float **data ) +static void freeInputBaseBufferData( + float **data ) { if ( *data != NULL ) { @@ -300,7 +303,9 @@ static void freeInputBaseBufferData( float **data ) return; } -static ivas_error allocateMcLfeDelayBuffer( float **lfeDelayBuffer, const int16_t data_size ) +static ivas_error allocateMcLfeDelayBuffer( + float **lfeDelayBuffer, + const int16_t data_size ) { *lfeDelayBuffer = (float *) malloc( data_size * sizeof( float ) ); if ( *lfeDelayBuffer == NULL ) @@ -311,7 +316,8 @@ static ivas_error allocateMcLfeDelayBuffer( float **lfeDelayBuffer, const int16_ return IVAS_ERR_OK; } -static void freeMcLfeDelayBuffer( float **lfeDelayBuffer ) +static void freeMcLfeDelayBuffer( + float **lfeDelayBuffer ) { if ( *lfeDelayBuffer != NULL ) { @@ -741,6 +747,7 @@ static ivas_error initLimiter( return IVAS_ERR_OK; } + static LSSETUP_CUSTOM_STRUCT defaultCustomLs( void ) { @@ -760,6 +767,7 @@ static LSSETUP_CUSTOM_STRUCT defaultCustomLs( return ls; } + static ivas_error getSpeakerAzimuths( AUDIO_CONFIG config, const float **azimuths ) @@ -794,6 +802,7 @@ static ivas_error getSpeakerAzimuths( return IVAS_ERR_OK; } + static ivas_error getSpeakerElevations( AUDIO_CONFIG config, const float **elevations ) @@ -828,6 +837,7 @@ static ivas_error getSpeakerElevations( return IVAS_ERR_OK; } + static ivas_error getAmbisonicsOrder( AUDIO_CONFIG config, int16_t *order ) @@ -850,6 +860,7 @@ static ivas_error getAmbisonicsOrder( return IVAS_ERR_OK; } + static int16_t getNumLfeChannels( input_mc *inputMc ) { @@ -911,6 +922,7 @@ static ivas_error getMcConfigValues( int16_t *is_planar ) { int16_t i; + ivas_error error; *lfe_idx = -1; *is_planar = 1; @@ -934,16 +946,28 @@ static ivas_error getMcConfigValues( break; case AUDIO_CONFIG_MONO: case AUDIO_CONFIG_STEREO: - getSpeakerAzimuths( inConfig, azimuth ); - getSpeakerElevations( inConfig, elevation ); + if ( ( error = getSpeakerAzimuths( inConfig, azimuth ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( ( error = getSpeakerElevations( inConfig, elevation ) ) != IVAS_ERR_OK ) + { + return error; + } break; case AUDIO_CONFIG_5_1: case AUDIO_CONFIG_7_1: case AUDIO_CONFIG_5_1_2: case AUDIO_CONFIG_5_1_4: case AUDIO_CONFIG_7_1_4: - getSpeakerAzimuths( inConfig, azimuth ); - getSpeakerElevations( inConfig, elevation ); + if ( ( error = getSpeakerAzimuths( inConfig, azimuth ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( ( error = getSpeakerElevations( inConfig, elevation ) ) != IVAS_ERR_OK ) + { + return error; + } *lfe_idx = LFE_CHANNEL; *is_planar = ( inConfig == AUDIO_CONFIG_5_1 || inConfig == AUDIO_CONFIG_7_1 ) ? 1 : 0; break; @@ -955,6 +979,7 @@ static ivas_error getMcConfigValues( return IVAS_ERR_OK; } + static ivas_error initEfap( EFAP_WRAPPER *pEfapWrapper, AUDIO_CONFIG outConfig, @@ -1021,6 +1046,7 @@ static ivas_error initEfap( return IVAS_ERR_OK; } + static ivas_error getEfapGains( EFAP_WRAPPER efapWrapper, const float azi, @@ -1083,6 +1109,7 @@ static ivas_error getEfapGains( return IVAS_ERR_OK; } + static ivas_error initHeadRotation( IVAS_REND_HANDLE hIvasRend ) { @@ -1282,6 +1309,7 @@ static bool isIoConfigPairSupported( return true; } + static ivas_error initIsmMasaRendering( input_ism *inputIsm, const int32_t inSampleRate ) @@ -1379,11 +1407,7 @@ static ivas_error setRendInputActiveIsm( /* Open TD renderer wrappers */ for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) { - if ( ( error = ivas_td_binaural_open_ext( &inputIsm->splitTdRendWrappers[i], - inConfig, - hRendCfg, - NULL, - *inputIsm->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_open_ext( &inputIsm->splitTdRendWrappers[i], inConfig, hRendCfg, NULL, *inputIsm->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; } @@ -2604,7 +2628,12 @@ static ivas_error updateSplitPostRendPanGains( ivas_error error; rendering_context rendCtx; int16_t numOutChannels; - getAudioConfigNumChannels( outConfig, &numOutChannels ); + + if ( ( error = getAudioConfigNumChannels( outConfig, &numOutChannels ) ) != IVAS_ERR_OK ) + { + + return error; + } rendCtx = inputSplitPostRend->base.ctx; ivas_renderSplitGetMultiBinPoseData( &hRendCfg->split_rend_config, &inputSplitPostRend->splitPostRendWrapper.multiBinPoseData, rendCtx.pHeadRotData->sr_pose_pred_axis ); @@ -2746,18 +2775,14 @@ static ivas_error setRendInputActiveSplitPostRend( rendCtx = inputSplitPostRend->base.ctx; outConfig = *rendCtx.pOutConfig; - if ( ( error = allocateInputBaseBufferData( &inputSplitPostRend->bufferData, - MAX_CLDFB_BIN_BUFFER_LENGTH ) ) != IVAS_ERR_OK ) + if ( ( error = allocateInputBaseBufferData( &inputSplitPostRend->bufferData, MAX_CLDFB_BIN_BUFFER_LENGTH ) ) != IVAS_ERR_OK ) { return error; } - initRendInputBase( &inputSplitPostRend->base, inConfig, id, rendCtx, - inputSplitPostRend->bufferData, - MAX_CLDFB_BIN_BUFFER_LENGTH ); + initRendInputBase( &inputSplitPostRend->base, inConfig, id, rendCtx, inputSplitPostRend->bufferData, MAX_CLDFB_BIN_BUFFER_LENGTH ); inputSplitPostRend->numCachedSamples = 0; - if ( ( error = updateSplitPostRendPanGains( inputSplitPostRend, outConfig, hRendCfg ) ) != IVAS_ERR_OK ) { return error; @@ -2821,6 +2846,7 @@ static ivas_error setRendInputActiveSba( { return error; } + #ifdef SPLIT_REND_WITH_HEAD_ROT initRendInputBase( &inputSba->base, inConfig, id, rendCtx, inputSba->bufferData, MAX_CLDFB_BUFFER_LENGTH ); #else @@ -3334,6 +3360,7 @@ static ivas_error setRendInputActiveMasa( { return error; } + if ( getAudioConfigType( outConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) { inputMasa->metadataHasBeenFed = false; @@ -3490,8 +3517,15 @@ static void clearInputMasa( #ifdef SPLIT_REND_WITH_HEAD_ROT - -static ivas_error initSplitRend( SPLIT_REND_WRAPPER *pSplitRendWrapper, IVAS_REND_AudioBuffer *pSplitRendEncBuffer, const IVAS_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, IVAS_REND_HeadRotData headRotData, const int32_t outputSampleRate, const AUDIO_CONFIG outConfig, const int16_t cldfb_in, const int16_t is_5ms_frame ) +static ivas_error initSplitRend( + SPLIT_REND_WRAPPER *pSplitRendWrapper, + IVAS_REND_AudioBuffer *pSplitRendEncBuffer, + const IVAS_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, + IVAS_REND_HeadRotData headRotData, + const int32_t outputSampleRate, + const AUDIO_CONFIG outConfig, + const int16_t cldfb_in, + const int16_t is_5ms_frame ) { ivas_error error; IVAS_REND_AudioBufferConfig bufConfig; @@ -3507,8 +3541,7 @@ static ivas_error initSplitRend( SPLIT_REND_WRAPPER *pSplitRendWrapper, IVAS_REN ivas_renderSplitUpdateNoCorrectionPoseData( pSplit_rend_config, &pSplitRendWrapper->multiBinPoseData ); } - if ( ( error = ivas_split_renderer_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in, outConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM, - is_5ms_frame ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_split_renderer_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in, outConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM, is_5ms_frame ) ) != IVAS_ERR_OK ) { return error; } @@ -3701,6 +3734,7 @@ ivas_error IVAS_REND_Open( hIvasRend->inputsMasa[i].bufferData = NULL; hIvasRend->inputsMasa[i].hMasaPrerend = NULL; } + #ifdef SPLIT_REND_WITH_HEAD_ROT for ( i = 0; i < RENDERER_MAX_BIN_INPUTS; ++i ) { @@ -3777,6 +3811,12 @@ static ivas_error validateCustomLsLayout( } +/*-------------------------------------------------------------------* + * IVAS_REND_ConfigureCustomOutputLoudspeakerLayout() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( IVAS_REND_HANDLE hIvasRend, const IVAS_CUSTOM_LS_DATA layout ) @@ -3863,6 +3903,12 @@ ivas_error IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( } +/*-------------------------------------------------------------------* + * IVAS_REND_NumOutChannels() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_NumOutChannels( IVAS_REND_CONST_HANDLE hIvasRend, int16_t *numOutChannels ) @@ -4183,34 +4229,21 @@ ivas_error IVAS_REND_AddInput( } #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( - ( hIvasRend->outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasRend->outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) && - hIvasRend->splitRendEncBuffer.data == NULL && hIvasRend->hRendererConfig != NULL ) + if ( ( hIvasRend->outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasRend->outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) && + hIvasRend->splitRendEncBuffer.data == NULL && hIvasRend->hRendererConfig != NULL ) { int16_t cldfb_in; cldfb_in = getCldfbRendFlag( hIvasRend, getAudioConfigType( inConfig ) ); #ifdef FIX_658_SPLIT_REND_MASA - error = - ivas_split_rend_choose_default_codec( &hIvasRend->hRendererConfig->split_rend_config.codec, - &hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - ( cldfb_in == 0 ), - hIvasRend->outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ); - if ( error != IVAS_ERR_OK ) + if ( ( error = ivas_split_rend_choose_default_codec( &hIvasRend->hRendererConfig->split_rend_config.codec, &hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, ( cldfb_in == 0 ), hIvasRend->outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) != IVAS_ERR_OK ) { return error; } #endif - if ( ( error = initSplitRend( &hIvasRend->splitRendWrapper, - &hIvasRend->splitRendEncBuffer, - &hIvasRend->hRendererConfig->split_rend_config, - hIvasRend->headRotData, - hIvasRend->sampleRateOut, - hIvasRend->outputConfig, - cldfb_in, - ( hIvasRend->num_subframes == 1 ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + if ( ( error = initSplitRend( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in, ( hIvasRend->num_subframes == 1 ) ? 1 : 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -4480,7 +4513,7 @@ ivas_error IVAS_REND_SetInputLfePos( * * *-------------------------------------------------------------------*/ - +/* ToDo; unused function */ ivas_error IVAS_REND_RemoveInput( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_REND_InputId inputId /* i : ID of the input */ @@ -4835,7 +4868,7 @@ ivas_error IVAS_REND_FeedInputObjectMetadata( /*-------------------------------------------------------------------* - * IVAS_REND_FeedInputObjectMetadata() + * IVAS_REND_FeedInputObjectMetadataToOMasa() * * *-------------------------------------------------------------------*/ @@ -4908,7 +4941,7 @@ ivas_error IVAS_REND_FeedInputMasaMetadata( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_InitConfig( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const AUDIO_CONFIG outAudioConfig /* i : output audioConfig */ ) { @@ -5084,21 +5117,13 @@ int16_t IVAS_REND_FeedRenderConfig( int16_t cldfb_in; cldfb_in = getCldfbRendFlag( hIvasRend, IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN ); closeSplitRend( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer ); - if ( ( error = ivas_split_rend_choose_default_codec( &hIvasRend->hRendererConfig->split_rend_config.codec, - &hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - ( cldfb_in == 0 ), - hIvasRend->outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) != IVAS_ERR_OK ) + + if ( ( error = ivas_split_rend_choose_default_codec( &hIvasRend->hRendererConfig->split_rend_config.codec, &hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, ( cldfb_in == 0 ), hIvasRend->outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = initSplitRend( &hIvasRend->splitRendWrapper, - &hIvasRend->splitRendEncBuffer, - &hIvasRend->hRendererConfig->split_rend_config, - hIvasRend->headRotData, - hIvasRend->sampleRateOut, - hIvasRend->outputConfig, - cldfb_in, - ( hIvasRend->num_subframes == 1 ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + + if ( ( error = initSplitRend( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in, ( hIvasRend->num_subframes == 1 ) ? 1 : 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -5108,7 +5133,8 @@ int16_t IVAS_REND_FeedRenderConfig( return IVAS_ERR_OK; } -#if defined SPLIT_REND_WITH_HEAD_ROT + +#ifdef SPLIT_REND_WITH_HEAD_ROT /*-------------------------------------------------------------------* * IVAS_REND_FeedSplitBinauralBitstream() * @@ -5116,8 +5142,8 @@ 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_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 */ ) { @@ -5155,12 +5181,12 @@ ivas_error IVAS_REND_SetHeadRotation( const IVAS_QUATERNION headRot, /* i : head orientations for next rendering call */ const IVAS_VECTOR3 Pos, /* i : listener positions for next rendering call */ #ifdef SPLIT_REND_WITH_HEAD_ROT - , - IVAS_SPLIT_REND_ROT_AXIS rot_axis + IVAS_SPLIT_REND_ROT_AXIS rot_axis, #endif const int16_t sf_idx ) { IVAS_QUATERNION rotQuat; + ivas_error error; /* Validate function arguments */ if ( hIvasRend == NULL ) @@ -5184,7 +5210,11 @@ ivas_error IVAS_REND_SetHeadRotation( rotQuat = headRot; } - ivas_orient_trk_Process( hIvasRend->headRotData.hOrientationTracker, rotQuat, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &hIvasRend->headRotData.headPositions[sf_idx] ); + if ( ( error = ivas_orient_trk_Process( hIvasRend->headRotData.hOrientationTracker, rotQuat, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &hIvasRend->headRotData.headPositions[sf_idx] ) ) != IVAS_ERR_OK ) + { + return error; + } + hIvasRend->headRotData.Pos[sf_idx] = Pos; #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -5194,9 +5224,15 @@ ivas_error IVAS_REND_SetHeadRotation( return IVAS_ERR_OK; } -ivas_error -IVAS_REND_DisableHeadRotation( - IVAS_REND_HANDLE hIvasRend /* i/o: Renderer handle */ + +/*-------------------------------------------------------------------* + * IVAS_REND_DisableHeadRotation() + * + * + *-------------------------------------------------------------------*/ + +ivas_error IVAS_REND_DisableHeadRotation( + IVAS_REND_HANDLE hIvasRend /* i/o: Renderer handle */ ) { /* Validate function arguments */ @@ -5206,9 +5242,11 @@ IVAS_REND_DisableHeadRotation( } hIvasRend->headRotData.headRotEnabled = 0; + return IVAS_ERR_OK; } + #ifdef SPLIT_REND_WITH_HEAD_ROT /*-------------------------------------------------------------------* * IVAS_REND_SetSplitRendBFI() @@ -5216,8 +5254,7 @@ IVAS_REND_DisableHeadRotation( * *-------------------------------------------------------------------*/ -ivas_error -IVAS_REND_SetSplitRendBFI( +ivas_error IVAS_REND_SetSplitRendBFI( IVAS_REND_HANDLE hIvasRend, const int16_t bfi ) { @@ -5235,7 +5272,7 @@ IVAS_REND_SetSplitRendBFI( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_SetOrientationTrackingMode( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const HEAD_ORIENT_TRK_T orientation_tracking /* i : Head orientation tracking type */ ) { @@ -5276,7 +5313,7 @@ ivas_error IVAS_REND_SetReferenceRotation( * * *-------------------------------------------------------------------*/ - +// ToDo: not used ivas_error IVAS_REND_GetMainOrientation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ IVAS_QUATERNION *pOrientation /* i/o: Quaternion pointer for main orientation */ @@ -5303,7 +5340,7 @@ ivas_error IVAS_REND_GetMainOrientation( * * *-------------------------------------------------------------------*/ - +// ToDo: not used ivas_error IVAS_REND_GetTrackedRotation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ IVAS_QUATERNION *pRotation /* i/o: Quaternion pointer processed rotation */ @@ -5360,10 +5397,9 @@ ivas_error IVAS_REND_SetExternalOrientation( int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ - const int16_t sf_idx /*i : subframe index*/ + const int16_t sf_idx /* i : subframe index */ ) { - /* Validate function arguments */ if ( hIvasRend == NULL || hIvasRend->hExternalOrientationData == NULL ) { @@ -5395,7 +5431,7 @@ ivas_error IVAS_REND_SetExternalOrientation( *---------------------------------------------------------------------*/ ivas_error IVAS_REND_CombineHeadAndExternalOrientation( - IVAS_REND_HANDLE hIvasRend /* i/o: Renderer handle */ + IVAS_REND_HANDLE hIvasRend /* i/o: Renderer handle */ ) { if ( hIvasRend == NULL ) @@ -5412,7 +5448,7 @@ ivas_error IVAS_REND_CombineHeadAndExternalOrientation( * * *---------------------------------------------------------------------*/ - +// ToDo: not used ivas_error IVAS_REND_GetCombinedOrientation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ IVAS_QUATERNION *pOrientation /* i/o: Quaternion pointer processed orientation */ @@ -5527,9 +5563,13 @@ static void renderBufferChannel( return; } -static ivas_error chooseCrossfade( const IVAS_REND_HeadRotData *headRotData, const float **pCrossfade ) + +static ivas_error chooseCrossfade( + const IVAS_REND_HeadRotData *headRotData, + const float **pCrossfade ) { *pCrossfade = headRotData->crossfade; + return IVAS_ERR_OK; } @@ -5549,7 +5589,6 @@ static ivas_error rotateFrameMc( const float *crossfade; int16_t num_subframes; int16_t subframe_idx, subframe_len; - int16_t azimuth, elevation; int16_t is_planar_setup, lfe_idx; int16_t nchan; @@ -5582,9 +5621,7 @@ static ivas_error rotateFrameMc( nchan = pInCustomLs->num_spk + pInCustomLs->num_lfe; } - if ( ( error = getMcConfigValues( inConfig, - pInCustomLs, - &ls_azimuth, &ls_elevation, &lfe_idx, &is_planar_setup ) ) != IVAS_ERR_OK ) + if ( ( error = getMcConfigValues( inConfig, pInCustomLs, &ls_azimuth, &ls_elevation, &lfe_idx, &is_planar_setup ) ) != IVAS_ERR_OK ) { return error; } @@ -5811,10 +5848,8 @@ static ivas_error renderIsmToBinaural( ism_md_subframe_update_ext = (int16_t) round( ismInput->ism_metadata_delay_ms / ( 1000 / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) ); copyBufferTo2dArray( ismInput->base.inputBuffer, tmpTDRendBuffer ); - if ( ( error = ivas_td_binaural_renderer_ext( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, - ismInput->hReverb, ism_md_subframe_update_ext, - *ismInput->base.ctx.pOutSampleRate, - outAudio.config.numSamplesPerChannel, tmpTDRendBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer_ext( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, ism_md_subframe_update_ext, + *ismInput->base.ctx.pOutSampleRate, outAudio.config.numSamplesPerChannel, tmpTDRendBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -5826,7 +5861,10 @@ static ivas_error renderIsmToBinaural( return IVAS_ERR_OK; } -static int16_t getNumSubframesInBuffer( const IVAS_REND_AudioBuffer *buffer, int32_t sampleRate ) + +static int16_t getNumSubframesInBuffer( + const IVAS_REND_AudioBuffer *buffer, + const int32_t sampleRate ) { #ifdef SPLIT_REND_WITH_HEAD_ROT int16_t cldfb2tdSampleFact; @@ -5849,6 +5887,7 @@ static int16_t getNumSubframesInBuffer( const IVAS_REND_AudioBuffer *buffer, int #endif } + static ivas_error renderIsmToBinauralRoom( input_ism *ismInput, IVAS_REND_AudioBuffer outAudio ) @@ -5972,8 +6011,7 @@ static ivas_error renderIsmToBinauralRoom( copyBufferTo2dArray( tmpMcBuffer, tmpRendBuffer ); - if ( ( error = ivas_rend_crendProcess( ismInput->crendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM_IR, - NULL, NULL, NULL, NULL, p_tmpRendBuffer, *ismInput->base.ctx.pOutSampleRate, + if ( ( error = ivas_rend_crendProcess( ismInput->crendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *ismInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *ismInput->base.ctx.pOutSampleRate ) #ifdef SPLIT_REND_WITH_HEAD_ROT , @@ -6007,16 +6045,8 @@ static ivas_error renderIsmToBinauralReverb( ism_md_subframe_update_ext = (int16_t) round( ismInput->ism_metadata_delay_ms / ( 1000 / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) ); copyBufferTo2dArray( ismInput->base.inputBuffer, tmpRendBuffer ); - if ( ( error = ivas_td_binaural_renderer_ext( &ismInput->tdRendWrapper, - ismInput->base.inConfig, - NULL, - ismInput->base.ctx.pCombinedOrientationData, - &ismInput->currentPos, - ismInput->hReverb, - ism_md_subframe_update_ext, - *ismInput->base.ctx.pOutSampleRate, - outAudio.config.numSamplesPerChannel, - tmpRendBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer_ext( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, + ism_md_subframe_update_ext, *ismInput->base.ctx.pOutSampleRate, outAudio.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -6216,17 +6246,8 @@ static ivas_error renderIsmToSplitBinaural( } /* Render */ - error = ivas_td_binaural_renderer_ext( ( pos_idx == 0 ) ? &ismInput->tdRendWrapper : &ismInput->splitTdRendWrappers[pos_idx - 1], - ismInput->base.inConfig, - NULL, - ismInput->base.ctx.pCombinedOrientationData, - &ismInput->currentPos, - NULL, - ism_md_subframe_update_ext, - *ismInput->base.ctx.pOutSampleRate, - output_frame, - tmpProcessing ); - if ( error != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer_ext( ( pos_idx == 0 ) ? &ismInput->tdRendWrapper : &ismInput->splitTdRendWrappers[pos_idx - 1], ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, + NULL, ism_md_subframe_update_ext, *ismInput->base.ctx.pOutSampleRate, output_frame, tmpProcessing ) ) != IVAS_ERR_OK ) { return error; } @@ -6504,13 +6525,8 @@ static ivas_error renderMcToBinaural( { copyBufferTo2dArray( mcInput->base.inputBuffer, tmpRendBuffer ); - if ( ( error = ivas_td_binaural_renderer_ext( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, - mcInput->base.ctx.pCombinedOrientationData, - NULL, - mcInput->hReverb, - 0, - *mcInput->base.ctx.pOutSampleRate, - mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer_ext( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pCombinedOrientationData, NULL, mcInput->hReverb, + 0, *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -6524,10 +6540,7 @@ static ivas_error renderMcToBinaural( 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, + 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], #else @@ -6619,12 +6632,8 @@ static ivas_error renderMcToBinauralRoom( { copyBufferTo2dArray( mcInput->base.inputBuffer, tmpRendBuffer ); - if ( ( error = ivas_td_binaural_renderer_ext( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, - mcInput->base.ctx.pCombinedOrientationData, - NULL, mcInput->hReverb, - 0, - *mcInput->base.ctx.pOutSampleRate, - mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer_ext( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pCombinedOrientationData, NULL, mcInput->hReverb, + 0, *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -6638,10 +6647,7 @@ 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, + 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], #else @@ -6737,10 +6743,7 @@ 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, + 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], #else @@ -6772,8 +6775,7 @@ static ivas_error renderMcCustomLsToBinauralRoom( copyBufferTo2dArray( tmpMcBuffer, tmpCrendBuffer ); /* call CREND */ - if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, - p_tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate, + if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) #ifdef SPLIT_REND_WITH_HEAD_ROT , @@ -6959,16 +6961,8 @@ static ivas_error renderMcToSplitBinaural( copyBufferTo2dArray( mcInput->base.inputBuffer, tmpRendBuffer ); /* Render */ - if ( ( error = ivas_td_binaural_renderer_ext( ( pos_idx == 0 ) ? &mcInput->tdRendWrapper : &mcInput->splitTdRendWrappers[pos_idx - 1], - mcInput->base.inConfig, - &mcInput->customLsInput, - &pCombinedOrientationDataLocal, - NULL, - mcInput->hReverb, - 0, /* Ism Audio Metadata Delay Sync in ms for External Renderer */ - *mcInput->base.ctx.pOutSampleRate, - mcInput->base.inputBuffer.config.numSamplesPerChannel, - tmpRendBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer_ext( ( pos_idx == 0 ) ? &mcInput->tdRendWrapper : &mcInput->splitTdRendWrappers[pos_idx - 1], mcInput->base.inConfig, &mcInput->customLsInput, &pCombinedOrientationDataLocal, + NULL, mcInput->hReverb, 0, /* Ism Audio Metadata Delay Sync in ms for External Renderer */ *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -6993,18 +6987,13 @@ static ivas_error renderMcToSplitBinaural( /* perform rotation in source format to tmpRotBuffer */ pCombinedOrientationDataLocal = &combinedOrientationDataLocal; - if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, - mcInput->base.inConfig, - &mcInput->customLsInput, - mcInput->base.ctx.pHeadRotData, - &pCombinedOrientationDataLocal, + if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, &pCombinedOrientationDataLocal, #ifdef SPLIT_REND_WITH_HEAD_ROT mcInput->rot_gains_prev[pos_idx], #else mcInput->rot_gains_prev, #endif - mcInput->efapInWrapper.hEfap, - tmpRotBuffer ) ) != IVAS_ERR_OK ) + mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -7012,15 +7001,7 @@ static ivas_error renderMcToSplitBinaural( copyBufferTo2dArray( tmpRotBuffer, tmpRendBuffer ); /* call CREND (rotation already performed) */ - if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, - mcInput->base.inConfig, - outConfig, - NULL, - NULL, - NULL, - NULL, - p_tmpRendBuffer, - *mcInput->base.ctx.pOutSampleRate, + if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &mcInput->base.inputBuffer, *mcInput->base.ctx.pOutSampleRate ), #ifdef SPLIT_REND_WITH_HEAD_ROT pos_idx @@ -7224,8 +7205,7 @@ static ivas_error splitBinLc3plusDecode( } /* Read LC3plus bitstream size info */ lc3plusBitrateId = ivas_split_rend_bitstream_read_int32( bits, 8 ); - lc3plusBitstreamSize = ivas_get_lc3plus_size_from_id( (int8_t) lc3plusBitrateId, pose_correction, - (int16_t) ( hSplitBin->hLc3plusDec->config.ivas_frame_duration_us / 1000 ) ); + lc3plusBitstreamSize = ivas_get_lc3plus_size_from_id( (int8_t) lc3plusBitrateId, pose_correction, (int16_t) ( hSplitBin->hLc3plusDec->config.ivas_frame_duration_us / 1000 ) ); for ( int16_t i = 0; i < BINAURAL_CHANNELS * hSplitBin->multiBinPoseData.num_poses; ++i ) { @@ -7254,8 +7234,7 @@ static ivas_error renderSplitBinauralWithPostRot( float Cldfb_RealBuffer_Binaural_5ms[MAX_PARAM_SPATIAL_SUBFRAMES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural_5ms[MAX_PARAM_SPATIAL_SUBFRAMES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; IVAS_QUATERNION QuaternionsPost[MAX_PARAM_SPATIAL_SUBFRAMES]; - int16_t sf_idx; - + int16_t sf_idx, ch_idx; ivas_split_rend_bits_t bits; float tmpCrendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; float tmpCrendBuffer_sf[BINAURAL_CHANNELS][L_FRAME48k]; @@ -7268,11 +7247,8 @@ static ivas_error renderSplitBinauralWithPostRot( int16_t numSamplesPerChannelCacheSize, numColPerChannelCacheSize; float *readPtr, *writePtr; - isPostRendInputCldfb = 0; - push_wmops( "renderSplitBinauralWithPostRot" ); - error = IVAS_ERR_OK; pCombinedOrientationData = *splitBinInput->base.ctx.pCombinedOrientationData; @@ -7339,6 +7315,7 @@ static ivas_error renderSplitBinauralWithPostRot( ); } } + /*copy pose correction after MD is parsed*/ hSplitBin->multiBinPoseData.poseCorrectionMode = bits.pose_correction; @@ -7363,12 +7340,7 @@ static ivas_error renderSplitBinauralWithPostRot( { if ( bits.codec == IVAS_SPLIT_REND_CODEC_LCLD ) { - ivas_splitBinLCLDDecProcess( - hSplitBin->hSplitBinLCLDDec, - &bits, - Cldfb_RealBuffer_Binaural, - Cldfb_ImagBuffer_Binaural, - SplitRendBFI ); + ivas_splitBinLCLDDecProcess( hSplitBin->hSplitBinLCLDDec, &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, SplitRendBFI ); /* copy data over to 5ms buffer */ for ( chnlIdx = 0; chnlIdx < BINAURAL_CHANNELS; ++chnlIdx ) @@ -7379,6 +7351,7 @@ static ivas_error renderSplitBinauralWithPostRot( mvr2r( Cldfb_ImagBuffer_Binaural[chnlIdx][slotIdx], Cldfb_ImagBuffer_Binaural_5ms[sf_idx][chnlIdx][slotIdx], CLDFB_NO_CHANNELS_MAX ); } } + /* cache the remaining 15ms */ splitBinInput->numCachedSamples = numColPerChannelCacheSize; writePtr = splitBinInput->bufferData; @@ -7399,19 +7372,15 @@ static ivas_error renderSplitBinauralWithPostRot( } else { - error = splitBinLc3plusDecode( hSplitBin, &bits, tmpCrendBuffer, bits.pose_correction ); - if ( error != IVAS_ERR_OK ) + if ( ( error = splitBinLc3plusDecode( hSplitBin, &bits, tmpCrendBuffer, bits.pose_correction ) ) != IVAS_ERR_OK ) { return error; } + /* cache the remaining 15ms */ splitBinInput->numCachedSamples = numSamplesPerChannelCacheSize; - mvr2r( &tmpCrendBuffer[0][outBufNumSamplesPerChannel], - splitBinInput->bufferData, - numSamplesPerChannelCacheSize ); - mvr2r( &tmpCrendBuffer[1][outBufNumSamplesPerChannel], - splitBinInput->bufferData + numSamplesPerChannelCacheSize, - numSamplesPerChannelCacheSize ); + mvr2r( &tmpCrendBuffer[0][outBufNumSamplesPerChannel], splitBinInput->bufferData, numSamplesPerChannelCacheSize ); + mvr2r( &tmpCrendBuffer[1][outBufNumSamplesPerChannel], splitBinInput->bufferData + numSamplesPerChannelCacheSize, numSamplesPerChannelCacheSize ); } } else @@ -7444,12 +7413,8 @@ static ivas_error renderSplitBinauralWithPostRot( else { int16_t readOffset = numSamplesPerChannelCacheSize - splitBinInput->numCachedSamples; - mvr2r( splitBinInput->bufferData + readOffset, - &tmpCrendBuffer[0][sf_idx * outBufNumSamplesPerChannel], - outBufNumSamplesPerChannel ); - mvr2r( splitBinInput->bufferData + readOffset + numSamplesPerChannelCacheSize, - &tmpCrendBuffer[1][sf_idx * outBufNumSamplesPerChannel], - outBufNumSamplesPerChannel ); + mvr2r( splitBinInput->bufferData + readOffset, &tmpCrendBuffer[0][sf_idx * outBufNumSamplesPerChannel], outBufNumSamplesPerChannel ); + mvr2r( splitBinInput->bufferData + readOffset + numSamplesPerChannelCacheSize, &tmpCrendBuffer[1][sf_idx * outBufNumSamplesPerChannel], outBufNumSamplesPerChannel ); splitBinInput->numCachedSamples -= outBufNumSamplesPerChannel; } } @@ -7466,7 +7431,7 @@ static ivas_error renderSplitBinauralWithPostRot( if ( bits.pose_correction == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE && isPostRendInputCldfb ) { /* 0DOF with LCLD codec requires CLDFB synthesis */ - int16_t ch_idx, slot_idx; + int16_t slot_idx; for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) { @@ -7488,27 +7453,13 @@ static ivas_error renderSplitBinauralWithPostRot( } else if ( bits.pose_correction == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) { - mvr2r( &tmpCrendBuffer[0][sf_idx * outBufNumSamplesPerChannel], - tmpCrendBuffer_sf[0], - outBufNumSamplesPerChannel ); - mvr2r( &tmpCrendBuffer[1][sf_idx * outBufNumSamplesPerChannel], - tmpCrendBuffer_sf[1], - outBufNumSamplesPerChannel ); - ivas_rend_CldfbSplitPostRendProcess( - hSplitBin->hBinHrSplitPostRend, - &hSplitBin->multiBinPoseData, - QuaternionsPost[sf_idx], - Cldfb_RealBuffer_Binaural_5ms[sf_idx], - Cldfb_ImagBuffer_Binaural_5ms[sf_idx], - tmpCrendBuffer_sf, - isPostRendInputCldfb ); - - mvr2r( tmpCrendBuffer_sf[0], - &tmpCrendBuffer[0][sf_idx * outBufNumSamplesPerChannel], - outBufNumSamplesPerChannel ); - mvr2r( tmpCrendBuffer_sf[1], - &tmpCrendBuffer[1][sf_idx * outBufNumSamplesPerChannel], - outBufNumSamplesPerChannel ); + mvr2r( &tmpCrendBuffer[0][sf_idx * outBufNumSamplesPerChannel], tmpCrendBuffer_sf[0], outBufNumSamplesPerChannel ); + mvr2r( &tmpCrendBuffer[1][sf_idx * outBufNumSamplesPerChannel], tmpCrendBuffer_sf[1], outBufNumSamplesPerChannel ); + + ivas_rend_CldfbSplitPostRendProcess( hSplitBin->hBinHrSplitPostRend, &hSplitBin->multiBinPoseData, QuaternionsPost[sf_idx], Cldfb_RealBuffer_Binaural_5ms[sf_idx], Cldfb_ImagBuffer_Binaural_5ms[sf_idx], tmpCrendBuffer_sf, isPostRendInputCldfb ); + + mvr2r( tmpCrendBuffer_sf[0], &tmpCrendBuffer[0][sf_idx * outBufNumSamplesPerChannel], outBufNumSamplesPerChannel ); + mvr2r( tmpCrendBuffer_sf[1], &tmpCrendBuffer[1][sf_idx * outBufNumSamplesPerChannel], outBufNumSamplesPerChannel ); } } } @@ -7516,7 +7467,6 @@ static ivas_error renderSplitBinauralWithPostRot( { if ( splitBinInput->base.inConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { - int16_t ch_idx; for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) { set_zero( tmpCrendBuffer[ch_idx], outAudio.config.numSamplesPerChannel ); @@ -7611,10 +7561,7 @@ static ivas_error renderSbaToMultiBinaural( assert( sbaInput->crendWrapper->hCrend[0]->hReverb == NULL ); /* call CREND */ - if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, - NULL, NULL, NULL, NULL, - p_tmpCrendBuffer, - *sbaInput->base.ctx.pOutSampleRate, + if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &sbaInput->base.inputBuffer, *sbaInput->base.ctx.pOutSampleRate ), #ifdef SPLIT_REND_WITH_HEAD_ROT pos_idx @@ -7640,34 +7587,29 @@ static ivas_error renderSbaToMultiBinaural( free( tmpRotBuffer.data ); pop_wmops(); - return IVAS_ERR_OK; } -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, - int16_t num_subframes ) + +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 ) { float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; copyBufferToCLDFBarray( sbaInput->base.inputBuffer, Cldfb_RealBuffer, Cldfb_ImagBuffer ); - 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 ); + 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; } + static ivas_error renderSbaToSplitBinaural( input_sba *sbaInput, const AUDIO_CONFIG outConfig, @@ -7686,11 +7628,12 @@ static ivas_error renderSbaToSplitBinaural( if ( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection == IVAS_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) { - renderSbaToMultiBinauralCldfb( sbaInput, - Cldfb_RealBuffer_Binaural, - Cldfb_ImagBuffer_Binaural, - low_res_pre_rend_rot, - getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ); + 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; + } + accumulateCLDFBArrayToBuffer( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); } else @@ -7731,11 +7674,13 @@ 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]; - renderSbaToMultiBinauralCldfb( sbaInput, - Cldfb_RealBuffer_Binaural, - Cldfb_ImagBuffer_Binaural, - 0, - getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ); + + if ( ( error = renderSbaToMultiBinauralCldfb( sbaInput, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, 0, + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) + { + return error; + } + accumulateCLDFBArrayToBuffer( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); } else @@ -7791,8 +7736,7 @@ static ivas_error renderSbaToBinaural( } /* call CREND */ - if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, - NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, + if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) #ifdef SPLIT_REND_WITH_HEAD_ROT , @@ -7811,6 +7755,7 @@ static ivas_error renderSbaToBinaural( return IVAS_ERR_OK; } + static ivas_error renderSbaToBinauralRoom( input_sba *sbaInput, const AUDIO_CONFIG outConfig, @@ -7894,8 +7839,7 @@ static ivas_error renderSbaToBinauralRoom( copyBufferTo2dArray( tmpMcBuffer, tmpCrendBuffer ); /* call CREND */ - if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, AUDIO_CONFIG_7_1_4, outConfig, - NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, + if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) #ifdef SPLIT_REND_WITH_HEAD_ROT , @@ -7919,6 +7863,7 @@ static ivas_error renderSbaToBinauralRoom( return IVAS_ERR_OK; } + #ifdef SPLIT_REND_WITH_HEAD_ROT static ivas_error renderInputSplitBin( input_split_post_rend *splitBinInput, @@ -7941,8 +7886,7 @@ static ivas_error renderInputSplitBin( switch ( outConfig ) { case AUDIO_CONFIG_BINAURAL: - error = renderSplitBinauralWithPostRot( splitBinInput, outAudio, - SplitRendBFI ); + error = renderSplitBinauralWithPostRot( splitBinInput, outAudio, SplitRendBFI ); break; default: return IVAS_ERR_INVALID_OUTPUT_FORMAT; @@ -7952,7 +7896,8 @@ static ivas_error renderInputSplitBin( } #endif -static ivas_error renderSbaToMasa( + +static void renderSbaToMasa( input_sba *sbaInput, IVAS_REND_AudioBuffer outAudio ) { @@ -7966,9 +7911,10 @@ static ivas_error renderSbaToMasa( pop_wmops(); - return IVAS_ERR_OK; + return; } + static ivas_error renderInputSba( input_sba *sbaInput, const AUDIO_CONFIG outConfig, @@ -7976,7 +7922,7 @@ static ivas_error renderInputSba( { ivas_error error; IVAS_REND_AudioBuffer inAudio; -#if defined( SPLIT_REND_WITH_HEAD_ROT ) +#ifdef SPLIT_REND_WITH_HEAD_ROT int16_t cldfb2tdSampleFact; #endif @@ -8062,8 +8008,7 @@ static ivas_error renderActiveInputsSplitBin( continue; } - if ( ( error = renderInputSplitBin( pCurrentInput, hIvasRend->outputConfig, outAudio, - hIvasRend->splitRendBFI ) ) != IVAS_ERR_OK ) + if ( ( error = renderInputSplitBin( pCurrentInput, hIvasRend->outputConfig, outAudio, hIvasRend->splitRendBFI ) ) != IVAS_ERR_OK ) { return error; } @@ -8099,6 +8044,7 @@ static ivas_error renderActiveInputsSba( return IVAS_ERR_OK; } + static void copyMasaMetadataToDiracRenderer( MASA_METADATA_FRAME *meta, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom ) @@ -8141,6 +8087,7 @@ static void copyMasaMetadataToDiracRenderer( return; } + static void renderMasaToMc( input_masa *masaInput, IVAS_REND_AudioBuffer outAudio ) @@ -8170,6 +8117,7 @@ static void renderMasaToMc( return; } + static void renderMasaToSba( input_masa *masaInput, IVAS_REND_AudioBuffer outAudio ) @@ -8192,6 +8140,7 @@ static void renderMasaToSba( return; } + static void renderMasaToBinaural( input_masa *masaInput, IVAS_REND_AudioBuffer outAudio @@ -8364,7 +8313,7 @@ static ivas_error renderInputMasa( IVAS_REND_AudioBuffer outAudio ) { IVAS_REND_AudioBuffer inAudio; -#if defined( SPLIT_REND_WITH_HEAD_ROT ) +#ifdef SPLIT_REND_WITH_HEAD_ROT int16_t cldfb2tdSampleFact; #endif @@ -8491,7 +8440,7 @@ static ivas_error renderActiveInputsMasa( ivas_error IVAS_REND_GetMasaMetadata( IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to analyzed MASA metadata */ - IVAS_REND_AudioConfigType inputType /* i : Input type */ + const IVAS_REND_AudioConfigType inputType /* i : Input type */ ) { if ( hIvasRend == NULL ) @@ -8530,8 +8479,8 @@ ivas_error IVAS_REND_GetMasaMetadata( ivas_error IVAS_REND_MergeMasaMetadata( IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to merged metadata */ - IVAS_REND_AudioConfigType inputType1, /* i : Input type 1 */ - IVAS_REND_AudioConfigType inputType2 /* i : Input type 2 */ + const IVAS_REND_AudioConfigType inputType1, /* i : Input type 1 */ + const IVAS_REND_AudioConfigType inputType2 /* i : Input type 2 */ ) { MASA_DECODER_EXT_OUT_META_HANDLE inMeta2; @@ -8599,7 +8548,6 @@ ivas_error IVAS_REND_MergeMasaMetadata( ivas_prerend_merge_masa_metadata( *hMasaExtOutMeta, *hMasaExtOutMeta, inputType1, *inEne1, inMeta2, inputType2, *inEne2 ); ( *hMasaExtOutMeta )->descriptiveMeta.numberOfChannels = hIvasRend->outputConfig == AUDIO_CONFIG_MASA1 ? 0u : 1u; - return IVAS_ERR_OK; } @@ -8778,6 +8726,7 @@ static ivas_error getSamplesInternal( set_zero( outAudio.data, outAudio.config.numChannels * outAudio.config.numSamplesPerChannel ); } #endif + if ( ( error = renderActiveInputsIsm( hIvasRend, outAudio ) ) != IVAS_ERR_OK ) { return error; @@ -8797,6 +8746,7 @@ static ivas_error getSamplesInternal( { return error; } + #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = renderActiveInputsSplitBin( hIvasRend, outAudio ) ) != IVAS_ERR_OK ) { @@ -8858,7 +8808,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, td_input, @@ -8883,6 +8833,7 @@ static ivas_error getSamplesInternal( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------* * IVAS_REND_GetSamples() * @@ -8894,15 +8845,23 @@ ivas_error IVAS_REND_GetSamples( IVAS_REND_AudioBuffer outAudio /* i/o: buffer for output audio */ ) { - return getSamplesInternal( hIvasRend, outAudio + #ifdef SPLIT_REND_WITH_HEAD_ROT - , - NULL + return getSamplesInternal( hIvasRend, outAudio, NULL ); + +#else + return getSamplesInternal( hIvasRend, outAudio ); #endif - ); } + #ifdef SPLIT_REND_WITH_HEAD_ROT +/*-------------------------------------------------------------------* + * IVAS_REND_GetSplitBinauralBitstream() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_GetSplitBinauralBitstream( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ @@ -8929,6 +8888,13 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( return getSamplesInternal( hIvasRend, outAudio, hBits ); } + +/*-------------------------------------------------------------------* + * IVAS_REND_GetSplitBinauralSamples() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_GetSplitBinauralSamples( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ @@ -9025,20 +8991,21 @@ void IVAS_REND_Close( * *-------------------------------------------------------------------*/ -int16_t IVAS_REND_openCldfb( +ivas_error IVAS_REND_openCldfb( IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS], - IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_INPUT_CHANNELS], + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_OUTPUT_CHANNELS], const int16_t num_in_chs, const int16_t num_out_chs, const int32_t output_Fs ) { int16_t n; + ivas_error error; for ( n = 0; n < num_in_chs; n++ ) { - if ( openCldfb( &( cldfbAna[n] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) != IVAS_ERR_OK ) + if ( ( error = openCldfb( &( cldfbAna[n] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { - return -1; + return error; } } for ( ; n < IVAS_MAX_INPUT_CHANNELS; n++ ) @@ -9048,17 +9015,17 @@ int16_t IVAS_REND_openCldfb( for ( n = 0; n < num_out_chs; n++ ) { - if ( openCldfb( &( cldfbSyn[n] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) != IVAS_ERR_OK ) + if ( ( error = openCldfb( &( cldfbSyn[n] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { - return -1; + return error; } } - for ( ; n < IVAS_MAX_INPUT_CHANNELS; n++ ) + for ( ; n < IVAS_MAX_OUTPUT_CHANNELS; n++ ) { cldfbSyn[n] = NULL; } - return 0; + return IVAS_ERR_OK; } @@ -9070,7 +9037,7 @@ int16_t IVAS_REND_openCldfb( void IVAS_REND_closeCldfb( IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS], - IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_INPUT_CHANNELS] ) + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_OUTPUT_CHANNELS] ) { int16_t n; @@ -9081,7 +9048,10 @@ void IVAS_REND_closeCldfb( deleteCldfb( &( cldfbAna[n] ) ); cldfbAna[n] = NULL; } + } + for ( n = 0; n < IVAS_MAX_OUTPUT_CHANNELS; n++ ) + { if ( cldfbSyn[n] != NULL ) { deleteCldfb( &( cldfbSyn[n] ) ); diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 9994fbc111..900d25a868 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -250,17 +250,19 @@ int16_t IVAS_REND_FeedRenderConfig( const IVAS_RENDER_CONFIG_DATA renderConfig /* i : Render configuration struct */ ); -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT 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_error IVAS_REND_GetSplitBinauralSamples( IVAS_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 */ bool* needNewFrame ); + ivas_error IVAS_REND_GetSplitBinauralBitstream( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ @@ -338,14 +340,14 @@ ivas_error IVAS_REND_GetCombinedOrientation( ivas_error IVAS_REND_GetMasaMetadata( IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to analyzed MASA metadata */ - IVAS_REND_AudioConfigType inputType /* i : Input type */ + const IVAS_REND_AudioConfigType inputType /* i : Input type */ ); ivas_error IVAS_REND_MergeMasaMetadata( IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to merged metadata */ - IVAS_REND_AudioConfigType inputType1, /* i : Input type 1 */ - IVAS_REND_AudioConfigType inputType2 /* i : Input type 2 */ + const IVAS_REND_AudioConfigType inputType1, /* i : Input type 1 */ + const IVAS_REND_AudioConfigType inputType2 /* i : Input type 2 */ ); ivas_error IVAS_REND_SetTotalNumberOfObjects( @@ -378,9 +380,9 @@ void IVAS_REND_Close( #ifdef SPLIT_REND_WITH_HEAD_ROT /* Split binaural rendering functions */ -int16_t IVAS_REND_openCldfb( +ivas_error IVAS_REND_openCldfb( IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS], - IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_INPUT_CHANNELS], + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_OUTPUT_CHANNELS], const int16_t num_in_chs, const int16_t num_out_chs, const int32_t output_Fs @@ -388,7 +390,7 @@ int16_t IVAS_REND_openCldfb( void IVAS_REND_closeCldfb( IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS], - IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_INPUT_CHANNELS] + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_OUTPUT_CHANNELS] ); void IVAS_REND_cldfbAnalysis_ts_wrapper( -- GitLab From cbd669c672140c7609cf5f13806278c09e82476e Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 13 Sep 2023 11:12:56 +0200 Subject: [PATCH 03/13] formatting around recent switches --- lib_dec/ivas_dec.c | 1 + lib_dec/ivas_jbm_dec.c | 6 ++---- lib_dec/ivas_mc_param_dec.c | 1 + lib_dec/ivas_mc_paramupmix_dec.c | 11 ++++++++++- lib_dec/ivas_sba_rendering_internal.c | 2 ++ lib_dec/ivas_stat_dec.h | 1 + 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index c22198ca0c..f4d1c0bcf0 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -890,6 +890,7 @@ ivas_error ivas_dec( } } } + #ifndef NONBE_FIX_727_MC_PARAMUPMIX_HEADROTATION if ( st_ivas->transport_config != st_ivas->intern_config && ( st_ivas->intern_config == AUDIO_CONFIG_FOA || st_ivas->intern_config == AUDIO_CONFIG_HOA2 || st_ivas->intern_config == AUDIO_CONFIG_HOA3 ) ) { diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 6b4986c727..f6c69cec24 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -162,16 +162,14 @@ ivas_error ivas_jbm_dec_tc( } else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hDirAC->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, - st_ivas->hSCE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hDirAC->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) { return error; } } else /* ISM_MODE_DISC */ { - if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, - st_ivas->hSCE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 42ab312263..47e39cf0cf 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -100,6 +100,7 @@ static ivas_error param_mc_get_diff_proto_info( const float *proto_mtx, const ui #ifndef NONBE_FIX_727_MC_PARAMUPMIX_HEADROTATION static void ivas_param_mc_mc2sba_cldfb( IVAS_OUTPUT_SETUP hTransSetup, float *hoa_encoder, const int16_t slot_idx, float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], const int16_t nBands, const float gain_lfe ); #endif + static void ivas_param_mc_get_param_band_mapping( const int16_t n_target_bands, const int16_t *target_band_grouping, const int16_t n_source_bands, const int16_t *source_band_grouping, PARAM_MC_PARAMETER_BAND_MAPPING *parameter_band_mapping ); static void ivas_param_mc_bs_decode_parameter_values( uint16_t bit_buffer[], int16_t *bit_pos, const int16_t max_bits, int16_t *BER_detect, HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC, HANDLE_PARAM_MC_PARAMETER_CODING_INFO hParamCodingInfo, const int16_t map_size_wo_lfe, const int16_t map_size, const int16_t num_lfe_bands, const int16_t band_step, const int16_t num_param_bands, float *value_buffer ); diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index aa7cb29cf7..8324cab7e8 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -319,6 +319,7 @@ void ivas_mc_paramupmix_dec( } idx_in += 2; } + #ifdef NONBE_FIX_727_MC_PARAMUPMIX_HEADROTATION if ( st_ivas->hCombinedOrientationData && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { @@ -328,6 +329,7 @@ void ivas_mc_paramupmix_dec( } } #endif + #ifdef SPLIT_REND_WITH_HEAD_ROT /*LFE handling for split rendering cases*/ if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) @@ -396,6 +398,7 @@ void ivas_mc_paramupmix_dec( } } #endif + for ( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) { for ( slot_idx = 0; slot_idx < JBM_CLDFB_SLOTS_IN_SUBFRAME; slot_idx++ ) @@ -661,9 +664,11 @@ ivas_error ivas_mc_paramupmix_dec_open( assert( 0 && "Number of TC not supported for MC ParamUpmix!" ); #endif } + #ifdef NONBE_FIX_727_MC_PARAMUPMIX_HEADROTATION hMCParamUpmix->hoa_encoder = NULL; #endif + /*-----------------------------------------------------------------* * set input parameters *-----------------------------------------------------------------*/ @@ -787,11 +792,14 @@ void ivas_mc_paramupmix_dec_close( return; } + + /*------------------------------------------------------------------------- * ivas_param_upmix_dec_decorr_subframes() * * *------------------------------------------------------------------------*/ + static void paramupmix_td_decorr_process_jbm( ivas_td_decorr_state_t *hTdDecorr[], /* i/o: SPAR Covar. decoder handle */ float *pcm_in[], /* i : input audio channels */ @@ -838,8 +846,9 @@ static void paramupmix_td_decorr_process_jbm( return; } + static void ivas_param_upmix_dec_decorr_subframes( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const int16_t nSamplesForRendering ) { MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix; diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 91a5db5ca2..845172b3ec 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -212,6 +212,7 @@ void ivas_mc2sba( return; } + #ifdef NONBE_FIX_727_MC_PARAMUPMIX_HEADROTATION /*-------------------------------------------------------------------------* * ivas_param_mc_mc2sba_cldfb() @@ -289,6 +290,7 @@ void ivas_param_mc_mc2sba_cldfb( } #endif + /*-------------------------------------------------------------------* * ivas_sba_remapTCs() * diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 5f946d48ad..93a24f5e5c 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -553,6 +553,7 @@ typedef struct ivas_mc_paramupmix_dec_data_structure #ifdef NONBE_FIX_727_MC_PARAMUPMIX_HEADROTATION float *hoa_encoder; #endif + } MC_PARAMUPMIX_DEC_DATA, *MC_PARAMUPMIX_DEC_HANDLE; -- GitLab From 591d92df92e26c6db7ac049f446dffd245ad6feb Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 14 Sep 2023 16:56:43 +0200 Subject: [PATCH 04/13] formatting around function calls related to SPLIT_REND_WITH_HEAD_ROT --- apps/decoder.c | 27 ++-- apps/renderer.c | 66 +++++----- lib_com/ivas_prot.h | 28 ++--- lib_com/prot.h | 4 +- lib_dec/ivas_binRenderer_internal.c | 14 +-- lib_dec/ivas_dec.c | 18 ++- lib_dec/ivas_init_dec.c | 18 +-- lib_dec/ivas_ism_dec.c | 14 +-- lib_dec/ivas_mc_paramupmix_dec.c | 4 +- lib_dec/ivas_mct_dec.c | 38 +++--- lib_dec/ivas_stat_dec.h | 140 +++++++++++---------- lib_enc/init_enc.c | 4 +- lib_enc/ivas_enc.c | 7 +- lib_enc/ivas_omasa_enc.c | 4 +- lib_enc/ivas_osba_enc.c | 6 +- lib_enc/ivas_sce_enc.c | 7 +- lib_enc/ivas_spar_encoder.c | 7 +- lib_rend/ivas_crend.c | 22 ++-- lib_rend/lib_rend.c | 184 +++++++++++++--------------- lib_rend/lib_rend.h | 7 +- 20 files changed, 292 insertions(+), 327 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 6135c74666..52c01979ab 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2441,11 +2441,10 @@ static ivas_error decodeG192( if ( decodedGoodFrame ) { #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( hSplitRendFileReadWrite != NULL ) && ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) + if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, splitRendBits.bits_buf, &splitRendBits.bits_read, &splitRendBits.bits_written, - splitRendBits.codec, splitRendBits.pose_correction, - splitRendBits.codec_frame_size_ms ) != IVAS_ERR_OK ) + splitRendBits.codec, splitRendBits.pose_correction, splitRendBits.codec_frame_size_ms ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to write to bitstream file!\n" ); goto cleanup; @@ -2453,11 +2452,10 @@ static ivas_error decodeG192( } else { - if ( ( hSplitRendFileReadWrite != NULL ) && ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, splitRendBits.bits_buf, &splitRendBits.bits_read, &splitRendBits.bits_written, - splitRendBits.codec, splitRendBits.pose_correction, - splitRendBits.codec_frame_size_ms ) != IVAS_ERR_OK ) + splitRendBits.codec, splitRendBits.pose_correction, splitRendBits.codec_frame_size_ms ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to write to bitstream file!\n" ); goto cleanup; @@ -2613,13 +2611,11 @@ static ivas_error decodeG192( goto cleanup; } - - if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos[0], 0 #ifdef SPLIT_REND_WITH_HEAD_ROT - , - DEFAULT_AXIS + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos[0], 0, DEFAULT_AXIS ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos[0], 0 ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2627,13 +2623,12 @@ static ivas_error decodeG192( } /* decode and get samples */ - if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, + #ifdef SPLIT_REND_WITH_HEAD_ROT - IVAS_DEC_PCM_INT16, - (void *) + if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) #endif - pcmBuf, - &nSamplesFlushed ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; diff --git a/apps/renderer.c b/apps/renderer.c index 29009497a6..59a4c9e4e3 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -447,21 +447,16 @@ static void printSupportedAudioConfigs( void ); static IVAS_AUDIO_CONFIG parseAudioConfig( const char *configString ); -static void convertInputBuffer( const int16_t *intBuffer, const int16_t numIntSamplesPerChannel, const int16_t numFloatSamplesPerChannel, const int16_t numChannels, float *floatBuffer #ifdef SPLIT_REND_WITH_HEAD_ROT - , - const int16_t cldfb_in, - IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna -#endif -); +static void convertInputBuffer( const int16_t *intBuffer, const int16_t numIntSamplesPerChannel, const int16_t numFloatSamplesPerChannel, const int16_t numChannels, float *floatBuffer, const int16_t cldfb_in, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna ); -static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamplesPerChannel, const int16_t numChannels, int16_t *intBuffer -#ifdef SPLIT_REND_WITH_HEAD_ROT - , - const int16_t cldfb_in, - IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn +static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamplesPerChannel, const int16_t numChannels, int16_t *intBuffer, const int16_t cldfb_in, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn ); +#else +static void convertInputBuffer( const int16_t *intBuffer, const int16_t numIntSamplesPerChannel, const int16_t numFloatSamplesPerChannel, const int16_t numChannels, float *floatBuffer ); + +static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamplesPerChannel, const int16_t numChannels, int16_t *intBuffer ); #endif -); + /*------------------------------------------------------------------------------------------* * Local functions @@ -902,12 +897,11 @@ int main( else { /* With single-format input, all information is given on command line. */ - setupWithSingleFormatInput( args, audioFilePath, positionProvider, masaReaders #ifdef SPLIT_REND_WITH_HEAD_ROT - , - &hSplitRendFileReadWrite + setupWithSingleFormatInput( args, audioFilePath, positionProvider, masaReaders, &hSplitRendFileReadWrite ); +#else + setupWithSingleFormatInput( args, audioFilePath, positionProvider, masaReaders ); #endif - ); } /* Check that there is allowed configuration for MASA format output */ @@ -965,6 +959,7 @@ int main( inFileSampleRate = args.sampleRate; } #endif + switch ( error ) { case IVAS_ERR_OK: @@ -1016,8 +1011,7 @@ int main( IVAS_REND_InputId splitBinIds[RENDERER_MAX_BIN_INPUTS] = { 0 }; #endif - if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, args.nonDiegeticPan, args.nonDiegeticPanGain, - ( args.framing_5ms ) ? 1 : 4 ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, args.nonDiegeticPan, args.nonDiegeticPanGain, ( args.framing_5ms ) ? 1 : 4 ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error opening renderer handle: %s\n", ivas_error_to_string( error ) ); exit( -1 ); @@ -1311,12 +1305,11 @@ int main( } } - const int16_t totalNumInChannels = getTotalNumInChannels( hIvasRend, mcIds, ismIds, sbaIds, masaIds #ifdef SPLIT_REND_WITH_HEAD_ROT - , - splitBinIds + const int16_t totalNumInChannels = getTotalNumInChannels( hIvasRend, mcIds, ismIds, sbaIds, masaIds, splitBinIds ); +#else + const int16_t totalNumInChannels = getTotalNumInChannels( hIvasRend, mcIds, ismIds, sbaIds, masaIds ); #endif - ); if ( inFileNumChannels != 0 /* inFileNumChannels is 0 with raw PCM input */ && totalNumInChannels != inFileNumChannels ) { @@ -1527,12 +1520,11 @@ int main( } /* Convert from int to float and from interleaved to packed */ - convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer #ifdef SPLIT_REND_WITH_HEAD_ROT - , - inBuffer.config.is_cldfb, cldfbAna + convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer, inBuffer.config.is_cldfb, cldfbAna ); +#else + convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer ); #endif - ); int16_t num_subframes, sf_idx; num_subframes = ( args.framing_5ms ) ? 1 : IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; @@ -1589,13 +1581,12 @@ int main( fprintf( stderr, "Error in Head Rotation File Reading: %s\n", ivas_error_to_string( error ) ); exit( -1 ); } - if ( ( error = IVAS_REND_SetHeadRotation( hIvasRend, headRot, Pos + #ifdef SPLIT_REND_WITH_HEAD_ROT - , - DEFAULT_AXIS + if ( ( error = IVAS_REND_SetHeadRotation( hIvasRend, headRot, Pos, DEFAULT_AXIS, sf_idx ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_REND_SetHeadRotation( hIvasRend, headRot, Pos, sf_idx ) ) != IVAS_ERR_OK ) #endif - , - sf_idx ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error setting Head Rotation: %s\n", ivas_error_to_string( error ) ); exit( -1 ); @@ -1829,13 +1820,11 @@ int main( /* Convert from float to int and from packed to interleaved. * Values in outFloatBuffer are guaranteed to be within range INT16_MIN:INT16_MAX */ - convertOutputBuffer( outFloatBuffer, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer #ifdef SPLIT_REND_WITH_HEAD_ROT - , - cldfb_in, - cldfbSyn + convertOutputBuffer( outFloatBuffer, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer, cldfb_in, cldfbSyn ); +#else + convertOutputBuffer( outFloatBuffer, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer ); #endif - ); if ( delayNumSamples == -1 ) { @@ -1850,6 +1839,7 @@ int main( fprintf( stderr, "\nUnable to get delay of renderer!\n" ); exit( -1 ); } + #ifdef SPLIT_REND_WITH_HEAD_ROT if ( is_split_post_rend_mode( &args ) && ( hSplitRendFileReadWrite != NULL ) ) { @@ -1858,6 +1848,7 @@ int main( delayNumSamples += (int16_t) roundf( (float) pre_rend_delay_ns * delayTimeScale / 1000000000.f ); } #endif + delayNumSamples_orig = delayNumSamples; } else @@ -1868,7 +1859,7 @@ int main( } #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( hSplitRendFileReadWrite != NULL ) && is_split_pre_rend_mode( &args ) ) + if ( is_split_pre_rend_mode( &args ) ) { if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead, &bitsBuffer.config.bitsWritten, bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, @@ -1878,6 +1869,7 @@ int main( exit( -1 ); } } + if ( audioWriter != NULL ) { #endif diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 2ac5085b04..6a47a296b3 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5674,39 +5674,39 @@ void ivas_osba_enc( const int32_t input_Fs /* i : input sampling rate */ #ifdef FIX_732_PLANAR_SBA_OSBA , - const int16_t sba_planar /* i : planar SBA flag*/ + const int16_t sba_planar /* i : planar SBA flag */ #endif ); ivas_error ivas_masa_ism_data_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ); ivas_error ivas_sba_ism_separate_object_renderer_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); ivas_error ivas_osba_dirac_td_binaural( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[], /* o : output synthesis signal */ - const int16_t output_frame /* i : output frame length per channel */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output[], /* o : output synthesis signal */ + const int16_t output_frame /* i : output frame length per channel */ ); ivas_error ivas_osba_ism_metadata_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int32_t ism_total_brate, /* i : ISM total bitrate */ - int16_t *nchan_ism, /* o : number of ISM separated channels */ - int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int32_t ism_total_brate, /* i : ISM total bitrate */ + int16_t *nchan_ism, /* o : number of ISM separated channels */ + int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ ); ivas_error ivas_osba_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output_f[], /* i/o: core-coder transport channels/object output */ - const int16_t output_frame /* i : output frame length per channel */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output_f[], /* i/o: core-coder transport channels/object output */ + const int16_t output_frame /* i : output frame length per channel */ ); void ivas_masa_ism_data_close( - MASA_ISM_DATA_HANDLE *hMasaIsmData /* i/o: MASA_ISM rendering handle */ + MASA_ISM_DATA_HANDLE *hMasaIsmData /* i/o: MASA_ISM rendering handle */ ); diff --git a/lib_com/prot.h b/lib_com/prot.h index 239d1b57eb..babc0b3141 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -2266,7 +2266,7 @@ void read_next_force( ivas_error init_encoder( Encoder_State *st, /* i/o: state structure */ - Encoder_Struct *st_ivas, /* i/o: encoder state structure */ + Encoder_Struct *st_ivas, /* i/o: encoder state structure */ const int16_t idchan, /* i : channel ID */ const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */ const int16_t interval_SID, /* i : interval for SID update */ @@ -2274,7 +2274,7 @@ ivas_error init_encoder( const ISM_MODE ism_mode /* i : ISM mode */ #ifdef IGF_MEMORY_ALLOC_OPT , - const int32_t element_brate + const int32_t element_brate /* element bitrate */ #endif ); diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index daeae98497..e8ce6df818 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1187,12 +1187,11 @@ ivas_error ivas_binRenderer_open( else { /* Allocate memories and buffers needed for convolutional module */ - if ( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv #ifdef SPLIT_REND_WITH_HEAD_ROT - , - hBinRenderer->numPoses + if ( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -1421,12 +1420,11 @@ void ivas_binRenderer_close( if ( ( *hBinRenderer )->hBinRenConvModule != NULL ) { - ivas_binRenderer_convModuleClose( hBinRenderer #ifdef SPLIT_REND_WITH_HEAD_ROT - , - ( *hBinRenderer )->numPoses + ivas_binRenderer_convModuleClose( hBinRenderer, ( *hBinRenderer )->numPoses ); +#else + ivas_binRenderer_convModuleClose( hBinRenderer ); #endif - ); } if ( ( *hBinRenderer )->hReverb != NULL ) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 3d36438a25..6602c344c1 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -309,12 +309,11 @@ ivas_error ivas_dec( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, p_output, output_Fs, MAX_PARAM_SPATIAL_SUBFRAMES #ifdef SPLIT_REND_WITH_HEAD_ROT - , - 0 + if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, p_output, output_Fs, MAX_PARAM_SPATIAL_SUBFRAMES, 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, p_output, output_Fs, MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -815,15 +814,12 @@ ivas_error ivas_dec( } else { -#endif if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, - st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, p_output, output_Fs, MAX_PARAM_SPATIAL_SUBFRAMES -#ifdef SPLIT_REND_WITH_HEAD_ROT - , - 0 + st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, p_output, output_Fs, MAX_PARAM_SPATIAL_SUBFRAMES, 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, + st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, p_output, output_Fs, MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) - { return error; } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 7df962b5f0..0f1c121f1f 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1978,13 +1978,13 @@ ivas_error ivas_init_decoder( } } - if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, - st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs #ifdef SPLIT_REND_WITH_HEAD_ROT - , - st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, + st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, + st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -2631,12 +2631,12 @@ void ivas_destroy_dec( #endif /* Crend handle */ - ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) + #ifdef SPLIT_REND_WITH_HEAD_ROT - , - st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses + ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ); +#else + ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); #endif - ); /* Reverb handle */ ivas_reverb_close( &st_ivas->hReverb ); diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 870812f767..e20dfc1cb2 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -235,12 +235,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( #endif /* Open Crend Binaural renderer */ - if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs #ifdef SPLIT_REND_WITH_HEAD_ROT - , - st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -319,12 +318,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( } /* close the crend binaural renderer */ - ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) #ifdef SPLIT_REND_WITH_HEAD_ROT - , - st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses + ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ); +#else + ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); #endif - ); } } diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 0f77c6bac2..7a2e21c462 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -59,7 +59,7 @@ static void ps_pred_process( MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix, float qmf_m static void ps_pred_process_sf( MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix, DECODER_TC_BUFFER_HANDLE hTcBuffer, float qmf_mod_re[JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float qmf_mod_im[JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float qmf_side_re[JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float qmf_side_im[JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float *param_interpol, const int16_t ch, const int16_t slots_rendered ); #ifdef SPLIT_REND_WITH_HEAD_ROT -static void ivas_mc_paramupmix_dec_sf( Decoder_Struct *st_ivas, float *output_f[MAX_OUTPUT_CHANNELS], int16_t slot_index_start ); +static void ivas_mc_paramupmix_dec_sf( Decoder_Struct *st_ivas, float *output_f[MAX_OUTPUT_CHANNELS], const int16_t slot_index_start ); #else static void ivas_mc_paramupmix_dec_sf( Decoder_Struct *st_ivas, float *output_f[MAX_OUTPUT_CHANNELS] ); #endif @@ -1044,7 +1044,7 @@ static void ivas_mc_paramupmix_dec_sf( float *output_f[MAX_OUTPUT_CHANNELS] /* i/o: synthesized core-coder transport channels */ #ifdef SPLIT_REND_WITH_HEAD_ROT , - int16_t slot_index_start + const int16_t slot_index_start #endif ) { diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 017bb81b96..dfe115c6a7 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -692,11 +692,12 @@ ivas_error ivas_mc_dec_config( { if ( st_ivas->hDecoderConfig->last_ivas_total_brate != st_ivas->hDecoderConfig->ivas_total_brate || st_ivas->transport_config != signaled_config || last_mc_mode != st_ivas->mc_mode ) { - if ( ( error = ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, #ifdef SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, + if ( ( error = ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) + { return error; } @@ -723,7 +724,7 @@ static ivas_error ivas_mc_dec_reconfig( 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 */ + int16_t *data /* o : output synthesis signal */ #endif ) { @@ -806,11 +807,11 @@ static ivas_error ivas_mc_dec_reconfig( tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { - if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, #ifdef SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, + if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) { return error; } @@ -1221,12 +1222,12 @@ 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 { - ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) + #ifdef SPLIT_REND_WITH_HEAD_ROT - , - st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses + ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ); +#else + ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); #endif - ); } if ( st_ivas->hBinRendererTd != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) ) @@ -1267,12 +1268,11 @@ static ivas_error ivas_mc_dec_reconfig( if ( st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - if ( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper #ifdef SPLIT_REND_WITH_HEAD_ROT - , - 1 + if ( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper, 1 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Wrapper\n" ); } @@ -1280,7 +1280,6 @@ static ivas_error ivas_mc_dec_reconfig( #ifdef SPLIT_REND_WITH_HEAD_ROT st_ivas->hCrendWrapper->hCrend[0] = NULL; st_ivas->hCrendWrapper->hHrtfCrend = NULL; - if ( ( st_ivas->hCrendWrapper->hCrend[0] = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" ); @@ -1297,12 +1296,11 @@ static ivas_error ivas_mc_dec_reconfig( } else if ( st_ivas->hCrendWrapper == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { - if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs #ifdef SPLIT_REND_WITH_HEAD_ROT - , - st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 40cfd67fcd..3a3530a7d5 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -818,6 +818,7 @@ typedef struct ivas_binaural_rendering_struct } BINAURAL_RENDERER, *BINAURAL_RENDERER_HANDLE; #endif + /*----------------------------------------------------------------------------------* * MASA decoder structures *----------------------------------------------------------------------------------*/ @@ -887,72 +888,9 @@ typedef struct ivas_masa_ism_data_structure /*----------------------------------------------------------------------------------* - * Decoder configuration structure + * JBM structures *----------------------------------------------------------------------------------*/ -typedef struct decoder_config_structure -{ - int32_t ivas_total_brate; /* IVAS total bitrate in bps */ - int32_t last_ivas_total_brate; /* last IVAS total bitrate in bps */ - int32_t output_Fs; /* output signal sampling frequency in Hz */ - int16_t nchan_out; /* number of output audio channels */ - AUDIO_CONFIG output_config; /* output audio configuration */ - int16_t Opt_LsCustom; /* indicates whether loudspeaker custom setup is used */ - int16_t Opt_HRTF_binary; /* indicates whether HRTF binary file is used */ - int16_t Opt_Headrotation; /* indicates whether head-rotation is used */ - int16_t Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ - IVAS_HEAD_ORIENT_TRK_T orientation_tracking; /* indicates orientation tracking type */ - int16_t Opt_non_diegetic_pan; /* indicates diegetic or not */ - float non_diegetic_pan_gain; /* non diegetic panning gain*/ - int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ - int16_t Opt_ExternalOrientation; /* indiates whether external orientations are used */ -#ifdef FIX_708_DPID_COMMAND_LINE - int16_t Opt_dpid_on; /* indicates whether Directivity pattern option is used */ -#endif -#ifdef FIX_708_AEID_COMMAND_LINE - int16_t Opt_aeid_on; /* indicates whether Acoustic environment option is used */ -#endif - - /* temp. development parameters */ -#ifdef DEBUGGING - int16_t force_rend; /* forced TD/CLDFB binaural renderer (for ISM and MC) */ -#endif - int16_t Opt_tsm; -#ifdef SPLIT_REND_WITH_HEAD_ROT - int16_t Opt_Limiter; -#endif - int16_t Opt_5ms; - int16_t Opt_delay_comp; /* flag indicating delay compensation active */ - -} DECODER_CONFIG, *DECODER_CONFIG_HANDLE; - -#ifdef SPLIT_REND_WITH_HEAD_ROT -typedef struct -{ - 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]; - -} IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA, *IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE; - -typedef struct -{ - float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - AUDIO_CONFIG config; - -} IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA, *IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE; - -typedef struct -{ - IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE hMultiBinCldfbData; /*scratch buffer for frame by frame processing*/ - IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits; /*scratch buffer for frame by frame processing*/ - SPLIT_REND_WRAPPER splitrend; - IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE hCldfbDataOut; /*buffer to store cldfb data before binauralization*/ - float *tdDataOut; /*buffer to store TD data before binauralization*/ - int16_t numTdSamplesPerChannelCached; -} IVAS_DEC_SPLIT_REND_WRAPPER; -#endif - typedef struct decoder_tc_buffer_structure { float *tc_buffer; /* the buffer itself */ @@ -996,6 +934,80 @@ typedef struct jbm_metadata_structure } JBM_METADATA, *JBM_METADATA_HANDLE; +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*----------------------------------------------------------------------------------* + * Split rendering structures + *----------------------------------------------------------------------------------*/ + +typedef struct +{ + 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]; + +} IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA, *IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE; + +typedef struct +{ + float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + AUDIO_CONFIG config; + +} IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA, *IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE; + +typedef struct +{ + IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE hMultiBinCldfbData; /*scratch buffer for frame by frame processing*/ + IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits; /*scratch buffer for frame by frame processing*/ + SPLIT_REND_WRAPPER splitrend; + IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE hCldfbDataOut; /*buffer to store cldfb data before binauralization*/ + float *tdDataOut; /*buffer to store TD data before binauralization*/ + int16_t numTdSamplesPerChannelCached; + +} IVAS_DEC_SPLIT_REND_WRAPPER; +#endif + + +/*----------------------------------------------------------------------------------* + * Decoder configuration structure + *----------------------------------------------------------------------------------*/ + +typedef struct decoder_config_structure +{ + int32_t ivas_total_brate; /* IVAS total bitrate in bps */ + int32_t last_ivas_total_brate; /* last IVAS total bitrate in bps */ + int32_t output_Fs; /* output signal sampling frequency in Hz */ + int16_t nchan_out; /* number of output audio channels */ + AUDIO_CONFIG output_config; /* output audio configuration */ + int16_t Opt_LsCustom; /* indicates whether loudspeaker custom setup is used */ + int16_t Opt_HRTF_binary; /* indicates whether HRTF binary file is used */ + int16_t Opt_Headrotation; /* indicates whether head-rotation is used */ + int16_t Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ + IVAS_HEAD_ORIENT_TRK_T orientation_tracking; /* indicates orientation tracking type */ + int16_t Opt_non_diegetic_pan; /* indicates diegetic or not */ + float non_diegetic_pan_gain; /* non diegetic panning gain*/ + int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ + int16_t Opt_ExternalOrientation; /* indiates whether external orientations are used */ +#ifdef FIX_708_DPID_COMMAND_LINE + int16_t Opt_dpid_on; /* indicates whether Directivity pattern option is used */ +#endif +#ifdef FIX_708_AEID_COMMAND_LINE + int16_t Opt_aeid_on; /* indicates whether Acoustic environment option is used */ +#endif + + /* temp. development parameters */ +#ifdef DEBUGGING + int16_t force_rend; /* forced TD/CLDFB binaural renderer (for ISM and MC) */ +#endif + int16_t Opt_tsm; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t Opt_Limiter; +#endif + int16_t Opt_5ms; + int16_t Opt_delay_comp; /* flag indicating delay compensation active */ + +} DECODER_CONFIG, *DECODER_CONFIG_HANDLE; + + /*----------------------------------------------------------------------------------* * * Main IVAS decoder structure diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index c7b8ab3190..63af9dda77 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -55,7 +55,7 @@ ivas_error init_encoder( Encoder_State *st, /* i/o: state structure */ - Encoder_Struct *st_ivas, /* i/o: encoder state structure */ + Encoder_Struct *st_ivas, /* i/o: encoder state structure */ const int16_t idchan, /* i : channel ID */ const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */ const int16_t interval_SID, /* i : interval for SID update */ @@ -63,7 +63,7 @@ ivas_error init_encoder( const ISM_MODE ism_mode /* i : ISM mode */ #ifdef IGF_MEMORY_ALLOC_OPT , - const int32_t element_brate + const int32_t element_brate /* i : element bitrate */ #endif ) { diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 8b5d25df04..d497722744 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -397,12 +397,11 @@ ivas_error ivas_enc( #endif /* Analyze objects and determine needed audio signals */ - ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order, hEncoderConfig->input_Fs #ifdef FIX_732_PLANAR_SBA_OSBA - , - hEncoderConfig->sba_planar + ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order, hEncoderConfig->input_Fs, hEncoderConfig->sba_planar ); +#else + ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order, hEncoderConfig->input_Fs ); #endif - ); if ( st_ivas->ism_mode == ISM_MODE_NONE ) { diff --git a/lib_enc/ivas_omasa_enc.c b/lib_enc/ivas_omasa_enc.c index 9d363c0938..a566f5a83a 100644 --- a/lib_enc/ivas_omasa_enc.c +++ b/lib_enc/ivas_omasa_enc.c @@ -668,10 +668,10 @@ void ivas_set_ism_importance_interformat( *--------------------------------------------------------------------------*/ void ivas_set_surplus_brate_enc( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ #ifdef DEBUG_MODE_INFO , - const int16_t *nb_bits_metadata /* i : number of metadata bits */ + const int16_t *nb_bits_metadata /* i : number of metadata bits */ #endif ) { diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index 4d988a8c4c..0c0e0d19a0 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -390,11 +390,11 @@ void ivas_osba_enc( const int16_t input_frame, /* i : Input frame size */ const int16_t nchan_ism, /* i : Number of objects for parameter analysis */ const ISM_MODE ism_mode, /* i : ISM mode */ - const int16_t sba_analysis_order, /* i : SBA order evaluated in DirAC/SPAR encoder */ - const int32_t input_Fs /* i : input sampling rate*/ + const int16_t sba_analysis_order, /* i : SBA order evaluated in DirAC/SPAR encoder */ + const int32_t input_Fs /* i : input sampling rate */ #ifdef FIX_732_PLANAR_SBA_OSBA , - const int16_t sba_planar /* i : planar SBA flag*/ + const int16_t sba_planar /* i : planar SBA flag */ #endif ) { diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index e297d747a8..8567693244 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -371,12 +371,11 @@ ivas_error create_sce_enc( st->total_brate = hSCE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; - if ( ( error = init_encoder( st, st_ivas, 0, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID, 0, st_ivas->ism_mode #ifdef IGF_MEMORY_ALLOC_OPT - , - hSCE->element_brate + if ( ( error = init_encoder( st, st_ivas, 0, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID, 0, st_ivas->ism_mode, hSCE->element_brate ) ) != IVAS_ERR_OK ) +#else + if ( ( error = init_encoder( st, st_ivas, 0, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID, 0, st_ivas->ism_mode ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 7b0e5cbd8d..7f97417739 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -223,12 +223,11 @@ ivas_error ivas_spar_enc_open( hSpar->hCoreCoderVAD->total_brate = hEncoderConfig->ivas_total_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ hSpar->hCoreCoderVAD->mct_chan_mode = MCT_CHAN_MODE_IGNORE; - if ( ( error = init_encoder( hSpar->hCoreCoderVAD, st_ivas, 0, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 1, st_ivas->ism_mode #ifdef IGF_MEMORY_ALLOC_OPT - , - hSpar->hCoreCoderVAD->total_brate + if ( ( error = init_encoder( hSpar->hCoreCoderVAD, st_ivas, 0, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 1, st_ivas->ism_mode, hSpar->hCoreCoderVAD->total_brate ) ) != IVAS_ERR_OK ) +#else + if ( ( error = init_encoder( hSpar->hCoreCoderVAD, st_ivas, 0, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 1, st_ivas->ism_mode ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 0d9092958a..b79d329d96 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1212,12 +1212,11 @@ ivas_error ivas_rend_openMultiBinCrend( { ivas_error error; - if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, output_Fs #ifdef SPLIT_REND_WITH_HEAD_ROT - , - pMultiBinPoseData->num_poses + if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, 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 - ) ) != IVAS_ERR_OK ) { return error; } @@ -1256,12 +1255,12 @@ ivas_error ivas_rend_openCrend( #endif error = IVAS_ERR_OK; - if ( ( error = ivas_rend_initCrendWrapper( pCrend + #ifdef SPLIT_REND_WITH_HEAD_ROT - , - num_poses + if ( ( error = ivas_rend_initCrendWrapper( pCrend, num_poses ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_initCrendWrapper( pCrend ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -1838,12 +1837,11 @@ ivas_error ivas_rend_crendProcess( if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED || inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) { - if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, output, p_pcm_tmp, output_Fs, subframe_idx #ifdef SPLIT_REND_WITH_HEAD_ROT - , - pos_idx + if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, output, p_pcm_tmp, output_Fs, subframe_idx, pos_idx ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, output, p_pcm_tmp, output_Fs, subframe_idx ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 7f6b34584d..1e6de47076 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -66,7 +66,6 @@ #define MAX_BUFFER_LENGTH ( MAX_BUFFER_LENGTH_PER_CHANNEL * MAX_INPUT_CHANNELS ) #endif - #define MAX_BIN_DELAY_SAMPLES 50 /* Maximum supported rendering latency for binaural IRs */ /* Frame size required when rendering to binaural */ @@ -1330,12 +1329,11 @@ static ivas_error initIsmMasaRendering( inputIsm->tdRendWrapper.hHrtfTD = NULL; } - ivas_rend_closeCrend( &inputIsm->crendWrapper #ifdef SPLIT_REND_WITH_HEAD_ROT - , - inputIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses + ivas_rend_closeCrend( &inputIsm->crendWrapper, inputIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else + ivas_rend_closeCrend( &inputIsm->crendWrapper ); #endif - ); ivas_reverb_close( &inputIsm->hReverb ); @@ -1468,12 +1466,11 @@ static ivas_error setRendInputActiveIsm( } else if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { - if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate #ifdef SPLIT_REND_WITH_HEAD_ROT - , - rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses + if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -1499,13 +1496,11 @@ static void clearInputIsm( initRendInputBase( &inputIsm->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); /* Free input's internal handles */ - - ivas_rend_closeCrend( &inputIsm->crendWrapper #ifdef SPLIT_REND_WITH_HEAD_ROT - , - inputIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses + ivas_rend_closeCrend( &inputIsm->crendWrapper, inputIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else + ivas_rend_closeCrend( &inputIsm->crendWrapper ); #endif - ); ivas_reverb_close( &inputIsm->hReverb ); @@ -2201,14 +2196,11 @@ static ivas_error initMcBinauralRendering( inputMc->splitTdRendWrappers[i].hHrtfTD = NULL; } } -#endif - ivas_rend_closeCrend( &inputMc->crendWrapper -#ifdef SPLIT_REND_WITH_HEAD_ROT - , - inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses + ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else + ivas_rend_closeCrend( &inputMc->crendWrapper ); #endif - ); ivas_reverb_close( &inputMc->hReverb ); @@ -2274,16 +2266,14 @@ static ivas_error initMcBinauralRendering( } } - { - if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, NULL, outSampleRate #ifdef SPLIT_REND_WITH_HEAD_ROT - , - ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 + if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, NULL, outSampleRate, ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, NULL, outSampleRate ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) - { - return error; - } + + { + return error; } /* Initialise the EFAP handle for rotation on input layout */ @@ -2321,12 +2311,11 @@ static ivas_error initMcMasaRendering( inputMc->tdRendWrapper.hHrtfTD = NULL; } - ivas_rend_closeCrend( &inputMc->crendWrapper #ifdef SPLIT_REND_WITH_HEAD_ROT - , - inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses + ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else + ivas_rend_closeCrend( &inputMc->crendWrapper ); #endif - ); ivas_reverb_close( &inputMc->hReverb ); @@ -2512,12 +2501,12 @@ static void clearInputMc( efap_free_data( &inputMc->efapInWrapper.hEfap ); } - ivas_rend_closeCrend( &inputMc->crendWrapper + #ifdef SPLIT_REND_WITH_HEAD_ROT - , - inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses + ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else + ivas_rend_closeCrend( &inputMc->crendWrapper ); #endif - ); ivas_reverb_close( &inputMc->hReverb ); @@ -2725,12 +2714,12 @@ static ivas_error updateSbaPanGains( else #endif { - if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate #ifdef SPLIT_REND_WITH_HEAD_ROT - , - rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses + if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) + { return error; } @@ -2743,12 +2732,11 @@ static ivas_error updateSbaPanGains( return error; } - if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate #ifdef SPLIT_REND_WITH_HEAD_ROT - , - rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses + if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -2814,12 +2802,11 @@ static ivas_error initSbaMasaRendering( { ivas_error error; - ivas_rend_closeCrend( &inputSba->crendWrapper #ifdef SPLIT_REND_WITH_HEAD_ROT - , - inputSba->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses + ivas_rend_closeCrend( &inputSba->crendWrapper, inputSba->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else + ivas_rend_closeCrend( &inputSba->crendWrapper ); #endif - ); if ( ( error = ivas_dirac_ana_open( &inputSba->hDirAC, inSampleRate ) ) != IVAS_ERR_OK ) { @@ -3386,12 +3373,11 @@ static ivas_error setRendInputActiveMasa( } else { - inputMasa->decDummy = initDecoderDummy( *rendCtx.pOutSampleRate, numInChannels, outConfig, 0 #ifdef SPLIT_REND_WITH_HEAD_ROT - , - rendCtx.pSplitRendWrapper + inputMasa->decDummy = initDecoderDummy( *rendCtx.pOutSampleRate, numInChannels, outConfig, 0, rendCtx.pSplitRendWrapper ); +#else + inputMasa->decDummy = initDecoderDummy( *rendCtx.pOutSampleRate, numInChannels, outConfig, 0 ); #endif - ); inputMasa->metadataHasBeenFed = false; @@ -6086,14 +6072,16 @@ static ivas_error renderIsmToBinauralRoom( #endif /* render 7_1_4 with BRIRs */ +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_rend_crendProcess( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *ismInput->base.ctx.pOutSampleRate, - getNumSubframesInBuffer( &outAudio, *ismInput->base.ctx.pOutSampleRate ) -#ifdef SPLIT_REND_WITH_HEAD_ROT - , - 0 + getNumSubframesInBuffer( &outAudio, *ismInput->base.ctx.pOutSampleRate ), 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcess( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, + NULL, NULL, NULL, NULL, p_tmpRendBuffer, *ismInput->base.ctx.pOutSampleRate, + getNumSubframesInBuffer( &outAudio, *ismInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) + #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -6738,13 +6726,13 @@ static ivas_error renderMcToBinaural( } /* call CREND */ - if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, - getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) #ifdef SPLIT_REND_WITH_HEAD_ROT - , - 0 + if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, + getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ), 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, + getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -6845,13 +6833,13 @@ static ivas_error renderMcToBinauralRoom( } /* call CREND */ - if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, - getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) #ifdef SPLIT_REND_WITH_HEAD_ROT - , - 0 + if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, + getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ), 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, + getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -6953,14 +6941,13 @@ static ivas_error renderMcCustomLsToBinauralRoom( copyBufferTo2dArray( tmpMcBuffer, tmpCrendBuffer ); /* call CREND */ - if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, - p_tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate, - getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) #ifdef SPLIT_REND_WITH_HEAD_ROT - , - 0 + if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, + p_tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ), 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, + p_tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -7491,12 +7478,11 @@ static ivas_error renderSplitBinauralWithPostRot( { if ( !SplitRendBFI ) { - ivas_splitBinPostRendMdDec( &bits, hSplitBin->hBinHrSplitPostRend, &hSplitBin->multiBinPoseData #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - , - hSplitBin->hBinHrSplitPreRend + ivas_splitBinPostRendMdDec( &bits, hSplitBin->hBinHrSplitPostRend, &hSplitBin->multiBinPoseData, hSplitBin->hBinHrSplitPreRend ); +#else + ivas_splitBinPostRendMdDec( &bits, hSplitBin->hBinHrSplitPostRend, &hSplitBin->multiBinPoseData ); #endif - ); } } @@ -7898,15 +7884,13 @@ static ivas_error renderSbaToBinaural( /* copy input for in-place rotation */ 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], + if ( ( error = rotateFrameSba( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, + sbaInput->base.ctx.pCombinedOrientationData, sbaInput->rot_gains_prev[0], tmpRotBuffer ) ) != IVAS_ERR_OK ) #else - sbaInput->rot_gains_prev, + if ( ( error = rotateFrameSba( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, + sbaInput->base.ctx.pCombinedOrientationData, sbaInput->rot_gains_prev, tmpRotBuffer ) ) != IVAS_ERR_OK ) #endif - tmpRotBuffer ) ) != IVAS_ERR_OK ) - { return error; } @@ -7920,13 +7904,13 @@ static ivas_error renderSbaToBinaural( } /* call CREND */ - if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, - getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) #ifdef SPLIT_REND_WITH_HEAD_ROT - , - 0 + if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ), 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -8025,12 +8009,11 @@ static ivas_error renderSbaToBinauralRoom( /* call CREND */ if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, - getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) #ifdef SPLIT_REND_WITH_HEAD_ROT - , - 0 + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ), 0 ) ) != IVAS_ERR_OK ) +#else + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -8558,12 +8541,12 @@ static ivas_error renderInputMasa( switch ( outConfig ) { case IVAS_AUDIO_CONFIG_BINAURAL: - renderMasaToBinaural( masaInput, outAudio + #ifdef SPLIT_REND_WITH_HEAD_ROT - , - 0 + renderMasaToBinaural( masaInput, outAudio, 0 ); +#else + renderMasaToBinaural( masaInput, outAudio ); #endif - ); break; /* ToDo */ // #ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG @@ -8577,12 +8560,11 @@ static ivas_error renderInputMasa( #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: - renderMasaToBinaural( masaInput, outAudio #ifdef SPLIT_REND_WITH_HEAD_ROT - , - 1 + renderMasaToBinaural( masaInput, outAudio, 1 ); +#else + renderMasaToBinaural( masaInput, outAudio ); #endif - ); break; #endif default: @@ -9013,7 +8995,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, td_input, diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 2635e77f83..4cf758a671 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -273,12 +273,11 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( ivas_error IVAS_REND_SetHeadRotation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_QUATERNION headRot, /* i : head orientations for next rendering call */ - const IVAS_VECTOR3 Pos /* i : listener positions for next rendering call */ + const IVAS_VECTOR3 Pos, /* i : listener positions for next rendering call */ #ifdef SPLIT_REND_WITH_HEAD_ROT - , - IVAS_SPLIT_REND_ROT_AXIS rot_axis + IVAS_SPLIT_REND_ROT_AXIS rot_axis, #endif -, const int16_t sf_idx + const int16_t sf_idx ); /* Head rotation becomes enabled by calling IVAS_REND_SetHeadRotation. Use this to disable. */ -- GitLab From 6de6409d8f5e43b48ace32ac111a0bfbe7b28c32 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 15 Sep 2023 15:04:15 +0200 Subject: [PATCH 05/13] formatting, "const", harmonize flags related to the SR code. --- apps/renderer.c | 42 +++++------ lib_com/ivas_cnst.h | 9 ++- lib_dec/ivas_dirac_dec.c | 7 +- lib_dec/ivas_init_dec.c | 99 +++++++++++++------------ lib_dec/ivas_mc_paramupmix_dec.c | 17 ++--- lib_dec/ivas_osba_dec.c | 3 +- lib_dec/lib_dec.c | 38 +++++----- lib_rend/ivas_dirac_rend.c | 6 +- lib_rend/ivas_objectRenderer.c | 2 +- lib_rend/ivas_prot_rend.h | 37 +++++---- lib_rend/ivas_splitRendererPost.c | 4 +- lib_rend/ivas_splitRendererPre.c | 62 +++++++--------- lib_rend/ivas_splitRenderer_utils.c | 17 +++-- lib_rend/lib_rend.c | 68 ++++++++--------- lib_util/split_render_file_read_write.h | 3 +- 15 files changed, 203 insertions(+), 211 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 59a4c9e4e3..d11ff01c76 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -675,21 +675,21 @@ static int16_t get_cldfb_in_flag( const IVAS_AUDIO_CONFIG audioConfig, IVAS_RENDER_CONFIG_DATA *renderConfig ) { - int16_t cldfb_in; + int16_t cldfb_in_flag; - cldfb_in = 0; + cldfb_in_flag = 0; if ( renderConfig->split_rend_config.rendererSelection == IVAS_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) { #ifdef DEBUGGING - cldfb_in = 1; + cldfb_in_flag = 1; #endif if ( audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { - cldfb_in = 1; + cldfb_in_flag = 1; } } - return cldfb_in; + return cldfb_in_flag; } @@ -740,7 +740,7 @@ int main( #ifdef SPLIT_REND_WITH_HEAD_ROT IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS]; IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_INPUT_CHANNELS]; - int16_t cldfb_in, CLDFBframeSize_smpls; + int16_t cldfb_in_flag, CLDFBframeSize_smpls; SplitRendBFIFileReader *splitRendBFIReader = NULL; #endif Vector3PairFileReader *referenceVectorReader = NULL; @@ -1026,7 +1026,7 @@ int main( #ifdef SPLIT_REND_WITH_HEAD_ROT CLDFBframeSize_smpls = 0; - cldfb_in = 0; + cldfb_in_flag = 0; #endif if ( args.renderConfigFilePath[0] != '\0' ) @@ -1097,7 +1097,7 @@ int main( if ( !is_split_post_rend_mode( &args ) ) { CLDFBframeSize_smpls = frameSize_smpls * 2; - cldfb_in = get_cldfb_in_flag( args.outConfig.audioConfig, &renderConfig ); + cldfb_in_flag = get_cldfb_in_flag( args.outConfig.audioConfig, &renderConfig ); } #endif } @@ -1333,7 +1333,7 @@ int main( } #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( cldfb_in ) + if ( cldfb_in_flag ) { if ( ( error = IVAS_REND_openCldfb( cldfbAna, cldfbSyn, totalNumInChannels, numOutChannels, args.sampleRate ) ) != IVAS_ERR_OK ) { @@ -1389,7 +1389,7 @@ int main( inpInt16Buffer = malloc( inBufferSize * sizeof( int16_t ) ); #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( cldfb_in == 0 ) + if ( cldfb_in_flag == 0 ) { inFloatBuffer = malloc( inBufferSize * sizeof( float ) ); inBuffer.config.numSamplesPerChannel = (int16_t) frameSize_smpls; @@ -1405,11 +1405,11 @@ int main( } outInt16Buffer = malloc( outBufferSize * sizeof( int16_t ) ); - inBuffer.config.is_cldfb = cldfb_in; + inBuffer.config.is_cldfb = cldfb_in_flag; inBuffer.config.numChannels = (int16_t) totalNumInChannels; inBuffer.data = inFloatBuffer; - outBuffer.config.is_cldfb = cldfb_in; + outBuffer.config.is_cldfb = cldfb_in_flag; outBuffer.config.numChannels = (int16_t) numOutChannels; outBuffer.data = outFloatBuffer; @@ -1821,7 +1821,7 @@ int main( /* Convert from float to int and from packed to interleaved. * Values in outFloatBuffer are guaranteed to be within range INT16_MIN:INT16_MAX */ #ifdef SPLIT_REND_WITH_HEAD_ROT - convertOutputBuffer( outFloatBuffer, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer, cldfb_in, cldfbSyn ); + convertOutputBuffer( outFloatBuffer, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer, cldfb_in_flag, cldfbSyn ); #else convertOutputBuffer( outFloatBuffer, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer ); #endif @@ -2063,15 +2063,12 @@ int main( } #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( cldfb_in ) + if ( cldfb_in_flag ) { IVAS_REND_closeCldfb( cldfbAna, cldfbSyn ); } - if ( hSplitRendFileReadWrite != NULL ) - { - split_rend_reader_writer_close( &hSplitRendFileReadWrite ); - } + split_rend_reader_writer_close( &hSplitRendFileReadWrite ); #endif for ( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i ) @@ -3805,7 +3802,7 @@ static void convertInputBuffer( float *floatBuffer #ifdef SPLIT_REND_WITH_HEAD_ROT , - const int16_t cldfb_in, + const int16_t cldfb_in_flag, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna #endif ) @@ -3813,8 +3810,9 @@ static void convertInputBuffer( int16_t chnl, smpl, i; i = 0; + #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( cldfb_in ) + if ( cldfb_in_flag ) { int16_t slotIdx, numCldfbBands, numFloatPcmSamples; float fIn[IVAS_MAX_OUTPUT_CHANNELS][IVAS_MAX_FRAME_SIZE]; @@ -3892,7 +3890,7 @@ static void convertOutputBuffer( int16_t *intBuffer #ifdef SPLIT_REND_WITH_HEAD_ROT , - const int16_t cldfb_in, + const int16_t cldfb_in_flag, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn #endif ) @@ -3903,7 +3901,7 @@ static void convertOutputBuffer( i = 0; #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( cldfb_in ) + if ( cldfb_in_flag ) { int16_t slotIdx, numCldfbBands, numPcmSamples, b; float fIn[IVAS_MAX_OUTPUT_CHANNELS][IVAS_MAX_FRAME_SIZE]; diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 6aeac2559e..e38f342328 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -367,15 +367,16 @@ typedef enum #ifndef FIX_747_ISM_TODOS #define BRATE_ISM_INACTIVE 2450 /* CoreCoder bitrate in ISM inactive frames */ #endif +/* ISM modes */ typedef enum { ISM_MODE_NONE, ISM_MODE_DISC, /* discrete ISM */ ISM_MODE_PARAM, /* parametric ISM */ - ISM_MASA_MODE_MASA_ONE_OBJ, /* MASA ISM mode when one object is encoded separately and remainder using MASA parameters */ - ISM_MASA_MODE_PARAM_ONE_OBJ, /* MASA ISM mode when one object is encoded separately and remainder using parametric object model */ - ISM_MASA_MODE_DISC, /* MASA ISM mode when all objects are encoded separarately */ - ISM_SBA_MODE_DISC /* MASA ISM mode when all objects are encoded separarately */ + ISM_MASA_MODE_MASA_ONE_OBJ, /* MASA ISM mode when one object is encoded separately and remainder using MASA parameters */ + ISM_MASA_MODE_PARAM_ONE_OBJ, /* MASA ISM mode when one object is encoded separately and remainder using parametric object model */ + ISM_MASA_MODE_DISC, /* MASA ISM mode when all objects are encoded separarately */ + ISM_SBA_MODE_DISC /* SBA ISM mode when all objects are encoded separarately */ } ISM_MODE; diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 907d04a7d3..3086fb5a48 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2427,11 +2427,12 @@ 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, subframe_idx, hSpatParamRendCom->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); +#else + ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, subframe_idx, hSpatParamRendCom->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); #endif - st_ivas->hCombinedOrientationData, subframe_idx, hSpatParamRendCom->subframe_nbslots[subframe_idx], 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 ba1426cd1a..6f4bf2e1d2 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -72,22 +72,22 @@ static ivas_error ivas_dec_reconfig_split_rend( ) { ivas_error error; - int16_t cldfb_in, num_ch, ch, isCldfbNeeded, i, pcm_out; + int16_t cldfb_in_flag, num_ch, ch, isCldfbNeeded, i, pcm_out_flag; SPLIT_REND_WRAPPER *hSplitRendWrapper; #ifndef OSBA_SPLIT_RENDERING CLDFB_TYPE cldfbMode; #endif hSplitRendWrapper = &st_ivas->hSplitBinRend.splitrend; - pcm_out = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; - cldfb_in = 0; + 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 = 1; + cldfb_in_flag = 1; } ivas_renderSplitGetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &hSplitRendWrapper->multiBinPoseData, st_ivas->hHeadTrackData->sr_pose_pred_axis ); @@ -98,26 +98,27 @@ static ivas_error ivas_dec_reconfig_split_rend( #else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) { - cldfb_in = 0; + cldfb_in_flag = 0; } #endif + if ( st_ivas->renderer_type != RENDERER_DISABLE ) { - if ( cldfb_in == 0 ) + if ( cldfb_in_flag == 0 ) { isCldfbNeeded = 1; #ifndef OSBA_SPLIT_RENDERING cldfbMode = CLDFB_ANALYSIS; #endif } - else if ( st_ivas->hRenderConfig->split_rend_config.codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && cldfb_in ) + else if ( st_ivas->hRenderConfig->split_rend_config.codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && cldfb_in_flag ) { isCldfbNeeded = 1; #ifndef OSBA_SPLIT_RENDERING cldfbMode = CLDFB_SYNTHESIS; #endif } - else if ( pcm_out && cldfb_in ) + else if ( pcm_out_flag && cldfb_in_flag ) { isCldfbNeeded = 1; #ifndef OSBA_SPLIT_RENDERING @@ -143,13 +144,12 @@ static ivas_error ivas_dec_reconfig_split_rend( for ( ch = 0; ch < num_ch; ch++ ) { - if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), #ifndef OSBA_SPLIT_RENDERING - cldfbMode, + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), cldfbMode, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) #else - CLDFB_ANALYSIS, + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) #endif - 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" ) ); } @@ -158,9 +158,7 @@ static ivas_error ivas_dec_reconfig_split_rend( #ifdef OSBA_SPLIT_RENDERING 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 ) + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return error; } @@ -178,6 +176,7 @@ static ivas_error ivas_dec_reconfig_split_rend( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; } } + #ifdef OSBA_SPLIT_RENDERING for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -188,6 +187,7 @@ static ivas_error ivas_dec_reconfig_split_rend( } } #endif + free( hSplitRendWrapper->hCldfbHandles ); hSplitRendWrapper->hCldfbHandles = NULL; } @@ -224,22 +224,22 @@ static ivas_error ivas_dec_init_split_rend( ) { ivas_error error; - int16_t cldfb_in, pcm_out; + int16_t cldfb_in_flag, pcm_out_flag; - pcm_out = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; - cldfb_in = 0; + 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 = 1; + cldfb_in_flag = 1; } ivas_renderSplitGetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hHeadTrackData->sr_pose_pred_axis ); - if ( cldfb_in == 1 && ( st_ivas->hSplitBinRend.splitrend.multiBinPoseData.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) + if ( cldfb_in_flag == 1 && ( st_ivas->hSplitBinRend.splitrend.multiBinPoseData.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) { if ( ( st_ivas->hSplitBinRend.hCldfbDataOut = (IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc( sizeof( IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL ) { @@ -247,10 +247,7 @@ static ivas_error ivas_dec_init_split_rend( } } - if ( ( error = ivas_split_rend_choose_default_codec( &st_ivas->hRenderConfig->split_rend_config.codec, - &st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, - ( cldfb_in == 0 ), - pcm_out ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_split_rend_choose_default_codec( &st_ivas->hRenderConfig->split_rend_config.codec, &st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, cldfb_in_flag, pcm_out_flag ) ) != IVAS_ERR_OK ) { return error; } @@ -258,11 +255,11 @@ static ivas_error ivas_dec_init_split_rend( #ifdef OSBA_SPLIT_RENDERING if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) { - cldfb_in = 0; + cldfb_in_flag = 0; } #endif - error = ivas_split_renderer_open( &st_ivas->hSplitBinRend.splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in, pcm_out, st_ivas->hDecoderConfig->Opt_5ms ); + error = ivas_split_renderer_open( &st_ivas->hSplitBinRend.splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->Opt_5ms ); return error; } @@ -305,6 +302,9 @@ ivas_error ivas_dec_setup( ivas_read_format( st_ivas, &num_bits_read ); + /*-------------------------------------------------------------------* + * Read other signling (ISM/MC mode, number of channels, etc.) + *-------------------------------------------------------------------*/ if ( is_DTXrate( ivas_total_brate ) == 0 ) { @@ -334,11 +334,11 @@ ivas_error ivas_dec_setup( st_ivas->nchan_ism = nchan_ism; - if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, #ifdef SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, + if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) { return error; } @@ -395,11 +395,12 @@ ivas_error ivas_dec_setup( } else { - if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, + #ifdef SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, + if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) { return error; } @@ -407,11 +408,12 @@ ivas_error ivas_dec_setup( } else { - if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, #ifdef SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, + if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) + { return error; } @@ -432,11 +434,11 @@ ivas_error ivas_dec_setup( /* reconfigure in case a change of operation mode is detected */ if ( ( ivas_total_brate > IVAS_SID_5k2 && ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) || ( st_ivas->ini_active_frame == 0 ) ) { - if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, #ifdef SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, + if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) { return error; } @@ -478,6 +480,7 @@ ivas_error ivas_dec_setup( else { ivas_sba_config( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init ); + /*correct number of CPEs for discrete ISM coding*/ if ( st_ivas->ini_frame > 0 && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { @@ -508,11 +511,14 @@ ivas_error ivas_dec_setup( num_bits_read += MC_LS_SETUP_BITS; /* select MC format mode; reconfigure the MC format decoder */ - ivas_mc_dec_config( st_ivas, idx, nSamplesRendered, #ifdef SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, + if ( ( error = ivas_mc_dec_config( st_ivas, idx, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) + { + return error; + } +#else + ivas_mc_dec_config( st_ivas, idx, nSamplesRendered, data ); #endif - data ); } /*-------------------------------------------------------------------* @@ -533,7 +539,6 @@ ivas_error ivas_dec_setup( { st_ivas->element_mode_init = 0 + IVAS_CPE_DFT; } - /* (*num_bits_read)++; */ } else { @@ -630,11 +635,11 @@ ivas_error ivas_dec_setup( st_ivas->ism_mode = (ISM_MODE) ( idx + 1 ); } - if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, #ifdef SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, + if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) { return error; } @@ -2165,10 +2170,8 @@ ivas_error ivas_init_decoder( /*-----------------------------------------------------------------* * Allocate and initialize JBM struct + buffer *-----------------------------------------------------------------*/ - if ( - st_ivas->hDecoderConfig->Opt_5ms && - st_ivas->hTcBuffer == NULL ) + if ( st_ivas->hDecoderConfig->Opt_5ms && st_ivas->hTcBuffer == NULL ) { /* no module has yet open the TC buffer, open a default one */ n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 7a2e21c462..e0e9a8287f 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -1193,16 +1193,16 @@ static void ivas_mc_paramupmix_dec_sf( #endif /* Implement 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, subframeIdx, + st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_subfr, Cldfb_ImagBuffer_subfr ); + +#else + ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, subframeIdx, + st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_subfr, Cldfb_ImagBuffer_subfr ); + #endif - st_ivas->hCombinedOrientationData, - subframeIdx, - st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], - Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - Cldfb_RealBuffer_subfr, - Cldfb_ImagBuffer_subfr ); #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 ) @@ -1222,7 +1222,6 @@ static void ivas_mc_paramupmix_dec_sf( } #endif - /* Implement CLDFB synthesis */ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 7c70de4801..438a89264d 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -198,8 +198,7 @@ ivas_error ivas_osba_dirac_td_binaural( } #endif #ifdef OSBA_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 ) ) + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { int16_t slot_idx, num_cldfb_bands, b, nchan_transport_orig; float Cldfb_RealBuffer[CLDFB_NO_CHANNELS_MAX]; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index ce8eff24c3..0d4bb9025b 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -974,9 +974,9 @@ 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 */ - IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits, /* o : bitstream output for split rendering mode */ + IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits, /* o : bitstream output for split rendering mode */ int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ - bool *needNewFrame /* indication that the decoder needs a new frame */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ ) { Decoder_Struct *st_ivas; @@ -994,7 +994,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ivas_error error; IVAS_DEC_SPLIT_REND_WRAPPER *hSplitBinRend; int16_t max_band; - int16_t pcm_out; + int16_t pcm_out_flag; int16_t td_input; int16_t numPoses; @@ -1094,30 +1094,30 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( { pOutput[i] = output[i]; } + max_band = (int16_t) ( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 ); - pcm_out = ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + pcm_out_flag = ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; td_input = st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC; - error = ivas_renderMultiBinToSplitBinaural( &hSplitBinRend->splitrend, - st_ivas->hHeadTrackData->Quaternions[0], - st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, - st_ivas->hRenderConfig->split_rend_config.codec, - st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, - hSplitBinRend->hSplitRendBits, - hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural, - hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural, - max_band, - pOutput, - 1, - td_input, - pcm_out ); - if ( error != IVAS_ERR_OK ) + if ( ( error = ivas_renderMultiBinToSplitBinaural( &hSplitBinRend->splitrend, + st_ivas->hHeadTrackData->Quaternions[0], + st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, + st_ivas->hRenderConfig->split_rend_config.codec, + st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, + hSplitBinRend->hSplitRendBits, + hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural, + hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural, + max_band, + pOutput, + 1, + !td_input, + pcm_out_flag ) ) != IVAS_ERR_OK ) { return error; } /* convert to int16 with limiting for BINAURAL_SPLIT_PCM */ - if ( pcm_out ) + if ( pcm_out_flag ) { if ( st_ivas->hDecoderConfig->Opt_5ms ) { diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index d4d7657a1e..6709b9b4e0 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -967,12 +967,12 @@ void ivas_dirac_dec_get_frequency_axis( void initDiffuseResponses( float *diffuse_response_function, const int16_t num_channels, - AUDIO_CONFIG output_config, - IVAS_OUTPUT_SETUP hOutSetup, + const AUDIO_CONFIG output_config, + const IVAS_OUTPUT_SETUP hOutSetup, const int16_t ambisonics_order, const IVAS_FORMAT ivas_format, int16_t *num_ele_spk_no_diffuse_rendering, - AUDIO_CONFIG transport_config ) + const AUDIO_CONFIG transport_config ) { int16_t i, l, k, idx, num_horizontal_speakers; *num_ele_spk_no_diffuse_rendering = 0; diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index ad292c7690..3db14715aa 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -387,7 +387,7 @@ ivas_error TDREND_GetMix( float *output[], /* i/o: ISM object synth / rendered output in 0,1 */ const int16_t subframe_length, /* i/o: subframe length */ const int16_t subframe_idx, /* i : Subframe index to 5 ms subframe */ - const int16_t ism_md_subframe_update /* Number of subframes to delay ism metadata to sync with audio */ + const int16_t ism_md_subframe_update /* i : Number of subframes to delay ism metadata to sync with audio */ ) { int16_t i; diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index ce53337649..3b303cbc4b 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -208,12 +208,12 @@ void ivas_dirac_free_mem( void initDiffuseResponses( float *diffuse_response_function, const int16_t num_channels, - AUDIO_CONFIG output_config, - IVAS_OUTPUT_SETUP hOutSetup, + const AUDIO_CONFIG output_config, + const IVAS_OUTPUT_SETUP hOutSetup, const int16_t ambisonics_order, const IVAS_FORMAT ivas_format, int16_t *num_ele_spk_no_diffuse_rendering, - AUDIO_CONFIG transport_config + const AUDIO_CONFIG transport_config ); void computeIntensityVector_dec( @@ -505,7 +505,6 @@ void ivas_dirac_deallocate_parameters( ); - /*----------------------------------------------------------------------------------* * HRTF *----------------------------------------------------------------------------------*/ @@ -572,7 +571,7 @@ ivas_error ivas_td_binaural_renderer_ext( const IVAS_REND_AudioObjectPosition *currentPos, /* i : Object position */ const REVERB_HANDLE hReverb, /* i : Reverberator handle */ const int16_t ism_md_subframe_update_ext, /* i : Metadata Delay in subframes to sync with audio delay */ - const int32_t output_Fs, /* i : output sampling rate */ + const int32_t output_Fs, /* i : output sampling rate */ const int16_t output_frame, /* i : output frame length */ float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */ ); @@ -602,11 +601,11 @@ void ivas_td_binaural_close( ); ivas_error TDREND_GetMix( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - float *output[], /* i/o: ISM object synth / rendered output in 0,1 */ - const int16_t subframe_length, /* i/o: subframe length */ - const int16_t subframe_idx, /* i : Subframe index to 5 ms subframe */ - const int16_t ism_md_subframe_update /* Number of subframes to delay metadata to sync with audio */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + float *output[], /* i/o: ISM object synth/rendered output in 0,1 */ + const int16_t subframe_length, /* i/o: subframe length */ + const int16_t subframe_idx, /* i : Subframe index to 5 ms subframe */ + const int16_t ism_md_subframe_update /* i : Number of subframes to delay metadata to sync with audio */ ); ivas_error TDREND_Update_listener_orientation( @@ -1388,8 +1387,8 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitBinRend, const IVAS_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, const int32_t output_Fs, - const int16_t is_cldfb_in, - const int16_t is_pcm_out, + const int16_t cldfb_in_flag, + const int16_t pcm_out_flag, const int16_t is_5ms_frame ); @@ -1475,8 +1474,8 @@ ivas_error ivas_renderMultiBinToSplitBinaural( const int16_t max_bands, float *output[], const int16_t low_res_pre_rend_rot, - int16_t td_input, - const int16_t pcm_out + const int16_t cldfb_in_flag, + const int16_t pcm_out_flag ); void ivas_rend_CldfbSplitPreRendProcess( @@ -1497,7 +1496,7 @@ void ivas_rend_CldfbSplitPostRendProcess( 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 is_cldfb_in + const int16_t cldfb_in_flag ); void ivas_splitBinPreRendClose( @@ -1812,7 +1811,7 @@ int32_t ivas_get_lcld_bitrate( int32_t ivas_get_split_rend_md_target_brate( const int32_t SplitRendBitRate, - const int16_t pcm_out + const int16_t pcm_out_flag ); int32_t ivas_get_lc3plus_bitrate( @@ -1833,7 +1832,7 @@ int32_t ivas_get_lc3plus_size_from_id( ivas_error ivas_split_rend_validate_config( const IVAS_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, - const int16_t is_pcm_out + const int16_t pcm_out_flag ); void ivas_split_rend_get_quant_params( @@ -1856,8 +1855,8 @@ void ivas_split_rend_get_quant_params( ivas_error ivas_split_rend_choose_default_codec( IVAS_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 isRenderingInTd, /* i : flag: is rendering done in TD? */ - int16_t pcm_out /* i : flag to indicate PCM output */ + const int16_t cldfb_in_flag, /* i : flag indicating rendering in CLDFB */ + const int16_t pcm_out_flag /* i : flag to indicate PCM output */ ); #endif diff --git a/lib_rend/ivas_splitRendererPost.c b/lib_rend/ivas_splitRendererPost.c index 5cc7e928b2..68bfb726ad 100644 --- a/lib_rend/ivas_splitRendererPost.c +++ b/lib_rend/ivas_splitRendererPost.c @@ -1870,7 +1870,7 @@ void ivas_rend_CldfbSplitPostRendProcess( 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], float output[][L_FRAME48k], - const int16_t is_cldfb_in ) + const int16_t cldfb_in_flag ) { int16_t ch_idx, slot_idx, num_cldfb_bands; @@ -1878,7 +1878,7 @@ void ivas_rend_CldfbSplitPostRendProcess( num_cldfb_bands = hBinHrSplitPostRend->cldfbSyn[0]->no_channels; - if ( is_cldfb_in == 0 ) + if ( cldfb_in_flag == 0 ) { ivas_rend_CldfbSplitPostRendProcessTdIn( hBinHrSplitPostRend, pMultiBinPoseData, QuaternionPost, output ); pop_wmops(); diff --git a/lib_rend/ivas_splitRendererPre.c b/lib_rend/ivas_splitRendererPre.c index 482edb090f..2be6e7429d 100644 --- a/lib_rend/ivas_splitRendererPre.c +++ b/lib_rend/ivas_splitRendererPre.c @@ -1970,8 +1970,8 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper, const IVAS_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, const int32_t OutSampleRate, - const int16_t is_cldfb_in, - const int16_t is_pcm_out, + const int16_t cldfb_in_flag, + const int16_t pcm_out_flag, const int16_t is_5ms_frame ) { ivas_error error, ch, num_ch; @@ -1983,19 +1983,19 @@ ivas_error ivas_split_renderer_open( cldfbMode = CLDFB_ANALYSIS; #endif - if ( ( error = ivas_split_rend_validate_config( pSplitRendConfig, is_pcm_out ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_split_rend_validate_config( pSplitRendConfig, pcm_out_flag ) ) != IVAS_ERR_OK ) { return error; } - if ( is_cldfb_in == 0 ) + if ( cldfb_in_flag == 0 ) { isCldfbNeeded = 1; #ifndef OSBA_SPLIT_RENDERING cldfbMode = CLDFB_ANALYSIS; #endif } - else if ( pSplitRendConfig->codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && is_cldfb_in ) + else if ( pSplitRendConfig->codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && cldfb_in_flag ) { #ifdef OSBA_SPLIT_RENDERING isCldfbNeeded = 1; @@ -2004,7 +2004,7 @@ ivas_error ivas_split_renderer_open( cldfbMode = CLDFB_SYNTHESIS; #endif } - else if ( is_pcm_out && is_cldfb_in ) + else if ( pcm_out_flag && cldfb_in_flag ) { #ifdef OSBA_SPLIT_RENDERING isCldfbNeeded = 1; @@ -2075,7 +2075,7 @@ ivas_error ivas_split_renderer_open( } } - if ( is_pcm_out == 0 ) + if ( pcm_out_flag == 0 ) { if ( pSplitRendConfig->codec == IVAS_SPLIT_REND_CODEC_LC3PLUS ) { @@ -2238,7 +2238,7 @@ static ivas_error ivas_renderMultiTDBinToSplitBinaural( const int16_t max_bands, float *in[], const int16_t low_res_pre_rend_rot, - const int16_t pcm_out ) + const int16_t pcm_out_flag ) { ivas_error error; int32_t bit_len, available_bits, target_md_bits, actual_md_bits; @@ -2278,9 +2278,9 @@ static ivas_error ivas_renderMultiTDBinToSplitBinaural( } actual_md_bits = pBits->bits_written; - if ( ( hSplitBin->multiBinPoseData.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) || ( !useLc3plus && !pcm_out ) ) + if ( ( hSplitBin->multiBinPoseData.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) || ( !useLc3plus && !pcm_out_flag ) ) { - if ( !useLc3plus && codec_frame_size_ms != 20 && !pcm_out ) + if ( !useLc3plus && codec_frame_size_ms != 20 && !pcm_out_flag ) { return IVAS_ERROR( IVAS_ERR_INVALID_INPUT_BUFFER_SIZE, "Unsupported framing for LCLD codec!" ); } @@ -2319,21 +2319,14 @@ static ivas_error ivas_renderMultiTDBinToSplitBinaural( if ( hSplitBin->multiBinPoseData.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) { - target_md_bits = ivas_get_split_rend_md_target_brate( SplitRendBitRate, pcm_out ) * L_FRAME48k / 48000; + target_md_bits = ivas_get_split_rend_md_target_brate( SplitRendBitRate, pcm_out_flag ) * L_FRAME48k / 48000; actual_md_bits = pBits->bits_written; - ivas_rend_CldfbSplitPreRendProcess( - hSplitBin->hBinHrSplitPreRend, - headPosition, - &hSplitBin->multiBinPoseData, - Cldfb_In_BinReal, - Cldfb_In_BinImag, - pBits, - target_md_bits, - low_res_pre_rend_rot ); + + ivas_rend_CldfbSplitPreRendProcess( hSplitBin->hBinHrSplitPreRend, headPosition, &hSplitBin->multiBinPoseData, Cldfb_In_BinReal, Cldfb_In_BinImag, pBits, target_md_bits, low_res_pre_rend_rot ); } - if ( pcm_out == 0 ) + if ( pcm_out_flag == 0 ) { pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode; pBits->codec = useLc3plus ? IVAS_SPLIT_REND_CODEC_LC3PLUS : IVAS_SPLIT_REND_CODEC_LCLD; @@ -2344,12 +2337,8 @@ static ivas_error ivas_renderMultiTDBinToSplitBinaural( actual_md_bits = pBits->bits_written - actual_md_bits; available_bits -= actual_md_bits; pBits->codec_frame_size_ms = 20; - ivas_splitBinLCLDEncProcess( - hSplitBin->hSplitBinLCLDEnc, - Cldfb_In_BinReal, - Cldfb_In_BinImag, - available_bits, - pBits ); + + ivas_splitBinLCLDEncProcess( hSplitBin->hSplitBinLCLDEnc, Cldfb_In_BinReal, Cldfb_In_BinImag, available_bits, pBits ); } else { @@ -2366,7 +2355,7 @@ static ivas_error ivas_renderMultiTDBinToSplitBinaural( } /*zero pad*/ - if ( pcm_out ) + if ( pcm_out_flag ) { bit_len = SplitRendBitRate / FRAMES_PER_SEC; } @@ -2474,8 +2463,8 @@ ivas_error ivas_renderMultiBinToSplitBinaural( const int16_t max_bands, float *output[], const int16_t low_res_pre_rend_rot, - int16_t td_input, - const int16_t pcm_out ) + const int16_t cldfb_in_flag, + const int16_t pcm_out_flag ) { ivas_error error; int32_t bit_len, target_md_bits, actual_md_bits, available_bits; @@ -2492,16 +2481,16 @@ ivas_error ivas_renderMultiBinToSplitBinaural( /* Needs to be done at runtime. If this was in another API function, * there would be no guarantee that the user did not change * the split rendering config before calling the main rendering function */ - if ( ( error = ivas_split_rend_choose_default_codec( &splitCodec, &codec_frame_size_ms, td_input, pcm_out ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_split_rend_choose_default_codec( &splitCodec, &codec_frame_size_ms, cldfb_in_flag, pcm_out_flag ) ) != IVAS_ERR_OK ) { return error; } - if ( td_input ) + if ( cldfb_in_flag == 0 ) { /*TD input*/ /*if CLDFB handles have been allocated then assume valid multi binaural input in out[][] buffer and perform CLDFB analysis*/ - error = ivas_renderMultiTDBinToSplitBinaural( hSplitBin, headPosition, SplitRendBitRate, codec_frame_size_ms, pBits, max_bands, output, low_res_pre_rend_rot, pcm_out ); + error = ivas_renderMultiTDBinToSplitBinaural( hSplitBin, headPosition, SplitRendBitRate, codec_frame_size_ms, pBits, max_bands, output, low_res_pre_rend_rot, pcm_out_flag ); pop_wmops(); return error; @@ -2516,13 +2505,13 @@ ivas_error ivas_renderMultiBinToSplitBinaural( actual_md_bits = pBits->bits_written; if ( hSplitBin->multiBinPoseData.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) { - target_md_bits = ivas_get_split_rend_md_target_brate( SplitRendBitRate, pcm_out ) * L_FRAME48k / 48000; + target_md_bits = ivas_get_split_rend_md_target_brate( SplitRendBitRate, pcm_out_flag ) * L_FRAME48k / 48000; actual_md_bits = pBits->bits_written; ivas_rend_CldfbSplitPreRendProcess( hSplitBin->hBinHrSplitPreRend, headPosition, &hSplitBin->multiBinPoseData, Cldfb_In_BinReal, Cldfb_In_BinImag, pBits, target_md_bits, low_res_pre_rend_rot ); } - if ( pcm_out == 0 ) + if ( pcm_out_flag == 0 ) { pBits->codec = splitCodec; pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode; @@ -2577,6 +2566,7 @@ ivas_error ivas_renderMultiBinToSplitBinaural( Cldfb_In_BinReal_p[slot_idx] = Cldfb_In_BinReal[ch][slot_idx]; Cldfb_In_BinImag_p[slot_idx] = Cldfb_In_BinImag[ch][slot_idx]; } + #ifndef OSBA_SPLIT_RENDERING cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, output[ch], hSplitBin->hCldfbHandles->cldfbAna[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbAna[ch] ); #else @@ -2590,7 +2580,7 @@ ivas_error ivas_renderMultiBinToSplitBinaural( /*zero pad*/ /*TODO: do this inside the LCLD ENC codec */ - if ( pcm_out ) + if ( pcm_out_flag ) { bit_len = SplitRendBitRate / FRAMES_PER_SEC; } diff --git a/lib_rend/ivas_splitRenderer_utils.c b/lib_rend/ivas_splitRenderer_utils.c index f239b3af3e..3583294f61 100644 --- a/lib_rend/ivas_splitRenderer_utils.c +++ b/lib_rend/ivas_splitRenderer_utils.c @@ -503,11 +503,11 @@ void ivas_log_cldfb2wav_data( int32_t ivas_get_split_rend_md_target_brate( const int32_t SplitRendBitRate, - const int16_t pcm_out ) + const int16_t pcm_out_flag ) { int32_t md_bitrate; - if ( pcm_out == 1 ) + if ( pcm_out_flag == 1 ) { md_bitrate = SplitRendBitRate; } @@ -1081,16 +1081,17 @@ void ivas_init_multi_bin_pose_data( *------------------------------------------------------------------------*/ ivas_error ivas_split_rend_choose_default_codec( - IVAS_SPLIT_REND_CODEC *pCodec, - int16_t *pCodec_frame_size_ms, - const int16_t isRenderingInTd, - int16_t pcm_out ) + IVAS_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 */ +) { - if ( pcm_out == 0 ) + if ( pcm_out_flag == 0 ) { if ( *pCodec == IVAS_SPLIT_REND_CODEC_DEFAULT ) { - *pCodec = isRenderingInTd ? IVAS_SPLIT_REND_CODEC_LC3PLUS : IVAS_SPLIT_REND_CODEC_LCLD; + *pCodec = cldfb_in_flag ? IVAS_SPLIT_REND_CODEC_LCLD : IVAS_SPLIT_REND_CODEC_LC3PLUS; } } else diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 1e6de47076..39a80dae67 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -3525,7 +3525,7 @@ static ivas_error initSplitRend( IVAS_REND_HeadRotData headRotData, const int32_t outputSampleRate, const AUDIO_CONFIG outConfig, - const int16_t cldfb_in, + const int16_t cldfb_in_flag, const int16_t is_5ms_frame ) { ivas_error error; @@ -3542,19 +3542,18 @@ static ivas_error initSplitRend( ivas_renderSplitUpdateNoCorrectionPoseData( pSplit_rend_config, &pSplitRendWrapper->multiBinPoseData ); } - if ( ( error = ivas_split_renderer_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, is_5ms_frame ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_split_renderer_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in_flag, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, is_5ms_frame ) ) != IVAS_ERR_OK ) { return error; } - /*allocate for CLDFB in and change to TD during process if needed*/ bufConfig.numSamplesPerChannel = MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL; bufConfig.numChannels = BINAURAL_CHANNELS * pSplitRendWrapper->multiBinPoseData.num_poses; bufConfig.is_cldfb = 1; pSplitRendEncBuffer->config = bufConfig; - pSplitRendEncBuffer->data = malloc( bufConfig.numChannels * bufConfig.numSamplesPerChannel * sizeof( float ) ); - if ( pSplitRendEncBuffer->data == NULL ) + + if ( ( pSplitRendEncBuffer->data = malloc( bufConfig.numChannels * bufConfig.numSamplesPerChannel * sizeof( float ) ) ) == NULL ) { return IVAS_ERR_FAILED_ALLOC; } @@ -4233,17 +4232,17 @@ ivas_error IVAS_REND_AddInput( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) && hIvasRend->splitRendEncBuffer.data == NULL && hIvasRend->hRendererConfig != NULL ) { - int16_t cldfb_in; - cldfb_in = getCldfbRendFlag( hIvasRend, getAudioConfigType( inConfig ) ); + int16_t cldfb_in_flag; + cldfb_in_flag = getCldfbRendFlag( hIvasRend, getAudioConfigType( inConfig ) ); #ifdef FIX_658_SPLIT_REND_MASA - if ( ( error = ivas_split_rend_choose_default_codec( &hIvasRend->hRendererConfig->split_rend_config.codec, &hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, ( cldfb_in == 0 ), hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_split_rend_choose_default_codec( &hIvasRend->hRendererConfig->split_rend_config.codec, &hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, cldfb_in_flag, hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) != IVAS_ERR_OK ) { return error; } #endif - if ( ( error = initSplitRend( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in, ( hIvasRend->num_subframes == 1 ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + if ( ( error = initSplitRend( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, ( hIvasRend->num_subframes == 1 ) ? 1 : 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -5106,16 +5105,16 @@ int16_t IVAS_REND_FeedRenderConfig( if ( hIvasRend->splitRendEncBuffer.data != NULL && hIvasRend->hRendererConfig != NULL ) #endif { - int16_t cldfb_in; - cldfb_in = getCldfbRendFlag( hIvasRend, IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN ); + int16_t cldfb_in_flag; + cldfb_in_flag = getCldfbRendFlag( hIvasRend, IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN ); closeSplitRend( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer ); - if ( ( error = ivas_split_rend_choose_default_codec( &hIvasRend->hRendererConfig->split_rend_config.codec, &hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, ( cldfb_in == 0 ), hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_split_rend_choose_default_codec( &hIvasRend->hRendererConfig->split_rend_config.codec, &hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, cldfb_in_flag, hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = initSplitRend( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in, ( hIvasRend->num_subframes == 1 ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + if ( ( error = initSplitRend( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, ( hIvasRend->num_subframes == 1 ) ? 1 : 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -8963,7 +8962,7 @@ static ivas_error getSamplesInternal( if ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { ivas_split_rend_bits_t bits; - int16_t td_input; + int16_t cldfb_in_flag; 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 ch; @@ -8976,31 +8975,31 @@ static ivas_error getSamplesInternal( if ( outAudio.config.is_cldfb == 1 ) { - td_input = 0; + cldfb_in_flag = 1; copyBufferToCLDFBarray( outAudio, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural ); } else { - td_input = 1; + cldfb_in_flag = 0; copyBufferTo2dArray( outAudio, tmpBinaural_buff ); } /* Encode split rendering bitstream */ convertBitsBufferToInternalBitsBuff( *hBits, &bits ); - error = ivas_renderMultiBinToSplitBinaural( &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, - td_input, - ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); - if ( error != IVAS_ERR_OK ) + + if ( ( error = ivas_renderMultiBinToSplitBinaural( &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 ) ) != IVAS_ERR_OK ) { return error; } @@ -9055,10 +9054,11 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( IVAS_REND_BitstreamBuffer *hBits /* o : buffer for output bitstream */ ) { - int16_t cldfb_in; + int16_t cldfb_in_flag; + + cldfb_in_flag = getCldfbRendFlag( hIvasRend, IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN ); + hIvasRend->splitRendEncBuffer.config.is_cldfb = cldfb_in_flag; - cldfb_in = getCldfbRendFlag( hIvasRend, IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN ); - hIvasRend->splitRendEncBuffer.config.is_cldfb = cldfb_in; if ( hIvasRend->hRendererConfig->split_rend_config.codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && ( hIvasRend->hRendererConfig->split_rend_config.dof == 0 || hIvasRend->hRendererConfig->split_rend_config.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) { @@ -9068,7 +9068,7 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( { hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel = (int16_t) ( hIvasRend->sampleRateOut / FRAMES_PER_SEC ); } - hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel *= cldfb_in ? 2 : 1; + hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel *= cldfb_in_flag ? 2 : 1; /* hIvasRend->splitRendEncBuffer used for BINAURAL_SPLIT_CODED output outAudio used for BINAURAL_SPLIT_PCM output */ diff --git a/lib_util/split_render_file_read_write.h b/lib_util/split_render_file_read_write.h index 86db58bb7f..40028c2ad8 100644 --- a/lib_util/split_render_file_read_write.h +++ b/lib_util/split_render_file_read_write.h @@ -52,7 +52,8 @@ ivas_error split_rend_writer_open( const int32_t delayTimeScale ); /* Closes the split renderer reader/writer and deallocates memory */ -ivas_error split_rend_reader_writer_close( SplitFileReadWrite **hhSplitRendFileReadWrite ); +ivas_error split_rend_reader_writer_close( + SplitFileReadWrite **hhSplitRendFileReadWrite ); /*write split rend coded bitstream to file */ ivas_error split_rend_write_bitstream_to_file( -- GitLab From 968c022e03ba0aaab09c8d3ac456a0e11a8d4b3e Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 15 Sep 2023 15:19:24 +0200 Subject: [PATCH 06/13] clang-format --- lib_com/ivas_cnst.h | 20 +++++++------- lib_com/ivas_prot.h | 8 +++--- lib_com/ivas_rom_com.c | 6 ++-- lib_dec/ivas_rom_dec.c | 2 +- lib_dec/ivas_stat_dec.h | 6 ++-- lib_dec/lib_dec.h | 20 +++++++------- lib_enc/lib_enc.h | 14 +++++----- lib_rend/ivas_prot_rend.h | 58 +++++++++++++++++++-------------------- lib_rend/lib_rend.c | 2 +- 9 files changed, 68 insertions(+), 68 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index e38f342328..b7f24440b4 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -978,12 +978,12 @@ typedef enum #define DIRAC_SLOT_NS 1250000L /* time duration of a time slot, 1.25ms (==DELAY_RENERER_NS/MAX_PARAM_SPATIAL_SUBFRAMES) */ #define DIRAC_SLOT_ENC_NS 5000000L -#define DIRAC_MONO_THRESH_SILENCE 3e4f -#define DIRAC_MONO_NORM_FACTOR 1e13f -#define DIRAC_MONO_ONE_ON_NORM_FACTOR (1.f / 1e13f) -#define DIRAC_MONO_MAX_THRESH 1e6f -#define DIRAC_MONO_MIN_THRESH 1e2f -#define DIRAC_MONO_FRAME_THRESH 15 /* 30ms */ +#define DIRAC_MONO_THRESH_SILENCE 3e4f +#define DIRAC_MONO_NORM_FACTOR 1e13f +#define DIRAC_MONO_ONE_ON_NORM_FACTOR (1.f / 1e13f) +#define DIRAC_MONO_MAX_THRESH 1e6f +#define DIRAC_MONO_MIN_THRESH 1e2f +#define DIRAC_MONO_FRAME_THRESH 15 /* 30ms */ typedef enum { @@ -1504,12 +1504,12 @@ typedef enum ANY_YAW, PITCH_ONLY, ANY_ROLL, - PRED_ONLY, + PRED_ONLY, #ifdef SPLIT_REND_PRED_QUANT_63_PNTS - PRED_ROLL_ONLY, + PRED_ROLL_ONLY, #endif - COM_GAIN_ONLY, - LR_GAIN_ONLY + COM_GAIN_ONLY, + LR_GAIN_ONLY } IVAS_SPLIT_REND_POSE_TYPE; #endif diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 363b433d63..e17fd6bb55 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -253,7 +253,7 @@ ivas_error ivas_compute_core_buffers( /*! r: number of clipped samples */ uint32_t ivas_syn_output( - float *synth[], /* i/o: float synthesis signal */ + float *synth[], /* i/o: float synthesis signal */ const int16_t output_frame, /* i : output frame length (one channel) */ const int16_t n_channels, /* i : number of output channels */ int16_t *synth_out /* o : integer 16 bits synthesis signal */ @@ -4144,7 +4144,7 @@ ivas_error ivas_sba_linear_renderer( float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ const int16_t output_frame, /* i : output frame length per channel */ const int16_t nchan_in, /* i : number of input ambisonics channels */ - const int16_t nchan_ism, + const int16_t nchan_ism, const AUDIO_CONFIG output_config, /* i : output audio configuration */ const IVAS_OUTPUT_SETUP output_setup, /* i : output format setup */ const float hoa_dec_mtx[] /* i : HOA decoding mtx */ @@ -4262,7 +4262,7 @@ int16_t ivas_get_sba_num_TCs( void ivas_spar_set_bitrate_config( ivas_spar_md_com_cfg *pSpar_md_cfg, /* i/o: SPAR MD config. handle */ const int16_t table_idx, /* i : config. table index */ - const int16_t num_bands, /* i : number of bands */ + const int16_t num_bands, /* i : number of bands */ const int16_t dirac2spar_md_flag, const int16_t enc_flag, const int16_t pca_flag, @@ -4565,7 +4565,7 @@ ivas_error ivas_spar_covar_enc_open( const int32_t input_Fs, /* i : input sampling rate */ const int16_t nchan_inp, /* i : number of input channels */ const COV_SMOOTHING_TYPE smooth_mode, /* i : Smooth covariance for SPAR or MC */ - const int32_t ivas_total_brate /* i : IVAS total bitrate */ + const int32_t ivas_total_brate /* i : IVAS total bitrate */ ); void ivas_spar_covar_enc_close( diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index ca0981dd34..06232fe64e 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -887,11 +887,11 @@ const ivas_spar_br_table_t ivas_spar_br_table_consts[IVAS_SPAR_BR_TABLE_LEN] = { /* When AGC is ON additional (AGC_BITS_PER_CH+1) bits may be taken from each core-coder channel so minimum core-coder bitrate per channel can be min core-coder bitrates as per the table - AGC_BITS_PER_CH */ - { 13200, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 10000, 8150, 13150 } }, + { 13200, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 10000, 8150, 13150 } }, { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, - { 16400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 13200, 11350, 16350 } }, - { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, + { 16400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 13200, 11350, 16350 } }, + { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, { 24400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0,{ { 16400, 14850, 24350 } }, { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, diff --git a/lib_dec/ivas_rom_dec.c b/lib_dec/ivas_rom_dec.c index fc191e0deb..cc7b13618d 100644 --- a/lib_dec/ivas_rom_dec.c +++ b/lib_dec/ivas_rom_dec.c @@ -559,7 +559,7 @@ const float ivas_split_rend_relative_one_axis_pos_angles_hq[SPLIT_REND_MAX_ONE_A const int16_t ivas_split_rend_band_grouping[MAX_SPLIT_REND_MD_BANDS + 1] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 20, 25, 30, 35, 40, 50, 60 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 20, 25, 30, 35, 40, 50, 60 }; const int32_t ivas_split_rend_huff_p_d_consts[IVAS_SPLIT_REND_D_QUANT_PNTS][3] = diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 3a3530a7d5..95154d74a1 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1092,7 +1092,7 @@ typedef struct Decoder_Struct MONO_DOWNMIX_RENDERER_HANDLE hMonoDmxRenderer; /* Mono downmix structure */ CREND_WRAPPER_HANDLE hCrendWrapper; /* Crend handle */ REVERB_HANDLE hReverb; /* Reverb handle */ - HRTFS_CREND_HANDLE hSetOfHRTF; /* Set of HRTFs handle (CRend) */ + HRTFS_CREND_HANDLE hSetOfHRTF; /* Set of HRTFs handle (CRend) */ HRTFS_FASTCONV_HANDLE hHrtfFastConv; /* FASTCONV HRTF tables for binaural rendering */ HRTFS_PARAMBIN_HANDLE hHrtfParambin; /* HRTF tables for parametric binauralizer */ LSSETUP_CUSTOM_HANDLE hLsSetupCustom; /* Custom LS configuration handle */ @@ -1109,7 +1109,7 @@ typedef struct Decoder_Struct int16_t flag_omasa_brate; #ifdef SPLIT_REND_WITH_HEAD_ROT - IVAS_DEC_SPLIT_REND_WRAPPER hSplitBinRend; /* split binuaral rendering handle */ + IVAS_DEC_SPLIT_REND_WRAPPER hSplitBinRend; /* split binuaral rendering handle */ #endif /* JBM module */ @@ -1119,7 +1119,7 @@ typedef struct Decoder_Struct #ifdef DEBUGGING int32_t noClipping; /* number of clipped samples */ #endif - int32_t last_active_ivas_total_brate; + int32_t last_active_ivas_total_brate; int16_t ism_extmeta_active; /* Extended metadata active in decoder */ int16_t ism_extmeta_cnt; /* Change frame counter for extended metadata */ diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index ae8d8d0a98..3aa062e652 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -126,7 +126,7 @@ ivas_error IVAS_DEC_Configure( const IVAS_AUDIO_CONFIG outputConfig, /* i : audio configuration */ const int16_t tsmEnabled, /* i : enable TSM */ const int16_t enable5ms, /* i : enable 5ms rendering path */ - const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ + const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ const int16_t enableHeadRotation, /* i : enable head rotation for binaural output */ const int16_t enableExternalOrientation, /* i : enable external orientations */ @@ -207,9 +207,9 @@ ivas_error IVAS_DEC_GetObjectMetadata( /*! r: error code */ ivas_error IVAS_DEC_GetMasaMetadata( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to metadata from the most recently decoded frame */ - uint8_t getFromJbmBuffer /* i : get metadata from a JBM buffer */ + uint8_t getFromJbmBuffer /* i : get metadata from a JBM buffer */ ); /*! r: error code */ @@ -288,7 +288,7 @@ ivas_error IVAS_DEC_Flush( const IVAS_DEC_PCM_TYPE pcmType, void *pcmBuf, #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 */ + 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 *nSamplesFlushed /* o : number of samples flushed */ ); @@ -305,13 +305,13 @@ ivas_error IVAS_DEC_EnableVoIP( #ifdef SPLIT_REND_WITH_HEAD_ROT /*! r: error code */ ivas_error IVAS_DEC_EnableSplitRendering( - IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ ); #endif ivas_error IVAS_DEC_Get5msFlag( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *enable5ms /* o : 5ms flag */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *enable5ms /* o : 5ms flag */ ); #ifdef DEBUGGING @@ -377,8 +377,8 @@ ivas_error IVAS_DEC_GetHrtfHandle( /*! r: error code */ ivas_error IVAS_DEC_GetHrtfCRendHandle( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF /* o : Set of HRTF handle */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF /* o : Set of HRTF handle */ ); ivas_error IVAS_DEC_GetHrtfFastConvHandle( @@ -400,7 +400,7 @@ ivas_error IVAS_DEC_GetRenderConfig( /*! r: error code*/ ivas_error IVAS_DEC_GetDefaultRenderConfig( - IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render config handle */ + IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render config handle */ ); /*! r: error code*/ diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index b7582ed9e4..a69bb1bf35 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -203,13 +203,13 @@ ivas_error IVAS_ENC_ConfigureForObjects( /*! r: encoder error code */ ivas_error IVAS_ENC_ConfigureForMASAObjects( - IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the ouput bitstream */ - const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ - const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ - const uint16_t numObjects, /* i : number of objects to be encoded */ - const int16_t masaVariant /* i : index specifying the number of MASA transport channels */ + IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ + const int32_t inputFs, /* i : input sampling frequency */ + const int32_t bitrate, /* i : requested bitrate of the ouput bitstream */ + const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ + const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ + const uint16_t numObjects, /* i : number of objects to be encoded */ + const int16_t masaVariant /* i : index specifying the number of MASA transport channels */ ); /*! r: encoder error code */ diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 3b303cbc4b..f3cada0ab3 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -94,7 +94,7 @@ void ivas_limiter_close( void ivas_limiter_dec ( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ - float *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ + float *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ const int16_t num_channels, /* i : number of channels to be processed */ const int16_t output_frame, /* i : number of samples per channel in the buffer */ const int16_t BER_detect /* i : BER detect flag */ @@ -534,11 +534,11 @@ void ivas_HRTF_parambin_binary_close( ); ivas_error ivas_HRTF_CRend_binary_open( - HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */ + HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */ ); void ivas_HRTF_CRend_binary_close( - HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */ + HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */ ); @@ -572,7 +572,7 @@ ivas_error ivas_td_binaural_renderer_ext( const REVERB_HANDLE hReverb, /* i : Reverberator handle */ const int16_t ism_md_subframe_update_ext, /* i : Metadata Delay in subframes to sync with audio delay */ const int32_t output_Fs, /* i : output sampling rate */ - const int16_t output_frame, /* i : output frame length */ + const int16_t output_frame, /* i : output frame length */ float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */ ); @@ -1107,7 +1107,7 @@ void ivas_reverb_get_hrtf_set_properties( void ivas_shoebox_config_init( shoebox_config_t *cal, - RENDER_CONFIG_HANDLE pConfig + RENDER_CONFIG_HANDLE pConfig ); void ivas_shoebox_init( @@ -1129,7 +1129,7 @@ void ivas_shoebox_set_scene ( *-----------------------------------------------------------------------------------*/ ivas_error ivas_er_init( - er_struct_t *reflections, + er_struct_t *reflections, const AUDIO_CONFIG inConfig ); @@ -1384,11 +1384,11 @@ void ivas_init_split_post_rend_handles( ); ivas_error ivas_split_renderer_open( - SPLIT_REND_WRAPPER *hSplitBinRend, - const IVAS_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, - const int32_t output_Fs, - const int16_t cldfb_in_flag, - const int16_t pcm_out_flag, + SPLIT_REND_WRAPPER *hSplitBinRend, + const IVAS_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, + const int32_t output_Fs, + const int16_t cldfb_in_flag, + const int16_t pcm_out_flag, const int16_t is_5ms_frame ); @@ -1403,7 +1403,7 @@ ivas_error ivas_splitBinLCLDEncOpen( const int32_t iDataRate ); void ivas_splitBinLCLDEncClose( - BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc + BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc ); void ivas_splitBinLCLDEncProcess( @@ -1435,8 +1435,8 @@ void ivas_splitBinLCLDDecProcess( ivas_error ivas_splitBinPreRendOpen( BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend, MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - , +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + , const int32_t output_Fs #endif ); @@ -1444,17 +1444,17 @@ ivas_error ivas_splitBinPreRendOpen( ivas_error ivas_splitBinPostRendOpen( BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend, MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const int32_t output_Fs + const int32_t output_Fs ); void ivas_init_multi_bin_pose_data( - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); void ivas_renderSplitGetMultiBinPoseData( const IVAS_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const IVAS_SPLIT_REND_ROT_AXIS rot_axis + const IVAS_SPLIT_REND_ROT_AXIS rot_axis ); void ivas_renderSplitUpdateNoCorrectionPoseData( @@ -1464,7 +1464,7 @@ void ivas_renderSplitUpdateNoCorrectionPoseData( ivas_error ivas_renderMultiBinToSplitBinaural( SPLIT_REND_WRAPPER *hSplitBin, - const IVAS_QUATERNION headPosition, + const IVAS_QUATERNION headPosition, const int32_t SplitRendBitRate, IVAS_SPLIT_REND_CODEC splitCodec, int16_t codec_frame_size_ms, @@ -1473,20 +1473,20 @@ ivas_error ivas_renderMultiBinToSplitBinaural( float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const int16_t max_bands, float *output[], - const int16_t low_res_pre_rend_rot, + const int16_t low_res_pre_rend_rot, const int16_t cldfb_in_flag, const int16_t pcm_out_flag ); void ivas_rend_CldfbSplitPreRendProcess( const BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, - const IVAS_QUATERNION headPosition, + 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], ivas_split_rend_bits_t *pBits, - const int32_t target_md_bits, - const int16_t low_res_pre_rend_rot + const int32_t target_md_bits, + const int16_t low_res_pre_rend_rot ); void ivas_rend_CldfbSplitPostRendProcess( @@ -1496,18 +1496,18 @@ void ivas_rend_CldfbSplitPostRendProcess( 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 ivas_splitBinPreRendClose( - BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend + BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend ); void ivas_splitBinPostRendClose( BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend ); void ivas_splitBinPostRendMdDec( - ivas_split_rend_bits_t *pBits, + ivas_split_rend_bits_t *pBits, BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG @@ -1551,7 +1551,7 @@ void ivas_log_cldfb2wav_data( const int16_t num_chs, const int16_t num_freq_bands, const int32_t output_Fs, - const int16_t start_slot_idx, + const int16_t start_slot_idx, const int16_t md_band_idx, const char *filename ); @@ -1560,9 +1560,9 @@ void ivas_log_cldfb2wav_data( void ivas_SplitRenderer_GetRotMd( 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_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 low_res ); void ivas_SplitRenderer_PostRenderer( @@ -1856,7 +1856,7 @@ ivas_error ivas_split_rend_choose_default_codec( IVAS_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 CLDFB */ - const int16_t pcm_out_flag /* i : flag to indicate PCM output */ + const int16_t pcm_out_flag /* i : flag to indicate PCM output */ ); #endif diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 39a80dae67..2d9e8ea7ae 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -8995,7 +8995,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 1eda8f7521c94d5ca2660d395e446225c0a075e8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 18 Sep 2023 13:32:50 +0200 Subject: [PATCH 07/13] add error returns --- lib_com/ivas_prot.h | 34 +++++++++++++++++----------------- lib_dec/ivas_dirac_dec.c | 5 ++--- lib_enc/ivas_dirac_enc.c | 28 +++++++++++++++++----------- lib_enc/ivas_enc.c | 4 ++-- lib_enc/ivas_masa_enc.c | 16 +++++++++++++--- lib_enc/ivas_spar_encoder.c | 5 ++++- 6 files changed, 55 insertions(+), 37 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index e17fd6bb55..d340aebecc 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3596,17 +3596,17 @@ void ivas_dirac_enc_close( const int32_t input_Fs /* i : input sampling_rate */ ); -void ivas_dirac_enc( +ivas_error ivas_dirac_enc( DIRAC_ENC_HANDLE hDirAC, /* i/o: encoder DirAC handle */ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */ float *data_f[], /* i/o: SBA channels */ - float **ppIn_FR_real, /* o : real freq domain values */ - float **ppIn_FR_imag, /* o : imag freq domain values */ - const int16_t input_frame, /* i : input frame length */ - const int16_t dtx_vad, /* i : DTX vad flag */ - const IVAS_FORMAT ivas_format, /* i : ivas format */ - int16_t hodirac_flag /* i : hodirac flag */ + float **ppIn_FR_real, /* o : real freq domain values */ + float **ppIn_FR_imag, /* o : imag freq domain values */ + const int16_t input_frame, /* i : input frame length */ + const int16_t dtx_vad, /* i : DTX vad flag */ + const IVAS_FORMAT ivas_format, /* i : ivas format */ + const int16_t hodirac_flag /* i : hodirac flag */ ); ivas_error ivas_dirac_config( @@ -3677,7 +3677,7 @@ void ivas_dirac_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t num_subframes /* i : number of subframes to render */ + const int16_t num_subframes /* i : number of subframes to render */ ); void ivas_dirac_dec_render( @@ -3791,18 +3791,18 @@ void ivas_mc_paramupmix_dec_read_BS( ); void ivas_mc_paramupmix_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - const int16_t nSamplesForRendering /* i : number of samples provided */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + const int16_t nSamplesForRendering /* i : number of samples provided */ ); void ivas_mc_paramupmix_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *input_f[], /* i : core-coder transport channels */ - float *output_f[] /* i/o: synthesized core-coder transport channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *input_f[], /* i : core-coder transport channels */ + float *output_f[] /* i/o: synthesized core-coder transport channels */ ); void ivas_param_mc_metadata_open( diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 3086fb5a48..c0f23b4697 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -90,7 +90,6 @@ static ivas_error ivas_dirac_dec_config_internal( st_ivas->hDirAC = hDirAC; } - /*-----------------------------------------------------------------* * DirAC main configuration *-----------------------------------------------------------------*/ @@ -110,6 +109,7 @@ static ivas_error ivas_dirac_dec_config_internal( return error; } + static ivas_error ivas_dirac_rend_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const DIRAC_CONFIG_FLAG flag_config_inp, /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ @@ -685,11 +685,11 @@ static ivas_error ivas_dirac_rend_config( } } - if ( flag_config == DIRAC_OPEN ) { hDirACRend->buffer_energy = NULL; } + if ( ( flag_config == DIRAC_OPEN && hDirAC->hConfig->dec_param_estim == TRUE ) || ( flag_config == DIRAC_RECONFIGURE && ( hDirAC->hConfig->dec_param_estim == TRUE && dec_param_estim_old == FALSE ) ) ) { hDirACRend->index_buffer_intensity = 0; @@ -788,7 +788,6 @@ ivas_error ivas_dirac_dec_config( hodirac_flag = ivas_get_hodirac_flag( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ); dec_param_estim_old = ( dec_config_flag == DIRAC_RECONFIGURE ) ? st_ivas->hDirAC->hConfig->dec_param_estim : FALSE; - sparfoa_flag = 0; if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA && st_ivas->ivas_format == SBA_FORMAT && !hodirac_flag ) { diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index a82f5beea4..dc34471640 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -163,6 +163,7 @@ ivas_error ivas_dirac_enc_open( st_ivas->hDirAC = hDirAC; st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; + return error; } @@ -280,7 +281,7 @@ void ivas_dirac_enc_close( * *------------------------------------------------------------------------*/ -void ivas_dirac_enc( +ivas_error ivas_dirac_enc( DIRAC_ENC_HANDLE hDirAC, /* i/o: encoder DirAC handle */ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */ @@ -290,12 +291,14 @@ void ivas_dirac_enc( const int16_t input_frame, /* i : input frame length */ const int16_t dtx_vad, /* i : DTX vad flag */ const IVAS_FORMAT ivas_format, /* i : ivas format */ - int16_t hodirac_flag ) /* i : hodirac flag */ + const int16_t hodirac_flag /* i : hodirac flag */ +) { int16_t orig_dirac_bands; float dir[3], avg_dir[3]; float energySum, vecLen; int16_t i, j, b, i_ts; + ivas_error error; push_wmops( "ivas_dirac_enc" ); ivas_dirac_param_est_enc( hDirAC, hQMetaData->q_direction, hQMetaData->useLowerRes, data_f, ppIn_FR_real, ppIn_FR_imag, input_frame, ivas_format, hodirac_flag, hodirac_flag ? HOA2_CHANNELS : FOA_CHANNELS, &( hDirAC->mono_frame_count ), &( hQMetaData->dirac_mono_flag ) ); @@ -323,7 +326,10 @@ void ivas_dirac_enc( } } - ivas_qmetadata_enc_encode( hMetaData, hQMetaData, hodirac_flag ); + if ( ( error = ivas_qmetadata_enc_encode( hMetaData, hQMetaData, hodirac_flag ) ) != IVAS_ERR_OK ) + { + return error; + } } else { @@ -398,7 +404,7 @@ void ivas_dirac_enc( } pop_wmops(); - return; + return IVAS_ERR_OK; } @@ -409,11 +415,11 @@ void ivas_dirac_enc( *-------------------------------------------------------------------------*/ static int16_t ivas_dirac_get_mono_flag( - const int16_t *band_grouping, /* i : Band grouping for estimation */ - float Cldfb_RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal */ - float Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal */ - const int16_t nchan_ana, /* i : number of analysis channels */ - int16_t *mono_frame_count ) /* i/o : current number of mono frames count */ + const int16_t *band_grouping, /* i : Band grouping for estimation */ + float Cldfb_RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal */ + float Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal */ + const int16_t nchan_ana, /* i : number of analysis channels */ + int16_t *mono_frame_count ) /* i/o: current number of mono frames count */ { int16_t brange[2]; int16_t i, j, ch_idx; @@ -473,6 +479,7 @@ static int16_t ivas_dirac_get_mono_flag( } } } + /* If any band contains multi-channel content it's not mono */ if ( any_mc_band ) { @@ -486,6 +493,7 @@ static int16_t ivas_dirac_get_mono_flag( local_mono_flag = 1; } } + /* Hysteresis - only after DIRAC_MONO_FRAME_THRESH frames on mono will the actual mono flag be set */ if ( local_mono_flag ) { @@ -787,9 +795,7 @@ void ivas_dirac_param_est_enc( } if ( !hodirac_flag ) - { - for ( band_m_idx = 0; band_m_idx < hDirAC->hConfig->nbands; band_m_idx++ ) { renormalization_factor[band_m_idx] = EPSILON; diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index d497722744..1dabf0b1dc 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -252,8 +252,8 @@ ivas_error ivas_enc( { return error; } - if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, - ivas_total_brate, hEncoderConfig->Opt_DTX_ON, st_ivas->nchan_transport == 2 ? st_ivas->hCPE[0]->element_mode : -1, + + if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, hEncoderConfig->Opt_DTX_ON, st_ivas->nchan_transport == 2 ? st_ivas->hCPE[0]->element_mode : -1, ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index ac8c06b79a..c44491cc2f 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -252,6 +252,7 @@ ivas_error ivas_masa_encode( int16_t masa_sid_descriptor; int16_t low_bitrate_mode; int32_t masa_total_brate; + ivas_error error; masa_sid_descriptor = -1; h_orig_metadata = NULL; @@ -495,16 +496,25 @@ ivas_error ivas_masa_encode( { if ( masa_total_brate >= IVAS_512k ) { - ivas_qmetadata_enc_encode_hr_384_512( hMetaData, hQMetaData, 16, 4 ); + if ( ( error = ivas_qmetadata_enc_encode_hr_384_512( hMetaData, hQMetaData, 16, 4 ) ) != IVAS_ERR_OK ) + { + return error; + } } else { - ivas_qmetadata_enc_encode_hr_384_512( hMetaData, hQMetaData, 11, 3 ); + if ( ( error = ivas_qmetadata_enc_encode_hr_384_512( hMetaData, hQMetaData, 11, 3 ) ) != IVAS_ERR_OK ) + { + return error; + } } } else { - ivas_qmetadata_enc_encode( hMetaData, hQMetaData, 0 ); + if ( ( error = ivas_qmetadata_enc_encode( hMetaData, hQMetaData, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } } if ( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 7f97417739..f39e70dfea 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -697,7 +697,10 @@ static ivas_error ivas_spar_enc_process( hodirac_flag = ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ); - ivas_dirac_enc( st_ivas->hDirAC, hQMetaData, hMetaData, data_f, ppIn_FR_real, ppIn_FR_imag, input_frame, dtx_vad, hEncoderConfig->ivas_format, hodirac_flag ); + if ( ( error = ivas_dirac_enc( st_ivas->hDirAC, hQMetaData, hMetaData, data_f, ppIn_FR_real, ppIn_FR_imag, input_frame, dtx_vad, hEncoderConfig->ivas_format, hodirac_flag ) ) != IVAS_ERR_OK ) + { + return error; + } /* Set Energy Ratio to 0.0 if the mono flag has been set */ if ( hQMetaData->dirac_mono_flag ) -- GitLab From d2649417f1ec436087f68f91b16056da6754868e Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 18 Sep 2023 16:50:11 +0200 Subject: [PATCH 08/13] formatting --- lib_com/bitstream.c | 6 ++--- lib_dec/ivas_corecoder_dec_reconfig.c | 1 + lib_enc/dtx.c | 3 +-- lib_enc/enc_ppp.c | 4 +--- lib_enc/fd_cng_enc.c | 6 ++--- lib_enc/ivas_corecoder_enc_reconfig.c | 32 +++++---------------------- lib_enc/ivas_cpe_enc.c | 5 ++--- lib_enc/ivas_ism_dtx_enc.c | 4 +--- lib_enc/ivas_ism_enc.c | 1 + 9 files changed, 16 insertions(+), 46 deletions(-) diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 857a6e19c2..6ef9cc8ec2 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -1662,8 +1662,7 @@ static ivas_error write_indices_element( reset_indices_enc( st_ivas->hSCE[element_id]->hMetaData, st_ivas->hSCE[element_id]->hMetaData->nb_ind_tot ); } - reset_indices_enc( sts[0]->hBstr, - sts[0]->hBstr->nb_ind_tot ); + reset_indices_enc( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot ); } else { @@ -1674,8 +1673,7 @@ static ivas_error write_indices_element( for ( n = 0; n < n_channels; n++ ) { - reset_indices_enc( sts[n]->hBstr, - sts[n]->hBstr->nb_ind_tot ); + reset_indices_enc( sts[n]->hBstr, sts[n]->hBstr->nb_ind_tot ); } } diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index 25767099ae..eb6dd72e41 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -237,6 +237,7 @@ ivas_error ivas_corecoder_dec_reconfig( { st_ivas->element_mode_init = IVAS_CPE_MDCT; } + if ( ( error = create_cpe_dec( st_ivas, cpe_id, brate_CPE ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/dtx.c b/lib_enc/dtx.c index 34f250742f..606c8aaaf9 100644 --- a/lib_enc/dtx.c +++ b/lib_enc/dtx.c @@ -255,8 +255,7 @@ void dtx( /* reset the bitstream (IVAS format signaling was already written) */ if ( st->element_mode != IVAS_CPE_MDCT && st->hBstr != NULL ) { - reset_indices_enc( st->hBstr, - st->hBstr->nb_ind_tot ); + reset_indices_enc( st->hBstr, st->hBstr->nb_ind_tot ); } } diff --git a/lib_enc/enc_ppp.c b/lib_enc/enc_ppp.c index 25e5124eed..b5b7e45483 100644 --- a/lib_enc/enc_ppp.c +++ b/lib_enc/enc_ppp.c @@ -169,9 +169,7 @@ ivas_error encod_ppp( } /* delete previous indices */ - reset_indices_enc( hBstr, - hBstr->nb_ind_tot ); - + reset_indices_enc( hBstr, hBstr->nb_ind_tot ); /* signaling matrix (writing of signaling bits) */ signaling_enc( st ); diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c index eb35d9629b..407121d59d 100644 --- a/lib_enc/fd_cng_enc.c +++ b/lib_enc/fd_cng_enc.c @@ -923,11 +923,9 @@ void stereoFdCngCoherence( else if ( sts[0]->core_brate <= SID_2k40 && sts[1]->core_brate <= SID_2k40 ) { /* case: no VAD for both channels -> INACTIVE FRAME */ - reset_indices_enc( sts[0]->hBstr, - sts[0]->hBstr->nb_ind_tot ); + reset_indices_enc( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot ); - reset_indices_enc( sts[1]->hBstr, - sts[1]->hBstr->nb_ind_tot ); + reset_indices_enc( sts[1]->hBstr, sts[1]->hBstr->nb_ind_tot ); /* synchronize SID sending for variable SID rate */ if ( sts[0]->core_brate != sts[1]->core_brate ) diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c index 8cecc9dea0..07d4f7ce79 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig.c +++ b/lib_enc/ivas_corecoder_enc_reconfig.c @@ -295,15 +295,10 @@ ivas_error ivas_corecoder_enc_reconfig( mvr2r( input_buff[sce_id], st_ivas->hSCE[sce_id]->hCoreCoder[0]->input_buff, len_inp_memory ); } - /* only reset indices if it is not the first index list, this already contains the IVAS format bits */ if ( sce_id > 0 || hEncoderConfig->ivas_format == MASA_ISM_FORMAT ) { - reset_indices_enc( st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr, - st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->nb_ind_tot ); - } - else - { + reset_indices_enc( st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr, st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->nb_ind_tot ); } } } @@ -326,11 +321,7 @@ ivas_error ivas_corecoder_enc_reconfig( ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->nSCE > 0 ) || ( hEncoderConfig->ivas_format == MASA_ISM_FORMAT && st_ivas->nSCE > 0 ) ) { - reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, - st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_ind_tot ); - } - else - { + reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_ind_tot ); } } } @@ -361,8 +352,7 @@ ivas_error ivas_corecoder_enc_reconfig( /* only reset indices if it is not the first index list, this already contains the IVAS format bits */ if ( cpe_id * CPE_CHANNELS + n > 0 || ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->nSCE > 0 ) ) { - reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, - st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_ind_tot ); + reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_ind_tot ); } else { @@ -450,13 +440,7 @@ ivas_error ivas_corecoder_enc_reconfig( st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ); #ifdef IGF_MEMORY_ALLOC_OPT - if ( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, - st_ivas->hCPE[0]->hCoreCoder[n]->igf, - 1, - st_ivas->hCPE[0]->element_brate, - st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, - st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, - st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK ) + if ( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK ) { return error; } @@ -536,13 +520,7 @@ ivas_error ivas_corecoder_enc_reconfig( st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ); #ifdef IGF_MEMORY_ALLOC_OPT - if ( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, - st_ivas->hCPE[0]->hCoreCoder[n]->igf, - 1, - st_ivas->hCPE[0]->element_brate, - st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, - st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, - st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK ) + if ( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index d1e3485d63..18a609ccd6 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -911,11 +911,10 @@ ivas_error create_cpe_enc( st->total_brate = hCPE->element_brate / ( st_ivas->nCPE > 1 ? 1 : CPE_CHANNELS ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; - if ( ( error = init_encoder( st, st_ivas, n, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 0, #ifdef IGF_MEMORY_ALLOC_OPT - ISM_MODE_NONE, hCPE->element_brate ) ) != IVAS_ERR_OK ) + if ( ( error = init_encoder( st, st_ivas, n, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 0, ISM_MODE_NONE, hCPE->element_brate ) ) != IVAS_ERR_OK ) #else - ISM_MODE_NONE ) ) != IVAS_ERR_OK ) + if ( ( error = init_encoder( st, st_ivas, n, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 0, ISM_MODE_NONE ) ) != IVAS_ERR_OK ) #endif { return error; diff --git a/lib_enc/ivas_ism_dtx_enc.c b/lib_enc/ivas_ism_dtx_enc.c index c502bedf6c..1277d0d887 100644 --- a/lib_enc/ivas_ism_dtx_enc.c +++ b/lib_enc/ivas_ism_dtx_enc.c @@ -167,9 +167,7 @@ int16_t ivas_ism_dtx_enc( if ( dtx_flag ) { /* reset the bitstream (IVAS format signaling was already written) */ - reset_indices_enc( hSCE[0]->hCoreCoder[0]->hBstr, - - hSCE[0]->hCoreCoder[0]->hBstr->nb_ind_tot ); + reset_indices_enc( hSCE[0]->hCoreCoder[0]->hBstr, hSCE[0]->hCoreCoder[0]->hBstr->nb_ind_tot ); } /*------------------------------------------------------------------* diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 9b5c46745d..259153e89b 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -325,6 +325,7 @@ ivas_error ivas_ism_enc( /*----------------------------------------------------------------* * Core codec configuration *----------------------------------------------------------------*/ + #ifdef IGF_MEMORY_ALLOC_OPT /* IGF reconfiguration */ if ( hSCE->last_element_brate != hSCE->element_brate || st->last_bwidth != st->bwidth ) -- GitLab From 5544736ae7c1ff7228c628cc17495145e5d84587 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 19 Sep 2023 11:44:23 +0200 Subject: [PATCH 09/13] formatting again --- lib_com/ivas_arith.c | 13 ++++ lib_com/ivas_filters.c | 3 +- lib_com/ivas_masa_com.c | 2 +- lib_com/ivas_prot.h | 2 +- lib_com/ivas_qmetadata_com.c | 10 +-- lib_com/ivas_sba_config.c | 1 + lib_com/ivas_stereo_psychlpc_com.c | 3 +- lib_com/ivas_td_decorr.c | 5 +- lib_dec/ivas_binRenderer_internal.c | 66 ++++++----------- lib_dec/ivas_core_dec.c | 6 +- lib_dec/ivas_cpe_dec.c | 5 +- lib_dec/ivas_decision_matrix_dec.c | 4 +- lib_dec/ivas_dirac_dec.c | 29 ++------ lib_dec/ivas_init_dec.c | 9 ++- lib_dec/ivas_ism_dtx_dec.c | 6 +- lib_dec/ivas_ism_metadata_dec.c | 2 +- lib_dec/ivas_ism_param_dec.c | 36 ++++----- lib_dec/ivas_ism_renderer.c | 12 +-- lib_dec/ivas_masa_dec.c | 15 ++-- lib_dec/ivas_mc_param_dec.c | 77 ++++++-------------- lib_dec/ivas_mc_paramupmix_dec.c | 4 +- lib_dec/ivas_mct_dec.c | 11 +-- lib_dec/ivas_mdct_core_dec.c | 5 +- lib_dec/ivas_mono_dmx_renderer.c | 1 + lib_dec/ivas_objectRenderer_internal.c | 21 ++---- lib_dec/ivas_omasa_dec.c | 7 +- lib_dec/ivas_osba_dec.c | 5 +- lib_dec/ivas_out_setup_conversion.c | 3 +- lib_dec/ivas_output_config.c | 4 +- lib_dec/ivas_post_proc.c | 2 - lib_dec/ivas_qmetadata_dec.c | 74 +++++-------------- lib_dec/ivas_qspherical_dec.c | 5 -- lib_dec/ivas_sba_dec.c | 1 - lib_dec/ivas_sba_dirac_stereo_dec.c | 17 ++--- lib_dec/ivas_sba_rendering_internal.c | 3 - lib_dec/ivas_sns_dec.c | 8 +- lib_dec/ivas_spar_decoder.c | 34 +++++---- lib_dec/ivas_spar_md_dec.c | 23 ++++-- lib_dec/ivas_stereo_cng_dec.c | 7 +- lib_dec/ivas_stereo_dft_dec.c | 30 ++------ lib_dec/ivas_stereo_dft_dec_dmx.c | 8 +- lib_dec/ivas_stereo_icbwe_dec.c | 2 +- lib_dec/ivas_stereo_mdct_stereo_dec.c | 4 + lib_dec/ivas_stereo_switching_dec.c | 15 +++- lib_dec/ivas_stereo_td_dec.c | 6 +- lib_dec/ivas_svd_dec.c | 2 + lib_enc/ivas_corecoder_enc_reconfig.c | 3 - lib_enc/ivas_decision_matrix_enc.c | 4 +- lib_enc/ivas_enc_cov_handler.c | 6 +- lib_enc/ivas_entropy_coder.c | 1 + lib_enc/ivas_front_vad.c | 9 +-- lib_enc/ivas_init_enc.c | 10 +-- lib_enc/ivas_stereo_td_enc.c | 4 +- lib_rend/ivas_dirac_dec_binaural_functions.c | 9 +-- 54 files changed, 254 insertions(+), 400 deletions(-) diff --git a/lib_com/ivas_arith.c b/lib_com/ivas_arith.c index 3b8b75138b..0957d4ae50 100644 --- a/lib_com/ivas_arith.c +++ b/lib_com/ivas_arith.c @@ -95,6 +95,12 @@ static uint16_t ivas_ari_get_symbol( } +/*--------------------------------------------------------------- + * Function ivas_ari_decode_14bits_bit_ext_1_lfe() + * + * + *-------------------------------------------------------------*/ + uint16_t ivas_ari_decode_14bits_bit_ext_1_lfe( Decoder_State *st, Tastat *s, @@ -164,6 +170,12 @@ uint16_t ivas_ari_decode_14bits_bit_ext_1_lfe( } +/*--------------------------------------------------------------- + * Function ivas_ari_done_decoding_14bits_ext_1_lfe() + * + * + *-------------------------------------------------------------*/ + void ivas_ari_done_decoding_14bits_ext_1_lfe( Decoder_State *st, const int16_t extra_bits_read ) @@ -216,6 +228,7 @@ void ivas_ari_done_encoding_14bits( return; } + /*--------------------------------------------------------------- * Function ivas_ari_encode_14bits_ext() * diff --git a/lib_com/ivas_filters.c b/lib_com/ivas_filters.c index d89370e795..579e9d17c6 100644 --- a/lib_com/ivas_filters.c +++ b/lib_com/ivas_filters.c @@ -109,7 +109,8 @@ void ivas_filters_init( void ivas_filter_process( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ float *pIn_Out, /* i/o: signal subject to filtering */ - const int16_t length ) /* i : filter order */ + const int16_t length /* i : filter order */ +) { switch ( filter_state->order ) diff --git a/lib_com/ivas_masa_com.c b/lib_com/ivas_masa_com.c index 90c33d3eb3..17e4b47731 100644 --- a/lib_com/ivas_masa_com.c +++ b/lib_com/ivas_masa_com.c @@ -353,7 +353,7 @@ void masa_sample_rate_band_correction( IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: QMetadata structure for modification */ const uint8_t maxBand, /* i : max band */ uint8_t is_encoder, /* i : signals if called at encoder */ - MASA_DECODER_EXT_OUT_META_HANDLE hExtOutMeta /* i/o: MASA decoder metadata ext out buffer */ + MASA_DECODER_EXT_OUT_META_HANDLE hExtOutMeta /* i/o: MASA decoder metadata ext out buffer */ ) { uint8_t band, sf; diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index d340aebecc..b7aea28e90 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -2658,7 +2658,7 @@ void sns_avq_cod_stereo( void sns_avq_dec( int16_t *index, /* i : Quantization indices */ float SNS_Q[NB_DIV][M], /* o : Quantized SNS vectors */ - const int16_t L_frame, + const int16_t L_frame, /* i : frame length */ const int16_t numlpc /* i : Number of sets of lpc */ ); diff --git a/lib_com/ivas_qmetadata_com.c b/lib_com/ivas_qmetadata_com.c index 493977c2f0..d3b11da6d8 100644 --- a/lib_com/ivas_qmetadata_com.c +++ b/lib_com/ivas_qmetadata_com.c @@ -410,11 +410,11 @@ ivas_error only_reduce_bits_direction( *---------------------------------------------------------------*/ void update_bits_next_block( - IVAS_QDIRECTION *q_direction, /* i/o: qdirection */ - int16_t *p_diff, /* i/o: bits to be transferred */ - const int16_t j, /* i : subband to update bit alloc to */ - const int16_t max_i, /* i : number of subbands */ - const int16_t max_k /* i : n umber of subframes */ + IVAS_QDIRECTION *q_direction, /* i/o: qdirection */ + int16_t *p_diff, /* i/o: bits to be transferred */ + const int16_t j, /* i : subband to update bit alloc to*/ + const int16_t max_i, /* i : number of subbands */ + const int16_t max_k /* i : n umber of subframes */ ) { int16_t diff; diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index baf899e1f5..778a7bb90d 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -237,6 +237,7 @@ int16_t ivas_sba_get_nchan_metadata( return ( nb_channels ); } + /*-------------------------------------------------------------------* * ivas_sba_get_spar_hoa_ch_ind() * diff --git a/lib_com/ivas_stereo_psychlpc_com.c b/lib_com/ivas_stereo_psychlpc_com.c index aa24ef6b80..ac94d56b02 100644 --- a/lib_com/ivas_stereo_psychlpc_com.c +++ b/lib_com/ivas_stereo_psychlpc_com.c @@ -68,8 +68,7 @@ static void SpectrumWeighting_Init( * initialize a PsychoacousticParameters structure *-------------------------------------------------------------------*/ -ivas_error -PsychoacousticParameters_Init( +ivas_error PsychoacousticParameters_Init( const int32_t sr_core, /* i : sampling rate of core-coder */ const int16_t nBins, /* i : Number of bins (spectral lines) */ const int8_t nBands, /* i : Number of spectrum subbands */ diff --git a/lib_com/ivas_td_decorr.c b/lib_com/ivas_td_decorr.c index 9e91517d4d..d443129ab2 100644 --- a/lib_com/ivas_td_decorr.c +++ b/lib_com/ivas_td_decorr.c @@ -65,7 +65,6 @@ static const float ivas_hadamard_decorr_APD_coeff[IVAS_APD_16_SECT][IVAS_APD_16_ { 0.4f, -0.4f, -0.4f, 0.4f, -0.4f, 0.4f, 0.4f, -0.4f, -0.4f, 0.4f, 0.4f, -0.4f, 0.4f, -0.4f, -0.4f, 0.4f } }; - /* For R = 3.^([0:obj.parm_APD_nSections-1]/4); */ static const float ivas_three_pow_frac[IVAS_MAX_DECORR_APD_SECTIONS] = { 1.000000000000000f, @@ -86,7 +85,6 @@ static const float ivas_three_pow_frac[IVAS_MAX_DECORR_APD_SECTIONS] = { 61.54669053777900f, }; - #define IVAS_TDET_DUCK_MULT_FAC_PARA_BIN ( 2.0f ) #define IVAS_TDET_DUCK_MULT_FAC_PARA_BIN_LOW_BR ( 3.0f ) @@ -348,6 +346,7 @@ static int16_t ivas_get_APD_filt_orders( { APD_filt_orders[i] = (int16_t) ceil( output_Fs * IVAS_DECORR_PARM_APD_TAU * R[i] / sum_R ); } + return num_apd_sections; } @@ -387,6 +386,7 @@ static void ivas_td_decorr_init( * * APD IIR filter *-----------------------------------------------------------------------------------------*/ + void ivas_td_decorr_APD_iir_filter( ivas_td_decorr_APD_filt_state_t *filter_state, float *pIn_out, @@ -465,7 +465,6 @@ void ivas_td_decorr_process( int16_t i, j; float in_duck_gain[L_FRAME48k], out_duck_gain[L_FRAME48k]; - /* Look-ahead delay */ mvr2r( pcm_in[0], ppOut_pcm[0], output_frame ); delay_signal( ppOut_pcm[0], output_frame, hTdDecorr->look_ahead_buf, hTdDecorr->offset ); diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index e8ce6df818..5f4ba78280 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -394,7 +394,6 @@ 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]; @@ -417,7 +416,6 @@ static ivas_error ivas_binRenderer_convModuleOpen( set_zero( hBinRenConvModule->filterStatesLeftReal[bandIdx][chIdx], hBinRenConvModule->numTaps ); set_zero( hBinRenConvModule->filterStatesLeftImag[bandIdx][chIdx], hBinRenConvModule->numTaps ); #endif - if ( isLoudspeaker ) { hBinRenConvModule->filterTapsLeftReal[bandIdx][chIdx] = hHrtf->leftHRIRReal[bandIdx][tmp]; @@ -480,6 +478,7 @@ static ivas_error ivas_binRenderer_convModuleOpen( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------------* * ivas_init_binaural_hrtf() * @@ -586,7 +585,7 @@ static ivas_error ivas_alloc_pppMem( *-------------------------------------------------------------------------*/ ivas_error ivas_allocate_binaural_hrtf( - HRTFS_FASTCONV *HrtfFastConv, /* i/o: FASTCONV HRTF structure */ + HRTFS_FASTCONV *HrtfFastConv, /* i/o: FASTCONV HRTF structure */ const AUDIO_CONFIG input_config, /* i : input audio configuration */ const BINAURAL_INPUT_AUDIO_CONFIG bin_input_config, /* i : binaural input audio config */ const RENDERER_TYPE renderer_type, /* i : renderer type */ @@ -763,7 +762,6 @@ static ivas_error ivas_binaural_hrtf_open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for FastConv HRTF tables" ); } - ivas_init_binaural_hrtf( HrtfFastConv ); if ( input_config == IVAS_AUDIO_CONFIG_BINAURAL || renderer_type == RENDERER_BINAURAL_FASTCONV ) @@ -855,6 +853,7 @@ static ivas_error ivas_binaural_hrtf_open( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------------* * ivas_binaural_obtain_DMX() * @@ -1161,12 +1160,11 @@ ivas_error ivas_binRenderer_open( IVAS_OUTPUT_SETUP out_setup; /* Allocate memories and buffers needed for convolutional module in CICP19 */ - if ( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv #ifdef SPLIT_REND_WITH_HEAD_ROT - , - hBinRenderer->numPoses + if ( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -1232,9 +1230,7 @@ ivas_error ivas_binRenderer_open( /* Allocate memories needed for reverb module */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - if ( ( error = ivas_binaural_reverb_open( &( hBinRenderer->hReverb ), hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hIntSetup.output_config, st_ivas->hDecoderConfig->output_Fs, - RENDERER_BINAURAL_FASTCONV, - st_ivas->hHrtfFastConv, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_binaural_reverb_open( &( hBinRenderer->hReverb ), hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hIntSetup.output_config, st_ivas->hDecoderConfig->output_Fs, RENDERER_BINAURAL_FASTCONV, st_ivas->hHrtfFastConv, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) { return error; } @@ -1337,7 +1333,6 @@ static void ivas_binRenderer_convModuleClose( free( hBinRenConvModule->filterTapsRightImag ); hBinRenConvModule->filterTapsRightImag = NULL; - #ifdef SPLIT_REND_WITH_HEAD_ROT for ( posIdx = 0; posIdx < num_poses; posIdx++ ) { @@ -1438,6 +1433,7 @@ void ivas_binRenderer_close( return; } + /*------------------------------------------------------------------------- * ivas_free_pppHrtfMem() * @@ -1618,10 +1614,7 @@ void ivas_binaural_cldfb( } else { - cldfbAnalysis_ts( &( output_f[ch][maxBand * index_slot] ), - Cldfb_RealBuffer[idx_in][slot_idx], - Cldfb_ImagBuffer[idx_in][slot_idx], - maxBand, st_ivas->cldfbAnaDec[idx_in] ); + cldfbAnalysis_ts( &( output_f[ch][maxBand * index_slot] ), Cldfb_RealBuffer[idx_in][slot_idx], Cldfb_ImagBuffer[idx_in][slot_idx], maxBand, st_ivas->cldfbAnaDec[idx_in] ); idx_in++; } } @@ -1650,19 +1643,12 @@ void ivas_binaural_cldfb( } /* Implement binaural rendering */ - ivas_binRenderer( - st_ivas->hBinRenderer, #ifdef SPLIT_REND_WITH_HEAD_ROT - &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, -#endif - st_ivas->hCombinedOrientationData, - subframeIdx, - JBM_CLDFB_SLOTS_IN_SUBFRAME, -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - NULL, + ivas_binRenderer( st_ivas->hBinRenderer, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, subframeIdx, JBM_CLDFB_SLOTS_IN_SUBFRAME, NULL, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); +#else + ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, subframeIdx, JBM_CLDFB_SLOTS_IN_SUBFRAME, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); #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 ) @@ -1827,18 +1813,11 @@ void ivas_binaural_cldfb_sf( } /* Implement 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, subframeIdx, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); +#else + ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, subframeIdx, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); #endif - st_ivas->hCombinedOrientationData, - subframeIdx, - st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], - 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 ) @@ -2056,6 +2035,7 @@ void ivas_binRenderer( float reverbIm[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; float inRe[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; float inIm[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + ivas_binaural_obtain_DMX( numTimeSlots, hBinRenderer, RealBuffer, ImagBuffer, inRe, inIm ); for ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) @@ -2091,7 +2071,6 @@ void ivas_binRenderer( } pop_wmops(); - return; } @@ -2161,15 +2140,12 @@ void ivas_rend_CldfbMultiBinRendProcess( head_track_post.Quaternions[0] = ivas_split_rend_get_sf_rot_data( pHeadRotData->headPositionsPostRend, sf_idx ); #endif - ivas_binRenderer( hCldfbRend, - pMultiBinPoseData, - *pCombinedOrientationData, - sf_idx, - MAX_PARAM_SPATIAL_SUBFRAMES, #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - &head_track_post, + ivas_binRenderer( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, sf_idx, 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, sf_idx, MAX_PARAM_SPATIAL_SUBFRAMES, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn ); #endif - Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn ); + for ( pose_idx = 0; pose_idx < hCldfbRend->numPoses; pose_idx++ ) { diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index ee949f8665..e15cb85d1b 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -97,7 +97,6 @@ ivas_error ivas_core_dec( ivas_error error; error = IVAS_ERR_OK; - push_wmops( "ivas_core_dec" ); /*------------------------------------------------------------------* @@ -334,7 +333,6 @@ ivas_error ivas_core_dec( return error; } - flag_sec_CNA = -1; if ( hCPE != NULL ) { @@ -469,7 +467,6 @@ ivas_error ivas_core_dec( return error; } - /* for FD-CNG we need the delay compensation in the synth, so do this afterwards */ if ( sba_dirac_stereo_flag && hSCE && st->core_brate == SID_2k40 && st->cng_type == FD_CNG ) { @@ -652,8 +649,7 @@ ivas_error ivas_core_dec( mvr2r( tmp_buffer, st->hb_prev_synth_buffer, tmps ); } - if ( ( st->element_mode != IVAS_CPE_TD && !use_cldfb_for_dft ) /* IVAS-19: the logic seems to be not consistent between TD and DFT stereo and SCE -> verification needed also whether 1) it is correct here and 2) the DFT->(LR)TD transition is correct */ - || ( hCPE->element_mode == IVAS_CPE_TD && tdm_LRTD_flag ) ) + if ( ( st->element_mode != IVAS_CPE_TD && !use_cldfb_for_dft ) || ( hCPE->element_mode == IVAS_CPE_TD && tdm_LRTD_flag ) ) { /* Delay hb_synth */ delay_signal( hb_synth[n], output_frame, st->hb_prev_synth_buffer, tmps ); diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index 5318ec07a4..7bf06e18ee 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -389,10 +389,7 @@ ivas_error ivas_cpe_dec( { if ( !st_ivas->bfi ) { - tdm_configure_dec( - st_ivas->ivas_format, - st_ivas->ism_mode, - hCPE, &tdm_ratio_idx, nb_bits_metadata ); + tdm_configure_dec( st_ivas->ivas_format, st_ivas->ism_mode, hCPE, &tdm_ratio_idx, nb_bits_metadata ); sts[1]->bit_stream = sts[0]->bit_stream + ( sts[0]->total_brate / FRAMES_PER_SEC ); } diff --git a/lib_dec/ivas_decision_matrix_dec.c b/lib_dec/ivas_decision_matrix_dec.c index d238d43df7..fcbff7f0ed 100644 --- a/lib_dec/ivas_decision_matrix_dec.c +++ b/lib_dec/ivas_decision_matrix_dec.c @@ -174,7 +174,6 @@ void ivas_decision_matrix_dec( } else if ( st->idchan == 1 && st->element_mode == IVAS_CPE_TD ) { - *sharpFlag = 0; if ( st->coder_type == GENERIC || st->coder_type == VOICED ) { @@ -256,8 +255,7 @@ void ivas_decision_matrix_dec( } else if ( st->bwidth == SWB || st->bwidth == FB ) { - if ( st->total_brate >= MIN_BRATE_SWB_BWE /*&& (*coder_type != AUDIO || st->total_brate >= (MIN_BWE_PRI_BRATE+600))*/ - || ( st->total_brate >= MIN_MIN_BRATE_LRTD_SWB_BWE && st->element_mode == IVAS_CPE_TD && st->bwidth == SWB && st->tdm_LRTD_flag ) || ( element_brate < IVAS_16k4 && st->total_brate >= MIN_MIN_BRATE_LRTD_SWB_BWE && st->element_mode == IVAS_CPE_TD && st->bwidth == SWB ) ) + if ( st->total_brate >= MIN_BRATE_SWB_BWE || ( st->total_brate >= MIN_MIN_BRATE_LRTD_SWB_BWE && st->element_mode == IVAS_CPE_TD && st->bwidth == SWB && st->tdm_LRTD_flag ) || ( element_brate < IVAS_16k4 && st->total_brate >= MIN_MIN_BRATE_LRTD_SWB_BWE && st->element_mode == IVAS_CPE_TD && st->bwidth == SWB ) ) { /* read the SWB TBE/BWE selection bit */ tmp = get_next_indice( st, 1 ); diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index c0f23b4697..d0a015add2 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -596,15 +596,8 @@ static ivas_error ivas_dirac_rend_config( if ( ( flag_config == DIRAC_OPEN && hDirACRend->proto_signal_decorr_on ) || ( flag_config == DIRAC_RECONFIGURE && ( hDirACRend->proto_signal_decorr_on && !proto_signal_decorr_on_old ) ) ) { - if ( ( error = ivas_dirac_dec_decorr_open( &( hDirACRend->h_freq_domain_decorr_ap_params ), - &( hDirACRend->h_freq_domain_decorr_ap_state ), - hSpatParamRendCom->num_freq_bands, - hDirACRend->num_outputs_diff, - hDirACRend->num_protos_diff, - hDirACRend->synthesisConf, - hDirACRend->frequency_axis, - nchan_transport > 2 ? 4 : nchan_transport, - output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_decorr_open( &( hDirACRend->h_freq_domain_decorr_ap_params ), &( hDirACRend->h_freq_domain_decorr_ap_state ), hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff, + hDirACRend->num_protos_diff, hDirACRend->synthesisConf, hDirACRend->frequency_axis, nchan_transport > 2 ? 4 : nchan_transport, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -939,19 +932,11 @@ ivas_error ivas_dirac_dec_config( ivas_dirac_dec_get_frequency_axis( frequency_axis, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSpatParamRendCom->num_freq_bands ); #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN - if ( ( error = ivas_dirac_dec_decorr_open( &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params ), - &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_state ), + if ( ( error = ivas_dirac_dec_decorr_open( &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params ), &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_state ), st_ivas->hSpatParamRendCom->num_freq_bands, BINAURAL_CHANNELS, BINAURAL_CHANNELS, #else - if ( ( error = ivas_dirac_dec_decorr_open( &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params ), - &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_state ), + if ( ( error = ivas_dirac_dec_decorr_open( &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params ), &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_state ), st_ivas->hSpatParamRendCom->num_freq_bands, BINAURAL_CHANNELS, BINAURAL_CHANNELS, #endif - st_ivas->hSpatParamRendCom->num_freq_bands, - BINAURAL_CHANNELS, - BINAURAL_CHANNELS, - DIRAC_SYNTHESIS_PSD_LS, - frequency_axis, - BINAURAL_CHANNELS, - st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + DIRAC_SYNTHESIS_PSD_LS, frequency_axis, BINAURAL_CHANNELS, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -1050,7 +1035,7 @@ void ivas_dirac_dec_read_BS( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial rendering data handle */ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata */ int16_t *nb_bits, /* o : number of bits read */ - const int16_t last_bit_pos, /* i : last read bitstream position*/ + const int16_t last_bit_pos, /* i : last read bitstream position */ const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ ) @@ -1207,7 +1192,7 @@ void ivas_qmetadata_to_dirac( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ + const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ ) { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 6f4bf2e1d2..31de52db2b 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -517,7 +517,10 @@ ivas_error ivas_dec_setup( return error; } #else - ivas_mc_dec_config( st_ivas, idx, nSamplesRendered, data ); + if ( ( error = ivas_mc_dec_config( st_ivas, idx, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + { + return error; + } #endif } @@ -898,6 +901,7 @@ int16_t getNumChanSynthesis( n = st_ivas->nchan_transport; } } + return n; } @@ -963,7 +967,6 @@ ivas_error ivas_init_decoder_front( st_ivas->hDecoderConfig->force_rend = -1; #endif - /*-------------------------------------------------------------------* * Allocate and initialize Custom loudspeaker layout handle *--------------------------------------------------------------------*/ @@ -1901,7 +1904,6 @@ ivas_error ivas_init_decoder( set_f( st_ivas->mem_hp20_out[i], 0.0f, L_HP20_MEM ); } - /*-------------------------------------------------------------------* * Allocate and initialize rendering handles *--------------------------------------------------------------------*/ @@ -2078,6 +2080,7 @@ ivas_error ivas_init_decoder( return error; } } + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec.c index 80a4e1e2e5..69402d1c35 100644 --- a/lib_dec/ivas_ism_dtx_dec.c +++ b/lib_dec/ivas_ism_dtx_dec.c @@ -96,11 +96,11 @@ ivas_error ivas_ism_dtx_dec( st_ivas->ism_mode = ism_mode_bstr; } - if ( ( error = ivas_ism_dec_config( st_ivas, last_ism_mode, NULL, #ifdef SPLIT_REND_WITH_HEAD_ROT - PCM_NOT_KNOW, + if ( ( error = ivas_ism_dec_config( st_ivas, last_ism_mode, NULL, PCM_NOT_KNOW, NULL ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_ism_dec_config( st_ivas, last_ism_mode, NULL, NULL ) ) != IVAS_ERR_OK ) #endif - NULL ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index 3b0fe639fb..812c9915bb 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -50,9 +50,9 @@ static void decode_angle_indices( DEC_CORE_HANDLE st0, ISM_METADATA_ANGLE_HANDLE angle, const int16_t non_diegetic_flag, int16_t *flag_abs_azimuth ); - static int16_t decode_radius( DEC_CORE_HANDLE st0, int16_t *last_radius_idx, int16_t *flag_abs_radius ); + /*-------------------------------------------------------------------------* * Local constants *-------------------------------------------------------------------------*/ diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 4b452eba33..2f05b5ce8d 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -94,6 +94,7 @@ static void ivas_param_ism_dec_dequant_powrat( return; } + static void ivas_ism_get_interpolator( const int16_t subframe_nbslots, float *interpolator ) @@ -275,6 +276,7 @@ static void ivas_param_ism_compute_mixing_matrix( } direct_power[w] = sqrtf( direct_power[w] ); } + /* Compute mixing matrix */ computeMixingMatricesISM( nchan_transport, num_wave, nchan_out_woLFE, response_matrix, direct_power, cx_diag[bin_idx], cy_diag, proto_matrix, 1, PARAM_MC_REG_SX, PARAM_MC_REG_GHAT, mixing_matrix[bin_idx] ); @@ -871,12 +873,12 @@ void ivas_param_ism_dec( } } } + ivas_ism_param_dec_tc_gain_ajust( st_ivas, output_frame, output_frame / 2, p_tc ); + for ( ch = 0; ch < nchan_transport; ch++ ) { - /*-----------------------------------------------------------------* - * CLDFB Analysis - *-----------------------------------------------------------------*/ + /* CLDFB Analysis */ for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) { cldfbAnalysis_ts( &( output_f[ch][hSpatParamRendCom->num_freq_bands * slot_idx] ), Cldfb_RealBuffer_in[ch][slot_idx], Cldfb_ImagBuffer_in[ch][slot_idx], hSpatParamRendCom->num_freq_bands, st_ivas->cldfbAnaDec[ch] ); @@ -893,6 +895,7 @@ void ivas_param_ism_dec( /* Compute mixing matrix */ ivas_param_ism_compute_mixing_matrix( st_ivas->nchan_ism, hDirAC, st_ivas->hISMDTX, direct_response, nchan_transport, nchan_out_woLFE, cx_diag, ref_power, mixing_matrix ); + /* subframe loop for synthesis*/ for ( subframe_idx = 0; subframe_idx < hSpatParamRendCom->nb_subframes; subframe_idx++ ) { @@ -989,7 +992,6 @@ void ivas_ism_dec_digest_tc( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); if ( st_ivas->renderer_type == RENDERER_TD_PANNING || @@ -1026,6 +1028,7 @@ void ivas_ism_dec_digest_tc( { ivas_jbm_dec_get_adapted_linear_interpolator( (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ), st_ivas->hTcBuffer->n_samples_available, st_ivas->hIsmRendererData->interpolator ); } + /* also get the gains here */ num_objects = st_ivas->nchan_transport; for ( i = 0; i < num_objects; i++ ) @@ -1034,10 +1037,7 @@ void ivas_ism_dec_digest_tc( if ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_STEREO ) { - ivas_ism_get_stereo_gains( st_ivas->hIsmMetaData[i]->azimuth, - st_ivas->hIsmMetaData[i]->elevation, - &st_ivas->hIsmRendererData->gains[i][0], - &st_ivas->hIsmRendererData->gains[i][1] ); + ivas_ism_get_stereo_gains( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &st_ivas->hIsmRendererData->gains[i][0], &st_ivas->hIsmRendererData->gains[i][1] ); } else { @@ -1218,6 +1218,7 @@ void ivas_param_ism_dec_digest_tc( mvr2r( RealBuffer, &hDirAC->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); mvr2r( ImagBuffer, &hDirAC->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); } + ivas_param_ism_collect_slot( hDirAC, &hDirAC->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &hDirAC->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], ch, ref_power, cx_diag ); } } @@ -1244,10 +1245,10 @@ void ivas_param_ism_dec_digest_tc( *-------------------------------------------------------------------------*/ void ivas_ism_param_dec_tc_gain_ajust( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamples, /* i : number of samples to be compensate */ - const uint16_t nFadeLength, /* i : length of the crossfade in samples */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamples, /* i : number of samples to be compensate */ + const uint16_t nFadeLength, /* i : length of the crossfade in samples */ + float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output*/ ) { @@ -1259,7 +1260,6 @@ void ivas_ism_param_dec_tc_gain_ajust( ene_sum = 0.0f; last_gain = st_ivas->hDirAC->hParamIsm->last_dmx_gain; - for ( i = 0; i < nSamples; i++ ) { ene_tc += transport_channels_f[0][i] * transport_channels_f[0][i] + transport_channels_f[1][i] * transport_channels_f[1][i]; // L*L + R*R @@ -1291,11 +1291,13 @@ void ivas_ism_param_dec_tc_gain_ajust( transport_channels_f[1][i] *= gain; } } + st_ivas->hDirAC->hParamIsm->last_dmx_gain = gain; return; } + /*-------------------------------------------------------------------------* * ivas_ism_param_dec_render_sf() * @@ -1319,7 +1321,6 @@ static void ivas_ism_param_dec_render_sf( float *Cldfb_ImagBuffer_in[PARAM_ISM_MAX_DMX]; DIRAC_DEC_HANDLE hDirAC; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; - int16_t slot_idx_start; int16_t idx_in; int16_t idx_lfe; @@ -1352,8 +1353,7 @@ static void ivas_ism_param_dec_render_sf( /* Compute bandwise rendering to target LS using covariance rendering */ ivas_param_ism_render_slot( hDirAC, hSpatParamRendCom, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, - Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirAC->hParamIsmRendering->mixing_matrix_lin, index_slot, slot_idx, - nchan_out_woLFE, nchan_transport ); + Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirAC->hParamIsmRendering->mixing_matrix_lin, index_slot, slot_idx, nchan_out_woLFE, nchan_transport ); } /* CLDFB Synthesis */ @@ -1381,8 +1381,8 @@ static void ivas_ism_param_dec_render_sf( RealBuffer[i] = Cldfb_RealBuffer[idx_in][i]; ImagBuffer[i] = Cldfb_ImagBuffer[idx_in][i]; } - cldfbSynthesis( RealBuffer, ImagBuffer, output_f[ch], - hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch] ); + + cldfbSynthesis( RealBuffer, ImagBuffer, output_f[ch], hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch] ); idx_in++; } } diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index b867411399..de719d508a 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -183,10 +183,7 @@ void ivas_ism_render( { if ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_STEREO ) { - ivas_ism_get_stereo_gains( st_ivas->hIsmMetaData[i]->azimuth, - st_ivas->hIsmMetaData[i]->elevation, - &gains[i][0], - &gains[i][1] ); + ivas_ism_get_stereo_gains( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &gains[i][0], &gains[i][1] ); } else { @@ -243,6 +240,7 @@ void ivas_ism_render( return; } + /*-------------------------------------------------------------------------* * ivas_ism_render_sf() * @@ -274,12 +272,9 @@ void ivas_ism_render_sf( set_f( output_f[i], 0.0f, n_samples_to_render ); } - if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] ) { - ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, - n_samples_to_render, - st_ivas->hIsmRendererData->interpolator ); + ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator ); interp_offset = 0; } @@ -601,6 +596,7 @@ void ivas_omasa_separate_object_render( return; } + /*-------------------------------------------------------------------------* * ivas_omasa_separate_object_render_jbm() * diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index c114ae5a62..37cff3347e 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -886,7 +886,7 @@ static void index_16bits( } -/* Used to replicate subframe data when there is only one subframe sent */ +/* Replicate subframe data when there is only one subframe sent */ static void replicate_subframes( IVAS_QMETADATA_HANDLE hQMetaData ) { @@ -952,7 +952,7 @@ static void restore_lowbitrate_masa( } } } - hQMetaData->q_direction->cfg.nblocks = 4; /* Set just to be sure */ + hQMetaData->q_direction->cfg.nblocks = 4; } else { @@ -976,7 +976,7 @@ static void restore_lowbitrate_masa( } } } - hQMetaData->q_direction->cfg.nbands = numCodingBands; /* Set just to be sure */ + hQMetaData->q_direction->cfg.nbands = numCodingBands; } return; @@ -1928,10 +1928,11 @@ static void create_masa_ext_out_meta( } static void decode_index_slice( - int16_t index, /* i : index to decode */ - int16_t *ratio_idx_ism, /* o : decodec array of integers */ - const int16_t nchan_ism, /* i : number of elements in array (objects) */ - const int16_t K ) /* i : sum of array elements */ + int16_t index, /* i : index to decode */ + int16_t *ratio_idx_ism, /* o : decodec array of integers */ + const int16_t nchan_ism, /* i : number of elements in array (objects) */ + const int16_t K /* i : sum of array elements */ +) { int16_t i, j, sum, elem; int16_t base[MAX_NUM_OBJECTS]; diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 2631fe0c12..6bdba5039a 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -247,7 +247,6 @@ ivas_error ivas_param_mc_dec_open( param_mc_set_num_synth_bands( output_Fs, hParamMC ); - /* Band Grouping */ if ( hParamMC->hMetadataPMC->num_parameter_bands == 20 ) { @@ -324,9 +323,7 @@ ivas_error ivas_param_mc_dec_open( if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) { - matrix_product( hParamMC->ls_conv_dmx_matrix, nchan_out_cov, nchan_out_transport, 0, - ivas_param_mc_conf[config_index].dmx_fac, nchan_out_transport, nchan_transport, 0, - proto_matrix ); + matrix_product( hParamMC->ls_conv_dmx_matrix, nchan_out_cov, nchan_out_transport, 0, ivas_param_mc_conf[config_index].dmx_fac, nchan_out_transport, nchan_transport, 0, proto_matrix ); if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) { @@ -380,15 +377,8 @@ ivas_error ivas_param_mc_dec_open( ivas_dirac_dec_get_frequency_axis( frequency_axis, output_Fs, hParamMC->num_freq_bands ); - if ( ( error = ivas_dirac_dec_decorr_open( &( hParamMC->h_freq_domain_decorr_ap_params ), - &( hParamMC->h_freq_domain_decorr_ap_state ), - hParamMC->num_freq_bands, - hParamMC->num_outputs_diff, - hParamMC->diff_proto_info->num_protos_diff, - DIRAC_SYNTHESIS_COV_MC_LS, - frequency_axis, - nchan_transport, - output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_decorr_open( &( hParamMC->h_freq_domain_decorr_ap_params ), &( hParamMC->h_freq_domain_decorr_ap_state ), hParamMC->num_freq_bands, hParamMC->num_outputs_diff, hParamMC->diff_proto_info->num_protos_diff, + DIRAC_SYNTHESIS_COV_MC_LS, frequency_axis, nchan_transport, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -410,22 +400,14 @@ ivas_error ivas_param_mc_dec_open( } /* output synthesis */ - if ( ( error = ivas_dirac_dec_output_synthesis_cov_open( &( hParamMC->h_output_synthesis_params ), - &( hParamMC->h_output_synthesis_cov_state ), - hParamMC->max_band_decorr, - PARAM_MC_MAX_NSLOTS, - hParamMC->hMetadataPMC->num_parameter_bands, - max_param_band_residual, - nchan_transport, - nchan_out_cov, - proto_matrix ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_output_synthesis_cov_open( &( hParamMC->h_output_synthesis_params ), &( hParamMC->h_output_synthesis_cov_state ), hParamMC->max_band_decorr, PARAM_MC_MAX_NSLOTS, + hParamMC->hMetadataPMC->num_parameter_bands, max_param_band_residual, nchan_transport, nchan_out_cov, proto_matrix ) ) != IVAS_ERR_OK ) { return error; } ivas_param_mc_dec_compute_interpolator( 0, 0, DEFAULT_JBM_CLDFB_TIMESLOTS, hParamMC->h_output_synthesis_params.interpolator ); - /* Head or external rotation */ if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) { @@ -460,9 +442,7 @@ ivas_error ivas_param_mc_dec_open( ivas_param_mc_dec_init( hParamMC, nchan_transport, nchan_out_cov ); - if ( - st_ivas->hDecoderConfig->Opt_5ms && - hParamMC->synthesis_conf != PARAM_MC_SYNTH_MONO_STEREO ) + if ( st_ivas->hDecoderConfig->Opt_5ms && hParamMC->synthesis_conf != PARAM_MC_SYNTH_MONO_STEREO ) { int16_t n_cldfb_slots; @@ -482,6 +462,7 @@ ivas_error ivas_param_mc_dec_open( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); } set_zero( hParamMC->Cldfb_ImagBuffer_tc, n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands ); + if ( st_ivas->hTcBuffer == NULL ) { if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) @@ -749,7 +730,6 @@ ivas_error ivas_param_mc_dec_reconfig( param_mc_set_num_synth_bands( output_Fs, hParamMC ); - /* set max parameter band for abs cov */ k = 0; while ( hParamMC->band_grouping[k] <= PARAM_MC_MAX_BAND_ABS_COV_DEC ) @@ -894,15 +874,8 @@ ivas_error ivas_param_mc_dec_reconfig( ivas_dirac_dec_get_frequency_axis( frequency_axis, output_Fs, hParamMC->num_freq_bands ); - if ( ( error = ivas_dirac_dec_decorr_open( &( hParamMC->h_freq_domain_decorr_ap_params ), - &( hParamMC->h_freq_domain_decorr_ap_state ), - hParamMC->num_freq_bands, - hParamMC->num_outputs_diff, - hParamMC->diff_proto_info->num_protos_diff, - DIRAC_SYNTHESIS_COV_MC_LS, - frequency_axis, - nchan_transport, - output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_decorr_open( &( hParamMC->h_freq_domain_decorr_ap_params ), &( hParamMC->h_freq_domain_decorr_ap_state ), hParamMC->num_freq_bands, hParamMC->num_outputs_diff, + hParamMC->diff_proto_info->num_protos_diff, DIRAC_SYNTHESIS_COV_MC_LS, frequency_axis, nchan_transport, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -942,15 +915,8 @@ ivas_error ivas_param_mc_dec_reconfig( set_zero( tmp_buf, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS ); /* output synthesis */ - if ( ( error = ivas_dirac_dec_output_synthesis_cov_open( &( hParamMC->h_output_synthesis_params ), - &( hParamMC->h_output_synthesis_cov_state ), - hParamMC->max_band_decorr, - PARAM_MC_MAX_NSLOTS, - hParamMC->hMetadataPMC->num_parameter_bands, - max_param_band_residual, - nchan_transport, - nchan_out_cov, - proto_matrix ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_output_synthesis_cov_open( &( hParamMC->h_output_synthesis_params ), &( hParamMC->h_output_synthesis_cov_state ), hParamMC->max_band_decorr, PARAM_MC_MAX_NSLOTS, + hParamMC->hMetadataPMC->num_parameter_bands, max_param_band_residual, nchan_transport, nchan_out_cov, proto_matrix ) ) != IVAS_ERR_OK ) { return error; } @@ -959,7 +925,6 @@ ivas_error ivas_param_mc_dec_reconfig( ivas_dirac_dec_output_synthesis_cov_init( &( hParamMC->h_output_synthesis_cov_state ), nchan_transport, nchan_out_cov, hParamMC->hMetadataPMC->num_parameter_bands, max_param_band_residual ); - /* map old to new parameter banding, only for same number of TCs, needs some more thought for changing number of TCs */ if ( num_param_bands_old != hParamMC->hMetadataPMC->num_parameter_bands && nchan_transport_old == nchan_transport ) { @@ -1134,7 +1099,6 @@ void ivas_param_mc_dec_close( hParamMC->diff_proto_info = NULL; } - /* States */ /* free prototype signal buffers */ if ( hParamMC->proto_frame_f != NULL ) @@ -1784,17 +1748,23 @@ void ivas_param_mc_dec_render( } } #endif - ivas_binRenderer( st_ivas->hBinRenderer, + #ifdef SPLIT_REND_WITH_HEAD_ROT - &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + ivas_binRenderer( st_ivas->hBinRenderer, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, NULL, st_ivas->hCombinedOrientationData, subframe_idx, hParamMC->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + +#else + ivas_binRenderer( st_ivas->hBinRenderer, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, subframe_idx, hParamMC->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + #endif + +#else + ivas_binRenderer( st_ivas->hBinRenderer, #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG NULL, #endif - st_ivas->hCombinedOrientationData, - subframe_idx, - hParamMC->subframe_nbslots[subframe_idx], - Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + st_ivas->hCombinedOrientationData, subframe_idx, hParamMC->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); +#endif #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 ) @@ -2190,6 +2160,7 @@ static int16_t ivas_param_mc_range_decoder_LC( * * compute the interpolator used in the final synthesis *------------------------------------------------------------------------*/ + static void ivas_param_mc_dec_compute_interpolator( const uint16_t bAttackPresent, /* i : flag indicating if we have a transient in the current frame */ const uint16_t attackPos, /* i : position of the transient */ diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index e0e9a8287f..1451d8b00e 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -704,9 +704,7 @@ ivas_error ivas_mc_paramupmix_dec_open( /* allocate transport channels*/ hMCParamUpmix->free_param_interpolator = 0; hMCParamUpmix->param_interpolator = NULL; - if ( - st_ivas->hDecoderConfig->Opt_5ms == 1 && - st_ivas->hTcBuffer == NULL ) + if ( st_ivas->hDecoderConfig->Opt_5ms == 1 && st_ivas->hTcBuffer == NULL ) { int16_t nchan_to_allocate; int16_t nchan_tc; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index dfe115c6a7..efd369b534 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -54,14 +54,12 @@ * Local function prototypes *-----------------------------------------------------------------------*/ -static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas, uint16_t *nSamplesRendered, #ifdef SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas, uint16_t *nSamplesRendered, const PCM_RESOLUTION pcm_resolution, void *data ); #else - int16_t *data /* o : output synthesis signal */ +static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas, uint16_t *nSamplesRendered, int16_t *data ); #endif -); + /*--------------------------------------------------------------------------* * ivas_mct_dec() @@ -663,7 +661,7 @@ ivas_error ivas_mc_dec_config( 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 */ + int16_t *data /* o : output synthesis signal */ #endif ) { @@ -1060,7 +1058,6 @@ static ivas_error ivas_mc_dec_reconfig( if ( st->hHQ_core == NULL ) { - if ( ( st->hHQ_core = (HQ_DEC_HANDLE) malloc( sizeof( HQ_DEC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ core\n" ) ); diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index a7aa2c7701..d189cdc542 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -197,6 +197,7 @@ static void dec_prm_tcx_sidebits( getTCXparam( st, st0, hm_cfg, param, 0, 0, ( ( ch > 0 ) && ( tnsSize ) && ( tnsSize[0] + tnsSize[1] > 0 ) ? tnsSize : NULL ), p_param, nTnsBitsTCX10, 0 ); st->side_bits_frame_channel = st0->next_bit_pos - start_bit_pos; + return; } @@ -523,7 +524,6 @@ void ivas_mdct_core_invQ( TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode_bfi; push_wmops( "mdct_core_invQ" ); - sts = hCPE->hCoreCoder; bfi = sts[0]->bfi; noise_gen_mode_bfi = NOISE_GEN_MODE_UNDEF; @@ -1043,8 +1043,7 @@ void ivas_mdct_core_tns_ns( L_frameTCX_glob[ch] = st->hTcxDec->L_frameTCX / nSubframes[ch]; L_spec[ch] = st->hTcxCfg->tcx_coded_lines / nSubframes[ch]; - if ( - ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) || ( st->bfi && st->core == ACELP_CORE ) ) /* indicates LFE with no content, or odd number of channels */ + if ( ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) || ( st->bfi && st->core == ACELP_CORE ) ) /* indicates LFE with no content, or odd number of channels */ { if ( st->hTonalMDCTConc != NULL ) { diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 7ee5382408..599bee9ff9 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -187,6 +187,7 @@ void ivas_mono_stereo_downmix_mcmasa( return; } + #ifdef FIX_764_HARM_CODE /*------------------------------------------------------------------------- * ivas_apply_non_diegetic_panning() diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 0b8be72fcf..2536618bb7 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -82,9 +82,7 @@ ivas_error ivas_td_binaural_renderer( int16_t ism_md_subframe_update; int16_t nchan_transport; - nchan_transport = ( st_ivas->ism_mode == ISM_MASA_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) - ? st_ivas->nchan_ism - : st_ivas->nchan_transport; + nchan_transport = ( st_ivas->ism_mode == ISM_MASA_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) ? st_ivas->nchan_ism : st_ivas->nchan_transport; if ( st_ivas->hDecoderConfig->Opt_delay_comp ) { @@ -100,18 +98,11 @@ ivas_error ivas_td_binaural_renderer( ism_md_subframe_update = 2; } - return ivas_td_binaural_renderer_unwrap( - st_ivas->hReverb, - st_ivas->transport_config, - st_ivas->hBinRendererTd, - nchan_transport, - LFE_CHANNEL, st_ivas->ivas_format, - st_ivas->hIsmMetaData, - ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->enableCombinedOrientation : NULL, - ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->Quaternions : NULL, - ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->listenerPos : NULL, - ism_md_subframe_update, output, output_frame, - MAX_PARAM_SPATIAL_SUBFRAMES ); + return ivas_td_binaural_renderer_unwrap( st_ivas->hReverb, st_ivas->transport_config, st_ivas->hBinRendererTd, nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData, + ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->enableCombinedOrientation : NULL, + ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->Quaternions : NULL, + ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->listenerPos : NULL, + ism_md_subframe_update, output, output_frame, MAX_PARAM_SPATIAL_SUBFRAMES ); } diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index dd9642c26f..ec95599c03 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -92,7 +92,6 @@ ivas_error ivas_omasa_data_open( hMasaIsmData->q_azimuth_old[ch] = 0.0f; } - for ( obj_idx = 0; obj_idx < MAX_NUM_OBJECTS; obj_idx++ ) { set_s( hMasaIsmData->azimuth_ism[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); @@ -202,11 +201,11 @@ ivas_error ivas_omasa_dec_config( { st_ivas->hCPE[0]->nchan_out = 1; } - else if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, #ifdef SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, + else if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + else if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 438a89264d..39efa31c91 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -65,6 +65,8 @@ ivas_error ivas_masa_ism_data_open( return IVAS_ERR_OK; } + + /*-------------------------------------------------------------------* * ivas_masa_ism_data_close() * @@ -127,7 +129,6 @@ ivas_error ivas_sba_ism_separate_object_renderer_open( set_zero( st_ivas->hMasaIsmData->delayBuffer[i], st_ivas->hMasaIsmData->delayBuffer_size ); } - return IVAS_ERR_OK; } @@ -277,7 +278,6 @@ ivas_error ivas_osba_ism_metadata_dec( nchan_transport_ism = st_ivas->nchan_ism; *nchan_ism = st_ivas->nchan_ism; - /* decode ISM metadata */ if ( ( error = ivas_ism_metadata_dec( ism_total_brate, *nchan_ism, &nchan_transport_ism, st_ivas->hIsmMetaData, NULL, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hCPE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) @@ -288,6 +288,7 @@ ivas_error ivas_osba_ism_metadata_dec( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------------* * ivas_osba_render() * diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c index 56ed6b8cce..d622e4cf1e 100644 --- a/lib_dec/ivas_out_setup_conversion.c +++ b/lib_dec/ivas_out_setup_conversion.c @@ -1124,6 +1124,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( return; } + /*------------------------------------------------------------------------- * ivas_ls_setup_conversion_process_param_mc() * @@ -1149,7 +1150,6 @@ void ivas_lssetupconversion_process_param_mc( LSSETUP_CONVERSION_HANDLE hLsSetUpConversion; push_wmops( "LS_Renderer_Process_Param_MC" ); - /* inits */ inChannels = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; outChannels = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; @@ -1197,7 +1197,6 @@ void ivas_lssetupconversion_process_param_mc( Cldfb_RealBuffer_InOut[chOutIdx][slotIdx][bandIdx] += tmpDMXSig; targetEnergy[chOutIdx][bandIdx] += tmpDMXSig * tmpDMXSig; - tmpDMXSig = dmxCoeff * Cldfb_ImagBuffer_tmp[chInIdx][bandIdx]; Cldfb_ImagBuffer_InOut[chOutIdx][slotIdx][bandIdx] += tmpDMXSig; targetEnergy[chOutIdx][bandIdx] += tmpDMXSig * tmpDMXSig; diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 40d9a6cdbe..9acaebf7a0 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -362,8 +362,7 @@ void ivas_renderer_select( *renderer_type = RENDERER_DIRAC; ivas_format = ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_NONE ) ? SBA_FORMAT : st_ivas->ivas_format; /* treat ISM_SBA_MODE_NONE just like SBA_FORMAT */ - if ( ivas_format == SBA_FORMAT && - ( output_config != IVAS_AUDIO_CONFIG_5_1 && output_config != IVAS_AUDIO_CONFIG_5_1_2 && output_config != IVAS_AUDIO_CONFIG_5_1_4 && output_config != IVAS_AUDIO_CONFIG_7_1 && output_config != IVAS_AUDIO_CONFIG_7_1_4 && output_config != IVAS_AUDIO_CONFIG_LS_CUSTOM && output_config != IVAS_AUDIO_CONFIG_MONO && output_config != IVAS_AUDIO_CONFIG_STEREO ) ) + if ( ivas_format == SBA_FORMAT && ( output_config != IVAS_AUDIO_CONFIG_5_1 && output_config != IVAS_AUDIO_CONFIG_5_1_2 && output_config != IVAS_AUDIO_CONFIG_5_1_4 && output_config != IVAS_AUDIO_CONFIG_7_1 && output_config != IVAS_AUDIO_CONFIG_7_1_4 && output_config != IVAS_AUDIO_CONFIG_LS_CUSTOM && output_config != IVAS_AUDIO_CONFIG_MONO && output_config != IVAS_AUDIO_CONFIG_STEREO ) ) { if ( output_config == IVAS_AUDIO_CONFIG_HOA2 || output_config == IVAS_AUDIO_CONFIG_FOA ) { @@ -481,6 +480,7 @@ void ivas_renderer_select( else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { *internal_config = output_config; + /* No rendering for 1TC to Mono or Stereo and 2TC to Stereo */ if ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) { diff --git a/lib_dec/ivas_post_proc.c b/lib_dec/ivas_post_proc.c index f9ea70702b..0ec2fa24a2 100644 --- a/lib_dec/ivas_post_proc.c +++ b/lib_dec/ivas_post_proc.c @@ -200,7 +200,6 @@ void stereo_dft_dec_core_switching( #if defined( DEBUG_MODE_DFT ) && defined( DEBUG_STEREO_DFT_NOCORE ) stereo_dft_dec_analyze( hCPE, output, DFT, 0, output_frame, output_frame, DFT_STEREO_DEC_ANA_NOCORE, 0, 0 ); #else - /* resample DFT analysis memories in case of internal sampling rate change */ if ( st->last_L_frame != st->L_frame && st->last_L_frame <= L_FRAME16k && st->L_frame <= L_FRAME16k ) { @@ -442,7 +441,6 @@ void stereo_dft_dec_core_switching( } #endif - /*----------------------------------------------------------------* * enhanced stereo filling: allpass filter *----------------------------------------------------------------*/ diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c index a003a7ae9e..728c295ac5 100644 --- a/lib_dec/ivas_qmetadata_dec.c +++ b/lib_dec/ivas_qmetadata_dec.c @@ -55,7 +55,6 @@ static int16_t ivas_qmetadata_raw_decode_dir( IVAS_QDIRECTION *q_direction, uint static uint16_t ivas_qmetadata_DecodeQuasiUniform( const uint16_t *bitstream, int16_t *index, const uint16_t alphabet_size ); - static int16_t ivas_qmetadata_ReorderElevationDecoded( const int16_t elev_dist, const int16_t elev_avg, const int16_t elev_alph ); static int16_t read_directions( IVAS_QDIRECTION *q_direction, const uint8_t coding_subbands, const uint8_t masa_subframes, uint16_t *bitstream, int16_t *pbit_pos, int16_t *ind_order ); @@ -548,7 +547,6 @@ int16_t ivas_qmetadata_dec_decode( #ifdef DEBUGGING assert( ( diff_bits <= 0 ) || ( q_direction->not_in_2D == 0 ) ); #endif - /* Read raw-coded bits*/ for ( b = start_band; b < nbands; b++ ) { @@ -1075,7 +1073,6 @@ int16_t ivas_qmetadata_dec_decode_hr_384_512( /* move 2 dir data to its correct subband */ if ( bits_sph_idx == 11 ) { - int16_t nblocks; d = hQMetaData->q_direction[1].cfg.nbands - 1; nblocks = hQMetaData->q_direction[0].cfg.nblocks; @@ -1316,7 +1313,6 @@ int16_t ivas_qmetadata_dec_sid_decode( } else { - /* Decode diffuseness*/ for ( b = start_band; b < nbands; b++ ) { @@ -1351,9 +1347,7 @@ int16_t ivas_qmetadata_dec_sid_decode( q_direction->band_data[b].spherical_index[i] = value; } - deindex_spherical_component( q_direction->band_data[b].spherical_index[0], &avg_azimuth, &avg_elevation, - &q_direction->band_data[b].azimuth_index[0], &q_direction->band_data[b].elevation_index[0], q_direction->band_data[b].bits_sph_idx[0], - q_direction->cfg.mc_ls_setup ); + deindex_spherical_component( q_direction->band_data[b].spherical_index[0], &avg_azimuth, &avg_elevation, &q_direction->band_data[b].azimuth_index[0], &q_direction->band_data[b].elevation_index[0], q_direction->band_data[b].bits_sph_idx[0], q_direction->cfg.mc_ls_setup ); ivas_qmetadata_azimuth_elevation_to_direction_vector( avg_azimuth, avg_elevation, avg_direction_vector ); ivas_qmetadata_azimuth_elevation_to_direction_vector( q_direction->band_data[b].azimuth[nblocks - 1], q_direction->band_data[b].elevation[nblocks - 1], direction_vector ); @@ -1982,8 +1976,7 @@ static int16_t ivas_qmetadata_entropy_decode_dir( } /*decode elevation*/ - q_direction->band_data[b].elevation[m] = deindex_elevation( &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], - q_direction->cfg.mc_ls_setup ); + q_direction->band_data[b].elevation[m] = deindex_elevation( &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->cfg.mc_ls_setup ); } } } @@ -2047,8 +2040,7 @@ static int16_t ivas_qmetadata_entropy_decode_dir( } /*decode elevation*/ - q_direction->band_data[b].elevation[m] = deindex_elevation( &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], - q_direction->cfg.mc_ls_setup ); + q_direction->band_data[b].elevation[m] = deindex_elevation( &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->cfg.mc_ls_setup ); } } } @@ -2084,8 +2076,7 @@ static int16_t ivas_qmetadata_entropy_decode_dir( } /*decode elevation*/ - q_direction->band_data[b].elevation[m] = deindex_elevation( &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], - q_direction->cfg.mc_ls_setup ); + q_direction->band_data[b].elevation[m] = deindex_elevation( &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->cfg.mc_ls_setup ); } } } @@ -2114,10 +2105,7 @@ static int16_t ivas_qmetadata_entropy_decode_dir( } else { - q_direction->band_data[b].azimuth[m] = deindex_azimuth( q_direction->band_data[b].azimuth_index[m], - q_direction->band_data[b].bits_sph_idx[m], - q_direction->band_data[b].elevation_index[m], 0, - q_direction->cfg.mc_ls_setup ); + q_direction->band_data[b].azimuth[m] = deindex_azimuth( q_direction->band_data[b].azimuth_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->band_data[b].elevation_index[m], 0, q_direction->cfg.mc_ls_setup ); } } } @@ -2150,10 +2138,7 @@ static int16_t ivas_qmetadata_entropy_decode_dir( } else { - q_direction->band_data[b].azimuth[m] = deindex_azimuth( q_direction->band_data[b].azimuth_index[m], - q_direction->band_data[b].bits_sph_idx[m], - q_direction->band_data[b].elevation_index[m], 0, - q_direction->cfg.mc_ls_setup ); + q_direction->band_data[b].azimuth[m] = deindex_azimuth( q_direction->band_data[b].azimuth_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->band_data[b].elevation_index[m], 0, q_direction->cfg.mc_ls_setup ); } if ( ( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) && ( nblocks > 1 ) ) { @@ -2228,9 +2213,7 @@ static int16_t ivas_qmetadata_raw_decode_dir_512( } else { - deindex_spherical_component( q_direction->band_data[b].spherical_index[m], &q_direction->band_data[b].azimuth[m], &q_direction->band_data[b].elevation[m], - &q_direction->band_data[b].azimuth_index[m], &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], - q_direction->cfg.mc_ls_setup ); + deindex_spherical_component( q_direction->band_data[b].spherical_index[m], &q_direction->band_data[b].azimuth[m], &q_direction->band_data[b].elevation[m], &q_direction->band_data[b].azimuth_index[m], &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->cfg.mc_ls_setup ); } } } @@ -2285,8 +2268,7 @@ static int16_t ivas_qmetadata_raw_decode_dir( q_direction->band_data[b].elevation_index[m] = 0; azith_alph = no_phi_masa[bits_direction_masa[diff_idx] - 1][0]; q_direction->band_data[b].azimuth_index[m] = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, azith_alph ); - q_direction->band_data[b].azimuth[m] = deindex_azimuth( q_direction->band_data[b].azimuth_index[m], q_direction->band_data[b].bits_sph_idx[m], 0, 1, - q_direction->cfg.mc_ls_setup ); + q_direction->band_data[b].azimuth[m] = deindex_azimuth( q_direction->band_data[b].azimuth_index[m], q_direction->band_data[b].bits_sph_idx[m], 0, 1, q_direction->cfg.mc_ls_setup ); } } } @@ -2343,8 +2325,7 @@ static uint16_t ivas_qmetadata_DecodeQuasiUniform( *------------------------------------------------------------------------*/ /*! r: Value decoded from the bitstream */ -int16_t -ivas_qmetadata_DecodeExtendedGR( +int16_t ivas_qmetadata_DecodeExtendedGR( uint16_t *bitstream, /* i : pointer to the bitstream to read */ int16_t *index, /* i/o: position in the bitstream to start reading (gets updated with reading) */ const int16_t alph_size, /* i : size of the alphabet, used to calculate the number of bits needed */ @@ -2733,13 +2714,9 @@ static int16_t decode_azimuth( } else { - q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, - q_direction->band_data[idx_subband].azimuth_m_alphabet[k], MASA_GR_ORD_AZ - ( q_direction->band_data[idx_subband].bits_sph_idx[k] == 2 ) ); + q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, q_direction->band_data[idx_subband].azimuth_m_alphabet[k], MASA_GR_ORD_AZ - ( q_direction->band_data[idx_subband].bits_sph_idx[k] == 2 ) ); - q_direction->band_data[idx_subband].azimuth[k] = deindex_azimuth( q_direction->band_data[idx_subband].azimuth_index[k], - q_direction->band_data[idx_subband].bits_sph_idx[k], - q_direction->band_data[idx_subband].elevation_index[k], 1, - q_direction->cfg.mc_ls_setup ); + q_direction->band_data[idx_subband].azimuth[k] = deindex_azimuth( q_direction->band_data[idx_subband].azimuth_index[k], q_direction->band_data[idx_subband].bits_sph_idx[k], q_direction->band_data[idx_subband].elevation_index[k], 1, q_direction->cfg.mc_ls_setup ); } } } @@ -2760,12 +2737,8 @@ static int16_t decode_azimuth( { if ( no_phi_masa[q_direction->band_data[idx_subband].bits_sph_idx[k] - 1][q_direction->band_data[idx_subband].elevation_index[k]] > 1 ) { - q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, - q_direction->band_data[idx_subband].azimuth_m_alphabet[k], MASA_GR_ORD_AZ - byteBuffer ); - q_direction->band_data[idx_subband].azimuth[k] = deindex_azimuth( q_direction->band_data[idx_subband].azimuth_index[k], - q_direction->band_data[idx_subband].bits_sph_idx[k], - q_direction->band_data[idx_subband].elevation_index[k], 1, - q_direction->cfg.mc_ls_setup ); + q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, q_direction->band_data[idx_subband].azimuth_m_alphabet[k], MASA_GR_ORD_AZ - byteBuffer ); + q_direction->band_data[idx_subband].azimuth[k] = deindex_azimuth( q_direction->band_data[idx_subband].azimuth_index[k], q_direction->band_data[idx_subband].bits_sph_idx[k], q_direction->band_data[idx_subband].elevation_index[k], 1, q_direction->cfg.mc_ls_setup ); } else { @@ -2795,13 +2768,9 @@ static int16_t decode_azimuth( { if ( no_phi_masa[q_direction->band_data[idx_subband].bits_sph_idx[k] - 1][q_direction->band_data[idx_subband].elevation_index[k]] > 1 ) { - q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, - q_direction->band_data[idx_subband].azimuth_m_alphabet[k], MASA_GR_ORD_AZ - 1 - byteBuffer ); + q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, q_direction->band_data[idx_subband].azimuth_m_alphabet[k], MASA_GR_ORD_AZ - 1 - byteBuffer ); q_direction->band_data[idx_subband].azimuth_index[k] += min_idx; - q_direction->band_data[idx_subband].azimuth[k] = deindex_azimuth( q_direction->band_data[idx_subband].azimuth_index[k], - q_direction->band_data[idx_subband].bits_sph_idx[k], - q_direction->band_data[idx_subband].elevation_index[k], 1, - q_direction->cfg.mc_ls_setup ); + q_direction->band_data[idx_subband].azimuth[k] = deindex_azimuth( q_direction->band_data[idx_subband].azimuth_index[k], q_direction->band_data[idx_subband].bits_sph_idx[k], q_direction->band_data[idx_subband].elevation_index[k], 1, q_direction->cfg.mc_ls_setup ); } else { @@ -2901,8 +2870,7 @@ static int16_t decode_elevation( if ( q_direction->band_data[j].elevation_index[k] < MASA_NO_INDEX ) { q_direction->band_data[j].elevation_index[k] = same_idx; - q_direction->band_data[j].elevation[k] = deindex_elevation( &q_direction->band_data[j].elevation_index[k], q_direction->band_data[j].bits_sph_idx[k], - q_direction->cfg.mc_ls_setup ); + q_direction->band_data[j].elevation[k] = deindex_elevation( &q_direction->band_data[j].elevation_index[k], q_direction->band_data[j].bits_sph_idx[k], q_direction->cfg.mc_ls_setup ); } } } @@ -2917,8 +2885,7 @@ static int16_t decode_elevation( if ( q_direction->band_data[j].elevation_index[k] < MASA_NO_INDEX ) { q_direction->band_data[j].elevation_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, q_direction->band_data[j].elevation_m_alphabet[k], GR_ord_elevation ); - q_direction->band_data[j].elevation[k] = deindex_elevation( &q_direction->band_data[j].elevation_index[k], q_direction->band_data[j].bits_sph_idx[k], - q_direction->cfg.mc_ls_setup ); + q_direction->band_data[j].elevation[k] = deindex_elevation( &q_direction->band_data[j].elevation_index[k], q_direction->band_data[j].bits_sph_idx[k], q_direction->cfg.mc_ls_setup ); } } } @@ -2986,9 +2953,7 @@ static int16_t decode_fixed_rate( q_direction->band_data[b].spherical_index[m] = value; nbits += q_direction->band_data[b].bits_sph_idx[m]; - deindex_spherical_component( q_direction->band_data[b].spherical_index[m], &q_direction->band_data[b].azimuth[m], &q_direction->band_data[b].elevation[m], - &q_direction->band_data[b].azimuth_index[m], &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], - q_direction->cfg.mc_ls_setup ); + deindex_spherical_component( q_direction->band_data[b].spherical_index[m], &q_direction->band_data[b].azimuth[m], &q_direction->band_data[b].elevation[m], &q_direction->band_data[b].azimuth_index[m], &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->cfg.mc_ls_setup ); } return nbits; @@ -3101,6 +3066,7 @@ static void set_zero_direction( const int16_t len ) { int16_t k; + for ( k = 0; k < len; k++ ) { q_direction->band_data[idx_band].azimuth[k] = 0; @@ -3476,7 +3442,6 @@ static ivas_error read_huf( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong Huffman codeword for average index in coherence encoding." ); } #endif - *num_bits_read = end_pos; return IVAS_ERR_OK; @@ -3536,6 +3501,7 @@ static int16_t read_GR_min_removed_data( decoded_idx[j] += min_index; } } + #ifdef DEBUGGING assert( nbits == *p_bit_pos - bit_pos ); #endif diff --git a/lib_dec/ivas_qspherical_dec.c b/lib_dec/ivas_qspherical_dec.c index c56217326a..a3dc21f0c3 100644 --- a/lib_dec/ivas_qspherical_dec.c +++ b/lib_dec/ivas_qspherical_dec.c @@ -40,11 +40,6 @@ #include "prot.h" -/*-----------------------------------------------------------------------* - * Local function prototypes - *-----------------------------------------------------------------------*/ - - /*-------------------------------------------------------------------* * deindex_elevation() * diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 888912f5ab..595c4fd6ac 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -349,7 +349,6 @@ ivas_error ivas_sba_dec_reconfigure( ivas_dirac_rend_close( &( st_ivas->hDirACRend ) ); ivas_spat_hSpatParamRendCom_close( &( st_ivas->hSpatParamRendCom ) ); ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); - vbap_free_data( &( st_ivas->hVBAPdata ) ); } diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c index ee33bce164..a853a00728 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -180,6 +180,7 @@ static int16_t ivas_sba_dirac_stereo_band_config( return nbands; } + static float get_panning( const int16_t aziDeg, const int16_t eleDeg ) @@ -214,6 +215,7 @@ static float get_panning( return panning; } + /*-------------------------------------------------------------------* * map_params_dirac_to_stereo() * @@ -246,7 +248,6 @@ static void map_params_dirac_to_stereo( float subframe_band_nrg[NB_DIV][SBA_DIRAC_STEREO_NUM_BANDS]; float smooth_long_avg[NB_DIV][SBA_DIRAC_STEREO_NUM_BANDS]; float smooth_short_avg[NB_DIV][SBA_DIRAC_STEREO_NUM_BANDS]; - float *side_gain, *res_pred_gain; IVAS_QDIRECTION *q_direction; @@ -877,21 +878,18 @@ void ivas_sba_dirac_stereo_dec( } /* mapping of DirAC parameters (azimuth, elevation, diffuseness) to DFT Stereo parameters (side gain, prediction gain) */ - map_params_dirac_to_stereo( hStereoDft, st_ivas->hQMetaData, tmp_synth, DFT[0], - st_ivas->ivas_format == MC_FORMAT, + map_params_dirac_to_stereo( hStereoDft, st_ivas->hQMetaData, tmp_synth, DFT[0], st_ivas->ivas_format == MC_FORMAT, ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ) ? hSCE->hCoreCoder[0]->L_frame : output_frame, ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ) ); + if ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !mcmasa ) { set_f( hStereoDft->res_pred_gain, 1.f, 3 * STEREO_DFT_BAND_MAX ); } /* DFT Stereo upmix */ - stereo_dft_dec( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1 /*st_ivas->sba_dirac_stereo_flag*/, sba_mono_flag, - ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : NULL, - ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0, - st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport, - ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); + stereo_dft_dec( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1 /*st_ivas->sba_dirac_stereo_flag*/, sba_mono_flag, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : NULL, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0, + st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); /* DFT synthesis */ stereo_dft_dec_synthesize( hCPE, DFT, 0, output[0], output_frame ); @@ -923,8 +921,7 @@ void ivas_sba_dirac_stereo_dec( /* upmix ACELP BWE */ ivas_sba_dirac_stereo_compute_hb_gain( hStereoDft, hb_gain ); - ivas_sba_dirac_stereo_upmix_hb( hb_synth_stereo, hSCE->save_hb_synth, hb_gain, output_frame, - ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ), sba_mono_flag, hSCE->hCoreCoder[0]->bwidth, hStereoDft ); + ivas_sba_dirac_stereo_upmix_hb( hb_synth_stereo, hSCE->save_hb_synth, hb_gain, output_frame, ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ), sba_mono_flag, hSCE->hCoreCoder[0]->bwidth, hStereoDft ); /* add HB to ACELP core */ v_add( output[0], hb_synth_stereo[0], output[0], output_frame ); diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 955959897a..17812eabf7 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -76,7 +76,6 @@ void ivas_sba2mc_cldfb( int16_t nb_channels_in; push_wmops( "ivas_sba2mc_cldfb" ); - nb_channels_in = hInSetup.nchan_out_woLFE; assert( ( nb_channels_in == 16 ) && ( nb_channels_out == 11 ) && "ivas_sba2mc_cldfb; only HOA3 to CICP19 is for now supported!" ); @@ -124,7 +123,6 @@ void ivas_sba2mc_cldfb( } pop_wmops(); - return; } @@ -152,7 +150,6 @@ void ivas_mc2sba( int16_t sba_num_chans; assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" ); - /* Init*/ sba_num_chans = ( sba_order + 1 ) * ( sba_order + 1 ); for ( j = 0; j < sba_num_chans; j++ ) diff --git a/lib_dec/ivas_sns_dec.c b/lib_dec/ivas_sns_dec.c index 99fe5eb523..18eb18e788 100644 --- a/lib_dec/ivas_sns_dec.c +++ b/lib_dec/ivas_sns_dec.c @@ -128,9 +128,9 @@ static void sns_2st_dec( void sns_avq_dec( int16_t *index, /* i : Quantization indices */ - float SNS_Q[NB_DIV][M], /* o : Quantized SNS vectors */ - const int16_t L_frame, - const int16_t numlpc /* i : Number of sets of lpc */ + float SNS_Q[NB_DIV][M], /* o : Quantized SNS vectors */ + const int16_t L_frame, /* i : frame length */ + const int16_t numlpc /* i : Number of sets of lpc */ ) { int16_t i, nbi, last; @@ -194,7 +194,6 @@ void sns_avq_dec_stereo( if ( stereo_mode == 2 ) { /* MS coding */ - sns_1st_dec( *indexl++, TCX_20_CORE, L_frame, mid_q ); sns_2st_dec( mid_q, indexl ); @@ -217,7 +216,6 @@ void sns_avq_dec_stereo( else { /* LR decoding */ - sns_1st_dec( *indexl++, TCX_20_CORE, L_frame, SNS_Ql ); sns_2st_dec( SNS_Ql, indexl ); diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index b014faeb0f..77a45ef45b 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -52,7 +52,7 @@ * Local function prototypes *--------------------------------------------------------------------*/ -static void ivas_spar_dec_MD( Decoder_Struct *st_ivas, Decoder_State *st0 ); +static ivas_error ivas_spar_dec_MD( Decoder_Struct *st_ivas, Decoder_State *st0 ); /*------------------------------------------------------------------------- @@ -310,7 +310,6 @@ ivas_error ivas_spar_dec( ivas_error error; push_wmops( "ivas_spar_decode" ); - error = IVAS_ERR_OK; hDecoderConfig = st_ivas->hDecoderConfig; @@ -342,6 +341,7 @@ ivas_error ivas_spar_dec( { last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ); } + if ( !st0->bfi && hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 ) { last_bit_pos -= SID_FORMAT_NBITS; @@ -363,7 +363,14 @@ ivas_error ivas_spar_dec( st0->total_brate = hDecoderConfig->ivas_total_brate; /* to avoid BER detect */ } - ivas_spar_dec_MD( st_ivas, st0 ); + /*---------------------------------------------------------------------* + * Decode SPAR metadata + *---------------------------------------------------------------------*/ + + if ( ( error = ivas_spar_dec_MD( st_ivas, st0 ) ) != IVAS_ERR_OK ) + { + return error; + } *nb_bits_read = st0->next_bit_pos + nb_bits_read_orig; st0->bit_stream = bit_stream_orig; @@ -404,15 +411,13 @@ static int16_t ivas_get_spar_table_idx_from_coded_idx( for ( i = 0; i < IVAS_SPAR_BR_TABLE_LEN; i++ ) { ind1[j] = 0; - if ( ( ivas_spar_br_table_consts[i].ivas_total_brate == ivas_total_brate ) && - ( ivas_spar_br_table_consts[i].sba_order == sba_order ) ) + if ( ( ivas_spar_br_table_consts[i].ivas_total_brate == ivas_total_brate ) && ( ivas_spar_br_table_consts[i].sba_order == sba_order ) ) { ind1[j++] = i; } } assert( j > 0 ); - *bitlen = ivas_get_bits_to_encode( j - 1 ); ind2 = get_next_indice( st0, *bitlen ); @@ -721,7 +726,7 @@ int16_t ivas_is_res_channel( * IVAS SPAR MD decoder *-------------------------------------------------------------------*/ -static void ivas_spar_dec_MD( +static ivas_error ivas_spar_dec_MD( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ Decoder_State *st0 /* i/o: decoder state structure - for bitstream handling*/ ) @@ -729,6 +734,7 @@ static void ivas_spar_dec_MD( int16_t num_channels, table_idx, num_bands_out, bfi, sba_order; int32_t ivas_total_brate; int16_t num_md_sub_frames; + ivas_error error; DECODER_CONFIG_HANDLE hDecoderConfig = st_ivas->hDecoderConfig; SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; @@ -769,7 +775,10 @@ static void ivas_spar_dec_MD( hSpar->hTdDecorr->ducking_flag = ivas_spar_br_table_consts[table_idx].td_ducking; } - ivas_spar_md_dec_init( hSpar->hMdDec, hDecoderConfig, num_channels, sba_order ); + if ( ( error = ivas_spar_md_dec_init( hSpar->hMdDec, hDecoderConfig, num_channels, sba_order ) ) != IVAS_ERR_OK ) + { + return error; + } } } @@ -826,7 +835,7 @@ static void ivas_spar_dec_MD( } pop_wmops(); - return; + return IVAS_ERR_OK; } @@ -1188,8 +1197,10 @@ void ivas_spar_dec_set_render_map( hSpar->num_slots = nCldfbTs; hSpar->slots_rendered = 0; hSpar->subframes_rendered = 0; + set_s( hSpar->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); ivas_jbm_dec_get_adapted_subframes( nCldfbTs, hSpar->subframe_nbslots, &hSpar->nb_subframes ); + st_ivas->hTcBuffer->nb_subframes = hSpar->nb_subframes; mvs2s( hSpar->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hSpar->nb_subframes ); ivas_jbm_dec_get_md_map( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, 1, 0, DEFAULT_JBM_CLDFB_TIMESLOTS, hSpar->render_to_md_map ); @@ -1214,11 +1225,6 @@ void ivas_spar_dec_set_render_params( int16_t num_bands_out; hSpar = st_ivas->hSpar; - - /*---------------------------------------------------------------------* - * Gen umx mat - *---------------------------------------------------------------------*/ - nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 7d5d02482f..b7ede322b3 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -90,6 +90,7 @@ static void ivas_spar_dec_parse_md_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder * * Allocate and initialize SPAR MD decoder matrices *------------------------------------------------------------------------*/ + ivas_error ivas_spar_md_dec_matrix_open( ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ const int16_t num_channels, /* i : number of internal channels */ @@ -351,6 +352,7 @@ ivas_error ivas_spar_md_dec_open( * * Deallocate SPAR MD decoder matrices *------------------------------------------------------------------------*/ + void ivas_spar_md_dec_matrix_close( ivas_spar_md_dec_state_t *hMdDecoder, /* i/o: SPAR MD decoder handle */ const int16_t num_channels /* i : number of internal channels */ @@ -500,6 +502,7 @@ ivas_error ivas_spar_md_dec_init( int16_t i, j; int16_t nchan_transport; float pFC[IVAS_MAX_NUM_BANDS], PR_minmax[2]; + ivas_error error; ivas_sba_get_spar_hoa_md_flag( sba_order, hDecoderConfig->ivas_total_brate, &hMdDec->spar_hoa_md_flag, &hMdDec->spar_hoa_dirac2spar_md_flag ); @@ -517,7 +520,10 @@ ivas_error ivas_spar_md_dec_init( pFC[i] = ivas_fb_fcs_12band_1ms[i] * hDecoderConfig->output_Fs * 0.5f; } - ivas_spar_set_dec_config( hMdDec, nchan_transport, pFC ); + if ( ( error = ivas_spar_set_dec_config( hMdDec, nchan_transport, pFC ) ) != IVAS_ERR_OK ) + { + return error; + } if ( nchan_transport != 2 && ( ( hMdDec->spar_md_cfg.remix_unmix_order == 2 ) || ( hMdDec->spar_md_cfg.remix_unmix_order == 1 ) ) ) { @@ -629,6 +635,7 @@ static ivas_error ivas_spar_set_dec_config( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function ivas_dec_mono_sba_handling() * @@ -663,6 +670,7 @@ static void ivas_dec_mono_sba_handling( } } } + /* Combine the SPAR prediction coefs flag with the azimuth, elevation and energy ratio flag.*/ #ifdef NONBE_FIX_698_SBA_MSAN mono_flag = mono_flag && ivas_spar_chk_zero_coefs( st_ivas ); @@ -692,8 +700,11 @@ static void ivas_dec_mono_sba_handling( } } } + + return; } + /*-----------------------------------------------------------------------------------------* * Function ivas_spar_md_dec_process() * @@ -722,7 +733,6 @@ void ivas_spar_md_dec_process( num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - if ( hMdDec->spar_md_cfg.nchan_transport > 1 && hMdDec->spar_md_cfg.nchan_transport <= 3 ) { hMdDec->spar_md.res_ind = 0; @@ -761,8 +771,7 @@ void ivas_spar_md_dec_process( /* SPAR to DirAC conversion */ if ( hMdDec->spar_hoa_dirac2spar_md_flag == 1 ) { - ivas_spar_to_dirac( st_ivas, hMdDec, dtx_vad, num_bands_out, bw, - dyn_active_w_flag ); + ivas_spar_to_dirac( st_ivas, hMdDec, dtx_vad, num_bands_out, bw, dyn_active_w_flag ); } /* set correct number of bands*/ @@ -1592,6 +1601,7 @@ static void ivas_spar_dec_parse_md_bs( } ivas_parse_parameter_bitstream_dtx( &hMdDec->spar_md, st0, *bands_bw, *nB, hMdDec->spar_md_cfg.num_dmx_chans_per_band, hMdDec->spar_md_cfg.num_decorr_per_band ); + #ifdef NONBE_FIX_723_SBA_BR_SWITCH_MSAN active_brate = ( ivas_total_brate > IVAS_SID_5k2 ) ? ivas_total_brate : last_active_brate; @@ -1841,6 +1851,7 @@ static void ivas_decode_arith_bs( } } } + ivas_copy_band_coeffs_idx_to_arr( hMdDec->spar_md_prev.band_coeffs_idx_mapped, nB, symbol_arr_old_re, pred_cell_dims, PRED_COEFF ); } @@ -1873,7 +1884,6 @@ static void ivas_decode_arith_bs( ivas_copy_band_coeffs_idx_to_arr( hMdDec->spar_md_prev.band_coeffs_idx_mapped, nB, symbol_arr_old_re, drct_cell_dims, DRCT_COEFF ); } - ivas_arith_decode_cmplx_cell_array( &hMdDec->arith_coeffs.drct_arith_re[qsi], &hMdDec->arith_coeffs.drct_arith_re_diff[qsi], st0, drct_cell_dims, pDo_diff, nB, symbol_arr_re, symbol_arr_old_re ); @@ -2277,6 +2287,7 @@ static void ivas_parse_parameter_bitstream_dtx( int16_t pr_q_lvls, pr, pd, pd_q_lvls, pr_pd_bits; int16_t pr_q_lvls1, pr_q_lvls2, pr_idx1, pr_idx2, pr_pr_bits; int16_t zero_pad_bits, sid_bits_len; + sid_bits_len = st0->next_bit_pos; pr_min_max[0] = pSpar_md->min_max[0]; pr_min_max[1] = pSpar_md->min_max[1]; @@ -2457,6 +2468,7 @@ void ivas_spar_to_dirac( int16_t active_w_vlbr; int16_t i, num_subframes; int16_t active_w; + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; active_w = ( dyn_active_w_flag == 1 ) || ( hMdDec->spar_md_cfg.active_w == 1 ); sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); @@ -2464,7 +2476,6 @@ void ivas_spar_to_dirac( end_band = min( num_bands_out, SPAR_DIRAC_SPLIT_START_BAND ) / bw; hDirAC = st_ivas->hDirAC; - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; hSpatParamRendCom = st_ivas->hSpatParamRendCom; dirac_to_spar_md_bands = st_ivas->hSpar->dirac_to_spar_md_bands; diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index 276081237b..5953e93ed3 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -261,7 +261,6 @@ static void stereo_dft_generate_comfort_noise( hStereoCng->cm[b] = hStereoCng->coh[b]; } } - else if ( hStereoCng->nr_dft_frames < CM_INIT && hStereoCng->nr_sid_frames < SID_INIT ) { if ( hStereoCng->nr_corr_frames > CORR_INIT ) @@ -273,7 +272,6 @@ static void stereo_dft_generate_comfort_noise( hStereoCng->cm[b] = ( 1 - A_GFILT ) * hStereoCng->coh[b] + A_GFILT * hStereoCng->cm[b]; } } - else { hStereoCng->cm[b] = ( 1 - A_GFILT ) * hStereoCng->coh[b] + A_GFILT * hStereoCng->cm[b]; @@ -578,6 +576,7 @@ static void stereo_dft_generate_comfort_noise( ptr_level++; } } + /* Compute noise level */ lp_noise = 0.0f; ptr_level = hFdCngCom->cngNoiseLevel; @@ -677,8 +676,7 @@ void stereo_dtf_cng( for ( n = 0; n < CPE_CHANNELS; n++ ) { - stereo_dft_generate_comfort_noise( hCPE->hStereoDft, hCPE->hStereoCng, hCPE->last_element_mode, sts[0], DFT, sts[1], - hCPE->hStereoTCA->targetGain, n, output_frame ); + stereo_dft_generate_comfort_noise( hCPE->hStereoDft, hCPE->hStereoCng, hCPE->last_element_mode, sts[0], DFT, sts[1], hCPE->hStereoTCA->targetGain, n, output_frame ); } } } @@ -733,6 +731,7 @@ void stereo_cng_dec_update( } hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->active_frame_counter = hCPE->hStereoCng->active_frame_counter; + return; } diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index 24a9c7347b..5c515aeb2a 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -294,8 +294,7 @@ ivas_error stereo_dft_dec_create( stereo_dft_config( hStereoDft_loc->hConfig, element_brate, &tmpS, &tmpS ); } - stereo_dft_dec_open( hStereoDft_loc, output_Fs, - nchan_transport ); + stereo_dft_dec_open( hStereoDft_loc, output_Fs, nchan_transport ); *hStereoDft = hStereoDft_loc; @@ -366,7 +365,6 @@ static void stereo_dft_dec_open( hStereoDft->nbands = stereo_dft_band_config( hStereoDft->band_limits, hStereoDft->band_res[0], hStereoDft->NFFT, DEC ); hStereoDft->hb_stefi_delay = NS2SA( output_Fs, STEREO_DFT_TD_STEFI_DELAY_NS ); - if ( nchan_transport > 2 ) { hStereoDft->min_smooth_gains = min_smooth_gains2; @@ -405,10 +403,6 @@ void stereo_dft_dec_reset( set_s( hStereoDft->side_gain_index, 15, STEREO_DFT_BAND_MAX ); set_s( hStereoDft->side_gain_index_previous, 15, STEREO_DFT_BAND_MAX ); - /*IPD*/ - - /*ITD*/ - /*residual prediction*/ set_s( hStereoDft->res_pred_mode, hStereoDft->hConfig->res_pred_mode, STEREO_DFT_DEC_DFT_NB ); for ( i = 0; i < STEREO_DFT_PAST_MAX; i++ ) @@ -421,7 +415,6 @@ void stereo_dft_dec_reset( set_s( hStereoDft->res_pred_index_previous, 0, STEREO_DFT_BAND_MAX ); - for ( i = 0; i < STEREO_DFT_BAND_MAX; i++ ) { hStereoDft->res_gains_ind[0][i] = 15.f; @@ -446,6 +439,7 @@ void stereo_dft_dec_reset( hStereoDft->bpf_error_signal_last = 0.0f; hStereoDft->bpf_error_ratio_mem = 1.0f; hStereoDft->res_hb_nrg_mem = 0.0f; + /*reset parameters*/ set_zero( hStereoDft->side_gain, STEREO_DFT_DEC_DFT_NB * STEREO_DFT_BAND_MAX ); set_zero( hStereoDft->gipd, STEREO_DFT_DEC_DFT_NB ); @@ -518,7 +512,6 @@ void stereo_dft_dec_reset( hStereoDft->g_L_prev = 0.f; hStereoDft->g_R_prev = 0.f; - return; } @@ -1162,7 +1155,6 @@ void stereo_dft_dec( HANDLE_FD_CNG_DEC hFdCngDec = st0->hFdCngDec; HANDLE_FD_CNG_COM hFdCngCom = hFdCngDec->hFdCngCom; int16_t *cna_seed = &( hFdCngCom->seed ); - float DFT_W, DFT_Y; output_frame = (int16_t) ( st0->output_Fs / FRAMES_PER_SEC ); @@ -1206,11 +1198,7 @@ void stereo_dft_dec( /* Smoothing for the current frame */ if ( sba_dirac_stereo_flag ) { - ivas_sba_dirac_stereo_smooth_parameters( hStereoDft, - hMdDec, - cross_fade_start_offset, - output_Fs, - num_md_sub_frames ); + ivas_sba_dirac_stereo_smooth_parameters( hStereoDft, hMdDec, cross_fade_start_offset, output_Fs, num_md_sub_frames ); } else { @@ -1304,7 +1292,6 @@ void stereo_dft_dec( } } - #ifdef DEBUGGING if ( dbgflag( "write_res" ) ) { @@ -1316,7 +1303,6 @@ void stereo_dft_dec( dbgread( pDFT_RES, sizeof( float ), 2 * hStereoDft->band_limits[hStereoDft->res_cod_band_max], "dec_res.float" ); } #endif - /* Apply active DMX */ /* pDFT_RES is used for the second channel in inactive frames */ if ( hStereoDft->frame_sid_nodata && !sba_dirac_stereo_flag ) @@ -1357,7 +1343,6 @@ void stereo_dft_dec( dbgwrite( &g, sizeof( float ), 1, 1, "./res/stereo_dft_dec_g.pcm" ); } #endif - /* No residual coding in inactive frames, instead pDFT_RES is used for the second channel */ if ( b >= hStereoDft->res_cod_band_max && !hStereoDft->frame_sid_nodata && !( sba_dirac_stereo_flag && hMdDec ) ) { @@ -1396,6 +1381,7 @@ void stereo_dft_dec( DFT_L[2 * i + 1] = ( 1 + g ) * pDFT_DMX[2 * i + 1] + gamma * pDFT_RES[2 * i + 1]; DFT_R[2 * i + 1] = ( 1 - g ) * pDFT_DMX[2 * i + 1] - gamma * pDFT_RES[2 * i + 1]; } + if ( pgIpd[0] != 0.f ) { c0 = cosf( pgIpd[0] ); @@ -1537,11 +1523,8 @@ void stereo_dft_dec( } else { - - for ( i = hStereoDft->band_limits[b]; i < min( stop, hStereoDft->band_limits[b + 1] ); i++ ) { - tmp = g * pDFT_DMX[2 * i] + pDFT_RES[2 * i] + DFT_PRED_RES[2 * i]; DFT_L[2 * i] = pDFT_DMX[2 * i] + tmp; @@ -1810,7 +1793,6 @@ void stereo_dft_dec_res( } } #endif - mvr2r( win, output, L_FRAME8k ); #ifdef DEBUG_MODE_DFT @@ -1824,7 +1806,6 @@ void stereo_dft_dec_res( dbgwrite( tmp, sizeof( int16_t ), L_FRAME8k, 1, "./res/stereo_dft_dec_res_decoded.pcm" ); } #endif - if ( hCPE->hCoreCoder[0]->core == ACELP_CORE ) { /* bass post-filter */ @@ -1931,7 +1912,6 @@ void stereo_dft_dec_read_BS( assert( *nb_bits <= 800 ); #endif - /*------------------------------------------------------------------* * Initialization *-----------------------------------------------------------------*/ @@ -2469,6 +2449,7 @@ void stereo_dft_dec_read_BS( return; } + /*------------------------------------------------------------------------- * stereo_dft_compute_td_stefi_params() * @@ -2927,7 +2908,6 @@ void stereo_dft_generate_res_pred( } pop_wmops(); - return; } diff --git a/lib_dec/ivas_stereo_dft_dec_dmx.c b/lib_dec/ivas_stereo_dft_dec_dmx.c index 561f9d016b..e9bb3bc49a 100644 --- a/lib_dec/ivas_stereo_dft_dec_dmx.c +++ b/lib_dec/ivas_stereo_dft_dec_dmx.c @@ -57,10 +57,8 @@ void stereo_dft_dmx_out_reset( STEREO_DFT_DMX_DATA_HANDLE hStereoDftDmx /* i/o: DFT stereo DMX decoder */ ) { - { - hStereoDftDmx->targetGain = 1.0f; - hStereoDftDmx->prevTargetGain = 1.0f; - } + hStereoDftDmx->targetGain = 1.0f; + hStereoDftDmx->prevTargetGain = 1.0f; set_zero( hStereoDftDmx->memOutHB, NS2SA( 48000, STEREO_DFT32MS_OVL_NS ) ); set_zero( hStereoDftDmx->memTransitionHB, NS2SA( 48000, STEREO_DFT32MS_OVL_NS ) ); @@ -124,7 +122,6 @@ void stereo_dft_unify_dmx( dmx_nrg = stereo_dft_dmx_swb_nrg( DFT[0], DFT[0] + STEREO_DFT32MS_N_MAX, min( hStereoDft->NFFT, STEREO_DFT32MS_N_32k ) ); } - /* Analyze nature of current frame */ hStereoDft->trans = ( ( ( st0->clas_dec == ONSET ) || ( st0->clas_dec == SIN_ONSET ) || ( st0->clas_dec == UNVOICED_CLAS ) || ( st0->clas_dec == UNVOICED_TRANSITION ) ) || ( st0->stab_fac <= 0.25f ) ) || ( st0->core == TCX_20_CORE && ( ( st0->hTcxCfg->tcx_last_overlap_mode == MIN_OVERLAP ) || ( st0->hTcxCfg->tcx_last_overlap_mode == HALF_OVERLAP ) ) ) || ( st0->core == TCX_10_CORE ); @@ -243,6 +240,7 @@ void stereo_dft_unify_dmx( return; } + /*-------------------------------------------------------------------* * add_HB_to_mono_dmx() * diff --git a/lib_dec/ivas_stereo_icbwe_dec.c b/lib_dec/ivas_stereo_icbwe_dec.c index 1da2cc3682..aad34a8751 100644 --- a/lib_dec/ivas_stereo_icbwe_dec.c +++ b/lib_dec/ivas_stereo_icbwe_dec.c @@ -68,10 +68,10 @@ static void ic_bwe_dec_reset( set_f( hStereoICBWE->memShb_fsout_nonref, 0, INTERP_3_2_MEM_LEN ); hStereoICBWE->syn_dm_phase_nonref = 0; - return; } + /*-------------------------------------------------------------------* * stereo_icBWE_dec() * diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index 2d2a40d21f..bda6f0559c 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -270,6 +270,7 @@ void stereo_decoder_tcx( } } } +#ifdef DEBUGGING else { if ( mdct_stereo_mode[k] != SMDCT_DUAL_MONO ) @@ -277,6 +278,7 @@ void stereo_decoder_tcx( assert( !"Not supported MDCT stereo mode!\n" ); } } +#endif if ( igf ) { @@ -308,11 +310,13 @@ void stereo_decoder_tcx( } } } +#ifdef DEBUGGING else if ( hStereoMdct->IGFStereoMode[k] != SMDCT_DUAL_MONO ) { assert( !"Not supported MDCT stereo mode!\n" ); } } +#endif if ( !mct_on ) { diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 62ca749f40..d91fdf4b56 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -44,6 +44,12 @@ #include "wmc_auto.h" #include +/*-------------------------------------------------------------------* + * Local constants + *-------------------------------------------------------------------*/ + +#define DFT2TD_CORR_THRESH 0.9f + /*-------------------------------------------------------------------* * Function allocate_CoreCoder_TCX() @@ -421,8 +427,7 @@ ivas_error stereo_memory_dec( deallocate_CoreCoder( hCPE->hCoreCoder[1] ); /* allocate DFT stereo data structure */ - if ( ( error = stereo_dft_dec_create( &( hCPE->hStereoDft ), hCPE->element_brate, output_Fs, 0, - nchan_transport ) ) != IVAS_ERR_OK ) + if ( ( error = stereo_dft_dec_create( &( hCPE->hStereoDft ), hCPE->element_brate, output_Fs, 0, nchan_transport ) ) != IVAS_ERR_OK ) { return error; } @@ -1180,8 +1185,12 @@ void synchro_synthesis( /*----------------------------------------------------------------* * TD/MDCT stereo synchro *----------------------------------------------------------------*/ + if ( sba_dirac_stereo_flag ) + { return; + } + if ( hCPE->element_mode == IVAS_CPE_TD || hCPE->element_mode == IVAS_CPE_MDCT ) { /* handling of DFT->TD switching */ @@ -1783,8 +1792,6 @@ static float ncross_corr_self( * switching from DFT stereo to TD stereo *-------------------------------------------------------------------*/ -#define DFT2TD_CORR_THRESH 0.9f - void smooth_dft2td_transition( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ float *output[CPE_CHANNELS], /* i/o: synthesis @external Fs */ diff --git a/lib_dec/ivas_stereo_td_dec.c b/lib_dec/ivas_stereo_td_dec.c index 630129c474..41018cae25 100644 --- a/lib_dec/ivas_stereo_td_dec.c +++ b/lib_dec/ivas_stereo_td_dec.c @@ -77,6 +77,7 @@ void stereo_td_init_dec( return; } + /*-------------------------------------------------------------------* * tdm_configure_dec() * @@ -272,9 +273,7 @@ void tdm_configure_dec( * bitbudget distribution between channels (taking into account also metadata bitbudget) *----------------------------------------------------------------*/ - tdm_bit_alloc( ivas_format, - ism_mode, - hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC + hCPE->brate_surplus, + tdm_bit_alloc( ivas_format, ism_mode, hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC + hCPE->brate_surplus, hStereoTD->tdm_lp_reuse_flag, &( sts[0]->total_brate ), &( sts[1]->total_brate ), &hStereoTD->tdm_low_rate_mode, sts[1]->coder_type, *tdm_ratio_idx, hStereoTD->tdm_Pitch_reuse_flag, sts[0]->bwidth, sts[1]->bwidth, sts[0]->flag_ACELP16k, hStereoTD->tdm_LRTD_flag, mod_ct, tdm_inst_ratio_idx ); @@ -400,6 +399,7 @@ static void tdm_upmix_fade( return; } + /*-------------------------------------------------------------------* * stereo_tdm_combine() * diff --git a/lib_dec/ivas_svd_dec.c b/lib_dec/ivas_svd_dec.c index 37af3fb124..d2c72d62af 100644 --- a/lib_dec/ivas_svd_dec.c +++ b/lib_dec/ivas_svd_dec.c @@ -46,12 +46,14 @@ /*-----------------------------------------------------------------------* * Local constants *-----------------------------------------------------------------------*/ + /* The SVD is sensitive to changes to the following constants, so please be careful when trying to tune things */ #define SVD_MINIMUM_VALUE 1e-32f /* minimum value */ #define CONVERGENCE_FACTOR 1.19209290e-07f /* factor for SVD convergence */ #define SVD_MAX_NUM_ITERATION 75 /* maximum number of interations before exiting the SVD */ #define SVD_ZERO_FLUSH_THRESHOLD 1.0e-20f + /*-----------------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c index 07d4f7ce79..c80e463eba 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig.c +++ b/lib_enc/ivas_corecoder_enc_reconfig.c @@ -354,9 +354,6 @@ ivas_error ivas_corecoder_enc_reconfig( { reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_ind_tot ); } - else - { - } if ( hEncoderConfig->Opt_DTX_ON ) { diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index bc9968dcb5..e4447a1556 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -346,8 +346,7 @@ void ivas_decision_matrix_enc( } } - if ( st->element_mode >= IVAS_CPE_DFT && st->core == ACELP_CORE && ( st->extl == SWB_TBE || st->extl == FB_TBE ) && - !( st->element_mode == IVAS_CPE_TD && st->tdm_LRTD_flag ) ) + if ( st->element_mode >= IVAS_CPE_DFT && st->core == ACELP_CORE && ( st->extl == SWB_TBE || st->extl == FB_TBE ) && !( st->element_mode == IVAS_CPE_TD && st->tdm_LRTD_flag ) ) { icbwe_brate += STEREO_ICBWE_MSFLAG_BITS * FRAMES_PER_SEC; } @@ -413,7 +412,6 @@ void ivas_signaling_enc( push_indice( hBstr, IND_SMODE, ind, NBITS_ELEMENT_MODE ); } - /*-------------------------------------------------------------------------- * Write band-width info *--------------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_enc_cov_handler.c b/lib_enc/ivas_enc_cov_handler.c index 3ecb96c31f..0eb88dcc16 100644 --- a/lib_enc/ivas_enc_cov_handler.c +++ b/lib_enc/ivas_enc_cov_handler.c @@ -115,6 +115,7 @@ ivas_error ivas_spar_covar_enc_open( return error; } + /*------------------------------------------------------------------------- * ivas_spar_covar_enc_close() * @@ -295,9 +296,7 @@ void ivas_enc_cov_handler_process( pFb->fb_bin_to_band.pp_short_stride_bin_to_band, pFb->fb_bin_to_band.p_short_stride_start_bin_per_band, pFb->fb_bin_to_band.p_short_stride_num_bins_per_band, - start_band, end_band, - cov_real, - HOA_md_ind ); + start_band, end_band, cov_real, HOA_md_ind ); if ( is_sba ) { @@ -413,7 +412,6 @@ static void ivas_band_cov( { for ( j = i; j < num_chans; j++ ) { - int16_t i1 = HOA_md_ind[i]; int16_t j1 = HOA_md_ind[j]; diff --git a/lib_enc/ivas_entropy_coder.c b/lib_enc/ivas_entropy_coder.c index 741338fbf2..0157711bdd 100644 --- a/lib_enc/ivas_entropy_coder.c +++ b/lib_enc/ivas_entropy_coder.c @@ -208,6 +208,7 @@ static int16_t ivas_arithCoder_encode_array_diff( return -1; } } + return 0; } diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index 9f9acdbaf2..52c3b8cd45 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -53,8 +53,8 @@ *-----------------------------------------------------------------------------------------*/ ivas_error front_vad( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure, nullable */ - Encoder_State *st, /* i/o: encoder state structure */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure, nullable */ + Encoder_State *st, /* i/o: encoder state structure */ const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ FRONT_VAD_ENC_HANDLE *hFrontVads, /* i/o: FrontVad handles */ const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ @@ -82,7 +82,6 @@ ivas_error front_vad( ivas_error error; error = IVAS_ERR_OK; - push_wmops( "front_vad" ); if ( hCPE != NULL ) @@ -301,7 +300,6 @@ ivas_error front_vad_create( set_f( hFrontVad->delay_buf, 0, hFrontVad->delay_samples ); } - *hFrontVad_out = hFrontVad; return IVAS_ERR_OK; @@ -388,9 +386,7 @@ ivas_error front_vad_spar( ivas_error error; push_wmops( "front_vad_SPAR" ); - error = IVAS_ERR_OK; - hFrontVad = hSpar->hFrontVad; st = hSpar->hCoreCoderVAD; @@ -493,6 +489,5 @@ ivas_error front_vad_spar( } pop_wmops(); - return error; } diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 96badab949..ac6f81cea5 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -235,6 +235,7 @@ int16_t getNumChanAnalysis( { n = st_ivas->hEncoderConfig->nchan_ism + ( st_ivas->sba_analysis_order + 1 ) * ( st_ivas->sba_analysis_order + 1 ); } + return n; } @@ -373,6 +374,7 @@ ivas_error ivas_init_encoder( int16_t sce_id, cpe_id; IVAS_FORMAT ivas_format; int32_t input_Fs, ivas_total_brate; + int32_t element_brate_tmp[MAX_NUM_OBJECTS]; ENCODER_CONFIG_HANDLE hEncoderConfig; ivas_error error; @@ -507,8 +509,6 @@ ivas_error ivas_init_encoder( } else if ( ivas_format == ISM_FORMAT ) { - int32_t element_brate_tmp[MAX_NUM_OBJECTS]; - st_ivas->ism_mode = ivas_ism_mode_select( hEncoderConfig->nchan_inp, ivas_total_brate ); if ( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_inp, element_brate_tmp ) ) != IVAS_ERR_OK ) @@ -610,7 +610,6 @@ ivas_error ivas_init_encoder( } else if ( ivas_format == MASA_ISM_FORMAT ) { - int32_t element_brate_tmp[MAX_NUM_OBJECTS]; int32_t ism_total_brate; int16_t k; @@ -671,7 +670,6 @@ ivas_error ivas_init_encoder( } else if ( ivas_format == SBA_ISM_FORMAT ) { - int32_t element_brate_tmp[MAX_NUM_OBJECTS]; st_ivas->ism_mode = ISM_MODE_NONE; if ( ivas_total_brate >= IVAS_256k ) @@ -704,12 +702,10 @@ ivas_error ivas_init_encoder( if ( st_ivas->ism_mode == ISM_MODE_NONE ) { - sce_id = 0; /* allocate and initialize SBA core-coders */ if ( st_ivas->nchan_transport == 1 ) { - - if ( ( error = create_sce_enc( st_ivas, sce_id, ivas_total_brate ) ) != IVAS_ERR_OK ) + if ( ( error = create_sce_enc( st_ivas, 0, ivas_total_brate ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_stereo_td_enc.c b/lib_enc/ivas_stereo_td_enc.c index 596c0dcfb6..64446f3e51 100644 --- a/lib_enc/ivas_stereo_td_enc.c +++ b/lib_enc/ivas_stereo_td_enc.c @@ -481,9 +481,7 @@ void tdm_configure_enc( * bitbudget distribution between channels (taking into account also metadata bitbudget) *----------------------------------------------------------------*/ - tdm_bit_alloc( ivas_format, - ism_mode, - hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC + hCPE->brate_surplus, + tdm_bit_alloc( ivas_format, ism_mode, hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC + hCPE->brate_surplus, hStereoTD->tdm_lp_reuse_flag, &( sts[0]->total_brate ), &( sts[1]->total_brate ), &( hStereoTD->tdm_low_rate_mode ), sts[1]->coder_type, tdm_ratio_bit_alloc_idx, hStereoTD->tdm_Pitch_reuse_flag, sts[0]->bwidth, sts[1]->bwidth, sts[0]->flag_ACELP16k, hStereoTD->tdm_LRTD_flag, mod_ct, hStereoTD->tdm_inst_ratio_idx ); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 25332b707c..ddc379d2cd 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -234,14 +234,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( if ( hDiracDecBin->hReverb == NULL ) #endif { - if ( ( error = ivas_binaural_reverb_open( &hDiracDecBin->hReverb, - nBins, - CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, - st_ivas->hIntSetup.output_config, - output_Fs, - RENDERER_BINAURAL_PARAMETRIC_ROOM, - st_ivas->hHrtfFastConv, - st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_binaural_reverb_open( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, st_ivas->hIntSetup.output_config, output_Fs, RENDERER_BINAURAL_PARAMETRIC_ROOM, st_ivas->hHrtfFastConv, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From d77a366c529cdfc68b5a34df884dbe00431405fe Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 19 Sep 2023 15:04:17 +0200 Subject: [PATCH 10/13] formatting --- lib_dec/evs_dec.c | 2 -- lib_dec/init_dec.c | 5 ----- lib_dec/stat_dec.h | 5 +---- lib_enc/init_enc.c | 1 + lib_enc/stat_enc.h | 8 +++----- 5 files changed, 5 insertions(+), 16 deletions(-) diff --git a/lib_dec/evs_dec.c b/lib_dec/evs_dec.c index 4b8e5ab9e8..39815e6333 100644 --- a/lib_dec/evs_dec.c +++ b/lib_dec/evs_dec.c @@ -220,7 +220,6 @@ ivas_error evs_dec( } } - if ( st->codec_mode == MODE1 ) { /*------------------------------------------------------------------* @@ -252,7 +251,6 @@ ivas_error evs_dec( return error; } - /*---------------------------------------------------------------------* * ACELP core decoding * HQ core decoding diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c index a094710f06..86944e55f2 100644 --- a/lib_dec/init_dec.c +++ b/lib_dec/init_dec.c @@ -186,7 +186,6 @@ ivas_error init_decoder( st->old_bfi_cnt = 0; - /*-----------------------------------------------------------------* * parameters for AC mode (GSC) *-----------------------------------------------------------------*/ @@ -247,7 +246,6 @@ ivas_error init_decoder( st->hPFstat = NULL; } - /*-----------------------------------------------------------------* * HF (6-7kHz) (zero) BWE parameters *-----------------------------------------------------------------*/ @@ -356,7 +354,6 @@ ivas_error init_decoder( st->hHQ_nbfec = NULL; } - /*-----------------------------------------------------------------* * TBE parameters *-----------------------------------------------------------------*/ @@ -719,9 +716,7 @@ ivas_error init_decoder( } st->cngTDLevel = 0.f; - st->lp_noise = -20.0f; - st->force_lpd_reset = 0; /*-----------------------------------------------------------------* diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index c971cf0e21..1201d9a304 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -1064,7 +1064,6 @@ typedef struct Decoder_State AMRWB_IO_DEC_HANDLE hAmrwb_IO; - /*----------------------------------------------------------------------------------* * SC-VBR parameters *----------------------------------------------------------------------------------*/ @@ -1159,7 +1158,6 @@ typedef struct Decoder_State FD_BWE_DEC_HANDLE hBWE_FD; - /*----------------------------------------------------------------------------------* * LD music post-filter *----------------------------------------------------------------------------------*/ @@ -1177,7 +1175,6 @@ typedef struct Decoder_State TCX_DEC_HANDLE hTcxDec; - /*----------------------------------------------------------------------------------* * Mode 2 *----------------------------------------------------------------------------------*/ @@ -1336,7 +1333,7 @@ typedef struct Decoder_State TEC_DEC_HANDLE hTECDec; /*----------------------------------------------------------------------------------* - * Stereo/IVAS parameters + * IVAS parameters *----------------------------------------------------------------------------------*/ int16_t tdm_LRTD_flag; /* LRTD stereo mode flag */ diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index 63af9dda77..c40c7aa59b 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -873,6 +873,7 @@ ivas_error init_encoder( /*-----------------------------------------------------------------* * Transient detector *-----------------------------------------------------------------*/ + if ( ( st->hTranDet = (TRAN_DET_HANDLE) malloc( sizeof( TRAN_DET_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) ); diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index ee30669e3d..0b1772ec9b 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1108,6 +1108,8 @@ typedef struct tcx_enc_structure int16_t tns_ms_flag[2]; } TCX_ENC_DATA, *TCX_ENC_HANDLE; + + /*----------------------------------------------------------------------------------* * * Main Core encoder structure @@ -1272,7 +1274,6 @@ typedef struct enc_core_structure int16_t tdm_pc; /* pitch stability - used in TD stereo */ - /*----------------------------------------------------------------------------------* * General signal buffers *----------------------------------------------------------------------------------*/ @@ -1358,7 +1359,6 @@ typedef struct enc_core_structure SC_VBR_ENC_HANDLE hSC_VBR; - /*----------------------------------------------------------------------------------* * HQ core parameters *----------------------------------------------------------------------------------*/ @@ -1450,7 +1450,6 @@ typedef struct enc_core_structure float *wspeech_enc; float *synth; - int16_t enableTcxLpc; /* global toggle for the TCX LPC quantizer */ int16_t envWeighted; /* are is{p,f}_old_q[] weighted or not? */ @@ -1537,9 +1536,8 @@ typedef struct enc_core_structure int16_t tfa_flag; float tfa_enr[N_TEC_TFA_SUBFR]; - /*---------------------------------------------------------------* - * Stereo/IVAS parameters + * IVAS parameters *---------------------------------------------------------------*/ int16_t tdm_LRTD_flag; /* LRTD stereo mode flag */ -- GitLab From 4b1ac279b54e7a6c44962358874568a757a62d6f Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 19 Sep 2023 15:14:03 +0200 Subject: [PATCH 11/13] formatting --- lib_com/ivas_prot.h | 6 +++--- lib_dec/ivas_mc_paramupmix_dec.c | 33 ++++++++++++++++---------------- lib_dec/lib_dec.c | 4 ++-- lib_dec/lib_dec.h | 2 +- lib_enc/ivas_osba_enc.c | 2 +- lib_rend/ivas_rotation.c | 2 +- lib_rend/lib_rend.c | 12 ++++++------ lib_rend/lib_rend.h | 4 ++-- 8 files changed, 32 insertions(+), 33 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index b7aea28e90..17fb7412fd 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3792,7 +3792,7 @@ void ivas_mc_paramupmix_dec_read_BS( void ivas_mc_paramupmix_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ const int16_t nSamplesForRendering /* i : number of samples provided */ ); @@ -4397,8 +4397,8 @@ ivas_error ivas_spar_md_enc_process( const int16_t nchan_inp, const int16_t sba_order, /* i : Ambisonic (SBA) order */ float *prior_mixer[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH], /* i : prior mixer_matrix */ - const int16_t dyn_active_w_flag, /* i : flag to indicate dynamic active W */ - const int16_t dirac_mono_flag /* i : flag to indicate mono only mode in SBA */ + const int16_t dyn_active_w_flag, /* i : flag to indicate dynamic active W */ + const int16_t dirac_mono_flag /* i : flag to indicate mono only mode in SBA */ ); void ivas_compute_spar_params( diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 1451d8b00e..f478bfc2e9 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -153,7 +153,6 @@ void ivas_mc_paramupmix_dec_read_BS( } pop_wmops(); - return; } @@ -211,7 +210,6 @@ void ivas_mc_paramupmix_dec( hMCParamUpmix = st_ivas->hMCParamUpmix; assert( hMCParamUpmix ); - push_wmops( "mc_paramupmix_dec" ); set_s( channel_active, 0, MAX_CICP_CHANNELS ); @@ -369,20 +367,20 @@ void ivas_mc_paramupmix_dec( #endif /* Implement binaural rendering */ - ivas_binRenderer( st_ivas->hBinRenderer, #ifdef SPLIT_REND_WITH_HEAD_ROT - &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + ivas_binRenderer( st_ivas->hBinRenderer, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, subframeIdx, /* TODO (5ms) : tmu2Dlb please verify */ JBM_CLDFB_SLOTS_IN_SUBFRAME, NULL, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_subfr, Cldfb_ImagBuffer_subfr ); +#else + ivas_binRenderer( st_ivas->hBinRenderer, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, subframeIdx, /* TODO (5ms) : tmu2Dlb please verify */ JBM_CLDFB_SLOTS_IN_SUBFRAME, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_subfr, Cldfb_ImagBuffer_subfr ); #endif - st_ivas->hCombinedOrientationData, - subframeIdx, /* TODO (5ms) : tmu2Dlb please verify */ - JBM_CLDFB_SLOTS_IN_SUBFRAME, +#else + ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, subframeIdx, /* TODO (5ms) : tmu2Dlb please verify */ JBM_CLDFB_SLOTS_IN_SUBFRAME, #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG NULL, #endif - Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - Cldfb_RealBuffer_subfr, - Cldfb_ImagBuffer_subfr ); - + Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_subfr, Cldfb_ImagBuffer_subfr ); +#endif #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 ) @@ -492,7 +490,6 @@ void ivas_mc_paramupmix_dec( } pop_wmops(); - return; } @@ -505,14 +502,13 @@ void ivas_mc_paramupmix_dec( void ivas_mc_paramupmix_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - const int16_t nSamplesForRendering /* i : number of samples provided */ + const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels*/ + const int16_t nSamplesForRendering /* i : number of samples provided */ ) { MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix; hMCParamUpmix = st_ivas->hMCParamUpmix; assert( hMCParamUpmix ); - push_wmops( "ivas_mc_paramupmix_dec_digest_tc" ); ivas_param_upmix_dec_decorr_subframes( st_ivas, nSamplesForRendering ); @@ -523,6 +519,7 @@ void ivas_mc_paramupmix_dec_digest_tc( ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hMCParamUpmix->param_interpolator ); pop_wmops(); + return; } @@ -618,6 +615,7 @@ void ivas_mc_paramupmix_dec_render( *nSamplesAvailable = ( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered ) * slot_size; pop_wmops(); + return; } @@ -886,10 +884,10 @@ static void ivas_param_upmix_dec_decorr_subframes( } pop_wmops(); - return; } + /*****************************************************************************************/ /* local functions */ /*****************************************************************************************/ @@ -1118,6 +1116,7 @@ static void ivas_mc_paramupmix_dec_sf( } } } + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * st_ivas->hDecoderConfig->output_Fs ) / 48000 ); @@ -1199,7 +1198,6 @@ static void ivas_mc_paramupmix_dec_sf( #else ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, subframeIdx, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_subfr, Cldfb_ImagBuffer_subfr ); - #endif #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -1296,6 +1294,7 @@ static void ivas_mc_paramupmix_dec_sf( st_ivas->hTcBuffer->subframes_rendered++; pop_wmops(); + return; } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 0d4bb9025b..d44592c1c8 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -775,7 +775,7 @@ static ivas_error _GetSamples( 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 */ + 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 */ @@ -1671,7 +1671,7 @@ ivas_error IVAS_DEC_FeedExternalOrientationData( int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ - const int16_t subframe_idx /*i : subframe index*/ + const int16_t subframe_idx /* i : subframe index */ ) { EXTERNAL_ORIENTATION_HANDLE hExternalOrientationData; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 3aa062e652..22d39c9ed6 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -161,7 +161,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( /*! r: decoder error code */ 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 */ + 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 */ diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index 0c0e0d19a0..521d8e70ca 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -394,7 +394,7 @@ void ivas_osba_enc( const int32_t input_Fs /* i : input sampling rate */ #ifdef FIX_732_PLANAR_SBA_OSBA , - const int16_t sba_planar /* i : planar SBA flag */ + const int16_t sba_planar /* i : planar SBA flag */ #endif ) { diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index d72108755a..b6a81bca91 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -1087,7 +1087,7 @@ ivas_error combine_external_and_head_orientations( IVAS_QUATERNION *headRotQuaternions, /* i : quaternions for head rotation */ IVAS_VECTOR3 *listenerPos, /* i : listener position */ #ifdef SPLIT_REND_WITH_HEAD_ROT - IVAS_SPLIT_REND_ROT_AXIS sr_pose_pred_axis, /* i : split rend pose prediction axis*/ + IVAS_SPLIT_REND_ROT_AXIS sr_pose_pred_axis, /* i : split rend pose prediction axis */ #endif EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 2d9e8ea7ae..fb4a3d6439 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4566,7 +4566,7 @@ ivas_error IVAS_REND_RemoveInput( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_GetInputNumChannels( - IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ + IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ const IVAS_REND_InputId inputId, /* i : ID of the input */ int16_t *numChannels /* o : number of channels of the input */ ) @@ -4601,7 +4601,7 @@ ivas_error IVAS_REND_GetInputNumChannels( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_GetNumAllObjects( - IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ + IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ int16_t *numChannels /* o : number of all objects */ ) { @@ -4626,9 +4626,9 @@ ivas_error IVAS_REND_GetNumAllObjects( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_GetDelay( - IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer state */ - int16_t *nSamples, /* o : Renderer delay in samples */ - int32_t *timeScale /* o : Time scale of the delay, equal to renderer output sampling rate */ + IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer state */ + int16_t *nSamples, /* o : Renderer delay in samples */ + int32_t *timeScale /* o : Time scale of the delay, equal to renderer output sampling rate */ ) { /* TODO tmu : this function only returns the maximum delay across all inputs @@ -8995,7 +8995,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, diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 4cf758a671..c1d7360a46 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -323,8 +323,8 @@ ivas_error IVAS_REND_SetExternalOrientation( int8_t enableHeadRotation, /* i : flag to enable head rotation for this frame */ int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ - int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ - const int16_t sf_idx /*i : subframe index*/ + int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ + const int16_t sf_idx /* i : subframe index */ ); ivas_error IVAS_REND_CombineHeadAndExternalOrientation( -- GitLab From 7d98109a5d1b8d8703c513c3295d7013515b30df Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 19 Sep 2023 15:23:22 +0200 Subject: [PATCH 12/13] fix --- lib_dec/ivas_stereo_mdct_stereo_dec.c | 9 +++------ lib_rend/lib_rend.c | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index bda6f0559c..0610447a6f 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -271,12 +271,9 @@ void stereo_decoder_tcx( } } #ifdef DEBUGGING - else + else if ( mdct_stereo_mode[k] != SMDCT_DUAL_MONO ) { - if ( mdct_stereo_mode[k] != SMDCT_DUAL_MONO ) - { - assert( !"Not supported MDCT stereo mode!\n" ); - } + assert( !"Not supported MDCT stereo mode!\n" ); } #endif @@ -315,8 +312,8 @@ void stereo_decoder_tcx( { assert( !"Not supported MDCT stereo mode!\n" ); } - } #endif + } if ( !mct_on ) { diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index fb4a3d6439..87566670ac 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -8995,7 +8995,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 19478d41c5c083acde4e85fe225ca93d9ab31fc4 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 19 Sep 2023 16:02:29 +0200 Subject: [PATCH 13/13] fix SR build --- lib_dec/ivas_binRenderer_internal.c | 6 ++++-- lib_dec/ivas_dirac_dec.c | 1 - lib_dec/ivas_mc_paramupmix_dec.c | 9 ++------- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 5f4ba78280..cda75af2ff 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1644,12 +1644,15 @@ void ivas_binaural_cldfb( /* Implement binaural rendering */ #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG ivas_binRenderer( st_ivas->hBinRenderer, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, subframeIdx, JBM_CLDFB_SLOTS_IN_SUBFRAME, NULL, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); +#else + ivas_binRenderer( st_ivas->hBinRenderer, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, subframeIdx, JBM_CLDFB_SLOTS_IN_SUBFRAME, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); +#endif #else ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, subframeIdx, JBM_CLDFB_SLOTS_IN_SUBFRAME, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); #endif - #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 ) { @@ -2146,7 +2149,6 @@ void ivas_rend_CldfbMultiBinRendProcess( ivas_binRenderer( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, sf_idx, 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 d0a015add2..eeb582bc22 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2417,7 +2417,6 @@ void ivas_dirac_dec_render_sf( ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, subframe_idx, hSpatParamRendCom->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); #endif - #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_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index f478bfc2e9..ed002ccc66 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -368,7 +368,6 @@ void ivas_mc_paramupmix_dec( /* Implement binaural rendering */ #ifdef SPLIT_REND_WITH_HEAD_ROT - #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG ivas_binRenderer( st_ivas->hBinRenderer, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, subframeIdx, /* TODO (5ms) : tmu2Dlb please verify */ JBM_CLDFB_SLOTS_IN_SUBFRAME, NULL, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_subfr, Cldfb_ImagBuffer_subfr ); #else @@ -1190,14 +1189,10 @@ static void ivas_mc_paramupmix_dec_sf( #endif /* Implement binaural rendering */ - #ifdef SPLIT_REND_WITH_HEAD_ROT - ivas_binRenderer( st_ivas->hBinRenderer, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, subframeIdx, - st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_subfr, Cldfb_ImagBuffer_subfr ); - + ivas_binRenderer( st_ivas->hBinRenderer, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, subframeIdx, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_subfr, Cldfb_ImagBuffer_subfr ); #else - ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, subframeIdx, - st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_subfr, Cldfb_ImagBuffer_subfr ); + ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, subframeIdx, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_subfr, Cldfb_ImagBuffer_subfr ); #endif #ifdef SPLIT_REND_WITH_HEAD_ROT -- GitLab