Commit 4714a44d authored by Sandesh Venkatesh's avatar Sandesh Venkatesh Committed by Manuel Jander
Browse files

Fix for 3GPP issue 1341: Usage of open/deleteCldfb() functions - multiple variants

Link #1341
parent 820ea273
Loading
Loading
Loading
Loading
+10 −97
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)  */
    CODE_TYPE code_type )
{
    HANDLE_CLDFB_FILTER_BANK hs;
    Word16 buf_len;
@@ -1379,7 +1379,14 @@ ivas_error openCldfb_ivas_fx(
    move32();
    hs->prototype = prototype;
    move32();
    IF( code_type == IVAS_ENC )
    {
        configureCldfb_ivas_enc_fx( hs, sampling_rate );
    }
    ELSE
    {
        configureCldfb_ivas_fx( hs, sampling_rate );
    }
    hs->memory32 = NULL;
    hs->FilterStates = NULL;
    hs->memory_length = 0;
@@ -1413,65 +1420,6 @@ ivas_error openCldfb_ivas_fx(
    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;

    return IVAS_ERR_OK;
}

/*-------------------------------------------------------------------*
 * resampleCldfb_ivas()
 *
@@ -1563,41 +1511,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  */
)
+5 −1
Original line number Diff line number Diff line
@@ -803,7 +803,11 @@ typedef enum
    CLDFB_ANALYSIS,
    CLDFB_SYNTHESIS
} CLDFB_TYPE;

typedef enum
{
    IVAS_ENC,
    IVAS_DEC_REND
} CODE_TYPE;
typedef enum
{
    CLDFB_PROTOTYPE_1_25MS,
+2 −13
Original line number Diff line number Diff line
@@ -9803,8 +9803,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)  */
    CODE_TYPE code_type );
Word32 rand_gauss_fx(
    Word32 *x,
@@ -11944,13 +11944,6 @@ ivas_error openCldfb_ivas(
    CLDFB_PROTOTYPE prototype          /* i  : CLDFB version (1.25ms/5ms delay) */
);
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) */
);
void resampleCldfb_ivas(
    HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle          */
    const Word32 newSamplerate   /* i  : new samplerate to operate   */
@@ -11960,10 +11953,6 @@ ivas_error cldfb_save_memory_ivas(
    HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle          */
);
void deleteCldfb_ivas(
    HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle          */
);
/*! r: flag indicating a valid bitrate */
Word16 is_EVS_bitrate(
    const Word32 ivas_total_brate, /* i  : EVS total bitrate  */
+3 −3
Original line number Diff line number Diff line
@@ -1447,13 +1447,13 @@ ivas_error init_decoder_ivas_fx(
    IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) )
    {
        /* open analysis for max. SR 48kHz */
        IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) )
        IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) )
        {
            return error;
        }

        /* open analysis BPF for max. SR 16kHz */
        IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) )
        IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) )
        {
            return error;
        }
@@ -1465,7 +1465,7 @@ ivas_error init_decoder_ivas_fx(
    }

    /* open synthesis for output SR */
    IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) )
    IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) )
    {
        return error;
    }
+2 −2
Original line number Diff line number Diff line
@@ -602,7 +602,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx(
        /* create additional CLDFB synthesis instances */
        FOR( i = numCldfbAnalyses_old; i < numCldfbAnalyses; i++ )
        {
            IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) )
            IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) )
            {
                return error;
            }
@@ -622,7 +622,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx(
        /* create additional CLDFB synthesis instances */
        FOR( i = numCldfbSyntheses_old; i < numCldfbSyntheses; i++ )
        {
            IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) )
            IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) )
            {
                return error;
            }
Loading