Commit 56cf2e5f authored by multrus's avatar multrus
Browse files

[cleanup] accept HARMONIZE_2598_tcx_arith_decode_envelope

parent 2132a821
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -86,7 +86,6 @@
#define FIX_1990_SANITIZER_IN_REVERB_LOAD               /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */
#define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR      /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */
#define NONBE_1122_KEEP_EVS_MODE_UNCHANGED              /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR.  */
#define HARMONIZE_2598_tcx_arith_decode_envelope        /* FhG: harmonize tcx_arith_decode_envelope between EVS and IVAS versions */
#define HARMONIZE_2598_tcx_arith_encode_envelope        /* FhG: harmonize tcx_arith_encode_envelope between EVS and IVAS versions */
#define FIX_ISSUE_2594_FALSE_COMMENT                    /* FhG: basop issue 2594: fixing false comments about Q value*/
#define FIX_ISSUE_2616_BOUNDARY_CONDITION               /* FhG: basop issue 2616: Inconsistent boundary conditions in function stereo_dft_dequantize_res_gains*/
+0 −37
Original line number Diff line number Diff line
@@ -7956,25 +7956,6 @@ void decoder_tcx_ivas_fx(
    const Word16 sba_dirac_stereo_flag );


#ifndef HARMONIZE_2598_tcx_arith_decode_envelope
void tcx_arith_decode_envelope_fx(
    Word32 q_spectrum[],  /* o: quantised MDCT coefficients     Q31-e */
    Word16 *q_spectrum_e, /* o: MDCT exponent                   Q0 */
    Word16 L_frame,       /* i: frame or MDCT length          */
    Word16 L_frame_orig,  /* i: length w/o BW limitation      */
    Decoder_State *st,
    const Word16 A_ind[],   /* i: quantised LPC coefficients    */
    Word16 target_bits,     /* i: number of available bits      */
    Word16 prm[],           /* i: bitstream parameters          */
    Word8 use_hm,           /* i: use HM in current frame?      */
    Word16 prm_hm[],        /* i: HM parameter area             */
    Word16 tcxltp_pitch,    /* i: TCX LTP pitch in FD, -1 if n/a*/
    Word16 *arith_bits,     /* o: bits used for ari. coding     */
    Word16 *signaling_bits, /* o: bits used for signaling       */
    Word16 *nf_seed,        /* o: noise filling seed              Q0 */
    Word16 low_complexity   /* i: low-complexity flag           Q0 */
);
#endif

