Commit 41b03f2f authored by vaclav's avatar vaclav
Browse files

Merge remote-tracking branch 'remotes/origin/main' into FIX_FMSW_DEC

parents 02e21d6f 4cb9c948
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3133,7 +3133,7 @@ static ivas_error printBitstreamInfoVoip(
{
    bool previewFailed = true;
    ivas_error error = IVAS_ERR_OK;
    IVAS_RTP ivasRtp;
    IVAS_RTP ivasRtp = { 0 };
    uint8_t au[( IVAS_MAX_BITS_PER_FRAME + 7 ) >> 3];
    int16_t auSizeBits;
    uint8_t *auPtr = NULL;
+3 −0
Original line number Diff line number Diff line
@@ -163,13 +163,16 @@
#define NONBE_1122_KEEP_EVS_MODE_UNCHANGED              /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR.  */
#define FIX_FLOAT_1539_G192_FORMAT_SWITCH               /* Nokia: reintroduce format switching for g192 bitstreams */
#define FIX_1527_CMR_BITRATE_IDX                        /* Fix for incorrect bitrate idx packed in rtp CMR E-byte */
#define FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN            /* FhG: float issue 1560: Avoid optimizing the division on the result of maxWithSign() with -funsafe-math-optimizations */ 

/* #################### End BE switches ################################## */

/* #################### Start NON-BE switches ############################ */
/* any switch which is non-be wrt. TS 26.258 V3.0 */

#define USE_RTPDUMP                                     /* FhG: RTPDUMP format (rtptools standard) instead of custom format */
#define FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API            /* Expose Payload Type setting in RTP Header */
#define FIX_1574_EFAP_CODE_LINT                         /* FhG: issue 1574: Code quality fixes in ivas_efap.c */
#define FIX_FLOAT_1569_REND_RENDER_CONFIG_CHECKS        /* Nokia: float issue 1569: fix render config checks in renderer */
#define FIX_1571_BFI_COPY_ARRAY_CORRECT_LEN             /* FhG: issue 1571: use correct channel signal length for copying signal to buffer */
#define FIX_FMSW_DEC                                    /* float issue 1542: fix JBM issue in format switching */
+59 −0
Original line number Diff line number Diff line
@@ -272,7 +272,12 @@ static int16_t BidagonalDiagonalisation(
)
{
    int16_t kCh, nCh, iCh, jCh, split;
#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN
    volatile float c, s;
    float f1, f2;
#else
    float c, s, f1, f2;
#endif
    float g = 0.0f;
    int16_t convergence, iteration, found_split;
    int16_t error = 0;
@@ -385,9 +390,14 @@ static void ApplyQRTransform(
)
{
    int16_t ch, split;
#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN
    float d = 0.0f, g = 0.0f, r = 0.0f, x_ii = 0.0f, x_split = 0.0f, x_kk = 0.0f, aux = 0.0f;
    volatile float mu = 0.0f, c = 1.0f, s = 1.0f;
#else
    float d = 0.0f, g = 0.0f, r = 0.0f, x_ii = 0.0f, x_split = 0.0f, x_kk = 0.0f, mu = 0.0f, aux = 0.0f;
    float c = 1.0f;
    float s = 1.0f;
#endif

    x_kk = singularValues[currentIndex];
    x_ii = singularValues[startIndex];
@@ -525,10 +535,20 @@ static void biDiagonalReductionLeft(
    float *g )
{
    int16_t iCh, jCh;
#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN
    volatile float norm_x, r;
    volatile float f;
    volatile float g_loc;
#else
    float norm_x, f, r;
#endif

    /* Setting values to 0 */
#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN
    g_loc = 0.0f;
#else
    ( *g ) = 0.0f;
#endif

    if ( currChannel < nChannelsL ) /* i <= m */
    {
@@ -541,9 +561,15 @@ static void biDiagonalReductionLeft(

        if ( ( norm_x ) ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */
        {
#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN
            g_loc = -( singularVectors[currChannel][currChannel] >= 0 ? 1 : ( -1 ) ) * sqrtf( norm_x );
            r = g_loc * singularVectors[currChannel][currChannel] - norm_x;
            singularVectors[currChannel][currChannel] = ( singularVectors[currChannel][currChannel] - g_loc );
#else
            ( *g ) = -( singularVectors[currChannel][currChannel] >= 0 ? 1 : ( -1 ) ) * sqrtf( norm_x );
            r = ( *g ) * singularVectors[currChannel][currChannel] - norm_x;
            singularVectors[currChannel][currChannel] = ( singularVectors[currChannel][currChannel] - ( *g ) );
#endif

            for ( iCh = currChannel + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */
            {
@@ -564,6 +590,10 @@ static void biDiagonalReductionLeft(
        }
    }

#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN
    *g = g_loc;
#endif

    return;
}

@@ -582,10 +612,19 @@ static void biDiagonalReductionRight(
    float *g )
{
    int16_t iCh, jCh, idx;
#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN
    volatile float norm_x, r;
    volatile float g_loc;
#else
    float norm_x, r;
#endif

    /* Setting values to 0 */
#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN
    g_loc = 0.0f;
#else
    ( *g ) = 0.0f;
#endif

    if ( currChannel < nChannelsL && currChannel != ( nChannelsC - 1 ) ) /* i <=m && i !=n */
    {
@@ -600,9 +639,15 @@ static void biDiagonalReductionRight(

        if ( norm_x ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */
        {
#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN
            g_loc = -( singularVectors[currChannel][idx] >= 0 ? 1 : ( -1 ) ) * sqrtf( norm_x );
            r = g_loc * singularVectors[currChannel][idx] - norm_x;
            singularVectors[currChannel][idx] = ( singularVectors[currChannel][idx] - g_loc );
#else
            ( *g ) = -( singularVectors[currChannel][idx] >= 0 ? 1 : ( -1 ) ) * sqrtf( norm_x );
            r = ( *g ) * singularVectors[currChannel][idx] - norm_x;
            singularVectors[currChannel][idx] = ( singularVectors[currChannel][idx] - ( *g ) );
#endif

            for ( iCh = currChannel + 1; iCh < nChannelsL; iCh++ ) /*  nChannelsL */
            {
@@ -620,6 +665,10 @@ static void biDiagonalReductionRight(
        }
    }

#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN
    *g = g_loc;
#endif

    return;
}

@@ -638,7 +687,12 @@ static void singularVectorsAccumulationLeft(
{
    int16_t nCh, iCh, k;
    int16_t nChannels;
#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN
    float norm_y;
    volatile float t_jj, t_ii;
#else
    float norm_y, t_jj, t_ii;
#endif

    /* Processing */
    nChannels = min( nChannelsL, nChannelsC ); /* min(nChannelsL,ChannelsC) */
@@ -706,7 +760,12 @@ static void singularVectorsAccumulationRight(
{
    int16_t nCh, iCh, k;
    int16_t nChannels;
#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN
    float norm_y, t_ii;
    volatile float ratio;
#else
    float norm_y, t_ii, ratio;
#endif

    /* Processing */
    nChannels = nChannelsC; /* nChannelsC */
+4 −0
Original line number Diff line number Diff line
@@ -137,6 +137,10 @@ ivas_error ivas_sba_get_hoa_dec_matrix(
    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 ( ( error = efap_init_data( &( hEFAP ), hOutSetup.ls_azimuth, hOutSetup.ls_elevation, num_spk, EFAP_MODE_EFIP ) ) != IVAS_ERR_OK )
        {
            return error;
+88 −13
Original line number Diff line number Diff line
@@ -39,7 +39,9 @@
#include "ivas_prot.h"
#include "ivas_prot_rend.h"
#include "ivas_rom_rend.h"
#ifndef FIX_1574_EFAP_CODE_LINT
#include "ivas_stat_dec.h"
#endif
#ifdef DEBUGGING
#include "debug.h"
#endif
@@ -52,6 +54,9 @@
#define EFAP_MAX_SIZE_TMP_BUFF 30
#define EFAP_MAX_GHOST_LS      5 /* Maximum number of ghost Loudspeakers, for memory allocation purpose */
#define POLY_THRESH            1e-4f
#ifdef FIX_1574_EFAP_CODE_LINT
#define MAX_AZI_GAP ( 1.f / 160.f ) /* Max azimuth tolerance to extend the LS setup in the horizontal plane */
#endif
#ifdef DEBUG_EFAP_POLY_TOFILE
#define PANNING_AZI_RESOLUTION 2
#define PANNING_ELE_RESOLUTION 5
@@ -97,7 +102,11 @@ static void get_poly_select( EFAP_POLYSET_DATA *polyData );
 * EFAP Utils
 *-----------------------------------------------------------------------*/

#ifdef FIX_1574_EFAP_CODE_LINT
static void add_vertex( EFAP_VERTEX *vtxArray, const float azi, const float ele, const int16_t pos, const EFAP_VTX_DMX_TYPE dmxType );
#else
static void add_vertex( EFAP_VERTEX *vtxArray, const float azi, const float ele, const int16_t pos, const EFAP_VTX_DMX_TYPE );
#endif

static void efap_sort_s( int16_t *x, int16_t *idx, const int16_t len );

@@ -119,7 +128,11 @@ static void matrix_times_row( float mat[EFAP_MAX_SIZE_TMP_BUFF][EFAP_MAX_SIZE_TM

static void tri_to_poly( const EFAP_VERTEX *vtxArray, const EFAP_LS_TRIANGLE *triArray, const int16_t numVtx, const int16_t numTri, int16_t sortedChan[EFAP_MAX_POLY_SET][EFAP_MAX_CHAN_NUM], int16_t *outLengthPS, int16_t outLengthSorted[EFAP_MAX_POLY_SET] );

#ifdef FIX_1574_EFAP_CODE_LINT
static int16_t compare_poly( int16_t *old_poly, int16_t lenOld, int16_t *new_poly, int16_t lenNew );
#else
static int16_t compare_poly( int16_t *old, int16_t lenOld, int16_t *new, int16_t lenNew );
#endif

static void sort_channels_vertex( const EFAP_VERTEX *vtxArray, const EFAP_LS_TRIANGLE *triArray, int16_t channels[EFAP_MAX_CHAN_NUM], const int16_t lengthChannels, int16_t idxTri );

@@ -159,9 +172,21 @@ ivas_error efap_init_data(
    error = IVAS_ERR_OK;

    /* 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
    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" );
    }

@@ -202,13 +227,21 @@ ivas_error efap_init_data(
    /* 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
    }

    /*-----------------------------------------------------------------*
@@ -355,10 +388,18 @@ void efap_free_data(
    ( *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 );
    ( *hEFAPdata )->bufferLong = NULL;
@@ -501,12 +542,10 @@ static void get_poly_select(
    int16_t azi_index, ele_index;
    float P[2];

#ifdef DEBUG_EFAP_POLY_TOFILE
    /* Write polygon selection table to .csv file, modify filename according to selected loudspeaker layout! */
    static FILE *pF = NULL;
    if ( pF == NULL )
        pF = fopen( "./res/efap_poly_select_cicpX.csv", "w" );
#endif

    for ( azi_index = 0; azi_index <= ( 360 / PANNING_AZI_RESOLUTION ); azi_index++ )
    {
@@ -515,17 +554,13 @@ static void get_poly_select(
        {
            P[1] = (float) ( ( ele_index * PANNING_ELE_RESOLUTION ) - 90 );

#ifdef DEBUG_EFAP_POLY_TOFILE
            if ( pF != NULL )
                fprintf( pF, "%d,", get_poly_num( P, polyData ) );
#endif
        }
    }

#ifdef DEBUG_EFAP_POLY_TOFILE
    if ( pF != NULL )
        fclose( pF );
#endif

    return;
}
@@ -649,10 +684,15 @@ static void initial_polyeder(
    }

    /* 2. attempt to create a triangle with nonzero area */
#ifndef FIX_1574_EFAP_CODE_LINT
    tmp = 0.0f;
#endif
    v_sub( vtxData->vertexArray[tetrahedron[1]].pos, vtxData->vertexArray[tetrahedron[0]].pos, tmp1, 3 );
    while ( tetrahedron[2] < numVtx )
    {
#ifdef FIX_1574_EFAP_CODE_LINT // should be reset every loop iteration; happens to be BE
        tmp = 0.0f;
#endif
        v_sub( vtxData->vertexArray[tetrahedron[2]].pos, vtxData->vertexArray[tetrahedron[0]].pos, tmp2, 3 );
        efap_crossp( tmp1, tmp2, tmpCross );
        for ( i = 0; i < 3; i++ )
@@ -743,7 +783,9 @@ static void add_ghost_speakers(
    int16_t lengthHorGhst;      /* Nb of Horizontal Ghost */
    int16_t i, j, k, a;         /* Integer for loops */
    int16_t num_new;            /* Number of new vertices to add */
#ifndef FIX_1574_EFAP_CODE_LINT // use a static constant instead
    float maxAngle;             /* Max azimuth tolerance for extend the LS setup horizontaly */
#endif
    float newDiff; /* Angle differences that will help us set the extended LS setup */
    float newAzi;  /* New azimuth for the new horizontal LS */
    float ele[EFAP_MAX_SIZE_TMP_BUFF];
@@ -755,7 +797,9 @@ static void add_ghost_speakers(

    vtxDmxType = EFAP_DMX_INTENSITY;
    numVertex = *numVtx;
#ifndef FIX_1574_EFAP_CODE_LINT
    maxAngle = 1.f / 160.0f;
#endif

    /* Extracting Azi and Ele for computation purposes */
    for ( i = 0; i < numVertex; ++i )
@@ -838,7 +882,11 @@ static void add_ghost_speakers(
        a += 2;
        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 */
        v_sort( tmpAzi, 0, k - 1 );
@@ -847,7 +895,11 @@ static void add_ghost_speakers(
        for ( i = 0; i < k - 1; ++i )
        {
            tmpAngleDiff[i] = tmpAzi[i + 1] - tmpAzi[i];
#ifdef FIX_1574_EFAP_CODE_LINT
            sectors[i] = ceilf( tmpAngleDiff[i] * MAX_AZI_GAP );
#else
            sectors[i] = ceilf( tmpAngleDiff[i] * maxAngle );
#endif

            if ( sectors[i] > 1 )
            {
@@ -856,7 +908,11 @@ static void add_ghost_speakers(
        }
        tmpAngleDiff[k - 1] = tmpAzi[0] + 360 - tmpAzi[k - 1];

#ifdef FIX_1574_EFAP_CODE_LINT
        sectors[k - 1] = ceilf( tmpAngleDiff[k - 1] * MAX_AZI_GAP );
#else
        sectors[k - 1] = ceilf( tmpAngleDiff[k - 1] * maxAngle );
#endif

        if ( sectors[k - 1] > 1 )
        {
@@ -1187,7 +1243,11 @@ static void remap_ghosts(
                {
                    if ( triArray[i].LS[j] > g )
                    {
#ifdef FIX_1574_EFAP_CODE_LINT // g is the index being removed; happens to work since ghosts are always at the end of the array
                        triArray[i].LS[j]--;
#else
                        triArray[i].LS[j] = g - 1;
#endif
                    }
                }
            }
@@ -1931,7 +1991,11 @@ static void tri_to_poly(

    /* Output */
    *outLengthPS = lenPolySet;
#ifdef FIX_1574_EFAP_CODE_LINT // only move initialised members
    mvs2s( sortedLengths, outLengthSorted, lenPolySet );
#else
    mvs2s( sortedLengths, outLengthSorted, EFAP_MAX_POLY_SET );
#endif

    return;
}
@@ -1944,10 +2008,17 @@ static void tri_to_poly(
 *-------------------------------------------------------------------------*/

static int16_t compare_poly(
#ifdef FIX_1574_EFAP_CODE_LINT // avoid the variable name "new"
    int16_t *old_poly,         /* i  : Existing polygon            */
    int16_t lenOld,            /* i  : Length of existing polygon  */
    int16_t *new_poly,         /* i  : New polygon                 */
    int16_t lenNew             /* i  : Length of new polygon       */
#else
    int16_t *old,   /* i  : Existing polygon            */
    int16_t lenOld, /* i  : Length of existing polygon  */
    int16_t *new,   /* i  : New polygon                 */
    int16_t lenNew  /* i  : Length of new polygon       */
#endif
)
{
    int16_t i, j;
@@ -1959,7 +2030,11 @@ static int16_t compare_poly(
    {
        for ( j = count; j < lenNew; ++j )
        {
#ifdef FIX_1574_EFAP_CODE_LINT
            if ( old_poly[i] == new_poly[j] )
#else
            if ( old[i] == new[j] )
#endif
            {
                ++count;
                break;
Loading