protected void decode(final byte[] data,
                        final int offset,
                        final int len)
    throws StreamCorruptedException
  {
    int i;
    short val;
    int outputSize = 0;
    /* read packet bytes into bitstream */
    bits.read_from(data, offset, len);
    for (int frame=0; frame<framesPerPacket; frame++) {
      /* decode the bitstream */
      decoder.decode(bits, decodedData);
      if (channelCount == 2)
        decoder.decodeStereo(decodedData, frameSize);
      /* PCM saturation */
      for (i=0; i<frameSize*channelCount; i++) {
        if (decodedData[i] > 32767.0f)
          decodedData[i] = 32767.0f;
        else if (decodedData[i] < -32768.0f)
          decodedData[i] = -32768.0f;
      }
      /* convert to short and save to buffer */
      for (i=0; i<frameSize*channelCount; i++) {
        val = (decodedData[i]>0) ? (short)(decodedData[i]+.5) :
                                   (short)(decodedData[i]-.5);
        outputData[outputSize++] = (byte) (val & 0xff);
        outputData[outputSize++] = (byte) ((val >> 8) &  0xff );
      }
    }
  }