Commit d258eb24 authored by Fabian Bauer's avatar Fabian Bauer
Browse files

added code for HARMONIZE_2598_tcx_arith_encode_envelope

parent 666fd600
Loading
Loading
Loading
Loading
+48 −2
Original line number Diff line number Diff line
@@ -658,7 +658,7 @@ static Word16 tcx_arith_encode(
 *
 *
 *-------------------------------------------------------------------*/

#ifndef HARMONIZE_2598_tcx_arith_encode_envelope
void tcx_arith_encode_envelope_fx(
    Word32 spectrum[],          /* i/o: MDCT coefficients             Q31-e */
    Word16 *spectrum_e,         /* i/o: MDCT exponent                 Q0 */
@@ -800,8 +800,29 @@ void tcx_arith_encode_envelope_fx(

    return;
}
#endif


#ifdef HARMONIZE_2598_tcx_arith_encode_envelope
void tcx_arith_encode_envelope_fx(
    Word32 spectrum[],         /* i/o: MDCT coefficients             Q31-e */
    Word16 *spectrum_e,        /* i/o: MDCT exponent                 Q0 */
    Word16 signs[],            /* o  : signs (spectrum[.]<0)         Q0 */
    const Word16 L_frame,      /* i  : frame or MDCT length          Q0 */
    const Word16 L_spec,       /* i  : frame or MDCT length          Q0 */
    Encoder_State *st,         /* i/o: coder state                   */
    const Word16 A_ind[],      /* i  : quantised LPC coefficients    Q12 */
    Word16 target_bits,        /* i  : number of available bits      Q0 */
    Word16 prm[],              /* o  : bitstream parameters          Q0 */
    const Word8 use_hm,        /* i  : use HM in current frame?      */
    Word16 prm_hm[],           /* o  : HM parameter area             Q0 */
    const Word16 tcxltp_pitch, /* i  : TCX LTP pitch in FD, -1 if n/a  Q0*/
    Word16 *arith_bits,        /* o  : bits used for ari. coding     Q0 */
    Word16 *signaling_bits,    /* o  : bits used for signaling       Q0 */
    Word16 *nf_seed,
    /*IVAS:0*/                  /* o  : noise filling seed            Q0 */
    const Word16 low_complexity /* i  : low-complexity flag           Q0 */
)
#else
void tcx_arith_encode_envelope_ivas_fx(
    Word32 spectrum[],          /* i/o: MDCT coefficients             Q31-e */
    Word16 *spectrum_e,         /* i/o: MDCT exponent                 Q0 */
@@ -819,6 +840,7 @@ void tcx_arith_encode_envelope_ivas_fx(
    Word16 *signaling_bits,     /* o  : bits used for signaling       Q0 */
    const Word16 low_complexity /* i  : low-complexity flag           Q0 */
)
#endif
{
    Word32 env[N_MAX_ARI]; /* unscaled envelope (Q16) */
    Word16 *envelope;      /* scaled envelope (Q15-e) */
@@ -834,6 +856,9 @@ void tcx_arith_encode_envelope_ivas_fx(
    Word16 gamma_w, gamma_uw;
    Word16 hm_bits;
    Word32 L_tmp;
#ifdef HARMONIZE_2598_tcx_arith_encode_envelope
    Word64 W_tmp2;
#endif
    Word16 tmp;
    TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;

@@ -919,8 +944,21 @@ void tcx_arith_encode_envelope_ivas_fx(
    move16();

    /* Multiply back the signs */
#ifdef HARMONIZE_2598_tcx_arith_encode_envelope
    if ( EQ_16( st->element_mode, EVS_MONO ) )
    {
        W_tmp2 = 0;
        move32();
    }
#endif
    FOR( k = 0; k <= kMax; k++ )
    {
#ifdef HARMONIZE_2598_tcx_arith_encode_envelope
        if ( EQ_16( st->element_mode, EVS_MONO ) )
        {
            W_tmp2 = W_mac_16_16( W_tmp2, q_spectrum[k], k );
        }
#endif
        if ( signs[k] != 0 )
            L_tmp = L_mult( q_spectrum[k], -( 1 << ( 30 - SPEC_EXP_DEC ) ) );
        if ( signs[k] == 0 )
@@ -933,5 +971,13 @@ void tcx_arith_encode_envelope_ivas_fx(
    move16();
    set32_fx( spectrum + k, 0, sub( s_max( L_frame, L_spec ), k ) );

#ifdef HARMONIZE_2598_tcx_arith_encode_envelope
    if ( EQ_16( st->element_mode, EVS_MONO ) )
    {
        /* noise filling seed */
        *nf_seed = extract_l( W_extract_l( W_tmp2 ) );
        move16();
    }
#endif
    return;
}
+4 −1
Original line number Diff line number Diff line
@@ -3493,8 +3493,11 @@ void QuantizeTCXSpectrum_fx(
            low_complexiety = 1;
            move16();
        }
#ifdef HARMONIZE_2598_tcx_arith_encode_envelope
        tcx_arith_encode_envelope_fx( spectrum_fx, spectrum_e, hm_cfg->indexBuffer, L_frame, L_spec, st, Aqind, sqTargetBits, sqQ, tmp8, prm_hm, /* HM parameter area */ LtpPitchLag, &sqBits, &signaling_bits, 0, low_complexiety );
#else
        tcx_arith_encode_envelope_ivas_fx( spectrum_fx, spectrum_e, hm_cfg->indexBuffer, L_frame, L_spec, st, Aqind, sqTargetBits, sqQ, tmp8, prm_hm, /* HM parameter area */ LtpPitchLag, &sqBits, &signaling_bits, low_complexiety );

#endif
        sqTargetBits = sub( sqTargetBits, signaling_bits );
        *prm_target = sqTargetBits;
        move16();
+23 −0
Original line number Diff line number Diff line
@@ -1891,6 +1891,7 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx(
    Word16 *stop,       /* Q0 */
    CONTEXT_HM_CONFIG *hm_cfg );

#ifndef HARMONIZE_2598_tcx_arith_encode_envelope
void tcx_arith_encode_envelope_fx(
    Word32 spectrum[],          /* i/o: MDCT coefficients             Q31-e */
    Word16 *spectrum_e,         /* i/o: MDCT exponent                 Q0 */
@@ -1909,7 +1910,28 @@ void tcx_arith_encode_envelope_fx(
    Word16 *nf_seed,            /* o  : noise filling seed            Q0 */
    const Word16 low_complexity /* i  : low-complexity flag           Q0 */
);
#endif

#ifdef HARMONIZE_2598_tcx_arith_encode_envelope
void tcx_arith_encode_envelope_fx(
    Word32 spectrum[],          /* i/o: MDCT coefficients             Q31-e */
    Word16 *spectrum_e,         /* i/o: MDCT exponent                 Q0 */
    Word16 signs[],             /* o  : signs (spectrum[.]<0)         Q0 */
    const Word16 L_frame,       /* i  : frame or MDCT length          Q0 */
    const Word16 L_spec,        /* i  : frame or MDCT length          Q0 */
    Encoder_State *st,          /* i/o: coder state                   */
    const Word16 A_ind[],       /* i  : quantised LPC coefficients    Q12 */
    Word16 target_bits,         /* i  : number of available bits      Q0 */
    Word16 prm[],               /* o  : bitstream parameters          Q0 */
    const Word8 use_hm,         /* i  : use HM in current frame?      */
    Word16 prm_hm[],            /* o  : HM parameter area             Q0 */
    const Word16 tcxltp_pitch,  /* i  : TCX LTP pitch in FD, -1 if n/a  Q0*/
    Word16 *arith_bits,         /* o  : bits used for ari. coding     Q0 */
    Word16 *signaling_bits,     /* o  : bits used for signaling       Q0 */
    Word16 *nf_seed, /*IVAS:0*/ /* o  : noise filling seed            Q0 */
    const Word16 low_complexity /* i  : low-complexity flag           Q0 */
  );
#else
void tcx_arith_encode_envelope_ivas_fx(
    Word32 spectrum[],          /* i/o: MDCT coefficients             Q31-e */
    Word16 *spectrum_e,         /* i/o: MDCT exponent                 Q0 */
@@ -1927,6 +1949,7 @@ void tcx_arith_encode_envelope_ivas_fx(
    Word16 *signaling_bits,     /* o  : bits used for signaling       Q0 */
    const Word16 low_complexity /* i  : low-complexity flag           Q0 */
);
#endif

void QuantizeGain(
    Word16 n,