Commit 5defe4f2 authored by Jan Kiene's avatar Jan Kiene
Browse files

Merge branch 'main' into high-complexity-param-mc-prm-est

parents 91f046f4 20cb1008
Loading
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ variables:
  PRM_FILES: "scripts/config/self_test.prm scripts/config/self_test_ltv.prm"
  TESTCASE_TIMEOUT_STV: 900
  TESTCASE_TIMEOUT_LTV: 2400
  TESTCASE_TIMEOUT_LTV_SANITIZERS: 7200
  TESTCASE_TIMEOUT_LTV_SANITIZERS: 10800
  CI_REGRESSION_THRESH_MLD: "0.1"
  CI_REGRESSION_THRESH_MAX_ABS_DIFF: "50"
  CI_REGRESSION_THRESH_SSNR: "-1"
@@ -539,7 +539,7 @@ stages:
.ivas-pytest-sanitizers-anchor: &ivas-pytest-sanitizers-anchor
  stage: test
  needs: ["build-codec-linux-make"]
  timeout: "420 minutes"
  timeout: "600 minutes"
  rules:
    - if: $CI_PIPELINE_SOURCE == 'push'
      when: never
@@ -1328,7 +1328,9 @@ voip-be-on-merge-request:
  - public_dir="$CI_JOB_NAME-public"

  # if is needed to catch case when no artifact is there (first run), similarly as above
  - if [[ -d $public_dir ]]; then
  # 1. check for public_dir being there as this might not be the case when artifact download failed
  # 2. check for public dir not being empty - handle job failures in prev job that happen after the dir is created. In that case, the empty dir is in the artifacts
  - if [ -d $public_dir ] && [ ! -z "$( ls -A $public_dir )" ]; then
  -   mv $public_dir/* wmops/
  # check here if we have the split-by-levels files present - if not, fake them up with the existing global one
  # this is needed for the first run with split graphs on a branch where the global version did run previously
+5 −0
Original line number Diff line number Diff line
@@ -127,6 +127,8 @@
#define FIX_ISSUE_1165                          /* Ittiam: Fix for issue 1165: Assertion in lpc2lsp_fx for OMASA LTV input */
#define FIX_ISSUE_1185                          /* Ittiam: Fix for issue 1185: Assertion in ivas_dirac_dec_binaural_internal_fx() for crash in decoder in fft30_with_cmplx_data()*/
#define FIX_ISSUE_1209                          /* Ittiam: Fix for issue 1209: Assertion exit in BASOP encoder (stereo_dmx_evs)*/
#define FIX_ISSUE_1218                          /* Ittiam: Fix for issue 1218: Assert in stereo_dft_generate_comfort_noise_fx of BASOP decoder with BASOP MASA DTX bitstream at 32 kbps*/
#define FIX_ISSUE_1290                          /* Ittiam: Fix for issue 1218: Assert in stereo_dft_generate_comfort_noise_fx of BASOP decoder with BASOP MASA DTX bitstream at 32 kbps*/
#define IVAS_ISSUE_1188_EVS_CRASH               /* Ittiam: Fix for issue 1188: Issue due to ASAN */
#define FIX_ISSUE_1155                          /* Ittiam: Fix for issue 1155: Encoder crash for Stereo at 32kbps in PostShortTerm_ivas_enc_fx()*/
#define FIX_1010_OPT_DIV                        /* FhG: SVD complexity optimizations (non-be) */
@@ -159,4 +161,7 @@
#define SVD_WMOPS_OPT                           /* Ittiam : SVD related optimizations */
#define NONBE_FIX_1087_OOB_SBA_DTX_RS                   /* VA: issue 1087: Extend the length of the buffer for MCT decoding to avoid out-of-bound writing in SBA SID bitrate switching decoding */
#define IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST  /* FhG: reduces WMOPS of param_mc_prm_est, not bit-exact to previous version */
#define NONBE_FIX_1087_OOB_SBA_DTX_RS           /* VA: issue 1087: Extend the length of the buffer for MCT decoding to avoid out-of-bound writing in SBA SID bitrate switching decoding */
#define FIX_ISSUE_1279                          /* VA: correction of wrong scaling update */
#define FIX_ISSUE_1247
#endif
+11 −1
Original line number Diff line number Diff line
@@ -3642,6 +3642,16 @@ Word16 ITF_Detect_fx( Word32 const pSpectrum[],
                      Word16 *curr_order,
                      Word16 Q );
Word16 ITF_Detect_ivas_fx( Word32 const pSpectrum[],
                           const Word16 startLine,
                           const Word16 stopLine,
                           const Word16 maxOrder,
                           Word16 *A,
                           Word16 *Q_A,
                           Word16 *predictionGain,
                           Word16 *curr_order,
                           Word16 Q );
