Commit 91fed738 authored by TYAGIRIS's avatar TYAGIRIS
Browse files

improve precision of average sph harm resp

parent 8e294c8e
Loading
Loading
Loading
Loading
Loading
+28 −10
Original line number Diff line number Diff line
@@ -4264,7 +4264,7 @@ void ivas_get_spar_md_from_dirac_enc_fx(
                    Word16 norm_q;

#ifdef NONBE_FIX_1748_SPAR_DIV_OPT
                    Word16 num_ch_order;
                    Word16 num_ch_order, norm_t;
#else
                    Word16 num_ch_order, hoa2_ch_order;
#endif
@@ -4289,21 +4289,28 @@ void ivas_get_spar_md_from_dirac_enc_fx(
                    }

                    /*normalize 1st order*/
#if 0 // def NONBE_FIX_1748_SPAR_DIV_OPT
                    Word16 norm_t = L_norm_arr( &response_avg_fx[1], foa_ch - 1 );
                    norm_t = norm_t - 1;
                    scale_sig32( &response_avg_fx[1], foa_ch - 1, norm_t );
#ifdef NONBE_FIX_1748_SPAR_DIV_OPT
                    norm_t = L_norm_arr( &response_avg_fx[1], sub( foa_ch, 1 ) );
                    move16();
                    norm_t = sub( norm_t, 1 );
                    move16();
                    scale_sig32( &response_avg_fx[1], sub( foa_ch, 1 ), norm_t );
#endif
                    norm_fx = 0;
                    move32();
#ifndef NONBE_FIX_1748_SPAR_DIV_OPT
                    norm_q = 0;
                    move16();
#endif
                    FOR( ch = 1; ch < foa_ch; ch++ )
                    {
                        norm_fx = L_add( norm_fx, Mpy_32_32( response_avg_fx[ch], response_avg_fx[ch] ) ); // q29
                    }

                    norm_q = sub( 31, ( sub( add( 30, 30 ), 31 ) ) );
#ifdef NONBE_FIX_1748_SPAR_DIV_OPT
                    norm_fx = Sqrt32( norm_fx, &norm_q ); // q=31-norm_q
#else
                    IF( norm_fx )
                    {
                        norm_fx = Sqrt32( norm_fx, &norm_q ); // q=31-norm_q
@@ -4313,6 +4320,7 @@ void ivas_get_spar_md_from_dirac_enc_fx(
                        norm_fx = EPSILON_FX;
                        move32();
                    }
#endif
                    IF( norm_q <= 0 )
                    {
                        norm_fx = L_shr( norm_fx, ( negate( norm_q ) ) ); // q=31
@@ -4861,7 +4869,7 @@ void ivas_get_spar_md_from_dirac_fx(
                    Word32 norm_fx;
                    Word16 norm_q;
#ifdef NONBE_FIX_1748_SPAR_DIV_OPT
                    Word16 num_ch_order;
                    Word16 num_ch_order, norm_t;
#else
                    Word16 num_ch_order, hoa2_ch_order;
#endif
@@ -4886,21 +4894,29 @@ void ivas_get_spar_md_from_dirac_fx(
                    }

                    /*normalize 1st order*/
#if 0 // def NONBE_FIX_1748_SPAR_DIV_OPT
                    Word16 norm_t = L_norm_arr( &response_avg_fx[1], foa_ch - 1 );
                    norm_t = norm_t - 1;
                    scale_sig32( &response_avg_fx[1], foa_ch - 1, norm_t );
#ifdef NONBE_FIX_1748_SPAR_DIV_OPT
                    norm_t = L_norm_arr( &response_avg_fx[1], sub( foa_ch, 1 ) );
                    move16();
                    norm_t = sub( norm_t, 1 );
                    move16();
                    scale_sig32( &response_avg_fx[1], sub( foa_ch, 1 ), norm_t );
#endif
                    norm_fx = 0;
                    move32();
#ifndef NONBE_FIX_1748_SPAR_DIV_OPT
                    norm_q = 0;
                    move16();
#endif
                    FOR( ch = 1; ch < foa_ch; ch++ )
                    {
                        norm_fx = L_add( norm_fx, Mpy_32_32( response_avg_fx[ch], response_avg_fx[ch] ) ); // q29
                    }

                    norm_q = sub( 31, ( sub( add( 30, 30 ), 31 ) ) );

#ifdef NONBE_FIX_1748_SPAR_DIV_OPT
                    norm_fx = Sqrt32( norm_fx, &norm_q ); // q=31-norm_q
#else
                    IF( norm_fx )
                    {
                        norm_fx = Sqrt32( norm_fx, &norm_q ); // q=31-norm_q
@@ -4910,6 +4926,8 @@ void ivas_get_spar_md_from_dirac_fx(
                        norm_fx = EPSILON_FX;
                        move32();
                    }
#endif

                    IF( norm_q <= 0 )
                    {
                        norm_fx = L_shr( norm_fx, ( negate( norm_q ) ) ); // q=31