Commit 3a1b42af authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Fixes to merge of MASA prerend with HO-DirAC changes.

parent 87bcfa61
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1324,6 +1324,9 @@ int main(
    {
        MasaFileReader_close( &masaReaders[i] );
    }
#ifdef MASA_PREREND
    MasaFileWriter_close( &masaWriter );
#endif
    AudioFileReader_close( &audioReader );
    AudioFileWriter_close( &audioWriter );
    HeadRotationFileReader_close( &headRotReader );
+4 −4
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ ivas_error ivas_dirac_ana_open(
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DIRAC\n" ) );
    }

    numAnalysisChannels =  DIRAC_MAX_ANA_CHANS;
    numAnalysisChannels =  FOA_CHANNELS;

    /* Determine the number of bands */
    hDirAC->nbands = MASA_FREQUENCY_BANDS;
@@ -254,8 +254,8 @@ static void ivas_dirac_param_est_ana(
    int16_t num_freq_bands, index;
    float dir_v[DIRAC_NUM_DIMS];
    int16_t l_ts;
    float Foa_RealBuffer[DIRAC_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX];
    float Foa_ImagBuffer[DIRAC_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX];
    float Foa_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX];
    float Foa_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX];
    float intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS];
    float direction_vector[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS];
    float diffuseness_vector[MASA_FREQUENCY_BANDS];
@@ -270,7 +270,7 @@ static void ivas_dirac_param_est_ana(

    num_freq_bands = hDirAC->nbands;
    l_ts = input_frame / CLDFB_NO_COL_MAX;
    numAnalysisChannels = DIRAC_MAX_ANA_CHANS;
    numAnalysisChannels = FOA_CHANNELS;


    /* do processing over all CLDFB time slots */
+4 −4
Original line number Diff line number Diff line
@@ -414,10 +414,10 @@ void ivas_mcmasa_param_est_ana(
    int16_t l_ts;
    float Chnl_RealBuffer[MCMASA_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX];
    float Chnl_ImagBuffer[MCMASA_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX];
    float Foa_RealBuffer[DIRAC_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX];
    float Foa_ImagBuffer[DIRAC_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX];
    float FoaEven_RealBuffer[DIRAC_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX];
    float FoaEven_ImagBuffer[DIRAC_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX];
    float Foa_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX];
    float Foa_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX];
    float FoaEven_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX];
    float FoaEven_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX];
    float intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS];
    float intensity_even_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS];
    float direction_vector[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS];
+15 −15
Original line number Diff line number Diff line
@@ -259,15 +259,15 @@ static void ivas_omasa_param_est_ana(
    const int16_t input_frame,
    const int16_t nchan_ism )
{
    float reference_power[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
    float reference_power[MASA_FREQUENCY_BANDS];
    int16_t ts, i, d, j;
    int16_t num_freq_bins, num_freq_bands, index;
    float dir_v[DIRAC_NUM_DIMS];
    int16_t l_ts;
    float Chnl_RealBuffer[MCMASA_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX];
    float Chnl_ImagBuffer[MCMASA_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX];
    float Foa_RealBuffer[DIRAC_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX];
    float Foa_ImagBuffer[DIRAC_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX];
    float Chnl_RealBuffer[MAX_NUM_OBJECTS][CLDFB_NO_CHANNELS_MAX];
    float Chnl_ImagBuffer[MAX_NUM_OBJECTS][CLDFB_NO_CHANNELS_MAX];
    float Foa_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX];
    float Foa_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX];
    float intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS];
    float direction_vector[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS];
    float diffuseness_vector[MASA_FREQUENCY_BANDS];
@@ -374,7 +374,7 @@ static void ivas_omasa_param_est_ana(
            computeDirectionVectors( intensity_real[0], intensity_real[1], intensity_real[2], 0, num_freq_bands, direction_vector[0], direction_vector[1], direction_vector[2] );

            /* Power estimation for diffuseness */
            computeReferencePower_ana( hOMasa->band_grouping, Foa_RealBuffer, Foa_ImagBuffer, reference_power[ts], num_freq_bands );
            computeReferencePower_ana( hOMasa->band_grouping, Foa_RealBuffer, Foa_ImagBuffer, reference_power, num_freq_bands );

            /* Fill buffers of length "averaging_length" time slots for intensity and energy */
            hOMasa->index_buffer_intensity = ( hOMasa->index_buffer_intensity % DIRAC_NO_COL_AVG_DIFF ) + 1; /* averaging_length = 32 */
@@ -384,20 +384,20 @@ static void ivas_omasa_param_est_ana(
                /* only real part needed */
                mvr2r( intensity_real[i], &( hOMasa->buffer_intensity_real[i][index - 1][0] ), num_freq_bands );
            }
            mvr2r( reference_power[ts], &( hOMasa->buffer_energy[( index - 1 ) * num_freq_bands] ), num_freq_bands );
            mvr2r( reference_power, &( hOMasa->buffer_energy[( index - 1 ) * num_freq_bands] ), num_freq_bands );

            computeDiffuseness( hOMasa->buffer_intensity_real, hOMasa->buffer_energy, num_freq_bands, diffuseness_vector );

            for ( band_m_idx = 0; band_m_idx < hOMasa->nbands; band_m_idx++ )
            {
                norm_tmp = reference_power[ts][band_m_idx] * ( 1 - diffuseness_vector[band_m_idx] );
                norm_tmp = reference_power[band_m_idx] * ( 1 - diffuseness_vector[band_m_idx] );

                hOMasa->direction_vector_m[0][block_m_idx][band_m_idx] += norm_tmp * direction_vector[0][band_m_idx];
                hOMasa->direction_vector_m[1][block_m_idx][band_m_idx] += norm_tmp * direction_vector[1][band_m_idx];
                hOMasa->direction_vector_m[2][block_m_idx][band_m_idx] += norm_tmp * direction_vector[2][band_m_idx];

                diffuseness_m[band_m_idx] += reference_power[ts][band_m_idx] * diffuseness_vector[band_m_idx];
                renormalization_factor_diff[band_m_idx] += reference_power[ts][band_m_idx];
                diffuseness_m[band_m_idx] += reference_power[band_m_idx] * diffuseness_vector[band_m_idx];
                renormalization_factor_diff[band_m_idx] += reference_power[band_m_idx];
            }
        }

