Commit 4630e350 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'ivas_dirac_dec_binaural_determine_processing_matrices_fxd' into 'main'

ivas_dirac_dec_binaural_determine_processing_matrices: converted to fixed point

See merge request !369
parents ed7137ca 30ac07db
Loading
Loading
Loading
Loading
+721 −399

File changed.

Preview size limit exceeded, changes collapsed.

+12 −0
Original line number Diff line number Diff line
@@ -319,7 +319,19 @@ const float diffuseFieldCoherenceDifferenceZ[BINAURAL_COHERENCE_DIFFERENCE_BINS]
{
    0.048207f, 0.10796f, 0.11845f, 0.047886f, 0.035917f, 0.045196f, 0.018863f, 0.015547f, 0.014157f
};
#ifdef IVAS_FLOAT_FIXED
const Word32 diffuseFieldCoherenceDifferenceX_fx[BINAURAL_COHERENCE_DIFFERENCE_BINS] = { /* Q31 */
    101835824, 424621952, 484944768, 228427840, 18706944, 25829934, 68659344, 42236708, 17164408,
};

const Word32 diffuseFieldCoherenceDifferenceY_fx[BINAURAL_COHERENCE_DIFFERENCE_BINS] = { /* Q31 */
    -205359568, -656464256, -739314176, -331249344, -95837904, -122887608, -109167328, -75621488, -47566764,
};

const Word32 diffuseFieldCoherenceDifferenceZ_fx[BINAURAL_COHERENCE_DIFFERENCE_BINS] = { /* Q31 */
    103523744, 231842336, 254369440, 102834400, 77131168, 97057672, 40507984, 33386928, 30401926,
};
#endif

/*----------------------------------------------------------------------------------*
 * TD ISM binaural renderer ROM tables
+5 −0
Original line number Diff line number Diff line
@@ -99,6 +99,11 @@ extern const Word32 lowBitRateBinauralEQ_fx[LOW_BIT_RATE_BINAURAL_EQ_BINS];
extern const float diffuseFieldCoherenceDifferenceX[BINAURAL_COHERENCE_DIFFERENCE_BINS];
extern const float diffuseFieldCoherenceDifferenceY[BINAURAL_COHERENCE_DIFFERENCE_BINS];
extern const float diffuseFieldCoherenceDifferenceZ[BINAURAL_COHERENCE_DIFFERENCE_BINS];
#ifdef IVAS_FLOAT_FIXED
extern const Word32 diffuseFieldCoherenceDifferenceX_fx[BINAURAL_COHERENCE_DIFFERENCE_BINS];
extern const Word32 diffuseFieldCoherenceDifferenceY_fx[BINAURAL_COHERENCE_DIFFERENCE_BINS];
extern const Word32 diffuseFieldCoherenceDifferenceZ_fx[BINAURAL_COHERENCE_DIFFERENCE_BINS];
#endif // IVAS_FLOAT_FIXED


/*----------------------------------------------------------------------------------*
+12 −1
Original line number Diff line number Diff line
@@ -874,6 +874,7 @@ typedef struct ivas_diffuse_distribution_data_structure
/* Parametric binaural data structure */
typedef struct ivas_dirac_dec_binaural_data_structure
{
#ifndef IVAS_FLOAT_FIXED
    float ChEnePrev[BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX];
    float ChCrossRePrev[CLDFB_NO_CHANNELS_MAX];
    float ChCrossImPrev[CLDFB_NO_CHANNELS_MAX];
@@ -895,13 +896,16 @@ typedef struct ivas_dirac_dec_binaural_data_structure
    float diffuseFieldCoherenceY[BINAURAL_COHERENCE_DIFFERENCE_BINS];
    float diffuseFieldCoherenceZ[BINAURAL_COHERENCE_DIFFERENCE_BINS];
    float earlyPartEneCorrection[CLDFB_NO_CHANNELS_MAX];
#endif
    REVERB_STRUCT_HANDLE hReverb;
    uint8_t renderStereoOutputInsteadOfBinaural;
#ifndef IVAS_FLOAT_FIXED
    float frameMeanDiffuseness[CLDFB_NO_CHANNELS_MAX];
    float processMtxRePrev[BINAURAL_CHANNELS][BINAURAL_CHANNELS + MAX_NUM_OBJECTS][CLDFB_NO_CHANNELS_MAX];
    float processMtxImPrev[BINAURAL_CHANNELS][BINAURAL_CHANNELS + MAX_NUM_OBJECTS][CLDFB_NO_CHANNELS_MAX];
    float processMtxDecRePrev[BINAURAL_CHANNELS][BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX];
    float processMtxDecImPrev[BINAURAL_CHANNELS][BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX];
#endif
#ifdef IVAS_FLOAT_FIXED
    Word32 earlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX];
    Word16 q_earlyPartEneCorrection;
