Commit ba36acda authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

-10dB input crash fix, Stereo high MLD case fix, formulate2x2MixingMatrix_fx...

-10dB input crash fix, Stereo high MLD case fix, formulate2x2MixingMatrix_fx integration, struct cleanup

[x] Crash fixes: -10dB input: [ltv-SBA at 128 kbps, 32kHZ in, 32kHz out, BINAURAL_ROOM_REVERB out HR]
[x] High MLD fix: High MLD fix for the test case - stereo at 16.4 kbps, 32kHz in, 16kHz out, DTX on
[x] ASAN fixes and BASOP updates
[x] formulate2x2MixingMatrix_fx integration
[x] fb_mixer table updates
[x] dirac_dec_stack_mem and dirac_output_synthesis_state_structure cleanup
parent 72a8b06c
Loading
Loading
Loading
Loading
Loading
+363 −352
Original line number Diff line number Diff line
@@ -5485,6 +5485,17 @@ Word16 get_min_scalefactor( Word32 x, Word32 y )
    return scf;
}

Flag is_zero_arr( Word32 *arr, Word16 size )
{
    FOR( int i = 0; i < size; i++ )
    if ( arr[i] != 0 )
    {
        return 0;
    }

    return 1;
}

#if 0
/* Functions are already in fixed point and available in fft.c file */

+22 −4
Original line number Diff line number Diff line
@@ -959,6 +959,17 @@ void ivas_FB_mixer_close(
                        free( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[1][j] );
                        hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[1][j] = NULL;
                    }

#ifdef IVAS_FLOAT_FIXED
                    FOR ( j = start_diff_band_non48k; j < num_bands; j++ )
                    {
                        free( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[0][j] );
                        hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[0][j] = NULL;

                        free( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[1][j] );
                        hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[1][j] = NULL;
                    }
#endif
                }
            }
            if ( hFbMixer->pFb != NULL )
