Commit 7f02a251 authored by multrus's avatar multrus
Browse files

replace division by multiplication by inverse

parent 6af6d0f9
Loading
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -3262,8 +3262,27 @@ void stereo_dft_generate_res_pred_fx(
            q_dmx_nrg = add( sub( shl( hStereoDft->q_dft, 1 ), 31 ), norm_dmx_nrg );

            /* dmx_nrg * 2 / hStereoDft->NFFT */
            SWITCH( hStereoDft->NFFT )
            {
                case 960:
                    L_temp = Mpy_32_16_1( dmx_nrg, 17476 /* 1 / 480 in Q8 */ );
                    L_temp = L_shr( L_temp, Q1 ); /* reserve 1 bit headroom */
                    q_dmx_nrg = add( q_dmx_nrg, Q7 );
                    BREAK;
                case 640:
                    L_temp = Mpy_32_16_1( dmx_nrg, 26214 /* 1 / 320 in Q8 */ );
                    L_temp = L_shr( L_temp, Q1 ); /* reserve 1 bit headroom */
                    q_dmx_nrg = add( q_dmx_nrg, Q7 );
                    BREAK;
                case 320:
                    L_temp = Mpy_32_16_1( dmx_nrg, 26214 /* 1 / 320 in Q7 */ );
                    L_temp = L_shr( L_temp, Q1 ); /* reserve 1 bit headroom */
                    q_dmx_nrg = add( q_dmx_nrg, Q6 );
                    BREAK;
                default:
                    L_temp = BASOP_Util_Divide3232_Scale_newton( dmx_nrg, shr( hStereoDft->NFFT, 1 ), &temp_e );
                    L_temp = L_shr( L_temp, sub( 31, temp_e ) ); /* q_dmx_nrg */
            }

            /* for L_temp we have at least one bit of headroom due to the division above; check also for hStereoDft->hb_nrg_fx[0] and possibly reserve one bit*/
            test();