@@ -914,6 +918,13 @@ typedef struct ivas_dirac_dec_binaural_data_structure
    Word16 processMtxDecRePrev_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX];
    Word16 processMtxDecImPrev_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX];

    Word16 q_processMtx;
    Word16 q_processMtxSCCR;
    Word16 q_processMtxPrev;
    Word16 q_processMtxPrevSCCR;
    Word16 q_processMtxDec;
    Word16 q_processMtxDecPrev;

    Word32 ChEnePrev_fx[BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX];
    Word32 ChCrossRePrev_fx[CLDFB_NO_CHANNELS_MAX];
    Word32 ChCrossImPrev_fx[CLDFB_NO_CHANNELS_MAX];
@@ -2191,8 +2202,8 @@ typedef struct ivas_hrtfs_parambin_struct
#ifndef IVAS_FLOAT_FIXED
    float parametricReverberationTimes[CLDFB_NO_CHANNELS_MAX];
    float parametricReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX];
#endif
    float parametricEarlyPartEneCorrection[CLDFB_NO_CHANNELS_MAX];
#endif
#ifdef IVAS_FLOAT_FIXED
    Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX];          /* Q31 */
    Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */
+16 −29
Original line number Diff line number Diff line
@@ -5253,11 +5253,6 @@ static ivas_error setRendInputActiveMasa(
    }
#if 1 /*TODO: To be removed later(fixed to float)*/
    IF( inputMasa->hMasaExtRend )
    {
        IF( inputMasa->hMasaExtRend->hDiracDecBin )
        fixedToFloat_arrL( inputMasa->hMasaExtRend->hDiracDecBin->earlyPartEneCorrection_fx, inputMasa->hMasaExtRend->hDiracDecBin->earlyPartEneCorrection, (Word16) Q28 /*1.0f Q28*/, (Word16) CLDFB_NO_CHANNELS_MAX );
    }
    inputMasa->base.inputBuffer.data = inputMasa->bufferData;
    fixedToFloat_arrL( inputMasa->base.inputBuffer.data_fx, inputMasa->base.inputBuffer.data, 0, MAX_BUFFER_LENGTH ); /*fixed to float only for set zero(that's why q0)*/
