Commit b0f4b839 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'ivas_render_inputMC_fxd' into 'main'

renderInputMC functions converted to fixed point.

See merge request !192
parents fb8f3da9 de3dba04
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1544,6 +1544,7 @@ typedef enum
#define HRTF_NUM_BINS                           60
#define REVERB_PREDELAY_MAX                     20                          /* Max input delay for reverb module */
#define GAIN_LFE                                1.88364911f                 /* Gain applied to LFE during renderering */
#define GAIN_LFE_WORD32                         2022552831                 /* Gain applied to LFE during renderering */
#ifdef IVAS_FLOAT_FIXED
#define GAIN_LFE_FX                             30862                 /* Gain applied to LFE during renderering */
#endif // IVAS_FLOAT_FIXED
+107 −3
Original line number Diff line number Diff line
@@ -943,7 +943,114 @@ ivas_error ivas_td_binaural_open_ext(
    return ivas_td_binaural_open_unwrap( &pTDRend->hHrtfTD, outFs, nchan_transport, ivas_format, transport_config, directivity, hTransSetup, &pTDRend->hBinRendererTd, &pTDRend->binaural_latency_ns );
}

#ifdef IVAS_FLOAT_FIXED
/*---------------------------------------------------------------------*
 * ivas_td_binaural_renderer_ext()
 *
 * Receives the current frames for the object streams, updates metadata
 * and renders the current frame.
 *---------------------------------------------------------------------*/

