Commit 4ddd2769 authored by vaclav's avatar vaclav
Browse files

HARMONIZE_TBE2

parent cf7f073c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@
#define FIX_2391_INIT_HQ_GENERIC_OFFSET                 /* FhG/Eri: basop issue 2391: make sure hq_generic_offset is initialized inside hq_hr_dec_fx() */
#define FIX_2397_COPY_AQ_MDCT_CORE_BFI                  /* FhG: prevent copying of uninit memory in MDCT stereo core if bfi is set */
#define HARMONIZE_TBE                                   /* VA: harmonize core-coder TBE function duplications */
#define HARMONIZE_TBE2

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

+3 −0
Original line number Diff line number Diff line
@@ -10258,6 +10258,9 @@ void swb_pre_proc_ivas_fx(
    Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i  : real buffer Q - q_reImbuffer             */
    Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i  : imag buffer Q - q_reImbuffer             */
    Word16 q_reImBuffer,                                        /* i  : scale data of real and imag CLDFB buffers*/
#ifdef HARMONIZE_TBE
    const CLDFB_SCALE_FACTOR *cldfbScale,                       /* i : scale data of real and imag CLDFB buffers */
#endif
    CPE_ENC_HANDLE hCPE                                         /* i/o: CPE encoder structure                    */
);
+4 −0
Original line number Diff line number Diff line
@@ -450,7 +450,11 @@ ivas_error evs_enc_fx(
    IF( !st->Opt_SC_VBR && GE_32( st->input_Fs, 32000 ) )
    {
        /* Common pre-processing for SWB(FB) TBE and SWB BWE */
#ifdef HARMONIZE_TBEaa
        swb_pre_proc_ivas_fx( st, new_swb_speech, shb_speech, &Q_shb_spch, realBuffer, imagBuffer, 0, &cldfbScale, NULL );
#else
        swb_pre_proc_fx( st, st->input_fx, new_swb_speech, shb_speech, &Q_shb_spch, realBuffer, imagBuffer, &cldfbScale );
#endif
    }
    ELSE IF( GE_32( st->input_Fs, 32000 ) )
    {
+4 −0
Original line number Diff line number Diff line
@@ -734,7 +734,11 @@ ivas_error ivas_core_enc_fx(
            }

#ifdef REMOVE_SCALING_SHB_SPEECH
#ifdef HARMONIZE_TBE
            swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, shb_speech_fx, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], NULL, hCPE );
#else
            swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, shb_speech_fx, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE );
#endif
#else
            swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, new_swb_speech_fx, shb_speech_fx, &Q_shb_spch, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE );
