Commit cc50fede authored by vaillancour's avatar vaillancour
Browse files

Merge branch '2431-use-of-calloc-in-basop' into 'main'

Resolve "Use of calloc() in BASOP"

Closes #2431

See merge request !2820
parents 1077d9cc c71a3de2
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1598,17 +1598,27 @@ ivas_error cldfb_save_memory(
    }
    hs->memory_length = cldfb_get_memory_length( hs );
    move16();
#ifdef FIX_2431_AVOID_CALLOC
    hs->memory = (Word16 *) malloc( ( hs->memory_length + CLDFB_MEM_EXPONENTS + 1 ) * sizeof( Word16 ) );
    IF( hs->memory == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB\n" );
    }
#else
    hs->memory = (Word16 *) calloc( hs->memory_length + CLDFB_MEM_EXPONENTS + 1, sizeof( Word16 ) );
#endif

    /* save the memory */
    Copy( hs->FilterStates, hs->memory, hs->memory_length );
    Copy( hs->FilterStates_e, hs->memory + hs->memory_length, CLDFB_MEM_EXPONENTS );
    hs->memory[hs->memory_length + CLDFB_MEM_EXPONENTS] = hs->FilterStates_eg;
    move16();
#ifndef FIX_2431_AVOID_CALLOC
    IF( hs->memory == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB\n" );
    }
#endif

    return IVAS_ERR_OK;
}
+8 −2
Original line number Diff line number Diff line
@@ -651,7 +651,11 @@ Word16 modify_Fs_intcub3m_sup_fx(
    const Word16( *cu )[3] = 0;
    Word16 *sigin_sr, *sigOutptr, *cptr;
    const Word16 *uptr, *ctptr;
#ifdef FIX_2431_AVOID_CALLOC
    Word16 sigin_sr_tab[NS2SA( 16000, DELAY_CLDFB_NS ) + 2];
#else
    Word16 *sigin_sr_tab;
#endif
    Word16 lim, inc, lim2, lim3;
    Word32 vv32;
#define QSR 2 /* right shift to avoid overflow, 2 is OK */
@@ -677,7 +681,9 @@ Word16 modify_Fs_intcub3m_sup_fx(
    }
    ELSE
    {
#ifndef FIX_2431_AVOID_CALLOC
        sigin_sr_tab = (Word16 *) calloc( lg + 2, sizeof( *sigin_sr ) ); /*shift right*/
#endif
        sigin_sr = sigin_sr_tab + 2;
        FOR( i = -2; i < lg; i++ )
        {
@@ -861,7 +867,6 @@ Word16 modify_Fs_intcub3m_sup_fx(
            }
        }


        kk = sub( kk, 1 );
        if ( kk < 0 )
        {
@@ -916,8 +921,9 @@ Word16 modify_Fs_intcub3m_sup_fx(
        }
    }

#ifndef FIX_2431_AVOID_CALLOC
    free( sigin_sr_tab );

#endif
    return lg_out;
}

+1 −0
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@
#define FIX_OUTPUT_FRAME                                /* VA: harmonize "output_frame" parameter usage to correspond to FLP */
#define HARMONIZE_ISSUE_2435_WRITETNSDATA               /* FhG basop 2435: Harmonize WriteTnsData*_fx(), EncodeTnsData*_fx() */
#define HARM_2336_DOTP                                       /* VA: basop 2336; Harmonisation of some dot_product function + some BE optimisation */
#define FIX_2431_AVOID_CALLOC                           /* VA: basp issue 2431: avoid use of calloc() */

/* #################### End BE switches ################################## */

+10 −1
Original line number Diff line number Diff line
@@ -7346,8 +7346,14 @@ void core_switching_hq_prepare_dec_fx(
);

ivas_error amr_wb_dec_fx(
#ifdef FIX_2431_AVOID_CALLOC
    Decoder_State *st_fx,  /* i/o: Decoder static variables structure      */
    Word16 output_sp[],    /* o  : synthesis output                        */
    Word32 *mem_hp20_in_fx /* i/o: hp20 filter memory                    Qx*/
#else
    Word16 output_sp[],  /* o  : synthesis output                        */
    Decoder_State *st_fx /* o  : Decoder static variables structure      */
#endif
);

void amr_wb_dec_init_fx(
@@ -8719,6 +8725,9 @@ void d_gain_pred_fx(
ivas_error evs_dec_fx(
    Decoder_State *st_fx, /* i/o  : Decoder state structure  */
    Word16 output_sp[],   /* o    : output synthesis signal  */
#ifdef FIX_2431_AVOID_CALLOC
    Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory       Qx*/
#endif
    FRAME_MODE frameMode /* i    : Decoder frame mode       */
);

+4 −0
Original line number Diff line number Diff line
@@ -44,7 +44,11 @@ ivas_error DTFS_new_fx(
    Word16 i;

    DTFS_STRUCTURE *dtfs_fx = NULL;
#ifdef FIX_2431_AVOID_CALLOC
    dtfs_fx = (DTFS_STRUCTURE *) malloc( sizeof( DTFS_STRUCTURE ) );
#else
    dtfs_fx = (DTFS_STRUCTURE *) calloc( 1, sizeof( DTFS_STRUCTURE ) );
#endif
    IF( dtfs_fx == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTFS (SC-VBR) structure\n" ) );
Loading