Commit 35bbe937 authored by Nishant S Kulgod's avatar Nishant S Kulgod
Browse files

commit 1

parent 32128433
Loading
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@
 *-------------------------------------------------------------------*/

/*! r: index of next coefficient */
#ifndef IVAS_FLOAT_FIXED
int16_t get_next_coeff_mapped_ivas(
    int16_t ii[2],            /* i/o: coefficient indexes       */
    int32_t *pp,              /* o  : peak(1)/hole(0) indicator */
@@ -64,6 +65,28 @@ int16_t get_next_coeff_mapped_ivas(

    return hm_cfg->indexBuffer[*idx];
}
#else
Word16 get_next_coeff_mapped_ivas(
    Word16 ii[2],            /* i/o: coefficient indexes       */
    Word32 *pp,              /* o  : peak(1)/hole(0) indicator */
    Word16 *idx,             /* o  : index in unmapped domain  */
    CONTEXT_HM_CONFIG *hm_cfg /* i  : HM configuration          */
)
{
    UWord32 p;

    p = s_and( sub( ii[1], hm_cfg->numPeakIndices ), sub( hm_cfg->indexBuffer[ii[1]], hm_cfg->indexBuffer[ii[0]] ) );
    p >>= sub( sizeof( p ) * 8, 1 );
    *pp = p;
    move32();
    *idx = ii[p];
    move16();
    ii[p] = add( ii[p], 1 );
    move16();

    return hm_cfg->indexBuffer[*idx];
}
#endif


/*-------------------------------------------------------------------*
+2 −2
Original line number Diff line number Diff line
@@ -223,7 +223,7 @@ void powfp_odd2_evs(
 * and decoder remain synchronized.
 *-------------------------------------------------------------------------*/

void tcx_arith_scale_envelope_flt(
void tcx_arith_scale_envelope_ivas(
    const Word16 L_spec_core,    /* i  : number of lines to scale    Q0 */
    Word16 L_frame,              /* i  : number of lines             Q0 */
    const Word32 env[],          /* i  : unscaled envelope           Q16 */
@@ -518,7 +518,7 @@ void tcx_arith_scale_envelope_flt(
 * and decoder remain synchronized.
 *-------------------------------------------------------------------------*/

void tcx_arith_render_envelope_flt(
void tcx_arith_render_envelope_ivas(
    const Word16 A_ind[],     /* i  : LPC coefficients of signal envelope        */
    const Word16 L_frame,     /* i  : number of spectral lines                   */
    const Word16 L_spec,      /* i  : length of the coded spectrum               */
+249 −0
Original line number Diff line number Diff line
@@ -159,6 +159,138 @@ Word16 rate2EVSmode_float(
 * Re-allocate the list of indices
 *-------------------------------------------------------------------*/

#ifdef IVAS_FLOAT_FIXED
ivas_error ind_list_realloc(
    INDICE_HANDLE old_ind_list,   /* i  : pointer to the beginning of the old buffer of indices */
    const Word16 max_num_indices, /* i  : new maximum number of allowed indices in the list */
    Encoder_Struct *st_ivas       /* i  : IVAS encoder structure                  */
)
{
    Word16 i, n, ch, n_channels, ind_list_pos, is_metadata, ivas_max_num_indices;
    INDICE_HANDLE new_ind_list;
    BSTR_ENC_HANDLE hBstr;

    IF( st_ivas == NULL )
    {
        return IVAS_ERR_OK;
    }

    /* get the pointer to the beginning of the old buffer of indices (either metadata or core coders) */
    IF( old_ind_list == st_ivas->ind_list_metadata )
    {
        is_metadata = 1;
        ivas_max_num_indices = st_ivas->ivas_max_num_indices_metadata;
    }
    ELSE
    {
        is_metadata = 0;
        ivas_max_num_indices = st_ivas->ivas_max_num_indices;
    }
    move16();
    move16();

    /* allocate new buffer of indices */
    IF( ( new_ind_list = (INDICE_HANDLE) malloc( max_num_indices * sizeof( Indice ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for buffer of indices!\n" ) );
    }

    /* move indices from the old list to the new list */
    FOR( i = 0; i < s_min( max_num_indices, ivas_max_num_indices ); i++ )
    {
        IF( GT_16( old_ind_list[i].nb_bits, -1 ) )
        {
            new_ind_list[i].id = old_ind_list[i].id;
            new_ind_list[i].value = old_ind_list[i].value;
            move16();
            move16();
        }
        new_ind_list[i].nb_bits = old_ind_list[i].nb_bits;
        move16();
    }

    /* reset nb_bits of all other indices to -1 */
    FOR( ; i < max_num_indices; i++ )
    {
        new_ind_list[i].nb_bits = -1;
        move16();
    }

    /* update parameters in all SCE elements */
    FOR( n = 0; n < st_ivas->nSCE; n++ )
    {
        /* get the pointer to hBstr */
        IF( is_metadata )
        {
            hBstr = st_ivas->hSCE[n]->hMetaData;
        }
        ELSE
        {
            hBstr = st_ivas->hSCE[n]->hCoreCoder[0]->hBstr;
        }

        IF( hBstr != NULL )
        {
            /* get the current position inside the old list */
            ind_list_pos = (Word16) ( hBstr->ind_list - old_ind_list );

            /* set pointers in the new list */
            *( hBstr->ivas_ind_list_zero ) = new_ind_list;
            hBstr->ind_list = &new_ind_list[ind_list_pos];

            /* set the new maximum number of indices */
            *( hBstr->ivas_max_num_indices ) = max_num_indices;
            move16();
        }
    }

    /* update parameters in all CPE elements */
    FOR( n = 0; n < st_ivas->nCPE; n++ )
    {
        /* get the pointer to hBstr */
        IF( is_metadata )
        {
            n_channels = 1;
        }
        ELSE
        {
            n_channels = CPE_CHANNELS;
        }
        move16();

        FOR( ch = 0; ch < n_channels; ch++ )
        {
            IF( is_metadata )
            {
                hBstr = st_ivas->hCPE[n]->hMetaData;
            }
            ELSE
            {
                hBstr = st_ivas->hCPE[n]->hCoreCoder[ch]->hBstr;
            }

            IF( hBstr != NULL )
            {
                /* get the current position inside the old list */
                ind_list_pos = (Word16) ( hBstr->ind_list - old_ind_list );

                /* set pointers in the new list */
                *( hBstr->ivas_ind_list_zero ) = new_ind_list;
                hBstr->ind_list = &new_ind_list[ind_list_pos];

                /* set the new maximum number of indices */
                *( hBstr->ivas_max_num_indices ) = max_num_indices;
                move16();
            }
        }
    }

    /* free the old list */
    free( old_ind_list );

    return IVAS_ERR_OK;
}
#else
ivas_error ind_list_realloc(
    INDICE_HANDLE old_ind_list,    /* i  : pointer to the beginning of the old buffer of indices */
    const int16_t max_num_indices, /* i  : new maximum number of allowed indices in the list */
@@ -280,6 +412,7 @@ ivas_error ind_list_realloc(

    return IVAS_ERR_OK;
}
#endif // IVAS_FLOAT_FIXED


/*-----------------------------------------------------------------------*
@@ -1267,6 +1400,61 @@ void move_indices(
 * Check, if we will not overwrite an existing indice -> adjust the location
 *-------------------------------------------------------------------*/

#ifdef IVAS_FLOAT_FIXED
ivas_error check_ind_list_limits(
    BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle                    */
)
{
    Indice *ivas_ind_list_zero, *ivas_ind_list_last;
    ivas_error error;

    error = IVAS_ERR_OK;
    move32();
    ivas_ind_list_zero = *( hBstr->ivas_ind_list_zero );

    /* check, if the maximum number of indices has been reached and re-allocate the buffer */
    /* the re-allocation can be avoided by increasing the limits in get_ivas_max_num_indices() or get_ivas_max_num_indices_metadata() */
    IF( GE_16( (Word16)( &hBstr->ind_list[hBstr->nb_ind_tot] - ivas_ind_list_zero ), *( hBstr->ivas_max_num_indices ) ) )
    {

        /* reallocate the buffer of indices with increased limit */
        IF( ( error = ind_list_realloc( *hBstr->ivas_ind_list_zero, *( hBstr->ivas_max_num_indices ) + STEP_MAX_NUM_INDICES, hBstr->st_ivas ) ) != IVAS_ERR_OK )
        {
            return error;
        }
    }

    /* check, if we will not overwrite an existing indice */
    IF( hBstr->ind_list[hBstr->nb_ind_tot].nb_bits > 0 )
    {
        IF( hBstr->nb_ind_tot == 0 )
        {
            /* move the pointer to the next available empty slot */
            ivas_ind_list_last = &ivas_ind_list_zero[*( hBstr->ivas_max_num_indices )];
            WHILE( hBstr->ind_list[0].nb_bits > 0 && hBstr->ind_list < ivas_ind_list_last )
            {
                hBstr->ind_list++;
            }

            IF( hBstr->ind_list >= ivas_ind_list_last )
            {

                /* no available empty slot -> need to re-allocate the buffer */
                IF( ( error = ind_list_realloc( *hBstr->ivas_ind_list_zero, *( hBstr->ivas_max_num_indices ) + STEP_MAX_NUM_INDICES, hBstr->st_ivas ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
            }
        }
        ELSE
        {
            return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Buffer of indices corrupted in frame %d! Attempt to overwrite indice ID = %d (value: %d, bits: %d)!\n", hBstr->ind_list[hBstr->nb_ind_tot].id, hBstr->ind_list[hBstr->nb_ind_tot].value, hBstr->ind_list[hBstr->nb_ind_tot].nb_bits );
        }
    }

    return error;
}
#else
ivas_error check_ind_list_limits(
    BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle                    */
)
@@ -1319,6 +1507,7 @@ ivas_error check_ind_list_limits(

    return error;
}
#endif // IVAS_FLOAT_FIXED


/*-------------------------------------------------------------------*
@@ -1327,6 +1516,65 @@ ivas_error check_ind_list_limits(
 * Push a new indice into the buffer
 *-------------------------------------------------------------------*/

#ifdef IVAS_FLOAT_FIXED
ivas_error push_indice(
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle                    */
    Word16 id,             /* i  : ID of the indice                            */
    UWord16 value,         /* i  : value of the quantized indice               */
    Word16 nb_bits         /* i  : number of bits used to quantize the indice  */
)
{
    Word16 i;
    Word16 j;
    ivas_error error;

    error = IVAS_ERR_OK;
    move32();

    /* check the limits of the list of indices */
    IF( ( error = check_ind_list_limits( hBstr ) ) != IVAS_ERR_OK )
    {
        return IVAS_ERROR( error, "Error occured in push_indice() while re-allocating the list of indices (frame %d) !\n" );
    }

    /* find the location in the list of indices based on ID */
    i = hBstr->nb_ind_tot;
    move16();
    WHILE ( i > 0 && LT_16( id, hBstr->ind_list[i - 1].id ) )
    {
        i = sub( i, 1 );
    }

    /* shift indices, if the new ID is to be written somewhere inside the list */
    IF ( i < hBstr->nb_ind_tot )
    {
        FOR ( j = hBstr->nb_ind_tot; j > i; j-- )
        {
            hBstr->ind_list[j].id = hBstr->ind_list[j - 1].id;
            hBstr->ind_list[j].nb_bits = hBstr->ind_list[j - 1].nb_bits;
            hBstr->ind_list[j].value = hBstr->ind_list[j - 1].value;
            move16();
            move16();
            move16();
        }
    }


    /* store the new indice in the list */
    hBstr->ind_list[i].id = id;
    hBstr->ind_list[i].value = value;
    hBstr->ind_list[i].nb_bits = nb_bits;
    move16();
    move16();
    move16();

    /* updates */
    hBstr->nb_ind_tot = add( hBstr->nb_ind_tot, 1 );
    hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits );

    return error;
}
#else
ivas_error push_indice(
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle                    */
    int16_t id,            /* i  : ID of the indice                            */
@@ -1377,6 +1625,7 @@ ivas_error push_indice(

    return error;
}
#endif // IVAS_FLOAT_FIXED

/*-------------------------------------------------------------------*
 * push_next_indice()
+38 −38
Original line number Diff line number Diff line
@@ -280,23 +280,23 @@ void push_indice_fx(
        /* new indice - find an empty slot in the list */
        i = id;
        move16();
        WHILE( NE_16( hBstr->ind_list_fx[i].nb_bits, -1 ) )
        WHILE( NE_16( hBstr->ind_list[i].nb_bits, -1 ) )
        {
            i = add( i, 1 );
        }
    }

    /* store the values in the list */
    hBstr->ind_list_fx[i].value = value;
    hBstr->ind_list[i].value = value;
    move16();
    hBstr->ind_list_fx[i].nb_bits = nb_bits;
    hBstr->ind_list[i].nb_bits = nb_bits;
    move16();

    /* updates */
    hBstr->next_ind_fx = add( i, 1 );
    hBstr->last_ind_fx = id;
    move16();
    hBstr->nb_bits_tot_fx = add( hBstr->nb_bits_tot_fx, nb_bits );
    hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits );

    return;
}
@@ -314,15 +314,15 @@ void push_next_indice_fx(
{

    /* store the values in the list */
    hBstr->ind_list_fx[hBstr->next_ind_fx].value = value;
    hBstr->ind_list[hBstr->next_ind_fx].value = value;
    move16();
    hBstr->ind_list_fx[hBstr->next_ind_fx].nb_bits = nb_bits;
    hBstr->ind_list[hBstr->next_ind_fx].nb_bits = nb_bits;
    move16();
    hBstr->next_ind_fx = add( hBstr->next_ind_fx, 1 );


    /* update the total number of bits already written */
    hBstr->nb_bits_tot_fx = add( hBstr->nb_bits_tot_fx, nb_bits );
    hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits );

    return;
}
@@ -343,7 +343,7 @@ void push_next_bits_fx(
    Word16 i, nb_bits_m15;
    Indice *ptr;

    ptr = &hBstr->ind_list_fx[hBstr->next_ind_fx];
    ptr = &hBstr->ind_list[hBstr->next_ind_fx];
    nb_bits_m15 = sub( nb_bits, 15 );
    i = 0;
    move16();
@@ -374,8 +374,8 @@ void push_next_bits_fx(
            ++ptr;
        }
    }
    hBstr->next_ind_fx = (Word16) ( ptr - hBstr->ind_list_fx );
    hBstr->nb_bits_tot_fx = add( hBstr->nb_bits_tot_fx, nb_bits );
    hBstr->next_ind_fx = (Word16) ( ptr - hBstr->ind_list );
    hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits );
}

/*-------------------------------------------------------------------*
@@ -532,7 +532,7 @@ void reset_indices_enc_fx(
{
    Word16 i;

    hBstr->nb_bits_tot_fx = 0;
    hBstr->nb_bits_tot = 0;
    move16();
    hBstr->next_ind_fx = 0;
    move16();
@@ -541,7 +541,7 @@ void reset_indices_enc_fx(

    FOR( i = 0; i < MAX_NUM_INDICES; i++ )
    {
        hBstr->ind_list_fx[i].nb_bits = -1;
        hBstr->ind_list[i].nb_bits = -1;
        move16();
    }

@@ -596,7 +596,7 @@ void write_indices_fx(
            stream[i] = 0;
        }
        *pt_stream++ = (Word16) SYNC_GOOD_FRAME;
        *pt_stream++ = hBstr->nb_bits_tot_fx;
        *pt_stream++ = hBstr->nb_bits_tot;

        /*----------------------------------------------------------------*
         * Bitstream packing (conversion of individual indices into a serial stream)
@@ -605,15 +605,15 @@ void write_indices_fx(

        for ( i = 0; i < MAX_NUM_INDICES; i++ )
        {
            if ( hBstr->ind_list_fx[i].nb_bits != -1 )
            if ( hBstr->ind_list[i].nb_bits != -1 )
            {
                /* mask from MSB to LSB */
                mask = 1 << ( hBstr->ind_list_fx[i].nb_bits - 1 );
                mask = 1 << ( hBstr->ind_list[i].nb_bits - 1 );

                /* write bit by bit */
                for ( k = 0; k < hBstr->ind_list_fx[i].nb_bits; k++ )
                for ( k = 0; k < hBstr->ind_list[i].nb_bits; k++ )
                {
                    if ( hBstr->ind_list_fx[i].value & mask )
                    if ( hBstr->ind_list[i].value & mask )
                    {
                        *pt_stream++ = G192_BIN1;
                    }
@@ -631,7 +631,7 @@ void write_indices_fx(
    {
        /* Create and write ToC header */
        /*  qbit always  set to  1 on encoder side  for AMRWBIO ,  no qbit in use for EVS, but set to 0(bad)  */
        header = (UWord8) ( st_fx->Opt_AMR_WB << 5 | st_fx->Opt_AMR_WB << 4 | rate2EVSmode( hBstr->nb_bits_tot_fx * 50, &isAmrWb ) );
        header = (UWord8) ( st_fx->Opt_AMR_WB << 5 | st_fx->Opt_AMR_WB << 4 | rate2EVSmode( hBstr->nb_bits_tot * 50, &isAmrWb ) );
        fwrite( &header, sizeof( UWord8 ), 1, file );
        /* Write speech bits */
        fwrite( pFrame, sizeof( UWord8 ), ( pFrame_size + 7 ) >> 3, file );
@@ -640,7 +640,7 @@ void write_indices_fx(
    /* Clearing of indices */
    FOR( i = 0; i < MAX_NUM_INDICES; i++ )
    {
        hBstr->ind_list_fx[i].nb_bits = -1;
        hBstr->ind_list[i].nb_bits = -1;
        move16();
    }

@@ -651,7 +651,7 @@ void write_indices_fx(
        fwrite( stream, sizeof( unsigned short ), 2 + stream[1], file );
    }
    /* reset index pointers */
    hBstr->nb_bits_tot_fx = 0;
    hBstr->nb_bits_tot = 0;
    hBstr->next_ind_fx = 0;
    hBstr->last_ind_fx = -1;

@@ -690,7 +690,7 @@ void write_indices_buf_fx(
        }
        //*pt_stream++ = (Word16) SYNC_GOOD_FRAME;
        //*pt_stream++ = hBstr->nb_bits_tot_fx;
        *num_bits = hBstr->nb_bits_tot_fx;
        *num_bits = hBstr->nb_bits_tot;

        /*----------------------------------------------------------------*
         * Bitstream packing (conversion of individual indices into a serial stream)
@@ -698,15 +698,15 @@ void write_indices_buf_fx(
         *----------------------------------------------------------------*/
        for ( i = 0; i < MAX_NUM_INDICES; i++ )
        {
            if ( hBstr->ind_list_fx[i].nb_bits != -1 )
            if ( hBstr->ind_list[i].nb_bits != -1 )
            {
                /* mask from MSB to LSB */
                mask = 1 << ( hBstr->ind_list_fx[i].nb_bits - 1 );
                mask = 1 << ( hBstr->ind_list[i].nb_bits - 1 );

                /* write bit by bit */
                for ( k = 0; k < hBstr->ind_list_fx[i].nb_bits; k++ )
                for ( k = 0; k < hBstr->ind_list[i].nb_bits; k++ )
                {
                    if ( hBstr->ind_list_fx[i].value & mask )
                    if ( hBstr->ind_list[i].value & mask )
                    {
                        //*pt_stream++ = G192_BIN1;
                        *pt_stream++ = 1;
@@ -726,7 +726,7 @@ void write_indices_buf_fx(
    {
        /* Create and write ToC header */
        /*  qbit always  set to  1 on encoder side  for AMRWBIO ,  no qbit in use for EVS, but set to 0(bad)  */
        header = (UWord8) ( st_fx->Opt_AMR_WB << 5 | st_fx->Opt_AMR_WB << 4 | rate2EVSmode( hBstr->nb_bits_tot_fx * 50, &isAmrWb ) );
        header = (UWord8) ( st_fx->Opt_AMR_WB << 5 | st_fx->Opt_AMR_WB << 4 | rate2EVSmode( hBstr->nb_bits_tot * 50, &isAmrWb ) );
        // fwrite(&header, sizeof(UWord8), 1, file);
        memcpy( out_buf, &header, sizeof( UWord8 ) );
        *num_bits += sizeof( UWord8 );
@@ -739,7 +739,7 @@ void write_indices_buf_fx(
    /* Clearing of indices */
    FOR( i = 0; i < MAX_NUM_INDICES; i++ )
    {
        hBstr->ind_list_fx[i].nb_bits = -1;
        hBstr->ind_list[i].nb_bits = -1;
        move16();
    }

@@ -755,7 +755,7 @@ void write_indices_buf_fx(
        //*num_bits += sizeof( unsigned short ) * ( 2 + stream[1] );
    }
    /* reset index pointers */
    hBstr->nb_bits_tot_fx = 0;
    hBstr->nb_bits_tot = 0;
    hBstr->next_ind_fx = 0;
    hBstr->last_ind_fx = -1;

@@ -786,27 +786,27 @@ void indices_to_serial(
    if ( st_fx->Opt_AMR_WB )
    {
        cmi = rate2EVSmode( st_fx->total_brate, &isAmrWb );
        core_mode = rate2EVSmode( hBstr->nb_bits_tot_fx * 50, &isAmrWb );
        core_mode = rate2EVSmode( hBstr->nb_bits_tot * 50, &isAmrWb );

        j = 0;
        for ( i = 0; i < MAX_NUM_INDICES; i++ )
        {
            if ( hBstr->ind_list_fx[i].nb_bits != -1 )
            if ( hBstr->ind_list[i].nb_bits != -1 )
            {
                /* mask from MSB to LSB */
                mask = 1 << ( hBstr->ind_list_fx[i].nb_bits - 1 );
                mask = 1 << ( hBstr->ind_list[i].nb_bits - 1 );

                /* temporarily save bit */
                for ( k = 0; k < hBstr->ind_list_fx[i].nb_bits; k++ )
                for ( k = 0; k < hBstr->ind_list[i].nb_bits; k++ )
                {
                    amrwb_bits[j++] = ( hBstr->ind_list_fx[i].value & mask ) > 0;
                    amrwb_bits[j++] = ( hBstr->ind_list[i].value & mask ) > 0;
                    mask >>= 1;
                }
            }
        }
    }

    *pFrame_size = hBstr->nb_bits_tot_fx;
    *pFrame_size = hBstr->nb_bits_tot;

    /*----------------------------------------------------------------*
     * Bitstream packing (conversion of individual indices into a serial stream)
@@ -814,13 +814,13 @@ void indices_to_serial(
    j = 0;
    for ( i = 0; i < MAX_NUM_INDICES; i++ )
    {
        if ( hBstr->ind_list_fx[i].nb_bits != -1 )
        if ( hBstr->ind_list[i].nb_bits != -1 )
        {
            /* mask from MSB to LSB */
            mask = 1 << ( hBstr->ind_list_fx[i].nb_bits - 1 );
            mask = 1 << ( hBstr->ind_list[i].nb_bits - 1 );

            /* write bit by bit */
            for ( k = 0; k < hBstr->ind_list_fx[i].nb_bits; k++ )
            for ( k = 0; k < hBstr->ind_list[i].nb_bits; k++ )
            {
                if ( st_fx->Opt_AMR_WB )
                {
@@ -828,7 +828,7 @@ void indices_to_serial(
                }
                else
                {
                    pack_bit( hBstr->ind_list_fx[i].value & mask, &pt_pFrame, &omask );
                    pack_bit( hBstr->ind_list[i].value & mask, &pt_pFrame, &omask );
                    j++;
                }
                mask >>= 1;
+29 −28
Original line number Diff line number Diff line
@@ -1716,7 +1716,7 @@ ivas_error openCldfb_ivas_fx(
    return IVAS_ERR_OK;
}

ivas_error openCldfb_ivas_enc(
ivas_error openCldfb_ivas(
    HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle                */
    CLDFB_TYPE type,                   /* i  : analysis or synthesis             */
    const int32_t sampling_rate,       /* i  : sampling rate                     */
@@ -1734,25 +1734,17 @@ ivas_error openCldfb_ivas_enc(
    hs->type = type;
    hs->prototype = prototype;

    configureCldfb_ivas_enc( hs, sampling_rate );
    configureCldfb_ivas( hs, sampling_rate );
    hs->memory_flt = NULL;
    hs->memory_length = 0;

    if ( type == CLDFB_ANALYSIS )
    {
        buf_len = hs->p_filter_length - hs->no_channels;
#ifdef IVAS_FLOAT_FIXED
        hs->FilterStates = (Word16 *) malloc( ( 9 + 16 ) * CLDFB_getNumChannels( sampling_rate ) * sizeof( Word16 ) );
        hs->FilterStates_eg = 0;
#endif
    }
    else
    {
        buf_len = hs->p_filter_length;
#ifdef IVAS_FLOAT_FIXED
        hs->FilterStates = (Word16 *) malloc( 2 * ( 9 + 16 ) * CLDFB_getNumChannels( sampling_rate ) * sizeof( Word16 ) );
        hs->FilterStates_eg = 0;
#endif
    }

    if ( ( hs->cldfb_state = (float *) malloc( buf_len * sizeof( float ) ) ) == NULL )
@@ -1768,8 +1760,7 @@ ivas_error openCldfb_ivas_enc(
    hs->cldfb_state_length = buf_len; // Temporarily added to store the length of buffer
    hs->cldfb_size = buf_len;         /*for having original size at intermediatery conversion, will be removed on removing conversion*/
    set32_fx( hs->cldfb_state_fx, 0, buf_len );
    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] ) );
    hs->Q_cldfb_state = Q11;
#endif // IVAS_FLOAT_FIXED


@@ -1777,6 +1768,7 @@ ivas_error openCldfb_ivas_enc(

    return IVAS_ERR_OK;
}
#else
ivas_error openCldfb_ivas(
    HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle                */
    CLDFB_TYPE type,                   /* i  : analysis or synthesis             */
@@ -1812,25 +1804,15 @@ ivas_error openCldfb_ivas(
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
    }
    set_f( hs->cldfb_state, 0.0f, buf_len );
#ifdef IVAS_FLOAT_FIXED
    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
    hs->cldfb_size = buf_len;         /*for having original size at intermediatery conversion, will be removed on removing conversion*/
    set32_fx( hs->cldfb_state_fx, 0, buf_len );
    hs->Q_cldfb_state = Q11;
#endif // IVAS_FLOAT_FIXED

    set_f( hs->cldfb_state, 0.0f, buf_len );

    *h_cldfb = hs;

    return IVAS_ERR_OK;
}
#else
ivas_error openCldfb_ivas(
#endif
ivas_error openCldfb_ivas_enc(
    HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle                */
    CLDFB_TYPE type,                   /* i  : analysis or synthesis             */
    const int32_t sampling_rate,       /* i  : sampling rate                     */
@@ -1848,31 +1830,50 @@ ivas_error openCldfb_ivas(
    hs->type = type;
    hs->prototype = prototype;

    configureCldfb_ivas( hs, sampling_rate );
    configureCldfb_ivas_enc( hs, sampling_rate );
    hs->memory_flt = NULL;
    hs->memory_length = 0;

    if ( type == CLDFB_ANALYSIS )
    {
        buf_len = hs->p_filter_length - hs->no_channels;
#ifdef IVAS_FLOAT_FIXED
        hs->FilterStates = (Word16 *) malloc( ( 9 + 16 ) * CLDFB_getNumChannels( sampling_rate ) * sizeof( Word16 ) );
        hs->FilterStates_eg = 0;
#endif
    }
    else
    {
        buf_len = hs->p_filter_length;
#ifdef IVAS_FLOAT_FIXED
        hs->FilterStates = (Word16 *) malloc( 2 * ( 9 + 16 ) * CLDFB_getNumChannels( sampling_rate ) * sizeof( Word16 ) );
        hs->FilterStates_eg = 0;
#endif
    }

    if ( ( hs->cldfb_state = (float *) malloc( buf_len * sizeof( float ) ) ) == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
    }

    set_f( hs->cldfb_state, 0.0f, buf_len );
#ifdef IVAS_FLOAT_FIXED
    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
    hs->cldfb_size = buf_len;         /*for having original size at intermediatery conversion, will be removed on removing conversion*/
    set32_fx( hs->cldfb_state_fx, 0, buf_len );
    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] ) );
#endif // IVAS_FLOAT_FIXED


    *h_cldfb = hs;

    return IVAS_ERR_OK;
}
#endif

/*-------------------------------------------------------------------*
 * resampleCldfb_ivas()
 *
Loading