Commit 8fc8171e authored by multrus's avatar multrus
Browse files

Merge branch '20240326_cleanup' into 'main'

20240326 cleanup

See merge request !1482
parents eab00917 dfbcf03b
Loading
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -1195,11 +1195,7 @@ enum
#define MASA_COHERENCE_TOLERANCE                0.1f
#define MASA_COHERENCE_THRESHOLD                0.1f
#define MASA_RATIO_TOLERANCE                    0.1f
#ifdef NONBE_FIX_1034_DRY_MASA_RATIOS
#define MASA_RATIO_THRESHOLD                    0.015f
#else
#define MASA_RATIO_THRESHOLD                    0.1f
#endif
#define MASA_ANGLE_TOLERANCE                    0.5f
#define MASA_LIMIT_NO_BANDS_SUR_COH             8
#define MINIMUM_BIT_BUDGET_NORMAL_META          100
+0 −16
Original line number Diff line number Diff line
@@ -1095,13 +1095,6 @@ void ivas_param_ism_dec_close(
    const AUDIO_CONFIG output_config                            /* i  : output audio configuration                  */
);

#ifndef FIX_1022_REMOVE_PARAMISM_DEC
void ivas_param_ism_dec(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                      */
    float *output_f[]                                           /* i/o: synthesized core-coder transport channels/DirAC output  */
);

#endif
void ivas_ism_dec_digest_tc(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                      */
);
@@ -3869,13 +3862,6 @@ void ivas_param_mc_dec_render(
    float *output_f[]                                           /* o  : rendered time signal                                */
);

#ifndef FIX_1023_REMOVE_PARAMMC_DEC
void ivas_param_mc_dec(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder handle                                     */
    float *output_f[]                                           /* i/o: synthesized core-coder transport channels/DirAC output  */
);

