Commit 0eecbb1b authored by emerit's avatar emerit
Browse files

Merge branch 'main' into update_crend

parents d2c6c0d1 7c8eaa92
Loading
Loading
Loading
Loading
+19 −4
Original line number Diff line number Diff line
@@ -1950,7 +1950,7 @@ void analysisCldfbEncoder_ivas(

void analysisCldfbEncoder_ivas_fx(
    Encoder_State *st, /* i/o: encoder state structure   */
    const Word32 *timeIn, /*q11*/
    Word32 *timeIn,    /*q11*/
    Word16 timeInq,
    Word16 samplesToProcess,
    Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
@@ -1967,6 +1967,11 @@ void analysisCldfbEncoder_ivas_fx(
    Word32 *ppBuf_Imag[CLDFB_NO_COL_MAX];
    Word16 *ppBuf_Real16[CLDFB_NO_COL_MAX];
    Word16 *ppBuf_Imag16[CLDFB_NO_COL_MAX];
    Word32 l_timeIn[L_FRAME48k];
    Word16 norm_timeIn = L_norm_arr( timeIn, samplesToProcess );
    Word16 guard_bits = find_guarded_bits_fx( shl( samplesToProcess, 1 ) );
    Word16 shift = 0;
    move16();

    FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ )
    {
@@ -1975,9 +1980,19 @@ void analysisCldfbEncoder_ivas_fx(
        ppBuf_Real16[i] = &realBuffer16[i][0];
        ppBuf_Imag16[i] = &imagBuffer16[i][0];
    }
    cldfbAnalysis_ivas_fx( timeIn, ppBuf_Real, ppBuf_Imag, samplesToProcess, st->cldfbAnaEnc );
    IF( GT_16( guard_bits, norm_timeIn ) )
    {
        shift = sub( guard_bits, norm_timeIn );
        v_shr_32( timeIn, l_timeIn, samplesToProcess, shift );
    }
    ELSE
    {
        Copy32( timeIn, l_timeIn, samplesToProcess );
    }

    cldfbAnalysis_ivas_fx( l_timeIn, ppBuf_Real, ppBuf_Imag, samplesToProcess, st->cldfbAnaEnc );

    scale->lb_scale = sub( 16 + 5, timeInq );
    scale->lb_scale = sub( 16 + 5, sub( timeInq, shift ) );
    enerScale.lb_scale = negate( scale->lb_scale );
    enerScale.lb_scale16 = negate( scale->lb_scale );
    move16();
+4 −1
Original line number Diff line number Diff line
@@ -247,6 +247,7 @@ enum{
#define INV_LOG_2_FX                    23637 /*Q14*//* 1/log(2)  */
#endif // IVAS_FLOAT_FIXED
#define INV_SQRT_2                      0.70710676908493f  /* 1/sqrt(2) */
#define INV_SQRT_2_Q30                  759250112  /* 1/sqrt(2) in Q30*/
#define INV_SQRT_2_Q15                  23170  /* 1/sqrt(2) in Q15 */
#define INV_SQRT_2_Q31                  (Word32)1.51850022e+09  /* 1/sqrt(2) in Q31 */

@@ -784,6 +785,7 @@ enum
#define CLDFB_OVRLP_MIN_SLOTS               3                      /* CLDFB resampling - minimize processing to minimum required for transition frame ACELP->TCX/HQ */
#define INV_CLDFB_BANDWIDTH                 ( 1.f / 800.f )
#define INV_CLDFB_BANDWIDTH_Q31             ( 2684355l )
#define INV_CLDFB_BANDWIDTH_MDFT_FAC_Q31             ( 10737418 )
#define CLDFB_BANDWIDTH                     800

#define L_FILT_2OVER3                       12
@@ -1958,6 +1960,7 @@ typedef enum _DCTTYPE
#define TOD_NSPEC                           80                      /* number of spectral bins of the tonal detector */
#define TOD_NSPEC_INV_Q31                   26843546                /* inverse of number of spectral bins of the tonal detector */
#define TOD_THR_MASS                        0.86f                   /* initial value for the adaptive threshold of the tonal detector */
#define TOD_THR_MASS_FX_Q22                 3607101                 /* initial value for the adaptive threshold of the tonal detector */
#define P2A_FACT                            0.9f                    /* long-term averaging factor for peak-to-average ratio */
#define P2A_FACT_FX_Q15                     29491                   /* long-term averaging factor for peak-to-average ratio */
#define THR_P2A_HIGH                        95.0f                   /* higher threshold to detect strongly peaky signals at low bitrates*/
@@ -3042,7 +3045,7 @@ enum
#define EVS_2PI_FX                           51472    /* 2 * pi in Q13 */
#define EVS_PI_FX_Q27                        421657428     /* pi in Q28 */
#define EVS_2PI_FX_Q27                       843314856    /* 2 * pi in Q28 */
#define EVS_PI_BY_2_FX                            (Word16)(0x3244)
#define EVS_PI_BY_2_FX                            (Word16)(0x3244) // Q13
//#define EVS_PI_FX                            (Word16)(0x6488)

#define LG10                                 24660    /*  10*log10(2)  in Q13 */
+7 −0
Original line number Diff line number Diff line
@@ -827,6 +827,10 @@ enum fea_names
#define STEREO_TCA_GDMIN_FX                     -32768
#define STEREO_TCA_GDSTEP                       0.05f
#define STEREO_TCA_GDSTEP_FX                       819
#ifdef IVAS_FLOAT_FIXED
#define STEREO_TCA_GDMIN_FX_Q14                  (-16384)
#define STEREO_TCA_GDSTEP_FX_Q13                 (410)
#endif
#define STEREO_BITS_TCA                         ( STEREO_BITS_TCA_CHAN + STEREO_BITS_TCA_CORRSTATS + STEREO_BITS_TCA_GD )

#define STEREO_ICBWE_MSFLAG_BITS                1                           /* BWE Multi Source flag */
@@ -1282,6 +1286,9 @@ enum

#define MASA_COHERENCE_TOLERANCE                0.1f
#define MASA_COHERENCE_THRESHOLD                0.1f
#ifdef IVAS_FLOAT_FIXED
#define MASA_COHERENCE_THRESHOLD_FX             214748365 // 0.1 in Q31
#endif
#define MASA_RATIO_TOLERANCE                    0.1f
#define MASA_RATIO_THRESHOLD                    0.1f
#define MASA_ANGLE_TOLERANCE                    0.5f
+195 −1
Original line number Diff line number Diff line
@@ -359,6 +359,18 @@ ivas_error ivas_FB_mixer_open(
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
            }

#ifdef IVAS_FLOAT_FIXED
            if ( ( hFbMixer->ppFilterbank_inFR_re_fx[j] = (Word32 *) malloc( sizeof( Word32 ) * frame_len ) ) == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
            }

            if ( ( hFbMixer->ppFilterbank_inFR_im_fx[j] = (Word32 *) malloc( sizeof( Word32 ) * frame_len ) ) == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
            }
#endif
        }
    }

@@ -378,7 +390,25 @@ ivas_error ivas_FB_mixer_open(
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
        }
        set_f( hFbMixer->ppFilterbank_prior_input[i], 0, fb_cfg->prior_input_length );
#ifdef IVAS_FLOAT_FIXED
        IF( ( hFbMixer->ppFilterbank_prior_input_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * fb_cfg->prior_input_length ) ) == NULL )
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
        }
        set32_fx( hFbMixer->ppFilterbank_prior_input_fx[i], 0, fb_cfg->prior_input_length );