void ITF_Apply_fx( Word32 spectrum[],
                   Word16 startLine,
                   Word16 stopLine,
@@ -6631,7 +6641,7 @@ void nb_post_filt_fx(
    const Word16 tmp_noise,  /* i  : noise energy                       Q0   */
    Word16 *Synth,           /* i  : 12k8 synthesis                    Qsyn  */
    const Word16 *Aq,        /* i  : LP filter coefficient             Q12   */
    const Word16 *Pitch_buf, /* i  : Fractionnal subframe pitch buffer Q6    */
    const Word16 *Pitch_buf, /* i  : Fractionnal subframe pitch buffer Q0    */
    const Word16 coder_type, /* i  : coder_type                              */
    const Word16 BER_detect, /* i  : BER detect flag                         */
    const Word16 disable_hpf /* i  : flag to diabled HPF                     */
+139 −0
Original line number Diff line number Diff line
@@ -602,6 +602,145 @@ Word16 ITF_Detect_fx(

    return 1;
}

Word16 ITF_Detect_ivas_fx(
    const Word32 pSpectrum[], /*Q*/
    const Word16 startLine,   /*Q0*/
    const Word16 stopLine,    /*Q0*/
    const Word16 maxOrder,    /*Q0*/
    Word16 *A,                /*Q_A*/
    Word16 *Q_A,
    Word16 *predictionGain, /*Q7*/
    Word16 *curr_order,     /*Q0*/
    Word16 Q )
{
    Word32 norms[MAX_SUBDIVISIONS];
    Word16 num_subdivisions, i, length;
    Word16 iStartLine, iEndLine, spectrumLength;
    Word32 rxx[ITF_MAX_FILTER_ORDER + 1];
    Word16 q_rxx[ITF_MAX_FILTER_ORDER + 1];
    Word32 temp_spectrum[640];
    const Word16 *pWindow;
    const Word32 *ptr_spectrum1, *ptr_spectrum2;
    Word16 iSubdivisions, lag;
    Word16 headroom, guard_bits, shift, q_min;
    Word64 sum;
    Word16 fac, q_fac, exp, q_temp;
    Word32 temp;

    IF( maxOrder <= 0 )
    {
        return 0;
    }
    pWindow = tnsAcfWindow_fx;
    set_zero_fx( norms, MAX_SUBDIVISIONS );
    set_zero_fx( rxx, ITF_MAX_FILTER_ORDER + 1 );     /* This initialization is required */
    set16_fx( q_rxx, Q31, ITF_MAX_FILTER_ORDER + 1 ); /* This initialization is required */

    spectrumLength = sub( stopLine, startLine );
    num_subdivisions = 0;
    move16();

    /* Calculate norms for each spectrum part */
    FOR( iSubdivisions = 0; iSubdivisions < MAX_SUBDIVISIONS; iSubdivisions++ )
    {
        /* iStartLine = startLine + ( stopLine - startLine ) * iSubdivisions / nSubdivisions; */
        iStartLine = add( startLine, mult( imult1616( spectrumLength, iSubdivisions ), 10923 /* 1/MAX_SUBDIVISIONS in Q15 */ ) ); /*Q0*/
        /* iEndLine = startLine + ( stopLine - startLine ) * ( iSubdivisions + 1 ) / nSubdivisions; */
        iEndLine = add( startLine, mult( imult1616( spectrumLength, add( iSubdivisions, 1 ) ), 10923 /* 1/MAX_SUBDIVISIONS in Q15 */ ) ); /*Q0*/


        /*         Variable initialization             */
        /* norms[iSubdivisions] = sum2_f(pSpectrum + iStartLine - IGF_START_MN, iEndLine - iStartLine); */

        ptr_spectrum1 = pSpectrum + sub( iStartLine, IGF_START_MN );
        length = sub( iEndLine, iStartLine );
        headroom = L_norm_arr( ptr_spectrum1, length );
        guard_bits = find_guarded_bits_fx( length );
        shift = sub( headroom, guard_bits );

        Copy_Scale_sig32( ptr_spectrum1, temp_spectrum, length, shift ); // Q -> Q+shift

        sum = 0;
        move64();
        FOR( i = 0; i < length; i++ )
        {
            sum = W_mac_32_32( sum, temp_spectrum[i], temp_spectrum[i] ); // 2(Q+shift)+1
        }

        IF( LE_64( sum, W_shl( 32768 * 2 /* HLM_MIN_NRG in Q1 */, shl( add( Q, shift ), 1 ) ) ) )
        {
            BREAK;
        }

        /* fac = 1.0f / norms[iSubdivisions]; */
        exp = W_norm( sum );
        sum = W_shl( sum, exp );                                    // 2(Q+shift)+1+exp
        fac = div_s( ONE_IN_Q14, extract_h( W_extract_h( sum ) ) ); // 15+14-(2(Q+shift)+1+exp-48) = 76-(2(Q+shift)+exp)
        q_fac = sub( 76, add( shl( add( Q, shift ), 1 ), exp ) );
        pWindow = tnsAcfWindow_fx;

        /* For additional loop condition */
        /* Variable initialization */
        /*for ( lag = 1; lag <= maxOrder; lag++ )
        {
            rxx[lag] += fac * ( *pWindow ) * dotp( pSpectrum + iStartLine - IGF_START_MN, pSpectrum + iStartLine - IGF_START_MN + lag, iEndLine - iStartLine - lag );
            pWindow++;
        }*/

        ptr_spectrum1 = temp_spectrum; // pSpectrum + iStartLine - IGF_START_MN;
        FOR( lag = 1; lag <= maxOrder; lag++ )
        {
            /* dotp( pSpectrum + iStartLine - IGF_START_MN, pSpectrum + iStartLine - IGF_START_MN + lag, iEndLine - iStartLine - lag ) */
            ptr_spectrum2 = temp_spectrum + lag; //  pSpectrum + iStartLine - IGF_START_MN + lag;

            sum = 0;
            move64();
            FOR( i = 0; i < iEndLine - iStartLine - lag; i++ )
            {
                sum = W_mac_32_32( sum, ptr_spectrum1[i], ptr_spectrum2[i] ); // 2(Q+shift)+1
            }
            exp = W_norm( sum );
            sum = W_shl( sum, exp );                                          // 2(Q+shift)+1+exp
            temp = Mpy_32_32( L_mult0( fac, *pWindow ), W_extract_h( sum ) ); // (q_fac+15)+(2(Q+shift)+1+exp-32)-31 = q_fac+2(Q+shift)+exp-47
            q_temp = sub( add( q_fac, add( shl( add( Q, shift ), 1 ), exp ) ), 47 );

            /* rxx[lag] += fac * (*pWindow) * dotp(pSpectrum + iStartLine - IGF_START_MN, pSpectrum + iStartLine - IGF_START_MN + lag, iEndLine - iStartLine - lag); */
            q_min = sub( s_min( q_temp, q_rxx[lag] ), 1 );
            rxx[lag] = L_add( L_shl( rxx[lag], sub( q_min, q_rxx[lag] ) ), L_shl( temp, sub( q_min, q_temp ) ) );
            q_rxx[lag] = q_min;
            move32();
            move16();

            pWindow++;
        }

        num_subdivisions = add( num_subdivisions, 1 );
    }

    minimum_s( q_rxx + 1, ITF_MAX_FILTER_ORDER, &q_min );
    q_min = s_min( Q29, q_min );

    FOR( i = 1; i < ITF_MAX_FILTER_ORDER; i++ )
    {
        rxx[i] = L_shl( rxx[i], sub( q_min, q_rxx[i] ) );
        move32();
    }

    IF( EQ_16( iSubdivisions, MAX_SUBDIVISIONS ) ) /* meaning there is no subdivision with low energy */
    {
        rxx[0] = L_shl( MAX_SUBDIVISIONS, q_min );
        move32();

        /* Limit the maximum order to spectrum length/4 */
        ITF_GetFilterParameters_fx( rxx, s_min( maxOrder, shr( spectrumLength, 2 ) ), A, Q_A, predictionGain );

        *curr_order = maxOrder; /*Q0*/
        move16();
    }

    return 1;
}
/* Helper functions for Hufmann table coding */


+19 −3
Original line number Diff line number Diff line
@@ -180,7 +180,19 @@ ivas_error acelp_core_dec_ivas_fx(
            IF( EQ_32( st->core_brate, SID_2k40 ) )
            {
                FdCng_decodeSID_ivas_fx( st );
#ifdef FIX_ISSUE_1218
                Word16 n1, n2;
                n1 = L_norm_arr( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART );
                n2 = L_norm_arr( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART );

                Word16 common_e = s_max( sub( old_NoiseEstExp, n2 ), sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, n1 ) );
                scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, common_e ) );
                scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( old_NoiseEstExp, common_e ) );
                st->hFdCngDec->hFdCngCom->sidNoiseEstExp = common_e;
                move16();
