Commit 60715ab5 authored by vaclav's avatar vaclav
Browse files

decoder BR switching updates

parent 69090cd6
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -1160,6 +1160,12 @@ ivas_error ivas_init_decoder(

            reset_indices_dec( st_ivas->hSCE[0]->hCoreCoder[0] );

#ifdef OMASA_BRATE_SW
            if ( ( error = ivas_ism_metadata_dec_create( st_ivas, 1, NULL ) ) != IVAS_ERR_OK )
            {
                return error;
            }
#else
#ifdef OMASA_UPDATES
            if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ )
            {
@@ -1172,23 +1178,17 @@ ivas_error ivas_init_decoder(
            }
            else
            {
#ifdef OMASA_BRATE_SW
                if ( ( error = ivas_ism_metadata_dec_create( st_ivas, 1, NULL ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
#else
                if ( ( st_ivas->hIsmMetaData[0] = (ISM_METADATA_HANDLE) malloc( sizeof( ISM_METADATA_FRAME ) ) ) == NULL )
                {
                    return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ISm MetaData\n" ) );
                }
#endif
            }
#else
            if ( ( st_ivas->hIsmMetaData[0] = (ISM_METADATA_HANDLE) malloc( sizeof( ISM_METADATA_FRAME ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ISm MetaData\n" ) );
            }
#endif
#endif
        }
        else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC )
@@ -1535,6 +1535,7 @@ ivas_error ivas_init_decoder(
    }

#ifdef OMASA_UPDATES
    // VE: introduce a new renderer_type for this case
    if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL )
    {
        /* Use td renderer for the objects in DISC mode */
+7 −7
Original line number Diff line number Diff line
@@ -209,7 +209,7 @@ static ivas_error ivas_ism_bitrate_switching(
                ivas_td_binaural_close( &st_ivas->hBinRendererTd );
            }

            if ( st_ivas->hHrtfTD != NULL )
            if ( st_ivas->hHrtfTD != NULL ) // VE: this looks suspicious
            {
                st_ivas->hHrtfTD = NULL;
            }
+57 −3
Original line number Diff line number Diff line
@@ -35,6 +35,9 @@
#include "ivas_cnst.h"
#include "ivas_prot.h"
#include "prot.h"
#ifdef OMASA_UPDATES
#include "ivas_prot_rend.h"
#endif
#ifdef OMASA_BRATE_SW
#include "ivas_rom_com.h"
#endif
@@ -147,7 +150,6 @@ ivas_error ivas_omasa_dec_config(
    ivas_error error;

    /* initializations */
    error = IVAS_ERR_OK;
    ism_total_brate = 0;
    ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;

@@ -229,13 +231,16 @@ ivas_error ivas_omasa_dec_config(
        }
    }


    if ( ism_mode_old != st_ivas->ism_mode )
    {
        /* ISM MD reconfig. */
        n_MD = 0;

#ifdef OMASA_UPDATES
        if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ )
#else
        if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ )
#endif
        {
            n_MD = 1;

@@ -270,7 +275,11 @@ ivas_error ivas_omasa_dec_config(
        st_ivas->hCPE[0]->element_brate = ivas_total_brate - ism_total_brate;

        /* objects renderer reconfig. */
#ifdef OMASA_UPDATES
        if ( st_ivas->renderer_type == RENDERER_DIRAC && ( 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 ) )
#else
        if ( st_ivas->renderer_type == RENDERER_DIRAC && ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) )
#endif
        {
            if ( st_ivas->hIsmRendererData == NULL )
            {
@@ -279,7 +288,11 @@ ivas_error ivas_omasa_dec_config(
                    return error;
                }
            }
#ifdef OMASA_UPDATES
            else if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ )
#else
            else if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ )
#endif
            {
                for ( n = 1; n < st_ivas->hMasaIsmData->delayBuffer_nchan; n++ )
                {
@@ -313,8 +326,13 @@ ivas_error ivas_omasa_dec_config(
                mvr2r( tmp, st_ivas->hMasaIsmData->delayBuffer[0], st_ivas->hMasaIsmData->delayBuffer_size );
            }
        }
#ifdef OMASA_UPDATES
        else 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 )
#else
        else if ( st_ivas->ism_mode != ISM_MASA_MODE_PARAM_ONE_OBJ && st_ivas->ism_mode != ISM_MASA_MODE_DISC && st_ivas->hIsmRendererData != NULL )
#endif
        {
            // VE: use ivas_masa_ism_data_close() instead?
            for ( n = 0; n < st_ivas->hMasaIsmData->delayBuffer_nchan; n++ )
            {
                free( st_ivas->hMasaIsmData->delayBuffer[n] );
@@ -325,10 +343,46 @@ ivas_error ivas_omasa_dec_config(
            free( st_ivas->hIsmRendererData );
            st_ivas->hIsmRendererData = NULL;
        }

#ifdef OMASA_UPDATES
        // VE: introduce a new renderer_type for this case
        if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC )
        {
            /* Use td renderer for the objects in DISC mode */
            error = ivas_td_binaural_open_unwrap( &st_ivas->hHrtfTD, st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_ism, st_ivas->ivas_format,
                                                  st_ivas->transport_config,
#ifdef TD5
                                                  st_ivas->hRenderConfig->directivity,
#endif
                                                  st_ivas->hTransSetup, &st_ivas->hBinRendererTd, &st_ivas->binaural_latency_ns );
            if ( ( error ) != IVAS_ERR_OK )
            {
                return error;
            }

            /* Reserve memory for delay buffer */
            if ( ( error = ivas_masa_ism_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }
        else
        {
            if ( st_ivas->hBinRendererTd != NULL )
            {
                ivas_td_binaural_close( &st_ivas->hBinRendererTd );
            }

            if ( st_ivas->hHrtfTD != NULL ) // VE: this is copied from ivas_ism_bitrate_switching() but a review is needed
            {
                st_ivas->hHrtfTD = NULL;
            }
        }
#endif
    }

    return IVAS_ERR_OK;
}
#endif


+3 −2
Original line number Diff line number Diff line
@@ -633,6 +633,7 @@ ivas_error ivas_init_encoder(
                return error;
            }
        }

#ifdef OMASA_UPDATES
        if ( ivas_total_brate - ism_total_brate >= MIN_BRATE_MDCT_STEREO && ( st_ivas->ism_mode != ISM_MASA_MODE_PARAM ) )
#else
+5 −3
Original line number Diff line number Diff line
@@ -232,11 +232,9 @@ ivas_error ivas_omasa_enc_config(
    ENCODER_CONFIG_HANDLE hEncoderConfig;
    ivas_error error;

    error = IVAS_ERR_OK;
    hEncoderConfig = st_ivas->hEncoderConfig;
    ivas_total_brate = hEncoderConfig->ivas_total_brate;


    //ivas_masa_enc_reconfigure( st_ivas ); // VE: might not be needed


@@ -311,7 +309,11 @@ ivas_error ivas_omasa_enc_config(

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

#ifdef OMASA_UPDATES
        if ( ivas_total_brate - ism_total_brate >= MIN_BRATE_MDCT_STEREO && ( st_ivas->ism_mode != ISM_MASA_MODE_PARAM ) )
#else
        if ( ivas_total_brate - ism_total_brate >= MIN_BRATE_MDCT_STEREO )
#endif
        {
            hEncoderConfig->element_mode_init = IVAS_CPE_MDCT;
        }
@@ -333,7 +335,7 @@ ivas_error ivas_omasa_enc_config(
        ivas_omasa_set_config( st_ivas->hOMasa, st_ivas->hMasa, st_ivas->hEncoderConfig->input_Fs, st_ivas->ism_mode );
    }

    return error;
    return IVAS_ERR_OK;
}
#endif