void tcx_decoder_memory_update(
    Word16 *xn_buf,    /* i/o: mdct output buffer used also as temporary buffer  : Q0 */
@@ -9918,7 +9899,6 @@ void tcx_arith_render_envelope_ivas_fx(
    Word32 env[]              /* o  : shaped signal envelope                     Q16*/
);

#ifdef HARMONIZE_2598_tcx_arith_decode_envelope
void tcx_arith_decode_envelope_fx(
    Decoder_State *st,
    /* i/o: coder state                   */ /*EVS: move argument 5->1 */
@@ -9936,23 +9916,6 @@ void tcx_arith_decode_envelope_fx(
    Word16 *signaling_bits,                  /* o  : bits used for signaling       */
    Word16 *nf_seed,                         /* o  : noise filling seed         Q0 */
    const Word16 low_complexity              /* i  : low-complexity flag           */
#else
void tcx_arith_decode_envelope_ivas_fx(
    Decoder_State *st,          /* i/o: coder state                   */
    Word32 q_spectrum[],        /* o  : quantised MDCT coefficients Q(31-q_spectrum_e)  */
    Word16 *q_spectrum_e,       /* o  : MDCT exponent                 */
    const Word16 L_frame,       /* i  : frame or MDCT length          */
    Word16 L_spec,              /* i  : length w/o BW limitation      */
    const Word16 A_ind[],       /* i  : quantised LPC coefficients    */
    const Word16 target_bits,   /* i  : number of available bits      */
    Word16 prm[],               /* i  : bitstream parameters          */
    const Word16 use_hm,        /* i  : use HM in current frame?      */
    Word16 prm_hm[],            /* i  : HM parameter area             */
    Word16 tcxltp_pitch,        /* i  : TCX LTP pitch in FD, -1 if n/a*/
    Word16 *arith_bits,         /* o  : bits used for ari. coding     */
    Word16 *signaling_bits,     /* o  : bits used for signaling       */
    const Word16 low_complexity /* i  : low-complexity flag           */
#endif
);

void UnmapIndex_fx(
+0 −147
Original line number Diff line number Diff line
@@ -90,127 +90,6 @@ static Word16 tcx_arith_decode_fx(
    return bp;
}

#ifndef HARMONIZE_2598_tcx_arith_decode_envelope
void tcx_arith_decode_envelope_fx(
    Word32 q_spectrum[],    /* o  : quantised MDCT coefficients     Q31-e */
    Word16 *q_spectrum_e,   /* o  : MDCT exponent                   Q0 */
    Word16 L_frame,         /* i  : frame or MDCT length            Q0 */
    Word16 L_spec,          /* i  : length w/o BW limitation        Q0 */
    Decoder_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[],           /* i  : bitstream parameters            Q0 */
    Word8 use_hm,           /* i  : use HM in current frame?           */
    Word16 prm_hm[],        /* i  : HM parameter area               Q0 */
    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,        /* o  : noise filling seed              Q0 */
    Word16 low_complexity   /* i  : low-complexity flag             Q0 */
)
{
    Word32 env[N_MAX_ARI]; /* unscaled envelope */
    Word16 *envelope;      /* scaled envelope */
    Word16 envelope_e;
    Word16 L_spec_core;
    TCX_CONFIG_HANDLE tcx_cfg;
    Word16 gamma_w, gamma_uw;
    Word16 hm_bits;
    tcx_cfg = st->hTcxCfg;

    test();
    test();
    test();
    test();
    test();
    test();
    test();
    IF( GT_16( L_spec, N_MAX_ARI ) || ( EQ_16( st->element_mode, EVS_MONO ) && GT_16( target_bits, ( ACELP_13k20 / FRAMES_PER_SEC ) ) ) ||
        ( EQ_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE / FRAMES_PER_SEC ) ) ) ) ||
        ( GT_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE_CPE / FRAMES_PER_SEC ) ) ) ) ||
        ( target_bits <= 0 ) )
    {
        /* this could happen in case of bit errors */
        st->BER_detect = 1;
        move16();
        L_spec = N_MAX_ARI;
        move16();
        *signaling_bits = 0;
        move16();
        *arith_bits = 0;
        move16();
        set32_fx( q_spectrum, 0, L_frame );

        return;
    }

    *signaling_bits = 0;
    move16();
    assert( st->hTcxDec->enableTcxLpc );

    gamma_w = 32767 /*1.0f Q15*/;
    move16();
    gamma_uw = st->inv_gamma;
    move16();

    tcx_arith_render_envelope( A_ind, L_frame, L_spec, tcx_cfg->preemph_fac, gamma_w, gamma_uw, env );

    IF( use_hm )
    {
        IF( prm_hm[0] )
        {
            tcx_hm_decode( L_spec, env, target_bits, tcx_cfg->coder_type, prm_hm, tcxltp_pitch, &hm_bits );

            IF( hm_bits < 0 )
            {
                st->BER_detect = 1;
                move16();
                *signaling_bits = 0;
                move16();
                *arith_bits = 0;
                move16();
                set32_fx( q_spectrum, 0, L_frame );
                return;
            }
        }
        ELSE
        {
            hm_bits = 1;
            move16();
        }
        *signaling_bits = add( *signaling_bits, hm_bits );
        move16();
    }
    ELSE
    {
        prm_hm[0] = 0; /* just to be sure */
        move16();
    }

    L_spec_core = L_spec;
    move16();
    IF( st->igf )
    {
        L_spec_core = s_min( L_spec_core, st->hIGFDec->infoIGFStartLine );
    }
    envelope = (Word16 *) env;

    tcx_arith_scale_envelope( L_spec, L_spec_core, env, target_bits, low_complexity, envelope, &envelope_e );

    *arith_bits = tcx_arith_decode_fx( L_spec, envelope, envelope_e, target_bits, prm, q_spectrum, q_spectrum_e, nf_seed );
    move16();

    /* safety check in case of bit errors */
    IF( *arith_bits < 0 )
    {
        st->BER_detect = 1;
        move16();
        set32_fx( q_spectrum, 0, L_frame );
    }

    set32_fx( q_spectrum + L_spec, 0, sub( L_frame, L_spec ) );
}
#endif