#endif
    }

#ifdef IVAS_FLOAT_FIXED
    FOR( i = 0; i < num_chs_alloc; i++ )
    {
        IF( ( hFbMixer->ppFilterbank_prior_input_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * fb_cfg->prior_input_length ) ) == NULL )
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
        }
        set32_fx( hFbMixer->ppFilterbank_prior_input_fx[i], 0, fb_cfg->prior_input_length );
    }
#endif

    if ( ( fb_cfg->active_w_mixing != -1 ) && ( fb_cfg->num_out_chans > 0 ) )
    {
@@ -788,6 +818,13 @@ void ivas_FB_mixer_close(

                free( hFbMixer->ppFilterbank_inFR_im[j] );
                hFbMixer->ppFilterbank_inFR_im[j] = NULL;
#ifdef IVAS_FLOAT_FIXED
                free( hFbMixer->ppFilterbank_inFR_re_fx[j] );
                hFbMixer->ppFilterbank_inFR_re_fx[j] = NULL;

                free( hFbMixer->ppFilterbank_inFR_im_fx[j] );
                hFbMixer->ppFilterbank_inFR_im_fx[j] = NULL;
#endif
            }
        }

@@ -805,7 +842,13 @@ void ivas_FB_mixer_close(
            free( hFbMixer->ppFilterbank_prior_input[i] );
            hFbMixer->ppFilterbank_prior_input[i] = NULL;
        }

#ifdef IVAS_FLOAT_FIXED
        for ( i = 0; i < num_chs_alloc; i++ )
        {
            free( hFbMixer->ppFilterbank_prior_input_fx[i] );
            hFbMixer->ppFilterbank_prior_input_fx[i] = NULL;
        }
