diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index b7f24440b440bbed4ae42574344081a807ab8586..28642303802011ddd66ee0caf20fa028b409a5aa 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -185,7 +185,12 @@ typedef enum #define MAX_JBM_L_FRAME48k 1920 #define MAX_JBM_L_FRAME_NS 40000000L #define MAX_SPAR_INTERNAL_CHANNELS IVAS_SPAR_MAX_CH +#ifdef JBM_FOR_OSBA +#define MAX_CLDFB_DIGEST_CHANNELS (FOA_CHANNELS + MAX_NUM_OBJECTS) +#else #define MAX_CLDFB_DIGEST_CHANNELS 4 +#endif + #define MASA_JBM_RINGBUFFER_FRAMES 3 typedef enum diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index f57e92a634d890087f17e5f9663b1414b6698d42..04e803c0b6a2261c3258979e5cb4999d959a631a 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3480,6 +3480,16 @@ void ivas_sba_set_cna_cng_flag( ivas_error ivas_sba_dec_reconfigure( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#ifdef JBM_FOR_OSBA + , + uint16_t *nSamplesFlushed, /* o : number of samples flushed */ +#if defined SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else + int16_t *data /* o : output synthesis signal */ +#endif +#endif ); ivas_error ivas_sba_digest_tc( @@ -5719,6 +5729,18 @@ ivas_error ivas_sba_ism_separate_object_renderer_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); #endif + +#ifdef JBM_FOR_OSBA +ivas_error ivas_osba_dirac_td_binaural_jbm( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ +); +#endif + + ivas_error ivas_osba_dirac_td_binaural( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output[], /* o : output synthesis signal */ diff --git a/lib_com/options.h b/lib_com/options.h index 99120b3e3d3e395bb887a29d3c30443ff572a5f6..53de4ed72965fe97c06e5b6a4bf201d3464a4b49 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -127,7 +127,7 @@ /*#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 */ -/*#define VARIABLE_SPEED_DECODING*/ /* variable speed decoding employing the JBM functioniality; move to DEBUGGING after build for disabled is fixed */ +/*#define VARIABLE_SPEED_DECODING*/ /* variable speed decoding employing the JBM functioniality; move to DEBUGGING after build for disabled is fixed */ /*Split Rendering Debug switches*/ /*#define DBG_WAV_WRITER*/ /* add debugging function dbgwrite_wav() */ @@ -160,6 +160,7 @@ #endif #define FIX_705_REND_CONF_FALSE_WARNING /* Eri: Bug in MSVC ftell() for UNIX-style line endings trigger false warning messages in renderer configuration. */ + #define IGF_MEMORY_ALLOC_OPT /* FhG: Issue 157: allocate IGF encoder structure only when needed */ #define FIX_732_PLANAR_SBA_OSBA /* Dlb : issue 732: fix for crash in planar mode in OSBA format*/ #define FIX_708_DPID_COMMAND_LINE /* issue 708: sanity checks for '-dpid' command-line */ @@ -181,7 +182,6 @@ #define LIB_REND_FIX_HRTFPARAMBIN_MEMLEAK /* fix 755 */ #define FIX_803_SCE_MD_HANDLE /* VA: issue 803: Resolve "MD handle needed only for one SCE" */ - /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ @@ -189,6 +189,7 @@ /* all switches in this category should start with "NONBE_" */ #define NONBE_FIX_751_MASA_TD_BITRATE_CHECK /* Nokia: issue 751: prevents secondary channel to take reserved bitrate if not DTX mode */ + #define NONBE_FIX_736_FOA_BR_SWITCH /* FhG/Dlb : Issue 736: FOA bitrate switching decoding crashes in in ivas_spar_to_dirac */ #define NONBE_FIX_746_NONDIEGETIC_MD /* Eri: Issue 746: The non-diegetic panning flag affects the encoder bitstream even if extended metadata is not enabled. Crashes the decoder.*/ #define NONBE_FIX_723_SBA_BR_SWITCH_MSAN /* Dlb: issue 723: Uninitialised value used after BR switching*/ @@ -214,6 +215,12 @@ #define NONBE_FIX_798_OSBA_MC_DEC_CRASH #define NONBE_FIX_806_OMASA_ONE_SEP_TRANSPORT_MIX /* Nokia: issue 806: fix one separated object mode transport mix of the separated object */ +#define JBM_FOR_OSBA /* FhG: implement OSBA format in the JBM path */ + +#ifdef JBM_FOR_OSBA +#define OSBA_ROOM_IR +#endif + /* ##################### End NON-BE switches ########################### */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index eb6dd72e41d14ebea6f58491a37cc54478931552..6a134e6fda36a3a851ddcb794398ddf007deea8a 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -159,6 +159,15 @@ ivas_error ivas_corecoder_dec_reconfig( st_ivas->hSCE[sce_id] = NULL; } +#ifdef JBM_FOR_OSBA + if ( sba_dirac_stereo_flag_old && nCPE_old == 0 && st_ivas->hCPE[0] ) + { + st_ivas->hCPE[0]->hCoreCoder[0] = 0; /* this has been deallocated as part of the SCE it actually belongs to */ + destroy_cpe_dec( st_ivas->hCPE[0] ); + st_ivas->hCPE[0] = NULL; + } +#endif + for ( cpe_id = st_ivas->nCPE; cpe_id < nCPE_old; cpe_id++ ) { /* don't deallocate first CPE in case of mono/stereo output of 1 TC SBA, only deallocate core coder */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index d277d8406df99057d41a371435c3f71c354a01f6..494a885b1a7fd5f32903b81aec48973a2f5ccac5 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -692,7 +692,9 @@ ivas_error ivas_dec( } /* 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->renderer_type == RENDERER_BINAURAL_PARAMETRIC || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || + st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, &p_output[sba_ch_idx], nchan_remapped, MAX_PARAM_SPATIAL_SUBFRAMES ); } @@ -760,8 +762,12 @@ ivas_error ivas_dec( #endif } } +#ifdef JBM_FOR_OSBA + if ( ( error = ivas_sba_upmixer_renderer( st_ivas, p_output, output_frame ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_sba_upmixer_renderer( st_ivas, &p_output[sba_ch_idx], output_frame ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index dda8f05e6d81b08b909b8c5a7150edb0bf6548cc..b7d4698e3c54cc4ca09e1d4e3aba1d3f70660706 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1552,7 +1552,11 @@ void ivas_dirac_dec_set_md_map( ivas_jbm_dec_get_adapted_subframes( nCldfbTs, hSpatParamRendCom->subframe_nbslots, &hSpatParamRendCom->nb_subframes ); /* copy also to tc buffer */ /* only for non-combined formats and combinded formats w/o discrete objects */ - if ( st_ivas->ivas_format != MASA_ISM_FORMAT || st_ivas->ism_mode != ISM_MASA_MODE_DISC ) + if ( ( st_ivas->ivas_format != MASA_ISM_FORMAT || st_ivas->ism_mode != ISM_MASA_MODE_DISC ) +#ifdef JBM_FOR_OSBA + && !( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) +#endif + ) { st_ivas->hTcBuffer->nb_subframes = hSpatParamRendCom->nb_subframes; mvs2s( hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hSpatParamRendCom->nb_subframes ); @@ -2404,6 +2408,94 @@ void ivas_dirac_dec_render_sf( if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { + +#ifdef OSBA_ROOM_IR + /* render objects in combined format onto the CICP19 channels for BINAURAL_ROOM_IR */ + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + int16_t in_ch; + for ( in_ch = 0; in_ch < st_ivas->nchan_ism; in_ch++ ) + { + int16_t j, k, j2, l; + int16_t num_objects, nchan_out_woLFE, lfe_index; + int16_t az1, el1; + int16_t n_slots_to_render; + int16_t n_samples_to_render; + int16_t interp_offset; + float gain, prev_gain; + num_objects = st_ivas->nchan_ism; + nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; + n_slots_to_render = st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->subframes_rendered]; + n_samples_to_render = hSpatParamRendCom->num_freq_bands * n_slots_to_render; + interp_offset = st_ivas->hTcBuffer->n_samples_rendered; + + if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] ) + { + ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, + n_samples_to_render, + st_ivas->hIsmRendererData->interpolator ); + interp_offset = 0; + } + + for ( i = 0; i < num_objects; i++ ) + { + /* Combined rotation: rotate the object positions depending the head and external orientations */ + if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) + { + rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &az1, &el1, st_ivas->hCombinedOrientationData->Rmat[0], st_ivas->hIntSetup.is_planar_setup ); + if ( st_ivas->hEFAPdata != NULL ) + { + efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], az1, el1, EFAP_MODE_EFAP ); + } + } + + lfe_index = 0; + for ( j = 0, j2 = 0; j < nchan_out_woLFE; j++, j2++ ) + { + if ( ( st_ivas->hIntSetup.num_lfe > 0 ) && ( st_ivas->hIntSetup.index_lfe[lfe_index] == j ) ) + { + ( lfe_index < ( st_ivas->hIntSetup.num_lfe - 1 ) ) ? ( lfe_index++, j2++ ) : j2++; + } + + gain = st_ivas->hIsmRendererData->gains[i][j]; + prev_gain = st_ivas->hIsmRendererData->prev_gains[i][j]; + if ( fabsf( gain ) > 0.0f || fabsf( prev_gain ) > 0.0f ) + { + float *tc_re, *tc_im; + float *w1, w2; + + w1 = &st_ivas->hIsmRendererData->interpolator[interp_offset]; + tc_re = pppQMfFrame_ts_re[nchan_transport + i][0]; + tc_im = pppQMfFrame_ts_im[nchan_transport + i][0]; + + for ( k = 0; k < n_slots_to_render; k++ ) + { + float g; + + w2 = 1.0f - *w1; + g = ( *w1 * gain + w2 * prev_gain ); + + for ( l = 0; l < hSpatParamRendCom->num_freq_bands; l++ ) + { + Cldfb_RealBuffer[j2][0][k * hSpatParamRendCom->num_freq_bands + l] += g * *( tc_re++ ); + Cldfb_ImagBuffer[j2][0][k * hSpatParamRendCom->num_freq_bands + l] += g * *( tc_im++ ); + } + w1 += hSpatParamRendCom->num_freq_bands; + } + } + + /* update here only in case of head rotation */ + if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) + { + st_ivas->hIsmRendererData->prev_gains[i][j] = gain; + } + } + } + } + } +#endif + + #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index a56c2d221633d9e5e11a61368fe1031c38698ac6..bf1fff8a1eeebebe61ecb245974de362551696fa 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -359,7 +359,17 @@ ivas_error ivas_dec_setup( 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 ) + if ( ( error = ivas_sba_dec_reconfigure( st_ivas +#ifdef JBM_FOR_OSBA + , + nSamplesRendered, +#if defined SPLIT_REND_WITH_HEAD_ROT + pcm_resolution, +#endif + data +#endif + + ) ) != IVAS_ERR_OK ) { return error; } @@ -467,18 +477,33 @@ ivas_error ivas_dec_setup( st_ivas->sba_order = 3; } +#ifndef JBM_FOR_OSBA /* 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 ); +#endif 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 ) + if ( ( error = ivas_sba_dec_reconfigure( st_ivas +#ifdef JBM_FOR_OSBA + , + nSamplesRendered, +#if defined SPLIT_REND_WITH_HEAD_ROT + pcm_resolution, +#endif + data +#endif + ) ) != IVAS_ERR_OK ) { return error; } } else { +#ifdef JBM_FOR_OSBA + /* 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 ); +#endif 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*/ @@ -603,7 +628,16 @@ ivas_error ivas_dec_setup( st_ivas->hDecoderConfig->ivas_total_brate = IVAS_24k4; } - if ( ( error = ivas_sba_dec_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sba_dec_reconfigure( st_ivas +#ifdef JBM_FOR_OSBA + , + nSamplesRendered, +#if defined SPLIT_REND_WITH_HEAD_ROT + pcm_resolution, +#endif + data +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -885,6 +919,13 @@ int16_t getNumChanSynthesis( if ( st_ivas->sba_dirac_stereo_flag ) { n = CPE_CHANNELS; +#if 0 + /* TODO wkr: this is actually a correct bugfix for OSBA, it is disabled for now to pass the pipelines in the OSBA JBM branch */ + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + n += st_ivas->nchan_ism; + } +#endif } else if ( ( st_ivas->hMCT != NULL || st_ivas->ivas_format == SBA_FORMAT ) && st_ivas->ivas_format != SBA_ISM_FORMAT ) { @@ -1132,6 +1173,16 @@ ivas_error ivas_init_decoder( ivas_output_init( &( st_ivas->hOutSetup ), output_config ); +#ifdef OSBA_ROOM_IR + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) + { + st_ivas->hOutSetup.ambisonics_order = SBA_HOA3_ORDER; + st_ivas->intern_config = IVAS_AUDIO_CONFIG_7_1_4; + st_ivas->hOutSetup.output_config = st_ivas->intern_config; + st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels( st_ivas->intern_config ); + } +#endif + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { st_ivas->hOutSetup.ambisonics_order = SBA_HOA3_ORDER; @@ -1451,6 +1502,8 @@ ivas_error ivas_init_decoder( st_ivas->ism_extmeta_active = -1; st_ivas->ism_extmeta_cnt = 0; + st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); + if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) { return error; @@ -1499,7 +1552,6 @@ ivas_error ivas_init_decoder( 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 ); for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { @@ -2923,6 +2975,12 @@ void ivas_init_dec_get_num_cldfb_instances( { *numCldfbSyntheses = MAX_OUTPUT_CHANNELS; } +#ifdef OSBA_ROOM_IR + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + *numCldfbAnalyses = st_ivas->nchan_ism + st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans; + } +#endif } } else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index e867d7b2accdf377bb2382cb3b7b7ef7858cc421..38bedac3aed2354db8a164615ea0d76167cf56f7 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -784,6 +784,7 @@ void ivas_param_ism_dec( { p_tc[i] = output_f[i]; } + output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); nchan_transport = st_ivas->nchan_transport; @@ -999,7 +1000,11 @@ void ivas_ism_dec_digest_tc( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->hDecoderConfig->Opt_Headrotation == 0 ) ) + ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->hDecoderConfig->Opt_Headrotation == 0 ) +#ifdef JBM_FOR_OSBA + || st_ivas->renderer_type == RENDERER_OSBA_STEREO || st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS +#endif + ) { int16_t i, num_objects; int16_t azimuth, elevation; @@ -1031,7 +1036,11 @@ void ivas_ism_dec_digest_tc( } /* also get the gains here */ +#ifdef JBM_FOR_OSBA + num_objects = st_ivas->nchan_ism; +#else num_objects = st_ivas->nchan_transport; +#endif for ( i = 0; i < num_objects; i++ ) { mvr2r( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmRendererData->prev_gains[i], MAX_OUTPUT_CHANNELS ); @@ -1046,7 +1055,14 @@ void ivas_ism_dec_digest_tc( azimuth = (int16_t) floorf( st_ivas->hIsmMetaData[i]->azimuth + 0.5f ); elevation = (int16_t) floorf( st_ivas->hIsmMetaData[i]->elevation + 0.5f ); - if ( ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) && + if ( ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM +#ifdef JBM_FOR_OSBA + || st_ivas->renderer_type == RENDERER_OSBA_LS +#ifdef OSBA_ROOM_IR + || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM +#endif +#endif + ) && st_ivas->hCombinedOrientationData == NULL ) { if ( st_ivas->hIntSetup.is_planar_setup ) @@ -1060,7 +1076,11 @@ void ivas_ism_dec_digest_tc( efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], azimuth, elevation, EFAP_MODE_EFAP ); } } - else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV +#ifdef JBM_FOR_OSBA + || st_ivas->renderer_type == RENDERER_OSBA_AMBI +#endif + ) { /*get HOA gets for direction (ACN/SN3D)*/ ivas_dirac_dec_get_response( azimuth, elevation, st_ivas->hIsmRendererData->gains[i], st_ivas->hIntSetup.ambisonics_order ); diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 46dcf6133e2f9c08717f84b1670cbeeaace51883..6286d40278bfd339476e41c6ffc8a7235140ee36 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -262,6 +262,12 @@ void ivas_ism_render_sf( float gain, prev_gain; num_objects = st_ivas->nchan_transport; +#ifdef JBM_FOR_OSBA + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + num_objects = st_ivas->nchan_ism; + } +#endif nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; tc_offset = st_ivas->hTcBuffer->n_samples_rendered; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 3e664b87e8bc9d6ef86c917559642d256f38435f..89fc658d07a85a98fd49036520746d490d71e7b3 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -406,6 +406,132 @@ ivas_error ivas_jbm_dec_tc( ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); } } +#ifdef JBM_FOR_OSBA + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + int16_t nchan_ism, sba_ch_idx; + + set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); + nchan_ism = st_ivas->nchan_ism; + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + /* 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; + } + + /* SBA metadata decoding */ + if ( ( error = ivas_spar_dec( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( st_ivas->nchan_transport == CPE_CHANNELS && st_ivas->nCPE >= 1 ) + { + st_ivas->hCPE[0]->element_brate = ivas_total_brate; + } + + /* core-decoding of transport channels */ + if ( st_ivas->nSCE == 1 ) + { + st = st_ivas->hSCE[0]->hCoreCoder[0]; + if ( ( error = ivas_sce_dec( st_ivas, 0, p_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_cpe_dec( st_ivas, 0, p_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, p_output, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + if ( st_ivas->sba_dirac_stereo_flag ) + { + ivas_agc_dec_process( st_ivas->hSpar->hAgcDec, &p_output[sba_ch_idx], &p_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, &p_output[sba_ch_idx] ); + } + + ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, + ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, + st_ivas->last_active_ivas_total_brate ) ); + + ivas_sba_dirac_stereo_dec( st_ivas, &p_output[sba_ch_idx], output_frame, 0 ); + } + + /* HP filtering */ + for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) + { + hp20( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); + } + + nchan_remapped = ivas_sba_remapTCs( &p_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 ( int16_t t = 0; t < output_frame; t++ ) + { + for ( int16_t 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->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + 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, &p_output[sba_ch_idx], st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); + } + else if ( st_ivas->renderer_type != RENDERER_DISABLE && !st_ivas->sba_dirac_stereo_flag ) + { + ivas_spar_dec_agc_pca( st_ivas, &p_output[sba_ch_idx], output_frame ); + } + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + /* loudness correction */ + ivas_dirac_dec_binaural_sba_gain( &p_output[sba_ch_idx], nchan_remapped, output_frame ); + } + else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + + ivas_mono_downmix_render_passive( st_ivas, p_output, output_frame ); + + /* add W */ + for ( n = 0; n < nchan_out; n++ ) + { + v_add( p_output[n], p_output[n + max( nchan_out, nchan_ism )], p_output[n], output_frame ); + } + } + } +#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]; @@ -741,6 +867,43 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer( return error; } } +#ifdef JBM_FOR_OSBA + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + ivas_ism_dec_digest_tc( st_ivas ); + + /* delay the objects here for all renderers where it is needed */ + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_OSBA_AMBI || + st_ivas->renderer_type == RENDERER_OSBA_LS || + st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + { + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + delay_signal( st_ivas->hTcBuffer->tc[n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); + } + } + + if ( !st_ivas->sba_dirac_stereo_flag ) + { + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + { + n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); + } + + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + } + } + else + { + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + } + } +#endif else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) @@ -808,8 +971,12 @@ ivas_error ivas_jbm_dec_render( { int16_t n, nchan_out; int16_t nchan_transport; - float *p_output[MAX_OUTPUT_CHANNELS]; - float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; /* 'float' buffer for output synthesis */ + float output[MAX_OUTPUT_CHANNELS +#ifdef JBM_FOR_OSBA + + MAX_NUM_OBJECTS +#endif + ][L_FRAME48k]; /* 'float' buffer for output synthesis */ + int16_t nchan_remapped; int32_t output_Fs; AUDIO_CONFIG output_config; @@ -818,7 +985,18 @@ ivas_error ivas_jbm_dec_render( #endif int16_t nSamplesAskedLocal; ivas_error error; - float *p_tc[MAX_TRANSPORT_CHANNELS]; + + float *p_output[MAX_OUTPUT_CHANNELS +#ifdef JBM_FOR_OSBA + + MAX_NUM_OBJECTS +#endif + ]; + float *p_tc[MAX_TRANSPORT_CHANNELS +#ifdef JBM_FOR_OSBA + + MAX_NUM_OBJECTS +#endif + ]; + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; push_wmops( "ivas_dec_render" ); @@ -834,7 +1012,12 @@ ivas_error ivas_jbm_dec_render( output_config = st_ivas->hDecoderConfig->output_config; nSamplesAskedLocal = nSamplesAsked + st_ivas->hTcBuffer->n_samples_discard; - for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) + for ( n = 0; n < MAX_OUTPUT_CHANNELS +#ifdef JBM_FOR_OSBA + + MAX_NUM_OBJECTS +#endif + ; + n++ ) { p_output[n] = &output[n][0]; } @@ -1003,7 +1186,9 @@ ivas_error ivas_jbm_dec_render( { nchan_remapped = st_ivas->nchan_transport; - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + 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 ) { @@ -1022,6 +1207,105 @@ ivas_error ivas_jbm_dec_render( ivas_omasa_dirac_rend_jbm( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); } } +#ifdef JBM_FOR_OSBA + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + nchan_remapped = nchan_transport; + + /* Loudspeakers, Ambisonics or Binaural rendering */ + + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + { + if ( ( error = ivas_osba_dirac_td_binaural_jbm( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->renderer_type == RENDERER_OSBA_STEREO ) + { + *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + /* render objects */ + ivas_ism_render_sf( st_ivas, p_output, *nSamplesRendered ); + /* add already rendererd SBA part */ + for ( n = 0; n < nchan_out; n++ ) + { + v_add( p_output[n], p_tc[n + st_ivas->nchan_ism], p_output[n], *nSamplesRendered ); + } + } + else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS +#ifdef JBM_FOR_OSBA + || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM +#endif + ) + { + float output_ism[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + float *p_output_ism[MAX_OUTPUT_CHANNELS]; + + for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) + { + p_output_ism[n] = &output_ism[n][0]; + } + + ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); +#ifdef OSBA_ROOM_IR + if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) +#endif + { + ivas_ism_render_sf( st_ivas, p_output_ism, *nSamplesRendered ); + } + + for ( n = 0; n < nchan_out; n++ ) + { +#ifdef OSBA_ROOM_IR + if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) +#endif + { + v_add( p_output[n], p_output_ism[n], p_output[n], *nSamplesRendered ); + } + v_multc( p_output[n], 0.5f, p_output[n], *nSamplesRendered ); + } + } + else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) /*EXT output = individual objects + HOA3*/ + { + + ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, &p_output[st_ivas->nchan_ism] ); + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + mvr2r( st_ivas->hTcBuffer->tc[n] + st_ivas->hTcBuffer->n_samples_rendered, p_output[n], *nSamplesRendered ); + } + } + else + { + ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); + } + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || + st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); + } + else /* SBA_MODE_SPAR */ + { + ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + { +#ifdef DEBUGGING + assert( st_ivas->ism_mode == ISM_MODE_NONE ); +#endif + for ( n = st_ivas->hIntSetup.nchan_out_woLFE - 1; n >= 0; n-- ) + { + mvr2r( output[n], output[n + st_ivas->nchan_ism], *nSamplesRendered ); + } + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + set_zero( output[n], *nSamplesRendered ); + } + } + } + } +#endif else if ( st_ivas->ivas_format == MC_FORMAT ) { if ( st_ivas->mc_mode == MC_MODE_MCT ) @@ -1302,7 +1586,11 @@ ivas_error ivas_jbm_dec_flush_renderer( hTcBuffer->n_samples_buffered = hTcBuffer->n_samples_granularity + n_samples_still_available; hTcBuffer->n_samples_available = 0; hTcBuffer->n_samples_flushed = n_samples_to_render; +#ifdef CR_FIX_JBM_FLUSH_OFFSET + hTcBuffer->n_samples_rendered = 0; +#else hTcBuffer->n_samples_rendered = hTcBuffer->n_samples_granularity; +#endif for ( ch_idx = 0; ch_idx < MAX_CICP_CHANNELS; ch_idx++ ) { @@ -1401,12 +1689,59 @@ ivas_error ivas_jbm_dec_flush_renderer( } } } +#ifdef JBM_FOR_OSBA + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + float *tc_local[MAX_TRANSPORT_CHANNELS]; + int16_t last_spar_md_idx; + int16_t last_dirac_md_idx; + uint16_t nSamplesAvailableNext; + + last_spar_md_idx = st_ivas->hSpar->render_to_md_map[st_ivas->hSpar->slots_rendered - 1]; + last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1]; +#ifdef DEBUGGING + assert( ism_mode_old == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ); +#endif + /* copy from ISM delay buffer to the correct place in tcs */ + for ( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ ) + { + tc_local[ch_idx] = &st_ivas->hTcBuffer->tc[ch_idx + 2][hTcBuffer->n_samples_rendered]; + mvr2r( st_ivas->hSbaIsmData->delayBuffer[ch_idx], tc_local[ch_idx], st_ivas->hSbaIsmData->delayBuffer_size ); + } + /* transfer adapted sf info from hTcBuffer to SPAR and DirAC */ + st_ivas->hSpar->nb_subframes = 1; + st_ivas->hSpar->subframes_rendered = 0; + st_ivas->hSpar->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME; + st_ivas->hSpar->slots_rendered = 0; + st_ivas->hSpar->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME; + st_ivas->hSpatParamRendCom->nb_subframes = 1; + st_ivas->hSpatParamRendCom->subframes_rendered = 0; + st_ivas->hSpatParamRendCom->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME; + st_ivas->hSpatParamRendCom->slots_rendered = 0; + st_ivas->hSpatParamRendCom->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME; + /* also adapt md maps, just use the last index */ + set_s( st_ivas->hSpar->render_to_md_map, last_spar_md_idx, n_slots_still_available ); + set_s( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available ); + /* render the last subframe */ + if ( ( error = ivas_osba_dirac_td_binaural_jbm( st_ivas, (uint16_t) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif else { return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong IVAS format in VoIP renderer flushing!" ); } +#ifdef CR_FIX_JBM_FLUSH_OFFSET + hTcBuffer->n_samples_rendered = hTcBuffer->n_samples_granularity; +#endif } +#ifdef JBM_FOR_OSBA + *nSamplesRendered = n_samples_to_render; +#endif + /* Only write out the valid data*/ #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->Opt_Limiter ) @@ -1757,6 +2092,23 @@ int16_t ivas_jbm_dec_get_num_tc_channels( } } } +#ifdef JBM_FOR_OSBA + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + if ( st_ivas->sba_dirac_stereo_flag ) + { + num_tc = CPE_CHANNELS; + } + if ( ( st_ivas->sba_planar && num_tc >= 3 ) || ( num_tc == 3 ) ) + { + num_tc++; + } + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + num_tc += st_ivas->nchan_ism; + } + } +#endif else if ( st_ivas->ivas_format == MC_FORMAT ) { if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) @@ -1958,7 +2310,12 @@ ivas_error ivas_jbm_dec_tc_buffer_open( if ( hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_NONE ) { hTcBuffer->tc_buffer = NULL; - for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) + for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS +#ifdef JBM_FOR_OSBA + + MAX_NUM_OBJECTS +#endif + ; + ch_idx++ ) { hTcBuffer->tc[ch_idx] = NULL; } @@ -1985,7 +2342,12 @@ ivas_error ivas_jbm_dec_tc_buffer_open( if ( nsamp_to_allocate == 0 ) { hTcBuffer->tc_buffer = NULL; - for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) + for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS +#ifdef JBM_FOR_OSBA + + MAX_NUM_OBJECTS +#endif + ; + ch_idx++ ) { hTcBuffer->tc[ch_idx] = NULL; } @@ -2009,7 +2371,12 @@ ivas_error ivas_jbm_dec_tc_buffer_open( hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; offset += n_samp_residual; } - for ( ; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) + for ( ; ch_idx < MAX_TRANSPORT_CHANNELS +#ifdef JBM_FOR_OSBA + + MAX_NUM_OBJECTS +#endif + ; + ch_idx++ ) { hTcBuffer->tc[ch_idx] = NULL; } @@ -2088,7 +2455,10 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( #endif /* realloc buffers */ - free( hTcBuffer->tc_buffer ); + if ( hTcBuffer->tc_buffer ) + { + free( hTcBuffer->tc_buffer ); + } if ( st_ivas->hDecoderConfig->Opt_tsm ) { n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) + hTcBuffer->n_samples_granularity - 1 ); @@ -2119,7 +2489,13 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; offset += n_samp_residual; } - for ( ; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) + for ( ; ch_idx < MAX_TRANSPORT_CHANNELS +#ifdef JBM_FOR_OSBA + + MAX_NUM_OBJECTS +#endif + + ; + ch_idx++ ) { hTcBuffer->tc[ch_idx] = NULL; } @@ -2182,7 +2558,12 @@ void ivas_jbm_dec_tc_buffer_close( if ( *phTcBuffer != NULL ) { - for ( i = 0; i < MAX_TRANSPORT_CHANNELS; i++ ) + for ( i = 0; i < MAX_TRANSPORT_CHANNELS +#ifdef JBM_FOR_OSBA + + MAX_NUM_OBJECTS +#endif + ; + i++ ) { ( *phTcBuffer )->tc[i] = NULL; } diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 2536618bb78a407dd36f203117b9a5c98eb9ac81..dfaba8a0d3139b1e68ffcc7a65e6e4a74de1aa9c 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -138,6 +138,14 @@ ivas_error ivas_td_binaural_renderer_sf( nchan_ism = st_ivas->nchan_ism; ch_offset = 2; } +#ifdef JBM_FOR_OSBA + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + nchan_ism_internal = st_ivas->nchan_ism; + nchan_ism = st_ivas->nchan_ism; + ch_offset = 0; + } +#endif else { nchan_ism_internal = st_ivas->hTcBuffer->nchan_transport_internal; diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 80a252dbd8900ea0250a800da1afb0630c35cf67..0a35e3f5e23b720c18cea2ddf88578b1758d6266 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -215,6 +215,38 @@ ivas_error ivas_sba_ism_separate_object_renderer_open( * Binaural rendering in OSBA format *--------------------------------------------------------------------------*/ +#ifdef JBM_FOR_OSBA +ivas_error ivas_osba_dirac_td_binaural_jbm( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ +) +{ + int16_t n; + ivas_error error; + + ivas_sba_dec_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailable, &output_f[2] ); + + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, output_f, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + + for ( n = 0; n < BINAURAL_CHANNELS; n++ ) + { + int16_t i; + for ( i = 0; i < nSamplesAsked; i++ ) + { + output_f[n][i] = 0.5f * output_f[2 + n][i] + 0.5f * output_f[n][i]; + } + } + + return IVAS_ERR_OK; +} +#endif + ivas_error ivas_osba_dirac_td_binaural( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output[], /* o : output synthesis signal */ @@ -255,7 +287,13 @@ ivas_error ivas_osba_dirac_td_binaural( if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { - if ( ( error = ivas_sba_upmixer_renderer( st_ivas, &output[channel_offset], output_frame ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sba_upmixer_renderer( st_ivas, +#ifdef JBM_FOR_OSBA + output, +#else + &output[channel_offset], +#endif + output_frame ) ) != IVAS_ERR_OK ) { return error; } @@ -388,19 +426,11 @@ ivas_error ivas_osba_render( { 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; + int16_t n, nchan_out, nchan_ism; ivas_error error; 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; - } #ifdef NONBE_FIX_798_OSBA_MC_DEC_CRASH for ( n = 0; n < max( nchan_out, nchan_ism ); n++ ) @@ -433,7 +463,7 @@ ivas_error ivas_osba_render( } } - if ( ( error = ivas_sba_upmixer_renderer( st_ivas, &output_f[sba_ch_idx], output_frame ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sba_upmixer_renderer( st_ivas, output_f, output_frame ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 9acaebf7a04e80ef69cb2d06937b56c3b6d8f0d4..80c06d360be14dfc3a630e739ef37c30b6bb7723 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -170,6 +170,12 @@ void ivas_renderer_select( { *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM; } +#ifdef OSBA_ROOM_IR + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && *renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + *internal_config = IVAS_AUDIO_CONFIG_7_1_4; + } +#endif if ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index e1a58a6a8ed0abd2004955c24b939e4e36b4f979..62b735f218856c01514e8cbd09b9bd944972232d 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -102,6 +102,16 @@ void ivas_sba_set_cna_cng_flag( ivas_error ivas_sba_dec_reconfigure( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#ifdef JBM_FOR_OSBA + , + uint16_t *nSamplesFlushed, /* o : number of samples flushed */ +#if defined SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ +#else + int16_t *data /* o : output synthesis signal */ +#endif +#endif ) { int16_t nchan_transport_old, nSCE_old, nCPE_old, nchan_hp20_old; @@ -114,10 +124,16 @@ ivas_error ivas_sba_dec_reconfigure( int16_t ch, nchan_out_buff, nchan_out_buff_old; #ifdef NONBE_FIX_798_OSBA_MC_DEC_CRASH int16_t sba_analysis_order_old; +#endif +#ifdef JBM_FOR_OSBA + int16_t sba_analysis_order_old_flush; #endif DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; ISM_MODE ism_mode_old; +#ifdef JBM_FOR_OSBA + int16_t granularity_new; +#endif ism_mode_old = st_ivas->ism_mode; error = IVAS_ERR_OK; @@ -125,6 +141,9 @@ ivas_error ivas_sba_dec_reconfigure( hDecoderConfig = st_ivas->hDecoderConfig; ivas_total_brate = hDecoderConfig->ivas_total_brate; last_ivas_total_brate = st_ivas->last_active_ivas_total_brate; +#ifdef JBM_FOR_OSBA + sba_analysis_order_old_flush = st_ivas->sba_analysis_order; +#endif #ifdef NONBE_FIX_798_OSBA_MC_DEC_CRASH sba_analysis_order_old = ivas_sba_get_analysis_order( last_ivas_total_brate, st_ivas->sba_order ); #endif @@ -133,6 +152,11 @@ ivas_error ivas_sba_dec_reconfigure( * Set SBA high-level parameters * Save old SBA high-level parameters *-----------------------------------------------------------------*/ +#ifdef NONBE_FIX_798_OSBA_MC_DEC_CRASH + nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, sba_analysis_order_old, last_ivas_total_brate ); +#else + nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas ); +#endif ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); nchan_hp20_old = getNumChanSynthesis( st_ivas ); @@ -156,32 +180,117 @@ ivas_error ivas_sba_dec_reconfigure( nCPE_old = st_ivas->nCPE; nchan_transport_old = st_ivas->nchan_transport; sba_dirac_stereo_flag_old = st_ivas->sba_dirac_stereo_flag; -#ifdef NONBE_FIX_798_OSBA_MC_DEC_CRASH - nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, sba_analysis_order_old, last_ivas_total_brate ); -#else - nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas ); -#endif st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); - /* save old */ - if ( st_ivas->hDirAC == NULL && st_ivas->hSpar != NULL ) +#ifdef JBM_FOR_OSBA + *nSamplesFlushed = 0; + + granularity_new = st_ivas->hTcBuffer->n_samples_granularity; + + /* we may need to flush only for binaural and OSBA and TSM */ + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { - st_ivas->hTcBuffer->num_slots = st_ivas->hSpar->num_slots; - st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpar->nb_subframes; - st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpar->slots_rendered; - st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpar->subframes_rendered; - mvs2s( st_ivas->hSpar->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + RENDERER_TYPE renderer_type_new; + int16_t sba_order_internal; + + sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); + + /* get new renderer type */ + /* copy the logic from ivas_renderer_select(), because calling this function has too many side effects that would affect the flushing */ + if ( ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) <= 2 ) + { + + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL +#ifdef SPLIT_REND_WITH_HEAD_ROT + || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) + { + renderer_type_new = RENDERER_BINAURAL_PARAMETRIC; + } + else + { + renderer_type_new = RENDERER_BINAURAL_PARAMETRIC_ROOM; + } + } + else + { + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#ifdef SPLIT_REND_WITH_HEAD_ROT + || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) + { + renderer_type_new = RENDERER_BINAURAL_FASTCONV; + } + else + { + renderer_type_new = RENDERER_BINAURAL_FASTCONV_ROOM; + } + } + /* determine new granularity */ + granularity_new = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + /* this will change anyway only with binaural */ + if ( renderer_type_new == RENDERER_BINAURAL_FASTCONV && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + granularity_new *= JBM_CLDFB_SLOTS_IN_SUBFRAME; + } + /* flush renderer on granularity change form 5ms to 1.25ms, again only possible for binaural rendering */ + + if ( granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) + { + /* write back info for correct rendering of the flushable samples */ +#ifdef JBM_FOR_OSBA + st_ivas->sba_analysis_order = sba_analysis_order_old_flush; +#else + st_ivas->sba_analysis_order = sba_analysis_order_old; +#endif + st_ivas->hDecoderConfig->ivas_total_brate = last_ivas_total_brate; + if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, granularity_new, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, st_ivas->mc_mode, ism_mode_old, nSamplesFlushed, +#ifdef SPLIT_REND_WITH_HEAD_ROT + pcm_resolution, +#endif + data ) ) != IVAS_ERR_OK ) + { + return error; + } + /* restore correct values for the current frame*/ + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); + st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; + } + else if ( granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) + { + if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } } - else if ( st_ivas->hSpatParamRendCom != NULL ) +#endif + + /* save old */ +#ifdef JBM_FOR_OSBA + if ( ism_mode_old != ISM_SBA_MODE_DISC ) +#endif { - st_ivas->hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots; - st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes; - st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; - st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; - mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + if ( st_ivas->hDirAC == NULL && st_ivas->hSpar != NULL ) // ToDo; this never happens + { + st_ivas->hTcBuffer->num_slots = st_ivas->hSpar->num_slots; + st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpar->nb_subframes; + st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpar->slots_rendered; + st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpar->subframes_rendered; + mvs2s( st_ivas->hSpar->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + } + else if ( st_ivas->hSpatParamRendCom != NULL ) + { + st_ivas->hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots; + st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes; + st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; + st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; + mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + } } - /*-----------------------------------------------------------------* * Allocate, initialize, and configure SBA handles *-----------------------------------------------------------------*/ @@ -252,12 +361,14 @@ ivas_error ivas_sba_dec_reconfigure( hSpar = st_ivas->hSpar; st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); +#ifndef JBM_FOR_OSBA /* synchronize subframe info */ st_ivas->hSpar->num_slots = st_ivas->hTcBuffer->num_slots; st_ivas->hSpar->nb_subframes = st_ivas->hTcBuffer->nb_subframes; st_ivas->hSpar->slots_rendered = st_ivas->hTcBuffer->slots_rendered; st_ivas->hSpar->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpar->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); +#endif if ( st_ivas->nchan_transport == 1 ) { @@ -299,6 +410,21 @@ ivas_error ivas_sba_dec_reconfigure( ivas_binRenderer_close( &st_ivas->hBinRenderer ); } +#ifdef JBM_FOR_OSBA + if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX && !st_ivas->hMonoDmxRenderer ) + { + if ( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + if ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX && st_ivas->hMonoDmxRenderer != NULL ) + { + free( st_ivas->hMonoDmxRenderer ); + st_ivas->hMonoDmxRenderer = NULL; + } +#endif + #ifdef NONBE_FIX_736_FOA_BR_SWITCH if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK ) { @@ -325,6 +451,7 @@ ivas_error ivas_sba_dec_reconfigure( return error; } +#ifndef JBM_FOR_OSBA /* synchronize subframe info */ if ( st_ivas->hSpatParamRendCom != NULL ) { @@ -334,6 +461,7 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } +#endif } #ifdef NONBE_FIX_736_FOA_BR_SWITCH else @@ -535,8 +663,12 @@ ivas_error ivas_sba_dec_reconfigure( /*-----------------------------------------------------------------* * JBM TC buffer *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->Opt_5ms == 1 +#ifdef JBM_FOR_OSBA + || st_ivas->ivas_format == SBA_ISM_FORMAT +#endif - if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) + ) { int16_t tc_nchan_to_allocate; int16_t tc_nchan_tc; @@ -547,17 +679,37 @@ ivas_error ivas_sba_dec_reconfigure( tc_nchan_to_allocate = tc_nchan_tc; if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) { - tc_buffer_mode = TC_BUFFER_MODE_BUFFER; - tc_nchan_tc = st_ivas->hDecoderConfig->nchan_out; - tc_nchan_to_allocate = tc_nchan_tc; +#ifdef JBM_FOR_OSBA + if ( ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO ) ) + { + tc_nchan_tc = st_ivas->hDecoderConfig->nchan_out + st_ivas->nchan_ism; + tc_nchan_to_allocate = tc_nchan_tc; + } + else +#endif + { + tc_buffer_mode = TC_BUFFER_MODE_BUFFER; + tc_nchan_tc = st_ivas->hDecoderConfig->nchan_out; + tc_nchan_to_allocate = tc_nchan_tc; + } } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS; } - else if ( st_ivas->ivas_format == SBA_FORMAT ) + else if ( st_ivas->ivas_format == SBA_FORMAT +#ifdef JBM_FOR_OSBA + || st_ivas->ivas_format == SBA_ISM_FORMAT +#endif + ) { tc_nchan_to_allocate = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); +#ifdef JBM_FOR_OSBA + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + tc_nchan_to_allocate += st_ivas->nchan_ism; + } +#endif } else { @@ -567,15 +719,52 @@ ivas_error ivas_sba_dec_reconfigure( } } - if ( tc_nchan_tc != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || tc_buffer_mode != st_ivas->hTcBuffer->tc_buffer_mode ) + if ( tc_nchan_tc != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || tc_buffer_mode != st_ivas->hTcBuffer->tc_buffer_mode +#ifdef JBM_FOR_OSBA + || granularity_new != st_ivas->hTcBuffer->n_samples_granularity +#endif + ) { - if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, +#ifdef JBM_FOR_OSBA + granularity_new +#else + NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) +#endif + ) ) != IVAS_ERR_OK ) { return error; } } } +#ifdef JBM_FOR_OSBA + /* resync SPAR and DirAC JBM info from TC Buffer */ + if ( st_ivas->hSpatParamRendCom != NULL ) + { + if ( st_ivas->hSpatParamRendCom->slot_size == st_ivas->hTcBuffer->n_samples_granularity ) + { + mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; + st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + + mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpar->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + st_ivas->hSpar->nb_subframes = st_ivas->hTcBuffer->nb_subframes; + st_ivas->hSpar->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + } + } + + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + int16_t granularityMultiplier = st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size; + int16_t n; + for ( n = 0; n < MAX_JBM_SUBFRAMES_5MS; n++ ) + { + st_ivas->hSpatParamRendCom->subframe_nbslots[n] = st_ivas->hTcBuffer->subframe_nbslots[n] * granularityMultiplier; + } + } +#endif + /*-----------------------------------------------------------------* * floating-point output audio buffers *-----------------------------------------------------------------*/ @@ -636,7 +825,11 @@ ivas_error ivas_sba_dec_digest_tc( ivas_dirac_dec_set_md_map( st_ivas, nCldfbSlots ); } - if ( st_ivas->ivas_format == SBA_FORMAT ) + if ( st_ivas->ivas_format == SBA_FORMAT +#ifdef JBM_FOR_OSBA + || st_ivas->ivas_format == SBA_ISM_FORMAT +#endif + ) { ivas_spar_dec_digest_tc( st_ivas, st_ivas->nchan_transport, nCldfbSlots, nSamplesForRendering ); } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index d52201f95020094e2fbb8b0b833e29c75e3153a8..f89e288ff4d60bb1b30004883c1d25f996c423e3 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -212,28 +212,85 @@ ivas_error ivas_spar_dec_open( /* allocate transport channels*/ if ( - st_ivas->hDecoderConfig->Opt_5ms && + ( st_ivas->hDecoderConfig->Opt_5ms +#ifdef JBM_FOR_OSBA + || st_ivas->ivas_format == SBA_ISM_FORMAT +#endif + ) && st_ivas->hTcBuffer == NULL ) { int16_t nchan_to_allocate; int16_t nchan_tc; TC_BUFFER_MODE buffer_mode; +#ifdef JBM_FOR_OSBA + int16_t granularity; +#endif buffer_mode = TC_BUFFER_MODE_RENDERER; nchan_tc = ivas_jbm_dec_get_num_tc_channels( st_ivas ); nchan_to_allocate = num_channels_internal; - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) + +#ifdef JBM_FOR_OSBA + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - buffer_mode = TC_BUFFER_MODE_BUFFER; - nchan_tc = st_ivas->hDecoderConfig->nchan_out; - nchan_to_allocate = nchan_tc; + nchan_to_allocate += st_ivas->nchan_ism; } +#endif + + +#ifdef JBM_FOR_OSBA + granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); +#endif + + if ( ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) ) + { +#ifdef JBM_FOR_OSBA + if ( ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO ) ) + { + nchan_tc = st_ivas->hDecoderConfig->nchan_out + st_ivas->nchan_ism; + nchan_to_allocate = nchan_tc; + } + else +#endif + { + buffer_mode = TC_BUFFER_MODE_BUFFER; + nchan_tc = st_ivas->hDecoderConfig->nchan_out; + nchan_to_allocate = nchan_tc; + } + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { nchan_to_allocate = 2 * BINAURAL_CHANNELS; } - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#ifdef JBM_FOR_OSBA + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + /* get correct granularity in case of binaural rendering of the discrete objects with the td obj renderer */ + granularity = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); + } +#endif + +#ifdef JBM_FOR_OSBA + /* make sure we have a TC buffer with the correct granularity for rate switching in OSBA */ + if ( !st_ivas->hDecoderConfig->Opt_5ms ) + { + nchan_tc = 0; + nchan_to_allocate = 0; + } +#endif + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, + buffer_mode, + nchan_tc, + nchan_to_allocate, + nchan_to_allocate, +#ifdef JBM_FOR_OSBA + granularity +#else + NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -1201,8 +1258,16 @@ void ivas_spar_dec_set_render_map( set_s( hSpar->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); ivas_jbm_dec_get_adapted_subframes( nCldfbTs, hSpar->subframe_nbslots, &hSpar->nb_subframes ); - st_ivas->hTcBuffer->nb_subframes = hSpar->nb_subframes; - mvs2s( hSpar->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hSpar->nb_subframes ); + /* copy also to tc buffer */ + /* only for non-combined formats and combinded formats w/o discrete objects */ +#ifdef JBM_FOR_OSBA + if ( !( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) ) +#endif + { + st_ivas->hTcBuffer->nb_subframes = hSpar->nb_subframes; + mvs2s( hSpar->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hSpar->nb_subframes ); + } + ivas_jbm_dec_get_md_map( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, 1, 0, DEFAULT_JBM_CLDFB_TIMESLOTS, hSpar->render_to_md_map ); return; @@ -1257,8 +1322,22 @@ void ivas_spar_dec_digest_tc( float *pPcm_tmp[MAX_SPAR_INTERNAL_CHANNELS]; float *p_tc[MAX_SPAR_INTERNAL_CHANNELS]; int16_t nchan_internal, ch; +#ifdef JBM_FOR_OSBA + int16_t ch_sba_idx; +#endif int16_t nSamplesLeftForTD, default_frame; +#ifdef JBM_FOR_OSBA + ch_sba_idx = 0; + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + ch_sba_idx = st_ivas->nchan_ism; + } + } +#endif + /* TD decorrelator */ default_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); nSamplesLeftForTD = nSamplesForRendering; @@ -1267,7 +1346,11 @@ void ivas_spar_dec_digest_tc( for ( ch = 0; ch < nchan_internal; ch++ ) { pPcm_tmp[ch] = Pcm_tmp[ch]; +#ifdef JBM_FOR_OSBA + p_tc[ch] = st_ivas->hTcBuffer->tc[ch + ch_sba_idx]; +#else p_tc[ch] = st_ivas->hTcBuffer->tc[ch]; +#endif } while ( nSamplesLeftForTD ) @@ -1332,18 +1415,38 @@ void ivas_spar_dec_upmixer( float *output_f_local[MAX_OUTPUT_CHANNELS]; float Pcm_tmp[MAX_OUTPUT_CHANNELS][L_FRAME48k]; float *pPcm_tmp[MAX_OUTPUT_CHANNELS]; +#ifdef JBM_FOR_OSBA + int16_t nchan_internal_total; + int16_t sba_ch_offset; +#endif hSpar = st_ivas->hSpar; nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; n_samples_sf = JBM_CLDFB_SLOTS_IN_SUBFRAME * NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); - +#ifdef JBM_FOR_OSBA + nchan_internal_total = nchan_internal; + sba_ch_offset = 0; + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + nchan_internal_total += st_ivas->nchan_ism; + sba_ch_offset = st_ivas->nchan_ism; + } +#endif for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) { +#ifdef JBM_FOR_OSBA + output_f_local[n] = output[n + sba_ch_offset]; +#else output_f_local[n] = output[n]; +#endif } +#ifdef JBM_FOR_OSBA + for ( n = 0; n < nchan_internal_total; n++ ) +#else for ( n = 0; n < nchan_internal; n++ ) +#endif { st_ivas->hTcBuffer->tc[n] = output[n]; } @@ -1361,23 +1464,39 @@ void ivas_spar_dec_upmixer( { if ( hSpar->hTdDecorr ) { +#ifdef JBM_FOR_OSBA + ivas_td_decorr_process( hSpar->hTdDecorr, output_f_local, pPcm_tmp, output_frame ); +#else ivas_td_decorr_process( hSpar->hTdDecorr, st_ivas->hTcBuffer->tc, pPcm_tmp, output_frame ); +#endif if ( hSpar->hTdDecorr->num_apd_outputs >= ( nchan_internal - nchan_transport ) ) { for ( i = 0; i < nchan_internal - nchan_transport; i++ ) { +#ifdef JBM_FOR_OSBA + mvr2r( pPcm_tmp[hSpar->hTdDecorr->num_apd_outputs - 1 - i], st_ivas->hTcBuffer->tc[nchan_internal_total - 1 - i], output_frame ); +#else mvr2r( pPcm_tmp[hSpar->hTdDecorr->num_apd_outputs - 1 - i], st_ivas->hTcBuffer->tc[nchan_internal - 1 - i], output_frame ); +#endif } } else { for ( i = 0; i < nchan_internal - nchan_transport; i++ ) { +#ifdef JBM_FOR_OSBA + set_zero( st_ivas->hTcBuffer->tc[nchan_internal_total - 1 - i], output_frame ); +#else set_zero( st_ivas->hTcBuffer->tc[nchan_internal - 1 - i], output_frame ); +#endif } for ( i = 0; i < hSpar->hTdDecorr->num_apd_outputs; i++ ) { +#ifdef JBM_FOR_OSBA + mvr2r( pPcm_tmp[hSpar->hTdDecorr->num_apd_outputs - 1 - i], st_ivas->hTcBuffer->tc[nchan_internal_total - 1 - i], output_frame ); +#else mvr2r( pPcm_tmp[hSpar->hTdDecorr->num_apd_outputs - 1 - i], st_ivas->hTcBuffer->tc[nchan_internal - 1 - i], output_frame ); +#endif } } } @@ -1400,7 +1519,11 @@ void ivas_spar_dec_upmixer( } } +#ifdef JBM_FOR_OSBA + for ( n = 0; n < nchan_internal_total; n++ ) +#else for ( n = 0; n < nchan_internal; n++ ) +#endif { st_ivas->hTcBuffer->tc[n] = NULL; } @@ -1435,15 +1558,31 @@ void ivas_spar_dec_upmixer_sf( ) { int16_t cldfb_band, num_cldfb_bands, numch_in, numch_out; - float *cldfb_in_ts_re[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX]; - float *cldfb_in_ts_im[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX]; + float *cldfb_in_ts_re[MAX_OUTPUT_CHANNELS +#ifdef OSBA_ROOM_IR + + MAX_NUM_OBJECTS +#endif + ][CLDFB_NO_COL_MAX]; + float *cldfb_in_ts_im[MAX_OUTPUT_CHANNELS +#ifdef OSBA_ROOM_IR + + MAX_NUM_OBJECTS +#endif + ][CLDFB_NO_COL_MAX]; int16_t i, b, ts, out_ch, in_ch; int16_t num_spar_bands, spar_band, nchan_transport; int16_t num_in_ingest, split_band; int16_t slot_size, slot_idx_start; - float *p_tc[MAX_OUTPUT_CHANNELS]; + float *p_tc[MAX_OUTPUT_CHANNELS +#ifdef OSBA_ROOM_IR + + MAX_NUM_OBJECTS +#endif + ]; int16_t md_idx; - float Pcm_tmp[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + float Pcm_tmp[MAX_OUTPUT_CHANNELS +#ifdef OSBA_ROOM_IR + + MAX_NUM_OBJECTS +#endif + ][L_FRAME48k]; int16_t numch_out_dirac; float mixer_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS]; int16_t b_skip_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; @@ -1463,9 +1602,35 @@ void ivas_spar_dec_upmixer_sf( num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); slot_idx_start = hSpar->slots_rendered; - for ( i = 0; i < nchan_internal; i++ ) +#ifdef JBM_FOR_OSBA + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + int16_t nchan_ism; + + nchan_ism = st_ivas->nchan_ism; + + for ( i = 0; i < nchan_internal; i++ ) + { + p_tc[i] = st_ivas->hTcBuffer->tc[i + nchan_ism] + slot_idx_start * slot_size; + } + +#ifdef OSBA_ROOM_IR + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + for ( i = 0; i < nchan_ism; i++ ) + { + p_tc[i + nchan_internal] = st_ivas->hTcBuffer->tc[i] + slot_idx_start * slot_size; + } + } +#endif + } + else +#endif { - p_tc[i] = st_ivas->hTcBuffer->tc[i] + slot_idx_start * slot_size; + for ( i = 0; i < nchan_internal; i++ ) + { + p_tc[i] = st_ivas->hTcBuffer->tc[i] + slot_idx_start * slot_size; + } } #ifdef DEBUG_SPAR_BYPASS_EVS_CODEC @@ -1536,7 +1701,12 @@ void ivas_spar_dec_upmixer_sf( if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA ) { /* at this point, output channels are used as intermediate procesing buffers */ - for ( in_ch = 0; in_ch < MAX_OUTPUT_CHANNELS; in_ch++ ) + for ( in_ch = 0; in_ch < MAX_OUTPUT_CHANNELS +#ifdef OSBA_ROOM_IR + + MAX_NUM_OBJECTS +#endif + ; + in_ch++ ) { for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { @@ -1579,9 +1749,32 @@ void ivas_spar_dec_upmixer_sf( { for ( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { - cldfbAnalysis_ts( &p_tc[in_ch][ts * num_cldfb_bands], cldfb_in_ts_re[in_ch][ts], cldfb_in_ts_im[in_ch][ts], num_cldfb_bands, st_ivas->cldfbAnaDec[in_ch] ); + cldfbAnalysis_ts( + &p_tc[in_ch][ts * num_cldfb_bands], + cldfb_in_ts_re[in_ch][ts], + cldfb_in_ts_im[in_ch][ts], + num_cldfb_bands, + st_ivas->cldfbAnaDec[in_ch] ); + } + } +#ifdef OSBA_ROOM_IR + if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + int16_t nchan_all = st_ivas->nchan_ism + numch_in; + for ( ; in_ch < nchan_all; in_ch++ ) + { + for ( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) + { + cldfbAnalysis_ts( + &p_tc[in_ch][ts * num_cldfb_bands], + cldfb_in_ts_re[in_ch][ts], + cldfb_in_ts_im[in_ch][ts], + num_cldfb_bands, + st_ivas->cldfbAnaDec[in_ch] ); + } } } +#endif if ( ( hDecoderConfig->ivas_total_brate < IVAS_24k4 ) && ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 ) || ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) ) ) { @@ -1706,12 +1899,16 @@ void ivas_spar_dec_upmixer_sf( } else { - if ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA || - !( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB + if ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA || + !( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB #ifdef SPLIT_REND_WITH_HEAD_ROT - || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM + || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) ) +#ifdef OSBA_ROOM_IR + && !( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) #endif - ) ) + ) { for ( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index f17262b50bcd030552a4989f1d69ba47859e377c..b255b6085eedf81417c6eadae253ad061932d03a 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -953,16 +953,20 @@ typedef struct ivas_masa_ism_data_structure typedef struct decoder_tc_buffer_structure { - float *tc_buffer; /* the buffer itself */ - float *tc[MAX_TRANSPORT_CHANNELS]; /* pointers into the buffer to the beginning of each tc */ - TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ - int16_t nchan_transport_jbm; /* number of TCs after TC decoding */ - int16_t nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */ - int16_t nchan_buffer_full; /* number of channels to be fully buffered */ - int16_t n_samples_available; /* samples still available for rendering in the current frame */ - int16_t n_samples_buffered; /* full number of samples in the buffer (including spill to next frame) */ - int16_t n_samples_rendered; /* samples already rendered in the current frame */ - int16_t n_samples_granularity; /* render granularity */ + float *tc_buffer; /* the buffer itself */ + float *tc[MAX_TRANSPORT_CHANNELS +#ifdef JBM_FOR_OSBA + + MAX_NUM_OBJECTS +#endif + ]; /* pointers into the buffer to the beginning of each tc */ + TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ + int16_t nchan_transport_jbm; /* number of TCs after TC decoding */ + int16_t nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */ + int16_t nchan_buffer_full; /* number of channels to be fully buffered */ + int16_t n_samples_available; /* samples still available for rendering in the current frame */ + int16_t n_samples_buffered; /* full number of samples in the buffer (including spill to next frame) */ + int16_t n_samples_rendered; /* samples already rendered in the current frame */ + int16_t n_samples_granularity; /* render granularity */ int16_t n_samples_flushed; int16_t subframe_nbslots[MAX_JBM_SUBFRAMES_5MS]; int16_t nb_subframes; diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 3d57a7f2199d4cf3677521fe78ea3b0a26b9c5cc..efe23f0b5f685c9389e41c3236e2173819eb5b99 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -388,7 +388,12 @@ int16_t ivas_get_nchan_buffers_dec( nchan_out_buff = st_ivas->hDecoderConfig->nchan_out + st_ivas->nchan_ism; /*take into account sba_ch_idx' in ivas_dec() */ } #ifdef NONBE_FIX_798_OSBA_MC_DEC_CRASH - nchan_out_buff = max( nchan_out_buff, nchan_internal + st_ivas->nchan_ism ); +#ifdef JBM_FOR_OSBA + if ( !( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) ) +#endif + { + nchan_out_buff = max( nchan_out_buff, nchan_internal + st_ivas->nchan_ism ); + } #endif nchan_out_buff = min( nchan_out_buff, MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ); } diff --git a/scripts/config/ci_linux.json b/scripts/config/ci_linux.json index f7d6c4ec4b2059561672f53262a3ad49585efb28..33d46408b4193988d840995c876636d1d7c88b58 100644 --- a/scripts/config/ci_linux.json +++ b/scripts/config/ci_linux.json @@ -36,6 +36,18 @@ "OMASA_ISM4_1TC1DIR": "/usr/local/testv/stvOMASA_4ISM_1MASA1TC48c.wav", "OMASA_ISM4_1TC2DIR": "/usr/local/testv/stvOMASA_4ISM_2MASA1TC48c.wav", "OMASA_ISM4_2TC1DIR": "/usr/local/testv/stvOMASA_4ISM_1MASA2TC48c.wav", - "OMASA_ISM4_2TC2DIR": "/usr/local/testv/stvOMASA_4ISM_2MASA2TC48c.wav" + "OMASA_ISM4_2TC2DIR": "/usr/local/testv/stvOMASA_4ISM_2MASA2TC48c.wav", + "OSBA_ISM1_FOA": "/usr/local/testv/stvOSBA_1ISM_FOA48c.wav", + "OSBA_ISM1_HOA2": "/usr/local/testv/stvOSBA_1ISM_2OA48c.wav", + "OSBA_ISM1_HOA3": "/usr/local/testv/stvOSBA_1ISM_3OA48c.wav", + "OSBA_ISM2_FOA": "/usr/local/testv/stvOSBA_2ISM_FOA48c.wav", + "OSBA_ISM2_HOA2": "/usr/local/testv/stvOSBA_2ISM_2OA48c.wav", + "OSBA_ISM2_HOA3": "/usr/local/testv/stvOSBA_2ISM_3OA48c.wav", + "OSBA_ISM3_FOA": "/usr/local/testv/stvOSBA_3ISM_FOA48c.wav", + "OSBA_ISM3_HOA2": "/usr/local/testv/stvOSBA_3ISM_2OA48c.wav", + "OSBA_ISM3_HOA3": "/usr/local/testv/stvOSBA_3ISM_3OA48c.wav", + "OSBA_ISM4_FOA": "/usr/local/testv/stvOSBA_4ISM_FOA48c.wav", + "OSBA_ISM4_HOA2": "/usr/local/testv/stvOSBA_4ISM_2OA48c.wav", + "OSBA_ISM4_HOA3": "/usr/local/testv/stvOSBA_4ISM_3OA48c.wav" } } diff --git a/scripts/config/ivas_modes.json b/scripts/config/ivas_modes.json index e632c4c215a0e16844b18e1bd37ea4b328991a95..702413a58bd44648bcb8b2ec495723634145d111 100644 --- a/scripts/config/ivas_modes.json +++ b/scripts/config/ivas_modes.json @@ -3137,7 +3137,7 @@ "EXT": [] }, "in_config": "ISM1", - "table_name": "ISM1@{table_bitrate} RS kbps {bandwidth}", + "table_name": "ISM1@{table_bitrate} RS {bandwidth}", "nummetadata": 1, "metadatafilenames": [ "stvISM{mdi}.csv" @@ -6121,5 +6121,1387 @@ ] } } + }, + "OSBA": { + "OSBA_ISM1_HOA3_b{bitrate}_{bandwidth}_cbr": { + "encmodeoption": [ + "-ism_sba", + "1", + "3" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM1_HOA3", + "table_name": "OSBA ISM1 HOA3@{table_bitrate} kbps {bandwidth}", + "nummetadata": 1, + "metadatafilenames": [ + "{item}_ISM1.csv" + ], + "rs": false, + "amr": false, + "mono": false, + "bitrates": { + "wb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "swb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "fb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ] + } + }, + "OSBA_ISM1_HOA2_b{bitrate}_{bandwidth}_cbr": { + "encmodeoption": [ + "-ism_sba", + "1", + "2" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM1_HOA2", + "table_name": "OSBA ISM1 HOA2@{table_bitrate} kbps {bandwidth}", + "nummetadata": 1, + "metadatafilenames": [ + "{item}_ISM1.csv" + ], + "rs": false, + "amr": false, + "mono": false, + "bitrates": { + "wb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "swb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "fb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ] + } + }, + "OSBA_ISM1_FOA_b{bitrate}_{bandwidth}_cbr": { + "encmodeoption": [ + "-ism_sba", + "1", + "1" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM1_FOA", + "table_name": "OSBA ISM1 FOA@{table_bitrate} kbps {bandwidth}", + "nummetadata": 1, + "metadatafilenames": [ + "{item}_ISM1.csv" + ], + "rs": false, + "amr": false, + "mono": false, + "bitrates": { + "wb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "swb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "fb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ] + } + }, + "OSBA_ISM2_HOA3_b{bitrate}_{bandwidth}_cbr": { + "encmodeoption": [ + "-ism_sba", + "2", + "3" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM2_HOA3", + "table_name": "OSBA ISM2 HOA3@{table_bitrate} kbps {bandwidth}", + "nummetadata": 2, + "metadatafilenames": [ + "{item}_ISM1.csv", + "{item}_ISM2.csv" + ], + "rs": false, + "amr": false, + "mono": false, + "bitrates": { + "wb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "swb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "fb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ] + } + }, + "OSBA_ISM2_HOA2_b{bitrate}_{bandwidth}_cbr": { + "encmodeoption": [ + "-ism_sba", + "2", + "2" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM2_HOA2", + "table_name": "OSBA ISM2 HOA2@{table_bitrate} kbps {bandwidth}", + "nummetadata": 2, + "metadatafilenames": [ + "{item}_ISM1.csv", + "{item}_ISM2.csv" + ], + "rs": false, + "amr": false, + "mono": false, + "bitrates": { + "wb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "swb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "fb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ] + } + }, + "OSBA_ISM2_FOA_b{bitrate}_{bandwidth}_cbr": { + "encmodeoption": [ + "-ism_sba", + "2", + "1" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM2_FOA", + "table_name": "OSBA ISM2 FOA@{table_bitrate} kbps {bandwidth}", + "nummetadata": 2, + "metadatafilenames": [ + "{item}_ISM1.csv", + "{item}_ISM2.csv" + ], + "rs": false, + "amr": false, + "mono": false, + "bitrates": { + "wb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "swb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "fb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ] + } + }, + "OSBA_ISM3_HOA3_b{bitrate}_{bandwidth}_cbr": { + "encmodeoption": [ + "-ism_sba", + "3", + "3" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM3_HOA3", + "table_name": "OSBA ISM3 HOA3@{table_bitrate} kbps {bandwidth}", + "nummetadata": 3, + "metadatafilenames": [ + "{item}_ISM1.csv", + "{item}_ISM2.csv", + "{item}_ISM3.csv" + ], + "rs": false, + "amr": false, + "mono": false, + "bitrates": { + "wb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "swb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "fb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ] + } + }, + "OSBA_ISM3_HOA2_b{bitrate}_{bandwidth}_cbr": { + "encmodeoption": [ + "-ism_sba", + "3", + "2" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM3_HOA2", + "table_name": "OSBA ISM3 HOA2@{table_bitrate} kbps {bandwidth}", + "nummetadata": 3, + "metadatafilenames": [ + "{item}_ISM1.csv", + "{item}_ISM2.csv", + "{item}_ISM3.csv" + ], + "rs": false, + "amr": false, + "mono": false, + "bitrates": { + "wb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "swb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "fb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ] + } + }, + "OSBA_ISM3_FOA_b{bitrate}_{bandwidth}_cbr": { + "encmodeoption": [ + "-ism_sba", + "3", + "1" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM3_FOA", + "table_name": "OSBA ISM3 FOA@{table_bitrate} kbps {bandwidth}", + "nummetadata": 3, + "metadatafilenames": [ + "{item}_ISM1.csv", + "{item}_ISM2.csv", + "{item}_ISM3.csv" + ], + "rs": false, + "amr": false, + "mono": false, + "bitrates": { + "wb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "swb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "fb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ] + } + }, + "OSBA_ISM4_HOA3_b{bitrate}_{bandwidth}_cbr": { + "encmodeoption": [ + "-ism_sba", + "4", + "3" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM4_HOA3", + "table_name": "OSBA ISM4 HOA3@{table_bitrate} kbps {bandwidth}", + "nummetadata": 4, + "metadatafilenames": [ + "{item}_ISM1.csv", + "{item}_ISM2.csv", + "{item}_ISM3.csv", + "{item}_ISM4.csv" + ], + "rs": false, + "amr": false, + "mono": false, + "bitrates": { + "wb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "swb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "fb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ] + } + }, + "OSBA_ISM4_HOA2_b{bitrate}_{bandwidth}_cbr": { + "encmodeoption": [ + "-ism_sba", + "4", + "2" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM4_HOA2", + "table_name": "OSBA ISM4 HOA2@{table_bitrate} kbps {bandwidth}", + "nummetadata": 4, + "metadatafilenames": [ + "{item}_ISM1.csv", + "{item}_ISM2.csv", + "{item}_ISM3.csv", + "{item}_ISM4.csv" + ], + "rs": false, + "amr": false, + "mono": false, + "bitrates": { + "wb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "swb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "fb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ] + } + }, + "OSBA_ISM4_FOA_b{bitrate}_{bandwidth}_cbr": { + "encmodeoption": [ + "-ism_sba", + "4", + "1" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM4_FOA", + "table_name": "OSBA ISM4 FOA@{table_bitrate} kbps {bandwidth}", + "nummetadata": 4, + "metadatafilenames": [ + "{item}_ISM1.csv", + "{item}_ISM2.csv", + "{item}_ISM3.csv", + "{item}_ISM4.csv" + ], + "rs": false, + "amr": false, + "mono": false, + "bitrates": { + "wb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "swb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ], + "fb": [ + 13200, + 16400, + 24400, + 32000, + 48000, + 64000, + 80000, + 96000, + 128000, + 192000, + 256000, + 384000, + 512000 + ] + } + }, + "OSBA_ISM1_HOA3_b{bitrate}_{bandwidth}_rs": { + "encmodeoption": [ + "-ism_sba", + "1", + "3" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM1_HOA3", + "table_name": "OSBA ISM1 HOA3 RS {bandwidth}", + "nummetadata": 1, + "metadatafilenames": [ + "{item}_ISM1.csv" + ], + "rs": true, + "amr": false, + "mono": false, + "bitrates": { + "wb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "swb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "fb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + } + } + }, + "OSBA_ISM1_HOA2_b{bitrate}_{bandwidth}_rs": { + "encmodeoption": [ + "-ism_sba", + "1", + "2" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM1_HOA2", + "table_name": "OSBA ISM1 HOA2 RS {bandwidth}", + "nummetadata": 1, + "metadatafilenames": [ + "{item}_ISM1.csv" + ], + "rs": true, + "amr": false, + "mono": false, + "bitrates": { + "wb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "swb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "fb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + } + } + }, + "OSBA_ISM1_FOA_b{bitrate}_{bandwidth}_rs": { + "encmodeoption": [ + "-ism_sba", + "1", + "1" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM1_FOA", + "table_name": "OSBA ISM1 FOA RS {bandwidth}", + "nummetadata": 1, + "metadatafilenames": [ + "{item}_ISM1.csv" + ], + "rs": true, + "amr": false, + "mono": false, + "bitrates": { + "wb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "swb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "fb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + } + } + }, + "OSBA_ISM2_HOA3_b{bitrate}_{bandwidth}_rs": { + "encmodeoption": [ + "-ism_sba", + "2", + "3" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM2_HOA3", + "table_name": "OSBA ISM2 HOA RS {bandwidth}", + "nummetadata": 2, + "metadatafilenames": [ + "{item}_ISM1.csv", + "{item}_ISM2.csv" + ], + "rs": true, + "amr": false, + "mono": false, + "bitrates": { + "wb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "swb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "fb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + } + } + }, + "OSBA_ISM2_HOA2_b{bitrate}_{bandwidth}_rs": { + "encmodeoption": [ + "-ism_sba", + "2", + "2" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM2_HOA2", + "table_name": "OSBA ISM2 HOA2 RS {bandwidth}", + "nummetadata": 2, + "metadatafilenames": [ + "{item}_ISM1.csv", + "{item}_ISM2.csv" + ], + "rs": true, + "amr": false, + "mono": false, + "bitrates": { + "wb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "swb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "fb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + } + } + }, + "OSBA_ISM2_FOA_b{bitrate}_{bandwidth}_rs": { + "encmodeoption": [ + "-ism_sba", + "2", + "1" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM2_FOA", + "table_name": "OSBA ISM2 FOA RS {bandwidth}", + "nummetadata": 2, + "metadatafilenames": [ + "{item}_ISM1.csv", + "{item}_ISM2.csv" + ], + "rs": true, + "amr": false, + "mono": false, + "bitrates": { + "wb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "swb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "fb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + } + } + }, + "OSBA_ISM3_HOA3_b{bitrate}_{bandwidth}_rs": { + "encmodeoption": [ + "-ism_sba", + "3", + "3" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM3_HOA3", + "table_name": "OSBA ISM3 HOA3 RS {bandwidth}", + "nummetadata": 3, + "metadatafilenames": [ + "{item}_ISM1.csv", + "{item}_ISM2.csv", + "{item}_ISM3.csv" + ], + "rs": true, + "amr": false, + "mono": false, + "bitrates": { + "wb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "swb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "fb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + } + } + }, + "OSBA_ISM3_HOA2_b{bitrate}_{bandwidth}_rs": { + "encmodeoption": [ + "-ism_sba", + "3", + "2" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM3_HOA2", + "table_name": "OSBA ISM3 HOA2 RS {bandwidth}", + "nummetadata": 3, + "metadatafilenames": [ + "{item}_ISM1.csv", + "{item}_ISM2.csv", + "{item}_ISM3.csv" + ], + "rs": true, + "amr": false, + "mono": false, + "bitrates": { + "wb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "swb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "fb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + } + } + }, + "OSBA_ISM3_FOA_b{bitrate}_{bandwidth}_rs": { + "encmodeoption": [ + "-ism_sba", + "3", + "1" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM3_FOA", + "table_name": "OSBA ISM3 FOA RS {bandwidth}", + "nummetadata": 3, + "metadatafilenames": [ + "{item}_ISM1.csv", + "{item}_ISM2.csv", + "{item}_ISM3.csv" + ], + "rs": true, + "amr": false, + "mono": false, + "bitrates": { + "wb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "swb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "fb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + } + } + }, + "OSBA_ISM4_HOA3_b{bitrate}_{bandwidth}_rs": { + "encmodeoption": [ + "-ism_sba", + "4", + "3" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM4_HOA3", + "table_name": "OSBA ISM4 HOA3 RS {bandwidth}", + "nummetadata": 4, + "metadatafilenames": [ + "{item}_ISM1.csv", + "{item}_ISM2.csv", + "{item}_ISM3.csv", + "{item}_ISM4.csv" + ], + "rs": true, + "amr": false, + "mono": false, + "bitrates": { + "wb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "swb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "fb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + } + } + }, + "OSBA_ISM4_HOA2_b{bitrate}_{bandwidth}_rs": { + "encmodeoption": [ + "-ism_sba", + "4", + "2" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM4_HOA2", + "table_name": "OSBA ISM4 HOA2 RS {bandwidth}", + "nummetadata": 4, + "metadatafilenames": [ + "{item}_ISM1.csv", + "{item}_ISM2.csv", + "{item}_ISM3.csv", + "{item}_ISM4.csv" + ], + "rs": true, + "amr": false, + "mono": false, + "bitrates": { + "wb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "swb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "fb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + } + } + }, + "OSBA_ISM4_FOA_b{bitrate}_{bandwidth}_rs": { + "encmodeoption": [ + "-ism_sba", + "4", + "1" + ], + "encoptions": [ + "-max_band", + "{bandwidth}" + ], + "dec": { + "7_1_4": [], + "HOA3": [], + "mono": [], + "stereo": [], + "EXT": [] + }, + "in_config": "OSBA_ISM4_FOA", + "table_name": "OSBA ISM4 FOA RS {bandwidth}", + "nummetadata": 4, + "metadatafilenames": [ + "{item}_ISM1.csv", + "{item}_ISM2.csv", + "{item}_ISM3.csv", + "{item}_ISM4.csv" + ], + "rs": true, + "amr": false, + "mono": false, + "bitrates": { + "wb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "swb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + }, + "fb": { + "all": "{sw_files_path}/sw_13k2_512k.bin" + } + } + } } } diff --git a/scripts/prepare_combined_format_inputs.py b/scripts/prepare_combined_format_inputs.py index b8ad68557986fea358918580dd886e118749c990..f51da80db9c5a2c098eaa48fc1afea7c95b3ad60 100755 --- a/scripts/prepare_combined_format_inputs.py +++ b/scripts/prepare_combined_format_inputs.py @@ -65,6 +65,13 @@ masa_alts = ({'masa_meta_file': 'stv2MASA2TC48c.met', 'masa_audio_file': 'stv1MASA1TC48c.wav', 'masa_tag': '1MASA1TC'}) +sba_alts = ({'sba_audio_file': 'stvFOA48c.wav', + 'sba_tag': 'FOA'}, + {'sba_audio_file': 'stv2OA48c.wav', + 'sba_tag': '2OA'}, + {'sba_audio_file': 'stv3OA48c.wav', + 'sba_tag': '3OA'}) + # files containing 1-4 ISMs as channels ism_files = ('stv1ISM48s.wav', 'stv2ISM48s.wav', 'stv3ISM48s.wav', 'stv4ISM48s.wav') # per-object metadata @@ -100,6 +107,25 @@ for enum_idx, (ism_audio_file, ism_meta_file) in enumerate(zip(ism_files, ism_me if not os.path.exists(masa_meta_name) or force_overwrite: shutil.copyfile(os.path.join(input_dir, masa_item['masa_meta_file']), masa_meta_name) wrote_files.append(masa_meta_name) + for sba_item in sba_alts: + sba_tag = sba_item['sba_tag'] + + osba_file_body = f'stvOSBA_{n_isms}ISM_{sba_tag}48c' + osba_file = os.path.join(output_dir, f'{osba_file_body}.wav') + + if not os.path.exists(osba_file) or force_overwrite: + audiofile.combinefiles(in_filenames=[os.path.join(input_dir, ism_audio_file), + os.path.join(input_dir, sba_item['sba_audio_file'])], + out_file=osba_file) + wrote_files.append(osba_file) + + # copy ISM metadata files under names matching the combined file + for ism_idx in range(n_isms): + ism_file_name = os.path.join(output_dir, f'{osba_file_body}_ISM{ism_idx+1}{os.path.splitext(ism_meta_file)[1]}') + if not os.path.exists(ism_file_name) or force_overwrite: + shutil.copyfile(os.path.join(input_dir, ism_meta_file), ism_file_name) + wrote_files.append(ism_file_name) + # info print. helps setting up .gitignore if len(wrote_files) > 0: diff --git a/scripts/pyaudio3dtools/spatialaudioformat.py b/scripts/pyaudio3dtools/spatialaudioformat.py index 524e4d61f50fe50d05f75093be563b015f0468e9..0375063cc6ef562285997234a65127029ff53e21 100644 --- a/scripts/pyaudio3dtools/spatialaudioformat.py +++ b/scripts/pyaudio3dtools/spatialaudioformat.py @@ -356,6 +356,151 @@ _format_configs = { "lfe_index": [], "altname": "meta", }, + # OSBA Formats + "OSBA_ISM1_HOA3": + { + "name": "OSBA_ISM1_HOA3", + "ambi_order": 3, + "isplanar": False, + "nchannels": 17, + "isloudspeaker": False, + "isheadphones": False, + "lfe_index": [], + "altname": "osba3_ism1", + + }, + "OSBA_ISM1_HOA2": + { + "name": "OSBA_ISM1_HOA2", + "ambi_order": 2, + "isplanar": False, + "nchannels": 10, + "isloudspeaker": False, + "isheadphones": False, + "lfe_index": [], + "altname": "osba2_ism1", + + }, + "OSBA_ISM1_FOA": + { + "name": "OSBA_ISM1_FOA", + "ambi_order": 1, + "isplanar": False, + "nchannels": 5, + "isloudspeaker": False, + "isheadphones": False, + "lfe_index": [], + "altname": "osba1_ism1", + + }, + "OSBA_ISM2_HOA3": + { + "name": "OSBA_ISM2_HOA3", + "ambi_order": 3, + "isplanar": False, + "nchannels": 18, + "isloudspeaker": False, + "isheadphones": False, + "lfe_index": [], + "altname": "osba3_ism2", + + }, + "OSBA_ISM2_HOA2": + { + "name": "OSBA_ISM2_HOA2", + "ambi_order": 2, + "isplanar": False, + "nchannels": 11, + "isloudspeaker": False, + "isheadphones": False, + "lfe_index": [], + "altname": "osba2_ism2", + + }, + "OSBA_ISM2_FOA": + { + "name": "OSBA_ISM2_FOA", + "ambi_order": 1, + "isplanar": False, + "nchannels": 6, + "isloudspeaker": False, + "isheadphones": False, + "lfe_index": [], + "altname": "osba1_ism2", + + }, + "OSBA_ISM3_HOA3": + { + "name": "OSBA_ISM3_HOA3", + "ambi_order": 3, + "isplanar": False, + "nchannels": 19, + "isloudspeaker": False, + "isheadphones": False, + "lfe_index": [], + "altname": "osba3_ism3", + + }, + "OSBA_ISM3_HOA2": + { + "name": "OSBA_ISM3_HOA2", + "ambi_order": 2, + "isplanar": False, + "nchannels": 12, + "isloudspeaker": False, + "isheadphones": False, + "lfe_index": [], + "altname": "osba2_ism3", + + }, + "OSBA_ISM3_FOA": + { + "name": "OSBA_ISM3_FOA", + "ambi_order": 1, + "isplanar": False, + "nchannels": 7, + "isloudspeaker": False, + "isheadphones": False, + "lfe_index": [], + "altname": "osba1_ism3", + + }, + "OSBA_ISM4_HOA3": + { + "name": "OSBA_ISM4_HOA3", + "ambi_order": 3, + "isplanar": False, + "nchannels": 20, + "isloudspeaker": False, + "isheadphones": False, + "lfe_index": [], + "altname": "osba3_ism4", + + }, + "OSBA_ISM4_HOA2": + { + "name": "OSBA_ISM4_HOA2", + "ambi_order": 2, + "isplanar": False, + "nchannels": 13, + "isloudspeaker": False, + "isheadphones": False, + "lfe_index": [], + "altname": "osba2_ism4", + + }, + "OSBA_ISM4_FOA": + { + "name": "OSBA_ISM4_FOA", + "ambi_order": 1, + "isplanar": False, + "nchannels": 8, + "isloudspeaker": False, + "isheadphones": False, + "lfe_index": [], + "altname": "osba1_ism4", + + }, } # Channel indices of planar Ambisonic components of ACN diff --git a/scripts/pyivastest/IvasModeRunner.py b/scripts/pyivastest/IvasModeRunner.py index 16aed2b923b30f49a2a843a0cb0bb47d48ba86c7..c39ef36485d5a1b51bcc33e461572bcc794ef4cf 100644 --- a/scripts/pyivastest/IvasModeRunner.py +++ b/scripts/pyivastest/IvasModeRunner.py @@ -530,6 +530,13 @@ class IvasModeRunner(IvasModeCollector.IvasModeCollector): if config["cmd"]["in_config"] == "SBA": wav_info = af.get_wav_file_info(in_file_name_transformed) in_format = spformat.detect_format(wav_info["channels"]) + elif config["cmd"]["in_config"][0:4] == "OSBA": + # get number of ISMs expected + osba_ism_config = config["cmd"]["in_config"][5:9] + osba_ism_format_dict = spformat.get_format_dict(osba_ism_config) + wav_info = af.get_wav_file_info(in_file_name_transformed) + osba_ambi_config = spformat.detect_format(wav_info["channels"] - osba_ism_format_dict["nchannels"]) + in_format = f"OSBA_{osba_ism_config}_{osba_ambi_config}" # save in config as json file in_format_dict = spformat.get_format_dict(in_format)