liveMedia/BitVector.hh

Go to the documentation of this file.
00001 /**********
00002 This library is free software; you can redistribute it and/or modify it under
00003 the terms of the GNU Lesser General Public License as published by the
00004 Free Software Foundation; either version 2.1 of the License, or (at your
00005 option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
00006 
00007 This library is distributed in the hope that it will be useful, but WITHOUT
00008 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00009 FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
00010 more details.
00011 
00012 You should have received a copy of the GNU Lesser General Public License
00013 along with this library; if not, write to the Free Software Foundation, Inc.,
00014 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
00015 **********/
00016 // "liveMedia"
00017 // Copyright (c) 1996-2013 Live Networks, Inc.  All rights reserved.
00018 // Bit Vector data structure
00019 // C++ header
00020 
00021 #ifndef _BIT_VECTOR_HH
00022 #define _BIT_VECTOR_HH
00023 
00024 #ifndef _BOOLEAN_HH
00025 #include "Boolean.hh"
00026 #endif
00027 
00028 class BitVector {
00029 public:
00030   BitVector(unsigned char* baseBytePtr,
00031             unsigned baseBitOffset,
00032             unsigned totNumBits);
00033 
00034   void setup(unsigned char* baseBytePtr,
00035              unsigned baseBitOffset,
00036              unsigned totNumBits);
00037 
00038   void putBits(unsigned from, unsigned numBits); // "numBits" <= 32
00039   void put1Bit(unsigned bit);
00040 
00041   unsigned getBits(unsigned numBits); // "numBits" <= 32
00042   unsigned get1Bit();
00043   Boolean get1BitBoolean() { return get1Bit() != 0; }
00044 
00045   void skipBits(unsigned numBits);
00046 
00047   unsigned curBitIndex() const { return fCurBitIndex; }
00048   unsigned totNumBits() const { return fTotNumBits; }
00049   unsigned numBitsRemaining() const { return fTotNumBits - fCurBitIndex; }
00050 
00051   unsigned get_expGolomb();
00052       // Returns the value of the next bits, assuming that they were encoded using an exponential-Golomb code of order 0
00053 
00054 private:
00055   unsigned char* fBaseBytePtr;
00056   unsigned fBaseBitOffset;
00057   unsigned fTotNumBits;
00058   unsigned fCurBitIndex;
00059 };
00060 
00061 // A general bit copy operation:
00062 void shiftBits(unsigned char* toBasePtr, unsigned toBitOffset,
00063                unsigned char const* fromBasePtr, unsigned fromBitOffset,
00064                unsigned numBits);
00065 
00066 #endif

Generated on Mon Apr 29 13:28:01 2013 for live by  doxygen 1.5.2