Commit e7041da1 authored by multrus's avatar multrus
Browse files

[cleanup] accept NONBE_FIX_1748_SPAR_DIV_OPT

parent 802cd057
Loading
Loading
Loading
Loading
+0 −315
Original line number Diff line number Diff line
@@ -3846,12 +3846,8 @@ void ivas_compute_spar_params_fx(
Word32 diff_norm_order1_table[4] = { 0, 805306368, 402653184, 268435456 };                                              // q28
Word32 diff_norm_order2_table[6] = { 0, 1342177280, 671088640, 447392416, 335544320, 268435456 };                       // q28
Word32 diff_norm_order3_table[8] = { 0, 1879048192, 939524096, 626349376, 469762048, 375809632, 313174688, 268435456 }; // q28
#ifdef NONBE_FIX_1748_SPAR_DIV_OPT
#define EPSILON_FX_SHIFT 6
#define EPSILON_FX_THR   ( 1 << EPSILON_FX_SHIFT )
#else
#define EPSILON_FX_THR 70
#endif
#define ONE_BY_THREE_Q31 715827882
#define ONE_BY_FIVE_Q31  429496729
#define ONE_BY_SEVEN_Q31 306783378
@@ -4092,19 +4088,11 @@ void ivas_get_spar_md_from_dirac_enc_fx(
                    Word32 norm_fx;
                    Word16 norm_q;

#ifdef NONBE_FIX_1748_SPAR_DIV_OPT
                    Word16 num_ch_order, norm_t;
                    Word32 tmp_norm_out;
#else
                    Word16 num_ch_order, hoa2_ch_order;
#endif

                    num_ch_order = ivas_sba_get_nchan_fx( order, 0 );
#ifndef NONBE_FIX_1748_SPAR_DIV_OPT
                    hoa2_ch_order = ivas_sba_get_nchan_fx( SBA_HOA2_ORDER, 0 );
#else
                    assert( order == 1 );
#endif

                    FOR( ch = 0; ch < num_ch_order; ch++ )
                    {
@@ -4119,36 +4107,18 @@ void ivas_get_spar_md_from_dirac_enc_fx(
                    }

                    /*normalize 1st order*/
#ifdef NONBE_FIX_1748_SPAR_DIV_OPT
                    norm_t = L_norm_arr( &response_avg_fx[1], sub( foa_ch, 1 ) );
                    norm_t = sub( norm_t, 1 );
                    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
                    }
                    ELSE
                    {
                        norm_fx = EPSILON_FX;
                        move32();
                    }
#endif
                    IF( norm_q <= 0 )
                    {
                        norm_fx = L_shr( norm_fx, ( negate( norm_q ) ) ); // q=31
@@ -4157,7 +4127,6 @@ void ivas_get_spar_md_from_dirac_enc_fx(
                    }
                    norm_fx = L_shr( norm_fx, sub( 1, norm_q ) ); // q30

#ifdef NONBE_FIX_1748_SPAR_DIV_OPT
                    IF( LT_32( norm_fx, EPSILON_FX_THR ) )
                    {
                        FOR( ch = 1; ch < foa_ch; ch++ )
@@ -4176,136 +4145,7 @@ void ivas_get_spar_md_from_dirac_enc_fx(
                            move32();
                        }
                    }
#else
                    FOR( ch = 1; ch < foa_ch; ch++ )
                    {
                        IF( LT_32( norm_fx, EPSILON_FX_THR ) )
                        {
                            IF( response_avg_fx[ch] != 0 )
                            {
                                response_avg_fx[ch] = divide3232( response_avg_fx[ch], EPSILON_FX_THR ); // q15
                                move32();
                            }
                            response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 ); // q30
                            move32();
                        }
                        ELSE IF( GT_32( response_avg_fx[ch], norm_fx ) )
                        {
                            response_avg_fx[ch] = ONE_IN_Q30; // 1 q30
                            move32();
                        }
                        ELSE
                        {
                            response_avg_fx[ch] = divide3232( response_avg_fx[ch], norm_fx ); // q15
                            move32();
                            response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 ); // q30
                            move32();
                        }
                    }
#endif

#ifndef NONBE_FIX_1748_SPAR_DIV_OPT

                    /*normalize 2nd order*/
                    norm_fx = 0;
                    move32();
                    Word16 min_ch_order = s_min( hoa2_ch_order, num_ch_order );
                    FOR( ch = foa_ch; ch < min_ch_order; 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( 29, 29 ), 31 ) ) );
                    IF( norm_fx )
                    {
                        norm_fx = Sqrt32( norm_fx, &norm_q ); // q=31-norm_q
                    }
                    ELSE
                    {
                        norm_fx = EPSILON_FX;
                        move32();
                    }
                    IF( norm_q < 0 )
                    {
                        norm_fx = L_shr( norm_fx, negate( norm_q ) ); // q31
                        norm_q = 0;
                        move16();
                    }
                    norm_fx = L_shr( norm_fx, sub( 1, norm_q ) ); // q30
                    min_ch_order = s_min( hoa2_ch_order, num_ch_order );
                    FOR( ch = foa_ch; ch < min_ch_order; ch++ )
                    {
                        IF( LT_32( norm_fx, EPSILON_FX_THR ) )
                        {
                            response_avg_fx[ch] = response_avg_fx[ch];                               // q30
                            response_avg_fx[ch] = divide3232( response_avg_fx[ch], EPSILON_FX_THR ); // q15
                            response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 );                  // q30
                            move32();
                            move32();
                            move32();
                        }
                        ELSE IF( GT_32( response_avg_fx[ch], norm_fx ) )
                        {
                            response_avg_fx[ch] = ONE_IN_Q30; // q30
                            move32();
                        }
                        ELSE
                        {
                            response_avg_fx[ch] = divide3232( response_avg_fx[ch], norm_fx ); // q15
                            response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 );           // q30
                            move32();
                            move32();
                        }
                    }

                    /*normalize 3rd order*/
                    norm_fx = 0;
                    move32();
                    FOR( ch = hoa2_ch_order; ch < num_ch_order; 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( 29, 29 ), 31 ) ) );
                    IF( norm_fx )
                    {
                        norm_fx = Sqrt32( norm_fx, &norm_q ); // q=31-norm_q
                    }
                    ELSE
                    {
                        norm_fx = EPSILON_FX;
                        move32();
                    }
                    IF( norm_q < 0 )
                    {
                        norm_fx = L_shr( norm_fx, negate( norm_q ) ); // q31
                        norm_q = 0;
                        move16();
                    }
                    norm_fx = L_shr( norm_fx, sub( 1, norm_q ) ); // q30
                    FOR( ch = hoa2_ch_order; ch < num_ch_order; ch++ )
                    {
                        IF( LT_32( norm_fx, EPSILON_FX_THR ) )
                        {
                            response_avg_fx[ch] = response_avg_fx[ch];                               // q30
                            response_avg_fx[ch] = divide3232( response_avg_fx[ch], EPSILON_FX_THR ); // q15
                            response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 );                  // q30
                            move32();
                            move32();
                            move32();
                        }
                        ELSE IF( GT_32( response_avg_fx[ch], norm_fx ) )
                        {
                            response_avg_fx[ch] = ONE_IN_Q30; // 1 q30
                            move32();
                        }
                        ELSE
                        {
                            response_avg_fx[ch] = divide3232( response_avg_fx[ch], norm_fx ); // q15
                            move32();
                            response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 ); // q30
                            move32();
                        }
                    }
