Commit e2a48c74 authored by vaclav's avatar vaclav
Browse files

- port FIX_1585_ASAN_FORMAT_SW_ALT

- remove FIX_1585_ASAN_FORMAT_SW
parent 2ed9629a
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@
#define FIX_2095_REMOVE_UNUSED_ISAR_TABLES              /* Dolby: remove unused ISAR */
#define FIX_BASOP_2560_STEREO_DFT_DEC_RESET             /* FhG: BASOP issue 2560: align reset of hStereoDft->res_gains_ind_fx[][] between BASOP and float */
#define HARMONIZE_2539_cng_energy                       /* FhG: basop issue 2539: harmonize cng_energy with its ivas derivate */
#define FIX_1585_ASAN_FORMAT_SW                         /* VA: float issue 1585: fix memory leaks with format switching */
#define FIX_1585_ASAN_FORMAT_SW_ALT                     /* VA: float issue 1585: alternative fix memory leaks with format switching */

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

+24 −0
Original line number Diff line number Diff line
@@ -477,7 +477,9 @@ ivas_error ivas_hp20_dec_reconfig_fx(
)
{
    Word16 i, nchan_hp20;
#ifndef FIX_1585_ASAN_FORMAT_SW_ALT
    Word32 **old_mem_hp20_out_fx;
#endif
    ivas_error error;

    error = IVAS_ERR_OK;
@@ -491,6 +493,18 @@ ivas_error ivas_hp20_dec_reconfig_fx(

    IF( GT_16( nchan_hp20, nchan_hp20_old ) )
    {
#ifdef FIX_1585_ASAN_FORMAT_SW_ALT
        /* create additional hp20 memories */
        FOR( i = nchan_hp20_old; i < nchan_hp20; i++ )
        {
            IF( ( st_ivas->mem_hp20_out_fx[i] = (Word32 *) malloc( ( L_HP20_MEM + 2 ) * sizeof( Word32 ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
            }

            set32_fx( st_ivas->mem_hp20_out_fx[i], 0, L_HP20_MEM + 2 );
        }
#else
        /* save old mem_hp_20 pointer */
        old_mem_hp20_out_fx = st_ivas->mem_hp20_out_fx;
        st_ivas->mem_hp20_out_fx = NULL;
@@ -519,9 +533,18 @@ ivas_error ivas_hp20_dec_reconfig_fx(

        free( old_mem_hp20_out_fx );
        old_mem_hp20_out_fx = NULL;
#endif
    }
    ELSE IF( LT_16( nchan_hp20, nchan_hp20_old ) )
    {
#ifdef FIX_1585_ASAN_FORMAT_SW_ALT
        /* remove superfluous hp20 memories */
        FOR( i = nchan_hp20; i < nchan_hp20_old; i++ )
        {
            free( st_ivas->mem_hp20_out_fx[i] );
            st_ivas->mem_hp20_out_fx[i] = NULL;
        }
#else
        /* save old mem_hp_20 pointer */
        old_mem_hp20_out_fx = st_ivas->mem_hp20_out_fx;
        st_ivas->mem_hp20_out_fx = NULL;
@@ -546,6 +569,7 @@ ivas_error ivas_hp20_dec_reconfig_fx(

        free( old_mem_hp20_out_fx );
        old_mem_hp20_out_fx = NULL;
#endif
    }

    return error;
+421 −420
Original line number Diff line number Diff line
@@ -144,11 +144,9 @@ ivas_error ivas_dec_get_format_fx(
    test();
    IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->ivas_format, st_ivas->last_ivas_format ) &&
        !( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_ISM_FORMAT ) ) &&
        !( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) )
    {
        !( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
        IF( Opt_tsm )
        {
        IF( Opt_tsm ){
#endif
            st_ivas->restartNeeded = 1;
    move16();
@@ -199,11 +197,9 @@ ivas_error ivas_dec_get_format_fx(
        }

        test();
            IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) )
            {
        IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
                IF( Opt_tsm )
                {
            IF( Opt_tsm ){
#endif
                st_ivas->restartNeeded = 1;
        move16();
@@ -240,11 +236,9 @@ ivas_error ivas_dec_get_format_fx(
    num_bits_read = add( num_bits_read, SBA_PLANAR_BITS );

    test();
            IF( st_ivas->ini_frame > 0 && NE_16( sba_planar, st_ivas->sba_planar ) )
            {
    IF( st_ivas->ini_frame > 0 && NE_16( sba_planar, st_ivas->sba_planar ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
                IF( Opt_tsm )
                {
        IF( Opt_tsm ){
#endif
            st_ivas->restartNeeded = 1;
    move16();
@@ -268,11 +262,9 @@ ivas_error ivas_dec_get_format_fx(
sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) );

test();
            IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) )
            {
IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
                IF( Opt_tsm )
                {
    IF( Opt_tsm ){
#endif
        st_ivas->restartNeeded = 1;
move16();
@@ -374,11 +366,9 @@ ivas_error ivas_dec_get_format_fx(
    }

    test();
            IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) )
            {
    IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
                IF( Opt_tsm )
                {
        IF( Opt_tsm ){
#endif
            st_ivas->restartNeeded = 1;
    move16();
@@ -410,11 +400,9 @@ ivas_error ivas_dec_get_format_fx(
    st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, nchan_ism );

    test();
            IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) )
            {
    IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
                IF( Opt_tsm )
                {
        IF( Opt_tsm ){
#endif
            st_ivas->restartNeeded = 1;
    move16();
@@ -442,11 +430,9 @@ ivas_error ivas_dec_get_format_fx(
    nchan_ism = add( add( shl( st_ivas->bit_stream[k - 1], 1 ), st_ivas->bit_stream[k - 2] ), 1 );

    test();
            IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) )
            {
    IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
                IF( Opt_tsm )
                {
        IF( Opt_tsm ){
#endif
            st_ivas->restartNeeded = 1;
    move16();
@@ -487,11 +473,9 @@ ivas_error ivas_dec_get_format_fx(
}

test();
            IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) )
            {
IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
                IF( Opt_tsm )
                {
    IF( Opt_tsm ){
#endif
        st_ivas->restartNeeded = 1;
move16();
@@ -531,11 +515,9 @@ ivas_error ivas_dec_get_format_fx(
    signaled_config = ivas_mc_map_ls_setup_to_output_config_fx( idx );

    test();
            IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->transport_config, signaled_config ) )
            {
    IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->transport_config, signaled_config ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
                IF( Opt_tsm )
                {
        IF( Opt_tsm ){
#endif
            st_ivas->restartNeeded = 1;
    move16();
@@ -647,11 +629,9 @@ ivas_error ivas_dec_get_format_fx(
        k = sub( k, 1 );

        test();
            IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) )
            {
        IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
                IF( Opt_tsm )
                {
            IF( Opt_tsm ){
#endif
                st_ivas->restartNeeded = 1;
        move16();
@@ -2743,6 +2723,7 @@ ivas_error ivas_init_decoder_fx(
    /* set number of output channels used for synthesis/decoding */
    n = getNumChanSynthesis( st_ivas );

#ifndef FIX_1585_ASAN_FORMAT_SW_ALT
    IF( n > 0 )
    {
        IF( ( st_ivas->mem_hp20_out_fx = (Word32 **) malloc( n * sizeof( Word32 * ) ) ) == NULL )
@@ -2754,7 +2735,7 @@ ivas_error ivas_init_decoder_fx(
    {
        st_ivas->mem_hp20_out_fx = NULL;
    }

#endif
    FOR( i = 0; i < n; i++ )
    {
        IF( ( st_ivas->mem_hp20_out_fx[i] = (Word32 *) malloc( ( L_HP20_MEM + 2 ) * sizeof( Word32 ) ) ) == NULL )
@@ -2764,6 +2745,13 @@ ivas_error ivas_init_decoder_fx(
        set32_fx( st_ivas->mem_hp20_out_fx[i], 0, L_HP20_MEM + 2 );
    }

#ifdef FIX_1585_ASAN_FORMAT_SW_ALT
    FOR( ; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ )
    {
        st_ivas->mem_hp20_out_fx[i] = NULL;
    }
#endif

    /*-------------------------------------------------------------------*
     * Allocate and initialize rendering handles
     *--------------------------------------------------------------------*/
@@ -3383,7 +3371,9 @@ void ivas_initialize_handles_dec(
#ifdef FIX_FMSW_DEC
    }
#endif
#ifndef FIX_1585_ASAN_FORMAT_SW_ALT
    st_ivas->mem_hp20_out_fx = NULL;
#endif
    st_ivas->hLimiter = NULL;

    /* ISM metadata handles */
@@ -3527,6 +3517,16 @@ void ivas_destroy_dec_fx(
    }

    /* HP20 filter handles */
#ifdef FIX_1585_ASAN_FORMAT_SW_ALT
    FOR( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ )
    {
        IF( st_ivas->mem_hp20_out_fx[i] != NULL )
        {
            free( st_ivas->mem_hp20_out_fx[i] );
            st_ivas->mem_hp20_out_fx[i] = NULL;
        }
    }
#else
    IF( st_ivas->mem_hp20_out_fx != NULL )
    {
        FOR( i = 0; i < getNumChanSynthesis( st_ivas ); i++ )
@@ -3537,6 +3537,7 @@ void ivas_destroy_dec_fx(
        free( st_ivas->mem_hp20_out_fx );
        st_ivas->mem_hp20_out_fx = NULL;
    }
#endif

    /* ISM metadata handles */
    ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 );
+4 −0
Original line number Diff line number Diff line
@@ -1119,7 +1119,11 @@ typedef struct Decoder_Struct
    UWord16 *bit_stream;                                    /* Pointer to bitstream buffer */
    Word16 writeFECoffset;                                  /* parameter for debugging JBM stuff */
    
#ifdef FIX_1585_ASAN_FORMAT_SW_ALT
    Word32 *mem_hp20_out_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* output signals HP filter memories */
#else
    Word32 **mem_hp20_out_fx;                               /* output signals HP filter memories */
#endif
    IVAS_LIMITER_HANDLE hLimiter;                           /* Limiter handle */

    /* core-decoder modules */
+0 −5
Original line number Diff line number Diff line
@@ -456,11 +456,6 @@ ivas_error IVAS_DEC_Restart(
    hIvasDec->mode = mode;
    move16();

#ifdef FIX_1585_ASAN_FORMAT_SW
    /* set 'ivas_format' to the last one to properly close IVAS decoder handles */
    hIvasDec->st_ivas->ivas_format = hIvasDec->st_ivas->last_ivas_format;
#endif

    /* destroy Split binaural renderer (ISAR) handle */
    ivas_destroy_handle_isar( &hIvasDec->st_ivas->hSplitBinRend );