private int decodeTns(TemporalNoiseShaping tns,IndividualChannelStream ics){
  final int is8=ics.windowSequence[0] == EIGHT_SHORT_SEQUENCE ? 1 : 0;
  final int tnsMaxOrder=is8 != 0 ? 7 : ac.oc[1].m4ac.objectType == AOT_AAC_MAIN ? 20 : 12;
  for (int w=0; w < ics.numWindows; w++) {
    tns.nFilt[w]=br.read(2 - is8);
    if (tns.nFilt[w] != 0) {
      int coefRes=br.read1();
      for (int filt=0; filt < tns.nFilt[w]; filt++) {
        tns.length[w][filt]=br.read(6 - 2 * is8);
        tns.order[w][filt]=br.read(5 - 2 * is8);
        if (tns.order[w][filt] > tnsMaxOrder) {
          log.error(String.format("TNS filter order %d is greater than maximum %d",tns.order[w][filt],tnsMaxOrder));
          tns.order[w][filt]=0;
          return AAC_ERROR;
        }
        if (tns.order[w][filt] > 0) {
          tns.direction[w][filt]=br.readBool();
          int coefCompress=br.read1();
          int coefLen=coefRes + 3 - coefCompress;
          int tmp2Idx=2 * coefCompress + coefRes;
          for (int i=0; i < tns.order[w][filt]; i++) {
            tns.coef[w][filt][i]=tns_tmp2_map[tmp2Idx][br.read(coefLen)];
          }
        }
      }
    }
  }
  return 0;
}

private int decodeTns ( TemporalNoiseShaping tns , IndividualChannelStream ics ) { final int is8 = ics . windowSequence [ 0 ] == EIGHT_SHORT_SEQUENCE ? 1 : 0 ; final int tnsMaxOrder = is8 != 0 ? 7 : ac . oc [ 1 ] . m4ac . objectType == AOT_AAC_MAIN ? 20 : 12 ; for ( int w = 0 ; w < ics . numWindows ; w ++ ) { tns . nFilt [ w ] = br . read ( 2 - is8 ) ; if ( tns . nFilt [ w ] != 0 ) { int coefRes = br . read1 ( ) ; for ( int filt = 0 ; filt < tns . nFilt [ w ] ; filt ++ ) { tns . length [ w ] [ filt ] = br . read ( 6 - 2 * is8 ) ; tns . order [ w ] [ filt ] = br . read ( 5 - 2 * is8 ) ; if ( tns . order [ w ] [ filt ] > tnsMaxOrder ) { log . error ( String . format ( "TNS filter order %d is greater than maximum %d" , tns . order [ w ] [ filt ] , tnsMaxOrder ) ) ; tns . order [ w ] [ filt ] = 0 ; return AAC_ERROR ; } if ( tns . order [ w ] [ filt ] > 0 ) { tns . direction [ w ] [ filt ] = br . readBool ( ) ; int coefCompress = br . read1 ( ) ; int coefLen = coefRes + 3 - coefCompress ; int tmp2Idx = 2 * coefCompress + coefRes ; for ( int i = 0 ; i < tns . order [ w ] [ filt ] ; i ++ ) { tns . coef [ w ] [ filt ] [ i ] = tns_tmp2_map [ tmp2Idx ] [ br . read ( coefLen ) ] ; } } } } } return 0 ; }
decode temporal noise shaping data ; reference : table 4 . 48 .
