Commit b87e5972 authored by vaclav's avatar vaclav
Browse files

fix HARM_NON_LINEARITY

parent 42dafd27
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@
#define HARM_CORECODER_UPDT                             /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */
#define HARM_CORE_SW                                    /* VA: basop issue 2314: Remove duplicated code in the core switching */
#define HARM_PREPROC                                    /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX  */
#define HARM_NON_LINEARITY                              /* VA: basop issue 2345: Remove duplicated code in core-coder: non_linearity_fx() */

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

+10 −9
Original line number Diff line number Diff line
@@ -3169,12 +3169,13 @@ void non_linearity_fx(
    Word32 output[],         /* o  : output signal   2*Q_inp    */
    const Word16 length,     /* i  : i length                   */
    Word32 *prev_scale,      /* i/o: memory          Q30        */
    Word16 Q_inp,
    Word16 coder_type,     /* i  : Coder Type                     */
    const Word16 Q_inp,      /* i  : scaling of input           */
    const Word16 coder_type, /* i  : Coder Type                 */
    Word16 *voice_factors,   /* i  : Voice Factors              */
    const Word16 L_frame     /* i  : ACELP frame length         */
);
#ifndef HARM_NON_LINEARITY
void non_linearity_ivas_fx(
    const Word16 i[],    /* i  : i   signal    Q_inp          */
    Word32 output[],     /* o  : output signal   2*Q_inp      */
@@ -3185,7 +3186,7 @@ void non_linearity_ivas_fx(
    Word16 *voice_factors, /* i  : Voice Factors                  */
    const Word16 L_frame   /* i  : ACELP frame length             */
);
#endif
void interp_code_5over2_fx(
    const Word16 inp_code[], /* i  : i   vector                */
    Word16 interp_code[],    /* o  : output vector             */
+27 −16
Original line number Diff line number Diff line
@@ -5327,6 +5327,7 @@ void ScaleShapedWB_fx(
    return;
}

#ifndef HARM_NON_LINEARITY
/*-------------------------------------------------------------------*
 * non_linearity()
 *
@@ -5399,7 +5400,7 @@ static Word32 non_linearity_scaled_copy(
    }
    return prev_scale;
}

#endif

/*-------------------------------------------------------------------*
 * non_linearity()
@@ -5407,9 +5408,13 @@ static Word32 non_linearity_scaled_copy(
 * Apply a non linearity to the SHB excitation
 * -------------------------------------------------------------------*/

#ifdef HARM_NON_LINEARITY
static Word32 non_linearity_scaled_copy(
#else
static Word32 non_linearity_scaled_copy_ivas(
#endif
    const Word16 input[],
    Word16 j,
    const Word16 j,
    const Word16 length,
    Word32 output[],
    Word32 prev_scale,
@@ -5419,7 +5424,6 @@ static Word32 non_linearity_scaled_copy_ivas(
    Word16 i;
    Word32 L_tmp;


    IF( en_abs )
    {
        FOR( i = 0; i < j; i++ )
@@ -5507,6 +5511,7 @@ static Word32 non_linearity_scaled_copy_ivas(
            move32();
        }
    }

    return prev_scale;
}

@@ -5537,12 +5542,12 @@ void non_linearity_fx(
    Word32 output[],         /* o  : output signal  2*Q_inp */
    const Word16 length,     /* i  : input length           */
    Word32 *pPrevScale,      /* i/o: memory Q30             */
    Word16 Q_inp,
    Word16 coder_type,     /* i  : Coder Type          */
    const Word16 Q_inp,      /* i  : scaling of input       */
    const Word16 coder_type, /* i  : Coder Type             */
    Word16 *voice_factors,   /* i  : Voice Factors          */
    const Word16 L_frame     /* i  : ACELP frame length     */

)
#ifndef HARM_NON_LINEARITY
{
    Word16 i, j;
    Word16 max_val = 0;
@@ -5783,6 +5788,7 @@ void non_linearity_ivas_fx(
    const Word16 L_frame   /* i  : ACELP frame length  */

)
#endif
{
    Word16 i, j;
    Word16 max_val = 0;
@@ -5820,7 +5826,6 @@ void non_linearity_ivas_fx(
        move16(); /* 0.94*4 in Q12 */
    }


    FOR( i = 0; i < nframes; i++ )
    {
        v_fac = add( v_fac, shr( voice_factors[i], 3 ) ); /* Q12 */
@@ -5837,7 +5842,6 @@ void non_linearity_ivas_fx(
    prev_scale = *pPrevScale;
    move32();


    /* Delay Alignment in FX is done inside swb_tbe_enc_fx() */

    FOR( i = j = 0; i < length_half; i++ )
@@ -5851,7 +5855,6 @@ void non_linearity_ivas_fx(
        max_val = s_max( max_val, tmp );
    }


    IF( GT_16( max_val, shl_sat( 1, Q_inp ) ) )
    {
        exp = norm_s( max_val );
@@ -5866,6 +5869,7 @@ void non_linearity_ivas_fx(

    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 */
    {
@@ -5875,7 +5879,6 @@ void non_linearity_ivas_fx(
    }
    ELSE
    {

        /* Computing log2(scale) */
        IF( j == 0 )
        {
@@ -5912,7 +5915,11 @@ void non_linearity_ivas_fx(
        }
    }

#ifdef HARM_NON_LINEARITY
    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 );
#endif

    max_val = 0;
    move16();
@@ -5989,7 +5996,11 @@ void non_linearity_ivas_fx(
        }
    }

#ifdef HARM_NON_LINEARITY
    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 );
#endif

    *pPrevScale = prev_scale;
    move32();
+4 −0
Original line number Diff line number Diff line
@@ -2286,7 +2286,11 @@ ivas_error acelp_core_dec_fx(
            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 );
#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
                exp = sub( L_norm_arr( bwe_exc_extended_fx + L_FRAME32k, NL_BUFF_OFFSET ), 16 );
                Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, exp ); /* Q(2 * Q_exc) -> Q(q_old_bwe_exc_extended_fx) */
                st->hBWE_TD->q_old_bwe_exc_extended_fx = add( shl( st->Q_exc, 1 ), exp );
+4 −0
Original line number Diff line number Diff line
@@ -1434,7 +1434,11 @@ 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 );
#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
            Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( Q_new, 1 ), sub( st->hBWE_TD->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc
        }