Commit d7eb3752 authored by norvell's avatar norvell
Browse files

Merge branch 'main' into 1350-crash-in-evs-decoder-at-48-khz

parents 69a038c8 28058dce
Loading
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@
#include "stat_dec.h"
#include "rom_com.h"
#include "mime.h"
#include "ivas_prot.h"
#include "ivas_cnst.h"
#include "ivas_rom_com.h"
#include "wmc_auto.h"
+14 −99
Original line number Diff line number Diff line
@@ -1364,8 +1364,8 @@ ivas_error openCldfb_ivas_fx(
    HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle                */
    CLDFB_TYPE type,                   /* i  : analysis or synthesis             */
    const Word32 sampling_rate,        /* i  : sampling rate                     */
    CLDFB_PROTOTYPE prototype          /* i  : CLDFB version (1.25ms/5ms delay)  */
)
    CLDFB_PROTOTYPE prototype,         /* i  : CLDFB version (1.25ms/5ms delay)  */
    const Word16 enc_dec )             /* i  : encoder/decoder flag            */
{
    HANDLE_CLDFB_FILTER_BANK hs;
    Word16 buf_len;
@@ -1379,7 +1379,17 @@ ivas_error openCldfb_ivas_fx(
    move32();
    hs->prototype = prototype;
    move32();
    IF( enc_dec == ENC )
    {
        configureCldfb_ivas_enc_fx( hs, sampling_rate );
        hs->Q_cldfb_state = 0;
    }
    ELSE
    {
        configureCldfb_ivas_fx( hs, sampling_rate );
        hs->Q_cldfb_state = Q11;
    }
    move16();
    hs->memory32 = NULL;
    hs->FilterStates = NULL;
    hs->memory_length = 0;
@@ -1405,69 +1415,9 @@ ivas_error openCldfb_ivas_fx(
    hs->cldfb_size = buf_len; /*for having original size at intermediatery conversion, will be removed on removing conversion*/
    move16();
    set32_fx( hs->cldfb_state_fx, 0, buf_len );
    hs->Q_cldfb_state = Q11;
    move16();
    *h_cldfb = hs;
    move16();

    return IVAS_ERR_OK;
}

ivas_error openCldfb_ivas_enc(
    HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle                */
    CLDFB_TYPE type,                   /* i  : analysis or synthesis             */
    const Word32 sampling_rate,        /* i  : sampling rate                     */
    CLDFB_PROTOTYPE prototype          /* i  : CLDFB version (1.25ms/5ms delay)  */
)
{
    HANDLE_CLDFB_FILTER_BANK hs;
    Word16 buf_len;

    IF( ( hs = (HANDLE_CLDFB_FILTER_BANK) malloc( sizeof( CLDFB_FILTER_BANK ) ) ) == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
    }

    hs->type = type;
    move32();
    hs->prototype = prototype;
    move32();

    configureCldfb_ivas_enc_fx( hs, sampling_rate );
    hs->memory_length = 0;
    move32();

    IF( type == CLDFB_ANALYSIS )
    {
        buf_len = sub( hs->p_filter_length, hs->no_channels );
        hs->FilterStates = (Word16 *) malloc( ( 9 + 16 ) * CLDFB_getNumChannels( sampling_rate ) * sizeof( Word16 ) );
        hs->FilterStates_eg = 0;
        move16();
    }
    ELSE
    {
        buf_len = hs->p_filter_length;
        move16();
        hs->FilterStates = (Word16 *) malloc( 2 * ( 9 + 16 ) * CLDFB_getNumChannels( sampling_rate ) * sizeof( Word16 ) );
        hs->FilterStates_eg = 0;
        move16();
    }

    if ( ( hs->cldfb_state_fx = (Word32 *) malloc( buf_len * sizeof( Word32 ) ) ) == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
    }
    hs->cldfb_state_length = buf_len; // Temporarily added to store the length of buffer
    move16();
    hs->cldfb_size = buf_len; /*for having original size at intermediatery conversion, will be removed on removing conversion*/
    move16();
    set32_fx( hs->cldfb_state_fx, 0, buf_len );
    hs->Q_cldfb_state = 0;
    move16();
    set16_fx( hs->FilterStates, 0, i_mult( 9 + 16, hs->no_channels ) );
    set16_fx( hs->FilterStates_e, 0, sizeof( hs->FilterStates_e ) / sizeof( hs->FilterStates_e[0] ) );

    *h_cldfb = hs;
    move16();

    return IVAS_ERR_OK;
}
@@ -1563,41 +1513,6 @@ void analysisCldfbEncoder_ivas_fx(
    return;
}


/*-------------------------------------------------------------------*
 * GetEnergyCldfb_ivas()
 *
 * Remove handle
 *--------------------------------------------------------------------*/

void deleteCldfb_ivas(
    HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle  */
)
{
    HANDLE_CLDFB_FILTER_BANK hs = *h_cldfb;

    test();
    IF( h_cldfb == NULL || *h_cldfb == NULL )
    {
        return;
    }

    IF( hs->cldfb_state_fx )
    {
        free( hs->cldfb_state_fx );
    }

    IF( hs->FilterStates )
    {
        free( hs->FilterStates );
    }

    free( hs );
    *h_cldfb = NULL;

    return;
}

void deleteCldfb_ivas_fx(
    HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle  */
)
+0 −1
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@
#include "rom_com.h"
#include "prot_fx.h"
#include "wmc_auto.h"
#include "ivas_prot.h"
#include "ivas_prot_fx.h"

#define FSCALE_DENOM_BY_12800_Q15 1311
+20 −0
Original line number Diff line number Diff line
@@ -7636,6 +7636,26 @@ Word16 norm_arr( Word16 *arr, Word16 size )
    return q;
}

Word16 W_norm_arr( Word64 *arr, Word16 size )
{
    Word16 q = 63;
    Word16 exp = 0;
    move16();
    move16();
    FOR( Word16 i = 0; i < size; i++ )
    {
        if ( arr[i] != 0 )
        {
            exp = W_norm( arr[i] );
        }
        if ( arr[i] != 0 )
        {
            q = s_min( q, exp );
        }
    }
    return q;
}

Word16 get_min_scalefactor( Word32 x, Word32 y )
{
#ifndef FIX_1104_OPT_GETMINSCALEFAC
+5 −6
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@
#include "cnst.h"    /* Common constants                       */
#include "rom_com.h" /* Static table prototypes                */
#include "prot_fx.h" /* Function prototypes                    */
#include "ivas_prot.h" /* Function prototypes                    */
#include "assert.h"  /* Debug prototypes                       */
#include "stl.h"
#include "ivas_prot_fx.h"
Loading