Commit 251ed417 authored by emerit's avatar emerit
Browse files

Merge branch 'main' into orange/no-diegetic-pan-with-radius

parents 9e014aa3 eae756c7
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -1321,15 +1321,24 @@ static ivas_error initOnFirstGoodFrame(
        /* If outputting MASA, open output file and write metadata for initial bad frames */
        else if ( *pBsFormat == IVAS_DEC_BS_MASA )
        {
#ifdef FIX_350_MASA_DELAY_COMP
            if ( ( error = MasaFileWriter_open( arg.outputWavFilename, arg.delayCompensationEnabled, ppMasaWriter ) ) != IVAS_ERR_OK )
#else
            if ( ( error = MasaFileWriter_open( arg.outputWavFilename, ppMasaWriter ) ) != IVAS_ERR_OK )
#endif
            {
                fprintf( stderr, "\nError: Error opening MASA decoded metadata file %s\n", MasaFileWriter_getFilePath( *ppMasaWriter ) );
                return error;
            }

            /* Duplicate good first frame metadata to fill the beginning of stream. */
#ifdef FIX_350_MASA_DELAY_COMP
            MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta = NULL;
            if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta ) ) != IVAS_ERR_OK )
#else
            IVAS_MASA_QMETADATA_HANDLE qMetadata = NULL;
            if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &qMetadata ) ) != IVAS_ERR_OK )
#endif
            {
                fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                return error;
@@ -1337,7 +1346,11 @@ static ivas_error initOnFirstGoodFrame(

            for ( int16_t j = 0; j < numInitialBadFrames; ++j )
            {
#ifdef FIX_350_MASA_DELAY_COMP
                if ( ( error = MasaFileWriter_writeFrame( *ppMasaWriter, hMasaExtOutMeta ) ) != IVAS_ERR_OK )
#else
                if ( ( error = MasaFileWriter_writeFrame( *ppMasaWriter, qMetadata ) ) != IVAS_ERR_OK )
#endif
                {
                    fprintf( stderr, "\nError writing MASA metadata to file: %s\n", MasaFileWriter_getFilePath( *ppMasaWriter ) );
                    return error;
@@ -1581,14 +1594,23 @@ static ivas_error decodeG192(
            }
            else if ( bsFormat == IVAS_DEC_BS_MASA )
            {
#ifdef FIX_350_MASA_DELAY_COMP
                MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta;
                if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta ) ) != IVAS_ERR_OK )
#else
                IVAS_MASA_QMETADATA_HANDLE qMetadata;
                if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &qMetadata ) ) != IVAS_ERR_OK )
#endif
                {
                    fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }

#ifdef FIX_350_MASA_DELAY_COMP
                if ( ( error = MasaFileWriter_writeFrame( masaWriter, hMasaExtOutMeta ) ) != IVAS_ERR_OK )
#else
                if ( ( error = MasaFileWriter_writeFrame( masaWriter, qMetadata ) ) != IVAS_ERR_OK )
