Commit 0f159366 authored by vaclav's avatar vaclav
Browse files

HARM_CORE_SW, decoder step 7 (core_switching_pre_enc)

parent c2e5c89c
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -10945,6 +10945,7 @@ ivas_error IGF_Reconfig_fx(
    const Word16 rf_mode              /* i  : flag to signal the RF mode      */
);
#ifndef HARM_CORE_SW
void core_switching_post_enc_ivas_fx(
    Encoder_State *st /* i/o: encoder state structure             */
#ifndef CLEANUP_ACELP_ENC
@@ -10955,7 +10956,7 @@ void core_switching_post_enc_ivas_fx(
    Word16 Q_new
#endif
);
#endif
void residu_ivas_fx(
    const Word16 *a, /* i  : LP filter coefficients           Q31-a_exp*/
    const Word16 a_exp,
+4 −0
Original line number Diff line number Diff line
@@ -136,7 +136,11 @@ void amr_wb_enc_fx(
    /* Updates in case of HQ -> AMR-WB IO mode switching */
    Q_new = 0;
    move16(); /* prevent compiler warning only*/
#ifdef HARM_CORE_SW
    core_switching_pre_enc_fx( st, NULL, 0, NULL, 0, 0, 0 );
#else
    core_switching_pre_enc_fx( st, NULL, NULL, 0, 0 );
#endif

    set16_fx( hf_gain_fx, 0, NB_SUBFR );
    set16_fx( old_inp, 0, L_INP_12k8 );
+114 −12
Original line number Diff line number Diff line
@@ -21,7 +21,13 @@
void core_switching_pre_enc_fx(
    Encoder_State *st_fx,       /* i/o: encoder state structure             */
    const Word16 *old_inp_12k8, /* i  : old input signal @12.8kHz         Qx*/
#ifdef HARM_CORE_SW
    const Word16 q_old_inp_12k8, /* i  : Q old input signal @12.8kHz         */
#endif
    const Word16 *old_inp_16k, /* i  : old input signal @16kHz           Qx*/
#ifdef HARM_CORE_SW
    const Word16 q_old_inp_16k, /* i  : Q old input signal @16kHz           */
#endif
    const Word16 active_cnt,       /* i  : active frame counter              Q0*/
    const Word16 last_element_mode /* i  : last_element_mode                 Q0*/
)
@@ -112,7 +118,7 @@ void core_switching_pre_enc_fx(
    test();
    test();
    test();
    IF( EQ_16( st_fx->last_core, -1 ) && ( EQ_16( st_fx->core, HQ_CORE ) || EQ_16( st_fx->core, TCX_20_CORE ) || EQ_16( st_fx->core, TCX_10_CORE ) ) )
    if ( EQ_16( st_fx->last_core, -1 ) && ( EQ_16( st_fx->core, HQ_CORE ) || EQ_16( st_fx->core, TCX_20_CORE ) || EQ_16( st_fx->core, TCX_10_CORE ) ) )
    {
        /* very first frame is HQ_CORE */
        st_fx->last_core = HQ_CORE;
@@ -237,7 +243,16 @@ void core_switching_pre_enc_fx(
        }

        Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); /*Q6*/
#ifdef HARM_CORE_SW
        IF( NE_16( st_fx->element_mode, EVS_MONO ) )
        {
            set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR << 6, tmp16 );
        }
        ELSE
#endif
        {
            set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 );
        }

        /* Reset old ACELP buffers */
        test();
@@ -251,6 +266,7 @@ void core_switching_pre_enc_fx(

            /* reset BWE memories */
            hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
            move32();
        }
        IF( hBWE_FD != NULL )
        {
@@ -292,7 +308,7 @@ void core_switching_pre_enc_fx(
        {
            set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 );
            hBWE_TD->bwe_non_lin_prev_scale_fx = 0;
            move16();
            move32();
        }

        /* reset BWE memories */
@@ -301,6 +317,7 @@ void core_switching_pre_enc_fx(
            set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
        }
    }

    test();
    test();
    test();
@@ -341,8 +358,28 @@ void core_switching_pre_enc_fx(
                }
                Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) );
            }

#ifdef HARM_CORE_SW
            IF( NE_16( st_fx->element_mode, EVS_MONO ) )
            {
                IF( GT_16( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) )
                {
                    Copy_Scale_sig( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_12k8 ) ); // prev_Q_input_lp
                }
                ELSE
                {
                    Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) ); // q_old_inp_12k8
                    hBWE_FD->prev_Q_input_lp = q_old_inp_12k8;
                    move16();
                    Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP );
                }
            }
            ELSE
#endif
            {
                Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); /*Qx*/
            }
        }
        ELSE
        {
            Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS );
@@ -356,12 +393,36 @@ void core_switching_pre_enc_fx(
                Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) );
            }

#ifdef HARM_CORE_SW
            IF( NE_16( st_fx->element_mode, EVS_MONO ) )
            {
                IF( GT_16( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) )
                {
                    Copy_Scale_sig( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_16k ) ); // prev_Q_input_lp
                }
                ELSE
                {
                    Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) ); // q_old_inp_16k
                    hBWE_FD->prev_Q_input_lp = q_old_inp_16k;
                    move16();
                    Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP );
                }
            }
            ELSE
