Commit 6d61e915 authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Fixes to merge of main up to 1bfc64ea

parent 95c61ce5
Loading
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -5537,11 +5537,9 @@ void ivas_omasa_dirac_rend(

void preProcessStereoTransportsForMovedObjects(
    Decoder_Struct* st_ivas,
    float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
    float inIm[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
    const uint8_t nBins,
    const uint8_t firstSubframe,
    const uint8_t nSubframes
    float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX],
    float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX],
    const int16_t nBins
);

ivas_error ivas_masa_ism_separate_object_renderer_open(
+7 −7
Original line number Diff line number Diff line
@@ -2527,8 +2527,8 @@ void ivas_dirac_dec(
    float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
    float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
#ifdef MASA_AND_OBJECTS
    float Cldfb_RealBuffer_Temp[2][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; /* Todo Nokia: Temporary, to be removed once function calls have been refactored to accept another size */
    float Cldfb_ImagBuffer_Temp[2][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; /* Todo Nokia: Temporary, to be removed once function calls have been refactored to accept another size */
    float Cldfb_RealBuffer_Temp[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; /* Todo Nokia: Temporary, to be removed once function calls have been refactored to accept another size */
    float Cldfb_ImagBuffer_Temp[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; /* Todo Nokia: Temporary, to be removed once function calls have been refactored to accept another size */
#endif
    int16_t index, num_freq_bands;

@@ -2718,8 +2718,8 @@ void ivas_dirac_dec(
                for ( ch = 0; ch < nchan_transport; ch++ )
                {
                    cldfbAnalysis_ts( &( output_f[sba_map_tc[ch]][hDirAC->num_freq_bands * index_slot] ),
                                      Cldfb_RealBuffer_Temp[ch][index_slot],
                                      Cldfb_ImagBuffer_Temp[ch][index_slot],
                                      Cldfb_RealBuffer_Temp[ch][slot_idx],
                                      Cldfb_ImagBuffer_Temp[ch][slot_idx],
                                      hDirAC->num_freq_bands,
                                      st_ivas->cldfbAnaDec[ch] );
                }
@@ -2727,7 +2727,7 @@ void ivas_dirac_dec(

            if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC && st_ivas->ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ )
            {
                preProcessStereoTransportsForMovedObjects( st_ivas, Cldfb_RealBuffer_Temp, Cldfb_ImagBuffer_Temp, (uint8_t) ( hDirAC->num_freq_bands ), (uint8_t) subframe_idx, 1 );
                preProcessStereoTransportsForMovedObjects( st_ivas, Cldfb_RealBuffer_Temp, Cldfb_ImagBuffer_Temp, (uint8_t) ( hDirAC->num_freq_bands ) );
            }
        }
#endif
@@ -2749,8 +2749,8 @@ void ivas_dirac_dec(
            {
                for ( ch = 0; ch < nchan_transport; ch++ )
                {
                    mvr2r( Cldfb_RealBuffer_Temp[ch][index_slot], Cldfb_RealBuffer[ch][0], hDirAC->num_freq_bands );
                    mvr2r( Cldfb_ImagBuffer_Temp[ch][index_slot], Cldfb_ImagBuffer[ch][0], hDirAC->num_freq_bands );
                    mvr2r( Cldfb_RealBuffer_Temp[ch][slot_idx], Cldfb_RealBuffer[ch][0], hDirAC->num_freq_bands );
                    mvr2r( Cldfb_ImagBuffer_Temp[ch][slot_idx], Cldfb_ImagBuffer[ch][0], hDirAC->num_freq_bands );
                }
            }
#endif
+233 −145
Original line number Diff line number Diff line
@@ -498,8 +498,13 @@ static void ivas_dirac_dec_binaural_internal(
{
    DIRAC_DEC_HANDLE hDirAC;
    int16_t slot, ch, numInChannels;
#ifdef MASA_AND_OBJECTS
    float Cldfb_RealBuffer_in[6][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
    float Cldfb_ImagBuffer_in[6][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
#else
    float Cldfb_RealBuffer_in[4][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
    float Cldfb_ImagBuffer_in[4][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
#endif
    float Rmat[3][3];
    int16_t max_band_decorr;
    DIFFUSE_DISTRIBUTION_DATA diffuseDistData;
@@ -511,10 +516,21 @@ static void ivas_dirac_dec_binaural_internal(

    /* The input channel number at this processing function (not nchan_transport) */
    numInChannels = BINAURAL_CHANNELS;
#ifdef MASA_AND_OBJECTS
    if ( st_ivas->hOutSetup.separateChannelEnabled || ( st_ivas->ivas_format == MASA_ISM_FORMAT && ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) ) )
    {
        numInChannels++;
    }
    else if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC && ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
    {
        numInChannels += (uint8_t) st_ivas->nchan_ism;
    }
#else
    if ( st_ivas->hOutSetup.separateChannelEnabled )
    {
        numInChannels++;
    }
#endif

    Rmat[0][0] = 1.0f;
    Rmat[0][1] = 0.0f;
@@ -634,6 +650,13 @@ static void ivas_dirac_dec_binaural_internal(
        ivas_sba_prototype_renderer( st_ivas, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe );
    }

#ifdef MASA_AND_OBJECTS
    if ( st_ivas->ivas_format == MASA_ISM_FORMAT && nchan_transport == 2 && st_ivas->ism_mode != ISM_MASA_MODE_DISC && st_ivas->ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ )
    {
        preProcessStereoTransportsForMovedObjects( st_ivas, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, nBins );
    }
#endif

    if ( st_ivas->hHeadTrackData && st_ivas->hHeadTrackData->num_quaternions >= 0 )
    {
        QuatToRotMat( st_ivas->hHeadTrackData->Quaternions[subframe], Rmat );
@@ -1063,6 +1086,10 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric
    for ( bin = 0; bin < nBins; bin++ )
    {
        float diffuseness = 1.0f;              /* ratio1 and ratio2 are subtracted from diffuseness further below */
#ifdef MASA_AND_OBJECTS
        float diffusenessValForDecorrelationReduction = 1.0f;
        float diffEneValForDecorrelationReduction;
#endif
        float surCoh = 0.0f, spreadCoh = 0.0f; /* Default values if spreadSurroundCoherenceApplied == false */
        float diffEne, dirEne, meanEnePerCh;
        int16_t dirIndex;
@@ -1081,6 +1108,9 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric
            float lRealp, lImagp, rRealp, rImagp;
            float lRealpTmp, lImagpTmp, rRealpTmp, rImagpTmp;
            float hrtfEne[BINAURAL_CHANNELS], hrtfCrossRe, hrtfCrossIm, ratio;
#ifdef MASA_AND_OBJECTS
            uint8_t isIsmDirection = 0;
#endif

            if ( dirIndex == 0 ) /* For first of the two simultaneous directions */
            {
@@ -1089,15 +1119,55 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric
                ratio = hDirAC->energy_ratio1[dirac_read_idx][bin];
                spreadCoh = hDirAC->spreadCoherence[dirac_read_idx][bin];
            }
#ifdef MASA_AND_OBJECTS
            else if ( st_ivas->ivas_format != MASA_ISM_FORMAT || ( st_ivas->ivas_format == MASA_ISM_FORMAT && dirIndex < hDirAC->numParametricDirections ) ) /* For second of the two simultaneous directions */
#else
            else /* For second of the two simultaneous directions */
#endif
            {
                aziDeg = hDirAC->azimuth2[dirac_read_idx][bin];
                eleDeg = hDirAC->elevation2[dirac_read_idx][bin];
                ratio = hDirAC->energy_ratio2[dirac_read_idx][bin];
                spreadCoh = hDirAC->spreadCoherence2[dirac_read_idx][bin];
            }
#ifdef MASA_AND_OBJECTS
            else /* For object directions of MASA_ISM_FORMAT */
            {
                isIsmDirection = 1;
                uint16_t ismDirIndex;
                ismDirIndex = dirIndex - hDirAC->numParametricDirections;
                if ( st_ivas->hMasaIsmData->ism_is_edited[ismDirIndex] )
                {
                    aziDeg = st_ivas->hMasaIsmData->azimuth_ism_edited[ismDirIndex];
                    eleDeg = st_ivas->hMasaIsmData->elevation_ism_edited[ismDirIndex];
                }
                else
                {
                    aziDeg = st_ivas->hMasaIsmData->azimuth_ism[ismDirIndex][dirac_read_idx];
                    eleDeg = st_ivas->hMasaIsmData->elevation_ism[ismDirIndex][dirac_read_idx];
                }
                ratio = st_ivas->hMasaIsmData->energy_ratio_ism[ismDirIndex][dirac_read_idx][bin];
                spreadCoh = 0.0f;
            }
#endif
            diffuseness -= ratio; /* diffuseness = 1 - ratio1 - ratio2 */

#ifdef MASA_AND_OBJECTS
            if ( diffuseness < 0.0f )
            {
                diffuseness = 0.0f;
            }
            if ( isIsmDirection )
            {
                /* Objects cause lesser decorrelation reduction, to avoid removing all decorrelation when only objects are present */
                diffusenessValForDecorrelationReduction -= ratio * 0.5f;
            }
            else
            {
                diffusenessValForDecorrelationReduction -= ratio;
            }
#endif

            if ( separateCenterChannelRendering )
            {
                /* In masa + mono rendering mode, the center directions originate from phantom sources, so the
@@ -1233,13 +1303,32 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric
        diffuseness = max( 0.0f, diffuseness );
        diffEne = diffuseness * meanEnePerCh;
        surCoh = hDirAC->surroundingCoherence[dirac_read_idx][bin];

#ifdef MASA_AND_OBJECTS
        diffusenessValForDecorrelationReduction = max( 0.0f, diffusenessValForDecorrelationReduction );
        diffEneValForDecorrelationReduction = diffusenessValForDecorrelationReduction * meanEnePerCh;
#endif

        if ( ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) )
        {
            if ( !h->renderStereoOutputInsteadOfBinaural )
            {
#ifdef MASA_AND_OBJECTS
                float spectrumModVal;

                idx = min( bin, MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS - 1 );
                /* Apply target spectrum that emphasizes low frequencies when the sound is surround coherent */
                spectrumModVal = ( 1.0f - surCoh ) + surCoh * surCohEne[idx];
                diffEne *= spectrumModVal;
#else
                idx = min( bin, MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS - 1 );
                /* Apply target spectrum that emphasizes low frequencies when the sound is surround coherent */
                diffEne *= ( 1.0f - surCoh ) + surCoh * surCohEne[idx];
#endif
#ifdef MASA_AND_OBJECTS
                /* Modify also the value for decorrelation reduction */
                diffEneValForDecorrelationReduction *= spectrumModVal;
#endif
            }
        }
        h->ChEneOut[0][bin] += diffEne; /* Diff ene part*/
@@ -1265,7 +1354,11 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric
        }

        /* Store parameters for formulating average diffuseness over frame */
#ifdef MASA_AND_OBJECTS
        h->frameMeanDiffuseness[bin] += diffEneValForDecorrelationReduction;
#else
        h->frameMeanDiffuseness[bin] += diffEne;
#endif
        frameMeanDiffusenessEneWeight[bin] += meanEnePerCh;
    }

@@ -2048,7 +2141,6 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices(
                }
            }
#else

            gainFactor = 0.8414f * sqrtf( h->earlyPartEneCorrection[bin] );
            for ( chA = 0; chA < BINAURAL_CHANNELS; chA++ )
            {
@@ -3194,13 +3286,12 @@ static

void preProcessStereoTransportsForMovedObjects(
    Decoder_Struct *st_ivas,
    float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
    float inIm[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
    const uint8_t nBins,
    const uint8_t firstSubframe,
    const uint8_t nSubframes )
    float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX],
    float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX],
    const int16_t nBins
)
{
    int16_t subframe, bin, ch, inCh, outCh, ismDirIndex, slot;
    int16_t bin, ch, inCh, outCh, ismDirIndex, slot;
    DIRAC_DEC_HANDLE hDirAC;
    MASA_ISM_DATA_HANDLE hMasaIsmData;
    uint8_t enableCentering;
@@ -3236,8 +3327,6 @@ void preProcessStereoTransportsForMovedObjects(
    }

    /* Perform object-movement based processing */
    for ( subframe = firstSubframe; subframe < ( firstSubframe + nSubframes ); subframe++ )
    {
    dirac_read_idx = st_ivas->hDirAC->dirac_read_idx;

    for ( bin = 0; bin < nBins; bin++ )
@@ -3262,7 +3351,7 @@ void preProcessStereoTransportsForMovedObjects(
        set_zero( normEnes, 2 );

        /* Determine transport normalized energies and subframe energy */
            for ( slot = subframe * hDirAC->subframe_nbslots; slot < (int16_t) ( ( subframe + 1 ) * hDirAC->subframe_nbslots ); slot++ )
        for ( slot = 0; slot < hDirAC->subframe_nbslots; slot++ )
        {
            for ( ch = 0; ch < 2; ch++ )
            {
@@ -3371,7 +3460,7 @@ void preProcessStereoTransportsForMovedObjects(
        }

        /* Mix signals */
            for ( slot = subframe * hDirAC->subframe_nbslots; slot < (int16_t) ( ( subframe + 1 ) * hDirAC->subframe_nbslots ); slot++ )
        for ( slot = 0; slot < hDirAC->subframe_nbslots; slot++ )
        {
            float eqVal;
            float outSlotRe[2];
@@ -3408,7 +3497,6 @@ void preProcessStereoTransportsForMovedObjects(
            }
        }
    }
    }

    return;
}