#endif
/*! r: number of cldfb synthesis instances */
int16_t param_mc_get_num_cldfb_syntheses( 
    Decoder_Struct *st_ivas                                     /* i  : IVAS decoder structure                              */
@@ -5218,9 +5204,7 @@ void ivas_ism_renderer_close(

void ivas_ism_render_sf(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                          */
#ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH
    const RENDERER_TYPE renderer_type,                          /* i  : active renderer type                            */
#endif
    float *output_f[],                                          /* i/o: core-coder transport channels/object output     */
    const int16_t n_samples_to_render                           /* i  : output frame length per channel                 */
);
+0 −6
Original line number Diff line number Diff line
@@ -156,20 +156,14 @@
/*#define FIX_I4_OL_PITCH*/                             /* fix open-loop pitch used for EVS core switching */
/*#define SPLIT_REND_WITH_HEAD_ROT  */                  /* Dlb,FhG: Split Rendering contributions 21 and 35 */

#define FIX_1024_REMOVE_PARAMMC_MIXING_MAT              /* VA: issue 1024: remove unused function ivas_param_mc_get_mono_stereo_mixing_matrices() */
#define FIX_1023_REMOVE_PARAMMC_DEC                     /* VA: issue 1023: remove unused function ivas_param_mc_dec() */
#define FIX_1022_REMOVE_PARAMISM_DEC                    /* VA: issue 1022: remove unused function ivas_param_ism_dec() */
#define FIX_1033_MEMORY_LEAK_OMASA                      /* Nokia / Orange: issue #1033: Memory leak in OMASA to BINAURAL with HRTF with bitrate switching */

#define FIX_1035_HT_OSBA                                /* Dlb: issue 1035: Issue with headtracking in OSBA*/
/* #################### End BE switches ################################## */

/* #################### Start NON-BE switches ############################ */
/* any switch which is non-be wrt selection floating point code */
/* all switches in this category should start with "NONBE_" */

#define NONBE_FIX_1021_ISM_BRIR_RS_FLUSH                /* FhG: issue #1021: fix ISM with JBM and RS renderer flushing*/
#define NONBE_FIX_1034_DRY_MASA_RATIOS                  /* Nokia: Fix issue 1034, use of wrong numDir state. */

/* ##################### End NON-BE switches ########################### */

+0 −4
Original line number Diff line number Diff line
@@ -1122,11 +1122,7 @@ ivas_error ivas_binRenderer_open(

    /* Define of head rotation has to be done in binRendeder in CLDFB*/
    hBinRenderer->rotInCldfb = 0;
#ifdef FIX_1035_HT_OSBA
    if ( st_ivas->ivas_format == MC_FORMAT || st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT )
#else
    if ( st_ivas->ivas_format == MC_FORMAT || st_ivas->ivas_format == SBA_FORMAT )
#endif
    {
        hBinRenderer->rotInCldfb = 1;
    }
+35 −343
Original line number Diff line number Diff line
@@ -324,44 +324,6 @@ static void ivas_param_ism_render_slot(
    return;
}

#ifndef FIX_1022_REMOVE_PARAMISM_DEC
static void ivas_param_ism_rendering(
    PARAM_ISM_DEC_HANDLE hParamIsmDec,
    SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom,
    float Cldfb_RealBuffer_in[PARAM_ISM_MAX_DMX][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
    float Cldfb_ImagBuffer_in[PARAM_ISM_MAX_DMX][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
    float Cldfb_RealBuffer[PARAM_ISM_MAX_CHAN][4][CLDFB_NO_CHANNELS_MAX],
    float Cldfb_ImagBuffer[PARAM_ISM_MAX_CHAN][4][CLDFB_NO_CHANNELS_MAX],
    float mixing_matrix[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_CHAN * PARAM_ISM_MAX_DMX],
    const int16_t out_slot_idx,
    const int16_t slot_idx,
    const int16_t num_ch_LS,
    const int16_t nchan_transport )
{
    int16_t outchIdx, inchIdx, bin_idx;
    float tmp_1, mixing_matrix_smooth;

    tmp_1 = hParamIsmDec->hParamIsmRendering->interpolator[slot_idx];

    for ( bin_idx = 0; bin_idx < hSpatParamRendCom->num_freq_bands; bin_idx++ )
    {
        /* smooth the mixing matrix */
        for ( outchIdx = 0; outchIdx < num_ch_LS; outchIdx++ )
        {
            for ( inchIdx = 0; inchIdx < nchan_transport; inchIdx++ )
            {
                mixing_matrix_smooth = tmp_1 * mixing_matrix[bin_idx][outchIdx + inchIdx * num_ch_LS] +
                                       ( 1 - tmp_1 ) * hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_old[bin_idx][outchIdx + inchIdx * num_ch_LS];

                Cldfb_RealBuffer[outchIdx][out_slot_idx][bin_idx] += mixing_matrix_smooth * Cldfb_RealBuffer_in[inchIdx][slot_idx][bin_idx];
                Cldfb_ImagBuffer[outchIdx][out_slot_idx][bin_idx] += mixing_matrix_smooth * Cldfb_ImagBuffer_in[inchIdx][slot_idx][bin_idx];
            }
        }
    }

    return;
}
#endif

static ivas_error ivas_param_ism_rendering_init(
    PARAM_ISM_RENDERING_HANDLE hParamIsmRendering,
@@ -729,251 +691,6 @@ void ivas_param_ism_dec_close(
    return;
}

#ifndef FIX_1022_REMOVE_PARAMISM_DEC
/*-------------------------------------------------------------------------*
 * ivas_param_ism_dec()
 *
 * Param ISM decoder
 *-------------------------------------------------------------------------*/

void ivas_param_ism_dec(
    Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure                                */
    float *output_f[]        /* i/o: synthesized core-coder transport channels/DirAC output*/
)
{
    int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i;
    int16_t subframe_idx, slot_idx, index_slot, bin_idx;
    int32_t ivas_total_brate;
    int16_t output_frame;
    float *p_tc[PARAM_ISM_MAX_DMX];
    float ref_power[CLDFB_NO_CHANNELS_MAX];
    float cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX];
    /* CLDFB Input Buffers */
    float Cldfb_RealBuffer_in[PARAM_ISM_MAX_DMX][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
    float Cldfb_ImagBuffer_in[PARAM_ISM_MAX_DMX][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];

    /* CLDFB Output Buffers */
    float Cldfb_RealBuffer[PARAM_ISM_MAX_CHAN][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
    float Cldfb_ImagBuffer[PARAM_ISM_MAX_CHAN][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];

    /* Direct Response/EFAP Gains */
    float direct_response[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN];

    /* Covariance Rendering */
    float mixing_matrix[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_CHAN * PARAM_ISM_MAX_DMX];

    PARAM_ISM_DEC_HANDLE hParamIsmDec;
    SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;

    IVAS_OUTPUT_SETUP hSetup;

    /* Initialization */
    hParamIsmDec = st_ivas->hParamIsmDec;
    assert( hParamIsmDec );
    hSpatParamRendCom = st_ivas->hSpatParamRendCom;
    assert( hSpatParamRendCom );
    for ( i = 0; i < PARAM_ISM_MAX_DMX; i++ )
    {
        p_tc[i] = output_f[i];
    }
    output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC );

    nchan_transport = st_ivas->nchan_transport;
    if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL )
    {
        nchan_out = st_ivas->nchan_ism;
        nchan_out_woLFE = nchan_out;
        st_ivas->hDecoderConfig->nchan_out = nchan_out;
    }
    else
    {
        nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe;
        nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE;
    }

    ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;

    hSetup = st_ivas->hIntSetup;

    push_wmops( "ivas_param_ism_dec" );

    /* set buffers to zero */
    for ( bin_idx = 0; bin_idx < CLDFB_NO_CHANNELS_MAX; bin_idx++ )
    {
        set_zero( cx_diag[bin_idx], PARAM_ISM_MAX_DMX );
    }
    set_zero( ref_power, CLDFB_NO_CHANNELS_MAX );

    /* Frame-level Processing */
    /* De-quantization */
    if ( !( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) )
    {
        ivas_param_ism_dec_dequant_DOA( hParamIsmDec, st_ivas->nchan_ism );
        ivas_param_ism_dec_dequant_powrat( hParamIsmDec );
        st_ivas->hISMDTX.dtx_flag = 0;
    }
    else
    {
        st_ivas->hISMDTX.dtx_flag = 1;
    }

    /* obtain the direct response using EFAP */
    if ( !( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) )
    {
        for ( i = 0; i < st_ivas->nchan_ism; i++ )
        {
            efap_determine_gains( st_ivas->hEFAPdata, direct_response[i], hParamIsmDec->azimuth_values[i], hParamIsmDec->elevation_values[i], EFAP_MODE_EFAP );
        }
    }
    else
    {
        int16_t j;

        for ( i = 0; i < st_ivas->nchan_ism; i++ )
        {
            for ( j = 0; j < nchan_out_woLFE; j++ )
            {
                if ( i == j )
                {
                    direct_response[i][j] = 1.0f;
                }
                else
                {
                    direct_response[i][j] = 0.0f;
                }
            }
        }

        for ( j = 0; j < nchan_out_woLFE; j++ )
        {
            if ( hParamIsmDec->azimuth_values[j] > 0.0f )
            {
                hParamIsmDec->hParamIsmRendering->proto_matrix[j] = 1.0f;
                hParamIsmDec->hParamIsmRendering->proto_matrix[nchan_out_woLFE + j] = 0.0f;
            }
            else
            {
                if ( hParamIsmDec->azimuth_values[j] < 0.0f )
                {
                    hParamIsmDec->hParamIsmRendering->proto_matrix[j] = 0.0f;
                    hParamIsmDec->hParamIsmRendering->proto_matrix[nchan_out_woLFE + j] = 1.0f;
                }
                else /* == 0.0f */
                {
                    hParamIsmDec->hParamIsmRendering->proto_matrix[j] = 0.5f;
                    hParamIsmDec->hParamIsmRendering->proto_matrix[nchan_out_woLFE + j] = 0.5f;
                }
            }
        }
    }

    ivas_ism_param_dec_tc_gain_ajust( st_ivas, output_frame, output_frame / 2, p_tc );

    for ( ch = 0; ch < nchan_transport; ch++ )
    {
        /* CLDFB Analysis */
        for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ )
        {
            cldfbAnalysis_ts( &( output_f[ch][hSpatParamRendCom->num_freq_bands * slot_idx] ), Cldfb_RealBuffer_in[ch][slot_idx], Cldfb_ImagBuffer_in[ch][slot_idx], hSpatParamRendCom->num_freq_bands, st_ivas->cldfbAnaDec[ch] );

            ivas_param_ism_collect_slot( hParamIsmDec, Cldfb_RealBuffer_in[ch][slot_idx], Cldfb_ImagBuffer_in[ch][slot_idx], ch, ref_power, cx_diag );
        }
    }

    /* Obtain Mixing Matrix on a frame-level */
    for ( bin_idx = 0; bin_idx < hSpatParamRendCom->num_freq_bands; bin_idx++ )
    {
        set_f( mixing_matrix[bin_idx], 0.0f, nchan_transport * nchan_out_woLFE );
    }

    /* Compute mixing matrix */
    ivas_param_ism_compute_mixing_matrix( st_ivas->nchan_ism, hParamIsmDec, st_ivas->hISMDTX, direct_response, nchan_transport, nchan_out_woLFE, cx_diag, ref_power, mixing_matrix );

    /* subframe loop for synthesis*/
    for ( subframe_idx = 0; subframe_idx < hSpatParamRendCom->nb_subframes; subframe_idx++ )
    {
        uint16_t slot_idx_start = subframe_idx * hSpatParamRendCom->subframe_nbslots[subframe_idx];
        uint16_t idx_in;
        uint16_t idx_lfe;

        /* Set some memories to zero */
        for ( ch = 0; ch < nchan_out_woLFE; ch++ )
        {
            for ( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ )
            {
                set_f( Cldfb_RealBuffer[ch][slot_idx], 0.0f, hSpatParamRendCom->num_freq_bands );
                set_f( Cldfb_ImagBuffer[ch][slot_idx], 0.0f, hSpatParamRendCom->num_freq_bands );
            }
        }

        for ( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ )
        {
            index_slot = slot_idx_start + slot_idx;

            /* Compute bandwise rendering to target LS using covariance rendering */
            ivas_param_ism_rendering( hParamIsmDec, hSpatParamRendCom, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in,
                                      Cldfb_RealBuffer, Cldfb_ImagBuffer, mixing_matrix, slot_idx, index_slot,
                                      nchan_out_woLFE, nchan_transport );
        }

        /* CLDFB Synthesis */
        idx_in = 0;
        idx_lfe = 0;

        for ( ch = 0; ch < nchan_out; ch++ )
        {
            if ( ( hSetup.num_lfe > 0 ) && ( hSetup.index_lfe[idx_lfe] == ch ) )
            {
                set_zero( &( output_f[ch][slot_idx_start * hSpatParamRendCom->num_freq_bands] ), hSpatParamRendCom->subframe_nbslots[subframe_idx] * hSpatParamRendCom->num_freq_bands );
                if ( idx_lfe < ( hSetup.num_lfe - 1 ) )
                {
                    idx_lfe++;
                }
            }
            else
            {
                float *RealBuffer[16];
                float *ImagBuffer[16];

                /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */
                for ( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ )
                {
                    RealBuffer[i] = Cldfb_RealBuffer[idx_in][i];
                    ImagBuffer[i] = Cldfb_ImagBuffer[idx_in][i];
                }

                cldfbSynthesis( RealBuffer, ImagBuffer, &( output_f[ch][slot_idx_start * hSpatParamRendCom->num_freq_bands] ),
                                hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch] );

                idx_in++;
            }
        }
    }

    /* copy the memories */
    /* store mixing matrix for next subframe */
    ivas_param_ism_update_mixing_matrix( hParamIsmDec, mixing_matrix, nchan_transport, nchan_out_woLFE );

    /* store MetaData parameters */
    for ( ch = 0; ch < st_ivas->nchan_ism; ch++ )
    {
        if ( st_ivas->hParamIsmDec->azimuth_values[ch] > 180.0f )
        {
            st_ivas->hIsmMetaData[ch]->azimuth = st_ivas->hParamIsmDec->azimuth_values[ch] - 360.0f;
        }
        else
        {
            st_ivas->hIsmMetaData[ch]->azimuth = st_ivas->hParamIsmDec->azimuth_values[ch];
        }

        st_ivas->hIsmMetaData[ch]->elevation = st_ivas->hParamIsmDec->elevation_values[ch];
    }

    pop_wmops();

    return;
}
#endif

/*-------------------------------------------------------------------------*
 * ivas_ism_dec_digest_tc()
@@ -1533,10 +1250,6 @@ void ivas_param_ism_params_to_masa_param_mapping(
        st_ivas->hISMDTX.dtx_flag = 1;
    }

#ifndef FIX_1022_REMOVE_PARAMISM_DEC
    if ( st_ivas->nchan_ism > 1 )
    {
#endif
    if ( st_ivas->hISMDTX.dtx_flag )
    {
        float energy_ratio;
@@ -1600,27 +1313,6 @@ void ivas_param_ism_params_to_masa_param_mapping(
            }
        }
    }
#ifndef FIX_1022_REMOVE_PARAMISM_DEC
    }
    else
    {
        hSpatParamRendCom->numSimultaneousDirections = 1;
        azimuth[0] = (int16_t) roundf( hParamIsmDec->azimuth_values[0] );
        elevation[0] = (int16_t) roundf( hParamIsmDec->elevation_values[0] );

        for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
        {
            for ( bin_idx = 0; bin_idx < nBins; bin_idx++ )
            {
                hSpatParamRendCom->azimuth[sf_idx][bin_idx] = azimuth[0];
                hSpatParamRendCom->elevation[sf_idx][bin_idx] = elevation[0];
                hSpatParamRendCom->energy_ratio1[sf_idx][bin_idx] = 1.0f;
                hSpatParamRendCom->spreadCoherence[sf_idx][bin_idx] = 0.0f;
                hSpatParamRendCom->surroundingCoherence[sf_idx][bin_idx] = 0.0;
            }
        }
    }
#endif

    return;
}
Loading