Commit 7a150faf authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Fixes for few of the issues reported in ASAN test

parent 9105f17d
Loading
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -4652,11 +4652,11 @@ ivas_error ivas_param_mc_dec_reconfig(
void ivas_param_mc_dec_close_fx(
	PARAM_MC_DEC_HANDLE *hParamMC_out /* i/o: Parametric MC decoder handle   */
);
#endif // IVAS_FLOAT_FIXED

#else
void ivas_param_mc_dec_close(
    PARAM_MC_DEC_HANDLE *hParamMC                               /* i/o: Parametric MC decoder handle                        */
);
#endif // IVAS_FLOAT_FIXED

void ivas_param_mc_dec_read_BS(
    const int32_t ivas_total_brate,                             /* i  : IVAS total bitrate                                  */
@@ -6996,6 +6996,9 @@ ivas_error ivas_osba_data_open(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder handle                     */
);
#ifdef IVAS_FLOAT_FIXED
ivas_error ivas_osba_data_open_fx(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder handle                     */
);
ivas_error ivas_osba_dirac_td_binaural_jbm_fx(
    Decoder_Struct *st_ivas,      /* i/o: IVAS decoder structure                    */
    const UWord16 nSamplesAsked, /* i  : number of CLDFB slots requested           */
@@ -7047,6 +7050,11 @@ ivas_error ivas_osba_render_sf(
    float *output_f[]                                           /* o  : rendered time signal                    */
);
#endif
#ifdef IVAS_FLOAT_FIXED
void ivas_osba_data_close_fx(
    SBA_ISM_DATA_HANDLE *hSbaIsmData                            /* i/o: OSBA rendering handle                   */
);
#endif
void ivas_osba_data_close(
    SBA_ISM_DATA_HANDLE *hSbaIsmData                            /* i/o: OSBA rendering handle                   */
);
+2 −2
Original line number Diff line number Diff line
@@ -732,7 +732,7 @@ static ivas_error ivas_dirac_rend_config_fx(
        hDirACRend->proto_signal_decorr_on = 0;
    }

    IF( ( EQ_16( flag_config, DIRAC_OPEN && hDirACRend->proto_signal_decorr_on ) ) || ( EQ_16( flag_config, DIRAC_RECONFIGURE ) && ( hDirACRend->proto_signal_decorr_on && !proto_signal_decorr_on_old ) ) )
    IF( ( EQ_16( flag_config, DIRAC_OPEN) && hDirACRend->proto_signal_decorr_on ) || ( EQ_16( flag_config, DIRAC_RECONFIGURE ) && ( hDirACRend->proto_signal_decorr_on && !proto_signal_decorr_on_old ) ) )
    {
#ifdef IVAS_FLOAT_FIXED
        FOR( int ii = 0; ii < st_ivas->hSpatParamRendCom->num_freq_bands; ii++ )
@@ -3631,7 +3631,7 @@ void ivas_dirac_dec_render_sf_fx(
    Word32 proto_direct_buffer_f_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX];
    Word32 proto_power_smooth_fx[2 * CLDFB_NO_CHANNELS_MAX * MAX_OUTPUT_CHANNELS];
    Word32 reference_power_fix[5 * CLDFB_NO_CHANNELS_MAX];
    Word32 onset_filter_subframe_fix[2 * MAX_OUTPUT_CHANNELS];
    Word32 onset_filter_subframe_fix[2 * CLDFB_NO_CHANNELS_MAX];
    Word32 proto_diffuse_buffer_f_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX];
    //set_zero_fx( &proto_frame_f_fx[0], 2 * MAX_OUTPUT_CHANNELS * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX );
    set_zero_fx( &proto_direct_buffer_f_fx[0], 2 * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX * MAX_OUTPUT_CHANNELS );
+11 −2
Original line number Diff line number Diff line
@@ -1812,7 +1812,7 @@ ivas_error ivas_init_decoder_fx(
                return error;
            }

            IF ( ( error = ivas_osba_data_open( st_ivas ) ) != IVAS_ERR_OK )
            IF ( ( error = ivas_osba_data_open_fx( st_ivas ) ) != IVAS_ERR_OK )
            {
                return error;
            }
@@ -4089,7 +4089,11 @@ void ivas_destroy_dec(
    ivas_mc_paramupmix_dec_close( &( st_ivas->hMCParamUpmix ) );

    /* Parametric MC handle */
#ifdef IVAS_FLOAT_FIXED
    ivas_param_mc_dec_close_fx( &st_ivas->hParamMC );
#else
    ivas_param_mc_dec_close( &st_ivas->hParamMC );
#endif

    /* EFAP handle */
    efap_free_data( &st_ivas->hEFAPdata );
@@ -4133,7 +4137,11 @@ void ivas_destroy_dec(
    ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer );

    /* OSBA structure */
#ifdef IVAS_FLOAT_FIXED
    ivas_osba_data_close_fx( &st_ivas->hSbaIsmData );
#else
    ivas_osba_data_close( &st_ivas->hSbaIsmData );
#endif

    /* OMASA structure */
    ivas_omasa_data_close( &st_ivas->hMasaIsmData );
@@ -4150,9 +4158,10 @@ void ivas_destroy_dec(
    /* Time Domain binaural renderer handle */
    IF ( st_ivas->hBinRendererTd != NULL )
    {
        ivas_td_binaural_close( &st_ivas->hBinRendererTd );
#ifdef IVAS_FLOAT_FIXED
        ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd );
#else
        ivas_td_binaural_close( &st_ivas->hBinRendererTd );
#endif
    }
    ELSE IF ( st_ivas->hHrtfTD != NULL )
+30 −51
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@
#include "prot_fx1.h"
#include "prot_fx2.h"
#include "ivas_prot_fx.h"
#define IVAS_FLOAT_FIXED_TO_BE_REMOVED
#endif

#define INV_EPSILON_MANT 214748365
@@ -303,6 +304,8 @@ ivas_error ivas_param_mc_dec_open_fx(
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) );
    }
    set_f( hParamMC->icld_q, PARAM_MC_DEFAULT_MIN_ILD, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe );
    set_f( hParamMC->icc_q, 0, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe );
#endif

    param_mc_set_num_synth_bands( output_Fs, hParamMC );
@@ -1336,7 +1339,8 @@ ivas_error ivas_param_mc_dec_reconfig_fx(
        Word16 *ild_q_old_fx = hParamMC->icld_q_fx;
        Word16 *icc_q_old_fx = hParamMC->icc_q_fx;
#if 1/*To be removed later*/

        free( hParamMC->icc_q );
        free( hParamMC->icld_q );
        /* init arrays for the quantized parameters */
        IF ( ( hParamMC->icc_q = (float *) malloc( hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe * sizeof( float ) ) ) == NULL )
        {
@@ -2409,7 +2413,16 @@ void ivas_param_mc_dec_close_fx(
            free( hParamMC->diff_proto_info->proto_fac_fx[i] );
            hParamMC->diff_proto_info->proto_fac_fx[i] = NULL;
        }
#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED /*TODO: To be removed later(Floating point memory dealloc)------------------------------- */
        FOR( i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++ )
        {
            free( hParamMC->diff_proto_info->proto_fac[i] );
            hParamMC->diff_proto_info->proto_fac[i] = NULL;
        }

        free( hParamMC->diff_proto_info->proto_fac );
        hParamMC->diff_proto_info->proto_fac = NULL;
#endif /***********************************ends here************************************************/
        free( hParamMC->diff_proto_info->source_chan_idx );
        hParamMC->diff_proto_info->source_chan_idx = NULL;

@@ -2466,7 +2479,13 @@ void ivas_param_mc_dec_close_fx(
        free( hParamMC->Cldfb_ImagBuffer_tc_fx );
        hParamMC->Cldfb_ImagBuffer_tc_fx = NULL;
    }
#if 1 /*TODO: To be removed later(Floating point memory dealloc)------------------------------- */
#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED /*TODO: To be removed later(Floating point memory dealloc)------------------------------- */

    IF( hParamMC->proto_matrix_int != NULL )
    {
        free( hParamMC->proto_matrix_int );
        hParamMC->proto_matrix_int = NULL;
    }

    IF( hParamMC->icc_q != NULL )
    {
@@ -2479,16 +2498,6 @@ void ivas_param_mc_dec_close_fx(
        free( hParamMC->icld_q );
        hParamMC->icld_q = NULL;
    }
    IF( hParamMC->diff_proto_info )
    {
        FOR( i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++ )
        {
            free( hParamMC->diff_proto_info->proto_fac[i] );
            hParamMC->diff_proto_info->proto_fac[i] = NULL;
        }
        free( hParamMC->diff_proto_info->proto_fac );
        hParamMC->diff_proto_info->proto_fac = NULL;
    }
    IF( hParamMC->proto_frame_f != NULL )
    {
        free( hParamMC->proto_frame_f );
@@ -2504,6 +2513,11 @@ void ivas_param_mc_dec_close_fx(
    //    free( hParamMC->ls_conv_dmx_matrix );
    //    hParamMC->ls_conv_dmx_matrix = NULL;
    //}
    IF( hParamMC->hoa_encoder != NULL )
    {
        free( hParamMC->hoa_encoder );
        hParamMC->hoa_encoder = NULL;
    }
    IF( hParamMC->Cldfb_RealBuffer_tc != NULL )
    {
        free( hParamMC->Cldfb_RealBuffer_tc );
@@ -2521,7 +2535,7 @@ void ivas_param_mc_dec_close_fx(

    return;
}
#endif
#else
void ivas_param_mc_dec_close(
    PARAM_MC_DEC_HANDLE *hParamMC_out /* i/o: Parametric MC decoder handle   */
)
@@ -2537,11 +2551,7 @@ void ivas_param_mc_dec_close(
    hParamMC = *hParamMC_out;

    /* close sub-modules */
#ifdef IVAS_FLOAT_FIXED
    ivas_dirac_dec_output_synthesis_cov_close_fx( &hParamMC->h_output_synthesis_params, &hParamMC->h_output_synthesis_cov_state );
#else
    ivas_dirac_dec_output_synthesis_cov_close( &hParamMC->h_output_synthesis_params, &hParamMC->h_output_synthesis_cov_state );
#endif

    if ( hParamMC->h_freq_domain_decorr_ap_params != NULL || hParamMC->h_freq_domain_decorr_ap_state != NULL )
    {
@@ -2563,26 +2573,13 @@ void ivas_param_mc_dec_close(
        free( hParamMC->icc_q );
        hParamMC->icc_q = NULL;
    }
#ifdef IVAS_FLOAT_FIXED
    if ( hParamMC->icc_q_fx != NULL )
    {
        free( hParamMC->icc_q_fx );
        hParamMC->icc_q_fx = NULL;
    }
#endif

    if ( hParamMC->icld_q != NULL )
    {
        free( hParamMC->icld_q );
        hParamMC->icld_q = NULL;
    }
#ifdef IVAS_FLOAT_FIXED
    if ( hParamMC->icld_q_fx != NULL )
    {
        free( hParamMC->icld_q_fx );
        hParamMC->icld_q_fx = NULL;
    }
#endif

    /* diffuse prototype info */
    if ( hParamMC->diff_proto_info )
    {
@@ -2617,11 +2614,6 @@ void ivas_param_mc_dec_close(
    {
        free( hParamMC->proto_frame_f );
        hParamMC->proto_frame_f = NULL;

#ifdef IVAS_FLOAT_FIXED
        free(hParamMC->proto_frame_f_fx);
        hParamMC->proto_frame_f_fx = NULL;
#endif
    }

    if ( hParamMC->proto_frame_dec_f != NULL )
@@ -2629,32 +2621,18 @@ void ivas_param_mc_dec_close(
        free( hParamMC->proto_frame_dec_f );
        hParamMC->proto_frame_dec_f = NULL;
    }
#ifndef IVAS_FLOAT_FIXED

    if ( hParamMC->ls_conv_dmx_matrix != NULL )
    {
        free( hParamMC->ls_conv_dmx_matrix );
        hParamMC->ls_conv_dmx_matrix = NULL;
    }
#else
    if ( hParamMC->ls_conv_dmx_matrix_fx != NULL )
    {
        free( hParamMC->ls_conv_dmx_matrix_fx );
        hParamMC->ls_conv_dmx_matrix_fx = NULL;
    }
#endif

    if ( hParamMC->proto_matrix_int != NULL )
    {
        free( hParamMC->proto_matrix_int );
        hParamMC->proto_matrix_int = NULL;
    }
#ifdef IVAS_FLOAT_FIXED
    if ( hParamMC->proto_matrix_int_fx != NULL )
    {
        free( hParamMC->proto_matrix_int_fx );
        hParamMC->proto_matrix_int_fx = NULL;
    }
#endif

    if ( hParamMC->hoa_encoder != NULL )
    {
@@ -2678,6 +2656,7 @@ void ivas_param_mc_dec_close(

    return;
}
#endif

/*-------------------------------------------------------------------------
 * ivas_param_mc_dec_read_BS()
+80 −4
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@
#include "prot_fx1.h"
#include "prot_fx2.h"
#include "math.h"   // temporary (for fabs)
#define IVAS_FLOAT_FIXED_TO_BE_REMOVED
#endif // IVAS_FLOAT_FIXED


@@ -67,38 +68,73 @@ ivas_error ivas_osba_data_open(
    hSbaIsmData->delayBuffer_nchan = st_ivas->nchan_ism;
    hSbaIsmData->delayBuffer_size = (int16_t) ( ( st_ivas->hDecoderConfig->output_Fs / 50 ) / MAX_PARAM_SPATIAL_SUBFRAMES );

    if ( ( hSbaIsmData->delayBuffer = (float **) malloc( hSbaIsmData->delayBuffer_nchan * sizeof( float * ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for OSBA delay buffer \n" ) );
    }

    for ( i = 0; i < hSbaIsmData->delayBuffer_nchan; i++ )
    {
        if ( ( hSbaIsmData->delayBuffer[i] = (float *) malloc( hSbaIsmData->delayBuffer_size * sizeof( float ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for OSBA delay buffer \n" ) );
        }
        set_zero( hSbaIsmData->delayBuffer[i], hSbaIsmData->delayBuffer_size );
    }

    st_ivas->hSbaIsmData = hSbaIsmData;

    return IVAS_ERR_OK;
}

#ifdef IVAS_FLOAT_FIXED
ivas_error ivas_osba_data_open_fx(
    Decoder_Struct *st_ivas /* i/o: IVAS decoder handle  */
)
{
    SBA_ISM_DATA_HANDLE hSbaIsmData;
    int16_t i;

    if ( ( hSbaIsmData = (SBA_ISM_DATA_HANDLE) malloc( sizeof( SBA_ISM_DATA ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OSBA data\n" ) );
    }

    hSbaIsmData->delayBuffer_nchan = st_ivas->nchan_ism;
    hSbaIsmData->delayBuffer_size = (int16_t) ( ( st_ivas->hDecoderConfig->output_Fs / 50 ) / MAX_PARAM_SPATIAL_SUBFRAMES );

    if ( ( hSbaIsmData->delayBuffer_fx = (Word32 **) malloc( hSbaIsmData->delayBuffer_nchan * sizeof(Word32 * ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for OSBA delay buffer \n" ) );
    }
#endif
#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED
    if ( ( hSbaIsmData->delayBuffer = (float **) malloc( hSbaIsmData->delayBuffer_nchan * sizeof( float * ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for OSBA delay buffer \n" ) );
    }
#endif

    for ( i = 0; i < hSbaIsmData->delayBuffer_nchan; i++ )
    {
#ifdef IVAS_FLOAT_FIXED
        if ( ( hSbaIsmData->delayBuffer_fx[i] = (Word32 *) malloc( hSbaIsmData->delayBuffer_size * sizeof(Word32) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for OSBA delay buffer \n" ) );
        }
        set_zero_fx( hSbaIsmData->delayBuffer_fx[i], hSbaIsmData->delayBuffer_size );
#endif // IVAS_FLOAT_FIXED
#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED
        if ( ( hSbaIsmData->delayBuffer[i] = (float *) malloc( hSbaIsmData->delayBuffer_size * sizeof( float ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for OSBA delay buffer \n" ) );
        }
        set_zero( hSbaIsmData->delayBuffer[i], hSbaIsmData->delayBuffer_size );
#endif // IVAS_FLOAT_FIXED
    }

    st_ivas->hSbaIsmData = hSbaIsmData;

    return IVAS_ERR_OK;
}

#endif

/*-------------------------------------------------------------------*
 * ivas_osba_data_close()
@@ -133,6 +169,46 @@ void ivas_osba_data_close(
    return;
}

#ifdef IVAS_FLOAT_FIXED
void ivas_osba_data_close_fx(
    SBA_ISM_DATA_HANDLE *hSbaIsmData /* i/o: OSBA rendering handle    */
)
{
    int16_t i;

    if ( hSbaIsmData == NULL || *hSbaIsmData == NULL )
    {
        return;
    }

    if ( ( *hSbaIsmData )->delayBuffer_fx != NULL )
    {
        for ( i = 0; i < ( *hSbaIsmData )->delayBuffer_nchan; i++ )
        {
            free( ( *hSbaIsmData )->delayBuffer_fx[i] );
        }
        free( ( *hSbaIsmData )->delayBuffer_fx );
        ( *hSbaIsmData )->delayBuffer_fx = NULL;
    }

#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED
    if ( ( *hSbaIsmData )->delayBuffer != NULL )
    {
        for ( i = 0; i < ( *hSbaIsmData )->delayBuffer_nchan; i++ )
        {
            free( ( *hSbaIsmData )->delayBuffer[i] );
        }
        free( ( *hSbaIsmData )->delayBuffer );
        ( *hSbaIsmData )->delayBuffer = NULL;
    }
#endif

    free( *hSbaIsmData );
    *hSbaIsmData = NULL;

    return;
}
#endif

/*--------------------------------------------------------------------------*
 * ivas_osba_dirac_td_binaural_jbm()
Loading