Commit 1215ea66 authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

Merge branch 'main' into isar_lcld_crash_codec_fr_LT_isar_fr

parents 21bb08ab b25497ac
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@
#define NONBE_FIX_ISSUE_2206_TD_CHANNEL_EXTRAPOLATION   /* FhG: Use different scale to avoid saturation of LPC coefficient in TD Stereo signal extrapolation. */
#define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_SWB_fenv_fx2 /* FhG: Avoid overflow of SWB_fenv_fx in SWB_BWE_encoding_fx because of very small energies. */
#define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_MSVQ_Interpol_Tran_fx /* FhG: Fix saturation crash in MSVQ_Interpol_Tran_fx() */
#define NONBE_FIX_ISSUE_2206_SWB_EXPERIMENT_FIX_2527    /* Fix crash from issue #2527 */
#define FIX_2452_HQ_CORE_PEAQ_AVR_RATIO_HARM            /* Eri: Basop issue 2453: Fix alignment of peak_avrg_ratio_fx */
#define FIX_FLOAT_1539_G192_FORMAT_SWITCH               /* VA/Nokia: reintroduce format switching for g192 bitstreams */
#define FIX_1527_CMR_BITRATE_IDX                        /* Fix for incorrect bitrate idx packed in rtp CMR E-byte */
@@ -121,8 +122,8 @@
#define FIX_BASOP_2522_MAP_PARAMS_DIRAC_STEREO          /* FhG: BASOP issue 2522: Fix copy and paste error for side_gain calculation in map_params_dirac_to_stereo() */
#define FIX_2505_IVAS_DEC_SEGFAULT                      /* FhG: BASOP #2505: Add headroom to input of ivas_rend_crendProcessSubframe_fx() for ivas_mdft_fx() calculation */
#define HARMONIZE_DoRTFTn                               /* VA: harmonize functions DoRTFTn_fx() and DoRTFTn_fx_ivas() */
#define FIX_1574_EFAP_CODE_LINT                         /* FhG: float issue 1574: Code quality fixes in ivas_efap.c */
#define FIX_BASOP_2529_MASA_RATIO_SCALINGS              /* Nokia: BASOP issue 2529: Fix MASA ratio scalings and verifications */
#define FIX_BASOP_2525_MASA_MERGE_WRONG_ASSIGN          /* Nokia: BASOP issue 2525: Fix wrong assignment in MASA merge code */
#define FIX_1576_LCLD_CRASH_DIFFERENT_CODEC_ISAR_FRAME_SIZE  /* Dolby: float issue 1576: fix for crash in LCLD mode when codec frame size is less than isar frame size */

