From 0fe7509254a4edbee925c216d8fd357df1391f45 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 28 Mar 2023 18:24:08 +0200 Subject: [PATCH 01/23] formatting --- lib_dec/ivas_stereo_dft_dec.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index f1cbf180bd..6afb00e658 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -1204,10 +1204,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 ); + ivas_sba_dirac_stereo_smooth_parameters( hStereoDft, hMdDec, cross_fade_start_offset, output_Fs ); } else { -- GitLab From a07908f1ea871cc56435579cd65132350e976acb Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 30 Mar 2023 12:23:47 +0200 Subject: [PATCH 02/23] formatting + improve comments --- lib_com/stat_com.h | 4 ++-- lib_dec/ivas_dec.c | 1 - lib_dec/ivas_ism_dec.c | 22 +++++++++------------- lib_dec/ivas_ism_metadata_dec.c | 8 ++++---- lib_enc/ivas_ism_enc.c | 2 -- lib_enc/ivas_ism_metadata_enc.c | 18 +++++++++++------- lib_enc/pre_proc.c | 2 +- 7 files changed, 27 insertions(+), 30 deletions(-) diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 79976efa88..b36e31253f 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -461,7 +461,7 @@ typedef int16_t ( *TDecodeValue )( struct Decoder_State *st, int16_t index, int1 */ typedef float ( *TLinearPredictionFilter )( const int16_t order, const float parCoeff[], float *state, float x ); -/** Structure that defines mapping between a parameter and a bistream. */ +/** Structure that defines mapping between a parameter and a bitstream. */ typedef struct ParamBitMap { /** Number of bits in a bitstream required for the parameter. @@ -516,7 +516,7 @@ typedef struct ParamBitMap struct ParamsBitMap const *pSubParamBitMap; } ParamBitMap; -/** Structure that defines mapping between parameters and a bistream. */ +/** Structure that defines mapping between parameters and a bitstream. */ typedef struct ParamsBitMap { /** Number of parameters in params. */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 0983aee6cb..0495c08961 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -149,7 +149,6 @@ ivas_error ivas_dec( } else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - // VE: call ivas_ism_metadata_dec() with 'st_ivas' - TBD #ifdef DISCRETE_ISM_DTX_CNG #ifdef NCHAN_ISM_PARAMETER 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 ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index e6571e83d9..47e091d542 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -41,12 +41,12 @@ /*-------------------------------------------------------------------------* - * ivas_ism_bitrate_switching() - * + * ivas_ism_bitrate_switching_dec() * + * Reconfiguration of ISM decoder in case of bitrate switching *-------------------------------------------------------------------------*/ -static ivas_error ivas_ism_bitrate_switching( +static ivas_error ivas_ism_bitrate_switching_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nchan_transport_old, /* i : last number of transport channels */ const ISM_MODE last_ism_mode /* i : last ISM mode */ @@ -154,12 +154,8 @@ static ivas_error ivas_ism_bitrate_switching( ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); /* 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 ) ) != IVAS_ERR_OK ) + 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 ) { return error; } @@ -315,9 +311,9 @@ 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 ) ) { #ifdef NCHAN_ISM_PARAMETER - if ( ( error = ivas_ism_bitrate_switching( st_ivas, nchan_transport_old, last_ism_mode ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode ) ) != IVAS_ERR_OK ) #else - if ( ( error = ivas_ism_bitrate_switching( st_ivas, nchan_transport_old, last_ism_mode, num_obj ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, num_obj ) ) != IVAS_ERR_OK ) #endif { return error; @@ -351,9 +347,9 @@ ivas_error ivas_ism_dec_config( if ( st_ivas->ism_mode != last_ism_mode ) { #ifdef NCHAN_ISM_PARAMETER - if ( ( error = ivas_ism_bitrate_switching( st_ivas, nchan_transport_old, last_ism_mode ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode ) ) != IVAS_ERR_OK ) #else - if ( ( error = ivas_ism_bitrate_switching( st_ivas, nchan_transport_old, last_ism_mode, num_obj ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, num_obj ) ) != IVAS_ERR_OK ) #endif { return error; diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index 75b9164e1d..dc419b98bd 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -518,7 +518,7 @@ ivas_error ivas_ism_metadata_dec( } /*----------------------------------------------------------------* - * Set bitsream pointers + * Set bitstream pointers *----------------------------------------------------------------*/ /* set the bitstream pointer to its original position */ @@ -610,9 +610,9 @@ ivas_error ivas_ism_metadata_dec_create( *-------------------------------------------------------------------------*/ static void decode_angle_indices( - DEC_CORE_HANDLE st0, /* i/o: bitstream handle */ - ISM_METADATA_ANGLE_HANDLE angle, /* i/o: angle handle */ - int16_t *flag_abs_azimuth /* o : Azimuth encoding mode */ + DEC_CORE_HANDLE st0, /* i/o: bitstream handle */ + ISM_METADATA_ANGLE_HANDLE angle, /* i/o: angle handle */ + int16_t *flag_abs_azimuth /* o : Azimuth encoding mode */ ) { int16_t idx_azimuth, nbits_diff_azimuth, diff, sgn; diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index f073609b8a..ee16089c6d 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -269,7 +269,6 @@ ivas_error ivas_ism_enc( } else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - // VE: call ivas_ism_metadata_enc() with 'st_ivas' - TBD ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, #ifdef NCHAN_ISM_PARAMETER nchan_ism, @@ -302,7 +301,6 @@ ivas_error ivas_ism_enc( #endif { ivas_write_format_sid( st_ivas->hEncoderConfig->ivas_format, IVAS_SCE, st->hBstr ); - #ifndef DISCRETE_ISM_DTX_CNG if ( st_ivas->ism_mode != ISM_MODE_PARAM ) { diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index 5b45d909f1..9773edd663 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -78,10 +78,10 @@ static void encode_radius( BSTR_ENC_HANDLE hBstr, int16_t *last_radius_idx, int1 ivas_error ivas_set_ism_metadata( ISM_METADATA_HANDLE hIsmMeta, /* o : ISM metadata handle */ const float azimuth, /* i : azimuth value */ - const float elevation, /* i : elevation */ - const float radius_meta, /* i : radius */ - const float yaw, /* i : yaw */ - const float pitch /* i : pitch */ + const float elevation, /* i : elevation */ + const float radius_meta, /* i : radius */ + const float yaw, /* i : yaw */ + const float pitch /* i : pitch */ ) { if ( hIsmMeta == NULL ) @@ -436,13 +436,17 @@ ivas_error ivas_ism_metadata_enc( } } + /*----------------------------------------------------------------* + * Write ParamISM parameters into the bitstream + *----------------------------------------------------------------*/ + if ( ism_mode == ISM_MODE_PARAM ) { - /* Keep the metdata transmission as is during active parts */ + /* Keep the metadata transmission as is during active parts */ /* But send the flag with 1 bit */ push_next_indice( hBstr, hParamIsm->flag_noisy_speech, 1 ); - /* Loop over multiwave to write the object indices into bistream */ + /* Loop over multiwave to write the object indices into bitstream */ for ( ch = 0; ch < MAX_PARAM_ISM_WAVE; ch++ ) { for ( nbands = 0; nbands < hParamIsm->nbands; nbands++ ) @@ -454,7 +458,7 @@ ivas_error ivas_ism_metadata_enc( } } - /* Loop over bands to write the power ratio's indices into bistream */ + /* Loop over bands to write the power ratio's indices into bitstream */ for ( nbands = 0; nbands < hParamIsm->nbands; nbands++ ) { for ( nblocks = 0; nblocks < hParamIsm->nblocks[nbands]; nblocks++ ) diff --git a/lib_enc/pre_proc.c b/lib_enc/pre_proc.c index bbeba48a16..ec2dee5e27 100755 --- a/lib_enc/pre_proc.c +++ b/lib_enc/pre_proc.c @@ -387,7 +387,7 @@ void pre_proc( } else if ( st->rf_mode && st->core_brate != FRAME_NO_DATA && st->core_brate != SID_2k40 ) { - /* the RF config is for (n- fec_offset)th frame that will be packed along with the n-th frame bistream */ + /* the RF config is for (n- fec_offset)th frame that will be packed along with the n-th frame bitstream */ st->rf_mode = 1; st->codec_mode = MODE2; -- GitLab From 76f09f8e4307e24db2924bd33a6ebcc2b2c58338 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 30 Mar 2023 12:40:17 +0200 Subject: [PATCH 03/23] remove obsolete todos --- lib_com/bitstream.c | 3 --- lib_enc/ivas_agc_enc.c | 2 -- 2 files changed, 5 deletions(-) diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index e5f72590a6..d8cf0d60db 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -1845,9 +1845,6 @@ ivas_error preview_indices( break; case SID_ISM: st_ivas->ivas_format = ISM_FORMAT; - /* temporary hack to make mode signaling work with the current 1-object ISM DTX: read padding bits */ - /* Todo: how to apply this here? maybe pt_stream += ... would work? */ - /* st->bit_stream += ( IVAS_SID_4k4 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS; */ break; case SID_MULTICHANNEL: st_ivas->ivas_format = MC_FORMAT; diff --git a/lib_enc/ivas_agc_enc.c b/lib_enc/ivas_agc_enc.c index 83dbdad1e1..03cb2aa2ed 100644 --- a/lib_enc/ivas_agc_enc.c +++ b/lib_enc/ivas_agc_enc.c @@ -455,7 +455,6 @@ void ivas_agc_enc_process( /* writing to a temporary bitstream file */ if ( ivas_agc_writeBits( agcOut, n_channels, pState ) ) { - /* TODO: return error once error codes are harmonized */ IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "SPAR ENC AGC Failed to open agcOut\n " ); } #endif @@ -477,7 +476,6 @@ static int16_t ivas_agc_writeBits( FILE *stream, const int16_t n_channels, ivas_ if ( pState->gain_data[i].absGainExpCurr < 0 || pState->gain_data[i].absGainExpCurr >= (int16_t) pow( 2, pState->agc_com.betaE ) ) { - /* TODO: return error once error codes are harmonized */ IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error Gain values to write!!\n\n" ); } -- GitLab From 559323c3e632e20979739ac8574d47dd6f975fb3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 30 Mar 2023 12:41:06 +0200 Subject: [PATCH 04/23] typo in parameter name: FEPatterFileName -> FEPatternFileName --- apps/decoder.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index e883144987..2bda3a5e39 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -96,7 +96,7 @@ typedef struct char *jbmTraceFilename; #endif char *jbmOffsetFilename; - char *FEPatterFileName; + char *FEPatternFileName; float FER; bool hrtfReaderEnabled; char *hrtfFileName; @@ -388,9 +388,9 @@ int main( * Open Error pattern file for simulation *-----------------------------------------------------------------*/ - if ( arg.FEPatterFileName != NULL ) + if ( arg.FEPatternFileName != NULL ) { - if ( ( FEC_pattern = fopen( arg.FEPatterFileName, "rb" ) ) == NULL ) + if ( ( FEC_pattern = fopen( arg.FEPatternFileName, "rb" ) ) == NULL ) { fprintf( stderr, "Error: Missing or incorrect FEC filename specification\n\n" ); usage_dec(); @@ -406,11 +406,11 @@ int main( * Print information about FEC *-----------------------------------------------------------------*/ - if ( !arg.voipMode && ( arg.FEPatterFileName != NULL || arg.FER > 0 ) ) + if ( !arg.voipMode && ( arg.FEPatternFileName != NULL || arg.FER > 0 ) ) { - if ( arg.FEPatterFileName != NULL ) + if ( arg.FEPatternFileName != NULL ) { - fprintf( stdout, "FEC: %s\n", arg.FEPatterFileName ); + fprintf( stdout, "FEC: %s\n", arg.FEPatternFileName ); } else { @@ -741,7 +741,7 @@ static bool parseCmdlIVAS_dec( arg->jbmOffsetFilename = NULL; arg->FER = 0.f; - arg->FEPatterFileName = NULL; + arg->FEPatternFileName = NULL; arg->hrtfReaderEnabled = false; arg->hrtfFileName = NULL; @@ -852,7 +852,7 @@ static bool parseCmdlIVAS_dec( ftmp = 0.0f; if ( sscanf( argv[i + 1], "%f", &ftmp ) != 1 ) { - arg->FEPatterFileName = argv[i + 1]; + arg->FEPatternFileName = argv[i + 1]; } else { -- GitLab From c9d32d4197850ab64aa6a5070e0a3038f25d4d43 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 30 Mar 2023 12:45:16 +0200 Subject: [PATCH 05/23] remove leftover parameters arg.hrtfCRendReaderEnabled and arg.hrtfCRendFileName --- apps/decoder.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 2bda3a5e39..ad0916bdda 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -100,8 +100,6 @@ typedef struct float FER; bool hrtfReaderEnabled; char *hrtfFileName; - bool hrtfCRendReaderEnabled; - char *hrtfCRendFileName; IVAS_DEC_INPUT_FORMAT inputFormat; bool customLsOutputEnabled; char *customLsSetupFilename; @@ -499,7 +497,7 @@ int main( if ( ( error = create_SetOfHRTF_from_binary( hSetOfHRTF, hrtfReader, arg.output_Fs ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nError in loading HRTF binary file %s for CRend \n\n", arg.hrtfCRendFileName ); + fprintf( stderr, "\nError in loading HRTF binary file %s for CRend \n\n", arg.hrtfFileName ); goto cleanup; } IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv; @@ -507,14 +505,14 @@ int main( if ( ( error = load_fastconv_HRTF_from_binary( hHrtfFastConv, hrtfReader ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nError in loading HRTF binary file %s for FastConv \n\n", arg.hrtfCRendFileName ); + fprintf( stderr, "\nError in loading HRTF binary file %s for FastConv \n\n", arg.hrtfFileName ); } IVAS_DEC_HRTF_PARAMBIN_HANDLE hHrtfParambin; IVAS_DEC_GetHrtfParamBinHandle( hIvasDec, &hHrtfParambin ); if ( ( error = load_parambin_HRTF_from_binary( hHrtfParambin, hrtfReader ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nError in loading HRTF binary file %s for parametric binauralizer \n\n", arg.hrtfCRendFileName ); + fprintf( stderr, "\nError in loading HRTF binary file %s for parametric binauralizer \n\n", arg.hrtfFileName ); } } @@ -746,9 +744,6 @@ static bool parseCmdlIVAS_dec( arg->hrtfReaderEnabled = false; arg->hrtfFileName = NULL; - arg->hrtfCRendReaderEnabled = false; - arg->hrtfCRendFileName = NULL; - arg->customLsOutputEnabled = false; arg->customLsSetupFilename = NULL; -- GitLab From 66fa96f4e4df6a3bc68a4b6d30fb0341c0638d98 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 30 Mar 2023 12:55:44 +0200 Subject: [PATCH 06/23] tabs -> spaces --- lib_com/ivas_prot.h | 4 ++-- lib_dec/lib_dec.h | 4 ++-- lib_rend/ivas_prot_rend.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index c51321d667..f7c4bee17f 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4004,7 +4004,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 */ ); void ivas_spar_bitrate_dist( @@ -4153,7 +4153,7 @@ ivas_error ivas_spar_md_dec_open( ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */ const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ const int16_t num_channels, /* i : number of internal channels */ - const int16_t sba_order, /* i : SBA order */ + const int16_t sba_order, /* i : SBA order */ const int16_t sid_format /* i : SID format */ ); diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index e1e5bfe9f4..ba91696971 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -287,8 +287,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( diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 938e8de02c..85b909e0e6 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -199,11 +199,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 */ ); -- GitLab From 8161d353fdd2274b2b1a7a1ae519dc63dcc2c2ca Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 30 Mar 2023 12:56:19 +0200 Subject: [PATCH 07/23] comments to st_ivas parameters --- lib_dec/ivas_stat_dec.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index ab95c31b5e..430f728fdb 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1186,6 +1186,7 @@ typedef struct Decoder_Struct int16_t codec_mode; /* Mode 1 or 2 */ int16_t ini_frame; /* initialization frames counter */ int16_t ini_active_frame; /* initialization active frames counter */ + int32_t last_active_ivas_total_brate; /* last active frame IVAS total bitrate in bps */ int16_t bfi; /* FEC - bad frame indicator */ int16_t BER_detect; /* BER detect flag */ /* IVAS_fmToDo: eventually replace hCoreCoder->BER_detect by a pointer to ease the updating of this main parameter */ @@ -1237,11 +1238,11 @@ typedef struct Decoder_Struct EFAP_HANDLE hEFAPdata; /* EFAP structure */ VBAP_HANDLE hVBAPdata; /* VBAP structure */ MONO_DOWNMIX_RENDERER_HANDLE hMonoDmxRenderer; /* Mono downmix structure */ - CREND_WRAPPER_HANDLE hCrendWrapper; - REVERB_HANDLE hReverb; /* Reverb handle */ - HRTFS_CREND_HANDLE hSetOfHRTF; /* Set of HRTFs handle (CRend) */ + CREND_WRAPPER_HANDLE hCrendWrapper; /* Crend wrapper handle */ + 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 */ + REVERB_HANDLE hReverb; /* Reverb handle */ LSSETUP_CUSTOM_HANDLE hLsSetupCustom; /* Custom LS configuration handle */ float *hoa_dec_mtx; /* Pointer to decoder matrix for SBA */ HEAD_TRACK_DATA_HANDLE hHeadTrackData; /* Head tracking data structure */ @@ -1251,7 +1252,7 @@ typedef struct Decoder_Struct #ifdef DEBUGGING int32_t noClipping; /* number of clipped samples */ #endif - int32_t last_active_ivas_total_brate; + } Decoder_Struct; /* clang-format on */ -- GitLab From b6d98cb2f7fb66b56ecbeee9fdff6e0d3ff73eda Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 30 Mar 2023 13:02:06 +0200 Subject: [PATCH 08/23] comments --- lib_com/ivas_prot.h | 8 +++--- lib_com/ivas_transient_det.c | 3 +- lib_enc/ivas_mct_enc.c | 2 +- lib_enc/ivas_stereo_dft_enc.c | 20 +++++++------- lib_enc/ivas_stereo_dft_td_itd.c | 8 +++--- lib_rend/ivas_objectRenderer_sfx.c | 15 +++++----- lib_rend/ivas_objectRenderer_sources.c | 26 +++++++++--------- lib_rend/ivas_prot_rend.h | 38 +++++++++++++------------- lib_util/hrtf_file_reader.c | 4 +-- lib_util/hrtf_file_reader.h | 6 ++-- 10 files changed, 66 insertions(+), 64 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index f7c4bee17f..a4baefbaf7 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1085,8 +1085,8 @@ float stereo_dft_enc_synthesize( void stereo_dft_enc_process( CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ - const int16_t vad_flag_dtx[], /* i: VAD dtx flags */ - const int16_t vad_hover_flag[], /* i: VAD hangover flags */ + const int16_t vad_flag_dtx[], /* i : VAD dtx flags */ + const int16_t vad_hover_flag[], /* i : VAD hangover flags */ const int16_t input_frame /* i : input frame length */ ); @@ -2008,8 +2008,8 @@ void deindex_lvq_SHB( void stereo_td_itd_mdct_stereo( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder handle */ - const int16_t vad_flag_dtx[], /* i: VAD dtx flags */ - const int16_t vad_hover_flag[], /* i: VAD hangover flags */ + const int16_t vad_flag_dtx[], /* i : VAD dtx flags */ + const int16_t vad_hover_flag[], /* i : VAD hangover flags */ const int16_t input_frame /* i : frame length */ ); diff --git a/lib_com/ivas_transient_det.c b/lib_com/ivas_transient_det.c index 1e8f53c7ca..2962a91f9f 100644 --- a/lib_com/ivas_transient_det.c +++ b/lib_com/ivas_transient_det.c @@ -211,11 +211,12 @@ void ivas_transient_det_close( * * Transient detection process call *-----------------------------------------------------------------------------------------*/ + void ivas_transient_det_process( ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */ float *pIn_pcm, /* i : input audio channels */ const int16_t frame_len, /* i : frame length in samples */ - int16_t transient_det[2] /* o: transient det outputs */ + int16_t transient_det[2] /* o : transient det outputs */ ) { float in_duck_gain[L_FRAME48k]; diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index b66a2c5733..39f5d1d8e7 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -580,7 +580,7 @@ ivas_error ivas_mc_enc_config( static ivas_error ivas_mc_enc_reconfig( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const int16_t last_mc_mode /* i: last frame mc mode */ + const int16_t last_mc_mode /* i : last frame MC mode */ ) { int16_t nchan_transport_old, nSCE_old, nCPE_old; diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c index ab4844ab94..9e37101386 100644 --- a/lib_enc/ivas_stereo_dft_enc.c +++ b/lib_enc/ivas_stereo_dft_enc.c @@ -1243,10 +1243,10 @@ float stereo_dft_enc_synthesize( *-------------------------------------------------------------------------*/ void stereo_dft_enc_process( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const int16_t vad_flag_dtx[], /* i: VAD dtx flags */ - const int16_t vad_hover_flag[], /* i: VAD hangover flags */ - const int16_t input_frame /* i : input frame length */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + const int16_t vad_flag_dtx[], /* i : VAD dtx flags */ + const int16_t vad_hover_flag[], /* i : VAD hangover flags */ + const int16_t input_frame /* i : input frame length */ ) { int16_t i, j, b; @@ -3205,7 +3205,7 @@ static void res_pred_gain_mode_decision( *------------------------------------------------------------------------*/ static float stereo_dft_calc_mean_bipd( - float *pIpd, /* i: current bandwise IPD */ + float *pIpd, /* i : current bandwise IPD */ float ipd_buf[STEREO_DFT_IPD_BUF_LEN] /* i/o: previous bandwise IPDs */ ) { @@ -3270,9 +3270,9 @@ static float stereo_dft_calc_mean_bipd( *------------------------------------------------------------------------*/ static float stereo_dft_calc_mean_ipd_change( - float *pIpd, /* i: bandwise IPDs */ - float *ipd_smooth, /* i: mean of previous bandwise IPDs */ - int16_t gipd_band_max /* i: number of IPD bands */ + float *pIpd, /* i : bandwise IPDs */ + float *ipd_smooth, /* i : mean of previous bandwise IPDs */ + int16_t gipd_band_max /* i : number of IPD bands */ ) { int16_t b; @@ -3308,8 +3308,8 @@ static float stereo_dft_calc_mean_ipd_change( static void stereo_dft_gipd_stabilization( float *pgIpd, /* i/o: global IPD to be stabilized */ - float prev_gipd, /* i: previous global IPD */ - float ipd_mean_change /* i: mean of previous bandwise IPDs */ + float prev_gipd, /* i : previous global IPD */ + float ipd_mean_change /* i : mean of previous bandwise IPDs */ ) { float diff_gipd; diff --git a/lib_enc/ivas_stereo_dft_td_itd.c b/lib_enc/ivas_stereo_dft_td_itd.c index b7fb95422f..556f112bb4 100644 --- a/lib_enc/ivas_stereo_dft_td_itd.c +++ b/lib_enc/ivas_stereo_dft_td_itd.c @@ -383,10 +383,10 @@ void stereo_td_itd( * ---------------------------------------------------------------*/ void stereo_td_itd_mdct_stereo( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder handle */ - const int16_t vad_flag_dtx[], /* i: VAD dtx flags */ - const int16_t vad_hover_flag[], /* i: VAD hangover flags */ - const int16_t input_frame /* i : frame length */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder handle */ + const int16_t vad_flag_dtx[], /* i : VAD dtx flags */ + const int16_t vad_hover_flag[], /* i : VAD hangover flags */ + const int16_t input_frame /* i : frame length */ ) { int16_t i; diff --git a/lib_rend/ivas_objectRenderer_sfx.c b/lib_rend/ivas_objectRenderer_sfx.c index 98f45a5dd9..59cf06c67b 100644 --- a/lib_rend/ivas_objectRenderer_sfx.c +++ b/lib_rend/ivas_objectRenderer_sfx.c @@ -56,14 +56,15 @@ static void sincResample( const float *input, float *output, const int16_t lengt * * Apply ITD by delaying late channel *---------------------------------------------------------------------*/ + void TDREND_Apply_ITD( - float *input, /* i: Input subframe to be time adjusted */ - float *out_left, /* o: Output left channel with ITD applied */ - float *out_right, /* o: Output right channel with ITD applied */ - int16_t *previtd, /*i/o: Previous ITD value */ - const int16_t itd, /* i: Current subframe ITD value */ - float *mem_itd, /*i/o: ITD buffer memory */ - const int16_t length /* i: Subframe length */ + float *input, /* i : Input subframe to be time adjusted */ + float *out_left, /* o : Output left channel with ITD applied */ + float *out_right, /* o : Output right channel with ITD applied */ + int16_t *previtd, /* i/o: Previous ITD value */ + const int16_t itd, /* i : Current subframe ITD value */ + float *mem_itd, /* i/o: ITD buffer memory */ + const int16_t length /* i : Subframe length */ ) { int16_t transition_len; diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index 4449945711..d48b8a8e90 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -248,19 +248,19 @@ static void TDREND_SRC_REND_Init( --------------------------------------------------------------------*/ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ - TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */ - float *hrf_left_prev, /* o: Left filter */ - float *hrf_right_prev, /* o: Right filter */ - float *hrf_left_delta, /* o: Left filter interpolation delta */ - float *hrf_right_delta, /* o: Right filter interpolation delta */ - int16_t *intp_count, /* o: Interpolation count */ - int16_t *filterlength, /* o: Length of filters */ - int16_t *itd, /* o: ITD value */ - float *Gain, /* o: Gain value */ - TDREND_SRC_t *Src_p, /* i/o: Source pointer */ - const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ + TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */ + float *hrf_left_prev, /* o : Left filter */ + float *hrf_right_prev, /* o : Right filter */ + float *hrf_left_delta, /* o : Left filter interpolation delta */ + float *hrf_right_delta, /* o : Right filter interpolation delta */ + int16_t *intp_count, /* o : Interpolation count */ + int16_t *filterlength, /* o : Length of filters */ + int16_t *itd, /* o : ITD value */ + float *Gain, /* o : Gain value */ + TDREND_SRC_t *Src_p, /* i/o: Source pointer */ + const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ ) { TDREND_MIX_Listener_t *Listener_p; diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 85b909e0e6..22c0afc6b6 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -307,9 +307,9 @@ void HRTF_model_precalc( ivas_error TDREND_REND_RenderSourceHRFilt( TDREND_SRC_t *Src_p, /* i/o: The source to be rendered */ - const float *hrf_left_delta, /* i: Left filter interpolation delta */ - const float *hrf_right_delta, /* i: Right filter interpolation delta */ - const int16_t intp_count, /* i: Interpolation count */ + const float *hrf_left_delta, /* i : Left filter interpolation delta */ + const float *hrf_right_delta, /* i : Right filter interpolation delta */ + const int16_t intp_count, /* i : Interpolation count */ float output_buf[][L_SPATIAL_SUBFR_48k], /* o : Output buffer */ const int16_t subframe_length /* i : Subframe length in use */ ); @@ -344,15 +344,15 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */ - float *hrf_left_prev, /* o: Left filter */ - float *hrf_right_prev, /* o: Right filter */ - float *hrf_left_delta, /* o: Left filter interpolation delta */ - float *hrf_right_delta, /* o: Right filter interpolation delta */ - int16_t *intp_count, /* o: Interpolation count */ - int16_t *filterlength, /* o: Length of filters */ - int16_t *itd, /* o: ITD value */ - float *Gain, /* o: Gain value */ - TDREND_SRC_t *Src_p, + float *hrf_left_prev, /* o : Left filter */ + float *hrf_right_prev, /* o : Right filter */ + float *hrf_left_delta, /* o : Left filter interpolation delta */ + float *hrf_right_delta, /* o : Right filter interpolation delta */ + int16_t *intp_count, /* o : Interpolation count */ + int16_t *filterlength, /* o : Length of filters */ + int16_t *itd, /* o : ITD value */ + float *Gain, /* o : Gain value */ + TDREND_SRC_t *Src_p, /* i/o: Source pointer */ const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ ); @@ -445,13 +445,13 @@ ivas_error TDREND_MIX_Init( /* ----- Object renderer - sfx ----- */ void TDREND_Apply_ITD( - float *input, /* i: Input SCE subframe to be time adjusted */ - float *out_left, /* o: Output left channels with ITD applied */ - float *out_right, /* o: Output right channels with ITD applied */ - int16_t *previtd, /*i/o: Previous ITD value */ - const int16_t itd, /* i: Current subframe ITD value */ - float *mem_itd, /*i/o: ITD buffer memory */ - const int16_t length /* i: Subframe length */ + float *input, /* i : Input SCE subframe to be time adjusted */ + float *out_left, /* o : Output left channels with ITD applied */ + float *out_right, /* o : Output right channels with ITD applied */ + int16_t *previtd, /* i/o: Previous ITD value */ + const int16_t itd, /* i : Current subframe ITD value */ + float *mem_itd, /* i/o: ITD buffer memory */ + const int16_t length /* i : Subframe length */ ); void TDREND_firfilt( diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index b7ffe81682..de16986b99 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -726,8 +726,8 @@ static ivas_error ivas_hrtf_init( *---------------------------------------------------------------------*/ static ivas_error create_HRTF_from_rawdata( - HRTFS_HANDLE *hHRTF, /* i/o: HRTF CRend handle */ - char *hrtf_data /* i: pointer to binary file */ + HRTFS_HANDLE *hHRTF, /* i/o: HRTF CRend handle */ + char *hrtf_data /* i : pointer to binary file */ ) { int16_t i, j, k; diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index 2b59c3150b..2e20cad02a 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -86,9 +86,9 @@ ivas_error load_HRTF_binary( *---------------------------------------------------------------------*/ ivas_error create_SetOfHRTF_from_binary( - IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF, /* i/o: Set of HRTF CRend handle */ - const hrtfFileReader *hrtfReader, /* i: pointer to hrtfFileReader handle */ - int32_t output_Fs /* i: Output sampling frequency */ + IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF, /* i/o: Set of HRTF CRend handle */ + const hrtfFileReader *hrtfReader, /* i : pointer to hrtfFileReader handle */ + int32_t output_Fs /* i : Output sampling frequency */ ); -- GitLab From 2fe15be677e669d460d093f3bf78e55ef009facc Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 30 Mar 2023 13:17:49 +0200 Subject: [PATCH 09/23] - define ivas_hrtf_init() globally instead of twice as local - comments --- lib_rend/ivas_crend.c | 31 ++++++++++++---------- lib_rend/ivas_prot_rend.h | 39 ++++++++++++++-------------- lib_util/hrtf_file_reader.c | 51 ++++--------------------------------- 3 files changed, 43 insertions(+), 78 deletions(-) diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index c05ae7c262..b3798ec248 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -53,7 +53,7 @@ * Initialize hHrtf handle *------------------------------------------------------------------------*/ -static ivas_error ivas_hrtf_init( +ivas_error ivas_hrtf_init( HRTFS_DATA *hHrtf /* i/o: HRTF handle */ ) { @@ -105,6 +105,7 @@ static ivas_error ivas_hrtf_open( ) { HRTFS_HANDLE hHrtf; + ivas_error error; if ( *hHrtf_out == NULL ) { @@ -113,7 +114,10 @@ static ivas_error ivas_hrtf_open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR decoder\n" ); } - ivas_hrtf_init( hHrtf ); + if ( ( error = ivas_hrtf_init( hHrtf ) ) != IVAS_ERR_OK ) + { + return error; + } *hHrtf_out = hHrtf; } @@ -1098,15 +1102,16 @@ static ivas_error ivas_rend_crendConvolver( *-----------------------------------------------------------------------------------------*/ ivas_error ivas_rend_crendProcess( - const CREND_WRAPPER *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - DECODER_CONFIG_HANDLE hDecoderConfig, - HEAD_TRACK_DATA_HANDLE hHeadTrackData, - IVAS_OUTPUT_SETUP_HANDLE hIntSetup, - EFAP_HANDLE hEFAPdata, - float output[][L_FRAME48k], /* i/o: input/output audio channels */ - const int32_t output_Fs ) + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ + const HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : Head tracking data structure */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ + float output[][L_FRAME48k], /* i/o: input/output audio channels */ + const int32_t output_Fs /* i : ouput sampling rate */ +) { int16_t i, subframe_idx, output_frame, subframe_len; int16_t nchan_out; @@ -1135,10 +1140,9 @@ ivas_error ivas_rend_crendProcess( subframe_len = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ ) { + /* Rotation */ if ( hDecoderConfig && hDecoderConfig->Opt_Headrotation && hHeadTrackData && hHeadTrackData->num_quaternions >= 0 ) { - /* Orientation tracking */ - /* Rotation in SHD for: MC with elevation (5_1_2 / 5_1_4 / 7_1_4) -> BINAURAL SBA SPAR -> BINAURAL or BINAURAL_ROOM @@ -1154,6 +1158,7 @@ ivas_error ivas_rend_crendProcess( } } + /* Reverberation */ if ( ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) || ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) ) { if ( ( error = ivas_rend_crendConvolver( pCrend, inRendConfig, outRendConfig, output, pcm_tmp, output_Fs, subframe_idx ) ) != IVAS_ERR_OK ) diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 22c0afc6b6..15ad75596a 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -182,8 +182,12 @@ void ivas_HRTF_binary_close( TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ ); +ivas_error ivas_hrtf_init( + HRTFS_DATA *hHrtf /* i/o: HRTF handle */ +); + ivas_error ivas_HRTF_fastconv_binary_open( - HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ + HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ ); void ivas_HRTF_fastconv_binary_close( @@ -486,20 +490,17 @@ ivas_error ivas_rend_initCrendWrapper( CREND_WRAPPER_HANDLE *pCrend ); ivas_error ivas_rend_crendProcess( - const CREND_WRAPPER *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - DECODER_CONFIG_HANDLE hDecoderConfig, - HEAD_TRACK_DATA_HANDLE hHeadTrackData, - IVAS_OUTPUT_SETUP_HANDLE hIntSetup, - EFAP_HANDLE hEFAPdata, - float output[][L_FRAME48k], /* i/o: input/output audio channels */ - const int32_t output_Fs + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ + const HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : Head tracking data structure */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ + float output[][L_FRAME48k], /* i/o: input/output audio channels */ + const int32_t output_Fs /* i : ouput sampling rate */ ); - - - ivas_error ivas_crend_init_from_rom( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); @@ -747,18 +748,18 @@ void ivas_reverb_get_hrtf_set_properties( *-----------------------------------------------------------------------------------*/ ivas_error ivas_headTrack_open( - HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */ + HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */ ); void ivas_headTrack_close( - HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* i/o: head track handle */ + HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* i/o: head track handle */ ); void Euler2Quat( - const float yaw, /* i : yaw (x) */ - const float pitch, /* i : pitch (y) */ - const float roll, /* i : roll (z) */ - IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ + const float yaw, /* i : yaw (x) */ + const float pitch, /* i : pitch (y) */ + const float roll, /* i : roll (z) */ + IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ ); float deg2rad( float degrees ); diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index de16986b99..7dfa2e7cf0 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -674,51 +674,6 @@ ivas_error dealloc_HRTF_binary( } -/*------------------------------------------------------------------------- - * ivas_hrtf_init() - * - * Initialize hHRTF handle - *------------------------------------------------------------------------*/ - -static ivas_error ivas_hrtf_init( - HRTFS_DATA *hHRTF /* i/o: HRTF handle */ -) -{ - int16_t i, j; - - if ( hHRTF == NULL ) - { - return IVAS_ERR_WRONG_PARAMS; - } - - hHRTF->latency_s = 0; - hHRTF->max_num_ir = 0; - hHRTF->max_num_iterations = 0; - hHRTF->index_frequency_max_diffuse = 0; - - for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) - { - hHRTF->inv_diffuse_weight[i] = 0; - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHRTF->num_iterations[i][j] = 0; - hHRTF->pIndex_frequency_max[i][j] = NULL; - hHRTF->pOut_to_bin_re[i][j] = NULL; - hHRTF->pOut_to_bin_im[i][j] = NULL; - } - } - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHRTF->num_iterations_diffuse[j] = 0; - hHRTF->pIndex_frequency_max_diffuse[j] = NULL; - hHRTF->pOut_to_bin_diffuse_re[j] = NULL; - hHRTF->pOut_to_bin_diffuse_im[j] = NULL; - } - - return IVAS_ERR_OK; -} - - /*---------------------------------------------------------------------* * create_HRTF_from_rawdata() * @@ -736,6 +691,7 @@ static ivas_error create_HRTF_from_rawdata( uint32_t mem_size; char *hrtf_data_rptr; float *pOut_to_bin_wptr; + ivas_error error; if ( *hHRTF == NULL ) { @@ -744,7 +700,10 @@ static ivas_error create_HRTF_from_rawdata( return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Can not allocate memory for HRTF binary data\n" ); } - ivas_hrtf_init( *hHRTF ); + if ( ( error = ivas_hrtf_init( *hHRTF ) ) != IVAS_ERR_OK ) + { + return error; + } } else { -- GitLab From 058b855fed3eeeb306bb9d6386846524ecc99593 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 11 Apr 2023 12:23:49 +0200 Subject: [PATCH 10/23] formal improvements --- lib_com/ivas_prot.h | 4 ++- lib_dec/ivas_sba_dirac_stereo_dec.c | 5 ++-- lib_dec/ivas_sba_rendering_internal.c | 1 + lib_rend/ivas_dirac_dec_binaural_functions.c | 27 ++++++++++---------- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index f1c04f0b53..2a1eb91159 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3287,6 +3287,7 @@ void ivas_sba_getTCs( const int16_t input_frame /* i : frame length */ ); +/*! r: number of remapped SBA TCs */ int16_t ivas_sba_remapTCs( float sba_data[][L_FRAME48k], /* i/o: SBA signals */ Decoder_Struct *st_ivas, /* i/o: decoder struct */ @@ -3305,8 +3306,9 @@ void ivas_sba_dirac_stereo_config( ); #ifdef SBA2MONO +/*! r: SBA DirAC stereo flag */ int16_t ivas_get_sba_dirac_stereo_flag( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ ); #endif diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c index 82ccaceea9..7019131d6e 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -52,8 +52,9 @@ * Set sba_dirac_stereo_flag *-------------------------------------------------------------------*/ +/*! r: SBA DirAC stereo flag */ int16_t ivas_get_sba_dirac_stereo_flag( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ ) { int16_t sba_dirac_stereo_flag; @@ -92,7 +93,7 @@ int16_t ivas_get_sba_dirac_stereo_flag( *-------------------------------------------------------------------*/ void ivas_sba_dirac_stereo_config( - STEREO_DFT_CONFIG_DATA_HANDLE hConfig /* o : DFT stereo configuration */ + STEREO_DFT_CONFIG_DATA_HANDLE hConfig /* o : DFT stereo configuration */ ) { if ( hConfig != NULL ) diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index a80986b39e..7f21ba630f 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -215,6 +215,7 @@ void ivas_mc2sba( * Get TCs from Ambisonics signal in ACN *-------------------------------------------------------------------*/ +/*! r: number of remapped SBA TCs */ int16_t ivas_sba_remapTCs( float sba_data[][L_FRAME48k], /* i/o: SBA signals */ Decoder_Struct *st_ivas, /* i/o: decoder struct */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 09704b969e..1cdd904602 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -103,7 +103,7 @@ static void matrixMul( float Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Ai static void matrixTransp2Mul( float Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] ); #ifdef NOKIA_PARAMBIN_REQULARIZATION -static float configure_reqularization_factor( const IVAS_FORMAT ivas_format, const int32_t ivas_brate ); +static float configure_reqularization_factor( const IVAS_FORMAT ivas_format, const int32_t ivas_total_brate ); #endif /*------------------------------------------------------------------------- @@ -2099,35 +2099,36 @@ static void hrtfShGetHrtf( /*! r: Configured reqularization factor value to be set. */ static float configure_reqularization_factor( - const IVAS_FORMAT ivas_format, /* i: IVAS codec format in use */ - const int32_t ivas_brate ) /* i: Current IVAS bitrate */ + const IVAS_FORMAT ivas_format, /* i : IVAS codec format in use */ + const int32_t ivas_total_brate /* i : IVAS total bitrate */ +) { float reqularizationFactor; reqularizationFactor = 1.0f; /* Default value */ if ( ivas_format == MASA_FORMAT ) { - if ( ivas_brate >= IVAS_256k ) + if ( ivas_total_brate >= IVAS_256k ) { reqularizationFactor = 0.2f; } - else if ( ivas_brate == IVAS_192k ) + else if ( ivas_total_brate == IVAS_192k ) { reqularizationFactor = 0.3f; } - else if ( ivas_brate == IVAS_160k ) + else if ( ivas_total_brate == IVAS_160k ) { reqularizationFactor = 0.4f; } - else if ( ivas_brate == IVAS_128k ) + else if ( ivas_total_brate == IVAS_128k ) { reqularizationFactor = 0.5f; } - else if ( ivas_brate == IVAS_96k ) + else if ( ivas_total_brate == IVAS_96k ) { reqularizationFactor = 0.6f; } - else if ( ivas_brate >= IVAS_64k ) + else if ( ivas_total_brate >= IVAS_64k ) { reqularizationFactor = 0.8f; } @@ -2139,19 +2140,19 @@ static float configure_reqularization_factor( if ( ivas_format == MC_FORMAT ) /* This is always McMASA for parametric binauralizer. */ { - if ( ivas_brate >= IVAS_96k ) + if ( ivas_total_brate >= IVAS_96k ) { reqularizationFactor = 0.3f; } - else if ( ivas_brate >= IVAS_80k ) + else if ( ivas_total_brate >= IVAS_80k ) { reqularizationFactor = 0.5f; } - else if ( ivas_brate >= IVAS_64k ) + else if ( ivas_total_brate >= IVAS_64k ) { reqularizationFactor = 0.7f; } - else if ( ivas_brate >= IVAS_48k ) + else if ( ivas_total_brate >= IVAS_48k ) { reqularizationFactor = 0.8f; } -- GitLab From 3c15228a1f6c03e21c47aae66758134e3aaf227f Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 18 Apr 2023 10:05:22 +0200 Subject: [PATCH 11/23] fix typos in comments --- lib_com/prot.h | 4 ++-- lib_dec/FEC_clas_estim.c | 3 +-- lib_enc/FEC_enc.c | 3 +-- lib_enc/set_impulse.c | 8 ++++---- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib_com/prot.h b/lib_com/prot.h index 65846708ef..7c6584f6e1 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -3932,7 +3932,7 @@ void set_impulse( float exc[], /* o : adaptive codebook excitation */ float y1[], /* o : filtered adaptive codebook excitation */ int16_t *imp_shape, /* o : adaptive codebook index */ - int16_t *imp_pos, /* o : position of the glotal impulse center index */ + int16_t *imp_pos, /* o : position of the glottal impulse center index */ float *gain_trans /* o : transition gain */ ); @@ -4893,7 +4893,7 @@ void FEC_encode( int16_t FEC_pos_dec( Decoder_State *st, /* i/o: decoder state structure */ - int16_t *last_pulse_pos, /* o : Last glotal pulse position in the lost ACB */ + int16_t *last_pulse_pos, /* o : Last glottal pulse position in the lost ACB */ float *enr_q, /* o : Decoded energy */ const int16_t nBits_es_Pred /* i : number of bits for Es_pred Q */ ); diff --git a/lib_dec/FEC_clas_estim.c b/lib_dec/FEC_clas_estim.c index 4acd3dab9c..81175471d6 100644 --- a/lib_dec/FEC_clas_estim.c +++ b/lib_dec/FEC_clas_estim.c @@ -735,10 +735,9 @@ static void FEC_classificationMusic( int16_t FEC_pos_dec( Decoder_State *st, /* i/o: decoder state structure */ - int16_t *last_pulse_pos, /* o : last glotal pulse position in the lost ACB */ + int16_t *last_pulse_pos, /* o : last glottal pulse position in the lost ACB */ float *enr_q, /* o : decoded energy */ const int16_t nBits_es_Pred /* i : number of bits for Es_pred Q */ - ) { int16_t pitch_index, T0, T0_frac, T0_min, T0_max; diff --git a/lib_enc/FEC_enc.c b/lib_enc/FEC_enc.c index 5bf8d1f1f4..9b753c97b8 100644 --- a/lib_enc/FEC_enc.c +++ b/lib_enc/FEC_enc.c @@ -133,8 +133,7 @@ void FEC_encode( { /* retrieve the last glottal pulse position of the previous frame */ /* use the current pitch information to scale or not the quantization */ - tmp_FER_pitch = (int16_t) ( fpit[0] ); /* take the 1st subframe pitch, since it is easier to retieve it on decoder side */ - + tmp_FER_pitch = (int16_t) ( fpit[0] ); /* take the 1st subframe pitch, since it is easier to retrieve it on decoder side */ sign = 0; maxi = *last_pulse_pos; diff --git a/lib_enc/set_impulse.c b/lib_enc/set_impulse.c index 4cafeea9e8..2c8a7fdd08 100644 --- a/lib_enc/set_impulse.c +++ b/lib_enc/set_impulse.c @@ -61,10 +61,10 @@ static void convolve_tc2( const float g[], const float h[], float y[], const int /*---------------------------------------------------------------------------------------* * Function set_impulse() for TC * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - * Builds glottal codebook contribution based on glotal impulses positions finding. * + * Builds glottal codebook contribution based on glottal impulses positions finding. * * * - * Returns a position of the glotal impulse center and * - * a number of the glotal impulse shape. * + * Returns a position of the glottal impulse center and * + * a number of the glottal impulse shape. * * * * |----| |----| xn * * imp_pos-> || | imp_shape-> | g1 | | * @@ -89,7 +89,7 @@ void set_impulse( float exc[], /* o : adaptive codebook excitation */ float y1[], /* o : filtered adaptive codebook excitation */ int16_t *imp_shape, /* o : adaptive codebook index */ - int16_t *imp_pos, /* o : position of the glotal impulse center index */ + int16_t *imp_pos, /* o : position of the glottal impulse center index */ float *gain_trans /* o : transition gain */ ) { -- GitLab From 47f0d92024d82e5ac20520d67de2ac19e084eb35 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 18 Apr 2023 10:19:24 +0200 Subject: [PATCH 12/23] avoid ternary operator in ivas_core_dec() --- lib_dec/ivas_core_dec.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 05c1f41727..d1beb443dc 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -93,12 +93,13 @@ ivas_error ivas_core_dec( int16_t last_element_mode; int16_t nchan_out; float *save_hb_synth; + IVAS_FORMAT ivas_format; ivas_error error; - error = IVAS_ERR_OK; - push_wmops( "ivas_core_dec" ); + error = IVAS_ERR_OK; + /*------------------------------------------------------------------* * General initialization *-----------------------------------------------------------------*/ @@ -106,6 +107,12 @@ ivas_error ivas_core_dec( use_cldfb_for_dft = 0; tdm_LRTD_flag = -1; + ivas_format = UNDEFINED_FORMAT; + if ( st_ivas != NULL ) + { + ivas_format = st_ivas->ivas_format; + } + if ( hSCE != NULL ) { sts = hSCE->hCoreCoder; @@ -218,7 +225,7 @@ ivas_error ivas_core_dec( } /* n_channels loop */ /* MDCT stereo -> DFT stereo switching */ - if ( hCPE != NULL && hCPE->last_element_mode == IVAS_CPE_MDCT && hCPE->element_mode == IVAS_CPE_DFT ) + if ( last_element_mode == IVAS_CPE_MDCT && sts[0]->element_mode == IVAS_CPE_DFT ) { int16_t ovl, fade_len; if ( sts[0]->L_frame != sts[0]->last_L_frame ) @@ -341,7 +348,7 @@ ivas_error ivas_core_dec( if ( ( st->core == TCX_20_CORE || st->core == TCX_10_CORE ) && st->element_mode != IVAS_CPE_MDCT ) { /* TCX decoder */ - stereo_tcx_core_dec( st, frameMode[n], output[n], synth[n], pitch_buf[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hCPE == NULL ? NULL : hCPE->hStereoCng, nchan_out, st_ivas == NULL ? 0 : st_ivas->ivas_format + stereo_tcx_core_dec( st, frameMode[n], output[n], synth[n], pitch_buf[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hCPE == NULL ? NULL : hCPE->hStereoCng, nchan_out, ivas_format #ifndef DISCRETE_ISM_DTX_CNG , st_ivas == NULL ? 0 : st_ivas->ism_mode @@ -452,9 +459,9 @@ ivas_error ivas_core_dec( } #ifdef FIX_ISM_DTX_CLICKS - if ( ( error = core_switching_post_dec( st, synth[n], output[n], p_output_mem, ( st_ivas != NULL ) ? st_ivas->ivas_format : UNDEFINED_FORMAT, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, ( hCPE != NULL ) ? hCPE->last_element_mode : IVAS_SCE ) ) != IVAS_ERR_OK ) + if ( ( error = core_switching_post_dec( st, synth[n], output[n], p_output_mem, ivas_format, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode ) ) != IVAS_ERR_OK ) #else - if ( ( error = core_switching_post_dec( st, synth[n], output[n], p_output_mem, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, ( hCPE != NULL ) ? hCPE->last_element_mode : IVAS_SCE ) ) != IVAS_ERR_OK ) + if ( ( error = core_switching_post_dec( st, synth[n], output[n], p_output_mem, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode ) ) != IVAS_ERR_OK ) #endif { return error; @@ -468,7 +475,7 @@ ivas_error ivas_core_dec( } /* if we transition from inactive to active coding in MDCT-Stereo DTX and the output format is mono DMX, we need to sync the upsampled buffer between channels here */ - if ( n == 0 && st->element_mode == IVAS_CPE_MDCT && st->last_core == ACELP_CORE && st->core != ACELP_CORE && ( nchan_out == 1 || ( hCPE != NULL && hCPE->last_element_mode == IVAS_CPE_DFT ) ) ) + if ( n == 0 && st->element_mode == IVAS_CPE_MDCT && st->last_core == ACELP_CORE && st->core != ACELP_CORE && ( nchan_out == 1 || last_element_mode == IVAS_CPE_DFT ) ) { mvr2r( sts[0]->previoussynth, sts[1]->previoussynth, st->hTcxDec->L_frameTCX ); } @@ -598,7 +605,7 @@ ivas_error ivas_core_dec( /* Smooth transitions when switching between different technologies */ if ( !( ( st->core == TCX_20_CORE || st->core == TCX_10_CORE || st->core == HQ_CORE ) && st->last_core == ACELP_CORE ) && - ( st->extl != st->last_extl || ( st->extl == st->last_extl && ( st->core ^ st->last_core ) == HQ_CORE ) ) && !( st->extl == SWB_CNG && st->last_extl == SWB_TBE ) && ( st->element_mode != IVAS_CPE_TD || ( hCPE->element_mode == IVAS_CPE_TD && tdm_LRTD_flag ) ) ) + ( st->extl != st->last_extl || ( st->extl == st->last_extl && ( st->core ^ st->last_core ) == HQ_CORE ) ) && !( st->extl == SWB_CNG && st->last_extl == SWB_TBE ) && ( st->element_mode != IVAS_CPE_TD || ( st->element_mode == IVAS_CPE_TD && tdm_LRTD_flag ) ) ) { /* switching between BWE and TBE technologies */ incr = (int16_t) ( L_FRAME / ( tmps + 0.5f ) ); @@ -644,7 +651,7 @@ ivas_error ivas_core_dec( } 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 ) ) + || ( st->element_mode == IVAS_CPE_TD && tdm_LRTD_flag ) ) { /* Delay hb_synth */ delay_signal( hb_synth[n], output_frame, st->hb_prev_synth_buffer, tmps ); @@ -697,7 +704,7 @@ ivas_error ivas_core_dec( } else /* IVAS_CPE_DFT */ { - if ( hCPE->last_element_mode == IVAS_CPE_MDCT ) + if ( last_element_mode == IVAS_CPE_MDCT ) { stereo_mdct2dft_update( hCPE, output[0], synth[0] ); } -- GitLab From 66fd6f10e3476852374d634c99ea9f01929d388d Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 18 Apr 2023 16:10:05 +0200 Subject: [PATCH 13/23] remove obsolete ToDo comment + formatting --- lib_dec/dec_tcx.c | 4 ++-- lib_enc/ivas_masa_enc.c | 4 ++-- lib_rend/lib_rend.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index fbdd150217..491ae60a81 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -344,7 +344,7 @@ void IMDCT( || st->mct_chan_mode == MCT_CHAN_MODE_LFE #endif ) && - ( st->tcxonly ) ) + st->tcxonly ) { /* Mode decision in PLC @@ -573,7 +573,7 @@ void IMDCT( || st->mct_chan_mode == MCT_CHAN_MODE_LFE #endif ) && - ( st->tcxonly ) ) || + st->tcxonly ) || ( hTcxCfg->tcx_last_overlap_mode == TRANSITION_OVERLAP ) ) { if ( !bfi && ( frame_cnt > 0 ) && ( index == 0 ) && ( hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP ) && ( st->last_core != ACELP_CORE ) ) diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index fbb7af9ab4..c18aeb9ce4 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -1976,11 +1976,12 @@ static void copy_masa_metadata( * Compare the similarity of MASA metadata in two sub-frames *-------------------------------------------------------------------*/ +/* r: similarity decision */ static uint8_t are_masa_subframes_similar( const MASA_METADATA_HANDLE frame1, /* i : MASA metadata frame 1 */ const uint8_t sf1_idx, /* i : index of the subframe of frame1 to inspect */ const MASA_METADATA_HANDLE frame2, /* i : MASA metadata frame 2 */ - const uint8_t sf2_idx /* o : index of the subframe of frame2 to inspect */ + const uint8_t sf2_idx /* i : index of the subframe of frame2 to inspect */ ) { uint8_t num_dir; @@ -2054,7 +2055,6 @@ static uint8_t are_masa_subframes_similar( } } - /* TODO: a nicer negation */ // VE: ?? if ( sf_differ ) { return FALSE; diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index ec4c05a6d6..32efc2bcb7 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -228,9 +228,9 @@ 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 */ #ifdef FIX_392_LATE_REVERB - const IVAS_REND_AudioConfig outAudioConfig /* i : output audioConfig */ + const IVAS_REND_AudioConfig outAudioConfig /* i : output audioConfig */ #else const bool rendererConfigEnabled /* i : flag indicating if a renderer configuration file was supplied */ #endif -- GitLab From d8c90254c30ad562539251ddae2b78a9caf4d772 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 25 Apr 2023 09:57:11 +0200 Subject: [PATCH 14/23] comments, formatting --- lib_com/ivas_rom_com.c | 79 ++++++++++++++++++++++++------------ lib_com/ivas_rom_com.h | 1 + lib_dec/ivas_sns_dec.c | 10 +++++ lib_enc/ivas_mdct_core_enc.c | 3 +- lib_enc/ivas_sns_enc.c | 8 ++++ 5 files changed, 73 insertions(+), 28 deletions(-) diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 6677b53a9f..91dce4dc69 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -5554,12 +5554,18 @@ const int16_t ivas_num_active_bands[FB - WB + 1] = IVAS_16K_12BANDS_ACTIVE_BANDS, IVAS_FB_BANDS_12, IVAS_FB_BANDS_12 }; + #ifdef SNS_MSVQ +/*------------------------------------------------------------------------------------------* + * SNS MSVQ codebooks and means + *------------------------------------------------------------------------------------------*/ + const int16_t ivas_sns_cdbks_tcx20_levels[SNS_MSVQ_NSTAGES_TCX20] = { 128, 64, 32, 32 }; const int16_t ivas_sns_cdbks_tcx20_bits[SNS_MSVQ_NSTAGES_TCX20] = { 7, 6, 5, 5 }; /* codebooks trained for no adaptive tilt */ -const float ivas_sns_cdbk_tcx20_stage1[ 128 * 16 ] = { +const float ivas_sns_cdbk_tcx20_stage1[ 128 * 16 ] = +{ -3.24881770f, -1.99497051f, -0.04725080f, 1.02318508f, 1.51589220f, 1.44649178f, 1.27858728f, 1.15137095f, 0.98029724f, 0.69167126f, 0.33414576f, 0.11759238f, -0.27510520f, -0.63610342f, -1.05394049f, -1.28304590f, -3.24340413f, -4.15075396f, -2.86242117f, -1.11561919f, 1.12899983f, 1.98341478f, 0.56638511f, -0.05841474f, -0.14875192f, 0.31098029f, 1.87121037f, 0.91347082f, 1.02548459f, 1.98227488f, 1.30278860f, 0.49435585f, 1.23065598f, 0.87793778f, 0.28294330f, 0.02972172f, 0.42574775f, 0.83386805f, 0.95758438f, 1.21299710f, 1.15042593f, 1.00234403f, 0.60083169f, -0.06520030f, -1.53941239f, -2.26801783f, -2.42116011f, -2.31126766f, @@ -5689,7 +5695,9 @@ const float ivas_sns_cdbk_tcx20_stage1[ 128 * 16 ] = { 2.58466208f, 2.01534437f, 1.28252767f, 0.44865967f, -0.33100837f, -0.81011259f, -1.06701187f, -1.12743988f, -1.21505758f, -0.99337144f, -0.66853937f, -0.46093443f, -0.22132067f, 0.00996599f, 0.24481197f, 0.30882455f, -0.62864502f, 1.04984327f, 1.56877053f, 0.77975000f, 0.01037804f, 0.92352492f, 1.12297462f, 0.76284403f, -0.16106015f, -0.21398417f, -0.62673537f, -1.68917053f, -1.60748063f, -0.79116243f, -0.06290217f, -0.43694470f }; -const float ivas_sns_cdbk_tcx20_stage2[ 64 * 16 ] = { + +const float ivas_sns_cdbk_tcx20_stage2[ 64 * 16 ] = +{ -0.14487037f, 0.32346300f, 0.29798679f, -0.52393127f, -0.25671033f, 0.85717754f, -0.09030235f, -0.41110330f, -0.32938564f, -0.36580017f, -0.13142117f, -0.06404494f, 0.10671000f, 0.18731030f, 0.26606878f, 0.27885301f, 0.52707061f, 0.35016312f, 0.54090507f, 0.82023896f, 0.46675870f, -0.60012182f, -0.76783382f, -0.39198749f, -0.17916696f, -0.17307722f, -0.10507731f, -0.09327542f, -0.12176361f, -0.12715624f, -0.11980175f, -0.02587481f, -0.71420988f, -0.65927011f, -0.35007906f, -0.01478187f, 0.15375095f, 0.11149616f, 0.08819131f, 0.11537168f, 0.18041243f, 0.28846009f, 0.61920238f, 0.78709602f, 0.49945852f, -0.03863360f, -0.42339912f, -0.64306599f, @@ -5755,7 +5763,9 @@ const float ivas_sns_cdbk_tcx20_stage2[ 64 * 16 ] = { -0.42321919f, 0.85086362f, 0.60159420f, 0.08633772f, -0.28445894f, -0.22512885f, 0.23909004f, 0.20046697f, 0.01484137f, -0.11652413f, -0.12017169f, -0.26922922f, -0.26311675f, -0.18921524f, -0.06712212f, -0.03500777f, 0.58209071f, -0.26533411f, -0.20240535f, 0.27577532f, 0.65478295f, 0.66491349f, 0.41026256f, 0.22123940f, 0.15813271f, 0.07048989f, -0.03133192f, -0.19389440f, -0.34519672f, -0.53017394f, -0.73238212f, -0.73696843f }; -const float ivas_sns_cdbk_tcx20_stage3[ 32 * 16 ] = { + +const float ivas_sns_cdbk_tcx20_stage3[ 32 * 16 ] = +{ -0.08443224f, -0.18703635f, -0.02297765f, 0.35108322f, -0.47365404f, 0.60080101f, -0.14560352f, 0.01413276f, 0.01222370f, 0.01369841f, 0.05509108f, 0.03233707f, 0.01187713f, -0.08225931f, -0.08910713f, -0.00617424f, -0.45134081f, -0.18205893f, -0.21886586f, -0.27082278f, -0.18872267f, -0.08438255f, 0.11808124f, 0.11472340f, 0.08049694f, 0.05868671f, 0.08856118f, 0.10686811f, 0.14792971f, 0.16522330f, 0.21823435f, 0.29738868f, -0.11328915f, 0.10130429f, -0.14943437f, 0.15645630f, 0.63935450f, 0.37821704f, -0.21310801f, -0.24867988f, -0.01659672f, 0.03328198f, -0.08180066f, -0.05657044f, 0.10906149f, 0.03196869f, -0.22137928f, -0.34878580f, @@ -5789,7 +5799,9 @@ const float ivas_sns_cdbk_tcx20_stage3[ 32 * 16 ] = { 0.19660049f, -0.03582845f, -0.21224511f, -0.09633821f, 0.02140122f, 0.06690902f, 0.14753796f, 0.23491232f, 0.40075372f, 0.33318442f, -0.21453422f, -0.44835823f, -0.31995723f, -0.14770359f, -0.02720588f, 0.10087175f, 0.22313452f, 0.23174662f, 0.13588360f, -0.01979092f, -0.17483898f, -0.36387601f, -0.35104947f, -0.34545228f, -0.17072761f, 0.01654692f, 0.12560464f, 0.14070090f, 0.18025650f, 0.13082045f, 0.10588357f, 0.13515746f }; -const float ivas_sns_cdbk_tcx20_stage4[ 32 * 16 ] = { + +const float ivas_sns_cdbk_tcx20_stage4[ 32 * 16 ] = +{ -0.01178932f, -0.08216325f, 0.00009975f, 0.07861932f, 0.10639093f, 0.10607783f, -0.11972309f, 0.01910820f, -0.05635505f, 0.02765448f, -0.08840101f, -0.09623400f, 0.34917350f, -0.19835894f, -0.46938213f, 0.43528268f, -0.08636054f, 0.13923351f, -0.15932705f, -0.10849641f, -0.02303533f, -0.23968519f, -0.02192257f, 0.50128910f, 0.27139459f, -0.07262939f, -0.06622134f, -0.01073419f, -0.04308095f, -0.05629457f, -0.03175020f, 0.00762044f, 0.24815560f, 0.14657944f, 0.07172491f, 0.02302382f, 0.01991109f, -0.10204469f, -0.24960876f, -0.07085594f, 0.12223419f, 0.06999865f, 0.10986748f, 0.13492392f, 0.05865008f, -0.10366906f, -0.23987720f, -0.23901358f, @@ -5826,7 +5838,8 @@ const float ivas_sns_cdbk_tcx20_stage4[ 32 * 16 ] = { const float *const ivas_sns_cdbks_tcx20[SNS_MSVQ_NSTAGES_TCX20] = { ivas_sns_cdbk_tcx20_stage1, ivas_sns_cdbk_tcx20_stage2, ivas_sns_cdbk_tcx20_stage3, ivas_sns_cdbk_tcx20_stage4 }; -const float ivas_sns_means_tcx20[M] = { +const float ivas_sns_means_tcx20[M] = +{ 0.9155f , 1.2408f , 1.0050f , 0.5846f, 0.2472f , 0.1902f , 0.0984f , 0.1039f, -0.0139f , -0.0856f , -0.4157f , -0.6148f, @@ -5836,7 +5849,8 @@ const float ivas_sns_means_tcx20[M] = { const int16_t ivas_sns_cdbks_tcx10_levels[SNS_MSVQ_NSTAGES_TCX10] = { 128, 32, 8 }; const int16_t ivas_sns_cdbks_tcx10_bits[SNS_MSVQ_NSTAGES_TCX10] = { 7, 5, 3 }; -const float ivas_sns_cdbk_tcx10_stage1[ 128 * 16 ] = { +const float ivas_sns_cdbk_tcx10_stage1[ 128 * 16 ] = +{ 0.06343891f, -0.00651786f, -0.56994713f, -0.98772396f, -1.35099293f, -1.24848646f, -1.20301995f, -0.81089507f, -0.06563095f, 1.11147581f, 1.73933309f, 1.65859611f, 1.26237806f, 0.68028141f, 0.12449909f, -0.39678907f, -1.34007175f, -1.50272189f, -2.07958791f, -2.38322761f, -2.22156614f, -1.96435669f, -1.68760863f, -1.23664935f, -0.28772180f, 0.87765579f, 1.83822720f, 1.95281398f, 2.33671266f, 2.76119687f, 2.75790597f, 2.17899850f, -0.51450332f, 0.69692757f, 1.90898730f, 1.89179379f, 1.41350404f, 0.03604267f, 0.02251128f, -1.04270018f, -0.97981089f, -0.36225564f, 0.14171617f, -0.32050715f, -0.56272675f, -0.38710633f, -0.74842203f, -1.19345103f, @@ -5966,7 +5980,9 @@ const float ivas_sns_cdbk_tcx10_stage1[ 128 * 16 ] = { 2.30575156f, 2.37005513f, 1.37776397f, 0.78509487f, 0.18022242f, -0.13093354f, 0.22126477f, -0.11444642f, -0.35716968f, -0.59492665f, -0.35765935f, -0.44655201f, -1.03213345f, -1.27074059f, -1.44000075f, -1.49558947f, -1.00874079f, -1.64011865f, -1.86084729f, -1.06805908f, 0.07222945f, 1.36179475f, 1.87160360f, 1.76248472f, 1.52374330f, 1.04119855f, 0.73448166f, 0.13768018f, -0.49711929f, -0.73696841f, -0.89885406f, -0.79450886f }; -const float ivas_sns_cdbk_tcx10_stage2[ 32 * 16 ] = { + +const float ivas_sns_cdbk_tcx10_stage2[ 32 * 16 ] = +{ 0.30627323f, 0.48836579f, -0.02716944f, -0.47680077f, -0.52992614f, -0.25467720f, -0.13298242f, -0.14929291f, -0.14808149f, 0.08665801f, 0.28830653f, 0.27526330f, 0.09942358f, -0.01755061f, 0.03315580f, 0.15903469f, 0.40931263f, -0.04412117f, -0.08826419f, 0.38716891f, 0.51515595f, 0.42227845f, 0.34963425f, 0.26800736f, 0.03770000f, -0.19967080f, -0.31044249f, -0.32623294f, -0.38445978f, -0.38085950f, -0.38590829f, -0.26929836f, -0.16037262f, -0.37557223f, -0.41481262f, -0.12384627f, 0.25702942f, 0.29593484f, 0.04534352f, -0.04349856f, -0.11439445f, -0.20184919f, 0.03250628f, 0.58473249f, 1.07468564f, 0.31789485f, -0.43837532f, -0.73540590f, @@ -6000,7 +6016,9 @@ const float ivas_sns_cdbk_tcx10_stage2[ 32 * 16 ] = { -0.78143464f, 0.05520810f, 0.09851993f, -0.35088396f, -0.29183273f, 0.13535467f, 0.10630173f, -0.35151176f, -0.27502696f, 0.15923208f, 0.34325564f, 0.26263384f, 0.39924614f, 0.42088604f, 0.20935571f, -0.13930422f, -0.20363163f, -0.21557857f, -0.16300691f, -0.04183005f, -0.11100316f, -0.05771045f, 0.03898740f, 0.01316220f, 0.17362802f, 0.74914331f, 0.94477958f, 0.44778038f, -0.09421183f, -0.32736334f, -0.50631884f, -0.64682642f }; -const float ivas_sns_cdbk_tcx10_stage3[ 8 * 16 ] = { + +const float ivas_sns_cdbk_tcx10_stage3[ 8 * 16 ] = +{ 0.15213764f, -0.12778955f, 0.09362990f, -0.08343056f, -0.25379718f, 0.12518895f, 0.29943288f, -0.09857322f, -0.34816031f, -0.24349585f, -0.11266650f, -0.05996015f, 0.03254247f, 0.15532134f, 0.23410563f, 0.23551447f, -0.16242282f, -0.11097776f, -0.31747514f, -0.25628076f, 0.13836003f, 0.29861681f, 0.10506779f, 0.11734717f, 0.26608658f, 0.05454060f, -0.14603348f, -0.19239843f, 0.04173306f, 0.20966631f, 0.07432020f, -0.12015035f, -0.05086737f, 0.14763099f, -0.10027459f, -0.32093478f, -0.17515530f, -0.18641303f, -0.27141947f, -0.07787662f, 0.00378069f, -0.04285463f, 0.10140687f, 0.34974771f, 0.30832793f, 0.10107726f, 0.07691200f, 0.13691240f, @@ -6013,11 +6031,12 @@ const float ivas_sns_cdbk_tcx10_stage3[ 8 * 16 ] = { const float *const ivas_sns_cdbks_tcx10[SNS_MSVQ_NSTAGES_TCX10] = { ivas_sns_cdbk_tcx10_stage1, ivas_sns_cdbk_tcx10_stage2, ivas_sns_cdbk_tcx10_stage3}; -const float ivas_sns_means_tcx10[M] = { - 0.9510f , 1.1892f , 0.8969f , 0.3467f, - 0.1347f , 0.1074f , 0.0504f , -0.0790f, - -0.1305f , -0.3713f , -0.5611f , -0.5757f, - -0.4801f , -0.4108f , -0.4564f , -0.6112f +const float ivas_sns_means_tcx10[M] = +{ + 0.9510f, 1.1892f, 0.8969f, 0.3467f, + 0.1347f, 0.1074f, 0.0504f, -0.0790f, + -0.1305f, -0.3713f, -0.5611f, -0.5757f, + -0.4801f, -0.4108f, -0.4564f, -0.6112f }; const int16_t ivas_sns_cdbks_side_tcx20_levels[SNS_MSVQ_NSTAGES_SIDE] = { 32, 32 }; @@ -6025,14 +6044,16 @@ const int16_t ivas_sns_cdbks_side_tcx20_bits[SNS_MSVQ_NSTAGES_SIDE] = { 5, 5 }; const int16_t ivas_sns_cdbks_side_tcx10_levels[SNS_MSVQ_NSTAGES_SIDE] = { 32, 8 }; const int16_t ivas_sns_cdbks_side_tcx10_bits[SNS_MSVQ_NSTAGES_SIDE] = { 5, 3 }; -const float ivas_sns_means_side_tcx20[M] = { - -0.0181f , 0.0044f , 0.0133f , 0.0096f, - 0.0073f , 0.0038f , 0.0058f , 0.0015f, - -0.0046f , -0.0096f , -0.0099f , -0.0173f, - -0.0075f , 0.0049f , 0.0023f , 0.0141f +const float ivas_sns_means_side_tcx20[M] = +{ + -0.0181f, 0.0044f, 0.0133f, 0.0096f, + 0.0073f, 0.0038f, 0.0058f, 0.0015f, + -0.0046f, -0.0096f, -0.0099f, -0.0173f, + -0.0075f, 0.0049f, 0.0023f, 0.0141f }; -const float ivas_sns_cdbks_side_tcx20_stage1[ 32 * 16 ] = { +const float ivas_sns_cdbks_side_tcx20_stage1[ 32 * 16 ] = +{ -0.09561560f, -0.07036320f, 0.02878750f, 0.03511974f, 0.17132389f, -0.03138941f, -0.33178799f, -0.21216198f, -0.04445341f, 0.02221417f, 0.02283919f, 0.03233147f, 0.08941267f, 0.12190493f, 0.12476806f, 0.13706984f, 0.00109929f, 0.08875231f, 0.22238215f, 0.21457590f, 0.10015343f, 0.04638508f, 0.03393346f, -0.00874452f, -0.04376851f, -0.07742100f, -0.07534945f, -0.10337673f, -0.10407952f, -0.11112585f, -0.09133646f, -0.09207950f, -0.24818594f, 0.26921203f, 0.44107852f, 0.17248048f, 0.64417785f, 0.17680036f, 0.13990282f, -0.00956079f, 0.26766161f, -0.03617849f, -0.51006953f, -0.14559280f, 0.04585566f, -0.32296828f, -0.43440915f, -0.45020472f, @@ -6067,7 +6088,8 @@ const float ivas_sns_cdbks_side_tcx20_stage1[ 32 * 16 ] = { -0.17764482f, -0.15058551f, -0.12627503f, -0.06547272f, -0.05935809f, -0.01277874f, 0.01723090f, -0.00829920f, -0.02788840f, 0.01142219f, 0.05531784f, 0.04254613f, 0.04730144f, 0.07050022f, 0.15526930f, 0.22871460f }; -const float ivas_sns_cdbks_side_tcx20_stage2[ 32 * 16 ] = { +const float ivas_sns_cdbks_side_tcx20_stage2[ 32 * 16 ] = +{ -0.01387178f, 0.00066194f, 0.01705500f, 0.00585076f, 0.05625865f, -0.08189174f, -0.29272907f, 0.00394582f, 0.14068978f, 0.03888049f, 0.01046905f, 0.03828706f, 0.04214951f, 0.02083198f, 0.00583650f, 0.00757601f, -0.07101791f, -0.10250166f, 0.03818920f, 0.09162373f, 0.11895681f, 0.13465195f, 0.05088923f, -0.11144198f, -0.13846971f, -0.20720284f, -0.25737659f, -0.15071919f, 0.03249921f, 0.08124332f, 0.17587328f, 0.31480317f, 0.07163217f, 0.02904662f, 0.01959293f, 0.00805967f, 0.02343380f, 0.02069451f, 0.03232257f, 0.02206815f, 0.03462995f, 0.01790113f, -0.03778174f, -0.14048245f, -0.21681559f, -0.11035045f, 0.05755451f, 0.16849432f, @@ -6104,14 +6126,16 @@ const float ivas_sns_cdbks_side_tcx20_stage2[ 32 * 16 ] = { const float *const ivas_sns_cdbks_side_tcx20[SNS_MSVQ_NSTAGES_SIDE] = { ivas_sns_cdbks_side_tcx20_stage1, ivas_sns_cdbks_side_tcx20_stage2 }; -const float ivas_sns_means_side_tcx10[M] = { - -0.0085f , 0.0070f , 0.0074f , 0.0045f, - -0.0038f , 0.0071f , 0.0040f , -0.0068f, - -0.0104f , -0.0095f , -0.0259f , -0.0163f, - 0.0127f , 0.0087f , 0.0036f , 0.0262f +const float ivas_sns_means_side_tcx10[M] = +{ + -0.0085f, 0.0070f, 0.0074f, 0.0045f, + -0.0038f, 0.0071f, 0.0040f, -0.0068f, + -0.0104f, -0.0095f, -0.0259f, -0.0163f, + 0.0127f, 0.0087f, 0.0036f, 0.0262f }; -const float ivas_sns_cdbks_side_tcx10_stage1[ 32 * 16 ] = { +const float ivas_sns_cdbks_side_tcx10_stage1[ 32 * 16 ] = +{ -0.23085418f, -0.21005449f, -0.18570241f, -0.13606880f, -0.11948469f, -0.10308038f, -0.11104958f, -0.15882089f, -0.13896854f, -0.06621316f, 0.05217852f, 0.11795393f, 0.15762859f, 0.26837024f, 0.37542593f, 0.48873907f, 0.13745600f, 0.20131847f, 0.22182278f, 0.29526068f, 0.24656821f, 0.13757111f, 0.07460669f, 0.03134436f, -0.06561883f, -0.17480962f, -0.24070771f, -0.31627147f, -0.28865063f, -0.14849001f, -0.03399112f, -0.07740884f, -0.13299250f, -0.14002491f, -0.11936499f, -0.04179630f, -0.03438902f, 0.04431344f, 0.06951552f, 0.01403797f, 0.05531963f, -0.01394528f, -0.09745552f, 0.00448586f, 0.26823524f, 0.23321159f, 0.06675539f, -0.17590634f, @@ -6146,7 +6170,8 @@ const float ivas_sns_cdbks_side_tcx10_stage1[ 32 * 16 ] = { 0.26197082f, 0.21849905f, 0.21673972f, 0.16654799f, 0.18547759f, 0.16177425f, 0.16111117f, 0.20927596f, 0.18073438f, 0.03535012f, -0.14032550f, -0.22486416f, -0.33259461f, -0.40957544f, -0.38613800f, -0.30398287f }; -const float ivas_sns_cdbks_side_tcx10_stage2[ 8 * 16 ] = { +const float ivas_sns_cdbks_side_tcx10_stage2[ 8 * 16 ] = +{ -0.13993218f, -0.02453874f, 0.12672628f, 0.02785695f, 0.06681568f, 0.12811808f, 0.07492973f, -0.01977524f, -0.05822869f, -0.07547464f, -0.06553072f, -0.05473233f, -0.04357434f, -0.00634272f, 0.03406826f, 0.02961442f, -0.06711216f, -0.11444162f, -0.09789788f, -0.09123304f, -0.12190348f, -0.00995424f, 0.10989921f, 0.11555575f, 0.06002452f, 0.03801973f, 0.02047622f, 0.01721280f, 0.02414692f, 0.02829613f, 0.03827912f, 0.05063187f, 0.05523005f, 0.03052467f, 0.03910551f, 0.05802321f, 0.02158461f, 0.03249705f, 0.04015871f, -0.00878163f, -0.05597684f, -0.02391125f, 0.03722223f, 0.06349026f, 0.02718346f, -0.07380323f, -0.12743287f, -0.11511406f, diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index 9e3c431e70..6315aa5abe 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -407,6 +407,7 @@ extern const int16_t ivas_num_active_bands[FB - WB + 1]; /*------------------------------------------------------------------------------------------* * SNS MSVQ codebooks and means *------------------------------------------------------------------------------------------*/ + extern const int16_t ivas_sns_cdbks_tcx20_levels[]; extern const int16_t ivas_sns_cdbks_tcx20_bits[]; diff --git a/lib_dec/ivas_sns_dec.c b/lib_dec/ivas_sns_dec.c index e03c7594be..f7179f79a5 100644 --- a/lib_dec/ivas_sns_dec.c +++ b/lib_dec/ivas_sns_dec.c @@ -240,7 +240,14 @@ void sns_avq_dec_stereo( return; } + #ifdef SNS_MSVQ +/*------------------------------------------------------------------- + * dequantize_sns() + * + * Dequantize SNS + *-------------------------------------------------------------------*/ + void dequantize_sns( int16_t indices[CPE_CHANNELS][NPRM_LPC_NEW], float snsQ_out[CPE_CHANNELS][NB_DIV][M], @@ -290,6 +297,7 @@ void dequantize_sns( { msvq_dec( cdbks, NULL, NULL, nStages, M, M, &indices[ch][idxIndices + SNS_STEREO_MODE_OFFSET_INDICES], snsQ, NULL ); } + idxIndices += nStages; } } @@ -317,5 +325,7 @@ void dequantize_sns( v_add( snsQ_out[ch][k], means, snsQ_out[ch][k], M ); } } + + return; } #endif // SNS_MSVQ diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c index 834160d790..2f1b4e0007 100644 --- a/lib_enc/ivas_mdct_core_enc.c +++ b/lib_enc/ivas_mdct_core_enc.c @@ -1135,7 +1135,7 @@ void ivas_mdct_core_whitening_enc( *--------------------------------------------------------------------------------*/ #ifdef SNS_MSVQ - if ( !mct_on && sts[0]->sr_core == 25600 && ( ( hCPE->element_brate == IVAS_48k || hCPE->element_brate == IVAS_64k ) ) ) + if ( !mct_on && sts[0]->sr_core == 25600 && ( hCPE->element_brate == IVAS_48k || hCPE->element_brate == IVAS_64k ) ) { nbits_sns = 0; idx = 0; @@ -1220,6 +1220,7 @@ void ivas_mdct_core_whitening_enc( push_next_indice( hBstr, sns_low_br_mode, 1 ); } } + encode_lpc_avq( hBstr, num_sns, param_lpc[ch], st->core, st->element_mode ); st->side_bits_frame_channel += hBstr->nb_bits_tot - nbits_start_sns; diff --git a/lib_enc/ivas_sns_enc.c b/lib_enc/ivas_sns_enc.c index b69890aacf..0e61be561a 100644 --- a/lib_enc/ivas_sns_enc.c +++ b/lib_enc/ivas_sns_enc.c @@ -382,7 +382,14 @@ void sns_avq_cod_stereo( return; } + #ifdef SNS_MSVQ +/*------------------------------------------------------------------- + * quantize_sns() + * + * Quantize SNS + *-------------------------------------------------------------------*/ + int16_t quantize_sns( float sns_in[CPE_CHANNELS][NB_DIV][M], float snsQ_out[CPE_CHANNELS][NB_DIV][M], @@ -407,6 +414,7 @@ int16_t quantize_sns( sns_stereo_mode[1] = SNS_STEREO_MODE_LR; zero_side_flag[0] = 0; zero_side_flag[1] = 0; + if ( sts[0]->core == sts[1]->core ) { nSubframes = ( sts[0]->core == TCX_20_CORE ) ? 1 : NB_DIV; -- GitLab From 89bdf511cf71ed46d5db0d519047c44c6a80c206 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 25 Apr 2023 10:23:08 +0200 Subject: [PATCH 15/23] clang-format --- lib_com/ivas_stat_com.h | 8 ++++---- lib_dec/dec_tcx.c | 4 ++-- lib_dec/ivas_stat_dec.h | 2 +- lib_enc/ivas_ism_enc.c | 4 ++-- lib_enc/ivas_ism_metadata_enc.c | 6 +++--- lib_enc/lib_enc.c | 8 ++++---- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 6722b3dae8..46ab9573f7 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -61,12 +61,12 @@ typedef struct float azimuth; /* azimuth value read from the input metadata file */ float elevation; /* azimuth value read from the input metadata file */ float radius; - float yaw; /* azimuth orientation value read from the input metadata file */ - float pitch; /* elevation orientation value read from the input metadata file */ + float yaw; /* azimuth orientation value read from the input metadata file */ + float pitch; /* elevation orientation value read from the input metadata file */ ISM_METADATA_ANGLE position_angle; /* Angle structs for azimuth and elevation */ ISM_METADATA_ANGLE orientation_angle; /* Angle structs for yaw and pitch */ - int16_t last_radius_idx; /* last frame index of coded radius */ - int16_t radius_diff_cnt; /* FEC counter of consecutive differentially radius coded frames */ + int16_t last_radius_idx; /* last frame index of coded radius */ + int16_t radius_diff_cnt; /* FEC counter of consecutive differentially radius coded frames */ float last_azimuth; /* MD smoothing in DTX- last Q azimuth value */ float last_elevation; /* MD smoothing in DTX - last Q elevation value */ diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index b961118e4d..74c0437d53 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -1560,8 +1560,8 @@ void decoder_tcx_imdct( const int16_t fUseTns, /* i : flag that is set if TNS data is present */ float synth[], /* i/o: synth[-M..L_frame] */ float synthFB[], - const int16_t bfi, /* i : Bad frame indicator */ - const int16_t frame_cnt, /* i : frame counter in the super frame */ + const int16_t bfi, /* i : Bad frame indicator */ + const int16_t frame_cnt, /* i : frame counter in the super frame */ const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ ) { diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 4df9250f6d..d79939b191 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -951,7 +951,7 @@ typedef struct mct_dec_data_structure MCT_DEC_BLOCK_DATA_HANDLE hBlockData[MCT_MAX_BLOCKS]; int16_t chBitRatios[MCT_MAX_CHANNELS]; - int16_t lowE_ch[MCT_MAX_CHANNELS]; /* note: pointer to local parameter */ + int16_t lowE_ch[MCT_MAX_CHANNELS]; /* note: pointer to local parameter */ uint16_t mc_global_ild[MCT_MAX_CHANNELS]; /* note: pointer to local parameter */ } MCT_DEC_DATA, *MCT_DEC_HANDLE; diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 76382bfd2a..56d6bc880a 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -219,7 +219,7 @@ ivas_error ivas_ism_enc( if ( dtx_flag ) { ivas_ism_metadata_sid_enc( st_ivas->hISMDTX, flag_noisy_speech, nchan_ism, st_ivas->nchan_transport, st_ivas->ism_mode, st_ivas->hIsmMetaData, sid_flag, md_diff_flag, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata ); - } + } else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, @@ -244,7 +244,7 @@ ivas_error ivas_ism_enc( if ( sid_flag ) { ivas_write_format_sid( st_ivas->hEncoderConfig->ivas_format, IVAS_SCE, st->hBstr ); - } + } /*------------------------------------------------------------------* * CoreCoders encoding diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index e923ff7fa3..25725d602a 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -162,8 +162,8 @@ static void rate_ism_importance( *-------------------------------------------------------------------------*/ ivas_error ivas_ism_metadata_enc( - const int32_t ism_total_brate, /* i : ISM total bitrate */ - const int16_t nchan_ism, /* i : number of ISM channels */ + const int32_t ism_total_brate, /* i : ISM total bitrate */ + const int16_t nchan_ism, /* i : number of ISM channels */ const int16_t nchan_transport, /* i : number of transport channels */ ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ SCE_ENC_HANDLE hSCE[], /* i/o: SCE encoder handles */ @@ -218,8 +218,8 @@ ivas_error ivas_ism_metadata_enc( else if ( ism_mode == ISM_MODE_DISC ) { hIsmMeta[ch]->ism_metadata_flag = localVAD[ch] || hSCE[ch]->hCoreCoder[0]->lp_noise > 10; - } } + } /*----------------------------------------------------------------* * Rate importance of particular ISM streams diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index e80a896e3e..51dd3f8258 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -61,7 +61,7 @@ struct IVAS_ENC bool ismMetadataProvided[MAX_NUM_OBJECTS]; bool maxBandwidthUser; /* Was a specific max bandwith selected by the user? */ IVAS_ENC_BANDWIDTH newBandwidthApi; /* maximum encoded bandwidth, as set on API level */ - bool extMetadataApi; /* External metadata requested, to be checked against current bit rate */ + bool extMetadataApi; /* External metadata requested, to be checked against current bit rate */ }; /*---------------------------------------------------------------------* @@ -880,9 +880,9 @@ static ivas_error configureEncoder( if ( hEncoderConfig->Opt_DTX_ON && hEncoderConfig->ivas_format != MONO_FORMAT && ( ( hEncoderConfig->ivas_format == MASA_FORMAT && hEncoderConfig->ivas_total_brate > IVAS_128k ) || // ToDo: remove the bitrate limitation - ( hEncoderConfig->ivas_format == SBA_FORMAT && ivas_get_sba_num_TCs( hEncoderConfig->ivas_total_brate, 1 ) > 2 ) || // ToDo: support for 3+ TCs to be done - hEncoderConfig->ivas_format == MC_FORMAT // ToDo: TBD - ) ) + ( hEncoderConfig->ivas_format == SBA_FORMAT && ivas_get_sba_num_TCs( hEncoderConfig->ivas_total_brate, 1 ) > 2 ) || // ToDo: support for 3+ TCs to be done + hEncoderConfig->ivas_format == MC_FORMAT // ToDo: TBD + ) ) { return IVAS_ERROR( IVAS_ERR_DTX_NOT_SUPPORTED, "DTX is not supported in this IVAS format and element mode." ); } -- GitLab From 2b8d2114da11faac681f1b2576ce496a0d2bdbca Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 2 May 2023 13:55:10 +0200 Subject: [PATCH 16/23] formatting, comments --- lib_com/ivas_cnst.h | 2 +- lib_com/ivas_cov_smooth.c | 2 ++ lib_com/ivas_dirac_com.c | 1 + lib_com/ivas_prot.h | 4 ++-- lib_dec/ivas_sba_dec.c | 9 +++++++++ lib_dec/ivas_spar_decoder.c | 12 ++++++++++-- lib_dec/ivas_spar_md_dec.c | 8 ++++++++ lib_enc/ivas_init_enc.c | 2 ++ lib_enc/ivas_sba_enc.c | 8 ++++++++ lib_enc/ivas_spar_encoder.c | 4 ++++ lib_enc/ivas_spar_md_enc.c | 3 +++ 11 files changed, 50 insertions(+), 5 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index e16e779bda..86e7f2a827 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1027,7 +1027,7 @@ typedef enum #define IVAS_SPAR_BR_TABLE_LEN 18 #endif -/* TD decorr */ // VE: not all 16CH are currently supported -> t be revisited later +/* TD decorr */ // VE: not all 16CH are currently supported -> to be revisited later enum { IVAS_TD_DECORR_OUT_1CH = 1, diff --git a/lib_com/ivas_cov_smooth.c b/lib_com/ivas_cov_smooth.c index ef2f5e3693..0443158444 100644 --- a/lib_com/ivas_cov_smooth.c +++ b/lib_com/ivas_cov_smooth.c @@ -59,6 +59,7 @@ static void ivas_set_up_cov_smoothing( ) { int16_t j, k; + #ifdef LBR_SBA_DM_COV_FIX if ( ivas_total_brate < IVAS_24k4 ) { @@ -77,6 +78,7 @@ static void ivas_set_up_cov_smoothing( } hCovState->pSmoothing_factor[j] = update_factor / min_pool_size; + #ifdef LBR_SBA_EXTRA_COV_SMOOTH float smooth_fact; if ( ivas_total_brate < IVAS_24k4 ) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 172dbc5365..26344326e3 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -259,6 +259,7 @@ void ivas_dirac_config_bands( { band_grouping[reduced_band] = max_band; } + #ifdef LBR_SBA for ( band = enc_param_start_band + ( DIRAC_MAX_NBANDS - enc_param_start_band ) / 2 - 1, reduced_band = DIRAC_MAX_NBANDS - 1; band >= enc_param_start_band; band--, reduced_band -= step ) { diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 9f003e64e6..d2a924710f 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4203,7 +4203,7 @@ void ivas_spar_to_dirac( const int16_t num_bands_out /* i : number of output bands */ #ifdef LBR_SBA , - const int16_t bw /* i : band joining factor */ + const int16_t bw /* i : band joining factor */ #endif ); @@ -4266,7 +4266,7 @@ ivas_error ivas_spar_covar_smooth_enc_open( const int16_t nchan_inp /* i : number of input channels */ #ifdef LBR_SBA_EXTRA_COV_SMOOTH , - const int32_t ivas_total_brate /* i : IVAS total bitrate */ + const int32_t ivas_total_brate /* i : IVAS total bitrate */ #endif ); diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 6fb6deab71..48be2cae20 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -119,6 +119,7 @@ ivas_error ivas_sba_dec_reconfigure( #ifndef LBR_SBA_BR_SWITCHING int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1]; #endif + error = IVAS_ERR_OK; hDecoderConfig = st_ivas->hDecoderConfig; @@ -132,6 +133,7 @@ ivas_error ivas_sba_dec_reconfigure( #endif st_ivas->sba_mode = sba_mode_old; #endif + /*-----------------------------------------------------------------* * Set SBA high-level parameters * Save old SBA high-level parameters @@ -152,9 +154,11 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->sba_mode = ivas_sba_mode_select(); #endif #endif + /*-----------------------------------------------------------------* * Allocate, initialize, and configure SBA handles *-----------------------------------------------------------------*/ + #ifndef LBR_SBA_BR_SWITCHING if ( st_ivas->sba_mode != SBA_MODE_SPAR ) { @@ -210,6 +214,7 @@ ivas_error ivas_sba_dec_reconfigure( #ifndef LBR_SBA_BR_SWITCHING } #endif + if ( st_ivas->nchan_transport == 1 ) { st_ivas->element_mode_init = IVAS_SCE; @@ -273,6 +278,7 @@ ivas_error ivas_sba_dec_reconfigure( { ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); } + #ifndef LBR_SBA_BR_SWITCHING if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( sba_mode_old != st_ivas->sba_mode ) || ( ( st_ivas->sba_mode == SBA_MODE_SPAR ) && ( ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO ) ) ) ) #else @@ -298,6 +304,7 @@ ivas_error ivas_sba_dec_reconfigure( return error; } } + #ifndef LBR_SBA_BR_SWITCHING if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { @@ -323,6 +330,7 @@ ivas_error ivas_sba_dec_reconfigure( #ifndef LBR_SBA_BR_SWITCHING else if ( st_ivas->renderer_type == RENDERER_DISABLE || ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->sba_mode != SBA_MODE_SPAR ) ) #else + if ( st_ivas->renderer_type == RENDERER_DISABLE ) #endif { @@ -333,6 +341,7 @@ ivas_error ivas_sba_dec_reconfigure( #ifndef LBR_SBA_BR_SWITCHING if ( st_ivas->hDirAC != NULL && st_ivas->sba_mode == SBA_MODE_SPAR ) #else + if ( st_ivas->hDirAC != NULL ) #endif { diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index c5d25392ac..ce46349cb5 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -896,11 +896,17 @@ static void ivas_spar_get_skip_mat( #ifdef LBR_ADAP_SMOOTHING +/*-------------------------------------------------------------------* + * ivas_spar_calc_smooth_facs() + * + * + *-------------------------------------------------------------------*/ + static void ivas_spar_calc_smooth_facs( float *cldfb_in_ts_re[CLDFB_NO_COL_MAX], float *cldfb_in_ts_im[CLDFB_NO_COL_MAX], - int16_t nbands_spar, - ivas_fb_bin_to_band_data_t *bin2band, + const int16_t nbands_spar, + const ivas_fb_bin_to_band_data_t *bin2band, float *smooth_fac, float smooth_buf[IVAS_MAX_NUM_BANDS][2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1] ) { @@ -947,8 +953,10 @@ static void ivas_spar_calc_smooth_facs( /* calculate smoothing factor based on energy averages */ /* reduce factor for higher short-term energy */ smooth_fac[b] = min( 1.f, smooth_long_avg[b] / smooth_short_avg[b] ); + /* map factor to range [0;1] */ smooth_fac[b] = max( 0.f, smooth_fac[b] - (float) SBA_DIRAC_NRG_SMOOTH_SHORT / SBA_DIRAC_NRG_SMOOTH_LONG ) * ( (float) SBA_DIRAC_NRG_SMOOTH_LONG / ( SBA_DIRAC_NRG_SMOOTH_LONG - SBA_DIRAC_NRG_SMOOTH_SHORT ) ); + /* compress factor (higher compression in lowest bands) */ if ( b < 2 ) { diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 5e50f42b76..b98ce6cd84 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -659,8 +659,10 @@ void ivas_spar_md_dec_process( hMdDec = st_ivas->hSpar->hMdDec; #ifdef LBR_SBA int16_t active_w_vlbr; + active_w_vlbr = ( st_ivas->hDecoderConfig->ivas_total_brate < IVAS_24k4 ) ? 1 : 0; #endif + ivas_spar_dec_parse_md_bs( hMdDec, st0, &nB, &bw, &dtx_vad, st_ivas->hDecoderConfig->ivas_total_brate, ivas_spar_br_table_consts[hMdDec->table_idx].usePlanarCoeff, st_ivas->hQMetaData->sba_inactive_mode ); @@ -1277,6 +1279,7 @@ static void ivas_get_spar_matrices( #else active_w_dm_fac = ( dtx_vad == 0 ) ? IVAS_ACTIVEW_DM_F_SCALE_DTX : IVAS_ACTIVEW_DM_F_SCALE; #endif + for ( i_ts = 0; i_ts < n_ts; i_ts++ ) { for ( i = 0; i < numch_out; i++ ) @@ -1287,6 +1290,7 @@ static void ivas_get_spar_matrices( set_zero( &hMdDec->spar_coeffs.P_re[i][j][i_ts * IVAS_MAX_NUM_BANDS], IVAS_MAX_NUM_BANDS ); } } + #ifndef LBR_SBA if ( bw == IVAS_RED_BAND_FACT ) { @@ -1968,6 +1972,7 @@ static void ivas_spar_dec_parse_md_bs( { hMdDec->spar_md_prev.band_coeffs_idx[i].decd_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].decd_index_re[j]; } + #ifdef LBR_SBA hMdDec->valid_bands[*bands_bw * i] |= ( do_diff[i] == 0 && do_repeat[i] == 0 ) ? 1 : 0; for ( j = 1; j < *bands_bw; j++ ) @@ -2089,6 +2094,7 @@ static void ivas_decode_arith_bs( { ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[bands_bw * i]; ndec = hMdDec->spar_md_cfg.num_decorr_per_band[bands_bw * i]; + #ifdef LBR_SBA if ( ( ivas_total_brate < IVAS_24k4 ) && ( strat > 3 ) && ( ( ( i % 2 == 1 ) && ( strat % 2 == 0 ) ) || ( ( i % 2 == 0 ) && ( strat % 2 == 1 ) ) ) ) { @@ -2974,6 +2980,7 @@ void ivas_spar_to_dirac( dirac_to_spar_md_bands = st_ivas->hSpar->dirac_to_spar_md_bands; enc_param_start_band = st_ivas->hSpar->enc_param_start_band; #endif + if ( hDirAC != NULL ) { band_grouping = hDirAC->band_grouping; @@ -3186,6 +3193,7 @@ void ivas_spar_to_dirac( } } } + #ifdef LBR_SBA int16_t num_subframes; num_subframes = MAX_PARAM_SPATIAL_SUBFRAMES; diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 6171cd000a..5b165bb6f9 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -339,6 +339,7 @@ ivas_error ivas_init_encoder( /* In IVAS, ensure that minimum coded bandwidth is WB */ hEncoderConfig->max_bwidth = max( hEncoderConfig->max_bwidth, WB ); } + #ifdef LBR_SBA_BR_SWITCHING hEncoderConfig->spar_reconfig_flag = 0; #endif @@ -347,6 +348,7 @@ ivas_error ivas_init_encoder( st_ivas->sba_mode = SBA_MODE_NONE; st_ivas->nchan_transport = -1; + /*-----------------------------------------------------------------* * Allocate and initialize SCE/CPE and other handles *-----------------------------------------------------------------*/ diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 1766351c95..611f46a12b 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -140,6 +140,7 @@ ivas_error ivas_sba_enc_reconfigure( st_ivas->sba_mode = ivas_sba_mode_select(); #endif #endif + analysis_order_old = ivas_sba_get_analysis_order( hEncoderConfig->last_ivas_total_brate, hEncoderConfig->sba_order ); if ( analysis_order_old != st_ivas->sba_analysis_order ) @@ -218,6 +219,7 @@ ivas_error ivas_sba_enc_reconfigure( } } #endif + 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 ); @@ -237,6 +239,7 @@ ivas_error ivas_sba_enc_reconfigure( ivas_spar_enc_close( &( st_ivas->hSpar ), hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp, spar_reconfig_flag ); } #endif + hSpar = st_ivas->hSpar; if ( st_ivas->nchan_transport == 1 ) @@ -247,6 +250,7 @@ ivas_error ivas_sba_enc_reconfigure( { hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; } + #ifndef LBR_SBA_BR_SWITCHING if ( ( sba_mode_old != st_ivas->sba_mode ) || ( nchan_transport_old != st_ivas->nchan_transport ) ) #else @@ -315,13 +319,16 @@ ivas_error ivas_sba_enc_reconfigure( } #endif } + #ifdef LBR_SBA_BR_SWITCHING hEncoderConfig->spar_reconfig_flag = spar_reconfig_flag; #endif + if ( ( error = ivas_dirac_enc_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) { return error; } + #ifndef LBR_SBA_BR_SWITCHING if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { @@ -331,6 +338,7 @@ ivas_error ivas_sba_enc_reconfigure( #ifndef LBR_SBA_BR_SWITCHING } #endif + /*-----------------------------------------------------------------* * Allocate, initialize, and configure SCE/CPE/MCT handles *-----------------------------------------------------------------*/ diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index ad7db2ae6a..9c6e51c8a3 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -434,8 +434,10 @@ static ivas_error ivas_spar_enc_process( nchan_inp = ivas_sba_get_nchan_metadata( sba_order ); assert( nchan_inp <= hEncoderConfig->nchan_inp ); #ifdef LBR_SBA + int16_t active_w_vlbr; active_w_vlbr = ( hEncoderConfig->ivas_total_brate < IVAS_24k4 ) ? 1 : 0; + #endif for ( i = FOA_CHANNELS + 1; i < nchan_inp; i++ ) { @@ -451,12 +453,14 @@ static ivas_error ivas_spar_enc_process( { transient_det[1] = transient_det[0]; } + #ifdef LBR_SBA_EXTRA_COV_SMOOTH if ( ivas_total_brate < IVAS_24k4 ) { transient_det[1] = 0; } #endif + /* store previous input samples for W in local buffer */ assert( num_del_samples <= IVAS_FB_1MS_48K_SAMP ); mvr2r( &hSpar->hFbMixer->ppFilterbank_prior_input[0][hSpar->hFbMixer->fb_cfg->prior_input_length - num_del_samples], w_del_buf, num_del_samples ); diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index b76a831fea..26d64967a1 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -1008,6 +1008,7 @@ ivas_error ivas_spar_md_enc_process( { assert( qsi == 0 ); } + #ifdef LBR_SBA /* Reuse mixer matrix values for unsent bands */ if ( ( hEncoderConfig->ivas_total_brate < IVAS_24k4 ) && ( code_strat > 3 ) ) @@ -1477,6 +1478,7 @@ static void ivas_get_huffman_coded_bs( int16_t code, len; #ifdef LBR_SBA int16_t ndm, ndec; + ndm = hMdEnc->spar_md_cfg.num_dmx_chans_per_band[i * bands_bw]; ndec = hMdEnc->spar_md_cfg.num_decorr_per_band[i * bands_bw]; #else @@ -1826,6 +1828,7 @@ static void ivas_store_prior_coeffs( #ifndef LBR_SBA float one_by_bands_bw = ( 1.0f / bands_bw ); #endif + if ( dtx_vad == 0 ) { hMdEnc->spar_md_cfg.prior_strat = START; -- GitLab From b67721d85a098eda2f973b5127cf448b1dd7f3d0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 5 May 2023 10:50:59 +0200 Subject: [PATCH 17/23] formatting --- lib_com/ivas_cov_smooth.c | 32 ++++++++++++++++----------- lib_com/ivas_dirac_com.c | 4 ++-- lib_com/ivas_prot.h | 8 +++---- lib_com/prot.h | 29 +++++++++++------------- lib_dec/ivas_dirac_dec.c | 9 ++++++-- lib_dec/ivas_spar_md_dec.c | 13 +++++------ lib_dec/ivas_stat_dec.h | 1 - lib_dec/ivas_stereo_mdct_stereo_dec.c | 1 + lib_dec/lsf_dec.c | 25 +++++++++------------ lib_enc/ivas_enc_cov_handler.c | 5 ++--- lib_enc/ivas_spar_md_enc.c | 5 ++--- lib_enc/lsf_enc.c | 5 ++--- lib_rend/ivas_rotation.c | 6 ++++- 13 files changed, 73 insertions(+), 70 deletions(-) diff --git a/lib_com/ivas_cov_smooth.c b/lib_com/ivas_cov_smooth.c index b5bd6369c5..128500c364 100644 --- a/lib_com/ivas_cov_smooth.c +++ b/lib_com/ivas_cov_smooth.c @@ -39,7 +39,14 @@ #include "wmc_auto.h" #include "prot.h" + +/*-----------------------------------------------------------------------------------------* + * Local constants + *-----------------------------------------------------------------------------------------*/ + #define BAND_SMOOTH_REST_START_IDX ( 2 ) + + /*-----------------------------------------------------------------------------------------* * Function ivas_set_up_cov_smoothing() * @@ -51,20 +58,19 @@ static void ivas_set_up_cov_smoothing( ivas_filterbank_t *pFb, const float max_update_rate, const int16_t min_pool_size, - const int16_t nchan_inp /* i : number of input channels */ - , + const int16_t nchan_inp, const int32_t ivas_total_brate ) { int16_t j, k; + float update_factor, smooth_fact, *p_bin_to_band; + int16_t active_bins; + if ( ivas_total_brate < IVAS_24k4 ) { for ( j = 0; j < pFb->filterbank_num_bands; j++ ) { - float update_factor; - float *p_bin_to_band; update_factor = 0.0f; p_bin_to_band = pFb->fb_bin_to_band.pp_short_stride_bin_to_band[j]; - int16_t active_bins; active_bins = pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[j]; for ( k = 0; k < active_bins; k++ ) @@ -73,7 +79,7 @@ static void ivas_set_up_cov_smoothing( } hCovState->pSmoothing_factor[j] = update_factor / min_pool_size; - float smooth_fact; + if ( ivas_total_brate < IVAS_24k4 ) { smooth_fact = 0.5f; @@ -94,7 +100,6 @@ static void ivas_set_up_cov_smoothing( { for ( j = 0; j < pFb->filterbank_num_bands; j++ ) { - float update_factor; update_factor = 0.0f; for ( k = 0; k < pFb->fb_bin_to_band.pFb_active_bins_per_band[j]; k++ ) @@ -114,24 +119,25 @@ static void ivas_set_up_cov_smoothing( { for ( j = 0; j < pFb->filterbank_num_bands; j++ ) { - float update_factor; - float *p_bin_to_band; - int16_t active_bins; update_factor = 0.0f; p_bin_to_band = pFb->fb_bin_to_band.pp_short_stride_bin_to_band[j]; active_bins = pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[j]; + for ( k = 0; k < active_bins; k++ ) { update_factor += p_bin_to_band[k]; } + hCovState->pSmoothing_factor[j] = update_factor / min_pool_size; hCovState->pSmoothing_factor[j] *= ( j + 1 ) * 0.75f; + if ( hCovState->pSmoothing_factor[j] > max_update_rate ) { hCovState->pSmoothing_factor[j] = max_update_rate; } } } + hCovState->prior_bank_idx = -1; return; @@ -148,9 +154,8 @@ ivas_error ivas_spar_covar_smooth_enc_open( ivas_cov_smooth_state_t **hCovState_out, /* i/o: SPAR Covar. smoothing handle */ const ivas_cov_smooth_cfg_t *cov_smooth_cfg, /* i : SPAR config. handle */ ivas_filterbank_t *pFb, /* i/o: FB handle */ - const int16_t nchan_inp /* i : number of input channels */ - , - const int32_t ivas_total_brate /* i : IVAS total bitrate */ + const int16_t nchan_inp, /* i : number of input channels */ + const int32_t ivas_total_brate /* i : IVAS total bitrate */ ) { ivas_cov_smooth_state_t *hCovState; @@ -246,6 +251,7 @@ static void ivas_compute_smooth_cov( float factor = 0; int16_t sm_b; int16_t non_sm_b_idx; + sm_b = BAND_SMOOTH_REST_START_IDX; assert( end_band <= pFb->filterbank_num_bands ); diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 0ce3434b71..d5f5f99c68 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -140,6 +140,7 @@ ivas_error ivas_dirac_config( #ifdef FIX_391_SBA hConfig->dec_param_estim_old = hConfig->dec_param_estim; #endif + if ( ivas_format == SBA_FORMAT ) /* skip for MASA decoder */ { if ( ( error = ivas_dirac_sba_config( hQMetaData, nchan_transport, nSCE, nCPE, element_mode, ivas_total_brate, sba_order, sba_mode, hConfig->nbands - spar_dirac_split_band ) ) != IVAS_ERR_OK ) @@ -156,7 +157,6 @@ ivas_error ivas_dirac_config( hConfig->enc_param_start_band = hQMetaData->q_direction[0].cfg.start_band + spar_dirac_split_band; } - if ( sba_mode == SBA_MODE_SPAR ) { hConfig->dec_param_estim = TRUE; @@ -266,7 +266,7 @@ void ivas_dirac_config_bands( dirac_to_spar_md_bands[reduced_band] = dirac_to_spar_md_bands[band]; dirac_to_spar_md_bands[reduced_band - 1] = dirac_to_spar_md_bands[band]; } - } + } else { /* always code the last two fb bands together */ diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 84ba37fc41..60d1501a22 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4081,9 +4081,8 @@ ivas_error ivas_spar_md_enc_process( BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */ const int16_t dtx_vad, 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 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 */ ); void ivas_compute_spar_params( @@ -4245,8 +4244,7 @@ ivas_error ivas_spar_covar_smooth_enc_open( ivas_cov_smooth_state_t **hCovState, /* i/o: SPAR Covar. smoothing handle */ const ivas_cov_smooth_cfg_t *cov_smooth_cfg, /* i : SPAR config. handle */ ivas_filterbank_t *pFb, /* i/o: FB handle */ - const int16_t nchan_inp /* i : number of input channels */ - , + const int16_t nchan_inp, /* i : number of input channels */ const int32_t ivas_total_brate /* i : IVAS total bitrate */ ); diff --git a/lib_com/prot.h b/lib_com/prot.h index 7c01272e31..6638e59bab 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -3020,9 +3020,8 @@ void lsf_enc( float *lsp_mid, /* i : mid-frame LSP vector */ float *Aq, /* o : quantized A(z) for 4 subframes */ const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */ - , - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ + const int16_t GSC_IVAS_mode, /* i : GSC IVAS mode */ + const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ ); void isf_enc_amr_wb( @@ -4572,16 +4571,15 @@ void swb_CNG_dec( ); void lsf_dec( - Decoder_State *st, /* i/o: State structure */ - const int16_t tc_subfr, /* i : TC subframe index */ - float *Aq, /* o : quantized A(z) for 4 subframes */ - int16_t *LSF_Q_prediction, /* o : LSF prediction mode */ - float *lsf_new, /* o : de-quantized LSF vector */ - float *lsp_new, /* o : de-quantized LSP vector */ - float *lsp_mid, /* o : de-quantized mid-frame LSP vector */ - const int16_t tdm_low_rate_mode /* i : secondary channel low rate mode flag */ - , - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ + Decoder_State *st, /* i/o: State structure */ + const int16_t tc_subfr, /* i : TC subframe index */ + float *Aq, /* o : quantized A(z) for 4 subframes */ + int16_t *LSF_Q_prediction, /* o : LSF prediction mode */ + float *lsf_new, /* o : de-quantized LSF vector */ + float *lsp_new, /* o : de-quantized LSP vector */ + float *lsp_mid, /* o : de-quantized mid-frame LSP vector */ + const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ + const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ ); void isf_dec_amr_wb( @@ -8252,9 +8250,8 @@ void lsf_end_dec( float *qlsf, /* o : quantized LSFs in the cosine domain */ int16_t *lpc_param, /* i : LPC parameters */ int16_t *LSF_Q_prediction, /* o : LSF prediction mode */ - int16_t *nb_indices /* o : number of indices */ - , - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ + int16_t *nb_indices, /* o : number of indices */ + const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ ); ivas_error find_pred_mode( diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 446ed23bb3..cc2e308d68 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -823,6 +823,7 @@ ivas_error ivas_dirac_dec_config( #ifdef FIX_391_SBA hDirAC->hConfig->dec_param_estim_old = hDirAC->hConfig->dec_param_estim; #endif + if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { hDirAC->dirac_md_buffer_length = MAX_PARAM_SPATIAL_SUBFRAMES; @@ -991,11 +992,12 @@ ivas_error ivas_dirac_dec_config( { int16_t num_slots_in_subfr; num_slots_in_subfr = hDirAC->hConfig->dec_param_estim ? CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES : 1; + if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { - if ( ( hDirAC->hConfig->dec_param_estim_old != hDirAC->hConfig->dec_param_estim ) ) + if ( hDirAC->hConfig->dec_param_estim_old != hDirAC->hConfig->dec_param_estim ) { - + /* VE: following code is present at different place -> introduce a fucntion for it */ for ( i = 0; i < hDirAC->dirac_md_buffer_length; i++ ) { if ( hDirAC->azimuth[i] != NULL ) @@ -1060,9 +1062,12 @@ ivas_error ivas_dirac_dec_config( hDirAC->surroundingCoherence = NULL; } } + hDirAC->dirac_md_buffer_length = ( MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_DIRAC_PARAM_DEC_SFR ) * num_slots_in_subfr; hDirAC->dirac_bs_md_write_idx = DELAY_DIRAC_PARAM_DEC_SFR * num_slots_in_subfr; hDirAC->spar_to_dirac_write_idx = DELAY_DIRAC_PARAM_DEC_SFR * num_slots_in_subfr; + + /* VE: following code is present at different place -> introduce a fucntion for it */ if ( ( hDirAC->azimuth = (int16_t **) malloc( hDirAC->dirac_md_buffer_length * sizeof( int16_t * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index ba4312104b..e88bd5efa9 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -2036,8 +2036,8 @@ static void ivas_decode_arith_bs( decd_cell_dims[i].dim2 = 1; decx_cell_dims[i].dim1 = ( ndec * ( ndec - 1 ) ) >> 1; decx_cell_dims[i].dim2 = 1; - } } + } any_diff = 0; for ( i = 0; i < nB; i++ ) @@ -2348,9 +2348,9 @@ static void ivas_decode_huffman_bs( for ( j = pred_offset; j < pred_dim; j++ ) { - ivas_huffman_decode( &hMdDec->huff_coeffs.pred_huff_re[qsi], st0, - &hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j] ); - } + ivas_huffman_decode( &hMdDec->huff_coeffs.pred_huff_re[qsi], st0, + &hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j] ); + } if ( hMdDec->spar_hoa_md_flag ) { @@ -2800,9 +2800,8 @@ void ivas_spar_to_dirac( Decoder_Struct *st_ivas, ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ const int16_t dtx_vad, /* i : DTX frame flag */ - const int16_t num_bands_out /* i : number of output bands */ - , - const int16_t bw /* i : band joining factor */ + const int16_t num_bands_out, /* i : number of output bands */ + const int16_t bw /* i : band joining factor */ ) { DIRAC_DEC_HANDLE hDirAC; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 580cc0444f..b0df989527 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -980,7 +980,6 @@ typedef struct ivas_lfe_dec_data_structure } LFE_DEC_DATA, *LFE_DEC_HANDLE; -// Note: the following structures are used only in lib_dec but this would likely change in the future /*----------------------------------------------------------------------------------* * VBAP structures *----------------------------------------------------------------------------------*/ diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index 0e788a0821..90d94f5b06 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -475,6 +475,7 @@ ivas_error initMdctStereoDtxData( } #endif } + #ifdef FIX_413_SBA_DTX if ( st->first_CNG == 0 ) { diff --git a/lib_dec/lsf_dec.c b/lib_dec/lsf_dec.c index 73f8933daf..eb71afd842 100644 --- a/lib_dec/lsf_dec.c +++ b/lib_dec/lsf_dec.c @@ -64,16 +64,15 @@ static void dqlsf_CNG( Decoder_State *st, float *lsf_q ); *---------------------------------------------------------------------*/ void lsf_dec( - Decoder_State *st, /* i/o: State structure */ - const int16_t tc_subfr, /* i : TC subframe index */ - float *Aq, /* o : quantized A(z) for 4 subframes */ - int16_t *LSF_Q_prediction, /* o : LSF prediction mode */ - float *lsf_new, /* o : de-quantized LSF vector */ - float *lsp_new, /* o : de-quantized LSP vector */ - float *lsp_mid, /* o : de-quantized mid-frame LSP vector */ - const int16_t tdm_low_rate_mode /* i : secondary channel low rate mode flag */ - , - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ + Decoder_State *st, /* i/o: State structure */ + const int16_t tc_subfr, /* i : TC subframe index */ + float *Aq, /* o : quantized A(z) for 4 subframes */ + int16_t *LSF_Q_prediction, /* o : LSF prediction mode */ + float *lsf_new, /* o : de-quantized LSF vector */ + float *lsp_new, /* o : de-quantized LSP vector */ + float *lsp_mid, /* o : de-quantized mid-frame LSP vector */ + const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ + const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ ) { int16_t i, nBits, coder_type, no_param_lpc; @@ -258,9 +257,8 @@ void lsf_end_dec( float *qlsf, /* o : quantized LSFs in the cosine domain */ int16_t *lpc_param, /* i : LPC parameters */ int16_t *LSF_Q_prediction, /* o : LSF prediction mode */ - int16_t *nb_indices /* o : number of indices */ - , - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ + int16_t *nb_indices, /* o : number of indices */ + const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ ) { float pred0[M]; /* Prediction for the safety-net quantizer (usually mean)*/ @@ -362,7 +360,6 @@ void lsf_end_dec( st->safety_net = safety_net; - /* Make sure there are the correct bit allocations */ if ( st->idchan == 1 && predmode > 2 ) { diff --git a/lib_enc/ivas_enc_cov_handler.c b/lib_enc/ivas_enc_cov_handler.c index 9524fb656f..e9e126b8d9 100644 --- a/lib_enc/ivas_enc_cov_handler.c +++ b/lib_enc/ivas_enc_cov_handler.c @@ -65,9 +65,8 @@ ivas_error ivas_spar_covar_enc_open( ivas_enc_cov_handler_state_t **hCovEnc, /* i/o: SPAR Covar. encoder handle */ ivas_filterbank_t *pFb, /* i/o: FB handle */ const int32_t input_Fs, /* i : input sampling rate */ - const int16_t nchan_inp /* i : number of input channels */ - , - const int32_t ivas_total_brate /* i : IVAS total bitrate */ + const int16_t nchan_inp, /* i : number of input channels */ + const int32_t ivas_total_brate /* i : IVAS total bitrate */ ) { ivas_enc_cov_handler_state_t *hCovState; diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index f8892159cb..ff037fbbfc 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -543,8 +543,7 @@ ivas_error ivas_spar_md_enc_process( BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */ const int16_t dtx_vad, const int16_t nchan_inp, - const int16_t sba_order /* i : Ambisonic (SBA) order */ - , + 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 */ ) { @@ -1522,8 +1521,8 @@ static void ivas_get_arith_coded_bs( decd_cell_dims[i].dim2 = 1; decx_cell_dims[i].dim1 = ( ndec * ( ndec - 1 ) ) >> 1; decx_cell_dims[i].dim2 = 1; - } } + } any_diff = 0; for ( i = 0; i < nB; i++ ) diff --git a/lib_enc/lsf_enc.c b/lib_enc/lsf_enc.c index 66f8847608..968a9a0d25 100644 --- a/lib_enc/lsf_enc.c +++ b/lib_enc/lsf_enc.c @@ -82,9 +82,8 @@ void lsf_enc( float *lsp_mid, /* i/o: mid-frame LSP vector */ float *Aq, /* o : quantized A(z) for 4 subframes */ const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */ - , - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ + const int16_t GSC_IVAS_mode, /* i : GSC IVAS mode */ + const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ ) { int16_t i, nBits, force_sf, no_param_lpc; diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 4d9eeef3d5..da3062ef2c 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -187,11 +187,13 @@ void Euler2Quat( return; } + /*------------------------------------------------------------------------- * deg2rad() * * Converts degrees to normalized radians *------------------------------------------------------------------------*/ + float deg2rad( float degrees ) { @@ -207,6 +209,7 @@ float deg2rad( return PI_OVER_180 * degrees; } + /*------------------------------------------------------------------------- * rotateAziEle() * @@ -219,7 +222,7 @@ void rotateAziEle( int16_t *azi, /* o : rotated azimuth */ int16_t *ele, /* o : rotated elevation */ float Rmat[3][3], /* i : real-space rotation matrix */ - const int16_t isPlanar /* i : is rotation planar and elevation meaningless? */ + const int16_t isPlanar /* i : is rotation planar and elevation meaningless? */ ) { int16_t n; @@ -695,6 +698,7 @@ void rotateFrame_sd_cldfb( return; } + /*-----------------------------------------------------------------------* * Local Function definitions *-----------------------------------------------------------------------*/ -- GitLab From aabd2d78fe394ff80cfa004077ef818a2b791e54 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 15 May 2023 12:05:59 +0200 Subject: [PATCH 18/23] tabs -> spaces --- lib_com/ivas_prot.h | 23 ++++++++++------------- lib_com/ivas_rom_com.c | 9 ++++----- lib_dec/ivas_spar_md_dec.c | 6 +++--- lib_rend/ivas_prot_rend.h | 2 +- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 1a86b1cca2..7187158aa6 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -252,9 +252,9 @@ ivas_error ivas_compute_core_buffers( /*! r: number of clipped samples */ uint32_t ivas_syn_output( #ifdef JBM_TSM_ON_TCS - float *synth[], /* i/o: float synthesis signal */ + float *synth[], /* i/o: float synthesis signal */ #else - float synth[][L_FRAME48k], /* i/o: float synthesis signal */ + float synth[][L_FRAME48k], /* i/o: float synthesis signal */ #endif const int16_t output_frame, /* i : output frame length (one channel) */ const int16_t n_channels, /* i : number of output channels */ @@ -3780,7 +3780,7 @@ ivas_error ivas_dirac_dec_output_synthesis_open( const int16_t nchan_transport, /* i : number of transport channels */ const int32_t output_Fs /* i : output sampling rate */ #ifdef HODIRAC - , + , const int16_t hodirac /* i : flag to indicate HO-DirAC mode*/ #endif ); @@ -3813,7 +3813,7 @@ void ivas_dirac_dec_output_synthesis_process_slot( const float *p_Rmat, /* i : rotation matrix */ const VBAP_HANDLE hVBAPdata, /* i : VBAP structure */ const IVAS_OUTPUT_SETUP hOutSetup, /* i : output setup structure */ - const int16_t nchan_transport /* i : number of transport channels */ + const int16_t nchan_transport /* i : number of transport channels */ #if !defined( HODIRAC ) || defined( JBM_TSM_ON_TCS ) , const int16_t index_slot @@ -4634,8 +4634,7 @@ void ivas_get_spar_md_from_dirac( const int16_t end_band, const int16_t order, const int16_t dtx_vad, - float Wscale_d[IVAS_MAX_NUM_BANDS] - , + float Wscale_d[IVAS_MAX_NUM_BANDS], const uint8_t useLowerRes, const int16_t active_w_vlbr ); @@ -4686,9 +4685,8 @@ void ivas_spar_to_dirac( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ const int16_t dtx_vad, /* i : DTX frame flag */ - const int16_t num_bands_out /* i : number of output bands */ - , - const int16_t bw /* i : band joining factor */ + const int16_t num_bands_out, /* i : number of output bands */ + const int16_t bw /* i : band joining factor */ ); void ivas_spar_update_md_hist( @@ -4698,7 +4696,7 @@ void ivas_spar_update_md_hist( void ivas_spar_smooth_md_dtx( ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ const int16_t num_bands_out /* i : number of output bands */ - #ifdef SPAR_TUNING +#ifdef SPAR_TUNING , const int16_t num_md_sub_frames /* i : number of metadata subframes */ #endif @@ -4729,9 +4727,8 @@ ivas_error ivas_spar_covar_enc_open( ivas_enc_cov_handler_state_t **hCovEnc, /* i/o: SPAR Covar. encoder handle */ ivas_filterbank_t *pFb, /* i/o: FB handle */ const int32_t input_Fs, /* i : input sampling rate */ - const int16_t nchan_inp /* i : number of input channels */ - , - const int32_t ivas_total_brate /* i : IVAS total bitrate */ + const int16_t nchan_inp, /* i : number of input channels */ + 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 45adca8fbb..04d7279f9e 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -890,13 +890,12 @@ 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 */ /* preferred tuning (3.2/4.9kbps) with/out TDD */ - { 13200, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, - { { 10000, 8300, 13150 } }, + { 13200, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 10000, 8300, 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, 11500, 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, 11500, 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_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index f8b5e6a505..bbe6d2ddf9 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -756,6 +756,7 @@ void ivas_spar_md_dec_process( ivas_spar_dec_parse_md_bs( hMdDec, st0, &nB, &bw, &dtx_vad, st_ivas->hDecoderConfig->ivas_total_brate, ivas_spar_br_table_consts[hMdDec->table_idx].usePlanarCoeff, st_ivas->hQMetaData->sba_inactive_mode ); +#ifdef DEBUG_LBR_SBA #if 0 { char f_name[100]; @@ -765,8 +766,8 @@ void ivas_spar_md_dec_process( #ifdef SPAR_TUNING , st_ivas->hDecoderConfig->ivas_total_brate -#endif - ); +#endif + ); for ( b = 0; b < num_bands; b++ ) { sprintf( f_name, "spar_band_pred_coeffs_dec.bin" ); @@ -808,7 +809,6 @@ void ivas_spar_md_dec_process( } } #endif -#ifdef DEBUG_LBR_SBA /* Dumping SPAR HOA Coefficients */ /*char f_name[100]; int16_t nbands = 12; diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index c84146f8e7..72d1a320b5 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -93,7 +93,7 @@ void ivas_limiter_dec ( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ #ifdef JBM_TSM_ON_TCS - float *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ + float *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ #else float output[MAX_OUTPUT_CHANNELS][L_FRAME48k], /* i/o: input/output buffer */ #endif -- GitLab From 173a9e989803c545a0e554c21b4e0bb5aedf42a3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 15 May 2023 12:30:31 +0200 Subject: [PATCH 19/23] JBM_TSM_ON_TCS: formal improvements --- Workspace_msvc/lib_com.vcxproj | 2 +- Workspace_msvc/lib_debug.vcxproj | 2 +- Workspace_msvc/lib_dec.vcxproj | 2 +- Workspace_msvc/lib_enc.vcxproj | 2 +- Workspace_msvc/lib_rend.vcxproj | 2 +- lib_com/ivas_prot.h | 125 +++++++++++++------------- lib_dec/ivas_jbm_dec.c | 149 +++++++++++++++++++++++++------ 7 files changed, 194 insertions(+), 90 deletions(-) diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index bfe36b1f48..23aa2ae3f0 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -78,7 +78,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks diff --git a/Workspace_msvc/lib_debug.vcxproj b/Workspace_msvc/lib_debug.vcxproj index 9b7b580661..3b648fae04 100644 --- a/Workspace_msvc/lib_debug.vcxproj +++ b/Workspace_msvc/lib_debug.vcxproj @@ -73,7 +73,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_util;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) false diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index 760621d7a4..80910aa5e7 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -89,7 +89,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;..\lib_rend;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index d9f8e974f0..3378ac10f0 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -89,7 +89,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index 4bd0ca9a93..865652649a 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -89,7 +89,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 7187158aa6..d4823028cb 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -263,11 +263,11 @@ uint32_t ivas_syn_output( #ifdef JBM_TSM_ON_TCS void ivas_syn_output_f( - 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 */ - float *synth_out /* o : integer 16 bits 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 */ + float *synth_out /* o : integer 16 bits synthesis signal */ +); #endif void ivas_initialize_handles_enc( @@ -312,10 +312,10 @@ ivas_error ivas_dec( ivas_error ivas_dec_setup( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ - #ifdef JBM_TSM_ON_TCS +#ifdef JBM_TSM_ON_TCS , - uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ - int16_t *data /* o : flushed PCM samples */ + uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ + int16_t *data /* o : flushed PCM samples */ #endif ); @@ -759,102 +759,107 @@ void dtx_read_padding_bits( const int16_t num_bits ); + #ifdef JBM_TSM_ON_TCS /*----------------------------------------------------------------------------------* * JBM prototypes *----------------------------------------------------------------------------------*/ ivas_error ivas_jbm_dec_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *data /* o : output synthesis signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *data /* o : output synthesis signal */ ); ivas_error ivas_jbm_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - 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 */ - int16_t *data /* o : output synthesis signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + 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 */ + int16_t *data /* o : output synthesis signal */ ); ivas_error ivas_jbm_dec_flush_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t tc_granularity_new, /* i : new renderer granularity */ - const RENDERER_TYPE renderer_type_old, /* i : old renderer type */ - const AUDIO_CONFIG intern_config_old, /* i : old internal config */ - const IVAS_OUTPUT_SETUP_HANDLE hIntSetupOld, /* i : old internal output setup */ - 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 */ - int16_t *data /* o : rendered samples */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t tc_granularity_new, /* i : new renderer granularity */ + const RENDERER_TYPE renderer_type_old, /* i : old renderer type */ + const AUDIO_CONFIG intern_config_old, /* i : old internal config */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetupOld, /* i : old internal output setup */ + 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 */ + int16_t *data /* o : rendered samples */ ); ivas_error ivas_jbm_dec_feed_tc_to_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nSamplesForRendering, /* i: : number of TC samples available for rendering */ - int16_t *nSamplesResidual, /* o: : number of samples not fitting into the renderer grid and buffer for the next call*/ - float *data /* i/o: transport channels/output synthesis signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ + int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ + float *data /* i/o: transport channels/output synthesis signal */ ); ivas_error ivas_jbm_dec_set_discard_samples( - Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ + Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ ); void ivas_jbm_dec_get_adapted_linear_interpolator( - const int16_t default_interp_length, /* i : default length of the (full-frame) interpolator */ - const int16_t interp_length, /* i : length of the interpolator to be created */ - float *interpolator /* o : the interpolator */ + const int16_t default_interp_length, /* i : default length of the (full-frame) interpolator */ + const int16_t interp_length, /* i : length of the interpolator to be created */ + float *interpolator /* o : the interpolator */ ); void ivas_jbm_dec_get_adapted_subframes( - const int16_t nCldfbTs, /* i : number of time slots in the current frame */ - int16_t *subframe_nbslots, /* i/o: subframe grid */ - int16_t *nb_subframes /* i/o: number of subframes in the frame */ + const int16_t nCldfbTs, /* i : number of time slots in the current frame */ + int16_t *subframe_nbslots, /* i/o: subframe grid */ + int16_t *nb_subframes /* i/o: number of subframes in the frame */ ); void ivas_jbm_dec_get_md_map( - const int16_t default_len, /* i : default frame length in metadata slots */ - 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 default_len, /* i : default frame length in metadata slots */ + 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 */ ); -int16_t ivas_jbm_dec_get_num_tc_channels( Decoder_Struct *st_ivas ); /* i : IVAS decoder handle */ +int16_t ivas_jbm_dec_get_num_tc_channels( + Decoder_Struct *st_ivas /* i : IVAS decoder handle */ +); TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( - Decoder_Struct *st_ivas /* i : IVAS decoder handle */ + Decoder_Struct *st_ivas /* i : IVAS decoder handle */ ); -int16_t ivas_jbm_dec_get_render_granularity( /* o : render granularity */ - const RENDERER_TYPE rendererType, /* i : renderer type */ - const int32_t output_Fs /* i : sampling rate */ +/*! r: render granularity */ +int16_t ivas_jbm_dec_get_render_granularity( + const RENDERER_TYPE rendererType, /* i : renderer type */ + const int32_t output_Fs /* i : sampling rate */ ); ivas_error ivas_jbm_dec_tc_buffer_open( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ - const int16_t nchan_transport_jbm, /* i : number of real transport channels */ - const int16_t nchan_transport_internal, /* i : number of totally buffered channels */ - const int16_t nchan_full, /* i : nubmer of channels to fully store */ - const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ + const int16_t nchan_transport_jbm, /* i : number of real transport channels */ + const int16_t nchan_transport_internal, /* i : number of totally buffered channels */ + const int16_t nchan_full, /* i : nubmer of channels to fully store */ + const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ ); ivas_error ivas_jbm_dec_tc_buffer_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ - const int16_t nchan_transport_jbm, /* i : new number of real transport channels */ - const int16_t nchan_transport_internal, /* i : new number of totally buffered channels */ - const int16_t nchan_full, /* i : new number of channels to fully store */ - const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ + const int16_t nchan_transport_jbm, /* i : new number of real transport channels */ + const int16_t nchan_transport_internal, /* i : new number of totally buffered channels */ + const int16_t nchan_full, /* i : new number of channels to fully store */ + const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ ); void ivas_jbm_dec_tc_buffer_close( - DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ + DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ); + void ivas_jbm_dec_td_renderers_adapt_subframes( - Decoder_Struct *st_ivas + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); #endif diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 13a062fd93..48bfde33aa 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -51,18 +51,21 @@ /*-----------------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------------*/ + static void ivas_jbm_dec_copy_tc( Decoder_Struct *st_ivas, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *data, float *tc_digest_f[] ); + static void ivas_jbm_dec_tc_buffer_playout( Decoder_Struct *st_ivas, const uint16_t nSamplesAsked, uint16_t *nSamplesRendered, float *output[] ); /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc() * - * Principal IVAS decoder routine, decoding of metadata and transport channels + * Principal IVAS JBM decoder routine, decoding of metadata and transport channels *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *data /* o : transport channel signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *data /* o : transport channel signal */ ) { int16_t n, output_frame, nchan_out; @@ -535,10 +538,11 @@ ivas_error ivas_jbm_dec_tc( return error; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_feed_tc_to_renderer() * - * Feed decoded transport channels and metadata to the IVAS renderer routine + * Feed decoded transport channels and metadata to the IVAS JBM renderer routine *--------------------------------------------------------------------------*/ ivas_error ivas_jbm_dec_feed_tc_to_renderer( @@ -623,8 +627,9 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer( /*--------------------------------------------------------------------------* * ivas_dec_render() * - * Principal IVAS rendering routine + * Principal IVAS JBM rendering routine *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const uint16_t nSamplesAsked, /* i : number of samples wanted */ @@ -633,7 +638,6 @@ ivas_error ivas_jbm_dec_render( int16_t *data /* o : output synthesis signal */ ) { - int16_t n, nchan_out; int16_t nchan_transport; float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; /* 'float' buffer for output synthesis, MAX_OUTPUT_CHANNELS channels */ /* IVAS_fmToDo: buffer can be allocated dynamically based on the actual number of output channels */ @@ -658,6 +662,7 @@ ivas_error ivas_jbm_dec_render( nchan_transport = st_ivas->hTcBuffer->nchan_transport_jbm; 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]; @@ -817,6 +822,7 @@ ivas_error ivas_jbm_dec_render( { return error; } + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->tc, p_output ); } else if ( st_ivas->renderer_type == RENDERER_MC ) @@ -844,8 +850,6 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { - - /* Rendering */ int16_t offset = st_ivas->hDirAC->slots_rendered * st_ivas->hDirAC->slot_size; nchan_remapped = st_ivas->nchan_transport; @@ -857,7 +861,6 @@ ivas_error ivas_jbm_dec_render( { ivas_dirac_dec_render( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); - if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { /* we still need to copy the separate channel if available */ @@ -899,8 +902,10 @@ ivas_error ivas_jbm_dec_render( * - compensation for saturation * - float to integer conversion *----------------------------------------------------------------*/ + st_ivas->hTcBuffer->n_samples_available -= *nSamplesRendered; st_ivas->hTcBuffer->n_samples_rendered += *nSamplesRendered; + if ( st_ivas->hTcBuffer->n_samples_discard > 0 ) { for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) @@ -930,6 +935,7 @@ ivas_error ivas_jbm_dec_render( * * Flush samples if renderer granularity changes on a bitrate change *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_flush_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t tc_granularity_new, /* i : new renderer granularity */ @@ -963,7 +969,8 @@ ivas_error ivas_jbm_dec_flush_renderer( assert( n_samples_still_available < tc_granularity_new ); if ( n_slots_still_available ) { - int ch_idx; + int16_t ch_idx; + /* render what is still there with zero padding */ for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) { @@ -972,6 +979,7 @@ ivas_error ivas_jbm_dec_flush_renderer( set_zero( hTcBuffer->tc[ch_idx] + n_samples_to_render, hTcBuffer->n_samples_granularity - n_samples_to_render ); mvr2r( hTcBuffer->tc[ch_idx] + hTcBuffer->n_samples_rendered + n_samples_to_render, hTcBuffer->tc[ch_idx] + hTcBuffer->n_samples_granularity, n_samples_still_available ); } + /* simple change of the slot info */ hTcBuffer->num_slots = 1; hTcBuffer->nb_subframes = 1; @@ -1001,7 +1009,9 @@ ivas_error ivas_jbm_dec_flush_renderer( { /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ set_f( st_ivas->hIsmRendererData->interpolator, 1.0f, hTcBuffer->n_samples_granularity ); + ivas_ism_render_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ); + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM, @@ -1046,11 +1056,13 @@ ivas_error ivas_jbm_dec_flush_renderer( { return error; } + ivas_binaural_add_LFE( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc, p_output ); } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { ObjRenderIVASSubframe( st_ivas, p_output, hTcBuffer->n_samples_granularity ); + ivas_binaural_add_LFE( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc, p_output ); } } @@ -1082,6 +1094,7 @@ ivas_error ivas_jbm_dec_flush_renderer( * * Set number of samples to discard in the first subframe if the renderer granularity changes on a bitrate change *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_set_discard_samples( Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ ) @@ -1100,9 +1113,11 @@ ivas_error ivas_jbm_dec_set_discard_samples( /* set last subframes number to max to ensure correct continuation */ st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nMaxSlotsPerSubframe; } + return error; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_adapted_linear_interpolator() * @@ -1141,13 +1156,17 @@ void ivas_jbm_dec_get_adapted_linear_interpolator( { set_f( interpolator, 0.0f, idx + 1 ); } + + return; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_adapted_subframes() * * Get an interpolator that is adapted to time scale modified IVAS frame *--------------------------------------------------------------------------*/ + void ivas_jbm_dec_get_adapted_subframes( const int16_t nCldfbTs, /* i : number of time slots in the current frame */ int16_t *subframe_nbslots, /* i/o: subframe grid */ @@ -1156,6 +1175,7 @@ void ivas_jbm_dec_get_adapted_subframes( { uint16_t nSlotsInLastSubframe, nSlotsInFirstSubframe; uint16_t nCldfbSlotsLocal = nCldfbTs; + /* get last subframe size from previous frame, determine how many slots have to be processed in the first subframe (i.e. potential leftover of a 5ms subframe) */ nSlotsInFirstSubframe = ( PARAM_MC_MAX_NSLOTS_IN_SUBFRAME - subframe_nbslots[*nb_subframes - 1] ); @@ -1165,10 +1185,13 @@ void ivas_jbm_dec_get_adapted_subframes( *nb_subframes = 1; nCldfbSlotsLocal -= nSlotsInFirstSubframe; } + *nb_subframes += (int16_t) ceilf( (float) nCldfbSlotsLocal / (float) PARAM_MC_MAX_NSLOTS_IN_SUBFRAME ); nSlotsInLastSubframe = nCldfbSlotsLocal % PARAM_MC_MAX_NSLOTS_IN_SUBFRAME; + set_s( subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set_s( subframe_nbslots, PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, *nb_subframes ); + if ( nSlotsInFirstSubframe > 0 ) { subframe_nbslots[0] = nSlotsInFirstSubframe; @@ -1177,14 +1200,17 @@ void ivas_jbm_dec_get_adapted_subframes( { subframe_nbslots[*nb_subframes - 1] = nSlotsInLastSubframe; } + return; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_adapted_linear_interpolator() * * Get an meta data map adapted to a time scale modified IVAS frame *--------------------------------------------------------------------------*/ + void ivas_jbm_dec_get_md_map( const int16_t default_len, /* i : default frame length in metadata slots */ const int16_t len, /* i : length of the modfied frames in metadata slots */ @@ -1196,19 +1222,19 @@ void ivas_jbm_dec_get_md_map( { int16_t jbm_segment_len, map_idx, src_idx, src_idx_map; float dec, src_idx_f; + #ifdef DEBUGGING assert( default_len % 2 == 0 ); #endif - jbm_segment_len = ( default_len >> 1 ); dec = 1.0f / default_len; - for ( map_idx = len - 1, src_idx = default_len - 1; map_idx >= jbm_segment_len; map_idx--, src_idx-- ) { src_idx_map = max( 0, src_idx / subframe_len ); map[map_idx] = ( offset + src_idx_map ) % buf_len; } + /* changed part (first segment), interpolate index to parameters (we do not want to interpolate and smooth acutal direction/diffuseness values even more) */ if ( src_idx >= 0 ) @@ -1226,14 +1252,20 @@ void ivas_jbm_dec_get_md_map( { set_s( map, offset, map_idx + 1 ); } + + return; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_num_tc_channels() * * Get the number of transport channels provided by the JBM transport channel decode function *--------------------------------------------------------------------------*/ -int16_t ivas_jbm_dec_get_num_tc_channels( Decoder_Struct *st_ivas ) /* i : IVAS decoder handle */ + +int16_t ivas_jbm_dec_get_num_tc_channels( + Decoder_Struct *st_ivas /* i : IVAS decoder handle */ +) { int16_t num_tc; int32_t ivas_total_brate; @@ -1329,12 +1361,14 @@ int16_t ivas_jbm_dec_get_num_tc_channels( Decoder_Struct *st_ivas ) /* i : IVAS return num_tc; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_copy_tc() * * Copy interleaved transport chnannels to the correct buffers, update the TC * buffer handle *--------------------------------------------------------------------------*/ + void ivas_jbm_dec_copy_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSamplesForRendering, /* i : number of samples to digest */ @@ -1349,7 +1383,6 @@ void ivas_jbm_dec_copy_tc( int16_t n_ch_full_copy; int16_t n_ch_res_copy; - hTcBuffer = st_ivas->hTcBuffer; n_samples_still_available = hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered; hTcBuffer->n_samples_buffered = n_samples_still_available + nSamplesForRendering + hTcBuffer->n_samples_discard; @@ -1380,12 +1413,22 @@ void ivas_jbm_dec_copy_tc( } } hTcBuffer->n_samples_rendered = 0; + return; } -int16_t ivas_jbm_dec_get_render_granularity( const RENDERER_TYPE rendererType, - const int32_t output_Fs ) +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_get_render_granularity() + * + * + *--------------------------------------------------------------------------*/ + +/*! r: render granularity */ +int16_t ivas_jbm_dec_get_render_granularity( + const RENDERER_TYPE rendererType, /* i : renderer type */ + const int32_t output_Fs /* i : sampling rate */ +) { int16_t render_granularity; @@ -1401,11 +1444,13 @@ int16_t ivas_jbm_dec_get_render_granularity( const RENDERER_TYPE rendererType, return render_granularity; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc_buffer_open() * - * open and initialize the transport channel buffer + * open and initialize JBM transport channel buffer *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_tc_buffer_open( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ @@ -1430,8 +1475,9 @@ ivas_error ivas_jbm_dec_tc_buffer_open( if ( ( hTcBuffer = (DECODER_TC_BUFFER_HANDLE) malloc( sizeof( DECODER_TC_BUFFER ) ) ) == NULL ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TC Buffer\n" ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); } + hTcBuffer->tc_buffer_mode = tc_buffer_mode; hTcBuffer->nchan_transport_jbm = nchan_transport_jbm; hTcBuffer->nchan_transport_internal = nchan_transport_internal; @@ -1465,11 +1511,16 @@ ivas_error ivas_jbm_dec_tc_buffer_open( int16_t n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) + hTcBuffer->n_samples_granularity - 1 ); int16_t n_samp_residual = hTcBuffer->n_samples_granularity - 1; int32_t offset; + nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; nsamp_to_allocate += nchan_residual * n_samp_residual; - hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ); + if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); + } set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); offset = 0; + for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) { hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; @@ -1487,14 +1538,17 @@ ivas_error ivas_jbm_dec_tc_buffer_open( } st_ivas->hTcBuffer = hTcBuffer; + return error; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc_buffer_reconfigure() * - * open and initialize the transport channel buffer + * open and initialize JBM transport channel buffer *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_tc_buffer_reconfigure( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ @@ -1561,7 +1615,12 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( n_samp_residual = hTcBuffer->n_samples_granularity - 1; nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; nsamp_to_allocate += nchan_residual * n_samp_residual; - hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ); + + if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); + } + set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); offset = 0; for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) @@ -1582,7 +1641,14 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( return error; } -void ivas_jbm_dec_tc_buffer_playout( + +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_tc_buffer_playout() + * + * + *--------------------------------------------------------------------------*/ + +static void ivas_jbm_dec_tc_buffer_playout( Decoder_Struct *st_ivas, const uint16_t nSamplesAsked, uint16_t *nSamplesRendered, @@ -1592,6 +1658,7 @@ void ivas_jbm_dec_tc_buffer_playout( int16_t ch_idx, slot_size, slots_to_render, first_sf, last_sf; slot_size = st_ivas->hTcBuffer->n_samples_granularity; + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, nSamplesAsked / slot_size ); st_ivas->hTcBuffer->slots_rendered += slots_to_render; @@ -1609,8 +1676,17 @@ void ivas_jbm_dec_tc_buffer_playout( } st_ivas->hTcBuffer->subframes_rendered = last_sf; + + return; } + +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_tc_buffer_close() + * + * Close JBM transport channel buffer + *--------------------------------------------------------------------------*/ + void ivas_jbm_dec_tc_buffer_close( DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ) @@ -1632,20 +1708,31 @@ void ivas_jbm_dec_tc_buffer_close( free( *phTcBuffer ); *phTcBuffer = NULL; } + return; } + +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_td_renderers_adapt_subframes() + * + * Close JBM transport channel buffer + *--------------------------------------------------------------------------*/ + void ivas_jbm_dec_td_renderers_adapt_subframes( - Decoder_Struct *st_ivas ) + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) { int16_t nMaxSlotsPerSubframe, nSlotsAvailable; uint16_t nSlotsInLastSubframe, nSlotsInFirstSubframe; + nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; nSlotsAvailable = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; st_ivas->hTcBuffer->num_slots = nSlotsAvailable; st_ivas->hTcBuffer->n_samples_available = nSlotsAvailable * st_ivas->hTcBuffer->n_samples_granularity; nSlotsInFirstSubframe = nMaxSlotsPerSubframe - st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; st_ivas->hTcBuffer->nb_subframes = 0; + if ( nSlotsInFirstSubframe > 0 ) { st_ivas->hTcBuffer->nb_subframes = 1; @@ -1655,19 +1742,32 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( nSlotsInLastSubframe = nSlotsAvailable % nMaxSlotsPerSubframe; set_s( st_ivas->hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set_s( st_ivas->hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, st_ivas->hTcBuffer->nb_subframes ); + if ( nSlotsInFirstSubframe > 0 ) { st_ivas->hTcBuffer->subframe_nbslots[0] = nSlotsInFirstSubframe; } + if ( nSlotsInLastSubframe > 0 ) { st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nSlotsInLastSubframe; } + st_ivas->hTcBuffer->slots_rendered = 0; st_ivas->hTcBuffer->subframes_rendered = 0; + + return; } -TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( Decoder_Struct *st_ivas ) +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_get_tc_buffer_mode() + * + * + *--------------------------------------------------------------------------*/ + +TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) { TC_BUFFER_MODE buffer_mode; buffer_mode = TC_BUFFER_MODE_BUFFER; @@ -1736,7 +1836,6 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( Decoder_Struct *st_ivas ) #endif } - return buffer_mode; } #endif -- GitLab From 59fec700eefaa9aa1b31753abc13ff0f4ae3e4d7 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 15 May 2023 18:30:44 +0200 Subject: [PATCH 20/23] formal issues within SWITCHING_FORMAT_DEC --- apps/decoder.c | 20 +-- lib_com/fd_cng_com.c | 2 +- lib_com/ivas_cnst.h | 1 + lib_com/ivas_prot.h | 176 ++++++++++--------- lib_com/ivas_td_decorr.c | 2 +- lib_dec/fd_cng_dec.c | 2 - lib_dec/ivas_binRenderer_internal.c | 14 +- lib_dec/ivas_dirac_dec.c | 41 ++++- lib_dec/ivas_dirac_output_synthesis_cov.c | 15 +- lib_dec/ivas_init_dec.c | 23 ++- lib_dec/ivas_ism_dec.c | 13 +- lib_dec/ivas_ism_dtx_dec.c | 1 + lib_dec/ivas_ism_param_dec.c | 112 ++++++++---- lib_dec/ivas_ism_renderer.c | 11 +- lib_dec/ivas_jbm_dec.c | 125 ++++++------- lib_dec/ivas_masa_dec.c | 6 +- lib_dec/ivas_mct_dec.c | 5 +- lib_dec/ivas_objectRenderer_internal.c | 30 +++- lib_dec/ivas_out_setup_conversion.c | 2 +- lib_dec/ivas_sba_dec.c | 46 ++++- lib_dec/ivas_sba_rendering_internal.c | 5 +- lib_dec/ivas_spar_decoder.c | 64 ++++++- lib_dec/ivas_stat_dec.h | 13 +- lib_dec/jbm_pcmdsp_apa.c | 4 +- lib_dec/lib_dec.c | 57 ++++-- lib_dec/lib_dec.h | 18 +- lib_rend/ivas_crend.c | 42 +++-- lib_rend/ivas_dirac_dec_binaural_functions.c | 41 +++-- lib_rend/ivas_objectRenderer.c | 3 +- lib_rend/ivas_prot_rend.h | 52 +++--- lib_rend/ivas_rotation.c | 2 +- lib_rend/ivas_sba_rendering.c | 3 + lib_rend/lib_rend.c | 9 +- 33 files changed, 616 insertions(+), 344 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index bc0e7cfbf5..1e1052cde6 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -84,7 +84,6 @@ static #endif #ifdef JBM_TSM_ON_TCS #define JBM_FRONTEND_FETCH_FRAMESIZE_MS 20 -#define FRAME_SIZE_NS 20000000L #endif typedef struct @@ -2569,6 +2568,7 @@ static ivas_error decodeVariableSpeed( #endif nSamplesAvailableNext = 0; nOutSamples = (int16_t) ( arg.output_Fs / 1000 * VARIABLE_SPEED_FETCH_FRAMESIZE_MS ); + /*------------------------------------------------------------------------------------------* * Loop for every packet (frame) of bitstream data * - Read the bitstream packet @@ -2636,13 +2636,10 @@ static ivas_error decodeVariableSpeed( /* decode and get samples */ do { - error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, - pcmBuf, 0, - &nSamplesAvailableNext + error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, 0, &nSamplesAvailableNext #ifdef SUPPORT_JBM_TRACEFILE , - writeJbmTraceFileFrameWrapper, - jbmTraceWriter + writeJbmTraceFileFrameWrapper, jbmTraceWriter #endif ); if ( error != IVAS_ERR_OK && error != IVAS_ERR_VS_FRAME_NEEDED ) @@ -2741,7 +2738,6 @@ static ivas_error decodeVariableSpeed( } } - /* Write current frame */ if ( decodedGoodFrame ) { @@ -2828,6 +2824,7 @@ static ivas_error decodeVariableSpeed( /*------------------------------------------------------------------------------------------* * Flush what is still left in the VoIP Buffers.... *------------------------------------------------------------------------------------------*/ + while ( nSamplesAvailableNext > 0 ) { int16_t nSamplesFlushed; @@ -2888,25 +2885,19 @@ static ivas_error decodeVariableSpeed( } /* decode and get samples */ - if ( ( error = IVAS_DEC_VoIP_Flush( hIvasDec, nOutSamples, - pcmBuf, - &nSamplesAvailableNext, - &nSamplesFlushed ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_VoIP_Flush( hIvasDec, nOutSamples, pcmBuf, &nSamplesAvailableNext, &nSamplesFlushed ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } - /* Write current frame */ - if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, nSamplesFlushed * nOutChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nOutput audio file writer error\n" ); goto cleanup; } - /* Write ISm metadata to external file(s) */ if ( decodedGoodFrame && arg.outputFormat == IVAS_DEC_OUTPUT_EXT ) { @@ -2964,6 +2955,7 @@ static ivas_error decodeVariableSpeed( #endif } } + /*------------------------------------------------------------------------------------------* * Printouts after decoding has finished *------------------------------------------------------------------------------------------*/ diff --git a/lib_com/fd_cng_com.c b/lib_com/fd_cng_com.c index 99ae9894f4..e31ce67d13 100644 --- a/lib_com/fd_cng_com.c +++ b/lib_com/fd_cng_com.c @@ -966,7 +966,6 @@ void SynthesisSTFT_dirac( mvr2r( olapBuffer + hFdCngCom->frameSize, olapBuffer, hFdCngCom->frameSize ); set_f( olapBuffer + hFdCngCom->frameSize, 0.0f, hFdCngCom->frameSize ); /*olapBuffer, fftBuffer, olapWin*/ - for ( i = hFdCngCom->frameSize / 4; i < 3 * hFdCngCom->frameSize / 4; i++ ) { olapBuffer[i] += fftBuffer[i] * olapWin[i - hFdCngCom->frameSize / 4]; @@ -1009,6 +1008,7 @@ void SynthesisSTFT_dirac( } #endif + /*------------------------------------------------------------------- * mhvals() * diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 8d9beb6f18..3907008f8a 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -219,6 +219,7 @@ typedef enum #define MAX_JBM_L_FRAME_NS 40000000L #define MAX_SPAR_INTERNAL_CHANNELS IVAS_SPAR_MAX_CH #define MAX_CLDFB_DIGEST_CHANNELS 4 + typedef enum { TC_BUFFER_MODE_NONE = 0, diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index d4823028cb..f2ba6a7d45 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -767,7 +767,7 @@ void dtx_read_padding_bits( ivas_error ivas_jbm_dec_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *data /* o : output synthesis signal */ + float *data /* o : output synthesis signals */ ); ivas_error ivas_jbm_dec_render( @@ -792,8 +792,8 @@ ivas_error ivas_jbm_dec_flush_renderer( ivas_error ivas_jbm_dec_feed_tc_to_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ - int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ + const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ + int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ float *data /* i/o: transport channels/output synthesis signal */ ); @@ -841,7 +841,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open( const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ const int16_t nchan_transport_jbm, /* i : number of real transport channels */ const int16_t nchan_transport_internal, /* i : number of totally buffered channels */ - const int16_t nchan_full, /* i : nubmer of channels to fully store */ + const int16_t nchan_full, /* i : number of channels to fully store */ const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ ); @@ -1021,8 +1021,8 @@ ivas_error ivas_ism_dec_config( const ISM_MODE last_ism_mode /* i/o: last ISM mode */ #ifdef JBM_TSM_ON_TCS , - uint16_t *nSamplesRendered, /* o : number of samples flushed on renderer change */ - int16_t *data /* o : flushed PCM samples */ + uint16_t *nSamplesRendered, /* o : number of samples flushed on renderer change*/ + int16_t *data /* o : flushed PCM samples */ #endif ); @@ -1042,21 +1042,21 @@ void ivas_param_ism_dec( #ifdef JBM_TSM_ON_TCS void ivas_ism_dec_digest_tc( - Decoder_Struct *st_ivas + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); void ivas_param_ism_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ ); void ivas_param_ism_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 *output_f[] /* o : rendered time signal */ + 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 *output_f[] /* o : rendered time signal */ ); #endif @@ -3428,12 +3428,12 @@ ivas_error ivas_sba_dec_reconfigure( #ifdef JBM_TSM_ON_TCS ivas_error ivas_sba_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t nCldfbSlots, /* i : number of CLDFB slots */ - const int16_t nSamplesForRendering, /* i : number of samples provided */ - float *data[] /* i : transport channel samples */ - ); + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t nCldfbSlots, /* i : number of CLDFB slots */ + const int16_t nSamplesForRendering, /* i : number of samples provided */ + float *data[] /* i : transport channel samples */ +); #endif void ivas_init_dec_get_num_cldfb_instances( @@ -3634,31 +3634,32 @@ void ivas_dirac_dec_read_BS( #ifdef JBM_TSM_ON_TCS void generate_masking_noise_lb_dirac( - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */ - const int16_t nCldfbTs, /* i : number of CLDFB slots that will be rendered */ - const int16_t cna_flag /* i : CNA flag for LB and HB */ + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */ + const int16_t nCldfbTs, /* i : number of CLDFB slots that will be rendered */ + const int16_t cna_flag /* i : CNA flag for LB and HB */ ); void ivas_dirac_dec_set_md_map( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t nCldfbTs ); + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nCldfbTs /* i : number of CLDFB time slots */ +); void ivas_dirac_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t nchan_transport /* i : number of transport channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ + const int16_t nchan_transport /* i : number of transport channels */ ); #endif #ifdef JBM_TSM_ON_TCS void ivas_dirac_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - 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 *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t nchan_transport, /* i : number of transport channels */ + 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 *output_f[] /* o : rendered time signal */ ); #endif @@ -3669,9 +3670,9 @@ void ivas_dirac_dec_render_sf( #endif Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ #ifdef JBM_TSM_ON_TCS - float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ + float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ #else - float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ + float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ #endif const int16_t nchan_transport, /* i : number of transport channels */ float *pppQMfFrame_ts_re[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX], @@ -4512,46 +4513,46 @@ int16_t ivas_is_res_channel( #ifdef JBM_TSM_ON_TCS void ivas_spar_dec_agc_pca( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float output[][L_FRAME48k], /* i/o: input/output audio channels */ - const int16_t output_frame /* i : output frame length */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + float output[][L_FRAME48k], /* i/o: input/output audio channels */ + const int16_t output_frame /* i : output frame length */ ); void ivas_spar_dec_set_render_map( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t nCldfbTs + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nCldfbTs /* i : number of CLDFB time slots */ ); void ivas_spar_dec_set_render_params( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t n_cldfb_slots /* i : number of cldfb slots in this frame */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t n_cldfb_slots /* i : number of cldfb slots in this frame */ ); void ivas_spar_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t nCldfbSlots, /* i : number of CLDFB slots */ - const int16_t nSamplesForRendering /* i : number of samples provided */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t nCldfbSlots, /* i : number of CLDFB slots */ + const int16_t nSamplesForRendering /* i : number of samples provided */ ); ivas_error ivas_sba_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nCldfbSlots, /* i : number of CLDFB slots */ - const int16_t nSamplesForRendering /* i : number of samples provided */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t nCldfbSlots, /* i : number of CLDFB slots */ + const int16_t nSamplesForRendering /* i : number of samples provided */ ); void 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 */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + 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 *output_f[] /* o : rendered time signal */ ); void ivas_spar_dec_upmixer_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *output[], /* o : output audio channels */ - const int16_t nchan_internal /* i : number of internal channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + float *output[], /* o : output audio channels */ + const int16_t nchan_internal /* i : number of internal channels */ ); #endif @@ -5236,9 +5237,10 @@ void ivas_binaural_cldfb( #ifdef JBM_TSM_ON_TCS void ivas_binaural_cldfb_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t n_samples_to_render, - float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ + ); #endif @@ -5278,7 +5280,7 @@ ivas_error ivas_ism_renderer_open( void ivas_ism_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ #ifdef JBM_TSM_ON_TCS - float *output_f[], /* i/o: core-coder transport channels/object output */ + float *output_f[], /* i/o: core-coder transport channels/object output */ #else float output_f[][L_FRAME48k], /* i/o: core-coder transport channels/object output */ #endif @@ -5287,9 +5289,9 @@ void ivas_ism_render( #ifdef JBM_TSM_ON_TCS void ivas_ism_render_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output_f[], /* i/o: core-coder transport channels/object output */ - const int16_t n_samples_to_render /* 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 n_samples_to_render /* i : output frame length per channel */ ); #endif @@ -5315,9 +5317,9 @@ void ivas_mc2sba( void ivas_ism2sba( #ifdef JBM_TSM_ON_TCS - float *buffer_td[], /* i/o: TD signal buffers */ + float *buffer_td[], /* i/o: TD signal buffers */ #else - float buffer_td[][L_FRAME48k], /* i/o: TD signal buffers */ + float buffer_td[][L_FRAME48k], /* i/o: TD signal buffers */ #endif ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */ const ISM_METADATA_HANDLE hIsmMetaData[], /* i : object metadata */ @@ -5328,15 +5330,17 @@ void ivas_ism2sba( #ifdef JBM_TSM_ON_TCS void ivas_ism2sba_sf( - float *buffer_in[], /* i : TC buffer */ - float *buffer_out[], /* o : TD signal buffers */ - ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */ - const int16_t num_objects, /* i : number of objects */ - const int16_t n_samples_to_render, /* i : output frame length per channel */ - const int16_t offset, /* i : offset for the interpolatr */ - const int16_t sba_order /* i : Ambisonic (SBA) order */ + float *buffer_in[], /* i : TC buffer */ + float *buffer_out[], /* o : TD signal buffers */ + ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */ + const int16_t num_objects, /* i : number of objects */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + const int16_t offset, /* i : offset for the interpolatr */ + const int16_t sba_order /* i : Ambisonic (SBA) order */ ); #endif + + /*----------------------------------------------------------------------------------* * Amplitude Panning VBAP prototypes *----------------------------------------------------------------------------------*/ @@ -5393,10 +5397,10 @@ void ivas_ls_setup_conversion( #endif const int16_t output_frame, /* i : frame length */ #ifdef JBM_TSM_ON_TCS - float *input[], /* i : LS input/output synthesis signal */ - float *output[] /* i/o: LS input/output synthesis signal */ + float *input[], /* i : LS input/output synthesis signal */ + float *output[] /* i/o: LS input/output synthesis signal */ #else - float output[][L_FRAME48k] /* i/o: LS input/output synthesis signal */ + float output[][L_FRAME48k] /* i/o: LS input/output synthesis signal */ #endif ); @@ -5413,7 +5417,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( void ivas_lssetupconversion_process_param_mc( Decoder_Struct *st_ivas, /* i/o: LS setup conversion renderer handle */ #ifdef JBM_TSM_ON_TCS - int16_t num_timeslots, /* i : number of time slots to process */ + const int16_t num_timeslots, /* i : number of time slots to process */ #endif float Cldfb_RealBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ float Cldfb_ImagBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ @@ -5646,18 +5650,18 @@ ivas_error ivas_td_binaural_open( ivas_error ivas_td_binaural_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ #ifdef JBM_TSM_ON_TCS - float *output[], /* i/o: SCE channels / Binaural synthesis */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ #else - float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ + float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ #endif const int16_t output_frame /* i : output frame length */ ); #ifdef JBM_TSM_ON_TCS -void ObjRenderIVASSubframe( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[], /* i/o: SCE channels / Binaural synthesis */ - const int16_t output_frame /* i : output frame length */ +ivas_error ObjRenderIVASSubframe( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ + const int16_t output_frame /* i : output frame length */ ); #endif diff --git a/lib_com/ivas_td_decorr.c b/lib_com/ivas_td_decorr.c index 9a08c06f6a..7714915177 100644 --- a/lib_com/ivas_td_decorr.c +++ b/lib_com/ivas_td_decorr.c @@ -480,7 +480,7 @@ static void ivas_td_decorr_APD_sections( void ivas_td_decorr_process( ivas_td_decorr_state_t *hTdDecorr, /* i/o: SPAR Covar. decoder handle */ #ifdef JBM_TSM_ON_TCS - float *pcm_in[], + float *pcm_in[], /* i : input audio channels */ #else float pcm_in[][L_FRAME48k], /* i : input audio channels */ #endif diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index f9c3f59182..4d832de52e 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -1829,7 +1829,6 @@ void generate_masking_noise_lb_dirac( n_samples_out = hFdCngCom->frameSize / DEFAULT_JBM_CLDFB_TIMESLOTS * nCldfbTs; n_samples_start = 0; - /*LB CLDFB - CNA from STFT*/ #ifdef DEBUG_MODE_DIRAC { @@ -1951,7 +1950,6 @@ void generate_masking_noise_lb_dirac( return; } - #endif diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index bfe0a4bb53..5de5f881fa 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -997,17 +997,19 @@ void ivas_binaural_cldfb( return; } + + #ifdef JBM_TSM_ON_TCS /*-------------------------------------------------------------------------* - * ivas_binaural_cldfb() + * ivas_binaural_cldfb_sf() * * Perform CLDFB analysis, fastconv binaural rendering and CLDFB synthesis *-------------------------------------------------------------------------*/ void ivas_binaural_cldfb_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t n_samples_to_render, - float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ ) { float Cldfb_RealBuffer[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; @@ -1021,6 +1023,7 @@ void ivas_binaural_cldfb_sf( /* Implement a 5 msec loops */ maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * st_ivas->hDecoderConfig->output_Fs ) / 48000 ); slot_size = st_ivas->hTcBuffer->nb_subframes; + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, n_samples_to_render / slot_size ); first_sf = st_ivas->hTcBuffer->subframes_rendered; @@ -1028,6 +1031,7 @@ void ivas_binaural_cldfb_sf( slot_index_start = st_ivas->hTcBuffer->slots_rendered; slot_index_start_cldfb = 0; st_ivas->hTcBuffer->slots_rendered += slots_to_render; + while ( slots_to_render > 0 ) { slots_to_render -= st_ivas->hTcBuffer->subframe_nbslots[last_sf]; @@ -1086,7 +1090,9 @@ void ivas_binaural_cldfb_sf( slot_index_start += st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; slot_index_start_cldfb += st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; } + st_ivas->hTcBuffer->subframes_rendered = last_sf; + return; } #endif diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index b73c59c2c9..6ed885c744 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2601,9 +2601,11 @@ void ivas_qmetadata_to_dirac( * * Set metadata index mapping for DirAC *------------------------------------------------------------------------*/ + void ivas_dirac_dec_set_md_map( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t nCldfbTs ) + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nCldfbTs /* i : number of CLDFB time slots */ +) { int16_t num_slots_in_subfr; DIRAC_DEC_HANDLE hDirAC; @@ -2645,6 +2647,7 @@ void ivas_dirac_dec_set_md_map( { float tmp; int16_t sf_idx, slot_idx, slot_idx_abs; + slot_idx_abs = 0; for ( sf_idx = 0; sf_idx < hDirAC->nb_subframes; sf_idx++ ) { @@ -2656,17 +2659,20 @@ void ivas_dirac_dec_set_md_map( } hDirAC->render_to_md_map[sf_idx] = ( (int16_t) roundf( tmp / (float) hDirAC->subframe_nbslots[sf_idx] ) + hDirAC->dirac_read_idx ) % hDirAC->dirac_md_buffer_length; } + set_s( &hDirAC->render_to_md_map[hDirAC->nb_subframes], 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME - hDirAC->nb_subframes ); } return; } + /*------------------------------------------------------------------------- * ivas_dirac_dec() * * DirAC decoding process *------------------------------------------------------------------------*/ + void ivas_dirac_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ @@ -2685,17 +2691,21 @@ void ivas_dirac_dec( { output_f_local[n] = &output_f[n][0]; } + for ( n = 0; n < nchan_transport; n++ ) { st_ivas->hTcBuffer->tc[n] = output_f[n]; } + if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->sba_mode != SBA_MODE_SPAR ) { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; st_ivas->hTcBuffer->tc[nchan_transport] = &cng_td_buffer[0]; generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], DEFAULT_JBM_CLDFB_TIMESLOTS, st->cna_dirac_flag && st->flag_cna ); } + ivas_dirac_dec_set_md_map( st_ivas, DEFAULT_JBM_CLDFB_TIMESLOTS ); + for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ ) { ivas_dirac_dec_render_sf( st_ivas, output_f_local, nchan_transport, NULL, NULL ); @@ -2704,6 +2714,7 @@ void ivas_dirac_dec( output_f_local[n] += n_samples_sf; } } + if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 ) { st_ivas->hDirAC->dirac_read_idx = ( st_ivas->hDirAC->dirac_read_idx + DEFAULT_JBM_CLDFB_TIMESLOTS ) % st_ivas->hDirAC->dirac_md_buffer_length; @@ -2724,13 +2735,20 @@ void ivas_dirac_dec( return; } + +/*------------------------------------------------------------------------- + * ivas_dirac_dec_render() + * + * DirAC decoding renderer process + *------------------------------------------------------------------------*/ + void ivas_dirac_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - 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 *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t nchan_transport, /* i : number of transport channels */ + 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 *output_f[] /* o : rendered time signal */ ) { int16_t slots_to_render, first_sf, last_sf, subframe_idx; @@ -2749,16 +2767,19 @@ void ivas_dirac_dec_render( output_f_local[ch] = output_f[ch]; } slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( hDirAC->num_slots - hDirAC->slots_rendered, nSamplesAsked / slot_size ); *nSamplesRendered = slots_to_render * slot_size; first_sf = hDirAC->subframes_rendered; last_sf = first_sf; + while ( slots_to_render > 0 ) { slots_to_render -= hDirAC->subframe_nbslots[last_sf]; last_sf++; } + #ifdef DEBUGGING assert( slots_to_render == 0 ); #endif @@ -2782,16 +2803,20 @@ void ivas_dirac_dec_render( st_ivas->hDirAC->dirac_read_idx = ( st_ivas->hDirAC->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % st_ivas->hDirAC->dirac_md_buffer_length; } } + *nSamplesAvailable = ( hDirAC->num_slots - hDirAC->slots_rendered ) * slot_size; + return; } #endif + /*------------------------------------------------------------------------- * ivas_dirac_dec() * * DirAC decoding process *------------------------------------------------------------------------*/ + #ifndef JBM_TSM_ON_TCS void ivas_dirac_dec( #else diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 892cfe4acb..44a9d7e597 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -104,8 +104,12 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( set_zero( h_dirac_output_synthesis_state->cx_old[idx], nchan_in * nchan_in ); set_zero( h_dirac_output_synthesis_state->cy_old[idx], nchan_out * nchan_out ); set_zero( h_dirac_output_synthesis_state->mixing_matrix_old[idx], nchan_out * nchan_in ); + #ifdef JBM_TSM_ON_TCS - h_dirac_output_synthesis_state->mixing_matrix[idx] = (float *) malloc( nchan_out * nchan_in * sizeof( float ) ); + if ( ( h_dirac_output_synthesis_state->mixing_matrix[idx] = (float *) malloc( nchan_out * nchan_in * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis matrix\n" ) ); + } set_zero( h_dirac_output_synthesis_state->mixing_matrix[idx], nchan_out * nchan_in ); #endif } @@ -118,6 +122,7 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( h_dirac_output_synthesis_state->mixing_matrix[idx] = NULL; #endif } + for ( idx = 0; idx < num_param_bands_residual; idx++ ) { if ( ( h_dirac_output_synthesis_state->mixing_matrix_res_old[idx] = (float *) malloc( nchan_out * nchan_out * sizeof( float ) ) ) == NULL ) @@ -125,8 +130,12 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n" ) ); } set_zero( h_dirac_output_synthesis_state->mixing_matrix_res_old[idx], nchan_out * nchan_out ); + #ifdef JBM_TSM_ON_TCS - h_dirac_output_synthesis_state->mixing_matrix_res[idx] = (float *) malloc( nchan_out * nchan_out * sizeof( float ) ); + if ( ( h_dirac_output_synthesis_state->mixing_matrix_res[idx] = (float *) malloc( nchan_out * nchan_out * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis matrix\n" ) ); + } set_zero( h_dirac_output_synthesis_state->mixing_matrix_res[idx], nchan_out * nchan_out ); #endif } @@ -158,6 +167,7 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( return IVAS_ERR_OK; } + #ifdef JBM_TSM_ON_TCS /*-------------------------------------------------------------------* * ivas_dirac_dec_output_synthesis_cov_open() @@ -285,6 +295,7 @@ void ivas_dirac_dec_output_synthesis_cov_close( free( h_dirac_output_synthesis_state->mixing_matrix_res_old[idx] ); h_dirac_output_synthesis_state->mixing_matrix_res_old[idx] = NULL; } + #ifdef JBM_TSM_ON_TCS if ( h_dirac_output_synthesis_state->mixing_matrix[idx] != NULL ) { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index eeb77547bf..98ea0336ad 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -680,6 +680,9 @@ ivas_error ivas_init_decoder( int16_t i, k, n; int16_t sce_id, cpe_id; int16_t numCldfbAnalyses, numCldfbSyntheses; +#ifdef JBM_TSM_ON_TCS + int16_t granularity, n_channels_transport_jbm; +#endif int32_t output_Fs, ivas_total_brate; int32_t binauralization_delay_ns; AUDIO_CONFIG output_config; @@ -1333,13 +1336,13 @@ ivas_error ivas_init_decoder( return error; } } + #ifdef JBM_TSM_ON_TCS if ( st_ivas->hDecoderConfig->voip_active ) { - int16_t granularity; - int16_t n_channels_transport_jbm; granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) { return error; @@ -1378,13 +1381,13 @@ ivas_error ivas_init_decoder( } st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; + #ifdef JBM_TSM_ON_TCS if ( st_ivas->hDecoderConfig->voip_active ) { - int16_t granularity; - int16_t n_channels_transport_jbm; granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) { return error; @@ -1413,6 +1416,7 @@ ivas_error ivas_init_decoder( /*-----------------------------------------------------------------* * LFE handles for rendering after rendering to adjust LFE delay to binaural filter delay *-----------------------------------------------------------------*/ + #ifdef MC_PARAMUPMIX_MODE if ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) #else @@ -1488,15 +1492,21 @@ ivas_error ivas_init_decoder( } #ifdef JBM_TSM_ON_TCS + /*-----------------------------------------------------------------* + * Allocate and initialize JBM struct + buffer + *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->voip_active && st_ivas->hTcBuffer == NULL ) { /* no module has yet open the TC buffer, open a default one */ - int16_t n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) { return error; } } + if ( st_ivas->hTcBuffer == NULL ) { /* we need the handle anyway, but without the buffer*/ @@ -1510,9 +1520,6 @@ ivas_error ivas_init_decoder( return error; } -#ifdef JBM_TSM_ON_TCS - -#endif /*------------------------------------------------------------------------- * destroy_core_dec() diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 5a58a8bfae..37265e5e6a 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -55,8 +55,8 @@ static ivas_error ivas_ism_bitrate_switching_dec( const ISM_MODE last_ism_mode /* i : last ISM mode */ #ifdef JBM_TSM_ON_TCS , - uint16_t *nSamplesRendered, - int16_t *data + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + int16_t *data /* o : rendered samples */ #endif ) { @@ -66,7 +66,6 @@ static ivas_error ivas_ism_bitrate_switching_dec( #ifdef FIX_416_ISM_BR_SWITCHING int16_t numCldfbAnalyses_old, numCldfbSyntheses_old, ism_mode; #endif - #ifdef JBM_TSM_ON_TCS TC_BUFFER_MODE tc_buffer_mode_new; int16_t tc_nchan_tc_new; @@ -151,9 +150,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( st_ivas->hTcBuffer->slots_rendered = st_ivas->hDirAC->slots_rendered; mvs2s( st_ivas->hDirAC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } + /* 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->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 ) @@ -312,6 +313,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( /*-----------------------------------------------------------------* * Reconfigure TC buffer *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->voip_active == 1 ) { int16_t tc_nchan_full_new; @@ -322,15 +324,18 @@ static ivas_error ivas_ism_bitrate_switching_dec( tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas ); tc_nchan_allocate_new = tc_nchan_tc_new; tc_nchan_full_new = tc_nchan_tc_new; + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { tc_nchan_allocate_new = 2 * BINAURAL_CHANNELS; tc_nchan_full_new = tc_nchan_allocate_new; } + if ( st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX && st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { tc_nchan_full_new = 0; } + /* reconfigure buffer */ if ( hTcBuffer->tc_buffer_mode != tc_buffer_mode_new || hTcBuffer->nchan_transport_jbm != tc_nchan_tc_new || hTcBuffer->nchan_buffer_full != tc_nchan_full_new || hTcBuffer->nchan_transport_internal != tc_nchan_allocate_new ) @@ -340,6 +345,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( return error; } } + /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ if ( st_ivas->hDirAC != NULL ) { @@ -347,6 +353,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( st_ivas->hDirAC->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; st_ivas->hDirAC->num_slots = st_ivas->hTcBuffer->num_slots; st_ivas->hDirAC->slots_rendered = st_ivas->hTcBuffer->slots_rendered; + mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hDirAC->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } } diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec.c index b2bc737fa2..daf4b4b3ed 100644 --- a/lib_dec/ivas_ism_dtx_dec.c +++ b/lib_dec/ivas_ism_dtx_dec.c @@ -133,6 +133,7 @@ ivas_error ivas_ism_dtx_dec( ism_mode_bstr = (ISM_MODE) ( idx + 1 ); st_ivas->ism_mode = ism_mode_bstr; } + #ifdef JBM_TSM_ON_TCS if ( ( error = ivas_ism_dec_config( st_ivas, last_ism_mode, NULL, NULL ) ) != IVAS_ERR_OK ) #else diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 881886c6a1..cdc73ee81b 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -156,6 +156,7 @@ static void ivas_ism_get_proto_matrix( return; } + #ifdef JBM_TSM_ON_TCS static void ivas_param_ism_collect_slot( DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ @@ -184,9 +185,11 @@ static void ivas_param_ism_collect_slot( ref_power[bin_idx] += tmp; } } + return; } + static void ivas_param_ism_compute_mixing_matrix( const int16_t nchan_ism, /* i : number of ISM channels */ DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ @@ -403,6 +406,7 @@ static void ivas_param_ism_compute_mixing_matrix( } #endif + #ifdef JBM_TSM_ON_TCS static void ivas_param_ism_render_slot( DIRAC_DEC_HANDLE hDirAC, @@ -809,9 +813,16 @@ ivas_error ivas_param_ism_dec_open( } else { - hDirAC->hParamIsmRendering->Cldfb_RealBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands * sizeof( float ) ); + if ( ( hDirAC->hParamIsmRendering->Cldfb_RealBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Param ISM JBM Rendering handle\n" ) ); + } set_zero( hDirAC->hParamIsmRendering->Cldfb_RealBuffer_tc, MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands ); - hDirAC->hParamIsmRendering->Cldfb_ImagBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands * sizeof( float ) ); + + if ( ( hDirAC->hParamIsmRendering->Cldfb_ImagBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Param ISM JBM Rendering handle\n" ) ); + } set_zero( hDirAC->hParamIsmRendering->Cldfb_ImagBuffer_tc, MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands ); } if ( st_ivas->hTcBuffer == NULL ) @@ -1266,6 +1277,7 @@ void ivas_param_ism_dec( RealBuffer[i] = Cldfb_RealBuffer[idx_in][i]; ImagBuffer[i] = Cldfb_ImagBuffer[idx_in][i]; } + #ifdef JBM_TSM_ON_TCS cldfbSynthesis( RealBuffer, ImagBuffer, &( output_f[ch][slot_idx_start * hDirAC->num_freq_bands] ), hDirAC->num_freq_bands * hDirAC->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch] ); @@ -1304,21 +1316,29 @@ void ivas_param_ism_dec( } #ifdef JBM_TSM_ON_TCS + +/*-------------------------------------------------------------------------* + * ivas_ism_dec_digest_tc() + * + * + *-------------------------------------------------------------------------*/ + void ivas_ism_dec_digest_tc( - Decoder_Struct *st_ivas ) + 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 || - st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->hDecoderConfig->Opt_Headrotation == 0 ) ) + if ( st_ivas->renderer_type == RENDERER_TD_PANNING || + st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->hDecoderConfig->Opt_Headrotation == 0 ) ) { int16_t i, num_objects; int16_t azimuth, elevation; + /* we have a full frame interpolator, adapt it */ /* for BE testing */ if ( ( st_ivas->hDecoderConfig->output_Fs / (int32_t) FRAMES_PER_SECOND ) == st_ivas->hTcBuffer->n_samples_available ) @@ -1351,6 +1371,7 @@ void ivas_ism_dec_digest_tc( for ( i = 0; i < num_objects; i++ ) { mvr2r( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmRendererData->prev_gains[i], MAX_OUTPUT_CHANNELS ); + if ( st_ivas->intern_config == AUDIO_CONFIG_STEREO ) { ivas_ism_get_stereo_gains( st_ivas->hIsmMetaData[i]->azimuth, @@ -1363,15 +1384,15 @@ void ivas_ism_dec_digest_tc( // TODO tmu review when #215 is resolved azimuth = (int16_t) floorf( st_ivas->hIsmMetaData[i]->azimuth + 0.5f ); elevation = (int16_t) floorf( st_ivas->hIsmMetaData[i]->elevation + 0.5f ); + if ( ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) && st_ivas->hHeadTrackData == NULL ) { - - if ( st_ivas->hIntSetup.is_planar_setup ) { /* If no elevation support in output format, then rendering should be done with zero elevation */ elevation = 0; } + if ( st_ivas->hEFAPdata != NULL ) { efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], azimuth, elevation, EFAP_MODE_EFAP ); @@ -1385,13 +1406,21 @@ void ivas_ism_dec_digest_tc( } } } + return; } + +/*-------------------------------------------------------------------------* + * ivas_param_ism_dec_digest_tc() + * + * + *-------------------------------------------------------------------------*/ + void ivas_param_ism_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ ) { int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i; @@ -1401,7 +1430,6 @@ void ivas_param_ism_dec_digest_tc( float cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; /* Direct Response/EFAP Gains */ float direct_response[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN]; - DIRAC_DEC_HANDLE hDirAC; /* Initialization */ @@ -1520,21 +1548,27 @@ void ivas_param_ism_dec_digest_tc( /* 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, hDirAC->hParamIsmRendering->mixing_matrix_lin ); - pop_wmops(); return; } -static void ivas_ism_param_dec_render_sf( Decoder_Struct *st_ivas, - IVAS_OUTPUT_SETUP hSetup, - const int16_t nchan_transport, - const int16_t nchan_out, - const int16_t nchan_out_woLFE, - float *output_f[] /* o : rendered time signal */ + +/*-------------------------------------------------------------------------* + * ivas_ism_param_dec_render_sf() + * + * + *-------------------------------------------------------------------------*/ + +static void ivas_ism_param_dec_render_sf( + Decoder_Struct *st_ivas, + IVAS_OUTPUT_SETUP hSetup, + const int16_t nchan_transport, + const int16_t nchan_out, + const int16_t nchan_out_woLFE, + float *output_f[] /* o : rendered time signal */ ) { - int16_t ch, slot_idx, i, index_slot; /* CLDFB Output Buffers */ float Cldfb_RealBuffer[PARAM_ISM_MAX_CHAN][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; @@ -1572,7 +1606,6 @@ static void ivas_ism_param_dec_render_sf( Decoder_Struct *st_ivas, Cldfb_ImagBuffer_in[ch] = &hDirAC->hParamIsmRendering->Cldfb_ImagBuffer_tc[index_slot * hDirAC->num_freq_bands * nchan_transport + ch * hDirAC->num_freq_bands]; } - /* Compute bandwise rendering to target LS using covariance rendering */ ivas_param_ism_render_slot( hDirAC, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirAC->hParamIsmRendering->mixing_matrix_lin, index_slot, slot_idx, @@ -1609,16 +1642,26 @@ static void ivas_ism_param_dec_render_sf( Decoder_Struct *st_ivas, idx_in++; } } + hDirAC->slots_rendered += hDirAC->subframe_nbslots[subframe_idx]; hDirAC->subframes_rendered++; + + return; } + +/*-------------------------------------------------------------------------* + * ivas_param_ism_dec_render() + * + * + *-------------------------------------------------------------------------*/ + void ivas_param_ism_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 *output_f[] /* o : rendered time signal */ + 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 *output_f[] /* o : rendered time signal */ ) { int16_t ch, slots_to_render, first_sf, last_sf, subframe_idx; @@ -1646,11 +1689,13 @@ void ivas_param_ism_dec_render( nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; } slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( hDirAC->num_slots - hDirAC->slots_rendered, nSamplesAsked / slot_size ); *nSamplesRendered = slots_to_render * slot_size; first_sf = hDirAC->subframes_rendered; last_sf = first_sf; + while ( slots_to_render > 0 ) { slots_to_render -= hDirAC->subframe_nbslots[last_sf]; @@ -1659,10 +1704,12 @@ void ivas_param_ism_dec_render( #ifdef DEBUGGING assert( slots_to_render == 0 ); #endif + for ( ch = 0; ch < nchan_out; ch++ ) { output_f_local[ch] = &output_f[ch][0]; } + for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { ivas_ism_param_dec_render_sf( st_ivas, hSetup, nchan_transport, nchan_out, nchan_out_woLFE, output_f_local ); @@ -1672,6 +1719,7 @@ void ivas_param_ism_dec_render( output_f_local[ch] += n_samples_sf; } } + if ( hDirAC->slots_rendered == hDirAC->num_slots ) { /* copy the memories */ @@ -1693,10 +1741,11 @@ void ivas_param_ism_dec_render( st_ivas->hIsmMetaData[ch]->elevation = st_ivas->hDirAC->elevation_values[ch]; } } + *nSamplesAvailable = ( hDirAC->num_slots - hDirAC->slots_rendered ) * slot_size; + return; } - #endif @@ -1745,6 +1794,7 @@ void ivas_param_ism_params_to_masa_param_mapping( hDirAC->numSimultaneousDirections = 1; azimuth[0] = (int16_t) roundf( hDirAC->azimuth_values[0] ); elevation[0] = (int16_t) roundf( hDirAC->elevation_values[0] ); + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { for ( bin_idx = 0; bin_idx < nBins; bin_idx++ ) @@ -1788,6 +1838,7 @@ void ivas_param_ism_params_to_masa_param_mapping( } } } + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { for ( bin_idx = 0; bin_idx < nBins; bin_idx++ ) @@ -1804,6 +1855,7 @@ void ivas_param_ism_params_to_masa_param_mapping( hDirAC->numSimultaneousDirections = 1; azimuth[0] = (int16_t) roundf( hDirAC->azimuth_values[0] ); elevation[0] = (int16_t) roundf( hDirAC->elevation_values[0] ); + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { for ( bin_idx = 0; bin_idx < nBins; bin_idx++ ) diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 95c153fc80..f9461f894b 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -109,6 +109,7 @@ ivas_error ivas_ism_renderer_open( st_ivas->hIsmRendererData->interpolator[i] = (float) i / ( (float) interpolator_length - 1 ); } #endif + return error; } @@ -233,6 +234,12 @@ void ivas_ism_render( } #ifdef JBM_TSM_ON_TCS +/*-------------------------------------------------------------------------* + * ivas_ism_render_sf() + * + * Object rendering process + *-------------------------------------------------------------------------*/ + void ivas_ism_render_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output_f[], /* i/o: core-coder transport channels/object output */ @@ -263,6 +270,7 @@ void ivas_ism_render_sf( { /* Calculate rotation matrix from the quaternion */ QuatToRotMat( st_ivas->hHeadTrackData->Quaternions[st_ivas->hHeadTrackData->num_quaternions++], Rmat ); + ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator ); @@ -271,7 +279,6 @@ void ivas_ism_render_sf( for ( i = 0; i < num_objects; i++ ) { - /* Head rotation: rotate the object positions depending the head's orientation */ if ( st_ivas->hHeadTrackData != NULL && st_ivas->hHeadTrackData->num_quaternions >= 0 ) { @@ -302,6 +309,7 @@ void ivas_ism_render_sf( output_f[j2][k] += ( *( g1++ ) * gain + g2 * prev_gain ) * *( tc++ ); } } + /* update here only in case of head rotation */ if ( st_ivas->hHeadTrackData != NULL && st_ivas->hHeadTrackData->num_quaternions >= 0 ) { @@ -309,6 +317,7 @@ void ivas_ism_render_sf( } } } + return; } #endif diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 48bfde33aa..dbbd9e30b9 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -65,7 +65,7 @@ static void ivas_jbm_dec_tc_buffer_playout( Decoder_Struct *st_ivas, const uint1 ivas_error ivas_jbm_dec_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *data /* o : transport channel signal */ + float *data /* o : transport channel signals */ ) { int16_t n, output_frame, nchan_out; @@ -153,7 +153,6 @@ ivas_error ivas_jbm_dec_tc( } else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - // VE: call ivas_ism_metadata_dec() with 'st_ivas' - TBD 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 ) ) != IVAS_ERR_OK ) { return error; @@ -212,17 +211,11 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->hQMetaData != NULL ) { st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; - ivas_dirac_dec_read_BS( - ivas_total_brate, - st, - st_ivas->hDirAC, - st_ivas->hQMetaData, - &nb_bits_metadata[0], - st_ivas->sba_mode, + ivas_dirac_dec_read_BS( ivas_total_brate, st, st_ivas->hDirAC, st_ivas->hQMetaData, &nb_bits_metadata[0], st_ivas->sba_mode, #ifdef HODIRAC - st_ivas->sba_analysis_order > 1 && ivas_total_brate > IVAS_256k, + st_ivas->sba_analysis_order > 1 && ivas_total_brate > IVAS_256k, #endif - st_ivas->hSpar->dirac_to_spar_md_bands ); + st_ivas->hSpar->dirac_to_spar_md_bands ); } if ( ( error = ivas_spar_dec( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK ) @@ -546,10 +539,10 @@ ivas_error ivas_jbm_dec_tc( *--------------------------------------------------------------------------*/ ivas_error ivas_jbm_dec_feed_tc_to_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nSamplesForRendering, /* i: : number of TC samples available for rendering */ - int16_t *nSamplesResidual, /* o: : number of samples not fitting into the renderer grid and buffer for the next call*/ - float *data /* i : transport channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ + int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ + float *data /* i : transport channels */ ) { @@ -736,22 +729,15 @@ ivas_error ivas_jbm_dec_render( /* Binaural rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - ObjRenderIVASSubframe( st_ivas, p_output, *nSamplesRendered ); + if ( ( ObjRenderIVASSubframe( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, - AUDIO_CONFIG_7_1_4, - AUDIO_CONFIG_BINAURAL_ROOM, - st_ivas->hDecoderConfig, - NULL, - NULL, - NULL, - st_ivas->hTcBuffer, - p_output, - p_output, - *nSamplesRendered, - output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM, st_ivas->hDecoderConfig, NULL, NULL, + NULL, st_ivas->hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -768,6 +754,7 @@ ivas_error ivas_jbm_dec_render( else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { nchan_remapped = nchan_transport; + /* Loudspeakers, Ambisonics or Binaural rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { @@ -807,18 +794,8 @@ ivas_error ivas_jbm_dec_render( /* Rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, - st_ivas->intern_config, - st_ivas->hOutSetup.output_config, - st_ivas->hDecoderConfig, - st_ivas->hHeadTrackData, - &st_ivas->hIntSetup, - st_ivas->hEFAPdata, - st_ivas->hTcBuffer, - p_tc, - p_output, - *nSamplesRendered, - output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hHeadTrackData, + &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -840,7 +817,11 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - ObjRenderIVASSubframe( st_ivas, p_output, *nSamplesRendered ); + if ( ( ObjRenderIVASSubframe( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->tc, p_output ); } } @@ -960,6 +941,7 @@ ivas_error ivas_jbm_dec_flush_renderer( *nSamplesRendered = 0; hTcBuffer = st_ivas->hTcBuffer; + /* get number of possible slots in new granularity */ n_samples_still_available = hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered; n_slots_still_available = n_samples_still_available / tc_granularity_new; @@ -967,6 +949,7 @@ ivas_error ivas_jbm_dec_flush_renderer( n_samples_to_render = *nSamplesRendered; n_samples_still_available -= n_samples_to_render; assert( n_samples_still_available < tc_granularity_new ); + if ( n_slots_still_available ) { int16_t ch_idx; @@ -1003,7 +986,10 @@ ivas_error ivas_jbm_dec_flush_renderer( /* Binaural rendering */ if ( renderer_type_old == RENDERER_BINAURAL_OBJECTS_TD ) { - ObjRenderIVASSubframe( st_ivas, p_output, hTcBuffer->n_samples_granularity ); + if ( ( ObjRenderIVASSubframe( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) + { + return error; + } } else if ( renderer_type_old == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { @@ -1012,21 +998,12 @@ ivas_error ivas_jbm_dec_flush_renderer( ivas_ism_render_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ); - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, - AUDIO_CONFIG_7_1_4, - AUDIO_CONFIG_BINAURAL_ROOM, - st_ivas->hDecoderConfig, - NULL, - NULL, - NULL, - st_ivas->hTcBuffer, - p_output, - p_output, - hTcBuffer->n_samples_granularity, - st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM, st_ivas->hDecoderConfig, NULL, NULL, + NULL, st_ivas->hTcBuffer, p_output, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } + ivas_binaural_add_LFE( st_ivas, hTcBuffer->n_samples_granularity, p_output, p_output ); } } @@ -1041,18 +1018,8 @@ ivas_error ivas_jbm_dec_flush_renderer( { if ( renderer_type_old == RENDERER_BINAURAL_MIXER_CONV || renderer_type_old == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, - intern_config_old, - st_ivas->hOutSetup.output_config, - st_ivas->hDecoderConfig, - st_ivas->hHeadTrackData, - hIntSetupOld, - st_ivas->hEFAPdata, - st_ivas->hTcBuffer, - hTcBuffer->tc, - p_output, - hTcBuffer->n_samples_granularity, - st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hHeadTrackData, hIntSetupOld, + st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -1061,7 +1028,10 @@ ivas_error ivas_jbm_dec_flush_renderer( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - ObjRenderIVASSubframe( st_ivas, p_output, hTcBuffer->n_samples_granularity ); + if ( ( ObjRenderIVASSubframe( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) + { + return error; + } ivas_binaural_add_LFE( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc, p_output ); } @@ -1089,6 +1059,7 @@ ivas_error ivas_jbm_dec_flush_renderer( return error; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_set_discard_samples() * @@ -1144,6 +1115,7 @@ void ivas_jbm_dec_get_adapted_linear_interpolator( { interpolator[idx] = max( 0.0f, interpolator[idx + 1] - dec ); } + if ( interpolator[idx + 1] > 0.0f ) { dec = interpolator[idx + 1] / ( jbm_segment_len + 1 ); @@ -1196,6 +1168,7 @@ void ivas_jbm_dec_get_adapted_subframes( { subframe_nbslots[0] = nSlotsInFirstSubframe; } + if ( nSlotsInLastSubframe > 0 ) { subframe_nbslots[*nb_subframes - 1] = nSlotsInLastSubframe; @@ -1369,12 +1342,12 @@ int16_t ivas_jbm_dec_get_num_tc_channels( * buffer handle *--------------------------------------------------------------------------*/ -void ivas_jbm_dec_copy_tc( +static void ivas_jbm_dec_copy_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSamplesForRendering, /* i : number of samples to digest */ int16_t *nSamplesResidual, /* o : number of samples that will be left for the next frame */ float *data, /* i : (interleaved) transport channel samples */ - float *tc_digest_f[] /* o : samples that will be directly digestest (eg. by CLDFB) */ + float *tc_digest_f[] /* o : samples that will be directly digested (e.g. by CLDFB) */ ) { int16_t ch; @@ -1400,6 +1373,7 @@ void ivas_jbm_dec_copy_tc( hTcBuffer->tc[ch][n_samples_still_available + hTcBuffer->n_samples_discard + m] = data[m * st_ivas->hTcBuffer->nchan_transport_jbm + ch]; } } + if ( n_ch_res_copy > 0 ) { for ( ; ch < hTcBuffer->nchan_transport_jbm; ch++ ) @@ -1412,6 +1386,7 @@ void ivas_jbm_dec_copy_tc( mvr2r( tc_digest_f[ch] + hTcBuffer->n_samples_available, hTcBuffer->tc[ch], *nSamplesResidual ); } } + hTcBuffer->n_samples_rendered = 0; return; @@ -1456,7 +1431,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open( const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ const int16_t nchan_transport_jbm, /* i : number of real transport channels */ const int16_t nchan_transport_internal, /* i : number of totally buffered channels */ - const int16_t nchan_full, /* i : nubmer of channels to fully store */ + const int16_t nchan_full, /* i : number of channels to fully store */ const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ ) { @@ -1514,13 +1489,14 @@ ivas_error ivas_jbm_dec_tc_buffer_open( nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; nsamp_to_allocate += nchan_residual * n_samp_residual; + if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); } set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); - offset = 0; + offset = 0; for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) { hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; @@ -1606,8 +1582,10 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( hTcBuffer->nchan_buffer_full = nchan_full; nchan_residual = nchan_transport_internal - nchan_full; hTcBuffer->n_samples_granularity = n_samples_granularity; +#ifdef DEBUGGING /* what is remaining from last frames needs always be smaller than n_samples_granularity */ assert( ( hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered ) < n_samples_granularity ); +#endif /* realloc buffers */ free( hTcBuffer->tc_buffer ); @@ -1620,8 +1598,8 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); } - set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); + offset = 0; for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) { @@ -1665,11 +1643,13 @@ static void ivas_jbm_dec_tc_buffer_playout( *nSamplesRendered = (uint16_t) slots_to_render * slot_size; first_sf = st_ivas->hTcBuffer->subframes_rendered; last_sf = first_sf; + while ( slots_to_render > 0 ) { slots_to_render -= st_ivas->hTcBuffer->subframe_nbslots[last_sf]; last_sf++; } + for ( ch_idx = 0; ch_idx < st_ivas->hTcBuffer->nchan_transport_jbm; ch_idx++ ) { mvr2r( st_ivas->hTcBuffer->tc[ch_idx] + st_ivas->hTcBuffer->n_samples_rendered, output[ch_idx], *nSamplesRendered ); @@ -1759,6 +1739,7 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( return; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_tc_buffer_mode() * diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 40d2452254..22610ede4f 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -412,11 +412,13 @@ ivas_error ivas_masa_dec_open( { int16_t nchan_to_allocate; TC_BUFFER_MODE buffer_mode; + buffer_mode = TC_BUFFER_MODE_RENDERER; if ( st_ivas->mc_mode == MC_MODE_MCMASA && ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO ) ) { buffer_mode = TC_BUFFER_MODE_BUFFER; } + nchan_to_allocate = ivas_jbm_dec_get_num_tc_channels( st_ivas ); if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) { @@ -1291,11 +1293,13 @@ ivas_error ivas_masa_dec_reconfigure( buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); tc_nchan_transport = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + tc_nchan_to_allocate = tc_nchan_transport; if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS; } + if ( tc_nchan_transport != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || buffer_mode_new != st_ivas->hTcBuffer->tc_buffer_mode ) { if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, buffer_mode_new, tc_nchan_transport, tc_nchan_to_allocate, tc_nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) @@ -1305,6 +1309,7 @@ ivas_error ivas_masa_dec_reconfigure( } } #endif + return error; } @@ -1584,7 +1589,6 @@ void ivas_spar_param_to_masa_param_mapping( float slot_fac; #endif - /* Set values */ hDirAC = st_ivas->hDirAC; hDirAC->numSimultaneousDirections = 1; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 473c15dedc..2567f340e9 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -923,7 +923,6 @@ static ivas_error ivas_mc_dec_reconfig( } #endif - if ( last_mc_mode == MC_MODE_MCT ) { if ( st_ivas->hMCT != NULL && st_ivas->nchan_transport <= CPE_CHANNELS ) @@ -1325,6 +1324,7 @@ static ivas_error ivas_mc_dec_reconfig( /*-----------------------------------------------------------------* * Reconfigure TC buffer *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->voip_active == 1 ) { int16_t tc_nchan_full_new; @@ -1344,6 +1344,7 @@ static ivas_error ivas_mc_dec_reconfig( { tc_nchan_full_new = 0; } + /* reconfigure buffer */ if ( hTcBuffer->tc_buffer_mode != tc_buffer_mode_new || hTcBuffer->nchan_transport_jbm != tc_nchan_tc_new || hTcBuffer->nchan_buffer_full != tc_nchan_full_new || hTcBuffer->nchan_transport_internal != tc_nchan_allocate_new || @@ -1354,6 +1355,7 @@ static ivas_error ivas_mc_dec_reconfig( return error; } } + /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ if ( st_ivas->hDirAC != NULL ) { @@ -1373,5 +1375,6 @@ static ivas_error ivas_mc_dec_reconfig( } } #endif + return error; } diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 873c75938a..adc0bcb7e7 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -83,6 +83,7 @@ ivas_error ivas_td_binaural_renderer( ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Pos : NULL, output, output_frame ); } + #ifdef JBM_TSM_ON_TCS /*---------------------------------------------------------------------* * ObjRenderIVASFrame() @@ -91,7 +92,7 @@ ivas_error ivas_td_binaural_renderer( * and renders the current frame. *---------------------------------------------------------------------*/ -void ObjRenderIVASSubframe( +ivas_error ObjRenderIVASSubframe( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output[], /* i/o: SCE channels / Binaural synthesis */ const int16_t n_samples_asked ) @@ -102,24 +103,31 @@ void ObjRenderIVASSubframe( float *output_f_local[BINAURAL_CHANNELS]; float *tc_local[MAX_TRANSPORT_CHANNELS]; int16_t ch, slot_size, slots_to_render, output_frame; + ivas_error error; + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { p_reverb_signal[ch] = reverb_signal[ch]; } + for ( ch = 0; ch < st_ivas->hTcBuffer->nchan_transport_internal; ch++ ) { tc_local[ch] = st_ivas->hTcBuffer->tc[ch] + st_ivas->hTcBuffer->n_samples_rendered; } + for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) { output_f_local[ch] = output[ch]; } + slot_size = st_ivas->hTcBuffer->n_samples_granularity; + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, n_samples_asked / slot_size ); first_sf = st_ivas->hTcBuffer->subframes_rendered; last_sf = first_sf; st_ivas->hTcBuffer->slots_rendered += slots_to_render; + while ( slots_to_render > 0 ) { slots_to_render -= st_ivas->hTcBuffer->subframe_nbslots[last_sf]; @@ -129,22 +137,28 @@ void ObjRenderIVASSubframe( for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { output_frame = st_ivas->hTcBuffer->subframe_nbslots[subframe_idx] * st_ivas->hTcBuffer->n_samples_granularity; + /* Update object position(s) */ TDREND_Update_object_positions( st_ivas->hBinRendererTd, st_ivas->nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData, tc_local ); /* Update the listener's location/orientation */ - TDREND_Update_listener_orientation( st_ivas->hBinRendererTd, - st_ivas->hDecoderConfig->Opt_Headrotation, + TDREND_Update_listener_orientation( st_ivas->hBinRendererTd, st_ivas->hDecoderConfig->Opt_Headrotation, ( st_ivas->hHeadTrackData != NULL ) ? &st_ivas->hHeadTrackData->Quaternions[0] : NULL, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Pos : NULL ); if ( ( st_ivas->hRenderConfig != NULL ) && ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) ) { - ivas_reverb_process( st_ivas->hReverb, st_ivas->transport_config, 0, tc_local, p_reverb_signal, 0 ); + if ( ( error = ivas_reverb_process( st_ivas->hReverb, st_ivas->transport_config, 0, tc_local, p_reverb_signal, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } } /* Render subframe */ - TDREND_GetMix( st_ivas->hBinRendererTd, output_f_local, output_frame, 0 ); + if ( ( error = TDREND_GetMix( st_ivas->hBinRendererTd, output_f_local, output_frame, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } if ( st_ivas->hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */ { @@ -155,16 +169,20 @@ void ObjRenderIVASSubframe( v_add( reverb_signal[1], output_f_local[1], output_f_local[1], output_frame ); } } + for ( ch = 0; ch < st_ivas->hTcBuffer->nchan_transport_internal; ch++ ) { tc_local[ch] += output_frame; } + for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) { output_f_local[ch] += output_frame; } } + st_ivas->hTcBuffer->subframes_rendered = last_sf; - return; + + return IVAS_ERR_OK; } #endif diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c index 3f95113f60..1d6db5eebf 100644 --- a/lib_dec/ivas_out_setup_conversion.c +++ b/lib_dec/ivas_out_setup_conversion.c @@ -1161,7 +1161,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( void ivas_lssetupconversion_process_param_mc( Decoder_Struct *st_ivas, /* i/o: LS setup conversion renderer handle */ #ifdef JBM_TSM_ON_TCS - int16_t num_timeslots, + const int16_t num_timeslots, #endif float Cldfb_RealBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ float Cldfb_ImagBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index a12bf992a5..45daab00b2 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -203,6 +203,7 @@ ivas_error ivas_sba_dec_reconfigure( hSpar = st_ivas->hSpar; st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); + #ifdef JBM_TSM_ON_TCS /* synchronize subframe info */ st_ivas->hSpar->num_slots = st_ivas->hTcBuffer->num_slots; @@ -294,6 +295,7 @@ ivas_error ivas_sba_dec_reconfigure( { return error; } + #ifdef JBM_TSM_ON_TCS /* synchronize subframe info */ st_ivas->hDirAC->num_slots = st_ivas->hTcBuffer->num_slots; @@ -303,6 +305,7 @@ ivas_error ivas_sba_dec_reconfigure( mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hDirAC->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); #endif } + if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, @@ -379,8 +382,9 @@ ivas_error ivas_sba_dec_reconfigure( #ifdef JBM_TSM_ON_TCS /*-----------------------------------------------------------------* - * TC buffer + * JBM TC buffer *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->voip_active == 1 ) { int16_t tc_nchan_to_allocate; @@ -426,10 +430,17 @@ ivas_error ivas_sba_dec_reconfigure( } } #endif + return error; } #ifdef JBM_TSM_ON_TCS +/*-------------------------------------------------------------------* + * ivas_sba_dec_digest_tc() + * + * + *-------------------------------------------------------------------*/ + ivas_error ivas_sba_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const int16_t nCldfbSlots, /* i : number of CLDFB slots */ @@ -447,22 +458,27 @@ ivas_error ivas_sba_dec_digest_tc( { ivas_dirac_dec_set_md_map( st_ivas, nCldfbSlots ); } + if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { ivas_spar_dec_digest_tc( st_ivas, st_ivas->nchan_transport, nCldfbSlots, nSamplesForRendering ); } + if ( st_ivas->hDiracDecBin != NULL && ( st_ivas->hDiracDecBin->useTdDecorr ) ) { int16_t nSamplesLeftForTD, default_frame; float *decorr_signal[BINAURAL_CHANNELS]; float *p_tc[2 * BINAURAL_CHANNELS]; + default_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); nSamplesLeftForTD = nSamplesForRendering; + for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) { decorr_signal[ch_idx] = st_ivas->hTcBuffer->tc[ch_idx + BINAURAL_CHANNELS]; p_tc[ch_idx] = st_ivas->hTcBuffer->tc[ch_idx]; } + while ( nSamplesLeftForTD ) { int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame ); @@ -475,21 +491,30 @@ ivas_error ivas_sba_dec_digest_tc( nSamplesLeftForTD -= nSamplesToDecorr; } } + /* if we have a late CNG generation, do it here */ if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->sba_mode != SBA_MODE_SPAR ) { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], nCldfbSlots, st->cna_dirac_flag && st->flag_cna ); } + return error; } + +/*-------------------------------------------------------------------* + * ivas_sba_dec_render() + * + * + *-------------------------------------------------------------------*/ + void 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 */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + 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 *output_f[] /* o : rendered time signal */ ) { int16_t slots_to_render, first_sf, last_sf, subframe_idx; @@ -505,7 +530,9 @@ void ivas_sba_dec_render( st_ivas->hDecoderConfig->ivas_total_brate #endif ); + nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; + #ifdef DEBUGGING assert( hSpar ); #endif @@ -513,12 +540,15 @@ void ivas_sba_dec_render( { output_f_local[ch] = output_f[ch]; } + slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( hSpar->num_slots - hSpar->slots_rendered, nSamplesAsked / slot_size ); *nSamplesRendered = slots_to_render * slot_size; first_sf = hSpar->subframes_rendered; last_sf = first_sf; + while ( slots_to_render > 0 ) { slots_to_render -= hSpar->subframe_nbslots[last_sf]; @@ -527,9 +557,11 @@ void ivas_sba_dec_render( #ifdef DEBUGGING assert( slots_to_render == 0 ); #endif + for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { int16_t n_samples_sf = slot_size * hSpar->subframe_nbslots[subframe_idx]; + ivas_spar_dec_upmixer_sf( st_ivas, output_f_local, nchan_internal ); for ( ch = 0; ch < nchan_out; ch++ ) { @@ -541,6 +573,7 @@ void ivas_sba_dec_render( { ivas_sba_linear_renderer( output_f, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); } + if ( st_ivas->hDirAC != NULL && hSpar->slots_rendered == hSpar->num_slots ) { if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 ) @@ -552,6 +585,7 @@ void ivas_sba_dec_render( st_ivas->hDirAC->dirac_read_idx = ( st_ivas->hDirAC->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % st_ivas->hDirAC->dirac_md_buffer_length; } } + *nSamplesAvailable = ( hSpar->num_slots - hSpar->slots_rendered ) * slot_size; return; diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index f9e43700a0..3d7959df2f 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -92,6 +92,7 @@ void ivas_sba2mc_cldfb( g = hoa_dec_mtx[SBA_NHARM_HOA3 * n + m]; p_realOut = realOut[n]; p_imagOut = imagOut[n]; + #ifdef JBM_TSM_ON_TCS for ( iBlock = 0; iBlock < nb_timeslots; iBlock++ ) #else @@ -115,6 +116,7 @@ void ivas_sba2mc_cldfb( { p_realOut = realOut[n]; p_imagOut = imagOut[n]; + #ifdef JBM_TSM_ON_TCS for ( iBlock = 0; iBlock < nb_timeslots; iBlock++ ) #else @@ -430,7 +432,6 @@ void ivas_sba_upmixer_renderer( const int16_t output_frame /* i : output frame length */ ) { - int16_t nchan_internal; #ifndef JBM_TSM_ON_TCS int16_t i; @@ -467,10 +468,12 @@ void ivas_sba_upmixer_renderer( #ifdef JBM_TSM_ON_TCS float *output_f[MAX_OUTPUT_CHANNELS]; int16_t ch; + for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) { output_f[ch] = output[ch]; } + ivas_sba_linear_renderer( output_f, output_frame, st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); #else ivas_sba_linear_renderer( output, output_frame, st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 91b06ada6b..2f28145b4c 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -213,6 +213,7 @@ ivas_error ivas_spar_dec_open( hSpar->subframes_rendered = 0; hSpar->slots_rendered = 0; hSpar->num_slots = DEFAULT_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME; + /* init render timeslot mapping */ { int16_t map_idx; @@ -222,6 +223,7 @@ ivas_error ivas_spar_dec_open( hSpar->render_to_md_map[map_idx] = map_idx; } } + /* allocate transport channels*/ if ( st_ivas->hDecoderConfig->voip_active == 1 && st_ivas->hTcBuffer == NULL ) { @@ -1123,14 +1125,20 @@ static void ivas_spar_calc_smooth_facs( return; } + #ifdef JBM_TSM_ON_TCS +/*-------------------------------------------------------------------* + * ivas_spar_dec_agc_pca() + * + * + *-------------------------------------------------------------------*/ + void ivas_spar_dec_agc_pca( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float output[][L_FRAME48k], /* i/o: input/output audio channels */ - const int16_t output_frame /* i : output frame length */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + float output[][L_FRAME48k], /* i/o: input/output audio channels */ + const int16_t output_frame /* i : output frame length */ ) { - int16_t nchan_transport; int16_t num_in_ingest; DECODER_CONFIG_HANDLE hDecoderConfig; @@ -1168,6 +1176,7 @@ void ivas_spar_dec_agc_pca( { num_in_ingest = nchan_transport; } + /*---------------------------------------------------------------------* * AGC *---------------------------------------------------------------------*/ @@ -1187,12 +1196,21 @@ void ivas_spar_dec_agc_pca( #endif } pop_wmops(); + return; } + +/*-------------------------------------------------------------------* + * ivas_spar_dec_set_render_map() + * + * + *-------------------------------------------------------------------*/ + void ivas_spar_dec_set_render_map( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t nCldfbTs ) + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nCldfbTs /* i : number of CLDFB time slots */ +) { SPAR_DEC_HANDLE hSpar; @@ -1211,6 +1229,8 @@ void ivas_spar_dec_set_render_map( return; } + + /*-------------------------------------------------------------------* * ivas_spar_dec_upmixer() * @@ -1227,11 +1247,14 @@ 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 #ifdef SPAR_TUNING , @@ -1244,6 +1267,13 @@ void ivas_spar_dec_set_render_params( return; } + +/*-------------------------------------------------------------------* + * ivas_spar_dec_digest_tc() + * + * + *-------------------------------------------------------------------*/ + void ivas_spar_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const int16_t nchan_transport, /* i : number of transport channels */ @@ -1261,6 +1291,7 @@ void ivas_spar_dec_digest_tc( float *p_tc[MAX_SPAR_INTERNAL_CHANNELS]; int16_t nchan_internal, ch; int16_t nSamplesLeftForTD, default_frame; + /* TD decorrelator */ default_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); nSamplesLeftForTD = nSamplesForRendering; @@ -1270,6 +1301,7 @@ void ivas_spar_dec_digest_tc( st_ivas->hDecoderConfig->ivas_total_brate #endif ); + for ( ch = 0; ch < nchan_internal; ch++ ) { pPcm_tmp[ch] = Pcm_tmp[ch]; @@ -1279,7 +1311,9 @@ void ivas_spar_dec_digest_tc( while ( nSamplesLeftForTD ) { int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame ); + ivas_td_decorr_process( hSpar->hTdDecorr, p_tc, pPcm_tmp, nSamplesToDecorr ); + #ifdef SPAR_TUNING if ( hSpar->hTdDecorr->num_apd_outputs >= ( nchan_internal - nchan_transport ) ) { @@ -1309,16 +1343,23 @@ void ivas_spar_dec_digest_tc( { p_tc[ch] += nSamplesToDecorr; } + nSamplesLeftForTD -= nSamplesToDecorr; } } ivas_spar_dec_set_render_params( st_ivas, nCldfbSlots ); - return; } + +/*-------------------------------------------------------------------* + * ivas_spar_dec_upmixer() + * + * + *-------------------------------------------------------------------*/ + void ivas_spar_dec_upmixer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ float output[][L_FRAME48k], /* i/o: input/output audio channels */ @@ -1338,10 +1379,12 @@ void ivas_spar_dec_upmixer( nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; n_samples_sf = JBM_CLDFB_SLOTS_IN_SUBFRAME * NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) { output_f_local[n] = &output[n][0]; } + for ( n = 0; n < nchan_internal; n++ ) { st_ivas->hTcBuffer->tc[n] = output[n]; @@ -1350,10 +1393,12 @@ void ivas_spar_dec_upmixer( /*---------------------------------------------------------------------* * TD decorrelation *---------------------------------------------------------------------*/ + for ( i = 0; i < nchan_internal; i++ ) { pPcm_tmp[i] = Pcm_tmp[i]; } + if ( hSpar->hMdDec->td_decorr_flag ) { ivas_td_decorr_process( hSpar->hTdDecorr, st_ivas->hTcBuffer->tc, pPcm_tmp, output_frame ); @@ -1384,7 +1429,6 @@ void ivas_spar_dec_upmixer( #endif } - ivas_spar_dec_set_render_params( st_ivas, DEFAULT_JBM_CLDFB_TIMESLOTS ); if ( st_ivas->hDirAC != 0 ) @@ -1400,10 +1444,12 @@ void ivas_spar_dec_upmixer( output_f_local[n] += n_samples_sf; } } + for ( n = 0; n < nchan_internal; n++ ) { st_ivas->hTcBuffer->tc[n] = NULL; } + if ( st_ivas->hDirAC != 0 ) { if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 ) @@ -1415,6 +1461,7 @@ void ivas_spar_dec_upmixer( st_ivas->hDirAC->dirac_read_idx = ( st_ivas->hDirAC->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % st_ivas->hDirAC->dirac_md_buffer_length; } } + return; } #endif @@ -1426,6 +1473,7 @@ void ivas_spar_dec_upmixer( * * IVAS SPAR upmixer *-------------------------------------------------------------------*/ + void ivas_spar_dec_upmixer_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ float *output[], /* o : output audio channels */ diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index bd925affe8..49551fa500 100755 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -440,6 +440,7 @@ typedef struct param_ism_rendering float *Cldfb_RealBuffer_tc; float *Cldfb_ImagBuffer_tc; #endif + } PARAM_ISM_RENDERING_DATA, *PARAM_ISM_RENDERING_HANDLE; @@ -1258,8 +1259,11 @@ typedef struct decoder_tc_buffer_structure int16_t slots_rendered; int16_t num_slots; int16_t n_samples_discard; /* number of samples to discard from the beginning of the output */ + } DECODER_TC_BUFFER, *DECODER_TC_BUFFER_HANDLE; #endif + + /*----------------------------------------------------------------------------------* * * Main IVAS decoder structure @@ -1350,6 +1354,11 @@ typedef struct Decoder_Struct RENDER_CONFIG_DATA *hRenderConfig; /* Renderer config pointer */ int32_t binaural_latency_ns; /* Binauralization latency in ns */ +#ifdef JBM_TSM_ON_TCS + /* JBM module */ + DECODER_TC_BUFFER_HANDLE hTcBuffer; /* JBM handle */ +#endif + #ifdef DEBUGGING int32_t noClipping; /* number of clipped samples */ #endif @@ -1357,10 +1366,6 @@ typedef struct Decoder_Struct int16_t ism_extmeta_active; /* Extended metadata active in decoder */ int16_t ism_extmeta_cnt; /* Change frame counter for extended metadata */ - -#ifdef JBM_TSM_ON_TCS - DECODER_TC_BUFFER_HANDLE hTcBuffer; -#endif } Decoder_Struct; /* clang-format on */ diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c index c224b4cfbf..9742a01183 100644 --- a/lib_dec/jbm_pcmdsp_apa.c +++ b/lib_dec/jbm_pcmdsp_apa.c @@ -412,7 +412,9 @@ bool apa_set_renderer_residual_samples( return 0; } -bool apa_set_evs_compat_mode( apa_state_t *ps, bool mode ) +bool apa_set_evs_compat_mode( + apa_state_t *ps, + bool mode ) { /* make sure pointer is valid */ if ( ps == NULL ) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 17c718bb48..a67c51e5da 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -279,6 +279,7 @@ static void init_decoder_config( #ifdef JBM_TSM_ON_TCS hDecoderConfig->voip_active = 0; #endif + return; } @@ -582,7 +583,6 @@ ivas_error IVAS_DEC_EnableVoIP( #endif #endif - #ifndef JBM_TSM_ON_TCS assert( hDecoderConfig->nchan_out > 0 && "EXT output not yet supported in VoIP mode" ); #endif @@ -612,6 +612,7 @@ ivas_error IVAS_DEC_EnableVoIP( #else hIvasDec->hVoIP->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs * hDecoderConfig->nchan_out / FRAMES_PER_SEC ); #endif + #ifdef JBM_TSM_ON_TCS /* postpone init of the buffers until we know the real number of TCs*/ hIvasDec->hVoIP->apaExecBuffer = NULL; @@ -680,7 +681,6 @@ ivas_error IVAS_DEC_EnableVoIP( #endif #ifdef JBM_TSM_ON_TCS - /* postpone init of time scaler until we know the real number of TCs */ hIvasDec->hVoIP->hTimeScaler = NULL; /* create output pcm fifo*/ @@ -933,6 +933,7 @@ static ivas_error IVAS_DEC_Setup( return error; } + /*---------------------------------------------------------------------* * IVAS_DEC_GetTcSamples( ) * @@ -1998,6 +1999,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #ifdef JBM_TSM_ON_TCS uint16_t l_ts = 1; uint16_t nSamplesRendered_loop; + /* setup ivas decoder and get the number of TCs */ /* might render some remaining samples from the previous frame too if the renderer granularity changed */ if ( hVoIP->hFifoOut ) @@ -2019,11 +2021,13 @@ ivas_error IVAS_DEC_VoIP_GetSamples( return error; } } + nSamplesRendered += nSamplesRendered_loop; if ( nTransportChannels != hVoIP->nTransportChannelsOld ) { IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ); } + /* decode TCs only */ if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hVoIP->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) { @@ -2117,10 +2121,12 @@ ivas_error IVAS_DEC_VoIP_GetSamples( { /* render IVAS frames */ int16_t nResidualSamples; + if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hVoIP->apaExecBuffer ) ) != IVAS_ERR_OK ) { return error; } + /* feed residual samples to TSM for the next call */ if ( apa_set_renderer_residual_samples( hVoIP->hTimeScaler, (uint16_t) nResidualSamples ) != 0 ) { @@ -2158,6 +2164,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #endif #ifdef JBM_TSM_ON_TCS } + if ( hIvasDec->hasBeenFedFirstGoodFrame && hVoIP->rendererType != JBM_RENDERER_NONE ) { uint16_t nSamplesRendered_loop; @@ -2165,12 +2172,15 @@ ivas_error IVAS_DEC_VoIP_GetSamples( if ( hVoIP->hFifoOut ) { int16_t rendererPcmBuf[( MAX_OUTPUT_CHANNELS * L_FRAME_MAX * APA_MAX_SCALE ) / 100]; + nSamplesToRender = nSamplesPerChannel - pcmdsp_fifo_nReadableSamplesPerChannel( hVoIP->hFifoOut ); + /* render IVAS frames */ if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hVoIP->nSamplesAvailableNext, rendererPcmBuf ) ) != IVAS_ERR_OK ) { return error; } + if ( pcmdsp_fifo_write( hVoIP->hFifoOut, (uint8_t *) rendererPcmBuf, nSamplesRendered_loop ) != 0 ) { return IVAS_ERR_UNKNOWN; @@ -2179,13 +2189,16 @@ ivas_error IVAS_DEC_VoIP_GetSamples( else { nSamplesToRender = nSamplesPerChannel - nSamplesRendered; + /* render IVAS frames directly to the output buffer */ if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hVoIP->nSamplesAvailableNext, pcmBuf + nSamplesRendered * nOutChannels ) ) != IVAS_ERR_OK ) { return error; } } + nSamplesRendered += nSamplesRendered_loop; + #ifdef VARIABLE_SPEED_DECODING if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED && hVoIP->nSamplesAvailableNext == 0 ) { @@ -2200,12 +2213,14 @@ ivas_error IVAS_DEC_VoIP_GetSamples( else { hVoIP->nSamplesAvailableNext = max( 0, pcmdsp_fifo_nReadableSamplesPerChannel( hVoIP->hFifoOut ) - nSamplesPerChannel ); + #ifdef VARIABLE_SPEED_DECODING if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED && hVoIP->nSamplesAvailableNext < nSamplesPerChannel ) { hVoIP->needNewFrame = true; } #endif + hVoIP->nSamplesAvailableNext = 0; } #endif @@ -2268,6 +2283,7 @@ ivas_error IVAS_DEC_VoIP_Flush( uint16_t nSamplesToRender; uint16_t nSamplesFlushedLocal; #endif + error = IVAS_ERR_OK; hVoIP = hIvasDec->hVoIP; @@ -2276,6 +2292,7 @@ ivas_error IVAS_DEC_VoIP_Flush( #else *nSamplesFlushed = min( nSamplesPerChannel, pcmdsp_fifo_nReadableSamplesPerChannel( hVoIP->hFifoAfterTimeScaler ) ); #endif + #ifdef JBM_TSM_ON_TCS if ( hVoIP->rendererType == JBM_RENDERER_NONE ) { @@ -2299,25 +2316,28 @@ ivas_error IVAS_DEC_VoIP_Flush( } else { - nSamplesToRender = (uint16_t) *nSamplesFlushed; /* render IVAS frames */ if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hVoIP->nSamplesAvailableNext, rendererPcmBuf ) ) != IVAS_ERR_OK ) { return error; } + if ( pcmdsp_fifo_write( hVoIP->hFifoOut, (uint8_t *) rendererPcmBuf, nSamplesFlushedLocal ) != 0 ) { return IVAS_ERR_UNKNOWN; } + if ( pcmdsp_fifo_read( hVoIP->hFifoOut, nSamplesFlushedLocal, (uint8_t *) pcmBuf ) != 0 ) { return IVAS_ERR_UNKNOWN; } + *nSamplesAvailableNext = hVoIP->nSamplesAvailableNext; *nSamplesFlushed = (int16_t) nSamplesFlushedLocal; } #endif + return error; } #endif @@ -2333,7 +2353,7 @@ bool IVAS_DEC_VoIP_IsEmpty( IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ #ifdef JBM_TSM_ON_TCS , - int16_t nSamplesAsked + const int16_t nSamplesAsked #endif ) { @@ -2387,6 +2407,7 @@ static void IVAS_DEC_Close_VoIP( #else pcmdsp_fifo_destroy( &hVoIP->hFifoAfterTimeScaler ); #endif + if ( hVoIP->apaExecBuffer != NULL ) { free( hVoIP->apaExecBuffer ); @@ -2972,7 +2993,6 @@ static ivas_error evs_dec_main( /* BE workaround */ int16_t pcm_buf_local[L_FRAME48k]; - /* convert 'float' output data to 'short' */ #ifdef DEBUGGING st_ivas->noClipping += @@ -3006,6 +3026,7 @@ static ivas_error evs_dec_main( #ifdef JBM_TSM_ON_TCS } #endif + return error; } @@ -3198,13 +3219,15 @@ static ivas_error input_format_API_to_internal( } #ifdef JBM_TSM_ON_TCS -static int16_t IVAS_DEC_VoIP_GetRenderGranularity( Decoder_Struct *st_ivas ) +static int16_t IVAS_DEC_VoIP_GetRenderGranularity( + Decoder_Struct *st_ivas ) { return st_ivas->hTcBuffer->n_samples_granularity; } -static JBM_RENDERER_TYPE IVAS_DEC_VoIP_GetRendererConfig( IVAS_DEC_HANDLE hIvasDec ) +static JBM_RENDERER_TYPE IVAS_DEC_VoIP_GetRendererConfig( + IVAS_DEC_HANDLE hIvasDec ) { JBM_RENDERER_TYPE rendererType; rendererType = JBM_RENDERER_NONE; @@ -3221,13 +3244,15 @@ static JBM_RENDERER_TYPE IVAS_DEC_VoIP_GetRendererConfig( IVAS_DEC_HANDLE hIvasD return rendererType; } -ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t nTransportChannels, const uint16_t l_ts ) +ivas_error IVAS_DEC_VoIP_reconfigure( + IVAS_DEC_HANDLE hIvasDec, + const uint16_t nTransportChannels, + const uint16_t l_ts ) { IVAS_DEC_VOIP *hVoIP; ivas_error error; - hVoIP = hIvasDec->hVoIP; if ( hIvasDec->hVoIP->hTimeScaler == NULL ) @@ -3269,12 +3294,13 @@ ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t n { return IVAS_ERR_INIT_ERROR; } - hIvasDec->hVoIP->apaExecBuffer = malloc( sizeof( float ) * APA_BUF_PER_CHANNEL * nTransportChannels ); - set_zero( hIvasDec->hVoIP->apaExecBuffer, APA_BUF_PER_CHANNEL * nTransportChannels ); - if ( hIvasDec->hVoIP->apaExecBuffer == NULL ) + + if ( ( hIvasDec->hVoIP->apaExecBuffer = malloc( sizeof( float ) * APA_BUF_PER_CHANNEL * nTransportChannels ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); } + set_zero( hIvasDec->hVoIP->apaExecBuffer, APA_BUF_PER_CHANNEL * nTransportChannels ); + if ( apa_init( &hIvasDec->hVoIP->hTimeScaler, nTransportChannels ) != IVAS_ERR_OK || apa_set_rate( hIvasDec->hVoIP->hTimeScaler, hDecoderConfig->output_Fs ) != 0 || @@ -3284,6 +3310,7 @@ ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t n { return IVAS_ERR_INIT_ERROR; } + if ( hVoIP->hFifoOut == NULL && hVoIP->rendererType == JBM_RENDERER_NONE ) { /* we still need the FIFO out buffer */ @@ -3303,6 +3330,7 @@ ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t n } } #endif + if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) { if ( apa_set_evs_compat_mode( hIvasDec->hVoIP->hTimeScaler, true ) != 0 ) @@ -3320,12 +3348,11 @@ ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t n /* realloc apa_exe_buffer */ free( hIvasDec->hVoIP->apaExecBuffer ); - hIvasDec->hVoIP->apaExecBuffer = malloc( sizeof( float ) * APA_BUF_PER_CHANNEL * nTransportChannels ); - set_zero( hIvasDec->hVoIP->apaExecBuffer, APA_BUF_PER_CHANNEL * nTransportChannels ); - if ( hIvasDec->hVoIP->apaExecBuffer == NULL ) + if ( ( hIvasDec->hVoIP->apaExecBuffer = malloc( sizeof( float ) * APA_BUF_PER_CHANNEL * nTransportChannels ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); } + set_zero( hIvasDec->hVoIP->apaExecBuffer, APA_BUF_PER_CHANNEL * nTransportChannels ); } hIvasDec->hVoIP->nTransportChannelsOld = (uint8_t) nTransportChannels; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 4e9ebd012c..9e27e903f8 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -229,8 +229,8 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( #ifdef VARIABLE_SPEED_DECODING /*! r: error code */ ivas_error IVAS_DEC_VoIP_SetScale( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t scale /* i : TSM scale to set */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t scale /* i : TSM scale to set */ ); #endif @@ -242,7 +242,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( const uint32_t systemTimestamp_ms /* i : current system timestamp */ #if defined( JBM_TSM_ON_TCS ) || defined(VARIABLE_SPEED_DECODING ) , - uint16_t *sampleAvailableNext /* o : samples available for the next call */ + uint16_t *sampleAvailableNext /* o : samples available for the next call */ #endif #ifdef SUPPORT_JBM_TRACEFILE , JbmTraceFileWriterFn jbmWriterFn, @@ -252,11 +252,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #if defined( JBM_TSM_ON_TCS ) || defined(VARIABLE_SPEED_DECODING ) ivas_error IVAS_DEC_VoIP_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 */ - 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 */ - uint16_t *nSamplesAvailableNext, /* o : number of samples still available */ - int16_t *nSamplesFlushed /* o : number of samples flushed */ + 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 */ + 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 */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still available */ + int16_t *nSamplesFlushed /* o : number of samples flushed */ ); #endif @@ -386,7 +386,7 @@ bool IVAS_DEC_VoIP_IsEmpty( IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ #ifdef JBM_TSM_ON_TCS , - int16_t nSamplesAsked + const int16_t nSamplesAsked #endif ); diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 5ec11fa6ec..05a5a483e4 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1149,12 +1149,14 @@ ivas_error ivas_rend_crendProcess( output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); subframe_len = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; + #ifdef JBM_TSM_ON_TCS for ( i = 0; i < BINAURAL_CHANNELS; i++ ) { p_pcm_tmp[i] = pcm_tmp[i]; } #endif + for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ ) { /* Rotation */ @@ -1216,20 +1218,28 @@ ivas_error ivas_rend_crendProcess( return IVAS_ERR_OK; } + #ifdef JBM_TSM_ON_TCS +/*-----------------------------------------------------------------------------------------* + * Function ivas_rend_crendProcessSubframe() + * + * + *-----------------------------------------------------------------------------------------*/ + ivas_error ivas_rend_crendProcessSubframe( - const CREND_WRAPPER *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - DECODER_CONFIG_HANDLE hDecoderConfig, - HEAD_TRACK_DATA_HANDLE hHeadTrackData, - IVAS_OUTPUT_SETUP_HANDLE hIntSetup, - EFAP_HANDLE hEFAPdata, - DECODER_TC_BUFFER_HANDLE hTcBuffer, - float *input_f[], - float *output[], /* i/o: input/output audio channels */ - const int16_t n_samples_to_render, - const int32_t output_Fs ) + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ + const HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : Head tracking data structure */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ + DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */ + float *input_f[], /* i : transport channels */ + float *output[], /* i/o: input/output audio channels */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + const int32_t output_Fs /* i : output sampling rate */ +) { int16_t subframe_idx, subframe_len; int16_t nchan_out, nchan_in, ch, first_sf, last_sf, slot_size, slots_to_render; @@ -1249,10 +1259,12 @@ ivas_error ivas_rend_crendProcessSubframe( in_config = getIvasAudioConfigFromRendAudioConfig( inRendConfig ); inConfigType = getAudioConfigType( inRendConfig ); + if ( ( error = getAudioConfigNumChannels( outRendConfig, &nchan_out ) ) != IVAS_ERR_OK ) { return error; } + if ( ( error = getAudioConfigNumChannels( inRendConfig, &nchan_in ) ) != IVAS_ERR_OK ) { return error; @@ -1262,17 +1274,20 @@ ivas_error ivas_rend_crendProcessSubframe( { tc_local[ch] = input_f[ch]; } + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { p_pcm_tmp[ch] = pcm_tmp[ch]; } slot_size = hTcBuffer->n_samples_granularity; + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( hTcBuffer->num_slots - hTcBuffer->slots_rendered, n_samples_to_render / slot_size ); first_sf = hTcBuffer->subframes_rendered; last_sf = first_sf; hTcBuffer->slots_rendered += slots_to_render; + while ( slots_to_render > 0 ) { slots_to_render -= hTcBuffer->subframe_nbslots[last_sf]; @@ -1282,9 +1297,9 @@ ivas_error ivas_rend_crendProcessSubframe( for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { subframe_len = hTcBuffer->subframe_nbslots[subframe_idx] * hTcBuffer->n_samples_granularity; + if ( hDecoderConfig && hDecoderConfig->Opt_Headrotation && hHeadTrackData && hHeadTrackData->num_quaternions >= 0 ) { - /* Rotation in SHD for: MC with elevation (5_1_2 / 5_1_4 / 7_1_4) -> BINAURAL SBA SPAR -> BINAURAL or BINAURAL_ROOM @@ -1335,7 +1350,6 @@ ivas_error ivas_rend_crendProcessSubframe( mvr2r( pcm_tmp[ch], output[ch], n_samples_to_render ); } - hTcBuffer->subframes_rendered = last_sf; pop_wmops(); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 06fd160bb2..ec05cab974 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -140,6 +140,8 @@ static void ivas_dirac_dec_binaural_internal_sf( Decoder_Struct *st_ivas, float static void ivas_dirac_dec_decorrelate_slot_sf( DIRAC_DEC_HANDLE hDirAC, const int8_t slot, float inRe[][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float decRe[][CLDFB_NO_CHANNELS_MAX], float decIm[][CLDFB_NO_CHANNELS_MAX] ); #endif #endif + + /*------------------------------------------------------------------------- * ivas_dirac_dec_init_binaural_data() * @@ -408,8 +410,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( return error; } } - -#endif /* JBM_TMS_ON_TCS*/ +#endif return IVAS_ERR_OK; } @@ -489,14 +490,21 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs( return IVAS_ERR_OK; } + #ifdef JBM_TSM_ON_TCS +/*------------------------------------------------------------------------- + * void ivas_dirac_dec_binaural_render() + * + * + *------------------------------------------------------------------------*/ + void ivas_dirac_dec_binaural_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 */ - const int16_t nchan_transport, - float *output_f[] /* o : rendered time signal */ + 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 */ + const int16_t nchan_transport, /* i : number of transport channels */ + float *output_f[] /* o : rendered time signal */ ) { int16_t slots_to_render, first_sf, last_sf, subframe_idx; @@ -515,16 +523,19 @@ void ivas_dirac_dec_binaural_render( output_f_local[ch] = output_f[ch]; } slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( hDirAC->num_slots - hDirAC->slots_rendered, nSamplesAsked / slot_size ); *nSamplesRendered = slots_to_render * slot_size; first_sf = hDirAC->subframes_rendered; last_sf = first_sf; + while ( slots_to_render > 0 ) { slots_to_render -= hDirAC->subframe_nbslots[last_sf]; last_sf++; } + #ifdef DEBUGGING assert( slots_to_render == 0 ); #endif @@ -541,16 +552,19 @@ void ivas_dirac_dec_binaural_render( output_f_local[ch] += n_samples_sf; } } + if ( hDirAC->slots_rendered == hDirAC->num_slots ) { st_ivas->hDirAC->dirac_read_idx = ( st_ivas->hDirAC->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % st_ivas->hDirAC->dirac_md_buffer_length; } + *nSamplesAvailable = ( hDirAC->num_slots - hDirAC->slots_rendered ) * slot_size; return; } #endif + /*------------------------------------------------------------------------- * ivas_dirac_dec_binaural() * @@ -612,14 +626,15 @@ void ivas_dirac_dec_binaural( #endif } output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + #ifdef JBM_TSM_ON_TCS - { - ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, p_output, decorr_signal, output_frame ); - } + ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, p_output, decorr_signal, output_frame ); + #else ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, output_f, decorr_signal, output_frame ); #endif } + #ifdef JBM_TSM_ON_TCS if ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) { @@ -634,7 +649,9 @@ void ivas_dirac_dec_binaural( { #ifdef JBM_TSM_ON_TCS int16_t n_samples_sf = slot_size * st_ivas->hDirAC->subframe_nbslots[subframe]; + ivas_dirac_dec_binaural_internal( st_ivas, p_output, nchan_transport, subframe ); + for ( ch = 0; ch < 2 * BINAURAL_CHANNELS; ch++ ) { p_output[ch] += n_samples_sf; @@ -658,12 +675,14 @@ void ivas_dirac_dec_binaural( ivas_dirac_dec_binaural_internal( st_ivas, output_f, nchan_transport, 0u, (uint8_t) MAX_PARAM_SPATIAL_SUBFRAMES ); } #endif + #ifdef JBM_TSM_ON_TCS for ( ch = 0; ch < 2 * BINAURAL_CHANNELS; ch++ ) { st_ivas->hTcBuffer->tc[ch] = NULL; } #endif + return; } diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 83db832937..d1c5246655 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -316,7 +316,6 @@ ivas_error ivas_td_binaural_renderer_unwrap( } } - if ( hReverb != NULL && hReverb->pConfig.roomAcoustics.late_reverb_on ) { /* add reverb to rendered signals */ @@ -452,7 +451,7 @@ void TDREND_Update_object_positions( const IVAS_FORMAT in_format, /* i : Format of input sources */ const ISM_METADATA_HANDLE *hIsmMetaData, /* i : Input metadata for ISM objects */ #ifdef JBM_TSM_ON_TCS - float *output[] + float *output[] /* i/o: SCE/MC channels */ #else float output[][L_FRAME48k] /* i/o: SCE/MC channels */ #endif diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 72d1a320b5..ba89b59b9c 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -171,12 +171,12 @@ void ivas_dirac_dec_binaural( #ifdef JBM_TSM_ON_TCS void ivas_dirac_dec_binaural_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 */ - const int16_t nchan_transport, - float *output_f[] /* o : rendered time signal */ + 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 */ + const int16_t nchan_transport, /* i : number of transport channels */ + float *output_f[] /* o : rendered time signal */ ); #endif @@ -251,7 +251,7 @@ ivas_error ivas_td_binaural_renderer_unwrap( const IVAS_QUATERNION *Quaternions, /* i : Head tracking data per subframe */ const IVAS_VECTOR3 *Pos, /* i : Listener position data per subframe */ #ifdef JBM_TSM_ON_TCS - float *output[], /* i/o: SCE channels / Binaural synthesis */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ #else float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ #endif @@ -528,7 +528,8 @@ void ivas_rend_closeCrend( CREND_WRAPPER_HANDLE *pCrend ); ivas_error ivas_rend_initCrendWrapper( - CREND_WRAPPER_HANDLE *pCrend ); + CREND_WRAPPER_HANDLE *pCrend +); ivas_error ivas_rend_crendProcess( const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ @@ -539,7 +540,7 @@ ivas_error ivas_rend_crendProcess( const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ #ifdef JBM_TSM_ON_TCS - float *output[], /* i/o: input/output audio channels */ + float *output[], /* i/o: input/output audio channels */ #else float output[][L_FRAME48k], /* i/o: input/output audio channels */ #endif @@ -548,18 +549,19 @@ ivas_error ivas_rend_crendProcess( #ifdef JBM_TSM_ON_TCS ivas_error ivas_rend_crendProcessSubframe( - const CREND_WRAPPER *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - DECODER_CONFIG_HANDLE hDecoderConfig, - HEAD_TRACK_DATA_HANDLE hHeadTrackData, - IVAS_OUTPUT_SETUP_HANDLE hIntSetup, - EFAP_HANDLE hEFAPdata, - DECODER_TC_BUFFER_HANDLE hTcBuffer, - float *input_f[], - float *output[], /* i/o: input/output audio channels */ - const int16_t n_samples_to_render, - const int32_t output_Fs ); + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ + const HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : Head tracking data structure */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ + DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */ + float *input_f[], /* i : transport channels */ + float *output[], /* i/o: input/output audio channels */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + const int32_t output_Fs /* i : output sampling rate */ +); #endif @@ -655,8 +657,8 @@ ivas_error ivas_reverb_process( const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ const int16_t mix_signals, /* i : add reverb to output signal */ #ifdef JBM_TSM_ON_TCS - float *pcm_in[], /* i : the PCM audio to apply reverb on */ - float *pcm_out[], /* o : the PCM audio with reverb applied */ + float *pcm_in[], /* i : the PCM audio to apply reverb on */ + float *pcm_out[], /* o : the PCM audio with reverb applied */ #else float pcm_in[][L_FRAME48k], /* i : the PCM audio to apply reverb on */ float pcm_out[][L_FRAME48k], /* o : the PCM audio with reverb applied */ @@ -896,7 +898,7 @@ void rotateFrame_shd( void rotateFrame_sd( HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ #ifdef JBM_TSM_ON_TCS - float *output[], /* i/o: unrotated SD signal buffer in TD */ + float *output[], /* i/o: unrotated SD signal buffer in TD */ #else float output[][L_FRAME48k], /* i/o: unrotated SD signal buffer in TD */ #endif @@ -912,7 +914,7 @@ void rotateFrame_shd_cldfb( float Rmat[3][3], /* i : real-space rotation matrix */ const int16_t nInChannels, /* i : number of channels */ #ifdef JBM_TSM_ON_TCS - const int16_t numTimeSlots, /* i : number of time slots to process */ + const int16_t numTimeSlots, /* i : number of time slots to process */ #endif const int16_t shd_rot_max_order /* i : split-order rotation method */ ); diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 70f1eed194..a97ff1b9e3 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -514,7 +514,7 @@ void rotateFrame_shd_cldfb( float Rmat[3][3], /* i : real-space rotation matrix */ const int16_t nInChannels, /* i : number of channels */ #ifdef JBM_TSM_ON_TCS - const int16_t numTimeSlots, + const int16_t numTimeSlots, /* i : number of time slots to process */ #endif const int16_t shd_rot_max_order /* i : split-order rotation method */ ) diff --git a/lib_rend/ivas_sba_rendering.c b/lib_rend/ivas_sba_rendering.c index c549461c37..7affa9a913 100644 --- a/lib_rend/ivas_sba_rendering.c +++ b/lib_rend/ivas_sba_rendering.c @@ -93,10 +93,12 @@ void ivas_sba_prototype_renderer_sf( outChEnd = 2; } slot_idx_start = hSpar->slots_rendered; + /* Apply mixing matrix */ for ( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { int16_t md_idx = hSpar->render_to_md_map[ts + slot_idx_start]; + /* determine SPAR parameters for this time slot */ ivas_spar_get_parameters( hSpar, hDecoderConfig, md_idx, numch_out, numch_in, num_spar_bands, mixer_mat ); @@ -202,6 +204,7 @@ void ivas_sba_prototype_renderer_sf( } #endif + #ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS void ivas_sba_prototype_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index d82e00c067..a1a75a2e8d 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4420,6 +4420,7 @@ static ivas_error renderIsmToBinauralRoom( const IVAS_REND_HeadRotData *headRotData; #ifdef JBM_TSM_ON_TCS float *p_tmpRendBuffer[MAX_OUTPUT_CHANNELS]; + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { p_tmpRendBuffer[i] = tmpRendBuffer[i]; @@ -4802,10 +4803,10 @@ static ivas_error renderMcToBinaural( IVAS_REND_AudioConfig inConfig; ivas_error error; IVAS_REND_AudioBuffer tmpRotBuffer; - #ifdef JBM_TSM_ON_TCS float *p_tmpRendBuffer[MAX_OUTPUT_CHANNELS]; int16_t i; + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { p_tmpRendBuffer[i] = tmpRendBuffer[i]; @@ -4886,10 +4887,10 @@ static ivas_error renderMcToBinauralRoom( IVAS_REND_AudioConfig inConfig; ivas_error error; IVAS_REND_AudioBuffer tmpRotBuffer; - #ifdef JBM_TSM_ON_TCS float *p_tmpRendBuffer[MAX_OUTPUT_CHANNELS]; int16_t i; + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { p_tmpRendBuffer[i] = tmpRendBuffer[i]; @@ -4973,7 +4974,6 @@ static ivas_error renderMcCustomLsToBinauralRoom( IVAS_REND_AudioBuffer tmpRotBuffer; IVAS_REND_AudioBuffer tmpMcBuffer; IVAS_REND_AudioBuffer *tmpBufPtr; - #ifdef JBM_TSM_ON_TCS float *p_tmpCrendBuffer[MAX_OUTPUT_CHANNELS]; #endif @@ -5229,10 +5229,8 @@ static ivas_error renderSbaToBinaural( IVAS_REND_AudioBuffer outAudio ) { float tmpCrendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - ivas_error error; IVAS_REND_AudioBuffer tmpRotBuffer; - #ifdef JBM_TSM_ON_TCS float *p_tmpCrendBuffer[MAX_OUTPUT_CHANNELS]; int16_t i; @@ -5301,7 +5299,6 @@ static ivas_error renderSbaToBinauralRoom( IVAS_REND_AudioBuffer tmpRotBuffer; IVAS_REND_AudioBuffer tmpMcBuffer; IVAS_REND_AudioBuffer *tmpBufPtr; - #ifdef JBM_TSM_ON_TCS float *p_tmpCrendBuffer[MAX_OUTPUT_CHANNELS]; #endif -- GitLab From 357b0465100c726c2a9a2c2c00342be3bb0bd5e9 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 15 May 2023 18:39:22 +0200 Subject: [PATCH 21/23] clang-format --- lib_dec/ivas_sba_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 45daab00b2..da7d088791 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -438,7 +438,7 @@ ivas_error ivas_sba_dec_reconfigure( /*-------------------------------------------------------------------* * ivas_sba_dec_digest_tc() * - * + * *-------------------------------------------------------------------*/ ivas_error ivas_sba_dec_digest_tc( -- GitLab From fcf6bf90fcdb7e8d525665182d492328cb4189e4 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 16 May 2023 09:53:43 +0200 Subject: [PATCH 22/23] VARIABLE_SPEED_DECODING: formal improvements --- apps/decoder.c | 4 +-- lib_com/ivas_prot.h | 4 +-- lib_dec/ivas_jbm_dec.c | 9 ++++--- lib_dec/ivas_objectRenderer_internal.c | 13 +++++----- lib_dec/lib_dec.c | 36 ++++++++++++++++++++++---- readme.txt | 2 ++ 6 files changed, 49 insertions(+), 19 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 1e1052cde6..a2f4adcf10 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1004,7 +1004,7 @@ static bool parseCmdlIVAS_dec( else if ( strcmp( argv_to_upper, "-VS" ) == 0 ) { i++; - int tmp = 100; + int32_t tmp = 100; arg->variableSpeedMode = true; if ( i < argc - 3 ) { @@ -1031,7 +1031,7 @@ static bool parseCmdlIVAS_dec( else if ( strcmp( argv_to_upper, "-VOIP_FRAMESIZE" ) == 0 ) { i++; - int tmp; + int32_t tmp; if ( i < argc - 3 ) { if ( !is_digits_only( argv[i] ) ) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index f2ba6a7d45..b9021d587a 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5658,10 +5658,10 @@ ivas_error ivas_td_binaural_renderer( ); #ifdef JBM_TSM_ON_TCS -ivas_error ObjRenderIVASSubframe( +ivas_error ivas_td_binaural_renderer_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output[], /* i/o: SCE channels / Binaural synthesis */ - const int16_t output_frame /* i : output frame length */ + const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ ); #endif diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index dbbd9e30b9..7b1f167c6d 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -714,6 +714,7 @@ ivas_error ivas_jbm_dec_render( else /* ISM_MODE_DISC */ { *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + /* Loudspeaker or Ambisonics rendering */ if ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { @@ -729,7 +730,7 @@ ivas_error ivas_jbm_dec_render( /* Binaural rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - if ( ( ObjRenderIVASSubframe( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) { return error; } @@ -817,7 +818,7 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - if ( ( ObjRenderIVASSubframe( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) { return error; } @@ -986,7 +987,7 @@ ivas_error ivas_jbm_dec_flush_renderer( /* Binaural rendering */ if ( renderer_type_old == RENDERER_BINAURAL_OBJECTS_TD ) { - if ( ( ObjRenderIVASSubframe( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) + if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) { return error; } @@ -1028,7 +1029,7 @@ ivas_error ivas_jbm_dec_flush_renderer( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - if ( ( ObjRenderIVASSubframe( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) + if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index adc0bcb7e7..d84df109d5 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -86,16 +86,17 @@ ivas_error ivas_td_binaural_renderer( #ifdef JBM_TSM_ON_TCS /*---------------------------------------------------------------------* - * ObjRenderIVASFrame() + * ivas_td_binaural_renderer_sf() * * Receives the current frames for the object streams, updates metadata * and renders the current frame. *---------------------------------------------------------------------*/ -ivas_error ObjRenderIVASSubframe( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[], /* i/o: SCE channels / Binaural synthesis */ - const int16_t n_samples_asked ) +ivas_error ivas_td_binaural_renderer_sf( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ + const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ +) { int16_t first_sf, last_sf, subframe_idx; float reverb_signal[BINAURAL_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; @@ -123,7 +124,7 @@ ivas_error ObjRenderIVASSubframe( slot_size = st_ivas->hTcBuffer->n_samples_granularity; /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ - slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, n_samples_asked / slot_size ); + slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, n_samples_granularity / slot_size ); first_sf = st_ivas->hTcBuffer->subframes_rendered; last_sf = first_sf; st_ivas->hTcBuffer->slots_rendered += slots_to_render; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index a67c51e5da..5ca1f489bd 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -536,8 +536,8 @@ ivas_error IVAS_DEC_Configure( ivas_error IVAS_DEC_EnableVoIP( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ #ifdef VARIABLE_SPEED_DECODING - const IVAS_DEC_VOIP_MODE voipMode, /* i : VoIP or varable speed */ - const uint16_t speedFac, /* i : speed factor for varable speed */ + const IVAS_DEC_VOIP_MODE voipMode, /* i : VoIP or varable speed */ + const uint16_t speedFac, /* i : speed factor for varable speed */ #endif const int16_t jbmSafetyMargin, /* i : allowed delay reserve for JBM, in milliseconds */ const IVAS_DEC_INPUT_FORMAT inputFormat /* i : format of the input bitstream */ @@ -1892,6 +1892,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( return IVAS_ERR_VS_FRAME_NEEDED; } #endif + #ifdef JBM_TSM_ON_TCS if ( hVoIP->nSamplesAvailableNext == 0 ) { @@ -1910,6 +1911,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( extBufferedTime_ms = extBufferedSamples * 1000 / hDecoderConfig->output_Fs; dataUnit = NULL; + #ifdef VARIABLE_SPEED_DECODING if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VOIP ) { @@ -1969,6 +1971,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #ifdef VARIABLE_SPEED_DECODING } #endif + /* decode */ if ( !hIvasDec->hasBeenFedFirstGoodFrame ) { @@ -2066,6 +2069,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( hVoIP->lastDecodedWasActive = 1; } #endif + /* limit scale to range supported by time scaler */ if ( scale < APA_MIN_SCALE ) { @@ -2269,11 +2273,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #if defined( VARIABLE_SPEED_DECODING ) || defined( JBM_TSM_ON_TCS ) ivas_error IVAS_DEC_VoIP_Flush( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + 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 */ 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 */ - uint16_t *nSamplesAvailableNext, /* o : number of samples still available */ - int16_t *nSamplesFlushed /* o : number of samples flushed */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still available */ + int16_t *nSamplesFlushed /* o : number of samples flushed */ ) { ivas_error error; @@ -3218,7 +3222,14 @@ static ivas_error input_format_API_to_internal( return IVAS_ERR_OK; } + #ifdef JBM_TSM_ON_TCS +/*---------------------------------------------------------------------* + * IVAS_DEC_VoIP_GetRenderGranularity() + * + * + *---------------------------------------------------------------------*/ + static int16_t IVAS_DEC_VoIP_GetRenderGranularity( Decoder_Struct *st_ivas ) { @@ -3226,6 +3237,13 @@ static int16_t IVAS_DEC_VoIP_GetRenderGranularity( return st_ivas->hTcBuffer->n_samples_granularity; } + +/*---------------------------------------------------------------------* + * IVAS_DEC_VoIP_GetRendererConfig() + * + * + *---------------------------------------------------------------------*/ + static JBM_RENDERER_TYPE IVAS_DEC_VoIP_GetRendererConfig( IVAS_DEC_HANDLE hIvasDec ) { @@ -3244,6 +3262,13 @@ static JBM_RENDERER_TYPE IVAS_DEC_VoIP_GetRendererConfig( return rendererType; } + +/*---------------------------------------------------------------------* + * IVAS_DEC_VoIP_reconfigure() + * + * + *---------------------------------------------------------------------*/ + ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t nTransportChannels, @@ -3267,6 +3292,7 @@ ivas_error IVAS_DEC_VoIP_reconfigure( #else startQuality = 1.0f; #endif + /* get current renderer type*/ hVoIP->rendererType = IVAS_DEC_VoIP_GetRendererConfig( hIvasDec ); hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; diff --git a/readme.txt b/readme.txt index 21a5a19e79..5660aa353f 100644 --- a/readme.txt +++ b/readme.txt @@ -245,6 +245,8 @@ Options: The decoder may read rtpdump files containing TS26.445 Annex A.2.2 EVS RTP Payload Format. The SDP parameter hf_only is required. Reading RFC4867 AMR/AMR-WB RTP payload format is not supported. +-VS fac : Varaible Speed mode: change speed of playout fac as integer in percent. + fac<100 faster, fac>100 slower -Tracefile TF : VoIP mode: Generate trace file named TF -fec_cfg_file : Optimal channel aware configuration computed by the JBM as described in Section 6.3.1 of TS26.448. The output is -- GitLab From 59884ea825e272ef43edd994f1885f31935cf0e6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 16 May 2023 10:04:25 +0200 Subject: [PATCH 23/23] typo in comments --- lib_dec/lib_dec.c | 6 ++---- lib_dec/lib_dec.h | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 5ca1f489bd..ba14c70a45 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -536,8 +536,8 @@ ivas_error IVAS_DEC_Configure( ivas_error IVAS_DEC_EnableVoIP( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ #ifdef VARIABLE_SPEED_DECODING - const IVAS_DEC_VOIP_MODE voipMode, /* i : VoIP or varable speed */ - const uint16_t speedFac, /* i : speed factor for varable speed */ + const IVAS_DEC_VOIP_MODE voipMode, /* i : VoIP or variable speed */ + const uint16_t speedFac, /* i : speed factor for variable speed */ #endif const int16_t jbmSafetyMargin, /* i : allowed delay reserve for JBM, in milliseconds */ const IVAS_DEC_INPUT_FORMAT inputFormat /* i : format of the input bitstream */ @@ -558,11 +558,9 @@ ivas_error IVAS_DEC_EnableVoIP( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; hIvasDec->Opt_VOIP = 1; - #ifdef JBM_TSM_ON_TCS hDecoderConfig->voip_active = 1; #endif diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 9e27e903f8..94d1543ac7 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -266,8 +266,8 @@ ivas_error IVAS_DEC_VoIP_Flush( ivas_error IVAS_DEC_EnableVoIP( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ #ifdef VARIABLE_SPEED_DECODING - const IVAS_DEC_VOIP_MODE voipMode, /* i : VoIP or varable speed */ - const uint16_t speedFac, /* i : speed factor for varable speed */ + const IVAS_DEC_VOIP_MODE voipMode, /* i : VoIP or variable speed */ + const uint16_t speedFac, /* i : speed factor for variable speed */ #endif const int16_t jbmSafetyMargin, /* i : allowed delay reserve for JBM, in milliseconds */ const IVAS_DEC_INPUT_FORMAT inputFormat /* i : format of the input bitstream */ -- GitLab