Commit 65720d90 authored by vaclav's avatar vaclav
Browse files

HARMONIZE_TBE3

parent 5427429c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -418,7 +418,7 @@ ivas_error evs_dec_fx(
            /* SWB TBE decoder */
#ifdef HARMONIZE_TBE3
            swb_tbe_dec_ivas_fx( st_fx, NULL, bwe_exc_extended_fx, voice_factors_fx,
                                 old_syn_12k8_16k_fx, fb_exc_fx, &Q_fb_exc, hb_synth_fx, NULL, pitch_buf_fx, &hb_synth_fx_exp );
                                 old_syn_12k8_16k_fx, fb_exc_fx, &Q_fb_exc, hb_synth_fx, NULL, &hb_synth_fx_exp, pitch_buf_fx );
#else
            swb_tbe_dec_fx( st_fx, st_fx->coder_type, bwe_exc_extended_fx, st_fx->Q_exc, voice_factors_fx,
                            old_syn_12k8_16k_fx, fb_exc_fx, &Q_fb_exc, hb_synth_fx, &hb_synth_fx_exp, pitch_buf_fx );
@@ -860,7 +860,7 @@ ivas_error evs_dec_fx(
                        /* SWB TBE decoder */
#ifdef HARMONIZE_TBE3
                        swb_tbe_dec_ivas_fx( st_fx, NULL, bwe_exc_extended_fx, voice_factors_fx,
                                             hBWE_TD->old_core_synth_fx, fb_exc_fx, &Q_fb_exc, hb_synth_fx, NULL, pitch_buf_fx, &hb_synth_fx_exp );
                                             hBWE_TD->old_core_synth_fx, fb_exc_fx, &Q_fb_exc, hb_synth_fx, NULL, &hb_synth_fx_exp, pitch_buf_fx );
#else
                        swb_tbe_dec_fx( st_fx, st_fx->coder_type, bwe_exc_extended_fx, st_fx->Q_exc, voice_factors_fx, hBWE_TD->old_core_synth_fx,
                                        fb_exc_fx, &Q_fb_exc, hb_synth_fx, &hb_synth_fx_exp, pitch_buf_fx );
+1 −1
Original line number Diff line number Diff line
@@ -1001,7 +1001,7 @@ ivas_error ivas_core_dec_fx(
        {
            /* SWB TBE decoder */
#ifdef HARMONIZE_TBE3
            swb_tbe_dec_ivas_fx( st, hStereoICBWE, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx[n], tmp_buffer_fx /*fb_exc*/, &Q_white_exc, NULL, hb_synth_32_fx[n], pitch_buf_fx[n], &tmp16 );
            swb_tbe_dec_ivas_fx( st, hStereoICBWE, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx[n], tmp_buffer_fx /*fb_exc*/, &Q_white_exc, NULL, hb_synth_32_fx[n], &tmp16, pitch_buf_fx[n] );
#else
            swb_tbe_dec_ivas_fx( st, hStereoICBWE, bwe_exc_extended_fx[n], st->Q_exc, voice_factors_fx[n], old_syn_12k8_16k_fx[n], tmp_buffer_fx /*fb_exc*/, hb_synth_32_fx[n], pitch_buf_fx[n], &Q_white_exc );
#endif
+93 −62
Original line number Diff line number Diff line
@@ -5059,13 +5059,6 @@ void swb_tbe_dec_ivas_fx(
        }
    }

#ifndef HARMONIZE_TBE3 // VE: TBV!!!
    test();
    IF( st->use_partial_copy && st->nelp_mode_dec )
    {
        set16_fx( vf_modified_fx, 0, NB_SUBFR16k );
    }
#endif
    /* SHB LSF from current frame; and convert to LSP for interpolation */
    E_LPC_lsf_lsp_conversion( lsf_shb_fx, lsp_shb_2_fx, LPC_SHB_ORDER );

@@ -5186,9 +5179,14 @@ void swb_tbe_dec_ivas_fx(
                Copy( lsp_shb_2_fx, lsp_temp_fx, LPC_SHB_ORDER );
            }

#ifdef HARMONIZE_TBE3
            IF( st->element_mode != EVS_MONO )
#endif
            {
                /* convert from lsp to lsf */
                lsp2lsf_fx( lsp_temp_fx, lsf_shb_fx, LPC_SHB_ORDER, 1 );
            }
        }

        Copy( lsf_diff_fx + 1, hBWE_TD->prev_lsf_diff_fx, LPC_SHB_ORDER - 2 );
        hBWE_TD->prev_tilt_para_fx = tilt_para_fx;
