Commit 83e968f4 authored by multrus's avatar multrus
Browse files

[cleanup] accept CLEANUP_ACELP_ENC

parent 77670b49
Loading
Loading
Loading
Loading
+0 −110
Original line number Diff line number Diff line
@@ -33,93 +33,9 @@
/* RETURN ARGUMENTS :                                                    */
/* _ (Word16) tolt_code :  tilt of the code           Q15                */
/*=======================================================================*/
#ifndef CLEANUP_ACELP_ENC
Word16 est_tilt_fx(                         /* o  : tilt of the code              Q15      */
                    const Word16 *exc,      /* i  : adaptive excitation vector      Qx  */
                    const Word16 gain_pit,  /* i  : adaptive gain                   Q14 */
                    const Word16 *code,     /* i  : algebraic excitation vector    Q9  */
                    const Word32 gain_code, /* i  : algebraic code gain             Q16 */
                    Word16 *voice_fac,      /* o  : voicing factor                  Q15 */
                    const Word16 Q_exc      /* i  : Scaling factor of excitation    Q0  */
)
{
    Word16 i, tmp, exp, ener1, exp1, ener2, exp2;
    Word32 L_tmp;
    Word16 tilt_code;

    ener1 = extract_h( Dot_product12( exc, exc, L_SUBFR, &exp1 ) );
    exp1 = sub( exp1, add( Q_exc, Q_exc ) );
    L_tmp = L_mult( gain_pit, gain_pit ); /* energy of pitch excitation */
    exp = norm_l( L_tmp );
    tmp = extract_h( L_shl( L_tmp, exp ) );
    ener1 = mult( ener1, tmp );
    exp1 = sub( sub( exp1, exp ), 10 ); /* 10 -> gain_pit Q14 to Q9   */

    ener2 = extract_h( Dot_product12( code, code, L_SUBFR, &exp2 ) );

    exp = norm_l( gain_code );
    tmp = extract_h( L_shl( gain_code, exp ) );
    tmp = mult( tmp, tmp ); /* energy of innovative code excitation */
    ener2 = mult( ener2, tmp );
    exp2 = sub( exp2, add( exp, exp ) );

    i = sub( exp1, exp2 );
    BASOP_SATURATE_WARNING_OFF_EVS
    ener1 = shr_sat( ener1, sub( 1, s_min( i, 0 ) ) );
    ener2 = shr_sat( ener2, add( s_max( 0, i ), 1 ) );
    BASOP_SATURATE_WARNING_ON_EVS
    tmp = sub( ener1, ener2 );
    ener1 = add( add( ener1, ener2 ), 1 );

    /* find voice factor (1=voiced, -1=unvoiced) */
    exp = div_s( abs_s( tmp ), ener1 );
    if ( tmp < 0 )
    {
        exp = negate( exp );
    }
    *voice_fac = exp;
    move16();

    /* tilt of code for next subframe: 0.5=voiced, 0=unvoiced */

    /* tilt_code = (float)(0.25*(1.0 + *voice_fac)) */
    tilt_code = mac_r( 8192L /*0.25.Q15*/ * 65536 /*1.Q16*/ - 0x8000 /*1.Q15*/, *voice_fac, 8192 /*0.25.Q15*/ ); /*Q15 */

    return tilt_code;
}

/*======================================================================*/
/* FUNCTION : est_tilt_ivas_fx()                                         */
/*-----------------------------------------------------------------------*/
/* PURPOSE :  Estimate spectral tilt based on the relative E of adaptive */
/* and innovative excitations                                            */
/*                                                                       */
/*-----------------------------------------------------------------------*/
/*  INPUT ARGUMENTS :                                                    */
/* _ (Word16 *) exc :  adaptive excitation vector      Q0                */
/* _ (Word16) gain_pit : adaptive gain                 Q14               */
/* _ (Word16 *) code : algebraic exctitation vector    Q12               */
/* _ (Word32) gain_code :  algebraic code gain         Q16               */
/* _ (Word16) Q_exc : Scaling factor of excitation     Q0                */
/*-----------------------------------------------------------------------*/
/* OUTPUT ARGUMENTS :                                                    */
/* _ (Word16 *) voice_fac :   voicing factor          Q15                */
/*-----------------------------------------------------------------------*/
/* INPUT OUTPUT ARGUMENTS                                                */
/*-----------------------------------------------------------------------*/

