Commit 6bceabd5 authored by Dominik Weckbecker's avatar Dominik Weckbecker 💬
Browse files

Merge branch '474-heap-buffer-overflow-error-in-sba-to-stereo-decoding-af-512kbps' into 'main'

Resolve "Heap buffer overflow error in SBA to stereo decoding af 512kbps"

See merge request !650
parents 86dcf5af 086de6c7
Loading
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -1322,6 +1322,10 @@ void stereo_dft_dec(
    const int16_t cross_fade_start_offset,                      /* i  : SPAR mixer delay compensation       */
    const int32_t output_Fs,                                    /* i  : Fs for delay calculation            */
    const int16_t nchan_transport                               /* i  : number of transpor channels         */
#ifdef FIX_STEREO_474
    ,
    const int16_t num_md_sub_frames                             /* i:  number of MD subframes              */
#endif
);

void stereo_dft_res_ecu(
@@ -3561,6 +3565,10 @@ void ivas_sba_dirac_stereo_smooth_parameters(
    ivas_spar_md_dec_state_t *hMdDec,                           /* i/o: SPAR MD handle for upmixing             */
    const int16_t cross_fade_start_offset,                      /* i  : SPAR mixer delay compensation           */
    const int32_t output_Fs                                     /* i  : Fs for delay calculation                */
#ifdef FIX_STEREO_474
    ,
    const int16_t num_md_sub_frames                             /* i : number of subframes in mixing matrix  */
#endif
);

void ivas_sba2mc_cldfb(
+2 −0
Original line number Diff line number Diff line
@@ -211,6 +211,8 @@

#define FIX_DTX_428                                     /* FhG: fix for issue 428, crash with DTX and bitrate switching */

#define FIX_STEREO_474                                  /* FhG fix for issue 574, crash with SBA to stereo output at 512 kbps */

/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */

+6 −1
Original line number Diff line number Diff line
@@ -405,7 +405,12 @@ ivas_error ivas_cpe_dec(
        }
        else
        {
            stereo_dft_dec( hCPE->hStereoDft, sts[0], DFT, hCPE->input_mem[1], hCPE->hStereoCng, 0, 0, 0, 0, 0, 0 );
            stereo_dft_dec( hCPE->hStereoDft, sts[0], DFT, hCPE->input_mem[1], hCPE->hStereoCng, 0, 0, 0, 0, 0, 0
#ifdef FIX_STEREO_474
                            ,
                            MAX_PARAM_SPATIAL_SUBFRAMES
#endif
            );
        }

        /* synthesis iFFT */
+22 −1
Original line number Diff line number Diff line
@@ -693,6 +693,10 @@ void ivas_sba_dirac_stereo_smooth_parameters(
    ivas_spar_md_dec_state_t *hMdDec,      /* i/o: SPAR MD handle for upmixing      */
    const int16_t cross_fade_start_offset, /* i  : SPAR mixer delay compensation    */
    const int32_t output_Fs                /* i  : Fs for delay calculation         */
#ifdef FIX_STEREO_474
    ,
    const int16_t num_md_sub_frames /* i : number of subframes in mixing matrix  */
#endif
)
{
    int16_t i, j, k, i_sf;
@@ -732,6 +736,9 @@ void ivas_sba_dirac_stereo_smooth_parameters(
        float xfade_start_ns;
        int16_t xfade_delay_subframes;
        int16_t i_hist;
#ifdef FIX_STEREO_474
        int16_t md_sf;
#endif

        xfade_start_ns = cross_fade_start_offset / (float) output_Fs * 1000000000.f - IVAS_FB_ENC_DELAY_NS;
        xfade_delay_subframes = (int16_t) ( xfade_start_ns / ( FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ) );
@@ -742,6 +749,11 @@ void ivas_sba_dirac_stereo_smooth_parameters(
        {
            for ( i_sf = k * 2; i_sf < ( k + 1 ) * 2; i_sf++ )
            {

#ifdef FIX_STEREO_474
                md_sf = ( num_md_sub_frames == MAX_PARAM_SPATIAL_SUBFRAMES ) ? i_sf : 0;
#endif

                if ( hStereoDft->first_frame )
                {
                    for ( i = 0; i < 2; i++ )
@@ -786,7 +798,11 @@ void ivas_sba_dirac_stereo_smooth_parameters(
                    {
                        for ( b = 0; b < hStereoDft->nbands; b++ )
                        {
#ifdef FIX_STEREO_474
                            hMdDec->mixer_mat_prev[4][i][j][b] = hMdDec->mixer_mat[i][j][b + md_sf * IVAS_MAX_NUM_BANDS];
#else
                            hMdDec->mixer_mat_prev[4][i][j][b] = hMdDec->mixer_mat[i][j][b + i_sf * IVAS_MAX_NUM_BANDS];
#endif
                        }
                    }
                }
@@ -881,7 +897,12 @@ void ivas_sba_dirac_stereo_dec(
    stereo_dft_dec( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1 /*st_ivas->sba_dirac_stereo_flag*/, sba_mono_flag,
                    ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : NULL,
                    ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0,
                    st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport );
                    st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport
#ifdef FIX_STEREO_474
                    ,
                    ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate )
#endif
    );

    /* DFT synthesis */
    stereo_dft_dec_synthesize( hCPE, DFT, 0, output[0], output_frame );
+10 −1
Original line number Diff line number Diff line
@@ -1131,6 +1131,10 @@ void stereo_dft_dec(
    const int16_t cross_fade_start_offset,       /* i  : SPAR mixer delay compensation      */
    const int32_t output_Fs,                     /* i  : Fs for delay calculation           */
    const int16_t nchan_transport                /* i  : number of transpor channels        */
#ifdef FIX_STEREO_474
    ,
    const int16_t num_md_sub_frames /* i:  number of MD subframes              */
#endif
)
{
    int16_t i, k, b, N_div, stop;
@@ -1208,7 +1212,12 @@ void stereo_dft_dec(
            ivas_sba_dirac_stereo_smooth_parameters( hStereoDft,
                                                     hMdDec,
                                                     cross_fade_start_offset,
                                                     output_Fs );
                                                     output_Fs
#ifdef FIX_STEREO_474
                                                     ,
                                                     num_md_sub_frames
#endif
            );
        }
        else
        {