From 3a25dbd118ee99d0f7d9f86459f85eb24281e27c Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 6 Jul 2023 11:42:11 +0200 Subject: [PATCH 001/109] New OSBA baseline with minimum ISM_MODE_NONE functionality - always render objects to SBA --- Workspace_msvc/lib_enc.vcxproj | 1 + Workspace_msvc/lib_enc.vcxproj.filters | 1 + apps/encoder.c | 128 +++++++++ lib_com/bitstream.c | 28 ++ lib_com/cnst.h | 3 + lib_com/delay_comp.c | 5 +- lib_com/ivas_cnst.h | 7 +- lib_com/ivas_dirac_com.c | 16 ++ lib_com/ivas_prot.h | 24 ++ lib_com/options.h | 2 +- lib_enc/ivas_core_enc.c | 17 ++ lib_enc/ivas_cpe_enc.c | 12 + lib_enc/ivas_enc.c | 77 +++++ lib_enc/ivas_init_enc.c | 93 +++++- lib_enc/ivas_mct_core_enc.c | 4 + lib_enc/ivas_mct_enc.c | 8 + lib_enc/ivas_osba_enc.c | 373 +++++++++++++++++++++++++ lib_enc/ivas_stat_enc.h | 38 +++ lib_enc/lib_enc.c | 77 +++++ lib_enc/lib_enc.h | 18 ++ 20 files changed, 928 insertions(+), 4 deletions(-) create mode 100644 lib_enc/ivas_osba_enc.c diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index 3378ac10f0..e77516104c 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -215,6 +215,7 @@ + diff --git a/Workspace_msvc/lib_enc.vcxproj.filters b/Workspace_msvc/lib_enc.vcxproj.filters index b3970764c0..7c7898ee29 100644 --- a/Workspace_msvc/lib_enc.vcxproj.filters +++ b/Workspace_msvc/lib_enc.vcxproj.filters @@ -590,6 +590,7 @@ enc_ivas_c + diff --git a/apps/encoder.c b/apps/encoder.c index 75798f240d..9bf1f3f561 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -89,6 +89,16 @@ typedef union _EncInputFormatConfig /* MC details */ IVAS_ENC_MC_LAYOUT mcLayout; +#ifdef SBA_AND_OBJECTS + struct EncSbaIsmConfig + { + int16_t numObjects; + const char *metadataFiles[IVAS_MAX_NUM_OBJECTS]; + IVAS_ENC_SBA_ORDER order; + bool isPlanar; + } sba_ism; +#endif + } EncInputFormatConfig; /* Struct for storing cmdln arguments */ @@ -233,7 +243,11 @@ int main( * Print out file names *------------------------------------------------------------------------------------------*/ +#ifdef SBA_AND_OBJECTS + if ( arg.inputFormat == IVAS_ENC_INPUT_ISM || arg.inputFormat == IVAS_ENC_INPUT_SBA_ISM ) +#else if ( arg.inputFormat == IVAS_ENC_INPUT_ISM ) +#endif { for ( i = 0; i < arg.inputFormatConfig.ism.numObjects; i++ ) { @@ -427,6 +441,15 @@ int main( goto cleanup; } break; +#ifdef SBA_AND_OBJECTS + case IVAS_ENC_INPUT_SBA_ISM: + if ( ( error = IVAS_ENC_ConfigureForSBAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba_ism.numObjects, arg.inputFormatConfig.sba_ism.order, arg.inputFormatConfig.sba_ism.isPlanar, arg.pca ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_ENC_ConfigureForSBAObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + exit( -1 ); + } + break; +#endif default: fprintf( stderr, "\nInvalid input type\n\n" ); goto cleanup; @@ -511,7 +534,11 @@ int main( } } +#ifdef SBA_AND_OBJECTS + const int16_t numIsmInputs = ( arg.inputFormat == IVAS_ENC_INPUT_ISM || arg.inputFormat == IVAS_ENC_INPUT_SBA_ISM ) ? arg.inputFormatConfig.ism.numObjects : 0; +#else const int16_t numIsmInputs = arg.inputFormat == IVAS_ENC_INPUT_ISM ? arg.inputFormatConfig.ism.numObjects : 0; +#endif for ( i = 0; i < numIsmInputs; ++i ) { @@ -1490,6 +1517,96 @@ static bool parseCmdlIVAS_enc( return false; } } +#ifdef SBA_AND_OBJECTS + else if ( strcmp( to_upper( argv[i] ), "-ISM_SBA" ) == 0 ) + { + arg->inputFormat = IVAS_ENC_INPUT_SBA_ISM; + i++; + + if ( i < argc - 5 ) + { + if ( sscanf( argv[i], "%d", &tmp ) > 0 ) + { + i++; + } + + if ( tmp <= 0 ) + { + fprintf( stderr, "Error: Too low number of ISM channels specified!\n\n" ); + usage_enc(); + } + else + { + if ( tmp <= IVAS_MAX_NUM_OBJECTS ) /* number of ISM channels */ + { + arg->inputFormatConfig.sba_ism.numObjects = (int16_t) tmp; + } + else + { + fprintf( stderr, "Error: Too high number of ISM channels!\n\n" ); + usage_enc(); + } + } + } + else + { + fprintf( stderr, "Error: Number of ISM channels not specified!\n\n" ); + usage_enc(); + } + + if ( i < argc - 4 ) + { + if ( sscanf( argv[i], "%d", &tmp ) > 0 ) + { + i++; + } + + arg->inputFormatConfig.sba_ism.isPlanar = ( tmp < 0 ); + + tmp = abs( tmp ); + switch ( tmp ) + { + case 1: + arg->inputFormatConfig.sba_ism.order = IVAS_ENC_SBA_FOA; + break; + case 2: + arg->inputFormatConfig.sba_ism.order = IVAS_ENC_SBA_HOA2; + break; + case 3: + arg->inputFormatConfig.sba_ism.order = IVAS_ENC_SBA_HOA3; + break; + default: + fprintf( stderr, "Error: Wrong SBA order specified!\n\n" ); + usage_enc(); + return false; + } + } + + /* read input metadata files */ + for ( j = 0; j < arg->inputFormatConfig.sba_ism.numObjects; j++ ) + { + if ( i < argc - 4 ) + { + if ( strcmp( argv[i], "NULL" ) == 0 || strcmp( argv[i], "null" ) == 0 ) + { + /* no metadata input file -> encode only audio streams */ + arg->inputFormatConfig.sba_ism.metadataFiles[j] = NULL; + } + else + { + arg->inputFormatConfig.sba_ism.metadataFiles[j] = argv[i]; + } + + i++; + } + else + { + fprintf( stderr, "Error: not enough arguments\n\n" ); + usage_enc(); + } + } + } +#endif else if ( strcmp( argv_to_upper, "-STEREO_DMX_EVS" ) == 0 ) { arg->inputFormat = IVAS_ENC_INPUT_MONO; @@ -1671,6 +1788,10 @@ static void usage_enc( void ) fprintf( stdout, " for 4 ISM also 512000 \n" ); fprintf( stdout, " for IVAS SBA, MASA, MC R=(13200, 16400, 24400, 32000, 48000, 64000, 80000, \n" ); fprintf( stdout, " 96000, 128000, 160000, 192000, 256000, 384000, 512000) \n" ); +#ifdef SBA_AND_OBJECTS + fprintf( stdout, " for IVAS objects-SBA R =(13200, 16400, 24400, 32000, 48000, 64000, 96000, 128000, \n" ); + fprintf( stdout, " 160000, 192000, 256000, 384000, 512000)\n" ); +#endif fprintf( stdout, " Alternatively, R can be a bitrate switching file which consists of R values\n" ); fprintf( stdout, " indicating the bitrate for each frame in bps. These values are stored in\n" ); fprintf( stdout, " binary format using 4 bytes per value\n" ); @@ -1694,6 +1815,13 @@ static void usage_enc( void ) fprintf( stdout, "-masa Ch File : MASA format \n" ); fprintf( stdout, " where Ch specifies the number of input/transport channels (1 or 2): \n" ); fprintf( stdout, " and File specifies input file containing parametric MASA metadata \n" ); +#ifdef SBA_AND_OBJECTS + fprintf( stdout, "-ism_sba IsmChannels SBAChannels IsmFiles SBAFile : MASA and objects format \n" ); + fprintf( stdout, " where IsmChannels specifies the number of ISms (1-4)\n" ); + fprintf( stdout, " and SBAChannels specifies the SBA order (1 to 3) \n" ); + fprintf( stdout, " and IsmFiles specify input files containing metadata, one file per object \n" ); + fprintf( stdout, " and SBAFile specifies SBA input file \n" ); +#endif fprintf( stdout, "-mc InputConf : Multi-channel format\n" ); fprintf( stdout, " where InputConf specifies the channel configuration: 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4\n" ); fprintf( stdout, " Loudspeaker positions are assumed to have azimuth and elevation as per \n" ); diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 25d388aed1..f55253b9b8 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -319,7 +319,11 @@ int16_t get_ivas_max_num_indices( return 1650; } } +#ifdef SBA_AND_OBJECTS + else if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) +#else else if ( ivas_format == SBA_FORMAT ) +#endif { if ( ivas_total_brate <= IVAS_16k4 ) { @@ -698,7 +702,11 @@ int16_t get_ivas_max_num_indices_metadata( return 80; } } +#ifdef SBA_AND_OBJECTS + else if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) +#else else if ( ivas_format == SBA_FORMAT ) +#endif { if ( ivas_total_brate <= IVAS_16k4 ) { @@ -2569,6 +2577,26 @@ ivas_error preview_indices( break; case 2: st_ivas->ivas_format = ISM_FORMAT; + + if ( total_brate >= IVAS_24k4 ) + { + if ( bit_stream[2] ) + { +#ifdef SBA_AND_OBJECTS + if ( bit_stream[3] ) + { + st_ivas->ivas_format = SBA_ISM_FORMAT; + + /* Placeholder for SBA + objects */ + } + else + { + /*st_ivas->ivas_format = MASA_ISM_FORMAT;*/ + } + /* placeholder for combined format signaling */ +#endif + } + } break; case 3: if ( bit_stream[2] == 0 ) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index e1362b0d75..d7ce02fe76 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -263,6 +263,9 @@ enum{ enum { IND_IVAS_FORMAT, +#ifdef MASA_AND_OBJECTS + IND_SMODE_OMASA, +#endif IND_SMODE, IND_SID_TYPE, IND_BWIDTH, diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c index 003d942245..742d2addc5 100644 --- a/lib_com/delay_comp.c +++ b/lib_com/delay_comp.c @@ -74,8 +74,11 @@ int32_t get_delay( delay = 0; /* All delay is compensated in the decoder with MASA */ } } - +#ifdef SBA_AND_OBJECTS + if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) +#else if ( ivas_format == SBA_FORMAT ) +#endif { /* compensate for DirAC/SPAR filterbank delay */ delay += IVAS_FB_ENC_DELAY_NS; diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 60807f62cb..29b685d5d2 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -69,7 +69,9 @@ typedef enum SBA_FORMAT, /* IVAS SBA (ambisonics) format */ MASA_FORMAT, /* IVAS MASA format */ MC_FORMAT, /* IVAS multi-channel format */ - +#ifdef SBA_AND_OBJECTS + SBA_ISM_FORMAT /* IVAS combined SBA + objects format */ +#endif } IVAS_FORMAT; @@ -79,6 +81,9 @@ typedef enum #define IVAS_FORMAT_SIGNALING_NBITS 2 /* number of bits for signaling the IVAS format */ #define IVAS_FORMAT_SIGNALING_NBITS_EXTENDED ( IVAS_FORMAT_SIGNALING_NBITS + 1 ) +#ifdef SBA_AND_OBJECTS +#define IVAS_COMBINED_FORMAT_SIGNALLING_BITS 1 +#endif /*----------------------------------------------------------------------------------* diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 20f4b24953..b7235542f4 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -140,7 +140,11 @@ ivas_error ivas_dirac_config( dirac_to_spar_md_bands = ( (Decoder_Struct *) st_ivas )->hSpar->dirac_to_spar_md_bands; } +#ifdef SBA_AND_OBJECTS + if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) +#else if ( ivas_format == SBA_FORMAT ) +#endif { hConfig->nbands = IVAS_MAX_NUM_BANDS; @@ -158,7 +162,11 @@ ivas_error ivas_dirac_config( } hConfig->enc_param_start_band = 0; hConfig->dec_param_estim = FALSE; +#ifdef SBA_AND_OBJECTS + if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) /* skip for MASA decoder */ +#else if ( ivas_format == SBA_FORMAT ) /* skip for MASA decoder */ +#endif { if ( ( error = ivas_dirac_sba_config( hQMetaData, element_mode, ivas_total_brate, sba_order, hConfig->nbands - spar_dirac_split_band ) ) != IVAS_ERR_OK ) { @@ -167,7 +175,11 @@ ivas_error ivas_dirac_config( if ( hQMetaData != NULL ) { +#ifdef SBA_AND_OBJECTS + if ( enc_dec == ENC || ( ivas_format != SBA_FORMAT && ivas_format != SBA_ISM_FORMAT ) ) /* Todo: This condition should probably be corrected in main */ +#else if ( enc_dec == ENC || ivas_format != SBA_FORMAT ) +#endif { hConfig->nbands = hQMetaData->q_direction[0].cfg.nbands; } @@ -190,7 +202,11 @@ ivas_error ivas_dirac_config( } } +#ifdef SBA_AND_OBJECTS + if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) +#else if ( ivas_format == SBA_FORMAT ) +#endif { ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( Fs * INV_CLDFB_BANDWIDTH + 0.5f ), dirac_to_spar_md_bands, hQMetaData->useLowerBandRes, hConfig->enc_param_start_band, hFbMdft ); } diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 9bc253776d..42f7b62e13 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5541,6 +5541,30 @@ void ivas_filter_process( const int16_t length /* i : filter order */ ); +#ifdef SBA_AND_OBJECTS +ivas_error ivas_osba_enc_open( + Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ +); + +void ivas_osba_enc_close( + OSBA_ENC_HANDLE *hOSba /* i/o: encoder OSBA handle */ +); + +ivas_error ivas_osba_enc_config( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +void ivas_osba_enc( + OSBA_ENC_HANDLE hOSba, /* i/o: OSBA encoder handle */ + ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handle */ + float data_in_f[][L_FRAME48k], /* i/o: Input / transport audio signals */ + const int16_t input_frame, /* i : Input frame size */ + const int16_t nchan_ism, /* i : Number of objects for parameter analysis*/ + const ISM_MODE ism_mode, /* i : ISM mode */ + float data_separated_object[L_FRAME48k], /* o : Separated object audio signal */ + int16_t *idx_separated_object /* o : Index of the separated object */ +); +#endif /*----------------------------------------------------------------------------------* * TD Binaural Object renderer diff --git a/lib_com/options.h b/lib_com/options.h index e4d3a06b58..df9551f444 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -161,7 +161,7 @@ #define ISM_FB_16k4 /* VA: Issue: 579: change BW from SWB to FB in NxISM conditions to match the EVS codec */ #define FIX_580_PARAMMC_ENER_BURSTS /* FhG: issue 580: energy bursts due to ILD holding when energy relations change too much */ - +#define SBA_AND_OBJECTS /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index 7ff583a6d2..3da7096463 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -425,6 +425,23 @@ ivas_error ivas_core_enc( } } +/**TODOFTO: is this needed */ +#ifdef MASA_AND_OBJECTS + /*------------------------------------------------------------------* + * Write potentially unused bits in combined format coding + *-----------------------------------------------------------------*/ + + if ( hCPE != NULL && hCPE->element_mode == IVAS_CPE_DFT && hCPE->brate_surplus > 0 ) + { + while ( diff_nBits > 0 ) + { + n = min( diff_nBits, 16 ); + push_indice( sts[0]->hBstr, IND_UNUSED, 0, n ); + diff_nBits -= n; + } + } +#endif + #ifdef DEBUG_MODE_INFO for ( n = 0; n < n_CoreChannels; n++ ) { diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 3c1d7a61c6..31262ddd5f 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -320,7 +320,11 @@ ivas_error ivas_cpe_enc( hCPE->hStereoMdct->mdct_stereo_mode_cmdl = hEncoderConfig->mdct_stereo_mode_cmdl; #endif initMdctStereoEncData( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, max_bwidth, 0, NULL, 0 ); +#ifdef SBA_AND_OBJECTS + hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->nchan_transport == 2 ) ); +#else hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT ) && ( st_ivas->nchan_transport == 2 ) ); +#endif } } @@ -488,7 +492,11 @@ ivas_error ivas_cpe_enc( if ( sts[0]->bwidth != sts[0]->last_bwidth || ( ( hCPE->last_element_brate != hCPE->element_brate || hCPE->last_element_mode != hCPE->element_mode ) && sts[0]->bwidth != sts[0]->max_bwidth ) ) { initMdctStereoEncData( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, sts[0]->bwidth, 0, NULL, 0 ); +#ifdef SBA_AND_OBJECTS + hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->nchan_transport == 2 ) ); +#else hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT ) && ( st_ivas->nchan_transport == 2 ) ); +#endif if ( hCPE->element_brate <= MAX_MDCT_ITD_BRATE && ivas_format == STEREO_FORMAT ) { @@ -955,7 +963,11 @@ ivas_error create_cpe_enc( hCPE->hStereoMdct->mdct_stereo_mode_cmdl = st_ivas->hEncoderConfig->mdct_stereo_mode_cmdl; #endif initMdctStereoEncData( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, max_bwidth, 0, NULL, 1 ); +#ifdef SBA_AND_OBJECTS + hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->nchan_transport == 2 ) ); +#else hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT ) && ( st_ivas->nchan_transport == 2 ) ); +#endif if ( hCPE->element_mode == IVAS_CPE_MDCT && element_brate <= MAX_MDCT_ITD_BRATE && ivas_format == STEREO_FORMAT ) { diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 854354ceb8..3abe9fed4b 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -62,7 +62,11 @@ ivas_error ivas_enc( BSTR_ENC_HANDLE hMetaData; Encoder_State *st; /* used for bitstream handling */ int16_t nb_bits_metadata[MAX_SCE]; +#ifdef SBA_AND_OBJECTS + float data_f[MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; +#else float data_f[MAX_INPUT_CHANNELS][L_FRAME48k]; +#endif int32_t ivas_total_brate; ivas_error error; error = IVAS_ERR_OK; @@ -266,6 +270,79 @@ ivas_error ivas_enc( } } } +#ifdef SBA_AND_OBJECTS + else if ( ivas_format == SBA_ISM_FORMAT ) + { + float data_separated_object[L_FRAME48k]; + int16_t idx_separated_object; + + /*Default mode for OSBA*/ + st_ivas->ism_mode = ISM_MODE_NONE; + + if ( st_ivas->ism_mode == ISM_MODE_NONE ) /*rendering of objects in SBA signal*/ + { + /* Analyze objects and determine needed audio signals */ + ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, data_separated_object, &idx_separated_object ); + } + else /*not an option for now*/ + { + /* delay ISM input channels to match the SBA encoder delay */ + for ( n = 0; n < hEncoderConfig->nchan_ism; n++ ) + { + delay_signal( data_f[n], input_frame, st_ivas->hSpar->input_data_mem[n], NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ) ); + } + } + + if ( st_ivas->ism_mode == ISM_MODE_NONE ) + { + if ( st_ivas->nchan_transport == 1 ) + { + st = st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0]; + hMetaData = st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData; + } + else + { + st = st_ivas->hCPE[0]->hCoreCoder[0]; + hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; + } + + /* Write SBA planar flag */ + push_indice( st->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); + + /* Write SBA order */ + push_indice( st->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS ); + + /* SBA metadata encoding and SBA metadata bitstream writing */ + if ( ( error = ivas_spar_enc( st_ivas, data_f, input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* core-coding of transport channels */ + if ( st_ivas->nSCE == 1 ) + { + if ( ( error = ivas_sce_enc( st_ivas, 0, data_f[0], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->nCPE == 1 ) /* Stereo DMX */ + { + if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->nCPE > 1 ) /* FOA/HOA format */ + { + if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + } +#endif else if ( ivas_format == MC_FORMAT ) { /* select MC format mode; write MC LS setup; reconfigure the MC format encoder */ diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index fdb562243c..5fb81f4b0a 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -83,6 +83,20 @@ void ivas_write_format( ind = 7; nBits += extra_bits; break; +#ifdef SBA_AND_OBJECTS + case SBA_ISM_FORMAT: + if ( st_ivas->ism_mode == ISM_MODE_NONE ) + { + ind = 6; /* send SBA format */ + nBits += extra_bits; + } + else + { + ind = 11; /* 1011 */ + nBits += extra_bits + IVAS_COMBINED_FORMAT_SIGNALLING_BITS; + } + break; +#endif default: assert( !"Invalid format. Aborting." ); break; @@ -203,7 +217,13 @@ int16_t getNumChanAnalysis( { n = st_ivas->hEncoderConfig->nchan_inp; } - +#ifdef SBA_AND_OBJECTS + else if ( st_ivas->hEncoderConfig->ivas_format == SBA_ISM_FORMAT ) + { + // Todo OSBA merge: This might be wrong after addition of HO-DirAC. Decide if that is desired for combined format. + n = st_ivas->hEncoderConfig->nchan_ism + FOA_CHANNELS; + } +#endif return n; } @@ -542,6 +562,77 @@ ivas_error ivas_init_encoder( } } } +#ifdef SBA_AND_OBJECTS + // Todo OSBA merge: This requires adjustment to follow all the new things like dynamic indices + else if ( ivas_format == SBA_ISM_FORMAT ) + { + int32_t element_brate_tmp[MAX_NUM_OBJECTS]; + + st_ivas->ism_mode = ISM_MODE_NONE; + + if ( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* allocate and initialize SBA handles */ + if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) + { + return error; + } + + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); + + if ( ( error = ivas_spar_enc_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) /*TODOfto:remove this*/ + { + return error; + } + + if ( ( error = ivas_dirac_enc_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + + + if ( st_ivas->ism_mode == ISM_MODE_NONE ) + { + sce_id = 0; + /* allocate and initialize SBA core-coders */ + if ( st_ivas->nchan_transport == 1 ) + { + + if ( ( error = create_sce_enc( st_ivas, sce_id, ivas_total_brate ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + { + if ( ( error = create_cpe_enc( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + if ( st_ivas->nCPE > 1 ) + { + if ( ( error = create_mct_enc( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + + if ( st_ivas->ism_mode == ISM_MODE_NONE ) + { + if ( ( error = ivas_osba_enc_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } +#endif else if ( ivas_format == MC_FORMAT ) { st_ivas->mc_mode = ivas_mc_mode_select( hEncoderConfig->mc_input_setup, ivas_total_brate ); diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 0c98f82d05..f879a6ea55 100755 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -481,7 +481,11 @@ void ivas_mct_core_enc( nAvailBits -= IVAS_FORMAT_SIGNALING_NBITS; nAvailBits -= MC_LS_SETUP_BITS; } +#ifdef SBA_AND_OBJECTS + else if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) +#else else if ( ivas_format == SBA_FORMAT ) +#endif { nAvailBits -= IVAS_FORMAT_SIGNALING_NBITS_EXTENDED; nAvailBits -= SBA_ORDER_BITS + SBA_PLANAR_BITS; diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 42ce327a4c..f9e5c9e28d 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -82,7 +82,11 @@ static void set_mct_enc_params( } hMCT->hbr_mct = 0; +#ifdef SBA_AND_OBJECTS + if ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && ivas_total_brate >= IVAS_256k ) +#else if ( ivas_format == SBA_FORMAT && ivas_total_brate >= IVAS_256k ) +#endif { hMCT->hbr_mct = 1; } @@ -304,7 +308,11 @@ ivas_error create_mct_enc( { hMCT->nchan_out_woLFE = st_ivas->hEncoderConfig->nchan_inp - 1; /* LFE channel is coded separately */ } +#ifdef SBA_AND_OBJECTS + else if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) +#else else if ( ivas_format == SBA_FORMAT ) +#endif { hMCT->nchan_out_woLFE = ivas_get_sba_num_TCs( ivas_total_brate, st_ivas->sba_analysis_order ); } diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c new file mode 100644 index 0000000000..f27ee39ad7 --- /dev/null +++ b/lib_enc/ivas_osba_enc.c @@ -0,0 +1,373 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "options.h" +#include +#include +#include +#include "ivas_cnst.h" +#include "ivas_prot.h" +#include "prot.h" +#include "ivas_rom_com.h" +#include "ivas_rom_enc.h" +#ifdef DEBUGGING +#include "debug.h" +#endif +#include "wmc_auto.h" + +#ifdef SBA_AND_OBJECTS + +/*------------------------------------------------------------------------- + * Local function prototypes + *------------------------------------------------------------------------*/ + +static void ivas_osba_energy_and_ratio_est( OSBA_ENC_HANDLE hOSba, float data_f[][L_FRAME48k], const int16_t input_frame, const int16_t nchan_inp ); + +static void ivas_osba_render_ism_to_sba( float data_in_f[][L_FRAME48k], float data_out_f[][L_FRAME48k], const int16_t input_frame, const int16_t nchan_sba, const int16_t nchan_ism, ISM_METADATA_HANDLE hIsmMeta[], float prev_gains[][FOA_CHANNELS], const float interpolator[L_FRAME48k] ); + +/*-------------------------------------------------------------------* + * ivas_merge_sba_transports() + * + * Merge SBA transport channels + *-------------------------------------------------------------------*/ + +static void ivas_merge_sba_transports( + float data_in_f1[][L_FRAME48k], + float data_in_f2[][L_FRAME48k], + float data_out_f[][L_FRAME48k], + const int16_t input_frame, + const int16_t num_transport_channels ) +{ + int16_t i, j; + + for ( i = 0; i < num_transport_channels; i++ ) + { + for ( j = 0; j < input_frame; j++ ) + { + data_out_f[i][j] = data_in_f1[i][j] + data_in_f2[i][j]; + } + } + + return; +} + +/*--------------------------------------------------------------------------* + * ivas_osba_enc_open() + * + * Allocate and initialize OMASA handle + *--------------------------------------------------------------------------*/ + +ivas_error ivas_osba_enc_open( + Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ +) +{ + int16_t i; + OSBA_ENC_HANDLE hOSba; + int16_t input_frame; + ivas_error error; + + error = IVAS_ERR_OK; + + + if ( ( hOSba = (OSBA_ENC_HANDLE) malloc( sizeof( OSBA_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OMASA encoder\n" ) ); + } + + for ( i = 0; i < MAX_NUM_OBJECTS; i++ ) + { + set_f( hOSba->prev_object_dm_gains[i], (float) sqrt( 0.5 ), FOA_CHANNELS ); + } + set_zero( hOSba->broadband_energy_sm, MAX_NUM_OBJECTS + FOA_CHANNELS ); + set_zero( hOSba->broadband_energy_prev, MAX_NUM_OBJECTS + FOA_CHANNELS ); + hOSba->prev_selected_object = 0; + hOSba->changing_object = 0; + + input_frame = (int16_t) ( st_ivas->hEncoderConfig->input_Fs / FRAMES_PER_SEC ); + for ( i = 0; i < input_frame; i++ ) + { + hOSba->interpolator[i] = ( (float) i ) / ( (float) input_frame ); + hOSba->fade_out_gain[i] = ( 1.0f + cosf( ( (float) i ) / ( (float) input_frame ) * EVS_PI ) ) / 2.0f; + hOSba->fade_in_gain[i] = 1.0f - hOSba->fade_out_gain[i]; + } + + st_ivas->hOSba = hOSba; + + return error; +} + + +/*--------------------------------------------------------------------------* + * ivas_omasa_enc_close() + * + * Close OMASA handle + *--------------------------------------------------------------------------*/ + +void ivas_osba_enc_close( + OSBA_ENC_HANDLE *hOSba /* i/o: encoder OSBA handle */ +) +{ + if ( hOSba == NULL || *hOSba == NULL ) + { + return; + } + + free( *hOSba ); + ( *hOSba ) = NULL; + + return; +} + + +/*--------------------------------------------------------------------------* + * ivas_osba_enc_config() + * + * oSBA encoder configuration + *--------------------------------------------------------------------------*/ + +ivas_error ivas_osba_enc_config( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +) +{ + + ENCODER_CONFIG_HANDLE hEncoderConfig; + + hEncoderConfig = st_ivas->hEncoderConfig; + +#if 0 + st_ivas->ism_mode = ivas_osba_ism_mode_select( hEncoderConfig->ivas_total_brate, hEncoderConfig->nchan_ism ); +#else + st_ivas->ism_mode = ISM_MODE_NONE; +#endif + + /* reconfiguration in case of bitrate switching */ + if ( hEncoderConfig->last_ivas_total_brate != hEncoderConfig->ivas_total_brate ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "bitrate switching not supported in OSBA yet" ); + } + + return IVAS_ERR_OK; +} + + +/*--------------------------------------------------------------------------* + * ivas_osba_enc() + * + * Main OSBA encoding function + *--------------------------------------------------------------------------*/ + +void ivas_osba_enc( + OSBA_ENC_HANDLE hOSba, /* i/o: OSBA encoder handle */ + ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handle */ + float data_in_f[][L_FRAME48k], /* i/o: Input / transport audio signals */ + const int16_t input_frame, /* i : Input frame size */ + const int16_t nchan_ism, /* i : Number of objects for parameter analysis */ + const ISM_MODE ism_mode, /* i : ISM mode */ + float data_separated_object[L_FRAME48k], /* o : Separated object audio signal */ + int16_t *idx_separated_object /* o : Index of the separated object */ +) +{ + float data_out_f[FOA_CHANNELS][L_FRAME48k]; + + if ( ism_mode == ISM_MODE_NONE ) + { + /* Convert ISM to SBA */ + ivas_osba_render_ism_to_sba( data_in_f, data_out_f, input_frame, FOA_CHANNELS, nchan_ism, hIsmMeta, hOSba->prev_object_dm_gains, hOSba->interpolator ); + + /* Merge SBA signals */ + ivas_merge_sba_transports( data_out_f, &( data_in_f[nchan_ism] ), data_in_f, input_frame, FOA_CHANNELS ); + } + /* Set the number of objects */ + hOSba->nchan_ism = nchan_ism; + + return; +} + + +/*--------------------------------------------------------------------------* + * Local functions + *--------------------------------------------------------------------------*/ + +/* Estimate energies and ratios */ +static void ivas_osba_energy_and_ratio_est( + OSBA_ENC_HANDLE hOSba, + float data_f[][L_FRAME48k], + const int16_t input_frame, + const int16_t nchan_inp ) +{ + int16_t ts, i, j, k; + int16_t num_freq_bands; + int16_t l_ts; + float *pcm_in[MAX_NUM_OBJECTS]; + float Chnl_RealBuffer[MAX_NUM_OBJECTS][DIRAC_NO_FB_BANDS_MAX]; + float Chnl_ImagBuffer[MAX_NUM_OBJECTS][DIRAC_NO_FB_BANDS_MAX]; + float *p_Chnl_RealBuffer[MAX_NUM_OBJECTS]; + float *p_Chnl_ImagBuffer[MAX_NUM_OBJECTS]; + int16_t block_m_idx; + int16_t mrange[2], brange[2]; + float tftile_energy; + float ism_ratio_sum; + + num_freq_bands = hOSba->nbands; + l_ts = input_frame / MDFT_NO_COL_MAX; + + for ( i = 0; i < nchan_inp; i++ ) + { + pcm_in[i] = &data_f[i][0]; + p_Chnl_RealBuffer[i] = &Chnl_RealBuffer[i][0]; + p_Chnl_ImagBuffer[i] = &Chnl_ImagBuffer[i][0]; + } + + /* do processing for all subframes */ + for ( block_m_idx = 0; block_m_idx < hOSba->nSubframes; block_m_idx++ ) + { + mrange[0] = hOSba->block_grouping[block_m_idx]; + mrange[1] = hOSba->block_grouping[block_m_idx + 1]; + + /* Reset variable */ + for ( i = 0; i < hOSba->nbands; i++ ) + { + set_zero( hOSba->energy_ratio_ism[block_m_idx][i], nchan_inp ); + } + set_zero( hOSba->energy_ism[block_m_idx], num_freq_bands ); + + /* Compute TF transform and energy */ + for ( ts = mrange[0]; ts < mrange[1]; ts++ ) + { + ivas_fb_mixer_get_windowed_fr( hOSba->hFbMixer, pcm_in, p_Chnl_RealBuffer, p_Chnl_ImagBuffer, l_ts, l_ts, hOSba->hFbMixer->fb_cfg->num_in_chans ); + + ivas_fb_mixer_update_prior_input( hOSba->hFbMixer, pcm_in, l_ts, hOSba->hFbMixer->fb_cfg->num_in_chans ); + + for ( i = 0; i < nchan_inp; i++ ) + { + pcm_in[i] += l_ts; + } + + for ( i = 0; i < num_freq_bands; i++ ) + { + brange[0] = hOSba->band_grouping[i]; + brange[1] = hOSba->band_grouping[i + 1]; + for ( j = brange[0]; j < brange[1]; j++ ) + { + for ( k = 0; k < nchan_inp; k++ ) + { + tftile_energy = Chnl_RealBuffer[k][j] * Chnl_RealBuffer[k][j] + Chnl_ImagBuffer[k][j] * Chnl_ImagBuffer[k][j]; + hOSba->energy_ism[block_m_idx][i] += tftile_energy; + hOSba->energy_ratio_ism[block_m_idx][i][k] += tftile_energy; + } + } + } + } + + /* Compute ISM energy ratios */ + for ( i = 0; i < num_freq_bands; i++ ) + { + ism_ratio_sum = 0.0f; + for ( j = 0; j < nchan_inp; j++ ) + { + hOSba->energy_ratio_ism[block_m_idx][i][j] /= ( hOSba->energy_ism[block_m_idx][i] + EPSILON ); + ism_ratio_sum += hOSba->energy_ratio_ism[block_m_idx][i][j]; + } + + if ( ism_ratio_sum == 0.0f ) + { + float temp_ism_ratio = 1.0f / ( (float) nchan_inp ); + for ( j = 0; j < nchan_inp; j++ ) + { + hOSba->energy_ratio_ism[block_m_idx][i][j] = temp_ism_ratio; + } + } + } + } + + return; +} + +/* Render ISMs to SBA */ +static void ivas_osba_render_ism_to_sba( + float data_in_f[][L_FRAME48k], + float data_out_f[][L_FRAME48k], + const int16_t input_frame, + const int16_t nchan_sba, + const int16_t nchan_ism, + ISM_METADATA_HANDLE hIsmMeta[], + float prev_gains[][FOA_CHANNELS], + const float interpolator[L_FRAME48k] ) +{ + int16_t i, j, k; + int16_t azimuth, elevation; + float gains[FOA_CHANNELS]; + float g1, g2; + float output_gain; + + + for ( i = 0; i < nchan_sba; i++ ) + { + set_zero( data_out_f[i], input_frame ); + } + + for ( i = 0; i < nchan_ism; i++ ) + { + azimuth = (int16_t) floorf( hIsmMeta[i]->azimuth + 0.5f ); + elevation = (int16_t) floorf( hIsmMeta[i]->elevation + 0.5f ); + + ivas_dirac_dec_get_response( azimuth, elevation, gains, 1 ); + + /* Render using the sh gains */ + for ( j = 0; j < nchan_sba; j++ ) + { + if ( fabsf( gains[j] ) > 0.0 || fabsf( prev_gains[i][j] ) > 0.0f ) + { + for ( k = 0; k < input_frame; k++ ) + { + g1 = interpolator[k]; + g2 = 1.0f - g1; + data_out_f[j][k] += ( g1 * gains[j] + g2 * prev_gains[i][j] ) * data_in_f[i][k]; + } + } + prev_gains[i][j] = gains[j]; + } + } + + /* Gain with loudness-matching gains */ + output_gain = 0.7499f; + for ( j = 0; j < nchan_sba; j++ ) + { + for ( k = 0; k < input_frame; k++ ) + { + data_out_f[j][k] *= output_gain; + } + } + + return; +} +#endif /* SBA_AND_OBJECTS */ diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 6a5964e86c..daa2ffea3b 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -708,6 +708,10 @@ typedef struct ivas_spar_enc_lib_t int16_t front_vad_dtx_flag; int16_t force_front_vad; +#ifdef SBA_AND_OBJECTS + float *input_data_mem[MAX_NUM_OBJECTS]; +#endif + } SPAR_ENC_DATA, *SPAR_ENC_HANDLE; @@ -866,6 +870,37 @@ typedef struct ivas_mcmasa_enc_data_structure } MCMASA_ENC_DATA, *MCMASA_ENC_HANDLE; +#ifdef SBA_AND_OBJECTS +/*----------------------------------------------------------------------------------* + * Object SBA (OSBA) encoder structure + *----------------------------------------------------------------------------------*/ + +typedef struct ivas_osba_enc_data_structure +{ + uint8_t nbands; + uint8_t nSubframes; + + int16_t band_grouping[MASA_FREQUENCY_BANDS + 1]; + int16_t block_grouping[5]; + + IVAS_FB_MIXER_HANDLE hFbMixer; + + float interpolator[L_FRAME48k]; + + float prev_object_dm_gains[MAX_NUM_OBJECTS][FOA_CHANNELS]; + float broadband_energy_sm[MAX_NUM_OBJECTS + FOA_CHANNELS]; + float broadband_energy_prev[MAX_NUM_OBJECTS + FOA_CHANNELS]; + int16_t prev_selected_object; + uint8_t changing_object; + float fade_out_gain[L_FRAME48k]; + float fade_in_gain[L_FRAME48k]; + + float energy_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* TODO Nokia: Make an own struct for these, and reserve it only when needed. */ + float energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS]; + int16_t nchan_ism; + +} OSBA_ENC_DATA, *OSBA_ENC_HANDLE; +#endif /*----------------------------------------------------------------------------------* * Stereo CNG handle @@ -1163,6 +1198,9 @@ typedef struct PARAM_MC_ENC_HANDLE hParamMC; /* Parametric MC handle */ MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix; /* MC Param-Upmix handle */ MCMASA_ENC_HANDLE hMcMasa; /* Multi-channel MASA data handle */ +#ifdef SBA_AND_OBJECTS + OSBA_ENC_HANDLE hOSba; /* Object-SBA data handle */ +#endif LFE_ENC_HANDLE hLFE; /* LFE data handle */ #ifdef FIX_572_LFE_LPF_ENC ivas_filters_process_state_t *hLfeLpf; /* low pass filter state for LFE */ diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 18cfb9247d..36093bf29e 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -408,7 +408,11 @@ ivas_error IVAS_ENC_FeedObjectMetadata( return IVAS_ERR_NOT_CONFIGURED; } +#ifdef SBA_AND_OBJECTS + if ( hIvasEnc->st_ivas->hEncoderConfig->ivas_format != ISM_FORMAT && hIvasEnc->st_ivas->hEncoderConfig->ivas_format != SBA_ISM_FORMAT ) +#else if ( hIvasEnc->st_ivas->hEncoderConfig->ivas_format != ISM_FORMAT ) +#endif { return IVAS_ERR_METADATA_NOT_EXPECTED; } @@ -494,6 +498,57 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( return error; } +#ifdef SBA_AND_OBJECTS +/*---------------------------------------------------------------------* + * IVAS_ENC_ConfigureForSBAObjects() + * + * Configure and initialize the combined SBA and ISM encoder. + *---------------------------------------------------------------------*/ + +ivas_error IVAS_ENC_ConfigureForSBAObjects( + IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ + const int32_t inputFs, /* i : input sampling frequency */ + const int32_t bitrate, /* i : requested bitrate of the ouput bitstream */ + const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ + const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ + const uint16_t numObjects, /* i : number of objects to be encoded */ + const IVAS_ENC_SBA_ORDER order, /* i : order of the Ambisonics input */ + const bool isPlanar, /* i : if true, input is treated as planar Ambisonics */ + const bool Opt_PCA_ON /* i : PCA option flag */ +) +{ + Encoder_Struct *st_ivas; + ivas_error error; + + if ( ( error = doCommonConfigureChecks( hIvasEnc ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( numObjects > MAX_NUM_OBJECTS ) + { + return IVAS_ERR_TOO_MANY_INPUTS; + } + st_ivas = hIvasEnc->st_ivas; + + st_ivas->hEncoderConfig->element_mode_init = IVAS_SCE; /* Just needs to be something not mono, will be set later */ + st_ivas->hEncoderConfig->sba_planar = isPlanar; + st_ivas->hEncoderConfig->sba_order = order; + + /* Input in ACN/SN3D in all cases (3D and planar): get number of channels */ + st_ivas->hEncoderConfig->nchan_inp = ivas_sba_get_nchan( st_ivas->hEncoderConfig->sba_order, isPlanar ) + numObjects; + + st_ivas->hEncoderConfig->Opt_PCA_ON = (int16_t) Opt_PCA_ON; + + /* Currently this is true but it is already shown in descriptive metadata that there can be inequality for this. */ + st_ivas->nchan_transport = st_ivas->hEncoderConfig->nchan_inp - numObjects; + st_ivas->hEncoderConfig->ivas_format = SBA_ISM_FORMAT; + st_ivas->hEncoderConfig->nchan_ism = numObjects; + + return configureEncoder( hIvasEnc, inputFs, bitrate, maxBandwidth, dtxConfig, IVAS_ENC_GetDefaultChannelAwareConfig() ); +} +#endif + /*---------------------------------------------------------------------* * IVAS_ENC_ConfigureForMasa() @@ -793,6 +848,22 @@ static ivas_error configureEncoder( } } } +/*TODOFTO: to be reconsidered */ +#ifdef SBA_AND_OBJECTS + else if ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT ) + { + st_ivas->ism_mode = ISM_MODE_NONE; + + /*adapt element_mode according to the bit-rate*/ + if ( hEncoderConfig->element_mode_init != IVAS_SCE ) + { + if ( st_ivas->hEncoderConfig->ivas_total_brate >= IVAS_48k ) + { + hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; + } + } + } +#endif } else /* EVS mono */ { @@ -1588,6 +1659,12 @@ static ivas_error printConfigInfo_enc( fprintf( stdout, "IVAS mode: Multi-Channel 7.1+4\n" ); } } +#ifdef SBA_AND_OBJECTS + else if ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT ) + { + fprintf( stdout, "IVAS format: combined ISM and SBA (%i ISM stream(s))\n", hEncoderConfig->nchan_ism ); + } +#endif if ( hEncoderConfig->is_binaural ) { diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 9d25787557..4ecec98688 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -50,6 +50,9 @@ typedef enum _IVAS_ENC_INPUT_FORMAT IVAS_ENC_INPUT_SBA, IVAS_ENC_INPUT_MASA, IVAS_ENC_INPUT_MC, +#ifdef SBA_AND_OBJECTS + IVAS_ENC_INPUT_SBA_ISM, +#endif IVAS_DEC_INPUT_UNKNOWN = 0xffff } IVAS_ENC_INPUT_FORMAT; @@ -193,6 +196,21 @@ ivas_error IVAS_ENC_ConfigureForObjects( const bool ism_extended_metadata /* i : Extended metadata used (true/false), where extended metadata includes radius and orientation */ ); +#ifdef SBA_AND_OBJECTS +/*! r: encoder error code */ +ivas_error IVAS_ENC_ConfigureForSBAObjects( + IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ + const int32_t inputFs, /* i : input sampling frequency */ + const int32_t bitrate, /* i : requested bitrate of the ouput bitstream */ + const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ + const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ + const uint16_t numObjects, /* i : number of objects to be encoded */ + const IVAS_ENC_SBA_ORDER order, /* i : order of the Ambisonics input */ + const bool isPlanar, /* i : if true, input is treated as planar Ambisonics */ + const bool Opt_PCA_ON /* i : PCA option flag */ +); +#endif + /*! r: error code */ ivas_error IVAS_ENC_ConfigureForAmbisonics( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ -- GitLab From 7f07083d768b732d556a66113660b9611f24fe1f Mon Sep 17 00:00:00 2001 From: wkr Date: Wed, 5 Jul 2023 13:17:00 +0200 Subject: [PATCH 002/109] fix object rendering to HOA at high BRs --- lib_com/ivas_prot.h | 17 +++++++++-------- lib_enc/ivas_enc.c | 2 +- lib_enc/ivas_init_enc.c | 3 +-- lib_enc/ivas_osba_enc.c | 30 ++++++++++++++++++------------ lib_enc/ivas_stat_enc.h | 2 +- 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 42f7b62e13..88ad19097f 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5555,14 +5555,15 @@ ivas_error ivas_osba_enc_config( ); void ivas_osba_enc( - OSBA_ENC_HANDLE hOSba, /* i/o: OSBA encoder handle */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handle */ - float data_in_f[][L_FRAME48k], /* i/o: Input / transport audio signals */ - const int16_t input_frame, /* i : Input frame size */ - const int16_t nchan_ism, /* i : Number of objects for parameter analysis*/ - const ISM_MODE ism_mode, /* i : ISM mode */ - float data_separated_object[L_FRAME48k], /* o : Separated object audio signal */ - int16_t *idx_separated_object /* o : Index of the separated object */ + OSBA_ENC_HANDLE hOSba, /* i/o: OSBA encoder handle */ + ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handle */ + float data_in_f[][L_FRAME48k], /* i/o: Input / transport audio signals */ + const int16_t input_frame, /* i : Input frame size */ + const int16_t nchan_ism, /* i : Number of objects for parameter analysis */ + const ISM_MODE ism_mode, /* i : ISM mode */ + const int16_t sba_analysis_order, /* i : SBA order evaluated in DirAC/SPAR encoder */ + float data_separated_object[L_FRAME48k], /* o : Separated object audio signal */ + int16_t *idx_separated_object /* o : Index of the separated object */ ); #endif diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 3abe9fed4b..02660f9ade 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -282,7 +282,7 @@ ivas_error ivas_enc( if ( st_ivas->ism_mode == ISM_MODE_NONE ) /*rendering of objects in SBA signal*/ { /* Analyze objects and determine needed audio signals */ - ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, data_separated_object, &idx_separated_object ); + ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order, data_separated_object, &idx_separated_object ); } else /*not an option for now*/ { diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 5fb81f4b0a..c0c97dc9d9 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -220,8 +220,7 @@ int16_t getNumChanAnalysis( #ifdef SBA_AND_OBJECTS else if ( st_ivas->hEncoderConfig->ivas_format == SBA_ISM_FORMAT ) { - // Todo OSBA merge: This might be wrong after addition of HO-DirAC. Decide if that is desired for combined format. - n = st_ivas->hEncoderConfig->nchan_ism + FOA_CHANNELS; + n = st_ivas->hEncoderConfig->nchan_ism + ( st_ivas->sba_analysis_order + 1 ) * ( st_ivas->sba_analysis_order + 1 ); } #endif return n; diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index f27ee39ad7..87b5dc37cc 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -52,7 +52,7 @@ static void ivas_osba_energy_and_ratio_est( OSBA_ENC_HANDLE hOSba, float data_f[][L_FRAME48k], const int16_t input_frame, const int16_t nchan_inp ); -static void ivas_osba_render_ism_to_sba( float data_in_f[][L_FRAME48k], float data_out_f[][L_FRAME48k], const int16_t input_frame, const int16_t nchan_sba, const int16_t nchan_ism, ISM_METADATA_HANDLE hIsmMeta[], float prev_gains[][FOA_CHANNELS], const float interpolator[L_FRAME48k] ); +static void ivas_osba_render_ism_to_sba( float data_in_f[][L_FRAME48k], float data_out_f[][L_FRAME48k], const int16_t input_frame, const int16_t nchan_sba, const int16_t nchan_ism, ISM_METADATA_HANDLE hIsmMeta[], float prev_gains[][MAX_INPUT_CHANNELS], const float interpolator[L_FRAME48k] ); /*-------------------------------------------------------------------* * ivas_merge_sba_transports() @@ -65,11 +65,13 @@ static void ivas_merge_sba_transports( float data_in_f2[][L_FRAME48k], float data_out_f[][L_FRAME48k], const int16_t input_frame, - const int16_t num_transport_channels ) + const int16_t sba_analysis_order ) { - int16_t i, j; + int16_t i, j, nchan_sba; - for ( i = 0; i < num_transport_channels; i++ ) + nchan_sba = (sba_analysis_order+1)*(sba_analysis_order+1); + + for ( i = 0; i < nchan_sba; i++ ) { for ( j = 0; j < input_frame; j++ ) { @@ -105,7 +107,7 @@ ivas_error ivas_osba_enc_open( for ( i = 0; i < MAX_NUM_OBJECTS; i++ ) { - set_f( hOSba->prev_object_dm_gains[i], (float) sqrt( 0.5 ), FOA_CHANNELS ); + set_f( hOSba->prev_object_dm_gains[i], (float) sqrt( 0.5 ), MAX_INPUT_CHANNELS ); } set_zero( hOSba->broadband_energy_sm, MAX_NUM_OBJECTS + FOA_CHANNELS ); set_zero( hOSba->broadband_energy_prev, MAX_NUM_OBJECTS + FOA_CHANNELS ); @@ -192,19 +194,20 @@ void ivas_osba_enc( const int16_t input_frame, /* i : Input frame size */ const int16_t nchan_ism, /* i : Number of objects for parameter analysis */ const ISM_MODE ism_mode, /* i : ISM mode */ + const int16_t sba_analysis_order, /* i : SBA order evaluated in DirAC/SPAR encoder */ float data_separated_object[L_FRAME48k], /* o : Separated object audio signal */ int16_t *idx_separated_object /* o : Index of the separated object */ ) { - float data_out_f[FOA_CHANNELS][L_FRAME48k]; + float data_out_f[MAX_INPUT_CHANNELS][L_FRAME48k]; if ( ism_mode == ISM_MODE_NONE ) { /* Convert ISM to SBA */ - ivas_osba_render_ism_to_sba( data_in_f, data_out_f, input_frame, FOA_CHANNELS, nchan_ism, hIsmMeta, hOSba->prev_object_dm_gains, hOSba->interpolator ); + ivas_osba_render_ism_to_sba( data_in_f, data_out_f, input_frame, sba_analysis_order, nchan_ism, hIsmMeta, hOSba->prev_object_dm_gains, hOSba->interpolator ); /* Merge SBA signals */ - ivas_merge_sba_transports( data_out_f, &( data_in_f[nchan_ism] ), data_in_f, input_frame, FOA_CHANNELS ); + ivas_merge_sba_transports( data_out_f, &( data_in_f[nchan_ism] ), data_in_f, input_frame, sba_analysis_order ); } /* Set the number of objects */ hOSba->nchan_ism = nchan_ism; @@ -317,18 +320,21 @@ static void ivas_osba_render_ism_to_sba( float data_in_f[][L_FRAME48k], float data_out_f[][L_FRAME48k], const int16_t input_frame, - const int16_t nchan_sba, + const int16_t sba_analysis_order, const int16_t nchan_ism, ISM_METADATA_HANDLE hIsmMeta[], - float prev_gains[][FOA_CHANNELS], + float prev_gains[][MAX_INPUT_CHANNELS], const float interpolator[L_FRAME48k] ) { int16_t i, j, k; int16_t azimuth, elevation; - float gains[FOA_CHANNELS]; + float gains[MAX_INPUT_CHANNELS]; float g1, g2; float output_gain; + int16_t nchan_sba; + + nchan_sba = (sba_analysis_order+1)*(sba_analysis_order+1); for ( i = 0; i < nchan_sba; i++ ) { @@ -340,7 +346,7 @@ static void ivas_osba_render_ism_to_sba( azimuth = (int16_t) floorf( hIsmMeta[i]->azimuth + 0.5f ); elevation = (int16_t) floorf( hIsmMeta[i]->elevation + 0.5f ); - ivas_dirac_dec_get_response( azimuth, elevation, gains, 1 ); + ivas_dirac_dec_get_response( azimuth, elevation, gains, sba_analysis_order ); /* Render using the sh gains */ for ( j = 0; j < nchan_sba; j++ ) diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index daa2ffea3b..875b6ee7bd 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -887,7 +887,7 @@ typedef struct ivas_osba_enc_data_structure float interpolator[L_FRAME48k]; - float prev_object_dm_gains[MAX_NUM_OBJECTS][FOA_CHANNELS]; + float prev_object_dm_gains[MAX_NUM_OBJECTS][MAX_INPUT_CHANNELS]; float broadband_energy_sm[MAX_NUM_OBJECTS + FOA_CHANNELS]; float broadband_energy_prev[MAX_NUM_OBJECTS + FOA_CHANNELS]; int16_t prev_selected_object; -- GitLab From adb999d22712ab18a59d40abba38c62f36a263d7 Mon Sep 17 00:00:00 2001 From: wkr Date: Fri, 7 Jul 2023 08:56:52 +0200 Subject: [PATCH 003/109] fix compiler warnings --- lib_com/ivas_prot.h | 1 - lib_enc/ivas_enc.c | 2 +- lib_enc/ivas_osba_enc.c | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 88ad19097f..acec851cdf 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5562,7 +5562,6 @@ void ivas_osba_enc( const int16_t nchan_ism, /* i : Number of objects for parameter analysis */ const ISM_MODE ism_mode, /* i : ISM mode */ const int16_t sba_analysis_order, /* i : SBA order evaluated in DirAC/SPAR encoder */ - float data_separated_object[L_FRAME48k], /* o : Separated object audio signal */ int16_t *idx_separated_object /* o : Index of the separated object */ ); #endif diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 02660f9ade..7213b3132d 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -282,7 +282,7 @@ ivas_error ivas_enc( if ( st_ivas->ism_mode == ISM_MODE_NONE ) /*rendering of objects in SBA signal*/ { /* Analyze objects and determine needed audio signals */ - ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order, data_separated_object, &idx_separated_object ); + ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order, &idx_separated_object ); } else /*not an option for now*/ { diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index 87b5dc37cc..dfc06cf969 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -195,7 +195,6 @@ void ivas_osba_enc( const int16_t nchan_ism, /* i : Number of objects for parameter analysis */ const ISM_MODE ism_mode, /* i : ISM mode */ const int16_t sba_analysis_order, /* i : SBA order evaluated in DirAC/SPAR encoder */ - float data_separated_object[L_FRAME48k], /* o : Separated object audio signal */ int16_t *idx_separated_object /* o : Index of the separated object */ ) { -- GitLab From 1592b3a7e7938cc2ed6873f7424f394a81fab828 Mon Sep 17 00:00:00 2001 From: wkr Date: Fri, 7 Jul 2023 09:31:58 +0200 Subject: [PATCH 004/109] fix one more compiler warning --- lib_com/ivas_prot.h | 3 +-- lib_enc/ivas_enc.c | 5 +---- lib_enc/ivas_osba_enc.c | 3 +-- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index acec851cdf..6da2728856 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5561,8 +5561,7 @@ void ivas_osba_enc( const int16_t input_frame, /* i : Input frame size */ const int16_t nchan_ism, /* i : Number of objects for parameter analysis */ const ISM_MODE ism_mode, /* i : ISM mode */ - const int16_t sba_analysis_order, /* i : SBA order evaluated in DirAC/SPAR encoder */ - int16_t *idx_separated_object /* o : Index of the separated object */ + const int16_t sba_analysis_order /* i : SBA order evaluated in DirAC/SPAR encoder */ ); #endif diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 7213b3132d..17c04552b6 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -273,16 +273,13 @@ ivas_error ivas_enc( #ifdef SBA_AND_OBJECTS else if ( ivas_format == SBA_ISM_FORMAT ) { - float data_separated_object[L_FRAME48k]; - int16_t idx_separated_object; - /*Default mode for OSBA*/ st_ivas->ism_mode = ISM_MODE_NONE; if ( st_ivas->ism_mode == ISM_MODE_NONE ) /*rendering of objects in SBA signal*/ { /* Analyze objects and determine needed audio signals */ - ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order, &idx_separated_object ); + ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order ); } else /*not an option for now*/ { diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index dfc06cf969..ea179a18a5 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -194,8 +194,7 @@ void ivas_osba_enc( const int16_t input_frame, /* i : Input frame size */ const int16_t nchan_ism, /* i : Number of objects for parameter analysis */ const ISM_MODE ism_mode, /* i : ISM mode */ - const int16_t sba_analysis_order, /* i : SBA order evaluated in DirAC/SPAR encoder */ - int16_t *idx_separated_object /* o : Index of the separated object */ + const int16_t sba_analysis_order /* i : SBA order evaluated in DirAC/SPAR encoder */ ) { float data_out_f[MAX_INPUT_CHANNELS][L_FRAME48k]; -- GitLab From 7dcdd71beb5e5765a72b617c7bd66b6a0bdc311b Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Fri, 7 Jul 2023 14:47:07 +0200 Subject: [PATCH 005/109] encoder changes to code discrete ISMs with SBA with MCT under OSBA_DISC_OBJ_MCT. Encoder runs through. --- lib_com/ivas_cnst.h | 4 ++ lib_com/options.h | 4 ++ lib_enc/ivas_enc.c | 79 ++++++++++++++++++++++++++++++++++++- lib_enc/ivas_init_enc.c | 40 +++++++++++++++++++ lib_enc/ivas_ism_enc.c | 8 ++++ lib_enc/ivas_mct_core_enc.c | 7 ++++ lib_enc/ivas_mct_enc.c | 32 ++++++++++++++- lib_enc/ivas_osba_enc.c | 55 ++++++++++++++++++++------ lib_enc/ivas_stat_enc.h | 4 ++ 9 files changed, 219 insertions(+), 14 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 29b685d5d2..ae75b10e68 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -401,6 +401,10 @@ typedef enum ISM_MODE_NONE, ISM_MODE_DISC, /* discrete ISM */ ISM_MODE_PARAM /* parametric ISM */ +#ifdef OSBA_DISC_OBJ_MCT +, + ISM_SBA_MODE_DISC /* discrete coding of objects with OSBA*/ +#endif } ISM_MODE; diff --git a/lib_com/options.h b/lib_com/options.h index df9551f444..9e9811c76b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -162,6 +162,10 @@ #define FIX_580_PARAMMC_ENER_BURSTS /* FhG: issue 580: energy bursts due to ILD holding when energy relations change too much */ #define SBA_AND_OBJECTS +#ifdef SBA_AND_OBJECTS +#define OSBA_DISC_OBJ_MCT +#endif + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 17c04552b6..7f54dbb357 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -274,7 +274,7 @@ ivas_error ivas_enc( else if ( ivas_format == SBA_ISM_FORMAT ) { /*Default mode for OSBA*/ - st_ivas->ism_mode = ISM_MODE_NONE; + // st_ivas->ism_mode = ISM_MODE_NONE; if ( st_ivas->ism_mode == ISM_MODE_NONE ) /*rendering of objects in SBA signal*/ { @@ -286,7 +286,7 @@ ivas_error ivas_enc( /* delay ISM input channels to match the SBA encoder delay */ for ( n = 0; n < hEncoderConfig->nchan_ism; n++ ) { - delay_signal( data_f[n], input_frame, st_ivas->hSpar->input_data_mem[n], NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ) ); + delay_signal( data_f[n], input_frame, st_ivas->hOSba->input_data_mem[n], NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ) ); } } @@ -338,6 +338,81 @@ ivas_error ivas_enc( } } } + else + { + + n = hEncoderConfig->nchan_ism; +/*deal with metadata writing a bit later*/ +#if 0 +/* Encode ISMs metadata */ + if ( ( error = ivas_ism_enc( st_ivas, data_f, input_frame, &nb_bits_metadata[1] /*, 0 */ ) ) != IVAS_ERR_OK ) /*TODOfto: not needed for now*/ + { + return error; + } + if ( st_ivas->nchan_transport == 1 ) + { + st = st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0]; + hMetaData = st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData; + + /* update pointer to the buffer of indices (ISM indices were alredy written) */ + hMetaData->ind_list = st_ivas->hSCE[st_ivas->nSCE - 2]->hMetaData->ind_list + st_ivas->hSCE[st_ivas->nSCE - 2]->hMetaData->nb_ind_tot; + st->hBstr->ind_list = st_ivas->hSCE[st_ivas->nSCE - 2]->hCoreCoder[0]->hBstr->ind_list + st_ivas->hSCE[st_ivas->nSCE - 2]->hCoreCoder[0]->hBstr->nb_ind_tot; + } + else + { + st = st_ivas->hCPE[0]->hCoreCoder[0]; + hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; + + /* update pointer to the buffer of indices (ISM indices were alredy written) */ + hMetaData->ind_list = st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData->ind_list + st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData->nb_ind_tot; + st->hBstr->ind_list = st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0]->hBstr->ind_list + st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0]->hBstr->nb_ind_tot; + } +#endif + st = st_ivas->hCPE[0]->hCoreCoder[0]; + hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; + /* Write SBA planar flag */ + push_indice( st->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); + + /* Write SBA order */ + push_indice( st->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS ); + + /* SBA metadata encoding and SBA metadata bitstream writing */ + if ( ( error = ivas_spar_enc( st_ivas, &data_f[n], input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* get SBA TCs */ + ivas_sba_getTCs( &data_f[n], st_ivas, input_frame ); + + // if ( st_ivas->hEncoderConfig->ivas_total_brate >= IVAS_256k ) + // { + // st_ivas->nchan_transport += n; + //} + + /* encode SBA transport channels */ + if ( st_ivas->nchan_transport == 1 ) + { + if ( ( error = ivas_sce_enc( st_ivas, hEncoderConfig->nchan_ism, data_f[n], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->nCPE == 1 ) /* Stereo DMX */ + { + if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[n], data_f[n + 1], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->nCPE > 1 ) /* FOA/HOA format */ + { + if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } } #endif else if ( ivas_format == MC_FORMAT ) diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index c0c97dc9d9..2615441c8c 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -569,6 +569,11 @@ ivas_error ivas_init_encoder( st_ivas->ism_mode = ISM_MODE_NONE; + if ( ivas_total_brate >= IVAS_256k ) + { + st_ivas->ism_mode = ISM_SBA_MODE_DISC; + } + if ( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK ) { return error; @@ -622,14 +627,49 @@ ivas_error ivas_init_encoder( } } } + else + { + + +#if 0 + /* allocate and initialize ISM core-coder handles */ + for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) + { + if ( ( error = create_sce_enc( st_ivas, sce_id, sep_object_brate_osba[k - 2][st_ivas->nSCE - 1] ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif + + /* allocate and initialize MCT core coder */ + + st_ivas->nCPE += st_ivas->hEncoderConfig->nchan_ism >> 1; + for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + { + if ( ( error = create_cpe_enc( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + if ( ( error = create_mct_enc( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#ifndef OSBA_DISC_OBJ_MCT if ( st_ivas->ism_mode == ISM_MODE_NONE ) { +#endif if ( ( error = ivas_osba_enc_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } +#ifndef OSBA_DISC_OBJ_MCT } +#endif } #endif else if ( ivas_format == MC_FORMAT ) diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 558455f017..e7ca234dbf 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -242,6 +242,14 @@ ivas_error ivas_ism_enc( ivas_write_format_sid( st_ivas->hEncoderConfig->ivas_format, IVAS_SCE, st->hBstr ); } +#ifdef OSBA_DISC_OBJ_MCT + /*only metadata encoding is needed for this case*/ + if ( st_ivas->hEncoderConfig->ivas_format == SBA_ISM_FORMAT ) + { + assert( st_ivas->ism_mode != ISM_MODE_NONE ); + return error; + } +#endif /*------------------------------------------------------------------* * CoreCoders encoding *-----------------------------------------------------------------*/ diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index f879a6ea55..2884c9430f 100755 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -489,6 +489,10 @@ void ivas_mct_core_enc( { nAvailBits -= IVAS_FORMAT_SIGNALING_NBITS_EXTENDED; nAvailBits -= SBA_ORDER_BITS + SBA_PLANAR_BITS; + if ( ivas_format == SBA_ISM_FORMAT && nChannels > 4 ) /*TODOfto: recheck this condition*/ + { + nAvailBits -= IVAS_COMBINED_FORMAT_SIGNALLING_BITS; + } } for ( cpe_id = 0, i = 0; cpe_id < nCPE; cpe_id++ ) @@ -562,6 +566,9 @@ void ivas_mct_core_enc( #ifdef DEBUGGING format_bits = ( ivas_format == MC_FORMAT ? IVAS_FORMAT_SIGNALING_NBITS + MC_LS_SETUP_BITS : IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + SBA_ORDER_BITS + SBA_PLANAR_BITS ); +#ifdef OSBA_DISC_OBJ_MCT + format_bits += ( ivas_format == SBA_ISM_FORMAT && nChannels > FOA_CHANNELS ); +#endif mct_bits += hMCT->nBitsMCT + hMCT->nchan_out_woLFE; assert( ( total_brate + ( NBITS_BWIDTH + format_bits + mct_bits + sba_meta + lfe_bits ) * FRAMES_PER_SEC ) == ivas_total_brate ); #endif diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index f9e5c9e28d..88bd7e2a64 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -83,7 +83,12 @@ static void set_mct_enc_params( hMCT->hbr_mct = 0; #ifdef SBA_AND_OBJECTS - if ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && ivas_total_brate >= IVAS_256k ) + if ( ( ivas_format == SBA_FORMAT +#ifndef OSBA_DISC_OBJ_MCT + || ivas_format == SBA_ISM_FORMAT +#endif + ) && + ivas_total_brate >= IVAS_256k ) #else if ( ivas_format == SBA_FORMAT && ivas_total_brate >= IVAS_256k ) #endif @@ -113,7 +118,15 @@ static void map_input_to_cpe_channels( ) { int16_t i, n; +#ifdef OSBA_DISC_OBJ_MCT + int16_t nchan_transport; + nchan_transport = st_ivas->nchan_transport; + if ( st_ivas->hEncoderConfig->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + nchan_transport += st_ivas->hEncoderConfig->nchan_ism; + } +#endif i = 0; for ( n = 0; n < LFE_CHANNEL - 1; n++ ) @@ -123,7 +136,11 @@ static void map_input_to_cpe_channels( } if ( st_ivas->hEncoderConfig->ivas_format == MC_FORMAT && ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) { +#ifndef OSBA_DISC_OBJ_MCT for ( n = LFE_CHANNEL + 1; n < st_ivas->nchan_transport; n++ ) +#else + for ( n = LFE_CHANNEL + 1; n < nchan_transport; n++ ) +#endif { pdata[i] = data[n]; i++; @@ -132,7 +149,11 @@ static void map_input_to_cpe_channels( } else { +#ifndef OSBA_DISC_OBJ_MCT for ( ; n < st_ivas->nchan_transport; n++ ) +#else + for ( ; n < nchan_transport; n++ ) +#endif { pdata[i] = data[n]; i++; @@ -140,7 +161,12 @@ static void map_input_to_cpe_channels( } /* odd channel CPE*/ +#ifndef OSBA_DISC_OBJ_MCT if ( ( st_ivas->nchan_transport < st_ivas->nCPE * CPE_CHANNELS ) || ( ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) && st_ivas->hMCT->nchan_out_woLFE < st_ivas->nCPE * CPE_CHANNELS ) ) +#else + if ( ( nchan_transport < st_ivas->nCPE * CPE_CHANNELS ) || ( ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) && st_ivas->hMCT->nchan_out_woLFE < st_ivas->nCPE * CPE_CHANNELS ) ) + +#endif { pdata[st_ivas->nCPE * CPE_CHANNELS - 1] = NULL; } @@ -315,6 +341,10 @@ ivas_error create_mct_enc( #endif { hMCT->nchan_out_woLFE = ivas_get_sba_num_TCs( ivas_total_brate, st_ivas->sba_analysis_order ); + if ( ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + hMCT->nchan_out_woLFE += st_ivas->hEncoderConfig->nchan_ism; + } } else if ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC ) { diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index ea179a18a5..719e0dddf7 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -69,7 +69,7 @@ static void ivas_merge_sba_transports( { int16_t i, j, nchan_sba; - nchan_sba = (sba_analysis_order+1)*(sba_analysis_order+1); + nchan_sba = ( sba_analysis_order + 1 ) * ( sba_analysis_order + 1 ); for ( i = 0; i < nchan_sba; i++ ) { @@ -96,7 +96,9 @@ ivas_error ivas_osba_enc_open( OSBA_ENC_HANDLE hOSba; int16_t input_frame; ivas_error error; - +#ifdef OSBA_DISC_OBJ_MCT + int16_t len; +#endif error = IVAS_ERR_OK; @@ -105,10 +107,32 @@ ivas_error ivas_osba_enc_open( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OMASA encoder\n" ) ); } + for ( i = 0; i < MAX_NUM_OBJECTS; i++ ) { set_f( hOSba->prev_object_dm_gains[i], (float) sqrt( 0.5 ), MAX_INPUT_CHANNELS ); } +#ifdef OSBA_DISC_OBJ_MCT + + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + len = NS2SA( st_ivas->hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ); + + for ( i = 0; i < st_ivas->hEncoderConfig->nchan_ism; i++ ) + { + if ( ( hOSba->input_data_mem[i] = (float *) malloc( len * sizeof( float ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OSBA input buffers" ); + } + set_f( hOSba->input_data_mem[i], 0.0f, len ); + } + + for ( ; i < MAX_NUM_OBJECTS; i++ ) + { + hOSba->input_data_mem[i] = NULL; + } + } +#endif set_zero( hOSba->broadband_energy_sm, MAX_NUM_OBJECTS + FOA_CHANNELS ); set_zero( hOSba->broadband_energy_prev, MAX_NUM_OBJECTS + FOA_CHANNELS ); hOSba->prev_selected_object = 0; @@ -142,7 +166,16 @@ void ivas_osba_enc_close( { return; } - +#ifdef OSBA_DISC_OBJ_MCT + for ( int16_t n = 0; n < MAX_NUM_OBJECTS; n++ ) + { + if ( ( *hOSba )->input_data_mem[n] != NULL ) + { + free( ( *hOSba )->input_data_mem[n] ); + ( *hOSba )->input_data_mem[n] = NULL; + } + } +#endif free( *hOSba ); ( *hOSba ) = NULL; @@ -188,13 +221,13 @@ ivas_error ivas_osba_enc_config( *--------------------------------------------------------------------------*/ void ivas_osba_enc( - OSBA_ENC_HANDLE hOSba, /* i/o: OSBA encoder handle */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handle */ - float data_in_f[][L_FRAME48k], /* i/o: Input / transport audio signals */ - const int16_t input_frame, /* i : Input frame size */ - const int16_t nchan_ism, /* i : Number of objects for parameter analysis */ - const ISM_MODE ism_mode, /* i : ISM mode */ - const int16_t sba_analysis_order /* i : SBA order evaluated in DirAC/SPAR encoder */ + OSBA_ENC_HANDLE hOSba, /* i/o: OSBA encoder handle */ + ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handle */ + float data_in_f[][L_FRAME48k], /* i/o: Input / transport audio signals */ + const int16_t input_frame, /* i : Input frame size */ + const int16_t nchan_ism, /* i : Number of objects for parameter analysis */ + const ISM_MODE ism_mode, /* i : ISM mode */ + const int16_t sba_analysis_order /* i : SBA order evaluated in DirAC/SPAR encoder */ ) { float data_out_f[MAX_INPUT_CHANNELS][L_FRAME48k]; @@ -332,7 +365,7 @@ static void ivas_osba_render_ism_to_sba( int16_t nchan_sba; - nchan_sba = (sba_analysis_order+1)*(sba_analysis_order+1); + nchan_sba = ( sba_analysis_order + 1 ) * ( sba_analysis_order + 1 ); for ( i = 0; i < nchan_sba; i++ ) { diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 875b6ee7bd..d336c648b4 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -899,6 +899,10 @@ typedef struct ivas_osba_enc_data_structure float energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS]; int16_t nchan_ism; +#ifdef OSBA_DISC_OBJ_MCT + float *input_data_mem[MAX_NUM_OBJECTS]; +#endif + } OSBA_ENC_DATA, *OSBA_ENC_HANDLE; #endif -- GitLab From 8075eabd8f38ef9c3386d1fdeadfcb63c53b1bdd Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 13 Jul 2023 08:21:56 +0200 Subject: [PATCH 006/109] enable decoder functionality . Core cofing functionality working as expected --- lib_com/bitstream.c | 11 ++ lib_com/ivas_cnst.h | 3 + lib_com/ivas_prot.h | 37 ++++++ lib_com/options.h | 1 + lib_dec/ivas_dec.c | 220 ++++++++++++++++++++++++++++++++++- lib_dec/ivas_dirac_dec.c | 39 ++++++- lib_dec/ivas_init_dec.c | 212 ++++++++++++++++++++++++++++++++- lib_dec/ivas_jbm_dec.c | 12 +- lib_dec/ivas_mct_dec.c | 12 +- lib_dec/ivas_output_config.c | 12 ++ lib_dec/ivas_spar_decoder.c | 21 +++- lib_dec/ivas_stat_dec.h | 37 ++++++ lib_enc/ivas_enc.c | 49 +++++++- lib_enc/ivas_init_enc.c | 3 +- lib_enc/ivas_ism_enc.c | 14 ++- lib_enc/ivas_mct_enc.c | 2 + lib_enc/ivas_spar_encoder.c | 8 ++ 17 files changed, 670 insertions(+), 23 deletions(-) diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index f55253b9b8..d6d082440c 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -2759,6 +2759,17 @@ ivas_error preview_indices( ivas_sba_config( total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &( st_ivas->nSCE ), &( st_ivas->nCPE ), &( st_ivas->element_mode_init ) ); } +#ifdef OSBA_DISC_OBJ_MCT + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + /* read number of objects from the bitstream */ + if ( total_brate != SID_2k40 && total_brate != FRAME_NO_DATA ) + { + st_ivas->nchan_ism = 2 * bit_stream[total_brate / FRAMES_PER_SEC - 1] + bit_stream[total_brate / FRAMES_PER_SEC - 2] + 1; + st_ivas->ism_mode = ISM_SBA_MODE_DISC; + } + } +#endif } st_ivas->hDecoderConfig->ivas_total_brate = total_brate; diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index ae75b10e68..44e353b0d5 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1258,6 +1258,9 @@ typedef enum MASA_FRAME_4SF } MASA_FRAME_MODE; +#ifdef OSBA_DISC_OBJ_MCT +#define NO_BITS_MASA_ISM_NO_OBJ 2 +#endif /*----------------------------------------------------------------------------------* * Multichannel format *----------------------------------------------------------------------------------*/ diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 6da2728856..7e0d863d39 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -962,6 +962,10 @@ ivas_error ivas_ism_metadata_enc( const int16_t ism_mode, /* i : ISM mode */ const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */ const int16_t ism_extended_metadata_flag /* i : Extended metadata flag */ +#ifdef OSBA_DISC_OBJ_MCT + , + const int16_t ini_frame +#endif ); ivas_error ivas_ism_metadata_dec( @@ -977,6 +981,9 @@ ivas_error ivas_ism_metadata_dec( const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */ int16_t *ism_extended_metadata_flag, /* i/o: Extended metadata active in renderer */ int16_t *ism_extmeta_cnt /* i/o: Number of change frames observed */ +#ifdef OSBA_DISC_OBJ_MCT + , DEC_CORE_HANDLE st0 +#endif ); @@ -3594,6 +3601,9 @@ void ivas_dirac_dec_read_BS( DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q metadata */ int16_t *nb_bits, /* o : number of bits read */ +#ifdef OSBA_DISC_OBJ_MCT + const int16_t last_bit_pos, /* i : last read bitstream position*/ +#endif const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ ); @@ -5563,6 +5573,33 @@ void ivas_osba_enc( const ISM_MODE ism_mode, /* i : ISM mode */ const int16_t sba_analysis_order /* i : SBA order evaluated in DirAC/SPAR encoder */ ); +#ifdef OSBA_DISC_OBJ_MCT +ivas_error ivas_masa_ism_data_open( + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ +); +ivas_error ivas_masa_ism_separate_object_renderer_open( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +ivas_error ivas_omasa_dirac_td_binaural( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float output[][L_FRAME48k], /* o : output synthesis signal */ + const int16_t output_frame /* i : output frame length per channel */ +); + +ivas_error ivas_osba_ism_metadata_dec( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int32_t ism_total_brate, /* i : ISM total bitrate */ + int16_t *nchan_ism, /* o : number of ISM separated channels */ + int16_t *nchan_transport_ism, /* o : number of ISM TCs */ + const int16_t dirac_bs_md_write_idx, /* i : DirAC bitstream write index */ + int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ +); + +void ivas_masa_ism_data_close( + MASA_ISM_DATA_HANDLE *hMasaIsmData /* i/o: MASA_ISM rendering handle */ +); +#endif #endif /*----------------------------------------------------------------------------------* diff --git a/lib_com/options.h b/lib_com/options.h index 9e9811c76b..90db660fd5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -164,6 +164,7 @@ #define SBA_AND_OBJECTS #ifdef SBA_AND_OBJECTS #define OSBA_DISC_OBJ_MCT +//#define ENABLE_ISM_MD_CODING #endif /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 439a90fb2c..4899a7a3ac 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -165,14 +165,24 @@ ivas_error ivas_dec( } else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hDirAC->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hDirAC->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt +#ifdef OSBA_DISC_OBJ_MCT + , + st_ivas->hSCE[0]->hCoreCoder[0] +#endif + ) ) != IVAS_ERR_OK ) { return error; } } else /* ISM_MODE_DISC */ { - if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt +#ifdef OSBA_DISC_OBJ_MCT + , + st_ivas->hSCE[0]->hCoreCoder[0] +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -440,6 +450,212 @@ ivas_error ivas_dec( ivas_sba_upmixer_renderer( st_ivas, output, output_frame ); /* Note: ivas_sba_linear_renderer() or ivas_dirac_dec() are called internally */ } } +#ifdef OSBA_DISC_OBJ_MCT + // Todo OSBA merge: This was added as a whole block so probably something is wrong. + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + int16_t nchan_ism, nchan_transport_ism; + int16_t dirac_bs_md_write_idx; + + set_s( nb_bits_metadata, 0, MAX_SCE ); + nchan_transport_ism = 1; + + dirac_bs_md_write_idx = 0; + if ( st_ivas->hDirAC != NULL ) + { + dirac_bs_md_write_idx = st_ivas->hDirAC->dirac_bs_md_write_idx; /* Store the write-index for this frame */ + } + + + /* SBA metadata decoding */ + if ( ( error = ivas_spar_dec( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK ) + { + return error; + } +#ifdef ENABLE_ISM_MD_CODING + /* set ISM parameters and decode ISM metadata in OSBA format */ + if ( ( error = ivas_osba_ism_metadata_dec( st_ivas, ivas_total_brate, &nchan_ism, &nchan_transport_ism, dirac_bs_md_write_idx, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif +#if 0 + /* Configuration of combined-format bit-budget distribution */ + ivas_set_surplus_brate_dec( st_ivas, &ism_total_brate ); + + if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) + { + /* set ISM parameters and decode ISM metadata in OSBA format */ + if ( ( error = ivas_omasa_ism_metadata_dec( st_ivas, ism_total_brate, &nchan_ism, &nchan_transport_ism, dirac_bs_md_write_idx, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* the separated object */ + st = st_ivas->hSCE[0]->hCoreCoder[0]; + st->bit_stream = &( st_ivas->bit_stream[0] ); + if ( ( error = ivas_sce_dec( st_ivas, 0, &output[st_ivas->nchan_transport], output_frame, nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* prepare for SBA content decoding */ + if ( st_ivas->nchan_transport == 1 ) + { + st = st_ivas->hSCE[1]->hCoreCoder[0]; + } + else + { + st = st_ivas->hCPE[0]->hCoreCoder[0]; + } +#if 1 + st->bit_stream = &( st_ivas->bit_stream[( ism_total_brate / FRAMES_PER_SEC )] ); +#else + st->bit_stream = st_ivas->hSCE[0]->hCoreCoder[0]->bit_stream; //& ( st_ivas->bit_stream[( st_ivas->hSCE[0]->hCoreCoder[0]->total_brate / FRAMES_PER_SEC )] ); +#endif + } + else if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + { + // TBD !!!!! + } + + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { +#endif +#if 1 /*TODOfto: no MD for now*/ + +#endif +#if 0 + /* decode ISM channels */ + for ( n = 0; n < nchan_transport_ism; n++ ) + { + if ( ( error = ivas_sce_dec( st_ivas, n, &output[st_ivas->nchan_transport + n], output_frame, nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + if ( st_ivas->nchan_transport == 1 ) + { + st = st_ivas->hSCE[nchan_transport_ism]->hCoreCoder[0]; + } + else + { + st = st_ivas->hCPE[0]->hCoreCoder[0]; + } +#else + st = st_ivas->hCPE[0]->hCoreCoder[0]; +#endif + // st->bit_stream = &( st_ivas->bit_stream[( ism_total_brate / FRAMES_PER_SEC )] ); + // st->next_bit_pos = SBA_PLANAR_BITS + SBA_ORDER_BITS; + +#if 0 + /* decode SBA transport channels */ + if ( st_ivas->nchan_transport == 1 ) + { + if ( ( error = ivas_sce_dec( st_ivas, nchan_transport_ism, &output[0], output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->nCPE == 1 ) + { + if ( ( error = ivas_cpe_dec( st_ivas, 0, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->nCPE > 1 ) + { + + if ( ( error = ivas_mct_dec( st_ivas, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#else + if ( ( error = ivas_mct_dec( st_ivas, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + + /* HP filtering */ + for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) + { + hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + } + +#if 1 + + { + int16_t nchan = st_ivas->nchan_transport + st_ivas->nchan_ism; + for ( int t = 0; t < output_frame; t++ ) + { + for ( int c = 0; c < nchan; c++ ) + { + int16_t val = (int16_t) ( output[c][t] + 0.5f ); + dbgwrite( &val, sizeof( int16_t ), 1, 1, "int_dec_core_out.raw" ); + } + } + } +#endif + + nchan_remapped = ivas_sba_remapTCs( output, st_ivas, output_frame ); + + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + ivas_sba_mix_matrix_determiner( st_ivas->hSpar, output, st_ivas->bfi, nchan_remapped, output_frame ); + } +#if 0 + /* Set the number of objects for the parametric rendering */ + if ( st_ivas->hDirAC != NULL ) + { + st_ivas->hDirAC->numIsmDirections = 0; + if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC && st_ivas->ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ ) + { + st_ivas->hDirAC->numIsmDirections = st_ivas->nchan_ism; + } + } +#endif +#if 0 + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + /* loudness correction */ + ivas_dirac_dec_binaural_gain( output, nchan_remapped, output_frame ); + } + + /* 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 ) + { + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) + { + if ( ( error = ivas_omasa_dirac_td_binaural( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, output, st_ivas->nchan_transport ); + } + } + else +#endif + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + { + if ( ( error = ivas_omasa_dirac_td_binaural( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + /* Todo OSBA: Implement other outputs. */ + } + } +#endif else if ( st_ivas->ivas_format == MC_FORMAT ) { st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index f3ea6912f3..c5a553d9b3 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -312,7 +312,11 @@ ivas_error ivas_dirac_dec_config( num_protos_diff_old = 0; nchan_transport_orig = st_ivas->nchan_transport; +#ifndef OSBA_DISC_OBJ_MCT if ( st_ivas->ivas_format == SBA_FORMAT && !( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) +#else + if ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) +#endif { st_ivas->nchan_transport = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); } @@ -322,8 +326,11 @@ ivas_error ivas_dirac_dec_config( { nchan_transport = 1; } - +#ifdef OSBA_DISC_OBJ_MCT + if ( flag_config == DIRAC_RECONFIGURE && ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) ) +#else if ( flag_config == DIRAC_RECONFIGURE && st_ivas->ivas_format == SBA_FORMAT ) +#endif { int16_t tmp1, tmp2, tmp3; ivas_sba_config( ivas_total_brate, st_ivas->sba_analysis_order, -1, &nchan_transport_old, st_ivas->sba_planar, &tmp1, &tmp2, &tmp3 ); @@ -1023,7 +1030,11 @@ ivas_error ivas_dirac_dec_config( return error; } +#ifdef OSBA_DISC_OBJ_MCT + if ( st_ivas->ivas_format == MASA_FORMAT || ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && st_ivas->hDecoderConfig->ivas_total_brate > IVAS_256k ) ) +#else if ( st_ivas->ivas_format == MASA_FORMAT || ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->hDecoderConfig->ivas_total_brate > IVAS_256k ) ) +#endif { if ( ( error = ivas_dirac_allocate_parameters( hDirAC, 2 ) ) != IVAS_ERR_OK ) { @@ -1639,18 +1650,28 @@ void ivas_dirac_dec_read_BS( DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata */ int16_t *nb_bits, /* o : number of bits read */ - const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ - int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ +#ifdef OSBA_DISC_OBJ_MCT + const int16_t last_bit_pos, /* i : last read bitstream position*/ +#endif + const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ + int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ ) { int16_t i, j, b, dir, orig_dirac_bands; int16_t next_bit_pos_orig; +#ifndef OSBA_DISC_OBJ_MCT *nb_bits = 0; +#endif if ( !st->bfi && ivas_total_brate > IVAS_SID_5k2 ) { next_bit_pos_orig = st->next_bit_pos; st->next_bit_pos = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC - 1 ); - +#ifdef OSBA_DISC_OBJ_MCT + if ( last_bit_pos > 0 ) + { + st->next_bit_pos = last_bit_pos; + } +#endif /* 1 bit flag for signaling metadata to read */ b = st->bit_stream[( st->next_bit_pos )--]; ( *nb_bits )++; @@ -2377,8 +2398,11 @@ void ivas_dirac_dec_render_sf( onset_filter_subframe = DirAC_mem.onset_filter + hDirAC->num_freq_bands; hodirac_flag = ivas_get_hodirac_flag( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ); - +#ifdef OSBA_DISC_OBJ_MCT + if ( st_ivas->hQMetaData != NULL && st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) +#else if ( st_ivas->hQMetaData != NULL && st_ivas->ivas_format != SBA_FORMAT ) +#endif { coherence_flag = st_ivas->hQMetaData->coherence_flag; } @@ -2546,8 +2570,11 @@ void ivas_dirac_dec_render_sf( { md_idx = hDirAC->render_to_md_map[subframe_idx]; } - +#ifdef OSBA_DISC_OBJ_MCT + if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) +#else if ( st_ivas->ivas_format == SBA_FORMAT ) +#endif { for ( ch = 0; ch < nchan_transport; ch++ ) { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 2294203053..5e2ed44186 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -177,6 +177,52 @@ ivas_error ivas_dec_setup( } } } +#ifdef OSBA_DISC_OBJ_MCT + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + int32_t sba_total_brate; + + /* the number of objects is written at the end of the bitstream, in the SBA metadata */ + st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1; +#if 0 /*TODOfto: why is this?*/ + if ( st_ivas->sba_analysis_order == 0 ) + { + st_ivas->sba_analysis_order = SBA_FOA_ORDER; + } +#else + /* read Ambisonic (SBA) planar flag */ + st_ivas->sba_planar = st_ivas->bit_stream[num_bits_read]; + num_bits_read += SBA_PLANAR_BITS; + + /* read Ambisonic (SBA) order */ + st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; + st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; + + /* set Ambisonic (SBA) order used for analysis and coding */ + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); + + num_bits_read += SBA_ORDER_BITS; + if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate && ivas_total_brate > IVAS_SID_5k2 ) + { + if ( ( error = ivas_sba_dec_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + ivas_sba_config( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init ); + } +#endif + /*correct number of CPEs for discrete ISM coding*/ + if ( st_ivas->ini_frame > 0 && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + st_ivas->nCPE += st_ivas->nchan_ism >> 1; + } + + st_ivas->ism_mode = ISM_SBA_MODE_DISC; + } +#endif else if ( st_ivas->ivas_format == MC_FORMAT ) { /* read MC configuration */ @@ -399,19 +445,26 @@ static ivas_error ivas_read_format( break; case 2: st_ivas->ivas_format = ISM_FORMAT; - if ( ivas_total_brate >= IVAS_24k4 ) { if ( st_ivas->bit_stream[*num_bits_read] ) { +#ifdef OSBA_DISC_OBJ_MCT + ( *num_bits_read )++; + if ( st_ivas->bit_stream[*num_bits_read] ) + { + + st_ivas->ivas_format = SBA_ISM_FORMAT; + } +#else /* placeholder for combined format signaling */ ( *num_bits_read )++; +#endif } ( *num_bits_read )++; } - break; case 3: if ( st_ivas->bit_stream[*num_bits_read] ) @@ -527,7 +580,12 @@ int16_t getNumChanSynthesis( { n = st_ivas->nchan_transport; } - +#ifdef SBA_AND_OBJECTS + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + n = st_ivas->nchan_transport + st_ivas->nchan_ism; + } +#endif return n; } @@ -1006,6 +1064,94 @@ ivas_error ivas_init_decoder( /* set CNA/CNG flags */ ivas_sba_set_cna_cng_flag( st_ivas ); } +#ifdef OSBA_DISC_OBJ_MCT + // Todo OSBA merge: This part should be verified as it was a large added block. Some fixes done already. + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + st_ivas->ism_extmeta_active = -1; + st_ivas->ism_extmeta_cnt = 0; + + if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* this is resetting the nSCE to 1 */ + if ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Todo Nokia: Renderer should be selected in ivas_renderer_select(), but currently the number of transport channels is not available at that point. + * Hence, a temporary fix was done here, which adjusts the renderer after the number of transports is known. Optimally, this should be fixed by + * reading the number of transports before the renderer is selected. */ + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->nchan_transport >= 3 ) + { + st_ivas->renderer_type = RENDERER_BINAURAL_FASTCONV; + st_ivas->intern_config = AUDIO_CONFIG_HOA3; + st_ivas->hIntSetup.output_config = AUDIO_CONFIG_HOA3; /* Todo: Check if this affects tdrend in some way. */ + } + + if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( error = ivas_dirac_dec_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + + st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; + + st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); + + + int32_t temp_brate[MAX_SCE]; +#ifndef OSBA_DISC_OBJ_MCT + st_ivas->nSCE = st_ivas->nchan_ism; /* number of objects */ +#else + st_ivas->nCPE += st_ivas->nchan_ism >> 1; +#endif + + + st_ivas->element_mode_init = IVAS_CPE_MDCT; + + for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + { + if ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) + { + return error; + } + + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] ); + } + } + + + if ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + + + if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* set CNA/CNG flags */ + ivas_sba_set_cna_cng_flag( st_ivas ); +#if 1 /*TODOfto: is this neede for OSBA?*/ + if ( ( error = ivas_masa_ism_data_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + } +#endif else if ( st_ivas->ivas_format == MC_FORMAT ) { if ( st_ivas->mc_mode == MC_MODE_MCT ) @@ -1356,6 +1502,38 @@ ivas_error ivas_init_decoder( return error; } } +#ifdef OSBA_DISC_OBJ_MCT +#if 1 /*TODOfto leave for later*/ + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + /* Allocate TD renderer for the objects in DISC mode */ + if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ + if ( ( error = ivas_masa_ism_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#if 0 + } + + if ( st_ivas->renderer_type == RENDERER_DIRAC && ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + { + /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ + if ( ( error = ivas_masa_ism_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + } + } +#endif +#endif /*-----------------------------------------------------------------* * LFE handles for rendering after rendering to adjust LFE delay to binaural filter delay @@ -1417,7 +1595,11 @@ ivas_error ivas_init_decoder( } /* CLDFB Interpolation weights */ +#ifdef OSBA_DISC_OBJ_MCT + if ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !st_ivas->sba_dirac_stereo_flag && st_ivas->hDecoderConfig->nchan_out != 1 ) +#else if ( st_ivas->ivas_format == SBA_FORMAT && !st_ivas->sba_dirac_stereo_flag && st_ivas->hDecoderConfig->nchan_out != 1 ) +#endif { ivas_spar_get_cldfb_gains( st_ivas->hSpar, st_ivas->cldfbAnaDec[0], st_ivas->cldfbSynDec[0], hDecoderConfig ); } @@ -1683,6 +1865,9 @@ void ivas_initialize_handles_dec( st_ivas->hHrtfFastConv = NULL; st_ivas->hHrtfParambin = NULL; st_ivas->hoa_dec_mtx = NULL; +#ifdef OSBA_DISC_OBJ_MCT + st_ivas->hMasaIsmData = NULL; +#endif st_ivas->hHeadTrackData = NULL; st_ivas->hHrtfTD = NULL; @@ -1850,6 +2035,10 @@ void ivas_destroy_dec( free( st_ivas->hMonoDmxRenderer ); st_ivas->hMonoDmxRenderer = NULL; } +#ifdef OSBA_DISC_OBJ_MCT + /* MASA ISM structure */ + ivas_masa_ism_data_close( &st_ivas->hMasaIsmData ); +#endif /* Head track data handle */ ivas_headTrack_close( &st_ivas->hHeadTrackData ); @@ -1940,7 +2129,20 @@ void ivas_init_dec_get_num_cldfb_instances( { *numCldfbAnalyses = st_ivas->nchan_transport + 1; } +#ifdef OSBA_DISC_OBJ_MCT + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + *numCldfbAnalyses += st_ivas->nchan_ism; + } + } +#endif + if ( st_ivas->hDiracDecBin->useTdDecorr ) + { + *numCldfbAnalyses += 2; + } if ( st_ivas->hDiracDecBin->useTdDecorr ) { *numCldfbAnalyses += 2; @@ -2014,7 +2216,11 @@ void ivas_init_dec_get_num_cldfb_instances( case RENDERER_BINAURAL_MIXER_CONV_ROOM: case RENDERER_BINAURAL_FASTCONV: case RENDERER_BINAURAL_FASTCONV_ROOM: +#ifdef OSBA_DISC_OBJ_MCT + if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) +#else if ( st_ivas->ivas_format == SBA_FORMAT ) +#endif { if ( st_ivas->sba_dirac_stereo_flag ) { diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index ff28af051a..08f1c6d52a 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -154,14 +154,22 @@ ivas_error ivas_jbm_dec_tc( } else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hDirAC->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hDirAC->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt +#ifdef OSBA_DISC_OBJ_MCT + , st_ivas->hSCE[0]->hCoreCoder[0] +#endif + ) ) != IVAS_ERR_OK ) { return error; } } else /* ISM_MODE_DISC */ { - if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt +#ifdef OSBA_DISC_OBJ_MCT + , st_ivas->hSCE[0]->hCoreCoder[0] +#endif + ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 7742656899..5371e28d6b 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -331,9 +331,19 @@ ivas_error create_mct_dec( *-----------------------------------------------------------------*/ /* Determine active channels */ - if ( ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC ) || st_ivas->ivas_format == SBA_FORMAT ) + if ( ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC ) || st_ivas->ivas_format == SBA_FORMAT +#ifdef OSBA_DISC_OBJ_MCT + || st_ivas->ivas_format == SBA_ISM_FORMAT +#endif + ) { hMCT->nchan_out_woLFE = st_ivas->nchan_transport; +#ifdef OSBA_DISC_OBJ_MCT + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + hMCT->nchan_out_woLFE += st_ivas->nchan_ism; + } +#endif } else if ( st_ivas->mc_mode == MC_MODE_MCT ) { diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 16787b63cd..4cbb8c602d 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -124,7 +124,11 @@ void ivas_renderer_select( } } } +#ifdef OSBA_DISC_OBJ_MCT + else if ( st_ivas->ivas_format == MASA_FORMAT || ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && st_ivas->nchan_transport <= 2 ) ) +#else else if ( st_ivas->ivas_format == MASA_FORMAT || ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->nchan_transport <= 2 ) ) +#endif { *internal_config = output_config; if ( output_config == AUDIO_CONFIG_BINAURAL ) @@ -136,7 +140,11 @@ void ivas_renderer_select( *renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM; } } +#ifdef OSBA_DISC_OBJ_MCT + else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) +#else else if ( st_ivas->ivas_format == SBA_FORMAT ) +#endif { *internal_config = AUDIO_CONFIG_HOA3; if ( output_config == AUDIO_CONFIG_BINAURAL ) @@ -311,7 +319,11 @@ void ivas_renderer_select( } } } +#ifdef OSBA_DISC_OBJ_MCT + else if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) +#else else if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == SBA_FORMAT ) +#endif { *renderer_type = RENDERER_DIRAC; if ( st_ivas->ivas_format == SBA_FORMAT && diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 906a73b317..1e36404f22 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -317,11 +317,28 @@ ivas_error ivas_spar_dec( bit_stream_orig = st0->bit_stream; next_bit_pos_orig = st0->next_bit_pos; +#ifdef OSBA_DISC_OBJ_MCT + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ); + /* the number of objects was read */ + last_bit_pos -= NO_BITS_MASA_ISM_NO_OBJ; + *nb_bits_read += NO_BITS_MASA_ISM_NO_OBJ; + } + else + { + *nb_bits_read = 0; + } +#endif + /* read DirAC bitstream */ if ( st_ivas->hQMetaData != NULL ) { - ivas_dirac_dec_read_BS( hDecoderConfig->ivas_total_brate, st0, st_ivas->hDirAC, st_ivas->hQMetaData, nb_bits_read, - ivas_get_hodirac_flag( hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ), st_ivas->hSpar->dirac_to_spar_md_bands ); +#ifdef OSBA_DISC_OBJ_MCT + ivas_dirac_dec_read_BS( hDecoderConfig->ivas_total_brate, st0, st_ivas->hDirAC, st_ivas->hQMetaData, nb_bits_read, last_bit_pos, ivas_get_hodirac_flag( hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ), st_ivas->hSpar->dirac_to_spar_md_bands ); +#else + ivas_dirac_dec_read_BS( hDecoderConfig->ivas_total_brate, st0, st_ivas->hDirAC, st_ivas->hQMetaData, nb_bits_read, ivas_get_hodirac_flag( hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ), st_ivas->hSpar->dirac_to_spar_md_bands ); +#endif } last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ); diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 315cfbad66..94ba5fec1e 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -722,6 +722,40 @@ typedef struct ivas_dirac_dec_data_structure } DIRAC_DEC_DATA, *DIRAC_DEC_HANDLE; +#ifdef OSBA_DISC_OBJ_MCT +/* Data structure for MASA_ISM rendering */ +typedef struct ivas_masa_ism_data_structure +{ +#if 0 + int16_t azimuth_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + int16_t elevation_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + float energy_ratio_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR][CLDFB_NO_CHANNELS_MAX]; + + int16_t azimuth_ism_edited[MAX_NUM_OBJECTS]; + int16_t elevation_ism_edited[MAX_NUM_OBJECTS]; + uint8_t ism_is_edited[MAX_NUM_OBJECTS]; + + int16_t idx_separated_ism; + int16_t azimuth_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + int16_t elevation_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + + float q_azimuth_old[MAX_NUM_OBJECTS]; + float q_elevation_old[MAX_NUM_OBJECTS]; + + float ismPreprocMatrix[2][2][CLDFB_NO_CHANNELS_MAX]; + uint8_t objectsMoved; + float eneMoveIIR[2][CLDFB_NO_CHANNELS_MAX]; + float enePreserveIIR[2][CLDFB_NO_CHANNELS_MAX]; + float preprocEneTarget[CLDFB_NO_CHANNELS_MAX]; + float preprocEneRealized[CLDFB_NO_CHANNELS_MAX]; +#endif + + float **delayBuffer; + int16_t delayBuffer_size; + int16_t delayBuffer_nchan; + +} MASA_ISM_DATA, *MASA_ISM_DATA_HANDLE; +#endif /*----------------------------------------------------------------------------------* * ParamMC structures @@ -1330,6 +1364,9 @@ typedef struct Decoder_Struct int32_t binaural_latency_ns; /* Binauralization latency in ns */ EXTERNAL_ORIENTATION_HANDLE hExtOrientationData; /* External orientation data structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData; /* Combined external and head orientation data structure */ +#ifdef OSBA_DISC_OBJ_MCT + MASA_ISM_DATA_HANDLE hMasaIsmData; +#endif /* JBM module */ DECODER_TC_BUFFER_HANDLE hTcBuffer; /* JBM structure */ diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 7f54dbb357..31fefe9054 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -283,11 +283,14 @@ ivas_error ivas_enc( } else /*not an option for now*/ { +#ifdef OSBA_DISC_OBJ_MCT /* delay ISM input channels to match the SBA encoder delay */ for ( n = 0; n < hEncoderConfig->nchan_ism; n++ ) { delay_signal( data_f[n], input_frame, st_ivas->hOSba->input_data_mem[n], NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ) ); } + +#endif } if ( st_ivas->ism_mode == ISM_MODE_NONE ) @@ -342,13 +345,29 @@ ivas_error ivas_enc( { n = hEncoderConfig->nchan_ism; -/*deal with metadata writing a bit later*/ + st = st_ivas->hCPE[0]->hCoreCoder[0]; + hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; +#ifdef ENABLE_ISM_MD_CODING + if ( ( error = ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->nchan_transport, st_ivas->hIsmMetaData, NULL, hMetaData, nb_bits_metadata, 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag +#ifdef OSBA_DISC_OBJ_MCT + , + st->ini_frame +#endif + + ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif #if 0 -/* Encode ISMs metadata */ + /* Encode ISMs metadata */ if ( ( error = ivas_ism_enc( st_ivas, data_f, input_frame, &nb_bits_metadata[1] /*, 0 */ ) ) != IVAS_ERR_OK ) /*TODOfto: not needed for now*/ { return error; } +#endif +#if 0 + if ( st_ivas->nchan_transport == 1 ) { st = st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0]; @@ -368,8 +387,15 @@ ivas_error ivas_enc( st->hBstr->ind_list = st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0]->hBstr->ind_list + st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0]->hBstr->nb_ind_tot; } #endif - st = st_ivas->hCPE[0]->hCoreCoder[0]; - hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; + +#if 0 // TODOfto: why is this needed for ISM_NONE? + /* write number of objects - unary coding */ + for ( n = 1; n < hEncoderConfig->nchan_ism; n++ ) + { + push_indice( hMetaData, IND_ISM_NUM_OBJECTS, 1, 1 ); + } + push_indice( hMetaData, IND_ISM_NUM_OBJECTS, 0, 1 ); +#endif /* Write SBA planar flag */ push_indice( st->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); @@ -407,6 +433,21 @@ ivas_error ivas_enc( } else if ( st_ivas->nCPE > 1 ) /* FOA/HOA format */ { +#if 1 + + { + int16_t nchan = st_ivas->nchan_transport + st_ivas->hEncoderConfig->nchan_ism; + for ( int t = 0; t < input_frame; t++ ) + { + for ( int c = 0; c < nchan; c++ ) + { + int16_t val = (int16_t) ( data_f[c][t] + 0.5f ); + dbgwrite( &val, sizeof( int16_t ), 1, 1, "int_enc_core_in.raw" ); + } + } + } +#endif + if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 2615441c8c..5e90847cab 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -568,11 +568,12 @@ ivas_error ivas_init_encoder( int32_t element_brate_tmp[MAX_NUM_OBJECTS]; st_ivas->ism_mode = ISM_MODE_NONE; - +#ifdef OSBA_DISC_OBJ_MCT if ( ivas_total_brate >= IVAS_256k ) { st_ivas->ism_mode = ISM_SBA_MODE_DISC; } +#endif if ( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK ) { diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index e7ca234dbf..55a996bcf1 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -222,11 +222,21 @@ ivas_error ivas_ism_enc( } else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, st_ivas->nchan_transport, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm, st_ivas->hEncoderConfig->ism_extended_metadata_flag ); + ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, st_ivas->nchan_transport, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm, st_ivas->hEncoderConfig->ism_extended_metadata_flag +#ifdef OSBA_DISC_OBJ_MCT + , + st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame +#endif + ); } else /* ISM_MODE_DISC */ { - ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, st_ivas->nchan_transport, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata, vad_flag, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag ); + ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, st_ivas->nchan_transport, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata, vad_flag, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag +#ifdef OSBA_DISC_OBJ_MCT + , + st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame +#endif + ); } update_last_metadata( nchan_ism, st_ivas->hIsmMetaData, md_diff_flag ); diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 88bd7e2a64..af40bad663 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -341,10 +341,12 @@ ivas_error create_mct_enc( #endif { hMCT->nchan_out_woLFE = ivas_get_sba_num_TCs( ivas_total_brate, st_ivas->sba_analysis_order ); +#ifdef OSBA_DISC_OBJ_MCT if ( ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { hMCT->nchan_out_woLFE += st_ivas->hEncoderConfig->nchan_ism; } +#endif } else if ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC ) { diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 5f382c4719..984df6b8bb 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -339,6 +339,14 @@ ivas_error ivas_spar_enc( error = IVAS_ERR_OK; hEncoderConfig = st_ivas->hEncoderConfig; +#ifdef OSBA_DISC_OBJ_MCT + if ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode != ISM_MODE_NONE ) + { + /* write the number of objects in ISM_SBA format*/ + push_next_indice( hMetaData, hEncoderConfig->nchan_ism - 1, NO_BITS_MASA_ISM_NO_OBJ ); + } +#endif + /* check last sba_mode */ /* front VAD */ -- GitLab From da5392cff748495040fd191937bb7b394e785fd2 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Fri, 14 Jul 2023 15:20:22 +0200 Subject: [PATCH 007/109] add ISM metadata encoding and decoding functionality --- lib_com/options.h | 2 +- lib_dec/ivas_dec.c | 22 ++++---- lib_dec/ivas_ism_metadata_dec.c | 85 +++++++++++++++++++++++++----- lib_dec/ivas_spar_decoder.c | 17 +++++- lib_enc/ivas_enc.c | 11 +++- lib_enc/ivas_ism_metadata_enc.c | 93 ++++++++++++++++++++++++++++----- lib_enc/ivas_spar_encoder.c | 2 + lib_rend/ivas_objectRenderer.c | 20 ++++++- 8 files changed, 211 insertions(+), 41 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 90db660fd5..9a375cda70 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -164,7 +164,7 @@ #define SBA_AND_OBJECTS #ifdef SBA_AND_OBJECTS #define OSBA_DISC_OBJ_MCT -//#define ENABLE_ISM_MD_CODING +#define ENABLE_ISM_MD_CODING #endif /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 4899a7a3ac..5d178d2ef9 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -61,7 +61,11 @@ ivas_error ivas_dec( float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; /* 'float' buffer for output synthesis, MAX_OUTPUT_CHANNELS channels */ int16_t nchan_remapped; float output_lfe_ch[L_FRAME48k]; +#ifndef OSBA_DISC_OBJ_MCT int16_t nb_bits_metadata[MAX_SCE]; +#else + int16_t nb_bits_metadata[MAX_SCE+1]; +#endif int32_t output_Fs, ivas_total_brate; AUDIO_CONFIG output_config; float pan_left, pan_right; @@ -457,7 +461,7 @@ ivas_error ivas_dec( int16_t nchan_ism, nchan_transport_ism; int16_t dirac_bs_md_write_idx; - set_s( nb_bits_metadata, 0, MAX_SCE ); + set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); nchan_transport_ism = 1; dirac_bs_md_write_idx = 0; @@ -465,13 +469,6 @@ ivas_error ivas_dec( { dirac_bs_md_write_idx = st_ivas->hDirAC->dirac_bs_md_write_idx; /* Store the write-index for this frame */ } - - - /* SBA metadata decoding */ - if ( ( error = ivas_spar_dec( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK ) - { - return error; - } #ifdef ENABLE_ISM_MD_CODING /* set ISM parameters and decode ISM metadata in OSBA format */ if ( ( error = ivas_osba_ism_metadata_dec( st_ivas, ivas_total_brate, &nchan_ism, &nchan_transport_ism, dirac_bs_md_write_idx, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) @@ -479,6 +476,13 @@ ivas_error ivas_dec( return error; } #endif + + /* SBA metadata decoding */ + if ( ( error = ivas_spar_dec( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK ) + { + return error; + } + #if 0 /* Configuration of combined-format bit-budget distribution */ ivas_set_surplus_brate_dec( st_ivas, &ism_total_brate ); @@ -574,7 +578,7 @@ ivas_error ivas_dec( } } #else - if ( ( error = ivas_mct_dec( st_ivas, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_mct_dec( st_ivas, output, output_frame, nb_bits_metadata[0]+nb_bits_metadata[1] )) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index 86c43f0ffd..36ccc0588c 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -150,12 +150,18 @@ ivas_error ivas_ism_metadata_dec( const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */ int16_t *ism_extmeta_active, /* i/o: Extended metadata active in renderer */ int16_t *ism_extmeta_cnt /* i/o: Number of change frames observed */ +#ifdef OSBA_DISC_OBJ_MCT + , + DEC_CORE_HANDLE st0 +#endif ) { int16_t ch, nb_bits_start = 0, last_bit_pos; int16_t idx_radius; int32_t element_brate[MAX_NUM_OBJECTS], total_brate[MAX_NUM_OBJECTS]; +#ifndef OSBA_DISC_OBJ_MCT DEC_CORE_HANDLE st0; +#endif int16_t ism_extmeta_bitstream; int16_t non_diegetic_flag_global; float yaw, pitch, radius; @@ -178,7 +184,9 @@ ivas_error ivas_ism_metadata_dec( push_wmops( "ism_meta_dec" ); /* initialization */ +#ifndef OSBA_DISC_OBJ_MCT st0 = hSCE[0]->hCoreCoder[0]; +#endif ism_metadata_flag_global = 0; nchan_transport_prev = *nchan_transport; @@ -204,21 +212,32 @@ ivas_error ivas_ism_metadata_dec( /*----------------------------------------------------------------* * Read ISM common signaling *----------------------------------------------------------------*/ - - /* number of objects was read in ivas_dec_setup() */ - st0->next_bit_pos += nchan_ism; - - ism_mode = ivas_ism_mode_select( nchan_ism, ism_total_brate ); - - if ( ism_mode == ISM_MODE_PARAM ) +#ifdef OSBA_DISC_OBJ_MCT + if ( ism_mode == ISM_SBA_MODE_DISC ) { - *nchan_transport = MAX_PARAM_ISM_WAVE; + /* number of objects was read in ivas_dec_setup() */ + st0->next_bit_pos += NO_BITS_MASA_ISM_NO_OBJ; } - else if ( ism_mode == ISM_MODE_DISC ) + else { - *nchan_transport = nchan_ism; - } +#endif + /* number of objects was read in ivas_dec_setup() */ + st0->next_bit_pos += nchan_ism; + ism_mode = ivas_ism_mode_select( nchan_ism, ism_total_brate ); + + + if ( ism_mode == ISM_MODE_PARAM ) + { + *nchan_transport = MAX_PARAM_ISM_WAVE; + } + else if ( ism_mode == ISM_MODE_DISC ) + { + *nchan_transport = nchan_ism; + } +#ifdef OSBA_DISC_OBJ_MCT + } +#endif if ( *nchan_transport != nchan_transport_prev ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong number of objects signalled!" ); @@ -255,8 +274,16 @@ ivas_error ivas_ism_metadata_dec( /* Read ISM metadata flags (one per object) */ for ( ch = 0; ch < *nchan_transport; ch++ ) { - ism_imp[ch] = get_next_indice( st0, ISM_METADATA_FLAG_BITS ); - +#ifdef OSBA_DISC_OBJ_MCT + if ( ism_mode != ISM_SBA_MODE_DISC ) + { + ism_imp[ch] = get_next_indice( st0, ISM_METADATA_FLAG_BITS ); + } + else + { + ism_imp[ch] = get_next_indice( st0, 1 ); + } +#endif if ( ism_imp[ch] > ISM_NO_META ) { hIsmMeta[ch]->ism_metadata_flag = 1; @@ -276,7 +303,11 @@ ivas_error ivas_ism_metadata_dec( } /* read ISM_NO_META class signalling */ +#ifdef OSBA_DISC_OBJ_MCT + if ( ism_mode == ISM_MODE_DISC && ism_mode != ISM_SBA_MODE_DISC ) +#else if ( ism_mode == ISM_MODE_DISC ) +#endif { for ( ch = 0; ch < *nchan_transport; ch++ ) { @@ -324,7 +355,11 @@ ivas_error ivas_ism_metadata_dec( for ( ch = 0; ch < nchan_ism; ch++ ) { hIsmMetaData = hIsmMeta[ch]; +#ifdef OSBA_DISC_OBJ_MCT + if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC ) +#else if ( ism_mode == ISM_MODE_DISC ) +#endif { nb_bits_start = st0->next_bit_pos; } @@ -410,7 +445,11 @@ ivas_error ivas_ism_metadata_dec( } } /* save number of metadata bits read */ +#ifdef OSBA_DISC_OBJ_MCT + if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC ) +#else if ( ism_mode == ISM_MODE_DISC ) +#endif { nb_bits_metadata[ch] = st0->next_bit_pos - nb_bits_start; } @@ -494,6 +533,23 @@ ivas_error ivas_ism_metadata_dec( hISMDTX.ism_dtx_hangover_cnt += 1; } +#ifdef OSBA_DISC_OBJ_MCT + if ( ism_mode == ISM_SBA_MODE_DISC ) + { + /* set the bitstream pointer to its original position */ + nb_bits_metadata[0]=st0->next_bit_pos; + st0->bit_stream = bstr_orig; + st0->next_bit_pos = next_bit_pos_orig; + + /* updates*/ + set_s( md_diff_flag, 1, nchan_ism ); + + update_last_metadata( nchan_ism, hIsmMeta, md_diff_flag ); + pop_wmops(); + return IVAS_ERR_OK; + } +#endif + /*----------------------------------------------------------------* * Configuration and decision about bitrates per channel *----------------------------------------------------------------*/ @@ -561,7 +617,8 @@ ivas_error ivas_ism_metadata_dec( set_s( md_diff_flag, 1, nchan_ism ); - update_last_metadata( nchan_ism, hIsmMeta, md_diff_flag ); + + for ( ch = 0; ch < *nchan_transport; ch++ ) { diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 1e36404f22..1eadd77b46 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -320,10 +320,14 @@ ivas_error ivas_spar_dec( #ifdef OSBA_DISC_OBJ_MCT if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { +#ifndef ENABLE_ISM_MD_CODING last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ); /* the number of objects was read */ last_bit_pos -= NO_BITS_MASA_ISM_NO_OBJ; *nb_bits_read += NO_BITS_MASA_ISM_NO_OBJ; +#else + last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - nb_bits_read[1]; +#endif } else { @@ -341,7 +345,18 @@ ivas_error ivas_spar_dec( #endif } - last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ); +#ifdef OSBA_DISC_OBJ_MCT + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - nb_bits_read[1]; + } + else + { +#endif + last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ); +#ifdef OSBA_DISC_OBJ_MCT + } +#endif if ( !st0->bfi && hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 ) { last_bit_pos -= SID_FORMAT_NBITS; diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 31fefe9054..90e0c5de4b 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -347,8 +347,17 @@ ivas_error ivas_enc( n = hEncoderConfig->nchan_ism; st = st_ivas->hCPE[0]->hCoreCoder[0]; hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; +#ifdef OSBA_DISC_OBJ_MCT +#ifdef ENABLE_ISM_MD_CODING + if ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode != ISM_MODE_NONE ) + { + /* write the number of objects in ISM_SBA format*/ + push_next_indice( hMetaData, hEncoderConfig->nchan_ism - 1, NO_BITS_MASA_ISM_NO_OBJ ); + } +#endif +#endif #ifdef ENABLE_ISM_MD_CODING - if ( ( error = ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->nchan_transport, st_ivas->hIsmMetaData, NULL, hMetaData, nb_bits_metadata, 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag + if ( ( error = ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->nchan_transport, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag #ifdef OSBA_DISC_OBJ_MCT , st->ini_frame diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index cbf3d945de..5105d8e8dd 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -179,6 +179,10 @@ ivas_error ivas_ism_metadata_enc( const int16_t ism_mode, /* i : ISM mode */ const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Enc Handle */ const int16_t ism_extended_metadata_flag /* i : Extended metadata flag */ +#ifdef OSBA_DISC_OBJ_MCT + , + const int16_t ini_frame +#endif ) { int16_t i, ch, nb_bits_start = 0; @@ -226,14 +230,21 @@ ivas_error ivas_ism_metadata_enc( { hIsmMeta[ch]->ism_metadata_flag = 1; } +#ifdef OSBA_DISC_OBJ_MCT + else if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC ) +#else else if ( ism_mode == ISM_MODE_DISC ) +#endif { null_metadata_flag[ch] = !hIsmMeta[ch]->ism_metadata_flag; if ( hIsmMeta[ch]->ism_metadata_flag == 1 ) { - /* In case of low level noise for low bitrate inactive frames, do not sent metadata */ - hIsmMeta[ch]->ism_metadata_flag = vad_flag[ch] || hSCE[ch]->hCoreCoder[0]->lp_noise > 10 || hSCE[ch]->hCoreCoder[0]->tcxonly; + if ( ism_mode != ISM_SBA_MODE_DISC ) /*TODOfto this may cost a few bits but it is supposed to be for the higher bitrates anyway*/ + { + /* In case of low level noise for low bitrate inactive frames, do not sent metadata */ + hIsmMeta[ch]->ism_metadata_flag = vad_flag[ch] || hSCE[ch]->hCoreCoder[0]->lp_noise > 10 || hSCE[ch]->hCoreCoder[0]->tcxonly; + } /* in inactive frames, send MD 1) in ISM_MD_INC_DIFF_CNT_MAX consecutive frames when MD significantly change, 2) at least every ISM_MD_FEC_DIFF frames */ if ( hIsmMeta[ch]->ism_metadata_flag == 0 ) @@ -270,19 +281,31 @@ ivas_error ivas_ism_metadata_enc( /*----------------------------------------------------------------* * Rate importance of particular ISM streams *----------------------------------------------------------------*/ - - rate_ism_importance( nchan_transport, hIsmMeta, hSCE, lowrate_metadata_flag, ism_imp ); +#ifdef OSBA_DISC_OBJ_MCT + if ( ism_mode != ISM_SBA_MODE_DISC ) + { +#endif + rate_ism_importance( nchan_transport, hIsmMeta, hSCE, lowrate_metadata_flag, ism_imp ); +#ifdef OSBA_DISC_OBJ_MCT + } +#endif /*----------------------------------------------------------------* * Write ISM common signaling *----------------------------------------------------------------*/ - - /* write number of objects - unary coding */ - for ( ch = 1; ch < nchan_ism; ch++ ) +#ifdef OSBA_DISC_OBJ_MCT + if ( ism_mode != ISM_SBA_MODE_DISC ) { - push_indice( hBstr, IND_ISM_NUM_OBJECTS, 1, 1 ); +#endif + /* write number of objects - unary coding */ + for ( ch = 1; ch < nchan_ism; ch++ ) + { + push_indice( hBstr, IND_ISM_NUM_OBJECTS, 1, 1 ); + } + push_indice( hBstr, IND_ISM_NUM_OBJECTS, 0, 1 ); +#ifdef OSBA_DISC_OBJ_MCT } - push_indice( hBstr, IND_ISM_NUM_OBJECTS, 0, 1 ); +#endif for ( ch = 0; ch < nchan_ism; ch++ ) { @@ -303,6 +326,7 @@ ivas_error ivas_ism_metadata_enc( } } + /* write ISM metadata flag (one per object) */ for ( ch = 0; ch < nchan_transport; ch++ ) { @@ -313,9 +337,19 @@ ivas_error ivas_ism_metadata_enc( /* write the ISM class to ISM_NO_META and again the true ISM class */ push_indice( hBstr, IND_ISM_METADATA_FLAG, ISM_NO_META, ISM_METADATA_FLAG_BITS ); - push_indice( hBstr, IND_ISM_MD_INACTIVE_FLAG, ism_imp[ch], ISM_METADATA_FLAG_BITS ); +#ifdef OSBA_DISC_OBJ_MCT + if ( ism_mode != ISM_SBA_MODE_DISC ) + { +#endif + push_indice( hBstr, IND_ISM_MD_INACTIVE_FLAG, ism_imp[ch], ISM_METADATA_FLAG_BITS ); +#ifdef OSBA_DISC_OBJ_MCT + } +#endif } else +#ifdef OSBA_DISC_OBJ_MCT + if ( ism_mode != ISM_SBA_MODE_DISC ) +#endif { push_indice( hBstr, IND_ISM_METADATA_FLAG, ism_imp[ch], ISM_METADATA_FLAG_BITS ); @@ -328,6 +362,11 @@ ivas_error ivas_ism_metadata_enc( push_indice( hBstr, IND_ISM_MD_INACTIVE_FLAG, lowrate_metadata_flag[ch], ISM_METADATA_INACTIVE_FLAG_BITS ); } } + else /*ism_mode == ISM_SBA_MODE_DISC*/ + { + /* all objects are considered active*/ + push_indice( hBstr, IND_ISM_METADATA_FLAG, 1, 1 ); + } } @@ -349,7 +388,11 @@ ivas_error ivas_ism_metadata_enc( for ( ch = 0; ch < nchan_ism; ch++ ) { hIsmMetaData = hIsmMeta[ch]; +#ifdef OSBA_DISC_OBJ_MCT + if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC ) +#else if ( ism_mode == ISM_MODE_DISC ) +#endif { nb_bits_start = hBstr->nb_bits_tot; } @@ -384,7 +427,11 @@ ivas_error ivas_ism_metadata_enc( } else { +#ifdef OSBA_DISC_OBJ_MCT + if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC ) +#else if ( ism_mode == ISM_MODE_DISC ) +#endif { idx_angle1_abs = ism_quant_meta( hIsmMetaData->azimuth, &valQ, ism_azimuth_borders, ISM_Q_STEP, ISM_Q_STEP_BORDER, 1 << ISM_AZIMUTH_NBITS ); idx_angle2_abs = ism_quant_meta( hIsmMetaData->elevation, &valQ, ism_elevation_borders, ISM_Q_STEP, ISM_Q_STEP_BORDER, 1 << ISM_ELEVATION_NBITS ); @@ -394,26 +441,40 @@ ivas_error ivas_ism_metadata_enc( idx_angle1_abs = hParamIsm->azi_index[ch]; idx_angle2_abs = hParamIsm->ele_index[ch]; } - +#ifdef OSBA_DISC_OBJ_MCT + encode_angle_indices( hBstr, &( hIsmMetaData->position_angle ), hIsmMetaData->last_ism_metadata_flag, ini_frame, idx_angle1_abs, idx_angle2_abs, &flag_abs_azimuth[ch], &flag_abs_elevation[ch] ); +#else encode_angle_indices( hBstr, &( hIsmMetaData->position_angle ), hIsmMetaData->last_ism_metadata_flag, hSCE[0]->hCoreCoder[0]->ini_frame, idx_angle1_abs, idx_angle2_abs, &flag_abs_azimuth[ch], &flag_abs_elevation[ch] ); +#endif /*----------------------------------------------------------------* * Quantize and encode radius, yaw, and pitch *----------------------------------------------------------------*/ - +#ifdef OSBA_DISC_OBJ_MCT + if ( ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC ) && ism_extended_metadata_flag ) +#else if ( ism_mode == ISM_MODE_DISC && ism_extended_metadata_flag ) +#endif { idx_angle1_abs = ism_quant_meta( hIsmMetaData->yaw, &valQ, ism_azimuth_borders, ISM_Q_STEP, ISM_Q_STEP_BORDER, 1 << ISM_AZIMUTH_NBITS ); idx_angle2_abs = ism_quant_meta( hIsmMetaData->pitch, &valQ, ism_elevation_borders, ISM_Q_STEP, ISM_Q_STEP_BORDER, 1 << ISM_ELEVATION_NBITS ); idx_radius_abs = usquant( hIsmMetaData->radius, &valQ, ISM_RADIUS_MIN, ISM_RADIUS_DELTA, 1 << ISM_RADIUS_NBITS ); +#ifdef OSBA_DISC_OBJ_MCT + encode_angle_indices( hBstr, &( hIsmMetaData->orientation_angle ), hIsmMetaData->last_ism_metadata_flag, ini_frame, idx_angle1_abs, idx_angle2_abs, &flag_abs_yaw[ch], &flag_abs_pitch[ch] ); +#else encode_angle_indices( hBstr, &( hIsmMetaData->orientation_angle ), hIsmMetaData->last_ism_metadata_flag, hSCE[0]->hCoreCoder[0]->ini_frame, idx_angle1_abs, idx_angle2_abs, &flag_abs_yaw[ch], &flag_abs_pitch[ch] ); +#endif encode_radius( hBstr, &hIsmMetaData->last_radius_idx, &hIsmMetaData->radius_diff_cnt, hIsmMetaData->last_ism_metadata_flag, idx_radius_abs, &flag_abs_radius[ch] ); } } /* save number of metadata bits written */ +#ifdef OSBA_DISC_OBJ_MCT + if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC ) +#else if ( ism_mode == ISM_MODE_DISC ) +#endif { nb_bits_metadata[ch] = hBstr->nb_bits_tot - nb_bits_start; } @@ -496,6 +557,12 @@ ivas_error ivas_ism_metadata_enc( } } +#ifdef OSBA_DISC_OBJ_MCT + if ( ism_mode == ISM_SBA_MODE_DISC ) + { + return error; + } +#endif if ( ism_mode == ISM_MODE_PARAM ) { /* Keep the metdata transmission as is during active parts */ @@ -551,7 +618,7 @@ ivas_error ivas_ism_metadata_enc( *----------------------------------------------------------------*/ if ( ( error = ivas_ism_config( ism_total_brate, nchan_transport, nchan_ism, hIsmMeta, ism_extended_metadata_flag, null_metadata_flag, ism_imp, element_brate, total_brate, nb_bits_metadata ) ) != IVAS_ERR_OK ) - { + { return error; } diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 984df6b8bb..957a725e8a 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -340,11 +340,13 @@ ivas_error ivas_spar_enc( hEncoderConfig = st_ivas->hEncoderConfig; #ifdef OSBA_DISC_OBJ_MCT +#ifndef ENABLE_ISM_MD_CODING if ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode != ISM_MODE_NONE ) { /* write the number of objects in ISM_SBA format*/ push_next_indice( hMetaData, hEncoderConfig->nchan_ism - 1, NO_BITS_MASA_ISM_NO_OBJ ); } +#endif #endif /* check last sba_mode */ diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 2ba225b2f1..79de9b31a2 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -190,7 +190,11 @@ ivas_error ivas_td_binaural_open_unwrap( TDREND_MIX_SRC_SetDirAtten( pBinRendTd, nS, DirAtten_p ); } } +#ifdef OSBA_DISC_OBJ_MCT + if ( ivas_format == ISM_FORMAT || ivas_format == SBA_ISM_FORMAT ) +#else if ( ivas_format == ISM_FORMAT ) +#endif { DirAtten_p = pBinRendTd->DirAtten_p; if ( NULL == directivity ) @@ -213,7 +217,14 @@ ivas_error ivas_td_binaural_open_unwrap( } *hBinRendererTd = pBinRendTd; - *binaural_latency_ns = (int32_t) ( ( *hBinRendererTd )->HrFiltSet_p->latency_s * 1000000000.f ); +#ifdef OSBA_DISC_OBJ_MCT + if ( ivas_format != SBA_ISM_FORMAT ) + { +#endif + *binaural_latency_ns = (int32_t) ( ( *hBinRendererTd )->HrFiltSet_p->latency_s * 1000000000.f ); +#ifdef OSBA_DISC_OBJ_MCT + } +#endif return error; } @@ -455,7 +466,12 @@ void TDREND_Update_object_positions( /* For each source, write the frame data to the source object*/ for ( nS = 0; nS < num_src; nS++ ) { - if ( in_format == ISM_FORMAT ) + if ( in_format == ISM_FORMAT +#ifdef OSBA_DISC_OBJ_MCT + || in_format == SBA_ISM_FORMAT +#endif + + ) { /* Update the source positions */ /* Source position and direction */ -- GitLab From 60a0d1f4161c173259435e6c0880860737180679 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Fri, 14 Jul 2023 17:07:22 +0200 Subject: [PATCH 008/109] fix buffer and add missing file --- lib_dec/ivas_osba_dec.c | 365 ++++++++++++++++++++++++++++++++++++++++ lib_enc/ivas_enc.c | 8 + 2 files changed, 373 insertions(+) create mode 100644 lib_dec/ivas_osba_dec.c diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c new file mode 100644 index 0000000000..a9b5d8afd0 --- /dev/null +++ b/lib_dec/ivas_osba_dec.c @@ -0,0 +1,365 @@ +/****************************************************************************************************** + + (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include "options.h" +#include +#include "ivas_cnst.h" +#include "ivas_prot.h" +#include "prot.h" +#include "ivas_prot_rend.h" +#include "ivas_rom_com.h" +#ifdef DEBUGGING +#include "debug.h" +#endif + + +#ifdef OSBA_DISC_OBJ_MCT + +/*-------------------------------------------------------------------* + * ivas_masa_ism_data_open() + * + * Allocate and initialize MASA_ISM rendering handle + *-------------------------------------------------------------------*/ + +ivas_error ivas_masa_ism_data_open( + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ +) +{ + MASA_ISM_DATA_HANDLE hMasaIsmData; + int16_t ch, bin; + int16_t sf, obj_idx; + + if ( ( hMasaIsmData = (MASA_ISM_DATA_HANDLE) malloc( sizeof( MASA_ISM_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA ISM data\n" ) ); + } +#if 0 + for ( bin = 0; bin < CLDFB_NO_CHANNELS_MAX; bin++ ) + { + for ( ch = 0; ch < 2; ch++ ) + { + hMasaIsmData->ismPreprocMatrix[ch][ch][bin] = 1.0f; + hMasaIsmData->ismPreprocMatrix[1 - ch][ch][bin] = 0.0f; + hMasaIsmData->eneMoveIIR[ch][bin] = 0.0f; + hMasaIsmData->enePreserveIIR[ch][bin] = 0.0f; + } + hMasaIsmData->preprocEneTarget[bin] = 0.0f; + hMasaIsmData->preprocEneRealized[bin] = 0.0f; + } + + hMasaIsmData->objectsMoved = 0; + hMasaIsmData->delayBuffer = NULL; + + for ( ch = 0; ch < st_ivas->nchan_ism; ch++ ) + { + hMasaIsmData->q_elevation_old[ch] = 0.0f; + hMasaIsmData->q_azimuth_old[ch] = 0.0f; + } + + for ( obj_idx = 0; obj_idx < MAX_NUM_OBJECTS; obj_idx++ ) + { + set_s( hMasaIsmData->azimuth_ism[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); + set_s( hMasaIsmData->elevation_ism[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); + for ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR; sf++ ) + { + set_zero( hMasaIsmData->energy_ratio_ism[obj_idx][sf], CLDFB_NO_CHANNELS_MAX ); + } + } + set_s( hMasaIsmData->azimuth_separated_ism, 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); + set_s( hMasaIsmData->elevation_separated_ism, 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); +#endif + st_ivas->hMasaIsmData = hMasaIsmData; + + return IVAS_ERR_OK; +} +/*-------------------------------------------------------------------* + * ivas_masa_ism_data_close() + * + * Deallocate MASA_ISM rendering handle + *-------------------------------------------------------------------*/ + +void ivas_masa_ism_data_close( + MASA_ISM_DATA_HANDLE *hMasaIsmData /* i/o: MASA_ISM rendering handle */ +) +{ + int16_t i; + + if ( hMasaIsmData == NULL || *hMasaIsmData == NULL ) + { + return; + } + + if ( ( *hMasaIsmData )->delayBuffer != NULL ) + { + for ( i = 0; i < ( *hMasaIsmData )->delayBuffer_nchan; i++ ) + { + free( ( *hMasaIsmData )->delayBuffer[i] ); + } + free( ( *hMasaIsmData )->delayBuffer ); + ( *hMasaIsmData )->delayBuffer = NULL; + } + + free( *hMasaIsmData ); + *hMasaIsmData = NULL; + + return; +} + +/*-------------------------------------------------------------------------* + * ivas_masa_ism_separate_object_renderer_open() + * + * Open structures, reserve memory, and init values. + *-------------------------------------------------------------------------*/ + +ivas_error ivas_masa_ism_separate_object_renderer_open( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + int16_t interpolator_length; + int16_t i; + int16_t init_interpolator_length; + + + st_ivas->hMasaIsmData->delayBuffer_nchan = st_ivas->nchan_ism; + st_ivas->hMasaIsmData->delayBuffer_size = (int16_t) ( ( st_ivas->hDecoderConfig->output_Fs / 50 ) / MAX_PARAM_SPATIAL_SUBFRAMES ); + + if ( ( st_ivas->hMasaIsmData->delayBuffer = (float **) malloc( st_ivas->hMasaIsmData->delayBuffer_nchan * sizeof( float * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA ISM delay buffer \n" ) ); + } + + for ( i = 0; i < st_ivas->hMasaIsmData->delayBuffer_nchan; i++ ) + { + if ( ( st_ivas->hMasaIsmData->delayBuffer[i] = (float *) malloc( st_ivas->hMasaIsmData->delayBuffer_size * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA ISM delay buffer \n" ) ); + } + set_zero( st_ivas->hMasaIsmData->delayBuffer[i], st_ivas->hMasaIsmData->delayBuffer_size ); + } + + + return IVAS_ERR_OK; +} + + +/*--------------------------------------------------------------------------* + * ivas_omasa_dirac_td_binaural() + * + * Binaural rendering in OMASA format + *--------------------------------------------------------------------------*/ + +ivas_error ivas_omasa_dirac_td_binaural( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float output[][L_FRAME48k], /* o : output synthesis signal */ + const int16_t output_frame /* i : output frame length per channel */ +) +{ + int16_t n; + float data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k]; + float gain = 0.7943f; /* Todo Nokia: Temporary gain for roughly matching the loudness of other processing paths. */ + ivas_error error; + float *p_sepobj[MAX_NUM_OBJECTS]; +#ifdef SBA_AND_OBJECTS + int16_t channel_offset; +#endif + + for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) + { + p_sepobj[n] = &data_separated_objects[n][0]; + } +#ifdef SBA_AND_OBJECTS + channel_offset = st_ivas->nchan_transport; + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->nchan_transport == 3 ) /* channels are remapped in ivas_sba_remapTCs() */ + { + channel_offset = 4; + } + channel_offset = 0; +#endif + + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { +#ifdef SBA_AND_OBJECTS + mvr2r( output[channel_offset + n], data_separated_objects[n], output_frame ); +#else + mvr2r( output[2 + n], data_separated_objects[n], output_frame ); +#endif + // v_multc( data_separated_objects[n], gain, data_separated_objects[n], output_frame ); + } +#if 1 + + { + int16_t nchan = st_ivas->hOutSetup.nchan_out_woLFE; + for ( int t = 0; t < output_frame; t++ ) + { + for ( int c = 0; c < 4; c++ ) + { + int16_t val = (int16_t) ( data_separated_objects[c][t] + 0.5f ); + dbgwrite( &val, sizeof( int16_t ), 1, 1, "sep_obj.raw" ); + } + } + } +#endif + + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + delay_signal( data_separated_objects[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); + } + + +#if 1 + + { + int16_t nchan = st_ivas->hOutSetup.nchan_out_woLFE; + for ( int t = 0; t < output_frame; t++ ) + { + for ( int c = 0; c < 4; c++ ) + { + int16_t val = (int16_t) ( data_separated_objects[c][t] + 0.5f ); + dbgwrite( &val, sizeof( int16_t ), 1, 1, "sep_obj_delay.raw" ); + } + } + } +#endif + +#ifdef SBA_AND_OBJECTS + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + { + ivas_sba_upmixer_renderer( st_ivas, &output[MAX_NUM_OBJECTS], output_frame ); + } + else + { + ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, &output[MAX_NUM_OBJECTS], st_ivas->nchan_transport ); + } +#else + ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, output, st_ivas->nchan_transport ); +#endif + + +#if 1 + + { + int16_t nchan = st_ivas->hOutSetup.nchan_out_woLFE; + for ( int t = 0; t < output_frame; t++ ) + { + for ( int c = 4; c < 4 + nchan; c++ ) + { + int16_t val = (int16_t) ( output[c][t] + 0.5f ); + dbgwrite( &val, sizeof( int16_t ), 1, 1, "int_dec_bin_hoa.raw" ); + } + } + } +#endif + + if ( ( error = ivas_td_binaural_renderer( st_ivas, p_sepobj, output_frame ) ) != IVAS_ERR_OK ) + { + return error; + } +#if 1 + + { + int16_t nchan = st_ivas->hOutSetup.nchan_out_woLFE; + for ( int t = 0; t < output_frame; t++ ) + { + for ( int c = 0; c < nchan; c++ ) + { + int16_t val = (int16_t) ( p_sepobj[c][t] + 0.5f ); + dbgwrite( &val, sizeof( int16_t ), 1, 1, "int_dec_bin_obj.raw" ); + } + } + } +#endif + + for ( n = 0; n < BINAURAL_CHANNELS; n++ ) + { +#if 0 + v_add( output[MAX_NUM_OBJECTS + n], p_sepobj[n], output[n], output_frame ); +#else + int16_t i; + for(i=0; inchan_ism; + *nchan_transport_ism = st_ivas->nchan_ism; + + + /* decode ISM metadata */ + if ( ( error = ivas_ism_metadata_dec( ism_total_brate, *nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, NULL, st_ivas->bfi, + nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hCPE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) + { + return error; + } +#if 0 + if ( st_ivas->hDirAC != NULL ) + { + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + azimuth_ism = (int16_t) ( st_ivas->hIsmMetaData[n]->azimuth + 0.5f ); + elevation_ism = (int16_t) ( st_ivas->hIsmMetaData[n]->elevation + 0.5f ); + + for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) + { + meta_write_index = ( dirac_bs_md_write_idx + block ) % st_ivas->hDirAC->dirac_md_buffer_length; + st_ivas->hMasaIsmData->azimuth_ism[n][meta_write_index] = azimuth_ism; + st_ivas->hMasaIsmData->elevation_ism[n][meta_write_index] = elevation_ism; + } + } + } + } +#endif + + + return IVAS_ERR_OK; +} +#endif diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 90e0c5de4b..aa68bf5ee6 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -61,7 +61,11 @@ ivas_error ivas_enc( ENCODER_CONFIG_HANDLE hEncoderConfig; BSTR_ENC_HANDLE hMetaData; Encoder_State *st; /* used for bitstream handling */ +#ifdef OSBA_DISC_OBJ_MCT + int16_t nb_bits_metadata[MAX_SCE + 1]; +#else int16_t nb_bits_metadata[MAX_SCE]; +#endif #ifdef SBA_AND_OBJECTS float data_f[MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; #else @@ -87,7 +91,11 @@ ivas_error ivas_enc( input_frame = (int16_t) ( input_Fs / FRAMES_PER_SEC ); n_samples_chan = n_samples / nchan_inp; +#ifdef OSBA_DISC_OBJ_MCT + set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); +#else set_s( nb_bits_metadata, 0, MAX_SCE ); +#endif /*----------------------------------------------------------------* * convert 'short' input data to 'float' -- GitLab From 6f096955d304dfd55ba69725f11e633b71478fbc Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Fri, 14 Jul 2023 17:41:40 +0200 Subject: [PATCH 009/109] cleanup inactive code --- lib_dec/ivas_dec.c | 153 +----------------------------------- lib_dec/ivas_init_dec.c | 30 +------ lib_dec/ivas_osba_dec.c | 58 -------------- lib_enc/ivas_enc.c | 56 ------------- lib_enc/ivas_init_enc.c | 13 --- lib_enc/ivas_mct_core_enc.c | 2 +- lib_enc/ivas_mct_enc.c | 2 +- 7 files changed, 7 insertions(+), 307 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 5d178d2ef9..7ee66f5af2 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -455,7 +455,6 @@ ivas_error ivas_dec( } } #ifdef OSBA_DISC_OBJ_MCT - // Todo OSBA merge: This was added as a whole block so probably something is wrong. else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { int16_t nchan_ism, nchan_transport_ism; @@ -467,7 +466,7 @@ ivas_error ivas_dec( dirac_bs_md_write_idx = 0; if ( st_ivas->hDirAC != NULL ) { - dirac_bs_md_write_idx = st_ivas->hDirAC->dirac_bs_md_write_idx; /* Store the write-index for this frame */ + dirac_bs_md_write_idx = st_ivas->hDirAC->dirac_bs_md_write_idx; /* Store the write-index for this frame *//*TODOfto:this seems not to be needed?*/ } #ifdef ENABLE_ISM_MD_CODING /* set ISM parameters and decode ISM metadata in OSBA format */ @@ -483,170 +482,22 @@ ivas_error ivas_dec( return error; } -#if 0 - /* Configuration of combined-format bit-budget distribution */ - ivas_set_surplus_brate_dec( st_ivas, &ism_total_brate ); - - if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) - { - /* set ISM parameters and decode ISM metadata in OSBA format */ - if ( ( error = ivas_omasa_ism_metadata_dec( st_ivas, ism_total_brate, &nchan_ism, &nchan_transport_ism, dirac_bs_md_write_idx, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* the separated object */ - st = st_ivas->hSCE[0]->hCoreCoder[0]; - st->bit_stream = &( st_ivas->bit_stream[0] ); - if ( ( error = ivas_sce_dec( st_ivas, 0, &output[st_ivas->nchan_transport], output_frame, nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* prepare for SBA content decoding */ - if ( st_ivas->nchan_transport == 1 ) - { - st = st_ivas->hSCE[1]->hCoreCoder[0]; - } - else - { - st = st_ivas->hCPE[0]->hCoreCoder[0]; - } -#if 1 - st->bit_stream = &( st_ivas->bit_stream[( ism_total_brate / FRAMES_PER_SEC )] ); -#else - st->bit_stream = st_ivas->hSCE[0]->hCoreCoder[0]->bit_stream; //& ( st_ivas->bit_stream[( st_ivas->hSCE[0]->hCoreCoder[0]->total_brate / FRAMES_PER_SEC )] ); -#endif - } - else if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) - { - // TBD !!!!! - } - - if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) - { -#endif -#if 1 /*TODOfto: no MD for now*/ - -#endif -#if 0 - /* decode ISM channels */ - for ( n = 0; n < nchan_transport_ism; n++ ) - { - if ( ( error = ivas_sce_dec( st_ivas, n, &output[st_ivas->nchan_transport + n], output_frame, nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - if ( st_ivas->nchan_transport == 1 ) - { - st = st_ivas->hSCE[nchan_transport_ism]->hCoreCoder[0]; - } - else - { - st = st_ivas->hCPE[0]->hCoreCoder[0]; - } -#else st = st_ivas->hCPE[0]->hCoreCoder[0]; -#endif - // st->bit_stream = &( st_ivas->bit_stream[( ism_total_brate / FRAMES_PER_SEC )] ); - // st->next_bit_pos = SBA_PLANAR_BITS + SBA_ORDER_BITS; -#if 0 - /* decode SBA transport channels */ - if ( st_ivas->nchan_transport == 1 ) - { - if ( ( error = ivas_sce_dec( st_ivas, nchan_transport_ism, &output[0], output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else if ( st_ivas->nCPE == 1 ) - { - if ( ( error = ivas_cpe_dec( st_ivas, 0, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else if ( st_ivas->nCPE > 1 ) - { - - if ( ( error = ivas_mct_dec( st_ivas, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) - { - return error; - } - } -#else if ( ( error = ivas_mct_dec( st_ivas, output, output_frame, nb_bits_metadata[0]+nb_bits_metadata[1] )) != IVAS_ERR_OK ) { return error; } -#endif /* HP filtering */ - for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) + for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) /*TODOfto:check what needs to be filtered here*/ { hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } -#if 1 - - { - int16_t nchan = st_ivas->nchan_transport + st_ivas->nchan_ism; - for ( int t = 0; t < output_frame; t++ ) - { - for ( int c = 0; c < nchan; c++ ) - { - int16_t val = (int16_t) ( output[c][t] + 0.5f ); - dbgwrite( &val, sizeof( int16_t ), 1, 1, "int_dec_core_out.raw" ); - } - } - } -#endif - nchan_remapped = ivas_sba_remapTCs( output, st_ivas, output_frame ); - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) - { - ivas_sba_mix_matrix_determiner( st_ivas->hSpar, output, st_ivas->bfi, nchan_remapped, output_frame ); - } -#if 0 - /* Set the number of objects for the parametric rendering */ - if ( st_ivas->hDirAC != NULL ) - { - st_ivas->hDirAC->numIsmDirections = 0; - if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC && st_ivas->ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ ) - { - st_ivas->hDirAC->numIsmDirections = st_ivas->nchan_ism; - } - } -#endif -#if 0 - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) - { - /* loudness correction */ - ivas_dirac_dec_binaural_gain( output, nchan_remapped, output_frame ); - } - - /* 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 ) - { - if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) - { - if ( ( error = ivas_omasa_dirac_td_binaural( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else - { - ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, output, st_ivas->nchan_transport ); - } - } - else -#endif if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { if ( ( error = ivas_omasa_dirac_td_binaural( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 5e2ed44186..f239b07a1c 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -180,16 +180,9 @@ ivas_error ivas_dec_setup( #ifdef OSBA_DISC_OBJ_MCT else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { - int32_t sba_total_brate; - /* the number of objects is written at the end of the bitstream, in the SBA metadata */ st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1; -#if 0 /*TODOfto: why is this?*/ - if ( st_ivas->sba_analysis_order == 0 ) - { - st_ivas->sba_analysis_order = SBA_FOA_ORDER; - } -#else + /* read Ambisonic (SBA) planar flag */ st_ivas->sba_planar = st_ivas->bit_stream[num_bits_read]; num_bits_read += SBA_PLANAR_BITS; @@ -213,7 +206,7 @@ ivas_error ivas_dec_setup( { ivas_sba_config( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init ); } -#endif + /*correct number of CPEs for discrete ISM coding*/ if ( st_ivas->ini_frame > 0 && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { @@ -1065,7 +1058,6 @@ ivas_error ivas_init_decoder( ivas_sba_set_cna_cng_flag( st_ivas ); } #ifdef OSBA_DISC_OBJ_MCT - // Todo OSBA merge: This part should be verified as it was a large added block. Some fixes done already. else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { st_ivas->ism_extmeta_active = -1; @@ -1108,11 +1100,8 @@ ivas_error ivas_init_decoder( int32_t temp_brate[MAX_SCE]; -#ifndef OSBA_DISC_OBJ_MCT - st_ivas->nSCE = st_ivas->nchan_ism; /* number of objects */ -#else + st_ivas->nCPE += st_ivas->nchan_ism >> 1; -#endif st_ivas->element_mode_init = IVAS_CPE_MDCT; @@ -1503,7 +1492,6 @@ ivas_error ivas_init_decoder( } } #ifdef OSBA_DISC_OBJ_MCT -#if 1 /*TODOfto leave for later*/ if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) @@ -1519,20 +1507,8 @@ ivas_error ivas_init_decoder( { return error; } -#if 0 - } - - if ( st_ivas->renderer_type == RENDERER_DIRAC && ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) - { - /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ - if ( ( error = ivas_masa_ism_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif } } -#endif #endif /*-----------------------------------------------------------------* diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index a9b5d8afd0..b5d2bb4be1 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -214,20 +214,6 @@ ivas_error ivas_omasa_dirac_td_binaural( #endif // v_multc( data_separated_objects[n], gain, data_separated_objects[n], output_frame ); } -#if 1 - - { - int16_t nchan = st_ivas->hOutSetup.nchan_out_woLFE; - for ( int t = 0; t < output_frame; t++ ) - { - for ( int c = 0; c < 4; c++ ) - { - int16_t val = (int16_t) ( data_separated_objects[c][t] + 0.5f ); - dbgwrite( &val, sizeof( int16_t ), 1, 1, "sep_obj.raw" ); - } - } - } -#endif for ( n = 0; n < st_ivas->nchan_ism; n++ ) { @@ -235,21 +221,6 @@ ivas_error ivas_omasa_dirac_td_binaural( } -#if 1 - - { - int16_t nchan = st_ivas->hOutSetup.nchan_out_woLFE; - for ( int t = 0; t < output_frame; t++ ) - { - for ( int c = 0; c < 4; c++ ) - { - int16_t val = (int16_t) ( data_separated_objects[c][t] + 0.5f ); - dbgwrite( &val, sizeof( int16_t ), 1, 1, "sep_obj_delay.raw" ); - } - } - } -#endif - #ifdef SBA_AND_OBJECTS if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { @@ -264,39 +235,10 @@ ivas_error ivas_omasa_dirac_td_binaural( #endif -#if 1 - - { - int16_t nchan = st_ivas->hOutSetup.nchan_out_woLFE; - for ( int t = 0; t < output_frame; t++ ) - { - for ( int c = 4; c < 4 + nchan; c++ ) - { - int16_t val = (int16_t) ( output[c][t] + 0.5f ); - dbgwrite( &val, sizeof( int16_t ), 1, 1, "int_dec_bin_hoa.raw" ); - } - } - } -#endif - if ( ( error = ivas_td_binaural_renderer( st_ivas, p_sepobj, output_frame ) ) != IVAS_ERR_OK ) { return error; } -#if 1 - - { - int16_t nchan = st_ivas->hOutSetup.nchan_out_woLFE; - for ( int t = 0; t < output_frame; t++ ) - { - for ( int c = 0; c < nchan; c++ ) - { - int16_t val = (int16_t) ( p_sepobj[c][t] + 0.5f ); - dbgwrite( &val, sizeof( int16_t ), 1, 1, "int_dec_bin_obj.raw" ); - } - } - } -#endif for ( n = 0; n < BINAURAL_CHANNELS; n++ ) { diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index aa68bf5ee6..7ca1270b93 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -376,43 +376,7 @@ ivas_error ivas_enc( return error; } #endif -#if 0 - /* Encode ISMs metadata */ - if ( ( error = ivas_ism_enc( st_ivas, data_f, input_frame, &nb_bits_metadata[1] /*, 0 */ ) ) != IVAS_ERR_OK ) /*TODOfto: not needed for now*/ - { - return error; - } -#endif -#if 0 - - if ( st_ivas->nchan_transport == 1 ) - { - st = st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0]; - hMetaData = st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData; - - /* update pointer to the buffer of indices (ISM indices were alredy written) */ - hMetaData->ind_list = st_ivas->hSCE[st_ivas->nSCE - 2]->hMetaData->ind_list + st_ivas->hSCE[st_ivas->nSCE - 2]->hMetaData->nb_ind_tot; - st->hBstr->ind_list = st_ivas->hSCE[st_ivas->nSCE - 2]->hCoreCoder[0]->hBstr->ind_list + st_ivas->hSCE[st_ivas->nSCE - 2]->hCoreCoder[0]->hBstr->nb_ind_tot; - } - else - { - st = st_ivas->hCPE[0]->hCoreCoder[0]; - hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; - /* update pointer to the buffer of indices (ISM indices were alredy written) */ - hMetaData->ind_list = st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData->ind_list + st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData->nb_ind_tot; - st->hBstr->ind_list = st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0]->hBstr->ind_list + st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0]->hBstr->nb_ind_tot; - } -#endif - -#if 0 // TODOfto: why is this needed for ISM_NONE? - /* write number of objects - unary coding */ - for ( n = 1; n < hEncoderConfig->nchan_ism; n++ ) - { - push_indice( hMetaData, IND_ISM_NUM_OBJECTS, 1, 1 ); - } - push_indice( hMetaData, IND_ISM_NUM_OBJECTS, 0, 1 ); -#endif /* Write SBA planar flag */ push_indice( st->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); @@ -428,11 +392,6 @@ ivas_error ivas_enc( /* get SBA TCs */ ivas_sba_getTCs( &data_f[n], st_ivas, input_frame ); - // if ( st_ivas->hEncoderConfig->ivas_total_brate >= IVAS_256k ) - // { - // st_ivas->nchan_transport += n; - //} - /* encode SBA transport channels */ if ( st_ivas->nchan_transport == 1 ) { @@ -450,21 +409,6 @@ ivas_error ivas_enc( } else if ( st_ivas->nCPE > 1 ) /* FOA/HOA format */ { -#if 1 - - { - int16_t nchan = st_ivas->nchan_transport + st_ivas->hEncoderConfig->nchan_ism; - for ( int t = 0; t < input_frame; t++ ) - { - for ( int c = 0; c < nchan; c++ ) - { - int16_t val = (int16_t) ( data_f[c][t] + 0.5f ); - dbgwrite( &val, sizeof( int16_t ), 1, 1, "int_enc_core_in.raw" ); - } - } - } -#endif - if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 5e90847cab..0f72888c35 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -630,19 +630,6 @@ ivas_error ivas_init_encoder( } else { - - -#if 0 - /* allocate and initialize ISM core-coder handles */ - for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) - { - if ( ( error = create_sce_enc( st_ivas, sce_id, sep_object_brate_osba[k - 2][st_ivas->nSCE - 1] ) ) != IVAS_ERR_OK ) - { - return error; - } - } -#endif - /* allocate and initialize MCT core coder */ st_ivas->nCPE += st_ivas->hEncoderConfig->nchan_ism >> 1; diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 2884c9430f..835169ee30 100755 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -567,7 +567,7 @@ void ivas_mct_core_enc( #ifdef DEBUGGING format_bits = ( ivas_format == MC_FORMAT ? IVAS_FORMAT_SIGNALING_NBITS + MC_LS_SETUP_BITS : IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + SBA_ORDER_BITS + SBA_PLANAR_BITS ); #ifdef OSBA_DISC_OBJ_MCT - format_bits += ( ivas_format == SBA_ISM_FORMAT && nChannels > FOA_CHANNELS ); + format_bits += ( ivas_format == SBA_ISM_FORMAT && nChannels > FOA_CHANNELS ); /*TODO needs to be rechecked when coding FOA*/ #endif mct_bits += hMCT->nBitsMCT + hMCT->nchan_out_woLFE; assert( ( total_brate + ( NBITS_BWIDTH + format_bits + mct_bits + sba_meta + lfe_bits ) * FRAMES_PER_SEC ) == ivas_total_brate ); diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index af40bad663..20c0d4bdb2 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -85,7 +85,7 @@ static void set_mct_enc_params( #ifdef SBA_AND_OBJECTS if ( ( ivas_format == SBA_FORMAT #ifndef OSBA_DISC_OBJ_MCT - || ivas_format == SBA_ISM_FORMAT + || ivas_format == SBA_ISM_FORMAT #endif ) && ivas_total_brate >= IVAS_256k ) -- GitLab From 2308c7a05236e55c41d0d51dd1d431429497e9dc Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Fri, 14 Jul 2023 18:30:49 +0200 Subject: [PATCH 010/109] remaining from merge --- lib_com/options.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index e2e6160e9b..38371493f2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -170,14 +170,16 @@ #define NONBE_FIX_589_JBM_TC_OFFSETS /* FhG: issue 589: wrong offset into the TC buffers is used in some rendering paths in the JBM main rendering function */ #define FIX_MEM_REALLOC_IND_LIST /* VA: issue 601: failure of the automatic memory re-allocation mechanism when ind_list[] buffer is depleted in MASA mode with 2 TC*/ -/* ################## End BE DEVELOPMENT switches ######################### */ - #define SBA_AND_OBJECTS #ifdef SBA_AND_OBJECTS #define OSBA_DISC_OBJ_MCT #define ENABLE_ISM_MD_CODING #endif +/* ################## End BE DEVELOPMENT switches ######################### */ + + + /* #################### Start NON-BE CR switches ########################## */ /* any switch which is non-be wrt operation points tested in selection */ /* all switches in this category should start with "CR_" */ -- GitLab From 8e615d5614470494feb3d37ade9a91fd11a583ae Mon Sep 17 00:00:00 2001 From: wkr Date: Mon, 17 Jul 2023 09:57:02 +0200 Subject: [PATCH 011/109] fix compile errors with OSBA_DISC_OBJ_MCT and ENABLE_ISM_MD_CODING disabled --- lib_enc/ivas_ism_metadata_enc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index 5105d8e8dd..e1d9c3fd09 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -240,7 +240,9 @@ ivas_error ivas_ism_metadata_enc( if ( hIsmMeta[ch]->ism_metadata_flag == 1 ) { +#ifdef OSBA_DISC_OBJ_MCT if ( ism_mode != ISM_SBA_MODE_DISC ) /*TODOfto this may cost a few bits but it is supposed to be for the higher bitrates anyway*/ +#endif { /* In case of low level noise for low bitrate inactive frames, do not sent metadata */ hIsmMeta[ch]->ism_metadata_flag = vad_flag[ch] || hSCE[ch]->hCoreCoder[0]->lp_noise > 10 || hSCE[ch]->hCoreCoder[0]->tcxonly; @@ -362,11 +364,13 @@ ivas_error ivas_ism_metadata_enc( push_indice( hBstr, IND_ISM_MD_INACTIVE_FLAG, lowrate_metadata_flag[ch], ISM_METADATA_INACTIVE_FLAG_BITS ); } } +#ifdef OSBA_DISC_OBJ_MCT else /*ism_mode == ISM_SBA_MODE_DISC*/ { /* all objects are considered active*/ push_indice( hBstr, IND_ISM_METADATA_FLAG, 1, 1 ); } +#endif } -- GitLab From b9392a0a5395a1be9c105d1f5bfde8e85ef8f5b6 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Mon, 17 Jul 2023 10:47:48 +0200 Subject: [PATCH 012/109] fix windows build --- Workspace_msvc/lib_dec.vcxproj | 1 + Workspace_msvc/lib_dec.vcxproj.filters | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index 80910aa5e7..1e5027f35e 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -296,6 +296,7 @@ + diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters index 6284884920..ec212b8eef 100644 --- a/Workspace_msvc/lib_dec.vcxproj.filters +++ b/Workspace_msvc/lib_dec.vcxproj.filters @@ -524,6 +524,9 @@ dec_ivas_c + + dec_ivas_c + -- GitLab From 11bd534b1b983081e4570e3db117bcbdfa3f4f24 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Mon, 17 Jul 2023 10:51:10 +0200 Subject: [PATCH 013/109] fix clang-format --- lib_dec/ivas_dec.c | 6 +++--- lib_dec/ivas_ism_metadata_dec.c | 4 +--- lib_dec/ivas_jbm_dec.c | 12 +++++++----- lib_dec/ivas_osba_dec.c | 4 ++-- lib_dec/ivas_spar_decoder.c | 4 ++-- lib_enc/ivas_ism_enc.c | 12 ++++++------ lib_enc/ivas_ism_metadata_enc.c | 6 +++--- lib_enc/ivas_mct_enc.c | 2 +- 8 files changed, 25 insertions(+), 25 deletions(-) mode change 100755 => 100644 lib_dec/ivas_spar_decoder.c diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 7ee66f5af2..dfc40822dd 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -64,7 +64,7 @@ ivas_error ivas_dec( #ifndef OSBA_DISC_OBJ_MCT int16_t nb_bits_metadata[MAX_SCE]; #else - int16_t nb_bits_metadata[MAX_SCE+1]; + int16_t nb_bits_metadata[MAX_SCE + 1]; #endif int32_t output_Fs, ivas_total_brate; AUDIO_CONFIG output_config; @@ -466,7 +466,7 @@ ivas_error ivas_dec( dirac_bs_md_write_idx = 0; if ( st_ivas->hDirAC != NULL ) { - dirac_bs_md_write_idx = st_ivas->hDirAC->dirac_bs_md_write_idx; /* Store the write-index for this frame *//*TODOfto:this seems not to be needed?*/ + dirac_bs_md_write_idx = st_ivas->hDirAC->dirac_bs_md_write_idx; /* Store the write-index for this frame */ /*TODOfto:this seems not to be needed?*/ } #ifdef ENABLE_ISM_MD_CODING /* set ISM parameters and decode ISM metadata in OSBA format */ @@ -484,7 +484,7 @@ ivas_error ivas_dec( st = st_ivas->hCPE[0]->hCoreCoder[0]; - if ( ( error = ivas_mct_dec( st_ivas, output, output_frame, nb_bits_metadata[0]+nb_bits_metadata[1] )) != IVAS_ERR_OK ) + if ( ( error = ivas_mct_dec( st_ivas, output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index 36ccc0588c..89000941f7 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -537,7 +537,7 @@ ivas_error ivas_ism_metadata_dec( if ( ism_mode == ISM_SBA_MODE_DISC ) { /* set the bitstream pointer to its original position */ - nb_bits_metadata[0]=st0->next_bit_pos; + nb_bits_metadata[0] = st0->next_bit_pos; st0->bit_stream = bstr_orig; st0->next_bit_pos = next_bit_pos_orig; @@ -617,8 +617,6 @@ ivas_error ivas_ism_metadata_dec( set_s( md_diff_flag, 1, nchan_ism ); - - for ( ch = 0; ch < *nchan_transport; ch++ ) { diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index ab45675651..7c575dc0b0 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -156,20 +156,22 @@ ivas_error ivas_jbm_dec_tc( { 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 #ifdef OSBA_DISC_OBJ_MCT - , st_ivas->hSCE[0]->hCoreCoder[0] + , + st_ivas->hSCE[0]->hCoreCoder[0] #endif - ) ) != IVAS_ERR_OK ) + ) ) != IVAS_ERR_OK ) { return error; } } else /* ISM_MODE_DISC */ { - if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt + if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt #ifdef OSBA_DISC_OBJ_MCT - , st_ivas->hSCE[0]->hCoreCoder[0] + , + st_ivas->hSCE[0]->hCoreCoder[0] #endif - ) ) != IVAS_ERR_OK ) + ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index b5d2bb4be1..caf53d5844 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -246,9 +246,9 @@ ivas_error ivas_omasa_dirac_td_binaural( v_add( output[MAX_NUM_OBJECTS + n], p_sepobj[n], output[n], output_frame ); #else int16_t i; - for(i=0; iivas_format == SBA_ISM_FORMAT ) { -#ifndef ENABLE_ISM_MD_CODING +#ifndef ENABLE_ISM_MD_CODING last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ); /* the number of objects was read */ last_bit_pos -= NO_BITS_MASA_ISM_NO_OBJ; @@ -348,7 +348,7 @@ ivas_error ivas_spar_dec( #ifdef OSBA_DISC_OBJ_MCT if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { - last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - nb_bits_read[1]; + last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - nb_bits_read[1]; } else { diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 55a996bcf1..f6bf8b1430 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -222,19 +222,19 @@ ivas_error ivas_ism_enc( } else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, st_ivas->nchan_transport, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm, st_ivas->hEncoderConfig->ism_extended_metadata_flag + ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, st_ivas->nchan_transport, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm, st_ivas->hEncoderConfig->ism_extended_metadata_flag #ifdef OSBA_DISC_OBJ_MCT - , - st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame + , + st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame #endif - ); + ); } else /* ISM_MODE_DISC */ { ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, st_ivas->nchan_transport, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata, vad_flag, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag #ifdef OSBA_DISC_OBJ_MCT - , - st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame + , + st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame #endif ); } diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index e1d9c3fd09..4982c4a473 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -475,8 +475,8 @@ ivas_error ivas_ism_metadata_enc( /* save number of metadata bits written */ #ifdef OSBA_DISC_OBJ_MCT - if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC ) -#else + if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC ) +#else if ( ism_mode == ISM_MODE_DISC ) #endif { @@ -622,7 +622,7 @@ ivas_error ivas_ism_metadata_enc( *----------------------------------------------------------------*/ if ( ( error = ivas_ism_config( ism_total_brate, nchan_transport, nchan_ism, hIsmMeta, ism_extended_metadata_flag, null_metadata_flag, ism_imp, element_brate, total_brate, nb_bits_metadata ) ) != IVAS_ERR_OK ) - { + { return error; } diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 20c0d4bdb2..af40bad663 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -85,7 +85,7 @@ static void set_mct_enc_params( #ifdef SBA_AND_OBJECTS if ( ( ivas_format == SBA_FORMAT #ifndef OSBA_DISC_OBJ_MCT - || ivas_format == SBA_ISM_FORMAT + || ivas_format == SBA_ISM_FORMAT #endif ) && ivas_total_brate >= IVAS_256k ) -- GitLab From 859d9509a5d368837c859decd23d81e92d06c608 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Mon, 17 Jul 2023 11:50:33 +0200 Subject: [PATCH 014/109] fix issue for ISM_MODE_NONE mode and errors in DirAC bitstream reading --- lib_dec/ivas_spar_decoder.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 8bbec5211a..faf87492aa 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -318,7 +318,7 @@ ivas_error ivas_spar_dec( next_bit_pos_orig = st0->next_bit_pos; #ifdef OSBA_DISC_OBJ_MCT - if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { #ifndef ENABLE_ISM_MD_CODING last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ); @@ -332,6 +332,7 @@ ivas_error ivas_spar_dec( else { *nb_bits_read = 0; + last_bit_pos = 0; } #endif @@ -346,7 +347,7 @@ ivas_error ivas_spar_dec( } #ifdef OSBA_DISC_OBJ_MCT - if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - nb_bits_read[1]; } -- GitLab From 9562e705ccb4a8cc76818e45e8da169742a1a438 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Mon, 17 Jul 2023 14:45:53 +0200 Subject: [PATCH 015/109] remove obsolete if condition --- lib_dec/ivas_ism_metadata_dec.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index 89000941f7..cee667ad7f 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -303,11 +303,7 @@ ivas_error ivas_ism_metadata_dec( } /* read ISM_NO_META class signalling */ -#ifdef OSBA_DISC_OBJ_MCT - if ( ism_mode == ISM_MODE_DISC && ism_mode != ISM_SBA_MODE_DISC ) -#else if ( ism_mode == ISM_MODE_DISC ) -#endif { for ( ch = 0; ch < *nchan_transport; ch++ ) { -- GitLab From 19ceea642261f8c88703119a3a3bc97278e27b7d Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Mon, 17 Jul 2023 18:54:03 +0200 Subject: [PATCH 016/109] fix for 3 object case --- lib_dec/ivas_init_dec.c | 4 ++-- lib_enc/ivas_enc.c | 2 +- lib_enc/ivas_init_enc.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index f239b07a1c..cdf52ed6c2 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -210,7 +210,7 @@ ivas_error ivas_dec_setup( /*correct number of CPEs for discrete ISM coding*/ if ( st_ivas->ini_frame > 0 && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - st_ivas->nCPE += st_ivas->nchan_ism >> 1; + st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; } st_ivas->ism_mode = ISM_SBA_MODE_DISC; @@ -1101,7 +1101,7 @@ ivas_error ivas_init_decoder( int32_t temp_brate[MAX_SCE]; - st_ivas->nCPE += st_ivas->nchan_ism >> 1; + st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; st_ivas->element_mode_init = IVAS_CPE_MDCT; diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 7ca1270b93..bd001a1b39 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -365,7 +365,7 @@ ivas_error ivas_enc( #endif #endif #ifdef ENABLE_ISM_MD_CODING - if ( ( error = ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->nchan_transport, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag + if ( ( error = ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag #ifdef OSBA_DISC_OBJ_MCT , st->ini_frame diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 0f72888c35..f6d889c2b3 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -632,7 +632,7 @@ ivas_error ivas_init_encoder( { /* allocate and initialize MCT core coder */ - st_ivas->nCPE += st_ivas->hEncoderConfig->nchan_ism >> 1; + st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1; for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { -- GitLab From 591ca6edb7dd26b8a4a6e3308f0b98331ebde1b1 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Tue, 18 Jul 2023 15:26:04 +0200 Subject: [PATCH 017/109] -fix for binaural output with 2 objects -fix decoder printout for combined format -add debugging output --- lib_com/bitstream.c | 23 +++++++++++----- lib_com/options.h | 1 + lib_dec/ivas_dec.c | 13 ++++++++++ lib_dec/ivas_objectRenderer_internal.c | 18 +++++++++++++ lib_dec/ivas_osba_dec.c | 36 ++++++++++++++++++++++---- lib_dec/lib_dec.c | 12 ++++++--- 6 files changed, 88 insertions(+), 15 deletions(-) diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 9ebf432b59..b815b00b7d 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -2507,7 +2507,7 @@ static Word16 read_error_flag( } } #ifdef WRAP_AS_EIDXOR - if ( wrap != 0 ) /* wrap file and read again, try to get the next flag , */ + if ( wrap != 0 ) /* wrap file and read again, try to get the next flag , */ { tmp = 0; /* needed for byte re-reading */ if ( ( ep_type == 1 ) ? ( fread( &tmp, sizeof( int8_t ), 1, FEC_pattern ) != 1 ) /* read byte directly stored in short variable */ @@ -2904,6 +2904,15 @@ ivas_error preview_indices( st_ivas->nchan_ism = 2 * bit_stream[total_brate / FRAMES_PER_SEC - 1] + bit_stream[total_brate / FRAMES_PER_SEC - 2] + 1; st_ivas->ism_mode = ISM_SBA_MODE_DISC; } + + /* Read SBA planar flag and SBA order */ + st_ivas->sba_planar = ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + IVAS_COMBINED_FORMAT_SIGNALLING_BITS] == 1 ); + st_ivas->sba_order = ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + IVAS_COMBINED_FORMAT_SIGNALLING_BITS + 2] == 1 ); + st_ivas->sba_order += 2 * ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + IVAS_COMBINED_FORMAT_SIGNALLING_BITS + 1] == 1 ); + + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( total_brate, st_ivas->sba_order ); + + ivas_sba_config( total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &( st_ivas->nSCE ), &( st_ivas->nCPE ), &( st_ivas->element_mode_init ) ); } #endif } @@ -3082,7 +3091,7 @@ ivas_error read_indices( speech_lost = 0; if ( total_brate == FRAME_NO_DATA && st_ivas->bfi != 0 ) /* unsent NO_DATA or stolen NO_DATA/signaling frame */ { - speech_lost = 1; /* initial ft assumption, CNG_state decides what to do */ + speech_lost = 1; /* initial ft assumption, CNG_state decides what to do */ } /* Do not allow decoder to enter CNG-synthesis for any instantly received GOOD+LENGTH==0 frame @@ -3120,7 +3129,7 @@ ivas_error read_indices( ( *CNG != 0 ) && ( ( speech_bad != 0 ) || ( speech_lost != 0 ) ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */ ( sid_upd_bad != 0 ) ) /* SID_UPD_BAD --> start CNG */ { - st_ivas->bfi = 0; /* bfi=0 needed to activate CNG code */ + st_ivas->bfi = 0; /* bfi=0 needed to activate CNG code */ total_brate = FRAME_NO_DATA; } @@ -3256,7 +3265,7 @@ static Word32 read_indices_mime_handle_dtx( if ( total_brate > SID_2k40 && st->bfi == 1 ) /* typically from q bit */ { - speech_bad = 1; /* initial assumption, CNG synt state decides what to actually do */ + speech_bad = 1; /* initial assumption, CNG synt state decides what to actually do */ } /* all frame types decoded */ @@ -3297,8 +3306,8 @@ static Word32 read_indices_mime_handle_dtx( if ( ( *CNG != 0 && ( speech_bad || speech_lost || no_data ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */ sid_upd_bad ) /* SID_UPD_BAD --> start/stay CNG */ { - st->bfi = 0; /* mark as good to not start speech PLC */ - total_brate = 0; /* this zeroing needed for speech_bad, sid_bad frames */ + st->bfi = 0; /* mark as good to not start speech PLC */ + total_brate = 0; /* this zeroing needed for speech_bad, sid_bad frames */ } @@ -3322,7 +3331,7 @@ static Word32 read_indices_mime_handle_dtx( { init_rate = AMRWB_IOmode2rate[core_mode]; /* read from from ToC */ } - st->total_brate = init_rate; /* not updated on bfi as decoderSelectCodec is not called below */ + st->total_brate = init_rate; /* not updated on bfi as decoderSelectCodec is not called below */ st->core_brate = init_rate; } diff --git a/lib_com/options.h b/lib_com/options.h index 38371493f2..1a277336c3 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -124,6 +124,7 @@ /*#define DEBUG_AGC*/ /* debug SPAR AGC in-out */ #endif /*#define SPAR_HOA_DBG*/ /* SPAR HOA debug statements */ +#define DEBUG_OSBA /*#define DEBUG_BINAURAL_FILTER_DESIGN*/ /* debugging of Crend binaural filter design */ /*#define DEBUG_AGC_ENCODER_CMD_OPTION*/ /* Ability to force enable or disable AGC behaviour in DIRAC/SPAR via command line option */ #define DEBUG_JBM_CMD_OPTION /* ability for telling the decoder the frontend fetch size and to not delay compensate for bad frames at the beginning */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index dfc40822dd..dabaa89263 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -497,6 +497,19 @@ ivas_error ivas_dec( nchan_remapped = ivas_sba_remapTCs( output, st_ivas, output_frame ); +#ifdef DEBUG_OSBA + { + int16_t nchan = st_ivas->nchan_transport + st_ivas->nchan_ism; + for ( int t = 0; t < output_frame; t++ ) + { + for ( int c = 0; c < nchan; c++ ) + { + int16_t val = (int16_t) ( output[c][t] + 0.5f ); + dbgwrite( &val, sizeof( int16_t ), 1, 1, "./res/TC_dec_core_out.raw" ); + } + } + } +#endif if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 3be8a2c62e..1a7b6cfa6e 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -72,6 +72,11 @@ ivas_error ivas_td_binaural_renderer( ) { int16_t ism_md_subframe_update; +#ifdef OSBA_DISC_OBJ_MCT + int16_t nchan_transport; + + nchan_transport = ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) ? st_ivas->nchan_ism : st_ivas->nchan_transport; +#endif if ( st_ivas->hDecoderConfig->Opt_delay_comp ) { @@ -81,6 +86,18 @@ ivas_error ivas_td_binaural_renderer( { ism_md_subframe_update = 2; } + +#ifdef OSBA_DISC_OBJ_MCT + return ivas_td_binaural_renderer_unwrap( + st_ivas->hReverb, + st_ivas->transport_config, + st_ivas->hBinRendererTd, nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, + st_ivas->hIsmMetaData, + ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->enableCombinedOrientation : NULL, + ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->Quaternions : NULL, + ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->listenerPos : NULL, + ism_md_subframe_update, output, output_frame ); +#else return ivas_td_binaural_renderer_unwrap( st_ivas->hReverb, st_ivas->transport_config, @@ -90,6 +107,7 @@ ivas_error ivas_td_binaural_renderer( ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->Quaternions : NULL, ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->listenerPos : NULL, ism_md_subframe_update, output, output_frame ); +#endif } diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index caf53d5844..b3858a60c4 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -197,18 +197,20 @@ ivas_error ivas_omasa_dirac_td_binaural( p_sepobj[n] = &data_separated_objects[n][0]; } #ifdef SBA_AND_OBJECTS +#if 0 channel_offset = st_ivas->nchan_transport; if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->nchan_transport == 3 ) /* channels are remapped in ivas_sba_remapTCs() */ { channel_offset = 4; } - channel_offset = 0; +#endif + channel_offset = st_ivas->nchan_ism; #endif for ( n = 0; n < st_ivas->nchan_ism; n++ ) { #ifdef SBA_AND_OBJECTS - mvr2r( output[channel_offset + n], data_separated_objects[n], output_frame ); + mvr2r( output[n], data_separated_objects[n], output_frame ); #else mvr2r( output[2 + n], data_separated_objects[n], output_frame ); #endif @@ -224,22 +226,46 @@ ivas_error ivas_omasa_dirac_td_binaural( #ifdef SBA_AND_OBJECTS if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { - ivas_sba_upmixer_renderer( st_ivas, &output[MAX_NUM_OBJECTS], output_frame ); + ivas_sba_upmixer_renderer( st_ivas, &output[channel_offset], output_frame ); } else { - ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, &output[MAX_NUM_OBJECTS], st_ivas->nchan_transport ); + ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, &output[channel_offset], st_ivas->nchan_transport ); } #else ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, output, st_ivas->nchan_transport ); #endif +#ifdef DEBUG_OSBA + { + for ( int t = 0; t < output_frame; t++ ) + { + for ( int c = 0; c < BINAURAL_CHANNELS; c++ ) + { + int16_t val = (int16_t) ( output[channel_offset + c][t] + 0.5f ); + dbgwrite( &val, sizeof( int16_t ), 1, 1, "./res/sba_fast_conv_out.raw" ); + } + } + } +#endif if ( ( error = ivas_td_binaural_renderer( st_ivas, p_sepobj, output_frame ) ) != IVAS_ERR_OK ) { return error; } +#ifdef DEBUG_OSBA + { + for ( int t = 0; t < output_frame; t++ ) + { + for ( int c = 0; c < BINAURAL_CHANNELS; c++ ) + { + int16_t val = (int16_t) ( p_sepobj[c][t] + 0.5f ); + dbgwrite( &val, sizeof( int16_t ), 1, 1, "./res/ism_td_bin_out.raw" ); + } + } + } +#endif for ( n = 0; n < BINAURAL_CHANNELS; n++ ) { #if 0 @@ -248,7 +274,7 @@ ivas_error ivas_omasa_dirac_td_binaural( int16_t i; for ( i = 0; i < output_frame; i++ ) { - output[n][i] = 0.5f * output[MAX_NUM_OBJECTS + n][i] + 0.5f * p_sepobj[n][i]; + output[n][i] = 0.5f * output[channel_offset + n][i] + 0.5f * p_sepobj[n][i]; } #endif } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 5cc4bdd9b9..d25b71641b 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -496,10 +496,10 @@ ivas_error IVAS_DEC_Configure( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_EnableVoIP( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ #ifdef VARIABLE_SPEED_DECODING - const IVAS_DEC_VOIP_MODE voipMode, /* i : VoIP or variable speed */ - const uint16_t speedFac, /* i : speed factor for variable 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 */ @@ -2533,6 +2533,12 @@ static ivas_error printConfigInfo_dec( { fprintf( stdout, "Input configuration: Scene Based Audio, Ambisonic order %i%s, %d transport channel(s)\n", st_ivas->sba_order, st_ivas->sba_planar ? " (Planar)" : "", st_ivas->nchan_transport ); } +#ifdef OSBA_DISC_OBJ_MCT + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + fprintf( stdout, "Input configuration: Combined Scene Based Audio, Ambisonic order %i, with %d Objects \n", st_ivas->sba_order, st_ivas->nchan_ism ); + } +#endif else if ( st_ivas->ivas_format == MASA_FORMAT ) { fprintf( stdout, "Input configuration: MASA - %d channel(s)\n", st_ivas->nchan_transport ); -- GitLab From 495785ec0035014e6302c4d48be434d23da040c2 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Wed, 19 Jul 2023 16:15:35 +0200 Subject: [PATCH 018/109] fix remapping of SBA channels at decoder side --- lib_dec/ivas_dec.c | 2 +- lib_enc/ivas_ism_metadata_enc.c | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index dabaa89263..f9a2faff05 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -495,7 +495,7 @@ ivas_error ivas_dec( hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } - nchan_remapped = ivas_sba_remapTCs( output, st_ivas, output_frame ); + nchan_remapped = ivas_sba_remapTCs( &output[st_ivas->nchan_ism], st_ivas, output_frame ); #ifdef DEBUG_OSBA { diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index 4982c4a473..efedec90d5 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -564,6 +564,27 @@ ivas_error ivas_ism_metadata_enc( #ifdef OSBA_DISC_OBJ_MCT if ( ism_mode == ISM_SBA_MODE_DISC ) { + int16_t md_diff_flag[MAX_NUM_OBJECTS]; + + set_s( md_diff_flag, 1, nchan_ism ); + for ( ch = 0; ch < nchan_ism; ch++ ) + { + hIsmMeta[ch]->last_ism_metadata_flag = hIsmMeta[ch]->ism_metadata_flag; + + if ( hIsmMeta[ch]->ism_metadata_flag == 0 ) + { + hIsmMeta[ch]->ism_md_fec_cnt_enc++; + } + else + { + hIsmMeta[ch]->ism_md_fec_cnt_enc = 0; + } + hIsmMeta[ch]->ism_md_inc_diff_cnt++; + hIsmMeta[ch]->ism_md_inc_diff_cnt = min( hIsmMeta[ch]->ism_md_inc_diff_cnt, ISM_MD_INC_DIFF_CNT_MAX ); + } + + update_last_metadata( nchan_ism, hIsmMeta, md_diff_flag ); + return error; } #endif @@ -761,7 +782,7 @@ static void encode_radius( idx_radius = idx_radius_abs; nbits_diff_radius = 0; - *flag_abs_radius = 0; /* differential coding by default */ + *flag_abs_radius = 0; /* differential coding by default */ if ( *radius_diff_cnt == ISM_FEC_MAX /* make differential encoding in ISM_FEC_MAX consecutive frames at maximum (in order to control the decoding in FEC) */ || last_ism_metadata_flag == 0 /* If last frame had no metadata coded, do not use differential coding */ -- GitLab From 9e119445aa616e0b348f77d3027a31debe99d551 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Wed, 19 Jul 2023 17:13:07 +0200 Subject: [PATCH 019/109] fix instrumentation build --- lib_dec/ivas_init_dec.c | 4 +--- lib_enc/ivas_ism_metadata_enc.c | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 6d4d7e4a3d..ba706bb487 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1064,6 +1064,7 @@ ivas_error ivas_init_decoder( #ifdef OSBA_DISC_OBJ_MCT else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { + int32_t temp_brate[MAX_SCE]; st_ivas->ism_extmeta_active = -1; st_ivas->ism_extmeta_cnt = 0; @@ -1102,9 +1103,6 @@ ivas_error ivas_init_decoder( st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); - - int32_t temp_brate[MAX_SCE]; - st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index efedec90d5..a538c16079 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -585,6 +585,7 @@ ivas_error ivas_ism_metadata_enc( update_last_metadata( nchan_ism, hIsmMeta, md_diff_flag ); + pop_wmops(); return error; } #endif -- GitLab From 5db78a47c477476015fa731c99c4b6d534b59009 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 20 Jul 2023 10:11:56 +0200 Subject: [PATCH 020/109] re-insert accidentally removed update in non-osba mode --- lib_dec/ivas_ism_metadata_dec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index cee667ad7f..29d6948be6 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -613,6 +613,7 @@ ivas_error ivas_ism_metadata_dec( set_s( md_diff_flag, 1, nchan_ism ); + update_last_metadata( nchan_ism, hIsmMeta, md_diff_flag ); for ( ch = 0; ch < *nchan_transport; ch++ ) { -- GitLab From 172b83fc4c14216718e7404cff5fa3218600f96c Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 20 Jul 2023 10:34:25 +0200 Subject: [PATCH 021/109] clang-format --- lib_com/bitstream.c | 14 +++++++------- lib_dec/lib_dec.c | 6 +++--- lib_enc/ivas_ism_metadata_enc.c | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 8ab05c6a23..0208902e56 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -2517,7 +2517,7 @@ static Word16 read_error_flag( } } #ifdef WRAP_AS_EIDXOR - if ( wrap != 0 ) /* wrap file and read again, try to get the next flag , */ + if ( wrap != 0 ) /* wrap file and read again, try to get the next flag , */ { tmp = 0; /* needed for byte re-reading */ if ( ( ep_type == 1 ) ? ( fread( &tmp, sizeof( int8_t ), 1, FEC_pattern ) != 1 ) /* read byte directly stored in short variable */ @@ -3101,7 +3101,7 @@ ivas_error read_indices( speech_lost = 0; if ( total_brate == FRAME_NO_DATA && st_ivas->bfi != 0 ) /* unsent NO_DATA or stolen NO_DATA/signaling frame */ { - speech_lost = 1; /* initial ft assumption, CNG_state decides what to do */ + speech_lost = 1; /* initial ft assumption, CNG_state decides what to do */ } /* Do not allow decoder to enter CNG-synthesis for any instantly received GOOD+LENGTH==0 frame @@ -3139,7 +3139,7 @@ ivas_error read_indices( ( *CNG != 0 ) && ( ( speech_bad != 0 ) || ( speech_lost != 0 ) ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */ ( sid_upd_bad != 0 ) ) /* SID_UPD_BAD --> start CNG */ { - st_ivas->bfi = 0; /* bfi=0 needed to activate CNG code */ + st_ivas->bfi = 0; /* bfi=0 needed to activate CNG code */ total_brate = FRAME_NO_DATA; } @@ -3275,7 +3275,7 @@ static Word32 read_indices_mime_handle_dtx( if ( total_brate > SID_2k40 && st->bfi == 1 ) /* typically from q bit */ { - speech_bad = 1; /* initial assumption, CNG synt state decides what to actually do */ + speech_bad = 1; /* initial assumption, CNG synt state decides what to actually do */ } /* all frame types decoded */ @@ -3316,8 +3316,8 @@ static Word32 read_indices_mime_handle_dtx( if ( ( *CNG != 0 && ( speech_bad || speech_lost || no_data ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */ sid_upd_bad ) /* SID_UPD_BAD --> start/stay CNG */ { - st->bfi = 0; /* mark as good to not start speech PLC */ - total_brate = 0; /* this zeroing needed for speech_bad, sid_bad frames */ + st->bfi = 0; /* mark as good to not start speech PLC */ + total_brate = 0; /* this zeroing needed for speech_bad, sid_bad frames */ } @@ -3341,7 +3341,7 @@ static Word32 read_indices_mime_handle_dtx( { init_rate = AMRWB_IOmode2rate[core_mode]; /* read from from ToC */ } - st->total_brate = init_rate; /* not updated on bfi as decoderSelectCodec is not called below */ + st->total_brate = init_rate; /* not updated on bfi as decoderSelectCodec is not called below */ st->core_brate = init_rate; } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index d6dcb4e50e..560a22c6e7 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -509,10 +509,10 @@ ivas_error IVAS_DEC_Configure( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_EnableVoIP( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ #ifdef VARIABLE_SPEED_DECODING - const IVAS_DEC_VOIP_MODE voipMode, /* i : VoIP or variable speed */ - const uint16_t speedFac, /* i : speed factor for variable 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 */ diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index a538c16079..8e73bf5f90 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -783,7 +783,7 @@ static void encode_radius( idx_radius = idx_radius_abs; nbits_diff_radius = 0; - *flag_abs_radius = 0; /* differential coding by default */ + *flag_abs_radius = 0; /* differential coding by default */ if ( *radius_diff_cnt == ISM_FEC_MAX /* make differential encoding in ISM_FEC_MAX consecutive frames at maximum (in order to control the decoding in FEC) */ || last_ism_metadata_flag == 0 /* If last frame had no metadata coded, do not use differential coding */ -- GitLab From 3521fbf82d7ab11f704ae5c6e654996e43874ed3 Mon Sep 17 00:00:00 2001 From: rtyag Date: Mon, 24 Jul 2023 21:42:35 +1000 Subject: [PATCH 022/109] ism SBA 512 kbps dirac mapping fix --- lib_dec/ivas_dirac_dec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index b2913baa04..7979bb75dd 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -579,7 +579,11 @@ ivas_error ivas_dirac_dec_config( set_s( hDirAC->proto_index_diff, 0, hDirAC->num_outputs_diff ); hDirAC->sba_map_tc = sba_map_tc; +#ifdef SBA_AND_OBJECTS + if ( ( st_ivas->ivas_format == SBA_FORMAT ) || ( st_ivas->ivas_format == SBA_ISM_FORMAT ) ) +#else if ( st_ivas->ivas_format == SBA_FORMAT ) +#endif { if ( st_ivas->sba_order > SBA_FOA_ORDER && ivas_total_brate >= IVAS_512k ) { -- GitLab From b81b4cff94a0184749843e9cd79d6b2ff45d0874 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Mon, 24 Jul 2023 18:27:44 +0200 Subject: [PATCH 023/109] fix for when SBA_AND_OBJECTS switch is disabled --- lib_enc/ivas_mct_core_enc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 835169ee30..8f3c498580 100755 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -196,7 +196,7 @@ void ivas_mct_core_enc( int16_t ch, ch_core, nSubframes, L_subframeTCX; int16_t i, cpe_id, n, nAvailBits; int16_t nCPE; - float *orig_spectrum[MCT_MAX_CHANNELS][2]; /* Pointers to MDCT output for a short block (L/R) */ + float *orig_spectrum[MCT_MAX_CHANNELS][2]; /* Pointers to MDCT output for a short block (L/R) */ float powerSpec[MCT_MAX_CHANNELS][L_FRAME48k]; float powerSpecMsInv_long[MCT_MAX_CHANNELS][L_FRAME48k]; /* MS inv power spectrum, also inverse MDST spectrum */ float *powerSpecMsInv[MCT_MAX_CHANNELS][2]; @@ -489,10 +489,12 @@ void ivas_mct_core_enc( { nAvailBits -= IVAS_FORMAT_SIGNALING_NBITS_EXTENDED; nAvailBits -= SBA_ORDER_BITS + SBA_PLANAR_BITS; +#ifdef SBA_AND_OBJECTS if ( ivas_format == SBA_ISM_FORMAT && nChannels > 4 ) /*TODOfto: recheck this condition*/ { nAvailBits -= IVAS_COMBINED_FORMAT_SIGNALLING_BITS; } +#endif } for ( cpe_id = 0, i = 0; cpe_id < nCPE; cpe_id++ ) -- GitLab From a575435e3f19d4d35ba1d490a307a30003aeedef Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Tue, 25 Jul 2023 11:18:39 +0200 Subject: [PATCH 024/109] fix BE issues after merge of DirAC refactoring --- lib_dec/ivas_init_dec.c | 5 +---- lib_dec/ivas_ism_metadata_dec.c | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index bcc2ec601b..400428f82e 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -438,6 +438,7 @@ static ivas_error ivas_read_format( break; case 2: st_ivas->ivas_format = ISM_FORMAT; + if ( ivas_total_brate >= IVAS_24k4 ) { if ( st_ivas->bit_stream[*num_bits_read] ) @@ -2329,10 +2330,6 @@ void ivas_init_dec_get_num_cldfb_instances( } #endif - if ( st_ivas->hDiracDecBin->useTdDecorr ) - { - *numCldfbAnalyses += 2; - } if ( st_ivas->hDiracDecBin->useTdDecorr ) { *numCldfbAnalyses += 2; diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index 20f14ac55a..de686d14ef 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -277,7 +277,9 @@ ivas_error ivas_ism_metadata_dec( #ifdef OSBA_DISC_OBJ_MCT if ( ism_mode != ISM_SBA_MODE_DISC ) { +#endif ism_imp[ch] = get_next_indice( st0, ISM_METADATA_FLAG_BITS ); +#ifdef OSBA_DISC_OBJ_MCT } else { -- GitLab From 1e2031686324f877aacffd15fbf7a376f629ddc6 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Wed, 26 Jul 2023 18:37:06 +0200 Subject: [PATCH 025/109] enable EXT output under OSBA_EXT_OUT --- apps/decoder.c | 25 +++++++++++++------ lib_com/options.h | 1 + lib_dec/ivas_dec.c | 26 +++++++++++++++----- lib_dec/ivas_init_dec.c | 32 ++++++++++++++++++------ lib_dec/ivas_output_config.c | 4 +++ lib_dec/ivas_sba_rendering_internal.c | 20 ++++++++++----- lib_dec/lib_dec.c | 35 ++++++++++++++++++++------- lib_dec/lib_dec.h | 3 +++ 8 files changed, 111 insertions(+), 35 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 6e3e23bb47..dbda606482 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -80,8 +80,12 @@ static #else #define MAX_FRAME_SIZE ( 48000 / 50 ) #endif -#define MAX_NUM_OUTPUT_CHANNELS 16 +#define MAX_NUM_OUTPUT_CHANNELS 16 +#ifdef OSBA_EXT_OUT +#define MAX_OUTPUT_PCM_BUFFER_SIZE ( ( MAX_NUM_OUTPUT_CHANNELS + IVAS_MAX_NUM_OBJECTS ) * MAX_FRAME_SIZE ) +#else #define MAX_OUTPUT_PCM_BUFFER_SIZE ( MAX_NUM_OUTPUT_CHANNELS * MAX_FRAME_SIZE ) +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT #define MAX_SPLIT_REND_BITRATE ( 1792000 ) /* TODO tmu: unify with SPLIT_REND_MAX_BRATE ?*/ #define MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES ( ( ( (int32_t) MAX_SPLIT_REND_BITRATE / NUM_FRAMES_PER_SEC ) + 7 ) >> 3 ) @@ -1527,7 +1531,7 @@ static void usage_dec( void ) static int16_t app_own_random( int16_t *seed ) { - *seed = (int16_t) ( *seed * 31821L + 13849L ); + *seed = ( int16_t )( *seed * 31821L + 13849L ); return ( *seed ); } @@ -1680,9 +1684,12 @@ static ivas_error initOnFirstGoodFrame( fprintf( stderr, "\nError in IVAS_DEC_GetFormat, code: %d\n", error ); return error; } - /* If outputting ISM, get number of objects, open output files and write zero metadata for initial bad frames */ +#ifdef OSBA_EXT_OUT + if ( *pBsFormat == IVAS_DEC_BS_OBJ || *pBsFormat == IVAS_DEC_BS_SBA_ISM ) +#else if ( *pBsFormat == IVAS_DEC_BS_OBJ ) +#endif { if ( ( error = IVAS_DEC_GetNumObjects( hIvasDec, pNumObj ) ) != IVAS_ERR_OK ) { @@ -2078,7 +2085,11 @@ static ivas_error decodeG192( /* Write ISM metadata to external file(s) */ if ( decodedGoodFrame && arg.outputFormat == IVAS_DEC_OUTPUT_EXT ) { +#ifdef OSBA_EXT_OUT + if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_SBA_ISM ) +#else if ( bsFormat == IVAS_DEC_BS_OBJ ) +#endif { if ( ( error = IVAS_DEC_GetNumObjects( hIvasDec, &numObj ) ) != IVAS_ERR_OK ) { @@ -2497,9 +2508,9 @@ static ivas_error decodeVoIP( int16_t nOutSamples = 0; uint16_t nSamplesAvailableNext = 0; #ifdef DEBUG_JBM_CMD_OPTION - nOutSamples = (int16_t) ( arg.output_Fs / 1000 * arg.frontendFetchSizeMs ); + nOutSamples = ( int16_t )( arg.output_Fs / 1000 * arg.frontendFetchSizeMs ); #else - nOutSamples = (int16_t) ( arg.output_Fs / 1000 * JBM_FRONTEND_FETCH_FRAMESIZE_MS ); + nOutSamples = ( int16_t )( arg.output_Fs / 1000 * JBM_FRONTEND_FETCH_FRAMESIZE_MS ); #endif /* read all packets with a receive time smaller than the system time */ while ( nextPacketRcvTime_ms <= systemTime_ms ) @@ -2545,7 +2556,7 @@ static ivas_error decodeVoIP( /* we are finished when all packets have been received and jitter buffer is empty */ /* also stop when the input file contains less than two frames, because JBM cannot calculate a delay value and won't start decoding */ /* last clause should make sure that for BE tests we end up with the same number of samples...*/ - if ( nextPacketRcvTime_ms == (uint32_t) ( -1 ) && ( IVAS_DEC_VoIP_IsEmpty( hIvasDec, nOutSamples ) || nFramesFed < 2 ) ) + if ( nextPacketRcvTime_ms == ( uint32_t )( -1 ) && ( IVAS_DEC_VoIP_IsEmpty( hIvasDec, nOutSamples ) || nFramesFed < 2 ) ) { break; } @@ -2849,7 +2860,7 @@ static ivas_error decodeVariableSpeed( reset_wmops(); #endif nSamplesAvailableNext = 0; - nOutSamples = (int16_t) ( arg.output_Fs / 1000 * VARIABLE_SPEED_FETCH_FRAMESIZE_MS ); + nOutSamples = ( int16_t )( arg.output_Fs / 1000 * VARIABLE_SPEED_FETCH_FRAMESIZE_MS ); /*------------------------------------------------------------------------------------------* * Loop for every packet (frame) of bitstream data diff --git a/lib_com/options.h b/lib_com/options.h index 9c279de3a0..bde9e0a200 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -194,6 +194,7 @@ #ifdef SBA_AND_OBJECTS #define OSBA_DISC_OBJ_MCT #define ENABLE_ISM_MD_CODING +#define OSBA_EXT_OUT #endif /* ################## End BE DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index b99744087c..84d7e3630f 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -61,8 +61,12 @@ ivas_error ivas_dec( ) { int16_t n, output_frame, nchan_out; - Decoder_State *st; /* used for bitstream handling */ + Decoder_State *st; /* used for bitstream handling */ +#ifdef OSBA_EXT_OUT + float output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; /* 'float' buffer for output synthesis, MAX_OUTPUT_CHANNELS channels */ +#else float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; /* 'float' buffer for output synthesis, MAX_OUTPUT_CHANNELS channels */ +#endif int16_t nchan_remapped; float output_lfe_ch[L_FRAME48k]; #ifndef OSBA_DISC_OBJ_MCT @@ -74,7 +78,11 @@ ivas_error ivas_dec( AUDIO_CONFIG output_config; float pan_left, pan_right; ivas_error error; +#ifdef OSBA_EXT_OUT + float *p_output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; +#else float *p_output[MAX_OUTPUT_CHANNELS]; +#endif #ifdef VLBR_20MS_MD int16_t num_md_sub_frames; #endif @@ -108,9 +116,13 @@ ivas_error ivas_dec( output_config = st_ivas->hDecoderConfig->output_config; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); + output_frame = ( int16_t )( output_Fs / FRAMES_PER_SEC ); +#ifdef OSBA_EXT_OUT + for ( n = 0; n < nchan_out; n++ ) +#else for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) +#endif { p_output[n] = &output[n][0]; } @@ -553,7 +565,7 @@ ivas_error ivas_dec( { for ( int c = 0; c < nchan; c++ ) { - int16_t val = (int16_t) ( output[c][t] + 0.5f ); + int16_t val = ( int16_t )( output[c][t] + 0.5f ); dbgwrite( &val, sizeof( int16_t ), 1, 1, "./res/TC_dec_core_out.raw" ); } } @@ -567,9 +579,11 @@ ivas_error ivas_dec( return error; } } - else + else /*HOA3 rendering for now*/ { - /* Todo OSBA: Implement other outputs. */ +#ifdef OSBA_EXT_OUT + ivas_sba_upmixer_renderer( st_ivas, &output[st_ivas->nchan_ism], output_frame ); +#endif } } #endif @@ -930,7 +944,7 @@ ivas_error ivas_dec( int16_t max_band; int16_t pcm_out; hSplitBinRend = &st_ivas->splitBinRend; - max_band = (int16_t) ( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 ); + max_band = ( int16_t )( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 ); pcm_out = ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; ivas_renderMultiBinToSplitBinaural( &hSplitBinRend->splitrend, diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 400428f82e..00a948b51a 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -105,7 +105,7 @@ ivas_error ivas_dec_setup( /* read the number of objects */ st_ivas->nchan_transport = 1; nchan_ism = 1; - k = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ); + k = ( int16_t )( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ); while ( st_ivas->bit_stream[k] && nchan_ism < MAX_NUM_OBJECTS ) { nchan_ism++; @@ -327,7 +327,7 @@ ivas_error ivas_dec_setup( /* read the number of objects */ st_ivas->nchan_transport = 1; nchan_ism = 1; - k = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - SID_FORMAT_NBITS; + k = ( int16_t )( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - SID_FORMAT_NBITS; while ( st_ivas->bit_stream[k] && nchan_ism < MAX_NUM_OBJECTS ) { nchan_ism++; @@ -342,7 +342,7 @@ ivas_error ivas_dec_setup( { k -= nchan_ism; /* SID metadata flags */ idx = st_ivas->bit_stream[k]; - st_ivas->ism_mode = (ISM_MODE) ( idx + 1 ); + st_ivas->ism_mode = ( ISM_MODE )( idx + 1 ); } if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) @@ -530,7 +530,7 @@ static ivas_error ivas_read_format( { #ifndef SBA_MODE_CLEANUP_2 int16_t tc_mode_offset; - tc_mode_offset = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC - 1 ); + tc_mode_offset = ( int16_t )( ivas_total_brate / FRAMES_PER_SEC - 1 ); idx = st_ivas->bit_stream[tc_mode_offset]; #endif if ( st_ivas->sba_analysis_order == 0 ) @@ -779,7 +779,15 @@ ivas_error ivas_init_decoder( if ( output_config == AUDIO_CONFIG_EXTERNAL ) { - if ( !( st_ivas->ism_mode == ISM_MODE_PARAM ) ) +#ifdef OSBA_EXT_OUT + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + hDecoderConfig->nchan_out = audioCfg2channels( AUDIO_CONFIG_HOA3 ); /*TODOfto: only hoa3 ouput for now*/ + hDecoderConfig->nchan_out += st_ivas->nchan_ism; + } + else +#endif + if ( !( st_ivas->ism_mode == ISM_MODE_PARAM ) ) { hDecoderConfig->nchan_out = st_ivas->nchan_transport; } @@ -794,6 +802,16 @@ ivas_error ivas_init_decoder( ivas_output_init( &( st_ivas->hOutSetup ), output_config ); +#ifdef OSBA_EXT_OUT + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL ) + { + st_ivas->hOutSetup.ambisonics_order = SBA_HOA3_ORDER; + st_ivas->intern_config = AUDIO_CONFIG_HOA3; + st_ivas->hOutSetup.output_config = AUDIO_CONFIG_HOA3; + st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels( AUDIO_CONFIG_HOA3 ); + } +#endif + /* Only initialize transport setup if it is used */ if ( st_ivas->transport_config != AUDIO_CONFIG_INVALID ) { @@ -993,7 +1011,7 @@ ivas_error ivas_init_decoder( st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands; } - ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, ( int16_t )( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); } st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); @@ -1177,7 +1195,7 @@ ivas_error ivas_init_decoder( st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands; } - ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, ( int16_t )( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); } st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index cdcc6d2582..839a1d78f3 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -397,7 +397,11 @@ void ivas_renderer_select( #endif { *renderer_type = RENDERER_DIRAC; +#ifdef OSBA_EXT_OUT + if ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && +#else if ( st_ivas->ivas_format == SBA_FORMAT && +#endif ( output_config != AUDIO_CONFIG_5_1 && output_config != AUDIO_CONFIG_5_1_2 && output_config != AUDIO_CONFIG_5_1_4 && output_config != AUDIO_CONFIG_7_1 && output_config != AUDIO_CONFIG_7_1_4 && output_config != AUDIO_CONFIG_LS_CUSTOM && output_config != AUDIO_CONFIG_MONO && output_config != AUDIO_CONFIG_STEREO ) ) { if ( output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_FOA ) diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 643c7b5a6c..45e7d24b3e 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -183,8 +183,8 @@ void ivas_mc2sba( } else { - azimuth = (int16_t) ( hIntSetup.ls_azimuth[idx_in] ); - elevation = (int16_t) ( hIntSetup.ls_elevation[idx_in] ); + azimuth = ( int16_t )( hIntSetup.ls_azimuth[idx_in] ); + elevation = ( int16_t )( hIntSetup.ls_elevation[idx_in] ); idx_in++; /* get HOA response for direction (ACN/SN3D)*/ @@ -406,13 +406,21 @@ void ivas_sba_upmixer_renderer( { float *output_f[MAX_OUTPUT_CHANNELS]; int16_t ch; +#ifdef OSBA_EXT_OUT + AUDIO_CONFIG output_config; + + output_config = ( st_ivas->ivas_format == SBA_ISM_FORMAT ? st_ivas->hOutSetup.output_config : st_ivas->hDecoderConfig->output_config ); +#endif for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) { output_f[ch] = output[ch]; } - +#ifdef OSBA_EXT_OUT + ivas_sba_linear_renderer( output_f, output_frame, st_ivas->hIntSetup.nchan_out_woLFE, output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); +#else 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 ); +#endif } pop_wmops(); @@ -654,7 +662,7 @@ static void debug_mode_dirac( #ifdef DEBUG_MODE_DIRAC_NOCORE for ( n = 0; n < nchan_transport; n++ ) { - sprintf( file_name, "./res/ivas_dirac_enc_%d.%d.pcm", n, (int16_t) ( output_frame * 0.05 ) ); + sprintf( file_name, "./res/ivas_dirac_enc_%d.%d.pcm", n, ( int16_t )( output_frame * 0.05 ) ); dbgread( tmp, sizeof( int16_t ), output_frame, file_name ); for ( i = 0; i < output_frame; i++ ) { @@ -666,10 +674,10 @@ static void debug_mode_dirac( { for ( i = 0; i < output_frame; i++ ) { - tmp[i] = (int16_t) ( output[n][i] + 0.5f ); + tmp[i] = ( int16_t )( output[n][i] + 0.5f ); } - sprintf( file_name, "./res/ivas_dirac_dec_%d.%d.pcm", n, (int16_t) ( output_frame * 0.05 ) ); + sprintf( file_name, "./res/ivas_dirac_dec_%d.%d.pcm", n, ( int16_t )( output_frame * 0.05 ) ); dbgwrite( tmp, sizeof( int16_t ), output_frame, 1, file_name ); } #endif diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 231a1c5509..a81355e45d 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -399,6 +399,10 @@ static IVAS_DEC_BS_FORMAT mapIvasFormat( return IVAS_DEC_BS_MC; case SBA_FORMAT: return IVAS_DEC_BS_SBA; +#ifdef OSBA_EXT_OUT + case SBA_ISM_FORMAT: + return IVAS_DEC_BS_SBA_ISM; +#endif case MASA_FORMAT: return IVAS_DEC_BS_MASA; default: @@ -563,7 +567,7 @@ ivas_error IVAS_DEC_EnableVoIP( hIvasDec->hVoIP->speedFac = speedFac; hIvasDec->hVoIP->needNewFrame = false; #endif - hIvasDec->hVoIP->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + hIvasDec->hVoIP->nSamplesFrame = ( uint16_t )( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); hIvasDec->hVoIP->nSamplesAvailableNext = 0; hIvasDec->hVoIP->rendererType = JBM_RENDERER_NONE; hIvasDec->hVoIP->hFifoOut = NULL; @@ -735,7 +739,7 @@ ivas_error IVAS_DEC_GetSamples( st_ivas = hIvasDec->st_ivas; - *nOutSamples = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + *nOutSamples = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) { @@ -858,7 +862,7 @@ ivas_error IVAS_DEC_GetTcSamples( st_ivas = hIvasDec->st_ivas; - *nOutSamples = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + *nOutSamples = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) { @@ -995,11 +999,17 @@ ivas_error IVAS_DEC_GetNumObjects( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - +#ifdef OSBA_EXT_OUT + if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + *numObjects = hIvasDec->st_ivas->nchan_ism; + } +#else if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT ) { *numObjects = hIvasDec->st_ivas->hDecoderConfig->nchan_out; } +#endif else { *numObjects = 0; @@ -1080,13 +1090,20 @@ ivas_error IVAS_DEC_GetObjectMetadata( } st_ivas = hIvasDec->st_ivas; - +#ifdef OSBA_EXT_OUT + if ( st_ivas->ivas_format != ISM_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) +#else if ( st_ivas->ivas_format != ISM_FORMAT ) +#endif { return IVAS_ERR_WRONG_MODE; } +#ifdef OSBA_EXT_OUT + if ( objectIdx >= st_ivas->nchan_ism ) +#else if ( objectIdx >= st_ivas->hDecoderConfig->nchan_out ) +#endif { return IVAS_ERR_INVALID_INDEX; } @@ -1762,7 +1779,7 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( /* create data unit for primary copy in the frame */ dataUnit = JB4_AllocDataUnit( hIvasDec->hVoIP->hJBM ); - mvc2c( au, dataUnit->data, (int16_t) ( ( auSize + 7 ) / 8 ) ); + mvc2c( au, dataUnit->data, ( int16_t )( ( auSize + 7 ) / 8 ) ); dataUnit->dataSize = auSize; dataUnit->duration = 20; dataUnit->sequenceNumber = rtpSequenceNumber; @@ -1785,7 +1802,7 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( { /* create data unit for partial copy in the frame */ dataUnit = JB4_AllocDataUnit( hIvasDec->hVoIP->hJBM ); - mvc2c( au, dataUnit->data, (int16_t) ( ( auSize + 7 ) / 8 ) ); + mvc2c( au, dataUnit->data, ( int16_t )( ( auSize + 7 ) / 8 ) ); dataUnit->dataSize = auSize; dataUnit->duration = 20; dataUnit->sequenceNumber = rtpSequenceNumber; @@ -3193,7 +3210,7 @@ ivas_error IVAS_DEC_VoIP_reconfigure( { /* we still need the FIFO out buffer */ if ( pcmdsp_fifo_create( &hIvasDec->hVoIP->hFifoOut ) != 0 || - pcmdsp_fifo_init( hIvasDec->hVoIP->hFifoOut, (uint16_t) ( hDecoderConfig->output_Fs * 4 / FRAMES_PER_SEC ) /* 4 frames */, hDecoderConfig->nchan_out, sizeof( int16_t ) ) != 0 ) + pcmdsp_fifo_init( hIvasDec->hVoIP->hFifoOut, ( uint16_t )( hDecoderConfig->output_Fs * 4 / FRAMES_PER_SEC ) /* 4 frames */, hDecoderConfig->nchan_out, sizeof( int16_t ) ) != 0 ) { return IVAS_ERR_INIT_ERROR; } @@ -3202,7 +3219,7 @@ ivas_error IVAS_DEC_VoIP_reconfigure( else if ( hIvasDec->hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ) { if ( pcmdsp_fifo_create( &hIvasDec->hVoIP->hFifoOut ) != 0 || - pcmdsp_fifo_init( hIvasDec->hVoIP->hFifoOut, (uint16_t) ( hDecoderConfig->output_Fs * 4 / FRAMES_PER_SEC ) /* 4 frames */, hDecoderConfig->nchan_out, sizeof( int16_t ) ) != 0 ) + pcmdsp_fifo_init( hIvasDec->hVoIP->hFifoOut, ( uint16_t )( hDecoderConfig->output_Fs * 4 / FRAMES_PER_SEC ) /* 4 frames */, hDecoderConfig->nchan_out, sizeof( int16_t ) ) != 0 ) { return IVAS_ERR_INIT_ERROR; } diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 9edc1a130c..7b71a0833f 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -114,6 +114,9 @@ typedef enum _IVAS_DEC_BS_FORMAT IVAS_DEC_BS_STEREO, IVAS_DEC_BS_MC, IVAS_DEC_BS_SBA, +#ifdef OSBA_EXT_OUT + IVAS_DEC_BS_SBA_ISM, +#endif IVAS_DEC_BS_OBJ, IVAS_DEC_BS_MASA, IVAS_DEC_BS_UNKOWN = 0xffff -- GitLab From 08bf0447217769f2b5c3b122f173a22dc240ab3b Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Wed, 26 Jul 2023 18:52:15 +0200 Subject: [PATCH 026/109] clang format --- apps/decoder.c | 10 ++--- lib_dec/ivas_dec.c | 6 +-- lib_dec/ivas_dirac_dec.c | 6 +-- lib_dec/ivas_init_dec.c | 12 +++--- lib_dec/ivas_ism_metadata_dec.c | 2 +- lib_dec/ivas_sba_rendering_internal.c | 10 ++--- lib_dec/ivas_stat_dec.h | 56 +++++++++++++-------------- lib_dec/lib_dec.c | 14 +++---- lib_enc/ivas_mct_core_enc.c | 2 +- 9 files changed, 59 insertions(+), 59 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index c01547518c..71f0c19ff5 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1531,7 +1531,7 @@ static void usage_dec( void ) static int16_t app_own_random( int16_t *seed ) { - *seed = ( int16_t )( *seed * 31821L + 13849L ); + *seed = (int16_t) ( *seed * 31821L + 13849L ); return ( *seed ); } @@ -2507,9 +2507,9 @@ static ivas_error decodeVoIP( int16_t nOutSamples = 0; uint16_t nSamplesAvailableNext = 0; #ifdef DEBUG_JBM_CMD_OPTION - nOutSamples = ( int16_t )( arg.output_Fs / 1000 * arg.frontendFetchSizeMs ); + nOutSamples = (int16_t) ( arg.output_Fs / 1000 * arg.frontendFetchSizeMs ); #else - nOutSamples = ( int16_t )( arg.output_Fs / 1000 * JBM_FRONTEND_FETCH_FRAMESIZE_MS ); + nOutSamples = (int16_t) ( arg.output_Fs / 1000 * JBM_FRONTEND_FETCH_FRAMESIZE_MS ); #endif /* read all packets with a receive time smaller than the system time */ while ( nextPacketRcvTime_ms <= systemTime_ms ) @@ -2555,7 +2555,7 @@ static ivas_error decodeVoIP( /* we are finished when all packets have been received and jitter buffer is empty */ /* also stop when the input file contains less than two frames, because JBM cannot calculate a delay value and won't start decoding */ /* last clause should make sure that for BE tests we end up with the same number of samples...*/ - if ( nextPacketRcvTime_ms == ( uint32_t )( -1 ) && ( IVAS_DEC_VoIP_IsEmpty( hIvasDec, nOutSamples ) || nFramesFed < 2 ) ) + if ( nextPacketRcvTime_ms == (uint32_t) ( -1 ) && ( IVAS_DEC_VoIP_IsEmpty( hIvasDec, nOutSamples ) || nFramesFed < 2 ) ) { break; } @@ -2858,7 +2858,7 @@ static ivas_error decodeVariableSpeed( reset_wmops(); #endif nSamplesAvailableNext = 0; - nOutSamples = ( int16_t )( arg.output_Fs / 1000 * VARIABLE_SPEED_FETCH_FRAMESIZE_MS ); + nOutSamples = (int16_t) ( arg.output_Fs / 1000 * VARIABLE_SPEED_FETCH_FRAMESIZE_MS ); /*------------------------------------------------------------------------------------------* * Loop for every packet (frame) of bitstream data diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 84d7e3630f..c606e097ef 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -116,7 +116,7 @@ ivas_error ivas_dec( output_config = st_ivas->hDecoderConfig->output_config; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - output_frame = ( int16_t )( output_Fs / FRAMES_PER_SEC ); + output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); #ifdef OSBA_EXT_OUT for ( n = 0; n < nchan_out; n++ ) @@ -565,7 +565,7 @@ ivas_error ivas_dec( { for ( int c = 0; c < nchan; c++ ) { - int16_t val = ( int16_t )( output[c][t] + 0.5f ); + int16_t val = (int16_t) ( output[c][t] + 0.5f ); dbgwrite( &val, sizeof( int16_t ), 1, 1, "./res/TC_dec_core_out.raw" ); } } @@ -944,7 +944,7 @@ ivas_error ivas_dec( int16_t max_band; int16_t pcm_out; hSplitBinRend = &st_ivas->splitBinRend; - max_band = ( int16_t )( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 ); + max_band = (int16_t) ( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 ); pcm_out = ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; ivas_renderMultiBinToSplitBinaural( &hSplitBinRend->splitrend, diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 7027d1f011..1c6d9f6b89 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1013,10 +1013,10 @@ void ivas_dirac_dec_read_BS( IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata */ int16_t *nb_bits, /* o : number of bits read */ #ifdef OSBA_DISC_OBJ_MCT - const int16_t last_bit_pos, /* i : last read bitstream position*/ + const int16_t last_bit_pos, /* i : last read bitstream position*/ #endif - const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ - int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ + const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ + int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ ) { int16_t i, j, b, dir, orig_dirac_bands; diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 00a948b51a..5aa3a67074 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -105,7 +105,7 @@ ivas_error ivas_dec_setup( /* read the number of objects */ st_ivas->nchan_transport = 1; nchan_ism = 1; - k = ( int16_t )( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ); + k = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ); while ( st_ivas->bit_stream[k] && nchan_ism < MAX_NUM_OBJECTS ) { nchan_ism++; @@ -327,7 +327,7 @@ ivas_error ivas_dec_setup( /* read the number of objects */ st_ivas->nchan_transport = 1; nchan_ism = 1; - k = ( int16_t )( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - SID_FORMAT_NBITS; + k = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - SID_FORMAT_NBITS; while ( st_ivas->bit_stream[k] && nchan_ism < MAX_NUM_OBJECTS ) { nchan_ism++; @@ -342,7 +342,7 @@ ivas_error ivas_dec_setup( { k -= nchan_ism; /* SID metadata flags */ idx = st_ivas->bit_stream[k]; - st_ivas->ism_mode = ( ISM_MODE )( idx + 1 ); + st_ivas->ism_mode = (ISM_MODE) ( idx + 1 ); } if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) @@ -530,7 +530,7 @@ static ivas_error ivas_read_format( { #ifndef SBA_MODE_CLEANUP_2 int16_t tc_mode_offset; - tc_mode_offset = ( int16_t )( ivas_total_brate / FRAMES_PER_SEC - 1 ); + tc_mode_offset = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC - 1 ); idx = st_ivas->bit_stream[tc_mode_offset]; #endif if ( st_ivas->sba_analysis_order == 0 ) @@ -1011,7 +1011,7 @@ ivas_error ivas_init_decoder( st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands; } - ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, ( int16_t )( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); } st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); @@ -1195,7 +1195,7 @@ ivas_error ivas_init_decoder( st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands; } - ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, ( int16_t )( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); } st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index de686d14ef..1c23035426 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -279,7 +279,7 @@ ivas_error ivas_ism_metadata_dec( { #endif ism_imp[ch] = get_next_indice( st0, ISM_METADATA_FLAG_BITS ); -#ifdef OSBA_DISC_OBJ_MCT +#ifdef OSBA_DISC_OBJ_MCT } else { diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 45e7d24b3e..349e8d73bd 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -183,8 +183,8 @@ void ivas_mc2sba( } else { - azimuth = ( int16_t )( hIntSetup.ls_azimuth[idx_in] ); - elevation = ( int16_t )( hIntSetup.ls_elevation[idx_in] ); + azimuth = (int16_t) ( hIntSetup.ls_azimuth[idx_in] ); + elevation = (int16_t) ( hIntSetup.ls_elevation[idx_in] ); idx_in++; /* get HOA response for direction (ACN/SN3D)*/ @@ -662,7 +662,7 @@ static void debug_mode_dirac( #ifdef DEBUG_MODE_DIRAC_NOCORE for ( n = 0; n < nchan_transport; n++ ) { - sprintf( file_name, "./res/ivas_dirac_enc_%d.%d.pcm", n, ( int16_t )( output_frame * 0.05 ) ); + sprintf( file_name, "./res/ivas_dirac_enc_%d.%d.pcm", n, (int16_t) ( output_frame * 0.05 ) ); dbgread( tmp, sizeof( int16_t ), output_frame, file_name ); for ( i = 0; i < output_frame; i++ ) { @@ -674,10 +674,10 @@ static void debug_mode_dirac( { for ( i = 0; i < output_frame; i++ ) { - tmp[i] = ( int16_t )( output[n][i] + 0.5f ); + tmp[i] = (int16_t) ( output[n][i] + 0.5f ); } - sprintf( file_name, "./res/ivas_dirac_dec_%d.%d.pcm", n, ( int16_t )( output_frame * 0.05 ) ); + sprintf( file_name, "./res/ivas_dirac_dec_%d.%d.pcm", n, (int16_t) ( output_frame * 0.05 ) ); dbgwrite( tmp, sizeof( int16_t ), output_frame, 1, file_name ); } #endif diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 8d1210ece4..ea5bdbd0e9 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -84,11 +84,11 @@ typedef struct stereo_dft_dec_data_struct const float *dft_trigo_8k; int16_t dft_trigo_step; - int16_t dft32ms_ovl; /* Overlap size */ - const float *win32ms; /* DFT window */ - const float *win32ms_12k8; /* DFT window */ - const float *win32ms_16k; /* DFT window */ - const float *win32ms_8k; /* DFT window */ + int16_t dft32ms_ovl; /* Overlap size */ + const float *win32ms; /* DFT window */ + const float *win32ms_12k8; /* DFT window */ + const float *win32ms_16k; /* DFT window */ + const float *win32ms_8k; /* DFT window */ int16_t dft32ms_ovl2; /* Overlap2 size */ const float *win232ms; /* DFT window */ @@ -96,7 +96,7 @@ typedef struct stereo_dft_dec_data_struct const float *win232ms_16k; /* DFT window */ const float *win232ms_8k; /* DFT window */ - const float *win_8k; /* DFT window residual */ + const float *win_8k; /* DFT window residual */ /*Bands*/ int16_t band_res[STEREO_DFT_DEC_DFT_NB]; @@ -264,18 +264,18 @@ typedef struct stereo_td_dec_data_structure int16_t tdm_SM_flag; /* current channel combination scheme flag */ int16_t tdm_use_IAWB_Ave_lpc; /* Flag to indicate the usage of mean inactive LP coefficients */ - int16_t tdm_lp_reuse_flag; /* Flag that indicate if it is possible to reuse the LP coefficient from the primary channel or not */ - int16_t tdm_low_rate_mode; /* secondary channel low rate mode flag */ + int16_t tdm_lp_reuse_flag; /* Flag that indicate if it is possible to reuse the LP coefficient from the primary channel or not */ + int16_t tdm_low_rate_mode; /* secondary channel low rate mode flag */ float tdm_Pri_pitch_buf[NB_SUBFR]; int16_t tdm_Pitch_reuse_flag; int16_t tdm_LRTD_flag; - int16_t flag_skip_DMX; /* flag that indicates whether the TD downmixing is skipped */ + int16_t flag_skip_DMX; /* flag that indicates whether the TD downmixing is skipped */ float TCX_old_syn_Overl[L_FRAME16k / 2]; /* past ovrl buffer for possible switching from TD stereo ACELP to MDCT stereo TCX frame */ - float prevSP_ratio; /* previous SP ratio */ - float SP_ratio_LT; /* longterm SP ratio */ - float c_LR_LT; /* left-right cross-correlation */ + float prevSP_ratio; /* previous SP ratio */ + float SP_ratio_LT; /* longterm SP ratio */ + float c_LR_LT; /* left-right cross-correlation */ } STEREO_TD_DEC_DATA, *STEREO_TD_DEC_DATA_HANDLE; @@ -295,7 +295,7 @@ typedef struct stereo_mdct_dec_data_structure int16_t global_ild[2]; /* Quantized ILD for the whole spectrum */ int16_t split_ratio; /* Ratio of bitrate (1 to 7), split_ratio = 8 * 1st chn bitrate / (1st + 2nd chn bitrate) */ - int16_t IGFStereoMode[2]; /* MDCT stereo mode for IGF */ + int16_t IGFStereoMode[2]; /* MDCT stereo mode for IGF */ int16_t use_itd; int16_t itd_mode; /*0/1*/ @@ -319,21 +319,21 @@ typedef struct stereo_mdct_dec_data_structure typedef struct stereo_tca_dec_data_structure { - int16_t refChanIndx; /* reference channel index in current frame */ - int16_t prevRefChanIndx; /* reference channel index in previous frame */ - int16_t indx_ica_NCShift; /* ICA target channel inter-channel corrstats */ - int16_t indx_ica_gD; /* ICA target gain */ - float targetGain; /* gain norm applied on target (or right) channel in current frame */ - float prevTargetGain; /* gain norm applied on target (or right) channel in previous frame */ + int16_t refChanIndx; /* reference channel index in current frame */ + int16_t prevRefChanIndx; /* reference channel index in previous frame */ + int16_t indx_ica_NCShift; /* ICA target channel inter-channel corrstats */ + int16_t indx_ica_gD; /* ICA target gain */ + float targetGain; /* gain norm applied on target (or right) channel in current frame */ + float prevTargetGain; /* gain norm applied on target (or right) channel in previous frame */ - int16_t corrLagStats; /* corr lag stats in current frame */ - int16_t prevCorrLagStats; /* corr lag stats in previous frame */ + int16_t corrLagStats; /* corr lag stats in current frame */ + int16_t prevCorrLagStats; /* corr lag stats in previous frame */ int16_t interp_dec_prevNCShift; /* NC Shift in previous frame */ int16_t interp_dec_switch_to_zero_diff; /* switch flag for interpolation */ - float memChanL[L_DEC_MEM_LEN_ICA]; /* left channel input to correct at the cross-over */ - float memChanR[L_DEC_MEM_LEN_ICA]; /* right channel input to correct at the cross-over */ + float memChanL[L_DEC_MEM_LEN_ICA]; /* left channel input to correct at the cross-over */ + float memChanR[L_DEC_MEM_LEN_ICA]; /* right channel input to correct at the cross-over */ } STEREO_TCA_DEC_DATA, *STEREO_TCA_DEC_HANDLE; @@ -446,7 +446,7 @@ typedef struct dirac_output_synthesis_cov_state_structure float *diffuse_power_factor; /* only pointer to local buffers */ - float *direct_responses; /* direct responses for DOA of current frame. Size: num_freq_bands*num_channels. */ + float *direct_responses; /* direct responses for DOA of current frame. Size: num_freq_bands*num_channels. */ float *direct_responses_square; float *diffuse_responses_square; /* squared diffuse responses. Size: num_channels. */ @@ -718,8 +718,8 @@ typedef struct cpe_dec_data_structure int32_t element_brate; /* CPE element total bitrate in bps */ int32_t last_element_brate; /* last CPE element total bitrate in bps */ - int16_t element_mode; /* element mode, in CPE it can be IVAS_CPE_DFT, IVAS_CPE_TD or IVAS_CPE_MDCT */ - int16_t last_element_mode; /* last element mode */ + int16_t element_mode; /* element mode, in CPE it can be IVAS_CPE_DFT, IVAS_CPE_TD or IVAS_CPE_MDCT */ + int16_t last_element_mode; /* last element mode */ int16_t stereo_switching_counter; int16_t NbFrameMod; @@ -737,7 +737,7 @@ typedef struct cpe_dec_data_structure STEREO_ICBWE_DEC_HANDLE hStereoICBWE; /* Stereo inter-channel BWE data handle */ STEREO_CNG_DEC_HANDLE hStereoCng; /* Stereo CNG data structure */ - int16_t nchan_out; /* number of output channels (1: mono dmx, 2: default stereo) */ + int16_t nchan_out; /* number of output channels (1: mono dmx, 2: default stereo) */ float prev_hb_synth[CPE_CHANNELS][NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS )]; float prev_synth[CPE_CHANNELS][NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS )]; @@ -770,7 +770,7 @@ typedef struct mct_dec_block_data_struct typedef struct mct_dec_data_structure { - int16_t nchan_out_woLFE; /* number of active channels within multi-channel configuration */ + int16_t nchan_out_woLFE; /* number of active channels within multi-channel configuration */ int16_t currBlockDataCnt; int16_t bitsChannelPairIndex; /* bits needed to code channel pair index, depends on number of active channels */ MCT_DEC_BLOCK_DATA_HANDLE hBlockData[MCT_MAX_BLOCKS]; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index a81355e45d..75c7303be6 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -567,7 +567,7 @@ ivas_error IVAS_DEC_EnableVoIP( hIvasDec->hVoIP->speedFac = speedFac; hIvasDec->hVoIP->needNewFrame = false; #endif - hIvasDec->hVoIP->nSamplesFrame = ( uint16_t )( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + hIvasDec->hVoIP->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ); hIvasDec->hVoIP->nSamplesAvailableNext = 0; hIvasDec->hVoIP->rendererType = JBM_RENDERER_NONE; hIvasDec->hVoIP->hFifoOut = NULL; @@ -739,7 +739,7 @@ ivas_error IVAS_DEC_GetSamples( st_ivas = hIvasDec->st_ivas; - *nOutSamples = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + *nOutSamples = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) { @@ -862,7 +862,7 @@ ivas_error IVAS_DEC_GetTcSamples( st_ivas = hIvasDec->st_ivas; - *nOutSamples = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + *nOutSamples = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) { @@ -1779,7 +1779,7 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( /* create data unit for primary copy in the frame */ dataUnit = JB4_AllocDataUnit( hIvasDec->hVoIP->hJBM ); - mvc2c( au, dataUnit->data, ( int16_t )( ( auSize + 7 ) / 8 ) ); + mvc2c( au, dataUnit->data, (int16_t) ( ( auSize + 7 ) / 8 ) ); dataUnit->dataSize = auSize; dataUnit->duration = 20; dataUnit->sequenceNumber = rtpSequenceNumber; @@ -1802,7 +1802,7 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( { /* create data unit for partial copy in the frame */ dataUnit = JB4_AllocDataUnit( hIvasDec->hVoIP->hJBM ); - mvc2c( au, dataUnit->data, ( int16_t )( ( auSize + 7 ) / 8 ) ); + mvc2c( au, dataUnit->data, (int16_t) ( ( auSize + 7 ) / 8 ) ); dataUnit->dataSize = auSize; dataUnit->duration = 20; dataUnit->sequenceNumber = rtpSequenceNumber; @@ -3210,7 +3210,7 @@ ivas_error IVAS_DEC_VoIP_reconfigure( { /* we still need the FIFO out buffer */ if ( pcmdsp_fifo_create( &hIvasDec->hVoIP->hFifoOut ) != 0 || - pcmdsp_fifo_init( hIvasDec->hVoIP->hFifoOut, ( uint16_t )( hDecoderConfig->output_Fs * 4 / FRAMES_PER_SEC ) /* 4 frames */, hDecoderConfig->nchan_out, sizeof( int16_t ) ) != 0 ) + pcmdsp_fifo_init( hIvasDec->hVoIP->hFifoOut, (uint16_t) ( hDecoderConfig->output_Fs * 4 / FRAMES_PER_SEC ) /* 4 frames */, hDecoderConfig->nchan_out, sizeof( int16_t ) ) != 0 ) { return IVAS_ERR_INIT_ERROR; } @@ -3219,7 +3219,7 @@ ivas_error IVAS_DEC_VoIP_reconfigure( else if ( hIvasDec->hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ) { if ( pcmdsp_fifo_create( &hIvasDec->hVoIP->hFifoOut ) != 0 || - pcmdsp_fifo_init( hIvasDec->hVoIP->hFifoOut, ( uint16_t )( hDecoderConfig->output_Fs * 4 / FRAMES_PER_SEC ) /* 4 frames */, hDecoderConfig->nchan_out, sizeof( int16_t ) ) != 0 ) + pcmdsp_fifo_init( hIvasDec->hVoIP->hFifoOut, (uint16_t) ( hDecoderConfig->output_Fs * 4 / FRAMES_PER_SEC ) /* 4 frames */, hDecoderConfig->nchan_out, sizeof( int16_t ) ) != 0 ) { return IVAS_ERR_INIT_ERROR; } diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 4de7baa0b5..7a10b3f35b 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -201,7 +201,7 @@ void ivas_mct_core_enc( int16_t ch, ch_core, nSubframes, L_subframeTCX; int16_t i, cpe_id, n, nAvailBits; int16_t nCPE; - float *orig_spectrum[MCT_MAX_CHANNELS][2]; /* Pointers to MDCT output for a short block (L/R) */ + float *orig_spectrum[MCT_MAX_CHANNELS][2]; /* Pointers to MDCT output for a short block (L/R) */ float powerSpec[MCT_MAX_CHANNELS][L_FRAME48k]; float powerSpecMsInv_long[MCT_MAX_CHANNELS][L_FRAME48k]; /* MS inv power spectrum, also inverse MDST spectrum */ float *powerSpecMsInv[MCT_MAX_CHANNELS][2]; -- GitLab From 0c91e966ad5c05b747bbf83223c5ba7fa9dac7a0 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 27 Jul 2023 14:39:12 +0200 Subject: [PATCH 027/109] fix clang errors introduced under OSBA_EXT_OUT --- lib_dec/ivas_dec.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index c606e097ef..a536fe919b 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -119,13 +119,23 @@ ivas_error ivas_dec( output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); #ifdef OSBA_EXT_OUT - for ( n = 0; n < nchan_out; n++ ) -#else - for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) -#endif + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL ) + { + for ( n = 0; n < nchan_out; n++ ) + { + p_output[n] = &output[n][0]; + } + } + else { - p_output[n] = &output[n][0]; +#endif + for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) + { + p_output[n] = &output[n][0]; + } +#ifdef OSBA_EXT_OUT } +#endif /*----------------------------------------------------------------* * Combine orientations -- GitLab From a720c3f3c77898dcf93290106ebac71992622952 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 31 Jul 2023 16:21:58 +0200 Subject: [PATCH 028/109] correct setting of channels getNumChanSynthesis() --- lib_dec/ivas_init_dec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 5aa3a67074..afb9503d2d 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -572,7 +572,11 @@ int16_t getNumChanSynthesis( { n = CPE_CHANNELS; } +#ifdef SBA_AND_OBJECTS + else if ( (st_ivas->hMCT != NULL || st_ivas->ivas_format == SBA_FORMAT) && st_ivas->ivas_format != SBA_ISM_FORMAT ) +#else else if ( st_ivas->hMCT != NULL || st_ivas->ivas_format == SBA_FORMAT ) +#endif { n = st_ivas->nchan_transport; } -- GitLab From dac1a86dec131799623fb40647a248123371d507 Mon Sep 17 00:00:00 2001 From: rhb Date: Mon, 31 Jul 2023 17:14:36 +0200 Subject: [PATCH 029/109] first version of mono and stereo output for OSBA --- lib_com/ivas_cnst.h | 3 ++ lib_com/options.h | 1 + lib_dec/ivas_dec.c | 48 +++++++++++++++++++++++++++++ lib_dec/ivas_init_dec.c | 13 ++++++-- lib_dec/ivas_mct_dec.c | 17 +++++++++- lib_dec/ivas_mono_dmx_renderer.c | 11 +++++++ lib_dec/ivas_osba_dec.c | 7 +++++ lib_dec/ivas_output_config.c | 10 ++++++ lib_dec/ivas_sba_dirac_stereo_dec.c | 32 ++++++++++++++++++- 9 files changed, 138 insertions(+), 4 deletions(-) mode change 100644 => 100755 lib_com/ivas_cnst.h mode change 100644 => 100755 lib_dec/ivas_dec.c mode change 100644 => 100755 lib_dec/ivas_init_dec.c mode change 100644 => 100755 lib_dec/ivas_mono_dmx_renderer.c mode change 100644 => 100755 lib_dec/ivas_osba_dec.c mode change 100644 => 100755 lib_dec/ivas_output_config.c mode change 100644 => 100755 lib_dec/ivas_sba_dirac_stereo_dec.c diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h old mode 100644 new mode 100755 index 997e1ea221..9cdef34059 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -162,6 +162,9 @@ typedef enum RENDERER_BINAURAL_MIXER_CONV, RENDERER_BINAURAL_MIXER_CONV_ROOM, RENDERER_NON_DIEGETIC_DOWNMIX +#ifdef OSBA_MONO_STEREO_OUTPUT + , RENDERER_OSBA_STEREO +#endif } RENDERER_TYPE; diff --git a/lib_com/options.h b/lib_com/options.h index d6aefb4700..00173af579 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -216,6 +216,7 @@ #define OSBA_DISC_OBJ_MCT #define ENABLE_ISM_MD_CODING #define OSBA_EXT_OUT +#define OSBA_MONO_STEREO_OUTPUT #endif /* ################## End BE DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c old mode 100644 new mode 100755 index a536fe919b..85a3173316 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -560,6 +560,28 @@ ivas_error ivas_dec( return error; } +#ifdef OSBA_MONO_STEREO_OUTPUT + if ( st_ivas->sba_dirac_stereo_flag ) + { + ivas_agc_dec_process( st_ivas->hSpar->hAgcDec, &output[st_ivas->nchan_ism], &output[st_ivas->nchan_ism], st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); + + if ( st_ivas->hSpar->hPCA != NULL ) + { + ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &output[st_ivas->nchan_ism] ); + } + + ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, + ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate +#ifdef VLBR_20MS_MD + , + st_ivas->last_active_ivas_total_brate +#endif + ) ); + + ivas_sba_dirac_stereo_dec( st_ivas, &output[st_ivas->nchan_ism], output_frame, 0 ); + } +#endif + /* HP filtering */ for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) /*TODOfto:check what needs to be filtered here*/ { @@ -589,6 +611,32 @@ ivas_error ivas_dec( return error; } } +#ifdef OSBA_MONO_STEREO_OUTPUT + else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC && ( st_ivas->renderer_type == RENDERER_OSBA_STEREO || st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) ) + { + if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) + { + ivas_mono_downmix_render_passive( st_ivas, output, output_frame ); + } + else /* stereo output */ + { + /* shift SBA channels to avoid overwrite by ISM upmix in 1 object case */ + if ( nchan_ism == 1 ) + { + mvr2r( output[2], output[3], output_frame ); + mvr2r( output[1], output[2], output_frame ); + } + ivas_ism_render( st_ivas, p_output, output_frame ); + } + + for ( n = 0; n < nchan_out; n++ ) + { + v_add( output[n], output[n + max(nchan_out, nchan_ism)], output[n], output_frame ); + } + + //ivas_sba_upmixer_renderer( st_ivas, &output[st_ivas->nchan_ism], output_frame ); + } +#endif else /*HOA3 rendering for now*/ { #ifdef OSBA_EXT_OUT diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c old mode 100644 new mode 100755 index 5aa3a67074..2a7de33050 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1199,8 +1199,6 @@ ivas_error ivas_init_decoder( st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); } st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); - - #endif st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; @@ -1692,11 +1690,19 @@ ivas_error ivas_init_decoder( } } +#ifdef OSBA_MONO_STEREO_OUTPUT + if ( ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && + ( st_ivas->ism_mode == ISM_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) && +#else if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_DISC && +#endif ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || +#ifdef OSBA_MONO_STEREO_OUTPUT + st_ivas->renderer_type == RENDERER_OSBA_STEREO || +#endif st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) @@ -2421,6 +2427,9 @@ void ivas_init_dec_get_num_cldfb_instances( case RENDERER_BINAURAL_MIXER_CONV_ROOM: case RENDERER_BINAURAL_FASTCONV: case RENDERER_BINAURAL_FASTCONV_ROOM: +#ifdef OSBA_MONO_STEREO_OUTPUT + case RENDERER_OSBA_STEREO: +#endif #ifdef OSBA_DISC_OBJ_MCT if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) #else diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 40c10a2842..5640751f36 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -160,7 +160,11 @@ ivas_error ivas_mct_dec( ivas_mct_core_dec( hMCT, st_ivas->hCPE, nCPE, output ); /* for sba to stereo output disable any further processing for TCs > 2 as it is not needed*/ +#ifdef OSBA_MONO_STEREO_OUTPUT + if ( st_ivas->sba_dirac_stereo_flag && st_ivas->ivas_format != SBA_ISM_FORMAT ) +#else if ( st_ivas->sba_dirac_stereo_flag ) +#endif { for ( cpe_id = 1; cpe_id < nCPE; cpe_id++ ) { @@ -226,14 +230,21 @@ ivas_error ivas_mct_dec( for ( n = 0; n < CPE_CHANNELS; n++ ) { - +#ifdef OSBA_MONO_STEREO_OUTPUT + if ( st_ivas->sba_dirac_stereo_flag && ( st_ivas->ivas_format != SBA_ISM_FORMAT || cpe_id >= nCPE - 2 ) ) +#else if ( st_ivas->sba_dirac_stereo_flag ) +#endif { ivas_post_proc( NULL, hCPE, n, synth[n], NULL, output_frame, 1 ); } /* Postprocessing for ACELP/MDCT core switching and synchronization */ +#ifdef OSBA_MONO_STEREO_OUTPUT + if ( ( error = core_switching_post_dec( sts[n], synth[n], output[cpe_id * CPE_CHANNELS + n], hCPE->output_mem[1], st_ivas->ivas_format, 0, output_frame, 0 /*core_switching_flag*/, (st_ivas->ivas_format != SBA_ISM_FORMAT || cpe_id >= nCPE - 2) ? st_ivas->sba_dirac_stereo_flag : 0, -1, hCPE->last_element_mode ) ) != IVAS_ERR_OK ) +#else if ( ( error = core_switching_post_dec( sts[n], synth[n], output[cpe_id * CPE_CHANNELS + n], hCPE->output_mem[1], st_ivas->ivas_format, 0, output_frame, 0 /*core_switching_flag*/, st_ivas->sba_dirac_stereo_flag, -1, hCPE->last_element_mode ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -254,7 +265,11 @@ ivas_error ivas_mct_dec( /* synthesis synchronization between stereo modes */ +#ifdef OSBA_MONO_STEREO_OUTPUT + if ( !st_ivas->sba_dirac_stereo_flag || ( st_ivas->ivas_format == SBA_ISM_FORMAT && cpe_id < nCPE - 2 ) ) +#else if ( !st_ivas->sba_dirac_stereo_flag ) +#endif { synchro_synthesis( ivas_total_brate, hCPE, output + cpe_id * CPE_CHANNELS, output_frame, 0 ); } diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c old mode 100644 new mode 100755 index d4dcb7ac73..bbe319ccff --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -93,7 +93,18 @@ void ivas_mono_downmix_render_passive( float proto_signal[L_FRAME48k], eq; MONO_DOWNMIX_RENDERER_HANDLE hDownmix; +#ifdef OSBA_MONO_STEREO_OUTPUT + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + numInputChannels = st_ivas->nchan_ism; + } + else + { + numInputChannels = st_ivas->nSCE; + } +#else numInputChannels = st_ivas->nSCE; +#endif hDownmix = st_ivas->hMonoDmxRenderer; set_zero( proto_signal, output_frame ); diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c old mode 100644 new mode 100755 index b3858a60c4..b4602c85ad --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -282,6 +282,13 @@ ivas_error ivas_omasa_dirac_td_binaural( return IVAS_ERR_OK; } + +#ifdef OSBA_MONO_STEREO_OUTPUT + +#endif + + + ivas_error ivas_osba_ism_metadata_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int32_t ism_total_brate, /* i : ISM total bitrate */ diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c old mode 100644 new mode 100755 index 839a1d78f3..c50ac2dc85 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -439,6 +439,16 @@ void ivas_renderer_select( { *renderer_type = RENDERER_SBA_LINEAR_DEC; } +#ifdef OSBA_MONO_STEREO_OUTPUT + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_STEREO ) + { + *renderer_type = RENDERER_OSBA_STEREO; + } + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_MONO ) + { + *renderer_type = RENDERER_MONO_DOWNMIX; + } +#endif } else if ( st_ivas->ivas_format == MC_FORMAT ) { diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c old mode 100644 new mode 100755 index f743f2072b..6edc2fae4a --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -78,6 +78,15 @@ int16_t ivas_get_sba_dirac_stereo_flag( } } } +#ifdef OSBA_MONO_STEREO_OUTPUT + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + if ( output_config == AUDIO_CONFIG_STEREO ) + { + sba_dirac_stereo_flag = 1; + } + } +#endif return sba_dirac_stereo_flag; } @@ -849,7 +858,11 @@ void ivas_sba_dirac_stereo_dec( memOffset = NS2SA( output_frame * FRAMES_PER_SEC, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); ivas_sba_dirac_stereo_config( hStereoDft->hConfig ); - hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, st_ivas->hDecoderConfig->output_Fs, hStereoDft->NFFT, ( st_ivas->ivas_format == SBA_FORMAT && !mcmasa ) ); +#ifdef OSBA_MONO_STEREO_OUTPUT + hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, st_ivas->hDecoderConfig->output_Fs, hStereoDft->NFFT, ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !mcmasa ) ); +#else + hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, st_ivas->hDecoderConfig->output_Fs, hStereoDft->NFFT, ( st_ivas->ivas_format == SBA_FORMAT && !mcmasa) ); +#endif stereo_dft_dec_update( hStereoDft, output_frame, 1 /*st_ivas->sba_dirac_stereo_flag*/ ); if ( st_ivas->nchan_transport > 1 ) { @@ -873,9 +886,18 @@ void ivas_sba_dirac_stereo_dec( /* mapping of DirAC parameters (azimuth, elevation, diffuseness) to DFT Stereo parameters (side gain, prediction gain) */ map_params_dirac_to_stereo( hStereoDft, st_ivas->hQMetaData, tmp_synth, DFT[0], st_ivas->ivas_format == MC_FORMAT, +#ifdef OSBA_MONO_STEREO_OUTPUT + ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ) ? hSCE->hCoreCoder[0]->L_frame : output_frame, + ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ) ); +#else ( st_ivas->ivas_format != SBA_FORMAT || mcmasa ) ? hSCE->hCoreCoder[0]->L_frame : output_frame, ( st_ivas->ivas_format != SBA_FORMAT || mcmasa ) ); +#endif +#ifdef OSBA_MONO_STEREO_OUTPUT + if ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !mcmasa ) +#else if ( st_ivas->ivas_format == SBA_FORMAT && !mcmasa ) +#endif { set_f( hStereoDft->res_pred_gain, 1.f, 3 * STEREO_DFT_BAND_MAX ); } @@ -923,7 +945,11 @@ void ivas_sba_dirac_stereo_dec( ivas_sba_dirac_stereo_compute_hb_gain( hStereoDft, hb_gain ); ivas_sba_dirac_stereo_upmix_hb( hb_synth_stereo, hSCE->save_hb_synth, hb_gain, output_frame, +#ifdef OSBA_MONO_STEREO_OUTPUT + ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ), sba_mono_flag, hSCE->hCoreCoder[0]->bwidth, hStereoDft ); +#else ( st_ivas->ivas_format != SBA_FORMAT || mcmasa ), sba_mono_flag, hSCE->hCoreCoder[0]->bwidth, hStereoDft ); +#endif /* add HB to ACELP core */ v_add( output[0], hb_synth_stereo[0], output[0], output_frame ); @@ -932,7 +958,11 @@ void ivas_sba_dirac_stereo_dec( v_add( output[1], hb_synth_stereo[1], output[1], output_frame ); /* apply TD Stereo Filling as is done in ICBWE */ +#ifdef OSBA_MONO_STEREO_OUTPUT + ivas_sba_dirac_stereo_apply_td_stefi( hStereoDft, output, output_frame, ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !mcmasa ) ); +#else ivas_sba_dirac_stereo_apply_td_stefi( hStereoDft, output, output_frame, ( st_ivas->ivas_format == SBA_FORMAT && !mcmasa ) ); +#endif } } -- GitLab From 9eb545175cd4676cc3191183fba534db6d535c85 Mon Sep 17 00:00:00 2001 From: rhb Date: Mon, 31 Jul 2023 17:22:25 +0200 Subject: [PATCH 030/109] small cleanup --- lib_dec/ivas_dec.c | 2 -- lib_dec/ivas_osba_dec.c | 6 ------ 2 files changed, 8 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 85a3173316..cd558c435e 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -633,8 +633,6 @@ ivas_error ivas_dec( { v_add( output[n], output[n + max(nchan_out, nchan_ism)], output[n], output_frame ); } - - //ivas_sba_upmixer_renderer( st_ivas, &output[st_ivas->nchan_ism], output_frame ); } #endif else /*HOA3 rendering for now*/ diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index b4602c85ad..7217770f25 100755 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -283,12 +283,6 @@ ivas_error ivas_omasa_dirac_td_binaural( } -#ifdef OSBA_MONO_STEREO_OUTPUT - -#endif - - - ivas_error ivas_osba_ism_metadata_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int32_t ism_total_brate, /* i : ISM total bitrate */ -- GitLab From a1c0144a646762aae2eb14e7868e9251b646faf2 Mon Sep 17 00:00:00 2001 From: rhb Date: Tue, 1 Aug 2023 15:20:03 +0200 Subject: [PATCH 031/109] another fix for EXT_OUT --- lib_dec/ivas_dirac_dec.c | 4 ++++ 1 file changed, 4 insertions(+) mode change 100644 => 100755 lib_dec/ivas_dirac_dec.c diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c old mode 100644 new mode 100755 index 1c6d9f6b89..13b223c0fa --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2403,7 +2403,11 @@ void ivas_dirac_dec_render_sf( st_ivas->cldfbSynDec[ch] ); } } +#ifdef OSBA_EXT_OUT + else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) +#else else if ( st_ivas->ivas_format == SBA_FORMAT ) +#endif { for ( ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE; ch++ ) { -- GitLab From 5643df9bbdc915d0d4185792ad8bc7752cb4b205 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Tue, 1 Aug 2023 16:36:16 +0200 Subject: [PATCH 032/109] initialize hMasaIsmData->delayBuffer --- lib_dec/ivas_osba_dec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 7217770f25..6f1717509d 100755 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -62,6 +62,8 @@ ivas_error ivas_masa_ism_data_open( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA ISM data\n" ) ); } + hMasaIsmData->delayBuffer = NULL; + #if 0 for ( bin = 0; bin < CLDFB_NO_CHANNELS_MAX; bin++ ) { @@ -77,7 +79,6 @@ ivas_error ivas_masa_ism_data_open( } hMasaIsmData->objectsMoved = 0; - hMasaIsmData->delayBuffer = NULL; for ( ch = 0; ch < st_ivas->nchan_ism; ch++ ) { -- GitLab From aec28e419c9bf879d0de9aaaa12e2f855f264f21 Mon Sep 17 00:00:00 2001 From: rhb Date: Tue, 1 Aug 2023 16:43:05 +0200 Subject: [PATCH 033/109] implement Ambisonics output for OSBA --- lib_com/ivas_cnst.h | 4 +++- lib_com/options.h | 1 + lib_dec/ivas_dec.c | 26 ++++++++++++++++++++++++++ lib_dec/ivas_dirac_dec.c | 3 +++ lib_dec/ivas_init_dec.c | 6 ++++++ lib_dec/ivas_output_config.c | 16 ++++++++++++---- 6 files changed, 51 insertions(+), 5 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 9cdef34059..0f1727dcbf 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -165,7 +165,9 @@ typedef enum #ifdef OSBA_MONO_STEREO_OUTPUT , RENDERER_OSBA_STEREO #endif - +#ifdef OSBA_AMBISONICS_OUT + , RENDERER_OSBA_AMBI +#endif } RENDERER_TYPE; /*----------------------------------------------------------------------------------* diff --git a/lib_com/options.h b/lib_com/options.h index 00173af579..f5bb68602d 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -217,6 +217,7 @@ #define ENABLE_ISM_MD_CODING #define OSBA_EXT_OUT #define OSBA_MONO_STEREO_OUTPUT +#define OSBA_AMBISONICS_OUT #endif /* ################## End BE DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index cd558c435e..62230bdb0c 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -634,6 +634,32 @@ ivas_error ivas_dec( v_add( output[n], output[n + max(nchan_out, nchan_ism)], output[n], output_frame ); } } +#endif +#ifdef OSBA_AMBISONICS_OUT + else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI ) + { + float tmp_ism_out[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + float *p_tmp_ism_out[MAX_OUTPUT_CHANNELS]; + + for ( n = 0; n < nchan_out; n++ ) + { + p_tmp_ism_out[n] = &tmp_ism_out[n][0]; + } + + for ( n = 0; n < nchan_ism; n++ ) + { + mvr2r( output[n], tmp_ism_out[n], output_frame ); + } + + ivas_ism2sba( p_tmp_ism_out, st_ivas->hIsmRendererData, st_ivas->hIsmMetaData, st_ivas->nchan_ism, output_frame, st_ivas->hIntSetup.ambisonics_order ); + + ivas_sba_upmixer_renderer( st_ivas, &output[st_ivas->nchan_ism], output_frame ); + + for ( n = 0; n < nchan_out; n++ ) + { + v_add( output[n + nchan_ism], tmp_ism_out[n], output[n], output_frame ); + } + } #endif else /*HOA3 rendering for now*/ { diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 13b223c0fa..7f64b693a2 100755 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -849,6 +849,9 @@ ivas_error ivas_dirac_dec_config( case RENDERER_BINAURAL_FASTCONV_ROOM: case RENDERER_SBA_LINEAR_ENC: case RENDERER_SBA_LINEAR_DEC: +#ifdef OSBA_AMBISONICS_OUT + case RENDERER_OSBA_AMBI: +#endif need_dirac_rend = 1; break; default: diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 94f6461381..dd4486fd31 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1706,6 +1706,9 @@ ivas_error ivas_init_decoder( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || #ifdef OSBA_MONO_STEREO_OUTPUT st_ivas->renderer_type == RENDERER_OSBA_STEREO || +#endif +#ifdef OSBA_AMBISONICS_OUT + st_ivas->renderer_type == RENDERER_OSBA_AMBI || #endif st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || @@ -2434,6 +2437,9 @@ void ivas_init_dec_get_num_cldfb_instances( #ifdef OSBA_MONO_STEREO_OUTPUT case RENDERER_OSBA_STEREO: #endif +#ifdef OSBA_AMBISONICS_OUT + case RENDERER_OSBA_AMBI: +#endif #ifdef OSBA_DISC_OBJ_MCT if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) #else diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index c50ac2dc85..e5493cdb0b 100755 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -397,11 +397,7 @@ void ivas_renderer_select( #endif { *renderer_type = RENDERER_DIRAC; -#ifdef OSBA_EXT_OUT - if ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && -#else if ( st_ivas->ivas_format == SBA_FORMAT && -#endif ( output_config != AUDIO_CONFIG_5_1 && output_config != AUDIO_CONFIG_5_1_2 && output_config != AUDIO_CONFIG_5_1_4 && output_config != AUDIO_CONFIG_7_1 && output_config != AUDIO_CONFIG_7_1_4 && output_config != AUDIO_CONFIG_LS_CUSTOM && output_config != AUDIO_CONFIG_MONO && output_config != AUDIO_CONFIG_STEREO ) ) { if ( output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_FOA ) @@ -448,6 +444,18 @@ void ivas_renderer_select( { *renderer_type = RENDERER_MONO_DOWNMIX; } +#endif +#ifdef OSBA_AMBISONICS_OUT + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 ) ) + { + *renderer_type = RENDERER_OSBA_AMBI; + } +#endif +#ifdef OSBA_EXT_OUT + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL ) + { + *renderer_type = RENDERER_SBA_LINEAR_DEC; + } #endif } else if ( st_ivas->ivas_format == MC_FORMAT ) -- GitLab From 543a3317ca2b3862fe8300a62cdd4c0df145166d Mon Sep 17 00:00:00 2001 From: rhb Date: Tue, 1 Aug 2023 17:22:08 +0200 Subject: [PATCH 034/109] add scaling for Ambisonics output to align loudness with binaural output --- lib_dec/ivas_dec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 62230bdb0c..bcc2a2a225 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -658,6 +658,7 @@ ivas_error ivas_dec( for ( n = 0; n < nchan_out; n++ ) { v_add( output[n + nchan_ism], tmp_ism_out[n], output[n], output_frame ); + v_multc( output[n], 0.5f, output[n], output_frame ); } } #endif -- GitLab From ffb63b5046761211be703322d35dae857e27202e Mon Sep 17 00:00:00 2001 From: rhb Date: Wed, 2 Aug 2023 13:46:03 +0200 Subject: [PATCH 035/109] add another switch OSBA_LS_OUT that enables LS output for OSBA --- lib_com/ivas_cnst.h | 3 +++ lib_com/options.h | 1 + lib_dec/ivas_dec.c | 28 ++++++++++++++++++++++++++++ lib_dec/ivas_dirac_dec.c | 3 +++ lib_dec/ivas_init_dec.c | 6 ++++++ lib_dec/ivas_output_config.c | 6 ++++++ 6 files changed, 47 insertions(+) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 0f1727dcbf..5a285f44dd 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -168,6 +168,9 @@ typedef enum #ifdef OSBA_AMBISONICS_OUT , RENDERER_OSBA_AMBI #endif +#ifdef OSBA_LS_OUT + , RENDERER_OSBA_LS +#endif } RENDERER_TYPE; /*----------------------------------------------------------------------------------* diff --git a/lib_com/options.h b/lib_com/options.h index f5bb68602d..50390d3dd3 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -218,6 +218,7 @@ #define OSBA_EXT_OUT #define OSBA_MONO_STEREO_OUTPUT #define OSBA_AMBISONICS_OUT +#define OSBA_LS_OUT #endif /* ################## End BE DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index bcc2a2a225..53f2803866 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -662,6 +662,34 @@ ivas_error ivas_dec( } } #endif +#ifdef OSBA_LS_OUT + /* todo: almost the same path as for Ambisonics output. Should be merged at some point. */ + else if ( st_ivas->renderer_type == RENDERER_OSBA_LS ) + { + float tmp_ism_out[MAX_CICP_CHANNELS][L_FRAME48k]; + float *p_tmp_ism_out[MAX_CICP_CHANNELS]; + + for ( n = 0; n < nchan_out; n++ ) + { + p_tmp_ism_out[n] = &tmp_ism_out[n][0]; + } + + for ( n = 0; n < nchan_ism; n++ ) + { + mvr2r( output[n], tmp_ism_out[n], output_frame ); + } + + ivas_ism_render( st_ivas, p_tmp_ism_out, output_frame ); + + ivas_sba_upmixer_renderer( st_ivas, &output[st_ivas->nchan_ism], output_frame ); + + for ( n = 0; n < nchan_out; n++ ) + { + v_add( output[n + nchan_ism], tmp_ism_out[n], output[n], output_frame ); + v_multc( output[n], 0.5f, output[n], output_frame ); + } + } +#endif else /*HOA3 rendering for now*/ { #ifdef OSBA_EXT_OUT diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 7f64b693a2..005ee72271 100755 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -851,6 +851,9 @@ ivas_error ivas_dirac_dec_config( case RENDERER_SBA_LINEAR_DEC: #ifdef OSBA_AMBISONICS_OUT case RENDERER_OSBA_AMBI: +#endif +#ifdef OSBA_LS_OUT + case RENDERER_OSBA_LS: #endif need_dirac_rend = 1; break; diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index dd4486fd31..08dd311d68 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1709,6 +1709,9 @@ ivas_error ivas_init_decoder( #endif #ifdef OSBA_AMBISONICS_OUT st_ivas->renderer_type == RENDERER_OSBA_AMBI || +#endif +#ifdef OSBA_LS_OUT + st_ivas->renderer_type == RENDERER_OSBA_LS || #endif st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || @@ -2440,6 +2443,9 @@ void ivas_init_dec_get_num_cldfb_instances( #ifdef OSBA_AMBISONICS_OUT case RENDERER_OSBA_AMBI: #endif +#ifdef OSBA_LS_OUT + case RENDERER_OSBA_LS: +#endif #ifdef OSBA_DISC_OBJ_MCT if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) #else diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index e5493cdb0b..b4ac95c4f9 100755 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -451,6 +451,12 @@ void ivas_renderer_select( *renderer_type = RENDERER_OSBA_AMBI; } #endif +#ifdef OSBA_LS_OUT + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && ( output_config == AUDIO_CONFIG_5_1 || output_config == AUDIO_CONFIG_5_1_2 || output_config == AUDIO_CONFIG_5_1_4 || output_config == AUDIO_CONFIG_7_1 || output_config == AUDIO_CONFIG_7_1_4 || output_config == AUDIO_CONFIG_LS_CUSTOM ) ) + { + *renderer_type = RENDERER_OSBA_LS; + } +#endif #ifdef OSBA_EXT_OUT else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL ) { -- GitLab From 2b5f2160362afb4d3b7f6c5ae1d0de8402a6c4d4 Mon Sep 17 00:00:00 2001 From: rhb Date: Wed, 2 Aug 2023 16:49:59 +0200 Subject: [PATCH 036/109] add missing delay to ISMs for Ambisonics, LS and EXT output --- lib_dec/ivas_dec.c | 7 +++++++ lib_dec/ivas_init_dec.c | 11 +++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 53f2803866..170b745387 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -649,6 +649,7 @@ ivas_error ivas_dec( for ( n = 0; n < nchan_ism; n++ ) { mvr2r( output[n], tmp_ism_out[n], output_frame ); + delay_signal( tmp_ism_out[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); } ivas_ism2sba( p_tmp_ism_out, st_ivas->hIsmRendererData, st_ivas->hIsmMetaData, st_ivas->nchan_ism, output_frame, st_ivas->hIntSetup.ambisonics_order ); @@ -677,6 +678,7 @@ ivas_error ivas_dec( for ( n = 0; n < nchan_ism; n++ ) { mvr2r( output[n], tmp_ism_out[n], output_frame ); + delay_signal( tmp_ism_out[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); } ivas_ism_render( st_ivas, p_tmp_ism_out, output_frame ); @@ -693,6 +695,11 @@ ivas_error ivas_dec( else /*HOA3 rendering for now*/ { #ifdef OSBA_EXT_OUT + for ( n = 0; n < nchan_ism; n++ ) + { + delay_signal( output[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); + } + ivas_sba_upmixer_renderer( st_ivas, &output[st_ivas->nchan_ism], output_frame ); #endif } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 08dd311d68..0dbfbeb317 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1732,12 +1732,11 @@ ivas_error ivas_init_decoder( { return error; } - - /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ - if ( ( error = ivas_masa_ism_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } + } + /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ + if ( ( error = ivas_masa_ism_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; } } #endif -- GitLab From 8287eb9eff678f2c8c4f0e7dec7b1efc9cc300c7 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 3 Aug 2023 08:10:14 +0200 Subject: [PATCH 037/109] fix spar_to_dirac_write_idx for SBA_ISM_FORMAT --- lib_dec/ivas_dirac_dec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 005ee72271..86c2c52f69 100755 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -102,7 +102,11 @@ static ivas_error ivas_dirac_dec_config_internal( if ( flag_config == DIRAC_OPEN ) { - hDirAC->spar_to_dirac_write_idx = st_ivas->ivas_format == SBA_FORMAT ? DELAY_DIRAC_PARAM_DEC_SFR : 0; +#ifdef OSBA_DISC_OBJ_MCT + hDirAC->spar_to_dirac_write_idx = (st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) ? DELAY_DIRAC_PARAM_DEC_SFR : 0; +#else + hDirAC->spar_to_dirac_write_idx = st_ivas->ivas_format == SBA_FORMAT ? DELAY_DIRAC_PARAM_DEC_SFR : 0; +#endif hDirAC->dithering_seed = DIRAC_DITH_SEED; st_ivas->hDirAC = hDirAC; } -- GitLab From db38ab8aed2cb0b3478c9a51ae350afee5cb3fee Mon Sep 17 00:00:00 2001 From: rhb Date: Thu, 3 Aug 2023 15:52:59 +0200 Subject: [PATCH 038/109] replace some decoder files that weren't merged properly --- lib_dec/ivas_dec.c | 438 +++++++++++-- lib_dec/ivas_init_dec.c | 828 ++++++++++++++++++++++--- lib_dec/ivas_ism_metadata_dec.c | 183 +++++- lib_dec/ivas_mono_dmx_renderer.c | 20 + lib_dec/ivas_objectRenderer_internal.c | 41 +- lib_dec/ivas_output_config.c | 78 ++- lib_dec/ivas_stat_dec.h | 105 +++- lib_dec/lib_dec.c | 40 +- 8 files changed, 1538 insertions(+), 195 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 8a66e36024..43e5e961b9 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -61,19 +61,34 @@ ivas_error ivas_dec( ) { int16_t n, output_frame, nchan_out; - Decoder_State *st; /* used for bitstream handling */ + Decoder_State *st; /* used for bitstream handling */ +#ifdef OSBA_EXT_OUT + float output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; /* 'float' buffer for output synthesis, MAX_OUTPUT_CHANNELS channels */ +#else float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; /* 'float' buffer for output synthesis, MAX_OUTPUT_CHANNELS channels */ +#endif int16_t nchan_remapped; float output_lfe_ch[L_FRAME48k]; +#if defined MASA_AND_OBJECTS || defined OSBA_DISC_OBJ_MCT + int16_t nb_bits_metadata[MAX_SCE + 1]; +#else int16_t nb_bits_metadata[MAX_SCE]; +#endif int32_t output_Fs, ivas_total_brate; AUDIO_CONFIG output_config; float pan_left, pan_right; ivas_error error; +#ifdef OSBA_EXT_OUT + float *p_output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; +#else float *p_output[MAX_OUTPUT_CHANNELS]; +#endif #ifdef VLBR_20MS_MD int16_t num_md_sub_frames; #endif +#ifdef MASA_AND_OBJECTS + int32_t ism_total_brate; +#endif error = IVAS_ERR_OK; @@ -106,10 +121,24 @@ ivas_error ivas_dec( output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); - for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) +#ifdef OSBA_EXT_OUT + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL ) { - p_output[n] = &output[n][0]; + for ( n = 0; n < nchan_out; n++ ) + { + p_output[n] = &output[n][0]; + } + } + else + { +#endif + for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) + { + p_output[n] = &output[n][0]; + } +#ifdef OSBA_EXT_OUT } +#endif /*----------------------------------------------------------------* * Combine orientations @@ -124,10 +153,19 @@ ivas_error ivas_dec( if ( ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + assert( ( st_ivas->ivas_format != UNDEFINED_FORMAT && + st_ivas->ivas_format != MONO_FORMAT && + st_ivas->ivas_format != STEREO_FORMAT ) && + ( output_Fs == 48000 ) && "split binaural mode is currently supported with SBA, MASA, ISM, or MC formats and 48 kHz sampling rate only" ); +#else assert( ( st_ivas->ivas_format == SBA_FORMAT || + st_ivas->ivas_format == MASA_FORMAT || + st_ivas->ivas_format == ISM_FORMAT || ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode != ISM_MODE_PARAM ) || ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode != MC_MODE_MCMASA ) ) && ( output_Fs == 48000 ) && "split binaural mode is currently supported with SBA, discrete ISM, or MCT-MC formats and 48 kHz sampling rate only" ); +#endif ivas_set_split_rend_setup( &st_ivas->splitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, hSplitRendBits ); } #endif @@ -183,14 +221,24 @@ ivas_error ivas_dec( } else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hDirAC->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hDirAC->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt +#ifdef OSBA_DISC_OBJ_MCT + , + st_ivas->hSCE[0]->hCoreCoder[0] +#endif + ) ) != IVAS_ERR_OK ) { return error; } } else /* ISM_MODE_DISC */ { - if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt +#ifdef OSBA_DISC_OBJ_MCT + , + st_ivas->hSCE[0]->hCoreCoder[0] +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -494,6 +542,301 @@ ivas_error ivas_dec( ivas_sba_upmixer_renderer( st_ivas, output, output_frame ); /* Note: ivas_sba_linear_renderer() or ivas_dirac_dec() are called internally */ } } +#ifdef MASA_AND_OBJECTS + // Todo OMASA JBM: Check here for p_output vs. output and possibly also metadata indices + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + int16_t nchan_ism, nchan_transport_ism; + int16_t dirac_bs_md_write_idx; + + st = st_ivas->hCPE[0]->hCoreCoder[0]; + set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); + + /* Set the number of objects for the parametric rendering */ + dirac_bs_md_write_idx = 0; + if ( st_ivas->hDirAC != NULL ) /* TODO: should this check for st_ivas->hSpatParamRendCom != NULL ? */ + { + st_ivas->hSpatParamRendCom->numIsmDirections = 0; + if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC && st_ivas->ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ ) + { + st_ivas->hSpatParamRendCom->numIsmDirections = st_ivas->nchan_ism; + } + + dirac_bs_md_write_idx = st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx; /* Store the write-index for this frame */ + } + + /* MASA metadata decoding */ + if ( ( error = ivas_masa_decode( st_ivas, st, &nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Configuration of combined-format bit-budget distribution */ + ivas_set_surplus_brate_dec( st_ivas, &ism_total_brate ); + + st->bit_stream = &( st_ivas->bit_stream[( ism_total_brate / FRAMES_PER_SEC )] ); + + /* set ISM parameters and decode ISM metadata in OMASA format */ + if ( ( error = ivas_omasa_ism_metadata_dec( st_ivas, ism_total_brate, &nchan_ism, &nchan_transport_ism, dirac_bs_md_write_idx, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* decode ISM channels */ + for ( n = 0; n < nchan_transport_ism; n++ ) + { + if ( ( error = ivas_sce_dec( st_ivas, n, &output[st_ivas->nchan_transport + n], output_frame, nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* decode MASA channels */ + if ( ( error = ivas_cpe_dec( st_ivas, 0, output, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( st_ivas->hCPE[0]->nchan_out == 1 ) + { + mvr2r( output[0], output[1], output_frame ); /* Copy mono signal to stereo output channels */ + } + + /* HP filtering */ + for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) + { + hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + } + + /* Set edited object positions, if editing enabled */ + ivas_omasa_set_edited_objects( st_ivas ); + + /* Rendering */ + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) + { + if ( ( error = ivas_omasa_dirac_td_binaural( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, output, st_ivas->nchan_transport ); + } + } + else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) + { + ivas_mono_downmix_render_passive( st_ivas, output, output_frame ); + } + else if ( st_ivas->renderer_type == RENDERER_DIRAC ) + { + ivas_omasa_dirac_rend( st_ivas, output, output_frame ); + } + + /* external output */ + if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_EXTERNAL ) + { + /* sanity check in case of bitrate switching */ + if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for combined MASA and ISM format" ); + } + + /* in case of external rendering, rearrange the channels order */ + mvr2r( output[0], output[MAX_OUTPUT_CHANNELS - 2], output_frame ); + mvr2r( output[1], output[MAX_OUTPUT_CHANNELS - 1], output_frame ); + + for ( n = 0; n < nchan_transport_ism; n++ ) + { + mvr2r( output[st_ivas->nchan_transport + n], output[n], output_frame ); + } + mvr2r( output[MAX_OUTPUT_CHANNELS - 2], output[n], output_frame ); + mvr2r( output[MAX_OUTPUT_CHANNELS - 1], output[++n], output_frame ); + } + } +#endif +#ifdef OSBA_DISC_OBJ_MCT + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + int16_t nchan_ism, nchan_transport_ism; + int16_t dirac_bs_md_write_idx; + + set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); + nchan_transport_ism = 1; + + dirac_bs_md_write_idx = 0; + if ( st_ivas->hDirAC != NULL ) + { + dirac_bs_md_write_idx = st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx; /* Store the write-index for this frame */ /*TODOfto:this seems not to be needed?*/ + } +#ifdef ENABLE_ISM_MD_CODING + /* set ISM parameters and decode ISM metadata in OSBA format */ + if ( ( error = ivas_osba_ism_metadata_dec( st_ivas, ivas_total_brate, &nchan_ism, &nchan_transport_ism, dirac_bs_md_write_idx, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + + /* SBA metadata decoding */ + if ( ( error = ivas_spar_dec( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK ) + { + return error; + } + + st = st_ivas->hCPE[0]->hCoreCoder[0]; + + if ( ( error = ivas_mct_dec( st_ivas, output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + { + return error; + } + +#ifdef OSBA_MONO_STEREO_OUTPUT + if ( st_ivas->sba_dirac_stereo_flag ) + { + ivas_agc_dec_process( st_ivas->hSpar->hAgcDec, &output[st_ivas->nchan_ism], &output[st_ivas->nchan_ism], st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); + + if ( st_ivas->hSpar->hPCA != NULL ) + { + ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &output[st_ivas->nchan_ism] ); + } + + ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, + ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate +#ifdef VLBR_20MS_MD + , + st_ivas->last_active_ivas_total_brate +#endif + ) ); + + ivas_sba_dirac_stereo_dec( st_ivas, &output[st_ivas->nchan_ism], output_frame, 0 ); + } +#endif + + /* HP filtering */ + for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) /*TODOfto:check what needs to be filtered here*/ + { + hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + } + + nchan_remapped = ivas_sba_remapTCs( &output[st_ivas->nchan_ism], st_ivas, output_frame ); + +#ifdef DEBUG_OSBA + { + int16_t nchan = st_ivas->nchan_transport + st_ivas->nchan_ism; + for ( int t = 0; t < output_frame; t++ ) + { + for ( int c = 0; c < nchan; c++ ) + { + int16_t val = (int16_t) ( output[c][t] + 0.5f ); + dbgwrite( &val, sizeof( int16_t ), 1, 1, "./res/TC_dec_core_out.raw" ); + } + } + } +#endif + + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + { + if ( ( error = ivas_omasa_dirac_td_binaural( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#ifdef OSBA_MONO_STEREO_OUTPUT + else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC && ( st_ivas->renderer_type == RENDERER_OSBA_STEREO || st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) ) + { + if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) + { + ivas_mono_downmix_render_passive( st_ivas, output, output_frame ); + } + else /* stereo output */ + { + /* shift SBA channels to avoid overwrite by ISM upmix in 1 object case */ + if ( nchan_ism == 1 ) + { + mvr2r( output[2], output[3], output_frame ); + mvr2r( output[1], output[2], output_frame ); + } + ivas_ism_render( st_ivas, p_output, output_frame ); + } + + for ( n = 0; n < nchan_out; n++ ) + { + v_add( output[n], output[n + max(nchan_out, nchan_ism)], output[n], output_frame ); + } + } +#endif +#ifdef OSBA_AMBISONICS_OUT + else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI ) + { + float tmp_ism_out[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + float *p_tmp_ism_out[MAX_OUTPUT_CHANNELS]; + + for ( n = 0; n < nchan_out; n++ ) + { + p_tmp_ism_out[n] = &tmp_ism_out[n][0]; + } + + for ( n = 0; n < nchan_ism; n++ ) + { + mvr2r( output[n], tmp_ism_out[n], output_frame ); + delay_signal( tmp_ism_out[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); + } + + ivas_ism2sba( p_tmp_ism_out, st_ivas->hIsmRendererData, st_ivas->hIsmMetaData, st_ivas->nchan_ism, output_frame, st_ivas->hIntSetup.ambisonics_order ); + + ivas_sba_upmixer_renderer( st_ivas, &output[st_ivas->nchan_ism], output_frame ); + + for ( n = 0; n < nchan_out; n++ ) + { + v_add( output[n + nchan_ism], tmp_ism_out[n], output[n], output_frame ); + v_multc( output[n], 0.5f, output[n], output_frame ); + } + } +#endif +#ifdef OSBA_LS_OUT + /* todo: almost the same path as for Ambisonics output. Should be merged at some point. */ + else if ( st_ivas->renderer_type == RENDERER_OSBA_LS ) + { + float tmp_ism_out[MAX_CICP_CHANNELS][L_FRAME48k]; + float *p_tmp_ism_out[MAX_CICP_CHANNELS]; + + for ( n = 0; n < nchan_out; n++ ) + { + p_tmp_ism_out[n] = &tmp_ism_out[n][0]; + } + + for ( n = 0; n < nchan_ism; n++ ) + { + mvr2r( output[n], tmp_ism_out[n], output_frame ); + delay_signal( tmp_ism_out[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); + } + + ivas_ism_render( st_ivas, p_tmp_ism_out, output_frame ); + + ivas_sba_upmixer_renderer( st_ivas, &output[st_ivas->nchan_ism], output_frame ); + + for ( n = 0; n < nchan_out; n++ ) + { + v_add( output[n + nchan_ism], tmp_ism_out[n], output[n], output_frame ); + v_multc( output[n], 0.5f, output[n], output_frame ); + } + } +#endif + else /*HOA3 rendering for now*/ + { +#ifdef OSBA_EXT_OUT + for ( n = 0; n < nchan_ism; n++ ) + { + delay_signal( output[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); + } + + ivas_sba_upmixer_renderer( st_ivas, &output[st_ivas->nchan_ism], output_frame ); +#endif + } + } +#endif else if ( st_ivas->ivas_format == MC_FORMAT ) { st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; @@ -612,11 +955,16 @@ ivas_error ivas_dec( ivas_mc_paramupmix_dec( st_ivas, output ); /* HP filtering */ - for ( n = 0; n < st_ivas->nchan_transport; n++ ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) +#endif { - if ( n != LFE_CHANNEL ) + for ( n = 0; n < st_ivas->nchan_transport; n++ ) { - hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + if ( n != LFE_CHANNEL ) + { + hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + } } } @@ -629,45 +977,15 @@ ivas_error ivas_dec( #ifdef JBM_PARAMUPMIX if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { - ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output ); -#else - if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) - { #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - ivas_rend_crendProcessSplitBin( - st_ivas->hCrendWrapper, - st_ivas->intern_config, - st_ivas->hOutSetup.output_config, - &st_ivas->splitBinRend.splitrend.multiBinPoseData, - st_ivas->hDecoderConfig, - st_ivas->hCombinedOrientationData, - &st_ivas->hIntSetup, - st_ivas->hEFAPdata, - p_output, - output_Fs ); - } - else - { + if ( ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && + ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) #endif - if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, - st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, p_output, output_Fs -#ifdef SPLIT_REND_WITH_HEAD_ROT - , - 0 -#endif - ) ) != IVAS_ERR_OK ) - { - return error; - } -#ifdef SPLIT_REND_WITH_HEAD_ROT + { ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output ); } -#endif -#endif /* JBM_PARAMUPMIX */ } +#endif /* JBM_PARAMUPMIX */ else if ( st_ivas->renderer_type == RENDERER_MC ) { if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO ) || ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO ) ) @@ -850,20 +1168,32 @@ ivas_error ivas_dec( IVAS_DEC_SPLIT_REND_WRAPPER *hSplitBinRend; int16_t max_band; int16_t pcm_out; +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + int16_t td_input; + + td_input = st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC; +#endif hSplitBinRend = &st_ivas->splitBinRend; max_band = (int16_t) ( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 ); pcm_out = ( output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; - ivas_renderMultiBinToSplitBinaural( &hSplitBinRend->splitrend, - st_ivas->hHeadTrackData->Quaternions, - st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, - st_ivas->hRenderConfig->split_rend_config.codec, - hSplitBinRend->hSplitRendBits, - hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural, - hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural, - max_band, output, 1, - st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV, - pcm_out ); + if ( ( error = ivas_renderMultiBinToSplitBinaural( &hSplitBinRend->splitrend, + st_ivas->hHeadTrackData->Quaternions, + st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, + st_ivas->hRenderConfig->split_rend_config.codec, + hSplitBinRend->hSplitRendBits, + hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural, + hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural, + max_band, output, 1, +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + td_input, +#else + st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV, +#endif + pcm_out ) ) != IVAS_ERR_OK ) + { + return error; + } free( st_ivas->splitBinRend.hMultiBinCldfbData ); } @@ -902,6 +1232,10 @@ ivas_error ivas_dec( st_ivas->ini_active_frame++; } +#ifdef MASA_AND_OBJECTS + st_ivas->last_ivas_format = st_ivas->ivas_format; +#endif + #ifdef DEBUG_MODE_INFO dbgwrite( &st_ivas->bfi, sizeof( int16_t ), 1, output_frame, "res/bfi" ); dbgwrite( &st_ivas->BER_detect, sizeof( int16_t ), 1, output_frame, "res/BER_detect" ); diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 616069f25f..66dd843c19 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -53,7 +53,159 @@ static ivas_error ivas_read_format( Decoder_Struct *st_ivas, int16_t *num_bits_read ); static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas ); +#endif + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*-------------------------------------------------------------------* + * ivas_dec_reconfig_split_rend() + * + * IVAS decoder split rend reconfig + *-------------------------------------------------------------------*/ +static ivas_error ivas_dec_reconfig_split_rend( + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ +) +{ + ivas_error error; + int16_t cldfb_in, num_ch, ch, isCldfbNeeded, i, pcm_out; + SPLIT_REND_WRAPPER *hSplitRendWrapper; + CLDFB_TYPE cldfbMode; + + hSplitRendWrapper = &st_ivas->splitBinRend.splitrend; + pcm_out = ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + cldfb_in = 0; + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + cldfb_in = 1; + } + ivas_renderSplitGetMultiBinPoseData( + &st_ivas->hRenderConfig->split_rend_config, + &hSplitRendWrapper->multiBinPoseData, + st_ivas->hHeadTrackData->sr_pose_pred_axis ); + + isCldfbNeeded = 0; + cldfbMode = CLDFB_ANALYSIS; + if ( st_ivas->renderer_type != RENDERER_DISABLE ) + { + if ( cldfb_in == 0 ) + { + isCldfbNeeded = 1; + cldfbMode = CLDFB_ANALYSIS; + } + else if ( st_ivas->hRenderConfig->split_rend_config.codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && cldfb_in ) + { + isCldfbNeeded = 1; + cldfbMode = CLDFB_SYNTHESIS; + } + else if ( pcm_out && cldfb_in ) + { + isCldfbNeeded = 1; + cldfbMode = CLDFB_SYNTHESIS; + } + } + + if ( isCldfbNeeded == 1 && hSplitRendWrapper->hCldfbHandles == NULL ) + { + if ( ( hSplitRendWrapper->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) ); + } + + num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; + for ( ch = 0; ch < num_ch; ch++ ) + { + hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; + } + num_ch = hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; + + for ( ch = 0; ch < num_ch; ch++ ) + { + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), + cldfbMode, + st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not open CLDFB handles\n" ) ); + } + } + } + else if ( isCldfbNeeded == 0 && hSplitRendWrapper->hCldfbHandles != NULL ) + { + num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; + for ( ch = 0; ch < num_ch; ch++ ) + { + if ( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] != NULL ) + { + deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ); + hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; + } + } + free( hSplitRendWrapper->hCldfbHandles ); + hSplitRendWrapper->hCldfbHandles = NULL; + } + + if ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) + { + for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) + { + if ( hSplitRendWrapper->hTdRendHandles[i] != NULL ) + { + hSplitRendWrapper->hTdRendHandles[i]->HrFiltSet_p = NULL; + ivas_td_binaural_close( &hSplitRendWrapper->hTdRendHandles[i] ); + } + } + } + + return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------* + * ivas_dec_init_split_rend() + * + * IVAS decoder split rend init + *-------------------------------------------------------------------*/ +ivas_error ivas_dec_init_split_rend( + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ +) +{ + ivas_error error; + int16_t cldfb_in, pcm_out; + + pcm_out = ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + cldfb_in = 0; + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + cldfb_in = 1; + } + ivas_renderSplitGetMultiBinPoseData( + &st_ivas->hRenderConfig->split_rend_config, + &st_ivas->splitBinRend.splitrend.multiBinPoseData, + st_ivas->hHeadTrackData->sr_pose_pred_axis ); + if ( cldfb_in == 1 && ( st_ivas->splitBinRend.splitrend.multiBinPoseData.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) + { + if ( ( st_ivas->splitBinRend.hCldfbDataOut = (IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc( sizeof( IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for cldfb data out buffer\n" ) ); + } + } + + ivas_split_rend_choose_default_codec( &st_ivas->hRenderConfig->split_rend_config.codec, ( cldfb_in == 0 ), pcm_out ); + + error = ivas_split_renderer_open( &st_ivas->splitBinRend.splitrend, + &st_ivas->hRenderConfig->split_rend_config, + st_ivas->hDecoderConfig->output_Fs, + cldfb_in, pcm_out ); + + return error; +} +#endif /*-------------------------------------------------------------------* * ivas_dec_setup() @@ -72,6 +224,7 @@ ivas_error ivas_dec_setup( Decoder_State *st; int32_t ivas_total_brate; ivas_error error; + error = IVAS_ERR_OK; num_bits_read = 0; @@ -163,20 +316,95 @@ ivas_error ivas_dec_setup( /* reconfigure in case a change of operation mode is detected */ if ( ( ivas_total_brate > IVAS_SID_5k2 && ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) || ( st_ivas->ini_active_frame == 0 ) ) { - if ( st_ivas->ini_active_frame == 0 && ivas_total_brate != FRAME_NO_DATA && ivas_total_brate < MASA_STEREO_MIN_BITRATE && st_ivas->nCPE == 1 ) +#ifdef MASA_AND_OBJECTS + if ( st_ivas->last_ivas_format == MASA_FORMAT ) { - st_ivas->hCPE[0]->nchan_out = 1; +#endif + if ( st_ivas->ini_active_frame == 0 && ivas_total_brate != FRAME_NO_DATA && ivas_total_brate < MASA_STEREO_MIN_BITRATE && st_ivas->nCPE == 1 ) + { + st_ivas->hCPE[0]->nchan_out = 1; + } + else + { + if ( ( error = ivas_masa_dec_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#ifdef MASA_AND_OBJECTS } else { - if ( ( error = ivas_masa_dec_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_omasa_dec_config( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } +#endif + } + } + } +#ifdef MASA_AND_OBJECTS + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + st_ivas->nchan_transport = 2; /* always 2 MASA transport channels */ + + /* for the DISC mode the number of objects are written at the end of the bitstream, in the MASA metadata */ + st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1; + st_ivas->ism_mode = ivas_omasa_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ); + + if ( st_ivas->ini_frame > 0 ) + { + /* reconfigure in case a change of operation mode is detected */ + if ( ( ivas_total_brate > IVAS_SID_5k2 && ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) || ( st_ivas->ini_active_frame == 0 ) ) + { + if ( ( error = ivas_omasa_dec_config( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + } +#endif +#ifdef OSBA_DISC_OBJ_MCT + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + /* the number of objects is written at the end of the bitstream, in the SBA metadata */ + st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1; + + /* read Ambisonic (SBA) planar flag */ + st_ivas->sba_planar = st_ivas->bit_stream[num_bits_read]; + num_bits_read += SBA_PLANAR_BITS; + + /* read Ambisonic (SBA) order */ + st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; + st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; + + /* set Ambisonic (SBA) order used for analysis and coding */ + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); + + num_bits_read += SBA_ORDER_BITS; + if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate && ivas_total_brate > IVAS_SID_5k2 ) + { + if ( ( error = ivas_sba_dec_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; } } + else + { + ivas_sba_config( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init ); + } + + /*correct number of CPEs for discrete ISM coding*/ + if ( st_ivas->ini_frame > 0 && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; + } + + st_ivas->ism_mode = ISM_SBA_MODE_DISC; } +#endif else if ( st_ivas->ivas_format == MC_FORMAT ) { /* read MC configuration */ @@ -313,6 +541,17 @@ ivas_error ivas_dec_setup( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*-----------------------------------------------------------------* + * reconfig split rendering as renderer might change after bitrate switching + *-----------------------------------------------------------------*/ + if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + ivas_dec_reconfig_split_rend( st_ivas ); + } +#endif + /*-------------------------------------------------------------------* * Initialize decoder in the first good frame based on IVAS format * and number of transport channels @@ -404,14 +643,29 @@ static ivas_error ivas_read_format( { if ( st_ivas->bit_stream[*num_bits_read] ) { +#if defined OSBA_DISC_OBJ_MCT || defined MASA_AND_OBJECTS + ( *num_bits_read )++; +#ifdef OSBA_DISC_OBJ_MCT + if ( st_ivas->bit_stream[*num_bits_read] ) + { + st_ivas->ivas_format = SBA_ISM_FORMAT; + } + else +#endif + { +#ifdef MASA_AND_OBJECTS + st_ivas->ivas_format = MASA_ISM_FORMAT; +#endif + } +#else /* placeholder for combined format signaling */ ( *num_bits_read )++; +#endif } ( *num_bits_read )++; } - break; case 3: if ( st_ivas->bit_stream[*num_bits_read] ) @@ -423,6 +677,7 @@ static ivas_error ivas_read_format( st_ivas->ivas_format = SBA_FORMAT; } ( *num_bits_read )++; + break; } } @@ -525,11 +780,20 @@ int16_t getNumChanSynthesis( { n = CPE_CHANNELS; } +#ifdef SBA_AND_OBJECTS + else if ( (st_ivas->hMCT != NULL || st_ivas->ivas_format == SBA_FORMAT) && st_ivas->ivas_format != SBA_ISM_FORMAT ) +#else else if ( st_ivas->hMCT != NULL || st_ivas->ivas_format == SBA_FORMAT ) +#endif { n = st_ivas->nchan_transport; } - +#ifdef SBA_AND_OBJECTS + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + n = st_ivas->nchan_transport + st_ivas->nchan_ism; + } +#endif return n; } @@ -705,7 +969,11 @@ ivas_error ivas_init_decoder( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { +#ifdef MASA_AND_OBJECTS + int16_t i, n, k; +#else int16_t i, n; +#endif int16_t sce_id, cpe_id; int16_t numCldfbAnalyses, numCldfbSyntheses; int16_t granularity, n_channels_transport_jbm; @@ -714,6 +982,9 @@ ivas_error ivas_init_decoder( AUDIO_CONFIG output_config; DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; +#ifdef MASA_AND_OBJECTS + int32_t ism_total_brate; +#endif error = IVAS_ERR_OK; @@ -727,10 +998,26 @@ ivas_error ivas_init_decoder( if ( output_config == AUDIO_CONFIG_EXTERNAL ) { - if ( !( st_ivas->ism_mode == ISM_MODE_PARAM ) ) +#ifdef OSBA_EXT_OUT + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + hDecoderConfig->nchan_out = audioCfg2channels( AUDIO_CONFIG_HOA3 ); /*TODOfto: only hoa3 ouput for now*/ + hDecoderConfig->nchan_out += st_ivas->nchan_ism; + } + else +#endif +#ifdef MASA_AND_OBJECTS + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + hDecoderConfig->nchan_out = st_ivas->nchan_transport + st_ivas->nchan_ism; + } + else +#endif + if ( !( st_ivas->ism_mode == ISM_MODE_PARAM ) ) { hDecoderConfig->nchan_out = st_ivas->nchan_transport; } + st_ivas->hOutSetup.nchan_out_woLFE = hDecoderConfig->nchan_out; } @@ -742,6 +1029,16 @@ ivas_error ivas_init_decoder( ivas_output_init( &( st_ivas->hOutSetup ), output_config ); +#ifdef OSBA_EXT_OUT + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL ) + { + st_ivas->hOutSetup.ambisonics_order = SBA_HOA3_ORDER; + st_ivas->intern_config = AUDIO_CONFIG_HOA3; + st_ivas->hOutSetup.output_config = AUDIO_CONFIG_HOA3; + st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels( AUDIO_CONFIG_HOA3 ); + } +#endif + /* Only initialize transport setup if it is used */ if ( st_ivas->transport_config != AUDIO_CONFIG_INVALID ) { @@ -802,6 +1099,21 @@ ivas_error ivas_init_decoder( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*-----------------------------------------------------------------* + * Initialize split rendering + *-----------------------------------------------------------------*/ + if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + ivas_dec_init_split_rend( st_ivas ); + } + else + { + st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses = 1; + } +#endif + /*-----------------------------------------------------------------* * Allocate and initialize SCE/CPE and other handles *-----------------------------------------------------------------*/ @@ -994,6 +1306,11 @@ ivas_error ivas_init_decoder( } else if ( st_ivas->ivas_format == MASA_FORMAT ) { +#ifdef MASA_AND_OBJECTS + /* if we start in ISM_MODE_NONE in MASA_ISM, that appears as normal MASA, but we may change to a mode with ISMs */ + st_ivas->ism_extmeta_active = -1; + st_ivas->ism_extmeta_cnt = 0; +#endif if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) { return error; @@ -1038,6 +1355,226 @@ ivas_error ivas_init_decoder( /* set CNA/CNG flags */ ivas_sba_set_cna_cng_flag( st_ivas ); } +#ifdef OSBA_DISC_OBJ_MCT + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + int32_t temp_brate[MAX_SCE]; + st_ivas->ism_extmeta_active = -1; + st_ivas->ism_extmeta_cnt = 0; +#if 0 + if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* this is resetting the nSCE to 1 */ + if ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Todo Nokia: Renderer should be selected in ivas_renderer_select(), but currently the number of transport channels is not available at that point. + * Hence, a temporary fix was done here, which adjusts the renderer after the number of transports is known. Optimally, this should be fixed by + * reading the number of transports before the renderer is selected. */ + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->nchan_transport >= 3 ) + { + st_ivas->renderer_type = RENDERER_BINAURAL_FASTCONV; + st_ivas->intern_config = AUDIO_CONFIG_HOA3; + st_ivas->hIntSetup.output_config = AUDIO_CONFIG_HOA3; /* Todo: Check if this affects tdrend in some way. */ + } + + if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( error = ivas_dirac_dec_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + + st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; + + st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); +#else + if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->hOutSetup.is_loudspeaker_setup ) + { + if ( ( error = ivas_sba_get_hoa_dec_matrix( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA && st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO ) + { + if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) + { + return error; + } + + st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; + } + else + { + int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1]; + + st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); + if ( ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ) + { + st_ivas->hSpar->enc_param_start_band = 0; + + set_c( (int8_t *) st_ivas->hQMetaData->twoDirBands, (int8_t) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); + st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands; + } + + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); + } + st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); +#endif + + st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; + + st_ivas->element_mode_init = IVAS_CPE_MDCT; + + for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + { + if ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) + { + return error; + } + + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] ); + } + } + + if ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* set CNA/CNG flags */ + ivas_sba_set_cna_cng_flag( st_ivas ); +#if 1 /*TODOfto: is this neede for OSBA?*/ + if ( ( error = ivas_masa_ism_data_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + + } +#endif +#ifdef MASA_AND_OBJECTS + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + st_ivas->ism_extmeta_active = -1; + st_ivas->ism_extmeta_cnt = 0; + + if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) + { + return error; + } + + k = 0; + ism_total_brate = 0; + while ( k < SIZE_IVAS_BRATE_TBL && ivas_total_brate != ivas_brate_tbl[k] ) + { + k++; + } + + if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + { + /* one separated object */ + st_ivas->nSCE = 1; + + ism_total_brate = sep_object_brate[k - 2][0]; + if ( ( error = create_sce_dec( st_ivas, 0, ism_total_brate ) ) != IVAS_ERR_OK ) + { + return error; + } + + reset_indices_dec( st_ivas->hSCE[0]->hCoreCoder[0] ); + + if ( ( error = ivas_ism_metadata_dec_create( st_ivas, 1, NULL ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + int32_t temp_brate[MAX_SCE]; + st_ivas->nSCE = st_ivas->nchan_ism; /* number of objects */ + + for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) + { + temp_brate[sce_id] = sep_object_brate[k - 2][st_ivas->nSCE - 1]; + ism_total_brate += temp_brate[sce_id]; + + if ( ( error = create_sce_dec( st_ivas, sce_id, temp_brate[sce_id] ) ) != IVAS_ERR_OK ) + { + return error; + } + + reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] ); + } + + if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + if ( ( error = ivas_masa_dec_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( error = ivas_omasa_data_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + if ( ( error = create_cpe_dec( st_ivas, 0, ivas_total_brate - ism_total_brate ) ) != IVAS_ERR_OK ) + { + return error; + } + + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + reset_indices_dec( st_ivas->hCPE[0]->hCoreCoder[n] ); + } + } +#endif else if ( st_ivas->ivas_format == MC_FORMAT ) { if ( st_ivas->mc_mode == MC_MODE_MCT ) @@ -1188,7 +1725,11 @@ ivas_error ivas_init_decoder( } else { +#ifdef MASA_AND_OBJECTS + vbap_determine_gains( st_ivas->hVBAPdata, st_ivas->hLsSetupCustom->separate_ch_gains, 0, 0, 0 ); +#else vbap_determine_gains( st_ivas->hVBAPdata, st_ivas->hLsSetupCustom->separate_ch_gains, 0, 0 ); +#endif } } @@ -1280,41 +1821,12 @@ ivas_error ivas_init_decoder( /*-------------------------------------------------------------------* * Allocate and initialize rendering handles *--------------------------------------------------------------------*/ - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - ivas_renderSplitGetMultiBinPoseData( - &st_ivas->hRenderConfig->split_rend_config, - &st_ivas->splitBinRend.splitrend.multiBinPoseData, - st_ivas->hHeadTrackData->sr_pose_pred_axis ); - } -#endif if ( ( error = ivas_binRenderer_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - ivas_split_rend_choose_default_codec( &st_ivas->hRenderConfig->split_rend_config.codec, 0, - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); - - error = ivas_split_renderer_open( &st_ivas->splitBinRend.splitrend, - &st_ivas->hRenderConfig->split_rend_config, - hDecoderConfig->output_Fs, - 1, ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); - - if ( error != IVAS_ERR_OK ) - { - return error; - } - } -#endif } /* ParamISM is handled separately from other common config */ else if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) @@ -1348,29 +1860,6 @@ ivas_error ivas_init_decoder( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - ivas_split_rend_choose_default_codec( &st_ivas->hRenderConfig->split_rend_config.codec, 1, - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); - - ivas_renderSplitGetMultiBinPoseData( - &st_ivas->hRenderConfig->split_rend_config, - &st_ivas->splitBinRend.splitrend.multiBinPoseData, - st_ivas->hHeadTrackData->sr_pose_pred_axis ); - - error = ivas_split_renderer_open( &st_ivas->splitBinRend.splitrend, - &st_ivas->hRenderConfig->split_rend_config, - hDecoderConfig->output_Fs, 0, - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); - - if ( error != IVAS_ERR_OK ) - { - return error; - } - } -#endif if ( st_ivas->hDecoderConfig->voip_active ) { granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -1406,41 +1895,11 @@ ivas_error ivas_init_decoder( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT - int16_t num_poses; - if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - int16_t pcm_out; - pcm_out = ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; - ivas_split_rend_choose_default_codec( &st_ivas->hRenderConfig->split_rend_config.codec, 1, - pcm_out ); - - ivas_renderSplitGetMultiBinPoseData( - &st_ivas->hRenderConfig->split_rend_config, - &st_ivas->splitBinRend.splitrend.multiBinPoseData, - st_ivas->hHeadTrackData->sr_pose_pred_axis ); - - error = ivas_split_renderer_open( &st_ivas->splitBinRend.splitrend, - &st_ivas->hRenderConfig->split_rend_config, - hDecoderConfig->output_Fs, 0, pcm_out ); - if ( error != IVAS_ERR_OK ) - { - return error; - } - num_poses = st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses; - } - else - { - num_poses = 1; - } -#endif - if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs #ifdef SPLIT_REND_WITH_HEAD_ROT , - num_poses + st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses #endif ) ) != IVAS_ERR_OK ) { @@ -1487,11 +1946,54 @@ ivas_error ivas_init_decoder( } } +#ifdef MASA_AND_OBJECTS + if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + /* Allocate TD renderer for the objects in DISC mode */ + if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ + if ( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + if ( st_ivas->renderer_type == RENDERER_DIRAC && ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + { + /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ + if ( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } +#endif + +#if defined OSBA_MONO_STEREO_OUTPUT || defined OSBA_AMBISONICS_OUT || defined OSBA_LS_OUT + if ( ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && + ( st_ivas->ism_mode == ISM_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) && +#else if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_DISC && +#endif ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || +#ifdef OSBA_MONO_STEREO_OUTPUT + st_ivas->renderer_type == RENDERER_OSBA_STEREO || +#endif +#ifdef OSBA_AMBISONICS_OUT + st_ivas->renderer_type == RENDERER_OSBA_AMBI || +#endif +#ifdef OSBA_LS_OUT + st_ivas->renderer_type == RENDERER_OSBA_LS || +#endif st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) @@ -1501,6 +2003,24 @@ ivas_error ivas_init_decoder( return error; } } +#ifdef OSBA_DISC_OBJ_MCT + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + /* Allocate TD renderer for the objects in DISC mode */ + if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ + if ( ( error = ivas_masa_ism_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif /*-----------------------------------------------------------------* * LFE handles for rendering after rendering to adjust LFE delay to binaural filter delay @@ -1513,8 +2033,14 @@ ivas_error ivas_init_decoder( { if ( st_ivas->hBinRenderer->render_lfe ) { - /* Account for filterbank delay */ - binauralization_delay_ns += IVAS_FB_DEC_DELAY_NS; +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && + ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) +#endif + { + /* Account for filterbank delay */ + binauralization_delay_ns += IVAS_FB_DEC_DELAY_NS; + } } else { @@ -1562,7 +2088,11 @@ ivas_error ivas_init_decoder( } /* CLDFB Interpolation weights */ +#ifdef OSBA_DISC_OBJ_MCT + if ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !st_ivas->sba_dirac_stereo_flag && st_ivas->hDecoderConfig->nchan_out != 1 ) +#else if ( st_ivas->ivas_format == SBA_FORMAT && !st_ivas->sba_dirac_stereo_flag && st_ivas->hDecoderConfig->nchan_out != 1 ) +#endif { ivas_spar_get_cldfb_gains( st_ivas->hSpar, st_ivas->cldfbAnaDec[0], st_ivas->cldfbSynDec[0], hDecoderConfig ); } @@ -1818,9 +2348,17 @@ void ivas_initialize_handles_dec( #ifdef SPLIT_REND_WITH_HEAD_ROT st_ivas->splitBinRend.hMultiBinCldfbData = NULL; st_ivas->splitBinRend.hSplitRendBits = NULL; + st_ivas->splitBinRend.hCldfbDataOut = NULL; ivas_init_split_rend_handles( &st_ivas->splitBinRend.splitrend ); #endif +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + for ( i = 0; i < MAX_HEAD_ROT_POSES; i++ ) + { + st_ivas->hDiracDecBin[i] = NULL; + } +#else st_ivas->hDiracDecBin = NULL; +#endif st_ivas->hDirACRend = NULL; st_ivas->hSpatParamRendCom = NULL; st_ivas->hLsSetUpConversion = NULL; @@ -1835,6 +2373,9 @@ void ivas_initialize_handles_dec( st_ivas->hHrtfFastConv = NULL; st_ivas->hHrtfParambin = NULL; st_ivas->hoa_dec_mtx = NULL; +#if defined OSBA_DISC_OBJ_MCT || defined MASA_AND_OBJECTS + st_ivas->hMasaIsmData = NULL; +#endif st_ivas->hHeadTrackData = NULL; st_ivas->hHrtfTD = NULL; @@ -1920,7 +2461,11 @@ void ivas_destroy_dec( } /* ISM metadata handles */ +#ifdef MASA_AND_OBJECTS + ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 ); +#else ivas_ism_metadata_close( st_ivas->hIsmMetaData ); +#endif /* ISM renderer handle */ if ( st_ivas->hIsmRendererData != NULL ) @@ -1981,16 +2526,24 @@ void ivas_destroy_dec( #ifdef SPLIT_REND_WITH_HEAD_ROT /* Split binaural renderer handle */ ivas_split_renderer_close( &st_ivas->splitBinRend.splitrend ); + if ( st_ivas->splitBinRend.hCldfbDataOut != NULL ) + { + free( st_ivas->splitBinRend.hCldfbDataOut ); + } #endif /* Parametric binaural renderer handle */ +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); +#else ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); +#endif /* Crend handle */ ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) #ifdef SPLIT_REND_WITH_HEAD_ROT , - 1 + st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses #endif ); @@ -2013,6 +2566,15 @@ void ivas_destroy_dec( free( st_ivas->hMonoDmxRenderer ); st_ivas->hMonoDmxRenderer = NULL; } +#ifdef OSBA_DISC_OBJ_MCT + /* MASA ISM structure */ + ivas_masa_ism_data_close( &st_ivas->hMasaIsmData ); +#endif + +#ifdef MASA_AND_OBJECTS + /* OMASA structure */ + ivas_omasa_data_close( &st_ivas->hMasaIsmData ); +#endif /* Head track data handle */ ivas_headTrack_close( &st_ivas->hHeadTrackData ); @@ -2037,7 +2599,10 @@ void ivas_destroy_dec( /* CRend binaural renderer handle */ ivas_HRTF_CRend_binary_close( &st_ivas->hSetOfHRTF ); - +#ifdef FIX_1720_HRTF_FASTCONV + /* Fastconv HRTF memories */ + ivas_binaural_hrtf_close( &st_ivas->hHrtfFastConv ); +#endif /* Fastconv HRTF filters */ ivas_HRTF_fastconv_binary_close( &st_ivas->hHrtfFastConv ); @@ -2094,6 +2659,7 @@ void ivas_init_dec_get_num_cldfb_instances( case RENDERER_BINAURAL_PARAMETRIC: case RENDERER_BINAURAL_PARAMETRIC_ROOM: case RENDERER_STEREO_PARAMETRIC: +#ifdef MASA_AND_OBJECTS if ( st_ivas->nchan_transport == 1 ) { *numCldfbAnalyses = st_ivas->nchan_transport + 1; @@ -2103,8 +2669,60 @@ void ivas_init_dec_get_num_cldfb_instances( { *numCldfbAnalyses = st_ivas->nchan_transport + 1; } +#ifdef OSBA_DISC_OBJ_MCT + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + *numCldfbAnalyses += st_ivas->nchan_ism; + } + } +#endif + + if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + *numCldfbAnalyses += st_ivas->nchan_ism; + } + else if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + { + *numCldfbAnalyses = st_ivas->nchan_transport + 1; + } + } +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( st_ivas->hDiracDecBin[0]->useTdDecorr ) +#else + if ( st_ivas->hDiracDecBin->useTdDecorr ) +#endif + { + *numCldfbAnalyses += 2; + } + break; + case RENDERER_NON_DIEGETIC_DOWNMIX: + case RENDERER_MONO_DOWNMIX: + if ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + /* CLDFB not used in rendering */ + *numCldfbAnalyses = 0; + *numCldfbSyntheses = 0; + } + break; +#else + if ( st_ivas->nchan_transport == 1 ) + { + *numCldfbAnalyses = st_ivas->nchan_transport + 1; + } + if ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->hOutSetup.separateChannelEnabled ) + { + *numCldfbAnalyses = st_ivas->nchan_transport + 1; + } +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + if ( st_ivas->hDiracDecBin[0]->useTdDecorr ) +#else if ( st_ivas->hDiracDecBin->useTdDecorr ) +#endif { *numCldfbAnalyses += 2; } @@ -2118,6 +2736,7 @@ void ivas_init_dec_get_num_cldfb_instances( *numCldfbSyntheses = 0; } break; +#endif case RENDERER_DIRAC: if ( st_ivas->ivas_format == SBA_FORMAT ) { @@ -2177,7 +2796,20 @@ void ivas_init_dec_get_num_cldfb_instances( case RENDERER_BINAURAL_MIXER_CONV_ROOM: case RENDERER_BINAURAL_FASTCONV: case RENDERER_BINAURAL_FASTCONV_ROOM: +#ifdef OSBA_MONO_STEREO_OUTPUT + case RENDERER_OSBA_STEREO: +#endif +#ifdef OSBA_AMBISONICS_OUT + case RENDERER_OSBA_AMBI: +#endif +#ifdef OSBA_LS_OUT + case RENDERER_OSBA_LS: +#endif +#ifdef OSBA_DISC_OBJ_MCT + if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) +#else if ( st_ivas->ivas_format == SBA_FORMAT ) +#endif { if ( st_ivas->sba_dirac_stereo_flag ) { @@ -2343,6 +2975,16 @@ static ivas_error doSanityChecks_IVAS( } } +#ifdef MASA_AND_OBJECTS + if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC && output_config == AUDIO_CONFIG_EXTERNAL ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for combined MASA and ISM format" ); + } + } +#endif + #ifdef DEBUGGING if ( ( st_ivas->hDecoderConfig->force_rend == FORCE_TD_RENDERER ) && ( ( st_ivas->ivas_format != MC_FORMAT && st_ivas->ivas_format != ISM_FORMAT ) || ( output_config != AUDIO_CONFIG_BINAURAL && output_config != AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM ) || ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode != MC_MODE_MCT ) ) ) { diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index f5ed58974f..ee53527052 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -150,12 +150,18 @@ ivas_error ivas_ism_metadata_dec( const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */ int16_t *ism_extmeta_active, /* i/o: Extended metadata active in renderer */ int16_t *ism_extmeta_cnt /* i/o: Number of change frames observed */ +#ifdef OSBA_DISC_OBJ_MCT + , + DEC_CORE_HANDLE st0 +#endif ) { int16_t ch, nb_bits_start = 0, last_bit_pos; int16_t idx_radius; int32_t element_brate[MAX_NUM_OBJECTS], total_brate[MAX_NUM_OBJECTS]; +#ifndef OSBA_DISC_OBJ_MCT DEC_CORE_HANDLE st0; +#endif int16_t ism_extmeta_bitstream; int16_t non_diegetic_flag_global; float yaw, pitch, radius; @@ -178,7 +184,9 @@ ivas_error ivas_ism_metadata_dec( push_wmops( "ism_meta_dec" ); /* initialization */ +#ifndef OSBA_DISC_OBJ_MCT st0 = hSCE[0]->hCoreCoder[0]; +#endif ism_metadata_flag_global = 0; nchan_transport_prev = *nchan_transport; @@ -204,11 +212,23 @@ ivas_error ivas_ism_metadata_dec( /*----------------------------------------------------------------* * Read ISM common signaling *----------------------------------------------------------------*/ +#ifdef OSBA_DISC_OBJ_MCT + if ( ism_mode == ISM_SBA_MODE_DISC ) + { + /* number of objects was read in ivas_dec_setup() */ + st0->next_bit_pos += NO_BITS_MASA_ISM_NO_OBJ; + } + else +#endif +#ifdef MASA_AND_OBJECTS + if ( ism_mode != ISM_MASA_MODE_DISC && ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ ) +#endif + { + /* number of objects was read in ivas_dec_setup() */ + st0->next_bit_pos += nchan_ism; - /* number of objects was read in ivas_dec_setup() */ - st0->next_bit_pos += nchan_ism; - - ism_mode = ivas_ism_mode_select( nchan_ism, ism_total_brate ); + ism_mode = ivas_ism_mode_select( nchan_ism, ism_total_brate ); + } if ( ism_mode == ISM_MODE_PARAM ) { @@ -225,7 +245,11 @@ ivas_error ivas_ism_metadata_dec( } /* read extended metadata presence flag */ +#ifdef MASA_AND_OBJECTS + if ( ism_mode == ISM_MODE_DISC && ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) +#else if ( ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) +#endif { ism_extmeta_bitstream = get_next_indice( st0, ISM_EXTENDED_METADATA_BITS ); @@ -255,7 +279,24 @@ ivas_error ivas_ism_metadata_dec( /* Read ISM metadata flags (one per object) */ for ( ch = 0; ch < *nchan_transport; ch++ ) { - ism_imp[ch] = get_next_indice( st0, ISM_METADATA_FLAG_BITS ); +#ifdef OSBA_DISC_OBJ_MCT + if ( ism_mode == ISM_SBA_MODE_DISC ) + { + ism_imp[ch] = get_next_indice( st0, 1 ); +#endif + } + else +#ifdef MASA_AND_OBJECTS + if ( ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) + { + /* ISM importance flag is already read in ivas_masa_decode() */ + ism_imp[ch] = hIsmMeta[ch]->ism_imp; + } + else +#endif + { + ism_imp[ch] = get_next_indice( st0, ISM_METADATA_FLAG_BITS ); + } if ( ism_imp[ch] > ISM_NO_META ) { @@ -282,8 +323,17 @@ ivas_error ivas_ism_metadata_dec( { if ( ism_imp[ch] == ISM_NO_META ) { +#ifdef MASA_AND_OBJECTS /* low-rate ISM_NO_META frame */ - null_metadata_flag[ch] = get_next_indice( st0, ISM_METADATA_INACTIVE_FLAG_BITS ); + if ( ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) + { + null_metadata_flag[ch] = hIsmMeta[ch]->ism_md_null_flag; + } + else +#endif + { + null_metadata_flag[ch] = get_next_indice( st0, ISM_METADATA_INACTIVE_FLAG_BITS ); + } } } @@ -291,17 +341,31 @@ ivas_error ivas_ism_metadata_dec( { if ( ism_imp[ch] == ISM_NO_META ) { - if ( null_metadata_flag[ch] ) +#ifdef MASA_AND_OBJECTS + if ( ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) { - /* read the true ISM class */ - ism_imp[ch] = get_next_indice( st0, ISM_METADATA_FLAG_BITS ); + lowrate_metadata_flag[ch] = hIsmMeta[ch]->ism_md_lowrate_flag; + + if ( null_metadata_flag[ch] == 0 ) + { + ism_metadata_flag_global |= lowrate_metadata_flag[ch]; + } } else +#endif { - /* read presence of MD in low-rate ISM_NO_META frame flag */ - lowrate_metadata_flag[ch] = get_next_indice( st0, ISM_METADATA_INACTIVE_FLAG_BITS ); + if ( null_metadata_flag[ch] ) + { + /* read the true ISM class */ + ism_imp[ch] = get_next_indice( st0, ISM_METADATA_FLAG_BITS ); + } + else + { + /* read presence of MD in low-rate ISM_NO_META frame flag */ + lowrate_metadata_flag[ch] = get_next_indice( st0, ISM_METADATA_INACTIVE_FLAG_BITS ); - ism_metadata_flag_global |= lowrate_metadata_flag[ch]; + ism_metadata_flag_global |= lowrate_metadata_flag[ch]; + } } } } @@ -324,7 +388,14 @@ ivas_error ivas_ism_metadata_dec( for ( ch = 0; ch < nchan_ism; ch++ ) { hIsmMetaData = hIsmMeta[ch]; - if ( ism_mode == ISM_MODE_DISC ) + if ( ism_mode == ISM_MODE_DISC +#ifdef OSBA_DISC_OBJ_MCT + || ism_mode == ISM_SBA_MODE_DISC +#endif +#ifdef MASA_AND_OBJECTS + || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ +#endif + ) { nb_bits_start = st0->next_bit_pos; } @@ -410,7 +481,14 @@ ivas_error ivas_ism_metadata_dec( } } /* save number of metadata bits read */ - if ( ism_mode == ISM_MODE_DISC ) + if ( ism_mode == ISM_MODE_DISC +#ifdef OSBA_DISC_OBJ_MCT + || ism_mode == ISM_SBA_MODE_DISC +#endif +#ifdef MASA_AND_OBJECTS + || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ +#endif + ) { nb_bits_metadata[ch] = st0->next_bit_pos - nb_bits_start; } @@ -494,13 +572,55 @@ ivas_error ivas_ism_metadata_dec( hISMDTX.ism_dtx_hangover_cnt += 1; } +#ifdef OSBA_DISC_OBJ_MCT + if ( ism_mode == ISM_SBA_MODE_DISC ) + { + /* set the bitstream pointer to its original position */ + nb_bits_metadata[0] = st0->next_bit_pos; + st0->bit_stream = bstr_orig; + st0->next_bit_pos = next_bit_pos_orig; + + /* updates*/ + set_s( md_diff_flag, 1, nchan_ism ); + + update_last_metadata( nchan_ism, hIsmMeta, md_diff_flag ); + pop_wmops(); + return IVAS_ERR_OK; + } +#endif + +#ifdef MASA_AND_OBJECTS + if ( ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) + { + ism_metadata_flag_global = 1; + } +#endif + /*----------------------------------------------------------------* * Configuration and decision about bitrates per channel *----------------------------------------------------------------*/ if ( !bfi ) { - if ( ( error = ivas_ism_config( ism_total_brate, *nchan_transport, nchan_ism, hIsmMeta, ism_extmeta_bitstream, null_metadata_flag, ism_imp, element_brate, total_brate, nb_bits_metadata ) ) != IVAS_ERR_OK ) +#ifdef MASA_AND_OBJECTS + int16_t masa_ism_flag = 0; + if ( ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) + { + masa_ism_flag = 1; + + for ( ch = 0; ch < *nchan_transport; ch++ ) + { + element_brate[ch] = hSCE[ch]->element_brate; + } + } +#endif + + if ( ( error = ivas_ism_config( ism_total_brate, *nchan_transport, nchan_ism, hIsmMeta, ism_extmeta_bitstream, null_metadata_flag, ism_imp, element_brate, total_brate, nb_bits_metadata +#ifdef MASA_AND_OBJECTS + , + masa_ism_flag +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -510,7 +630,11 @@ ivas_error ivas_ism_metadata_dec( hIsmMeta[ch]->last_ism_metadata_flag = hIsmMeta[ch]->ism_metadata_flag; hSCE[ch]->hCoreCoder[0]->low_rate_mode = 0; +#ifdef MASA_AND_OBJECTS + if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) +#else if ( ism_mode == ISM_MODE_DISC ) +#endif { if ( ism_imp[ch] == ISM_NO_META && ( ( total_brate[ch] < ACELP_8k00 && element_brate[ch] < SCE_CORE_16k_LOW_LIMIT ) || ( total_brate[ch] <= ACELP_16k_LOW_LIMIT && element_brate[ch] >= SCE_CORE_16k_LOW_LIMIT ) ) ) @@ -519,7 +643,12 @@ ivas_error ivas_ism_metadata_dec( } } - hSCE[ch]->element_brate = element_brate[ch]; +#ifdef MASA_AND_OBJECTS + if ( ism_mode != ISM_MASA_MODE_DISC && ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ ) +#endif + { + hSCE[ch]->element_brate = element_brate[ch]; + } hSCE[ch]->hCoreCoder[0]->total_brate = total_brate[ch]; } @@ -605,13 +734,31 @@ ivas_error ivas_ism_metadata_dec_create( st_ivas->hIsmMetaData[ch]->last_azimuth = 0; st_ivas->hIsmMetaData[ch]->last_elevation = 0; +#ifdef MASA_AND_OBJECTS + st_ivas->hIsmMetaData[ch]->ism_imp = -1; + st_ivas->hIsmMetaData[ch]->ism_md_null_flag = 0; + st_ivas->hIsmMetaData[ch]->ism_md_lowrate_flag = 0; +#endif + ivas_ism_reset_metadata( st_ivas->hIsmMetaData[ch] ); } - if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, n_ISms, n_ISms, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL ) ) != IVAS_ERR_OK ) +#ifdef MASA_AND_OBJECTS + if ( element_brate_tmp != NULL ) { - return error; +#endif + if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, n_ISms, n_ISms, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL +#ifdef MASA_AND_OBJECTS + , + 0 +#endif + ) ) != IVAS_ERR_OK ) + { + return error; + } +#ifdef MASA_AND_OBJECTS } +#endif st_ivas->hISMDTX.ism_dtx_hangover_cnt = IVAS_ISM_DTX_HO_MAX; diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index d4dcb7ac73..956b52cdad 100755 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -94,6 +94,26 @@ void ivas_mono_downmix_render_passive( MONO_DOWNMIX_RENDERER_HANDLE hDownmix; numInputChannels = st_ivas->nSCE; +#ifdef OSBA_MONO_STEREO_OUTPUT + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + numInputChannels = st_ivas->nchan_ism; + } +#endif +#ifdef MASA_AND_OBJECTS + if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + { + numInputChannels = st_ivas->nchan_transport + 1; + } + else + { + numInputChannels = st_ivas->nchan_transport + st_ivas->nchan_ism; + } + } +#endif + hDownmix = st_ivas->hMonoDmxRenderer; set_zero( proto_signal, output_frame ); diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 3be8a2c62e..274e9fd268 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -53,8 +53,22 @@ ivas_error ivas_td_binaural_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { +#ifdef MASA_AND_OBJECTS + int16_t num_src; + + num_src = st_ivas->nchan_transport; + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + num_src = st_ivas->nchan_ism; + } + + return ivas_td_binaural_open_unwrap( &st_ivas->hHrtfTD, st_ivas->hDecoderConfig->output_Fs, num_src, st_ivas->ivas_format, + st_ivas->transport_config, st_ivas->hRenderConfig->directivity, st_ivas->hTransSetup, &st_ivas->hBinRendererTd, &st_ivas->binaural_latency_ns ); +#else + return ivas_td_binaural_open_unwrap( &st_ivas->hHrtfTD, st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport, st_ivas->ivas_format, st_ivas->transport_config, st_ivas->hRenderConfig->directivity, st_ivas->hTransSetup, &st_ivas->hBinRendererTd, &st_ivas->binaural_latency_ns ); +#endif } @@ -72,6 +86,17 @@ ivas_error ivas_td_binaural_renderer( ) { int16_t ism_md_subframe_update; +#if defined OSBA_DISC_OBJ_MCT || defined MASA_AND_OBJECTS + int16_t nchan_transport; +#endif + +#if defined OSBA_DISC_OBJ_MCT && defined MASA_AND_OBJECTS + nchan_transport = ( st_ivas->ism_mode == ISM_SBA_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) ? st_ivas->nchan_ism : st_ivas->nchan_transport; +#elif defined MASA_AND_OBJECTS + nchan_transport = ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ? st_ivas->nchan_ism : st_ivas->nchan_transport; +#elif defined OSBA_DISC_OBJ_MCT + nchan_transport = ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) ? st_ivas->nchan_ism : st_ivas->nchan_transport; +#endif if ( st_ivas->hDecoderConfig->Opt_delay_comp ) { @@ -81,10 +106,24 @@ ivas_error ivas_td_binaural_renderer( { ism_md_subframe_update = 2; } + +#ifdef MASA_AND_OBJECTS + if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + ism_md_subframe_update = 0; // ToDo (for Mikko-Ville): verify whether it should not be 2 + } +#endif + return ivas_td_binaural_renderer_unwrap( st_ivas->hReverb, st_ivas->transport_config, - st_ivas->hBinRendererTd, st_ivas->nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, + st_ivas->hBinRendererTd, +#if defined OSBA_DISC_OBJ_MCT || defined MASA_AND_OBJECTS + nchan_transport, +#else + st_ivas->nchan_transport, +#endif + LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData, ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->enableCombinedOrientation : NULL, ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->Quaternions : NULL, diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index abc9a9012d..52d1dd2d09 100755 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -90,7 +90,11 @@ void ivas_renderer_select( if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { #ifdef FIX_571_REVERB_NOT_ACTIVATED_ISM - if ( output_config == AUDIO_CONFIG_BINAURAL ) + if ( output_config == AUDIO_CONFIG_BINAURAL +#ifdef SPLIT_REND_WITH_HEAD_ROT + || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) #else if ( output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #endif @@ -147,7 +151,16 @@ void ivas_renderer_select( } } } - else if ( st_ivas->ivas_format == MASA_FORMAT || ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->nchan_transport <= 2 ) ) + else if ( st_ivas->ivas_format == MASA_FORMAT +#ifdef MASA_AND_OBJECTS + || st_ivas->ivas_format == MASA_ISM_FORMAT +#endif +#ifdef OSBA_DISC_OBJ_MCT + || ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) +#else + || ( st_ivas->ivas_format == SBA_FORMAT +#endif + && st_ivas->nchan_transport <= 2 ) ) { *internal_config = output_config; if ( output_config == AUDIO_CONFIG_BINAURAL @@ -163,7 +176,11 @@ void ivas_renderer_select( *renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM; } } +#ifdef OSBA_DISC_OBJ_MCT + else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) +#else else if ( st_ivas->ivas_format == SBA_FORMAT ) +#endif { *internal_config = AUDIO_CONFIG_HOA3; #ifdef FIX_571_REVERB_NOT_ACTIVATED_ISM @@ -214,7 +231,11 @@ void ivas_renderer_select( if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { *internal_config = output_config; - if ( output_config == AUDIO_CONFIG_BINAURAL ) + if ( output_config == AUDIO_CONFIG_BINAURAL +#ifdef SPLIT_REND_WITH_HEAD_ROT + || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) { *renderer_type = RENDERER_BINAURAL_PARAMETRIC; } @@ -382,7 +403,11 @@ void ivas_renderer_select( } } } +#ifdef OSBA_DISC_OBJ_MCT + else if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) +#else else if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == SBA_FORMAT ) +#endif { *renderer_type = RENDERER_DIRAC; if ( st_ivas->ivas_format == SBA_FORMAT && @@ -423,7 +448,54 @@ void ivas_renderer_select( { *renderer_type = RENDERER_SBA_LINEAR_DEC; } +#ifdef OSBA_MONO_STEREO_OUTPUT + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_STEREO ) + { + *renderer_type = RENDERER_OSBA_STEREO; + } + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_MONO ) + { + *renderer_type = RENDERER_MONO_DOWNMIX; + } +#endif +#ifdef OSBA_AMBISONICS_OUT + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 ) ) + { + *renderer_type = RENDERER_OSBA_AMBI; + } +#endif +#ifdef OSBA_LS_OUT + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && ( output_config == AUDIO_CONFIG_5_1 || output_config == AUDIO_CONFIG_5_1_2 || output_config == AUDIO_CONFIG_5_1_4 || output_config == AUDIO_CONFIG_7_1 || output_config == AUDIO_CONFIG_7_1_4 || output_config == AUDIO_CONFIG_LS_CUSTOM ) ) + { + *renderer_type = RENDERER_OSBA_LS; + } +#endif +#ifdef OSBA_EXT_OUT + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL ) + { + *renderer_type = RENDERER_SBA_LINEAR_DEC; + } +#endif + } +#ifdef MASA_AND_OBJECTS + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + { + *renderer_type = RENDERER_DIRAC; + + if ( output_config == AUDIO_CONFIG_MONO ) + { + *renderer_type = RENDERER_MONO_DOWNMIX; + } + else if ( output_config == AUDIO_CONFIG_STEREO ) + { + *renderer_type = RENDERER_STEREO_PARAMETRIC; + } + else if ( output_config == AUDIO_CONFIG_EXTERNAL ) + { + *renderer_type = RENDERER_DISABLE; + } } +#endif else if ( st_ivas->ivas_format == MC_FORMAT ) { *internal_config = transport_config; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 5c70409ac2..57e173e33f 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -465,6 +465,44 @@ typedef struct dirac_output_synthesis_cov_state_structure } DIRAC_OUTPUT_SYNTHESIS_COV_STATE; +#ifdef OSBA_DISC_OBJ_MCT +/* Data structure for MASA_ISM rendering */ +typedef struct ivas_masa_ism_data_structure +{ +#if 0 + int16_t azimuth_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + int16_t elevation_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + float energy_ratio_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR][CLDFB_NO_CHANNELS_MAX]; + + int16_t azimuth_ism_edited[MAX_NUM_OBJECTS]; + int16_t elevation_ism_edited[MAX_NUM_OBJECTS]; + uint8_t ism_is_edited[MAX_NUM_OBJECTS]; + + int16_t idx_separated_ism; + int16_t azimuth_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + int16_t elevation_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + + float q_azimuth_old[MAX_NUM_OBJECTS]; + float q_elevation_old[MAX_NUM_OBJECTS]; + + float ismPreprocMatrix[2][2][CLDFB_NO_CHANNELS_MAX]; + uint8_t objectsMoved; + float eneMoveIIR[2][CLDFB_NO_CHANNELS_MAX]; + float enePreserveIIR[2][CLDFB_NO_CHANNELS_MAX]; + float preprocEneTarget[CLDFB_NO_CHANNELS_MAX]; + float preprocEneRealized[CLDFB_NO_CHANNELS_MAX]; +#endif + + float **delayBuffer; + int16_t delayBuffer_size; + int16_t delayBuffer_nchan; + +} MASA_ISM_DATA, *MASA_ISM_DATA_HANDLE; +#endif + +/*----------------------------------------------------------------------------------* + * ParamMC structures + *----------------------------------------------------------------------------------*/ typedef struct ivas_param_mc_diff_proto_info_structure { int16_t num_protos_diff; @@ -715,6 +753,10 @@ typedef struct cpe_dec_data_structure float old_out_mdct[STEREO_MDCT2DFT_FADE_LEN_48k]; float old_outLB_mdct[2 * STEREO_MDCT2DFT_FADE_LEN_48k]; +#ifdef MASA_AND_OBJECTS + int32_t brate_surplus; /* bitrate surplus for bitrate adaptation in combined format coding */ +#endif + } CPE_DEC_DATA, *CPE_DEC_HANDLE; @@ -840,6 +882,40 @@ typedef struct ivas_masa_decoder_struct } MASA_DECODER, *MASA_DECODER_HANDLE; +#ifdef MASA_AND_OBJECTS +/* Data structure for MASA_ISM rendering */ +typedef struct ivas_masa_ism_data_structure +{ + int16_t azimuth_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + int16_t elevation_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + float energy_ratio_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR][CLDFB_NO_CHANNELS_MAX]; + + int16_t azimuth_ism_edited[MAX_NUM_OBJECTS]; + int16_t elevation_ism_edited[MAX_NUM_OBJECTS]; + uint8_t ism_is_edited[MAX_NUM_OBJECTS]; + + int16_t idx_separated_ism; + int16_t azimuth_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + int16_t elevation_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + + float q_azimuth_old[MAX_NUM_OBJECTS]; + float q_elevation_old[MAX_NUM_OBJECTS]; + + float ismPreprocMatrix[2][2][CLDFB_NO_CHANNELS_MAX]; + uint8_t objectsMoved; + float eneMoveIIR[2][CLDFB_NO_CHANNELS_MAX]; + float enePreserveIIR[2][CLDFB_NO_CHANNELS_MAX]; + float preprocEneTarget[CLDFB_NO_CHANNELS_MAX]; + float preprocEneRealized[CLDFB_NO_CHANNELS_MAX]; + + float **delayBuffer; + int16_t delayBuffer_size; + int16_t delayBuffer_nchan; + +} MASA_ISM_DATA, *MASA_ISM_DATA_HANDLE; +#endif + + /*----------------------------------------------------------------------------------* * Decoder configuration structure *----------------------------------------------------------------------------------*/ @@ -875,11 +951,20 @@ typedef struct float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; } IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA, *IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE; + +typedef struct +{ + float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + AUDIO_CONFIG config; +} IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA, *IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE; + typedef struct { IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE hMultiBinCldfbData; /*scratch buffer for frame by frame processing*/ IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits; /*scratch buffer for frame by frame processing*/ SPLIT_REND_WRAPPER splitrend; + IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE hCldfbDataOut; /*buffer to store cldfb data before binauralization*/ } IVAS_DEC_SPLIT_REND_WRAPPER; #endif @@ -940,6 +1025,9 @@ typedef struct Decoder_Struct DECODER_CONFIG_HANDLE hDecoderConfig; /* Decoder configuration structure */ IVAS_FORMAT ivas_format; /* IVAS format */ +#ifdef MASA_AND_OBJECTS + IVAS_FORMAT last_ivas_format; /* last frame IVAS format */ +#endif int16_t sid_format; /* IVAS format indicator from SID frame */ int16_t nchan_transport; /* number of transport channels */ IVAS_OUTPUT_SETUP hOutSetup; /* output setup structure */ @@ -997,14 +1085,18 @@ typedef struct Decoder_Struct BINAURAL_RENDERER_HANDLE hBinRenderer; /* fastconv binaural renderer handle */ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd; /* Time domain binaural object renderer handle */ TDREND_HRFILT_FiltSet_t *hHrtfTD; /* pointer to HRTF data for TD renderer */ +#ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN + DIRAC_DEC_BIN_HANDLE hDiracDecBin[MAX_HEAD_ROT_POSES]; /* parametric binaural renderer handle */ +#else DIRAC_DEC_BIN_HANDLE hDiracDecBin; /* parametric binaural renderer handle */ +#endif LSSETUP_CONVERSION_HANDLE hLsSetUpConversion; /* MC LS configuration convertion handle */ EFAP_HANDLE hEFAPdata; /* EFAP structure */ VBAP_HANDLE hVBAPdata; /* VBAP structure */ MONO_DOWNMIX_RENDERER_HANDLE hMonoDmxRenderer; /* Mono downmix structure */ CREND_WRAPPER_HANDLE hCrendWrapper; /* Crend handle */ REVERB_HANDLE hReverb; /* Reverb handle */ - HRTFS_CREND_HANDLE hSetOfHRTF; /* Set of HRTFs handle (CRend) */ + HRTFS_CREND_HANDLE hSetOfHRTF; /* Set of HRTFs handle (CRend) */ HRTFS_FASTCONV_HANDLE hHrtfFastConv; /* FASTCONV HRTF tables for binaural rendering */ HRTFS_PARAMBIN_HANDLE hHrtfParambin; /* HRTF tables for parametric binauralizer */ LSSETUP_CUSTOM_HANDLE hLsSetupCustom; /* Custom LS configuration handle */ @@ -1016,6 +1108,17 @@ typedef struct Decoder_Struct COMBINED_ORIENTATION_HANDLE hCombinedOrientationData; /* Combined external and head orientation data structure */ DIRAC_REND_HANDLE hDirACRend; /* DirAC renderer handle */ SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; /* Spatial parametric (DirAC rend, ParamBin, ParamISM) rendering common data handle. */ +#if defined OSBA_DISC_OBJ_MCT || defined MASA_AND_OBJECTS + MASA_ISM_DATA_HANDLE hMasaIsmData; +#endif +#ifdef MASA_AND_OBJECTS + uint8_t editing_ism_enabled; /* Todo Nokia: Temporary, used until proper ISM control available */ + int16_t index_of_edited_ism; /* Todo Nokia: Temporary, used until proper ISM control available */ + int16_t azimuth_edited; /* Todo Nokia: Temporary, used until proper ISM control available */ + int16_t elevation_edited; /* Todo Nokia: Temporary, used until proper ISM control available */ + + int16_t flag_omasa_brate; +#endif /* JBM module */ DECODER_TC_BUFFER_HANDLE hTcBuffer; /* JBM structure */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 20a33bcf1d..90289a0ae3 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1099,28 +1099,21 @@ ivas_error IVAS_DEC_GetNumObjects( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -<<<<<<< HEAD + if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT #ifdef OSBA_EXT_OUT - if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) - { - *numObjects = hIvasDec->st_ivas->nchan_ism; - } -======= - + || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT +#endif #ifdef MASA_AND_OBJECTS - if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT ) ->>>>>>> main -#else - if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT ) + || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT #endif + ) { -#ifdef MASA_AND_OBJECTS +#if defined OSBA_EXT_OUT || defined MASA_AND_OBJECTS *numObjects = hIvasDec->st_ivas->nchan_ism; #else *numObjects = hIvasDec->st_ivas->hDecoderConfig->nchan_out; #endif } -#endif else { *numObjects = 0; @@ -1201,26 +1194,19 @@ ivas_error IVAS_DEC_GetObjectMetadata( } st_ivas = hIvasDec->st_ivas; -<<<<<<< HEAD -#ifdef OSBA_EXT_OUT - if ( st_ivas->ivas_format != ISM_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) -======= - + if ( st_ivas->ivas_format != ISM_FORMAT #ifdef MASA_AND_OBJECTS - if ( st_ivas->ivas_format != ISM_FORMAT && st_ivas->ivas_format != MASA_ISM_FORMAT ) ->>>>>>> main -#else - if ( st_ivas->ivas_format != ISM_FORMAT ) + && st_ivas->ivas_format != MASA_ISM_FORMAT #endif +#ifdef OSBA_EXT_OUT + && st_ivas->ivas_format != SBA_ISM_FORMAT +#endif + ) { return IVAS_ERR_WRONG_MODE; } -<<<<<<< HEAD -#ifdef OSBA_EXT_OUT -======= -#ifdef MASA_AND_OBJECTS ->>>>>>> main +#if defined OSBA_EXT_OUT || defined MASA_AND_OBJECTS if ( objectIdx >= st_ivas->nchan_ism ) #else if ( objectIdx >= st_ivas->hDecoderConfig->nchan_out ) -- GitLab From b9d3e0e448b73bafccde49a975c63c9fe21c0511 Mon Sep 17 00:00:00 2001 From: rhb Date: Thu, 3 Aug 2023 16:07:12 +0200 Subject: [PATCH 039/109] correct another wrong decoder file --- lib_dec/lib_dec.h | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 9edc1a130c..3ebce86ff3 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -114,8 +114,14 @@ typedef enum _IVAS_DEC_BS_FORMAT IVAS_DEC_BS_STEREO, IVAS_DEC_BS_MC, IVAS_DEC_BS_SBA, +#ifdef OSBA_EXT_OUT + IVAS_DEC_BS_SBA_ISM, +#endif IVAS_DEC_BS_OBJ, IVAS_DEC_BS_MASA, +#ifdef MASA_AND_OBJECTS + IVAS_DEC_BS_MASA_ISM, +#endif IVAS_DEC_BS_UNKOWN = 0xffff } IVAS_DEC_BS_FORMAT; @@ -182,6 +188,17 @@ ivas_error IVAS_DEC_GetSamples( #endif ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*! r: decoder error code */ +ivas_error IVAS_DEC_GetCldfbSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + float *out_real, /* o: buffer for decoded PCM real output in CLDFB domain */ + float *out_imag, /* o: buffer for decoded PCM imag output in CLDFB domain */ + IVAS_DEC_AUDIO_CONFIG *audio_config, + int16_t *nOutSamples /* o : number of samples per channel written to output buffer */ +); +#endif + /*! r: error code */ ivas_error IVAS_DEC_GetObjectMetadata( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ @@ -358,15 +375,16 @@ ivas_error IVAS_DEC_GetHrtfCRendHandle( ); ivas_error IVAS_DEC_GetHrtfFastConvHandle( - IVAS_DEC_HANDLE hIvasDec, /* i/oL IVAS decoder handle */ - IVAS_DEC_HRTF_FASTCONV_HANDLE *hHrtfFastConv /* o : FASTCONV HRTF handle */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_FASTCONV_HANDLE *hHrtfFastConv /* o : FASTCONV HRTF handle */ ); ivas_error IVAS_DEC_GetHrtfParamBinHandle( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_DEC_HRTF_PARAMBIN_HANDLE *hHrtfParambin /* o : Parametric binauralizer HRTF handle */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_PARAMBIN_HANDLE *hHrtfParambin /* o : Parametric binauralizer HRTF handle */ ); + /*! r: error code*/ ivas_error IVAS_DEC_GetRenderConfig( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ -- GitLab From b6ed2b2c4bca082a539ad1e878c79e787d4d5849 Mon Sep 17 00:00:00 2001 From: rhb Date: Thu, 3 Aug 2023 16:12:03 +0200 Subject: [PATCH 040/109] remove duplicated structure from ivas_stat_dec.h --- lib_dec/ivas_stat_dec.h | 34 ---------------------------------- 1 file changed, 34 deletions(-) mode change 100644 => 100755 lib_dec/ivas_stat_dec.h diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h old mode 100644 new mode 100755 index 57e173e33f..bb432ee3fb --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -465,40 +465,6 @@ typedef struct dirac_output_synthesis_cov_state_structure } DIRAC_OUTPUT_SYNTHESIS_COV_STATE; -#ifdef OSBA_DISC_OBJ_MCT -/* Data structure for MASA_ISM rendering */ -typedef struct ivas_masa_ism_data_structure -{ -#if 0 - int16_t azimuth_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; - int16_t elevation_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; - float energy_ratio_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR][CLDFB_NO_CHANNELS_MAX]; - - int16_t azimuth_ism_edited[MAX_NUM_OBJECTS]; - int16_t elevation_ism_edited[MAX_NUM_OBJECTS]; - uint8_t ism_is_edited[MAX_NUM_OBJECTS]; - - int16_t idx_separated_ism; - int16_t azimuth_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; - int16_t elevation_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; - - float q_azimuth_old[MAX_NUM_OBJECTS]; - float q_elevation_old[MAX_NUM_OBJECTS]; - - float ismPreprocMatrix[2][2][CLDFB_NO_CHANNELS_MAX]; - uint8_t objectsMoved; - float eneMoveIIR[2][CLDFB_NO_CHANNELS_MAX]; - float enePreserveIIR[2][CLDFB_NO_CHANNELS_MAX]; - float preprocEneTarget[CLDFB_NO_CHANNELS_MAX]; - float preprocEneRealized[CLDFB_NO_CHANNELS_MAX]; -#endif - - float **delayBuffer; - int16_t delayBuffer_size; - int16_t delayBuffer_nchan; - -} MASA_ISM_DATA, *MASA_ISM_DATA_HANDLE; -#endif /*----------------------------------------------------------------------------------* * ParamMC structures -- GitLab From e36ee4721c811ec49b312abb739ff55802166c7d Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 3 Aug 2023 16:20:56 +0200 Subject: [PATCH 041/109] fix compile errors --- lib_enc/ivas_enc.c | 2 +- lib_enc/ivas_ism_metadata_enc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 76aac69b1b..eb1b5a87a9 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -474,7 +474,7 @@ ivas_error ivas_enc( #endif #endif #ifdef ENABLE_ISM_MD_CODING - if ( ( error = ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag + if ( ( error = ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag,-1,0,NULL #ifdef OSBA_DISC_OBJ_MCT , st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index 567749a6ee..4ae430ee46 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -438,7 +438,7 @@ ivas_error ivas_ism_metadata_enc( #ifdef MASA_AND_OBJECTS if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ #ifdef OSBA_DISC_OBJ_MCT - || ism_mode == ISB_SBA_MODE_DISC + || ism_mode == ISM_SBA_MODE_DISC #endif ) #else -- GitLab From c15e5b099158a62bdff531e787bcae3a335a670f Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 3 Aug 2023 16:24:48 +0200 Subject: [PATCH 042/109] fix compile error --- lib_dec/ivas_omasa_dec.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 7cff26a856..1abdb9bb60 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -512,7 +512,12 @@ ivas_error ivas_omasa_ism_metadata_dec( { /* decode ISM metadata */ if ( ( error = ivas_ism_metadata_dec( ism_total_brate, *nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, - nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt ) ) != IVAS_ERR_OK ) + nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt +#ifdef OSBA_DISC_OBJ_MCT + , + st_ivas->hSCE[0]->hCoreCoder[0] +#endif + ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From d422c33c359d5b2cc3f6b3fe6d24758967b7173c Mon Sep 17 00:00:00 2001 From: rhb Date: Thu, 3 Aug 2023 16:41:54 +0200 Subject: [PATCH 043/109] rename binauralization function for OSBA to avoid duplicated file name --- lib_com/ivas_prot.h | 2 +- lib_dec/ivas_dec.c | 2 +- lib_dec/ivas_osba_dec.c | 4 ++-- lib_enc/ivas_enc.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) mode change 100644 => 100755 lib_com/ivas_prot.h mode change 100644 => 100755 lib_enc/ivas_enc.c diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h old mode 100644 new mode 100755 index e5d841a530..d9a32f6bc8 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5676,7 +5676,7 @@ ivas_error ivas_masa_ism_separate_object_renderer_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); -ivas_error ivas_omasa_dirac_td_binaural( +ivas_error ivas_osba_dirac_td_binaural( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float output[][L_FRAME48k], /* o : output synthesis signal */ const int16_t output_frame /* i : output frame length per channel */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 43e5e961b9..0a2fd96767 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -738,7 +738,7 @@ ivas_error ivas_dec( if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { - if ( ( error = ivas_omasa_dirac_td_binaural( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_osba_dirac_td_binaural( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 6f1717509d..de5ee80b35 100755 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -173,12 +173,12 @@ ivas_error ivas_masa_ism_separate_object_renderer_open( /*--------------------------------------------------------------------------* - * ivas_omasa_dirac_td_binaural() + * ivas_osba_dirac_td_binaural() * * Binaural rendering in OMASA format *--------------------------------------------------------------------------*/ -ivas_error ivas_omasa_dirac_td_binaural( +ivas_error ivas_osba_dirac_td_binaural( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float output[][L_FRAME48k], /* o : output synthesis signal */ const int16_t output_frame /* i : output frame length per channel */ diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c old mode 100644 new mode 100755 index eb1b5a87a9..832207cb72 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -474,7 +474,7 @@ ivas_error ivas_enc( #endif #endif #ifdef ENABLE_ISM_MD_CODING - if ( ( error = ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag,-1,0,NULL + if ( ( error = ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag,-1,0,NULL #ifdef OSBA_DISC_OBJ_MCT , st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame -- GitLab From 0523da5a30dcf9fed80245a9d59e01b2594acbc7 Mon Sep 17 00:00:00 2001 From: rhb Date: Thu, 3 Aug 2023 17:29:55 +0200 Subject: [PATCH 044/109] fix encoder crash --- lib_enc/ivas_enc.c | 3 +-- lib_enc/ivas_ism_metadata_enc.c | 8 +++++++- 2 files changed, 8 insertions(+), 3 deletions(-) mode change 100644 => 100755 lib_enc/ivas_ism_metadata_enc.c diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 832207cb72..02d2614d84 100755 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -477,9 +477,8 @@ ivas_error ivas_enc( if ( ( error = ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag,-1,0,NULL #ifdef OSBA_DISC_OBJ_MCT , - st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame + st->ini_frame #endif - ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c old mode 100644 new mode 100755 index 4ae430ee46..0f02ee8f4a --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -314,8 +314,14 @@ ivas_error ivas_ism_metadata_enc( /*----------------------------------------------------------------* * Rate importance of particular ISM streams *----------------------------------------------------------------*/ - +#ifdef OSBA_DISC_OBJ_MCT + if ( ism_mode != ISM_SBA_MODE_DISC ) + { + rate_ism_importance( nchan_transport, hIsmMeta, hSCE, lowrate_metadata_flag, ism_imp ); + } +#else rate_ism_importance( nchan_transport, hIsmMeta, hSCE, lowrate_metadata_flag, ism_imp ); +#endif #ifdef MASA_AND_OBJECTS } #endif -- GitLab From 4135f19be61a58fd6c8d50c882b6a1d799430856 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 4 Aug 2023 08:55:03 +0200 Subject: [PATCH 045/109] fix decoder crash at 384 and 512 kbps --- lib_rend/ivas_dirac_rend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 9312591a37..76028275cb 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -315,7 +315,7 @@ ivas_error ivas_spat_hSpatParamRendCom_config( #ifdef MASA_AND_OBJECTS if ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT -#ifdef OSSBA_DISC_OBJ_MCT +#ifdef OSBA_DISC_OBJ_MCT || ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && hodirac_flag ) -- GitLab From e107fd3b58e068036406a8574f497e10fb04d49f Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 4 Aug 2023 09:28:24 +0200 Subject: [PATCH 046/109] fix compiler warnings --- lib_dec/ivas_osba_dec.c | 66 ++--------------------------------------- 1 file changed, 2 insertions(+), 64 deletions(-) diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index de5ee80b35..0eb435f5b8 100755 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -55,8 +55,6 @@ ivas_error ivas_masa_ism_data_open( ) { MASA_ISM_DATA_HANDLE hMasaIsmData; - int16_t ch, bin; - int16_t sf, obj_idx; if ( ( hMasaIsmData = (MASA_ISM_DATA_HANDLE) malloc( sizeof( MASA_ISM_DATA ) ) ) == NULL ) { @@ -64,40 +62,6 @@ ivas_error ivas_masa_ism_data_open( } hMasaIsmData->delayBuffer = NULL; -#if 0 - for ( bin = 0; bin < CLDFB_NO_CHANNELS_MAX; bin++ ) - { - for ( ch = 0; ch < 2; ch++ ) - { - hMasaIsmData->ismPreprocMatrix[ch][ch][bin] = 1.0f; - hMasaIsmData->ismPreprocMatrix[1 - ch][ch][bin] = 0.0f; - hMasaIsmData->eneMoveIIR[ch][bin] = 0.0f; - hMasaIsmData->enePreserveIIR[ch][bin] = 0.0f; - } - hMasaIsmData->preprocEneTarget[bin] = 0.0f; - hMasaIsmData->preprocEneRealized[bin] = 0.0f; - } - - hMasaIsmData->objectsMoved = 0; - - for ( ch = 0; ch < st_ivas->nchan_ism; ch++ ) - { - hMasaIsmData->q_elevation_old[ch] = 0.0f; - hMasaIsmData->q_azimuth_old[ch] = 0.0f; - } - - for ( obj_idx = 0; obj_idx < MAX_NUM_OBJECTS; obj_idx++ ) - { - set_s( hMasaIsmData->azimuth_ism[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); - set_s( hMasaIsmData->elevation_ism[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); - for ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR; sf++ ) - { - set_zero( hMasaIsmData->energy_ratio_ism[obj_idx][sf], CLDFB_NO_CHANNELS_MAX ); - } - } - set_s( hMasaIsmData->azimuth_separated_ism, 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); - set_s( hMasaIsmData->elevation_separated_ism, 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); -#endif st_ivas->hMasaIsmData = hMasaIsmData; return IVAS_ERR_OK; @@ -145,10 +109,7 @@ ivas_error ivas_masa_ism_separate_object_renderer_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { - int16_t interpolator_length; int16_t i; - int16_t init_interpolator_length; - st_ivas->hMasaIsmData->delayBuffer_nchan = st_ivas->nchan_ism; st_ivas->hMasaIsmData->delayBuffer_size = (int16_t) ( ( st_ivas->hDecoderConfig->output_Fs / 50 ) / MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -186,8 +147,8 @@ ivas_error ivas_osba_dirac_td_binaural( { int16_t n; float data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k]; - float gain = 0.7943f; /* Todo Nokia: Temporary gain for roughly matching the loudness of other processing paths. */ - ivas_error error; + + ivas_error error; float *p_sepobj[MAX_NUM_OBJECTS]; #ifdef SBA_AND_OBJECTS int16_t channel_offset; @@ -293,8 +254,6 @@ ivas_error ivas_osba_ism_metadata_dec( int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ ) { - int16_t n, block; - int16_t azimuth_ism, elevation_ism, meta_write_index; ivas_error error; /* set ISM parameters */ @@ -308,27 +267,6 @@ ivas_error ivas_osba_ism_metadata_dec( { return error; } -#if 0 - if ( st_ivas->hDirAC != NULL ) - { - if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) - { - for ( n = 0; n < st_ivas->nchan_ism; n++ ) - { - azimuth_ism = (int16_t) ( st_ivas->hIsmMetaData[n]->azimuth + 0.5f ); - elevation_ism = (int16_t) ( st_ivas->hIsmMetaData[n]->elevation + 0.5f ); - - for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) - { - meta_write_index = ( dirac_bs_md_write_idx + block ) % st_ivas->hDirAC->dirac_md_buffer_length; - st_ivas->hMasaIsmData->azimuth_ism[n][meta_write_index] = azimuth_ism; - st_ivas->hMasaIsmData->elevation_ism[n][meta_write_index] = elevation_ism; - } - } - } - } -#endif - return IVAS_ERR_OK; } -- GitLab From d485d3c20837b9a7b0cdfa22fa28cbd338c4dfaf Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 4 Aug 2023 09:50:45 +0200 Subject: [PATCH 047/109] fix warning about unused argument in ivas_osba_ism_metadata_dec --- lib_com/ivas_prot.h | 1 - lib_dec/ivas_dec.c | 2 +- lib_dec/ivas_osba_dec.c | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index d9a32f6bc8..d87a99f8a2 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5687,7 +5687,6 @@ ivas_error ivas_osba_ism_metadata_dec( const int32_t ism_total_brate, /* i : ISM total bitrate */ int16_t *nchan_ism, /* o : number of ISM separated channels */ int16_t *nchan_transport_ism, /* o : number of ISM TCs */ - const int16_t dirac_bs_md_write_idx, /* i : DirAC bitstream write index */ int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ ); diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 0a2fd96767..30fa96c497 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -673,7 +673,7 @@ ivas_error ivas_dec( } #ifdef ENABLE_ISM_MD_CODING /* set ISM parameters and decode ISM metadata in OSBA format */ - if ( ( error = ivas_osba_ism_metadata_dec( st_ivas, ivas_total_brate, &nchan_ism, &nchan_transport_ism, dirac_bs_md_write_idx, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_osba_ism_metadata_dec( st_ivas, ivas_total_brate, &nchan_ism, &nchan_transport_ism, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 0eb435f5b8..fd4fcbafa6 100755 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -250,7 +250,6 @@ ivas_error ivas_osba_ism_metadata_dec( const int32_t ism_total_brate, /* i : ISM total bitrate */ int16_t *nchan_ism, /* o : number of ISM separated channels */ int16_t *nchan_transport_ism, /* o : number of ISM TCs */ - const int16_t dirac_bs_md_write_idx, /* i : DirAC bitstream write index */ int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ ) { -- GitLab From 820c4c156eff4adc96e7327141e1d760edfbae6f Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 4 Aug 2023 10:53:18 +0200 Subject: [PATCH 048/109] fix compiler warning in ivas_dec --- lib_dec/ivas_dec.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 30fa96c497..6f26a0e31a 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -661,16 +661,10 @@ ivas_error ivas_dec( else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { int16_t nchan_ism, nchan_transport_ism; - int16_t dirac_bs_md_write_idx; set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); nchan_transport_ism = 1; - dirac_bs_md_write_idx = 0; - if ( st_ivas->hDirAC != NULL ) - { - dirac_bs_md_write_idx = st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx; /* Store the write-index for this frame */ /*TODOfto:this seems not to be needed?*/ - } #ifdef ENABLE_ISM_MD_CODING /* set ISM parameters and decode ISM metadata in OSBA format */ if ( ( error = ivas_osba_ism_metadata_dec( st_ivas, ivas_total_brate, &nchan_ism, &nchan_transport_ism, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) -- GitLab From 22b140ae0f96a482cded9cdf8b4d6434648977b0 Mon Sep 17 00:00:00 2001 From: rhb Date: Fri, 4 Aug 2023 11:50:01 +0200 Subject: [PATCH 049/109] some cleanup of unused code --- lib_dec/ivas_init_dec.c | 36 ------------------------------------ lib_dec/ivas_osba_dec.c | 28 ++-------------------------- lib_enc/ivas_osba_enc.c | 4 ---- 3 files changed, 2 insertions(+), 66 deletions(-) mode change 100644 => 100755 lib_enc/ivas_osba_enc.c diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 66dd843c19..11838d4e3f 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1361,42 +1361,7 @@ ivas_error ivas_init_decoder( int32_t temp_brate[MAX_SCE]; st_ivas->ism_extmeta_active = -1; st_ivas->ism_extmeta_cnt = 0; -#if 0 - if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) - { - return error; - } - /* this is resetting the nSCE to 1 */ - if ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* Todo Nokia: Renderer should be selected in ivas_renderer_select(), but currently the number of transport channels is not available at that point. - * Hence, a temporary fix was done here, which adjusts the renderer after the number of transports is known. Optimally, this should be fixed by - * reading the number of transports before the renderer is selected. */ - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->nchan_transport >= 3 ) - { - st_ivas->renderer_type = RENDERER_BINAURAL_FASTCONV; - st_ivas->intern_config = AUDIO_CONFIG_HOA3; - st_ivas->hIntSetup.output_config = AUDIO_CONFIG_HOA3; /* Todo: Check if this affects tdrend in some way. */ - } - - if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( ( error = ivas_dirac_dec_open( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; - - st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); -#else if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) { return error; @@ -1446,7 +1411,6 @@ ivas_error ivas_init_decoder( st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); } st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); -#endif st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index fd4fcbafa6..c4e4780c53 100755 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -148,35 +148,20 @@ ivas_error ivas_osba_dirac_td_binaural( int16_t n; float data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k]; - ivas_error error; + ivas_error error; float *p_sepobj[MAX_NUM_OBJECTS]; -#ifdef SBA_AND_OBJECTS int16_t channel_offset; -#endif for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) { p_sepobj[n] = &data_separated_objects[n][0]; } -#ifdef SBA_AND_OBJECTS -#if 0 - channel_offset = st_ivas->nchan_transport; - if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->nchan_transport == 3 ) /* channels are remapped in ivas_sba_remapTCs() */ - { - channel_offset = 4; - } -#endif + channel_offset = st_ivas->nchan_ism; -#endif for ( n = 0; n < st_ivas->nchan_ism; n++ ) { -#ifdef SBA_AND_OBJECTS mvr2r( output[n], data_separated_objects[n], output_frame ); -#else - mvr2r( output[2 + n], data_separated_objects[n], output_frame ); -#endif - // v_multc( data_separated_objects[n], gain, data_separated_objects[n], output_frame ); } for ( n = 0; n < st_ivas->nchan_ism; n++ ) @@ -184,8 +169,6 @@ ivas_error ivas_osba_dirac_td_binaural( delay_signal( data_separated_objects[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); } - -#ifdef SBA_AND_OBJECTS if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { ivas_sba_upmixer_renderer( st_ivas, &output[channel_offset], output_frame ); @@ -194,9 +177,6 @@ ivas_error ivas_osba_dirac_td_binaural( { ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, &output[channel_offset], st_ivas->nchan_transport ); } -#else - ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, output, st_ivas->nchan_transport ); -#endif #ifdef DEBUG_OSBA { @@ -230,15 +210,11 @@ ivas_error ivas_osba_dirac_td_binaural( #endif for ( n = 0; n < BINAURAL_CHANNELS; n++ ) { -#if 0 - v_add( output[MAX_NUM_OBJECTS + n], p_sepobj[n], output[n], output_frame ); -#else int16_t i; for ( i = 0; i < output_frame; i++ ) { output[n][i] = 0.5f * output[channel_offset + n][i] + 0.5f * p_sepobj[n][i]; } -#endif } return IVAS_ERR_OK; diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c old mode 100644 new mode 100755 index 719e0dddf7..2e13bd1293 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -198,11 +198,7 @@ ivas_error ivas_osba_enc_config( hEncoderConfig = st_ivas->hEncoderConfig; -#if 0 - st_ivas->ism_mode = ivas_osba_ism_mode_select( hEncoderConfig->ivas_total_brate, hEncoderConfig->nchan_ism ); -#else st_ivas->ism_mode = ISM_MODE_NONE; -#endif /* reconfiguration in case of bitrate switching */ if ( hEncoderConfig->last_ivas_total_brate != hEncoderConfig->ivas_total_brate ) -- GitLab From 81d420395806565af9f9753fc01919a348642f56 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 4 Aug 2023 13:46:21 +0200 Subject: [PATCH 050/109] fix formatting --- apps/decoder.c | 16 +++++++-------- apps/encoder.c | 8 +++++--- lib_dec/ivas_dec.c | 8 ++++---- lib_dec/ivas_dirac_dec.c | 4 ++-- lib_dec/ivas_init_dec.c | 5 ++--- lib_dec/ivas_ism_metadata_dec.c | 18 ++++++++-------- lib_dec/ivas_mct_dec.c | 2 +- lib_dec/ivas_omasa_dec.c | 4 ++-- lib_dec/ivas_osba_dec.c | 10 ++++----- lib_dec/ivas_output_config.c | 8 ++++---- lib_dec/ivas_sba_dirac_stereo_dec.c | 2 +- lib_dec/lib_dec.c | 12 +++++------ lib_enc/ivas_enc.c | 6 +++--- lib_enc/ivas_ism_enc.c | 6 +++--- lib_enc/ivas_ism_metadata_enc.c | 32 ++++++++++++++--------------- lib_enc/lib_enc.c | 6 +++--- lib_rend/ivas_dirac_rend.c | 10 ++++----- lib_rend/ivas_objectRenderer.c | 12 +++++------ 18 files changed, 84 insertions(+), 85 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 22f31c38d0..7fb162fac8 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1690,12 +1690,12 @@ static ivas_error initOnFirstGoodFrame( } /* If outputting ISM, get number of objects, open output files and write zero metadata for initial bad frames */ #ifdef MASA_AND_OBJECTS - if ( *pBsFormat == IVAS_DEC_BS_OBJ || *pBsFormat == IVAS_DEC_BS_MASA_ISM + if ( *pBsFormat == IVAS_DEC_BS_OBJ || *pBsFormat == IVAS_DEC_BS_MASA_ISM #ifdef OSBA_EXT_OUT - - || *pBsFormat == IVAS_DEC_BS_SBA_ISM -#endif - ) + + || *pBsFormat == IVAS_DEC_BS_SBA_ISM +#endif + ) #else if ( *pBsFormat == IVAS_DEC_BS_OBJ ) #endif @@ -2107,11 +2107,11 @@ static ivas_error decodeG192( if ( decodedGoodFrame && arg.outputFormat == IVAS_DEC_OUTPUT_EXT ) { #ifdef MASA_AND_OBJECTS - if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_MASA_ISM + if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_MASA_ISM #ifdef OSBA_EXT_OUT - || bsFormat == IVAS_DEC_BS_SBA_ISM + || bsFormat == IVAS_DEC_BS_SBA_ISM #endif - ) + ) #else if ( bsFormat == IVAS_DEC_BS_OBJ ) #endif diff --git a/apps/encoder.c b/apps/encoder.c index ac4c72caee..b332d53863 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -556,11 +556,13 @@ int main( } #ifdef MASA_AND_OBJECTS - const int16_t numIsmInputs = ( arg.inputFormat == IVAS_ENC_INPUT_ISM || arg.inputFormat == IVAS_ENC_INPUT_MASA_ISM + const int16_t numIsmInputs = ( arg.inputFormat == IVAS_ENC_INPUT_ISM || arg.inputFormat == IVAS_ENC_INPUT_MASA_ISM #ifdef SBA_AND_OBJECTS - || arg.inputFormat == IVAS_ENC_INPUT_SBA_ISM + || arg.inputFormat == IVAS_ENC_INPUT_SBA_ISM #endif - ) ? arg.inputFormatConfig.ism.numObjects : 0; + ) + ? arg.inputFormatConfig.ism.numObjects + : 0; #else const int16_t numIsmInputs = arg.inputFormat == IVAS_ENC_INPUT_ISM ? arg.inputFormatConfig.ism.numObjects : 0; #endif diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index e696791bf8..6ca0345111 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -720,10 +720,10 @@ ivas_error ivas_dec( ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate #ifdef VLBR_20MS_MD - , - st_ivas->last_active_ivas_total_brate + , + st_ivas->last_active_ivas_total_brate #endif - ) ); + ) ); ivas_sba_dirac_stereo_dec( st_ivas, &output[st_ivas->nchan_ism], output_frame, 0 ); } @@ -778,7 +778,7 @@ ivas_error ivas_dec( for ( n = 0; n < nchan_out; n++ ) { - v_add( output[n], output[n + max(nchan_out, nchan_ism)], output[n], output_frame ); + v_add( output[n], output[n + max( nchan_out, nchan_ism )], output[n], output_frame ); } } #endif diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index d3ae36b100..13f0dcd88c 100755 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -103,9 +103,9 @@ static ivas_error ivas_dirac_dec_config_internal( if ( flag_config == DIRAC_OPEN ) { #ifdef OSBA_DISC_OBJ_MCT - hDirAC->spar_to_dirac_write_idx = (st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) ? DELAY_DIRAC_PARAM_DEC_SFR : 0; + hDirAC->spar_to_dirac_write_idx = ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) ? DELAY_DIRAC_PARAM_DEC_SFR : 0; #else - hDirAC->spar_to_dirac_write_idx = st_ivas->ivas_format == SBA_FORMAT ? DELAY_DIRAC_PARAM_DEC_SFR : 0; + hDirAC->spar_to_dirac_write_idx = st_ivas->ivas_format == SBA_FORMAT ? DELAY_DIRAC_PARAM_DEC_SFR : 0; #endif hDirAC->dithering_seed = DIRAC_DITH_SEED; st_ivas->hDirAC = hDirAC; diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 11838d4e3f..778f360283 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -781,7 +781,7 @@ int16_t getNumChanSynthesis( n = CPE_CHANNELS; } #ifdef SBA_AND_OBJECTS - else if ( (st_ivas->hMCT != NULL || st_ivas->ivas_format == SBA_FORMAT) && st_ivas->ivas_format != SBA_ISM_FORMAT ) + else if ( ( st_ivas->hMCT != NULL || st_ivas->ivas_format == SBA_FORMAT ) && st_ivas->ivas_format != SBA_ISM_FORMAT ) #else else if ( st_ivas->hMCT != NULL || st_ivas->ivas_format == SBA_FORMAT ) #endif @@ -1007,7 +1007,7 @@ ivas_error ivas_init_decoder( else #endif #ifdef MASA_AND_OBJECTS - if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { hDecoderConfig->nchan_out = st_ivas->nchan_transport + st_ivas->nchan_ism; } @@ -1447,7 +1447,6 @@ ivas_error ivas_init_decoder( return error; } #endif - } #endif #ifdef MASA_AND_OBJECTS diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index ee53527052..7bd5e42e49 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -221,7 +221,7 @@ ivas_error ivas_ism_metadata_dec( else #endif #ifdef MASA_AND_OBJECTS - if ( ism_mode != ISM_MASA_MODE_DISC && ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ ) + if ( ism_mode != ISM_MASA_MODE_DISC && ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ ) #endif { /* number of objects was read in ivas_dec_setup() */ @@ -287,7 +287,7 @@ ivas_error ivas_ism_metadata_dec( } else #ifdef MASA_AND_OBJECTS - if ( ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) + if ( ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) { /* ISM importance flag is already read in ivas_masa_decode() */ ism_imp[ch] = hIsmMeta[ch]->ism_imp; @@ -390,12 +390,12 @@ ivas_error ivas_ism_metadata_dec( hIsmMetaData = hIsmMeta[ch]; if ( ism_mode == ISM_MODE_DISC #ifdef OSBA_DISC_OBJ_MCT - || ism_mode == ISM_SBA_MODE_DISC + || ism_mode == ISM_SBA_MODE_DISC #endif #ifdef MASA_AND_OBJECTS - || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ + || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ #endif - ) + ) { nb_bits_start = st0->next_bit_pos; } @@ -483,12 +483,12 @@ ivas_error ivas_ism_metadata_dec( /* save number of metadata bits read */ if ( ism_mode == ISM_MODE_DISC #ifdef OSBA_DISC_OBJ_MCT - || ism_mode == ISM_SBA_MODE_DISC + || ism_mode == ISM_SBA_MODE_DISC #endif #ifdef MASA_AND_OBJECTS - || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ + || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ #endif - ) + ) { nb_bits_metadata[ch] = st0->next_bit_pos - nb_bits_start; } @@ -633,7 +633,7 @@ ivas_error ivas_ism_metadata_dec( #ifdef MASA_AND_OBJECTS if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) #else - if ( ism_mode == ISM_MODE_DISC ) + if ( ism_mode == ISM_MODE_DISC ) #endif { if ( ism_imp[ch] == ISM_NO_META && ( ( total_brate[ch] < ACELP_8k00 && element_brate[ch] < SCE_CORE_16k_LOW_LIMIT ) || diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index a3472b67f6..8e3864d505 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -241,7 +241,7 @@ ivas_error ivas_mct_dec( /* Postprocessing for ACELP/MDCT core switching and synchronization */ #ifdef OSBA_MONO_STEREO_OUTPUT - if ( ( error = core_switching_post_dec( sts[n], synth[n], output[cpe_id * CPE_CHANNELS + n], hCPE->output_mem[1], st_ivas->ivas_format, 0, output_frame, 0 /*core_switching_flag*/, (st_ivas->ivas_format != SBA_ISM_FORMAT || cpe_id >= nCPE - 2) ? st_ivas->sba_dirac_stereo_flag : 0, -1, hCPE->last_element_mode ) ) != IVAS_ERR_OK ) + if ( ( error = core_switching_post_dec( sts[n], synth[n], output[cpe_id * CPE_CHANNELS + n], hCPE->output_mem[1], st_ivas->ivas_format, 0, output_frame, 0 /*core_switching_flag*/, ( st_ivas->ivas_format != SBA_ISM_FORMAT || cpe_id >= nCPE - 2 ) ? st_ivas->sba_dirac_stereo_flag : 0, -1, hCPE->last_element_mode ) ) != IVAS_ERR_OK ) #else if ( ( error = core_switching_post_dec( sts[n], synth[n], output[cpe_id * CPE_CHANNELS + n], hCPE->output_mem[1], st_ivas->ivas_format, 0, output_frame, 0 /*core_switching_flag*/, st_ivas->sba_dirac_stereo_flag, -1, hCPE->last_element_mode ) ) != IVAS_ERR_OK ) #endif diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 1abdb9bb60..d21a6ea754 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -512,12 +512,12 @@ ivas_error ivas_omasa_ism_metadata_dec( { /* decode ISM metadata */ if ( ( error = ivas_ism_metadata_dec( ism_total_brate, *nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, - nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt + nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt #ifdef OSBA_DISC_OBJ_MCT , st_ivas->hSCE[0]->hCoreCoder[0] #endif - ) ) != IVAS_ERR_OK ) + ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index c4e4780c53..130600201c 100755 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -222,11 +222,11 @@ ivas_error ivas_osba_dirac_td_binaural( ivas_error ivas_osba_ism_metadata_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int32_t ism_total_brate, /* i : ISM total bitrate */ - int16_t *nchan_ism, /* o : number of ISM separated channels */ - int16_t *nchan_transport_ism, /* o : number of ISM TCs */ - int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int32_t ism_total_brate, /* i : ISM total bitrate */ + int16_t *nchan_ism, /* o : number of ISM separated channels */ + int16_t *nchan_transport_ism, /* o : number of ISM TCs */ + int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ ) { ivas_error error; diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 52d1dd2d09..c342cbcfe2 100755 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -153,14 +153,14 @@ void ivas_renderer_select( } else if ( st_ivas->ivas_format == MASA_FORMAT #ifdef MASA_AND_OBJECTS - || st_ivas->ivas_format == MASA_ISM_FORMAT + || st_ivas->ivas_format == MASA_ISM_FORMAT #endif #ifdef OSBA_DISC_OBJ_MCT - || ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) + || ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) #else - || ( st_ivas->ivas_format == SBA_FORMAT + || ( st_ivas->ivas_format == SBA_FORMAT #endif - && st_ivas->nchan_transport <= 2 ) ) + && st_ivas->nchan_transport <= 2 ) ) { *internal_config = output_config; if ( output_config == AUDIO_CONFIG_BINAURAL diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c index 6edc2fae4a..4ff17b75c8 100755 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -861,7 +861,7 @@ void ivas_sba_dirac_stereo_dec( #ifdef OSBA_MONO_STEREO_OUTPUT hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, st_ivas->hDecoderConfig->output_Fs, hStereoDft->NFFT, ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !mcmasa ) ); #else - hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, st_ivas->hDecoderConfig->output_Fs, hStereoDft->NFFT, ( st_ivas->ivas_format == SBA_FORMAT && !mcmasa) ); + hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, st_ivas->hDecoderConfig->output_Fs, hStereoDft->NFFT, ( st_ivas->ivas_format == SBA_FORMAT && !mcmasa ) ); #endif stereo_dft_dec_update( hStereoDft, output_frame, 1 /*st_ivas->sba_dirac_stereo_flag*/ ); if ( st_ivas->nchan_transport > 1 ) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 90289a0ae3..b66dda5681 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1099,14 +1099,14 @@ ivas_error IVAS_DEC_GetNumObjects( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT + if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT #ifdef OSBA_EXT_OUT - || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT + || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT #endif #ifdef MASA_AND_OBJECTS - || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT + || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT #endif - ) + ) { #if defined OSBA_EXT_OUT || defined MASA_AND_OBJECTS *numObjects = hIvasDec->st_ivas->nchan_ism; @@ -1199,9 +1199,9 @@ ivas_error IVAS_DEC_GetObjectMetadata( && st_ivas->ivas_format != MASA_ISM_FORMAT #endif #ifdef OSBA_EXT_OUT - && st_ivas->ivas_format != SBA_ISM_FORMAT + && st_ivas->ivas_format != SBA_ISM_FORMAT #endif - ) + ) { return IVAS_ERR_WRONG_MODE; } diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 02d2614d84..8c7715361a 100755 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -474,10 +474,10 @@ ivas_error ivas_enc( #endif #endif #ifdef ENABLE_ISM_MD_CODING - if ( ( error = ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag,-1,0,NULL + if ( ( error = ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -1, 0, NULL #ifdef OSBA_DISC_OBJ_MCT - , - st->ini_frame + , + st->ini_frame #endif ) ) != IVAS_ERR_OK ) { diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 034673bf22..d0ea5a45ba 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -249,12 +249,12 @@ ivas_error ivas_ism_enc( { #ifdef MASA_AND_OBJECTS ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, - nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -1, 0, NULL + nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -1, 0, NULL #ifdef OSBA_DISC_OBJ_MCT , st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame #endif -); + ); #else ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, st_ivas->nchan_transport, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm, st_ivas->hEncoderConfig->ism_extended_metadata_flag ); #endif @@ -283,7 +283,7 @@ ivas_error ivas_ism_enc( , st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame #endif - ); + ); if ( st_ivas->hEncoderConfig->ivas_format == MASA_ISM_FORMAT ) { diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index 0f02ee8f4a..b12a0d21dd 100755 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -255,11 +255,11 @@ ivas_error ivas_ism_metadata_enc( #ifdef MASA_AND_OBJECTS else if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC #ifdef OSBA_DISC_OBJ_MCT - || ism_mode == ISM_SBA_MODE_DISC + || ism_mode == ISM_SBA_MODE_DISC #endif - ) + ) #else - else if ( ism_mode == ISM_MODE_DISC ) + else if ( ism_mode == ISM_MODE_DISC ) #endif { null_metadata_flag[ch] = !hIsmMeta[ch]->ism_metadata_flag; @@ -267,12 +267,12 @@ ivas_error ivas_ism_metadata_enc( if ( hIsmMeta[ch]->ism_metadata_flag == 1 ) { #ifdef OSBA_DISC_OBJ_MCT - if ( ism_mode != ISM_SBA_MODE_DISC ) /*TODOfto this may cost a few bits but it is supposed to be for the higher bitrates anyway*/ + if ( ism_mode != ISM_SBA_MODE_DISC ) /*TODOfto this may cost a few bits but it is supposed to be for the higher bitrates anyway*/ #endif - { - /* In case of low level noise for low bitrate inactive frames, do not sent metadata */ - hIsmMeta[ch]->ism_metadata_flag = vad_flag[ch] || hSCE[ch]->hCoreCoder[0]->lp_noise > 10 || hSCE[ch]->hCoreCoder[0]->tcxonly; - } + { + /* In case of low level noise for low bitrate inactive frames, do not sent metadata */ + hIsmMeta[ch]->ism_metadata_flag = vad_flag[ch] || hSCE[ch]->hCoreCoder[0]->lp_noise > 10 || hSCE[ch]->hCoreCoder[0]->tcxonly; + } /* in inactive frames, send MD 1) in ISM_MD_INC_DIFF_CNT_MAX consecutive frames when MD significantly change, 2) at least every ISM_MD_FEC_DIFF frames */ if ( hIsmMeta[ch]->ism_metadata_flag == 0 ) @@ -320,7 +320,7 @@ ivas_error ivas_ism_metadata_enc( rate_ism_importance( nchan_transport, hIsmMeta, hSCE, lowrate_metadata_flag, ism_imp ); } #else - rate_ism_importance( nchan_transport, hIsmMeta, hSCE, lowrate_metadata_flag, ism_imp ); + rate_ism_importance( nchan_transport, hIsmMeta, hSCE, lowrate_metadata_flag, ism_imp ); #endif #ifdef MASA_AND_OBJECTS } @@ -331,11 +331,11 @@ ivas_error ivas_ism_metadata_enc( *----------------------------------------------------------------*/ #ifdef MASA_AND_OBJECTS - if ( ism_mode != ISM_MASA_MODE_DISC && ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ + if ( ism_mode != ISM_MASA_MODE_DISC && ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ #ifdef OSBA_DISC_OBJ_MCT && ism_mode != ISM_SBA_MODE_DISC #endif -) + ) { #endif /* write number of objects - unary coding */ @@ -446,7 +446,7 @@ ivas_error ivas_ism_metadata_enc( #ifdef OSBA_DISC_OBJ_MCT || ism_mode == ISM_SBA_MODE_DISC #endif - ) + ) #else if ( ism_mode == ISM_MODE_DISC ) #endif @@ -485,11 +485,11 @@ ivas_error ivas_ism_metadata_enc( else { #ifdef MASA_AND_OBJECTS - if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ + if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ #ifdef OSBA_DISC_OBJ_MCT || ism_mode == ISM_SBA_MODE_DISC #endif -) + ) #else if ( ism_mode == ISM_MODE_DISC ) #endif @@ -532,11 +532,11 @@ ivas_error ivas_ism_metadata_enc( /* save number of metadata bits written */ #ifdef MASA_AND_OBJECTS - if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ + if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ #ifdef OSBA_DISC_OBJ_MCT || ism_mode == ISM_SBA_MODE_DISC #endif -) + ) #else if ( ism_mode == ISM_MODE_DISC ) #endif diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index ec95312dfe..d858f5fb3d 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -454,11 +454,11 @@ ivas_error IVAS_ENC_FeedObjectMetadata( } #ifdef MASA_AND_OBJECTS - if ( hIvasEnc->st_ivas->hEncoderConfig->ivas_format != ISM_FORMAT && hIvasEnc->st_ivas->hEncoderConfig->ivas_format != MASA_ISM_FORMAT + if ( hIvasEnc->st_ivas->hEncoderConfig->ivas_format != ISM_FORMAT && hIvasEnc->st_ivas->hEncoderConfig->ivas_format != MASA_ISM_FORMAT #ifdef SBA_AND_OBJECTS - && hIvasEnc->st_ivas->hEncoderConfig->ivas_format != SBA_ISM_FORMAT + && hIvasEnc->st_ivas->hEncoderConfig->ivas_format != SBA_ISM_FORMAT #endif -) + ) #else if ( hIvasEnc->st_ivas->hEncoderConfig->ivas_format != ISM_FORMAT ) #endif diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 76028275cb..03898cbad7 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -314,15 +314,13 @@ ivas_error ivas_spat_hSpatParamRendCom_config( } #ifdef MASA_AND_OBJECTS - if ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT + if ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT #ifdef OSBA_DISC_OBJ_MCT - || ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) - && hodirac_flag - ) + || ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && hodirac_flag ) #else - || ( ivas_format == SBA_FORMAT && hodirac_flag ) + || ( ivas_format == SBA_FORMAT && hodirac_flag ) #endif -) + ) #else if ( ivas_format == MASA_FORMAT || ( ivas_format == SBA_FORMAT && hodirac_flag ) ) #endif diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 0521a3b4ce..d7320f39a6 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -197,9 +197,9 @@ ivas_error ivas_td_binaural_open_unwrap( #ifdef MASA_AND_OBJECTS if ( ivas_format == ISM_FORMAT || ivas_format == MASA_ISM_FORMAT #ifdef OSBA_DISC_OBJ_MCT - || ivas_format == SBA_ISM_FORMAT + || ivas_format == SBA_ISM_FORMAT #endif - ) + ) #else if ( ivas_format == ISM_FORMAT ) #endif @@ -227,11 +227,11 @@ ivas_error ivas_td_binaural_open_unwrap( *hBinRendererTd = pBinRendTd; #ifdef MASA_AND_OBJECTS - if ( ivas_format != MASA_ISM_FORMAT + if ( ivas_format != MASA_ISM_FORMAT #ifdef OSBA_DISC_OBJ_MCT - && ivas_format != SBA_ISM_FORMAT + && ivas_format != SBA_ISM_FORMAT #endif -) + ) { *binaural_latency_ns = (int32_t) ( ( *hBinRendererTd )->HrFiltSet_p->latency_s * 1000000000.f ); } @@ -521,7 +521,7 @@ void TDREND_Update_object_positions( #ifdef OSBA_DISC_OBJ_MCT || in_format == SBA_ISM_FORMAT #endif - ) + ) #else if ( in_format == ISM_FORMAT ) #endif -- GitLab From 771ec2a2790f375d8ca2f9af9bb224842b70c752 Mon Sep 17 00:00:00 2001 From: rhb Date: Fri, 4 Aug 2023 14:26:05 +0200 Subject: [PATCH 051/109] fix compiler error witch OSBA switch disabled --- lib_dec/ivas_ism_metadata_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 lib_dec/ivas_ism_metadata_dec.c diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c old mode 100644 new mode 100755 index ee53527052..fdaaaf5f6a --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -283,9 +283,9 @@ ivas_error ivas_ism_metadata_dec( if ( ism_mode == ISM_SBA_MODE_DISC ) { ism_imp[ch] = get_next_indice( st0, 1 ); -#endif } else +#endif #ifdef MASA_AND_OBJECTS if ( ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) { -- GitLab From d120fa082af6c94898cf31994bb2417ad8251a31 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 4 Aug 2023 15:07:50 +0200 Subject: [PATCH 052/109] fix merge error in ivas_td_binaural_renderer --- lib_dec/ivas_objectRenderer_internal.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 274e9fd268..f90bee51dd 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -90,12 +90,12 @@ ivas_error ivas_td_binaural_renderer( int16_t nchan_transport; #endif -#if defined OSBA_DISC_OBJ_MCT && defined MASA_AND_OBJECTS - nchan_transport = ( st_ivas->ism_mode == ISM_SBA_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) ? st_ivas->nchan_ism : st_ivas->nchan_transport; -#elif defined MASA_AND_OBJECTS - nchan_transport = ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ? st_ivas->nchan_ism : st_ivas->nchan_transport; -#elif defined OSBA_DISC_OBJ_MCT - nchan_transport = ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) ? st_ivas->nchan_ism : st_ivas->nchan_transport; +#if defined MASA_AND_OBJECTS + nchan_transport = ( st_ivas->ism_mode == ISM_MASA_MODE_DISC +#if defined OSBA_DISC_OBJ_MCT + || st_ivas->ism_mode == ISM_SBA_MODE_DISC +#endif + ) ? st_ivas->nchan_ism : st_ivas->nchan_transport; #endif if ( st_ivas->hDecoderConfig->Opt_delay_comp ) -- GitLab From 992d127c75ca1bbb1761c298942eff8844c9ccb5 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 4 Aug 2023 15:43:39 +0200 Subject: [PATCH 053/109] fix formatting in ivas_ism_metadata_dec.c and ivas_objectRenderer_internal.c --- lib_dec/ivas_ism_metadata_dec.c | 2 +- lib_dec/ivas_objectRenderer_internal.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index da673749d0..8660681309 100755 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -633,7 +633,7 @@ ivas_error ivas_ism_metadata_dec( #ifdef MASA_AND_OBJECTS if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) #else - if ( ism_mode == ISM_MODE_DISC ) + if ( ism_mode == ISM_MODE_DISC ) #endif { if ( ism_imp[ch] == ISM_NO_META && ( ( total_brate[ch] < ACELP_8k00 && element_brate[ch] < SCE_CORE_16k_LOW_LIMIT ) || diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index f90bee51dd..a4ac2cba54 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -93,9 +93,11 @@ ivas_error ivas_td_binaural_renderer( #if defined MASA_AND_OBJECTS nchan_transport = ( st_ivas->ism_mode == ISM_MASA_MODE_DISC #if defined OSBA_DISC_OBJ_MCT - || st_ivas->ism_mode == ISM_SBA_MODE_DISC + || st_ivas->ism_mode == ISM_SBA_MODE_DISC #endif - ) ? st_ivas->nchan_ism : st_ivas->nchan_transport; + ) + ? st_ivas->nchan_ism + : st_ivas->nchan_transport; #endif if ( st_ivas->hDecoderConfig->Opt_delay_comp ) -- GitLab From fb6c35bcad545af502bab0f8bd87a79405de3195 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 6 Aug 2023 20:20:39 +0200 Subject: [PATCH 054/109] enable extended metadata support for OSBA again; brings it back to BE with rev. 2b5f2160362afb4d3b7f6c5ae1d0de8402a6c4d4 --- lib_dec/ivas_ism_metadata_dec.c | 4 ++++ lib_enc/ivas_ism_metadata_enc.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index 8660681309..3a0086324b 100755 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -246,7 +246,11 @@ ivas_error ivas_ism_metadata_dec( /* read extended metadata presence flag */ #ifdef MASA_AND_OBJECTS +#ifdef OSBA_DISC_OBJ_MCT + if ( (ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC) && ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) +#else if ( ism_mode == ISM_MODE_DISC && ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) +#endif #else if ( ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) #endif diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index b12a0d21dd..e8376e8b17 100755 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -357,7 +357,11 @@ ivas_error ivas_ism_metadata_enc( /* write extended metadata presence flag */ #ifdef MASA_AND_OBJECTS +#ifdef OSBA_DISC_OBJ_MCT + if ( (ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC) && *ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) +#else if ( ism_mode == ISM_MODE_DISC && *ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) +#endif #else if ( ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) #endif -- GitLab From 46528c3060f9ddfedcccf01815b4385ca78bba5f Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 7 Aug 2023 09:41:39 +0200 Subject: [PATCH 055/109] delete resolved TODOfto comments --- lib_dec/ivas_dec.c | 4 ++-- lib_dec/ivas_init_dec.c | 4 +--- lib_enc/ivas_init_enc.c | 2 +- lib_enc/ivas_ism_metadata_enc.c | 2 +- lib_enc/ivas_mct_core_enc.c | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 6ca0345111..4ab343a0d0 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -730,7 +730,7 @@ ivas_error ivas_dec( #endif /* HP filtering */ - for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) /*TODOfto:check what needs to be filtered here*/ + for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) { hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } @@ -839,7 +839,7 @@ ivas_error ivas_dec( } } #endif - else /*HOA3 rendering for now*/ + else /*EXT output = individual objects + HOA3*/ { #ifdef OSBA_EXT_OUT for ( n = 0; n < nchan_ism; n++ ) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 778f360283..448206f4ac 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1001,7 +1001,7 @@ ivas_error ivas_init_decoder( #ifdef OSBA_EXT_OUT if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - hDecoderConfig->nchan_out = audioCfg2channels( AUDIO_CONFIG_HOA3 ); /*TODOfto: only hoa3 ouput for now*/ + hDecoderConfig->nchan_out = audioCfg2channels( AUDIO_CONFIG_HOA3 ); hDecoderConfig->nchan_out += st_ivas->nchan_ism; } else @@ -1441,12 +1441,10 @@ ivas_error ivas_init_decoder( /* set CNA/CNG flags */ ivas_sba_set_cna_cng_flag( st_ivas ); -#if 1 /*TODOfto: is this neede for OSBA?*/ if ( ( error = ivas_masa_ism_data_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } -#endif } #endif #ifdef MASA_AND_OBJECTS diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 2a5dbf2406..a260fcb23e 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -682,7 +682,7 @@ ivas_error ivas_init_encoder( st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); - if ( ( error = ivas_spar_enc_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) /*TODOfto:remove this*/ + if ( ( error = ivas_spar_enc_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index e8376e8b17..b6cfa5281f 100755 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -267,7 +267,7 @@ ivas_error ivas_ism_metadata_enc( if ( hIsmMeta[ch]->ism_metadata_flag == 1 ) { #ifdef OSBA_DISC_OBJ_MCT - if ( ism_mode != ISM_SBA_MODE_DISC ) /*TODOfto this may cost a few bits but it is supposed to be for the higher bitrates anyway*/ + if ( ism_mode != ISM_SBA_MODE_DISC ) #endif { /* In case of low level noise for low bitrate inactive frames, do not sent metadata */ diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 7a10b3f35b..fcf5f85d79 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -495,7 +495,7 @@ void ivas_mct_core_enc( nAvailBits -= IVAS_FORMAT_SIGNALING_NBITS_EXTENDED; nAvailBits -= SBA_ORDER_BITS + SBA_PLANAR_BITS; #ifdef SBA_AND_OBJECTS - if ( ivas_format == SBA_ISM_FORMAT && nChannels > 4 ) /*TODOfto: recheck this condition*/ + if ( ivas_format == SBA_ISM_FORMAT && nChannels > 4 ) { nAvailBits -= IVAS_COMBINED_FORMAT_SIGNALLING_BITS; } -- GitLab From 72260b097c90331a734a489127eb9fa059a2ed52 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 7 Aug 2023 16:14:28 +0200 Subject: [PATCH 056/109] remove todo-comment --- lib_enc/ivas_init_enc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index a260fcb23e..67d14f1c35 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -656,7 +656,6 @@ ivas_error ivas_init_encoder( } #endif #ifdef SBA_AND_OBJECTS - // Todo OSBA merge: This requires adjustment to follow all the new things like dynamic indices else if ( ivas_format == SBA_ISM_FORMAT ) { int32_t element_brate_tmp[MAX_NUM_OBJECTS]; @@ -692,7 +691,6 @@ ivas_error ivas_init_encoder( return error; } - if ( st_ivas->ism_mode == ISM_MODE_NONE ) { sce_id = 0; -- GitLab From 88e86efcc33a526bc568d9a0047de79e564d3d91 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 7 Aug 2023 22:02:58 +0200 Subject: [PATCH 057/109] disable DTX for OSBA --- lib_enc/lib_enc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index d858f5fb3d..dd779bcb54 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -1014,6 +1014,9 @@ static ivas_error configureEncoder( hEncoderConfig->ivas_format == MC_FORMAT #ifdef MASA_AND_OBJECTS || hEncoderConfig->ivas_format == MASA_ISM_FORMAT +#endif +#ifdef SBA_AND_OBJECTS + || hEncoderConfig->ivas_format == SBA_ISM_FORMAT #endif ) ) { -- GitLab From e81dcba4065fe38e8c77e3a43e17fed7388bdc4a Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 8 Aug 2023 16:58:24 +1000 Subject: [PATCH 058/109] OSBA encoder bitrate switching fix --- lib_com/ivas_prot.h | 5 +- lib_com/options.h | 1 + lib_enc/ivas_enc.c | 16 ++- lib_enc/ivas_init_enc.c | 4 + lib_enc/ivas_ism_metadata_enc.c | 8 +- lib_enc/ivas_mct_enc.c | 4 + lib_enc/ivas_osba_enc.c | 221 ++++++++++++++++++++++++++++++-- 7 files changed, 244 insertions(+), 15 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 6791d7e2c7..ddacba77cd 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5662,7 +5662,7 @@ void ivas_osba_enc_close( OSBA_ENC_HANDLE *hOSba /* i/o: encoder OSBA handle */ ); -ivas_error ivas_osba_enc_config( +ivas_error ivas_osba_enc_reconfig( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); @@ -5674,6 +5674,9 @@ void ivas_osba_enc( const int16_t nchan_ism, /* i : Number of objects for parameter analysis */ const ISM_MODE ism_mode, /* i : ISM mode */ const int16_t sba_analysis_order /* i : SBA order evaluated in DirAC/SPAR encoder */ +#ifdef OSBA_BR_SWITCHING + , const int32_t input_Fs /* i : input sampling rate*/ +#endif ); #ifdef OSBA_DISC_OBJ_MCT ivas_error ivas_masa_ism_data_open( diff --git a/lib_com/options.h b/lib_com/options.h index d607a83757..89f2376176 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -226,6 +226,7 @@ #define OSBA_MONO_STEREO_OUTPUT #define OSBA_AMBISONICS_OUT #define OSBA_LS_OUT +#define OSBA_BR_SWITCHING #endif /* ################## End BE DEVELOPMENT switches ######################### */ diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 8c7715361a..cc601bfec5 100755 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -390,13 +390,22 @@ ivas_error ivas_enc( #ifdef SBA_AND_OBJECTS else if ( ivas_format == SBA_ISM_FORMAT ) { - /*Default mode for OSBA*/ - // st_ivas->ism_mode = ISM_MODE_NONE; +#ifdef OSBA_BR_SWITCHING + ivas_osba_enc_reconfig( st_ivas ); +#endif +#ifndef OSBA_BR_SWITCHING if ( st_ivas->ism_mode == ISM_MODE_NONE ) /*rendering of objects in SBA signal*/ { +#endif /* Analyze objects and determine needed audio signals */ - ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order ); + ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order +#ifdef OSBA_BR_SWITCHING + , + hEncoderConfig->input_Fs +#endif + ); +#ifndef OSBA_BR_SWITCHING } else /*not an option for now*/ { @@ -409,6 +418,7 @@ ivas_error ivas_enc( #endif } +#endif if ( st_ivas->ism_mode == ISM_MODE_NONE ) { diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 67d14f1c35..17422e6d80 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -102,7 +102,11 @@ void ivas_write_format( #endif #ifdef SBA_AND_OBJECTS case SBA_ISM_FORMAT: +#ifdef OSBA_BR_SWITCHING + if ( st_ivas->hEncoderConfig->ivas_total_brate < IVAS_256k ) +#else if ( st_ivas->ism_mode == ISM_MODE_NONE ) +#endif { ind = 6; /* send SBA format */ nBits += extra_bits; diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index b6cfa5281f..93f16f46d8 100755 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -358,7 +358,7 @@ ivas_error ivas_ism_metadata_enc( /* write extended metadata presence flag */ #ifdef MASA_AND_OBJECTS #ifdef OSBA_DISC_OBJ_MCT - if ( (ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC) && *ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) + if ( ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC ) && *ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) #else if ( ism_mode == ISM_MODE_DISC && *ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) #endif @@ -879,6 +879,12 @@ ivas_error ivas_ism_metadata_enc_create( nchan_transport = MAX_PARAM_ISM_WAVE; ivas_set_omasa_TC( st_ivas->ism_mode, n_ISms, &st_ivas->nSCE, &st_ivas->nCPE ); } +#ifdef OSBA_BR_SWITCHING + else if ( st_ivas->hEncoderConfig->ivas_format == SBA_ISM_FORMAT ) + { + nchan_transport = n_ISms; + } +#endif else { #endif diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index af40bad663..fafc8fc858 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -470,7 +470,11 @@ ivas_error mct_enc_reconfigure( { hMCT->nchan_out_woLFE = ivas_param_mc_getNumTransportChannels( ivas_total_brate, st_ivas->hEncoderConfig->mc_input_setup ); } +#ifdef OSBA_BR_SWITCHING + else if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) +#else else if ( ivas_format == SBA_FORMAT ) +#endif { hMCT->nchan_out_woLFE = st_ivas->nchan_transport; } diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index 2e13bd1293..02081975e5 100755 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -113,9 +113,10 @@ ivas_error ivas_osba_enc_open( set_f( hOSba->prev_object_dm_gains[i], (float) sqrt( 0.5 ), MAX_INPUT_CHANNELS ); } #ifdef OSBA_DISC_OBJ_MCT - +#ifndef OSBA_BR_SWITCHING if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { +#endif len = NS2SA( st_ivas->hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ); for ( i = 0; i < st_ivas->hEncoderConfig->nchan_ism; i++ ) @@ -131,7 +132,9 @@ ivas_error ivas_osba_enc_open( { hOSba->input_data_mem[i] = NULL; } +#ifndef OSBA_BR_SWITCHING } +#endif #endif set_zero( hOSba->broadband_energy_sm, MAX_NUM_OBJECTS + FOA_CHANNELS ); set_zero( hOSba->broadband_energy_prev, MAX_NUM_OBJECTS + FOA_CHANNELS ); @@ -184,29 +187,195 @@ void ivas_osba_enc_close( /*--------------------------------------------------------------------------* - * ivas_osba_enc_config() + * ivas_osba_enc_reconfig() * - * oSBA encoder configuration + * oSBA encoder reconfiguration *--------------------------------------------------------------------------*/ -ivas_error ivas_osba_enc_config( +ivas_error ivas_osba_enc_reconfig( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ) { + int16_t n, nSCE_old, nCPE_old, nchan_transport_old, old_ism_mode; + int32_t ivas_total_brate; + ivas_error error; ENCODER_CONFIG_HANDLE hEncoderConfig; + error = IVAS_ERR_OK; hEncoderConfig = st_ivas->hEncoderConfig; + ivas_total_brate = hEncoderConfig->ivas_total_brate; - st_ivas->ism_mode = ISM_MODE_NONE; - - /* reconfiguration in case of bitrate switching */ - if ( hEncoderConfig->last_ivas_total_brate != hEncoderConfig->ivas_total_brate ) + if ( ivas_total_brate != hEncoderConfig->last_ivas_total_brate ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "bitrate switching not supported in OSBA yet" ); + DIRAC_ENC_HANDLE hDirAC = st_ivas->hDirAC; + SPAR_ENC_HANDLE hSpar; + int16_t analysis_order_old; + int16_t spar_reconfig_flag; + int16_t nbands_old; + int16_t ndir_old; + + spar_reconfig_flag = 0; + old_ism_mode = st_ivas->ism_mode; + if ( ivas_total_brate >= IVAS_256k ) + { + st_ivas->ism_mode = ISM_SBA_MODE_DISC; + } + else + { + st_ivas->ism_mode = ISM_MODE_NONE; + } + nchan_transport_old = st_ivas->nchan_transport; + nCPE_old = st_ivas->nCPE; + nSCE_old = st_ivas->nSCE; + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, hEncoderConfig->sba_order ); + analysis_order_old = ivas_sba_get_analysis_order( hEncoderConfig->last_ivas_total_brate, hEncoderConfig->sba_order ); + nbands_old = st_ivas->hQMetaData->q_direction->cfg.nbands; + ndir_old = st_ivas->hQMetaData->no_directions; + + if ( ( analysis_order_old != st_ivas->sba_analysis_order ) || ( old_ism_mode != st_ivas->ism_mode ) ) + { + int16_t i, n_old; + float **old_mem_hp20_in; + + n_old = st_ivas->hEncoderConfig->nchan_ism + ( analysis_order_old + 1 ) * ( analysis_order_old + 1 ); + n = st_ivas->hEncoderConfig->nchan_ism + ( st_ivas->sba_analysis_order + 1 ) * ( st_ivas->sba_analysis_order + 1 ); + + if ( n > n_old ) + { + /* save old mem_hp_20 pointer */ + old_mem_hp20_in = st_ivas->mem_hp20_in; + st_ivas->mem_hp20_in = NULL; + + if ( ( st_ivas->mem_hp20_in = (float **) malloc( n * sizeof( float * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); + } + + for ( i = 0; i < n_old; i++ ) + { + st_ivas->mem_hp20_in[i] = old_mem_hp20_in[i]; + old_mem_hp20_in[i] = NULL; + } + /* create additional hp20 memories */ + for ( ; i < n; i++ ) + { + if ( ( st_ivas->mem_hp20_in[i] = (float *) malloc( L_HP20_MEM * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); + } + + set_f( st_ivas->mem_hp20_in[i], 0.0f, L_HP20_MEM ); + } + + free( old_mem_hp20_in ); + old_mem_hp20_in = NULL; + } + else if ( n < n_old ) + { + /* save old mem_hp_20 pointer */ + old_mem_hp20_in = st_ivas->mem_hp20_in; + st_ivas->mem_hp20_in = NULL; + + if ( ( st_ivas->mem_hp20_in = (float **) malloc( n * sizeof( float * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); + } + + for ( i = 0; i < n; i++ ) + { + st_ivas->mem_hp20_in[i] = old_mem_hp20_in[i]; + old_mem_hp20_in[i] = NULL; + } + /* remove superfluous hp20 memories */ + for ( ; i < n_old; i++ ) + { + free( old_mem_hp20_in[i] ); + old_mem_hp20_in[i] = NULL; + } + + free( old_mem_hp20_in ); + old_mem_hp20_in = NULL; + } + } + ivas_spar_config( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), + &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); + hSpar = st_ivas->hSpar; + + if ( st_ivas->nchan_transport == 1 ) + { + hEncoderConfig->element_mode_init = IVAS_SCE; + } + else + { + hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; + } + if ( nchan_transport_old != st_ivas->nchan_transport || ( ivas_total_brate < IVAS_512k && hEncoderConfig->last_ivas_total_brate >= IVAS_512k ) || ( ivas_total_brate >= IVAS_512k && hEncoderConfig->last_ivas_total_brate < IVAS_512k ) ) + { + /* FB mixer handle */ + if ( hDirAC->hFbMixer != NULL ) + { + ivas_FB_mixer_close( &( hDirAC->hFbMixer ), hEncoderConfig->input_Fs, 0 ); + hDirAC->hFbMixer = NULL; + } + spar_reconfig_flag = 1; + ivas_spar_enc_close( &( st_ivas->hSpar ), hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp, spar_reconfig_flag ); + + if ( ( error = ivas_spar_enc_open( st_ivas, spar_reconfig_flag ) ) != IVAS_ERR_OK ) + { + return error; + } + } + st_ivas->hSpar->spar_reconfig_flag = spar_reconfig_flag; + if ( ( error = ivas_dirac_enc_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( st_ivas->hQMetaData->q_direction->cfg.nbands != nbands_old || st_ivas->hQMetaData->no_directions != ndir_old ) + { + int16_t dir, j, i; + IVAS_QDIRECTION *q_direction = st_ivas->hQMetaData->q_direction; + for ( dir = 0; dir < st_ivas->hQMetaData->no_directions; dir++ ) + { + for ( j = 0; j < q_direction[dir].cfg.nbands; j++ ) + { + for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + { + q_direction[dir].band_data[j].energy_ratio_index[i] = 0; + q_direction[dir].band_data[j].energy_ratio_index_mod[i] = 0; + } + } + } + } + hSpar->enc_param_start_band = hDirAC->hConfig->enc_param_start_band; + + /*-----------------------------------------------------------------* + * Allocate, initialize, and configure SCE/CPE/MCT handles + *-----------------------------------------------------------------*/ + if ( old_ism_mode == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + st_ivas->nchan_transport += st_ivas->hEncoderConfig->nchan_ism; + st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1; + } + else if ( old_ism_mode == ISM_SBA_MODE_DISC && st_ivas->ism_mode == ISM_MODE_NONE ) + { + nchan_transport_old += st_ivas->hEncoderConfig->nchan_ism; + } + else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + st_ivas->nchan_transport += st_ivas->hEncoderConfig->nchan_ism; + st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1; + nCPE_old = st_ivas->nCPE; + nchan_transport_old = st_ivas->nchan_transport; + } + + if ( ( error = ivas_corecoder_enc_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, ivas_total_brate / st_ivas->nchan_transport, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS, MC_MODE_NONE ) ) != IVAS_ERR_OK ) + { + return error; + } } - return IVAS_ERR_OK; + return error; } @@ -224,18 +393,50 @@ void ivas_osba_enc( const int16_t nchan_ism, /* i : Number of objects for parameter analysis */ const ISM_MODE ism_mode, /* i : ISM mode */ const int16_t sba_analysis_order /* i : SBA order evaluated in DirAC/SPAR encoder */ +#ifdef OSBA_BR_SWITCHING + , + const int32_t input_Fs /* i : input sampling rate*/ +#endif ) { float data_out_f[MAX_INPUT_CHANNELS][L_FRAME48k]; +#ifdef OSBA_BR_SWITCHING + int16_t n, delay_s; + delay_s = NS2SA( input_Fs, IVAS_FB_ENC_DELAY_NS ); +#endif if ( ism_mode == ISM_MODE_NONE ) { +#ifdef OSBA_BR_SWITCHING + /*keep the delay buffer up to date*/ + for ( n = 0; n < nchan_ism; n++ ) + { + mvr2r( &data_in_f[n][input_frame - delay_s], hOSba->input_data_mem[n], delay_s ); + } +#endif /* Convert ISM to SBA */ ivas_osba_render_ism_to_sba( data_in_f, data_out_f, input_frame, sba_analysis_order, nchan_ism, hIsmMeta, hOSba->prev_object_dm_gains, hOSba->interpolator ); /* Merge SBA signals */ ivas_merge_sba_transports( data_out_f, &( data_in_f[nchan_ism] ), data_in_f, input_frame, sba_analysis_order ); } +#ifdef OSBA_BR_SWITCHING + else + { + int16_t azimuth, elevation; + /* delay ISM input channels to match the SBA encoder delay */ + for ( n = 0; n < nchan_ism; n++ ) + { + delay_signal( data_in_f[n], input_frame, hOSba->input_data_mem[n], delay_s ); + + + /*keep prev gain upto date for bitrate switching*/ + azimuth = (int16_t) floorf( hIsmMeta[n]->azimuth + 0.5f ); + elevation = (int16_t) floorf( hIsmMeta[n]->elevation + 0.5f ); + ivas_dirac_dec_get_response( azimuth, elevation, hOSba->prev_object_dm_gains[n], sba_analysis_order ); + } + } +#endif /* Set the number of objects */ hOSba->nchan_ism = nchan_ism; -- GitLab From 20ff927975b52647e8dc3aec23d6e1270976adb5 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Tue, 8 Aug 2023 09:24:39 +0200 Subject: [PATCH 059/109] OSBA testvectors --- scripts/testv/stvOSBA_1ISM_2OA48c.wav | 3 +++ scripts/testv/stvOSBA_1ISM_3OA48c.wav | 3 +++ scripts/testv/stvOSBA_1ISM_FOA48c.wav | 3 +++ scripts/testv/stvOSBA_2ISM_2OA48c.wav | 3 +++ scripts/testv/stvOSBA_2ISM_3OA48c.wav | 3 +++ scripts/testv/stvOSBA_2ISM_FOA48c.wav | 3 +++ scripts/testv/stvOSBA_3ISM_2OA48c.wav | 3 +++ scripts/testv/stvOSBA_3ISM_3OA48c.wav | 3 +++ scripts/testv/stvOSBA_3ISM_FOA48c.wav | 3 +++ scripts/testv/stvOSBA_4ISM_2OA48c.wav | 3 +++ scripts/testv/stvOSBA_4ISM_3OA48c.wav | 3 +++ scripts/testv/stvOSBA_4ISM_FOA48c.wav | 3 +++ 12 files changed, 36 insertions(+) create mode 100644 scripts/testv/stvOSBA_1ISM_2OA48c.wav create mode 100644 scripts/testv/stvOSBA_1ISM_3OA48c.wav create mode 100644 scripts/testv/stvOSBA_1ISM_FOA48c.wav create mode 100644 scripts/testv/stvOSBA_2ISM_2OA48c.wav create mode 100644 scripts/testv/stvOSBA_2ISM_3OA48c.wav create mode 100644 scripts/testv/stvOSBA_2ISM_FOA48c.wav create mode 100644 scripts/testv/stvOSBA_3ISM_2OA48c.wav create mode 100644 scripts/testv/stvOSBA_3ISM_3OA48c.wav create mode 100644 scripts/testv/stvOSBA_3ISM_FOA48c.wav create mode 100644 scripts/testv/stvOSBA_4ISM_2OA48c.wav create mode 100644 scripts/testv/stvOSBA_4ISM_3OA48c.wav create mode 100644 scripts/testv/stvOSBA_4ISM_FOA48c.wav diff --git a/scripts/testv/stvOSBA_1ISM_2OA48c.wav b/scripts/testv/stvOSBA_1ISM_2OA48c.wav new file mode 100644 index 0000000000..29db3aa5dd --- /dev/null +++ b/scripts/testv/stvOSBA_1ISM_2OA48c.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7664fa3a3e2cabed85ee80cac657932509403f20df557f3228c81bd569da24f2 +size 19200558 diff --git a/scripts/testv/stvOSBA_1ISM_3OA48c.wav b/scripts/testv/stvOSBA_1ISM_3OA48c.wav new file mode 100644 index 0000000000..ec3db290da --- /dev/null +++ b/scripts/testv/stvOSBA_1ISM_3OA48c.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:79178d7cfe0601d5c30573b19718fd15681d6e98f4e54cf54608f35775c28fcc +size 32640908 diff --git a/scripts/testv/stvOSBA_1ISM_FOA48c.wav b/scripts/testv/stvOSBA_1ISM_FOA48c.wav new file mode 100644 index 0000000000..e13733b9d6 --- /dev/null +++ b/scripts/testv/stvOSBA_1ISM_FOA48c.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3635635d169efb32d5c13a732961cf786fa3413261376b47b7d7a1cb05b4353b +size 9600308 diff --git a/scripts/testv/stvOSBA_2ISM_2OA48c.wav b/scripts/testv/stvOSBA_2ISM_2OA48c.wav new file mode 100644 index 0000000000..950224b112 --- /dev/null +++ b/scripts/testv/stvOSBA_2ISM_2OA48c.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:489f5e16c9c0f1539304b05d65c16e901b271e51aa9f8cf50d5a17a78b094afa +size 21120608 diff --git a/scripts/testv/stvOSBA_2ISM_3OA48c.wav b/scripts/testv/stvOSBA_2ISM_3OA48c.wav new file mode 100644 index 0000000000..a4705b6a4b --- /dev/null +++ b/scripts/testv/stvOSBA_2ISM_3OA48c.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:57b26cedbb5a2e94147bb9e35030313c77a3fbbfae54c31249271c34646d6cea +size 34560958 diff --git a/scripts/testv/stvOSBA_2ISM_FOA48c.wav b/scripts/testv/stvOSBA_2ISM_FOA48c.wav new file mode 100644 index 0000000000..2462122747 --- /dev/null +++ b/scripts/testv/stvOSBA_2ISM_FOA48c.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9111e9152d64b07f664f9ec383d5025bb4dd8559c758763f4aad8850ddee07c6 +size 11520358 diff --git a/scripts/testv/stvOSBA_3ISM_2OA48c.wav b/scripts/testv/stvOSBA_3ISM_2OA48c.wav new file mode 100644 index 0000000000..060ee4dd8a --- /dev/null +++ b/scripts/testv/stvOSBA_3ISM_2OA48c.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:95538891804a01d3cef90f791380621946729fbd7211792e64c2f4dcd644748d +size 23040658 diff --git a/scripts/testv/stvOSBA_3ISM_3OA48c.wav b/scripts/testv/stvOSBA_3ISM_3OA48c.wav new file mode 100644 index 0000000000..fd42874d9e --- /dev/null +++ b/scripts/testv/stvOSBA_3ISM_3OA48c.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f37e3fcdcd1b0d65955e5f85626bb726de522ce9076fd5e13290093943c1f4f7 +size 36481008 diff --git a/scripts/testv/stvOSBA_3ISM_FOA48c.wav b/scripts/testv/stvOSBA_3ISM_FOA48c.wav new file mode 100644 index 0000000000..5b83e7e149 --- /dev/null +++ b/scripts/testv/stvOSBA_3ISM_FOA48c.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42934c64888b445fde28d8adf15588f4d5cad2952935da6902de63eff844b01c +size 13440408 diff --git a/scripts/testv/stvOSBA_4ISM_2OA48c.wav b/scripts/testv/stvOSBA_4ISM_2OA48c.wav new file mode 100644 index 0000000000..5e9b98fb41 --- /dev/null +++ b/scripts/testv/stvOSBA_4ISM_2OA48c.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5d9bfd27855b58648e3b2d690d748ef7bc6802cc185a1ba9aa89b1e29ed5be3a +size 24960708 diff --git a/scripts/testv/stvOSBA_4ISM_3OA48c.wav b/scripts/testv/stvOSBA_4ISM_3OA48c.wav new file mode 100644 index 0000000000..00505bfd77 --- /dev/null +++ b/scripts/testv/stvOSBA_4ISM_3OA48c.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f38c65c89564220f4e93fcefdf6e797541d2fe03066e980fd207681f3a7d4917 +size 38401058 diff --git a/scripts/testv/stvOSBA_4ISM_FOA48c.wav b/scripts/testv/stvOSBA_4ISM_FOA48c.wav new file mode 100644 index 0000000000..7f1be2e759 --- /dev/null +++ b/scripts/testv/stvOSBA_4ISM_FOA48c.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6e8a25490b47def9fe5b6f58c35ae2d103e166c397dfe48c55e1410d07c16a44 +size 15360458 -- GitLab From 3f22a95b905a70a835c52e6207f3a623e7f4b689 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Tue, 8 Aug 2023 10:16:12 +0200 Subject: [PATCH 060/109] add self-test cases for OSBA --- scripts/config/self_test.prm | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/scripts/config/self_test.prm b/scripts/config/self_test.prm index 205ff96f18..da812f373c 100644 --- a/scripts/config/self_test.prm +++ b/scripts/config/self_test.prm @@ -1365,3 +1365,55 @@ networkSimulator_g192 ../scripts/dly_error_profiles/dly_error_profile_5.dat bit ../IVAS_cod -ism_masa 4 2 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv testv/stv2MASA2TC48c.met ../scripts/switchPaths/sw_13k2_512k_2fr_start_384k_omasatechs_4ism.bin 48 testv/stvOMASA_4ISM_2MASA2TC48c.wav bit ../IVAS_dec BINAURAL_ROOM_REVERB 48 bit testv/stvOMASA_4ISM_2MASA2TC48c.wav_BINAURAL_ROOM_REVERB_sw_48-48.tst + +// OSBA FOA 1ISM at 32 kbps, 48kHz in, 48kHz out, BINAURAL out +../IVAS_cod -ism_sba 1 1 testv/stvISM1.csv 32000 48 testv/stvOSBA_1ISM_FOA48c.wav bit +../IVAS_dec BINAURAL 48 bit testv/stvOSBA_1ISM_FOA48c.wav_BINAURAL_32000_48-48.tst + +// OSBA FOA 2ISM at 64 kbps, 48kHz in, 48kHz out, HOA3 out +../IVAS_cod -ism_sba 2 1 testv/stvISM1.csv testv/stvISM2.csv 64000 48 testv/stvOSBA_2ISM_FOA48c.wav bit +../IVAS_dec HOA3 48 bit testv/stvOSBA_2ISM_FOA48c.wav_HOA3_64000_48-48.tst + +// OSBA FOA 3ISM at 128 kbps, 48kHz in, 48kHz out, 7_1_4 out +../IVAS_cod -ism_sba 3 1 testv/stvISM1.csv testv/stvISM1.csv testv/stvISM3.csv 128000 48 testv/stvOSBA_3ISM_FOA48c.wav bit +../IVAS_dec 7_1_4 48 bit testv/stvOSBA_3ISM_FOA48c.wav_7_1_4_128000_48-48.tst + +// OSBA FOA 4ISM at 256 kbps, 48kHz in, 48kHz out, EXT out +../IVAS_cod -ism_sba 4 1 testv/stvISM1.csv testv/stvISM1.csv testv/stvISM3.csv testv/stvISM4.csv 256000 48 testv/stvOSBA_4ISM_FOA48c.wav bit +../IVAS_dec EXT 48 bit testv/stvOSBA_4ISM_FOA48c.wav_EXT_256000_48-48.tst + +// OSBA FOA 4ISM at 512 kbps, 48kHz in, 48kHz out, BINAURAL out +../IVAS_cod -ism_sba 4 1 testv/stvISM1.csv testv/stvISM1.csv testv/stvISM3.csv testv/stvISM4.csv 512000 48 testv/stvOSBA_4ISM_FOA48c.wav bit +../IVAS_dec BINAURAL 48 bit testv/stvOSBA_4ISM_FOA48c.wav_BINAURAL_512000_48-48.tst + +// OSBA 2OA 1ISM at 24.4 kbps, 48kHz in, 48kHz out, FOA out +../IVAS_cod -ism_sba 1 2 testv/stvISM1.csv 24400 48 testv/stvOSBA_1ISM_2OA48c.wav bit +../IVAS_dec FOA 48 bit testv/stvOSBA_1ISM_2OA48c.wav_FOA_24400_48-48.tst + +// OSBA 2OA 2ISM at 48 kbps, 48kHz in, 48kHz out, MONO out +../IVAS_cod -ism_sba 2 2 testv/stvISM1.csv testv/stvISM2.csv 48000 48 testv/stvOSBA_2ISM_2OA48c.wav bit +../IVAS_dec MONO 48 bit testv/stvOSBA_2ISM_2OA48c.wav_MONO_48000_48-48.tst + +// OSBA 2OA 3ISM at 96 kbps, 48kHz in, 48kHz out, STEREO out +../IVAS_cod -ism_sba 3 2 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv 96000 48 testv/stvOSBA_3ISM_2OA48c.wav bit +../IVAS_dec STEREO 48 bit testv/stvOSBA_3ISM_2OA48c.wav_STEREO_96000_48-48.tst + +// OSBA 2OA 4ISM at 384 kbps, 48kHz in, 48kHz out, BINAURAL out +../IVAS_cod -ism_sba 4 2 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 384000 48 testv/stvOSBA_4ISM_2OA48c.wav bit +../IVAS_dec BINAURAL 48 bit testv/stvOSBA_4ISM_2OA48c.wav_BINAURAL_384000_48-48.tst + +// OSBA 3OA 1ISM at 512 kbps, 48kHz in, 48kHz out, EXT out +../IVAS_cod -ism_sba 1 3 testv/stvISM1.csv 512000 48 testv/stvOSBA_1ISM_3OA48c.wav bit +../IVAS_dec EXT 48 bit testv/stvOSBA_1ISM_3OA48c.wav_EXT_512000_48-48.tst + +// OSBA 3OA 2ISM at 256 kbps, 48kHz in, 48kHz out, 7_1 out +../IVAS_cod -ism_sba 2 3 testv/stvISM1.csv testv/stvISM2.csv 256000 48 testv/stvOSBA_2ISM_3OA48c.wav bit +../IVAS_dec 7_1 48 bit testv/stvOSBA_2ISM_3OA48c.wav_7_1_256000_48-48.tst + +// OSBA 3OA 3ISM at 128 kbps, 48kHz in, 48kHz out, BINAURAL out +../IVAS_cod -ism_sba 3 3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv 128000 48 testv/stvOSBA_3ISM_3OA48c.wav bit +../IVAS_dec BINAURAL 48 bit testv/stvOSBA_3ISM_3OA48c.wav_BINAURAL_128000_48-48.tst + +// OSBA 3OA 4ISM at 16.4 kbps, 48kHz in, 48kHz out, 5_1 out +../IVAS_cod -ism_sba 4 3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 16400 48 testv/stvOSBA_4ISM_3OA48c.wav bit +../IVAS_dec 5_1 48 bit testv/stvOSBA_4ISM_3OA48c.wav_5_1_16400_48-48.tst -- GitLab From bf2ee6cf5788432beb24199f9107cc5123c130be Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Tue, 8 Aug 2023 10:34:58 +0200 Subject: [PATCH 061/109] compiler warning --- lib_enc/ivas_osba_enc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index 02081975e5..68a51f0866 100755 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -197,7 +197,8 @@ ivas_error ivas_osba_enc_reconfig( ) { - int16_t n, nSCE_old, nCPE_old, nchan_transport_old, old_ism_mode; + int16_t n, nSCE_old, nCPE_old, nchan_transport_old; + ISM_MODE old_ism_mode; int32_t ivas_total_brate; ivas_error error; ENCODER_CONFIG_HANDLE hEncoderConfig; -- GitLab From 12d742dec5c58e7ac8c2a974b3ac05097ebf6025 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 8 Aug 2023 10:33:11 +0200 Subject: [PATCH 062/109] delete unused variables from struct ivas_osba_enc_data_structure --- lib_enc/ivas_osba_enc.c | 5 ----- lib_enc/ivas_stat_enc.h | 5 ----- 2 files changed, 10 deletions(-) diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index 02081975e5..915f7a67ab 100755 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -136,17 +136,12 @@ ivas_error ivas_osba_enc_open( } #endif #endif - set_zero( hOSba->broadband_energy_sm, MAX_NUM_OBJECTS + FOA_CHANNELS ); - set_zero( hOSba->broadband_energy_prev, MAX_NUM_OBJECTS + FOA_CHANNELS ); - hOSba->prev_selected_object = 0; hOSba->changing_object = 0; input_frame = (int16_t) ( st_ivas->hEncoderConfig->input_Fs / FRAMES_PER_SEC ); for ( i = 0; i < input_frame; i++ ) { hOSba->interpolator[i] = ( (float) i ) / ( (float) input_frame ); - hOSba->fade_out_gain[i] = ( 1.0f + cosf( ( (float) i ) / ( (float) input_frame ) * EVS_PI ) ) / 2.0f; - hOSba->fade_in_gain[i] = 1.0f - hOSba->fade_out_gain[i]; } st_ivas->hOSba = hOSba; diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 316e1382dd..94970cb09b 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -946,12 +946,7 @@ typedef struct ivas_osba_enc_data_structure float interpolator[L_FRAME48k]; float prev_object_dm_gains[MAX_NUM_OBJECTS][MAX_INPUT_CHANNELS]; - float broadband_energy_sm[MAX_NUM_OBJECTS + FOA_CHANNELS]; - float broadband_energy_prev[MAX_NUM_OBJECTS + FOA_CHANNELS]; - int16_t prev_selected_object; uint8_t changing_object; - float fade_out_gain[L_FRAME48k]; - float fade_in_gain[L_FRAME48k]; float energy_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* TODO Nokia: Make an own struct for these, and reserve it only when needed. */ float energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS]; -- GitLab From 4a1c01538b89beee6328771f0711dc526425e6f6 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 8 Aug 2023 10:42:43 +0200 Subject: [PATCH 063/109] delete more unused variables from struct ivas_osba_enc_data_structure --- lib_enc/ivas_osba_enc.c | 1 - lib_enc/ivas_stat_enc.h | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index d364f57bf3..7f0f6caf99 100755 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -136,7 +136,6 @@ ivas_error ivas_osba_enc_open( } #endif #endif - hOSba->changing_object = 0; input_frame = (int16_t) ( st_ivas->hEncoderConfig->input_Fs / FRAMES_PER_SEC ); for ( i = 0; i < input_frame; i++ ) diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 94970cb09b..1fc4bc85bd 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -946,9 +946,8 @@ typedef struct ivas_osba_enc_data_structure float interpolator[L_FRAME48k]; float prev_object_dm_gains[MAX_NUM_OBJECTS][MAX_INPUT_CHANNELS]; - uint8_t changing_object; - float energy_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* TODO Nokia: Make an own struct for these, and reserve it only when needed. */ + float energy_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; float energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS]; int16_t nchan_ism; -- GitLab From f4bc412cb51f900128a291860916d23230650d7c Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Tue, 8 Aug 2023 11:23:00 +0200 Subject: [PATCH 064/109] fix memory leak --- lib_enc/ivas_init_enc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 17422e6d80..94eceeaed9 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -367,6 +367,11 @@ void ivas_initialize_handles_enc( st_ivas->hOMasa = NULL; #endif +#ifdef SBA_AND_OBJECTS + /* OSBA handle */ + st_ivas->hOSba = NULL; +#endif + return; } @@ -1189,6 +1194,11 @@ void ivas_destroy_enc( ivas_omasa_enc_close( &( st_ivas->hOMasa ) ); #endif +#ifdef SBA_AND_OBJECTS + /* OSBA handle */ + ivas_osba_enc_close( &( st_ivas->hOSba ) ); +#endif + /* Stereo downmix for EVS encoder handle */ stereo_dmx_evs_close_encoder( &( st_ivas->hStereoDmxEVS ) ); -- GitLab From 10abfd0366881605bfea7b4877b318056bd05087 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 8 Aug 2023 11:36:03 +0200 Subject: [PATCH 065/109] delete unused function ivas_osba_energy_and_ratio_est --- lib_enc/ivas_osba_enc.c | 97 ----------------------------------------- 1 file changed, 97 deletions(-) diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index 7f0f6caf99..38728460f4 100755 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -50,8 +50,6 @@ * Local function prototypes *------------------------------------------------------------------------*/ -static void ivas_osba_energy_and_ratio_est( OSBA_ENC_HANDLE hOSba, float data_f[][L_FRAME48k], const int16_t input_frame, const int16_t nchan_inp ); - static void ivas_osba_render_ism_to_sba( float data_in_f[][L_FRAME48k], float data_out_f[][L_FRAME48k], const int16_t input_frame, const int16_t nchan_sba, const int16_t nchan_ism, ISM_METADATA_HANDLE hIsmMeta[], float prev_gains[][MAX_INPUT_CHANNELS], const float interpolator[L_FRAME48k] ); /*-------------------------------------------------------------------* @@ -443,101 +441,6 @@ void ivas_osba_enc( * Local functions *--------------------------------------------------------------------------*/ -/* Estimate energies and ratios */ -static void ivas_osba_energy_and_ratio_est( - OSBA_ENC_HANDLE hOSba, - float data_f[][L_FRAME48k], - const int16_t input_frame, - const int16_t nchan_inp ) -{ - int16_t ts, i, j, k; - int16_t num_freq_bands; - int16_t l_ts; - float *pcm_in[MAX_NUM_OBJECTS]; - float Chnl_RealBuffer[MAX_NUM_OBJECTS][DIRAC_NO_FB_BANDS_MAX]; - float Chnl_ImagBuffer[MAX_NUM_OBJECTS][DIRAC_NO_FB_BANDS_MAX]; - float *p_Chnl_RealBuffer[MAX_NUM_OBJECTS]; - float *p_Chnl_ImagBuffer[MAX_NUM_OBJECTS]; - int16_t block_m_idx; - int16_t mrange[2], brange[2]; - float tftile_energy; - float ism_ratio_sum; - - num_freq_bands = hOSba->nbands; - l_ts = input_frame / MDFT_NO_COL_MAX; - - for ( i = 0; i < nchan_inp; i++ ) - { - pcm_in[i] = &data_f[i][0]; - p_Chnl_RealBuffer[i] = &Chnl_RealBuffer[i][0]; - p_Chnl_ImagBuffer[i] = &Chnl_ImagBuffer[i][0]; - } - - /* do processing for all subframes */ - for ( block_m_idx = 0; block_m_idx < hOSba->nSubframes; block_m_idx++ ) - { - mrange[0] = hOSba->block_grouping[block_m_idx]; - mrange[1] = hOSba->block_grouping[block_m_idx + 1]; - - /* Reset variable */ - for ( i = 0; i < hOSba->nbands; i++ ) - { - set_zero( hOSba->energy_ratio_ism[block_m_idx][i], nchan_inp ); - } - set_zero( hOSba->energy_ism[block_m_idx], num_freq_bands ); - - /* Compute TF transform and energy */ - for ( ts = mrange[0]; ts < mrange[1]; ts++ ) - { - ivas_fb_mixer_get_windowed_fr( hOSba->hFbMixer, pcm_in, p_Chnl_RealBuffer, p_Chnl_ImagBuffer, l_ts, l_ts, hOSba->hFbMixer->fb_cfg->num_in_chans ); - - ivas_fb_mixer_update_prior_input( hOSba->hFbMixer, pcm_in, l_ts, hOSba->hFbMixer->fb_cfg->num_in_chans ); - - for ( i = 0; i < nchan_inp; i++ ) - { - pcm_in[i] += l_ts; - } - - for ( i = 0; i < num_freq_bands; i++ ) - { - brange[0] = hOSba->band_grouping[i]; - brange[1] = hOSba->band_grouping[i + 1]; - for ( j = brange[0]; j < brange[1]; j++ ) - { - for ( k = 0; k < nchan_inp; k++ ) - { - tftile_energy = Chnl_RealBuffer[k][j] * Chnl_RealBuffer[k][j] + Chnl_ImagBuffer[k][j] * Chnl_ImagBuffer[k][j]; - hOSba->energy_ism[block_m_idx][i] += tftile_energy; - hOSba->energy_ratio_ism[block_m_idx][i][k] += tftile_energy; - } - } - } - } - - /* Compute ISM energy ratios */ - for ( i = 0; i < num_freq_bands; i++ ) - { - ism_ratio_sum = 0.0f; - for ( j = 0; j < nchan_inp; j++ ) - { - hOSba->energy_ratio_ism[block_m_idx][i][j] /= ( hOSba->energy_ism[block_m_idx][i] + EPSILON ); - ism_ratio_sum += hOSba->energy_ratio_ism[block_m_idx][i][j]; - } - - if ( ism_ratio_sum == 0.0f ) - { - float temp_ism_ratio = 1.0f / ( (float) nchan_inp ); - for ( j = 0; j < nchan_inp; j++ ) - { - hOSba->energy_ratio_ism[block_m_idx][i][j] = temp_ism_ratio; - } - } - } - } - - return; -} - /* Render ISMs to SBA */ static void ivas_osba_render_ism_to_sba( float data_in_f[][L_FRAME48k], -- GitLab From fd410502547dd4453c36aa4793acd520696cec06 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 8 Aug 2023 12:05:47 +0200 Subject: [PATCH 066/109] fix usage printout for -ism_sba --- apps/encoder.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index b332d53863..4fa2b9a750 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -1943,11 +1943,10 @@ static void usage_enc( void ) fprintf( stdout, " where Ch specifies the number of MASA input/transport channels (1 or 2): \n" ); fprintf( stdout, " and File specifies input file containing parametric MASA metadata \n" ); #ifdef SBA_AND_OBJECTS - fprintf( stdout, "-ism_sba IsmChannels SBAChannels IsmFiles SBAFile : MASA and objects format \n" ); + fprintf( stdout, "-ism_sba IsmChannels SBAorder IsmFiles : SBA and ISM format \n" ); fprintf( stdout, " where IsmChannels specifies the number of ISms (1-4)\n" ); - fprintf( stdout, " and SBAChannels specifies the SBA order (1 to 3) \n" ); + fprintf( stdout, " and SBAorder specifies the SBA order (1 to 3) \n" ); fprintf( stdout, " and IsmFiles specify input files containing metadata, one file per object \n" ); - fprintf( stdout, " and SBAFile specifies SBA input file \n" ); #endif #ifdef MASA_AND_OBJECTS fprintf( stdout, "-ism_masa IsmCh MasaCh IsmFiles MasaFile : MASA and ISM format \n" ); -- GitLab From 8aa2f2a121660222d5bc9b8d4e9a670de104ed13 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 8 Aug 2023 13:46:16 +0200 Subject: [PATCH 067/109] delete TODO comment --- lib_enc/ivas_mct_core_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index fcf5f85d79..6e94650178 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -574,7 +574,7 @@ void ivas_mct_core_enc( #ifdef DEBUGGING format_bits = ( ivas_format == MC_FORMAT ? IVAS_FORMAT_SIGNALING_NBITS + MC_LS_SETUP_BITS : IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + SBA_ORDER_BITS + SBA_PLANAR_BITS ); #ifdef OSBA_DISC_OBJ_MCT - format_bits += ( ivas_format == SBA_ISM_FORMAT && nChannels > FOA_CHANNELS ); /*TODO needs to be rechecked when coding FOA*/ + format_bits += ( ivas_format == SBA_ISM_FORMAT && nChannels > FOA_CHANNELS ); #endif mct_bits += hMCT->nBitsMCT + hMCT->nchan_out_woLFE; assert( ( total_brate + ( NBITS_BWIDTH + format_bits + mct_bits + sba_meta + lfe_bits ) * FRAMES_PER_SEC ) == ivas_total_brate ); -- GitLab From 5112e7fe9ca4ea4dd3dddb1d247c87427d6057d2 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 8 Aug 2023 14:04:33 +0200 Subject: [PATCH 068/109] remove extraneous argument from ivas_osba_ism_metadata_dec --- lib_com/ivas_prot.h | 1 - lib_dec/ivas_dec.c | 5 ++--- lib_dec/ivas_osba_dec.c | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index ddacba77cd..8409d45240 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5696,7 +5696,6 @@ ivas_error ivas_osba_ism_metadata_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int32_t ism_total_brate, /* i : ISM total bitrate */ int16_t *nchan_ism, /* o : number of ISM separated channels */ - int16_t *nchan_transport_ism, /* o : number of ISM TCs */ int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ ); diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 4ab343a0d0..7ee2421477 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -681,14 +681,13 @@ ivas_error ivas_dec( #ifdef OSBA_DISC_OBJ_MCT else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { - int16_t nchan_ism, nchan_transport_ism; + int16_t nchan_ism; set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); - nchan_transport_ism = 1; #ifdef ENABLE_ISM_MD_CODING /* set ISM parameters and decode ISM metadata in OSBA format */ - if ( ( error = ivas_osba_ism_metadata_dec( st_ivas, ivas_total_brate, &nchan_ism, &nchan_transport_ism, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_osba_ism_metadata_dec( st_ivas, ivas_total_brate, &nchan_ism, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 130600201c..c343d47bbc 100755 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -225,15 +225,15 @@ ivas_error ivas_osba_ism_metadata_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int32_t ism_total_brate, /* i : ISM total bitrate */ int16_t *nchan_ism, /* o : number of ISM separated channels */ - int16_t *nchan_transport_ism, /* o : number of ISM TCs */ int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ ) { ivas_error error; + int16_t *nchan_transport_ism = 0; /* set ISM parameters */ - *nchan_ism = st_ivas->nchan_ism; *nchan_transport_ism = st_ivas->nchan_ism; + *nchan_ism = st_ivas->nchan_ism; /* decode ISM metadata */ -- GitLab From 79ad44ea78f2d8db960995ff021a1d648094aff2 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 8 Aug 2023 14:35:14 +0200 Subject: [PATCH 069/109] merge all sub-switches into SBA_AND_OBJECTS --- apps/decoder.c | 6 ++-- lib_com/bitstream.c | 2 +- lib_com/ivas_cnst.h | 10 +++---- lib_com/ivas_prot.h | 12 ++++---- lib_com/options.h | 11 +------ lib_dec/ivas_dec.c | 28 +++++++++--------- lib_dec/ivas_dirac_dec.c | 22 +++++++------- lib_dec/ivas_init_dec.c | 40 +++++++++++++------------- lib_dec/ivas_ism_metadata_dec.c | 18 ++++++------ lib_dec/ivas_jbm_dec.c | 4 +-- lib_dec/ivas_mct_dec.c | 12 ++++---- lib_dec/ivas_mono_dmx_renderer.c | 2 +- lib_dec/ivas_objectRenderer_internal.c | 6 ++-- lib_dec/ivas_omasa_dec.c | 2 +- lib_dec/ivas_osba_dec.c | 4 +-- lib_dec/ivas_output_config.c | 14 ++++----- lib_dec/ivas_sba_dirac_stereo_dec.c | 12 ++++---- lib_dec/ivas_sba_rendering_internal.c | 4 +-- lib_dec/ivas_spar_decoder.c | 10 +++---- lib_dec/ivas_stat_dec.h | 2 +- lib_dec/lib_dec.c | 12 ++++---- lib_dec/lib_dec.h | 2 +- lib_enc/ivas_enc.c | 18 ++++++------ lib_enc/ivas_init_enc.c | 8 +++--- lib_enc/ivas_ism_enc.c | 6 ++-- lib_enc/ivas_ism_metadata_enc.c | 32 ++++++++++----------- lib_enc/ivas_mct_core_enc.c | 2 +- lib_enc/ivas_mct_enc.c | 14 ++++----- lib_enc/ivas_osba_enc.c | 18 ++++++------ lib_enc/ivas_spar_encoder.c | 4 +-- lib_enc/ivas_stat_enc.h | 2 +- lib_rend/ivas_dirac_rend.c | 4 +-- lib_rend/ivas_objectRenderer.c | 6 ++-- 33 files changed, 170 insertions(+), 179 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 7fb162fac8..c3014262bf 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -81,7 +81,7 @@ static #define MAX_FRAME_SIZE ( 48000 / 50 ) #endif #define MAX_NUM_OUTPUT_CHANNELS 16 -#ifdef OSBA_EXT_OUT +#ifdef SBA_AND_OBJECTS #define MAX_OUTPUT_PCM_BUFFER_SIZE ( ( MAX_NUM_OUTPUT_CHANNELS + IVAS_MAX_NUM_OBJECTS ) * MAX_FRAME_SIZE ) #else #define MAX_OUTPUT_PCM_BUFFER_SIZE ( MAX_NUM_OUTPUT_CHANNELS * MAX_FRAME_SIZE ) @@ -1691,7 +1691,7 @@ static ivas_error initOnFirstGoodFrame( /* If outputting ISM, get number of objects, open output files and write zero metadata for initial bad frames */ #ifdef MASA_AND_OBJECTS if ( *pBsFormat == IVAS_DEC_BS_OBJ || *pBsFormat == IVAS_DEC_BS_MASA_ISM -#ifdef OSBA_EXT_OUT +#ifdef SBA_AND_OBJECTS || *pBsFormat == IVAS_DEC_BS_SBA_ISM #endif @@ -2108,7 +2108,7 @@ static ivas_error decodeG192( { #ifdef MASA_AND_OBJECTS if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_MASA_ISM -#ifdef OSBA_EXT_OUT +#ifdef SBA_AND_OBJECTS || bsFormat == IVAS_DEC_BS_SBA_ISM #endif ) diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index a6184beb60..726a9c3462 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -2994,7 +2994,7 @@ ivas_error preview_indices( ivas_sba_config( total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &( st_ivas->nSCE ), &( st_ivas->nCPE ), &( st_ivas->element_mode_init ) ); } -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { /* read number of objects from the bitstream */ diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 1d8abe8aac..4f4452b058 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -165,13 +165,13 @@ typedef enum RENDERER_BINAURAL_MIXER_CONV, RENDERER_BINAURAL_MIXER_CONV_ROOM, RENDERER_NON_DIEGETIC_DOWNMIX -#ifdef OSBA_MONO_STEREO_OUTPUT +#ifdef SBA_AND_OBJECTS , RENDERER_OSBA_STEREO #endif -#ifdef OSBA_AMBISONICS_OUT +#ifdef SBA_AND_OBJECTS , RENDERER_OSBA_AMBI #endif -#ifdef OSBA_LS_OUT +#ifdef SBA_AND_OBJECTS , RENDERER_OSBA_LS #endif } RENDERER_TYPE; @@ -429,7 +429,7 @@ typedef enum ISM_MASA_MODE_PARAM_ONE_OBJ, /* MASA ISM mode when one object is encoded separately and remainder using parametric object model */ ISM_MASA_MODE_DISC /* MASA ISM mode when all objects are encoded separarately */ #endif -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS , ISM_SBA_MODE_DISC /* MASA ISM mode when all objects are encoded separarately */ #endif @@ -1304,7 +1304,7 @@ typedef enum MASA_FRAME_4SF } MASA_FRAME_MODE; -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS #define NO_BITS_MASA_ISM_NO_OBJ 2 #endif /*----------------------------------------------------------------------------------* diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 8409d45240..fc097a3c9a 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1001,7 +1001,7 @@ ivas_error ivas_ism_metadata_enc( const int16_t flag_omasa_ener_brate, /* i : less bitrate for objects in OMASA flag */ int16_t *omasa_stereo_sw_cnt #endif -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS , const int16_t ini_frame #endif @@ -1020,7 +1020,7 @@ ivas_error ivas_ism_metadata_dec( const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */ int16_t *ism_extended_metadata_flag, /* i/o: Extended metadata active in renderer */ int16_t *ism_extmeta_cnt /* i/o: Number of change frames observed */ -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS , DEC_CORE_HANDLE st0 #endif ); @@ -3656,7 +3656,7 @@ void ivas_dirac_dec_read_BS( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial rendering data handle */ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q metadata */ int16_t *nb_bits, /* o : number of bits read */ -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS const int16_t last_bit_pos, /* i : last read bitstream position*/ #endif const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ @@ -5674,15 +5674,15 @@ void ivas_osba_enc( const int16_t nchan_ism, /* i : Number of objects for parameter analysis */ const ISM_MODE ism_mode, /* i : ISM mode */ const int16_t sba_analysis_order /* i : SBA order evaluated in DirAC/SPAR encoder */ -#ifdef OSBA_BR_SWITCHING +#ifdef SBA_AND_OBJECTS , const int32_t input_Fs /* i : input sampling rate*/ #endif ); -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS ivas_error ivas_masa_ism_data_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ); -ivas_error ivas_masa_ism_separate_object_renderer_open( +ivas_error ivas_sba_ism_separate_object_renderer_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); diff --git a/lib_com/options.h b/lib_com/options.h index 89f2376176..bf4ebc120b 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -218,16 +218,7 @@ #define MASA_AND_OBJECTS /* Nokia: Combination of MASA and objects */ -#define SBA_AND_OBJECTS -#ifdef SBA_AND_OBJECTS -#define OSBA_DISC_OBJ_MCT -#define ENABLE_ISM_MD_CODING -#define OSBA_EXT_OUT -#define OSBA_MONO_STEREO_OUTPUT -#define OSBA_AMBISONICS_OUT -#define OSBA_LS_OUT -#define OSBA_BR_SWITCHING -#endif +#define SBA_AND_OBJECTS /* FhG: Combined coding of SBA and objects*/ /* ################## End BE DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 7ee2421477..1b4bcad350 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -62,14 +62,14 @@ ivas_error ivas_dec( { int16_t n, output_frame, nchan_out; Decoder_State *st; /* used for bitstream handling */ -#ifdef OSBA_EXT_OUT +#ifdef SBA_AND_OBJECTS float output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; /* 'float' buffer for output synthesis, MAX_OUTPUT_CHANNELS channels */ #else float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; /* 'float' buffer for output synthesis, MAX_OUTPUT_CHANNELS channels */ #endif int16_t nchan_remapped; float output_lfe_ch[L_FRAME48k]; -#if defined MASA_AND_OBJECTS || defined OSBA_DISC_OBJ_MCT +#if defined MASA_AND_OBJECTS || defined SBA_AND_OBJECTS int16_t nb_bits_metadata[MAX_SCE + 1]; #else int16_t nb_bits_metadata[MAX_SCE]; @@ -78,7 +78,7 @@ ivas_error ivas_dec( AUDIO_CONFIG output_config; float pan_left, pan_right; ivas_error error; -#ifdef OSBA_EXT_OUT +#ifdef SBA_AND_OBJECTS float *p_output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; #else float *p_output[MAX_OUTPUT_CHANNELS]; @@ -121,7 +121,7 @@ ivas_error ivas_dec( output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); -#ifdef OSBA_EXT_OUT +#ifdef SBA_AND_OBJECTS if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL ) { for ( n = 0; n < nchan_out; n++ ) @@ -136,7 +136,7 @@ ivas_error ivas_dec( { p_output[n] = &output[n][0]; } -#ifdef OSBA_EXT_OUT +#ifdef SBA_AND_OBJECTS } #endif @@ -232,7 +232,7 @@ ivas_error ivas_dec( else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hDirAC->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS , st_ivas->hSCE[0]->hCoreCoder[0] #endif @@ -244,7 +244,7 @@ ivas_error ivas_dec( else /* ISM_MODE_DISC */ { if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS , st_ivas->hSCE[0]->hCoreCoder[0] #endif @@ -678,14 +678,14 @@ ivas_error ivas_dec( } } #endif -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { int16_t nchan_ism; set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); -#ifdef ENABLE_ISM_MD_CODING +#ifdef SBA_AND_OBJECTS /* set ISM parameters and decode ISM metadata in OSBA format */ if ( ( error = ivas_osba_ism_metadata_dec( st_ivas, ivas_total_brate, &nchan_ism, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) { @@ -706,7 +706,7 @@ ivas_error ivas_dec( return error; } -#ifdef OSBA_MONO_STEREO_OUTPUT +#ifdef SBA_AND_OBJECTS if ( st_ivas->sba_dirac_stereo_flag ) { ivas_agc_dec_process( st_ivas->hSpar->hAgcDec, &output[st_ivas->nchan_ism], &output[st_ivas->nchan_ism], st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); @@ -757,7 +757,7 @@ ivas_error ivas_dec( return error; } } -#ifdef OSBA_MONO_STEREO_OUTPUT +#ifdef SBA_AND_OBJECTS else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC && ( st_ivas->renderer_type == RENDERER_OSBA_STEREO || st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) ) { if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) @@ -781,7 +781,7 @@ ivas_error ivas_dec( } } #endif -#ifdef OSBA_AMBISONICS_OUT +#ifdef SBA_AND_OBJECTS else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI ) { float tmp_ism_out[MAX_OUTPUT_CHANNELS][L_FRAME48k]; @@ -809,7 +809,7 @@ ivas_error ivas_dec( } } #endif -#ifdef OSBA_LS_OUT +#ifdef SBA_AND_OBJECTS /* todo: almost the same path as for Ambisonics output. Should be merged at some point. */ else if ( st_ivas->renderer_type == RENDERER_OSBA_LS ) { @@ -840,7 +840,7 @@ ivas_error ivas_dec( #endif else /*EXT output = individual objects + HOA3*/ { -#ifdef OSBA_EXT_OUT +#ifdef SBA_AND_OBJECTS for ( n = 0; n < nchan_ism; n++ ) { delay_signal( output[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 13f0dcd88c..65416f4f5b 100755 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -102,7 +102,7 @@ static ivas_error ivas_dirac_dec_config_internal( if ( flag_config == DIRAC_OPEN ) { -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS hDirAC->spar_to_dirac_write_idx = ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) ? DELAY_DIRAC_PARAM_DEC_SFR : 0; #else hDirAC->spar_to_dirac_write_idx = st_ivas->ivas_format == SBA_FORMAT ? DELAY_DIRAC_PARAM_DEC_SFR : 0; @@ -174,7 +174,7 @@ static ivas_error ivas_dirac_rend_config( num_protos_diff_old = 0; nchan_transport_orig = st_ivas->nchan_transport; -#ifndef OSBA_DISC_OBJ_MCT +#ifndef SBA_AND_OBJECTS if ( st_ivas->ivas_format == SBA_FORMAT ) #else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) @@ -188,7 +188,7 @@ static ivas_error ivas_dirac_rend_config( { nchan_transport = 1; } -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( flag_config == DIRAC_RECONFIGURE && ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) ) #else if ( flag_config == DIRAC_RECONFIGURE && st_ivas->ivas_format == SBA_FORMAT ) @@ -876,10 +876,10 @@ ivas_error ivas_dirac_dec_config( case RENDERER_BINAURAL_FASTCONV_ROOM: case RENDERER_SBA_LINEAR_ENC: case RENDERER_SBA_LINEAR_DEC: -#ifdef OSBA_AMBISONICS_OUT +#ifdef SBA_AND_OBJECTS case RENDERER_OSBA_AMBI: #endif -#ifdef OSBA_LS_OUT +#ifdef SBA_AND_OBJECTS case RENDERER_OSBA_LS: #endif need_dirac_rend = 1; @@ -1089,7 +1089,7 @@ void ivas_dirac_dec_read_BS( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial rendering data handle */ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata */ int16_t *nb_bits, /* o : number of bits read */ -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS const int16_t last_bit_pos, /* i : last read bitstream position*/ #endif const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ @@ -1098,14 +1098,14 @@ void ivas_dirac_dec_read_BS( { int16_t i, j, b, dir, orig_dirac_bands; int16_t next_bit_pos_orig; -#ifndef OSBA_DISC_OBJ_MCT +#ifndef SBA_AND_OBJECTS *nb_bits = 0; #endif if ( !st->bfi && ivas_total_brate > IVAS_SID_5k2 ) { next_bit_pos_orig = st->next_bit_pos; st->next_bit_pos = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC - 1 ); -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( last_bit_pos > 0 ) { st->next_bit_pos = last_bit_pos; @@ -1869,7 +1869,7 @@ void ivas_dirac_dec_render_sf( #endif hodirac_flag = ivas_get_hodirac_flag( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ); -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( st_ivas->hQMetaData != NULL && st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) #else if ( st_ivas->hQMetaData != NULL && st_ivas->ivas_format != SBA_FORMAT ) @@ -2075,7 +2075,7 @@ void ivas_dirac_dec_render_sf( { md_idx = hSpatParamRendCom->render_to_md_map[subframe_idx]; } -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) #else if ( st_ivas->ivas_format == SBA_FORMAT ) @@ -2546,7 +2546,7 @@ void ivas_dirac_dec_render_sf( st_ivas->cldfbSynDec[ch] ); } } -#ifdef OSBA_EXT_OUT +#ifdef SBA_AND_OBJECTS else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) #else else if ( st_ivas->ivas_format == SBA_FORMAT ) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 448206f4ac..0f04ca330a 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -366,7 +366,7 @@ ivas_error ivas_dec_setup( } } #endif -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { /* the number of objects is written at the end of the bitstream, in the SBA metadata */ @@ -643,9 +643,9 @@ static ivas_error ivas_read_format( { if ( st_ivas->bit_stream[*num_bits_read] ) { -#if defined OSBA_DISC_OBJ_MCT || defined MASA_AND_OBJECTS +#if defined SBA_AND_OBJECTS || defined MASA_AND_OBJECTS ( *num_bits_read )++; -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( st_ivas->bit_stream[*num_bits_read] ) { st_ivas->ivas_format = SBA_ISM_FORMAT; @@ -998,7 +998,7 @@ ivas_error ivas_init_decoder( if ( output_config == AUDIO_CONFIG_EXTERNAL ) { -#ifdef OSBA_EXT_OUT +#ifdef SBA_AND_OBJECTS if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { hDecoderConfig->nchan_out = audioCfg2channels( AUDIO_CONFIG_HOA3 ); @@ -1029,7 +1029,7 @@ ivas_error ivas_init_decoder( ivas_output_init( &( st_ivas->hOutSetup ), output_config ); -#ifdef OSBA_EXT_OUT +#ifdef SBA_AND_OBJECTS if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL ) { st_ivas->hOutSetup.ambisonics_order = SBA_HOA3_ORDER; @@ -1355,7 +1355,7 @@ ivas_error ivas_init_decoder( /* set CNA/CNG flags */ ivas_sba_set_cna_cng_flag( st_ivas ); } -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { int32_t temp_brate[MAX_SCE]; @@ -1936,7 +1936,7 @@ ivas_error ivas_init_decoder( } #endif -#if defined OSBA_MONO_STEREO_OUTPUT || defined OSBA_AMBISONICS_OUT || defined OSBA_LS_OUT +#if defined SBA_AND_OBJECTS || defined SBA_AND_OBJECTS || defined SBA_AND_OBJECTS if ( ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->ism_mode == ISM_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) && #else @@ -1946,13 +1946,13 @@ ivas_error ivas_init_decoder( ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || -#ifdef OSBA_MONO_STEREO_OUTPUT +#ifdef SBA_AND_OBJECTS st_ivas->renderer_type == RENDERER_OSBA_STEREO || #endif -#ifdef OSBA_AMBISONICS_OUT +#ifdef SBA_AND_OBJECTS st_ivas->renderer_type == RENDERER_OSBA_AMBI || #endif -#ifdef OSBA_LS_OUT +#ifdef SBA_AND_OBJECTS st_ivas->renderer_type == RENDERER_OSBA_LS || #endif st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || @@ -1964,7 +1964,7 @@ ivas_error ivas_init_decoder( return error; } } -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) @@ -1976,7 +1976,7 @@ ivas_error ivas_init_decoder( } } /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ - if ( ( error = ivas_masa_ism_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sba_ism_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -2049,7 +2049,7 @@ ivas_error ivas_init_decoder( } /* CLDFB Interpolation weights */ -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !st_ivas->sba_dirac_stereo_flag && st_ivas->hDecoderConfig->nchan_out != 1 ) #else if ( st_ivas->ivas_format == SBA_FORMAT && !st_ivas->sba_dirac_stereo_flag && st_ivas->hDecoderConfig->nchan_out != 1 ) @@ -2334,7 +2334,7 @@ void ivas_initialize_handles_dec( st_ivas->hHrtfFastConv = NULL; st_ivas->hHrtfParambin = NULL; st_ivas->hoa_dec_mtx = NULL; -#if defined OSBA_DISC_OBJ_MCT || defined MASA_AND_OBJECTS +#if defined SBA_AND_OBJECTS || defined MASA_AND_OBJECTS st_ivas->hMasaIsmData = NULL; #endif @@ -2527,7 +2527,7 @@ void ivas_destroy_dec( free( st_ivas->hMonoDmxRenderer ); st_ivas->hMonoDmxRenderer = NULL; } -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS /* MASA ISM structure */ ivas_masa_ism_data_close( &st_ivas->hMasaIsmData ); #endif @@ -2630,7 +2630,7 @@ void ivas_init_dec_get_num_cldfb_instances( { *numCldfbAnalyses = st_ivas->nchan_transport + 1; } -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) @@ -2757,16 +2757,16 @@ void ivas_init_dec_get_num_cldfb_instances( case RENDERER_BINAURAL_MIXER_CONV_ROOM: case RENDERER_BINAURAL_FASTCONV: case RENDERER_BINAURAL_FASTCONV_ROOM: -#ifdef OSBA_MONO_STEREO_OUTPUT +#ifdef SBA_AND_OBJECTS case RENDERER_OSBA_STEREO: #endif -#ifdef OSBA_AMBISONICS_OUT +#ifdef SBA_AND_OBJECTS case RENDERER_OSBA_AMBI: #endif -#ifdef OSBA_LS_OUT +#ifdef SBA_AND_OBJECTS case RENDERER_OSBA_LS: #endif -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) #else if ( st_ivas->ivas_format == SBA_FORMAT ) diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index 3a0086324b..d801ad5f75 100755 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -150,7 +150,7 @@ ivas_error ivas_ism_metadata_dec( const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */ int16_t *ism_extmeta_active, /* i/o: Extended metadata active in renderer */ int16_t *ism_extmeta_cnt /* i/o: Number of change frames observed */ -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS , DEC_CORE_HANDLE st0 #endif @@ -159,7 +159,7 @@ ivas_error ivas_ism_metadata_dec( int16_t ch, nb_bits_start = 0, last_bit_pos; int16_t idx_radius; int32_t element_brate[MAX_NUM_OBJECTS], total_brate[MAX_NUM_OBJECTS]; -#ifndef OSBA_DISC_OBJ_MCT +#ifndef SBA_AND_OBJECTS DEC_CORE_HANDLE st0; #endif int16_t ism_extmeta_bitstream; @@ -184,7 +184,7 @@ ivas_error ivas_ism_metadata_dec( push_wmops( "ism_meta_dec" ); /* initialization */ -#ifndef OSBA_DISC_OBJ_MCT +#ifndef SBA_AND_OBJECTS st0 = hSCE[0]->hCoreCoder[0]; #endif ism_metadata_flag_global = 0; @@ -212,7 +212,7 @@ ivas_error ivas_ism_metadata_dec( /*----------------------------------------------------------------* * Read ISM common signaling *----------------------------------------------------------------*/ -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( ism_mode == ISM_SBA_MODE_DISC ) { /* number of objects was read in ivas_dec_setup() */ @@ -246,7 +246,7 @@ ivas_error ivas_ism_metadata_dec( /* read extended metadata presence flag */ #ifdef MASA_AND_OBJECTS -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( (ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC) && ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) #else if ( ism_mode == ISM_MODE_DISC && ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) @@ -283,7 +283,7 @@ ivas_error ivas_ism_metadata_dec( /* Read ISM metadata flags (one per object) */ for ( ch = 0; ch < *nchan_transport; ch++ ) { -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( ism_mode == ISM_SBA_MODE_DISC ) { ism_imp[ch] = get_next_indice( st0, 1 ); @@ -393,7 +393,7 @@ ivas_error ivas_ism_metadata_dec( { hIsmMetaData = hIsmMeta[ch]; if ( ism_mode == ISM_MODE_DISC -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS || ism_mode == ISM_SBA_MODE_DISC #endif #ifdef MASA_AND_OBJECTS @@ -486,7 +486,7 @@ ivas_error ivas_ism_metadata_dec( } /* save number of metadata bits read */ if ( ism_mode == ISM_MODE_DISC -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS || ism_mode == ISM_SBA_MODE_DISC #endif #ifdef MASA_AND_OBJECTS @@ -576,7 +576,7 @@ ivas_error ivas_ism_metadata_dec( hISMDTX.ism_dtx_hangover_cnt += 1; } -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( ism_mode == ISM_SBA_MODE_DISC ) { /* set the bitstream pointer to its original position */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 74d516169a..1f3c9e907b 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -158,7 +158,7 @@ ivas_error ivas_jbm_dec_tc( else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hDirAC->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS , st_ivas->hSCE[0]->hCoreCoder[0] #endif @@ -170,7 +170,7 @@ ivas_error ivas_jbm_dec_tc( else /* ISM_MODE_DISC */ { if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS , st_ivas->hSCE[0]->hCoreCoder[0] #endif diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 8e3864d505..0d9df5a053 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -160,7 +160,7 @@ ivas_error ivas_mct_dec( ivas_mct_core_dec( hMCT, st_ivas->hCPE, nCPE, output ); /* for sba to stereo output disable any further processing for TCs > 2 as it is not needed*/ -#ifdef OSBA_MONO_STEREO_OUTPUT +#ifdef SBA_AND_OBJECTS if ( st_ivas->sba_dirac_stereo_flag && st_ivas->ivas_format != SBA_ISM_FORMAT ) #else if ( st_ivas->sba_dirac_stereo_flag ) @@ -230,7 +230,7 @@ ivas_error ivas_mct_dec( for ( n = 0; n < CPE_CHANNELS; n++ ) { -#ifdef OSBA_MONO_STEREO_OUTPUT +#ifdef SBA_AND_OBJECTS if ( st_ivas->sba_dirac_stereo_flag && ( st_ivas->ivas_format != SBA_ISM_FORMAT || cpe_id >= nCPE - 2 ) ) #else if ( st_ivas->sba_dirac_stereo_flag ) @@ -240,7 +240,7 @@ ivas_error ivas_mct_dec( } /* Postprocessing for ACELP/MDCT core switching and synchronization */ -#ifdef OSBA_MONO_STEREO_OUTPUT +#ifdef SBA_AND_OBJECTS if ( ( error = core_switching_post_dec( sts[n], synth[n], output[cpe_id * CPE_CHANNELS + n], hCPE->output_mem[1], st_ivas->ivas_format, 0, output_frame, 0 /*core_switching_flag*/, ( st_ivas->ivas_format != SBA_ISM_FORMAT || cpe_id >= nCPE - 2 ) ? st_ivas->sba_dirac_stereo_flag : 0, -1, hCPE->last_element_mode ) ) != IVAS_ERR_OK ) #else if ( ( error = core_switching_post_dec( sts[n], synth[n], output[cpe_id * CPE_CHANNELS + n], hCPE->output_mem[1], st_ivas->ivas_format, 0, output_frame, 0 /*core_switching_flag*/, st_ivas->sba_dirac_stereo_flag, -1, hCPE->last_element_mode ) ) != IVAS_ERR_OK ) @@ -265,7 +265,7 @@ ivas_error ivas_mct_dec( /* synthesis synchronization between stereo modes */ -#ifdef OSBA_MONO_STEREO_OUTPUT +#ifdef SBA_AND_OBJECTS if ( !st_ivas->sba_dirac_stereo_flag || ( st_ivas->ivas_format == SBA_ISM_FORMAT && cpe_id < nCPE - 2 ) ) #else if ( !st_ivas->sba_dirac_stereo_flag ) @@ -347,13 +347,13 @@ ivas_error create_mct_dec( /* Determine active channels */ if ( ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC ) || st_ivas->ivas_format == SBA_FORMAT -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS || st_ivas->ivas_format == SBA_ISM_FORMAT #endif ) { hMCT->nchan_out_woLFE = st_ivas->nchan_transport; -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { hMCT->nchan_out_woLFE += st_ivas->nchan_ism; diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 956b52cdad..9937c9b855 100755 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -94,7 +94,7 @@ void ivas_mono_downmix_render_passive( MONO_DOWNMIX_RENDERER_HANDLE hDownmix; numInputChannels = st_ivas->nSCE; -#ifdef OSBA_MONO_STEREO_OUTPUT +#ifdef SBA_AND_OBJECTS if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { numInputChannels = st_ivas->nchan_ism; diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index a4ac2cba54..7b323e9d2b 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -86,13 +86,13 @@ ivas_error ivas_td_binaural_renderer( ) { int16_t ism_md_subframe_update; -#if defined OSBA_DISC_OBJ_MCT || defined MASA_AND_OBJECTS +#if defined SBA_AND_OBJECTS || defined MASA_AND_OBJECTS int16_t nchan_transport; #endif #if defined MASA_AND_OBJECTS nchan_transport = ( st_ivas->ism_mode == ISM_MASA_MODE_DISC -#if defined OSBA_DISC_OBJ_MCT +#if defined SBA_AND_OBJECTS || st_ivas->ism_mode == ISM_SBA_MODE_DISC #endif ) @@ -120,7 +120,7 @@ ivas_error ivas_td_binaural_renderer( st_ivas->hReverb, st_ivas->transport_config, st_ivas->hBinRendererTd, -#if defined OSBA_DISC_OBJ_MCT || defined MASA_AND_OBJECTS +#if defined SBA_AND_OBJECTS || defined MASA_AND_OBJECTS nchan_transport, #else st_ivas->nchan_transport, diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index d21a6ea754..028513e20b 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -513,7 +513,7 @@ ivas_error ivas_omasa_ism_metadata_dec( /* decode ISM metadata */ if ( ( error = ivas_ism_metadata_dec( ism_total_brate, *nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS , st_ivas->hSCE[0]->hCoreCoder[0] #endif diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index c343d47bbc..553274bf06 100755 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -42,7 +42,7 @@ #endif -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS /*-------------------------------------------------------------------* * ivas_masa_ism_data_open() @@ -105,7 +105,7 @@ void ivas_masa_ism_data_close( * Open structures, reserve memory, and init values. *-------------------------------------------------------------------------*/ -ivas_error ivas_masa_ism_separate_object_renderer_open( +ivas_error ivas_sba_ism_separate_object_renderer_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index c342cbcfe2..468c3f7c35 100755 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -155,7 +155,7 @@ void ivas_renderer_select( #ifdef MASA_AND_OBJECTS || st_ivas->ivas_format == MASA_ISM_FORMAT #endif -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS || ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) #else || ( st_ivas->ivas_format == SBA_FORMAT @@ -176,7 +176,7 @@ void ivas_renderer_select( *renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM; } } -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) #else else if ( st_ivas->ivas_format == SBA_FORMAT ) @@ -403,7 +403,7 @@ void ivas_renderer_select( } } } -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS else if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) #else else if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == SBA_FORMAT ) @@ -448,7 +448,7 @@ void ivas_renderer_select( { *renderer_type = RENDERER_SBA_LINEAR_DEC; } -#ifdef OSBA_MONO_STEREO_OUTPUT +#ifdef SBA_AND_OBJECTS else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_STEREO ) { *renderer_type = RENDERER_OSBA_STEREO; @@ -458,19 +458,19 @@ void ivas_renderer_select( *renderer_type = RENDERER_MONO_DOWNMIX; } #endif -#ifdef OSBA_AMBISONICS_OUT +#ifdef SBA_AND_OBJECTS else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 ) ) { *renderer_type = RENDERER_OSBA_AMBI; } #endif -#ifdef OSBA_LS_OUT +#ifdef SBA_AND_OBJECTS else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && ( output_config == AUDIO_CONFIG_5_1 || output_config == AUDIO_CONFIG_5_1_2 || output_config == AUDIO_CONFIG_5_1_4 || output_config == AUDIO_CONFIG_7_1 || output_config == AUDIO_CONFIG_7_1_4 || output_config == AUDIO_CONFIG_LS_CUSTOM ) ) { *renderer_type = RENDERER_OSBA_LS; } #endif -#ifdef OSBA_EXT_OUT +#ifdef SBA_AND_OBJECTS else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL ) { *renderer_type = RENDERER_SBA_LINEAR_DEC; diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c index 4ff17b75c8..1b12db0e6d 100755 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -78,7 +78,7 @@ int16_t ivas_get_sba_dirac_stereo_flag( } } } -#ifdef OSBA_MONO_STEREO_OUTPUT +#ifdef SBA_AND_OBJECTS else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { if ( output_config == AUDIO_CONFIG_STEREO ) @@ -858,7 +858,7 @@ void ivas_sba_dirac_stereo_dec( memOffset = NS2SA( output_frame * FRAMES_PER_SEC, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); ivas_sba_dirac_stereo_config( hStereoDft->hConfig ); -#ifdef OSBA_MONO_STEREO_OUTPUT +#ifdef SBA_AND_OBJECTS hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, st_ivas->hDecoderConfig->output_Fs, hStereoDft->NFFT, ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !mcmasa ) ); #else hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, st_ivas->hDecoderConfig->output_Fs, hStereoDft->NFFT, ( st_ivas->ivas_format == SBA_FORMAT && !mcmasa ) ); @@ -886,14 +886,14 @@ void ivas_sba_dirac_stereo_dec( /* mapping of DirAC parameters (azimuth, elevation, diffuseness) to DFT Stereo parameters (side gain, prediction gain) */ map_params_dirac_to_stereo( hStereoDft, st_ivas->hQMetaData, tmp_synth, DFT[0], st_ivas->ivas_format == MC_FORMAT, -#ifdef OSBA_MONO_STEREO_OUTPUT +#ifdef SBA_AND_OBJECTS ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ) ? hSCE->hCoreCoder[0]->L_frame : output_frame, ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ) ); #else ( st_ivas->ivas_format != SBA_FORMAT || mcmasa ) ? hSCE->hCoreCoder[0]->L_frame : output_frame, ( st_ivas->ivas_format != SBA_FORMAT || mcmasa ) ); #endif -#ifdef OSBA_MONO_STEREO_OUTPUT +#ifdef SBA_AND_OBJECTS if ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !mcmasa ) #else if ( st_ivas->ivas_format == SBA_FORMAT && !mcmasa ) @@ -945,7 +945,7 @@ void ivas_sba_dirac_stereo_dec( ivas_sba_dirac_stereo_compute_hb_gain( hStereoDft, hb_gain ); ivas_sba_dirac_stereo_upmix_hb( hb_synth_stereo, hSCE->save_hb_synth, hb_gain, output_frame, -#ifdef OSBA_MONO_STEREO_OUTPUT +#ifdef SBA_AND_OBJECTS ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ), sba_mono_flag, hSCE->hCoreCoder[0]->bwidth, hStereoDft ); #else ( st_ivas->ivas_format != SBA_FORMAT || mcmasa ), sba_mono_flag, hSCE->hCoreCoder[0]->bwidth, hStereoDft ); @@ -958,7 +958,7 @@ void ivas_sba_dirac_stereo_dec( v_add( output[1], hb_synth_stereo[1], output[1], output_frame ); /* apply TD Stereo Filling as is done in ICBWE */ -#ifdef OSBA_MONO_STEREO_OUTPUT +#ifdef SBA_AND_OBJECTS ivas_sba_dirac_stereo_apply_td_stefi( hStereoDft, output, output_frame, ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !mcmasa ) ); #else ivas_sba_dirac_stereo_apply_td_stefi( hStereoDft, output, output_frame, ( st_ivas->ivas_format == SBA_FORMAT && !mcmasa ) ); diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 349e8d73bd..92420b92ef 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -406,7 +406,7 @@ void ivas_sba_upmixer_renderer( { float *output_f[MAX_OUTPUT_CHANNELS]; int16_t ch; -#ifdef OSBA_EXT_OUT +#ifdef SBA_AND_OBJECTS AUDIO_CONFIG output_config; output_config = ( st_ivas->ivas_format == SBA_ISM_FORMAT ? st_ivas->hOutSetup.output_config : st_ivas->hDecoderConfig->output_config ); @@ -416,7 +416,7 @@ void ivas_sba_upmixer_renderer( { output_f[ch] = output[ch]; } -#ifdef OSBA_EXT_OUT +#ifdef SBA_AND_OBJECTS ivas_sba_linear_renderer( output_f, output_frame, st_ivas->hIntSetup.nchan_out_woLFE, output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); #else 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 ); diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 2ac8e408c2..c3033c765a 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -322,10 +322,10 @@ ivas_error ivas_spar_dec( bit_stream_orig = st0->bit_stream; next_bit_pos_orig = st0->next_bit_pos; -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { -#ifndef ENABLE_ISM_MD_CODING +#ifndef SBA_AND_OBJECTS last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ); /* the number of objects was read */ last_bit_pos -= NO_BITS_MASA_ISM_NO_OBJ; @@ -344,14 +344,14 @@ ivas_error ivas_spar_dec( /* read DirAC bitstream */ if ( st_ivas->hQMetaData != NULL ) { -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS ivas_dirac_dec_read_BS( hDecoderConfig->ivas_total_brate, st0, st_ivas->hDirAC, st_ivas->hSpatParamRendCom, st_ivas->hQMetaData, nb_bits_read, last_bit_pos, ivas_get_hodirac_flag( hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ), st_ivas->hSpar->dirac_to_spar_md_bands ); #else ivas_dirac_dec_read_BS( hDecoderConfig->ivas_total_brate, st0, st_ivas->hDirAC, st_ivas->hSpatParamRendCom, st_ivas->hQMetaData, nb_bits_read, ivas_get_hodirac_flag( hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ), st_ivas->hSpar->dirac_to_spar_md_bands ); #endif } -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - nb_bits_read[1]; @@ -360,7 +360,7 @@ ivas_error ivas_spar_dec( { #endif last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ); -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS } #endif if ( !st0->bfi && hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 ) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index bb432ee3fb..cb56d7afad 100755 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1074,7 +1074,7 @@ typedef struct Decoder_Struct COMBINED_ORIENTATION_HANDLE hCombinedOrientationData; /* Combined external and head orientation data structure */ DIRAC_REND_HANDLE hDirACRend; /* DirAC renderer handle */ SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; /* Spatial parametric (DirAC rend, ParamBin, ParamISM) rendering common data handle. */ -#if defined OSBA_DISC_OBJ_MCT || defined MASA_AND_OBJECTS +#if defined SBA_AND_OBJECTS || defined MASA_AND_OBJECTS MASA_ISM_DATA_HANDLE hMasaIsmData; #endif #ifdef MASA_AND_OBJECTS diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index b66dda5681..eeee5dd4b1 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -495,7 +495,7 @@ static IVAS_DEC_BS_FORMAT mapIvasFormat( return IVAS_DEC_BS_MC; case SBA_FORMAT: return IVAS_DEC_BS_SBA; -#ifdef OSBA_EXT_OUT +#ifdef SBA_AND_OBJECTS case SBA_ISM_FORMAT: return IVAS_DEC_BS_SBA_ISM; #endif @@ -1100,7 +1100,7 @@ ivas_error IVAS_DEC_GetNumObjects( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT -#ifdef OSBA_EXT_OUT +#ifdef SBA_AND_OBJECTS || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT #endif #ifdef MASA_AND_OBJECTS @@ -1108,7 +1108,7 @@ ivas_error IVAS_DEC_GetNumObjects( #endif ) { -#if defined OSBA_EXT_OUT || defined MASA_AND_OBJECTS +#if defined SBA_AND_OBJECTS || defined MASA_AND_OBJECTS *numObjects = hIvasDec->st_ivas->nchan_ism; #else *numObjects = hIvasDec->st_ivas->hDecoderConfig->nchan_out; @@ -1198,7 +1198,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( #ifdef MASA_AND_OBJECTS && st_ivas->ivas_format != MASA_ISM_FORMAT #endif -#ifdef OSBA_EXT_OUT +#ifdef SBA_AND_OBJECTS && st_ivas->ivas_format != SBA_ISM_FORMAT #endif ) @@ -1206,7 +1206,7 @@ ivas_error IVAS_DEC_GetObjectMetadata( return IVAS_ERR_WRONG_MODE; } -#if defined OSBA_EXT_OUT || defined MASA_AND_OBJECTS +#if defined SBA_AND_OBJECTS || defined MASA_AND_OBJECTS if ( objectIdx >= st_ivas->nchan_ism ) #else if ( objectIdx >= st_ivas->hDecoderConfig->nchan_out ) @@ -2743,7 +2743,7 @@ static ivas_error printConfigInfo_dec( { fprintf( stdout, "Input configuration: Scene Based Audio, Ambisonic order %i%s, %d transport channel(s)\n", st_ivas->sba_order, st_ivas->sba_planar ? " (Planar)" : "", st_ivas->nchan_transport ); } -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { fprintf( stdout, "Input configuration: Combined Scene Based Audio, Ambisonic order %i, with %d Objects \n", st_ivas->sba_order, st_ivas->nchan_ism ); diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 3ebce86ff3..12ca06607f 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -114,7 +114,7 @@ typedef enum _IVAS_DEC_BS_FORMAT IVAS_DEC_BS_STEREO, IVAS_DEC_BS_MC, IVAS_DEC_BS_SBA, -#ifdef OSBA_EXT_OUT +#ifdef SBA_AND_OBJECTS IVAS_DEC_BS_SBA_ISM, #endif IVAS_DEC_BS_OBJ, diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index cc601bfec5..e15c4fb797 100755 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -390,26 +390,26 @@ ivas_error ivas_enc( #ifdef SBA_AND_OBJECTS else if ( ivas_format == SBA_ISM_FORMAT ) { -#ifdef OSBA_BR_SWITCHING +#ifdef SBA_AND_OBJECTS ivas_osba_enc_reconfig( st_ivas ); #endif -#ifndef OSBA_BR_SWITCHING +#ifndef SBA_AND_OBJECTS if ( st_ivas->ism_mode == ISM_MODE_NONE ) /*rendering of objects in SBA signal*/ { #endif /* Analyze objects and determine needed audio signals */ ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order -#ifdef OSBA_BR_SWITCHING +#ifdef SBA_AND_OBJECTS , hEncoderConfig->input_Fs #endif ); -#ifndef OSBA_BR_SWITCHING +#ifndef SBA_AND_OBJECTS } else /*not an option for now*/ { -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS /* delay ISM input channels to match the SBA encoder delay */ for ( n = 0; n < hEncoderConfig->nchan_ism; n++ ) { @@ -474,8 +474,8 @@ ivas_error ivas_enc( n = hEncoderConfig->nchan_ism; st = st_ivas->hCPE[0]->hCoreCoder[0]; hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; -#ifdef OSBA_DISC_OBJ_MCT -#ifdef ENABLE_ISM_MD_CODING +#ifdef SBA_AND_OBJECTS +#ifdef SBA_AND_OBJECTS if ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode != ISM_MODE_NONE ) { /* write the number of objects in ISM_SBA format*/ @@ -483,9 +483,9 @@ ivas_error ivas_enc( } #endif #endif -#ifdef ENABLE_ISM_MD_CODING +#ifdef SBA_AND_OBJECTS if ( ( error = ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -1, 0, NULL -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS , st->ini_frame #endif diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 94eceeaed9..b3f078f409 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -102,7 +102,7 @@ void ivas_write_format( #endif #ifdef SBA_AND_OBJECTS case SBA_ISM_FORMAT: -#ifdef OSBA_BR_SWITCHING +#ifdef SBA_AND_OBJECTS if ( st_ivas->hEncoderConfig->ivas_total_brate < IVAS_256k ) #else if ( st_ivas->ism_mode == ISM_MODE_NONE ) @@ -670,7 +670,7 @@ ivas_error ivas_init_encoder( int32_t element_brate_tmp[MAX_NUM_OBJECTS]; st_ivas->ism_mode = ISM_MODE_NONE; -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( ivas_total_brate >= IVAS_256k ) { st_ivas->ism_mode = ISM_SBA_MODE_DISC; @@ -748,7 +748,7 @@ ivas_error ivas_init_encoder( return error; } } -#ifndef OSBA_DISC_OBJ_MCT +#ifndef SBA_AND_OBJECTS if ( st_ivas->ism_mode == ISM_MODE_NONE ) { #endif @@ -756,7 +756,7 @@ ivas_error ivas_init_encoder( { return error; } -#ifndef OSBA_DISC_OBJ_MCT +#ifndef SBA_AND_OBJECTS } #endif } diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index d0ea5a45ba..5b95543061 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -250,7 +250,7 @@ ivas_error ivas_ism_enc( #ifdef MASA_AND_OBJECTS ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -1, 0, NULL -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS , st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame #endif @@ -279,7 +279,7 @@ ivas_error ivas_ism_enc( ivas_ism_metadata_enc( &ism_total_brate, nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata, vad_flag, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, st_ivas->hMasa != NULL ? st_ivas->hMasa->data.hOmasaData->lp_noise_CPE : 0, flag_omasa_ener_brate, st_ivas->hMasa != NULL ? &( st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt ) : NULL -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS , st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame #endif @@ -307,7 +307,7 @@ ivas_error ivas_ism_enc( ivas_write_format_sid( st_ivas->hEncoderConfig->ivas_format, IVAS_SCE, st->hBstr ); } -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS /*only metadata encoding is needed for this case*/ if ( st_ivas->hEncoderConfig->ivas_format == SBA_ISM_FORMAT ) { diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index 93f16f46d8..9ee8effec3 100755 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -189,7 +189,7 @@ ivas_error ivas_ism_metadata_enc( const int16_t flag_omasa_ener_brate, /* i : less bitrate for objects in OMASA flag */ int16_t *omasa_stereo_sw_cnt #endif -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS , const int16_t ini_frame #endif @@ -254,7 +254,7 @@ ivas_error ivas_ism_metadata_enc( } #ifdef MASA_AND_OBJECTS else if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS || ism_mode == ISM_SBA_MODE_DISC #endif ) @@ -266,7 +266,7 @@ ivas_error ivas_ism_metadata_enc( if ( hIsmMeta[ch]->ism_metadata_flag == 1 ) { -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( ism_mode != ISM_SBA_MODE_DISC ) #endif { @@ -314,7 +314,7 @@ ivas_error ivas_ism_metadata_enc( /*----------------------------------------------------------------* * Rate importance of particular ISM streams *----------------------------------------------------------------*/ -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( ism_mode != ISM_SBA_MODE_DISC ) { rate_ism_importance( nchan_transport, hIsmMeta, hSCE, lowrate_metadata_flag, ism_imp ); @@ -332,7 +332,7 @@ ivas_error ivas_ism_metadata_enc( #ifdef MASA_AND_OBJECTS if ( ism_mode != ISM_MASA_MODE_DISC && ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS && ism_mode != ISM_SBA_MODE_DISC #endif ) @@ -357,7 +357,7 @@ ivas_error ivas_ism_metadata_enc( /* write extended metadata presence flag */ #ifdef MASA_AND_OBJECTS -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC ) && *ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) #else if ( ism_mode == ISM_MODE_DISC && *ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) @@ -387,7 +387,7 @@ ivas_error ivas_ism_metadata_enc( hIsmMeta[ch]->ism_md_lowrate_flag = lowrate_metadata_flag[ch]; } else -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( ism_mode != ISM_SBA_MODE_DISC ) #endif { @@ -417,7 +417,7 @@ ivas_error ivas_ism_metadata_enc( #ifdef MASA_AND_OBJECTS } #endif -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS else /*ism_mode == ISM_SBA_MODE_DISC*/ { /* all objects are considered active*/ @@ -447,7 +447,7 @@ ivas_error ivas_ism_metadata_enc( hIsmMetaData = hIsmMeta[ch]; #ifdef MASA_AND_OBJECTS if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS || ism_mode == ISM_SBA_MODE_DISC #endif ) @@ -490,7 +490,7 @@ ivas_error ivas_ism_metadata_enc( { #ifdef MASA_AND_OBJECTS if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS || ism_mode == ISM_SBA_MODE_DISC #endif ) @@ -506,7 +506,7 @@ ivas_error ivas_ism_metadata_enc( idx_angle1_abs = hParamIsm->azi_index[ch]; idx_angle2_abs = hParamIsm->ele_index[ch]; } -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS encode_angle_indices( hBstr, &( hIsmMetaData->position_angle ), hIsmMetaData->last_ism_metadata_flag, ini_frame, idx_angle1_abs, idx_angle2_abs, &flag_abs_azimuth[ch], &flag_abs_elevation[ch] ); #else encode_angle_indices( hBstr, &( hIsmMetaData->position_angle ), hIsmMetaData->last_ism_metadata_flag, hSCE[0]->hCoreCoder[0]->ini_frame, idx_angle1_abs, idx_angle2_abs, &flag_abs_azimuth[ch], &flag_abs_elevation[ch] ); @@ -515,7 +515,7 @@ ivas_error ivas_ism_metadata_enc( /*----------------------------------------------------------------* * Quantize and encode radius, yaw, and pitch *----------------------------------------------------------------*/ -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC ) && ism_extended_metadata_flag ) #else if ( ism_mode == ISM_MODE_DISC && ism_extended_metadata_flag ) @@ -525,7 +525,7 @@ ivas_error ivas_ism_metadata_enc( idx_angle2_abs = ism_quant_meta( hIsmMetaData->pitch, &valQ, ism_elevation_borders, ISM_Q_STEP, ISM_Q_STEP_BORDER, 1 << ISM_ELEVATION_NBITS ); idx_radius_abs = usquant( hIsmMetaData->radius, &valQ, ISM_RADIUS_MIN, ISM_RADIUS_DELTA, 1 << ISM_RADIUS_NBITS ); -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS encode_angle_indices( hBstr, &( hIsmMetaData->orientation_angle ), hIsmMetaData->last_ism_metadata_flag, ini_frame, idx_angle1_abs, idx_angle2_abs, &flag_abs_yaw[ch], &flag_abs_pitch[ch] ); #else encode_angle_indices( hBstr, &( hIsmMetaData->orientation_angle ), hIsmMetaData->last_ism_metadata_flag, hSCE[0]->hCoreCoder[0]->ini_frame, idx_angle1_abs, idx_angle2_abs, &flag_abs_yaw[ch], &flag_abs_pitch[ch] ); @@ -537,7 +537,7 @@ ivas_error ivas_ism_metadata_enc( /* save number of metadata bits written */ #ifdef MASA_AND_OBJECTS if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS || ism_mode == ISM_SBA_MODE_DISC #endif ) @@ -626,7 +626,7 @@ ivas_error ivas_ism_metadata_enc( } } -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( ism_mode == ISM_SBA_MODE_DISC ) { int16_t md_diff_flag[MAX_NUM_OBJECTS]; @@ -879,7 +879,7 @@ ivas_error ivas_ism_metadata_enc_create( nchan_transport = MAX_PARAM_ISM_WAVE; ivas_set_omasa_TC( st_ivas->ism_mode, n_ISms, &st_ivas->nSCE, &st_ivas->nCPE ); } -#ifdef OSBA_BR_SWITCHING +#ifdef SBA_AND_OBJECTS else if ( st_ivas->hEncoderConfig->ivas_format == SBA_ISM_FORMAT ) { nchan_transport = n_ISms; diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 6e94650178..29763d1400 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -573,7 +573,7 @@ void ivas_mct_core_enc( #ifdef DEBUGGING format_bits = ( ivas_format == MC_FORMAT ? IVAS_FORMAT_SIGNALING_NBITS + MC_LS_SETUP_BITS : IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + SBA_ORDER_BITS + SBA_PLANAR_BITS ); -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS format_bits += ( ivas_format == SBA_ISM_FORMAT && nChannels > FOA_CHANNELS ); #endif mct_bits += hMCT->nBitsMCT + hMCT->nchan_out_woLFE; diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index fafc8fc858..36c95c6ef9 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -84,7 +84,7 @@ static void set_mct_enc_params( hMCT->hbr_mct = 0; #ifdef SBA_AND_OBJECTS if ( ( ivas_format == SBA_FORMAT -#ifndef OSBA_DISC_OBJ_MCT +#ifndef SBA_AND_OBJECTS || ivas_format == SBA_ISM_FORMAT #endif ) && @@ -118,7 +118,7 @@ static void map_input_to_cpe_channels( ) { int16_t i, n; -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS int16_t nchan_transport; nchan_transport = st_ivas->nchan_transport; @@ -136,7 +136,7 @@ static void map_input_to_cpe_channels( } if ( st_ivas->hEncoderConfig->ivas_format == MC_FORMAT && ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) { -#ifndef OSBA_DISC_OBJ_MCT +#ifndef SBA_AND_OBJECTS for ( n = LFE_CHANNEL + 1; n < st_ivas->nchan_transport; n++ ) #else for ( n = LFE_CHANNEL + 1; n < nchan_transport; n++ ) @@ -149,7 +149,7 @@ static void map_input_to_cpe_channels( } else { -#ifndef OSBA_DISC_OBJ_MCT +#ifndef SBA_AND_OBJECTS for ( ; n < st_ivas->nchan_transport; n++ ) #else for ( ; n < nchan_transport; n++ ) @@ -161,7 +161,7 @@ static void map_input_to_cpe_channels( } /* odd channel CPE*/ -#ifndef OSBA_DISC_OBJ_MCT +#ifndef SBA_AND_OBJECTS if ( ( st_ivas->nchan_transport < st_ivas->nCPE * CPE_CHANNELS ) || ( ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) && st_ivas->hMCT->nchan_out_woLFE < st_ivas->nCPE * CPE_CHANNELS ) ) #else if ( ( nchan_transport < st_ivas->nCPE * CPE_CHANNELS ) || ( ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) && st_ivas->hMCT->nchan_out_woLFE < st_ivas->nCPE * CPE_CHANNELS ) ) @@ -341,7 +341,7 @@ ivas_error create_mct_enc( #endif { hMCT->nchan_out_woLFE = ivas_get_sba_num_TCs( ivas_total_brate, st_ivas->sba_analysis_order ); -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { hMCT->nchan_out_woLFE += st_ivas->hEncoderConfig->nchan_ism; @@ -470,7 +470,7 @@ ivas_error mct_enc_reconfigure( { hMCT->nchan_out_woLFE = ivas_param_mc_getNumTransportChannels( ivas_total_brate, st_ivas->hEncoderConfig->mc_input_setup ); } -#ifdef OSBA_BR_SWITCHING +#ifdef SBA_AND_OBJECTS else if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) #else else if ( ivas_format == SBA_FORMAT ) diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index 38728460f4..6767605c03 100755 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -94,7 +94,7 @@ ivas_error ivas_osba_enc_open( OSBA_ENC_HANDLE hOSba; int16_t input_frame; ivas_error error; -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS int16_t len; #endif error = IVAS_ERR_OK; @@ -110,8 +110,8 @@ ivas_error ivas_osba_enc_open( { set_f( hOSba->prev_object_dm_gains[i], (float) sqrt( 0.5 ), MAX_INPUT_CHANNELS ); } -#ifdef OSBA_DISC_OBJ_MCT -#ifndef OSBA_BR_SWITCHING +#ifdef SBA_AND_OBJECTS +#ifndef SBA_AND_OBJECTS if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { #endif @@ -130,7 +130,7 @@ ivas_error ivas_osba_enc_open( { hOSba->input_data_mem[i] = NULL; } -#ifndef OSBA_BR_SWITCHING +#ifndef SBA_AND_OBJECTS } #endif #endif @@ -161,7 +161,7 @@ void ivas_osba_enc_close( { return; } -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS for ( int16_t n = 0; n < MAX_NUM_OBJECTS; n++ ) { if ( ( *hOSba )->input_data_mem[n] != NULL ) @@ -386,21 +386,21 @@ void ivas_osba_enc( const int16_t nchan_ism, /* i : Number of objects for parameter analysis */ const ISM_MODE ism_mode, /* i : ISM mode */ const int16_t sba_analysis_order /* i : SBA order evaluated in DirAC/SPAR encoder */ -#ifdef OSBA_BR_SWITCHING +#ifdef SBA_AND_OBJECTS , const int32_t input_Fs /* i : input sampling rate*/ #endif ) { float data_out_f[MAX_INPUT_CHANNELS][L_FRAME48k]; -#ifdef OSBA_BR_SWITCHING +#ifdef SBA_AND_OBJECTS int16_t n, delay_s; delay_s = NS2SA( input_Fs, IVAS_FB_ENC_DELAY_NS ); #endif if ( ism_mode == ISM_MODE_NONE ) { -#ifdef OSBA_BR_SWITCHING +#ifdef SBA_AND_OBJECTS /*keep the delay buffer up to date*/ for ( n = 0; n < nchan_ism; n++ ) { @@ -413,7 +413,7 @@ void ivas_osba_enc( /* Merge SBA signals */ ivas_merge_sba_transports( data_out_f, &( data_in_f[nchan_ism] ), data_in_f, input_frame, sba_analysis_order ); } -#ifdef OSBA_BR_SWITCHING +#ifdef SBA_AND_OBJECTS else { int16_t azimuth, elevation; diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index e8f5534530..fd3a0df2c4 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -339,8 +339,8 @@ ivas_error ivas_spar_enc( error = IVAS_ERR_OK; hEncoderConfig = st_ivas->hEncoderConfig; -#ifdef OSBA_DISC_OBJ_MCT -#ifndef ENABLE_ISM_MD_CODING +#ifdef SBA_AND_OBJECTS +#ifndef SBA_AND_OBJECTS if ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode != ISM_MODE_NONE ) { /* write the number of objects in ISM_SBA format*/ diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 1fc4bc85bd..a5d782049f 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -951,7 +951,7 @@ typedef struct ivas_osba_enc_data_structure float energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS]; int16_t nchan_ism; -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS float *input_data_mem[MAX_NUM_OBJECTS]; #endif diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 03898cbad7..8d3b50613c 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -244,7 +244,7 @@ ivas_error ivas_spat_hSpatParamRendCom_config( /*-----------------------------------------------------------------* * set input parameters *-----------------------------------------------------------------*/ -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS if ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && flag_config == DIRAC_RECONFIGURE ) #else if ( ivas_format == SBA_FORMAT && flag_config == DIRAC_RECONFIGURE ) @@ -315,7 +315,7 @@ ivas_error ivas_spat_hSpatParamRendCom_config( #ifdef MASA_AND_OBJECTS if ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS || ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && hodirac_flag ) #else || ( ivas_format == SBA_FORMAT && hodirac_flag ) diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index d7320f39a6..91fdbaf8cd 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -196,7 +196,7 @@ ivas_error ivas_td_binaural_open_unwrap( #ifdef MASA_AND_OBJECTS if ( ivas_format == ISM_FORMAT || ivas_format == MASA_ISM_FORMAT -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS || ivas_format == SBA_ISM_FORMAT #endif ) @@ -228,7 +228,7 @@ ivas_error ivas_td_binaural_open_unwrap( #ifdef MASA_AND_OBJECTS if ( ivas_format != MASA_ISM_FORMAT -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS && ivas_format != SBA_ISM_FORMAT #endif ) @@ -518,7 +518,7 @@ void TDREND_Update_object_positions( { #ifdef MASA_AND_OBJECTS if ( in_format == ISM_FORMAT || in_format == MASA_ISM_FORMAT -#ifdef OSBA_DISC_OBJ_MCT +#ifdef SBA_AND_OBJECTS || in_format == SBA_ISM_FORMAT #endif ) -- GitLab From 791d3afc1bb5343b0849629ef097a6f1533e9983 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 8 Aug 2023 15:20:02 +0200 Subject: [PATCH 070/109] delete unused variables from struct ivas_osba_enc_data_structure --- lib_dec/ivas_osba_dec.c | 2 +- lib_enc/ivas_stat_enc.h | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 553274bf06..8ef91cad44 100755 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -100,7 +100,7 @@ void ivas_masa_ism_data_close( } /*-------------------------------------------------------------------------* - * ivas_masa_ism_separate_object_renderer_open() + * ivas_sba_ism_separate_object_renderer_open() * * Open structures, reserve memory, and init values. *-------------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index a5d782049f..2577912c33 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -935,20 +935,10 @@ typedef struct ivas_mcmasa_enc_data_structure typedef struct ivas_osba_enc_data_structure { - uint8_t nbands; - uint8_t nSubframes; - - int16_t band_grouping[MASA_FREQUENCY_BANDS + 1]; - int16_t block_grouping[5]; - - IVAS_FB_MIXER_HANDLE hFbMixer; float interpolator[L_FRAME48k]; - float prev_object_dm_gains[MAX_NUM_OBJECTS][MAX_INPUT_CHANNELS]; - float energy_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - float energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS]; int16_t nchan_ism; #ifdef SBA_AND_OBJECTS -- GitLab From 56d99db4f575375b933a9a19d381b9cbb3b41585 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 8 Aug 2023 15:31:33 +0200 Subject: [PATCH 071/109] simplify for loop to set p_output in ivas_dec --- lib_dec/ivas_dec.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 1b4bcad350..f3c82296de 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -122,23 +122,14 @@ ivas_error ivas_dec( output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); #ifdef SBA_AND_OBJECTS - if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL ) - { - for ( n = 0; n < nchan_out; n++ ) - { - p_output[n] = &output[n][0]; - } - } - else - { + for ( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) +#else + for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) #endif - for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) - { - p_output[n] = &output[n][0]; - } -#ifdef SBA_AND_OBJECTS + { + p_output[n] = &output[n][0]; } -#endif + /*----------------------------------------------------------------* * Combine orientations -- GitLab From 5210f3da4679d771aef468af7e339d7a6cf363f4 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 8 Aug 2023 15:35:03 +0200 Subject: [PATCH 072/109] simplify ism-mode condition in ivas_dec --- lib_dec/ivas_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index f3c82296de..5d4c2d5f5b 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -741,7 +741,7 @@ ivas_error ivas_dec( } #endif - if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { if ( ( error = ivas_osba_dirac_td_binaural( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) { -- GitLab From 6a48881932825c6a9f9eac494a246907d7d5254b Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 8 Aug 2023 15:54:33 +0200 Subject: [PATCH 073/109] merge cases of RENDERER_OSBA_AMBI and RENDERER_OSBA_LS in ivas_dec --- lib_dec/ivas_dec.c | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 5d4c2d5f5b..c53b35da6d 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -773,7 +773,7 @@ ivas_error ivas_dec( } #endif #ifdef SBA_AND_OBJECTS - else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI ) + else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS ) { float tmp_ism_out[MAX_OUTPUT_CHANNELS][L_FRAME48k]; float *p_tmp_ism_out[MAX_OUTPUT_CHANNELS]; @@ -789,36 +789,14 @@ ivas_error ivas_dec( delay_signal( tmp_ism_out[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); } - ivas_ism2sba( p_tmp_ism_out, st_ivas->hIsmRendererData, st_ivas->hIsmMetaData, st_ivas->nchan_ism, output_frame, st_ivas->hIntSetup.ambisonics_order ); - - ivas_sba_upmixer_renderer( st_ivas, &output[st_ivas->nchan_ism], output_frame ); - - for ( n = 0; n < nchan_out; n++ ) + if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI ) { - v_add( output[n + nchan_ism], tmp_ism_out[n], output[n], output_frame ); - v_multc( output[n], 0.5f, output[n], output_frame ); - } - } -#endif -#ifdef SBA_AND_OBJECTS - /* todo: almost the same path as for Ambisonics output. Should be merged at some point. */ - else if ( st_ivas->renderer_type == RENDERER_OSBA_LS ) - { - float tmp_ism_out[MAX_CICP_CHANNELS][L_FRAME48k]; - float *p_tmp_ism_out[MAX_CICP_CHANNELS]; - - for ( n = 0; n < nchan_out; n++ ) - { - p_tmp_ism_out[n] = &tmp_ism_out[n][0]; - } - - for ( n = 0; n < nchan_ism; n++ ) - { - mvr2r( output[n], tmp_ism_out[n], output_frame ); - delay_signal( tmp_ism_out[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); - } - - ivas_ism_render( st_ivas, p_tmp_ism_out, output_frame ); + ivas_ism2sba( p_tmp_ism_out, st_ivas->hIsmRendererData, st_ivas->hIsmMetaData, st_ivas->nchan_ism, output_frame, st_ivas->hIntSetup.ambisonics_order ); + } + else + { + ivas_ism_render( st_ivas, p_tmp_ism_out, output_frame ); + } ivas_sba_upmixer_renderer( st_ivas, &output[st_ivas->nchan_ism], output_frame ); -- GitLab From 9255e34be131c0f0ac92781eecb88e29400e0cc2 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 8 Aug 2023 16:17:22 +0200 Subject: [PATCH 074/109] delete unreachable code in configureEncoder --- lib_enc/lib_enc.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index dd779bcb54..12a80a034f 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -925,15 +925,6 @@ static ivas_error configureEncoder( else if ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT ) { st_ivas->ism_mode = ISM_MODE_NONE; - - /*adapt element_mode according to the bit-rate*/ - if ( hEncoderConfig->element_mode_init != IVAS_SCE ) - { - if ( st_ivas->hEncoderConfig->ivas_total_brate >= IVAS_48k ) - { - hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; - } - } } #endif } -- GitLab From 9e6bc9e625edff71eecd99b602f7613913945a4b Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 8 Aug 2023 16:38:44 +0200 Subject: [PATCH 075/109] fix segmentation fault in decoder --- lib_dec/ivas_osba_dec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 8ef91cad44..a746578875 100755 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -229,15 +229,15 @@ ivas_error ivas_osba_ism_metadata_dec( ) { ivas_error error; - int16_t *nchan_transport_ism = 0; + int16_t nchan_transport_ism; /* set ISM parameters */ - *nchan_transport_ism = st_ivas->nchan_ism; + nchan_transport_ism = st_ivas->nchan_ism; *nchan_ism = st_ivas->nchan_ism; /* decode ISM metadata */ - if ( ( error = ivas_ism_metadata_dec( ism_total_brate, *nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, NULL, st_ivas->bfi, + if ( ( error = ivas_ism_metadata_dec( ism_total_brate, *nchan_ism, &nchan_transport_ism, st_ivas->hIsmMetaData, NULL, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hCPE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) { return error; -- GitLab From 69ab1d3f81e6f89cf7bdc656cd3608c63267fbc2 Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 9 Aug 2023 16:48:51 +1000 Subject: [PATCH 076/109] decoder bitrate switching and split rendering changes --- lib_com/options.h | 1 + lib_dec/ivas_dec.c | 3 + lib_dec/ivas_init_dec.c | 66 +++++++++++++++- lib_dec/ivas_mct_dec.c | 8 +- lib_dec/ivas_osba_dec.c | 76 ++++++++++++++---- lib_dec/ivas_sba_dec.c | 106 ++++++++++++++++++++++++++ lib_enc/ivas_corecoder_enc_reconfig.c | 4 + lib_rend/ivas_splitRendererPre.c | 59 +++++++++++++- lib_rend/ivas_stat_rend.h | 4 +- 9 files changed, 306 insertions(+), 21 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 89f2376176..c6d7bb1b31 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -227,6 +227,7 @@ #define OSBA_AMBISONICS_OUT #define OSBA_LS_OUT #define OSBA_BR_SWITCHING +#define OSBA_SPLIT_RENDERING #endif /* ################## End BE DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 4ab343a0d0..f4bf4c40a0 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -386,6 +386,9 @@ ivas_error ivas_dec( } else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { +#ifdef OSBA_BR_SWITCHING + st_ivas->ism_mode = ISM_MODE_NONE; +#endif set_s( nb_bits_metadata, 0, MAX_SCE ); /* read parameters from the bitstream */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 448206f4ac..fd5dda090c 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -70,7 +70,9 @@ static ivas_error ivas_dec_reconfig_split_rend( ivas_error error; int16_t cldfb_in, num_ch, ch, isCldfbNeeded, i, pcm_out; SPLIT_REND_WRAPPER *hSplitRendWrapper; +#ifndef OSBA_SPLIT_RENDERING CLDFB_TYPE cldfbMode; +#endif hSplitRendWrapper = &st_ivas->splitBinRend.splitrend; pcm_out = ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; @@ -88,23 +90,36 @@ static ivas_error ivas_dec_reconfig_split_rend( st_ivas->hHeadTrackData->sr_pose_pred_axis ); isCldfbNeeded = 0; +#ifndef OSBA_SPLIT_RENDERING cldfbMode = CLDFB_ANALYSIS; +#else + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + cldfb_in = 0; + } +#endif if ( st_ivas->renderer_type != RENDERER_DISABLE ) { if ( cldfb_in == 0 ) { isCldfbNeeded = 1; +#ifndef OSBA_SPLIT_RENDERING cldfbMode = CLDFB_ANALYSIS; +#endif } else if ( st_ivas->hRenderConfig->split_rend_config.codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && cldfb_in ) { isCldfbNeeded = 1; +#ifndef OSBA_SPLIT_RENDERING cldfbMode = CLDFB_SYNTHESIS; +#endif } else if ( pcm_out && cldfb_in ) { isCldfbNeeded = 1; +#ifndef OSBA_SPLIT_RENDERING cldfbMode = CLDFB_SYNTHESIS; +#endif } } @@ -126,12 +141,28 @@ static ivas_error ivas_dec_reconfig_split_rend( for ( ch = 0; ch < num_ch; ch++ ) { if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), +#ifndef OSBA_SPLIT_RENDERING cldfbMode, +#else + CLDFB_ANALYSIS, +#endif st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not open CLDFB handles\n" ) ); } } + +#ifdef OSBA_SPLIT_RENDERING + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), + CLDFB_SYNTHESIS, + st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif } else if ( isCldfbNeeded == 0 && hSplitRendWrapper->hCldfbHandles != NULL ) { @@ -144,11 +175,26 @@ static ivas_error ivas_dec_reconfig_split_rend( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; } } +#ifdef OSBA_SPLIT_RENDERING + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + if ( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] != NULL ) + { + deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ); + hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] = NULL; + } + } +#endif free( hSplitRendWrapper->hCldfbHandles ); hSplitRendWrapper->hCldfbHandles = NULL; } +#ifdef OSBA_SPLIT_RENDERING + if ( ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) && + ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV || st_ivas->ivas_format != SBA_ISM_FORMAT ) ) +#else if ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) +#endif { for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) { @@ -197,7 +243,12 @@ ivas_error ivas_dec_init_split_rend( } ivas_split_rend_choose_default_codec( &st_ivas->hRenderConfig->split_rend_config.codec, ( cldfb_in == 0 ), pcm_out ); - +#ifdef OSBA_SPLIT_RENDERING + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + cldfb_in = 0; + } +#endif error = ivas_split_renderer_open( &st_ivas->splitBinRend.splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, @@ -394,13 +445,21 @@ ivas_error ivas_dec_setup( else { ivas_sba_config( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init ); +#ifdef OSBA_BR_SWITCHING + /*correct number of CPEs for discrete ISM coding*/ + if ( st_ivas->ini_frame > 0 && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; + } +#endif } - +#ifndef OSBA_BR_SWITCHING /*correct number of CPEs for discrete ISM coding*/ if ( st_ivas->ini_frame > 0 && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; } +#endif st_ivas->ism_mode = ISM_SBA_MODE_DISC; } @@ -1429,6 +1488,9 @@ ivas_error ivas_init_decoder( } } +#ifdef OSBA_BR_SWITCHING + st_ivas->nchan_transport += st_ivas->nchan_ism; +#endif if ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 8e3864d505..e2c94ac05b 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -353,11 +353,13 @@ ivas_error create_mct_dec( ) { hMCT->nchan_out_woLFE = st_ivas->nchan_transport; +#ifndef OSBA_BR_SWITCHING #ifdef OSBA_DISC_OBJ_MCT if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { hMCT->nchan_out_woLFE += st_ivas->nchan_ism; } +#endif #endif } else if ( st_ivas->mc_mode == MC_MODE_MCT ) @@ -466,7 +468,11 @@ ivas_error mct_dec_reconfigure( if ( b_nchan_change ) { /* Determine active channels */ - if ( ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC ) || st_ivas->ivas_format == SBA_FORMAT ) + if ( ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC ) || st_ivas->ivas_format == SBA_FORMAT +#ifdef OSBA_BR_SWITCHING + || st_ivas->ivas_format == SBA_ISM_FORMAT +#endif + ) { hMCT->nchan_out_woLFE = st_ivas->nchan_transport; } diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 130600201c..0fa2b345a3 100755 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -164,9 +164,15 @@ ivas_error ivas_osba_dirac_td_binaural( mvr2r( output[n], data_separated_objects[n], output_frame ); } - for ( n = 0; n < st_ivas->nchan_ism; n++ ) +#ifdef OSBA_SPLIT_RENDERING + if ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_BINAURAL_SPLIT_CODED && + st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif { - delay_signal( data_separated_objects[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + delay_signal( data_separated_objects[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); + } } if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) @@ -190,32 +196,70 @@ ivas_error ivas_osba_dirac_td_binaural( } } #endif - - if ( ( error = ivas_td_binaural_renderer( st_ivas, p_sepobj, output_frame ) ) != IVAS_ERR_OK ) +#ifdef OSBA_SPLIT_RENDERING + if ( ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - return error; + int16_t slot_idx, num_cldfb_bands, b, nchan_transport_orig; + float Cldfb_RealBuffer[CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer[CLDFB_NO_CHANNELS_MAX]; + num_cldfb_bands = st_ivas->splitBinRend.splitrend.hCldfbHandles->cldfbAna[0]->no_channels; + nchan_transport_orig = st_ivas->nchan_transport; + st_ivas->nchan_transport = st_ivas->nchan_ism; + ObjRenderIvasFrame_splitBinaural( st_ivas, output, output_frame ); + st_ivas->nchan_transport = nchan_transport_orig; + for ( n = 0; n < st_ivas->splitBinRend.splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++n ) + { + for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) + { + cldfbAnalysis_ts( &( output[n][num_cldfb_bands * slot_idx] ), + Cldfb_RealBuffer, + Cldfb_ImagBuffer, + num_cldfb_bands, + st_ivas->splitBinRend.splitrend.hCldfbHandles->cldfbAna[n] ); + for ( b = 0; b < num_cldfb_bands; b++ ) + { + st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx][b] = + ( 0.5f * st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx][b] ) + + ( 0.5f * Cldfb_RealBuffer[b] ); + st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx][b] = + ( 0.5f * st_ivas->splitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx][b] ) + + ( 0.5f * Cldfb_ImagBuffer[b] ); + } + } + } } + else + { +#endif + if ( ( error = ivas_td_binaural_renderer( st_ivas, p_sepobj, output_frame ) ) != IVAS_ERR_OK ) + { + return error; + } #ifdef DEBUG_OSBA - { - for ( int t = 0; t < output_frame; t++ ) { - for ( int c = 0; c < BINAURAL_CHANNELS; c++ ) + for ( int t = 0; t < output_frame; t++ ) { - int16_t val = (int16_t) ( p_sepobj[c][t] + 0.5f ); - dbgwrite( &val, sizeof( int16_t ), 1, 1, "./res/ism_td_bin_out.raw" ); + for ( int c = 0; c < BINAURAL_CHANNELS; c++ ) + { + int16_t val = (int16_t) ( p_sepobj[c][t] + 0.5f ); + dbgwrite( &val, sizeof( int16_t ), 1, 1, "./res/ism_td_bin_out.raw" ); + } } } - } #endif - for ( n = 0; n < BINAURAL_CHANNELS; n++ ) - { - int16_t i; - for ( i = 0; i < output_frame; i++ ) + for ( n = 0; n < BINAURAL_CHANNELS; n++ ) { - output[n][i] = 0.5f * output[channel_offset + n][i] + 0.5f * p_sepobj[n][i]; + int16_t i; + for ( i = 0; i < output_frame; i++ ) + { + output[n][i] = 0.5f * output[channel_offset + n][i] + 0.5f * p_sepobj[n][i]; + } } +#ifdef OSBA_SPLIT_RENDERING } +#endif return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index e1c95812ac..9825d7f54d 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -116,6 +116,11 @@ ivas_error ivas_sba_dec_reconfigure( DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; +#ifdef OSBA_BR_SWITCHING + ISM_MODE ism_mode_old; + ism_mode_old = st_ivas->ism_mode; +#endif + error = IVAS_ERR_OK; hDecoderConfig = st_ivas->hDecoderConfig; @@ -129,6 +134,16 @@ ivas_error ivas_sba_dec_reconfigure( ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); nchan_hp20_old = getNumChanSynthesis( st_ivas ); +#ifdef OSBA_BR_SWITCHING + if ( ism_mode_old == ISM_MODE_NONE && st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + nchan_hp20_old = st_ivas->nchan_transport; + } + else if ( ism_mode_old == ISM_SBA_MODE_DISC && st_ivas->ivas_format == SBA_FORMAT ) + { + nchan_hp20_old += st_ivas->nchan_ism; + } +#endif nSCE_old = st_ivas->nSCE; nCPE_old = st_ivas->nCPE; nchan_transport_old = st_ivas->nchan_transport; @@ -311,7 +326,98 @@ ivas_error ivas_sba_dec_reconfigure( /*-----------------------------------------------------------------* * Allocate, initialize, and configure SCE/CPE/MCT handles *-----------------------------------------------------------------*/ +#ifdef OSBA_BR_SWITCHING + if ( ism_mode_old == ISM_MODE_NONE && st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + int32_t temp_brate[MAX_SCE]; + st_ivas->ism_mode = ISM_SBA_MODE_DISC; + if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( ( st_ivas->renderer_type == RENDERER_TD_PANNING || + st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX || + st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || +#ifdef OSBA_MONO_STEREO_OUTPUT + st_ivas->renderer_type == RENDERER_OSBA_STEREO || +#endif +#ifdef OSBA_AMBISONICS_OUT + st_ivas->renderer_type == RENDERER_OSBA_AMBI || +#endif +#ifdef OSBA_LS_OUT + st_ivas->renderer_type == RENDERER_OSBA_LS || +#endif + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) + { + if ( ( error = ivas_ism_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + { + /* Allocate TD renderer for the objects in DISC mode */ + if ( st_ivas->hBinRendererTd == NULL ) + { + if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + if ( ( error = ivas_masa_ism_data_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ + if ( ( error = ivas_masa_ism_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + + + st_ivas->nchan_transport += st_ivas->nchan_ism; + st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; + } + else if ( ism_mode_old == ISM_SBA_MODE_DISC && st_ivas->ivas_format == SBA_FORMAT ) + { + /* ISM renderer handle */ + if ( st_ivas->hIsmRendererData != NULL ) + { + free( st_ivas->hIsmRendererData->interpolator ); + free( st_ivas->hIsmRendererData ); + st_ivas->hIsmRendererData = NULL; + } + ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 ); + ivas_masa_ism_data_close( &st_ivas->hMasaIsmData ); + + /* Time Domain binaural renderer handle */ + + if ( st_ivas->hBinRendererTd != NULL ) + { + if ( st_ivas->hBinRendererTd->HrFiltSet_p->ModelParams.modelROM == TRUE ) + { + ivas_td_binaural_close( &st_ivas->hBinRendererTd ); + if ( st_ivas->hHrtfTD != NULL ) + { + st_ivas->hHrtfTD = NULL; + } + } + } + nchan_transport_old += st_ivas->nchan_ism; + st_ivas->ism_mode = ISM_MODE_NONE; + } + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + st_ivas->nchan_transport += st_ivas->nchan_ism; + st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; + nCPE_old = st_ivas->nCPE; + nchan_transport_old = st_ivas->nchan_transport; + } +#endif if ( ( error = ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport, ( st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c index 6f43073801..2367bcc560 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig.c +++ b/lib_enc/ivas_corecoder_enc_reconfig.c @@ -534,7 +534,11 @@ ivas_error ivas_corecoder_enc_reconfig( st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->mdct_stereo_mode_cmdl = hEncoderConfig->stereo_mode_cmdl; #endif initMdctStereoEncData( st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct, hEncoderConfig->ivas_format, st_ivas->hCPE[st_ivas->nCPE - 1]->element_mode, st_ivas->hCPE[st_ivas->nCPE - 1]->element_brate, hEncoderConfig->max_bwidth, 0, NULL, 1 ); +#ifdef OSBA_BR_SWITCHING + st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->isSBAStereoMode = ( ( hEncoderConfig->ivas_format == SBA_FORMAT || hEncoderConfig->ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->nchan_transport == 2 ) ); +#else st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->isSBAStereoMode = ( ( hEncoderConfig->ivas_format == SBA_FORMAT ) && ( st_ivas->nchan_transport == 2 ) ); +#endif } } diff --git a/lib_rend/ivas_splitRendererPre.c b/lib_rend/ivas_splitRendererPre.c index 0d7e1ed19e..b6c372bb05 100644 --- a/lib_rend/ivas_splitRendererPre.c +++ b/lib_rend/ivas_splitRendererPre.c @@ -1899,9 +1899,13 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper, const int16_t is_pcm_out ) { ivas_error error, ch, num_ch; +#ifndef OSBA_SPLIT_RENDERING CLDFB_TYPE cldfbMode; +#endif uint8_t isCldfbNeeded = 0; +#ifndef OSBA_SPLIT_RENDERING cldfbMode = CLDFB_ANALYSIS; +#endif if ( ( error = ivas_split_rend_validate_config( pSplitRendConfig, is_pcm_out ) ) != IVAS_ERR_OK ) { @@ -1913,44 +1917,77 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper, if ( is_cldfb_in == 0 ) { isCldfbNeeded = 1; +#ifndef OSBA_SPLIT_RENDERING cldfbMode = CLDFB_ANALYSIS; +#endif } else if ( pSplitRendConfig->codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && is_cldfb_in ) { +#ifdef OSBA_SPLIT_RENDERING + isCldfbNeeded = 1; +#else isCldfbNeeded = 1; cldfbMode = CLDFB_SYNTHESIS; +#endif } else if ( is_pcm_out && is_cldfb_in ) { +#ifdef OSBA_SPLIT_RENDERING + isCldfbNeeded = 1; +#else isCldfbNeeded = 1; cldfbMode = CLDFB_SYNTHESIS; +#endif } hSplitRendWrapper->hCldfbHandles = NULL; + if ( isCldfbNeeded ) { if ( ( hSplitRendWrapper->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) ); } - num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; for ( ch = 0; ch < num_ch; ch++ ) { hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; } +#ifdef OSBA_SPLIT_RENDERING + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] = NULL; + } +#endif + num_ch = hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; for ( ch = 0; ch < num_ch; ch++ ) { if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), +#ifndef OSBA_SPLIT_RENDERING cldfbMode, +#else + CLDFB_ANALYSIS, +#endif OutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return error; } } + +#ifdef OSBA_SPLIT_RENDERING + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), + CLDFB_SYNTHESIS, + OutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif } if ( pSplitRendConfig->poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) @@ -2015,6 +2052,18 @@ void ivas_split_renderer_close( SPLIT_REND_WRAPPER *hSplitBinRend ) hSplitBinRend->hCldfbHandles->cldfbAna[ch] = NULL; } } + +#ifdef OSBA_SPLIT_RENDERING + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + if ( hSplitBinRend->hCldfbHandles->cldfbSyn[ch] != NULL ) + { + deleteCldfb( &hSplitBinRend->hCldfbHandles->cldfbSyn[ch] ); + hSplitBinRend->hCldfbHandles->cldfbSyn[ch] = NULL; + } + } +#endif + free( hSplitBinRend->hCldfbHandles ); hSplitBinRend->hCldfbHandles = NULL; } @@ -2379,7 +2428,11 @@ ivas_error ivas_renderMultiBinToSplitBinaural( Cldfb_In_BinReal_p[slot_idx] = Cldfb_In_BinReal[ch][slot_idx]; Cldfb_In_BinImag_p[slot_idx] = Cldfb_In_BinImag[ch][slot_idx]; } +#ifndef OSBA_SPLIT_RENDERING cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, out[ch], hSplitBin->hCldfbHandles->cldfbAna[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbAna[ch] ); +#else + cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, out[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); +#endif } if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, SplitRendBitRate, out ) ) != IVAS_ERR_OK ) @@ -2402,7 +2455,11 @@ ivas_error ivas_renderMultiBinToSplitBinaural( Cldfb_In_BinReal_p[slot_idx] = Cldfb_In_BinReal[ch][slot_idx]; Cldfb_In_BinImag_p[slot_idx] = Cldfb_In_BinImag[ch][slot_idx]; } +#ifndef OSBA_SPLIT_RENDERING cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, out[ch], hSplitBin->hCldfbHandles->cldfbAna[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbAna[ch] ); +#else + cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, out[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); +#endif } pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 4a034eecb4..3f46f9c210 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -689,9 +689,11 @@ typedef struct #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG HANDLE_CLDFB_FILTER_BANK cldfbAna[( 1 + MAX_HEAD_ROT_POSES ) * BINAURAL_CHANNELS]; #else - /* TODO(sgi): rename to "cldfb" during harmonization - these handles are sometimes also used for synthesis */ HANDLE_CLDFB_FILTER_BANK cldfbAna[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; #endif +#ifdef OSBA_SPLIT_RENDERING + HANDLE_CLDFB_FILTER_BANK cldfbSyn[BINAURAL_CHANNELS]; +#endif } CLDFB_HANDLES_WRAPPER, *CLDFB_HANDLES_WRAPPER_HANDLE; typedef struct -- GitLab From e03dc9ccabc13bd786ad65e3a9c264c052e14bd6 Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 9 Aug 2023 18:48:29 +1000 Subject: [PATCH 077/109] bug fix in TD rend open, it opens with 8 channels at 512 --- apps/decoder.c | 3 +++ lib_dec/ivas_objectRenderer_internal.c | 4 ++++ lib_rend/lib_rend.c | 3 +++ 3 files changed, 10 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index c3014262bf..787e10bca1 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1950,6 +1950,9 @@ static ivas_error decodeG192( Quaternions[i].x = 0.0f; Quaternions[i].y = 0.0f; Quaternions[i].z = 0.0f; + Pos[i].x = 0.0f; + Pos[i].y = 0.0f; + Pos[i].z = 0.0f; } } else diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 7b323e9d2b..a4b1ce0387 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -57,7 +57,11 @@ ivas_error ivas_td_binaural_open( int16_t num_src; num_src = st_ivas->nchan_transport; +#ifdef SBA_AND_OBJECTS + if ( ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) || ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) ) +#else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) +#endif { num_src = st_ivas->nchan_ism; } diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 8a023a1087..15f9eb4ff2 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -5095,6 +5095,9 @@ ivas_error IVAS_REND_SetHeadRotation( hIvasRend->headRotData.headPositions[i].x = 0.0f; hIvasRend->headRotData.headPositions[i].y = 0.0f; hIvasRend->headRotData.headPositions[i].z = 0.0f; + hIvasRend->headRotData.Pos[i].x = 0.0f; + hIvasRend->headRotData.Pos[i].y = 0.0f; + hIvasRend->headRotData.Pos[i].z = 0.0f; } } else -- GitLab From 5e664670dbc38413e3f0187df6c912a314d3907c Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 9 Aug 2023 14:53:37 +0200 Subject: [PATCH 078/109] re-purpose sba-order bits to signal the number of objects in OSBA at low BR --- lib_dec/ivas_init_dec.c | 16 ++++++++++++++++ lib_enc/ivas_enc.c | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 0ede88873f..831d1402ad 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -430,6 +430,22 @@ ivas_error ivas_dec_setup( /* read Ambisonic (SBA) order */ st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; + if ( ivas_total_brate >= IVAS_256k ) + { + st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; + st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; + st_ivas->ism_mode = ISM_SBA_MODE_DISC; + } + else + { + st_ivas->sba_order = 3; + + st_ivas->nchan_ism = st_ivas->bit_stream[num_bits_read + 1]; + st_ivas->nchan_ism += 2 * st_ivas->bit_stream[num_bits_read]; + st_ivas->nchan_ism++; + st_ivas->ivas_format = SBA_FORMAT; + st_ivas->ism_mode = ISM_MODE_NONE; + } /* set Ambisonic (SBA) order used for analysis and coding */ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index e15c4fb797..4a19c63ef4 100755 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -436,8 +436,8 @@ ivas_error ivas_enc( /* Write SBA planar flag */ push_indice( st->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); - /* Write SBA order */ - push_indice( st->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS ); + /* Previously used to signal the SBA order, now re-purposed for the number of objects */ + push_indice( st->hBstr, IND_SMODE, hEncoderConfig->nchan_ism - 1, NO_BITS_MASA_ISM_NO_OBJ ); /* SBA metadata encoding and SBA metadata bitstream writing */ if ( ( error = ivas_spar_enc( st_ivas, data_f, input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK ) -- GitLab From cf6842c61ac7c111e9f2ceb5fdd7a10d6c2bf978 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 9 Aug 2023 16:03:57 +0200 Subject: [PATCH 079/109] implement EXT output at low BRs --- lib_com/bitstream.c | 38 +++++++++++++--------- lib_com/ivas_prot.h | 3 ++ lib_dec/ivas_dec.c | 6 +++- lib_dec/ivas_init_dec.c | 4 +-- lib_dec/ivas_jbm_dec.c | 6 +++- lib_dec/ivas_sba_dec.c | 6 +++- lib_dec/ivas_sba_rendering_internal.c | 46 +++++++++++++++++++++------ lib_dec/ivas_spar_decoder.c | 32 +++++++++++-------- lib_enc/ivas_init_enc.c | 2 +- 9 files changed, 98 insertions(+), 45 deletions(-) diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 726a9c3462..d711ee37ca 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -236,7 +236,7 @@ ivas_error ind_list_realloc( if ( hBstr != NULL ) { /* get the current position inside the old list */ - ind_list_pos = (int16_t) ( hBstr->ind_list - old_ind_list ); + ind_list_pos = ( int16_t )( hBstr->ind_list - old_ind_list ); /* set pointers in the new list */ *( hBstr->ivas_ind_list_zero ) = new_ind_list; @@ -274,7 +274,7 @@ ivas_error ind_list_realloc( if ( hBstr != NULL ) { /* get the current position inside the old list */ - ind_list_pos = (int16_t) ( hBstr->ind_list - old_ind_list ); + ind_list_pos = ( int16_t )( hBstr->ind_list - old_ind_list ); /* set pointers in the new list */ *( hBstr->ivas_ind_list_zero ) = new_ind_list; @@ -326,7 +326,7 @@ ivas_error ind_list_realloc( } /* get the current position inside the old list */ - ind_list_pos = (int16_t) ( hBstr->ind_list - ( *hBstr->ivas_ind_list_zero ) ); + ind_list_pos = ( int16_t )( hBstr->ind_list - ( *hBstr->ivas_ind_list_zero ) ); /* free the old list */ free( ( *hBstr->ivas_ind_list_zero ) ); @@ -1348,7 +1348,7 @@ ivas_error push_next_bits( for ( i = 0; i < nb_bits_m15; i += 16 ) { - code = (uint16_t) ( ( bits[i] << 15 ) | ( ( bits[i + 1] << 14 ) | ( ( bits[i + 2] << 13 ) | ( ( bits[i + 3] << 12 ) | ( ( bits[i + 4] << 11 ) | ( ( bits[i + 5] << 10 ) | ( ( bits[i + 6] << 9 ) | ( ( bits[i + 7] << 8 ) | ( ( bits[i + 8] << 7 ) | ( ( bits[i + 9] << 6 ) | ( ( bits[i + 10] << 5 ) | ( ( bits[i + 11] << 4 ) | ( ( bits[i + 12] << 3 ) | ( ( bits[i + 13] << 2 ) | ( ( bits[i + 14] << 1 ) | bits[i + 15] ) ) ) ) ) ) ) ) ) ) ) ) ) ) ); + code = ( uint16_t )( ( bits[i] << 15 ) | ( ( bits[i + 1] << 14 ) | ( ( bits[i + 2] << 13 ) | ( ( bits[i + 3] << 12 ) | ( ( bits[i + 4] << 11 ) | ( ( bits[i + 5] << 10 ) | ( ( bits[i + 6] << 9 ) | ( ( bits[i + 7] << 8 ) | ( ( bits[i + 8] << 7 ) | ( ( bits[i + 9] << 6 ) | ( ( bits[i + 10] << 5 ) | ( ( bits[i + 11] << 4 ) | ( ( bits[i + 12] << 3 ) | ( ( bits[i + 13] << 2 ) | ( ( bits[i + 14] << 1 ) | bits[i + 15] ) ) ) ) ) ) ) ) ) ) ) ) ) ) ); /* check the limits of the list of indices */ if ( ( error = check_ind_list_limits( hBstr ) ) != IVAS_ERR_OK ) @@ -2027,7 +2027,7 @@ ivas_error write_indices_ivas( write_indices_element( st_ivas, &pt_stream, 0, n ); } - *num_bits = (uint16_t) ( pt_stream - bit_stream ); + *num_bits = ( uint16_t )( pt_stream - bit_stream ); return error; } @@ -2745,7 +2745,7 @@ void ivas_set_bitstream_pointers( { sts = st_ivas->hSCE[k]->hCoreCoder; sts[0]->bit_stream = st_ivas->bit_stream + num_bits; - num_bits += (int16_t) ( st_ivas->hSCE[k]->element_brate / FRAMES_PER_SEC ); + num_bits += ( int16_t )( st_ivas->hSCE[k]->element_brate / FRAMES_PER_SEC ); } /* set bitstream pointers for CPEs */ @@ -2753,7 +2753,7 @@ void ivas_set_bitstream_pointers( { sts = st_ivas->hCPE[k]->hCoreCoder; sts[0]->bit_stream = st_ivas->bit_stream + num_bits; - num_bits += (int16_t) ( st_ivas->hCPE[k]->element_brate / FRAMES_PER_SEC ); + num_bits += ( int16_t )( st_ivas->hCPE[k]->element_brate / FRAMES_PER_SEC ); } return; @@ -2783,7 +2783,7 @@ ivas_error preview_indices( error = IVAS_ERR_OK; /* convert the frame length to total bitrate */ - total_brate = (int32_t) ( num_bits * FRAMES_PER_SEC ); + total_brate = ( int32_t )( num_bits * FRAMES_PER_SEC ); if ( st_ivas->ivas_format != MONO_FORMAT && is_DTXrate( total_brate ) == 0 ) { @@ -2972,7 +2972,7 @@ ivas_error preview_indices( /* read number of objects from the bitstream */ st_ivas->nchan_transport = 1; - k = (int16_t) ( ( total_brate / FRAMES_PER_SEC ) - 1 ); + k = ( int16_t )( ( total_brate / FRAMES_PER_SEC ) - 1 ); while ( bit_stream[k] == 1 && st_ivas->nchan_transport < MAX_NUM_OBJECTS ) { st_ivas->nchan_transport++; @@ -3006,10 +3006,18 @@ ivas_error preview_indices( /* Read SBA planar flag and SBA order */ st_ivas->sba_planar = ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + IVAS_COMBINED_FORMAT_SIGNALLING_BITS] == 1 ); - st_ivas->sba_order = ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + IVAS_COMBINED_FORMAT_SIGNALLING_BITS + 2] == 1 ); - st_ivas->sba_order += 2 * ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + IVAS_COMBINED_FORMAT_SIGNALLING_BITS + 1] == 1 ); - st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( total_brate, st_ivas->sba_order ); + if ( total_brate > IVAS_256k ) + { + st_ivas->sba_order = ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + IVAS_COMBINED_FORMAT_SIGNALLING_BITS + 2] == 1 ); + st_ivas->sba_order += 2 * ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + IVAS_COMBINED_FORMAT_SIGNALLING_BITS + 1] == 1 ); + } + else + { + st_ivas->sba_order = 3; + } + + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( total_brate, st_ivas->sba_order ); ivas_sba_config( total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &( st_ivas->nSCE ), &( st_ivas->nCPE ), &( st_ivas->element_mode_init ) ); } @@ -3084,7 +3092,7 @@ ivas_error read_indices( #endif /* convert the frame length to total bitrate */ - total_brate = (int32_t) ( num_bits * FRAMES_PER_SEC ); + total_brate = ( int32_t )( num_bits * FRAMES_PER_SEC ); /* verify that a valid num bits value is present in the G.192 file */ /* only AMRWB, EVS or IVAS bitrates or 0(NO DATA) are allowed in G.192 file frame reading */ @@ -3501,7 +3509,7 @@ static void get_rfFrameType( ) { int16_t num_bits; - num_bits = (int16_t) ( st->total_brate / FRAMES_PER_SEC ); + num_bits = ( int16_t )( st->total_brate / FRAMES_PER_SEC ); if ( st->rf_flag == 1 ) { /* the last three bits in a packet is the RF frame type */ @@ -3582,7 +3590,7 @@ static void get_rf_fec_offset( ) { int16_t num_bits, tmp; - num_bits = (int16_t) ( st->total_brate / FRAMES_PER_SEC ); + num_bits = ( int16_t )( st->total_brate / FRAMES_PER_SEC ); if ( st->rf_flag == 1 ) { /* the two bits before the RF frame type contains the FEC offset */ diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index fc097a3c9a..2af5b23539 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4147,6 +4147,9 @@ ivas_error ivas_sba_linear_renderer( float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ const int16_t output_frame, /* i : output frame length per channel */ const int16_t nchan_in, /* i : number of input ambisonics channels */ +#ifdef SBA_AND_OBJECTS + const int16_t nchan_ism, +#endif const AUDIO_CONFIG output_config, /* i : output audio configuration */ const IVAS_OUTPUT_SETUP output_setup, /* i : output format setup */ const float hoa_dec_mtx[] /* i : HOA decoding mtx */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 0f758eefad..d0b195b980 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -542,7 +542,11 @@ ivas_error ivas_dec( { if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC ) { - if ( ( error = ivas_sba_linear_renderer( p_output, output_frame, nchan_remapped, output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sba_linear_renderer( p_output, output_frame, nchan_remapped, +#ifdef SBA_AND_OBJECTS + 0, +#endif + output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 831d1402ad..9e5dd39fba 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -428,8 +428,6 @@ ivas_error ivas_dec_setup( num_bits_read += SBA_PLANAR_BITS; /* read Ambisonic (SBA) order */ - st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; - st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; if ( ivas_total_brate >= IVAS_256k ) { st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; @@ -2973,7 +2971,7 @@ static ivas_error doSanityChecks_IVAS( else if ( st_ivas->ivas_format == SBA_FORMAT ) { /* Verify SBA output coniguration */ - if ( output_config == AUDIO_CONFIG_INVALID || output_config == AUDIO_CONFIG_EXTERNAL ) + if ( output_config == AUDIO_CONFIG_INVALID ) { return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for SBA" ); } diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 1f3c9e907b..982837aaf1 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -873,7 +873,11 @@ ivas_error ivas_jbm_dec_render( mvr2r( st_ivas->hTcBuffer->tc[n] + st_ivas->hTcBuffer->n_samples_rendered, p_output[n], *nSamplesRendered ); } - if ( ( error = ivas_sba_linear_renderer( p_output, *nSamplesRendered, nchan_remapped, output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sba_linear_renderer( p_output, *nSamplesRendered, nchan_remapped, +#ifdef SBA_AND_OBJECTS + 0, +#endif + output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 2e6fbadef8..ac74efe8fc 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -650,7 +650,11 @@ void ivas_sba_dec_render( if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC ) { - ivas_sba_linear_renderer( output_f, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); + ivas_sba_linear_renderer( output_f, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE, +#ifdef SBA_AND_OBJECTS + 0, +#endif + st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); } if ( st_ivas->hDirAC != NULL && hSpar->slots_rendered == hSpar->num_slots ) diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 92420b92ef..8fd1345596 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -183,8 +183,8 @@ void ivas_mc2sba( } else { - azimuth = (int16_t) ( hIntSetup.ls_azimuth[idx_in] ); - elevation = (int16_t) ( hIntSetup.ls_elevation[idx_in] ); + azimuth = ( int16_t )( hIntSetup.ls_azimuth[idx_in] ); + elevation = ( int16_t )( hIntSetup.ls_elevation[idx_in] ); idx_in++; /* get HOA response for direction (ACN/SN3D)*/ @@ -404,20 +404,31 @@ void ivas_sba_upmixer_renderer( if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC ) { +#ifdef SBA_AND_OBJECTS + float *output_f[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; +#else float *output_f[MAX_OUTPUT_CHANNELS]; +#endif int16_t ch; #ifdef SBA_AND_OBJECTS AUDIO_CONFIG output_config; output_config = ( st_ivas->ivas_format == SBA_ISM_FORMAT ? st_ivas->hOutSetup.output_config : st_ivas->hDecoderConfig->output_config ); #endif - +#ifdef SBA_AND_OBJECTS + for ( ch = 0; ch < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch++ ) +#else for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) +#endif { output_f[ch] = output[ch]; } #ifdef SBA_AND_OBJECTS - ivas_sba_linear_renderer( output_f, output_frame, st_ivas->hIntSetup.nchan_out_woLFE, output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); + ivas_sba_linear_renderer( output_f, output_frame, st_ivas->hIntSetup.nchan_out_woLFE, +#ifdef SBA_AND_OBJECTS + st_ivas->nchan_ism, +#endif + output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); #else 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 ); #endif @@ -495,9 +506,12 @@ static void ivas_sba_mtx_mult( *-------------------------------------------------------------------*/ ivas_error ivas_sba_linear_renderer( - float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t nchan_in, /* i : number of input ambisonics channels */ + float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ + const int16_t output_frame, /* i : output frame length per channel */ + const int16_t nchan_in, /* i : number of input ambisonics channels */ +#ifdef SBA_AND_OBJECTS + const int16_t nchan_ism, +#endif const AUDIO_CONFIG output_config, /* i : output audio configuration */ const IVAS_OUTPUT_SETUP output_setup, /* i : output format setup */ const float hoa_dec_mtx[] /* i : HOA decoding mtx */ @@ -566,6 +580,18 @@ ivas_error ivas_sba_linear_renderer( set_zero( output_f[i], output_frame ); } break; +#ifdef SBA_AND_OBJECTS + case AUDIO_CONFIG_EXTERNAL: + for ( i = output_setup.nchan_out_woLFE-1; i >= nchan_ism; i-- ) + { + mvr2r( output_f[i - nchan_ism], output_f[i], output_frame ); + } + for ( ; i >= 0; i-- ) + { + set_zero( output_f[i], output_frame ); + } + break; +#endif default: return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: illegal output configuration, Exiting.\n" ); } @@ -662,7 +688,7 @@ static void debug_mode_dirac( #ifdef DEBUG_MODE_DIRAC_NOCORE for ( n = 0; n < nchan_transport; n++ ) { - sprintf( file_name, "./res/ivas_dirac_enc_%d.%d.pcm", n, (int16_t) ( output_frame * 0.05 ) ); + sprintf( file_name, "./res/ivas_dirac_enc_%d.%d.pcm", n, ( int16_t )( output_frame * 0.05 ) ); dbgread( tmp, sizeof( int16_t ), output_frame, file_name ); for ( i = 0; i < output_frame; i++ ) { @@ -674,10 +700,10 @@ static void debug_mode_dirac( { for ( i = 0; i < output_frame; i++ ) { - tmp[i] = (int16_t) ( output[n][i] + 0.5f ); + tmp[i] = ( int16_t )( output[n][i] + 0.5f ); } - sprintf( file_name, "./res/ivas_dirac_dec_%d.%d.pcm", n, (int16_t) ( output_frame * 0.05 ) ); + sprintf( file_name, "./res/ivas_dirac_dec_%d.%d.pcm", n, ( int16_t )( output_frame * 0.05 ) ); dbgwrite( tmp, sizeof( int16_t ), output_frame, 1, file_name ); } #endif diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index c3033c765a..c0a63079e1 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -326,12 +326,12 @@ ivas_error ivas_spar_dec( if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { #ifndef SBA_AND_OBJECTS - last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ); + last_bit_pos = ( int16_t )( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ); /* the number of objects was read */ last_bit_pos -= NO_BITS_MASA_ISM_NO_OBJ; *nb_bits_read += NO_BITS_MASA_ISM_NO_OBJ; #else - last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - nb_bits_read[1]; + last_bit_pos = ( int16_t )( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - nb_bits_read[1]; #endif } else @@ -354,12 +354,12 @@ ivas_error ivas_spar_dec( #ifdef SBA_AND_OBJECTS if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - nb_bits_read[1]; + last_bit_pos = ( int16_t )( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - nb_bits_read[1]; } else { #endif - last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ); + last_bit_pos = ( int16_t )( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ); #ifdef SBA_AND_OBJECTS } #endif @@ -394,7 +394,7 @@ ivas_error ivas_spar_dec( { int16_t zero_pad_bits; *nb_bits_read += SID_FORMAT_NBITS; - zero_pad_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - *nb_bits_read; + zero_pad_bits = ( int16_t )( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - *nb_bits_read; assert( zero_pad_bits <= 1 ); *nb_bits_read += zero_pad_bits; } @@ -575,7 +575,7 @@ void ivas_spar_get_cldfb_gains( weights = hSpar->hFbMixer->cldfb_cross_fade; cf_cldfb_start = (int16_t) ceil( ( cf_start - decfb_delay / 2 ) / (float) stride - 0.5f ); - cf_cldfb_end = (int16_t) ( ( cf_start - decfb_delay / 2 + cf_len ) / (float) stride - 0.5f ); + cf_cldfb_end = ( int16_t )( ( cf_start - decfb_delay / 2 + cf_len ) / (float) stride - 0.5f ); num_cf_slots = cf_cldfb_end - cf_cldfb_start + 1; num_samples = num_cf_slots * stride + pt_len - stride; @@ -880,7 +880,7 @@ static float ivas_spar_get_cldfb_slot_gain( encfb_delay = IVAS_FB_ENC_DELAY_NS; decfb_delay = IVAS_FB_DEC_DELAY_NS; xfade_start_ns = hSpar->hFbMixer->cross_fade_start_offset / output_Fs * 1000000000.f - encfb_delay + decfb_delay * 0.5f; - xfade_delay_subframes = (int16_t) ( xfade_start_ns / ( FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ) ); + xfade_delay_subframes = ( int16_t )( xfade_start_ns / ( FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ) ); i_hist = 4 - xfade_delay_subframes; split_band = SPAR_DIRAC_SPLIT_START_BAND; @@ -1289,7 +1289,7 @@ void ivas_spar_dec_digest_tc( int16_t nSamplesLeftForTD, default_frame; /* TD decorrelator */ - default_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + default_frame = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); nSamplesLeftForTD = nSamplesForRendering; nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); @@ -1513,8 +1513,7 @@ void ivas_spar_dec_upmixer_sf( for ( i = 0; i < nchan_transport; i++ ) { tmp = roundf( output[i][j] * PCM16_TO_FLT_FAC ); - pcm = ( tmp > MAX16B_FLT ) ? MAX16B : ( tmp < MIN16B_FLT ) ? MIN16B - : (short) tmp; + pcm = ( tmp > MAX16B_FLT ) ? MAX16B : ( tmp < MIN16B_FLT ) ? MIN16B : (short) tmp; dbgwrite( &pcm, sizeof( int16_t ), 1, 1, "dmx_dec.raw" ); } } @@ -1727,6 +1726,12 @@ void ivas_spar_dec_upmixer_sf( idx_lfe = 0; outchannels = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + + if ( hDecoderConfig->output_config == AUDIO_CONFIG_EXTERNAL ) + { + outchannels -= st_ivas->nchan_ism; + } + for ( ch = 0; ch < outchannels; ch++ ) { if ( ( st_ivas->hOutSetup.num_lfe > 0 ) && ( st_ivas->hOutSetup.index_lfe[idx_lfe] == ch ) ) @@ -1739,11 +1744,12 @@ void ivas_spar_dec_upmixer_sf( } else { - if ( hDecoderConfig->output_config == AUDIO_CONFIG_FOA || !( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB + if ( hDecoderConfig->output_config == AUDIO_CONFIG_FOA || + !( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB #ifdef SPLIT_REND_WITH_HEAD_ROT - || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM + || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_SPLIT_PCM #endif - ) ) + ) ) { for ( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index b3f078f409..fcc1203271 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -103,7 +103,7 @@ void ivas_write_format( #ifdef SBA_AND_OBJECTS case SBA_ISM_FORMAT: #ifdef SBA_AND_OBJECTS - if ( st_ivas->hEncoderConfig->ivas_total_brate < IVAS_256k ) + if ( 0 ) #else if ( st_ivas->ism_mode == ISM_MODE_NONE ) #endif -- GitLab From 2a894ec0c97c5f972208e430ea546f870d0c2945 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 9 Aug 2023 16:13:56 +0200 Subject: [PATCH 080/109] fix formatting --- lib_com/bitstream.c | 28 +++++++++++++-------------- lib_dec/ivas_dec.c | 14 +++++++------- lib_dec/ivas_init_dec.c | 2 +- lib_dec/ivas_ism_metadata_dec.c | 2 +- lib_dec/ivas_jbm_dec.c | 4 ++-- lib_dec/ivas_sba_dec.c | 4 ++-- lib_dec/ivas_sba_rendering_internal.c | 12 ++++++------ lib_dec/ivas_spar_decoder.c | 19 +++++++++--------- 8 files changed, 43 insertions(+), 42 deletions(-) diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index d711ee37ca..3ed6283883 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -236,7 +236,7 @@ ivas_error ind_list_realloc( if ( hBstr != NULL ) { /* get the current position inside the old list */ - ind_list_pos = ( int16_t )( hBstr->ind_list - old_ind_list ); + ind_list_pos = (int16_t) ( hBstr->ind_list - old_ind_list ); /* set pointers in the new list */ *( hBstr->ivas_ind_list_zero ) = new_ind_list; @@ -274,7 +274,7 @@ ivas_error ind_list_realloc( if ( hBstr != NULL ) { /* get the current position inside the old list */ - ind_list_pos = ( int16_t )( hBstr->ind_list - old_ind_list ); + ind_list_pos = (int16_t) ( hBstr->ind_list - old_ind_list ); /* set pointers in the new list */ *( hBstr->ivas_ind_list_zero ) = new_ind_list; @@ -326,7 +326,7 @@ ivas_error ind_list_realloc( } /* get the current position inside the old list */ - ind_list_pos = ( int16_t )( hBstr->ind_list - ( *hBstr->ivas_ind_list_zero ) ); + ind_list_pos = (int16_t) ( hBstr->ind_list - ( *hBstr->ivas_ind_list_zero ) ); /* free the old list */ free( ( *hBstr->ivas_ind_list_zero ) ); @@ -1348,7 +1348,7 @@ ivas_error push_next_bits( for ( i = 0; i < nb_bits_m15; i += 16 ) { - code = ( uint16_t )( ( bits[i] << 15 ) | ( ( bits[i + 1] << 14 ) | ( ( bits[i + 2] << 13 ) | ( ( bits[i + 3] << 12 ) | ( ( bits[i + 4] << 11 ) | ( ( bits[i + 5] << 10 ) | ( ( bits[i + 6] << 9 ) | ( ( bits[i + 7] << 8 ) | ( ( bits[i + 8] << 7 ) | ( ( bits[i + 9] << 6 ) | ( ( bits[i + 10] << 5 ) | ( ( bits[i + 11] << 4 ) | ( ( bits[i + 12] << 3 ) | ( ( bits[i + 13] << 2 ) | ( ( bits[i + 14] << 1 ) | bits[i + 15] ) ) ) ) ) ) ) ) ) ) ) ) ) ) ); + code = (uint16_t) ( ( bits[i] << 15 ) | ( ( bits[i + 1] << 14 ) | ( ( bits[i + 2] << 13 ) | ( ( bits[i + 3] << 12 ) | ( ( bits[i + 4] << 11 ) | ( ( bits[i + 5] << 10 ) | ( ( bits[i + 6] << 9 ) | ( ( bits[i + 7] << 8 ) | ( ( bits[i + 8] << 7 ) | ( ( bits[i + 9] << 6 ) | ( ( bits[i + 10] << 5 ) | ( ( bits[i + 11] << 4 ) | ( ( bits[i + 12] << 3 ) | ( ( bits[i + 13] << 2 ) | ( ( bits[i + 14] << 1 ) | bits[i + 15] ) ) ) ) ) ) ) ) ) ) ) ) ) ) ); /* check the limits of the list of indices */ if ( ( error = check_ind_list_limits( hBstr ) ) != IVAS_ERR_OK ) @@ -2027,7 +2027,7 @@ ivas_error write_indices_ivas( write_indices_element( st_ivas, &pt_stream, 0, n ); } - *num_bits = ( uint16_t )( pt_stream - bit_stream ); + *num_bits = (uint16_t) ( pt_stream - bit_stream ); return error; } @@ -2745,7 +2745,7 @@ void ivas_set_bitstream_pointers( { sts = st_ivas->hSCE[k]->hCoreCoder; sts[0]->bit_stream = st_ivas->bit_stream + num_bits; - num_bits += ( int16_t )( st_ivas->hSCE[k]->element_brate / FRAMES_PER_SEC ); + num_bits += (int16_t) ( st_ivas->hSCE[k]->element_brate / FRAMES_PER_SEC ); } /* set bitstream pointers for CPEs */ @@ -2753,7 +2753,7 @@ void ivas_set_bitstream_pointers( { sts = st_ivas->hCPE[k]->hCoreCoder; sts[0]->bit_stream = st_ivas->bit_stream + num_bits; - num_bits += ( int16_t )( st_ivas->hCPE[k]->element_brate / FRAMES_PER_SEC ); + num_bits += (int16_t) ( st_ivas->hCPE[k]->element_brate / FRAMES_PER_SEC ); } return; @@ -2783,7 +2783,7 @@ ivas_error preview_indices( error = IVAS_ERR_OK; /* convert the frame length to total bitrate */ - total_brate = ( int32_t )( num_bits * FRAMES_PER_SEC ); + total_brate = (int32_t) ( num_bits * FRAMES_PER_SEC ); if ( st_ivas->ivas_format != MONO_FORMAT && is_DTXrate( total_brate ) == 0 ) { @@ -2972,7 +2972,7 @@ ivas_error preview_indices( /* read number of objects from the bitstream */ st_ivas->nchan_transport = 1; - k = ( int16_t )( ( total_brate / FRAMES_PER_SEC ) - 1 ); + k = (int16_t) ( ( total_brate / FRAMES_PER_SEC ) - 1 ); while ( bit_stream[k] == 1 && st_ivas->nchan_transport < MAX_NUM_OBJECTS ) { st_ivas->nchan_transport++; @@ -3015,9 +3015,9 @@ ivas_error preview_indices( else { st_ivas->sba_order = 3; - } + } - st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( total_brate, st_ivas->sba_order ); + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( total_brate, st_ivas->sba_order ); ivas_sba_config( total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &( st_ivas->nSCE ), &( st_ivas->nCPE ), &( st_ivas->element_mode_init ) ); } @@ -3092,7 +3092,7 @@ ivas_error read_indices( #endif /* convert the frame length to total bitrate */ - total_brate = ( int32_t )( num_bits * FRAMES_PER_SEC ); + total_brate = (int32_t) ( num_bits * FRAMES_PER_SEC ); /* verify that a valid num bits value is present in the G.192 file */ /* only AMRWB, EVS or IVAS bitrates or 0(NO DATA) are allowed in G.192 file frame reading */ @@ -3509,7 +3509,7 @@ static void get_rfFrameType( ) { int16_t num_bits; - num_bits = ( int16_t )( st->total_brate / FRAMES_PER_SEC ); + num_bits = (int16_t) ( st->total_brate / FRAMES_PER_SEC ); if ( st->rf_flag == 1 ) { /* the last three bits in a packet is the RF frame type */ @@ -3590,7 +3590,7 @@ static void get_rf_fec_offset( ) { int16_t num_bits, tmp; - num_bits = ( int16_t )( st->total_brate / FRAMES_PER_SEC ); + num_bits = (int16_t) ( st->total_brate / FRAMES_PER_SEC ); if ( st->rf_flag == 1 ) { /* the two bits before the RF frame type contains the FEC offset */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index d0b195b980..91d3b40d63 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -122,7 +122,7 @@ ivas_error ivas_dec( output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); #ifdef SBA_AND_OBJECTS - for ( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) + for ( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) #else for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) #endif @@ -546,7 +546,7 @@ ivas_error ivas_dec( #ifdef SBA_AND_OBJECTS 0, #endif - output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) + output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) { return error; } @@ -796,14 +796,14 @@ ivas_error ivas_dec( delay_signal( tmp_ism_out[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); } - if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI ) + if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI ) { ivas_ism2sba( p_tmp_ism_out, st_ivas->hIsmRendererData, st_ivas->hIsmMetaData, st_ivas->nchan_ism, output_frame, st_ivas->hIntSetup.ambisonics_order ); - } - else - { + } + else + { ivas_ism_render( st_ivas, p_tmp_ism_out, output_frame ); - } + } ivas_sba_upmixer_renderer( st_ivas, &output[st_ivas->nchan_ism], output_frame ); diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 9e5dd39fba..3c8729ad35 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2971,7 +2971,7 @@ static ivas_error doSanityChecks_IVAS( else if ( st_ivas->ivas_format == SBA_FORMAT ) { /* Verify SBA output coniguration */ - if ( output_config == AUDIO_CONFIG_INVALID ) + if ( output_config == AUDIO_CONFIG_INVALID ) { return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for SBA" ); } diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index d801ad5f75..e18bda5c34 100755 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -247,7 +247,7 @@ ivas_error ivas_ism_metadata_dec( /* read extended metadata presence flag */ #ifdef MASA_AND_OBJECTS #ifdef SBA_AND_OBJECTS - if ( (ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC) && ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) + if ( ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC ) && ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) #else if ( ism_mode == ISM_MODE_DISC && ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) #endif diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 982837aaf1..3031affb7c 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -873,11 +873,11 @@ ivas_error ivas_jbm_dec_render( mvr2r( st_ivas->hTcBuffer->tc[n] + st_ivas->hTcBuffer->n_samples_rendered, p_output[n], *nSamplesRendered ); } - if ( ( error = ivas_sba_linear_renderer( p_output, *nSamplesRendered, nchan_remapped, + if ( ( error = ivas_sba_linear_renderer( p_output, *nSamplesRendered, nchan_remapped, #ifdef SBA_AND_OBJECTS 0, #endif - output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) + output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index ac74efe8fc..972fd7e3d2 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -650,11 +650,11 @@ void ivas_sba_dec_render( if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC ) { - ivas_sba_linear_renderer( output_f, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE, + ivas_sba_linear_renderer( output_f, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE, #ifdef SBA_AND_OBJECTS 0, #endif - st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); + st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); } if ( st_ivas->hDirAC != NULL && hSpar->slots_rendered == hSpar->num_slots ) diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 8fd1345596..c0d40f8823 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -183,8 +183,8 @@ void ivas_mc2sba( } else { - azimuth = ( int16_t )( hIntSetup.ls_azimuth[idx_in] ); - elevation = ( int16_t )( hIntSetup.ls_elevation[idx_in] ); + azimuth = (int16_t) ( hIntSetup.ls_azimuth[idx_in] ); + elevation = (int16_t) ( hIntSetup.ls_elevation[idx_in] ); idx_in++; /* get HOA response for direction (ACN/SN3D)*/ @@ -582,7 +582,7 @@ ivas_error ivas_sba_linear_renderer( break; #ifdef SBA_AND_OBJECTS case AUDIO_CONFIG_EXTERNAL: - for ( i = output_setup.nchan_out_woLFE-1; i >= nchan_ism; i-- ) + for ( i = output_setup.nchan_out_woLFE - 1; i >= nchan_ism; i-- ) { mvr2r( output_f[i - nchan_ism], output_f[i], output_frame ); } @@ -688,7 +688,7 @@ static void debug_mode_dirac( #ifdef DEBUG_MODE_DIRAC_NOCORE for ( n = 0; n < nchan_transport; n++ ) { - sprintf( file_name, "./res/ivas_dirac_enc_%d.%d.pcm", n, ( int16_t )( output_frame * 0.05 ) ); + sprintf( file_name, "./res/ivas_dirac_enc_%d.%d.pcm", n, (int16_t) ( output_frame * 0.05 ) ); dbgread( tmp, sizeof( int16_t ), output_frame, file_name ); for ( i = 0; i < output_frame; i++ ) { @@ -700,10 +700,10 @@ static void debug_mode_dirac( { for ( i = 0; i < output_frame; i++ ) { - tmp[i] = ( int16_t )( output[n][i] + 0.5f ); + tmp[i] = (int16_t) ( output[n][i] + 0.5f ); } - sprintf( file_name, "./res/ivas_dirac_dec_%d.%d.pcm", n, ( int16_t )( output_frame * 0.05 ) ); + sprintf( file_name, "./res/ivas_dirac_dec_%d.%d.pcm", n, (int16_t) ( output_frame * 0.05 ) ); dbgwrite( tmp, sizeof( int16_t ), output_frame, 1, file_name ); } #endif diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index c0a63079e1..3ba85379a9 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -326,12 +326,12 @@ ivas_error ivas_spar_dec( if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { #ifndef SBA_AND_OBJECTS - last_bit_pos = ( int16_t )( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ); + last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ); /* the number of objects was read */ last_bit_pos -= NO_BITS_MASA_ISM_NO_OBJ; *nb_bits_read += NO_BITS_MASA_ISM_NO_OBJ; #else - last_bit_pos = ( int16_t )( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - nb_bits_read[1]; + last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - nb_bits_read[1]; #endif } else @@ -354,12 +354,12 @@ ivas_error ivas_spar_dec( #ifdef SBA_AND_OBJECTS if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - last_bit_pos = ( int16_t )( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - nb_bits_read[1]; + last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - nb_bits_read[1]; } else { #endif - last_bit_pos = ( int16_t )( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ); + last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ); #ifdef SBA_AND_OBJECTS } #endif @@ -394,7 +394,7 @@ ivas_error ivas_spar_dec( { int16_t zero_pad_bits; *nb_bits_read += SID_FORMAT_NBITS; - zero_pad_bits = ( int16_t )( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - *nb_bits_read; + zero_pad_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - *nb_bits_read; assert( zero_pad_bits <= 1 ); *nb_bits_read += zero_pad_bits; } @@ -575,7 +575,7 @@ void ivas_spar_get_cldfb_gains( weights = hSpar->hFbMixer->cldfb_cross_fade; cf_cldfb_start = (int16_t) ceil( ( cf_start - decfb_delay / 2 ) / (float) stride - 0.5f ); - cf_cldfb_end = ( int16_t )( ( cf_start - decfb_delay / 2 + cf_len ) / (float) stride - 0.5f ); + cf_cldfb_end = (int16_t) ( ( cf_start - decfb_delay / 2 + cf_len ) / (float) stride - 0.5f ); num_cf_slots = cf_cldfb_end - cf_cldfb_start + 1; num_samples = num_cf_slots * stride + pt_len - stride; @@ -880,7 +880,7 @@ static float ivas_spar_get_cldfb_slot_gain( encfb_delay = IVAS_FB_ENC_DELAY_NS; decfb_delay = IVAS_FB_DEC_DELAY_NS; xfade_start_ns = hSpar->hFbMixer->cross_fade_start_offset / output_Fs * 1000000000.f - encfb_delay + decfb_delay * 0.5f; - xfade_delay_subframes = ( int16_t )( xfade_start_ns / ( FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ) ); + xfade_delay_subframes = (int16_t) ( xfade_start_ns / ( FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ) ); i_hist = 4 - xfade_delay_subframes; split_band = SPAR_DIRAC_SPLIT_START_BAND; @@ -1289,7 +1289,7 @@ void ivas_spar_dec_digest_tc( int16_t nSamplesLeftForTD, default_frame; /* TD decorrelator */ - default_frame = ( int16_t )( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + default_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); nSamplesLeftForTD = nSamplesForRendering; nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); @@ -1513,7 +1513,8 @@ void ivas_spar_dec_upmixer_sf( for ( i = 0; i < nchan_transport; i++ ) { tmp = roundf( output[i][j] * PCM16_TO_FLT_FAC ); - pcm = ( tmp > MAX16B_FLT ) ? MAX16B : ( tmp < MIN16B_FLT ) ? MIN16B : (short) tmp; + pcm = ( tmp > MAX16B_FLT ) ? MAX16B : ( tmp < MIN16B_FLT ) ? MIN16B + : (short) tmp; dbgwrite( &pcm, sizeof( int16_t ), 1, 1, "dmx_dec.raw" ); } } -- GitLab From ed6d80ca124b113ae1bfe06c8bd553989dd564c7 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 9 Aug 2023 17:08:20 +0200 Subject: [PATCH 081/109] fix EXT output at high BRs --- lib_dec/ivas_spar_decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 3ba85379a9..1cc5c8f592 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1728,7 +1728,7 @@ void ivas_spar_dec_upmixer_sf( outchannels = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; - if ( hDecoderConfig->output_config == AUDIO_CONFIG_EXTERNAL ) + if ( hDecoderConfig->output_config == AUDIO_CONFIG_EXTERNAL && hDecoderConfig->ivas_total_brate < IVAS_256k ) { outchannels -= st_ivas->nchan_ism; } -- GitLab From 921fa531cdc99756f0dbf7559a39ba765c6ad82d Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 10 Aug 2023 17:42:02 +1000 Subject: [PATCH 082/109] ISM SBA format at all bitrates --- lib_dec/ivas_dec.c | 116 ++++++++++++++++++--- lib_dec/ivas_init_dec.c | 113 ++++++++++++++------ lib_dec/ivas_sba_dec.c | 154 +++++++++++++++------------- lib_dec/ivas_sce_dec.c | 6 ++ lib_dec/ivas_spar_decoder.c | 4 +- lib_dec/ivas_stereo_mdct_core_dec.c | 6 +- lib_enc/ivas_enc.c | 25 ++++- lib_enc/ivas_init_enc.c | 2 +- 8 files changed, 297 insertions(+), 129 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 91d3b40d63..370bf2c92b 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -679,17 +679,24 @@ ivas_error ivas_dec( #ifdef SBA_AND_OBJECTS else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { - int16_t nchan_ism; + int16_t nchan_ism, sba_ch_idx; set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); - -#ifdef SBA_AND_OBJECTS - /* set ISM parameters and decode ISM metadata in OSBA format */ - if ( ( error = ivas_osba_ism_metadata_dec( st_ivas, ivas_total_brate, &nchan_ism, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + nchan_ism = st_ivas->nchan_ism; + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - return error; + /* set ISM parameters and decode ISM metadata in OSBA format */ + if ( ( error = ivas_osba_ism_metadata_dec( st_ivas, ivas_total_brate, &nchan_ism, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + { + return error; + } + sba_ch_idx = st_ivas->nchan_ism; + } + else + { + nb_bits_metadata[1] += NO_BITS_MASA_ISM_NO_OBJ; + sba_ch_idx = 0; } -#endif /* SBA metadata decoding */ if ( ( error = ivas_spar_dec( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK ) @@ -697,21 +704,45 @@ ivas_error ivas_dec( return error; } - st = st_ivas->hCPE[0]->hCoreCoder[0]; + if ( st_ivas->nchan_transport == CPE_CHANNELS && st_ivas->nCPE >= 1 ) + { + st_ivas->hCPE[0]->element_brate = ivas_total_brate; + } - if ( ( error = ivas_mct_dec( st_ivas, output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + /* core-decoding of transport channels */ + if ( st_ivas->nSCE == 1 ) { - return error; + st = st_ivas->hSCE[0]->hCoreCoder[0]; + if ( ( error = ivas_sce_dec( st_ivas, 0, &output[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->nCPE == 1 ) + { + st = st_ivas->hCPE[0]->hCoreCoder[0]; + if ( ( error = ivas_cpe_dec( st_ivas, 0, output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->nCPE > 1 ) + { + st = st_ivas->hCPE[0]->hCoreCoder[0]; + if ( ( error = ivas_mct_dec( st_ivas, output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + { + return error; + } } #ifdef SBA_AND_OBJECTS if ( st_ivas->sba_dirac_stereo_flag ) { - ivas_agc_dec_process( st_ivas->hSpar->hAgcDec, &output[st_ivas->nchan_ism], &output[st_ivas->nchan_ism], st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); + ivas_agc_dec_process( st_ivas->hSpar->hAgcDec, &output[sba_ch_idx], &output[sba_ch_idx], st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); if ( st_ivas->hSpar->hPCA != NULL ) { - ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &output[st_ivas->nchan_ism] ); + ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &output[sba_ch_idx] ); } ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, @@ -722,7 +753,7 @@ ivas_error ivas_dec( #endif ) ); - ivas_sba_dirac_stereo_dec( st_ivas, &output[st_ivas->nchan_ism], output_frame, 0 ); + ivas_sba_dirac_stereo_dec( st_ivas, &output[sba_ch_idx], output_frame, 0 ); } #endif @@ -732,9 +763,10 @@ ivas_error ivas_dec( hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } - nchan_remapped = ivas_sba_remapTCs( &output[st_ivas->nchan_ism], st_ivas, output_frame ); + nchan_remapped = ivas_sba_remapTCs( &output[sba_ch_idx], st_ivas, output_frame ); #ifdef DEBUG_OSBA + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { int16_t nchan = st_ivas->nchan_transport + st_ivas->nchan_ism; for ( int t = 0; t < output_frame; t++ ) @@ -747,12 +779,62 @@ ivas_error ivas_dec( } } #endif + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { +#ifdef VLBR_20MS_MD + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, + st_ivas->last_active_ivas_total_brate ); + ivas_sba_mix_matrix_determiner( st_ivas->hSpar, &output[sba_ch_idx], st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); +#else + ivas_sba_mix_matrix_determiner( st_ivas->hSpar, output, st_ivas->bfi, nchan_remapped, output_frame ); +#endif + } + else if ( st_ivas->renderer_type != RENDERER_DISABLE ) + { + ivas_spar_dec_agc_pca( st_ivas, &output[sba_ch_idx], output_frame ); + } + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { +#ifdef FIX_564 + /* loudness correction */ + ivas_dirac_dec_binaural_sba_gain( &output[sba_ch_idx], nchan_remapped, output_frame ); +#else + float gain; + + if ( nchan_remapped == 1 ) + { + gain = 1.4454f; + } + else + { + gain = 1.3657f; + } + + for ( n = 0; n < nchan_remapped; n++ ) + { + v_multc( output[n], gain, output[n], output_frame ); + } +#endif + } - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + /* 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 ) { - if ( ( error = ivas_osba_dirac_td_binaural( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) + ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, &output[sba_ch_idx], nchan_remapped ); + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + { + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - return error; + if ( ( error = ivas_osba_dirac_td_binaural( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + ivas_sba_upmixer_renderer( st_ivas, &output[sba_ch_idx], output_frame ); } } #ifdef SBA_AND_OBJECTS diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 3c8729ad35..227d717e35 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -423,32 +423,27 @@ ivas_error ivas_dec_setup( /* the number of objects is written at the end of the bitstream, in the SBA metadata */ st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1; - /* read Ambisonic (SBA) planar flag */ - st_ivas->sba_planar = st_ivas->bit_stream[num_bits_read]; - num_bits_read += SBA_PLANAR_BITS; - - /* read Ambisonic (SBA) order */ - if ( ivas_total_brate >= IVAS_256k ) + if ( ivas_total_brate < IVAS_24k4 || ivas_total_brate >= IVAS_256k ) { - st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; - st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; - st_ivas->ism_mode = ISM_SBA_MODE_DISC; + /* read Ambisonic (SBA) planar flag */ + st_ivas->sba_planar = st_ivas->bit_stream[num_bits_read]; + num_bits_read += SBA_PLANAR_BITS; } - else + + st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; + st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; + num_bits_read += SBA_ORDER_BITS; + + /* read Ambisonic (SBA) order */ + if ( ivas_total_brate < IVAS_256k ) { st_ivas->sba_order = 3; - - st_ivas->nchan_ism = st_ivas->bit_stream[num_bits_read + 1]; - st_ivas->nchan_ism += 2 * st_ivas->bit_stream[num_bits_read]; - st_ivas->nchan_ism++; - st_ivas->ivas_format = SBA_FORMAT; - st_ivas->ism_mode = ISM_MODE_NONE; } + /* set Ambisonic (SBA) order used for analysis and coding */ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); - num_bits_read += SBA_ORDER_BITS; if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate && ivas_total_brate > IVAS_SID_5k2 ) { if ( ( error = ivas_sba_dec_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) @@ -474,8 +469,14 @@ ivas_error ivas_dec_setup( st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; } #endif - - st_ivas->ism_mode = ISM_SBA_MODE_DISC; + if ( ivas_total_brate >= IVAS_256k ) + { + st_ivas->ism_mode = ISM_SBA_MODE_DISC; + } + else + { + st_ivas->ism_mode = ISM_MODE_NONE; + } } #endif else if ( st_ivas->ivas_format == MC_FORMAT ) @@ -748,6 +749,17 @@ static ivas_error ivas_read_format( else { st_ivas->ivas_format = SBA_FORMAT; +#ifdef SBA_AND_OBJECTS + /* read Ambisonic (SBA) planar flag */ + st_ivas->sba_planar = st_ivas->bit_stream[( *num_bits_read ) + 1]; + /* read Ambisonic (SBA) order */ + st_ivas->sba_order = st_ivas->bit_stream[( *num_bits_read ) + 2 + SBA_PLANAR_BITS]; + st_ivas->sba_order += 2 * st_ivas->bit_stream[( *num_bits_read ) + 1 + SBA_PLANAR_BITS]; + if ( st_ivas->sba_order == 0 ) + { + st_ivas->ivas_format = SBA_ISM_FORMAT; + } +#endif } ( *num_bits_read )++; @@ -864,7 +876,14 @@ int16_t getNumChanSynthesis( #ifdef SBA_AND_OBJECTS else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { - n = st_ivas->nchan_transport + st_ivas->nchan_ism; + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + n = st_ivas->nchan_transport + st_ivas->nchan_ism; + } + else + { + n = st_ivas->nchan_transport; + } } #endif return n; @@ -1485,9 +1504,21 @@ ivas_error ivas_init_decoder( } st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); - st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; + for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) + { + if ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) + { + return error; + } + + reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] ); + } - st_ivas->element_mode_init = IVAS_CPE_MDCT; + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; + st_ivas->element_mode_init = IVAS_CPE_MDCT; + } for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { @@ -1503,24 +1534,35 @@ ivas_error ivas_init_decoder( } #ifdef OSBA_BR_SWITCHING - st_ivas->nchan_transport += st_ivas->nchan_ism; + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + st_ivas->nchan_transport += st_ivas->nchan_ism; + } #endif - if ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) + if ( st_ivas->nCPE > 1 ) { - return error; + if ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } } - if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - return error; + if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( error = ivas_masa_ism_data_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } } + /* set CNA/CNG flags */ ivas_sba_set_cna_cng_flag( st_ivas ); - if ( ( error = ivas_masa_ism_data_open( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } } #endif #ifdef MASA_AND_OBJECTS @@ -2051,10 +2093,13 @@ ivas_error ivas_init_decoder( return error; } } - /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ - if ( ( error = ivas_sba_ism_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - return error; + /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ + if ( ( error = ivas_sba_ism_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } } } #endif diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 972fd7e3d2..831fc4fdb8 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -135,14 +135,26 @@ ivas_error ivas_sba_dec_reconfigure( ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); nchan_hp20_old = getNumChanSynthesis( st_ivas ); #ifdef OSBA_BR_SWITCHING - if ( ism_mode_old == ISM_MODE_NONE && st_ivas->ivas_format == SBA_ISM_FORMAT ) + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { - nchan_hp20_old = st_ivas->nchan_transport; - } - else if ( ism_mode_old == ISM_SBA_MODE_DISC && st_ivas->ivas_format == SBA_FORMAT ) - { - nchan_hp20_old += st_ivas->nchan_ism; + if ( ivas_total_brate >= IVAS_256k ) + { + st_ivas->ism_mode = ISM_SBA_MODE_DISC; + } + else + { + st_ivas->ism_mode = ISM_MODE_NONE; + } + if ( ism_mode_old == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + nchan_hp20_old = st_ivas->nchan_transport; + } + else if ( ism_mode_old == ISM_SBA_MODE_DISC && st_ivas->ism_mode == ISM_MODE_NONE ) + { + nchan_hp20_old += st_ivas->nchan_ism; + } } + #endif nSCE_old = st_ivas->nSCE; nCPE_old = st_ivas->nCPE; @@ -327,91 +339,95 @@ ivas_error ivas_sba_dec_reconfigure( * Allocate, initialize, and configure SCE/CPE/MCT handles *-----------------------------------------------------------------*/ #ifdef OSBA_BR_SWITCHING - if ( ism_mode_old == ISM_MODE_NONE && st_ivas->ivas_format == SBA_ISM_FORMAT ) + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { - int32_t temp_brate[MAX_SCE]; - st_ivas->ism_mode = ISM_SBA_MODE_DISC; - if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) + if ( ism_mode_old == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - return error; - } - - if ( ( st_ivas->renderer_type == RENDERER_TD_PANNING || - st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX || - st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || - st_ivas->renderer_type == RENDERER_OSBA_STEREO || - st_ivas->renderer_type == RENDERER_OSBA_AMBI || - st_ivas->renderer_type == RENDERER_OSBA_LS || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) - { - if ( ( error = ivas_ism_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + int32_t temp_brate[MAX_SCE]; + st_ivas->ism_mode = ISM_SBA_MODE_DISC; + if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) { return error; } - } - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) - { - /* Allocate TD renderer for the objects in DISC mode */ - if ( st_ivas->hBinRendererTd == NULL ) + + if ( ( st_ivas->renderer_type == RENDERER_TD_PANNING || + st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX || + st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || + st_ivas->renderer_type == RENDERER_OSBA_STEREO || + st_ivas->renderer_type == RENDERER_OSBA_AMBI || + st_ivas->renderer_type == RENDERER_OSBA_LS || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { - if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } - } - if ( ( error = ivas_masa_ism_data_open( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ - if ( ( error = ivas_sba_ism_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + { + /* Allocate TD renderer for the objects in DISC mode */ + if ( st_ivas->hBinRendererTd == NULL ) + { + if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + if ( ( error = ivas_masa_ism_data_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ + if ( ( error = ivas_sba_ism_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } - st_ivas->nchan_transport += st_ivas->nchan_ism; - st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; - } - else if ( ism_mode_old == ISM_SBA_MODE_DISC && st_ivas->ivas_format == SBA_FORMAT ) - { - /* ISM renderer handle */ - if ( st_ivas->hIsmRendererData != NULL ) - { - free( st_ivas->hIsmRendererData->interpolator ); - free( st_ivas->hIsmRendererData ); - st_ivas->hIsmRendererData = NULL; + st_ivas->nchan_transport += st_ivas->nchan_ism; + st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; } - ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 ); - ivas_masa_ism_data_close( &st_ivas->hMasaIsmData ); + else if ( ism_mode_old == ISM_SBA_MODE_DISC && st_ivas->ism_mode == ISM_MODE_NONE ) + { + /* ISM renderer handle */ + if ( st_ivas->hIsmRendererData != NULL ) + { + free( st_ivas->hIsmRendererData->interpolator ); + free( st_ivas->hIsmRendererData ); + st_ivas->hIsmRendererData = NULL; + } + ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 ); + ivas_masa_ism_data_close( &st_ivas->hMasaIsmData ); - /* Time Domain binaural renderer handle */ + /* Time Domain binaural renderer handle */ - if ( st_ivas->hBinRendererTd != NULL ) - { - if ( st_ivas->hBinRendererTd->HrFiltSet_p->ModelParams.modelROM == TRUE ) + if ( st_ivas->hBinRendererTd != NULL ) { - ivas_td_binaural_close( &st_ivas->hBinRendererTd ); - if ( st_ivas->hHrtfTD != NULL ) + if ( st_ivas->hBinRendererTd->HrFiltSet_p->ModelParams.modelROM == TRUE ) { - st_ivas->hHrtfTD = NULL; + ivas_td_binaural_close( &st_ivas->hBinRendererTd ); + if ( st_ivas->hHrtfTD != NULL ) + { + st_ivas->hHrtfTD = NULL; + } } } + nchan_transport_old += st_ivas->nchan_ism; + st_ivas->ism_mode = ISM_MODE_NONE; + } + else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + st_ivas->nchan_transport += st_ivas->nchan_ism; + st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; + nCPE_old = st_ivas->nCPE; + nchan_transport_old = st_ivas->nchan_transport; } - nchan_transport_old += st_ivas->nchan_ism; - st_ivas->ism_mode = ISM_MODE_NONE; - } - else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) - { - st_ivas->nchan_transport += st_ivas->nchan_ism; - st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; - nCPE_old = st_ivas->nCPE; - nchan_transport_old = st_ivas->nchan_transport; } #endif + if ( ( error = ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport, ( st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index 3f8d8052e4..57c0bcc88d 100755 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -165,6 +165,12 @@ ivas_error ivas_sce_dec( { st->bits_frame_nominal = (int16_t) ( hSCE->element_brate / FRAMES_PER_SEC ); } +#ifdef SBA_AND_OBJECTS + if ( st_ivas->ism_mode == ISM_MODE_NONE && st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + st->bits_frame_nominal = (int16_t) ( st_ivas->hSpar->core_nominal_brate / FRAMES_PER_SEC ); + } +#endif else { st->bits_frame_nominal = st_ivas->hQMetaData->bits_frame_nominal; diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index a95a7b3fe1..9f6113c021 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -323,7 +323,7 @@ ivas_error ivas_spar_dec( next_bit_pos_orig = st0->next_bit_pos; #ifdef SBA_AND_OBJECTS - if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { #ifndef SBA_AND_OBJECTS last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ); @@ -352,7 +352,7 @@ ivas_error ivas_spar_dec( } #ifdef SBA_AND_OBJECTS - if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - nb_bits_read[1]; } diff --git a/lib_dec/ivas_stereo_mdct_core_dec.c b/lib_dec/ivas_stereo_mdct_core_dec.c index 1019868229..325ec91b0b 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec.c +++ b/lib_dec/ivas_stereo_mdct_core_dec.c @@ -215,9 +215,11 @@ void stereo_mdct_core_dec( set_s( ms_mask[1], 0, MAX_SFB ); initMdctStereoDecData( hCPE->hStereoMdct, sts[0]->igf, sts[0]->hIGFDec->igfData.igfInfo.grid, hCPE->element_brate, sts[0]->bwidth ); - +#ifdef SBA_AND_OBJECTS + hCPE->hStereoMdct->isSBAStereoMode = ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->nchan_transport == 2 ) ); +#else hCPE->hStereoMdct->isSBAStereoMode = ( ( st_ivas->ivas_format == SBA_FORMAT ) && ( st_ivas->nchan_transport == 2 ) ); - +#endif if ( !bfi ) { ivas_mdct_dec_side_bits_frame_channel( hCPE, param_lpc, p_param, hCPE->hCoreCoder[0], nTnsBitsTCX10, param, 0, 0 ); diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 4a19c63ef4..53ff0496f7 100755 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -390,6 +390,12 @@ ivas_error ivas_enc( #ifdef SBA_AND_OBJECTS else if ( ivas_format == SBA_ISM_FORMAT ) { + + if ( frame == 756 ) + { + frame = frame; + } + #ifdef SBA_AND_OBJECTS ivas_osba_enc_reconfig( st_ivas ); #endif @@ -433,11 +439,22 @@ ivas_error ivas_enc( hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; } - /* Write SBA planar flag */ - push_indice( st->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); + if ( st_ivas->hEncoderConfig->ivas_total_brate < IVAS_24k4 ) + { + /* Write SBA planar flag */ + push_indice( st->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); + + /* hack to indicate OSBA bitstream at VLBR */ + push_indice( st->hBstr, IND_SMODE, 0, SBA_ORDER_BITS ); + } + else + { + /* Write SBA order */ + push_indice( st->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS ); + } - /* Previously used to signal the SBA order, now re-purposed for the number of objects */ - push_indice( st->hBstr, IND_SMODE, hEncoderConfig->nchan_ism - 1, NO_BITS_MASA_ISM_NO_OBJ ); + /* write the number of objects in ISM_SBA format*/ + push_next_indice( hMetaData, hEncoderConfig->nchan_ism - 1, NO_BITS_MASA_ISM_NO_OBJ ); /* SBA metadata encoding and SBA metadata bitstream writing */ if ( ( error = ivas_spar_enc( st_ivas, data_f, input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK ) diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index fcc1203271..8146db099a 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -103,7 +103,7 @@ void ivas_write_format( #ifdef SBA_AND_OBJECTS case SBA_ISM_FORMAT: #ifdef SBA_AND_OBJECTS - if ( 0 ) + if ( st_ivas->hEncoderConfig->ivas_total_brate < IVAS_24k4 ) #else if ( st_ivas->ism_mode == ISM_MODE_NONE ) #endif -- GitLab From 71d5e62364bbd32cc7989e4ee6f146d37aa45d37 Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 10 Aug 2023 18:03:00 +1000 Subject: [PATCH 083/109] fix param bin for ISM SBA renderer --- lib_com/ivas_td_decorr.c | 8 ++++++ lib_rend/ivas_dirac_dec_binaural_functions.c | 30 +++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/lib_com/ivas_td_decorr.c b/lib_com/ivas_td_decorr.c index 4bf813ac35..4e521a73e7 100644 --- a/lib_com/ivas_td_decorr.c +++ b/lib_com/ivas_td_decorr.c @@ -118,7 +118,11 @@ ivas_error ivas_td_decorr_reconfig_dec( ivas_error error; useTdDecorr_new = 0; +#ifdef SBA_AND_OBJECTS + if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) +#else if ( ivas_format == SBA_FORMAT ) +#endif { if ( nchan_transport == 1 ) { @@ -146,7 +150,11 @@ ivas_error ivas_td_decorr_reconfig_dec( if ( *useTdDecorr ) { +#ifdef SBA_AND_OBJECTS + if ( ivas_total_brate >= IVAS_13k2 && ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) ) +#else if ( ivas_total_brate >= IVAS_13k2 && ivas_format == SBA_FORMAT ) +#endif { if ( *hTdDecorr == NULL ) { diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index c04ff82cbf..51bbe20e15 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -613,7 +613,11 @@ void ivas_dirac_dec_binaural( } ivas_dirac_dec_set_md_map( st_ivas, DEFAULT_JBM_CLDFB_TIMESLOTS ); +#ifdef SBA_AND_OBJECTS + if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) +#else if ( st_ivas->ivas_format == SBA_FORMAT ) +#endif { ivas_spar_dec_set_render_map( st_ivas, DEFAULT_JBM_CLDFB_TIMESLOTS ); } @@ -858,8 +862,12 @@ static void ivas_dirac_dec_binaural_internal( Cldfb_RealBuffer_in[ch][slot], Cldfb_ImagBuffer_in[ch][slot], nBins, st_ivas->cldfbAnaDec[ch] ); - +#ifdef SBA_AND_OBJECTS + if ( config_data.nchan_transport == 1 && + ( config_data.ivas_format == SBA_FORMAT || config_data.ivas_format == SBA_ISM_FORMAT ) ) +#else if ( config_data.nchan_transport == 1 && config_data.ivas_format == SBA_FORMAT ) +#endif { v_multc( Cldfb_RealBuffer_in[ch][slot], INV_SQRT_2, Cldfb_RealBuffer_in[ch][slot], nBins ); v_multc( Cldfb_ImagBuffer_in[ch][slot], INV_SQRT_2, Cldfb_ImagBuffer_in[ch][slot], nBins ); @@ -868,7 +876,11 @@ static void ivas_dirac_dec_binaural_internal( } } +#ifdef SBA_AND_OBJECTS + if ( config_data.ivas_format == SBA_FORMAT || config_data.ivas_format == SBA_ISM_FORMAT ) +#else if ( config_data.ivas_format == SBA_FORMAT ) +#endif { hDiracDecBin->hDiffuseDist = &diffuseDistData; @@ -1015,7 +1027,11 @@ static void ivas_dirac_dec_binaural_internal( hDiracDecBin = st_ivas->hDiracDecBin[pos_idx]; assert( hDiracDecBin != NULL && "No DiracDecBin handle for this position" ); +#ifdef SBA_AND_OBJECTS + if ( config_data.ivas_format == SBA_FORMAT || config_data.ivas_format == SBA_ISM_FORMAT ) +#else if ( config_data.ivas_format == SBA_FORMAT ) +#endif { hDiracDecBin->hDiffuseDist = &diffuseDistData; } @@ -1231,7 +1247,11 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices( } } +#ifdef SBA_AND_OBJECTS + if ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && nchan_transport == 2 ) +#else if ( ivas_format == SBA_FORMAT && nchan_transport == 2 ) +#endif { float tempRe, tempIm; #ifdef FIX_647_SILENT_W_PARAMBIN @@ -1651,7 +1671,11 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices( } else /* When rendering binaural, ambience has frequency dependent ICC. */ { +#ifdef SBA_AND_OBJECTS + if ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && bin < BINAURAL_COHERENCE_DIFFERENCE_BINS ) +#else if ( ivas_format == SBA_FORMAT && bin < BINAURAL_COHERENCE_DIFFERENCE_BINS ) +#endif { float diffuseFieldCoherence; diffuseFieldCoherence = hDiracDecBin->hDiffuseDist->diffuseRatioX[bin] * hDiracDecBin->diffuseFieldCoherenceX[bin] + hDiracDecBin->hDiffuseDist->diffuseRatioY[bin] * hDiracDecBin->diffuseFieldCoherenceY[bin] + hDiracDecBin->hDiffuseDist->diffuseRatioZ[bin] * hDiracDecBin->diffuseFieldCoherenceZ[bin]; @@ -2340,7 +2364,11 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices( { decorrelationReductionFactor = sqrtf( fmaxf( 0.0f, hDiracDecBin->frameMeanDiffuseness[bin] ) ); } +#ifdef SBA_AND_OBJECTS + if ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && nchan_transport == 1 ) +#else else if ( ivas_format == SBA_FORMAT && nchan_transport == 1 ) +#endif { decorrelationReductionFactor = 1.0f; } -- GitLab From bda3eef045bccfd7a25bb51adc5ed156769c3217 Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 10 Aug 2023 18:20:35 +1000 Subject: [PATCH 084/109] crahs fix with EXT out and bitrate switching --- lib_dec/ivas_dec.c | 20 +++++++++++++++++--- lib_dec/ivas_init_dec.c | 2 +- lib_enc/ivas_enc.c | 5 ----- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 370bf2c92b..79562a5c83 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -899,12 +899,26 @@ ivas_error ivas_dec( else /*EXT output = individual objects + HOA3*/ { #ifdef SBA_AND_OBJECTS - for ( n = 0; n < nchan_ism; n++ ) + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - delay_signal( output[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); + for ( n = 0; n < nchan_ism; n++ ) + { + delay_signal( output[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); + } } + ivas_sba_upmixer_renderer( st_ivas, &output[sba_ch_idx], output_frame ); - ivas_sba_upmixer_renderer( st_ivas, &output[st_ivas->nchan_ism], output_frame ); + if ( st_ivas->ism_mode == ISM_MODE_NONE ) + { + for ( n = st_ivas->hIntSetup.nchan_out_woLFE - 1; n >= 0; n-- ) + { + mvr2r( output[n], output[n + nchan_ism], output_frame ); + } + for ( n = 0; n < nchan_ism; n++ ) + { + set_zero( output[n], output_frame ); + } + } #endif } } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 227d717e35..ba3d129830 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1091,7 +1091,7 @@ ivas_error ivas_init_decoder( if ( output_config == AUDIO_CONFIG_EXTERNAL ) { #ifdef SBA_AND_OBJECTS - if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { hDecoderConfig->nchan_out = audioCfg2channels( AUDIO_CONFIG_HOA3 ); hDecoderConfig->nchan_out += st_ivas->nchan_ism; diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 53ff0496f7..31f64f9fba 100755 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -391,11 +391,6 @@ ivas_error ivas_enc( else if ( ivas_format == SBA_ISM_FORMAT ) { - if ( frame == 756 ) - { - frame = frame; - } - #ifdef SBA_AND_OBJECTS ivas_osba_enc_reconfig( st_ivas ); #endif -- GitLab From 871ee59e5cab9ed0c2fa2c1f1fa7c18e87f85d25 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 10 Aug 2023 10:24:03 +0200 Subject: [PATCH 085/109] disable DEBUG_OSBA by default --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8de9badb87..670ba66f6a 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -124,7 +124,7 @@ /*#define DEBUG_AGC*/ /* debug SPAR AGC in-out */ #endif /*#define SPAR_HOA_DBG*/ /* SPAR HOA debug statements */ -#define DEBUG_OSBA +/* #define DEBUG_OSBA */ /*#define DEBUG_BINAURAL_FILTER_DESIGN*/ /* debugging of Crend binaural filter design */ /*#define DEBUG_AGC_ENCODER_CMD_OPTION*/ /* Ability to force enable or disable AGC behaviour in DIRAC/SPAR via command line option */ #define DEBUG_JBM_CMD_OPTION /* ability for telling the decoder the frontend fetch size and to not delay compensate for bad frames at the beginning */ -- GitLab From 4951728e7b4996eee6cf2163feceabd68d31f6c4 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 10 Aug 2023 10:28:05 +0200 Subject: [PATCH 086/109] Revert "Merge branch 'new-osba-baseline' of forge.3gpp.org:ivas-codec-pc/ivas-codec into new-osba-baseline" This reverts commit e76fbf9f8b2d6309531fe6483a1c6305aa0dc76a, reversing changes made to 871ee59e5cab9ed0c2fa2c1f1fa7c18e87f85d25. --- lib_dec/ivas_dec.c | 20 +++----------------- lib_dec/ivas_init_dec.c | 2 +- lib_enc/ivas_enc.c | 5 +++++ 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 79562a5c83..370bf2c92b 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -899,26 +899,12 @@ ivas_error ivas_dec( else /*EXT output = individual objects + HOA3*/ { #ifdef SBA_AND_OBJECTS - if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + for ( n = 0; n < nchan_ism; n++ ) { - for ( n = 0; n < nchan_ism; n++ ) - { - delay_signal( output[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); - } + delay_signal( output[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); } - ivas_sba_upmixer_renderer( st_ivas, &output[sba_ch_idx], output_frame ); - if ( st_ivas->ism_mode == ISM_MODE_NONE ) - { - for ( n = st_ivas->hIntSetup.nchan_out_woLFE - 1; n >= 0; n-- ) - { - mvr2r( output[n], output[n + nchan_ism], output_frame ); - } - for ( n = 0; n < nchan_ism; n++ ) - { - set_zero( output[n], output_frame ); - } - } + ivas_sba_upmixer_renderer( st_ivas, &output[st_ivas->nchan_ism], output_frame ); #endif } } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index ba3d129830..227d717e35 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1091,7 +1091,7 @@ ivas_error ivas_init_decoder( if ( output_config == AUDIO_CONFIG_EXTERNAL ) { #ifdef SBA_AND_OBJECTS - if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { hDecoderConfig->nchan_out = audioCfg2channels( AUDIO_CONFIG_HOA3 ); hDecoderConfig->nchan_out += st_ivas->nchan_ism; diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 31f64f9fba..53ff0496f7 100755 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -391,6 +391,11 @@ ivas_error ivas_enc( else if ( ivas_format == SBA_ISM_FORMAT ) { + if ( frame == 756 ) + { + frame = frame; + } + #ifdef SBA_AND_OBJECTS ivas_osba_enc_reconfig( st_ivas ); #endif -- GitLab From d3159334c2b24ad2bbe4fa3903afb683f35d74e4 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 10 Aug 2023 10:34:23 +0200 Subject: [PATCH 087/109] Revert "Revert "Merge branch 'new-osba-baseline' of forge.3gpp.org:ivas-codec-pc/ivas-codec into new-osba-baseline"" This reverts commit 4951728e7b4996eee6cf2163feceabd68d31f6c4. --- lib_dec/ivas_dec.c | 20 +++++++++++++++++--- lib_dec/ivas_init_dec.c | 2 +- lib_enc/ivas_enc.c | 5 ----- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 370bf2c92b..79562a5c83 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -899,12 +899,26 @@ ivas_error ivas_dec( else /*EXT output = individual objects + HOA3*/ { #ifdef SBA_AND_OBJECTS - for ( n = 0; n < nchan_ism; n++ ) + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - delay_signal( output[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); + for ( n = 0; n < nchan_ism; n++ ) + { + delay_signal( output[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); + } } + ivas_sba_upmixer_renderer( st_ivas, &output[sba_ch_idx], output_frame ); - ivas_sba_upmixer_renderer( st_ivas, &output[st_ivas->nchan_ism], output_frame ); + if ( st_ivas->ism_mode == ISM_MODE_NONE ) + { + for ( n = st_ivas->hIntSetup.nchan_out_woLFE - 1; n >= 0; n-- ) + { + mvr2r( output[n], output[n + nchan_ism], output_frame ); + } + for ( n = 0; n < nchan_ism; n++ ) + { + set_zero( output[n], output_frame ); + } + } #endif } } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 227d717e35..ba3d129830 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1091,7 +1091,7 @@ ivas_error ivas_init_decoder( if ( output_config == AUDIO_CONFIG_EXTERNAL ) { #ifdef SBA_AND_OBJECTS - if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { hDecoderConfig->nchan_out = audioCfg2channels( AUDIO_CONFIG_HOA3 ); hDecoderConfig->nchan_out += st_ivas->nchan_ism; diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 53ff0496f7..31f64f9fba 100755 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -391,11 +391,6 @@ ivas_error ivas_enc( else if ( ivas_format == SBA_ISM_FORMAT ) { - if ( frame == 756 ) - { - frame = frame; - } - #ifdef SBA_AND_OBJECTS ivas_osba_enc_reconfig( st_ivas ); #endif -- GitLab From 57820c0ee9308f5b49ac89ee80dd03e3353f357a Mon Sep 17 00:00:00 2001 From: wkr Date: Thu, 10 Aug 2023 14:57:38 +0200 Subject: [PATCH 088/109] fix MC and OMASA errors --- lib_dec/ivas_sce_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index 57c0bcc88d..62fd41cc6e 100755 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -165,7 +165,7 @@ ivas_error ivas_sce_dec( { st->bits_frame_nominal = (int16_t) ( hSCE->element_brate / FRAMES_PER_SEC ); } -#ifdef SBA_AND_OBJECTS +#if 0 if ( st_ivas->ism_mode == ISM_MODE_NONE && st_ivas->ivas_format == SBA_ISM_FORMAT ) { st->bits_frame_nominal = (int16_t) ( st_ivas->hSpar->core_nominal_brate / FRAMES_PER_SEC ); -- GitLab From 2fffff98a80e5223a9922d2a21d23bea113dac9e Mon Sep 17 00:00:00 2001 From: wkr Date: Thu, 10 Aug 2023 16:31:58 +0200 Subject: [PATCH 089/109] fix condition for bitrate in SBA_ISM_FORMAT --- lib_dec/ivas_sce_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index 62fd41cc6e..57b3c3c5af 100755 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -165,8 +165,8 @@ ivas_error ivas_sce_dec( { st->bits_frame_nominal = (int16_t) ( hSCE->element_brate / FRAMES_PER_SEC ); } -#if 0 - if ( st_ivas->ism_mode == ISM_MODE_NONE && st_ivas->ivas_format == SBA_ISM_FORMAT ) +#ifdef SBA_AND_OBJECTS + else if ( st_ivas->ism_mode == ISM_MODE_NONE && st_ivas->ivas_format == SBA_ISM_FORMAT ) { st->bits_frame_nominal = (int16_t) ( st_ivas->hSpar->core_nominal_brate / FRAMES_PER_SEC ); } -- GitLab From a72d7cce710bc26cf5e0a6184817d4c451b4ac5a Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 10 Aug 2023 16:54:14 +0200 Subject: [PATCH 090/109] set st_ivas->nchan_ism correctly --- lib_dec/ivas_init_dec.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index ba3d129830..a0a4aa2e0e 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -420,8 +420,15 @@ ivas_error ivas_dec_setup( #ifdef SBA_AND_OBJECTS else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { - /* the number of objects is written at the end of the bitstream, in the SBA metadata */ - st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1; + if (st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + /* the number of objects is written at the end of the bitstream, in the SBA metadata */ + st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1; + } + else + { + st_ivas->nchan_ism = 0; + } if ( ivas_total_brate < IVAS_24k4 || ivas_total_brate >= IVAS_256k ) { -- GitLab From b83c813f0e7f9dfcb43df8afeaf46b45504cc43b Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 10 Aug 2023 17:06:09 +0200 Subject: [PATCH 091/109] fix renderer --- lib_dec/ivas_output_config.c | 40 +++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 468c3f7c35..91c1d0aa2f 100755 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -410,8 +410,17 @@ void ivas_renderer_select( #endif { *renderer_type = RENDERER_DIRAC; +#ifdef SBA_AND_OBJECTS + IVAS_FORMAT ivas_format = ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_NONE ) ? SBA_FORMAT : st_ivas->ivas_format; /* treat ISM_SBA_MODE_NONE just like SBA_FORMAT */ +#endif + +#ifdef SBA_AND_OBJECTS + if ( ivas_format == SBA_FORMAT && + ( output_config != AUDIO_CONFIG_5_1 && output_config != AUDIO_CONFIG_5_1_2 && output_config != AUDIO_CONFIG_5_1_4 && output_config != AUDIO_CONFIG_7_1 && output_config != AUDIO_CONFIG_7_1_4 && output_config != AUDIO_CONFIG_LS_CUSTOM && output_config != AUDIO_CONFIG_MONO && output_config != AUDIO_CONFIG_STEREO ) ) +#else if ( st_ivas->ivas_format == SBA_FORMAT && ( output_config != AUDIO_CONFIG_5_1 && output_config != AUDIO_CONFIG_5_1_2 && output_config != AUDIO_CONFIG_5_1_4 && output_config != AUDIO_CONFIG_7_1 && output_config != AUDIO_CONFIG_7_1_4 && output_config != AUDIO_CONFIG_LS_CUSTOM && output_config != AUDIO_CONFIG_MONO && output_config != AUDIO_CONFIG_STEREO ) ) +#endif { if ( output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_FOA ) { @@ -427,51 +436,72 @@ void ivas_renderer_select( } st_ivas->renderer_type = RENDERER_SBA_LINEAR_DEC; } +#ifdef SBA_AND_OBJECTS + else if ( ( ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) || + ( ivas_format == SBA_FORMAT && ( output_config == AUDIO_CONFIG_STEREO || output_config == AUDIO_CONFIG_MONO ) ) ) +#else else if ( ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) || ( st_ivas->ivas_format == SBA_FORMAT && ( output_config == AUDIO_CONFIG_STEREO || output_config == AUDIO_CONFIG_MONO ) ) ) +#endif { *renderer_type = RENDERER_DISABLE; } +#ifdef SBA_AND_OBJECTS + else if ( ( ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->ivas_total_brate < MASA_STEREO_MIN_BITRATE && st_ivas->hDecoderConfig->ivas_total_brate > IVAS_SID_5k2 ) ) +#else else if ( ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->ivas_total_brate < MASA_STEREO_MIN_BITRATE && st_ivas->hDecoderConfig->ivas_total_brate > IVAS_SID_5k2 ) ) +#endif { *renderer_type = RENDERER_DISABLE; } +#ifdef SBA_AND_OBJECTS + else if ( ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_STEREO ) +#else else if ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_STEREO ) +#endif { *renderer_type = RENDERER_STEREO_PARAMETRIC; } +#ifdef SBA_AND_OBJECTS + else if ( ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL ) +#else else if ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL ) +#endif { *renderer_type = RENDERER_DISABLE; } +#ifdef SBA_AND_OBJECTS + else if ( ivas_format == SBA_FORMAT && output_config == AUDIO_CONFIG_MONO ) +#else else if ( st_ivas->ivas_format == SBA_FORMAT && output_config == AUDIO_CONFIG_MONO ) +#endif { *renderer_type = RENDERER_SBA_LINEAR_DEC; } #ifdef SBA_AND_OBJECTS - else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_STEREO ) + else if ( ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_STEREO ) { *renderer_type = RENDERER_OSBA_STEREO; } - else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_MONO ) + else if ( ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_MONO ) { *renderer_type = RENDERER_MONO_DOWNMIX; } #endif #ifdef SBA_AND_OBJECTS - else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 ) ) + else if ( ivas_format == SBA_ISM_FORMAT && ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 ) ) { *renderer_type = RENDERER_OSBA_AMBI; } #endif #ifdef SBA_AND_OBJECTS - else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && ( output_config == AUDIO_CONFIG_5_1 || output_config == AUDIO_CONFIG_5_1_2 || output_config == AUDIO_CONFIG_5_1_4 || output_config == AUDIO_CONFIG_7_1 || output_config == AUDIO_CONFIG_7_1_4 || output_config == AUDIO_CONFIG_LS_CUSTOM ) ) + else if ( ivas_format == SBA_ISM_FORMAT && ( output_config == AUDIO_CONFIG_5_1 || output_config == AUDIO_CONFIG_5_1_2 || output_config == AUDIO_CONFIG_5_1_4 || output_config == AUDIO_CONFIG_7_1 || output_config == AUDIO_CONFIG_7_1_4 || output_config == AUDIO_CONFIG_LS_CUSTOM ) ) { *renderer_type = RENDERER_OSBA_LS; } #endif #ifdef SBA_AND_OBJECTS - else if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL ) + else if ( ivas_format == SBA_ISM_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL ) { *renderer_type = RENDERER_SBA_LINEAR_DEC; } -- GitLab From 51bd7f17826c1a3f4d98753d6639488a6798d5d4 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 10 Aug 2023 18:06:32 +0200 Subject: [PATCH 092/109] fixing condition --- lib_dec/ivas_init_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index a0a4aa2e0e..cc83ad54e1 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -420,7 +420,7 @@ ivas_error ivas_dec_setup( #ifdef SBA_AND_OBJECTS else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { - if (st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + if ( ivas_total_brate >= IVAS_256k ) { /* the number of objects is written at the end of the bitstream, in the SBA metadata */ st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1; -- GitLab From b680f1138202dce4ae7f6db0c58d444dd01b6b6b Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 10 Aug 2023 18:47:03 +0200 Subject: [PATCH 093/109] revert condition --- lib_dec/ivas_init_dec.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index cc83ad54e1..ba3d129830 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -420,15 +420,8 @@ ivas_error ivas_dec_setup( #ifdef SBA_AND_OBJECTS else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { - if ( ivas_total_brate >= IVAS_256k ) - { - /* the number of objects is written at the end of the bitstream, in the SBA metadata */ - st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1; - } - else - { - st_ivas->nchan_ism = 0; - } + /* the number of objects is written at the end of the bitstream, in the SBA metadata */ + st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1; if ( ivas_total_brate < IVAS_24k4 || ivas_total_brate >= IVAS_256k ) { -- GitLab From c773201f2e1c0acad4075455dfbd138f6b6b6cc1 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 10 Aug 2023 19:06:21 +0200 Subject: [PATCH 094/109] fix renderer selection for SBA_ISM_FORMAT --- lib_dec/ivas_output_config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 91c1d0aa2f..65cca6eac3 100755 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -438,7 +438,7 @@ void ivas_renderer_select( } #ifdef SBA_AND_OBJECTS else if ( ( ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) || - ( ivas_format == SBA_FORMAT && ( output_config == AUDIO_CONFIG_STEREO || output_config == AUDIO_CONFIG_MONO ) ) ) + ( ivas_format == SBA_FORMAT && ( output_config == AUDIO_CONFIG_STEREO || ( output_config == AUDIO_CONFIG_MONO && !st_ivas->ivas_format == SBA_ISM_FORMAT ) ) ) #else else if ( ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) || ( st_ivas->ivas_format == SBA_FORMAT && ( output_config == AUDIO_CONFIG_STEREO || output_config == AUDIO_CONFIG_MONO ) ) ) -- GitLab From efed1c5696e91dbe2ddea4a7d9a8b8b170c5ee3d Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 10 Aug 2023 19:13:06 +0200 Subject: [PATCH 095/109] fix compiler error --- lib_dec/ivas_output_config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 65cca6eac3..0d9654167e 100755 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -438,7 +438,7 @@ void ivas_renderer_select( } #ifdef SBA_AND_OBJECTS else if ( ( ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) || - ( ivas_format == SBA_FORMAT && ( output_config == AUDIO_CONFIG_STEREO || ( output_config == AUDIO_CONFIG_MONO && !st_ivas->ivas_format == SBA_ISM_FORMAT ) ) ) + ( ivas_format == SBA_FORMAT && ( output_config == AUDIO_CONFIG_STEREO || ( output_config == AUDIO_CONFIG_MONO && !(st_ivas->ivas_format == SBA_ISM_FORMAT) ) ) ) ) #else else if ( ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) || ( st_ivas->ivas_format == SBA_FORMAT && ( output_config == AUDIO_CONFIG_STEREO || output_config == AUDIO_CONFIG_MONO ) ) ) -- GitLab From 58c87cb74ac48e17d27eaaacd7f05390f4199c44 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 10 Aug 2023 19:20:36 +0200 Subject: [PATCH 096/109] fix instrumented build --- lib_dec/ivas_output_config.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 0d9654167e..56ecc27b72 100755 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -409,9 +409,12 @@ void ivas_renderer_select( else if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == SBA_FORMAT ) #endif { +#ifdef SBA_AND_OBJECTS + IVAS_FORMAT ivas_format; +#endif *renderer_type = RENDERER_DIRAC; #ifdef SBA_AND_OBJECTS - IVAS_FORMAT ivas_format = ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_NONE ) ? SBA_FORMAT : st_ivas->ivas_format; /* treat ISM_SBA_MODE_NONE just like SBA_FORMAT */ + ivas_format = ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_NONE ) ? SBA_FORMAT : st_ivas->ivas_format; /* treat ISM_SBA_MODE_NONE just like SBA_FORMAT */ #endif #ifdef SBA_AND_OBJECTS -- GitLab From 7d64a58bf65de2a9c5a968bbcf17dba1d71ac7f2 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 10 Aug 2023 21:24:02 +0200 Subject: [PATCH 097/109] typos in selftest --- scripts/config/self_test.prm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/config/self_test.prm b/scripts/config/self_test.prm index 2d1817b3a1..024734fda9 100644 --- a/scripts/config/self_test.prm +++ b/scripts/config/self_test.prm @@ -1391,15 +1391,15 @@ networkSimulator_g192 ../scripts/dly_error_profiles/dly_error_profile_5.dat bit ../IVAS_dec HOA3 48 bit testv/stvOSBA_2ISM_FOA48c.wav_HOA3_64000_48-48.tst // OSBA FOA 3ISM at 128 kbps, 48kHz in, 48kHz out, 7_1_4 out -../IVAS_cod -ism_sba 3 1 testv/stvISM1.csv testv/stvISM1.csv testv/stvISM3.csv 128000 48 testv/stvOSBA_3ISM_FOA48c.wav bit +../IVAS_cod -ism_sba 3 1 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv 128000 48 testv/stvOSBA_3ISM_FOA48c.wav bit ../IVAS_dec 7_1_4 48 bit testv/stvOSBA_3ISM_FOA48c.wav_7_1_4_128000_48-48.tst // OSBA FOA 4ISM at 256 kbps, 48kHz in, 48kHz out, EXT out -../IVAS_cod -ism_sba 4 1 testv/stvISM1.csv testv/stvISM1.csv testv/stvISM3.csv testv/stvISM4.csv 256000 48 testv/stvOSBA_4ISM_FOA48c.wav bit +../IVAS_cod -ism_sba 4 1 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 256000 48 testv/stvOSBA_4ISM_FOA48c.wav bit ../IVAS_dec EXT 48 bit testv/stvOSBA_4ISM_FOA48c.wav_EXT_256000_48-48.tst // OSBA FOA 4ISM at 512 kbps, 48kHz in, 48kHz out, BINAURAL out -../IVAS_cod -ism_sba 4 1 testv/stvISM1.csv testv/stvISM1.csv testv/stvISM3.csv testv/stvISM4.csv 512000 48 testv/stvOSBA_4ISM_FOA48c.wav bit +../IVAS_cod -ism_sba 4 1 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 512000 48 testv/stvOSBA_4ISM_FOA48c.wav bit ../IVAS_dec BINAURAL 48 bit testv/stvOSBA_4ISM_FOA48c.wav_BINAURAL_512000_48-48.tst // OSBA 2OA 1ISM at 24.4 kbps, 48kHz in, 48kHz out, FOA out -- GitLab From 9b628f5abbadfaef5212d1fbba3a98efe1ec24df Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 10 Aug 2023 22:45:22 +0200 Subject: [PATCH 098/109] fix crashes --- lib_dec/ivas_dec.c | 8 +++++++- lib_dec/ivas_dirac_dec.c | 4 ++++ lib_dec/ivas_init_dec.c | 31 +++++++++++++++++++++++++++++-- lib_dec/ivas_output_config.c | 2 +- 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 95395d409e..3cf41772f6 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -897,7 +897,13 @@ ivas_error ivas_dec( } } #endif - else /*EXT output = individual objects + HOA3*/ +#ifdef SBA_AND_OBJECTS + else if ( st_ivas->renderer_type == RENDERER_DIRAC && !st_ivas->sba_dirac_stereo_flag && nchan_out != 1 ) + { + ivas_sba_upmixer_renderer( st_ivas, output, output_frame ); /* Note: ivas_sba_linear_renderer() or ivas_dirac_dec() are called internally */ + } +#endif + else if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_EXTERNAL ) /*EXT output = individual objects + HOA3*/ { #ifdef SBA_AND_OBJECTS if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index e095e579f5..aea85f2b75 100755 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2116,7 +2116,11 @@ void ivas_dirac_dec_render_sf( } /* CNG in DirAC, extra CLDFB ana for CNA*/ +#ifdef SBA_AND_OBJECTS + if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && !(st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT) ) +#else if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->ivas_format != SBA_FORMAT ) +#endif { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 2eb1dac44c..d2d2243202 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2733,9 +2733,16 @@ void ivas_init_dec_get_num_cldfb_instances( int16_t *numCldfbSyntheses /* o : number of needed CLDFB synthesis instances */ ) { +#ifdef SBA_AND_OBJECTS + IVAS_FORMAT ivas_format; +#endif *numCldfbAnalyses = st_ivas->nchan_transport; *numCldfbSyntheses = st_ivas->hDecoderConfig->nchan_out; +#ifdef SBA_AND_OBJECTS + ivas_format = ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_NONE ) ? SBA_FORMAT : st_ivas->ivas_format; /* treat ISM_SBA_MODE_NONE just like SBA_FORMAT */ +#endif + switch ( st_ivas->renderer_type ) { case RENDERER_BINAURAL_PARAMETRIC: @@ -2752,7 +2759,7 @@ void ivas_init_dec_get_num_cldfb_instances( *numCldfbAnalyses = st_ivas->nchan_transport + 1; } #ifdef SBA_AND_OBJECTS - if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + if ( ivas_format == SBA_ISM_FORMAT ) { if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { @@ -2761,7 +2768,11 @@ void ivas_init_dec_get_num_cldfb_instances( } #endif +#ifdef SBA_AND_OBJECTS + if ( ivas_format == MASA_ISM_FORMAT ) +#else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) +#endif { if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { @@ -2783,7 +2794,11 @@ void ivas_init_dec_get_num_cldfb_instances( break; case RENDERER_NON_DIEGETIC_DOWNMIX: case RENDERER_MONO_DOWNMIX: +#ifdef SBA_AND_OBJECTS + if ( ivas_format == ISM_FORMAT || ivas_format == MASA_ISM_FORMAT ) +#else if ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) +#endif { /* CLDFB not used in rendering */ *numCldfbAnalyses = 0; @@ -2811,7 +2826,11 @@ void ivas_init_dec_get_num_cldfb_instances( break; case RENDERER_NON_DIEGETIC_DOWNMIX: case RENDERER_MONO_DOWNMIX: +#ifdef SBA_AND_OBJECTS + if ( ivas_format == ISM_FORMAT ) +#else if ( st_ivas->ivas_format == ISM_FORMAT ) +#endif { /* CLDFB not used in rendering */ *numCldfbAnalyses = 0; @@ -2820,7 +2839,11 @@ void ivas_init_dec_get_num_cldfb_instances( break; #endif case RENDERER_DIRAC: +#ifdef SBA_AND_OBJECTS + if ( ivas_format == SBA_FORMAT ) +#else if ( st_ivas->ivas_format == SBA_FORMAT ) +#endif { *numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans; @@ -2837,7 +2860,11 @@ void ivas_init_dec_get_num_cldfb_instances( *numCldfbSyntheses = MAX_OUTPUT_CHANNELS; } } +#ifdef SBA_AND_OBJECTS + if ( ivas_format != SBA_FORMAT ) +#else if ( st_ivas->ivas_format != SBA_FORMAT ) +#endif { if ( st_ivas->nchan_transport > 2 && st_ivas->sba_planar ) { @@ -2888,7 +2915,7 @@ void ivas_init_dec_get_num_cldfb_instances( case RENDERER_OSBA_LS: #endif #ifdef SBA_AND_OBJECTS - if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) + if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) #else if ( st_ivas->ivas_format == SBA_FORMAT ) #endif diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 9a20d3b720..91ac0ae2b6 100755 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -445,7 +445,7 @@ void ivas_renderer_select( } #ifdef SBA_AND_OBJECTS else if ( ( ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) || - ( ivas_format == SBA_FORMAT && ( output_config == AUDIO_CONFIG_STEREO || ( output_config == AUDIO_CONFIG_MONO && !(st_ivas->ivas_format == SBA_ISM_FORMAT) ) ) ) ) + ( ivas_format == SBA_FORMAT && ( output_config == AUDIO_CONFIG_STEREO || output_config == AUDIO_CONFIG_MONO ) ) ) #else else if ( ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) || ( st_ivas->ivas_format == SBA_FORMAT && ( output_config == AUDIO_CONFIG_STEREO || output_config == AUDIO_CONFIG_MONO ) ) ) -- GitLab From dad8a6d9de4e1787e71bb79f286bcc2078a6e5a6 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 10 Aug 2023 22:56:09 +0200 Subject: [PATCH 099/109] fix Ambisonics output --- lib_dec/ivas_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 3cf41772f6..edda816043 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -898,7 +898,7 @@ ivas_error ivas_dec( } #endif #ifdef SBA_AND_OBJECTS - else if ( st_ivas->renderer_type == RENDERER_DIRAC && !st_ivas->sba_dirac_stereo_flag && nchan_out != 1 ) + else if ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_EXTERNAL && !st_ivas->sba_dirac_stereo_flag && nchan_out != 1 ) { ivas_sba_upmixer_renderer( st_ivas, output, output_frame ); /* Note: ivas_sba_linear_renderer() or ivas_dirac_dec() are called internally */ } -- GitLab From 115c62c188a27d4e8c679a4164d61560d5c73b0b Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 10 Aug 2023 23:10:28 +0200 Subject: [PATCH 100/109] formatting --- lib_dec/ivas_dirac_dec.c | 2 +- lib_dec/ivas_output_config.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) mode change 100755 => 100644 lib_dec/ivas_dirac_dec.c mode change 100755 => 100644 lib_dec/ivas_output_config.c diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c old mode 100755 new mode 100644 index aea85f2b75..ac03c69b23 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2117,7 +2117,7 @@ void ivas_dirac_dec_render_sf( /* CNG in DirAC, extra CLDFB ana for CNA*/ #ifdef SBA_AND_OBJECTS - if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && !(st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT) ) + if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && !( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) ) #else if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->ivas_format != SBA_FORMAT ) #endif diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c old mode 100755 new mode 100644 index 91ac0ae2b6..8cf49138b2 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -415,7 +415,7 @@ void ivas_renderer_select( { #ifdef SBA_AND_OBJECTS IVAS_FORMAT ivas_format; -#endif +#endif *renderer_type = RENDERER_DIRAC; #ifdef SBA_AND_OBJECTS ivas_format = ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_NONE ) ? SBA_FORMAT : st_ivas->ivas_format; /* treat ISM_SBA_MODE_NONE just like SBA_FORMAT */ -- GitLab From d5728926ad2a0f5ceaa4889e02f5414cd27a17dc Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 10 Aug 2023 23:47:43 +0200 Subject: [PATCH 101/109] fix MSAN/ASAN errors --- lib_dec/ivas_init_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index d890358c0c..22f662ab08 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -877,7 +877,7 @@ int16_t getNumChanSynthesis( { n = st_ivas->nchan_transport; } -#ifdef SBA_AND_OBJECTS +#if defined(SBA_AND_OBJECTS) && !defined(OSBA_BR_SWITCHING) else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) -- GitLab From 0ecdd455db3858d5cd8a7afb4814dbc0dbec3439 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 10 Aug 2023 23:51:40 +0200 Subject: [PATCH 102/109] formatting --- lib_dec/ivas_init_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 lib_dec/ivas_init_dec.c diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c old mode 100755 new mode 100644 index 22f662ab08..18b682a3ec --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -877,7 +877,7 @@ int16_t getNumChanSynthesis( { n = st_ivas->nchan_transport; } -#if defined(SBA_AND_OBJECTS) && !defined(OSBA_BR_SWITCHING) +#if defined( SBA_AND_OBJECTS ) && !defined( OSBA_BR_SWITCHING ) else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) -- GitLab From e26e5fb4be230edcc4ea64c0ed36a08df3091922 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 11 Aug 2023 00:26:10 +0200 Subject: [PATCH 103/109] clean up SBA_AND_OBJECTS conditions --- lib_enc/ivas_enc.c | 24 ++------------ lib_enc/ivas_init_enc.c | 20 +++--------- lib_enc/ivas_mct_enc.c | 9 ------ lib_enc/ivas_osba_enc.c | 62 +++++++++++++------------------------ lib_enc/ivas_spar_encoder.c | 12 ------- lib_enc/ivas_stat_enc.h | 3 -- 6 files changed, 29 insertions(+), 101 deletions(-) diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 31f64f9fba..85738e1e00 100755 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -408,17 +408,6 @@ ivas_error ivas_enc( ); #ifndef SBA_AND_OBJECTS } - else /*not an option for now*/ - { -#ifdef SBA_AND_OBJECTS - /* delay ISM input channels to match the SBA encoder delay */ - for ( n = 0; n < hEncoderConfig->nchan_ism; n++ ) - { - delay_signal( data_f[n], input_frame, st_ivas->hOSba->input_data_mem[n], NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ) ); - } - -#endif - } #endif if ( st_ivas->ism_mode == ISM_MODE_NONE ) @@ -487,21 +476,14 @@ ivas_error ivas_enc( st = st_ivas->hCPE[0]->hCoreCoder[0]; hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; #ifdef SBA_AND_OBJECTS -#ifdef SBA_AND_OBJECTS + if ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode != ISM_MODE_NONE ) { /* write the number of objects in ISM_SBA format*/ push_next_indice( hMetaData, hEncoderConfig->nchan_ism - 1, NO_BITS_MASA_ISM_NO_OBJ ); } -#endif -#endif -#ifdef SBA_AND_OBJECTS - if ( ( error = ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -1, 0, NULL -#ifdef SBA_AND_OBJECTS - , - st->ini_frame -#endif - ) ) != IVAS_ERR_OK ) + + if ( ( error = ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -1, 0, NULL, st->ini_frame ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 8146db099a..e9ab1849b1 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -102,11 +102,7 @@ void ivas_write_format( #endif #ifdef SBA_AND_OBJECTS case SBA_ISM_FORMAT: -#ifdef SBA_AND_OBJECTS if ( st_ivas->hEncoderConfig->ivas_total_brate < IVAS_24k4 ) -#else - if ( st_ivas->ism_mode == ISM_MODE_NONE ) -#endif { ind = 6; /* send SBA format */ nBits += extra_bits; @@ -668,14 +664,12 @@ ivas_error ivas_init_encoder( else if ( ivas_format == SBA_ISM_FORMAT ) { int32_t element_brate_tmp[MAX_NUM_OBJECTS]; - st_ivas->ism_mode = ISM_MODE_NONE; -#ifdef SBA_AND_OBJECTS + if ( ivas_total_brate >= IVAS_256k ) { st_ivas->ism_mode = ISM_SBA_MODE_DISC; } -#endif if ( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK ) { @@ -748,17 +742,11 @@ ivas_error ivas_init_encoder( return error; } } -#ifndef SBA_AND_OBJECTS - if ( st_ivas->ism_mode == ISM_MODE_NONE ) + + if ( ( error = ivas_osba_enc_open( st_ivas ) ) != IVAS_ERR_OK ) { -#endif - if ( ( error = ivas_osba_enc_open( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } -#ifndef SBA_AND_OBJECTS + return error; } -#endif } #endif else if ( ivas_format == MC_FORMAT ) diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 36c95c6ef9..e392da6aed 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -82,16 +82,7 @@ static void set_mct_enc_params( } hMCT->hbr_mct = 0; -#ifdef SBA_AND_OBJECTS - if ( ( ivas_format == SBA_FORMAT -#ifndef SBA_AND_OBJECTS - || ivas_format == SBA_ISM_FORMAT -#endif - ) && - ivas_total_brate >= IVAS_256k ) -#else if ( ivas_format == SBA_FORMAT && ivas_total_brate >= IVAS_256k ) -#endif { hMCT->hbr_mct = 1; } diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index 6767605c03..91b33328bd 100755 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -94,9 +94,7 @@ ivas_error ivas_osba_enc_open( OSBA_ENC_HANDLE hOSba; int16_t input_frame; ivas_error error; -#ifdef SBA_AND_OBJECTS int16_t len; -#endif error = IVAS_ERR_OK; @@ -110,30 +108,22 @@ ivas_error ivas_osba_enc_open( { set_f( hOSba->prev_object_dm_gains[i], (float) sqrt( 0.5 ), MAX_INPUT_CHANNELS ); } -#ifdef SBA_AND_OBJECTS -#ifndef SBA_AND_OBJECTS - if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) - { -#endif - len = NS2SA( st_ivas->hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ); - - for ( i = 0; i < st_ivas->hEncoderConfig->nchan_ism; i++ ) - { - if ( ( hOSba->input_data_mem[i] = (float *) malloc( len * sizeof( float ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OSBA input buffers" ); - } - set_f( hOSba->input_data_mem[i], 0.0f, len ); - } - for ( ; i < MAX_NUM_OBJECTS; i++ ) + len = NS2SA( st_ivas->hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ); + + for ( i = 0; i < st_ivas->hEncoderConfig->nchan_ism; i++ ) + { + if ( ( hOSba->input_data_mem[i] = (float *) malloc( len * sizeof( float ) ) ) == NULL ) { - hOSba->input_data_mem[i] = NULL; + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OSBA input buffers" ); } -#ifndef SBA_AND_OBJECTS + set_f( hOSba->input_data_mem[i], 0.0f, len ); + } + + for ( ; i < MAX_NUM_OBJECTS; i++ ) + { + hOSba->input_data_mem[i] = NULL; } -#endif -#endif input_frame = (int16_t) ( st_ivas->hEncoderConfig->input_Fs / FRAMES_PER_SEC ); for ( i = 0; i < input_frame; i++ ) @@ -161,7 +151,7 @@ void ivas_osba_enc_close( { return; } -#ifdef SBA_AND_OBJECTS + for ( int16_t n = 0; n < MAX_NUM_OBJECTS; n++ ) { if ( ( *hOSba )->input_data_mem[n] != NULL ) @@ -170,7 +160,7 @@ void ivas_osba_enc_close( ( *hOSba )->input_data_mem[n] = NULL; } } -#endif + free( *hOSba ); ( *hOSba ) = NULL; @@ -379,41 +369,33 @@ ivas_error ivas_osba_enc_reconfig( *--------------------------------------------------------------------------*/ void ivas_osba_enc( - OSBA_ENC_HANDLE hOSba, /* i/o: OSBA encoder handle */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handle */ - float data_in_f[][L_FRAME48k], /* i/o: Input / transport audio signals */ - const int16_t input_frame, /* i : Input frame size */ - const int16_t nchan_ism, /* i : Number of objects for parameter analysis */ - const ISM_MODE ism_mode, /* i : ISM mode */ - const int16_t sba_analysis_order /* i : SBA order evaluated in DirAC/SPAR encoder */ -#ifdef SBA_AND_OBJECTS - , + OSBA_ENC_HANDLE hOSba, /* i/o: OSBA encoder handle */ + ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handle */ + float data_in_f[][L_FRAME48k], /* i/o: Input / transport audio signals */ + const int16_t input_frame, /* i : Input frame size */ + const int16_t nchan_ism, /* i : Number of objects for parameter analysis */ + const ISM_MODE ism_mode, /* i : ISM mode */ + const int16_t sba_analysis_order, /* i : SBA order evaluated in DirAC/SPAR encoder */ const int32_t input_Fs /* i : input sampling rate*/ -#endif ) { float data_out_f[MAX_INPUT_CHANNELS][L_FRAME48k]; -#ifdef SBA_AND_OBJECTS int16_t n, delay_s; delay_s = NS2SA( input_Fs, IVAS_FB_ENC_DELAY_NS ); -#endif if ( ism_mode == ISM_MODE_NONE ) { -#ifdef SBA_AND_OBJECTS /*keep the delay buffer up to date*/ for ( n = 0; n < nchan_ism; n++ ) { mvr2r( &data_in_f[n][input_frame - delay_s], hOSba->input_data_mem[n], delay_s ); } -#endif /* Convert ISM to SBA */ ivas_osba_render_ism_to_sba( data_in_f, data_out_f, input_frame, sba_analysis_order, nchan_ism, hIsmMeta, hOSba->prev_object_dm_gains, hOSba->interpolator ); /* Merge SBA signals */ ivas_merge_sba_transports( data_out_f, &( data_in_f[nchan_ism] ), data_in_f, input_frame, sba_analysis_order ); } -#ifdef SBA_AND_OBJECTS else { int16_t azimuth, elevation; @@ -429,7 +411,7 @@ void ivas_osba_enc( ivas_dirac_dec_get_response( azimuth, elevation, hOSba->prev_object_dm_gains[n], sba_analysis_order ); } } -#endif + /* Set the number of objects */ hOSba->nchan_ism = nchan_ism; diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 6d403ca6ce..0e82d08566 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -337,18 +337,6 @@ ivas_error ivas_spar_enc( error = IVAS_ERR_OK; hEncoderConfig = st_ivas->hEncoderConfig; -#ifdef SBA_AND_OBJECTS -#ifndef SBA_AND_OBJECTS - if ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode != ISM_MODE_NONE ) - { - /* write the number of objects in ISM_SBA format*/ - push_next_indice( hMetaData, hEncoderConfig->nchan_ism - 1, NO_BITS_MASA_ISM_NO_OBJ ); - } -#endif -#endif - - /* check last sba_mode */ - /* front VAD */ if ( ( error = front_vad_spar( st_ivas->hSpar, data_f[0], hEncoderConfig, input_frame ) ) != IVAS_ERR_OK ) { diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 571e6cc206..138e09b5c4 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -945,10 +945,7 @@ typedef struct ivas_osba_enc_data_structure float prev_object_dm_gains[MAX_NUM_OBJECTS][MAX_INPUT_CHANNELS]; int16_t nchan_ism; - -#ifdef SBA_AND_OBJECTS float *input_data_mem[MAX_NUM_OBJECTS]; -#endif } OSBA_ENC_DATA, *OSBA_ENC_HANDLE; #endif -- GitLab From 34dde5130f660145218c4f0f1a4adf6892af609d Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 11 Aug 2023 00:43:13 +0200 Subject: [PATCH 104/109] clean up SBA_AND_OBJECTS conditions --- lib_dec/ivas_dec.c | 10 ---------- lib_dec/ivas_dirac_dec.c | 2 -- lib_dec/ivas_init_dec.c | 10 ---------- lib_enc/ivas_osba_enc.c | 6 +++--- 4 files changed, 3 insertions(+), 25 deletions(-) mode change 100755 => 100644 lib_enc/ivas_osba_enc.c diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index edda816043..5138e5c4bf 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -736,7 +736,6 @@ ivas_error ivas_dec( } } -#ifdef SBA_AND_OBJECTS if ( st_ivas->sba_dirac_stereo_flag ) { ivas_agc_dec_process( st_ivas->hSpar->hAgcDec, &output[sba_ch_idx], &output[sba_ch_idx], st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); @@ -756,7 +755,6 @@ ivas_error ivas_dec( ivas_sba_dirac_stereo_dec( st_ivas, &output[sba_ch_idx], output_frame, 0 ); } -#endif /* HP filtering */ for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) @@ -838,7 +836,6 @@ ivas_error ivas_dec( ivas_sba_upmixer_renderer( st_ivas, &output[sba_ch_idx], output_frame ); } } -#ifdef SBA_AND_OBJECTS else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC && ( st_ivas->renderer_type == RENDERER_OSBA_STEREO || st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) ) { if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) @@ -861,8 +858,6 @@ ivas_error ivas_dec( v_add( output[n], output[n + max( nchan_out, nchan_ism )], output[n], output_frame ); } } -#endif -#ifdef SBA_AND_OBJECTS else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS ) { float tmp_ism_out[MAX_OUTPUT_CHANNELS][L_FRAME48k]; @@ -896,16 +891,12 @@ ivas_error ivas_dec( v_multc( output[n], 0.5f, output[n], output_frame ); } } -#endif -#ifdef SBA_AND_OBJECTS else if ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_EXTERNAL && !st_ivas->sba_dirac_stereo_flag && nchan_out != 1 ) { ivas_sba_upmixer_renderer( st_ivas, output, output_frame ); /* Note: ivas_sba_linear_renderer() or ivas_dirac_dec() are called internally */ } -#endif else if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_EXTERNAL ) /*EXT output = individual objects + HOA3*/ { -#ifdef SBA_AND_OBJECTS if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { for ( n = 0; n < nchan_ism; n++ ) @@ -926,7 +917,6 @@ ivas_error ivas_dec( set_zero( output[n], output_frame ); } } -#endif } } #endif diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index ac03c69b23..9a8c391ed2 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -878,8 +878,6 @@ ivas_error ivas_dirac_dec_config( case RENDERER_SBA_LINEAR_DEC: #ifdef SBA_AND_OBJECTS case RENDERER_OSBA_AMBI: -#endif -#ifdef SBA_AND_OBJECTS case RENDERER_OSBA_LS: #endif need_dirac_rend = 1; diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 18b682a3ec..6ca595ed02 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2070,11 +2070,7 @@ ivas_error ivas_init_decoder( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || #ifdef SBA_AND_OBJECTS st_ivas->renderer_type == RENDERER_OSBA_STEREO || -#endif -#ifdef SBA_AND_OBJECTS st_ivas->renderer_type == RENDERER_OSBA_AMBI || -#endif -#ifdef SBA_AND_OBJECTS st_ivas->renderer_type == RENDERER_OSBA_LS || #endif st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || @@ -2911,14 +2907,8 @@ void ivas_init_dec_get_num_cldfb_instances( case RENDERER_BINAURAL_FASTCONV_ROOM: #ifdef SBA_AND_OBJECTS case RENDERER_OSBA_STEREO: -#endif -#ifdef SBA_AND_OBJECTS case RENDERER_OSBA_AMBI: -#endif -#ifdef SBA_AND_OBJECTS case RENDERER_OSBA_LS: -#endif -#ifdef SBA_AND_OBJECTS if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) #else if ( st_ivas->ivas_format == SBA_FORMAT ) diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c old mode 100755 new mode 100644 index 91b33328bd..75858e9a15 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -110,7 +110,7 @@ ivas_error ivas_osba_enc_open( } len = NS2SA( st_ivas->hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ); - + for ( i = 0; i < st_ivas->hEncoderConfig->nchan_ism; i++ ) { if ( ( hOSba->input_data_mem[i] = (float *) malloc( len * sizeof( float ) ) ) == NULL ) @@ -119,7 +119,7 @@ ivas_error ivas_osba_enc_open( } set_f( hOSba->input_data_mem[i], 0.0f, len ); } - + for ( ; i < MAX_NUM_OBJECTS; i++ ) { hOSba->input_data_mem[i] = NULL; @@ -376,7 +376,7 @@ void ivas_osba_enc( const int16_t nchan_ism, /* i : Number of objects for parameter analysis */ const ISM_MODE ism_mode, /* i : ISM mode */ const int16_t sba_analysis_order, /* i : SBA order evaluated in DirAC/SPAR encoder */ - const int32_t input_Fs /* i : input sampling rate*/ + const int32_t input_Fs /* i : input sampling rate*/ ) { float data_out_f[MAX_INPUT_CHANNELS][L_FRAME48k]; -- GitLab From 489f8623a5097e9455adb19971b0dec4b5ee9fab Mon Sep 17 00:00:00 2001 From: rtyag Date: Fri, 11 Aug 2023 13:06:52 +1000 Subject: [PATCH 105/109] address comments, BR switching fix --- lib_com/ivas_prot.h | 12 +++++++ lib_dec/ivas_dec.c | 35 ++------------------ lib_dec/ivas_init_dec.c | 2 +- lib_dec/ivas_osba_dec.c | 64 ++++++++++++++++++++++++++++++++++++ lib_dec/ivas_sba_dec.c | 24 +++++++++----- lib_dec/ivas_spar_decoder.c | 5 --- lib_enc/ivas_osba_enc.c | 6 ++++ scripts/config/self_test.prm | 56 ++++++++++++++++--------------- 8 files changed, 130 insertions(+), 74 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 3560d70c15..f029892be9 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5769,6 +5769,18 @@ ivas_error ivas_osba_ism_metadata_dec( int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ ); +/*-------------------------------------------------------------------------* + * ivas_osba_render() + * + * Object + SBA rendering process. + *-------------------------------------------------------------------------*/ + +void ivas_osba_render( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float output_f[][L_FRAME48k], /* i/o: core-coder transport channels/object output */ + const int16_t output_frame /* i : output frame length per channel */ +); + void ivas_masa_ism_data_close( MASA_ISM_DATA_HANDLE *hMasaIsmData /* i/o: MASA_ISM rendering handle */ ); diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 5138e5c4bf..dc2a4f9a0a 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -377,9 +377,6 @@ ivas_error ivas_dec( } else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { -#ifdef OSBA_BR_SWITCHING - st_ivas->ism_mode = ISM_MODE_NONE; -#endif set_s( nb_bits_metadata, 0, MAX_SCE ); /* read parameters from the bitstream */ @@ -860,36 +857,7 @@ ivas_error ivas_dec( } else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS ) { - float tmp_ism_out[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - float *p_tmp_ism_out[MAX_OUTPUT_CHANNELS]; - - for ( n = 0; n < nchan_out; n++ ) - { - p_tmp_ism_out[n] = &tmp_ism_out[n][0]; - } - - for ( n = 0; n < nchan_ism; n++ ) - { - mvr2r( output[n], tmp_ism_out[n], output_frame ); - delay_signal( tmp_ism_out[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); - } - - if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI ) - { - ivas_ism2sba( p_tmp_ism_out, st_ivas->hIsmRendererData, st_ivas->hIsmMetaData, st_ivas->nchan_ism, output_frame, st_ivas->hIntSetup.ambisonics_order ); - } - else - { - ivas_ism_render( st_ivas, p_tmp_ism_out, output_frame ); - } - - ivas_sba_upmixer_renderer( st_ivas, &output[st_ivas->nchan_ism], output_frame ); - - for ( n = 0; n < nchan_out; n++ ) - { - v_add( output[n + nchan_ism], tmp_ism_out[n], output[n], output_frame ); - v_multc( output[n], 0.5f, output[n], output_frame ); - } + ivas_osba_render( st_ivas, output, output_frame ); } else if ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_EXTERNAL && !st_ivas->sba_dirac_stereo_flag && nchan_out != 1 ) { @@ -904,6 +872,7 @@ ivas_error ivas_dec( delay_signal( output[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); } } + ivas_sba_upmixer_renderer( st_ivas, &output[sba_ch_idx], output_frame ); if ( st_ivas->ism_mode == ISM_MODE_NONE ) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 6ca595ed02..0f819996d5 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -877,7 +877,7 @@ int16_t getNumChanSynthesis( { n = st_ivas->nchan_transport; } -#if defined( SBA_AND_OBJECTS ) && !defined( OSBA_BR_SWITCHING ) +#ifdef SBA_AND_OBJECTS else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 17e05df473..09a6bd27c8 100755 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -289,4 +289,68 @@ ivas_error ivas_osba_ism_metadata_dec( return IVAS_ERR_OK; } + +/*-------------------------------------------------------------------------* + * ivas_osba_render() + * + * Object + SBA rendering process. + *-------------------------------------------------------------------------*/ + +void ivas_osba_render( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float output_f[][L_FRAME48k], /* i/o: core-coder transport channels/object output */ + const int16_t output_frame /* i : output frame length per channel */ +) +{ + float tmp_ism_out[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + float *p_tmp_ism_out[MAX_OUTPUT_CHANNELS]; + int16_t n, nchan_out, nchan_ism, sba_ch_idx; + + nchan_out = st_ivas->hDecoderConfig->nchan_out; + nchan_ism = st_ivas->nchan_ism; + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + sba_ch_idx = st_ivas->nchan_ism; + } + else + { + sba_ch_idx = 0; + } + + for ( n = 0; n < nchan_out; n++ ) + { + p_tmp_ism_out[n] = &tmp_ism_out[n][0]; + } + + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + for ( n = 0; n < nchan_ism; n++ ) + { + mvr2r( output_f[n], tmp_ism_out[n], output_frame ); + delay_signal( tmp_ism_out[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); + } + + if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI ) + { + ivas_ism2sba( p_tmp_ism_out, st_ivas->hIsmRendererData, st_ivas->hIsmMetaData, st_ivas->nchan_ism, output_frame, st_ivas->hIntSetup.ambisonics_order ); + } + else + { + ivas_ism_render( st_ivas, p_tmp_ism_out, output_frame ); + } + } + + ivas_sba_upmixer_renderer( st_ivas, &output_f[sba_ch_idx], output_frame ); + + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + for ( n = 0; n < nchan_out; n++ ) + { + v_add( output_f[n + nchan_ism], tmp_ism_out[n], output_f[n], output_frame ); + v_multc( output_f[n], 0.5f, output_f[n], output_frame ); + } + } + + return; +} #endif diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 831fc4fdb8..7334ea4979 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -145,17 +145,13 @@ ivas_error ivas_sba_dec_reconfigure( { st_ivas->ism_mode = ISM_MODE_NONE; } - if ( ism_mode_old == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) - { - nchan_hp20_old = st_ivas->nchan_transport; - } - else if ( ism_mode_old == ISM_SBA_MODE_DISC && st_ivas->ism_mode == ISM_MODE_NONE ) - { - nchan_hp20_old += st_ivas->nchan_ism; - } } - + else + { + st_ivas->ism_mode = ISM_MODE_NONE; + } #endif + nSCE_old = st_ivas->nSCE; nCPE_old = st_ivas->nCPE; nchan_transport_old = st_ivas->nchan_transport; @@ -433,6 +429,16 @@ ivas_error ivas_sba_dec_reconfigure( return error; } +#ifdef OSBA_BR_SWITCHING + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + st_ivas->nchan_transport -= st_ivas->nchan_ism; + } + } +#endif + /*-----------------------------------------------------------------* * HP20 memories *-----------------------------------------------------------------*/ diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index c2280974f3..3695bf7bd0 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1741,11 +1741,6 @@ void ivas_spar_dec_upmixer_sf( outchannels = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; - if ( hDecoderConfig->output_config == AUDIO_CONFIG_EXTERNAL && hDecoderConfig->ivas_total_brate < IVAS_256k ) - { - outchannels -= st_ivas->nchan_ism; - } - for ( ch = 0; ch < outchannels; ch++ ) { if ( ( st_ivas->hOutSetup.num_lfe > 0 ) && ( st_ivas->hOutSetup.index_lfe[idx_lfe] == ch ) ) diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index 75858e9a15..d66126fe26 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -356,6 +356,12 @@ ivas_error ivas_osba_enc_reconfig( { return error; } + + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + /*retain original value for further processing*/ + st_ivas->nchan_transport -= st_ivas->hEncoderConfig->nchan_ism; + } } return error; diff --git a/scripts/config/self_test.prm b/scripts/config/self_test.prm index dc592501b0..2c3bf9c1a2 100644 --- a/scripts/config/self_test.prm +++ b/scripts/config/self_test.prm @@ -1383,53 +1383,57 @@ networkSimulator_g192 ../scripts/dly_error_profiles/dly_error_profile_5.dat bit // OSBA FOA 1ISM at 32 kbps, 48kHz in, 48kHz out, BINAURAL out -../IVAS_cod -ism_sba 1 1 testv/stvISM1.csv 32000 48 testv/stvOSBA_1ISM_FOA48c.wav bit -../IVAS_dec BINAURAL 48 bit testv/stvOSBA_1ISM_FOA48c.wav_BINAURAL_32000_48-48.tst +//../IVAS_cod -ism_sba 1 1 testv/stvISM1.csv 32000 48 testv/stvOSBA_1ISM_FOA48c.wav bit +//../IVAS_dec BINAURAL 48 bit testv/stvOSBA_1ISM_FOA48c.wav_BINAURAL_32000_48-48.tst // OSBA FOA 2ISM at 64 kbps, 48kHz in, 48kHz out, HOA3 out -../IVAS_cod -ism_sba 2 1 testv/stvISM1.csv testv/stvISM2.csv 64000 48 testv/stvOSBA_2ISM_FOA48c.wav bit -../IVAS_dec HOA3 48 bit testv/stvOSBA_2ISM_FOA48c.wav_HOA3_64000_48-48.tst +//../IVAS_cod -ism_sba 2 1 testv/stvISM1.csv testv/stvISM2.csv 64000 48 testv/stvOSBA_2ISM_FOA48c.wav bit +//../IVAS_dec HOA3 48 bit testv/stvOSBA_2ISM_FOA48c.wav_HOA3_64000_48-48.tst // OSBA FOA 3ISM at 128 kbps, 48kHz in, 48kHz out, 7_1_4 out -../IVAS_cod -ism_sba 3 1 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv 128000 48 testv/stvOSBA_3ISM_FOA48c.wav bit -../IVAS_dec 7_1_4 48 bit testv/stvOSBA_3ISM_FOA48c.wav_7_1_4_128000_48-48.tst +//../IVAS_cod -ism_sba 3 1 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv 128000 48 testv/stvOSBA_3ISM_FOA48c.wav bit +//../IVAS_dec 7_1_4 48 bit testv/stvOSBA_3ISM_FOA48c.wav_7_1_4_128000_48-48.tst // OSBA FOA 4ISM at 256 kbps, 48kHz in, 48kHz out, EXT out -../IVAS_cod -ism_sba 4 1 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 256000 48 testv/stvOSBA_4ISM_FOA48c.wav bit -../IVAS_dec EXT 48 bit testv/stvOSBA_4ISM_FOA48c.wav_EXT_256000_48-48.tst +//../IVAS_cod -ism_sba 4 1 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 256000 48 testv/stvOSBA_4ISM_FOA48c.wav bit +//../IVAS_dec EXT 48 bit testv/stvOSBA_4ISM_FOA48c.wav_EXT_256000_48-48.tst // OSBA FOA 4ISM at 512 kbps, 48kHz in, 48kHz out, BINAURAL out -../IVAS_cod -ism_sba 4 1 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 512000 48 testv/stvOSBA_4ISM_FOA48c.wav bit -../IVAS_dec BINAURAL 48 bit testv/stvOSBA_4ISM_FOA48c.wav_BINAURAL_512000_48-48.tst +//../IVAS_cod -ism_sba 4 1 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 512000 48 testv/stvOSBA_4ISM_FOA48c.wav bit +//../IVAS_dec BINAURAL 48 bit testv/stvOSBA_4ISM_FOA48c.wav_BINAURAL_512000_48-48.tst // OSBA 2OA 1ISM at 24.4 kbps, 48kHz in, 48kHz out, FOA out -../IVAS_cod -ism_sba 1 2 testv/stvISM1.csv 24400 48 testv/stvOSBA_1ISM_2OA48c.wav bit -../IVAS_dec FOA 48 bit testv/stvOSBA_1ISM_2OA48c.wav_FOA_24400_48-48.tst +//../IVAS_cod -ism_sba 1 2 testv/stvISM1.csv 24400 48 testv/stvOSBA_1ISM_2OA48c.wav bit +//../IVAS_dec FOA 48 bit testv/stvOSBA_1ISM_2OA48c.wav_FOA_24400_48-48.tst // OSBA 2OA 2ISM at 48 kbps, 48kHz in, 48kHz out, MONO out -../IVAS_cod -ism_sba 2 2 testv/stvISM1.csv testv/stvISM2.csv 48000 48 testv/stvOSBA_2ISM_2OA48c.wav bit -../IVAS_dec MONO 48 bit testv/stvOSBA_2ISM_2OA48c.wav_MONO_48000_48-48.tst +//../IVAS_cod -ism_sba 2 2 testv/stvISM1.csv testv/stvISM2.csv 48000 48 testv/stvOSBA_2ISM_2OA48c.wav bit +//../IVAS_dec MONO 48 bit testv/stvOSBA_2ISM_2OA48c.wav_MONO_48000_48-48.tst // OSBA 2OA 3ISM at 96 kbps, 48kHz in, 48kHz out, STEREO out -../IVAS_cod -ism_sba 3 2 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv 96000 48 testv/stvOSBA_3ISM_2OA48c.wav bit -../IVAS_dec STEREO 48 bit testv/stvOSBA_3ISM_2OA48c.wav_STEREO_96000_48-48.tst +//../IVAS_cod -ism_sba 3 2 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv 96000 48 testv/stvOSBA_3ISM_2OA48c.wav bit +//../IVAS_dec STEREO 48 bit testv/stvOSBA_3ISM_2OA48c.wav_STEREO_96000_48-48.tst // OSBA 2OA 4ISM at 384 kbps, 48kHz in, 48kHz out, BINAURAL out -../IVAS_cod -ism_sba 4 2 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 384000 48 testv/stvOSBA_4ISM_2OA48c.wav bit -../IVAS_dec BINAURAL 48 bit testv/stvOSBA_4ISM_2OA48c.wav_BINAURAL_384000_48-48.tst +//../IVAS_cod -ism_sba 4 2 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 384000 48 testv/stvOSBA_4ISM_2OA48c.wav bit +//../IVAS_dec BINAURAL 48 bit testv/stvOSBA_4ISM_2OA48c.wav_BINAURAL_384000_48-48.tst // OSBA 3OA 1ISM at 512 kbps, 48kHz in, 48kHz out, EXT out -../IVAS_cod -ism_sba 1 3 testv/stvISM1.csv 512000 48 testv/stvOSBA_1ISM_3OA48c.wav bit -../IVAS_dec EXT 48 bit testv/stvOSBA_1ISM_3OA48c.wav_EXT_512000_48-48.tst +//../IVAS_cod -ism_sba 1 3 testv/stvISM1.csv 512000 48 testv/stvOSBA_1ISM_3OA48c.wav bit +//../IVAS_dec EXT 48 bit testv/stvOSBA_1ISM_3OA48c.wav_EXT_512000_48-48.tst // OSBA 3OA 2ISM at 256 kbps, 48kHz in, 48kHz out, 7_1 out -../IVAS_cod -ism_sba 2 3 testv/stvISM1.csv testv/stvISM2.csv 256000 48 testv/stvOSBA_2ISM_3OA48c.wav bit -../IVAS_dec 7_1 48 bit testv/stvOSBA_2ISM_3OA48c.wav_7_1_256000_48-48.tst +//../IVAS_cod -ism_sba 2 3 testv/stvISM1.csv testv/stvISM2.csv 256000 48 testv/stvOSBA_2ISM_3OA48c.wav bit +//../IVAS_dec 7_1 48 bit testv/stvOSBA_2ISM_3OA48c.wav_7_1_256000_48-48.tst // OSBA 3OA 3ISM at 128 kbps, 48kHz in, 48kHz out, BINAURAL out -../IVAS_cod -ism_sba 3 3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv 128000 48 testv/stvOSBA_3ISM_3OA48c.wav bit -../IVAS_dec BINAURAL 48 bit testv/stvOSBA_3ISM_3OA48c.wav_BINAURAL_128000_48-48.tst +//../IVAS_cod -ism_sba 3 3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv 128000 48 testv/stvOSBA_3ISM_3OA48c.wav bit +//../IVAS_dec BINAURAL 48 bit testv/stvOSBA_3ISM_3OA48c.wav_BINAURAL_128000_48-48.tst // OSBA 3OA 4ISM at 16.4 kbps, 48kHz in, 48kHz out, 5_1 out -../IVAS_cod -ism_sba 4 3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 16400 48 testv/stvOSBA_4ISM_3OA48c.wav bit -../IVAS_dec 5_1 48 bit testv/stvOSBA_4ISM_3OA48c.wav_5_1_16400_48-48.tst +//../IVAS_cod -ism_sba 4 3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 16400 48 testv/stvOSBA_4ISM_3OA48c.wav bit +//../IVAS_dec 5_1 48 bit testv/stvOSBA_4ISM_3OA48c.wav_5_1_16400_48-48.tst + +// OSBA 3OA 4ISM bitrate switching 13.2 to 512, 48kHz in, 48kHz out, BIN out +//../IVAS_cod -ism_sba 4 3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv scripts\switchPaths\sw_13k2_512k.bin 48 testv/stvOSBA_4ISM_3OA48c.wav bit +//../IVAS_dec BINAURAL 48 bit testv/stvOSBA_4ISM_3OA48c.wav_BINAURAL_sw_13k2_512k_48-48.tst -- GitLab From c0e0d46972fd2678a310183e68ecb2d9337502de Mon Sep 17 00:00:00 2001 From: rtyag Date: Fri, 11 Aug 2023 13:20:13 +1000 Subject: [PATCH 106/109] address review comment --- lib_dec/ivas_init_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 0f819996d5..de56f1d5b0 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -448,7 +448,7 @@ ivas_error ivas_dec_setup( /* set Ambisonic (SBA) order used for analysis and coding */ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); - if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate && ivas_total_brate > IVAS_SID_5k2 ) + if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate ) { if ( ( error = ivas_sba_dec_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) { -- GitLab From cf055bd516db7694b1f380fb74729554e86a5d0b Mon Sep 17 00:00:00 2001 From: rtyag Date: Fri, 11 Aug 2023 13:52:09 +1000 Subject: [PATCH 107/109] fix prm file --- scripts/config/self_test.prm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/config/self_test.prm b/scripts/config/self_test.prm index 2c3bf9c1a2..ece3c2ed92 100644 --- a/scripts/config/self_test.prm +++ b/scripts/config/self_test.prm @@ -1435,5 +1435,5 @@ networkSimulator_g192 ../scripts/dly_error_profiles/dly_error_profile_5.dat bit //../IVAS_dec 5_1 48 bit testv/stvOSBA_4ISM_3OA48c.wav_5_1_16400_48-48.tst // OSBA 3OA 4ISM bitrate switching 13.2 to 512, 48kHz in, 48kHz out, BIN out -//../IVAS_cod -ism_sba 4 3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv scripts\switchPaths\sw_13k2_512k.bin 48 testv/stvOSBA_4ISM_3OA48c.wav bit +//../IVAS_cod -ism_sba 4 3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv switchPaths/sw_13k2_512k.bin 48 testv/stvOSBA_4ISM_3OA48c.wav bit //../IVAS_dec BINAURAL 48 bit testv/stvOSBA_4ISM_3OA48c.wav_BINAURAL_sw_13k2_512k_48-48.tst -- GitLab From 8e3c3ca60b87e400f089697866d84a38d9db056a Mon Sep 17 00:00:00 2001 From: rtyag Date: Fri, 11 Aug 2023 14:34:59 +1000 Subject: [PATCH 108/109] san issue fix --- lib_dec/ivas_init_dec.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index de56f1d5b0..bee42c25c6 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1551,6 +1551,13 @@ ivas_error ivas_init_decoder( } } +#ifdef OSBA_BR_SWITCHING + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + st_ivas->nchan_transport -= st_ivas->nchan_ism; + } +#endif + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) -- GitLab From 42afc22c21a01a20664015ec1ed8f1b55a532be6 Mon Sep 17 00:00:00 2001 From: rtyag Date: Fri, 11 Aug 2023 18:09:37 +1000 Subject: [PATCH 109/109] fix for MASA tests --- lib_rend/ivas_dirac_dec_binaural_functions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 19d90feab0..2b882468eb 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -2385,7 +2385,7 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices( decorrelationReductionFactor = sqrtf( fmaxf( 0.0f, hDiracDecBin->frameMeanDiffuseness[bin] ) ); } #ifdef SBA_AND_OBJECTS - if ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && nchan_transport == 1 ) + else if ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && nchan_transport == 1 ) #else else if ( ivas_format == SBA_FORMAT && nchan_transport == 1 ) #endif -- GitLab