#endif
+101 −2
Original line number Diff line number Diff line
@@ -784,6 +784,9 @@ void swb_pre_proc_ivas_fx(
    Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i  : real buffer Q - q_reImbuffer                */
    Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i  : imag buffer Q - q_reImbuffer                */
    Word16 q_reImBuffer,                                        /* i  : scale data of real and imag CLDFB buffers   */
#ifdef HARMONIZE_TBE
    const CLDFB_SCALE_FACTOR *cldfbScale, /* i : scale data of real and imag CLDFB buffers    */
#endif
    CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure                       */
)
{
@@ -895,7 +898,6 @@ void swb_pre_proc_ivas_fx(
    }
    ELSE /* 48 kHz */
    {

        Sample_Delay_SWB_BWE32k = NS2SA( 32000, DELAY_FD_BWE_ENC_12k8_NS );
        move16();
        Sample_Delay_SWB_BWE = NS2SA( 48000, DELAY_FD_BWE_ENC_12k8_NS );
@@ -1157,6 +1159,103 @@ void swb_pre_proc_ivas_fx(
            thr = icbwe_thr_DFT_fx;
            regV = icbwe_regressionValuesDFT_fx;
        }
#ifdef HARMONIZE_TBE
        ELSE IF( st->element_mode == EVS_MONO )
        {
            IF( EQ_16( st->L_frame, L_FRAME ) )
            {
                startB = 34;
                move16();
                endB = 14;
                move16();
                FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ )
                {
                    uB = 0;
                    move16();
                    FOR( nB = startB; nB > endB; nB-- )
                    {
                        realBufferFlipped[ts][uB] = realBuffer[ts][nB];
                        move32();
                        if ( s_and( ts, 1 ) != 0 )
                        {
                            realBufferFlipped[ts][uB] = L_negate( realBufferFlipped[ts][uB] );
                            move32();
                        }
                        imagBufferFlipped[ts][uB] = imagBuffer[ts][nB];
                        move32();
                        if ( s_and( ts, 1 ) == 0 )
                        {
                            imagBufferFlipped[ts][uB] = L_negate( imagBufferFlipped[ts][uB] );
                            move32();
                        }
                        uB = add( uB, 1 ); /* uB ++ */
                    }
                }
            }
            ELSE
            {
                startB = 39;
                move16();
                endB = 19;
                move16();
                FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ )
                {
                    uB = 0;
                    move16();
                    FOR( nB = startB; nB > endB; nB-- )
                    {
                        realBufferFlipped[ts][uB] = L_negate( realBuffer[ts][nB] );
                        move32();
                        imagBufferFlipped[ts][uB] = imagBuffer[ts][nB];
                        move32();
                        uB = add( uB, 1 ); /* uB ++ */
                    }
                }
            }

            /* Highband energy computation for gain shape control in case of bandwidth switching fix*/
            {
                Word32 cldfbWorkBuffer[256];

                lbEner = 0;
                move32();
                FOR( nB = 0; nB < 10; nB++ )
                {
                    FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ )
                    {
                        realQ_neg1 = extract_l( L_shr( realBufferFlipped[ts][nB], 31 - ( 15 + cldfbScale->hb_scale ) + 1 ) );
                        imagQ_neg1 = extract_l( L_shr( imagBufferFlipped[ts][nB], 31 - ( 15 + cldfbScale->hb_scale ) + 1 ) ); /* Q(-1), headroom needed */

                        lbEner = L_mac0_o( lbEner, realQ_neg1, realQ_neg1, &Overflow );
                        lbEner = L_mac0_o( lbEner, imagQ_neg1, imagQ_neg1, &Overflow ); /* Q(-2) */
                    }
                }

                exp = norm_l( lbEner );
                lbEner = L_shl( lbEner, exp ); /* CldfbHB_ener = CldfbHB_fl*2^(exp) */
                Cldfbtemp1 = ( Log2_norm_lc( lbEner ) );
                Cldfbtemp1 = add( shr( Cldfbtemp1, 6 ), shl( sub( 30, sub( exp, 2 ) ), 9 ) );      /* Log2_norm_lc(CldfbHB_ener) = 2^15*(log2(CldfbHB_ener/2^30)) = 2^15*(log2(CldfbHB_fl*(2^-2)*2^exp/2^30)) = 2^15*(log2(CldfbHB_fl) + exp-2-30) => 2^(-6)*l2nc + 2^9(20-(exp-2)) = 2^9*log2(CldfbHB_fl), Q9 */
                lbEner = L_mult( sub( Cldfbtemp1, 1741 /*3.401 Q9*/ ), 3495 );                     /* 3495 = Q19 log10(2)*0.1/log10(32768), Q = 19+9+1 = 29 */
                hBWE_TD->cldfbHBLT = mac_r( lbEner, 29491 /*0.9 Q15*/, hBWE_TD->cldfbHBLT );       /* cldfbHBLT is in Q13 */

                cldfbSynthesis_fx( st->cldfbSynTd, realBufferFlipped, imagBufferFlipped, cldfbScale, shb_speech, 0, CLDFB_NO_COL_MAX, cldfbWorkBuffer );
            }

            test();
            test();
            IF( NE_16( st->extl, WB_TBE ) && NE_16( st->extl, SWB_TBE ) && NE_16( st->extl, FB_TBE ) )
            {
                /* Update the previous superwideband speech buffer in case of a SWB_BWE frame - this code is in swb_tbe_enc */
                delay = L_LOOK_16k + L_SUBFR16k;
                Copy( shb_speech + L_FRAME16k - delay, hBWE_TD->old_speech_shb_fx, delay );
            }

            thr = 0; // just to avoid warnings
            move16();
            regV = 0; // just to avoid warnings
            move16();
        }
#endif
        ELSE
        {
            IF( EQ_16( st->L_frame, L_FRAME ) )