Logo Search packages:      
Sourcecode: libjlayer-java version File versions  Download package

int javazoom::jl::decoder::Bitstream::get_bits ( int  number_of_bits  )  [inline]

Read bits from buffer into the lower bits of an unsigned int. The LSB contains the latest read bit of the stream. (1 <= number_of_bits <= 16)

Definition at line 537 of file Bitstream.java.

References bitindex, framebuffer, and wordpointer.

Referenced by javazoom::jl::decoder::LayerIIIDecoder::get_side_info().

  {
      int                     returnvalue = 0;
      int               sum = bitindex + number_of_bits;

      // E.B
      // There is a problem here, wordpointer could be -1 ?!
    if (wordpointer < 0) wordpointer = 0;
    // E.B : End.

      if (sum <= 32)
      {
         // all bits contained in *wordpointer
         returnvalue = (framebuffer[wordpointer] >>> (32 - sum)) & bitmask[number_of_bits];
         // returnvalue = (wordpointer[0] >> (32 - sum)) & bitmask[number_of_bits];
         if ((bitindex += number_of_bits) == 32)
         {
             bitindex = 0;
             wordpointer++; // added by me!
         }
         return returnvalue;
    }

    // E.B : Check that ?
    //((short[])&returnvalue)[0] = ((short[])wordpointer + 1)[0];
    //wordpointer++; // Added by me!
    //((short[])&returnvalue + 1)[0] = ((short[])wordpointer)[0];
      int Right = (framebuffer[wordpointer] & 0x0000FFFF);
      wordpointer++;
      int Left = (framebuffer[wordpointer] & 0xFFFF0000);
      returnvalue = ((Right << 16) & 0xFFFF0000) | ((Left >>> 16)& 0x0000FFFF);

    returnvalue >>>= 48 - sum;      // returnvalue >>= 16 - (number_of_bits - (32 - bitindex))
    returnvalue &= bitmask[number_of_bits];
    bitindex = sum - 32;
    return returnvalue;
}


Generated by  Doxygen 1.6.0   Back to index