@@ -5250,10 +5248,6 @@ void swb_tbe_dec_ivas_fx(
        Copy( lsf_shb_fx, st->hTdCngDec->lsp_shb_prev_fx, LPC_SHB_ORDER );
    }

#ifdef HARMONIZE_TBE3
    IF( st->element_mode > EVS_MONO )
#endif
    {
    /* convert LSPs back into LP coeffs */
    E_LPC_f_lsp_a_conversion( lsp_temp_fx, lpc_shb_fx, LPC_SHB_ORDER );
    Copy_Scale_sig( lpc_shb_fx, lpc_shb_fx, LPC_SHB_ORDER + 1, sub( norm_s( lpc_shb_fx[0] ), 2 ) ); /* Q12 */
@@ -5261,7 +5255,11 @@ void swb_tbe_dec_ivas_fx(
    move16();

    test();
#ifdef HARMONIZE_TBE3
    IF( st->element_mode > EVS_MONO && ( EQ_32( st->extl_brate, SWB_TBE_1k10 ) || EQ_32( st->extl_brate, SWB_TBE_1k75 ) ) )
#else
    IF( EQ_32( st->extl_brate, SWB_TBE_1k10 ) || EQ_32( st->extl_brate, SWB_TBE_1k75 ) )
#endif
    {
        Word32 vind_temp = Mpy_32_32( L_shl( L_add( L_deposit_l( mixFactors_fx ), 1 ), 15 ), ( ( ( 1 << NUM_BITS_SHB_VF ) - 1 ) << 16 ) ); // check addition of 1
        vind = extract_l( L_shr( vind_temp, 15 ) ); /* 3 for mpy by 8.0f, -15 to bring it to Q0 */                                         /*mixFactors*7*/
@@ -5274,11 +5272,11 @@ void swb_tbe_dec_ivas_fx(
        /* i: mixFactors_fx in Q15 */
        /* o: vind in Q0        */
    }
    }

    /* Determine formant PF strength */
    formant_fac_fx = swb_formant_fac_fx( lpc_shb_fx[1], &hBWE_TD->tilt_mem_fx );
    /* i:lpc_shb_fx Q12, o:formant_fac_fx Q15 */

    IF( GT_32( st->total_brate, ACELP_32k ) )
    {
        FOR( j = 0; j < 4; j++ )
@@ -5291,9 +5289,23 @@ void swb_tbe_dec_ivas_fx(

    /* -------- start of  memory rescaling  -------- */
    /* ----- calculate optimum Q_bwe_exc and rescale memories accordingly ----- */
#ifdef HARMONIZE_TBE3
    Word16 sig_len = L_FRAME32k + NL_BUFF_OFFSET;
    move16();
    IF( st->element_mode == EVS_MONO )
    {
        sig_len = L_FRAME32k;
        move16();
    }

    Lmax = 0;
    move32();
    FOR( cnt = 0; cnt < sig_len; cnt++ )
#else
    Lmax = 0;
    move32();
    FOR( cnt = 0; cnt < L_FRAME32k + NL_BUFF_OFFSET; cnt++ )
#endif
    {
        Lmax = L_max( Lmax, L_abs( bwe_exc_extended_fx[cnt] ) );
    }
@@ -5324,13 +5336,29 @@ void swb_tbe_dec_ivas_fx(
    /* rescale the bwe_exc_extended and bring it to 16-bit single precision with dynamic norm  */
    sc = sub( Q_bwe_exc, add( Q_exc, Q_exc ) );

#ifdef HARMONIZE_TBE3
    IF( st->element_mode == EVS_MONO )
    {
        Copy( hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_16, NL_BUFF_OFFSET );

        FOR( cnt = 0; cnt < L_FRAME32k; cnt++ )
        {
            bwe_exc_extended_16[cnt + NL_BUFF_OFFSET] = round_fx_sat( L_shl_sat( bwe_exc_extended_fx[cnt], sc ) );
        }
        Copy( bwe_exc_extended_16 + L_FRAME32k, hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET );

        /* state_syn_shbexc_fx is kept at (st->prev_Q_bwe_syn) for 24.4/32kbps or is kept at Q_bwe_exc for 13.2/16.4kbps */
        Copy( hBWE_TD->state_syn_shbexc_fx, shaped_shb_excitation_fx, L_SHB_LAHEAD );
    }
    ELSE
#endif
    {
        FOR( cnt = 0; cnt < L_FRAME32k + NL_BUFF_OFFSET; cnt++ )
        {
            bwe_exc_extended_16[cnt] = round_fx_sat( L_shl_sat( bwe_exc_extended_fx[cnt], sc ) );
            move16();
        }

    /* state_syn_shbexc_fx is kept at (st_fx->prev_Q_bwe_syn) for 24.4/32kbps or is kept at Q_bwe_exc for 13.2/16.4kbps */
    }

    /* save the previous Q factor (32-bit) of the buffer */
    st->prev_Q_bwe_exc = Q_bwe_exc;
@@ -5356,12 +5384,19 @@ void swb_tbe_dec_ivas_fx(
                Copy( lpc_shb_fx, &lpc_shb_sf_fx[i_mult( j, LPC_SHB_ORDER + 1 )], LPC_SHB_ORDER + 1 );
            }
        }

        /* Calculate the 6 to 14 kHz (or 7.5 - 15.5 kHz) SHB excitation signal from the low band ACELP core excitation */
        GenShapedSHBExcitation_fx( shaped_shb_excitation_fx + L_SHB_LAHEAD, lpc_shb_fx, White_exc16k_fx,
                                   hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx,
                                   st->coder_type, st->element_mode, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified_fx, st->extl,
                                   &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), lpc_shb_sf_fx, shb_ener_sf_32,
                                   shb_res_gshape_fx, shb_res_dummy_fx, &vind, formant_fac_fx, hBWE_TD->fb_state_lpc_syn_fx,
                                   &( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, &Q_bwe_exc_fb, Q_shb, n_mem2, hBWE_TD->prev_Q_bwe_syn, st->total_brate, st->prev_bfi );
    }
    ELSE
#endif
    {
        Copy( hBWE_TD->state_syn_shbexc_fx, shaped_shb_excitation_fx, L_SHB_LAHEAD );
    }

#ifdef HARMONIZE_TBE2
        GenShapedSHBExcitation_ivas_fx( DEC, shaped_shb_excitation_fx + L_SHB_LAHEAD, lpc_shb_fx, White_exc16k_fx,
@@ -5382,6 +5417,7 @@ void swb_tbe_dec_ivas_fx(
                                            st->element_mode, st->flag_ACELP16k, nlExc16k_fx, mixExc16k_fx, st->extl_brate, MSFlag,
                                            NULL, &( hBWE_TD->prev_pow_exc16kWhtnd_fx32 ), &( hBWE_TD->prev_mix_factor_fx ), NULL, NULL );
#endif
    }

    *Q_white_exc = Q_bwe_exc_fb;
    move16();
@@ -5920,17 +5956,8 @@ void swb_tbe_dec_ivas_fx(
            move16();
            IF( i != 0 )
            {
#ifdef HARMONIZE_TBE3 // VE: TBV
                IF( st->element_mode == EVS_MONO )
                {
                    idx = idiv1616( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR );
                }
                ELSE
#endif
                {
                idx = shr( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR_LOG2 );
            }
            }
            GainShape_fx[i] = GainShape_tmp_fx[idx];
            move16();
        }
@@ -6485,9 +6512,11 @@ void swb_tbe_dec_ivas_fx(
                    move16(); /*Qx*/
                }
            }

            ELSE
            {
                Copy( error_fx16, synth_fx16, L_FRAME32k );
            }
        }
        ELSE
#endif
        {
@@ -6499,10 +6528,12 @@ void swb_tbe_dec_ivas_fx(
                    move32(); /*Qx*/
                }
            }

            ELSE
            {
                Copy32( error_fx, synth_fx, L_FRAME32k );
            }
        }
    }
    ELSE IF( EQ_32( st->output_Fs, 16000 ) )
    {
#ifdef HARMONIZE_TBE3