#endif
@@ -14119,40 +14114,34 @@ static ivas_error ivas_masa_ext_rend_parambin_init(
    {
        FOR( k = 0; k < BINAURAL_CHANNELS + MAX_NUM_OBJECTS; k++ )
        {
#if 1 /*To be removed later(floating buffer init)*/
            set_zero( hDiracDecBin->processMtxRe[j][k], nBins );
            set_zero( hDiracDecBin->processMtxIm[j][k], nBins );
#endif
            set16_fx( hDiracDecBin->processMtxRe_fx[j][k], 0, nBins );
            set16_fx( hDiracDecBin->processMtxIm_fx[j][k], 0, nBins );
        }
        FOR( k = 0; k < BINAURAL_CHANNELS; k++ )
        {
#if 1 /*To be removed later(floating buffer init)*/
            set_zero( hDiracDecBin->processMtxDecRe[j][k], nBins );
            set_zero( hDiracDecBin->processMtxDecIm[j][k], nBins );
#endif
            set16_fx( hDiracDecBin->processMtxDecRe_fx[j][k], 0, nBins );
            set16_fx( hDiracDecBin->processMtxDecIm_fx[j][k], 0, nBins );
        }
#if 1 /*TODO:To be removed later(floating buffer init)*/
        set_zero( hDiracDecBin->ChEnePrev[j], nBins );
        set_zero( hDiracDecBin->ChEneOutPrev[j], nBins );
#endif
        hDiracDecBin->q_processMtx = Q15;
        hDiracDecBin->q_processMtxSCCR = Q15;
        hDiracDecBin->q_processMtxPrev = Q15;
        hDiracDecBin->q_processMtxPrevSCCR = Q15;
        hDiracDecBin->q_processMtxDec = Q15;
        hDiracDecBin->q_processMtxDecPrev = Q15;
        set_zero_fx( hDiracDecBin->ChEnePrev_fx[j], nBins );
        set_zero_fx( hDiracDecBin->ChEneOutPrev_fx[j], nBins );
        set16_fx( hDiracDecBin->ChEnePrev_e[j], 0, nBins );
        set16_fx( hDiracDecBin->ChEneOutPrev_e[j], 0, nBins );
    }
#if 1 /*TODO:To be removed later(floating buffer init)*/
    set_zero( hDiracDecBin->ChCrossRePrev, nBins );
    set_zero( hDiracDecBin->ChCrossImPrev, nBins );
    set_zero( hDiracDecBin->ChCrossReOutPrev, nBins );
    set_zero( hDiracDecBin->ChCrossImOutPrev, nBins );
#endif
    set_zero_fx( hDiracDecBin->ChCrossRePrev_fx, nBins );
    set_zero_fx( hDiracDecBin->ChCrossImPrev_fx, nBins );
    set_zero_fx( hDiracDecBin->ChCrossReOutPrev_fx, nBins );
    set_zero_fx( hDiracDecBin->ChCrossImOutPrev_fx, nBins );
    set16_fx( hDiracDecBin->ChCrossRePrev_e, 0, nBins );
    set16_fx( hDiracDecBin->ChCrossImPrev_e, 0, nBins );
    set16_fx( hDiracDecBin->ChCrossReOutPrev_e, 0, nBins );
    set16_fx( hDiracDecBin->ChCrossImOutPrev_e, 0, nBins );
    hDiracDecBin->renderStereoOutputInsteadOfBinaural = 0;
    FOR( bin = 0; bin < nBins; bin++ )
@@ -14168,15 +14157,10 @@ static ivas_error ivas_masa_ext_rend_parambin_init(
        tmpFloat_fx = s_max( 0, sub( shl_sat( 1, 15 - tmp_e ), tmp ) ) /*max( 0.0f, 1.0f - binCenterFreq / 2700.0f )*/;                                                                   /*Q30*/
        tmp2 = extract_l( Mult_32_32( binCenterFreq_fx, 1952258 /*=2^31*180/(550)/360*/ ) % 32767 );                                                                                      //*binCenterFreq_fx * EVS_PI / 550.0f*/
        hDiracDecBin->diffuseFieldCoherence_fx[bin] = L_shl( L_mult0( divide3232( tmpFloat_fx, Mult_32_16( binCenterFreq_fx, 187 /*2^15*pi/550*/ ) ), getSineWord16R2( tmp2 ) ), tmp_e ); /*tmpFloat * sinf( binCenterFreq * EVS_PI / 550.0f ) / ( binCenterFreq * EVS_PI / 550.0f );*/
        hDiracDecBin->diffuseFieldCoherence[bin] = fixedToFloat( hDiracDecBin->diffuseFieldCoherence_fx[bin], Q30 );
        hDiracDecBin->diffuseFieldCoherence_fx[bin] = L_shl( hDiracDecBin->diffuseFieldCoherence_fx[bin], 1 );                                                                            // Q31
    }
    /* No SPAR in external renderer so set directive diffuse field coherence tables to zero */
#if 1 /*TODO: To be removed later(floating buffer init)*/
    set_zero( hDiracDecBin->diffuseFieldCoherenceX, BINAURAL_COHERENCE_DIFFERENCE_BINS );
    set_zero( hDiracDecBin->diffuseFieldCoherenceY, BINAURAL_COHERENCE_DIFFERENCE_BINS );
    set_zero( hDiracDecBin->diffuseFieldCoherenceZ, BINAURAL_COHERENCE_DIFFERENCE_BINS );
#endif
    set_zero_fx( hDiracDecBin->diffuseFieldCoherenceX_fx, BINAURAL_COHERENCE_DIFFERENCE_BINS );
    set_zero_fx( hDiracDecBin->diffuseFieldCoherenceY_fx, BINAURAL_COHERENCE_DIFFERENCE_BINS );
    set_zero_fx( hDiracDecBin->diffuseFieldCoherenceZ_fx, BINAURAL_COHERENCE_DIFFERENCE_BINS );
@@ -14184,11 +14168,13 @@ static ivas_error ivas_masa_ext_rend_parambin_init(
    IF( EQ_16( renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) /* Indication of binaural rendering without room effect */
    {
        set32_fx( hDiracDecBin->earlyPartEneCorrection_fx, ONE_IN_Q28 /*1.0f Q28*/, CLDFB_NO_CHANNELS_MAX );
        hDiracDecBin->q_earlyPartEneCorrection = Q28;
        hDiracDecBin->hReverb = NULL;
    }
    ELSE IF( EQ_16( renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) /* Indication of binaural rendering with room effect */
    {
        Copy32( hHrtfParambin->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins );
        hDiracDecBin->q_earlyPartEneCorrection = Q28;
        IF( hDiracDecBin->hReverb == NULL )
        {
@@ -14202,6 +14188,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init(
    ELSE IF( EQ_16( renderer_type, RENDERER_STEREO_PARAMETRIC ) )
    {
        set32_fx( hDiracDecBin->earlyPartEneCorrection_fx, ONE_IN_Q28 /*1.0f Q28*/, CLDFB_NO_CHANNELS_MAX );
        hDiracDecBin->q_earlyPartEneCorrection = Q28;
        hDiracDecBin->hReverb = NULL;
        hDiracDecBin->renderStereoOutputInsteadOfBinaural = 1;
    }
Loading