ivas_error ivas_td_binaural_renderer_ext_fx(
    const TDREND_WRAPPER *pTDRend,                               /* i  : TD Renderer wrapper structure           */
    const AUDIO_CONFIG inConfig,                                 /* i  : Input audio configuration               */
    const LSSETUP_CUSTOM_STRUCT *customLsInput,                  /* i  : Input custom loudspeaker layout         */
    const COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData, /* i  : Combined head and external orientations */
    const IVAS_ISM_METADATA *currentPos,                         /* i  : Object position                         */
    const REVERB_HANDLE hReverb,                                 /* i  : Reverberator handle                     */
    const Word16 ism_md_subframe_update_ext,                    /* i  : Metadata Delay in subframes to sync with audio delay */
    const Word32 output_Fs,                                     /* i  : output sampling rate                                    */
    const Word16 output_frame,                                  /* i  : output frame length                     */
    Word32 output[][L_FRAME48k],                                   /* i/o: SCE channels / Binaural synthesis       */
    Word16 exp
)
{
    ISM_METADATA_FRAME hIsmMetaDataFrame;
    ISM_METADATA_HANDLE hIsmMetaData[1];
    Word16 lfe_idx;
    Word16 num_src;
    IVAS_FORMAT ivas_format;
    IVAS_REND_AudioConfigType inConfigType;
    AUDIO_CONFIG transport_config;
    ivas_error error;
    float *p_output[MAX_OUTPUT_CHANNELS];
    float output_fl[MAX_OUTPUT_CHANNELS][L_FRAME48k];
    Word16 ch,j;
    /*This intermediate conversion will be removed once the subfunctions are also converted to fixed*/
    for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ )
    {
        for ( j = 0; j < L_FRAME48k ;j++)
        {
          output_fl[ch][j] = (float)output[ch][j]/(1<<exp);
        }
    }
    for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ )
    {
        p_output[ch] = output_fl[ch];
    }

    push_wmops( "ivas_td_binaural_renderer_ext" );

    inConfigType = getAudioConfigType( inConfig );
    lfe_idx = LFE_CHANNEL;
    hIsmMetaData[0] = NULL;


    IF ( EQ_32(inConfigType , IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED) )
    {
        ivas_format = MC_FORMAT;
        transport_config = inConfig;

        IF ( NE_32(inConfig , IVAS_AUDIO_CONFIG_LS_CUSTOM) )
        {
            IF ( ( error = getAudioConfigNumChannels( inConfig, &num_src ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }
        ELSE
        {
            lfe_idx = ( customLsInput->num_lfe > 0 ) ? customLsInput->lfe_idx[0] : -1;
            num_src = add(customLsInput->num_spk , customLsInput->num_lfe);
        }
    }
    ELSE
    {
        ivas_format = ISM_FORMAT;
        num_src = 1;
        transport_config = IVAS_AUDIO_CONFIG_ISM1;
        hIsmMetaData[0] = &hIsmMetaDataFrame;
        hIsmMetaData[0]->azimuth = currentPos->azimuth;
        hIsmMetaData[0]->elevation = currentPos->elevation;
        hIsmMetaData[0]->yaw = currentPos->yaw;
        hIsmMetaData[0]->pitch = currentPos->pitch;
        hIsmMetaData[0]->radius = currentPos->radius;
        hIsmMetaData[0]->non_diegetic_flag = currentPos->non_diegetic_flag;
    }

    IF ( ( error = ivas_td_binaural_renderer_unwrap( hReverb, transport_config, pTDRend->hBinRendererTd, num_src, lfe_idx, ivas_format, hIsmMetaData, *hCombinedOrientationData,
                                                     ism_md_subframe_update_ext, p_output, output_frame, (int16_t) ( ( output_frame * FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) / output_Fs ) ) ) != IVAS_ERR_OK )
    {
        return error;
    }
    IF ( hReverb != NULL)
    {
        exp = sub(exp , 2);
    }
    /*This intermediate conversion will be removed once the subfunctions are also converted to fixed*/
    for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ )
    {
        for ( j = 0; j < L_FRAME48k; j++ )
        {
            output[ch][j] = (Word32) output_fl[ch][j] *( 1 << (exp)) ;
        }
    }
    pop_wmops();

    return IVAS_ERR_OK;
}

#endif
/*---------------------------------------------------------------------*
 * ivas_td_binaural_renderer_ext()
 *
@@ -974,7 +1081,6 @@ ivas_error ivas_td_binaural_renderer_ext(
    ivas_error error;
    float *p_output[MAX_OUTPUT_CHANNELS];
    int16_t ch;

    for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ )
    {
        p_output[ch] = output[ch];
@@ -1030,8 +1136,6 @@ ivas_error ivas_td_binaural_renderer_ext(
}




/*---------------------------------------------------------------------*
 * angles_to_vec()
 *
+14 −0
Original line number Diff line number Diff line
@@ -867,6 +867,20 @@ ivas_error ivas_td_binaural_renderer_ext(
    float output[][L_FRAME48k]                                  /* i/o: SCE channels / Binaural synthesis       */
);
#ifdef IVAS_FLOAT_FIXED
ivas_error ivas_td_binaural_renderer_ext_fx(
    const TDREND_WRAPPER *pTDRend,                              /* i  : TD Renderer wrapper structure           */
    const AUDIO_CONFIG inConfig,                                /* i  : Input audio configuration               */
    const LSSETUP_CUSTOM_STRUCT *customLsInput,                 /* i  : Input custom loudspeaker layout         */
    const COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData,/* i  : Combined head and external orientations */
    const IVAS_ISM_METADATA *currentPos,                        /* i  : Object position                         */
    const REVERB_HANDLE hReverb,                                /* i  : Reverberator handle                     */
    const Word16 ism_md_subframe_update_ext,                   /* i  : Metadata Delay in subframes to sync with audio delay */
    const Word32 output_Fs,                                    /* i  : output sampling rate                    */
    const Word16 output_frame,                                 /* i  : output frame length                     */
    Word32 output[][L_FRAME48k],                                  /* i/o: SCE channels / Binaural synthesis       */
    Word16 exp
);

ivas_error ivas_td_binaural_open_unwrap_fx(
    TDREND_HRFILT_FiltSet_t **hHrtfTD,                          /* i/o: HR filter model (from file or NULL)     */
    const Word32 output_Fs,                                    /* i  : Output sampling rate                    */
+4 −4
Original line number Diff line number Diff line
@@ -893,10 +893,10 @@ const Word32 ls_conversion_cicpX_stereo_fx[12][2] = // Q30
    {0, 858993408},
    {858993408, 0},
    {0, 858993408},
    {858993408, 0},
    {0, 858993408},
    {858993408, 0},
    {0, 858993408}
    {912680512, 0},
    {0, 912680512},
    {912680512, 0},
    {0, 912680512}
};

const LS_CONVERSION_MATRIX_FX ls_conversion_cicp12_cicp6_fx[] = // Q30
+1 −1
Original line number Diff line number Diff line
@@ -1936,7 +1936,7 @@ typedef struct ivas_LS_setupconversion_struct
#ifdef IVAS_FLOAT_FIXED
typedef struct ivas_LS_setupconversion_matrix_fx
{
    int16_t index;
    Word16 index;
    Word32 value;
} LS_CONVERSION_MATRIX_FX;

Loading