#endif
                {
                    fprintf( stderr, "\nError writing MASA metadata to file: %s\n", MasaFileWriter_getFilePath( masaWriter ) );
                    goto cleanup;
+4 −0
Original line number Diff line number Diff line
@@ -99,7 +99,11 @@ typedef struct
#endif

typedef struct ivas_masa_metadata_frame_struct *IVAS_MASA_METADATA_HANDLE;
#ifdef FIX_350_MASA_DELAY_COMP
typedef struct ivas_masa_decoder_ext_out_meta_struct *MASA_DECODER_EXT_OUT_META_HANDLE;
#else
typedef struct ivas_masa_qmetadata_frame_struct *IVAS_MASA_QMETADATA_HANDLE;
#endif

typedef struct TDREND_HRFILT_FiltSet_struct *IVAS_DEC_HRTF_HANDLE;
typedef struct ivas_hrtfs_crend_structure *IVAS_DEC_HRTF_CREND_HANDLE;
+14 −0
Original line number Diff line number Diff line
@@ -72,6 +72,13 @@ int32_t get_delay(
        else /* IVAS */
        {
            delay = IVAS_ENC_DELAY_NS;

#ifdef FIX_350_MASA_DELAY_COMP
            if ( ivas_format == MASA_FORMAT )
            {
                delay = 0; /* All delay is compensated in the decoder with MASA */
            }
#endif
        }

        if ( ivas_format == SBA_FORMAT )
@@ -107,6 +114,13 @@ int32_t get_delay(
            /* compensate for binauralization delay */
            delay += binaural_latency_ns;
#endif

#ifdef FIX_350_MASA_DELAY_COMP
            if ( ivas_format == MASA_FORMAT )
            {
                delay += IVAS_ENC_DELAY_NS; /* Compensate also the encoder delay in the decoder with MASA */
            }
#endif
        }
    }

+8 −0
Original line number Diff line number Diff line
@@ -952,6 +952,10 @@ typedef enum
#define DELAY_DIRAC_SPAR_ENC_CMP_NS             500000L                    /* here we may set the 24 samples (at 48 kHz) additional delay to something else, leave as is for now*/       
#define DELAY_DIRAC_PARAM_DEC_SFR               2                           /* Delay to be compensation for DirAC parameters in the decoder (subframes) */

#ifdef FIX_350_MASA_DELAY_COMP
#define DELAY_MASA_PARAM_DEC_SFR                2                           /* Delay to be compensation for MASA parameters in the decoder (subframes) */
#endif

#define DIRAC_SLOT_NS                           1250000L                    /* time duration of a time slot, 1.25ms (==DELAY_RENERER_NS/MAX_PARAM_SPATIAL_SUBFRAMES) */
#define DIRAC_SLOT_ENC_NS                       5000000L

@@ -1121,7 +1125,11 @@ enum
#define MASA_MAXIMUM_CODING_SUBBANDS            24
#define MASA_MAXIMUM_DIRECTIONS                 2
#define MASA_MAX_TRANSPORT_CHANNELS             2

#ifndef FIX_350_MASA_DELAY_COMP
#define MASA_ENC_DELAY_SLOTS                    7
#endif

#define MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS   5

#define MASA_DELTA_AZI_DCT0                     30
+119 −72
Original line number Diff line number Diff line
@@ -175,6 +175,10 @@ ivas_error ivas_FB_mixer_open(
    IVAS_FB_MIXER_HANDLE *hFbMixer_out, /* i/o: FB mixer handle           */
    const int32_t sampling_rate,        /* i  : sampling rate             */
    IVAS_FB_CFG *fb_cfg                 /* i  : FB config. handle         */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    ,
    const int16_t spar_reconfig_flag /* i  : SPAR reconfiguration flag */
#endif
)
{
    IVAS_FB_MIXER_HANDLE hFbMixer;
@@ -186,7 +190,12 @@ ivas_error ivas_FB_mixer_open(

    frame_len = (int16_t) ( sampling_rate / FRAMES_PER_SEC );

#ifdef SBA_BR_SWITCHING_CLEAN_UP
    hFbMixer = *hFbMixer_out;

    if ( !spar_reconfig_flag )
    {
#endif
        if ( ( hFbMixer = (IVAS_FB_MIXER_HANDLE) malloc( sizeof( IVAS_FB_MIXER_DATA ) ) ) == NULL )
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
@@ -203,6 +212,10 @@ ivas_error ivas_FB_mixer_open(
        {
            hFbMixer->pFb = NULL;
        }
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    }
#endif

    if ( fb_cfg->active_w_mixing == -1 )
    {
        num_chs_alloc = 0;
@@ -247,6 +260,7 @@ ivas_error ivas_FB_mixer_open(
    {
        num_chs_alloc = fb_cfg->num_in_chans;
    }

    for ( i = 0; i < num_chs_alloc; i++ )
    {
        if ( ( hFbMixer->ppFilterbank_prior_input[i] = (float *) malloc( sizeof( float ) * fb_cfg->prior_input_length ) ) == NULL )
@@ -275,6 +289,10 @@ ivas_error ivas_FB_mixer_open(
        }
    }

#ifdef SBA_BR_SWITCHING_CLEAN_UP
    if ( !spar_reconfig_flag )
    {
#endif
        if ( fb_cfg->num_out_chans > 0 )
        {
            const int16_t *pActive_bins_per_band, *pActive_bins_per_band_abs, *pStart_offset, *pStart_offset_abs;
@@ -323,13 +341,25 @@ ivas_error ivas_FB_mixer_open(
            /* ignore all the deeper filter bank stuff for now */
            hFbMixer->num_diff_bands = 0;
        }
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    }
#endif

    hFbMixer->fb_cfg = fb_cfg;
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    set_s( hFbMixer->first_frame, 1, hFbMixer->fb_cfg->num_out_chans );
    set_s( hFbMixer->first_frame + hFbMixer->fb_cfg->num_out_chans, 0, IVAS_SPAR_MAX_CH - hFbMixer->fb_cfg->num_out_chans );

    if ( !spar_reconfig_flag )
    {
#endif
        if ( ( error = ivas_filterbank_setup( hFbMixer, sampling_rate ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    }
#endif

    *hFbMixer_out = hFbMixer;

@@ -346,6 +376,10 @@ ivas_error ivas_FB_mixer_open(
void ivas_FB_mixer_close(
    IVAS_FB_MIXER_HANDLE *hFbMixer_in, /* i/o: FB mixer handle              */
    const int32_t sampling_rate        /* i  : sampling rate in Hz          */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    ,
    const int16_t spar_reconfig_flag /* i  : SPAR reconfiguration flag    */
#endif
)
{
    IVAS_FB_MIXER_HANDLE hFbMixer;
@@ -405,6 +439,10 @@ void ivas_FB_mixer_close(
            hFbMixer->prior_mixer[0][0] = NULL;
        }

#ifdef SBA_BR_SWITCHING_CLEAN_UP
        if ( !spar_reconfig_flag )
        {
#endif
            if ( fb_cfg->num_out_chans > 0 )
            {
                num_bands = hFbMixer->pFb->filterbank_num_bands;
@@ -433,12 +471,14 @@ void ivas_FB_mixer_close(
                    }
                }
            }

            if ( hFbMixer->pFb != NULL )
            {
                free( hFbMixer->pFb );
                hFbMixer->pFb = NULL;
            }
#ifdef SBA_BR_SWITCHING_CLEAN_UP
        }
#endif

        if ( hFbMixer->fb_cfg != NULL )
        {
@@ -446,8 +486,15 @@ void ivas_FB_mixer_close(
            hFbMixer->fb_cfg = NULL;
        }

#ifdef SBA_BR_SWITCHING_CLEAN_UP
        if ( !spar_reconfig_flag )
        {
#endif
            free( hFbMixer );
            hFbMixer = NULL;
#ifdef SBA_BR_SWITCHING_CLEAN_UP
        }
#endif
    }

    return;
@@ -1027,10 +1074,10 @@ static ivas_error ivas_filterbank_setup(
    IVAS_FB_CFG *pCfg = hFbMixer->fb_cfg;

    error = IVAS_ERR_OK;

#ifndef SBA_BR_SWITCHING_CLEAN_UP
    set_s( hFbMixer->first_frame, 1, pCfg->num_out_chans );
    set_s( hFbMixer->first_frame + pCfg->num_out_chans, 0, IVAS_SPAR_MAX_CH - pCfg->num_out_chans );

#endif

    if ( pCfg->num_out_chans > 0 )
    {
Loading