#endif
        if ( ( fb_cfg->active_w_mixing != -1 ) && ( fb_cfg->num_out_chans > 0 ) )
        {
            free( hFbMixer->prior_mixer[0][0] );
@@ -1043,7 +1086,77 @@ void ivas_fb_mixer_pcm_ingest(

    return;
}
#ifdef IVAS_FLOAT_FIXED
void ivas_fb_mixer_pcm_ingest_fx(
    IVAS_FB_MIXER_HANDLE hFbMixer, /* i/o: FB mixer handle             */
    Word32 *pcm_in[],              /* i  : input audio channels     Qq_data_fix[]   */
    Word32 **ppOut_pcm,            /* o  : output audio channels    Qq_ppOut_pcm[]  */
    const Word16 frame_len,        /* i  : frame length                */
    const Word16 HOA_md_ind[IVAS_SPAR_MAX_CH],
    Word16 q_data_fix[MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS],
    Word16 *q_ppOut_pcm )
{
    Word16 i;
    Word16 num_chs_ingest;
    IVAS_FB_CFG *fb_cfg = hFbMixer->fb_cfg;

    IF( fb_cfg->active_w_mixing )
    {
        num_chs_ingest = fb_cfg->num_in_chans;
        move16();
    }
    ELSE
    {
        num_chs_ingest = 1; /* forward Filterbank MDFT only on W */
        move16();
    }


    FOR( i = 0; i < fb_cfg->num_in_chans; i++ )
    {
        Word16 q_temp = s_min( hFbMixer->q_ppFilterbank_prior_input_fx[i], q_data_fix[HOA_md_ind[i]] );


        // mvr2r(&hFbMixer->ppFilterbank_prior_input[i][fb_cfg->prior_input_length - frame_len], ppOut_pcm[i], frame_len);
        Copy32( &hFbMixer->ppFilterbank_prior_input_fx[i][fb_cfg->prior_input_length - frame_len], ppOut_pcm[i], frame_len );

        IF( LT_16( q_temp, hFbMixer->q_ppFilterbank_prior_input_fx[i] ) )
        {
            FOR( Word16 x = 0; x < frame_len; x++ )
            {
                ppOut_pcm[i][x] = L_shr( ppOut_pcm[i][x], sub( hFbMixer->q_ppFilterbank_prior_input_fx[i], q_temp ) );
                move32();
            }
        }
        // mvr2r(pcm_in[HOA_md_ind[i]], &ppOut_pcm[i][frame_len], frame_len);
        Copy32( pcm_in[HOA_md_ind[i]], &ppOut_pcm[i][frame_len], frame_len );

        IF( LT_16( q_temp, q_data_fix[HOA_md_ind[i]] ) )
        {
            FOR( Word16 x = frame_len; x < shl( frame_len, 1 ); x++ )
            {
                ppOut_pcm[i][x] = L_shr( ppOut_pcm[i][x], sub( q_data_fix[HOA_md_ind[i]], q_temp ) );
                move32();
            }
        }
        q_ppOut_pcm[i] = q_temp;
        move16();
    }

    Word16 guard_bits = find_guarded_bits_fx( shl( frame_len, 1 ) );

    FOR( i = 0; i < num_chs_ingest; i++ )
    {
        Word16 q_shift = sub( getScaleFactor32( ppOut_pcm[fb_cfg->remix_order[i]], shl( frame_len, 1 ) ), guard_bits );
        Scale_sig32( ppOut_pcm[fb_cfg->remix_order[i]], shl( frame_len, 1 ), q_shift );
        q_ppOut_pcm[fb_cfg->remix_order[i]] = add( q_ppOut_pcm[fb_cfg->remix_order[i]], q_shift );

        ivas_mdft_fx( ppOut_pcm[fb_cfg->remix_order[i]], hFbMixer->ppFilterbank_inFR_re_fx[fb_cfg->remix_order[i]], hFbMixer->ppFilterbank_inFR_im_fx[fb_cfg->remix_order[i]], shl( frame_len, 1 ), frame_len );
    }

    return;
}
#endif

/*-----------------------------------------------------------------------------------------*
 * Function ivas_fb_mixer_update_prior_input()
@@ -1069,6 +1182,26 @@ void ivas_fb_mixer_update_prior_input(
    return;
}

#ifdef IVAS_FLOAT_FIXED
void ivas_fb_mixer_update_prior_input_fx(
    IVAS_FB_MIXER_HANDLE hFbMixer, /* i/o: FB mixer handle              */
    Word32 *pcm_in_fx[],           /* i  : input audio channels         */
    const Word16 length,           /* i  : length of time slot          */
    const Word16 nchan_fb_in       /* i  : number of analysis channels  */
)
{
    Word16 i;

    FOR( i = 0; i < nchan_fb_in; i++ )
    {
        Copy32( &hFbMixer->ppFilterbank_prior_input_fx[i][length], hFbMixer->ppFilterbank_prior_input_fx[i], hFbMixer->fb_cfg->prior_input_length - length );
        Copy32( pcm_in_fx[i], &hFbMixer->ppFilterbank_prior_input_fx[i][hFbMixer->fb_cfg->prior_input_length - length], length );
    }

    return;
}
#endif


