Commit cba1fbbb authored by vaclav's avatar vaclav
Browse files

more simplifications + formatting

parent 8ff96d33
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -8072,7 +8072,6 @@ ivas_error core_switching_post_dec_ivas_fx(
    Word16 *synth,                      /* i/o: output synthesis                                                            Qsynth*/
    Word32 *output_fx,                  /* i/o: LB synth/upsampled LB synth														Q4*/
    Word16 output_mem_fx[],             /* i  : OLA memory from last TCX/HQ frame                                               Qx*/
    const IVAS_FORMAT ivas_format,      /* i  : IVAS format                                                                       */
    const Word16 use_cldfb_for_dft,     /* i  : flag to use of CLDFB for DFT Stereo                                             Q0*/
    const Word16 output_frame,          /* i  : frame length                                                                    Q0*/
    const Word16 core_switching_flag,   /* i  : ACELP->HQ switching flag                                                        Q0*/
+2 −2
Original line number Diff line number Diff line
@@ -1269,7 +1269,6 @@ ivas_error core_switching_post_dec_ivas_fx(
    Word16 *synth,                      /* i/o: output synthesis                                                            Qsynth*/
    Word32 *output_fx,                  /* i/o: LB synth/upsampled LB synth														Q4*/
    Word16 output_mem_fx[],             /* i  : OLA memory from last TCX/HQ frame                                               Qx*/
    const IVAS_FORMAT ivas_format,      /* i  : IVAS format                                                                       */
    const Word16 use_cldfb_for_dft,     /* i  : flag to use of CLDFB for DFT Stereo                                             Q0*/
    const Word16 output_frame,          /* i  : frame length                                                                    Q0*/
    const Word16 core_switching_flag,   /* i  : ACELP->HQ switching flag                                                        Q0*/
@@ -1523,11 +1522,12 @@ ivas_error core_switching_post_dec_ivas_fx(
                test();
                test();
                test();
                IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || ( EQ_16( ivas_format, ISM_FORMAT ) && EQ_16( st_fx->core, TCX_20_CORE ) /* <- means TCX in general, TCX10 is forbidden after ACELP */ ) ) && LE_32( st_fx->last_core_brate, SID_2k40 ) && GT_32( st_fx->core_brate, SID_2k40 ) )
                IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || ( st_fx->is_ism_format && EQ_16( st_fx->core, TCX_20_CORE ) /* <- means TCX in general, TCX10 is forbidden after ACELP */ ) ) && LE_32( st_fx->last_core_brate, SID_2k40 ) && GT_32( st_fx->core_brate, SID_2k40 ) )
                {
                    /* smooth transitions to avoid pops in car noise items */
                    smoothTransitionDtxToTcx_fx( synth, output_frame, delay_comp );
                }

                /* Reset memories of CLDFBs */
                IF( st_fx->cldfbAna != NULL )
                {
+39 −70
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@
 *
 * Principal IVAS core decoder routine, where number of core channels is 1 or 2
 *-------------------------------------------------------------------*/

ivas_error ivas_core_dec_fx(
    Decoder_Struct *st_ivas,                         /* i/o: IVAS decoder structure             */
    SCE_DEC_HANDLE hSCE,                             /* i/o: SCE decoder structure              */
@@ -65,15 +66,11 @@ ivas_error ivas_core_dec_fx(
    STEREO_ICBWE_DEC_HANDLE hStereoICBWE;
    STEREO_TD_DEC_DATA_HANDLE hStereoTD;
    STEREO_CNG_DEC_HANDLE hStereoCng;
    FD_BWE_DEC_HANDLE hBWE_FD;
    Word16 sharpFlag[CPE_CHANNELS];
    Word16 tmp_buffer_fx[L_FRAME48k];
    set16_fx( tmp_buffer_fx, 0, L_FRAME48k );
    Word16 tmp16, tmp16_2, j;
    tmp16 = 0;
    move16();
    Word16 Q_white_exc;
    Q_white_exc = 0;
    move16();

    Word16 tmps, incr;
    Word32 bwe_exc_extended_fx[CPE_CHANNELS][L_FRAME32k + NL_BUFF_OFFSET];
@@ -110,15 +107,8 @@ ivas_error ivas_core_dec_fx(
    move16();
    move16();

    FOR( i = 0; i < CPE_CHANNELS; i++ )
    {
        set16_fx( pitch_buf_fx[i], 0, NB_SUBFR16k );
        set16_fx( output_16_fx[i], 0, L_FRAME48k );
    }

    Word16 tdm_lsfQ_PCh_fx[M], tdm_lspQ_PCh_fx[M];
    Word32 conceal_eof_gain32;

    Flag Overflow;

    error = IVAS_ERR_OK;
@@ -151,6 +141,7 @@ ivas_error ivas_core_dec_fx(
        p_output_mem_fx = NULL;
        nchan_out = 1;
        move16();

        test();
        IF( st_ivas != NULL && EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
        {
@@ -174,7 +165,6 @@ ivas_error ivas_core_dec_fx(
        hStereoTD = hCPE->hStereoTD;
        hStereoCng = hCPE->hStereoCng;
        p_output_mem_fx = hCPE->output_mem_fx[1];

        nchan_out = hCPE->nchan_out;
        move16();

@@ -184,20 +174,13 @@ ivas_error ivas_core_dec_fx(
            move16();
        }

        IF( EQ_16( sts[0]->element_mode, IVAS_CPE_DFT ) )
        {
        test();
            IF( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF ) )
        test();
        IF( EQ_16( sts[0]->element_mode, IVAS_CPE_DFT ) && EQ_16( hCPE->nchan_out, 1 ) && EQ_16( hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF ) )
        {
            use_cldfb_for_dft = 1;
            move16();
        }
            ELSE
            {
                use_cldfb_for_dft = 0;
                move16();
            }
        }
    }

    FOR( n = 0; n < n_channels; n++ )
@@ -286,10 +269,8 @@ ivas_error ivas_core_dec_fx(
        IF( !st->bfi && st->prev_bfi && ( EQ_16( st->last_core_bfi, TCX_20_CORE ) || EQ_16( st->last_core_bfi, TCX_10_CORE ) ) && st->hTcxDec != NULL )
#endif
        {

            conceal_eof_gain32 = L_shr_sat( st->hTcxDec->conceal_eof_gain32, sub( 16, st->hTcxDec->conceal_eof_gain_e ) ); // e = 31 - Q , 16 - e => 16 - (31 - Q) => Q - 15,
                                                                                                                           // shr(16 -e ) = shr(Q -15) => 15 - Q ==> Q15

            FOR( i = 0; i < st->hTcxDec->L_frameTCX; i++ )
            {
                L_tmp = Mpy_32_16_1( conceal_eof_gain32, st->hHQ_core->old_out_fx[i] ); // Q0 (15+1+0 - (15 + 1)
@@ -312,6 +293,7 @@ ivas_error ivas_core_dec_fx(
        set16_fx( voice_factors_fx[n], 0, NB_SUBFR16k );
        set32_fx( hb_synth_32_fx[n], 0, L_FRAME48k );
        set16_fx( hb_synth_16_fx[n], 0, L_FRAME48k );

        /*------------------------------------------------------------------*
         * Decision matrix (selection of technologies)
         *-----------------------------------------------------------------*/
@@ -469,6 +451,7 @@ ivas_error ivas_core_dec_fx(
        /*---------------------------------------------------------------------*
         * Preprocessing (preparing) for ACELP/HQ core switching
         *---------------------------------------------------------------------*/

        Word16 Q_olapBufferSynth, Q_olapBufferSynth2;

        Q_olapBufferSynth = Q15;  /*Initializing with max values to avoid warnings*/
@@ -501,8 +484,8 @@ ivas_error ivas_core_dec_fx(
        {
            /* ACELP core decoder */
            Word16 old_syn_12k8_16k_fx_16[L_FRAME16k];
            set16_fx( output_16_fx[n], 0, L_FRAME48k );
            Word16 save_hb_synth_fx_arr[L_FRAME48k], *save_hb_synth_16_fx;

            IF( save_hb_synth_32_fx )
            {
                save_hb_synth_16_fx = save_hb_synth_fx_arr;
@@ -622,7 +605,9 @@ ivas_error ivas_core_dec_fx(
                ivas_format = st_ivas->ivas_format;
                move32();
            }

            stereo_tcx_core_dec_fx( st, frameMode[n], output_16_fx[n], synth_16_fx[n], pitch_buf_fx[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hStereoCng, nchan_out, ivas_format );

            st->hHQ_core->Q_old_wtda_LB = st->hHQ_core->Q_old_wtda;
            move16();
            Copy_Scale_sig_16_32_DEPREC( output_16_fx[n], output_32_fx[n], L_FRAME48k, Q11 ); // Q11
@@ -722,6 +707,7 @@ ivas_error ivas_core_dec_fx(
                move16();
                move16();
                sts = hCPE->hCoreCoder;

                FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
                {
                    st = sts[ch];
@@ -765,6 +751,7 @@ ivas_error ivas_core_dec_fx(
        ELSE IF( EQ_16( hCPE->nchan_out, 1 ) )
        {
            Word16 shift1, shift2;

            sts[0] = hCPE->hCoreCoder[0];
            sts[1] = hCPE->hCoreCoder[1];

@@ -775,6 +762,7 @@ ivas_error ivas_core_dec_fx(
                sts[1]->hHQ_core->exp_old_out = sub( 15, sts[1]->hHQ_core->Q_old_wtda );
                move16();
            }

            updateBuffersForDmxMdctStereo_fx( hCPE, output_frame, output_32_fx[0], output_32_fx[1], synth_16_fx );

            IF( LE_32( last_element_brate, IVAS_SID_5k2 ) )
@@ -846,6 +834,7 @@ ivas_error ivas_core_dec_fx(
    FOR( n = 0; n < n_channels; n++ )
    {
        st = sts[n];
        hBWE_FD = st->hBWE_FD;

        /*---------------------------------------------------------------------*
         * TD-BWE for ACELP to TCX transitions
@@ -932,6 +921,7 @@ ivas_error ivas_core_dec_fx(
#endif
            Copy( st->hBWE_TD->mem_resamp_HB_fx, st->hBWE_TD->state_32and48k_WB_upsample_fx, ( 2 * ALLPASSSECTIONS_STEEP ) );
        }

        /*---------------------------------------------------------------------*
         * Postprocessing for ACELP/MDCT core switching
         *---------------------------------------------------------------------*/
@@ -949,19 +939,7 @@ ivas_error ivas_core_dec_fx(
#endif
        }

        IVAS_FORMAT ivas_format;
        IF( st_ivas != NULL )
        {
            ivas_format = st_ivas->ivas_format;
            move32();
        }
        ELSE
        {
            ivas_format = UNDEFINED_FORMAT;
            move32();
        }

        IF( NE_32( ( error = core_switching_post_dec_ivas_fx( st, synth_16_fx[n], output_32_fx[n], p_output_mem_16, ivas_format, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) )
        IF( NE_32( ( error = core_switching_post_dec_ivas_fx( st, synth_16_fx[n], output_32_fx[n], p_output_mem_16, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) )
        {
            return error;
        }
@@ -990,6 +968,7 @@ ivas_error ivas_core_dec_fx(
        {
            Copy( sts[0]->previoussynth_fx, sts[1]->previoussynth_fx, st->hTcxDec->L_frameTCX );
        }

        /*---------------------------------------------------------------------*
         * Pre-processing for bandwidth switching
         *---------------------------------------------------------------------*/
@@ -1035,17 +1014,17 @@ ivas_error ivas_core_dec_fx(

        test();
        test();
        IF( NE_16( st->last_extl, WB_BWE ) && EQ_16( st->extl, WB_BWE ) && st->hBWE_FD != NULL )
        IF( NE_16( st->last_extl, WB_BWE ) && EQ_16( st->extl, WB_BWE ) && hBWE_FD != NULL )
        {
            test();
            if ( NE_16( st->last_extl, SWB_BWE ) && NE_16( st->last_extl, FB_BWE ) )
            {
                st->hBWE_FD->prev_mode = st->hBWE_FD->prev_mode;
                hBWE_FD->prev_mode = hBWE_FD->prev_mode;
                move16();
            }
            st->hBWE_FD->prev_L_swb_norm = st->hBWE_FD->prev_L_swb_norm;
            hBWE_FD->prev_L_swb_norm = hBWE_FD->prev_L_swb_norm;
            move16();
            st->hBWE_FD->prev_flag = st->hBWE_FD->prev_flag;
            hBWE_FD->prev_flag = hBWE_FD->prev_flag;
            move16();
        }

@@ -1070,9 +1049,6 @@ ivas_error ivas_core_dec_fx(
        Q_synth_fx = Q_synth;
        move16();

        FD_BWE_DEC_HANDLE hBWE_FD;
        hBWE_FD = st->hBWE_FD;

        Copy_Scale_sig_32_16( output_32_fx[n], output_16_fx[n], L_FRAME48k, sub( Q_input, Q11 ) ); // Q_input
        Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) );        // Q0
        test();
@@ -1129,6 +1105,10 @@ ivas_error ivas_core_dec_fx(
         * SWB(FB) TBE decoding
         * SWB(FB) BWE decoding
         *---------------------------------------------------------------------*/

        Q_white_exc = 0;
        move16();

        test();
        test();
        test();
@@ -1149,10 +1129,8 @@ ivas_error ivas_core_dec_fx(
        IF( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) || ( NE_16( st->coder_type, AUDIO ) && NE_16( st->coder_type, INACTIVE ) && GE_32( st->core_brate, SID_2k40 ) && EQ_16( st->core, ACELP_CORE ) && !st->con_tcx && GE_32( output_Fs, 32000 ) && GT_16( st->bwidth, NB ) && st->bws_cnt > 0 ) )
        {
            /* SWB TBE decoder */
            Q_white_exc = 0;
            move16();

            ivas_swb_tbe_dec_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 );

            Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->syn_overlap_fx, st->hBWE_TD->syn_overlap_fx_32, L_SHB_LAHEAD, sub( Q11, st->prev_Q_bwe_syn2 ) ); // Q11
            Copy_Scale_sig_32_16( st->hBWE_TD->old_tbe_synth_fx_32, st->hBWE_TD->old_tbe_synth_fx, L_SHB_TRANSITION_LENGTH, sub( st->prev_Qx, Q11 ) ); // prev_Qx

@@ -1176,7 +1154,7 @@ ivas_error ivas_core_dec_fx(

            Scale_sig32( hb_synth_32_fx[n], output_frame, sub( Q11, Q_syn_hb ) ); // Q11

            Copy_Scale_sig_32_16( st->hBWE_FD->L_old_wtda_swb_fx32, st->hBWE_FD->L_old_wtda_swb_fx, output_frame, sub( hBWE_FD->old_wtda_swb_fx_exp, Q11 ) ); // old_wtda_swb_fx_exp
            Copy_Scale_sig_32_16( hBWE_FD->L_old_wtda_swb_fx32, hBWE_FD->L_old_wtda_swb_fx, output_frame, sub( hBWE_FD->old_wtda_swb_fx_exp, Q11 ) ); // old_wtda_swb_fx_exp
        }

        /*---------------------------------------------------------------------*
@@ -1246,6 +1224,7 @@ ivas_error ivas_core_dec_fx(
        /*-------------------------------------------------------------------*
         *  Inter-channel BWE decoding
         *-------------------------------------------------------------------*/

        test();
        IF( n == 0 && GE_16( st->element_mode, IVAS_CPE_DFT ) )
        {
@@ -1442,24 +1421,13 @@ ivas_error ivas_core_dec_fx(
            {
                Word16 exp;
                Word32 fra;
                SWITCH( output_frame )
                {
                    case L_FRAME8k:
                        tmp16 = 205;
                        move16();
                        BREAK; /*Q15*/
                    case L_FRAME16k:
                        tmp16 = 102;
                        move16();
                        BREAK; /*Q15*/
                    case L_FRAME32k:
                        tmp16 = 51;

                tmp16 = 34; /*ouput_frame == L_FRAME 48k: Q15*/
                move16();
                        BREAK; /*Q15*/
                    case L_FRAME48k:
                        tmp16 = 34;
                if ( EQ_16( output_frame, L_FRAME32k ) )
                {
                    tmp16 = 51; /*Q15*/
                    move16();
                        BREAK; /*Q15*/
                }

                L_tmp = L_deposit_l( 2 ); /*0.001 in Q11*/
@@ -1499,6 +1467,7 @@ ivas_error ivas_core_dec_fx(
         * - core switching in DFT stereo
         * - updates for potential TD->DFT stereo switching
         *----------------------------------------------------------------*/

        IF( hCPE != NULL )
        {
            FOR( Word32 ch_ind = 0; ch_ind < n_channels; ch_ind++ )
@@ -1639,11 +1608,11 @@ ivas_error ivas_core_dec_fx(
            st->q_prev_synth_buffer_fx = sub( exp_max, st->q_prev_synth_buffer_fx );
            move16();
        }

        /* Save synthesis for HQ FEC */
        save_synthesis_hq_fec_fx( st, output_fx_loc, output_frame, hCPE );

        /* Updates */

        ivas_updt_dec_common_fx( st, NORMAL_HQ_CORE, -1, output_32_fx[n], Q11 );

        Scale_sig( st->delay_buf_out_fx, NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ), negate( exp_max ) ); // Q0
+1 −1
Original line number Diff line number Diff line
@@ -448,7 +448,7 @@ ivas_error ivas_mct_dec_fx(
            {
                dirac_stereo_flag = 0;
            }
            IF( NE_32( ( error = core_switching_post_dec_ivas_fx( sts[n], synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], output_mem_fx, st_ivas->ivas_format, 0, output_frame, 0 /*core_switching_flag*/, dirac_stereo_flag, -1, hCPE->last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) )
            IF( NE_32( ( error = core_switching_post_dec_ivas_fx( sts[n], synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], output_mem_fx, 0, output_frame, 0 /*core_switching_flag*/, dirac_stereo_flag, -1, hCPE->last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) )
            {
                return error;
            }