Commit c8b0e506 authored by multrus's avatar multrus
Browse files

Merge branch 'basop-2597-harmonize-shapespectrum' into 'main'

Resolve "Harmonize ShapeSpectrum"

Closes #2597

See merge request !3041
parents 2cd1f81f 0b832279
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@
#define FIX_FLOAT_1539_G192_FORMAT_SWITCH               /* VA/Nokia: reintroduce format switching for g192 bitstreams */
#define HARMONIZE_2595_reconfig_decoder_LPD             /* FhG: Harmonize reconfig_decoder_LPD with its ivas derivate */
#define HARMONIZE_2596_SetModeIndex                     /* FhG: Harmonize SetModeIndex with its ivas derivate */
#define HARMONIZE_2597_ShapeSpectrum                    /* FhG: Harmonize ShapeSpectrum with its ivas derivate */

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

+23 −1
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,
@@ -724,7 +731,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++ )
@@ -3793,12 +3804,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
@@ -520,7 +520,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