Main Page | Class Hierarchy | Class List | Directories | Class Members

BitParser Class Reference

A BitParser maintains a cursor into a BitStream. More...

#include <mnt_bit_parser.h>

List of all members.

Public Member Functions

int find_any_mpeg_hdr ()
 Move cursor the the beginning of the next MPEG sequence, GOP, or picture header.
int next_start_code (unsigned int *offsetPtr)
 This method is deprecated.
int next_mpeg_start_code (unsigned int *offsetPtr)
 Return the next start code in bitstream bp.
int dump_until_next_start_code (BitParser *outbp, unsigned int *offsetPtr)
 Similar to next_mpeg_start_code, but in this case, bytes parsed are written into another BitStream via another BitParser object.
int get_curr_start_code ()
 Assuming that the cursor is at the beginning of a MPEG start code, this method returns the start code.
 BitParser ()
 Create an empty BitParser, not pointing to any BitStream.
void copy_to (BitParser *dest)
 Create a copy of this BitParser.
void wrap (BitStream *bs)
 Attach this BitParser object to a BitStream bs.
void seek (int off)
 Move the cursor of this BitParser to given byte offset.
int tell ()
 Return the position of the cursor of this BitParser.

Public Attributes

BitStreambs
unsigned char * offsetPtr
int currentBits
int bitCount


Detailed Description

A BitParser maintains a cursor into a BitStream.

Reading and writing to and from a BitStream are usually done via a BitParser.

The BitParser API includes a bunch of macros that provides bit-level access interface to the content of the BitStream. A bitparser can be either output BitParser, which writes into the BitStream, or input BitParser, which reads from the BitStream. Both type of BitParser can operates in two modes: bit-modes or byte-modes. Calling byte-mode macros when the bitparser is in bit-mode can produce wrong result.

We can switch from bit-mode to byte-mode by calling Bp_InByteAlign (also called Bp_ByteAlign) or Bp_OutByteAlign. Switching from byte-mode to bit-mode is implicit whenever we called a bit-mode macros.

BitParser macros name takes the format of Bp_ActionUnit, where Action specifies what we are going to do, and Unit tell us how much data we are going to work on. Unit can be either Bits, Byte, Short, Int, Bytes. If Unit is bits, then we should not act on more than 16 bits from the BitStream. If more than 16 bits is required, we should divide the operation into two invocations.

Action

For instance, Bp_GetBits(bp,num,val) get num of bits and store the value in val.


Constructor & Destructor Documentation

BitParser::BitParser  ) 
 

Create an empty BitParser, not pointing to any BitStream.

wrap() should be called to attach this BitParser to a BitStream object.


Member Function Documentation

void BitParser::copy_to BitParser dest  ) 
 

Create a copy of this BitParser.

Note that the BitStream is not copied. Thus both the current and new BitParser objects points to the same BitStream.

Parameters:
dest Another BitParser object which we are copying this BitParser to.

int BitParser::dump_until_next_start_code BitParser outbp,
unsigned int *  offsetPtr
 

Similar to next_mpeg_start_code, but in this case, bytes parsed are written into another BitStream via another BitParser object.

Parameters:
outbp BitParser to write to.
offsetPtr Pointer to an integer which will stores the number of bytes parsed.

int BitParser::find_any_mpeg_hdr  ) 
 

Move cursor the the beginning of the next MPEG sequence, GOP, or picture header.

Returns:
The number of bytes parsed, or -1 if no header is found.

int BitParser::get_curr_start_code  ) 
 

Assuming that the cursor is at the beginning of a MPEG start code, this method returns the start code.

No bytes are parsed from the BitStream.

Returns:
The start code the current cursor is pointing to.

int BitParser::next_mpeg_start_code unsigned int *  offsetPtr  ) 
 

Return the next start code in bitstream bp.

Record the byte offset to the beginning of the code in offsetPtr. After this function call, the cursor will be positioned *after* the start code.

Returns:
The code value, or 0 if no code is found.
Parameters:
offsetPtr pointer to an integer, which will be updated with the number of bytes parsed until the beginning of the start code.

int BitParser::next_start_code unsigned int *  offsetPtr  ) 
 

This method is deprecated.

Please use next_mpeg_start_code()

void BitParser::seek int  off  ) 
 

Move the cursor of this BitParser to given byte offset.

Parameters:
off Byte offset to move cursor to.

int BitParser::tell  ) 
 

Return the position of the cursor of this BitParser.

This is the offset, in bytes, from the beginning of the BitStream to which this BitParser is attached.

void BitParser::wrap BitStream bs  ) 
 

Attach this BitParser object to a BitStream bs.

The cursor of this BitParser will be set to the first byte in bs. All future reads from and writes to bs will modify the data in this BitParser. All future writes using this BitParser will modify data in bs.

Parameters:
bs BitStream object to attach this BitParser to.


Member Data Documentation

int BitParser::bitCount
 

number of unconsumed bits in the currentBits.

BitStream* BitParser::bs
 

pointer to the BitStream the BitParser is attached to.

int BitParser::currentBits
 

32-bits data in the BitStream just before offsetPtr.

unsigned char* BitParser::offsetPtr
 

pointer to the next unconsumed byte inside the BitStream.


The documentation for this class was generated from the following files:
Generated on Wed Sep 14 12:37:11 2005 for mnt by  doxygen 1.4.4