#endif
                }
            }

@@ -4695,19 +4535,11 @@ 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, norm_t;
                    Word32 tmp_norm_out;
#else
                    Word16 num_ch_order, hoa2_ch_order;
#endif

                    num_ch_order = ivas_sba_get_nchan_fx( order, 0 );
#ifndef NONBE_FIX_1748_SPAR_DIV_OPT
                    hoa2_ch_order = ivas_sba_get_nchan_fx( SBA_HOA2_ORDER, 0 );
#else
                    assert( order == 1 );
#endif

                    FOR( ch = 0; ch < num_ch_order; ch++ )
                    {
@@ -4722,17 +4554,11 @@ void ivas_get_spar_md_from_dirac_fx(
                    }

                    /*normalize 1st order*/
#ifdef NONBE_FIX_1748_SPAR_DIV_OPT
                    norm_t = L_norm_arr( &response_avg_fx[1], sub( foa_ch, 1 ) );
                    norm_t = sub( norm_t, 1 );
                    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
@@ -4740,19 +4566,7 @@ void ivas_get_spar_md_from_dirac_fx(

                    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
                    }
                    ELSE
                    {
                        norm_fx = EPSILON_FX;
                        move32();
                    }
#endif

                    IF( norm_q <= 0 )
                    {
@@ -4762,7 +4576,6 @@ void ivas_get_spar_md_from_dirac_fx(
                    }
                    norm_fx = L_shr( norm_fx, sub( 1, norm_q ) ); // q30

#ifdef NONBE_FIX_1748_SPAR_DIV_OPT
                    IF( LT_32( norm_fx, EPSILON_FX_THR ) )
                    {
                        FOR( ch = 1; ch < foa_ch; ch++ )
@@ -4781,135 +4594,7 @@ void ivas_get_spar_md_from_dirac_fx(
                            move32();
                        }
                    }
#else
                    FOR( ch = 1; ch < foa_ch; ch++ )
                    {
                        IF( LT_32( norm_fx, EPSILON_FX_THR ) )
                        {
                            IF( response_avg_fx[ch] != 0 )
                            {
                                response_avg_fx[ch] = divide3232( response_avg_fx[ch], EPSILON_FX_THR ); // q15
                                move32();
                            }
                            response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 ); // q30
                            move32();
                        }
                        ELSE IF( GT_32( response_avg_fx[ch], norm_fx ) )
                        {
                            response_avg_fx[ch] = ONE_IN_Q30; // 1 q30
                            move32();
                        }
                        ELSE
                        {
                            response_avg_fx[ch] = divide3232( response_avg_fx[ch], norm_fx ); // q15
                            move32();
                            response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 ); // q30
                            move32();
                        }
                    }
