Commit 7f93de8f authored by Fabian Bauer's avatar Fabian Bauer
Browse files

added macro and code for HARMONIZE_2597_ShapeSpectrum

parent 6b289e01
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -112,6 +112,7 @@
#define HARMONIZE_2553_TonalConceal_Init                /* FhG: Harmonize TonalMDCTConceal_Init with its ivas derivate */
#define HARMONIZE_2553_TonalConceal_SaveFreqSignal      /* FhG: Harmonize TonalConceal_SaveFreqSignal with its ivas derivate */
#define HARMONIZE_2553_TonalConceal_SaveTimeSignal      /* FhG: Harmonize TonalConceal_SaveTimeSignal with its ivas derivate */
#define HARMONIZE_2597_ShapeSpectrum                    /* FhG: Harmonize ShapeSpectrum with its ivas derivate */

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

+51 −4
Original line number Diff line number Diff line
@@ -221,6 +221,7 @@ void TNSAnalysis_fx(
    }
}

#ifndef HARMONIZE_2597_ShapeSpectrum
void ShapeSpectrum_fx(
    TCX_CONFIG_HANDLE hTcxCfg, /* i  : configuration of TCX               */
    Word16 A[],                /* input: quantized coefficients NxAz_q[M+1]  Q = 14 - norm(A[0])*/
@@ -460,14 +461,20 @@ void ShapeSpectrum_fx(
        PsychAdaptLowFreqEmph_fx( spectrum, gainlpc, gainlpc_e );
    }
}
#endif

