private static int sbrMapping(Context ac,SpectralBandReplication sbr,SBRData chData,int eA[]){
  for (int i=1; i < 8; i++) {
    Arrays.fill(chData.sIndexmapped[i],0);
  }
  for (int e=0; e < chData.bsNumEnv; e++) {
    final int ilim=sbr.n[chData.bsFreqRes[e + 1]];
    int table[]=chData.bsFreqRes[e + 1] != 0 ? sbr.fTablehigh : sbr.fTablelow;
    if (sbr.kx[1] != table[0]) {
      log.error(String.format("kx != f_table{high,low}[0]. Derived frequency tables were not regenerated."));
      sbrTurnoff(sbr);
      return AAC_ERROR;
    }
    for (int i=0; i < ilim; i++) {
      for (int m=table[i]; m < table[i + 1]; m++) {
        sbr.eOrigmapped[e][m - sbr.kx[1]]=chData.envFacs[e + 1][i];
      }
    }
    int k=(chData.bsNumNoise > 1) && (chData.tEnv[e] >= chData.tQ[1]) ? 1 : 0;
    for (int i=0; i < sbr.nQ; i++) {
      for (int m=sbr.fTablenoise[i]; m < sbr.fTablenoise[i + 1]; m++) {
        sbr.qMapped[e][m - sbr.kx[1]]=chData.noiseFacs[k + 1][i];
      }
    }
    for (int i=0; i < sbr.n[1]; i++) {
      if (chData.bsAddHarmonicFlag) {
        final int m_midpoint=(sbr.fTablehigh[i] + sbr.fTablehigh[i + 1]) >> 1;
        chData.sIndexmapped[e + 1][m_midpoint - sbr.kx[1]]=chData.bsAddHarmonic[i] * (e >= eA[1] || (chData.sIndexmapped[0][m_midpoint - sbr.kx[1]] == 1) ? 1 : 0);
      }
    }
    for (int i=0; i < ilim; i++) {
      int additional_sinusoid_present=0;
      for (int m=table[i]; m < table[i + 1]; m++) {
        if (chData.sIndexmapped[e + 1][m - sbr.kx[1]] != 0) {
          additional_sinusoid_present=1;
          break;
        }
      }
      Arrays.fill(sbr.sMapped[e],table[i] - sbr.kx[1],table[i + 1] - sbr.kx[1],additional_sinusoid_present);
    }
  }
  System.arraycopy(chData.sIndexmapped[chData.bsNumEnv],0,chData.sIndexmapped[0],0,chData.sIndexmapped[0].length);
  return 0;
}

private static int sbrMapping ( Context ac , SpectralBandReplication sbr , SBRData chData , int eA [ ] ) { for ( int i = 1 ; i < 8 ; i ++ ) { Arrays . fill ( chData . sIndexmapped [ i ] , 0 ) ; } for ( int e = 0 ; e < chData . bsNumEnv ; e ++ ) { final int ilim = sbr . n [ chData . bsFreqRes [ e + 1 ] ] ; int table [ ] = chData . bsFreqRes [ e + 1 ] != 0 ? sbr . fTablehigh : sbr . fTablelow ; if ( sbr . kx [ 1 ] != table [ 0 ] ) { log . error ( String . format ( "kx != f_table{high,low}[0]. Derived frequency tables were not regenerated." ) ) ; sbrTurnoff ( sbr ) ; return AAC_ERROR ; } for ( int i = 0 ; i < ilim ; i ++ ) { for ( int m = table [ i ] ; m < table [ i + 1 ] ; m ++ ) { sbr . eOrigmapped [ e ] [ m - sbr . kx [ 1 ] ] = chData . envFacs [ e + 1 ] [ i ] ; } } int k = ( chData . bsNumNoise > 1 ) && ( chData . tEnv [ e ] >= chData . tQ [ 1 ] ) ? 1 : 0 ; for ( int i = 0 ; i < sbr . nQ ; i ++ ) { for ( int m = sbr . fTablenoise [ i ] ; m < sbr . fTablenoise [ i + 1 ] ; m ++ ) { sbr . qMapped [ e ] [ m - sbr . kx [ 1 ] ] = chData . noiseFacs [ k + 1 ] [ i ] ; } } for ( int i = 0 ; i < sbr . n [ 1 ] ; i ++ ) { if ( chData . bsAddHarmonicFlag ) { final int m_midpoint = ( sbr . fTablehigh [ i ] + sbr . fTablehigh [ i + 1 ] ) > > 1 ; chData . sIndexmapped [ e + 1 ] [ m_midpoint - sbr . kx [ 1 ] ] = chData . bsAddHarmonic [ i ] * ( e >= eA [ 1 ] || ( chData . sIndexmapped [ 0 ] [ m_midpoint - sbr . kx [ 1 ] ] == 1 ) ? 1 : 0 ) ; } } for ( int i = 0 ; i < ilim ; i ++ ) { int additional_sinusoid_present = 0 ; for ( int m = table [ i ] ; m < table [ i + 1 ] ; m ++ ) { if ( chData . sIndexmapped [ e + 1 ] [ m - sbr . kx [ 1 ] ] != 0 ) { additional_sinusoid_present = 1 ; break ; } } Arrays . fill ( sbr . sMapped [ e ] , table [ i ] - sbr . kx [ 1 ] , table [ i + 1 ] - sbr . kx [ 1 ] , additional_sinusoid_present ) ; } } System . arraycopy ( chData . sIndexmapped [ chData . bsNumEnv ] , 0 , chData . sIndexmapped [ 0 ] , 0 , chData . sIndexmapped [ 0 ] . length ) ; return 0 ; }
high frequency adjustment ( 14496 - 3 sp04 p217 ) and mapping ( 14496 - 3 sp04 p217 )