#else
                rescale_fdCngDec( st->hFdCngDec, sub( old_NoiseEstExp, st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) );
#endif
            }
            FOR( i = 0; i < NPART; i++ )
            {
@@ -790,7 +802,11 @@ ivas_error acelp_core_dec_ivas_fx(
            Copy_Scale_sig( syn1_fx, temp_buf_fx, st->L_frame, sub( -1, st->Q_syn ) ); // Q_syn
            IF( st->hBWE_FD != NULL )
            {
#ifdef FIX_ISSUE_1290
                save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
#else
                save_old_syn_fx( st->L_frame, syn1_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx );
#endif
            }
        }

@@ -1235,7 +1251,7 @@ ivas_error acelp_core_dec_ivas_fx(
             *------------------------------------------------------------*/


            Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, NB_SUBFR16k, -Q6 ); // Q0
            Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0
            FEC_scale_syn_ivas_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction,
                                   &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate,
                                   exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, 0 );
@@ -1393,7 +1409,7 @@ ivas_error acelp_core_dec_ivas_fx(
        test();
        IF( EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) )
        {
            Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, NB_SUBFR16k, -Q6 ); // Q0
            Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0

            FEC_scale_syn_ivas_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction,
                                   &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate,
@@ -1430,7 +1446,7 @@ ivas_error acelp_core_dec_ivas_fx(
    test();
    IF( st->last_bwidth == NB && st->hPFstat != NULL )
    {
        Copy( pitch_buf_fx, pitch_buf_tmp, NB_SUBFR16k );
        Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0
        IF( st->bwidth == NB )
        {
            st->hPFstat->on = 1;
Loading