Commit 73f4d595 authored by Jouni Paulus's avatar Jouni Paulus
Browse files

bugfixes for OMASA: missing inits of ISM extended meta flags and ISM/MASA...

bugfixes for OMASA: missing inits of ISM extended meta flags and ISM/MASA delay buffers. missing renderer reconfig in brsw.
parent a444b46f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -181,6 +181,7 @@
#define MASAISM_EDIT_OBJECTS                            /* Nokia: Temporary command line editing of object directions in the decoder */
#define OMASA_ENERGIES
#define FIX_OMASA_STEREO_SWITCHING                      // VA: introduce  Unified/MDCT stereo switching for 3ISM @96 kbps and 4ISM @128 kbps
#define FIX_OMASA_BRSW                                  /* Nokia + VA: Fix missing init of OMASA metadata delay buffers, brsw-related init fixes */
#endif


+5 −0
Original line number Diff line number Diff line
@@ -938,6 +938,11 @@ ivas_error ivas_init_decoder(

        if ( st_ivas->ivas_format == MASA_FORMAT )
        {
#ifdef FIX_OMASA_BRSW
            /* if we start in ISM_MODE_NONE in MASA_ISM, that appears as normal MASA, but we may change to a mode with ISMs */
            st_ivas->ism_extmeta_active = -1;
            st_ivas->ism_extmeta_cnt = 0;
#endif
            if ( ( error = ivas_masa_dec_open( st_ivas ) ) != IVAS_ERR_OK )
            {
                return error;
+85 −0
Original line number Diff line number Diff line
@@ -55,6 +55,9 @@ ivas_error ivas_masa_ism_data_open(
{
    MASA_ISM_DATA_HANDLE hMasaIsmData;
    int16_t ch, bin;
#ifdef FIX_OMASA_BRSW
    int16_t sf, obj_idx;
#endif

    if ( ( hMasaIsmData = (MASA_ISM_DATA_HANDLE) malloc( sizeof( MASA_ISM_DATA ) ) ) == NULL )
    {
@@ -83,6 +86,20 @@ ivas_error ivas_masa_ism_data_open(
        hMasaIsmData->q_azimuth_old[ch] = 0.0f;
    }

#ifdef FIX_OMASA_BRSW
    for ( obj_idx = 0; obj_idx < MAX_NUM_OBJECTS; obj_idx++ )
    {
        set_s( hMasaIsmData->azimuth_ism[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR );
        set_s( hMasaIsmData->elevation_ism[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR );
        for ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR; sf++ )
        {
            set_zero( hMasaIsmData->energy_ratio_ism[obj_idx][sf], CLDFB_NO_CHANNELS_MAX );
        }
    }
    set_s( hMasaIsmData->azimuth_separated_ism, 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR );
    set_s( hMasaIsmData->elevation_separated_ism, 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR );
#endif

    st_ivas->hMasaIsmData = hMasaIsmData;

    return IVAS_ERR_OK;
@@ -139,6 +156,10 @@ ivas_error ivas_omasa_dec_config(
    IVAS_FORMAT ivas_format_orig;
    ivas_error error;

#ifdef FIX_OMASA_BRSW
    RENDERER_TYPE old_renderer_type;
#endif

    /* initializations */
    ism_total_brate = 0;
    ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
@@ -158,6 +179,13 @@ ivas_error ivas_omasa_dec_config(
    /* set ism_mode of current frame */
    st_ivas->ism_mode = ivas_omasa_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism );

#ifdef FIX_OMASA_BRSW
    /*-----------------------------------------------------------------*
     * Renderer selection
     *-----------------------------------------------------------------*/
    old_renderer_type = st_ivas->renderer_type;
#endif

    /* MASA reconfig. */
    cpe_brate = calculate_cpe_brate_MASA_ISM( st_ivas->ism_mode, ivas_total_brate, st_ivas->nchan_ism );
    if ( st_ivas->ini_active_frame == 0 && ivas_total_brate != FRAME_NO_DATA && ( cpe_brate < MASA_STEREO_MIN_BITRATE ) && st_ivas->nCPE == 1 )
@@ -243,6 +271,7 @@ ivas_error ivas_omasa_dec_config(

        ivas_ism_metadata_close( st_ivas->hIsmMetaData, n_MD );

#ifndef FIX_OMASA_BRSW
#ifdef FIX_417_TD_DECORR_BRATE_SW
        /* TD Decorrelator */
        if ( st_ivas->hDiracDecBin != NULL )
@@ -259,9 +288,40 @@ ivas_error ivas_omasa_dec_config(
        {
            return error;
        }
#endif

        st_ivas->hCPE[0]->element_brate = ivas_total_brate - ism_total_brate;

#ifdef FIX_OMASA_BRSW
        /*-----------------------------------------------------------------*
         * Renderer selection
         *-----------------------------------------------------------------*/
        ivas_renderer_select( st_ivas );

        /*-------------------------------------------------------------------*
         * Reallocate rendering handles
         *--------------------------------------------------------------------*/

        if ( old_renderer_type != st_ivas->renderer_type )
        {
            if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX )
            {
                if ( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
            }
            else
            {
                if ( st_ivas->hMonoDmxRenderer != NULL )
                {
                    free( st_ivas->hMonoDmxRenderer );
                    st_ivas->hMonoDmxRenderer = NULL;
                }
            }
        }
#endif

        /* objects renderer reconfig. */
        if ( st_ivas->ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ && st_ivas->ism_mode != ISM_MASA_MODE_PARAM_ONE_OBJ && st_ivas->ism_mode != ISM_MASA_MODE_DISC && st_ivas->hIsmRendererData != NULL )
        {
@@ -331,6 +391,31 @@ ivas_error ivas_omasa_dec_config(
                }
            }
        }

#ifdef FIX_OMASA_BRSW
#ifdef FIX_417_TD_DECORR_BRATE_SW
        /*-----------------------------------------------------------------*
         * TD Decorrelator
         *-----------------------------------------------------------------*/

        if ( st_ivas->hDiracDecBin != NULL )
        {
            if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }
#endif

        /*-----------------------------------------------------------------*
         * CLDFB instances
         *-----------------------------------------------------------------*/

        if ( ( error = ivas_cldfb_dec_reconfig( st_ivas, 2, numCldfbAnalyses_old, numCldfbSyntheses_old ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif
    }

    return IVAS_ERR_OK;