#endif
            {
                Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); /*Qx*/
            }
        }

        tmp = sub( L_LOOK_16k + L_SUBFR16k, Sample_Delay_HP );
        Copy( &hBWE_TD->old_speech_shb_fx[tmp], hBWE_FD->new_input_hp_fx, Sample_Delay_HP ); /*Q(Q_shb_spch)*/
#ifdef HARM_CORE_SW
        hBWE_FD->Q_new_input_hp = 0;
        move16();
#else
        add( 0, 0 );
#endif

        IF( NE_16( st_fx->last_extl, WB_BWE ) )
        {
@@ -417,6 +478,13 @@ void core_switching_post_enc_fx(
        hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 );
        hBWE_FD->mem_deemph_old_syn_fx = 0;
        move16();
#ifdef HARM_CORE_SW
        IF( NE_16( st_fx->element_mode, EVS_MONO ) )
        {
            hBWE_FD->q_mem_deemph_old_syn = 0;
            move16();
        }
#endif
    }
    ELSE
    {
@@ -461,23 +529,56 @@ void core_switching_post_enc_fx(
        test();
        test();
        test();
#ifdef HARM_CORE_SW
        test();
        test();
        test();
        test();
        test();
        test();
        test();
#endif
        IF( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) ) &&
            ( EQ_16( st_fx->last_core, HQ_CORE ) || NE_16( st_fx->L_frame, st_fx->last_L_frame ) ||
              ( NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) && NE_16( st_fx->last_core, TCX_20_CORE ) && NE_16( st_fx->last_core, TCX_10_CORE ) ) ) )
        {
            set16_fx( hBWE_TD->state_ana_filt_shb_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) );
#ifdef HARM_CORE_SW
            IF( NE_16( st_fx->element_mode, EVS_MONO ) )
            {
                InitSWBencBufferStates_fx( st_fx->hBWE_TD, NULL );
            }
            ELSE
#endif
            {
                set16_fx( hBWE_TD->old_speech_shb_fx, 0, L_LOOK_16k + L_SUBFR16k );
            }

            swb_tbe_reset_fx( hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx,
                              hBWE_TD->syn_overlap_fx, hBWE_TD->state_syn_shbexc_fx, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ),
                              hBWE_TD->mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ) );

            set16_fx( hBWE_TD->dec_2_over_3_mem_fx, 0, 12 );
            set16_fx( hBWE_TD->dec_2_over_3_mem_fx, 0, L_FILT_2OVER3 );
#ifdef HARM_CORE_SW
            IF( NE_16( st_fx->element_mode, EVS_MONO ) )
            {
                set16_fx( st_fx->hBWE_TD->dec_2_over_3_mem_lp_fx, 0, L_FILT_2OVER3_LP );
            }
            ELSE
#endif
            {
                set16_fx( hBWE_TD->dec_2_over_3_mem_lp_fx, 0, 6 );
            }
        }
#ifdef HARM_CORE_SW
        ELSE IF( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) ) &&
                 ( ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) ) || ( NE_16( st_fx->element_mode, IVAS_CPE_TD ) && NE_32( st_fx->last_total_brate, st_fx->total_brate ) ) ||
                   ( NE_16( st_fx->last_bwidth, st_fx->bwidth ) ) || ( NE_16( st_fx->last_codec_mode, MODE1 ) ) || ( NE_16( st_fx->rf_mode_last, st_fx->rf_mode ) ) ) )
#else
        ELSE IF( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) ) &&
                 ( NE_32( st_fx->last_total_brate, st_fx->total_brate ) || NE_16( st_fx->last_bwidth, st_fx->bwidth ) ||
                   NE_16( st_fx->last_codec_mode, MODE1 ) || NE_16( st_fx->rf_mode, st_fx->rf_mode_last ) ) )
#endif
        {
            set16_fx( hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER );
            set16_fx( hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD );
@@ -1066,7 +1167,7 @@ void core_switching_pre_enc_ivas_fx(

    return;
}

#ifndef HARM_CORE_SW

/*---------------------------------------------------------------------*
 * core_switching_post_enc()
@@ -1208,3 +1309,4 @@ void core_switching_post_enc_ivas_fx(

    return;
}
#endif
+4 −0
Original line number Diff line number Diff line
@@ -260,7 +260,11 @@ ivas_error evs_enc_fx(
         * Preprocessing (preparing) for ACELP/HQ core switching
         *---------------------------------------------------------------------*/

#ifdef HARM_CORE_SW
        core_switching_pre_enc_fx( st, old_inp_12k8, 0, old_inp_16k, 0, 0, 0 );
#else
        core_switching_pre_enc_fx( st, old_inp_12k8, old_inp_16k, 0, 0 );
#endif

        /*---------------------------------------------------------------------*
         * ACELP core encoding
+1 −1
Original line number Diff line number Diff line
@@ -648,7 +648,7 @@ ivas_error ivas_core_enc_fx(
         *---------------------------------------------------------------------*/

#ifdef CLEANUP_ACELP_ENC
#ifdef HARM_CORE_SWaaa
#ifdef HARM_CORE_SW
        core_switching_post_enc_fx( st, NULL, NULL, NULL, 0, 0, 0, NULL );
#else
        core_switching_post_enc_ivas_fx( st );
Loading