Commit 0ad22373 authored by Jonas Svedberg's avatar Jonas Svedberg
Browse files

removed debug code and alt2(with rounding) code

parent e229c40d
Loading
Loading
Loading
Loading
Loading
+1 −55
Original line number Diff line number Diff line
@@ -1096,56 +1096,13 @@ static void subst_spec(

        Xph = corr_phase[m];
#ifdef FIX_1002_DEC_PHASE_ECU_USAN_OF_PHASE
        /* BE , but with maintained dual mult of a constant,  bnut mask the  10 bits in Word32, truncation  */
        /* BE , but with maintained dual mult of a constant,  mask the  10 bits in Word32, truncation  */
#define WMC_TOOL_SKIP
        Xph_short = (int16_t) ( 0x000003ff & (int32_t) ( ( Xph * 512 ) / EVS_PI ) );
        MULT( 2 );  /* mult with constant, twice due to legacy precedence use */
        LOGIC( 1 ); /* L_and        */
        MISC( 1 );  /* extract_l   */
#undef WMC_TOOL_SKIP
#if 1
        int16_t Xph_short_orig = (int16_t) ( ( (int32_t) ( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff; /* BE: 2 mults, 1 modulo */     /* bad line(for WMC):  WMC-costly modulo % in use,  no rounding   */
        int16_t Xph_short_1mult_nonbe = (int16_t) ( 0x000003ff & (int32_t) ( ( Xph * ( 512.0 / EVS_PI ) ) ) );                        /* nonBE:  single mult, mask the  10 bits in Word32 ,  still no rounding */
        int16_t Xph_short_1mult_rnd_nonbe = (int16_t) ( 0x000003ff & ( ( 1L + ( (int32_t) ( Xph * ( 1024.0 / EVS_PI ) ) ) ) >> 1 ) ); /* nonBE:  single mult, add 1(round) shift1,  mask the  10 bits in Word32 , i.e. with rounding */

        assert( Xph_short == Xph_short_orig && "Xph_short == Xph_short_orig" );
#endif

#ifdef DEBUGGING

        int32_t Xph_long_new = (int32_t) ( Xph * ( 512 / EVS_PI ) ); /* mult by a single constant and float cast to int32_t */
        int32_t Xph_long_old = (int32_t) ( ( Xph * 512 ) / EVS_PI ); /* mult by 2 constants ! and float cast to int32_t , (Xph<<9) / pi */
        int32_t Xph_long = Xph_long_old;

        // assert( Xph_long_new == Xph_long_old && __func__ && " Xph_long_new != Xph_long_old" ); // mat differ due to order of division

        int32_t L_tmp1 = Xph_long % 32768;      /* counts as division:  6-25 cycles */
        int32_t L_tmp2 = Xph_long & 0x00007fff; /* L_and mask : 1 cycle */
                                                // assert( L_tmp1 == L_tmp2 && __func__ && " L_tmp1 != L_tmp2 " );


        Xph_long = ( Xph_long & 0x00007fff ); /*  L_and()  equivalent to  % 32768 */
        int16_t Xph_short_new1 = ( (int16_t) Xph_long ) & 0x03ff;
        int16_t Xph_short_new2 = (int16_t) ( Xph_long_old & 0x000003ff );

        // assert( Xph_short == Xph_short_new1 && __func__ && " Xph_short != Xph_short_new1" );
        // assert( Xph_short == Xph_short_new2 && __func__ && " Xph_short != Xph_short_new2" );

#if 0
            /* guarantee no wrap around to negative side of 32 bit signed integer value  */
#define WMC_TOOL_SKIP
            tmpf = Xph * ( 1.0f / PI2 );                           /* normalize         :  mult() with a constant                           */
            tmpf = ( 1024.0f * ( tmpf - floorf( tmpf ) ) ) + 0.5f; /* obtain fraction  :  floor(), sub(), mult(), rnd(), out:  [0...1024.5[ */
            int16_t Xph_short_flt_correct = ( (int16_t) tmpf ) & 0x03ff;               /* mask to [0..1023]:  s_and()                      , out:  [0...1023]   */

            MULT( 2 );
            MISC( 1 );  /* floor    */
            ADD( 2 );   /* sub, rnd */
            LOGIC( 1 ); /* s_and    */
#undef WMC_TOOL_SKIP
#endif
#endif

#else
        Xph_short = (int16_t) ( ( (int32_t) ( Xph * 512 / EVS_PI ) ) % 32768 ) & 0x03ff;
#endif
@@ -1201,17 +1158,6 @@ static void subst_spec(
                LOGIC( 1 ); /* L_and        */
                MISC( 1 );  /* extract_l   */
#undef WMC_TOOL_SKIP
#if 1
                int16_t Xph_short_orig_ph_dith = (int16_t) ( Xph * 512 / EVS_PI ) & 0x03ff; /* USAN bad cast,  bad dual mults */
                assert( Xph_short == Xph_short_orig_ph_dith );
#endif

#ifdef DEBUGGING
                /* NB! USAN undefined behaviour warning for float-> short cast adressed, no rounding required here as phase is scrambled anyway */
                /* applied also  EVS_MONO */
#endif


#else
                Xph_short = (int16_t) ( Xph * 512 / EVS_PI ) & 0x03ff;
#endif