/* ##################### End NON-BE switches ########################### */
+4 −0
Original line number Diff line number Diff line
@@ -4895,7 +4895,11 @@ static void gainFrSmooth_En_fx(
        IF( NE_32( st_fx->total_brate, ACELP_24k40 ) )
        {
#ifdef NONBE_FIX_ISSUE_2206_SWB_EXPERIMENT
#ifdef NONBE_FIX_ISSUE_2206_SWB_EXPERIMENT_FIX_2527
            Scale_sig( hBWE_TD->shb_inv_filt_mem_fx, LPC_SHB_ORDER, sub( shb_frame_q, hBWE_TD->shb_inv_filt_mem_q ) );
#else
            scale_sig( hBWE_TD->shb_inv_filt_mem_fx, LPC_SHB_ORDER, sub( shb_frame_q, hBWE_TD->shb_inv_filt_mem_q ) );
#endif
            hBWE_TD->shb_inv_filt_mem_q = shb_frame_q;
            move16();
#endif
+6 −0
Original line number Diff line number Diff line
@@ -110,6 +110,12 @@ ivas_error ivas_sba_get_hoa_dec_matrix_fx(
    ELSE IF( hOutSetup.is_loudspeaker_setup )
    {
        /* init EFIP */

#ifdef FIX_1574_EFAP_CODE_LINT
        /* ensure the handle is NULL before passing, otherwise efap_init_data will think this is allocated memory and return an error */
        hEFAP = NULL;
#endif

        IF( NE_16( ( error = efap_init_data_fx( &( hEFAP ), hOutSetup.ls_azimuth_fx, hOutSetup.ls_elevation_fx, num_spk, EFAP_MODE_EFIP ) ), IVAS_ERR_OK ) )
        {
            return error;
+86 −4
Original line number Diff line number Diff line
@@ -37,7 +37,9 @@
#include "prot_fx.h"
#include "ivas_prot_rend_fx.h"
#include "ivas_rom_rend.h"
#ifndef FIX_1574_EFAP_CODE_LINT
#include "ivas_stat_dec.h"
#endif
#include "wmc_auto.h"
#include "ivas_prot_fx.h"

@@ -60,6 +62,9 @@
#define Q22_180_DEG 754974720
#define Q22_360_DEG 1509949440
#define Q22_120_DEG 503316480
#ifdef FIX_1574_EFAP_CODE_LINT
#define MAX_AZI_GAP 13421773 /* (1.f / 160.0f) in Q31 */
#endif
#define Q22_240_DEG 1006632960

/*-----------------------------------------------------------------------*
@@ -86,7 +91,11 @@ static Word32 get_tri_gain_fx( const Word32 A[2] /*q22*/, const Word32 B[2] /*q2
 * EFAP Utils
 *-----------------------------------------------------------------------*/

#ifdef FIX_1574_EFAP_CODE_LINT
static void add_vertex_fx( EFAP_VERTEX *vtxArray, const Word32 azi /*q22*/, const Word32 ele /*q22*/, const Word16 pos, const EFAP_VTX_DMX_TYPE dmxType );
#else
static void add_vertex_fx( EFAP_VERTEX *vtxArray, const Word32 azi /*q22*/, const Word32 ele /*q22*/, const Word16 pos, const EFAP_VTX_DMX_TYPE );
#endif
static void efap_sort_s_fx( Word16 *x, Word16 *idx, const Word16 len );

static Word32 vertex_distance_fx( const EFAP_VERTEX *vtxArray, const EFAP_LS_TRIANGLE tri, const Word16 vtxIdx );
@@ -99,7 +108,11 @@ static Word16 get_neighbours_fx( const EFAP_LS_TRIANGLE *triArray, const Word16

static void matrix_times_row_fx( Word32 mat[EFAP_MAX_SIZE_TMP_BUFF][EFAP_MAX_SIZE_TMP_BUFF] /*q31*/, const Word32 *vec /*q31*/, const Word16 L, Word32 *out /*q31*/ );
static void tri_to_poly_fx( const EFAP_VERTEX *vtxArray, const EFAP_LS_TRIANGLE *triArray, const Word16 numVtx, const Word16 numTri, Word16 sortedChan[EFAP_MAX_POLY_SET][EFAP_MAX_CHAN_NUM], Word16 *outLengthPS, Word16 outLengthSorted[EFAP_MAX_POLY_SET] );
#ifdef FIX_1574_EFAP_CODE_LINT
static Word16 compare_poly_fx( Word16 *old_poly, Word16 lenOld, Word16 *new_poly, Word16 lenNew );
#else
static Word16 compare_poly_fx( Word16 *old, Word16 lenOld, Word16 *new, Word16 lenNew );
#endif

static void sort_channels_vertex_fx( const EFAP_VERTEX *vtxArray, const EFAP_LS_TRIANGLE *triArray, Word16 channels[EFAP_MAX_CHAN_NUM], const Word16 lengthChannels, Word16 idxTri );
static Word32 efap_32mod32( const Word32 x /*q22*/, const Word32 y /*q22*/ );
@@ -136,10 +149,22 @@ ivas_error efap_init_data_fx(
    move32();

/* Basic init checks */
#ifdef FIX_1574_EFAP_CODE_LINT
    IF( hEFAPdata == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "pointer to EFAP handle is NULL" );
    }
    IF( *hEFAPdata != NULL )
    {
        return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "EFAP handle must be NULL before initialization" );
    }
#endif
    test();
    IF( !speaker_node_azi_deg || !speaker_node_ele_deg )
    {
#ifndef FIX_1574_EFAP_CODE_LINT
        hEFAPdata = NULL;
#endif
        return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "EFAP requires arrays of speaker azimuths and elevations" );
    }

@@ -181,13 +206,21 @@ ivas_error efap_init_data_fx(
    /* Memory allocation for the polyset array */
    IF( ( efap->polyData.polysetArray = (EFAP_POLYSET *) malloc( polyset_size * sizeof( EFAP_POLYSET ) ) ) == NULL )
    {
#ifdef FIX_1574_EFAP_CODE_LINT
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for EFAP polygon array\n" ) );
#else
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for EFAP bufferS\n" ) );
#endif
    }

    /* Memory allocation for the triangle array */
    IF( ( efap->polyData.triArray = (EFAP_LS_TRIANGLE *) malloc( polyset_size * sizeof( EFAP_LS_TRIANGLE ) ) ) == NULL )
    {
#ifdef FIX_1574_EFAP_CODE_LINT
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for EFAP triangle array\n" ) );
#else
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for EFAP bufferS\n" ) );
#endif
    }

    /*-----------------------------------------------------------------*
@@ -354,10 +387,18 @@ void efap_free_data_fx(
    ( *hEFAPdata )->vtxData.vtxOrder = NULL;

    free( ( *hEFAPdata )->polyData.polysetArray );
#ifdef FIX_1574_EFAP_CODE_LINT
    ( *hEFAPdata )->polyData.polysetArray = NULL;
#else
    ( *hEFAPdata )->vtxData.vtxOrder = NULL;
#endif

    free( ( *hEFAPdata )->polyData.triArray );
#ifdef FIX_1574_EFAP_CODE_LINT
    ( *hEFAPdata )->polyData.triArray = NULL;
#else
    ( *hEFAPdata )->vtxData.vtxOrder = NULL;
#endif

    free( ( *hEFAPdata )->bufferLong_fx );
    ( *hEFAPdata )->bufferLong_fx = NULL;
@@ -634,11 +675,17 @@ static void initial_polyeder_fx(
    }

    /* 2. attempt to create a triangle with nonzero area */
#ifndef FIX_1574_EFAP_CODE_LINT
    tmp = 0;
    move32();
#endif
    v_sub_fx( vtxData->vertexArray[tetrahedron[1]].pos, vtxData->vertexArray[tetrahedron[0]].pos, tmp1, 3, 1 ); // tmp1 Q(31-1)
    WHILE( LT_16( tetrahedron[2], numVtx ) )
    {
#ifdef FIX_1574_EFAP_CODE_LINT
        tmp = 0;
        move32();
#endif
        v_sub_fx( vtxData->vertexArray[tetrahedron[2]].pos, vtxData->vertexArray[tetrahedron[0]].pos, tmp2, 3, 1 ); // tmp2 Q(31-1)
        efap_crossp_fx( tmp1, tmp2, tmpCross );                                                                     // tmpCross Q29
        FOR( i = 0; i < 3; i++ )
@@ -750,7 +797,9 @@ static void add_ghost_speakers_fx(
    Word16 lengthHorGhst;  /* Nb of Horizontal Ghost */
    Word16 i, j, k, a;     /* Integer for loops */
    Word16 num_new;        /* Number of new vertices to add */
#ifndef FIX_1574_EFAP_CODE_LINT
    Word32 maxAngle; /* Max azimuth tolerance for extend the LS setup horizontaly */
#endif
    Word32 newDiff; /* Angle differences that will help us set the extended LS setup */
    Word32 newAzi;  /* New azimuth for the new horizontal LS */
    Word32 ele[EFAP_MAX_SIZE_TMP_BUFF];
@@ -765,8 +814,10 @@ static void add_ghost_speakers_fx(
    move32();
    numVertex = *numVtx;
    move16();
#ifndef FIX_1574_EFAP_CODE_LINT
    maxAngle = 13421773; //(1.f / 160.0f) in Q31
    move32();
#endif

    /* Extracting Azi and Ele for computation purposes */
    FOR( i = 0; i < numVertex; ++i )
@@ -857,7 +908,11 @@ static void add_ghost_speakers_fx(
        a = add( a, 2 );
        lengthHorGhst = add( lengthHorGhst, 2 );
    }
#ifdef FIX_1574_EFAP_CODE_LINT
    ELSE /* fill gaps greater than MAX_AZI_GAP */
#else
    ELSE /* fill gaps greater than maxAngle */
#endif
    {
        /* Here, k correspond to the number of LS whose ele is < 45 deg, should be = numVertex */
        sort_l( tmpAzi, k ); // tmpAzi q22
@@ -867,7 +922,11 @@ static void add_ghost_speakers_fx(
        {
            tmpAngleDiff[i] = L_sub( tmpAzi[i + 1], tmpAzi[i] ); // q22
            move32();
#ifdef FIX_1574_EFAP_CODE_LINT
            sectors[i] = ceil_fx( Mpy_32_32( tmpAngleDiff[i], MAX_AZI_GAP ), Q22 ); // q22
#else
            sectors[i] = ceil_fx( Mpy_32_32( tmpAngleDiff[i], maxAngle ), Q22 ); // q22
#endif
            move32();

            if ( GT_32( sectors[i], Q22_1 /*1 q22*/ ) )
@@ -877,7 +936,11 @@ static void add_ghost_speakers_fx(
        }
        tmpAngleDiff[k - 1] = L_sub( L_add( tmpAzi[0], Q22_360_DEG /*360 q22*/ ), tmpAzi[k - 1] ); // q22

#ifdef FIX_1574_EFAP_CODE_LINT
        sectors[k - 1] = ceil_fx( Mpy_32_32( tmpAngleDiff[k - 1], MAX_AZI_GAP ), Q22 ); // q22
#else
        sectors[k - 1] = ceil_fx( Mpy_32_32( tmpAngleDiff[k - 1], maxAngle ), Q22 ); // q22
#endif

        if ( GT_32( sectors[k - 1], Q22_1 /*1 q22*/ ) )
        {
@@ -1257,7 +1320,11 @@ static void remap_ghosts_fx(
                {
                    IF( GT_16( triArray[i].LS[j], g ) )
                    {
#ifdef FIX_1574_EFAP_CODE_LINT
                        triArray[i].LS[j] = sub( triArray[i].LS[j], 1 );
#else
                        triArray[i].LS[j] = sub( g, 1 );
#endif
                        move16();
                    }
                }
@@ -2159,7 +2226,11 @@ static void tri_to_poly_fx(
    /* Output */
    *outLengthPS = lenPolySet;
    move16();
#ifdef FIX_1574_EFAP_CODE_LINT
    Copy( sortedLengths, outLengthSorted, lenPolySet );
#else
    Copy( sortedLengths, outLengthSorted, EFAP_MAX_POLY_SET );
#endif
    return;
}

@@ -2171,10 +2242,17 @@ static void tri_to_poly_fx(
 *-------------------------------------------------------------------------*/

static Word16 compare_poly_fx(
#ifdef FIX_1574_EFAP_CODE_LINT
    Word16 *old_poly, /* i  : Existing polygon            */
    Word16 lenOld,    /* i  : Length of existing polygon  */
    Word16 *new_poly, /* i  : New polygon                 */
    Word16 lenNew     /* i  : Length of new polygon       */
#else
    Word16 *old,   /* i  : Existing polygon            */
    Word16 lenOld, /* i  : Length of existing polygon  */
    Word16 *new,   /* i  : New polygon                 */
    Word16 lenNew  /* i  : Length of new polygon       */
#endif
)
{
    Word16 i, j;
@@ -2187,7 +2265,11 @@ static Word16 compare_poly_fx(
    {
        FOR( j = count; j < lenNew; ++j )
        {
#ifdef FIX_1574_EFAP_CODE_LINT
            IF( EQ_16( old_poly[i], new_poly[j] ) )
#else
            IF( EQ_16( old[i], new[j] ) )
#endif
            {
                count = add( count, 1 );
                BREAK;