Commit 8efa516d authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Merge branch '79-masa-2tc-bitrate-switching-crashes-in-decoder' into 'main'

Resolve "MASA 2TC bitrate switching crashes in decoder" [non-BE]

See merge request !84
parents 95efcdf9 60c2d53f
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -150,6 +150,7 @@
#define DIRAC_DRCT_GAIN_TUNING                          /* issue 64: tuning of DirAC energy-compensation gains */
#define MDFT_ROM_OPTIMIZE                               /*Optimise ROM tables for MDFT/iMDFT*/
#define LFE_NO_ENTROPY_CODING                           /* issue 65: changes to add no entropy coding in LFE */
#define FIX_79_MASA2TC_BITRATE_SWITCHING                /* Nokia: Fix issue 79 on MASA 2TC bitrate switching crash in decoder. */

/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
+2 −3
Original line number Diff line number Diff line
@@ -108,7 +108,6 @@ ivas_error ivas_cpe_dec(
        return error;
    }


    /*------------------------------------------------------------------*
     * Initialization
     *-----------------------------------------------------------------*/
@@ -399,7 +398,6 @@ ivas_error ivas_cpe_dec(
            return error;
        }


        /* DFT Stereo residual decoding */
        if ( hCPE->hStereoDft->res_cod_band_max > 0 && !st_ivas->bfi )
        {
@@ -583,7 +581,6 @@ ivas_error create_cpe_dec(
    hCPE->hStereoMdct = NULL;
    hCPE->hStereoTCA = NULL;
    hCPE->hStereoICBWE = NULL;

    hCPE->hStereoCng = NULL;

    hCPE->stereo_switching_counter = 10;
@@ -789,6 +786,7 @@ ivas_error create_cpe_dec(
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Stereo MDCT\n" ) );
        }

        if ( st_ivas->ivas_format == STEREO_FORMAT && hCPE->element_brate <= MAX_MDCT_ITD_BRATE )
        {
            hCPE->hStereoMdct->use_itd = 1;
@@ -797,6 +795,7 @@ ivas_error create_cpe_dec(
        {
            hCPE->hStereoMdct->use_itd = 0;
        }

        hCPE->hStereoMdct->reverse_dmx = 0;
        hCPE->hStereoMdct->smooth_ratio = 1.f;
        set_s( hCPE->hStereoMdct->prev_ms_mask[0], 0, MAX_SFB );
+46 −0
Original line number Diff line number Diff line
@@ -891,6 +891,14 @@ ivas_error stereo_memory_dec(
                count_free( hCPE->prev_synth_chs[1] );
                hCPE->prev_synth_chs[1] = NULL;
            }
#ifdef FIX_79_MASA2TC_BITRATE_SWITCHING
            
            if ( hCPE->hStereoTCA != NULL )
            {
                count_free( hCPE->hStereoTCA );
                hCPE->hStereoTCA = NULL;
            }
#endif
        }
        else /* nchan_out == 2 */
        {
@@ -909,6 +917,44 @@ ivas_error stereo_memory_dec(
                }
                set_zero( hCPE->prev_synth_chs[1], NS2SA( st->output_Fs, FRAME_SIZE_NS ) );
            }
#ifdef FIX_79_MASA2TC_BITRATE_SWITCHING

            if ( hCPE->hStereoICBWE == NULL && hCPE->element_mode == IVAS_CPE_DFT )
            {
                if ( ( hCPE->hStereoICBWE = (STEREO_ICBWE_DEC_HANDLE) count_malloc( sizeof( STEREO_ICBWE_DEC_DATA ) ) ) == NULL )
                {
                    return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Stereo ICBWE \n" ) );
                }

                stereo_icBWE_init_dec( hCPE->hStereoICBWE );
            }

            if ( hCPE->hStereoTCA == NULL && ( hCPE->element_mode == IVAS_CPE_DFT || hCPE->element_mode == IVAS_CPE_TD ) )
            {
                if ( ( hCPE->hStereoTCA = (STEREO_TCA_DEC_HANDLE) count_malloc( sizeof( STEREO_TCA_DEC_DATA ) ) ) == NULL )
                {
                    return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Stereo TCA\n" ) );
                }

                stereo_tca_init_dec( hCPE->hStereoTCA );
            }

            if ( hCPE->element_mode == IVAS_CPE_MDCT )
            {
                if( hCPE->hStereoTCA != NULL )
                {
                    /* note: in MASA, hCPE->hStereoMdct->itd = 0 */
                    count_free( hCPE->hStereoTCA );
                    hCPE->hStereoTCA = NULL;
                }

                if ( hCPE->hStereoICBWE != NULL )
                {
                    count_free( hCPE->hStereoICBWE );
                    hCPE->hStereoICBWE = NULL;
                }
            }
#endif
        }
    }

+8 −0
Original line number Diff line number Diff line
@@ -702,6 +702,14 @@
../IVAS_cod -dtx -masa 2 testv/stv_IVASMASA_1dir2TC_DTX.met 32000 48 testv/stv_IVASMASA_1dir2TC_DTX.pcm bit
../IVAS_dec 5_1 48 bit testv/stv_IVASMASA_1dir2TC_DTX.pcm_32000_48-48_DTX_5_1.tst

// MASA 1dir 1TC bitrate switching from 13.2 kbps to 128 kbps, 48kHz in, 48kHz out, 5_1 out
../IVAS_cod -masa 1 testv/stv_IVASMASA_1dir1TC_DTX.met ../scripts/switchPaths/sw_13k2_to_128k_10fr.bin 48 testv/stv_IVASMASA_1dir1TC_DTX.pcm bit
../IVAS_dec 5_1 48 bit testv/stv_IVASMASA_1dir1TC_DTX.pcm_sw_48-48_5_1.tst

// MASA 1dir 2TC bitrate switching from 13.2 kbps to 512 kbps, 48kHz in, 48kHz out, BINAURAL out
../IVAS_cod -masa 2 testv/stv_IVASMASA_1dir2TC_DTX.met ../scripts/switchPaths/sw_13k2_512k.bin 48 testv/stv_IVASMASA_1dir2TC_DTX.pcm bit
../IVAS_dec BINAURAL 48 bit testv/stv_IVASMASA_1dir2TC_DTX.pcm_sw_48-48_BINAURAL.tst


// Multi-channel 5_1 at 13.2 kbps, 48kHz in, 48kHz out
../IVAS_cod -mc 5_1 13200 48 testv/stv51MC48c.pcm bit