From ad7d5805e676428e840875bd745c23b89bcb2a94 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Mon, 16 Jan 2023 13:48:06 +0200 Subject: [PATCH] Fix issue 292 by removing the remaining callocs in VBAP. --- lib_com/options.h | 1 + lib_dec/ivas_vbap.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index bea3e2670e..09e29ce40b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -151,6 +151,7 @@ #define FIX_235 /* Issue 235: Deallocation of HR filter memory separately for lib_rend (ROM) and lib_util (from file) */ #define ENV_STAB_FIX /* Contribution 23: HQ envelope stability memory fix */ #define STABILIZE_GIPD /* FhG: Contribution 22: gIPD stabilization */ +#define FIX_292_VBAP_CALLOC_REMOVAL /* Nokia: Fixes issue 292 by removing the remnant callocs */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/ivas_vbap.c b/lib_dec/ivas_vbap.c index a3ec6323cf..ecd3a1e6c9 100644 --- a/lib_dec/ivas_vbap.c +++ b/lib_dec/ivas_vbap.c @@ -200,7 +200,12 @@ ivas_error vbap_init_data( if ( is_success && virtual_bottom_type != NO_VIRTUAL_SPEAKER_NODE ) { +#ifdef FIX_292_VBAP_CALLOC_REMOVAL + vbap->bottom_virtual_speaker_node_division_gains = (float *) malloc( num_speaker_nodes * sizeof( float ) ); + set_zero( vbap->bottom_virtual_speaker_node_division_gains, num_speaker_nodes ); +#else vbap->bottom_virtual_speaker_node_division_gains = (float *) calloc( num_speaker_nodes, sizeof( float ) ); +#endif is_success &= vbap->bottom_virtual_speaker_node_division_gains != NULL; speaker_node_azi_deg_internal[vbap->bottom_virtual_speaker_node_index] = 0.0f; speaker_node_ele_deg_internal[vbap->bottom_virtual_speaker_node_index] = -90.0f; @@ -208,7 +213,12 @@ ivas_error vbap_init_data( if ( is_success && virtual_top_type != NO_VIRTUAL_SPEAKER_NODE ) { +#ifdef FIX_292_VBAP_CALLOC_REMOVAL + vbap->top_virtual_speaker_node_division_gains = (float *) malloc( num_speaker_nodes * sizeof( float ) ); + set_zero( vbap->top_virtual_speaker_node_division_gains, num_speaker_nodes ); +#else vbap->top_virtual_speaker_node_division_gains = (float *) calloc( num_speaker_nodes, sizeof( float ) ); +#endif is_success &= vbap->top_virtual_speaker_node_division_gains != NULL; speaker_node_azi_deg_internal[vbap->top_virtual_speaker_node_index] = 0.0f; speaker_node_ele_deg_internal[vbap->top_virtual_speaker_node_index] = 90.0f; @@ -216,7 +226,12 @@ ivas_error vbap_init_data( if ( is_success && virtual_back_type != NO_VIRTUAL_SPEAKER_NODE ) { +#ifdef FIX_292_VBAP_CALLOC_REMOVAL + vbap->back_virtual_speaker_node_division_gains = (float *) malloc( num_speaker_nodes * sizeof( float ) ); + set_zero( vbap->back_virtual_speaker_node_division_gains, num_speaker_nodes ); +#else vbap->back_virtual_speaker_node_division_gains = (float *) calloc( num_speaker_nodes, sizeof( float ) ); +#endif is_success &= vbap->back_virtual_speaker_node_division_gains != NULL; speaker_node_azi_deg_internal[vbap->back_virtual_speaker_node_index] = 180.0f; speaker_node_ele_deg_internal[vbap->back_virtual_speaker_node_index] = 0.0f; -- GitLab