Commit 7738e1ea authored by vaclav's avatar vaclav
Browse files

fix EVS BE

parent b87e5972
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -3165,6 +3165,9 @@ void ScaleShapedWB_fx(
);
void non_linearity_fx(
#ifdef HARM_NON_LINEARITY
    const Word16 element_mode, /* i  : element mode               */
#endif
    const Word16 i[],        /* i  : i signal    Q_inp          */
    Word32 output[],         /* o  : output signal   2*Q_inp    */
    const Word16 length,     /* i  : i length                   */
+86 −21
Original line number Diff line number Diff line
@@ -5327,7 +5327,7 @@ void ScaleShapedWB_fx(
    return;
}

#ifndef HARM_NON_LINEARITY

/*-------------------------------------------------------------------*
 * non_linearity()
 *
@@ -5336,7 +5336,7 @@ void ScaleShapedWB_fx(

static Word32 non_linearity_scaled_copy(
    const Word16 input[],
    Word16 j,
    const Word16 j,
    const Word16 length,
    Word32 output[],
    Word32 prev_scale,
@@ -5346,7 +5346,6 @@ static Word32 non_linearity_scaled_copy(
    Word16 i;
    Word32 L_tmp;


    IF( en_abs )
    {
        FOR( i = 0; i < j; i++ )
@@ -5398,21 +5397,18 @@ static Word32 non_linearity_scaled_copy(
            move32();
        }
    }

    return prev_scale;
}
#endif


/*-------------------------------------------------------------------*
 * non_linearity()
 *
 * Apply a non linearity to the SHB excitation
 * Apply a non linearity to the SHB excitation in IVAS formats
 * -------------------------------------------------------------------*/

#ifdef HARM_NON_LINEARITY
static Word32 non_linearity_scaled_copy(
#else
static Word32 non_linearity_scaled_copy_ivas(
#endif
    const Word16 input[],
    const Word16 j,
    const Word16 length,
@@ -5538,6 +5534,9 @@ static Word32 non_linearity_scaled_copy_ivas(
/*==========================================================================*/

void non_linearity_fx(
#ifdef HARM_NON_LINEARITY
    const Word16 element_mode, /* i  : element mode           */
#endif
    const Word16 input[],    /* i  : input signal     Q_inp */
    Word32 output[],         /* o  : output signal  2*Q_inp */
    const Word16 length,     /* i  : input length           */
@@ -5810,6 +5809,9 @@ void non_linearity_ivas_fx(
    Word32 prev_scale;
    Word16 length_half;
    Word16 sc_factor;
#ifdef HARM_NON_LINEARITY
    Word16 cond;
#endif

    IF( EQ_16( L_frame, L_FRAME16k ) )
    {
@@ -5867,11 +5869,37 @@ void non_linearity_ivas_fx(
        move32(); /* Q31; 0.67 in Q31 */
    }

#ifdef HARM_NON_LINEARITY
    cond = 0;
    move16();
    IF( element_mode == EVS_MONO )
    {
        if ( GT_32( Mult_32_16( prev_scale, 32 ), scale ) )
        {
            cond = 1;
            move16();
        }
    }
    ELSE
    {
        sc_factor = s_max( sub( 13, norm_s( add( j, 1 ) ) ), 0 ); /* Adapt the scaling factor allowed depending of max position  */
        sc_factor = s_max( sc_factor, 1 );                        /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */
        if ( GT_32( L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ), scale /*Q31*/ ) )
        {
            cond = 1;
            move16();
        }
    }

    test();
    IF( prev_scale <= 0 || cond ) /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */
#else
    sc_factor = s_max( sub( 13, norm_s( add( j, 1 ) ) ), 0 ); /* Adapt the scaling factor allowed depending of max position  */
    sc_factor = s_max( sc_factor, 1 );                        /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */

    test();
    IF( prev_scale <= 0 || GT_32( L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ), scale /*Q31*/ ) ) /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */
#endif
    {
        scale_step = 16384;
        move16();                       /* Q14 */
@@ -5916,10 +5944,15 @@ void non_linearity_ivas_fx(
    }

#ifdef HARM_NON_LINEARITY
    IF( element_mode == EVS_MONO )
    {
        prev_scale = non_linearity_scaled_copy( input, j, length_half, output, prev_scale, scale_step, en_abs );
#else
    prev_scale = non_linearity_scaled_copy_ivas( input, j, length_half, output, prev_scale, scale_step, en_abs );
    }
    ELSE
#endif
    {
        prev_scale = non_linearity_scaled_copy_ivas( input, j, length_half, output, prev_scale, scale_step, en_abs );
    }

    max_val = 0;
    move16();
@@ -5947,12 +5980,39 @@ void non_linearity_ivas_fx(
        move32(); /* Q31; 0.67 in Q31 */
    }

#ifdef HARM_NON_LINEARITY
    cond = 0;
    move16();
    IF( element_mode == EVS_MONO )
    {
        if ( GT_32( Mult_32_16( prev_scale, 32 ), scale ) )
        {
            cond = 1;
            move16();
        }
    }
    ELSE
    {
        sc_factor = s_max( sub( 12, norm_s( add( sub( j, length_half ), 1 ) ) ), 0 ); /* allowed intra frame jump is smaller */
        sc_factor = s_max( sc_factor, 1 );                                            /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */

        if ( GT_32( L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ), scale /*Q31*/ ) ) /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */
        {
            cond = 1;
            move16();
        }
    }

    test();
    IF( prev_scale <= 0 || cond )
#else
    /* if ( element_mode > EVS_MONO ) */                                                                     /* element mode is not needed because the function is duplicated for IVAS */
    sc_factor = s_max( sub( 12, norm_s( add( sub( j, length_half ), 1 ) ) ), 0 );                            /* allowed intra frame jump is smaller */
    sc_factor = s_max( sc_factor, 1 );                                                                       /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */

    test();
    IF( prev_scale <= 0 || GT_32( L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ), scale /*Q31*/ ) ) /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */
#endif
    {
        scale_step = 16384;
        move16();                       /*Q14 */
@@ -5997,10 +6057,15 @@ void non_linearity_ivas_fx(
    }

#ifdef HARM_NON_LINEARITY
    IF( element_mode == EVS_MONO )
    {
        prev_scale = non_linearity_scaled_copy( input + length_half, sub( j, length_half ), sub( length, length_half ), output + length_half, prev_scale, scale_step, en_abs );
#else
    prev_scale = non_linearity_scaled_copy_ivas( input + length_half, sub( j, length_half ), sub( length, length_half ), output + length_half, prev_scale, scale_step, en_abs );
    }
    ELSE
#endif
    {
        prev_scale = non_linearity_scaled_copy_ivas( input + length_half, sub( j, length_half ), sub( length, length_half ), output + length_half, prev_scale, scale_step, en_abs );
    }

    *pPrevScale = prev_scale;
    move32();
+5 −1
Original line number Diff line number Diff line
@@ -2281,13 +2281,17 @@ ivas_error acelp_core_dec_fx(
        {
            IF( EQ_16( st->element_mode, EVS_MONO ) )
            {
#ifdef HARM_NON_LINEARITY
                non_linearity_fx( st->element_mode, bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame );
#else
                non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame );
#endif
            }
            ELSE
            {
                Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( st->Q_exc, 1 ), st->hBWE_TD->q_old_bwe_exc_extended_fx ) ) ); /* Q(q_old_bwe_exc_extended_fx) -> Q(2 * Q_exc) */
#ifdef HARM_NON_LINEARITY
                non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame );
                non_linearity_fx( st->element_mode, bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame );
#else
                non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame );
#endif
+4 −0
Original line number Diff line number Diff line
@@ -479,7 +479,11 @@ Word16 dec_acelp_tcx_frame_fx(
            test();
            IF( st->core == ACELP_CORE && st->igf != 0 && st->con_tcx == 0 )
            {
#ifdef HARM_NON_LINEARITY
                non_linearity_fx( EVS_MONO, ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors, st->L_frame );
#else
                non_linearity_fx( ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors, st->L_frame );
#endif
                /* update the old BWE exe memory */
                Copy( &old_bwe_exc[L_FRAME32k], hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2 );
            }
+5 −1
Original line number Diff line number Diff line
@@ -620,7 +620,11 @@ ivas_error acelp_core_enc_fx(
        IF( !st_fx->Opt_SC_VBR )
        {
            /* Apply a non linearity to the SHB excitation */
#ifdef HARM_NON_LINEARITY
            non_linearity_fx( st_fx->element_mode, bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, coder_type, voice_factors_fx, st_fx->L_frame );
#else
            non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, coder_type, voice_factors_fx, st_fx->L_frame );
#endif
        }
        test();
        if ( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, FRAME_NO_DATA ) )
@@ -1435,7 +1439,7 @@ ivas_error acelp_core_enc_ivas_fx(
            /* Apply a non linearity to the SHB excitation */
            Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( Q_new, 1 ), sub( st->hBWE_TD->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc
#ifdef HARM_NON_LINEARITY
            non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, st->coder_type, voice_factors_fx, st->L_frame );
            non_linearity_fx( st->element_mode, bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, st->coder_type, voice_factors_fx, st->L_frame );
#else
            non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, st->coder_type, voice_factors_fx, st->L_frame );
#endif
Loading