Commit 4772f5fa authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'ivas_ism_dec_fxd_2' into 'main'

Changes for subfunctions of ivas_ism_bitrate_switching_dec function.

See merge request !140
parents 7969c8cc 4a2bbffb
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -231,6 +231,9 @@ typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG
    float pAcoustic_dsr[IVAS_CLDFB_NO_CHANNELS_MAX];  /*  - The room's Diffuse to Source Ratio per center frequency                                         */
    float acousticPreDelay;                           /* Time elapsed between input signal and late reverberation start, float, range [0.001..10]           */
    float inputPreDelay;                              /* Offset in seconds from where DSR is computed in the RIR (0 = at source), float, range [0.001..10]  */
#ifdef IVAS_FLOAT_FIXED
    Word32 acousticPreDelay_fx; /* Time elapsed between input signal and late reverberation start, float, range [0.001..10]           *//*Assumed Q-27*/
#endif // IVAS_FLOAT_FIXED

    /* early reflections */
    int16_t use_er;                      /* ER activation flag      */
+3 −0
Original line number Diff line number Diff line
@@ -1539,6 +1539,9 @@ typedef enum
#define HRTF_NUM_BINS                           60
#define REVERB_PREDELAY_MAX                     20                          /* Max input delay for reverb module */
#define GAIN_LFE                                1.88364911f                 /* Gain applied to LFE during renderering */
#ifdef IVAS_FLOAT_FIXED
#define GAIN_LFE_FX                             30862                 /* Gain applied to LFE during renderering */
#endif // IVAS_FLOAT_FIXED
#define LOW_BIT_RATE_BINAURAL_EQ_BINS           17                          /* Number of bins in an EQ applied at low bit rates in binauralization */
#define LOW_BIT_RATE_BINAURAL_EQ_OFFSET         14                          /* Offset of bins where the low-bit-rate EQ starts*/

+6 −0
Original line number Diff line number Diff line
@@ -379,6 +379,12 @@ ivas_error ivas_corecoder_dec_reconfig(
    const int32_t brate_SCE,                                    /* i  : bitrate to be set for the SCEs                            */
    const int32_t brate_CPE                                     /* i  : bitrate to be set for the CPEs                            */
);
#ifdef IVAS_FLOAT_FIXED
ivas_error ivas_hp20_dec_reconfig_fx(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                  */
    const Word16 nchan_hp20_old                                /* i  : number of HP20 filters in previous frame*/
);
#endif // IVAS_FLOAT_FIXED

ivas_error ivas_hp20_dec_reconfig(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                  */
+78 −0
Original line number Diff line number Diff line
@@ -379,6 +379,84 @@ ivas_error ivas_corecoder_dec_reconfig(
 * Allocate, initialize, and configure HP20 memory handles in case of bitrate switching
 *-------------------------------------------------------------------*/

#ifdef IVAS_FLOAT_FIXED
ivas_error ivas_hp20_dec_reconfig_fx(
    Decoder_Struct *st_ivas,     /* i/o: IVAS decoder structure                     */
    const Word16 nchan_hp20_old /* i  : number of HP20 filters in previous frame   */
)
{
    Word16 i, nchan_hp20;
    Word32 **old_mem_hp20_out_fx;
    ivas_error error;

    error = IVAS_ERR_OK;

    /*-----------------------------------------------------------------*
     * HP20 memories
     *-----------------------------------------------------------------*/

    nchan_hp20 = getNumChanSynthesis( st_ivas );

    IF ( GT_16(nchan_hp20 , nchan_hp20_old) )
    {
        /* save old mem_hp_20 pointer */
        old_mem_hp20_out_fx = st_ivas->mem_hp20_out_fx;
        st_ivas->mem_hp20_out_fx = NULL;

        IF ( ( st_ivas->mem_hp20_out_fx = (Word32 **) malloc( nchan_hp20 * sizeof( Word32 * ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
        }

        FOR ( i = 0; i < nchan_hp20_old; i++ )
        {
            st_ivas->mem_hp20_out_fx[i] = old_mem_hp20_out_fx[i];
            old_mem_hp20_out_fx[i] = NULL;
        }
        /* create additional hp20 memories */
        FOR ( ; i < nchan_hp20; i++ )
        {
            IF ( ( st_ivas->mem_hp20_out_fx[i] = (Word32 *) malloc( L_HP20_MEM * 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 );
        }

        free( old_mem_hp20_out_fx );
        old_mem_hp20_out_fx = NULL;
    }
    ELSE IF ( LT_16(nchan_hp20 , nchan_hp20_old) )
    {
        /* save old mem_hp_20 pointer */
        old_mem_hp20_out_fx = st_ivas->mem_hp20_out_fx;
        st_ivas->mem_hp20_out_fx = NULL;

        IF ( ( st_ivas->mem_hp20_out_fx = (Word32 **) malloc( nchan_hp20 * sizeof(Word32 * ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
        }

        FOR ( i = 0; i < nchan_hp20; i++ )
        {
            st_ivas->mem_hp20_out_fx[i] = old_mem_hp20_out_fx[i];
            old_mem_hp20_out_fx[i] = NULL;
        }
        /* remove superfluous hp20 memories */
        FOR ( ; i < nchan_hp20_old; i++ )
        {
            free( old_mem_hp20_out_fx[i] );
            old_mem_hp20_out_fx[i] = NULL;
        }

        free( old_mem_hp20_out_fx );
        old_mem_hp20_out_fx = NULL;
    }

    return error;
}
#endif
ivas_error ivas_hp20_dec_reconfig(
    Decoder_Struct *st_ivas,     /* i/o: IVAS decoder structure                     */
    const int16_t nchan_hp20_old /* i  : number of HP20 filters in previous frame   */
+15 −0
Original line number Diff line number Diff line
@@ -1696,6 +1696,12 @@ ivas_error ivas_init_decoder(
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
        }
#ifdef IVAS_FLOAT_FIXED
        IF( ( st_ivas->mem_hp20_out_fx = (Word32 **) malloc( n * sizeof(Word32 * ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
        }
#endif // IVAS_FLOAT_FIXED
    }
    ELSE
    {
@@ -1709,6 +1715,12 @@ ivas_error ivas_init_decoder(
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
        }

#ifdef IVAS_FLOAT_FIXED
        IF( ( st_ivas->mem_hp20_out_fx[i] = (Word32 *) malloc( L_HP20_MEM * sizeof(Word32) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
        }
#endif // IVAS_FLOAT_FIXED
        set_f( st_ivas->mem_hp20_out[i], 0.0f, L_HP20_MEM );
    }

@@ -2255,6 +2267,9 @@ void ivas_initialize_handles_dec(

    st_ivas->bit_stream = NULL;
    st_ivas->mem_hp20_out = NULL;
#ifdef IVAS_FLOAT_FIXED
    st_ivas->mem_hp20_out_fx = NULL;
#endif // IVAS_FLOAT_FIXED
    st_ivas->hLimiter = NULL;

    /* ISM metadata handles */
Loading