liveMedia/BitVector.cpp File Reference

#include "BitVector.hh"

Include dependency graph for BitVector.cpp:

Go to the source code of this file.

Defines

#define MAX_LENGTH   32

Functions

void shiftBits (unsigned char *toBasePtr, unsigned toBitOffset, unsigned char const *fromBasePtr, unsigned fromBitOffset, unsigned numBits)

Variables

static unsigned char const singleBitMask [8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}


Define Documentation

#define MAX_LENGTH   32

Definition at line 41 of file BitVector.cpp.

Referenced by BitVector::getBits(), and BitVector::putBits().


Function Documentation

void shiftBits ( unsigned char *  toBasePtr,
unsigned  toBitOffset,
unsigned char const *  fromBasePtr,
unsigned  fromBitOffset,
unsigned  numBits 
)

Definition at line 129 of file BitVector.cpp.

References singleBitMask.

Referenced by BitVector::getBits(), BitVector::putBits(), TranscodeMP3ADU(), and unpackBandwidthEfficientData().

00131                                  {
00132   /* Note that from and to may overlap, if from>to */
00133   unsigned char const* fromBytePtr = fromBasePtr + fromBitOffset/8;
00134   unsigned fromBitRem = fromBitOffset%8;
00135   unsigned char* toBytePtr = toBasePtr + toBitOffset/8;
00136   unsigned toBitRem = toBitOffset%8;
00137 
00138   while (numBits-- > 0) {
00139     unsigned char fromBitMask = singleBitMask[fromBitRem];
00140     unsigned char fromBit = (*fromBytePtr)&fromBitMask;
00141     unsigned char toBitMask = singleBitMask[toBitRem];
00142 
00143     if (fromBit != 0) {
00144       *toBytePtr |= toBitMask;
00145     } else {
00146       *toBytePtr &=~ toBitMask;
00147     }
00148 
00149     if (++fromBitRem == 8) {
00150       ++fromBytePtr;
00151       fromBitRem = 0;
00152     }
00153     if (++toBitRem == 8) {
00154       ++toBytePtr;
00155       toBitRem = 0;
00156     }
00157   }
00158 }


Variable Documentation

unsigned char const singleBitMask[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01} [static]

Definition at line 39 of file BitVector.cpp.

Referenced by BitVector::put1Bit(), and shiftBits().


Generated on Tue Oct 7 15:38:23 2008 for live by  doxygen 1.5.2