#ifdef HARMONIZE_2597_ShapeSpectrum
void ShapeSpectrum_fx(
#else
void ShapeSpectrum_ivas_fx(
#endif
    TCX_CONFIG_HANDLE hTcxCfg, /* i  : configuration of TCX               */
    Word16 A[],                /* input: quantized coefficients NxAz_q[M+1], Q = 14 - norm(A[0]) */
    Word16 gainlpc[],          /* output: MDCT gains for the previous frame Q(15-gainlpc_e)*/
    Word16 gainlpc_e[],        /* output: MDCT gains exponents */
    Word16 L_frame_glob,       /* input: frame length             */
    Word16 L_spec,
    Word32 spectrum[],  /* i/o: MDCT spectrum Q(31-spectrum_e) */
    Word32 spectrum[],         /* i/o: MDCT spectrum */
    Word16 *spectrum_e,        /* i/o: MDCT spectrum exponent */
    Word8 pfUseTns,            /* output: Flag indicating if TNS is used */
    Encoder_State *st,
@@ -541,7 +548,20 @@ void ShapeSpectrum_ivas_fx(
    test();
    test();
    test();
#ifdef HARMONIZE_2597_ShapeSpectrum
    Word32 condition;
    IF( EQ_16( st->element_mode, EVS_MONO ) )
    {
        condition = ( EQ_32( total_brate, ACELP_9k60 ) && EQ_16( st->bwidth, SWB ) ) || ( EQ_32( total_brate, ACELP_13k20 ) && EQ_16( st->bwidth, SWB ) );
    }
    ELSE
    {
        condition = ( LE_32( total_brate, ACELP_13k20 ) || ( LE_32( st->element_brate, IVAS_16k4 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( st->bwidth, SWB );
    }
    IF( condition )
#else
    IF( ( LE_32( total_brate, ACELP_13k20 ) || ( LE_32( st->element_brate, IVAS_16k4 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( st->bwidth, SWB ) )
#endif
    {
        max_low_pre = 0;
        move32();
@@ -619,7 +639,19 @@ void ShapeSpectrum_ivas_fx(
    test();
    test();
    test();
#ifdef HARMONIZE_2597_ShapeSpectrum
    IF( EQ_16( st->element_mode, EVS_MONO ) )
    {
        condition = ( EQ_32( st->total_brate, ACELP_9k60 ) && EQ_16( st->bwidth, SWB ) ) || ( EQ_32( st->total_brate, ACELP_13k20 ) && EQ_16( st->bwidth, SWB ) );
    }
    ELSE
    {
        condition = ( LE_32( total_brate, ACELP_13k20 ) || ( LE_32( st->element_brate, IVAS_16k4 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( st->bwidth, SWB );
    }
    IF( condition )
#else
    IF( ( LE_32( total_brate, ACELP_13k20 ) || ( LE_32( st->element_brate, IVAS_16k4 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( st->bwidth, SWB ) )
#endif
    {
        Word16 sf_width;
        Word16 dist_low, dist_high;
@@ -724,7 +756,11 @@ void ShapeSpectrum_ivas_fx(
        {
            Word16 fac;
            fac = divide3232( max_low2, max_high );
#ifdef HARMONIZE_2597_ShapeSpectrum
            IF( GE_16( norm_s( fac ), max_fac_s ) || EQ_16( st->element_mode, EVS_MONO ) )
#else
            IF( GE_16( norm_s( fac ), max_fac_s ) )
#endif
            {
                fac = shl( mult_r( fac, max_fac_m ), max_fac_s );
                FOR( i = 0; i < ( L_spec - L_frame ); i++ )
@@ -3836,12 +3872,23 @@ void coder_tcx_fx(
        ProcessIGF_fx( st, 0, spectrum, &q_spectrum, NULL, 0, powerSpec, &powerSpec_e, 1, 0, 0, 0 );
    }

#ifdef HARMONIZE_2597_ShapeSpectrum
    ShapeSpectrum_fx( hTcxCfg, A, gainlpc, gainlpc_e,
                      L_frame_glob,
                      L_spec,
                      spectrum,
                      0,
                      hTcxEnc->fUseTns[0],
                      st,
                      0 );
#else
    ShapeSpectrum_fx( hTcxCfg, A, gainlpc, gainlpc_e,
                      L_frame_glob,
                      L_spec,
                      spectrum,
                      hTcxEnc->fUseTns[0],
                      st );
#endif
    if ( st->igf )
    {
        nb_bits = sub( nb_bits, st->hIGFEnc->infoTotalBitsPerFrameWritten );
+28 −1
Original line number Diff line number Diff line
@@ -171,6 +171,19 @@ void core_encode_twodiv_fx(
            }

            /* Shape spectrum */
#ifdef HARMONIZE_2597_ShapeSpectrum
            ShapeSpectrum_fx( st->hTcxCfg,
                              A_q,
                              gainlpc[n],
                              gainlpc_e[n],
                              shr( st->L_frame, 1 ),
                              shr( st->hTcxCfg->tcx_coded_lines, 1 ),
                              spectrum[n],
                              0,
                              hTcxEnc->fUseTns[n],
                              st,
                              0 );
#else
            ShapeSpectrum_fx( st->hTcxCfg,
                              A_q,
                              gainlpc[n],
@@ -180,6 +193,7 @@ void core_encode_twodiv_fx(
                              spectrum[n],
                              hTcxEnc->fUseTns[n],
                              st );
#endif

            st->last_core = st->core;
            move16();
@@ -266,7 +280,19 @@ void core_encode_twodiv_fx(

        E_LPC_f_lsp_a_conversion( lsp_q, A_q, M );


#ifdef HARMONIZE_2597_ShapeSpectrum
        ShapeSpectrum_fx( st->hTcxCfg,
                          A_q,
                          gainlpc[0],
                          gainlpc_e[0],
                          st->L_frame,
                          st->hTcxCfg->tcx_coded_lines,
                          spectrum[0],
                          0,
                          hTcxEnc->fUseTns[0],
                          st,
                          0 );
#else
        ShapeSpectrum_fx( st->hTcxCfg,
                          A_q,
                          gainlpc[0],
@@ -276,6 +302,7 @@ void core_encode_twodiv_fx(
                          spectrum[0],
                          hTcxEnc->fUseTns[0],
                          st );
#endif

        /*_DIFF_FLOAT_FIX_EVS_IVAS  -> The line below is present in float */
        // hTcxEnc->measuredBwRatio = 0x4000;
+8 −0
Original line number Diff line number Diff line
@@ -2125,7 +2125,11 @@ void ivas_mdct_core_whitening_enc_fx(
            move16();

            /* Shape spectrum */
#ifdef HARMONIZE_2597_ShapeSpectrum
            ShapeSpectrum_fx( st->hTcxCfg, A_q_fx[ch][n], NULL, NULL, L_subframe, tcx_subframe_coded_lines, st->hTcxEnc->spectrum_fx[n], &st->hTcxEnc->spectrum_e[n], st->hTcxEnc->fUseTns[n], st, scf_q_fx[ch][n] );
#else
            ShapeSpectrum_ivas_fx( st->hTcxCfg, A_q_fx[ch][n], NULL, NULL, L_subframe, tcx_subframe_coded_lines, st->hTcxEnc->spectrum_fx[n], &st->hTcxEnc->spectrum_e[n], st->hTcxEnc->fUseTns[n], st, scf_q_fx[ch][n] );
#endif

            Scale_sig32( st->hTcxEnc->spectrum_fx[n] + L_subframe, sub( L_subframeTCX, L_subframe ), sub( exp_tmp, st->hTcxEnc->spectrum_e[n] ) );
        }
@@ -2265,7 +2269,11 @@ void ivas_mdct_core_whitening_enc_fx(
                move16();

                /* Shape spectrum */
#ifdef HARMONIZE_2597_ShapeSpectrum
                ShapeSpectrum_fx( st->hTcxCfg, A_q_fx[ch][n], NULL, NULL, L_subframe, tcx_subframe_coded_lines, mdst_spectrum_fx[ch][n], &mdst_spectrum_e[ch][n], st->hTcxEnc->fUseTns[n], st, scf_q_fx[ch][n] );
#else
                ShapeSpectrum_ivas_fx( st->hTcxCfg, A_q_fx[ch][n], NULL, NULL, L_subframe, tcx_subframe_coded_lines, mdst_spectrum_fx[ch][n], &mdst_spectrum_e[ch][n], st->hTcxEnc->fUseTns[n], st, scf_q_fx[ch][n] );
#endif

                Scale_sig32( mdst_spectrum_fx[ch][n] + L_subframe, sub( L_subframeTCX, L_subframe ), sub( exp_tmp, mdst_spectrum_e[ch][n] ) );
            }
+4 −0
Original line number Diff line number Diff line
@@ -531,7 +531,11 @@ void stereo_tcx_core_enc(
        bitsAvailable = sub( bitsAvailable, nbits_lpc[n] );

        /* Shape spectrum */
#ifdef HARMONIZE_2597_ShapeSpectrum
        ShapeSpectrum_fx( st->hTcxCfg, A_q_fx, gainlpc_fx[n], gainlpc_e[n], st->L_frame / n_subframes, st->hTcxCfg->tcx_coded_lines / n_subframes, hTcxEnc->spectrum_fx[n], &hTcxEnc->spectrum_e[n], hTcxEnc->fUseTns[n], st, NULL );
#else
        ShapeSpectrum_ivas_fx( st->hTcxCfg, A_q_fx, gainlpc_fx[n], gainlpc_e[n], st->L_frame / n_subframes, st->hTcxCfg->tcx_coded_lines / n_subframes, hTcxEnc->spectrum_fx[n], &hTcxEnc->spectrum_e[n], hTcxEnc->fUseTns[n], st, NULL );
#endif

        st->last_core = st->core;
        move16();
Loading