private void applyTns(float coef[],TemporalNoiseShaping tns,IndividualChannelStream ics,boolean decode){
  final int mmm=Math.min(ics.tnsMaxBands,ics.maxSfb);
  final float lpc[]=new float[TNS_MAX_ORDER];
  final float tmp[]=new float[TNS_MAX_ORDER + 1];
  for (int w=0; w < ics.numWindows; w++) {
    int bottom=ics.numSwb;
    for (int filt=0; filt < tns.nFilt[w]; filt++) {
      int top=bottom;
      bottom=Math.max(0,top - tns.length[w][filt]);
      int order=tns.order[w][filt];
      if (order == 0) {
        continue;
      }
      computeLpcCoefs(tns.coef[w][filt],order,lpc,0,false,false);
      int start=ics.swbOffset[Math.min(bottom,mmm)];
      int end=ics.swbOffset[Math.min(top,mmm)];
      int size=end - start;
      if (size <= 0) {
        continue;
      }
      int inc;
      if (tns.direction[w][filt]) {
        inc=-1;
        start=end - 1;
      }
 else {
        inc=1;
      }
      start+=w * 128;
      if (decode) {
        for (int m=0; m < size; m++, start+=inc) {
          for (int i=1; i <= Math.min(m,order); i++) {
            coef[start]-=coef[start - i * inc] * lpc[i - 1];
          }
        }
      }
 else {
        for (int m=0; m < size; m++, start+=inc) {
          tmp[0]=coef[start];
          for (int i=1; i <= Math.min(m,order); i++) {
            coef[start]+=tmp[i] * lpc[i - 1];
          }
          for (int i=order; i > 0; i--) {
            tmp[i]=tmp[i - 1];
          }
        }
      }
    }
  }
}

private void applyTns ( float coef [ ] , TemporalNoiseShaping tns , IndividualChannelStream ics , boolean decode ) { final int mmm = Math . min ( ics . tnsMaxBands , ics . maxSfb ) ; final float lpc [ ] = new float [ TNS_MAX_ORDER ] ; final float tmp [ ] = new float [ TNS_MAX_ORDER + 1 ] ; for ( int w = 0 ; w < ics . numWindows ; w ++ ) { int bottom = ics . numSwb ; for ( int filt = 0 ; filt < tns . nFilt [ w ] ; filt ++ ) { int top = bottom ; bottom = Math . max ( 0 , top - tns . length [ w ] [ filt ] ) ; int order = tns . order [ w ] [ filt ] ; if ( order == 0 ) { continue ; } computeLpcCoefs ( tns . coef [ w ] [ filt ] , order , lpc , 0 , false , false ) ; int start = ics . swbOffset [ Math . min ( bottom , mmm ) ] ; int end = ics . swbOffset [ Math . min ( top , mmm ) ] ; int size = end - start ; if ( size <= 0 ) { continue ; } int inc ; if ( tns . direction [ w ] [ filt ] ) { inc = - 1 ; start = end - 1 ; } else { inc = 1 ; } start += w * 128 ; if ( decode ) { for ( int m = 0 ; m < size ; m ++ , start += inc ) { for ( int i = 1 ; i <= Math . min ( m , order ) ; i ++ ) { coef [ start ] -= coef [ start - i * inc ] * lpc [ i - 1 ] ; } } } else { for ( int m = 0 ; m < size ; m ++ , start += inc ) { tmp [ 0 ] = coef [ start ] ; for ( int i = 1 ; i <= Math . min ( m , order ) ; i ++ ) { coef [ start ] += tmp [ i ] * lpc [ i - 1 ] ; } for ( int i = order ; i > 0 ; i -- ) { tmp [ i ] = tmp [ i - 1 ] ; } } } } } }
decode temporal noise shaping filter coefficients and apply all - pole filters ; reference : 4 . 6 . 9 . 3 .
