Commit d248032c authored by Fabian Müller's avatar Fabian Müller
Browse files

Add CODE_IMPROVEMENTS define

parent 5dc8c9a8
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -154,6 +154,7 @@

/* ################## Start DEVELOPMENT switches ######################### */

#define CODE_IMPROVEMENTS                               /* Small code improvements that do not change the functionality */

/* ################### Start BE switches ################################# */
/* only BE switches wrt selection floating point code */
+16 −0
Original line number Diff line number Diff line
@@ -1742,9 +1742,25 @@ double anint(
int16_t is_numeric_float(
    float x )
{
#ifdef CODE_IMPROVEMENTS
#define WMC_TOOL_SKIP
    return (int16_t) ( !isnan( x ) && !isinf( x ) );
#undef WMC_TOOL_SKIP
#else
#ifndef BASOP_NOGLOB
    union float_int
#else  /* BASOP_NOGLOB */
    union float_int
#endif /* BASOP_NOGLOB */
    {
        float float_val;
        int32_t int_val;
    } float_int;

    float_int.float_val = x;

    return ( ( float_int.int_val & 0x7f800000 ) != 0x7f800000 );
#endif
}

/*-------------------------------------------------------------------*
+6 −0
Original line number Diff line number Diff line
@@ -163,9 +163,15 @@ const float ap_lattice_coeffs_3[DIRAC_DECORR_FILTER_LEN_3*DIRAC_MAX_NUM_DECORR_F

const float * const ap_lattice_coeffs[DIRAC_DECORR_NUM_SPLIT_BANDS] =
{
#ifdef CODE_IMPROVEMENTS
    ap_lattice_coeffs_1,
    ap_lattice_coeffs_2,
    ap_lattice_coeffs_3,
#else
    &ap_lattice_coeffs_1[0],
    &ap_lattice_coeffs_2[0],
    &ap_lattice_coeffs_3[0],
#endif
};

const float ap_split_frequencies[DIRAC_DECORR_NUM_SPLIT_BANDS + 1] =
+56 −1
Original line number Diff line number Diff line
@@ -3291,6 +3291,7 @@ static ivas_error getConstInputById(
    return IVAS_ERR_OK;
}

#ifdef CODE_IMPROVEMENTS
static void *getInputByIndex(
    void *inputsArray,
    const size_t index,
@@ -3312,30 +3313,56 @@ static void *getInputByIndex(
            return NULL;
    }
}
#endif

static ivas_error findFreeInputSlot(
#ifdef CODE_IMPROVEMENTS
    void *inputs,
    const IVAS_REND_AudioConfigType inputType,
#else
    const void *inputs,
    const int32_t inputStructSize,
#endif
    const int32_t maxInputs,
    int32_t *inputIndex )
{
#ifdef CODE_IMPROVEMENTS
    /* Using a void pointer and a separately provided type is a hack for this function
       to be reusable for arrays of any input type (input_ism, input_mc, input_sba, input_masa).
        Assumptions:
            - input_base is always the first member in the input struct
            - memory alignments of original input type and input_base are the same
    */
#else
    /* Using a void pointer and a separately provided size is a hack for this function
       to be reusable for arrays of any input type (input_ism, input_mc, input_sba, input_masa).
        Assumptions:
            - input_base is always the first member in the input struct
            - provided size is correct
    */
#endif

    int32_t i;
    bool canAddInput;
#ifndef CODE_IMPROVEMENTS
    const uint8_t *pByte;
#endif
    const input_base *pInputBase;

    canAddInput = false;

    /* Find first unused input in array */
#ifdef CODE_IMPROVEMENTS
    for ( i = 0; i < maxInputs; ++i )
#else
    for ( i = 0, pByte = inputs; i < maxInputs; ++i, pByte += inputStructSize )
#endif
    {
#ifdef CODE_IMPROVEMENTS
        pInputBase = (const input_base *) getInputByIndex( inputs, i, inputType );
#else
        pInputBase = (const input_base *) pByte;
#endif

        if ( pInputBase->inConfig == IVAS_AUDIO_CONFIG_INVALID )
        {
@@ -3477,7 +3504,11 @@ ivas_error IVAS_REND_AddInput(
    ivas_error error;
    int32_t maxNumInputsOfType;
    void *inputsArray;
#ifdef CODE_IMPROVEMENTS
    IVAS_REND_AudioConfigType inputType;
#else
    int32_t inputStructSize;
#endif
    ivas_error ( *activateInput )( void *, AUDIO_CONFIG, IVAS_REND_InputId, RENDER_CONFIG_DATA *, hrtf_handles * );
    int32_t inputIndex;

@@ -3498,27 +3529,43 @@ ivas_error IVAS_REND_AddInput(
        }
    }

#ifdef CODE_IMPROVEMENTS
    inputType = getAudioConfigType( inConfig );
    switch ( inputType )
#else
    switch ( getAudioConfigType( inConfig ) )
#endif
    {
        case IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED:
            maxNumInputsOfType = RENDERER_MAX_ISM_INPUTS;
            inputsArray = hIvasRend->inputsIsm;
#ifndef CODE_IMPROVEMENTS
            inputStructSize = sizeof( *hIvasRend->inputsIsm );
#endif
            activateInput = setRendInputActiveIsm;
            break;
        case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED:
            maxNumInputsOfType = RENDERER_MAX_MC_INPUTS;
            inputsArray = hIvasRend->inputsMc;
#ifndef CODE_IMPROVEMENTS
            inputStructSize = sizeof( *hIvasRend->inputsMc );
#endif
            activateInput = setRendInputActiveMc;
            break;
        case IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS:
            maxNumInputsOfType = RENDERER_MAX_SBA_INPUTS;
            inputsArray = hIvasRend->inputsSba;
#ifndef CODE_IMPROVEMENTS
            inputStructSize = sizeof( *hIvasRend->inputsSba );
#endif
            activateInput = setRendInputActiveSba;
            break;
        case IVAS_REND_AUDIO_CONFIG_TYPE_MASA:
            maxNumInputsOfType = RENDERER_MAX_MASA_INPUTS;
            inputsArray = hIvasRend->inputsMasa;
#ifndef CODE_IMPROVEMENTS
            inputStructSize = sizeof( *hIvasRend->inputsMasa );
#endif
            activateInput = setRendInputActiveMasa;
            break;
        default:
@@ -3526,13 +3573,21 @@ ivas_error IVAS_REND_AddInput(
    }

        /* Find first free input in array corresponding to input type */
#ifdef CODE_IMPROVEMENTS
    if ( ( error = findFreeInputSlot( inputsArray, inputType, maxNumInputsOfType, &inputIndex ) ) != IVAS_ERR_OK )
#else
    if ( ( error = findFreeInputSlot( inputsArray, inputStructSize, maxNumInputsOfType, &inputIndex ) ) != IVAS_ERR_OK )
#endif
    {
        return error;
    }

    *inputId = makeInputId( inConfig, inputIndex );
#ifdef CODE_IMPROVEMENTS
    if ( ( error = activateInput( getInputByIndex( inputsArray, inputIndex, inputType ), inConfig, *inputId, hIvasRend->hRendererConfig, &hIvasRend->hHrtfs ) ) != IVAS_ERR_OK )
#else
    if ( ( error = activateInput( (uint8_t *) inputsArray + inputStructSize * inputIndex, inConfig, *inputId, hIvasRend->hRendererConfig, &hIvasRend->hHrtfs ) ) != IVAS_ERR_OK )
#endif
    {
        return error;
    }
+5 −0
Original line number Diff line number Diff line
@@ -67,8 +67,13 @@ typedef enum _G192_ERROR
 *-----------------------------------------------------------------------*/

/* main handle */
#ifdef CODE_IMPROVEMENTS
struct G192_STRUCT;
typedef struct G192_STRUCT *G192_HANDLE;
#else
struct __G192;
typedef struct __G192 *G192_HANDLE;
#endif


/*-----------------------------------------------------------------------*
Loading