Commit 5e8e48d4 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'enc_ltv_crash_msan_asan_errors_fix_Q_info_updates' into 'main'

Encoder LTV crash fix, MSAN/ASAN error fix and Q-info updates

See merge request !711
parents 71d2f480 a4047020
Loading
Loading
Loading
Loading
+81 −81
Original line number Diff line number Diff line
@@ -63,9 +63,9 @@
 *-----------------------------------------------------------------------------------------*/

void ivas_tda_fx(
    const Word32 *pIn,  /* i  : time domain buffer of size 2*length */
    Word32 *pOut,       /* o  : time domain buffer of size length   */
    const Word16 length /* i  : length of time alised signal buffer */
    const Word32 *pIn,  /* i  : time domain buffer of size 2*length  Q10*/
    Word32 *pOut,       /* o  : time domain buffer of size length  Q10 */
    const Word16 length /* i  : length of time alised signal buffer   Q0*/
)
{
    Word16 i;
@@ -74,9 +74,9 @@ void ivas_tda_fx(

    FOR( i = 0; i < len_by_2; i++ )
    {
        pOut[i] = L_sub( pIn[add( len_by_2, i )], pIn[sub( sub( len_by_2, i ), 1 )] );
        pOut[i] = L_sub( pIn[len_by_2 + i], pIn[len_by_2 - i - 1] ); /* Q10*/
        move32();
        pOut[add( len_by_2, i )] = L_add( pIn[sub( sub( i_mult( length, 2 ), i ), 1 )], pIn[add( length, i )] );
        pOut[len_by_2 + i] = L_add( pIn[length * 2 - i - 1], pIn[length + i] ); /* Q10*/
        move32();
    }

@@ -91,32 +91,32 @@ void ivas_tda_fx(
 *-----------------------------------------------------------------------------------------*/

void ivas_dct_windowing_fx(
    const Word16 fade_len,
    const Word16 full_len,
    const Word16 dct_len,
    const Word16 zero_pad_len,
    const Word32 *pWindow_coeffs,
    const Word16 frame_len,
    Word32 *pOut_buf,
    Word32 *pBuffer_prev,
    Word32 *pTemp_lfe )
    const Word16 fade_len,        /*Q0*/
    const Word16 full_len,        /*Q0*/
    const Word16 dct_len,         /*Q0*/
    const Word16 zero_pad_len,    /*Q0*/
    const Word32 *pWindow_coeffs, /*Q31*/
    const Word16 frame_len,       /*Q0*/
    Word32 *pOut_buf,             // Q10
    Word32 *pBuffer_prev,         // Q10
    Word32 *pTemp_lfe )           // Q10
{
    Word16 i;
    Word16 rem_len;
    rem_len = 0;
    move16();

    Copy32( pBuffer_prev, pOut_buf + zero_pad_len, fade_len );
    Copy32( pBuffer_prev, pOut_buf + zero_pad_len, fade_len ); // Q10

    Copy32( pTemp_lfe, ( pOut_buf + add( fade_len, zero_pad_len ) ), dct_len );
    Copy32( pTemp_lfe, ( pOut_buf + add( fade_len, zero_pad_len ) ), dct_len ); // Q10

    set32_fx( pOut_buf, 0, zero_pad_len );

    Copy32( ( pOut_buf + sub( full_len, fade_len ) ), pBuffer_prev, fade_len );
    Copy32( ( pOut_buf + sub( full_len, fade_len ) ), pBuffer_prev, fade_len ); // Q10

    FOR( i = 0; i < fade_len; i++ )
    {
        pOut_buf[add( zero_pad_len, i )] = Mult_32_32( pOut_buf[add( zero_pad_len, i )], pWindow_coeffs[i] );
        pOut_buf[zero_pad_len + i] = Mult_32_32( pOut_buf[zero_pad_len + i], pWindow_coeffs[i] ); // Q10
        move32();
    }

@@ -124,7 +124,7 @@ void ivas_dct_windowing_fx(

    FOR( i = 0; i < rem_len; i++ )
    {
        pOut_buf[add( add( i_mult( zero_pad_len, 3 ), fade_len ), i )] = Mult_32_32( pOut_buf[add( add( i_mult( zero_pad_len, 3 ), fade_len ), i )], pWindow_coeffs[sub( sub( fade_len, i ), 1 )] );
        pOut_buf[zero_pad_len * 3 + fade_len + i] = Mult_32_32( pOut_buf[zero_pad_len * 3 + fade_len + i], pWindow_coeffs[fade_len - i - 1] ); // Q10
        move32();
    }

@@ -141,9 +141,9 @@ void ivas_dct_windowing_fx(
 *-----------------------------------------------------------------------------------------*/

void ivas_mdct_fx(
    const Word32 *pIn,
    Word32 *pOut,
    const Word16 length,
    const Word32 *pIn,   // q_out
    Word32 *pOut,        // q_out
    const Word16 length, // Q0
    Word16 *q_out )
{
    const Word16 *pTwid_re, *pTwid_im;
@@ -152,23 +152,23 @@ void ivas_mdct_fx(
    Word32 ivas_mdct_scaling_gain;

    len_by_2 = shr( length, 1 );
    ivas_mdct_scaling_gain = ivas_get_mdct_scaling_gain_fx( len_by_2 );
    ivas_mdct_scaling_gain = ivas_get_mdct_scaling_gain_fx( len_by_2 ); // Q46

    ivas_get_twid_factors_fx1( length, &pTwid_re, &pTwid_im );

    FOR( i = 0; i < len_by_2; i++ )
    {
        pOut[i] = L_sub( pIn[add( len_by_2, i )], pIn[sub( sub( len_by_2, i ), 1 )] );
        pOut[i] = L_sub( pIn[len_by_2 + i], pIn[len_by_2 - i - 1] ); // q_out
        move32();
        pOut[add( len_by_2, i )] = L_add( pIn[sub( sub( imult1616( length, 2 ), i ), 1 )], pIn[add( length, i )] );
        pOut[len_by_2 + i] = L_add( pIn[length * 2 - i - 1], pIn[length + i] ); // q_out
        move32();
    }

    FOR( i = 0; i < len_by_2; i++ )
    {
        re[i] = L_negate( L_add( Mpy_32_16_1( pOut[2 * i], pTwid_re[i] ), Mpy_32_16_1( pOut[sub( sub( length, 1 ), imult1616( 2, i ) )], pTwid_im[i] ) ) );
        re[i] = L_negate( L_add( Mpy_32_16_1( pOut[2 * i], pTwid_re[i] ), Mpy_32_16_1( pOut[length - 1 - 2 * i], pTwid_im[i] ) ) ); // q_out
        move32();
        im[i] = L_sub( Mpy_32_16_1( pOut[sub( sub( length, 1 ), imult1616( 2, i ) )], pTwid_re[i] ), Mpy_32_16_1( pOut[2 * i], pTwid_im[i] ) );
        im[i] = L_sub( Mpy_32_16_1( pOut[length - 1 - 2 * i], pTwid_re[i] ), Mpy_32_16_1( pOut[2 * i], pTwid_im[i] ) ); // q_out
        move32();
    }

@@ -176,9 +176,9 @@ void ivas_mdct_fx(

    FOR( i = 0; i < len_by_2; i++ )
    {
        re[i] = Mult_32_32( re[i], ivas_mdct_scaling_gain );
        re[i] = Mult_32_32( re[i], ivas_mdct_scaling_gain ); // q_out+15
        move32();
        im[i] = Mult_32_32( im[i], ivas_mdct_scaling_gain );
        im[i] = Mult_32_32( im[i], ivas_mdct_scaling_gain ); // q_out +15
        move32();
    }
    *q_out = add( *q_out, Q15 );
@@ -186,18 +186,18 @@ void ivas_mdct_fx(
    FOR( i = 0; i < len_by_2; i++ )
    {
        Word32 tmp;
        tmp = L_sub( Mpy_32_16_1( re[i], pTwid_re[i] ), Mpy_32_16_1( im[i], pTwid_im[i] ) );
        im[i] = L_add( Mpy_32_16_1( im[i], pTwid_re[i] ), Mpy_32_16_1( re[i], pTwid_im[i] ) );
        tmp = L_sub( Mpy_32_16_1( re[i], pTwid_re[i] ), Mpy_32_16_1( im[i], pTwid_im[i] ) );   // q_out
        im[i] = L_add( Mpy_32_16_1( im[i], pTwid_re[i] ), Mpy_32_16_1( re[i], pTwid_im[i] ) ); // q_out
        move32();
        re[i] = tmp;
        re[i] = tmp; // q_out
        move32();
    }

    FOR( i = 0; i < len_by_2; i++ )
    {
        pOut[sub( sub( length, imult1616( 2, i ) ), 1 )] = re[i];
        pOut[length - 2 * i - 1] = re[i]; // q_out
        move32();
        pOut[2 * i] = im[i];
        pOut[2 * i] = im[i]; // q_out
        move32();
    }

@@ -212,33 +212,33 @@ void ivas_mdct_fx(
 *-----------------------------------------------------------------------------------------*/

static void ivas_ifft_cplx(
    Word32 *re,
    Word32 *im,
    const Word16 length )
    Word32 *re, /*Q24*/
    Word32 *im, /*Q24*/
    const Word16 length /*Q0*/ )
{
    Word16 i;
    Word32 ivas_imdct_one_by_powergain;
    ivas_imdct_one_by_powergain = IVAS_ONE_BY_IMDCT_SCALING_GAIN_Q16;
    ivas_imdct_one_by_powergain = IVAS_ONE_BY_IMDCT_SCALING_GAIN_Q16; // Q16
    move32();
    /*re-arrange inputs to use fft as ifft */
    re[0] = Mult_32_32( re[0], ivas_imdct_one_by_powergain );
    re[0] = Mult_32_32( re[0], ivas_imdct_one_by_powergain ); // Q9
    move32();
    im[0] = Mult_32_32( im[0], ivas_imdct_one_by_powergain );
    im[0] = Mult_32_32( im[0], ivas_imdct_one_by_powergain ); // Q9
    move32();

    FOR( i = 1; i <= shr( length, 1 ); i++ )
    FOR( i = 1; i <= ( length / 2 ); i++ )
    {
        Word32 tmp;
        tmp = Mult_32_32( re[sub( length, i )], ivas_imdct_one_by_powergain );
        re[sub( length, i )] = Mult_32_32( re[i], ivas_imdct_one_by_powergain );
        tmp = Mult_32_32( re[length - i], ivas_imdct_one_by_powergain );   // Q9
        re[length - i] = Mult_32_32( re[i], ivas_imdct_one_by_powergain ); // Q9
        move32();
        re[i] = tmp;
        re[i] = tmp; //-Q6
        move32();

        tmp = Mult_32_32( im[sub( length, i )], ivas_imdct_one_by_powergain );
        im[sub( length, i )] = Mult_32_32( im[i], ivas_imdct_one_by_powergain );
        tmp = Mult_32_32( im[length - i], ivas_imdct_one_by_powergain );   // Q9
        im[length - i] = Mult_32_32( im[i], ivas_imdct_one_by_powergain ); // Q9
        move32();
        im[i] = tmp;
        im[i] = tmp; // Q9
        move32();
    }

@@ -255,9 +255,9 @@ static void ivas_ifft_cplx(
 *-----------------------------------------------------------------------------------------*/

void ivas_itda_fx(
    const Word32 *re,   /* i  : time alised signal after IDCT       */
    const Word32 *re,   /* i  : time alised signal after IDCT      Q24 */
    Word32 *pOut,       /* o  : time domain buffer of size 2*length */
    const Word16 length /* i  : length of time alised signal buffer */
    const Word16 length /* i  : length of time alised signal buffer Q0 */
)
{
    Word16 i;
@@ -266,13 +266,13 @@ void ivas_itda_fx(

    FOR( i = 0; i < len_by_2; i++ )
    {
        pOut[i] = L_negate( re[sub( sub( len_by_2, i ), 1 )] );
        pOut[i] = L_negate( re[len_by_2 - i - 1] ); /*Q24 */
        move32();
        pOut[add( len_by_2, i )] = re[i];
        pOut[add( len_by_2, i )] = re[i]; /*Q24 */
        move32();
        pOut[add( length, i )] = re[add( len_by_2, i )];
        pOut[add( length, i )] = re[len_by_2 + i]; /*Q24 */
        move32();
        pOut[add( imult1616( 3, len_by_2 ), i )] = re[sub( sub( length, i ), 1 )];
        pOut[3 * len_by_2 + i] = re[length - i - 1]; /*Q24 */
        move32();
    }

@@ -287,9 +287,9 @@ void ivas_itda_fx(
 *-----------------------------------------------------------------------------------------*/

void ivas_imdct_fx(
    const Word32 *pIn,
    Word32 *pOut,
    const Word16 length,
    const Word32 *pIn, // Q24
    Word32 *pOut,      // q_out Q9
    const Word16 length /*Q0*/,
    Word16 *q_out )
{
    const Word16 *pTwid_re, *pTwid_im;
@@ -303,9 +303,9 @@ void ivas_imdct_fx(

    FOR( i = 0; i < len_by_2; i++ )
    {
        re[i] = L_add( Mpy_32_16_1( pIn[sub( sub( length, shl( i, 1 ) ), 1 )], pTwid_re[i] ), Mpy_32_16_1( pIn[2 * i], pTwid_im[i] ) ); /*stl_arr_index*/
        re[i] = L_add( Mpy_32_16_1( pIn[length - 2 * i - 1], pTwid_re[i] ), Mpy_32_16_1( pIn[2 * i], pTwid_im[i] ) ); /*stl_arr_index  Q24*/
        move32();
        im[i] = L_sub( Mpy_32_16_1( pIn[2 * i], pTwid_re[i] ), Mpy_32_16_1( pIn[sub( sub( length, shl( i, 1 ) ), 1 )], pTwid_im[i] ) ); /*stl_arr_index*/
        im[i] = L_sub( Mpy_32_16_1( pIn[2 * i], pTwid_re[i] ), Mpy_32_16_1( pIn[length - 2 * i - 1], pTwid_im[i] ) ); /*stl_arr_index Q24*/
        move32();
    }

@@ -319,30 +319,30 @@ void ivas_imdct_fx(
    FOR( i = 0; i < len_by_2; i++ )
    {
        Word32 tmp;
        tmp = L_add( Mpy_32_16_1( re[i], pTwid_re[i] ), Mpy_32_16_1( im[i], pTwid_im[i] ) );
        im[i] = L_sub( Mpy_32_16_1( im[i], pTwid_re[i] ), Mpy_32_16_1( re[i], pTwid_im[i] ) );
        tmp = L_add( Mpy_32_16_1( re[i], pTwid_re[i] ), Mpy_32_16_1( im[i], pTwid_im[i] ) );   // Q9
        im[i] = L_sub( Mpy_32_16_1( im[i], pTwid_re[i] ), Mpy_32_16_1( re[i], pTwid_im[i] ) ); // Q9
        move32();
        re[i] = tmp;
        re[i] = tmp; // Q9
        move32();
    }

    FOR( i = ( len_by_2 - 1 ); i >= 0; i-- )
    {
        re[add( shl( i, 1 ), 1 )] = im[sub( sub( len_by_2, 1 ), i )];
        re[2 * i + 1] = im[( len_by_2 - 1 ) - i]; // Q9
        move32();
        re[2 * i] = L_negate( re[i] );
        re[2 * i] = L_negate( re[i] ); // Q9
        move32();
    }

    FOR( i = 0; i < len_by_2; i++ )
    {
        pOut[i] = L_negate( re[sub( sub( len_by_2, i ), 1 )] );
        pOut[i] = L_negate( re[len_by_2 - i - 1] ); // Q9
        move32();
        pOut[add( len_by_2, i )] = re[i];
        pOut[len_by_2 + i] = re[i]; // Q9
        move32();
        pOut[add( length, i )] = re[add( len_by_2, i )];
        pOut[length + i] = re[len_by_2 + i]; // Q9
        move32();
        pOut[add( imult1616( 3, len_by_2 ), i )] = re[sub( sub( length, i ), 1 )];
        pOut[3 * len_by_2 + i] = re[length - i - 1]; // Q9
        move32();
    }

@@ -356,29 +356,29 @@ void ivas_imdct_fx(
 * Sets/Maps the fft twiddle tables based on fft length
 *-----------------------------------------------------------------------------------------*/
void ivas_get_twid_factors_fx1(
    const Word16 length,
    const Word16 **pTwid_re,
    const Word16 **pTwid_im )
    const Word16 length,      // Q0
    const Word16 **pTwid_re,  // Q15
    const Word16 **pTwid_im ) // Q15
{
    IF( EQ_16( length, 480 ) )
    {
        *pTwid_re = (const Word16 *) &ivas_cos_twiddle_480_fx[0];
        *pTwid_im = (const Word16 *) &ivas_sin_twiddle_480_fx[0];
        *pTwid_re = (const Word16 *) &ivas_cos_twiddle_480_fx[0]; // Q15
        *pTwid_im = (const Word16 *) &ivas_sin_twiddle_480_fx[0]; // Q15
    }
    ELSE IF( EQ_16( length, 320 ) )
    {
        *pTwid_re = (const Word16 *) &ivas_cos_twiddle_320_fx[0];
        *pTwid_im = (const Word16 *) &ivas_sin_twiddle_320_fx[0];
        *pTwid_re = (const Word16 *) &ivas_cos_twiddle_320_fx[0]; // Q15
        *pTwid_im = (const Word16 *) &ivas_sin_twiddle_320_fx[0]; // Q15
    }
    ELSE IF( EQ_16( length, 160 ) )
    {
        *pTwid_re = (const Word16 *) &ivas_cos_twiddle_160_fx[0];
        *pTwid_im = (const Word16 *) &ivas_sin_twiddle_160_fx[0];
        *pTwid_re = (const Word16 *) &ivas_cos_twiddle_160_fx[0]; // Q15
        *pTwid_im = (const Word16 *) &ivas_sin_twiddle_160_fx[0]; // Q15
    }
    ELSE IF( EQ_16( length, 80 ) )
    {
        *pTwid_re = (const Word16 *) &ivas_cos_twiddle_80_fx[0];
        *pTwid_im = (const Word16 *) &ivas_sin_twiddle_80_fx[0];
        *pTwid_re = (const Word16 *) &ivas_cos_twiddle_80_fx[0]; // Q15
        *pTwid_im = (const Word16 *) &ivas_sin_twiddle_80_fx[0]; // Q15
    }
    ELSE
    {
@@ -405,19 +405,19 @@ Word32 ivas_get_mdct_scaling_gain_fx(
    {
        case L_FRAME48k >> 2:
        {
            gain = IVAS_MDCT_SCALING_GAIN_48k_Q46;
            gain = IVAS_MDCT_SCALING_GAIN_48k_Q46; /*Q46*/
            move32();
            BREAK;
        }
        case L_FRAME32k >> 2:
        {
            gain = IVAS_MDCT_SCALING_GAIN_32k_Q46;
            gain = IVAS_MDCT_SCALING_GAIN_32k_Q46; /*Q46*/
            move32();
            BREAK;
        }
        case L_FRAME16k >> 2:
        {
            gain = IVAS_MDCT_SCALING_GAIN_16k_Q46;
            gain = IVAS_MDCT_SCALING_GAIN_16k_Q46; /*Q46*/
            move32();
            BREAK;
        }
+7 −0
Original line number Diff line number Diff line
@@ -4610,6 +4610,13 @@ Word16 quantize_phi_fx(
  Word32 *phi_hat,           /* o  : quantized azimuth                                             */
  const Word16 n           /* i  : azimuth codebook size                                         */
);

Word16 quantize_phi_enc_fx(
  Word32 phi,                /* i  : azimuth value                                                 */
  const Word16 flag_delta, /* i  : flag indicating if the azimuth codebook is translated or not  */
  Word32 *phi_hat,           /* o  : quantized azimuth                                             */
  const Word16 n           /* i  : azimuth codebook size                                         */
);
#endif
/*! r: decoded elevation value */
float deindex_elevation(
+8 −0
Original line number Diff line number Diff line
@@ -3516,4 +3516,12 @@ void ivas_omasa_enc_close_fx(
ivas_error ivas_omasa_enc_open_fx(
    Encoder_Struct *st_ivas /* i/o: IVAS encoder handle          */
);

void ivas_masa_estimate_energy_fx(
    MASA_ENCODER_HANDLE hMasa,    /* i/o: MASA encoder structure                    */
    Word32 *data_fx[],            /* i  : Input audio channels        Q(q_data)     */
    const Word16 input_frame,     /* i  : frame length                              */
    const Word16 nchan_transport, /* i  : number of MASA input/transport channels   */
    Word16 q_data                 /* i  : q for data_fx */
);
#endif
+11 −4
Original line number Diff line number Diff line
@@ -177,13 +177,20 @@ ivas_error ivas_qmetadata_allocate_memory(

                FOR( j = 0; j < nbands; j++ )
                {
#ifndef IVAS_FLOAT_FIXED
                    set_zero( hQMetaData->q_direction[dir].band_data[j].elevation, MAX_PARAM_SPATIAL_SUBFRAMES );
#ifdef IVAS_FLOAT_FIXED
                    set32_fx( hQMetaData->q_direction[dir].band_data[j].elevation_fx, 0, MAX_PARAM_SPATIAL_SUBFRAMES );
#endif
                    set_zero( hQMetaData->q_direction[dir].band_data[j].azimuth, MAX_PARAM_SPATIAL_SUBFRAMES );
#ifdef IVAS_FLOAT_FIXED
#ifdef MSAN_FIX
                    set_zero( hQMetaData->q_direction[dir].band_data[j].q_elevation, MAX_PARAM_SPATIAL_SUBFRAMES );
                    set_zero( hQMetaData->q_direction[dir].band_data[j].q_azimuth, MAX_PARAM_SPATIAL_SUBFRAMES );
#endif
#else
                    set32_fx( hQMetaData->q_direction[dir].band_data[j].elevation_fx, 0, MAX_PARAM_SPATIAL_SUBFRAMES );
                    set32_fx( hQMetaData->q_direction[dir].band_data[j].azimuth_fx, 0, MAX_PARAM_SPATIAL_SUBFRAMES );
#ifdef MSAN_FIX
                    set32_fx( hQMetaData->q_direction[dir].band_data[j].q_elevation_fx, 0, MAX_PARAM_SPATIAL_SUBFRAMES );
                    set32_fx( hQMetaData->q_direction[dir].band_data[j].q_azimuth_fx, 0, MAX_PARAM_SPATIAL_SUBFRAMES );
#endif
#endif
                    set_zero( hQMetaData->q_direction[dir].band_data[j].energy_ratio, MAX_PARAM_SPATIAL_SUBFRAMES );
#ifdef IVAS_FLOAT_FIXED
+78 −0
Original line number Diff line number Diff line
@@ -495,6 +495,84 @@ ELSE
move32();
id_phi = add( id_phi, shr( n, 1 ) );

return id_phi;
}

Word16 quantize_phi_enc_fx(
    Word32 phi,              /* i  : azimuth value, Q22                                            */
    const Word16 flag_delta, /* i  : flag indicating if the azimuth codebook is translated or not  */
    Word32 *phi_hat,         /* o  : quantized azimuth, Q22                                        */
    const Word16 n           /* i  : azimuth codebook size                                         */
)
{
    Word16 id_phi;
    Word32 dd_fx;
    Word32 delta_phi_fx;
    Word32 inv_delta_phi_fx;
    Word32 temp_res;
    Word16 temp_e;

    delta_phi_fx = BASOP_Util_Divide3232_Scale_cadence( 360, n, &temp_e );
    delta_phi_fx = L_shl( delta_phi_fx, sub( temp_e, 9 ) );
    inv_delta_phi_fx = BASOP_Util_Divide3232_Scale_cadence( n, 360, &temp_e );

    IF( EQ_16( n, 1 ) )
    {
        *phi_hat = 0;
        move32();

        return 0;
    }

    test();
    IF( EQ_16( flag_delta, 1 ) && GT_16( n, 2 ) )
    {
        dd_fx = dd_val[n];
        move32();
    }
    ELSE
    {
        dd_fx = 0;
        move32();
    }

    temp_res = Mpy_32_32( L_sub( L_sub( phi, DEGREE_180_Q_22 ), dd_fx ), inv_delta_phi_fx );
    temp_res = L_shl( temp_res, temp_e );
    id_phi = round_fx( L_shr( temp_res, Q22 - Q16 ) );

    assert( L_sub( L_abs( temp_res ), abs( id_phi ) * ONE_IN_Q22 ) <= ONE_IN_Q21 );


    IF( add( id_phi, shr( n, 1 ) ) < 0 )
    {
        id_phi = add( id_phi, 1 );
    }

    IF( sub( id_phi, shr( n, 1 ) ) >= 0 )
    {
        id_phi = negate( shr( n, 1 ) );
    }

    IF( EQ_16( id_phi, negate( add( shr( n, 1 ), ( n % 2 ) ) ) ) )
    {
        id_phi = add( id_phi, ( n % 2 ) );
    }
    ELSE{
        IF( EQ_16( id_phi, add( shr( n, 1 ), ( n % 2 ) ) ) ){
            IF( n % 2 ){
                id_phi = sub( id_phi, 1 );
}
ELSE
{
    id_phi = negate( id_phi );
}
}
}

*phi_hat = L_add_sat( L_add_sat( ( id_phi * delta_phi_fx ), dd_fx ), DEGREE_180_Q_22 );
move32();
id_phi = add( id_phi, shr( n, 1 ) );

return id_phi;
}
#endif
Loading