@@ -2712,13 +2723,20 @@ static void ivas_get_ld_fb_resp_fx(
            scratch1_fx[s] = L_shl( scratch1_fx[s], 1 ); // Q30
        }

        const Word32 *sine_till_frame_len = ivas_sine_frame_len_640_fx; // Q30
        offset = 1;
        const Word32 *sine_till_frame_len = NULL;

        IF( delay == IVAS_FB_1MS_16K_SAMP )
        {
            sine_till_frame_len = ivas_sine_frame_len_640_del_16_fx; // Q30
        }
        ELSE
        {
            sine_till_frame_len = ivas_sine_frame_len_640_del_32_fx; // Q30
        }
        Word16 iterator = 0;
        FOR( s = 2 * delay; s < frame_len + 1; s++ )
        {
            scratch1_fx[s] = Mpy_32_32( scratch1_fx[s], sine_till_frame_len[iterator + ( offset * delay_16 )] );
            offset = add( offset, 1 );
            scratch1_fx[s] = Mpy_32_32( scratch1_fx[s], sine_till_frame_len[iterator] );
            iterator = add( iterator, 1 );
            scratch1_fx[s] = L_shl( scratch1_fx[s], 1 ); // Q30

+35 −1
Original line number Diff line number Diff line
@@ -9436,7 +9436,7 @@ const Word32 ivas_sine_delay_32_fx[32] = {
};
/* Q Factor is 30 */
const Word32 ivas_sine_frame_len_640_fx[577] = {
const Word32 ivas_sine_frame_len_640_del_32_fx[577] = {
    1073737856,
    1073725888, 1073705984, 1073678144, 1073642368, 1073598592, 1073546880, 1073487168, 1073419584,
    1073343936, 1073260416, 1073168896, 1073069440, 1072962048, 1072846720, 1072723392, 1072592128,
@@ -9512,6 +9512,40 @@ const Word32 ivas_sine_frame_len_640_fx[577] = {
    20460476, 17537830, 14615058, 11692176, 8769208, 5846174, 2923098, 0
};
const Word32 ivas_sine_frame_len_640_del_16_fx[289] = {
    1073725952,
    1073678400, 1073599104, 1073488064, 1073345344, 1073170880, 1072964736, 1072726912, 1072457408, 1072156160, 1071823296,
    1071458752, 1071062528, 1070634688, 1070175232, 1069684096, 1069161472, 1068607168, 1068021312, 1067403904, 1066755008,
    1066074560, 1065362624, 1064619200, 1063844352, 1063038016, 1062200320, 1061331264, 1060430848, 1059499072, 1058536000,
    1057541696, 1056516096, 1055459328, 1054371392, 1053252288, 1052102016, 1050920704, 1049708352, 1048465024, 1047190656,
    1045885376, 1044549184, 1043182208, 1041784320, 1040355712, 1038896320, 1037406272, 1035885568, 1034334272, 1032752448,
    1031140096, 1029497216, 1027824000, 1026120384, 1024386432, 1022622272, 1020827904, 1019003328, 1017148672, 1015264000,
    1013349248, 1011404608, 1009430080, 1007425792, 1005391680, 1003327872, 1001234432, 999111424, 996958848, 994776896,
    992565568, 990324864, 988054912, 985755712, 983427456, 981070144, 978683904, 976268672, 973824576, 971351808,
    968850240, 966320128, 963761408, 961174272, 958558720, 955914816, 953242752, 950542464, 947814144, 945057728,
    942273472, 939461440, 936621504, 933753984, 930858880, 927936192, 924986176, 922008896, 919004288, 915972544,
    912913664, 909827968, 906715264, 903575808, 900409728, 897217024, 893997760, 890752128, 887480128, 884181888,
    880857600, 877507328, 874131072, 870729024, 867301184, 863847744, 860368832, 856864448, 853334848, 849779968,
    846199936, 842594944, 838965120, 835310400, 831631104, 827927168, 824198848, 820446144, 816669184, 812868096,
    809043008, 805194048, 801321216, 797424768, 793504832, 789561344, 785594560, 781604608, 777591488, 773555456,
    769496640, 765414976, 761310656, 757183936, 753034880, 748863552, 744670080, 740454592, 736217216, 731958144,
    727677376, 723375232, 719051648, 714706752, 710340864, 705953920, 701546112, 697117632, 692668544, 688198976,
    683709056, 679198976, 674668864, 670118720, 665548800, 660959296, 656350208, 651721728, 647074048, 642407168,
    637721344, 633016704, 628293376, 623551488, 618791104, 614012480, 609215744, 604400960, 599568384, 594718080,
    589850176, 584964864, 580062272, 575142528, 570205824, 565252224, 560281984, 555295168, 550291904, 545272448,
    540236864, 535185280, 530117952, 525034944, 519936384, 514822496, 509693408, 504549248, 499390144, 494216384,
    489027968, 483825056, 478607904, 473376640, 468131360, 462872224, 457599424, 452313152, 447013472, 441700608,
    436374688, 431035904, 425684352, 420320224, 414943680, 409554848, 404153984, 398741152, 393316512, 387880320,
    382432576, 376973600, 371503488, 366022368, 360530464, 355027904, 349514848, 343991456, 338457920, 332914368,
    327360992, 321797952, 316225376, 310643520, 305052416, 299452352, 293843392, 288225792, 282599680, 276965152,
    271322528, 265671856, 260013344, 254347136, 248673408, 242992352, 237304096, 231608848, 225906752, 220197984,
    214482704, 208761088, 203033328, 197299552, 191559952, 185814672, 180063936, 174307856, 168546624, 162780432,
    157009424, 151233776, 145453648, 139669232, 133880696, 128088216, 122291928, 116492040, 110688704, 104882096,
    99072408, 93259768, 87444384, 81626424, 75806048, 69983424, 64158744, 58332160, 52503856, 46674000,
    40842768, 35010324, 29176854, 23342516, 17507490, 11671948, 5836060, 0
};
/************************ Q30 *******************************/
const Word32 ivas_fb_fr_12band_1ms_re_fx[IVAS_FB_12_1MS_LEN] = {
    1046768256, 1012312512, 944113536, 843565952, 712700800, 554033920, 370399360, 163534048, -67588040,
+3 −1
Original line number Diff line number Diff line
@@ -594,7 +594,9 @@ extern const Word32 ivas_han_win_32k_fx[L_FRAME32k];
extern const Word32 ivas_han_win_16k_fx[L_FRAME32k];

extern const Word32 ivas_sine_delay_32_fx[32];
extern const Word32 ivas_sine_frame_len_640_fx[577];

extern const Word32 ivas_sine_frame_len_640_del_32_fx[577];
extern const Word32 ivas_sine_frame_len_640_del_16_fx[289];

extern const Word32 ivas_fb_fr_12band_1ms_re_fx[IVAS_FB_12_1MS_LEN];
extern const Word32 ivas_fb_fr_12band_1ms_im_fx[IVAS_FB_12_1MS_LEN];
+13 −7
Original line number Diff line number Diff line
@@ -734,6 +734,7 @@ static void ivas_get_pred_coeffs_fx(
        Word16 dm_alpha_e, den_f_e, s_dm_f;
        prev_tmp_shift = 31;
        dm_alpha_e = 0;
        Word16 dm_beta_re_e=0;

        IF( EQ_16( dyn_active_w_flag, 1 ) )
        {
@@ -842,6 +843,7 @@ static void ivas_get_pred_coeffs_fx(
                dm_beta_re = L_add( dm_beta_re, re );     // Q = 2*tmp_shift - 3 - 31
            }

            dm_beta_re_e = 31-(2 * tmp_shift - 3 - 31);
            dm_w = cov_real[0][0][b]; // Q30
            den_f = L_max( dm_w, 1 );
            passive_g = L_deposit_l( BASOP_Util_Divide3232_Scale( dm_alpha[b], den_f, &s_div ) );
@@ -911,15 +913,17 @@ static void ivas_get_pred_coeffs_fx(
            {
                Word32 sqrt_val;
                Word16 val_e;
                Word16 num_f_e;

                /* quadratic activeW */

                num_f = L_sub( dm_beta_re, L_shl( Mpy_32_32( dm_alpha[b], activew_quad_thresh ), 1 ) );
                num_f = BASOP_Util_Add_Mant32Exp( dm_beta_re, dm_beta_re_e, L_negate(L_shl( Mpy_32_32( dm_alpha[b], activew_quad_thresh ), 1 )), add(dm_alpha_e,(31-Q29)),&num_f_e);

                sqrt_val = L_shl( Mpy_32_32( Mpy_32_32( dm_alpha[b], dm_alpha[b] ), g_th_sq ), 2 );
                sqrt_val = L_add( sqrt_val, Mpy_32_32( dm_beta_re, dm_beta_re ) );
                sqrt_val = L_sub( sqrt_val, L_shl( Mpy_32_32( Mpy_32_32( dm_beta_re, g_th_sq ), dm_w ), 2 ) );
                val_e = norm_l( sqrt_val );
                sqrt_val = L_shl( Mpy_32_32( Mpy_32_32( dm_alpha[b], dm_alpha[b] ), g_th_sq ), 2 );/*Q27*/
                val_e = 4;
                sqrt_val = BASOP_Util_Add_Mant32Exp( sqrt_val,4, Mpy_32_32( dm_beta_re, dm_beta_re ),2* dm_beta_re_e,&val_e);
                sqrt_val = BASOP_Util_Add_Mant32Exp( sqrt_val, val_e, L_negate(L_shl( Mpy_32_32( Mpy_32_32( dm_beta_re, g_th_sq ), dm_w ), 2 )), add(dm_beta_re_e,4+1),&val_e);
                //val_e = norm_l( sqrt_val );
                sqrt_val = Sqrt32( sqrt_val, &val_e );
                IF( LT_16( val_e, 0 ) )
                {
@@ -930,13 +934,15 @@ static void ivas_get_pred_coeffs_fx(
                    sqrt_val = L_shl( sqrt_val, abs_s( val_e ) );
                    val_e = 0;
                }
                num_f = L_add( num_f, sqrt_val );
                num_f = BASOP_Util_Add_Mant32Exp( num_f, num_f_e, sqrt_val,0,&num_f_e);

                den_f = L_shl( Mpy_32_32( dm_beta_re, g_th_sq ), 1 );
                den_f_e = add( dm_beta_re_e , 4 );
                den_f = L_max( den_f, 1 );
                dm_g[b] = activew_quad_thresh; // Q29
                DM_F[b] = BASOP_Util_Divide3232_Scale_cadence( Mpy_32_32( dm_g[b], num_f ), den_f, &s_dm_f );
                div_shift = sub( s_dm_f, 2 );
                s_dm_f =add(s_dm_f,sub(add( 2 , num_f_e ) , den_f_e));/*Resultant exp for DM_F s_dm_f +( 2 + num_f_e ) - den_f_e*/
                div_shift = sub(s_dm_f, 1);
                DM_F[b] = L_shl( DM_F[b], div_shift ); // Q30
            }
        }
Loading