/*-------------------------------------------------------*
 * tcx_arith_decode()
@@ -295,7 +174,6 @@ static Word16 tcx_arith_decode_ivas_fx(
 *
 *-------------------------------------------------------*/

#ifdef HARMONIZE_2598_tcx_arith_decode_envelope
void tcx_arith_decode_envelope_fx(
    Decoder_State *st,
    /* i/o: coder state                   */ /*EVS: move argument 5->1 */
@@ -314,23 +192,6 @@ void tcx_arith_decode_envelope_fx(
    Word16 *nf_seed,
    /* o  : noise filling seed         Q0 */ /*IVAS: 0*/
    const Word16 low_complexity              /* i  : low-complexity flag           */
#else
void tcx_arith_decode_envelope_ivas_fx(
    Decoder_State *st,          /* i/o: coder state                   */
    Word32 q_spectrum[],        /* o  : quantised MDCT coefficients Q(31-q_spectrum_e)  */
    Word16 *q_spectrum_e,       /* o  : MDCT exponent                 */
    const Word16 L_frame,       /* i  : frame or MDCT length          */
    Word16 L_spec,              /* i  : length w/o BW limitation      */
    const Word16 A_ind[],       /* i  : quantised LPC coefficients    */
    const Word16 target_bits,   /* i  : number of available bits      */
    Word16 prm[],               /* i  : bitstream parameters          */
    const Word16 use_hm,        /* i  : use HM in current frame?      */
    const Word16 prm_hm[],      /* i  : HM parameter area             */
    Word16 tcxltp_pitch,        /* i  : TCX LTP pitch in FD, -1 if n/a*/
    Word16 *arith_bits,         /* o  : bits used for ari. coding     */
    Word16 *signaling_bits,     /* o  : bits used for signaling       */
    const Word16 low_complexity /* i  : low-complexity flag           */
#endif
)
{
    Word32 env[N_MAX_ARI]; /* unscaled envelope (Q16) */
@@ -376,18 +237,14 @@ void tcx_arith_decode_envelope_ivas_fx(
    move16();
    gamma_uw = st->inv_gamma;
    move16();
#ifdef HARMONIZE_2598_tcx_arith_decode_envelope
    IF( EQ_16( st->element_mode, EVS_MONO ) )
    {
        tcx_arith_render_envelope( A_ind, L_frame, L_spec, hTcxCfg->preemph_fac, gamma_w, gamma_uw, env );
    }
    ELSE
    {
#endif
        tcx_arith_render_envelope_ivas_fx( A_ind, L_frame, L_spec, hTcxCfg->preemph_fac, gamma_w, gamma_uw, env );
#ifdef HARMONIZE_2598_tcx_arith_decode_envelope
    }
#endif


    IF( use_hm != 0 )
@@ -427,18 +284,14 @@ void tcx_arith_decode_envelope_ivas_fx(

    envelope = (Word16 *) env;
    tcx_arith_scale_envelope( L_spec, L_spec_core, env, target_bits, low_complexity, envelope, &envelope_e );
#ifdef HARMONIZE_2598_tcx_arith_decode_envelope
    IF( EQ_16( st->element_mode, EVS_MONO ) )
    {
        *arith_bits = tcx_arith_decode_fx( L_spec, envelope, envelope_e, target_bits, prm, q_spectrum, q_spectrum_e, nf_seed );
    }
    ELSE
    {
#endif
        *arith_bits = tcx_arith_decode_ivas_fx( L_spec, envelope, envelope_e, target_bits, prm, q_spectrum, q_spectrum_e );
#ifdef HARMONIZE_2598_tcx_arith_decode_envelope
    }
#endif
    move16();

    /* safety check in case of bit errors */
+0 −27
Original line number Diff line number Diff line
@@ -356,7 +356,6 @@ void decoder_tcx_fx(
                    move16();
                }

#ifdef HARMONIZE_2598_tcx_arith_decode_envelope
                tcx_arith_decode_envelope_fx(
                    st,
                    x, &x_e,
@@ -373,24 +372,6 @@ void decoder_tcx_fx(
                    &nf_seed,
                    shr( st->bwidth, 1 ) /* equivalent to: (st->bwidth > WB)?1:0 */
                );
#else
                tcx_arith_decode_envelope_fx(
                    x, &x_e,
                    L_frame,
                    L_spec,
                    st,
                    Aind,
                    *prm_target,
                    prm_sqQ,
                    tmp8,
                    prm_hm, /* HM parameter area */
                    hTcxDec->tcx_hm_LtpPitchLag,
                    &arith_bits,
                    &signaling_bits,
                    &nf_seed,
                    shr( st->bwidth, 1 ) /* equivalent to: (st->bwidth > WB)?1:0 */
                );
#endif

                hTcxDec->resQBits[frame_cnt] = sub( *prm_target, arith_bits );
                move16();
@@ -4099,19 +4080,11 @@ void decoder_tcx_invQ_fx(

                IF( GT_32( st->bwidth, WB ) )
                {
#ifdef HARMONIZE_2598_tcx_arith_decode_envelope
                    tcx_arith_decode_envelope_fx( st, x, x_e, L_frame, L_spec, Aind, *prm_target, prm_sqQ, (Word16) NE_16( st->last_core_from_bs, ACELP_CORE ), prm_hm, /* HM parameter area */ hTcxDec->tcx_hm_LtpPitchLag, &arith_bits, &signaling_bits, 0, 1 );
#else
                    tcx_arith_decode_envelope_ivas_fx( st, x, x_e, L_frame, L_spec, Aind, *prm_target, prm_sqQ, (Word16) NE_16( st->last_core_from_bs, ACELP_CORE ), prm_hm, /* HM parameter area */ hTcxDec->tcx_hm_LtpPitchLag, &arith_bits, &signaling_bits, 1 );
#endif
                }
                ELSE
                {
#ifdef HARMONIZE_2598_tcx_arith_decode_envelope
                    tcx_arith_decode_envelope_fx( st, x, x_e, L_frame, L_spec, Aind, *prm_target, prm_sqQ, (Word16) NE_16( st->last_core_from_bs, ACELP_CORE ), prm_hm, /* HM parameter area */ hTcxDec->tcx_hm_LtpPitchLag, &arith_bits, &signaling_bits, 0, 0 );
#else
                    tcx_arith_decode_envelope_ivas_fx( st, x, x_e, L_frame, L_spec, Aind, *prm_target, prm_sqQ, (Word16) NE_16( st->last_core_from_bs, ACELP_CORE ), prm_hm, /* HM parameter area */ hTcxDec->tcx_hm_LtpPitchLag, &arith_bits, &signaling_bits, 0 );
#endif
                }

                hTcxDec->resQBits[frame_cnt] = sub( *prm_target, arith_bits );