private int decodeBandTypes(int bandType[],int bandTypeRunEnd[],IndividualChannelStream ics){
  int idx=0;
  final int bits=(ics.windowSequence[0] == EIGHT_SHORT_SEQUENCE) ? 3 : 5;
  for (int g=0; g < ics.numWindowGroups; g++) {
    int k=0;
    while (k < ics.maxSfb) {
      int sectEnd=k;
      int sectBandType=br.read(4);
      if (sectBandType == 12) {
        log.error(String.format("invalid band type"));
        return AAC_ERROR;
      }
      int sectLenIncr;
      do {
        sectLenIncr=br.read(bits);
        sectEnd+=sectLenIncr;
        if (br.getBitsLeft() < 0) {
          log.error(String.format("decodeBandTypes overread error"));
          return AAC_ERROR;
        }
        if (sectEnd > ics.maxSfb) {
          log.error(String.format("Number of bands (%d) exceeds limit (%d)",sectEnd,ics.maxSfb));
          return AAC_ERROR;
        }
      }
 while (sectLenIncr == (1 << bits) - 1);
      for (; k < sectEnd; k++) {
        bandType[idx]=sectBandType;
        bandTypeRunEnd[idx++]=sectEnd;
      }
    }
  }
  return 0;
}

private int decodeBandTypes ( int bandType [ ] , int bandTypeRunEnd [ ] , IndividualChannelStream ics ) { int idx = 0 ; final int bits = ( ics . windowSequence [ 0 ] == EIGHT_SHORT_SEQUENCE ) ? 3 : 5 ; for ( int g = 0 ; g < ics . numWindowGroups ; g ++ ) { int k = 0 ; while ( k < ics . maxSfb ) { int sectEnd = k ; int sectBandType = br . read ( 4 ) ; if ( sectBandType == 12 ) { log . error ( String . format ( "invalid band type" ) ) ; return AAC_ERROR ; } int sectLenIncr ; do { sectLenIncr = br . read ( bits ) ; sectEnd += sectLenIncr ; if ( br . getBitsLeft ( ) < 0 ) { log . error ( String . format ( "decodeBandTypes overread error" ) ) ; return AAC_ERROR ; } if ( sectEnd > ics . maxSfb ) { log . error ( String . format ( "Number of bands (%d) exceeds limit (%d)" , sectEnd , ics . maxSfb ) ) ; return AAC_ERROR ; } } while ( sectLenIncr == ( 1 << bits ) - 1 ) ; for ( ; k < sectEnd ; k ++ ) { bandType [ idx ] = sectBandType ; bandTypeRunEnd [ idx ++ ] = sectEnd ; } } } return 0 ; }
decode band types ( section_data payload ) ; reference : table 4 . 46 .
