question: private static void sbrGainCalc ( SpectralBandReplication sbr , SBRData chData , final int eA [ ] ) { int e , k , m ; for ( e = 0 ; e < chData . bsNumEnv ; e ++ ) { int delta = ! ( e == eA [ 1 ] ) || ( e == eA [ 0 ] ) ? 1 : 0 ; for ( k = 0 ; k < sbr . nLim ; k ++ ) { float gain_boost , gain_max ; float sum [ ] = { 0.0f , 0.0f } ; for ( m = sbr . fTablelim [ k ] - sbr . kx [ 1 ] ; m < sbr . fTablelim [ k + 1 ] - sbr . kx [ 1 ] ; m ++ ) { final float temp = sbr . eOrigmapped [ e ] [ m ] / ( 1.0f + sbr . qMapped [ e ] [ m ] ) ; sbr . qM [ e ] [ m ] = sqrtf ( temp * sbr . qMapped [ e ] [ m ] ) ; sbr . sM [ e ] [ m ] = sqrtf ( temp * chData . sIndexmapped [ e + 1 ] [ m ] ) ; if ( sbr . sMapped [ e ] [ m ] == 0 ) { sbr . gain [ e ] [ m ] = sqrtf ( sbr . eOrigmapped [ e ] [ m ] / ( ( 1.0f + sbr . eCurr [ e ] [ m ] ) * ( 1.0f + sbr . qMapped [ e ] [ m ] * delta ) ) ) ; } else { sbr . gain [ e ] [ m ] = sqrtf ( sbr . eOrigmapped [ e ] [ m ] * sbr . qMapped [ e ] [ m ] / ( ( 1.0f + sbr . eCurr [ e ] [ m ] ) * ( 1.0f + sbr . qMapped [ e ] [ m ] ) ) ) ; } } for ( m = sbr . fTablelim [ k ] - sbr . kx [ 1 ] ; m < sbr . fTablelim [ k + 1 ] - sbr . kx [ 1 ] ; m ++ ) { sum [ 0 ] += sbr . eOrigmapped [ e ] [ m ] ; sum [ 1 ] += sbr . eCurr [ e ] [ m ] ; } gain_max = limgain [ sbr . bsLimiterGains ] * sqrtf ( ( FLT_EPSILON + sum [ 0 ] ) / ( FLT_EPSILON + sum [ 1 ] ) ) ; gain_max = Math . min ( 100000.f , gain_max ) ; for ( m = sbr . fTablelim [ k ] - sbr . kx [ 1 ] ; m < sbr . fTablelim [ k + 1 ] - sbr . kx [ 1 ] ; m ++ ) { float qM_max = sbr . qM [ e ] [ m ] * gain_max / sbr . gain [ e ] [ m ] ; sbr . qM [ e ] [ m ] = Math . min ( sbr . qM [ e ] [ m ] , qM_max ) ; sbr . gain [ e ] [ m ] = Math . min ( sbr . gain [ e ] [ m ] , gain_max ) ; } sum [ 0 ] = sum [ 1 ] = 0.0f ; for ( m = sbr . fTablelim [ k ] - sbr . kx [ 1 ] ; m < sbr . fTablelim [ k + 1 ] - sbr . kx [ 1 ] ; m ++ ) { sum [ 0 ] += sbr . eOrigmapped [ e ] [ m ] ; sum [ 1 ] += sbr . eCurr [ e ] [ m ] * sbr . gain [ e ] [ m ] * sbr . gain [ e ] [ m ] + sbr . sM [ e ] [ m ] * sbr . sM [ e ] [ m ] + ( delta != 0 && sbr . sM [ e ] [ m ] == 0 ? 1 : 0 ) * sbr . qM [ e ] [ m ] * sbr . qM [ e ] [ m ] ; } gain_boost = sqrtf ( ( FLT_EPSILON + sum [ 0 ] ) / ( FLT_EPSILON + sum [ 1 ] ) ) ; gain_boost = Math . min ( 1.584893192f , gain_boost ) ; for ( m = sbr . fTablelim [ k ] - sbr . kx [ 1 ] ; m < sbr . fTablelim [ k + 1 ] - sbr . kx [ 1 ] ; m ++ ) { sbr . gain [ e ] [ m ] *= gain_boost ; sbr . qM [ e ] [ m ] *= gain_boost ; sbr . sM [ e ] [ m ] *= gain_boost ; } } } }
target:  Calculation of levels of additional HF signal components (14496-3 sp04 p219) and Calculation of gain (14496-3 sp04 p219)