@@ -495,8 +495,8 @@ static void ivas_omasa_dmx(

void computeIntensityVector_ana(
    const int16_t *band_grouping,                                       /* i  : Band grouping for estimation    */
    float Cldfb_RealBuffer[DIRAC_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX], /* i  : Real part of input signal       */
    float Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX], /* i  : Imag part of input signal       */
    float Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i  : Real part of input signal       */
    float Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i  : Imag part of input signal       */
    const int16_t num_frequency_bands,                                  /* i  : Number of frequency bands       */
    float intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS]          /* o  : Intensity vector                */
)
@@ -534,8 +534,8 @@ void computeIntensityVector_ana(

void computeReferencePower_ana(
    const int16_t *band_grouping,                                       /* i  : Band grouping for estimation    */
    float Cldfb_RealBuffer[DIRAC_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX], /* i  : Real part of input signal       */
    float Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX], /* i  : Imag part of input signal       */
    float Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i  : Real part of input signal       */
    float Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i  : Imag part of input signal       */
    float *reference_power,                                             /* o  : Estimated power                 */
    const int16_t num_freq_bands                                        /* i  : Number of frequency bands       */
)
@@ -549,7 +549,7 @@ void computeReferencePower_ana(
        brange[1] = band_grouping[i + 1];
        reference_power[i] = 0;

        for ( ch_idx = 0; ch_idx < DIRAC_MAX_ANA_CHANS; ch_idx++ )
        for ( ch_idx = 0; ch_idx < FOA_CHANNELS; ch_idx++ )
        {
            /* abs()^2 */
            for ( j = brange[0]; j < brange[1]; j++ )
+12 −0
Original line number Diff line number Diff line
@@ -2929,6 +2929,9 @@ ivas_error IVAS_REND_Open(
        hIvasRend->inputsIsm[i].tdRendWrapper.hBinRendererTd = NULL;
        hIvasRend->inputsIsm[i].nonDiegeticPan = nonDiegeticPan;
        hIvasRend->inputsIsm[i].nonDiegeticPanGain = nonDiegeticPanGain;
#ifdef MASA_PREREND
        hIvasRend->inputsIsm[i].hOMasa = NULL;
#endif
    }

    for ( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i )
@@ -2940,12 +2943,18 @@ ivas_error IVAS_REND_Open(
        hIvasRend->inputsMc[i].tdRendWrapper.hBinRendererTd = NULL;
        hIvasRend->inputsMc[i].nonDiegeticPan = nonDiegeticPan;
        hIvasRend->inputsMc[i].nonDiegeticPanGain = nonDiegeticPanGain;
#ifdef MASA_PREREND
        hIvasRend->inputsMc[i].hMcMasa = NULL;
#endif
    }

    for ( i = 0; i < RENDERER_MAX_SBA_INPUTS; ++i )
    {
        initRendInputBase( &hIvasRend->inputsSba[i].base, IVAS_REND_AUDIO_CONFIG_UNKNOWN, 0, getRendCtx( hIvasRend ) );
        hIvasRend->inputsSba[i].crendWrapper = NULL;
#ifdef MASA_PREREND
        hIvasRend->inputsSba[i].hDirAC = NULL;
#endif
    }

    for ( i = 0; i < RENDERER_MAX_MASA_INPUTS; ++i )
@@ -2953,6 +2962,9 @@ ivas_error IVAS_REND_Open(
        initRendInputBase( &hIvasRend->inputsMasa[i].base, IVAS_REND_AUDIO_CONFIG_UNKNOWN, 0, getRendCtx( hIvasRend ) );
        hIvasRend->inputsMasa[i].decDummy = NULL;
        hIvasRend->inputsMasa[i].metadataHasBeenFed = false;
#ifdef MASA_PREREND
        hIvasRend->inputsMasa[i].hMasaPrerend = NULL;
#endif
    }

    return IVAS_ERR_OK;