#endif

#ifndef NONBE_FIX_1748_SPAR_DIV_OPT
                    /*normalize 2nd order*/
                    norm_fx = 0;
                    move32();
                    Word16 min_ch_order = s_min( hoa2_ch_order, num_ch_order );
                    FOR( ch = foa_ch; ch < min_ch_order; 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( 29, 29 ), 31 ) ) );
                    IF( norm_fx )
                    {
                        norm_fx = Sqrt32( norm_fx, &norm_q ); // q=31-norm_q
                    }
                    ELSE
                    {
                        norm_fx = EPSILON_FX;
                        move32();
                    }
                    IF( norm_q < 0 )
                    {
                        norm_fx = L_shr( norm_fx, negate( norm_q ) ); // q31
                        norm_q = 0;
                        move16();
                    }
                    norm_fx = L_shr( norm_fx, sub( 1, norm_q ) ); // q30
                    min_ch_order = s_min( hoa2_ch_order, num_ch_order );
                    FOR( ch = foa_ch; ch < min_ch_order; ch++ )
                    {
                        IF( LT_32( norm_fx, EPSILON_FX_THR ) )
                        {
                            response_avg_fx[ch] = response_avg_fx[ch];                               // q30
                            response_avg_fx[ch] = divide3232( response_avg_fx[ch], EPSILON_FX_THR ); // q15
                            response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 );                  // q30
                            move32();
                            move32();
                            move32();
                        }
                        ELSE IF( GT_32( response_avg_fx[ch], norm_fx ) )
                        {
                            response_avg_fx[ch] = ONE_IN_Q30; // q30
                            move32();
                        }
                        ELSE
                        {
                            response_avg_fx[ch] = divide3232( response_avg_fx[ch], norm_fx ); // q15
                            response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 );           // q30
                            move32();
                            move32();
                        }
                    }

                    /*normalize 3rd order*/
                    norm_fx = 0;
                    move32();
                    FOR( ch = hoa2_ch_order; ch < num_ch_order; 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( 29, 29 ), 31 ) ) );
                    IF( norm_fx )
                    {
                        norm_fx = Sqrt32( norm_fx, &norm_q ); // q=31-norm_q
                    }
                    ELSE
                    {
                        norm_fx = EPSILON_FX;
                        move32();
                    }
                    IF( norm_q < 0 )
                    {
                        norm_fx = L_shr( norm_fx, negate( norm_q ) ); // q31
                        norm_q = 0;
                        move16();
                    }
                    norm_fx = L_shr( norm_fx, sub( 1, norm_q ) ); // q30
                    FOR( ch = hoa2_ch_order; ch < num_ch_order; ch++ )
                    {
                        IF( LT_32( norm_fx, EPSILON_FX_THR ) )
                        {
                            response_avg_fx[ch] = response_avg_fx[ch];                               // q30
                            response_avg_fx[ch] = divide3232( response_avg_fx[ch], EPSILON_FX_THR ); // q15
                            response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 );                  // q30
                            move32();
                            move32();
                            move32();
                        }
                        ELSE IF( GT_32( response_avg_fx[ch], norm_fx ) )
                        {
                            response_avg_fx[ch] = ONE_IN_Q30; // 1 q30
                            move32();
                        }
                        ELSE
                        {
                            response_avg_fx[ch] = divide3232( response_avg_fx[ch], norm_fx ); // q15
                            move32();
                            response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 ); // q30
                            move32();
                        }
                    }
#endif
                }
            }

+0 −1
Original line number Diff line number Diff line
@@ -95,7 +95,6 @@
 * The issue is fixed by simply casting one of the product operands to Word32 in lib_com/basop32.c
 */

#define NONBE_FIX_1748_SPAR_DIV_OPT                      /*Dlb: issue 1748: SPAR common div optimizations*/

#define FIX_ISSUE_1801_NOISE_FLOOR_REDUCTION    /* FhG: Fixed getScalefactor usage */