#include <mnt_bit_parser.h>
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 | |
BitStream * | bs |
unsigned char * | offsetPtr |
int | currentBits |
int | bitCount |
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
.
|
Create an empty BitParser, not pointing to any BitStream. wrap() should be called to attach this BitParser to a BitStream object. |
|
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.
|
|
Similar to next_mpeg_start_code, but in this case, bytes parsed are written into another BitStream via another BitParser object.
|
|
Move cursor the the beginning of the next MPEG sequence, GOP, or picture header.
|
|
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.
|
|
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.
|
|
This method is deprecated. Please use next_mpeg_start_code() |
|
Move the cursor of this BitParser to given byte offset.
|
|
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.
|
|
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. |