Commit 18285010 authored by lintervo's avatar lintervo
Browse files

Merge branch '2163_basop_port_mr_2246_masa_prerend_samplerates' into 'main'

Port 397 - Port float MR 2246 to BASOP main

See merge request !2465
parents efe23912 0b8c606b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -133,6 +133,7 @@
#define FIX_1330_JBM_MEMORY                             /* VA: issue 1330: memory savings in the JBM decoder */
#define FIX_1411_IGF_CRASH_BW_SWITCHING                 /* FhG: Fix for issue 1411: fixes crash that can happen for IGF with BW switching and DTX*/
#define NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG       /* FhG: Fix MDCT-Stereo comfort noise for certain noise types */
#define NONBE_1344_REND_MASA_LOW_FS                     /* Nokia: Issue 1344: Fix sanitizer errors when using IVAS_rend to render MASA with lower sampling rates */

// object-editing feature porting
#define TMP_FIX_SPLIT_REND                              // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions)
+16 −8
Original line number Diff line number Diff line
@@ -250,16 +250,24 @@ void ivas_dirac_ana_fx(
    const Word16 nchan_transport, /* i  : Number of transport channels        */
    const Word16 data_q )
{
    Word32 elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
    Word32 azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
    Word32 energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
    Word32 spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
    Word32 surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
    Word32 elevation_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
    Word32 azimuth_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
    Word32 energyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
    Word32 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
    Word32 surroundingCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
    /* Estimate MASA parameters from the SBA signals */
    ivas_dirac_param_est_ana_fx( hDirAC, data_fx, elevation_m_values, azimuth_m_values, energyRatio, spreadCoherence, surroundingCoherence, input_frame, data_q );
    /* Create MASA metadata buffer from the estimated values */
    ivas_dirac_param_est_ana_fx( hDirAC, data_fx, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx, input_frame, data_q );

    ivas_create_masa_out_meta_fx( hDirAC->hMasaOut, hDirAC->sph_grid16, nchan_transport, elevation_m_values, azimuth_m_values, energyRatio, spreadCoherence, surroundingCoherence, Q31, Q31, Q31 );
#ifdef NONBE_1344_REND_MASA_LOW_FS
    /* Add zeros to higher bands in case of lower sampling rates */
    IF( LT_16( hDirAC->nbands, MASA_FREQUENCY_BANDS ) )
    {
        ivas_masa_zero_high_bands_fx( hDirAC->nbands, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx );
    }
#endif

    /* Create MASA metadata buffer from the estimated values */
    ivas_create_masa_out_meta_fx( hDirAC->hMasaOut, hDirAC->sph_grid16, nchan_transport, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx, Q31, Q31, Q31 );

    /* Downmix */
    ivas_dirac_dmx_fx( data_fx, input_frame, nchan_transport ); // output Q of data_fx is same as that of input
+26 −0
Original line number Diff line number Diff line
@@ -37,6 +37,9 @@
#include "ivas_cnst.h"
#include "prot_fx.h"
#include "wmc_auto.h"
#ifdef NONBE_1344_REND_MASA_LOW_FS
#include "ivas_rom_com.h"
#endif
#include "ivas_prot_fx.h"

#define INV_UINT8_MAX 8421505 /* 1/UINT8_MAX in Q31 */
@@ -487,6 +490,9 @@ ivas_error masaPrerendOpen_fx(
{
    MASA_PREREND_HANDLE hMasaPrerend;
    Word16 i;
#ifdef NONBE_1344_REND_MASA_LOW_FS
    Word16 maxBin;
#endif
    ivas_error error;

    error = IVAS_ERR_OK;
@@ -498,6 +504,26 @@ ivas_error masaPrerendOpen_fx(
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA prerenderer\n" ) );
    }

#ifdef NONBE_1344_REND_MASA_LOW_FS
    /* Determine the number of bands and band grouping */
    hMasaPrerend->nbands = MASA_FREQUENCY_BANDS;
    move16();
    mvs2s( MASA_band_grouping_24, hMasaPrerend->band_grouping, MASA_FREQUENCY_BANDS + 1 );

    maxBin = extract_l( Mpy_32_32( input_Fs, INV_CLDFB_BANDWIDTH_Q31 ) ); /* Q0 */
    FOR( i = 1; i < hMasaPrerend->nbands + 1; i++ )
    {
        IF( GE_16( hMasaPrerend->band_grouping[i], maxBin ) )
        {
            hMasaPrerend->band_grouping[i] = maxBin;
            move16();
            hMasaPrerend->nbands = i;
            move16();
            break;
        }
    }
#endif

    hMasaPrerend->num_Cldfb_instances = numTransports;
    move16();
    FOR( i = 0; i < hMasaPrerend->num_Cldfb_instances; i++ )
+48 −0
Original line number Diff line number Diff line
@@ -486,6 +486,14 @@ void ivas_mcmasa_ana_fx(
    /* Analysis */
    ivas_mcmasa_param_est_ana_fx( hMcMasa, data, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx, q_data, input_frame, nchan_inp );

#ifdef NONBE_1344_REND_MASA_LOW_FS
    /* Add zeros to higher bands in case of lower sampling rates */
    IF( LT_16( hMcMasa->nbands, MASA_FREQUENCY_BANDS ) )
    {
        ivas_masa_zero_high_bands_fx( hMcMasa->nbands, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx );
    }
#endif

    /* Create MASA metadata buffer from the estimated values */
    ivas_create_masa_out_meta_fx( hMcMasa->hMasaOut, hMcMasa->sph_grid16, nchan_transport, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx, Q31, Q31, Q31 );

@@ -1703,3 +1711,43 @@ void ivas_create_masa_out_meta_fx(

    return;
}


#ifdef NONBE_1344_REND_MASA_LOW_FS
/*-------------------------------------------------------------------------
 * ivas_masa_zero_high_bands()
 *
 *
 *------------------------------------------------------------------------*/

void ivas_masa_zero_high_bands_fx(
    const Word16 nbands,                                                              /* i    : Number of frequency bands with estimated values */
    Word32 elevation_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS],  /* i/o  : Estimated elevation                             */
    Word32 azimuth_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS],    /* i/o  : Estimated azimuth                               */
    Word32 energyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS],         /* i/o  : Estimated direct-to-total ratio                 */
    Word32 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS],     /* i/o  : Estimated spread coherence                      */
    Word32 surroundingCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i/o  : Estimated surround coherence                    */
)
{
    Word16 sf, band;

    FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ )
    {
        FOR( band = nbands; band < MASA_FREQUENCY_BANDS; band++ )
        {
            elevation_m_values_fx[sf][band] = 0;
            move32();
            azimuth_m_values_fx[sf][band] = 0;
            move32();
            energyRatio_fx[sf][band] = 0;
            move32();
            spreadCoherence_fx[sf][band] = 0;
            move32();
            surroundingCoherence_fx[sf][band] = 0;
            move32();
        }
    }

    return;
}
#endif
+8 −0
Original line number Diff line number Diff line
@@ -318,6 +318,14 @@ void ivas_omasa_ana_fx(
    /* Estimate MASA parameters from the objects */
    ivas_omasa_param_est_ana_fx( hOMasa, data_in_f_fx, *data_in_q, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, &energyRatio_q, spreadCoherence_fx, &spreadCoherence_q, surroundingCoherence_fx, &sorroundingCoherence_q, input_frame, nchan_ism );

#ifdef NONBE_1344_REND_MASA_LOW_FS
    /* Add zeros to higher bands in case of lower sampling rates */
    IF( LT_16( hOMasa->nbands, MASA_FREQUENCY_BANDS ) )
    {
        ivas_masa_zero_high_bands_fx( hOMasa->nbands, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx );
    }
#endif

    /* Create MASA metadata buffer from the estimated values */
    ivas_create_masa_out_meta_fx( hOMasa->hMasaOut, hOMasa->sph_grid16, nchan_transport, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx, Q31, Q31, Q31 );

Loading