/*-----------------------------------------------------------------------*/
/* RETURN ARGUMENTS :                                                    */
/* _ (Word16) tolt_code :  tilt of the code           Q15                */
/*=======================================================================*/
#endif

/* o  : tilt of the code Q15 */
#ifdef CLEANUP_ACELP_ENC
Word16 est_tilt_fx(
#else
Word16 est_tilt_ivas_fx(
#endif
    const Word16 *exc,      /* i  : adaptive excitation vector      Qx  */
    const Word16 gain_pit,  /* i  : adaptive gain                   Q14 */
    const Word16 *code,     /* i  : algebraic excitation vector     Q9  */
@@ -127,10 +43,6 @@ Word16 est_tilt_ivas_fx(
    Word16 *voice_fac,      /* o  : voicing factor                  Q15 */
    const Word16 Q_exc,     /* i  : Scaling factor of excitation    Q0  */
    const Word16 L_subfr    /* i  : Sub frame length                    */
#ifndef CLEANUP_ACELP_ENC
    ,
    const Word16 flag_tilt /* i  : flag for special tilt        */
#endif
)
{
    Word16 i, tmp, exp, ener1, exp1, ener2, exp2;
@@ -170,29 +82,7 @@ Word16 est_tilt_ivas_fx(
    *voice_fac = exp;
    move16();

#ifdef CLEANUP_ACELP_ENC
    tilt_code = mac_r( 8192L /*0.25.Q15*/ * 65536 /*1.Q16*/ - 0x8000 /*1.Q15*/, *voice_fac, 8192 /*0.25.Q15*/ ); /*Q15 */
#else
    IF( flag_tilt == 0 )
    {
        /* tilt of code for next subframe: 0.5=voiced, 0=unvoiced */

        /* tilt_code = (float)(0.25*(1.0 + *voice_fac)) */
    tilt_code = mac_r( 8192L /*0.25.Q15*/ * 65536 /*1.Q16*/ - 0x8000 /*1.Q15*/, *voice_fac, 8192 /*0.25.Q15*/ ); /*Q15 */
    }
    ELSE IF( EQ_16( flag_tilt, 1 ) )
    {
        /*Between 0.25 (=unvoiced) and 0.5 (=voiced)*/
        // tilt_code = (float)(0.25f + (*voice_fac + 1.0f) * 0.125f);
        tilt_code = mac_r( 12288L /*0.375.Q15*/ * 65536 /*1.Q16*/ - 0x8000 /*1.Q15*/, *voice_fac, 4096 /*0.125.Q15*/ ); /*Q15 */
    }
    ELSE
    {
        /*Between 0.28 (=unvoiced) and 0.56 (=voiced)*/
        // tilt_code = (float)(0.28f + (*voice_fac + 1.0f) * 0.14f);
        tilt_code = mac_r( 13763L /*0.42.Q15*/ * 65536 /*1.Q16*/ - 0x8000 /*1.Q15*/, *voice_fac, 4588 /*0.14.Q15*/ ); /*Q15 */
    }
#endif

    return tilt_code;
}
+0 −1
Original line number Diff line number Diff line
@@ -90,7 +90,6 @@
#define FIX_1872_REMOVE_UNUSED_PSNOISEGEN_ISAR          /* Dolby: Remove unused psNoiseGen from ISAR */
#define FIX_1478_UNINIT_ON_BFI                          /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */
#define FIX_1486_INIT_OUTPUT_POINTERS                   /* FhG: always initialize pointers in renderer flush */
#define CLEANUP_ACELP_ENC                               /* VA: basop issue 2304: Remove duplicated code in excitation encoding in the ACELP core */
#define CLEANUP_VBR_CAM_ENC                             /* VA: basop issue 2299: Remove unused core-encoder VBR and CAM code */
#define FIX_1494_SET_SPLITBFI_UNUSED                    /* Dolby: Fix issue 1494, remove unused function setting BFI flag in ISAR renderer */
#define FIX_1479_MSAN_SPAR_UNINITIALIZED_VALUE          /* Dolby: Fix for issue 1479, MSAN error due to uninitialized value in SPAR */
+0 −65
Original line number Diff line number Diff line
@@ -2895,19 +2895,7 @@ Word16 tbe_celp_exc_offset(
    const Word16 L_frame     /* i  : frame lenght */
);
#ifdef CLEANUP_ACELP_ENC
void tbe_celp_exc_fx(
#else
void tbe_celp_exc(
    const Word16 L_frame_fx, /* i  : Frame lenght */
    const Word16 i_subfr_fx, /* i  : sub frame */
    const Word16 T0_fx,      /* i  : Integer pitch */
    const Word16 T0_frac_fx, /* i  : Fractional part of the pitch */
    Word16 *error_fx,        /* i/o: Error */
    Word16 *bwe_exc_fx       /* i/o: bandwitdh extension signal */
);
void tbe_celp_exc_ivas(
#endif
    const Word16 element_mode, /* i  : element mode            */
    const Word16 idchan,       /* i  : channel ID              */
    const Word16 L_frame_fx,   /* i  : Frame lenght */
@@ -4830,30 +4818,10 @@ Word16 est_tilt_fx(
    const Word16 *code,     /* i  : algebraic exctitation vector    Q9  */
    const Word32 gain_code, /* i  : algebraic code gain             Q16 */
    Word16 *voice_fac,      /* o  : voicing factor                  Q15 */
#ifdef CLEANUP_ACELP_ENC
    const Word16 Q_exc,  /* i  : Scaling factor of excitation    Q0  */
    const Word16 L_subfr /* i  : Sub frame length                    */
#else
    const Word16 Q_exc /* i  : Scaling factor of excitation    Q0  */
#endif
);
#ifndef CLEANUP_ACELP_ENC
/* o  : tilt of the code Q15 */
Word16 est_tilt_ivas_fx(
    const Word16 *exc,      /* i  : adaptive excitation vector      Qx  */
    const Word16 gain_pit,  /* i  : adaptive gain                   Q14 */
    const Word16 *code,     /* i  : algebraic excitation vector    Q9  */
    const Word32 gain_code, /* i  : algebraic code gain             Q16 */
    Word16 *voice_fac,      /* o  : voicing factor                  Q15 */
    const Word16 Q_exc,     /* i  : Scaling factor of excitation    Q0  */
    const Word16 L_subfr    /* i  : Sub frame length                    */
#ifndef CLEANUP_ACELP_ENC
    ,
    const Word16 flag_tilt /* i  : flag for special tilt        */
#endif
);
#endif
/* o  : tilt of the code                    */
Word16 Est_tilt2(
    const Word16 *exc,      /* i  : adaptive excitation vector      Qx  */
@@ -6846,18 +6814,7 @@ void gain_dec_lbr_fx(
);
void lp_gain_updt_fx(
#ifdef CLEANUP_ACELP_ENC
    const Word16 element_mode, /* i  : element mode                */
#else
    const Word16 i_subfr,        /* i  :  subframe number      Q0    */
    const Word16 gain_pit,       /* i  : Decoded gain pitch    Q14   */
    const Word32 norm_gain_code, /* i  : Normalised gain code   Q16  */
    Word16 *lp_gainp,            /* i/o: LP-filtered pitch gain(FEC) Q14 */
    Word16 *lp_gainc,            /* i/o: LP-filtered code gain (FEC) Q3 */
    const Word16 L_frame         /* i  : length of the frame         */
);
void lp_gain_updt_ivas_fx(
#endif
    const Word16 i_subfr,        /* i  :  subframe number      Q0    */
    const Word16 gain_pit,       /* i  : Decoded gain pitch    Q14   */
    const Word32 norm_gain_code, /* i  : Normalised gain code   Q16  */
@@ -7116,21 +7073,6 @@ void inov_decode_fx(
    const Word16 L_subfr     /* i  : subframe length Q0                             */
);
#ifndef CLEANUP_ACELP_ENC
void inov_decode_ivas_fx(
    Decoder_State *st_fx,    /* i/o: decoder state structure */
    const Word32 core_brate, /* i  : core bitrate Q0                                */
    const Word16 Opt_AMR_WB, /* i  : flag indicating AMR-WB IO mode Q0              */
    const Word16 L_frame,    /* i  : length of the frame Q0                         */
    const Word16 sharpFlag,  /* i  : formant sharpening flag Q0                     */
    const Word16 i_subfr,    /* i  : subframe index Q0                              */
    const Word16 *p_Aq,      /* i  : LP filter coefficients Q12                  */
    const Word16 tilt_code,  /* i  : tilt of the excitation of previous subframe Q15 */
    const Word16 pt_pitch,   /* i  : pointer to current subframe fractional pitch Q6*/
    Word16 *code,            /* o  : algebraic excitation Q12                        */
    const Word16 L_subfr     /* i  : subframe length Q0                             */
);
#endif
void dec_acelp_4t64_fx(
    Decoder_State *st_fx, /* i/o: decoder state structure */
    Word16 nbbits,        /* i  : number of bits per codebook               */
@@ -10897,13 +10839,6 @@ ivas_error IGF_Reconfig_fx(
void core_switching_post_enc_ivas_fx(
    Encoder_State *st /* i/o: encoder state structure             */
#ifndef CLEANUP_ACELP_ENC
    ,
    Word16 *old_inp_12k8_fx, /* i  : old input signal @12.8kHz           */
    Word16 *old_inp_16k_fx,  /* i  : old input signal @16kHz             */
    Word16 A_fx[],           /* i  : unquant. LP filter coefs.           */
    Word16 Q_new
#endif
);
void residu_ivas_fx(
+0 −122
Original line number Diff line number Diff line
@@ -160,92 +160,8 @@ Word16 tbe_celp_exc_offset(
 *
 * Compute tbe bwe celp excitation
 *-------------------------------------------------------------------*/
#ifndef CLEANUP_ACELP_ENC
void tbe_celp_exc(
    const Word16 L_frame_fx, /* i  : Frame lenght                       */
    const Word16 i_subfr_fx, /* i  : sub frame                          */
    const Word16 T0_fx,      /* i  : Integer pitch                   Q0 */
    const Word16 T0_frac_fx, /* i  : Fractional part of the pitch    Q1 */
    Word16 *error_fx,        /* i/o: Error                           Q5 */
    Word16 *bwe_exc_fx       /* i/o: bandwitdh extension signal         */
)
{
    Word16 offset_fx, tmp_fx, i;
    IF( EQ_16( L_frame_fx, L_FRAME ) )
    {
        /*offset = T0 * HIBND_ACB_L_FAC + (int) ((float) T0_frac * 0.25f * HIBND_ACB_L_FAC + 2 * HIBND_ACB_L_FAC + 0.5f) - 2 * HIBND_ACB_L_FAC;
        for (i=0; i<L_SUBFR * HIBND_ACB_L_FAC; i++)
        {
            bwe_exc[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc[i + i_subfr * HIBND_ACB_L_FAC - offset + (int) error];
        }
        error += (float) offset - (float) T0 * HIBND_ACB_L_FAC  - 0.25f * HIBND_ACB_L_FAC * (float) T0_frac;*/

        offset_fx = tbe_celp_exc_offset( T0_fx, T0_frac_fx, L_frame_fx );
        IF( *error_fx > 0 )
        {
            tmp_fx = shr( *error_fx, 5 ); /*Q0*/
        }
        ELSE
        {
            tmp_fx = negate( shr( abs_s( *error_fx ), 5 ) ); /*Q0*/
        }

        FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ )
        {
            bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC - offset_fx + tmp_fx]; // Qx
            move16();
        }
        tmp_fx = extract_l( L_mult( T0_frac_fx, 1 ) ); /*Q3; 0.25 in Q2*/
        tmp_fx = add( shl( T0_fx, 3 ), tmp_fx );       /*Q3*/
        tmp_fx = extract_l( L_mult( tmp_fx, 5 ) );     /*Q5, 2.5 in Q1*/
        tmp_fx = sub( shl( offset_fx, 5 ), tmp_fx );   /*Q5*/
        *error_fx = add( *error_fx, tmp_fx );          /*Q5*/
        move16();
    }
    ELSE
    {
        /*  offset = T0*2.5 + (int) ((float) T0_frac * 0.25f*2.5 + 2*2.5 + 0.5f) - 2*2.5;  - case above*/
        /*  offset = T0*2   + (int) ((float) T0_frac * 0.25f*2   + 2*2   + 0.5f) - 2*2;    - case here*/

        /*(int) ((float) T0_frac * 0.25f*2   + 2*2   + 0.5f)*/
        offset_fx = tbe_celp_exc_offset( T0_fx, T0_frac_fx, L_frame_fx );
        IF( *error_fx > 0 )
        {
            tmp_fx = shr( *error_fx, 5 ); /*Q0*/
        }
        ELSE
        {
            tmp_fx = negate( shr( abs_s( *error_fx ), 5 ) ); /*Q0*/
        }

        FOR( i = 0; i < L_SUBFR * 2; i++ )
        {
            bwe_exc_fx[i + i_subfr_fx * 2] = bwe_exc_fx[i + i_subfr_fx * 2 - offset_fx + tmp_fx]; // Qx
            move16();
        }

        /* error += (float) offset - (float) T0 * 2 - 0.5f * (float) T0_frac;*/
        tmp_fx = extract_l( L_mult( T0_frac_fx, 2 ) ); /*Q3; 0.5 in Q2*/
        tmp_fx = add( shl( T0_fx, 4 ), tmp_fx );       /* now tmp_fx = "T0_fx*2+ 0.5f*T0_frac_fx" in Q3*/
        tmp_fx = shl( tmp_fx, 2 );                     /*now above tmp_fx in Q5*/
        tmp_fx = sub( shl( offset_fx, 5 ), tmp_fx );   /*move offset_fx to Q5, tmp_fx in Q5, ans tmp_fx in Q5*/
        *error_fx = add( *error_fx, tmp_fx );          /*error_fx in Q5*/
        move16();
    }
}

/*-------------------------------------------------------------------*
 * swb_tbe_celp_exc_ivas()
 *
 * Compute tbe bwe celp excitation
 *-------------------------------------------------------------------*/
#endif

#ifdef CLEANUP_ACELP_ENC
void tbe_celp_exc_fx(
#else
void tbe_celp_exc_ivas(
#endif
    const Word16 element_mode, /* i  : element mode            */
    const Word16 idchan,       /* i  : channel ID              */
    const Word16 L_frame_fx,   /* i  : Frame lenght */
@@ -359,14 +275,12 @@ void tbe_celp_exc_ivas(
/* _ None */
/*---------------------------------------------------------------------------*/

#ifdef CLEANUP_ACELP_ENC
static const Word16 local_negsin_table17[17] = { 0, -11793, -22005, -29268, -32609, -31580,
                                                 -26319, -17530, -6393, 6393, 17530, 26319,
                                                 31580, 32609, 29268, 22005, 11793 }; /* Q15 */
static const Word16 local_cos_table17[17] = { 32767, 30571, 24279, 14732, 3212, -8739,
                                              -19519, -27683, -32137, -32137, -27683,
                                              -19519, -8739, 3212, 14732, 24279, 30571 }; /* Q15 */
#endif

void flip_and_downmix_generic_fx(
    Word16 input[],                      /* i : input spectrum Qx*/
@@ -390,24 +304,11 @@ void flip_and_downmix_generic_fx(
    /*Word16 s_tmp[L_FRAME32k];*/
    /*Word16 factor;*/
    Word16 period;
#ifndef CLEANUP_ACELP_ENC
    Word16 local_negsin_table17[17] = { 0, -11793, -22005, -29268, -32609, -31580,
                                        -26319, -17530, -6393, 6393, 17530, 26319,
                                        31580, 32609, 29268, 22005, 11793 }; /* Q15 */
    Word16 local_cos_table17[17] = { 32767, 30571, 24279, 14732, 3212, -8739,
                                     -19519, -27683, -32137, -32137, -27683,
                                     -19519, -8739, 3212, 14732, 24279, 30571 }; /* Q15 */
    Word16 *local_negsin_table, *local_cos_table;
#endif
    Word32 L_tmp;

    /* 1850 Hz downmix */
    period = 17;
    move16();
#ifndef CLEANUP_ACELP_ENC
    local_negsin_table = local_negsin_table17;
    local_cos_table = local_cos_table17;
#endif

    FOR( i = 0; i < length; i = i + 2 )
    {
@@ -489,13 +390,8 @@ void flip_and_downmix_generic_fx(
    {
        WHILE( ( j < period ) && ( i < length ) )
        {
#ifdef CLEANUP_ACELP_ENC
            L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table17[j] );           /*//Qx+16 */
            L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table17[j] ); /*Qx+16 */
#else
            L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table[j] );           /*//Qx+16 */
            L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table[j] ); /*Qx+16 */
#endif
            output[i] = round_fx( L_tmp ); /*Qx */
            move16();
            i++;
@@ -538,24 +434,11 @@ void flip_and_downmix_generic_fx32(
    /*Word16 s_tmp[L_FRAME32k];*/
    /*Word16 factor;*/
    Word16 period;
#ifndef CLEANUP_ACELP_ENC
    Word16 local_negsin_table17[17] = { 0, -11793, -22005, -29268, -32609, -31580,
                                        -26319, -17530, -6393, 6393, 17530, 26319,
                                        31580, 32609, 29268, 22005, 11793 }; /* Q15 */
    Word16 local_cos_table17[17] = { 32767, 30571, 24279, 14732, 3212, -8739,
                                     -19519, -27683, -32137, -32137, -27683,
                                     -19519, -8739, 3212, 14732, 24279, 30571 }; /* Q15 */
    Word16 *local_negsin_table, *local_cos_table;
#endif
    Word32 L_tmp;

    /* 1850 Hz downmix */
    period = 17;
    move16();
#ifndef CLEANUP_ACELP_ENC
    local_negsin_table = local_negsin_table17;
    local_cos_table = local_cos_table17;
#endif

    FOR( i = 0; i < length; i = i + 2 )
    {
@@ -627,13 +510,8 @@ void flip_and_downmix_generic_fx32(
        WHILE( ( j < period ) && ( i < length ) )
        {
            test();
#ifdef CLEANUP_ACELP_ENC
            L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table17[j] );           /*//Qx+16 */
            L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table17[j] ); /*Qx+16 */
#else
            L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table[j] );           /*//Qx+16 */
            L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table[j] ); /*Qx+16 */
#endif
            output[i] = L_tmp; /*Qx */
            move32();
            i++;
+0 −4
Original line number Diff line number Diff line
@@ -936,11 +936,7 @@ static void decod_gen_voic_core_switch_fx(
        gain_dec_mless_fx( st_fx, L_frame, GENERIC, 0, -1, code, st_fx->old_Es_pred_fx, &gain_pit, &gain_code, &gain_inov, &norm_gain_code );
    }

#ifdef CLEANUP_ACELP_ENC
    st_fx->tilt_code_fx = est_tilt_fx( exc, gain_pit, code, gain_code, &voice_fac, *Q_exc, L_SUBFR ); /*Q15*/
#else
    st_fx->tilt_code_fx = est_tilt_fx( exc, gain_pit, code, gain_code, &voice_fac, *Q_exc ); /*Q15*/
#endif
    move16();

    /*----------------------------------------------------------------------*
Loading