private int decodeIcsInfo(IndividualChannelStream ics){
  int aot=ac.oc[1].m4ac.objectType;
  if (aot != AOT_ER_AAC_ELD) {
    if (br.readBool()) {
      log.error(String.format("Reserved bit set"));
      return AAC_ERROR;
    }
    ics.windowSequence[1]=ics.windowSequence[0];
    ics.windowSequence[0]=br.read(2);
    if (aot == AOT_ER_AAC_LD && ics.windowSequence[0] != ONLY_LONG_SEQUENCE) {
      log.error(String.format("AAC LD is only defined for ONLY_LONG_SEQUENCE but window sequence %d found",ics.windowSequence[0]));
      ics.windowSequence[0]=ONLY_LONG_SEQUENCE;
      return AAC_ERROR;
    }
    ics.useKbWindow[1]=ics.useKbWindow[0];
    ics.useKbWindow[0]=br.readBool();
  }
  ics.numWindowGroups=1;
  ics.groupLen[0]=1;
  if (ics.windowSequence[0] == EIGHT_SHORT_SEQUENCE) {
    ics.maxSfb=br.read(4);
    for (int i=0; i < 7; i++) {
      if (br.readBool()) {
        ics.groupLen[ics.numWindowGroups - 1]++;
      }
 else {
        ics.numWindowGroups++;
        ics.groupLen[ics.numWindowGroups - 1]=1;
      }
    }
    ics.numWindows=8;
    ics.swbOffset=ff_swb_offset_128[ac.oc[1].m4ac.samplingIndex];
    ics.numSwb=ff_aac_num_swb_128[ac.oc[1].m4ac.samplingIndex];
    ics.tnsMaxBands=ff_tns_max_bands_128[ac.oc[1].m4ac.samplingIndex];
    ics.predictorPresent=false;
  }
 else {
    ics.maxSfb=br.read(6);
    ics.numWindows=1;
    if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD) {
      ics.swbOffset=ff_swb_offset_512[ac.oc[1].m4ac.samplingIndex];
      ics.numSwb=ff_aac_num_swb_512[ac.oc[1].m4ac.samplingIndex];
      ics.tnsMaxBands=ff_tns_max_bands_512[ac.oc[1].m4ac.samplingIndex];
      if (ics.numSwb == 0 || ics.swbOffset == null) {
        return AAC_ERROR;
      }
    }
 else {
      ics.swbOffset=ff_swb_offset_1024[ac.oc[1].m4ac.samplingIndex];
      ics.numSwb=ff_aac_num_swb_1024[ac.oc[1].m4ac.samplingIndex];
      ics.tnsMaxBands=ff_tns_max_bands_1024[ac.oc[1].m4ac.samplingIndex];
    }
    if (aot != AOT_ER_AAC_ELD) {
      ics.predictorPresent=br.readBool();
      ics.predictorResetGroup=0;
    }
    if (ics.predictorPresent) {
      if (aot == AOT_AAC_MAIN) {
        if (decodePrediction(ics) != 0) {
          ics.maxSfb=0;
          return AAC_ERROR;
        }
      }
 else       if (aot == AOT_AAC_LC || aot == AOT_ER_AAC_LC) {
        log.error(String.format("Prediction is not allowed in AAC-LC"));
        ics.maxSfb=0;
        return AAC_ERROR;
      }
 else {
        if (aot == AOT_ER_AAC_LD) {
          log.error(String.format("LTP in ER AAC LD not yet implemented"));
          return AAC_ERROR;
        }
        ics.ltp.present=br.readBool();
        if (ics.ltp.present) {
          decodeLtp(ics.ltp,ics.maxSfb);
        }
      }
    }
  }
  if (ics.maxSfb > ics.numSwb) {
    log.error(String.format("Number of scalefactor bands in group (%d) exceeds limit (%d)",ics.maxSfb,ics.numSwb));
    ics.maxSfb=0;
    return AAC_ERROR;
  }
  return 0;
}

