Commit 2075549a authored by vaclav's avatar vaclav
Browse files

Merge branch...

Merge branch 'basop-2304-remove-duplicated-code-in-core-encoder-acelp-excitation-coding' into 'main'

Resolve "Remove duplicated code in core-encoder: ACELP excitation coding"

See merge request !2685
parents f09f909a 8d7b6720
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
/* 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 */
@@ -111,17 +112,25 @@ Word16 est_tilt_fx( /* o : tilt of the code
/* 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  */
    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                    */
    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;
@@ -161,6 +170,9 @@ 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 */
@@ -180,6 +192,7 @@ Word16 est_tilt_ivas_fx(
        // 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;
}
+6 −6
Original line number Diff line number Diff line
@@ -2990,7 +2990,7 @@ Word16 ivas_acelp_tcx20_switching_fx(
    const Word16 flag_16k_smc                                   /* i  : flag to indicate if the OL SMC is run at 16 kHz */
);

void encod_gen_2sbfr(
void encod_gen_2sbfr_fx(
    Encoder_State *st,                                          /* i/o: state structure                         */
    const Word16 speech[],                                      /* i  : input speech                            */
    const Word16 Aw[],                                          /* i  : weighted A(z) unquantized for subframes */
@@ -3004,8 +3004,8 @@ void encod_gen_2sbfr(
    Word16 *bwe_exc,                                            /* o  : excitation for SWB TBE                  */
    const Word16 tdm_Pitch_reuse_flag,                          /* i  : primary channel pitch reuse flag        */
    const Word16 tdm_Pri_pitch_buf[],                           /* i  : pitch values for primary channel        */
    Word16 Q_new,
    Word16 shift 
    const Word16 Q_new,                                         /* i  : Scaling factor                          */
    const Word16 shift                                          /* i  : Shift needed to obtain 12 bits vectors  */
);

void acelp_fast_fx(
@@ -4483,7 +4483,7 @@ ivas_error signaling_enc_secondary_fx(
    const Word16 tdm_Pitch_reuse_flag                           /* i  : primary channel pitch reuse flag            */
);

void tdm_low_rate_enc(
void tdm_low_rate_enc_fx(
    Encoder_State *st,                                          /* i/o: State structure                             */
    const Word16 Aq[],                                          /* i  : 12k8 Lp coefficient                         */
    const Word16 *res,                                          /* i  : residual signal                        Q_new*/
@@ -4495,7 +4495,7 @@ void tdm_low_rate_enc(
    const Word16 attack_flag,                                   /* i  : attack flag                                 */
    const Word16 *lsf_new,                                      /* i  : current frame ISF vector              x2.56 */ 
    Word16 *tmp_noise,                                          /* o  : long-term noise energy                   Q8 */
    Word16 Q_new 
    const Word16 Q_new                                          /* i  : Scaling factor                              */
);

void tdm_low_rate_dec_fx(
+1 −0
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@
#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_1487_ACCESS_OF_UNINIT_VAL_FROM_ARR_ISM_DTX  /* FhG/VA: init nb_bits_metadata to zero */
#define CLEANUP_ACELP_ENC                               /* VA: basop issue 2304: Remove duplicated code in excitation encoding in the ACELP core */

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

+30 −10
Original line number Diff line number Diff line
@@ -2910,6 +2910,9 @@ 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 */
@@ -2918,8 +2921,8 @@ void tbe_celp_exc(
    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 */
@@ -4840,9 +4843,15 @@ 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  */
@@ -4851,10 +4860,13 @@ Word16 est_tilt_ivas_fx(
    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                    */
    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  */
@@ -6847,6 +6859,9 @@ 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  */
@@ -6854,8 +6869,8 @@ void lp_gain_updt_fx(
    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  */
@@ -7114,6 +7129,7 @@ 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                                */
@@ -7127,7 +7143,7 @@ void inov_decode_ivas_fx(
    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               */
@@ -10898,11 +10914,15 @@ ivas_error IGF_Reconfig_fx(
);
void core_switching_post_enc_ivas_fx(
    Encoder_State *st,       /* i/o: encoder state structure             */
    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 );
    Word16 Q_new
#endif
);
void residu_ivas_fx(
    const Word16 *a, /* i  : LP filter coefficients           Q31-a_exp*/
@@ -11194,7 +11214,7 @@ ivas_error acelp_core_enc_ivas_fx(
    Word16 *unbits,                      /* o  : number of unused bits                  Q0*/
    STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle               */
    Word16 tdm_lsfQ_PCh[M],              /* i  : Q LSFs for primary channel              X2.56*/
    Word16 Q_new );
    const Word16 Q_new );
void flip_and_downmix_generic_fx32(
    Word32 input[],                      /* i : input spectrum Qx*/
+42 −7
Original line number Diff line number Diff line
@@ -160,6 +160,7 @@ 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                          */
@@ -238,7 +239,13 @@ void tbe_celp_exc(
 *
 * 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 */
@@ -321,6 +328,8 @@ void tbe_celp_exc_ivas(
        *error_fx = add( *error_fx, tmp_fx );          /*error_fx in Q5*/
        move16();
    }

    return;
}

/*===========================================================================*/
@@ -349,6 +358,16 @@ void tbe_celp_exc_ivas(
/* RETURN ARGUMENTS : */
/* _ 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*/
    Word16 output[],                     /* o : output spectrum Qx*/
@@ -371,6 +390,7 @@ 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 */
@@ -378,14 +398,16 @@ void flip_and_downmix_generic_fx(
                                     -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 )
    {
@@ -467,8 +489,13 @@ 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++;
@@ -511,6 +538,7 @@ 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 */
@@ -518,14 +546,16 @@ void flip_and_downmix_generic_fx32(
                                     -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 )
    {
@@ -597,8 +627,13 @@ 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++;
Loading