#include <dvmmpeg.h>
This structure encapsulates a packet header in MPEG system streams. It contains information about a packet (which is part of either a video or audio stream).
typedef struct MpegPktHdr { int streamId; int packetLength; int bufferSize; double pts; double dts; } MpegPktHdr;
- streamId
- The id of the stream this packet belongs to. This value is stored as it is read from the bitstream. So the range is between 192 and 239. To find the actual stream id, substract 192 from this field. If the result is between 0 - 31, it indicates that the stream it belongs to is an audio stream; 32 - 47 indicates that the stream it belongs to is a video stream.
- packetLength
- The length of this packet in bytes. This includes the rest of the header after the packetLength field.
- buffersize
- The maximum decoding buffer size in bytes.
- pts
- The presentation time stamp for this packet. It indicates the intended time of presentation of this decoder. The timestamp is decoded and stored in this header.
- dts
- The decoding time stamp for this packet. It indicates the intended time of decoding of this packet. The timestamp is decoded and stored in this header.
This structure encapsulates a pack header from a MPEG system stream.
typedef struct MpegPckHdr { double sysClockRef; int muxRate; } MpegPckHdr;
- sysClockRef
- The system clock reference (intended arrival time of the last byte of this field to the decoder).
- muxRate
- The rate where the decoder should receive the system stream. in bytes/second.
This structure encapsulates the system header from a MPEG system stream.
typedef struct MpegSysHdr { int rateBound; unsigned char audioBound; unsigned char fixedFlag; unsigned char cspsFlag; unsigned char audioLock; unsigned char videoLock; unsigned char videoBound; unsigned char numOfStreamInfo; unsigned char streamId[48]; int bufferSize[48]; } MpegSysHdr;
- rateBound
- The upper bound for muxRate.
- audioBound
- This is greater than or equal to the maximum number of simultaneous active audio streams. It must be less than 32.
- fixedFlag
- This is 1 if the bitrate is fixed.
- cspsFlag
- This is 1 if the stream is a constrained system parameter stream.
- audioLock
- This is 1 if there is a constant relationship between the audio sampling rate and the system clock frequency.
- videoLock
- This is 1 if there is a constant relationship between the video frame rate and the system clock frequency.
- videoBound
- An upper bound for the maximum number of simultaneous active video streams.
- numOfStreamInfo
- The number of entries in the streamId array.
- streamId
- The stream id for the corresponding entry in the bufferSize array.
- bufferSize
- The decoding buffer size of each stream. For example, if bufferSize[0] = 40960 and streamId[0] = 32, then the buffer size of stream 32 should be 40960.
This structure maintains the information about a stream, including the number of packets, a filter for this stream and presentation times of packets from this stream.
typedef struct StreamInfo { int numOfPacket; int max; BitStreamFilter *index; float *time; } StreamInfo;
- numOfPacket
- The total number of packets in the stream.
- max
- The maximum number of allocated elements in the time array.
- index
- This is a pointer to a BitStreamFilter structure that contains a filter for this stream.
- time
- This is an array of floats which keep track of the presentation time stamps from the packet header. If a time stamp is not specified, then the corresponding element in the array is set to -1.
This structure stores informations about every streams in a system stream.
typedef struct MpegSysToc { int numOfVideoStreams; int numOfAudioStreams; StreamInfo *streamInfo[48]; } MpegSysToc;
- numOfVideoStreams
- The total number of video streams in the system stream.
- numOfAudioStreams
- The total number of audio streams in the system stream.
- streamInfo
- An array of 48 pointers to StreamInfo structure. If a stream i does not exist in the system stream, element i in this array will be NULL.
MpegSysHdr *MpegSysHdrNew ()
Allocate a new MpegSysHdr and return a pointer to it.
void MpegSysHdrFree (MpegSysHdr * hdr)
Deallocate the MpegSysHdr pointed to bye hdr
MpegPckHdr *MpegPckHdrNew ()
Allocate a new MpegPckHdr and return a pointer to it.
void MpegPckHdrFree (MpegPckHdr * hdr)
Deallocate the MpegPckHdr pointed to bye hdr
MpegPktHdr *MpegPktHdrNew ()
Allocate a new MpegPktHdr and return a pointer to it.
void MpegPktHdrFree (MpegPktHdr *hdr)
Deallocate the MpegPktHdr pointed to by hdr
MpegSysToc *MpegSysTocNew ()
Allocate a new MpegSysToc and return a pointer to it.
void MpegSysTocFree (MpegSysToc * toc)
Deallocate the MpegSysToc pointed to by toc. All filters allocated by this toc will be deallocated as well.
int MpegSysHdrFind (BitParser * bp)
Advance the BitParser bp to the beginning of the next system header, and return the number of bytes skipped.
int MpegSysHdrDump (BitParser *ibp, BitParser *obp)
Assuming the BitParser ibp is at the beginning of a system header, copy the system header, (with minimum parsing) to the output BitParser obp. Returns the number of bytes written into obp.
int MpegSysHdrSkip (BitParser *bp)
Assuming the BitParser bp is at the beginning of a system header, advance the cursor of bp to the end of the system header. Returns the number of bytes skipped.
int MpegSysHdrParse (BitParser *bp, MpegSysHdr *hdr)
Assuming the BitParser bp is at the beginning of a system header, parse the system header and stores the information in the MpegSysHdr hdr. After parsing, the cursor of bp is at the end of the system header. Returns the number of bytes read.
int MpegSysHdrEncode (MpegSysHdr *hdr, BitParser *bp)
Write the information contains in MpegSysHdr hdr, into BitStream attached to bp. Returns the number of bytes written.
int MpegPckHdrFind (BitParser * bp)
Advance the BitParser bp to the beginning of the next pack header, and return the number of bytes skipped.
int MpegPckHdrDump (BitParser *ibp, BitParser *obp)
Assuming the BitParser ibp is at the beginning of a pack header, copy the pack header, (with minimum parsing) to the output BitParser obp. Returns the number of bytes written into obp.
int MpegPckHdrSkip (BitParser *bp)
Assuming the BitParser bp is at the beginning of a pack header, advance the cursor of bp to the end of the pack header. Returns the number of bytes skipped.
int MpegPckHdrParse (BitParser *bp, MpegPckHdr *hdr)
Assuming the BitParser bp is at the beginning of a pack header, parse the pack header and stores the information in the MpegPckHdr hdr. After parsing, the cursor of bp is at the end of the pack header. Returns the number of bytes read.
int MpegPckHdrEncode (MpegPckHdr *hdr, BitParser *bp)
Write the information contains in MpegPckHdr hdr, into BitStream attached to bp. Returns the number of bytes written.
int MpegPktHdrFind (BitParser * bp)
Advance the BitParser bp to the beginning of the next packet header, and return the number of bytes skipped.
int MpegPktHdrDump (BitParser *ibp, BitParser *obp)
Assuming the BitParser ibp is at the beginning of a packet header, copy the pack header, (with minimum parsing) to the output BitParser obp. Returns the number of bytes written into obp.
int MpegPktHdrSkip (BitParser *bp)
Assuming the BitParser bp is at the beginning of a packet header, advance the cursor of bp to the end of the packet header. Returns the number of bytes skipped.
int MpegPktHdrParse (BitParser *bp, MpegPckHdr *hdr)
Assuming the BitParser bp is at the beginning of a packet header, parse the pack header and stores the information in the MpegPktHdr hdr. After parsing, the cursor of bp is at the end of the packet header. Returns the number of bytes read.
int MpegPktHdrEncode (MpegPckHdr *hdr, BitParser *bp)
Write the information contains in MpegPktHdr hdr, into BitStream attached to bp. Returns the number of bytes written.
void MpegSysHdrGetAudioBound (MpegSysHdr *hdr)
void MpegSysHdrGetAudioLock (MpegSysHdr *hdr)
void MpegSysHdrGetBufferSize (MpegSysHdr *hdr, int id)
void MpegSysHdrGetCspsFlag (MpegSysHdr *hdr)
void MpegSysHdrGetFixedFlag (MpegSysHdr *hdr)
void MpegSysHdrGetNumOfStreamInfo (MpegSysHdr *hdr)
void MpegSysHdrGetRateBound (MpegSysHdr *hdr)
void MpegSysHdrGetVideoBound (MpegSysHdr *hdr)
void MpegSysHdrGetVideoLock (MpegSysHdr *hdr)
Return various fields from the system header.
void MpegPckHdrGetSysClockRef (MpegPckHdr *hdr)
void MpegPckHdrGetMuxRate (MpegPckHdr *hdr)
Return various fields in MpegPckHdr.
void MpegPktHdrGetStreamId (MpegPktHdr *hdr)
void MpegPktHdrGetLength (MpegPktHdr *hdr)
void MpegPktHdrGetBufferSize (MpegPktHdr *hdr)
void MpegPktHdrGetPts (MpegPktHdr *hdr)
void MpegPktHdrGetDts (MpegPktHdr *hdr)
Return various fields in MpegPktHdr.
void MpegSysHdrSetAudioBound (MpegSysHdr *hdr, int bound)
void MpegSysHdrSetAudioLock (MpegSysHdr *hdr, int flag)
void MpegSysHdrSetBufferSize (MpegSysHdr *hdr, int id, int size)
void MpegSysHdrSetCspsFlag (MpegSysHdr *hdr, int flag)
void MpegSysHdrSetFixedFlag (MpegSysHdr *hdr, int flag)
void MpegSysHdrSetNumOfStreamInfo (MpegSysHdr *hdr, int num)
void MpegSysHdrSetRateBound (MpegSysHdr *hdr, int bound)
void MpegSysHdrSetVideoBound (MpegSysHdr *hdr, int bound)
void MpegSysHdrSetVideoLock (MpegSysHdr *hdr, int lock)
Return various fields from the system header.
void MpegPckHdrSetSysClockRef (MpegPckHdr *hdr, float clockRef)
void MpegPckHdrSetMuxRate (MpegPckHdr *hdr, float muxRate)
Return various fields in MpegPckHdr.
void MpegPktHdrSetStreamId (MpegPktHdr *hdr, int id)
void MpegPktHdrSetLength (MpegPktHdr *hdr, int len)
void MpegPktHdrSetBufferSize (MpegPktHdr *hdr, int size)
void MpegPktHdrSetPts (MpegPktHdr *hdr, float pts)
void MpegPktHdrSetDts (MpegPktHdr *hdr, float dts)
Return various fields in MpegPktHdr.
void MpegSysTocAdd (BitParser * bp, MpegSysToc * toc, int offset)
Update the toc by parsing the system stream using BitParser bp.offset specifies the offset of the bitstream from the beginning of the system stream.
int MpegSysTocGetOffset (MpegSysToc * toc, int id, double time)
Return the offset into the system stream input of the last packet from stream id that have presentation time less than or equal to time.
BitStreamFilter *MpegSysTocGetFilter (MpegSysToc * toc, int id)
Return a pointer to the BitStreamFilter that can be used to filter stream id.
Last updated : Saturday, November 14, 1998, 07:50 PM