Commit d7ce40a1 authored by Arash Azizi's avatar Arash Azizi
Browse files

Merge branch...

Merge branch 'basop-2389-harmonize-readtnsdata_ivas_fx-readtnsdata_fx-and-decodetnsdata_ivas_fx-decodetnsdata' of https://forge.3gpp.org/rep/sa4/audio/ivas-basop into basop-2389-harmonize-readtnsdata_ivas_fx-readtnsdata_fx-and-decodetnsdata_ivas_fx-decodetnsdata
parents 0e5d78f2 cf7f073c
Loading
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ void Copy_Quat_fx(


/*-------------------------------------------------------------------------
 * Scale_Quat_fx()
 * modify_Quat_q_fx()
 *
 * Quaternion q factor modification
 *------------------------------------------------------------------------*/
@@ -124,10 +124,18 @@ void modify_Quat_q_fx(
    Word16 q_new                    /* i  : quaternion describing the rotation             */
)
{
#ifdef FIX_BASOP_2361_OTR
    Word16 shift = sub( q_new, in_quat->q_fact );
    out_quat->w_fx = L_shl_sat( in_quat->w_fx, shift ); // q_new
    out_quat->x_fx = L_shl_sat( in_quat->x_fx, shift ); // q_new
    out_quat->y_fx = L_shl_sat( in_quat->y_fx, shift ); // q_new
    out_quat->z_fx = L_shl_sat( in_quat->z_fx, shift ); // q_new
#else
    out_quat->w_fx = L_shl_sat( in_quat->w_fx, sub( q_new, in_quat->q_fact ) ); // q_new
    out_quat->x_fx = L_shl_sat( in_quat->x_fx, sub( q_new, in_quat->q_fact ) ); // q_new
    out_quat->y_fx = L_shl_sat( in_quat->y_fx, sub( q_new, in_quat->q_fact ) ); // q_new
    out_quat->z_fx = L_shl_sat( in_quat->z_fx, sub( q_new, in_quat->q_fact ) ); // q_new
#endif
    out_quat->q_fact = q_new;
    return;
}
@@ -147,12 +155,19 @@ void modify_Rmat_q_fx(
)
{
    Word16 j, k;
#ifdef FIX_BASOP_2361_OTR
    Word16 shift = sub( q_new, q_cur );
#endif

    FOR( j = 0; j < 3; j++ )
    {
        FOR( k = 0; k < 3; k++ )
        {
#ifdef FIX_BASOP_2361_OTR
            Rmat_out[j][k] = L_shl( Rmat_in[j][k], shift );
#else
            Rmat_out[j][k] = L_shl( Rmat_in[j][k], sub( q_new, q_cur ) );
#endif
            move32();
        }
    }
+2 −0
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@
#define FIX_2383_INIT_Q_A_ITF                           /* FhG: Initialize Q_A_itf, to avoid reading of uninitialized memory in case ITF is not triggered */
#define FIX_2382_COPY_AQ_IN_MCT                         /* FhG: basop issue 2382: 2nd instance of prevent copying uninitialized values from Aq_fx[][] to Aq_fx_32[][] in TCX */
#define FIX_2391_INIT_HQ_GENERIC_OFFSET                 /* FhG/Eri: basop issue 2391: make sure hq_generic_offset is initialized inside hq_hr_dec_fx() */
#define FIX_2397_COPY_AQ_MDCT_CORE_BFI                  /* FhG: prevent copying of uninit memory in MDCT stereo core if bfi is set */
#define HARMONIZE_TBE                                   /* VA: harmonize core-coder TBE function duplications */
#define HARMONIZE_READ_DECODE_TNS                       /* FhG: issue 2389: Harmonization of two pairs ReadTnsData() and DecodeTnsData()*/
/* #################### End BE switches ################################## */
@@ -117,6 +118,7 @@
#define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT  /* Dolby: Issue 2250:  random vector generation in GenShapedSHBExcitation() */
#define FIX_2338_HARM_GSC_GAIN_COMP                     /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */
#define FIX_BASOP_2317_UNINIT_VALUE_IN_STEREO_CNG       /* Eri: Basop issue 2317: Uninitialized value read in case of DTX and BW switching   */
#define FIX_BASOP_2361_OTR                              /* FhG: Basop issue 2361: Orientation tracking tests for equivalent rotations fail */
#define FIX_1283_STEREO_DFT_COLLAPSE                    /* FhG: float issue 1283: fix for critical issue with DFT stereo core coder */
#define FIX_2379_REMOVE_previoussynth_fx_32             /* VA: basop issue 2379: remove duplicated buffer st->previoussynth_fx_32[] */
#define FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER           /* FhG/VA: basop issue 2396: keep TC channel pointers in one constant place during decoding and rendering */
+5 −0
Original line number Diff line number Diff line
@@ -228,7 +228,12 @@ ivas_error ivas_mct_dec_fx(
        FOR( n = 0; n < CPE_CHANNELS; n++ )
        {
#ifdef FIX_2382_COPY_AQ_IN_MCT
#ifdef FIX_2397_COPY_AQ_MDCT_CORE_BFI
            test();
            IF( !st_ivas->bfi && NE_16( hCPE->hCoreCoder[n]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
#else
            IF( NE_16( hCPE->hCoreCoder[n]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
#endif
            {
                Word16 nSubframes;

+18 −0
Original line number Diff line number Diff line
@@ -382,6 +382,23 @@ void stereo_mdct_core_dec_fx(
        }
    }

#ifdef FIX_2397_COPY_AQ_MDCT_CORE_BFI
    IF( !bfi )
    {
#ifdef FIX_2352_COPY_AQ_IN_TCX
        FOR( ch = 0; ch < nChannels; ch++ )
#else
        FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
#endif
        {
#ifdef FIX_2352_COPY_AQ_IN_TCX
            Copy_Scale_sig_16_32_DEPREC( Aq_fx[ch], Aq_fx_32[ch], i_mult( nSubframes[ch], M ), sub( Q16, Q12 ) ); /* Q16 */
#else
            Copy_Scale_sig_16_32_DEPREC( Aq_fx[ch], Aq_fx_32[ch], ( NB_SUBFR16k + 1 ) * ( M + 1 ), sub( Q16, Q12 ) ); /* Q16 */
#endif
        }
    }
#else
#ifdef FIX_2352_COPY_AQ_IN_TCX
    FOR( ch = 0; ch < nChannels; ch++ )
#else
@@ -394,6 +411,7 @@ void stereo_mdct_core_dec_fx(
        Copy_Scale_sig_16_32_DEPREC( Aq_fx[ch], Aq_fx_32[ch], ( NB_SUBFR16k + 1 ) * ( M + 1 ), sub( Q16, Q12 ) ); /* Q16 */
#endif
    }
#endif

    /*--------------------------------------------------------------------------------*
     * Stereo processing
+38 −1
Original line number Diff line number Diff line
@@ -482,11 +482,21 @@ static Word32 VectorLength_fx(
    IVAS_VECTOR3 p,
    Word16 *q_fact )
{
#ifdef FIX_BASOP_2361_OTR
    Word16 sqrt_e;
    Word32 result_fx;
    result_fx = Madd_32_32( Madd_32_32( Mpy_32_32( p.x_fx, p.x_fx ), p.y_fx, p.y_fx ), p.z_fx, p.z_fx );
    sqrt_e = shl( sub( 31, p.q_fact ), 1 ); /* convert Q to E */

    result_fx = Sqrt32( result_fx, &sqrt_e );
    *q_fact = sub( 31, sqrt_e ); /* back to Q again */
#else
    Word32 result_fx = 0;
    move32();
    result_fx = L_add( L_add( Mpy_32_32( p.x_fx, p.x_fx ), Mpy_32_32( p.y_fx, p.y_fx ) ), Mpy_32_32( p.z_fx, p.z_fx ) ); // // Q: ( p1.q_fact + p2.q_fact ) - 31

    *q_fact = sub( add( p.q_fact, p.q_fact ), 31 );
#endif
    move16();
    return result_fx;
}
@@ -702,7 +712,14 @@ ivas_error ivas_orient_trk_SetReferenceRotation_fx(
        Euler2Quat_fx( deg2rad_fx( refRot.x_fx ), deg2rad_fx( refRot.y_fx ), deg2rad_fx( refRot.z_fx ), &pOTR->refRot );
        modify_Quat_q_fx( &pOTR->refRot, &pOTR->refRot, Q29 );
    }
#ifdef FIX_BASOP_2361_OTR
    ELSE
    {
#endif
        pOTR->refRot = refRot;
#ifdef FIX_BASOP_2361_OTR
    }
#endif

    return IVAS_ERR_OK;
}
@@ -824,11 +841,16 @@ ivas_error ivas_orient_trk_SetReferenceVector_fx(
            return IVAS_ERR_WRONG_PARAMS;
    }

#ifdef FIX_BASOP_2361_OTR
    Word16 tmp_q;
    acousticFrontVectorLength = VectorLength_fx( acousticFrontVector, &tmp_q );
#else
    Word16 accoustic_q = acousticFrontVector.q_fact;
    move16();
    acousticFrontVectorLength = VectorLength_fx( acousticFrontVector, &acousticFrontVector.q_fact );
    acousticFrontVector.q_fact = accoustic_q;
    move16();
#endif
    /* if the length is zero, the user has entered insensible listener and reference positions */
    IF( LE_32( acousticFrontVectorLength, 0 ) )
    {
@@ -889,6 +911,18 @@ ivas_error ivas_orient_trk_Process_fx(
            /* Reset average orientation   */
            pOTR->absAvgRot = absRot;

#ifdef FIX_BASOP_2361_OTR
            Word16 scale_e;
            Word16 tmp;
            tmp = BASOP_Util_Divide3232_Scale( PI2_C_ADP_RATE_Q31, updateRate_fx, &scale_e );
            scale_e = add( scale_e, 23 - 31 ); /* updateRate_fx is hardcoded in caller to Q23 */

            /* sin(x) is approx x for small x */
            pOTR->alpha_fx = L_deposit_h( tmp );
            move32();
            pOTR->Q_alpha = sub( Q31, scale_e );
            move16();
#else
            Word16 scale_e;
            Word32 div;
            div = L_deposit_h( BASOP_Util_Divide3232_Scale( pOTR->centerAdaptationRate_fx, updateRate_fx, &scale_e ) );
@@ -897,6 +931,7 @@ ivas_error ivas_orient_trk_Process_fx(
            // here div value is less so we can use sandwitch rule of sine//
            pOTR->alpha_fx = div;
            move32();
#endif
            /* Compute relative orientation = (absolute orientation) - (reference orientation) */
            QuaternionInverse_fx( pOTR->refRot, &pOTR->trkRot );
            QuaternionProduct_fx( pOTR->trkRot, absRot, &pOTR->trkRot );
@@ -950,6 +985,8 @@ ivas_error ivas_orient_trk_Process_fx(
            cutoff_prod = L_shl( cutoff_prod, temp_diff );
            /* Compute adaptivity cutoff frequency: interpolate between minimum (center) and maximum (off-center) values */
            cutoffFrequency_fx = L_add( pOTR->centerAdaptationRate_fx, cutoff_prod ); // Q31

            /* Compute filter coefficient corresponding to desired cutoff frequency */
            cutoff_prod = Mpy_32_32( cutoffFrequency_fx, PI2_C_Q28 );
            q_cutoff_prod = ( ( 31 + 28 ) - 31 );
            temp_result = BASOP_Util_Divide3232_Scale( cutoff_prod, updateRate_fx, &result_e );
Loading