/*-----------------------------------------------------------------------------------------*
 * Function ivas_fb_mixer_get_windowed_fr()
@@ -1076,6 +1209,61 @@ void ivas_fb_mixer_update_prior_input(
 *
 *-----------------------------------------------------------------------------------------*/

#ifdef IVAS_FLOAT_FIXED
void ivas_fb_mixer_get_windowed_fr_fx(
    IVAS_FB_MIXER_HANDLE hFbMixer, /* i/o: FB mixer handle                    */
    Word32 *pcm_in_fx[],
    Word32 *frame_f_real_fx[],
    Word32 *frame_f_imag_fx[],
    const Word16 length,      /* i  : number of new samples in time slot */
    const Word16 mdft_len,    /* i  : MDFT frame length                  */
    const Word16 nchan_fb_in, /* i  : number of analysis channels        */
    Word16 gb )
{
    Word16 ch_idx, j, offset, rev_offset;
    Word16 n_old_samples;
    Word16 n_new_samples;
    Word32 fr_in_block_fx[L_FRAME48k * 2];
    const Word16 *win_ptr_fx;

    n_old_samples = s_min( ( sub( hFbMixer->fb_cfg->prior_input_length, hFbMixer->fb_cfg->windowed_fr_offset ) ), ( shl( mdft_len, 1 ) ) );
    n_new_samples = s_max( 0, sub( shl( length, 1 ), n_old_samples ) );
    offset = (Word16) ( sub( sub( shl( mdft_len, 1 ), length ), hFbMixer->ana_window_offset ) );
    rev_offset = (Word16) ( sub( shl( mdft_len, 1 ), hFbMixer->ana_window_offset ) );
    set32_fx( fr_in_block_fx, 0, offset );

    FOR( ch_idx = 0; ch_idx < nchan_fb_in; ch_idx++ )
    {
        Copy32( &hFbMixer->ppFilterbank_prior_input_fx[ch_idx][offset + hFbMixer->fb_cfg->windowed_fr_offset], &fr_in_block_fx[offset], n_old_samples - offset );
        Copy32( pcm_in_fx[ch_idx], &fr_in_block_fx[n_old_samples], n_new_samples );

        win_ptr_fx = hFbMixer->pAna_window_fx; /*Q15*/

        FOR( j = offset; j < sub( shl( mdft_len, 1 ), length ); j++ )
        {
            fr_in_block_fx[j] = Mpy_32_16_1( fr_in_block_fx[j], ( *( win_ptr_fx++ ) ) );
            move16();
        }

        FOR( j = rev_offset; j < shl( mdft_len, 1 ); j++ )
        {
            fr_in_block_fx[j] = Mpy_32_16_1( fr_in_block_fx[j], ( *( --win_ptr_fx ) ) );
            move16();
        }

        FOR( Word16 i = 0; i < shl( mdft_len, 1 ); i++ )
        {
            fr_in_block_fx[i] = L_shr( fr_in_block_fx[i], gb );
            move16();
        }

        ivas_mdft_fx( fr_in_block_fx, frame_f_real_fx[ch_idx], frame_f_imag_fx[ch_idx], mdft_len << 1, mdft_len );
    }

    return;
}
#endif

void ivas_fb_mixer_get_windowed_fr(
    IVAS_FB_MIXER_HANDLE hFbMixer, /* i/o: FB mixer handle                    */
    float *pcm_in[],               /* i  : input audio channels               */
@@ -2056,6 +2244,12 @@ static ivas_error ivas_filterbank_setup(
    {
        return error;
    }
#ifdef IVAS_FLOAT_FIXED
    IF( ( error = ivas_fb_mixer_get_window_fx( pCfg->fb_latency, sampling_rate, &( hFbMixer->pAna_window_fx ) ) ) != IVAS_ERR_OK )
    {
        return error;
    }
#endif

    if ( ( error = ivas_fb_mixer_get_window( pCfg->fade_len, sampling_rate, &( hFbMixer->pFilterbank_cross_fade ) ) ) != IVAS_ERR_OK )
    {
+80 −37

File changed.

Preview size limit exceeded, changes collapsed.

Loading