Commit 7e8c467e authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Fix issue 390 by changing the MASA metadata copying in external renderer to...

Fix issue 390 by changing the MASA metadata copying in external renderer to use the metadata write pointers.
parent ad1223e5
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -153,6 +153,8 @@

#define SBA2MONO                                        /* FhG: Issue 365: Adapt processing of SBA mono output to be in line with stereo output (less delay, lower complexity) */

#define FIX_390_EXT_REND_MASA_META_COPY                 /* Nokia: Issue 390: Fixes MASA metadata copying to renderer. */

/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
#endif
+37 −0
Original line number Diff line number Diff line
@@ -2222,6 +2222,9 @@ static ivas_error initMasaDummyDecForMcOut(
    {
        return error;
    }
#ifdef FIX_390_EXT_REND_MASA_META_COPY
    decDummy->hDirAC->dirac_bs_md_write_idx = 0;
#endif

    if ( decDummy->renderer_type == RENDERER_STEREO_PARAMETRIC )
    {
@@ -2298,6 +2301,9 @@ static ivas_error initMasaDummyDecForSbaOut(
    {
        return error;
    }
#ifdef FIX_390_EXT_REND_MASA_META_COPY
    decDummy->hDirAC->dirac_bs_md_write_idx = 0;
#endif

    numCldfbAnalyses = decDummy->nchan_transport;
    numCldfbSyntheses = decDummy->hDecoderConfig->nchan_out;
@@ -2366,6 +2372,9 @@ static ivas_error initMasaDummyDecForBinauralOut(
    {
        return error;
    }
#ifdef FIX_390_EXT_REND_MASA_META_COPY
    decDummy->hDirAC->dirac_bs_md_write_idx = 0;
#endif

    if ( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &decDummy->hHrtfParambin ) ) != IVAS_ERR_OK )
    {
@@ -5287,33 +5296,61 @@ static void copyMasaMetadataToDiracRenderer(
    DIRAC_DEC_HANDLE hDirAC )
{
    int16_t band, sf, bin;
#ifdef FIX_390_EXT_REND_MASA_META_COPY
    int16_t meta_write_index;
#endif

    hDirAC->numSimultaneousDirections = meta->descriptive_meta.numberOfDirections + 1;

    for ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ )
    {
#ifdef FIX_390_EXT_REND_MASA_META_COPY
        meta_write_index = ( hDirAC->dirac_bs_md_write_idx + sf ) % hDirAC->dirac_md_buffer_length;
#endif

        for ( band = 0; band < MASA_MAXIMUM_CODING_SUBBANDS; band++ )
        {
            for ( bin = MASA_band_grouping_24[band]; bin < MASA_band_grouping_24[band + 1]; bin++ )
            {
#ifdef FIX_390_EXT_REND_MASA_META_COPY
                hDirAC->azimuth[meta_write_index][bin] = (int16_t) meta->directional_meta[0].azimuth[sf][band];
                hDirAC->elevation[meta_write_index][bin] = (int16_t) meta->directional_meta[0].elevation[sf][band];
                hDirAC->energy_ratio1[meta_write_index][bin] = meta->directional_meta[0].energy_ratio[sf][band];
                hDirAC->diffuseness_vector[meta_write_index][bin] = 1.0f - meta->directional_meta[0].energy_ratio[sf][band];
                hDirAC->spreadCoherence[meta_write_index][bin] = meta->directional_meta[0].spread_coherence[sf][band];
                hDirAC->surroundingCoherence[meta_write_index][bin] = meta->common_meta.surround_coherence[sf][band];
#else
                hDirAC->azimuth[sf][bin] = (int16_t) meta->directional_meta[0].azimuth[sf][band];
                hDirAC->elevation[sf][bin] = (int16_t) meta->directional_meta[0].elevation[sf][band];
                hDirAC->energy_ratio1[sf][bin] = meta->directional_meta[0].energy_ratio[sf][band];
                hDirAC->diffuseness_vector[sf][bin] = 1.0f - meta->directional_meta[0].energy_ratio[sf][band];
                hDirAC->spreadCoherence[sf][bin] = meta->directional_meta[0].spread_coherence[sf][band];
                hDirAC->surroundingCoherence[sf][bin] = meta->common_meta.surround_coherence[sf][band];
#endif

                if ( hDirAC->numSimultaneousDirections == 2 )
                {
#ifdef FIX_390_EXT_REND_MASA_META_COPY
                    hDirAC->azimuth2[meta_write_index][bin] = (int16_t) meta->directional_meta[1].azimuth[sf][band];
                    hDirAC->elevation2[meta_write_index][bin] = (int16_t) meta->directional_meta[1].elevation[sf][band];
                    hDirAC->energy_ratio2[meta_write_index][bin] = meta->directional_meta[1].energy_ratio[sf][band];
                    hDirAC->diffuseness_vector[meta_write_index][bin] -= meta->directional_meta[1].energy_ratio[sf][band];
                    hDirAC->spreadCoherence2[meta_write_index][bin] = meta->directional_meta[1].spread_coherence[sf][band];
#else
                    hDirAC->azimuth2[sf][bin] = (int16_t) meta->directional_meta[1].azimuth[sf][band];
                    hDirAC->elevation2[sf][bin] = (int16_t) meta->directional_meta[1].elevation[sf][band];
                    hDirAC->energy_ratio2[sf][bin] = meta->directional_meta[1].energy_ratio[sf][band];
                    hDirAC->diffuseness_vector[sf][bin] -= meta->directional_meta[1].energy_ratio[sf][band];
                    hDirAC->spreadCoherence2[sf][bin] = meta->directional_meta[1].spread_coherence[sf][band];
#endif
                }
            }
        }
    }
#ifdef FIX_390_EXT_REND_MASA_META_COPY

    hDirAC->dirac_bs_md_write_idx = ( hDirAC->dirac_bs_md_write_idx + MAX_PARAM_SPATIAL_SUBFRAMES ) % hDirAC->dirac_md_buffer_length;
#endif

    return;
}