packetsize = SbEncoder.NB_FRAME_SIZE[SbEncoder.NB_QUALITY_MAP[encoder.getEncoder().getMode()]]; packetsize += SbEncoder.SB_FRAME_SIZE[SbEncoder.WB_QUALITY_MAP[encoder.getEncoder().getMode()]]; packetsize = (packetsize + 7) >> 3;  avail += (27 + packetsPerOggPage + packetsPerOggPage * packetsize) * (unencoded / (packetsPerOggPage * framesPerPacket * 640));
spxpacketsize = SbEncoder.NB_FRAME_SIZE[SbEncoder.NB_QUALITY_MAP[encoder.getEncoder().getMode()]]; spxpacketsize += SbEncoder.SB_FRAME_SIZE[SbEncoder.WB_QUALITY_MAP[encoder.getEncoder().getMode()]]; spxpacketsize *= framesPerPacket; spxpacketsize = (spxpacketsize + 7) >> 3;  oggpacketsize = 27 + packetsPerOggPage * (spxpacketsize + 1);  pcmframesize = framesPerPacket * 640 * encoder.getChannels(); avail += oggpacketsize * (unencoded / (packetsPerOggPage * pcmframesize));
  public synchronized int available()    throws IOException  {    int avail = super.available();    int unencoded = precount - prepos + in.available();    if (encoder.getEncoder().getVbr()) {      switch (mode) {        case 0: // Narrowband          // ogg header size = 27 + packetsPerOggPage          // count 1 byte (min 5 bits) for each block available          return avail + (27 + 2 * packetsPerOggPage) *                         (unencoded / (packetsPerOggPage*framesPerPacket*320));        case 1: // Wideband          // ogg header size = 27 + packetsPerOggPage          // count 2 byte (min 9 bits) for each block available          return avail + (27 + 2 * packetsPerOggPage) *                         (unencoded / (packetsPerOggPage*framesPerPacket*640));        case 2: // Ultra wideband          // ogg header size = 27 + packetsPerOggPage          // count 2 byte (min 13 bits) for each block available          return avail + (27 + 3 * packetsPerOggPage) *                         (unencoded / (packetsPerOggPage*framesPerPacket*1280));        default:          return avail;      }    }    else {      int packetsize;      switch (mode) {        case 0: // Narrowband          packetsize = NbEncoder.NB_FRAME_SIZE[NbEncoder.NB_QUALITY_MAP[encoder.getEncoder().getMode()]];          packetsize = (packetsize + 7) >> 3; // convert packetsize to bytes          // 1 frame = 20ms = 160ech = 320bytes          avail += (27 + packetsPerOggPage + packetsPerOggPage * packetsize) *                   (unencoded / (packetsPerOggPage * framesPerPacket * 320));          return avail;        case 1: // Wideband          packetsize = SbEncoder.NB_FRAME_SIZE[SbEncoder.NB_QUALITY_MAP[encoder.getEncoder().getMode()]];          packetsize += SbEncoder.SB_FRAME_SIZE[SbEncoder.WB_QUALITY_MAP[encoder.getEncoder().getMode()]];          packetsize = (packetsize + 7) >> 3; // convert packetsize to bytes          // 1 frame = 20ms = 320ech = 640bytes          avail += (27 + packetsPerOggPage + packetsPerOggPage * packetsize) *                   (unencoded / (packetsPerOggPage * framesPerPacket * 640));          return avail;        case 2: // Ultra wideband          packetsize = SbEncoder.NB_FRAME_SIZE[SbEncoder.NB_QUALITY_MAP[encoder.getEncoder().getMode()]];          packetsize += SbEncoder.SB_FRAME_SIZE[SbEncoder.WB_QUALITY_MAP[encoder.getEncoder().getMode()]];          packetsize += SbEncoder.SB_FRAME_SIZE[SbEncoder.UWB_QUALITY_MAP[encoder.getEncoder().getMode()]];          packetsize = (packetsize + 7) >> 3; // convert packetsize to bytes          // 1 frame = 20ms = 640ech = 1280bytes          avail += (27 + packetsPerOggPage + packetsPerOggPage * packetsize) *                   (unencoded / (packetsPerOggPage * framesPerPacket * 1280));          return avail;        default:          return avail;      }    }  }