BitParser Class Reference
#include <mnt_bit_parser.h>
List of all members.
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
-
Get: Consume data from the bitstream and output the value of the data. Advance the cursor.
-
Unget (also called Restore) Move the cursor back.
-
Peek: Same as Get but does not advance the cursor.
-
Flush: Same as Get but the value is ignored.
-
Put: Write data into the BitStream.
-
Unput: Undo writing of data into the BitStream.
-
Move: Get from one BitStream and Put into another.
For instance, Bp_GetBits(bp,num,val) get num
of bits and store the value in val
.
Constructor & Destructor Documentation
|
Create an empty BitParser, not pointing to any BitStream. wrap() should be called to attach this BitParser to a BitStream object. |
Member Function Documentation
|
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 |
) |
|
|
void BitParser::seek |
( |
int |
off |
) |
|
|
|
Move the cursor of this BitParser to given byte offset.
- Parameters:
-
| off | Byte offset to move cursor to. |
|
|
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. |
|
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
|
number of unconsumed bits in the currentBits. |
|
pointer to the BitStream the BitParser is attached to. |
|
32-bits data in the BitStream just before offsetPtr. |
|
pointer to the next unconsumed byte inside the BitStream. |
The documentation for this class was generated from the following files:
- /Users/ooiwt/5248proj/stage1/src/mnt_bit_parser.h
- /Users/ooiwt/5248proj/stage1/src/mnt_bit_parser.cc
Generated on Thu Aug 25 14:07:38 2005 for mnt by
1.4.4