diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index f226e5d95f6be98e4bb9bdb429f6d3c1c1cc8200..d829fa95d1970edbe3ed502527dfd26cc1944697 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1005,12 +1005,20 @@ Word16 IGF_MapBitRateToIndex( const Word16 rf_mode /* i : flag to signal the RF mode */ ); +#ifdef NONBE_1303_REND_GRANULARITY +Word16 ivas_jbm_dec_get_render_granularity_fx( + const RENDERER_TYPE renderer_type, /* i : renderer type */ + const RENDERER_TYPE renderer_type_sec, /* i : secondary renderer type */ + const int32_t output_Fs /* i : sampling rate */ +); +#else Word16 ivas_jbm_dec_get_render_granularity( const RENDERER_TYPE rendererType, /* i : renderer type */ const IVAS_FORMAT ivas_format, /* i : ivas format */ const MC_MODE mc_mode, /* i : MC mode */ const Word32 output_Fs /* i : sampling rate */ -); +); +#endif // ivas_stereo_dft_com.c void stereo_dft_config_fx( @@ -6252,7 +6260,7 @@ void ivas_renderer_select( #ifdef FIX_CREND_SIMPLIFY_CODE /*! r: secondary binaural renderer type */ -RENDERER_TYPE ivas_renderer_secondary_select( +RENDERER_TYPE ivas_renderer_secondary_select_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); #endif @@ -6275,15 +6283,15 @@ int16_t is_DTXrate( * JBM prototypes *----------------------------------------------------------------------------------*/ -ivas_error ivas_jbm_dec_set_discard_samples( +ivas_error ivas_jbm_dec_set_discard_samples_fx( Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ ); -TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( +TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode_fx( Decoder_Struct *st_ivas /* i : IVAS decoder handle */ ); -void ivas_jbm_dec_tc_buffer_close( +void ivas_jbm_dec_tc_buffer_close_fx( DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ); diff --git a/lib_com/options.h b/lib_com/options.h index 9867a2e8c9f37fd79bc39083c4683d890aa212ca..ee7d3b168d2ac849431cca3b4d6f61c7ee0318df 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -160,6 +160,7 @@ #define FIX_1384_MSAN_stereo_tcx_core_enc /* VA: issue 1384: fix use-of-uninitialized value in stereo_tcx_core_enc() */ #define NONBE_FIX_1297_SPAR_JBM_MEM_SAN /* Dolby: issue 1297, SPAR + JBM + BR switch memory sanitizer */ #define NONBE_1303_GRANULARITY_OSBA_REND /* VA: issue 1303: Correctly set the granularity in OSBA, Disc mode, and BINAURAL_ROOM_REVERB output */ +#define NONBE_1303_REND_GRANULARITY /* VA: issue 1303: Renderer granularity revision */ // object-editing feature porting #define OBJ_EDITING_API /* object editing changes related to the API */ diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 11fed28cb0ecbb511582a149a4b87ec627404007..80beb0ceae3465d19272fcd27f544aaafbaf123e 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -2661,7 +2661,7 @@ ivas_error ivas_init_decoder_fx( return error; } } - +#ifndef NONBE_1303_REND_GRANULARITY granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); @@ -2671,6 +2671,7 @@ ivas_error ivas_init_decoder_fx( { return error; } +#endif } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) ) { @@ -2720,7 +2721,7 @@ ivas_error ivas_init_decoder_fx( st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; move32(); - +#ifndef NONBE_1303_REND_GRANULARITY test(); IF( ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) && ( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) ) { @@ -2743,6 +2744,7 @@ ivas_error ivas_init_decoder_fx( return error; } } +#endif } IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) @@ -2781,7 +2783,7 @@ ivas_error ivas_init_decoder_fx( IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { - IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, output_Fs ) ), IVAS_ERR_OK ) ) { return error; } @@ -3029,9 +3031,16 @@ ivas_error ivas_init_decoder_fx( IF( st_ivas->hTcBuffer == NULL ) { /* no module has yet open the TC buffer, open a default one */ +#ifdef NONBE_1303_REND_GRANULARITY + granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), output_Fs ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode_fx( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ), IVAS_ERR_OK ) ) +#else + n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); + + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode_fx( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -3551,7 +3560,7 @@ void ivas_destroy_dec_fx( st_ivas->hDecoderConfig = NULL; } - ivas_jbm_dec_tc_buffer_close( &st_ivas->hTcBuffer ); + ivas_jbm_dec_tc_buffer_close_fx( &st_ivas->hTcBuffer ); IF( st_ivas->hJbmMetadata != NULL ) { diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index 63609317d01f7e41b5a51b96064e694003afe690..a9dec850d9e9ccefde10a93caf71a9348cc4735f 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -171,7 +171,11 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv render what still fits in the new granularity */ - tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); +#ifdef NONBE_1303_REND_GRANULARITY + tc_granularity_new = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); +#else + tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); +#endif IF( LT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { @@ -199,7 +203,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ ELSE IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { - IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -374,7 +378,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( DECODER_TC_BUFFER_HANDLE hTcBuffer; hTcBuffer = st_ivas->hTcBuffer; - tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); + tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode_fx( st_ivas ); tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); tc_nchan_allocate_new = tc_nchan_tc_new; move16(); diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 973d726b0b8a8f54d4236c3cec4d7842d0269f24..89d4f101d62cd19842893e9be4691a43f9b464b7 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -584,7 +584,11 @@ ivas_error ivas_param_ism_dec_open_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { +#ifdef NONBE_1303_REND_GRANULARITY + Word16 i, granularity; +#else Word16 i; +#endif PARAM_ISM_DEC_HANDLE hParamIsmDec; IVAS_OUTPUT_SETUP hOutSetup; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; @@ -747,6 +751,9 @@ ivas_error ivas_param_ism_dec_open_fx( st_ivas->hParamIsmDec = hParamIsmDec; st_ivas->hSpatParamRendCom = hSpatParamRendCom; +#ifdef NONBE_1303_REND_GRANULARITY + granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); +#endif test(); IF( NE_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) && NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) ) @@ -793,8 +800,11 @@ ivas_error ivas_param_ism_dec_open_fx( IF( st_ivas->hTcBuffer == NULL ) { +#ifdef NONBE_1303_REND_GRANULARITY + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, granularity ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) - +#endif { return error; } @@ -807,8 +817,12 @@ ivas_error ivas_param_ism_dec_open_fx( IF( st_ivas->hTcBuffer == NULL ) { Word16 nchan_to_allocate = st_ivas->hDecoderConfig->nchan_out; +#ifdef NONBE_1303_REND_GRANULARITY + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) ) +#else move16(); // NS2SA IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_BUFFER, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) +#endif { return error; } diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 48580801d892e11c1159ed259a801d403fdf77ab..3976a511baeafe8fe60dbf933a00f7d9221c4332 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -3102,7 +3102,7 @@ return IVAS_ERR_OK; * Set number of samples to discard in the first subframe if the renderer granularity changes on a bitrate change *--------------------------------------------------------------------------*/ -ivas_error ivas_jbm_dec_set_discard_samples( +ivas_error ivas_jbm_dec_set_discard_samples_fx( Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ ) { @@ -3616,8 +3616,37 @@ static void ivas_jbm_dec_copy_tc( *--------------------------------------------------------------------------*/ /*! r: render granularity */ +#ifdef NONBE_1303_REND_GRANULARITY +Word16 ivas_jbm_dec_get_render_granularity_fx( + const RENDERER_TYPE renderer_type, /* i : renderer type */ + const RENDERER_TYPE renderer_type_sec, /* i : secondary renderer type */ + const int32_t output_Fs /* i : sampling rate */ +) +{ + Word16 render_granularity; + test(); + test(); + test(); + IF( EQ_32( renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) || /* TD renderer */ + EQ_32( renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_32( renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) || /* Crend */ + EQ_32( renderer_type_sec, RENDERER_BINAURAL_OBJECTS_TD ) /* TD rend as a secondary renderer -> set the common granularity for both renderers */ + ) + { + /* 5 ms granularity */ + render_granularity = NS2SA_FX2( output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); + move16(); + } + ELSE + { + /* 1.25 ms granularity */ + render_granularity = NS2SA_FX2( output_Fs, CLDFB_SLOT_NS ); + move16(); + } + return render_granularity; +} +#else Word16 ivas_jbm_dec_get_render_granularity( const RENDERER_TYPE rendererType, /* i : renderer type */ const IVAS_FORMAT ivas_format, /* i : ivas format */ @@ -3648,6 +3677,7 @@ Word16 ivas_jbm_dec_get_render_granularity( return render_granularity; } +#endif /*--------------------------------------------------------------------------* @@ -3973,7 +4003,7 @@ static void ivas_jbm_dec_tc_buffer_playout_fx( * Close JBM transport channel buffer *--------------------------------------------------------------------------*/ -void ivas_jbm_dec_tc_buffer_close( +void ivas_jbm_dec_tc_buffer_close_fx( DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ) { @@ -4076,7 +4106,7 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( * *--------------------------------------------------------------------------*/ -TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( +TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 7dba2b5d4714c44e59743955cc05e2e939fd58da..3377a36f9cb7d8e14bde30268888acb637789f0c 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -907,6 +907,9 @@ ivas_error ivas_masa_dec_open_fx( IF( st_ivas->hTcBuffer == NULL && NE_16( st_ivas->renderer_type, RENDERER_DISABLE ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) && NE_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) { Word16 nchan_to_allocate, nchan_transport; +#ifdef NONBE_1303_REND_GRANULARITY + Word16 granularity; +#endif TC_BUFFER_MODE buffer_mode; buffer_mode = TC_BUFFER_MODE_RENDERER; @@ -951,7 +954,13 @@ ivas_error ivas_masa_dec_open_fx( nchan_to_allocate = add( nchan_to_allocate, 1 ); } +#ifdef NONBE_1303_REND_GRANULARITY + granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); + + IF( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_transport, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK ) +#else IF( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_transport, nchan_to_allocate, nchan_to_allocate, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1987,9 +1996,13 @@ ivas_error ivas_masa_dec_reconfigure_fx( TC_BUFFER_MODE buffer_mode_new; Word16 n_samples_granularity; +#ifdef NONBE_1303_REND_GRANULARITY + n_samples_granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), st_ivas->hDecoderConfig->output_Fs ); +#else n_samples_granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); move16(); - buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); +#endif + buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode_fx( st_ivas ); tc_nchan_transport = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); tc_nchan_to_allocate = tc_nchan_transport; @@ -2016,10 +2029,12 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) { +#ifndef NONBE_1303_REND_GRANULARITY n_samples_granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ +#endif IF( GT_16( n_samples_granularity, st_ivas->hTcBuffer->n_samples_granularity ) ) { - IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 250b37675be3e1d0c4432fa5bc2863ddc064b91b..54d5e29059e71876fd7a5f4dc6b53aaf289fd153 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -508,6 +508,9 @@ ivas_error ivas_param_mc_dec_open_fx( IF( NE_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { Word16 n_cldfb_slots; +#ifdef NONBE_1303_REND_GRANULARITY + Word16 granularity; +#endif n_cldfb_slots = DEFAULT_JBM_CLDFB_TIMESLOTS; move16(); @@ -537,7 +540,13 @@ ivas_error ivas_param_mc_dec_open_fx( IF( st_ivas->hTcBuffer == NULL ) { +#ifdef NONBE_1303_REND_GRANULARITY + granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); + + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, granularity ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) +#endif { return error; } diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index fa36c4f34adb85aa4c40ac21d3ca6ea4caaf176c..6088abe198876fbbf112a7a21636c4873c728fe9 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -408,6 +408,9 @@ ivas_error ivas_mc_paramupmix_dec_open( { Word16 nchan_to_allocate; Word16 nchan_tc; +#ifdef NONBE_1303_REND_GRANULARITY + Word16 granularity; +#endif TC_BUFFER_MODE buffer_mode; buffer_mode = TC_BUFFER_MODE_RENDERER; @@ -434,7 +437,13 @@ ivas_error ivas_mc_paramupmix_dec_open( move16(); } +#ifdef NONBE_1303_REND_GRANULARITY + granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, output_Fs ); + + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) +#endif { return error; } diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index cb533bb5a0328bcdaf20013c484d0184613e08ce..5afb5fc9a0d6aaef2f5125890437cdcaaf14e3e8 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -1019,11 +1019,16 @@ static ivas_error ivas_mc_dec_reconfig_fx( /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv render what still fits in the new granularity */ +#ifdef NONBE_1303_REND_GRANULARITY + tc_granularity_new = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); +#else tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); move16(); +#endif IF( LT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ){ #ifdef FIX_HRTF_LOAD /* flush already done in IVAS_DEC_ReadFormat() */ + #else IF( NE_32( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, data ) ), IVAS_ERR_OK ) ){ return error; @@ -1034,7 +1039,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( ELSE IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { - IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -1600,7 +1605,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( DECODER_TC_BUFFER_HANDLE hTcBuffer; hTcBuffer = st_ivas->hTcBuffer; - tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); + tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode_fx( st_ivas ); tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); tc_nchan_allocate_new = tc_nchan_tc_new; move16(); diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index a97567c198c8f2f9348370572adeb9081d996c4e..13d32405e3ce4c085ecdca22ea3e3c0f4cabe280 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -63,9 +63,14 @@ ivas_error ivas_td_binaural_open_fx( } #ifdef FIX_HRTF_LOAD +#ifdef NONBE_1303_REND_GRANULARITY + test(); + IF( st_ivas->hHrtfTD == NULL && st_ivas->hDecoderConfig->Opt_HRTF_binary ) +#else if ( st_ivas->hHrtfTD == NULL && st_ivas->hDecoderConfig->Opt_HRTF_binary && ( st_ivas->ivas_format != SBA_ISM_FORMAT ) // ToDo: temporary hack to avoid ASAN errors -> see issue #1202 ) +#endif { return IVAS_ERROR( IVAS_ERR_INTERNAL, "HRTF binary file present but not used in TD renderer" ); } diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index 9832cd8a6f68df32c09d970955ba5ef7bc8e9451..3b5d4ecefdad1a9ec60983782fe2ccf29028b315 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -611,7 +611,7 @@ void ivas_renderer_select( *-------------------------------------------------------------------------*/ /*! r: secondary binaural renderer type */ -RENDERER_TYPE ivas_renderer_secondary_select( +RENDERER_TYPE ivas_renderer_secondary_select_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index 21d446c88760a334119c3cb77c24898059fcbd48..028ca879e2e3213e6751e782f995be5a12c37e63 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -192,6 +192,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( test(); IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) { +#ifndef NONBE_1303_REND_GRANULARITY RENDERER_TYPE renderer_type_new; Word16 sba_order_internal; @@ -232,8 +233,11 @@ ivas_error ivas_sba_dec_reconfigure_fx( move16(); } } - +#endif /* determine new granularity */ +#ifdef NONBE_1303_REND_GRANULARITY + granularity_new = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), st_ivas->hDecoderConfig->output_Fs ); +#else granularity_new = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); /*Q0*/ move16(); @@ -243,6 +247,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( { granularity_new = i_mult( granularity_new, JBM_CLDFB_SLOTS_IN_SUBFRAME ); /*Q0*/ } +#endif /* flush renderer on granularity change form 5ms to 1.25ms, again only possible for binaural rendering */ IF( LT_16( granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) @@ -270,7 +275,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( } ELSE IF( GT_16( granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { - if ( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) ) + if ( NE_32( ( error = ivas_jbm_dec_set_discard_samples_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index d0c22e7b6c8f1e07df8a62282775d6e621f6a833..475b6c88edff5b4541545542641162a37cdb1289 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -292,6 +292,11 @@ ivas_error ivas_spar_dec_open_fx( move16(); } +#ifdef NONBE_1303_REND_GRANULARITY + granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), output_Fs ); + + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) ) +#else test(); test(); @@ -303,6 +308,7 @@ ivas_error ivas_spar_dec_open_fx( } IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) ) +#endif { return error; } diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index f0702487cc5ee7db61af6c9d30b1f5e0e24d6ecb..bb49a02a4fe7a11e0fc1a1158d8190c9e1c3f813 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3625,7 +3625,11 @@ ivas_error IVAS_DEC_ReadFormat( MC_MODE mc_mode_old; Word16 nchan_transport_old; AUDIO_CONFIG intern_config_old, transport_config_old, output_config; +#ifdef NONBE_1303_REND_GRANULARITY + RENDERER_TYPE renderer_type_old, renderer_type_sec_new, renderer_type_sec_old; +#else RENDERER_TYPE renderer_type_old, renderer_type_sec_new; +#endif test(); IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) @@ -3641,6 +3645,9 @@ ivas_error IVAS_DEC_ReadFormat( intern_config_old = st_ivas->intern_config; transport_config_old = st_ivas->transport_config; renderer_type_old = st_ivas->renderer_type; +#ifdef NONBE_1303_REND_GRANULARITY + renderer_type_sec_old = ivas_renderer_secondary_select_fx( st_ivas ); +#endif move32(); move32(); move32(); @@ -3648,6 +3655,9 @@ ivas_error IVAS_DEC_ReadFormat( move32(); move32(); move32(); +#ifdef NONBE_1303_REND_GRANULARITY + move32(); +#endif output_config = st_ivas->hDecoderConfig->output_config; move32(); @@ -3677,7 +3687,7 @@ ivas_error IVAS_DEC_ReadFormat( *binaural_renderer = renderer_type_to_mode( st_ivas->renderer_type ); /* Select secondary binaural renderer (used in combined formats) */ - renderer_type_sec_new = ivas_renderer_secondary_select( st_ivas ); + renderer_type_sec_new = ivas_renderer_secondary_select_fx( st_ivas ); *binaural_renderer_sec = renderer_type_to_mode( renderer_type_sec_new ); /* select HRTF audio configuration to load the right HRTF set for the external binary file */ @@ -3739,6 +3749,46 @@ ivas_error IVAS_DEC_ReadFormat( } } +#ifdef NONBE_1303_REND_GRANULARITY + test(); + test(); + test(); + test(); + /* JBM: compensate when binaural renderer granularity changes (happens in bitrate switching) */ + IF( st_ivas->ini_active_frame > 0 && st_ivas->hDecoderConfig->Opt_tsm && + ( NE_32( renderer_type_old, st_ivas->renderer_type ) || + NE_32( renderer_type_sec_old, renderer_type_sec_new ) ) ) + { + Word16 tc_granularity_new = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, renderer_type_sec_new, st_ivas->hDecoderConfig->output_Fs ); + +#ifdef NONBE_1200_ISM_JBM_BRATE_SW_FLUSH + st_ivas->nchan_transport = nchan_transport_old; + move16(); +#else + // st_ivas->nchan_transport = nchan_transport_old; // ToDo: temporarily deactivated to keep FIX_HRTF_LOAD bit-exact but this is likely a bug in the main -> see issue #1200 +#endif + +#ifndef NONBE_1199_OMASA_JBM_BRATE_SW_FLUSH + if ( st_ivas->ivas_format == MASA_FORMAT ) + { + st_ivas->nchan_ism = 0; // ToDo: temporary hack to keep FIX_HRTF_LOAD bit-exact but this is likely a bug in the main -> see issue #1199 + } +#endif + IF( st_ivas->hTcBuffer == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + /* when granularity goes down, render what still fits in the new granularity */ + IF( LT_32( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) + { + IF( NE_32( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &st_ivas->hIntSetup, mc_mode_old, ism_mode_old, &hIvasDec->nSamplesFlushed, hIvasDec->flushbuffer ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + } +#else #ifdef FIX_HRTF_LOAD test(); test(); @@ -3781,6 +3831,7 @@ ivas_error IVAS_DEC_ReadFormat( } } } +#endif #endif } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 8f063a897f1b1102b81989ab4492aba523c1ecac..54834112841c11b458e0e5dd45f64a7d4457ff4a 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -184,6 +184,15 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( move16(); } +#ifdef NONBE_1303_REND_GRANULARITY + output_Fs = st_ivas->hDecoderConfig->output_Fs; + move32(); + nBins = st_ivas->hSpatParamRendCom->num_freq_bands; + move16(); + renderer_type = st_ivas->renderer_type; + move32(); +#endif + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { hDiracDecBin = st_ivas->hDiracDecBin[pos_idx]; @@ -203,13 +212,14 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( hDiracDecBin->phHrtfParambin = NULL; } +#ifndef NONBE_1303_REND_GRANULARITY output_Fs = st_ivas->hDecoderConfig->output_Fs; move32(); nBins = st_ivas->hSpatParamRendCom->num_freq_bands; move16(); renderer_type = st_ivas->renderer_type; move32(); - +#endif FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { FOR( k = 0; k < BINAURAL_CHANNELS + MAX_NUM_OBJECTS; k++ ) @@ -349,7 +359,7 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( ivas_dirac_dec_decorr_close_fx( &hDiracDecBin->h_freq_domain_decorr_ap_params, &hDiracDecBin->h_freq_domain_decorr_ap_state ); } - if ( pos_idx == 0 ) /* open decorrelator only for the main direction */ + IF( pos_idx == 0 ) /* open decorrelator only for the main direction */ { IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( hDiracDecBin->hTdDecorr ), &( hDiracDecBin->useTdDecorr ) ) ), IVAS_ERR_OK ) ) { @@ -378,9 +388,10 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( } } } - else + ELSE { hDiracDecBin->useTdDecorr = st_ivas->hDiracDecBin[0]->useTdDecorr; /* copy the flag, but the implementation re-uses the decorrelated signal */ + move16(); } hDiracDecBin->reqularizationFactor_fx = configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); /* Q14 */ @@ -404,6 +415,9 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( nchan_to_allocate = add( BINAURAL_CHANNELS, st_ivas->nchan_ism ); } +#ifdef NONBE_1303_REND_GRANULARITY + n_samples_granularity = ivas_jbm_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), output_Fs ); +#else n_samples_granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); test(); test(); @@ -411,6 +425,7 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( { n_samples_granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ } +#endif IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ), nchan_to_allocate, nchan_to_allocate, n_samples_granularity ) ), IVAS_ERR_OK ) ) {