Commit 648b9cce authored by vaclav's avatar vaclav
Browse files

accept FIX_1320_STACK_CPE_DECODER and FIX_1314_STEREO_TO_EXT

parent 03819099
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -524,9 +524,7 @@ enum
#define ACELP_TCX_TRANS_NS                  1250000                             /* Duration of the ACELP->TCX overlap - 1.25 ms */
#define L_FRAME_MAX                         L_FRAME48k                          /* Max 20ms frame size @48kHz              */
#define L_FRAME_PLUS                        1200                                /* Max frame size (long TCX frame)            */
#ifdef FIX_1320_STACK_CPE_DECODER
#define L_FRAME_PLUS_INTERNAL               800                                 /* Max frame size (long TCX frame) at maximum internal sampling rate */
#endif
#define L_MDCT_OVLP_MAX                     NS2SA( 48000, ACELP_LOOK_NS )       /* = Max mdct overlap */
#define N_TCX10_MAX                         480                                 /* Max size of TCX10 MDCT spectrum */
#define BITS_TEC                            1                                   /* number of bits for TEC */
+0 −2
Original line number Diff line number Diff line
@@ -160,8 +160,6 @@

/*#define FIX_I4_OL_PITCH*/                             /* fix open-loop pitch used for EVS core switching */
#define TMP_FIX_1119_SPLIT_RENDERING_VOIP               /* FhG: Add error check for unsupported config: split rendering with VoIP mode */
#define FIX_1314_STEREO_TO_EXT                          /* VA: issue 1314: set RENDERER_DISABLE for stereo to EXT output */
#define FIX_1320_STACK_CPE_DECODER                      /* VA: issue 1320: Optimize the stack memory consumption in the CPE decoder */
#define FIX_NCHAN_BUFFERS                               /* VA: issue 1322: Correct the number of float buffers (channels) at the decoder */
#define FIX_RENDERER_STACK                              /* VA: issue 1322: reduction of renderers' buffers size */
#define FIX_1319_STACK_SBA_DECODER                      /* VA: issue 1319: Optimize the definition of buffer lengths in the SBA decoder */
+0 −9
Original line number Diff line number Diff line
@@ -71,11 +71,7 @@ void decoder_LPD(
{
    int16_t *prm;
    int16_t param_lpc[NPRM_LPC_NEW];
#ifdef FIX_1320_STACK_CPE_DECODER
    float synth_buf[OLD_SYNTH_INTERNAL_DEC + L_FRAME_PLUS_INTERNAL + M];
#else
    float synth_buf[OLD_SYNTH_SIZE_DEC + L_FRAME_PLUS + M];
#endif
    float *synth;
    float synth_bufFB[OLD_SYNTH_SIZE_DEC + L_FRAME_PLUS + M];
    float *synthFB;
@@ -128,14 +124,9 @@ void decoder_LPD(
    synthFB = synth_bufFB + st->hTcxDec->old_synth_lenFB;
    mvr2r( st->hTcxDec->old_synth, synth_buf, st->hTcxDec->old_synth_len );
    mvr2r( st->hTcxDec->old_synthFB, synth_bufFB, st->hTcxDec->old_synth_lenFB );
#ifdef FIX_1320_STACK_CPE_DECODER
    set_zero( synth, L_FRAME_PLUS_INTERNAL + M );
#else
    set_zero( synth, L_FRAME_PLUS + M );
#endif
    set_zero( synthFB, L_FRAME_PLUS + M );


    /*For post-processing (post-filtering+blind BWE)*/
    if ( st->tcxonly == 0 )
    {
+2 −45
Original line number Diff line number Diff line
@@ -75,12 +75,8 @@ ivas_error ivas_core_dec(
    float synth[CPE_CHANNELS][L_FRAME48k];
    float tmp_buffer[L_FRAME48k];
    int16_t tmps, incr;
#ifdef FIX_1320_STACK_CPE_DECODER
    float *bwe_exc_extended[CPE_CHANNELS] = { NULL, NULL };
    int16_t flag_bwe_bws;
#else
    float bwe_exc_extended[CPE_CHANNELS][L_FRAME32k + NL_BUFF_OFFSET];
#endif
    float voice_factors[CPE_CHANNELS][NB_SUBFR16k];
    int16_t core_switching_flag[CPE_CHANNELS];
    float old_syn_12k8_16k[CPE_CHANNELS][L_FRAME16k];
@@ -209,9 +205,7 @@ ivas_error ivas_core_dec(

        set_f( voice_factors[n], 0.f, NB_SUBFR16k );
        set_f( hb_synth[n], 0.0f, L_FRAME48k );
#ifdef FIX_1320_STACK_CPE_DECODER
        bwe_exc_extended[n] = hb_synth[n]; /* note: reuse the buffer */
#endif

        /*------------------------------------------------------------------*
         * Decision matrix (selection of technologies)
@@ -530,10 +524,8 @@ ivas_error ivas_core_dec(
         * SWB(FB) BWE decoding
         *---------------------------------------------------------------------*/

#ifdef FIX_1320_STACK_CPE_DECODER
        flag_bwe_bws = ( output_Fs >= 32000 && st->core == ACELP_CORE && st->bwidth > NB && st->bws_cnt > 0 && st->bfi == 0 );

#endif
        if ( st->extl == SWB_TBE || st->extl == FB_TBE || ( st->coder_type != AUDIO && st->coder_type != INACTIVE && st->core_brate >= SID_2k40 && st->core == ACELP_CORE && !st->con_tcx && output_Fs >= 32000 && st->bwidth > NB && st->bws_cnt > 0 ) )
        {
            /* SWB TBE decoder */
@@ -545,23 +537,17 @@ ivas_error ivas_core_dec(
                fb_tbe_dec( st, tmp_buffer /*fb_exc*/, hb_synth[n], tmp_buffer /*fb_synth_ref*/, output_frame );
            }
        }
#ifdef FIX_1320_STACK_CPE_DECODER
        else if ( st->extl == SWB_BWE || st->extl == FB_BWE || flag_bwe_bws )
#else
        else if ( st->extl == SWB_BWE || st->extl == FB_BWE || ( output_Fs >= 32000 && st->core == ACELP_CORE && st->bwidth > NB && st->bws_cnt > 0 && !st->ppp_mode_dec && !( st->nelp_mode_dec == 1 && st->bfi == 1 ) ) )
#endif
        {
            /* SWB BWE decoder */
            swb_bwe_dec( st, output[n], synth[n], hb_synth[n], use_cldfb_for_dft, output_frame );
        }

#ifdef FIX_1320_STACK_CPE_DECODER
        if ( ( st->core == ACELP_CORE && ( st->extl == -1 || st->extl == SWB_CNG ) ) && flag_bwe_bws == 0 )
        {
            set_f( hb_synth[n], 0.0f, L_FRAME48k );
        }

#endif
        /*---------------------------------------------------------------------*
         * FEC - recovery after lost HQ core (smoothing of the BWE component)
         *---------------------------------------------------------------------*/
@@ -595,23 +581,6 @@ ivas_error ivas_core_dec(
            stereo_icBWE_dec( hCPE, hb_synth[0], hb_synth[1], tmp_buffer /*fb_synth_ref*/, voice_factors[0], output_frame );
        }

#ifndef FIX_1320_STACK_CPE_DECODER
        if ( st->element_mode == EVS_MONO )
        {
            /*----------------------------------------------------------------*
             * BFI waveform adjustment
             *----------------------------------------------------------------*/

            if ( st->core == ACELP_CORE && !st->bfi && st->prev_bfi && st->last_total_brate >= HQ_48k && st->last_codec_mode == MODE2 && ( st->last_core_bfi == TCX_20_CORE || st->last_core_bfi == TCX_10_CORE ) && st->hPlcInfo->concealment_method == TCX_NONTONAL && st->hPlcInfo->nbLostCmpt < 4 )
            {
                tmps = NS2SA( output_Fs, DELAY_CLDFB_NS );

                waveform_adj2( st->hPlcInfo, st->hTonalMDCTConc->secondLastPcmOut, synth[n] + tmps, tmps, st->hPlcInfo->nbLostCmpt + 1, st->bfi );

                st->hPlcInfo->Pitch = 0;
            }
        }
#endif
        /*----------------------------------------------------------------*
         * Transition and synchronization of BWE components
         *----------------------------------------------------------------*/
@@ -626,20 +595,8 @@ ivas_error ivas_core_dec(
            }
            else
            {
#ifndef FIX_1320_STACK_CPE_DECODER
                if ( st->extl == SWB_BWE_HIGHRATE || st->extl == FB_BWE_HIGHRATE )
                {
                    /* HR SWB BWE on top of ACELP@16kHz */
                    tmps = NS2SA( output_Fs, DELAY_BWE_TOTAL_NS );
                }
                else
                {
#endif
                /* TBE on top of ACELP@16kHz */
                tmps = NS2SA( output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS );
#ifndef FIX_1320_STACK_CPE_DECODER
                }
#endif
            }

            /* Smooth transitions when switching between different technologies */
+0 −47
Original line number Diff line number Diff line
@@ -54,10 +54,8 @@ static void read_stereo_mode_and_bwidth( CPE_DEC_HANDLE hCPE, const Decoder_Stru

static void stereo_mode_combined_format_dec( const Decoder_Struct *st_ivas, CPE_DEC_HANDLE hCPE );

#ifdef FIX_1320_STACK_CPE_DECODER
static ivas_error stereo_dft_dec_main( CPE_DEC_HANDLE hCPE, const int32_t ivas_total_brate, const int16_t n_channels, float res_buf[STEREO_DFT_N_8k], float *output[], float outputHB[][L_FRAME48k], const int16_t output_frame );

#endif

/*--------------------------------------------------------------------------*
 * ivas_cpe_dec()
@@ -78,11 +76,7 @@ ivas_error ivas_cpe_dec(
    int16_t last_bwidth;
    int16_t tdm_ratio_idx;
    float outputHB[CPE_CHANNELS][L_FRAME48k]; /* 'float' buffer for output HB synthesis, both channels */
#ifdef FIX_1320_STACK_CPE_DECODER
    float *res_buf = NULL;
#else
    float res_buf[STEREO_DFT_N_8k];
#endif
    CPE_DEC_HANDLE hCPE;
    Decoder_State **sts;
    STEREO_DFT_CONFIG_DATA_HANDLE hConfigDft;
@@ -273,10 +267,8 @@ ivas_error ivas_cpe_dec(
            }
            else
            {
#ifdef FIX_1320_STACK_CPE_DECODER
                res_buf = outputHB[0]; /* note: temporarily reused buffer */

#endif
                if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT )
                {
                    nb_bits -= nb_bits_metadata;
@@ -465,47 +457,10 @@ ivas_error ivas_cpe_dec(

    if ( hCPE->element_mode == IVAS_CPE_DFT && !( hCPE->nchan_out == 1 && hConfigDft->res_cod_mode == STEREO_DFT_RES_COD_OFF ) )
    {
#ifdef FIX_1320_STACK_CPE_DECODER
        if ( ( error = stereo_dft_dec_main( hCPE, ivas_total_brate, n_channels, res_buf, output, outputHB, output_frame ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#else
        float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX];

        /* core decoder */
        if ( ( error = ivas_core_dec( NULL, NULL, hCPE, st_ivas->hMCT, n_channels, output, outputHB, DFT, 0 ) ) != IVAS_ERR_OK )
        {
            return error;
        }

        /* DFT Stereo residual decoding */
        if ( hCPE->hStereoDft->res_cod_band_max > 0 && !st_ivas->bfi )
        {
            stereo_dft_dec_res( hCPE, res_buf, output[1] );

            stereo_dft_dec_analyze( hCPE, output[1], DFT, 1, L_FRAME8k, output_frame, DFT_STEREO_DEC_ANA_LB, 0, 0 );
        }

        /* DFT stereo CNG */
        stereo_dtf_cng( hCPE, ivas_total_brate, DFT, output_frame );

        /* decoding */
        if ( hCPE->nchan_out == 1 )
        {
            stereo_dft_unify_dmx( hCPE->hStereoDft, sts[0], DFT, hCPE->input_mem[1], hCPE->hStereoCng->prev_sid_nodata );
        }
        else
        {
            stereo_dft_dec( hCPE->hStereoDft, sts[0], DFT, hCPE->input_mem[1], hCPE->hStereoCng, 0, 0, 0, 0, 0, 0, MAX_PARAM_SPATIAL_SUBFRAMES );
        }

        /* synthesis iFFT */
        for ( n = 0; n < hCPE->nchan_out; n++ )
        {
            stereo_dft_dec_synthesize( hCPE, DFT, n, output[n], output_frame );
        }
#endif
    }
    else if ( hCPE->element_mode == IVAS_CPE_TD )
    {
@@ -630,7 +585,6 @@ ivas_error ivas_cpe_dec(
    return error;
}

#ifdef FIX_1320_STACK_CPE_DECODER

/*-------------------------------------------------------------------------
 * stereo_dft_dec_main()
@@ -697,7 +651,6 @@ static ivas_error stereo_dft_dec_main(
    return IVAS_ERR_OK;
}

#endif

/*-------------------------------------------------------------------------
 * create_cpe_dec()
Loading