private int decodeIcsInfo ( IndividualChannelStream ics ) { int aot = ac . oc [ 1 ] . m4ac . objectType ; if ( aot != AOT_ER_AAC_ELD ) { if ( br . readBool ( ) ) { log . error ( String . format ( "Reserved bit set" ) ) ; return AAC_ERROR ; } ics . windowSequence [ 1 ] = ics . windowSequence [ 0 ] ; ics . windowSequence [ 0 ] = br . read ( 2 ) ; if ( aot == AOT_ER_AAC_LD && ics . windowSequence [ 0 ] != ONLY_LONG_SEQUENCE ) { log . error ( String . format ( "AAC LD is only defined for ONLY_LONG_SEQUENCE but window sequence %d found" , ics . windowSequence [ 0 ] ) ) ; ics . windowSequence [ 0 ] = ONLY_LONG_SEQUENCE ; return AAC_ERROR ; } ics . useKbWindow [ 1 ] = ics . useKbWindow [ 0 ] ; ics . useKbWindow [ 0 ] = br . readBool ( ) ; } ics . numWindowGroups = 1 ; ics . groupLen [ 0 ] = 1 ; if ( ics . windowSequence [ 0 ] == EIGHT_SHORT_SEQUENCE ) { ics . maxSfb = br . read ( 4 ) ; for ( int i = 0 ; i < 7 ; i ++ ) { if ( br . readBool ( ) ) { ics . groupLen [ ics . numWindowGroups - 1 ] ++ ; } else { ics . numWindowGroups ++ ; ics . groupLen [ ics . numWindowGroups - 1 ] = 1 ; } } ics . numWindows = 8 ; ics . swbOffset = ff_swb_offset_128 [ ac . oc [ 1 ] . m4ac . samplingIndex ] ; ics . numSwb = ff_aac_num_swb_128 [ ac . oc [ 1 ] . m4ac . samplingIndex ] ; ics . tnsMaxBands = ff_tns_max_bands_128 [ ac . oc [ 1 ] . m4ac . samplingIndex ] ; ics . predictorPresent = false ; } else { ics . maxSfb = br . read ( 6 ) ; ics . numWindows = 1 ; if ( aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD ) { ics . swbOffset = ff_swb_offset_512 [ ac . oc [ 1 ] . m4ac . samplingIndex ] ; ics . numSwb = ff_aac_num_swb_512 [ ac . oc [ 1 ] . m4ac . samplingIndex ] ; ics . tnsMaxBands = ff_tns_max_bands_512 [ ac . oc [ 1 ] . m4ac . samplingIndex ] ; if ( ics . numSwb == 0 || ics . swbOffset == null ) { return AAC_ERROR ; } } else { ics . swbOffset = ff_swb_offset_1024 [ ac . oc [ 1 ] . m4ac . samplingIndex ] ; ics . numSwb = ff_aac_num_swb_1024 [ ac . oc [ 1 ] . m4ac . samplingIndex ] ; ics . tnsMaxBands = ff_tns_max_bands_1024 [ ac . oc [ 1 ] . m4ac . samplingIndex ] ; } if ( aot != AOT_ER_AAC_ELD ) { ics . predictorPresent = br . readBool ( ) ; ics . predictorResetGroup = 0 ; } if ( ics . predictorPresent ) { if ( aot == AOT_AAC_MAIN ) { if ( decodePrediction ( ics ) != 0 ) { ics . maxSfb = 0 ; return AAC_ERROR ; } } else if ( aot == AOT_AAC_LC || aot == AOT_ER_AAC_LC ) { log . error ( String . format ( "Prediction is not allowed in AAC-LC" ) ) ; ics . maxSfb = 0 ; return AAC_ERROR ; } else { if ( aot == AOT_ER_AAC_LD ) { log . error ( String . format ( "LTP in ER AAC LD not yet implemented" ) ) ; return AAC_ERROR ; } ics . ltp . present = br . readBool ( ) ; if ( ics . ltp . present ) { decodeLtp ( ics . ltp , ics . maxSfb ) ; } } } } if ( ics . maxSfb > ics . numSwb ) { log . error ( String . format ( "Number of scalefactor bands in group (%d) exceeds limit (%d)" , ics . maxSfb , ics . numSwb ) ) ; ics . maxSfb = 0 ; return AAC_ERROR ; } return 0 ; }
decode individual channel stream info ; reference : table 4 . 6 .
