diff --git a/apps/renderer.c b/apps/renderer.c index 59dbb7571a49f3de8e252fc32b5eda5849d9ecb6..9372ff474b16b1b9f4a40368e65f74884a4ed2a2 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -170,6 +170,10 @@ typedef struct char customHrtfFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; char renderConfigFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; int8_t orientation_tracking; +#ifdef FIX_1135_EXT_RENDERER_HANDLES + int16_t Opt_Headrotation; + int16_t Opt_ExternalOrientation; +#endif int16_t nonDiegeticPan; float nonDiegeticPanGain; IVAS_REND_COMPLEXITY_LEVEL complexityLevel; @@ -896,7 +900,11 @@ int main( const int16_t frameSize_smpls = (int16_t) ( ( args.render_framesize ) * args.sampleRate * 5 / ( 1000 ) ); +#ifdef FIX_1135_EXT_RENDERER_HANDLES + if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, !isEmptyString( args.customHrtfFilePath ), args.nonDiegeticPan, args.nonDiegeticPanGain, args.Opt_Headrotation, args.Opt_ExternalOrientation, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, !isEmptyString( args.customHrtfFilePath ), args.nonDiegeticPan, args.nonDiegeticPanGain, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError opening renderer handle: %s\n", ivas_error_to_string( error ) ); goto cleanup; @@ -2652,7 +2660,13 @@ static CmdlnArgs defaultArgs( clearString( args.renderConfigFilePath ); clearString( args.externalOrientationFilePath ); +#ifdef FIX_1135_EXT_RENDERER_HANDLES + args.Opt_Headrotation = 0; + args.Opt_ExternalOrientation = 0; +#endif + args.orientation_tracking = IVAS_HEAD_ORIENT_TRK_NONE; + args.nonDiegeticPan = 0; args.nonDiegeticPanGain = 0.f; @@ -2744,6 +2758,9 @@ static void parseOption( break; case CmdLnOptionId_trajFile: assert( numOptionValues == 1 ); +#ifdef FIX_1135_EXT_RENDERER_HANDLES + args->Opt_Headrotation = 1; +#endif strncpy( args->headRotationFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); break; case CmdLnOptionId_outputMetadata: @@ -2764,6 +2781,9 @@ static void parseOption( break; case CmdLnOptionId_exteriorOrientationFile: assert( numOptionValues == 1 ); +#ifdef FIX_1135_EXT_RENDERER_HANDLES + args->Opt_ExternalOrientation = 1; +#endif strncpy( args->externalOrientationFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); break; case CmdLnOptionId_customHrtfFile: @@ -2897,6 +2917,13 @@ static CmdlnArgs parseCmdlnArgs( exit( -1 ); /* Error printout handled by failing function */ } +#ifdef FIX_1135_EXT_RENDERER_HANDLES + if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + args.Opt_Headrotation = 1; + } +#endif + return args; } diff --git a/lib_com/options.h b/lib_com/options.h index faafb029dc7b3a80c4eb6b98a198cdcf3f0e7495..d3451948790fd63ea7fc755ff45596afc066ab53 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -169,7 +169,7 @@ #define NONBE_1215_FIX_JBM_MAX_SCALING /* FhG: issue 1215: Fix assert hit in a specific VoIP decoder config. Caused by integer overflow in max scaling calculation. */ #define NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT /* fix 1070 USAN: nullptr-with-offset and Segfaults in 7_1_4 to BINAURAL and BINAURAL_ROOM_REVERB decoding with bitrate switching and head rotation*/ #define FIX_1068_ASAN_IN_MC_2_BINAURAL_ROOM_IR /* issue 1068 : Memory leak in MC to BINAURAL_ROOM decoding with bitrate switching*/ -#define NONBE_FIX_MC_LFE_LPF /* Dlb: Adding the LFE LPF filter back for MC content. */ +#define NONBE_FIX_MC_LFE_LPF /* Dlb: Adding the LFE LPF filter back for MC content. */ #define FIX_1050_EFAP_ALLOC /* FhG: issue 1050: reduction of memory allocated to EFAP handle */ #define NONBE_FIX_1052_SBA_EXT /* Dlb: SBA external output support */ #define FIX_1082_INSTRUM_FAILED_LC3PLUS /* VoiceAge: issue 1082: fix ambiguous syntax in LC3Plus code leading to fails of instrumented builds */ @@ -197,7 +197,8 @@ #define NONBE_FIX_1141_OSBA_ROOM_RENDERING /* FhG: Fix for issue 1141: render objects in OSBA decoder with room effect */ #define NONBE_1360_LFE_DELAY /* Dlb: LFE delay alignment when rendering in CLDFB domain*/ #define NONBE_1229_FIX_ISM1_DPID /* Eri: issue 1229: fix bug causing ISM 1 to use default -dpid instead of the specified one */ -#define NONBE_SVD_OPTIMIZATION +#define NONBE_SVD_OPTIMIZATION /* FhG: port-2211-svd-optimization */ +#define FIX_1135_EXT_RENDERER_HANDLES /* VA: issue 1135: Memory usage reduction in external renderer: Allocate only handles that are really needed. */ #define FIX_1209_SID_SIGNALING /* VA: issue 1209: remove dead code in IVAS SID signaling */ #define FIX_1158_FASTCONV_REVERB_HRTF /* Philips: issue 1158: Rendering with FastConv to BINAURAL_ROOM_REVERB uses BRIR convolution instead of HRTF */ #define NONBE_FIX_1176_OSBA_REVERB_JBM_ASAN_ERROR /* Ericsson: Issue 1176, fix in TDREND_firfilt for subframes shorter than the filter length */ diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index ae12ff552a0747289460e8d1829e0099bba9aa8a..7f1fa9a11c03444b46ab6c17e5aaba727b6dedd6 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -999,7 +999,7 @@ typedef struct decoder_config_structure int16_t Opt_non_diegetic_pan; /* indicates diegetic or not */ float non_diegetic_pan_gain; /* non diegetic panning gain*/ int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ - int16_t Opt_ExternalOrientation; /* indiates whether external orientations are used */ + int16_t Opt_ExternalOrientation; /* indicates whether external orientations are used */ int16_t Opt_dpid_on; /* indicates whether Directivity pattern option is used */ int16_t Opt_aeid_on; /* indicates whether Acoustic environment option is used */ #ifdef DEBUGGING diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index fbb413ab1ee35bd0d44d1268bc21c2a7fc42ab3c..1e14c81fecfcb87fc1f372ab4dad072d658a21ea 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -488,11 +488,12 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->render_framesize = renderFramesize; } +#ifndef FIX_1135_EXT_RENDERER_HANDLES if ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { hDecoderConfig->Opt_Headrotation = TRUE; } - +#endif /* Set decoder parameters to initial values */ if ( ( error = ivas_init_decoder_front( st_ivas ) ) != IVAS_ERR_OK ) { diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index d6e301c6d77e16f47efa0de673710109cb337ad1..4dbf7516876b489926cd97f3a0272c16471ad1ba 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -1108,7 +1108,11 @@ static ivas_error initHeadRotation( static void closeHeadRotation( IVAS_REND_HANDLE hIvasRend ) { +#ifdef FIX_1135_EXT_RENDERER_HANDLES + if ( hIvasRend != NULL && hIvasRend->headRotData.headRotEnabled && hIvasRend->headRotData.hOrientationTracker != NULL ) +#else if ( ( hIvasRend != NULL ) && ( hIvasRend->headRotData.hOrientationTracker != NULL ) ) +#endif { free( hIvasRend->headRotData.hOrientationTracker ); } @@ -2761,6 +2765,10 @@ ivas_error IVAS_REND_Open( const bool asHrtfBinary, const int16_t nonDiegeticPan, const float nonDiegeticPanGain, +#ifdef FIX_1135_EXT_RENDERER_HANDLES + const int16_t Opt_Headrotation, + const int16_t Opt_ExternalOrientation, +#endif const int16_t num_subframes ) { int16_t i; @@ -2815,22 +2823,46 @@ ivas_error IVAS_REND_Open( } /* Initialize headrotation data */ - if ( ( error = initHeadRotation( hIvasRend ) ) != IVAS_ERR_OK ) +#ifdef FIX_1135_EXT_RENDERER_HANDLES + hIvasRend->headRotData.headRotEnabled = 0; + if ( Opt_Headrotation ) { - return error; +#endif + if ( ( error = initHeadRotation( hIvasRend ) ) != IVAS_ERR_OK ) + { + return error; + } +#ifdef FIX_1135_EXT_RENDERER_HANDLES } +#endif /* Initialize external orientation data */ - if ( ( error = ivas_external_orientation_open( &( hIvasRend->hExternalOrientationData ), num_subframes ) ) != IVAS_ERR_OK ) +#ifdef FIX_1135_EXT_RENDERER_HANDLES + hIvasRend->hExternalOrientationData = NULL; + if ( Opt_ExternalOrientation ) { - return error; +#endif + if ( ( error = ivas_external_orientation_open( &( hIvasRend->hExternalOrientationData ), num_subframes ) ) != IVAS_ERR_OK ) + { + return error; + } +#ifdef FIX_1135_EXT_RENDERER_HANDLES } +#endif /* Initilize combined orientation data */ - if ( ( error = ivas_combined_orientation_open( &( hIvasRend->hCombinedOrientationData ), outputSampleRate, num_subframes ) ) != IVAS_ERR_OK ) +#ifdef FIX_1135_EXT_RENDERER_HANDLES + hIvasRend->hCombinedOrientationData = NULL; + if ( Opt_Headrotation || Opt_ExternalOrientation ) { - return error; +#endif + if ( ( error = ivas_combined_orientation_open( &( hIvasRend->hCombinedOrientationData ), outputSampleRate, num_subframes ) ) != IVAS_ERR_OK ) + { + return error; + } +#ifdef FIX_1135_EXT_RENDERER_HANDLES } +#endif /* Initialize EFAP */ if ( ( error = initEfap( &hIvasRend->efapOutWrapper, outConfig, &hIvasRend->customLsOut ) ) != IVAS_ERR_OK ) @@ -2938,10 +2970,18 @@ ivas_error IVAS_REND_Open( return error; } } - if ( ( error = ivas_HRTF_statistics_init( &( hIvasRend->hHrtfs.hHrtfStatistics ), hIvasRend->sampleRateOut ) ) != IVAS_ERR_OK ) + +#ifdef FIX_1135_EXT_RENDERER_HANDLES + if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - return error; +#endif + if ( ( error = ivas_HRTF_statistics_init( &( hIvasRend->hHrtfs.hHrtfStatistics ), hIvasRend->sampleRateOut ) ) != IVAS_ERR_OK ) + { + return error; + } +#ifdef FIX_1135_EXT_RENDERER_HANDLES } +#endif return IVAS_ERR_OK; } @@ -3866,7 +3906,11 @@ ivas_error IVAS_REND_GetDelay( { if ( hIvasRend->inputsSba[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) { +#ifdef FIX_1135_EXT_RENDERER_HANDLES + if ( hIvasRend->splitRendWrapper != NULL && hIvasRend->splitRendWrapper->hBinHrSplitPreRend != NULL ) +#else if ( hIvasRend->splitRendWrapper->hBinHrSplitPreRend != NULL ) +#endif { if ( hIvasRend->hRendererConfig->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) { @@ -4535,6 +4579,13 @@ ivas_error IVAS_REND_SetOrientationTrackingMode( const IVAS_HEAD_ORIENT_TRK_T orientation_tracking /* i : Head orientation tracking type */ ) { +#ifdef FIX_1135_EXT_RENDERER_HANDLES + if ( hIvasRend->headRotData.headRotEnabled == 0 ) + { + return IVAS_ERR_OK; + } +#endif + return ivas_orient_trk_SetTrackingType( hIvasRend->headRotData.hOrientationTracker, orientation_tracking ); } @@ -5165,7 +5216,11 @@ static ivas_error renderIsmToBinauralRoom( hCombinedOrientationData = ismInput->base.ctx.pCombinedOrientationData; combinedOrientationEnabled = 0; +#ifdef FIX_1135_EXT_RENDERER_HANDLES + if ( *hCombinedOrientationData != NULL ) +#else if ( hCombinedOrientationData != NULL ) +#endif { for ( subframe_idx = 0; subframe_idx < ( *hCombinedOrientationData )->num_subframes; subframe_idx++ ) { @@ -5780,7 +5835,11 @@ static ivas_error renderMcToBinaural( hCombinedOrientationData = mcInput->base.ctx.pCombinedOrientationData; combinedOrientationEnabled = 0; +#ifdef FIX_1135_EXT_RENDERER_HANDLES + if ( *hCombinedOrientationData != NULL ) +#else if ( hCombinedOrientationData != NULL ) +#endif { for ( subframe_idx = 0; subframe_idx < ( *hCombinedOrientationData )->num_subframes; subframe_idx++ ) { @@ -5870,7 +5929,11 @@ static ivas_error renderMcToBinauralRoom( hCombinedOrientationData = mcInput->base.ctx.pCombinedOrientationData; combinedOrientationEnabled = 0; +#ifdef FIX_1135_EXT_RENDERER_HANDLES + if ( *hCombinedOrientationData != NULL ) +#else if ( hCombinedOrientationData != NULL ) +#endif { for ( subframe_idx = 0; subframe_idx < ( *hCombinedOrientationData )->num_subframes; subframe_idx++ ) { @@ -5962,7 +6025,11 @@ static ivas_error renderMcCustomLsToBinauralRoom( hCombinedOrientationData = mcInput->base.ctx.pCombinedOrientationData; combinedOrientationEnabled = 0; +#ifdef FIX_1135_EXT_RENDERER_HANDLES + if ( *hCombinedOrientationData != NULL ) +#else if ( hCombinedOrientationData != NULL ) +#endif { for ( subframe_idx = 0; subframe_idx < ( *hCombinedOrientationData )->num_subframes; subframe_idx++ ) { @@ -6572,7 +6639,11 @@ static ivas_error renderSbaToBinaural( hCombinedOrientationData = sbaInput->base.ctx.pCombinedOrientationData; combinedOrientationEnabled = 0; +#ifdef FIX_1135_EXT_RENDERER_HANDLES + if ( *hCombinedOrientationData != NULL ) +#else if ( hCombinedOrientationData != NULL ) +#endif { for ( subframe_idx = 0; subframe_idx < ( *hCombinedOrientationData )->num_subframes; subframe_idx++ ) { @@ -6649,7 +6720,11 @@ static ivas_error renderSbaToBinauralRoom( hCombinedOrientationData = sbaInput->base.ctx.pCombinedOrientationData; combinedOrientationEnabled = 0; +#ifdef FIX_1135_EXT_RENDERER_HANDLES + if ( *hCombinedOrientationData != NULL ) +#else if ( hCombinedOrientationData != NULL ) +#endif { for ( subframe_idx = 0; subframe_idx < ( *hCombinedOrientationData )->num_subframes; subframe_idx++ ) { diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index ea35e99934640692b2502780a48d4e5569ec4e66..eb014f0dc5d10c8393e195ebf6f5d593ce1a9b68 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -113,7 +113,11 @@ ivas_error IVAS_REND_Open( const bool asHrtfBinary, /* i : load hrtf binary file */ const int16_t nonDiegeticPan, /* i : non-diegetic object flag */ const float nonDiegeticPanGain, /* i : non-diegetic panning gain */ - const int16_t num_subframes /* i : number of subframes */ +#ifdef FIX_1135_EXT_RENDERER_HANDLES + const int16_t Opt_Headrotation, /* i : indicates whether head-rotation is used */ + const int16_t Opt_ExternalOrientation, /* i : indicates whether external orientations are used */ +#endif + const int16_t num_subframes /* i : number of subframes */ ); /* Note: this will reset custom LFE routings set for any MC input */