Commit a310704f authored by vaclav's avatar vaclav
Browse files

HARM_CORE_SW, decoder step 4 (core_switching_post_dec)

parent cd43a380
Loading
Loading
Loading
Loading
+55 −23
Original line number Diff line number Diff line
@@ -1348,11 +1348,23 @@ ivas_error core_switching_post_dec_ivas_fx(
    test();
    IF( st_fx->core == ACELP_CORE && st_fx->bfi && hHQ_core != NULL && !st_fx->con_tcx )
    {
        if ( ( error = acelp_core_switch_dec_bfi_ivas_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK )
#ifdef HARM_CORE_SW
        IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
        {
            IF( ( error = acelp_core_switch_dec_bfi_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK )
            {
                return error;
            } /*the output at Q0*/
        }
        ELSE
#endif
        {
            IF( ( error = acelp_core_switch_dec_bfi_ivas_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK )
            {
                return error;
            } /*the output at Q0*/
        }
    }

    /* set multiplication factor according to the sampling rate */
    tmp = extract_l( L_shr( st_fx->output_Fs, 13 ) ); /* Q0 */
@@ -1360,14 +1372,14 @@ ivas_error core_switching_post_dec_ivas_fx(

    delta = 1;
    move16();
    IF( GE_16( output_frame, L_FRAME16k ) )
    if ( GE_16( output_frame, L_FRAME16k ) )
    {
        delta = shr( Fs_kHz, 3 );
    }

    /* set delay compensation between HQ synthesis and ACELP synthesis */
    delay_comp = i_mult2( delta, HQ_DELAY_COMP ); /* Q0 */
    /*needed to add more condition in if*/

    test();
    test();
    test();
@@ -1384,11 +1396,13 @@ ivas_error core_switching_post_dec_ivas_fx(
        {
            st_fx->use_acelp_preq = 0;
            move16();
            /* rescaling to the min exp of the 2 */
            /* Qtmp=s_min(*Qsynth,st_fx->Q_old_postdec);
             Scale_sig(synth, output_frame, sub(Qtmp,*Qsynth));
             Scale_sig(st_fx->delay_buf_out_fx, delay_comp, sub(Qtmp,st_fx->Q_old_postdec));*/

#ifdef HARM_CORE_SW
            test();
            if ( EQ_16( st_fx->element_mode, EVS_MONO ) && st_fx->hBWE_FD != NULL )
#else
            IF( st_fx->hBWE_FD != NULL )
#endif
            {
                hBWE_FD->mem_deemph_old_syn_fx = 0;
                move16();
@@ -1417,8 +1431,13 @@ ivas_error core_switching_post_dec_ivas_fx(
                    move16();
                }
            }

            /* delay HQ synthesis to synchronize with ACELP synthesis */
            /* rescaling to the min exp of the 2 */
#ifdef HARM_CORE_SW
            IF( NE_16( st_fx->element_mode, EVS_MONO ) )
#endif
            {
                Word16 NonZero = 1;
                move16();
                FOR( i = 0; i < delay_comp; i++ )
@@ -1438,6 +1457,8 @@ ivas_error core_switching_post_dec_ivas_fx(
                    move16();
                }
                move16();

            }
            Qtmp = s_min( *Qsynth, hHQ_core->Q_old_postdec );
            Scale_sig( synth, output_frame, sub( Qtmp, *Qsynth ) ); /* Qtmp */
            *Qsynth = Qtmp;
@@ -1602,7 +1623,6 @@ ivas_error core_switching_post_dec_ivas_fx(
            }
            ELSE IF( st_fx->element_mode != EVS_MONO )
            {
                /*needed to be filled with ivas specific code*/
                /* Reset memories of CLDFBs */
                IF( st_fx->cldfbAna != NULL )
                {
@@ -1650,6 +1670,7 @@ ivas_error core_switching_post_dec_ivas_fx(
                    move16();
                }
            }

            IF( st_fx->hBWE_TD != NULL )
            {
                hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 );
@@ -1768,6 +1789,17 @@ ivas_error core_switching_post_dec_ivas_fx(
                hHQ_core->oldHqVoicing = 0;
                move16();
            }

#ifdef HARM_CORE_SW
            IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
            {
                set16_fx( hHQ_core->prev_SWB_peak_pos_fx, 0, SPT_SHORTEN_SBNUM );
                hHQ_core->prev_frm_hfe2 = 0;
                move16();
                hHQ_core->prev_stab_hfe2 = 0;
                move16();
            }
#endif
        }
    }
    ELSE