#include <dvmmpeg.h>
The MpegSeqHdr structure contains all of the parameters contained in the sequence header of an MPEG stream.
typedef struct MpegSeqHdr {
short width;
short height;
short mb_width;
short mb_height;
int bitrate;
int vbv_buffer_size;
char pel_aspect_ratio;
char picture_rate;
char constrained;
char default_qt;
unsigned char iqt[64];
unsigned char niqt[64];
} MpegSeqHdr;
- width
- the width of each frame
- height
- the height of each frame
- mb_width
- the width of each frame in macroblocks
- mb_height
- the height of each frame in macroblocks
- bitrate
- the bitrate of the Mpeg video stream, in units of 400 bits/second
- vbv_buffer_size
- buffer size needed by a decoder to decode a frame. At least this many bytes should be present in a bitstream to guarantee that the bitstream contains an entire encoded frame.
- pel_aspect_ratio
- index to aspect ratio table. This table is shown below
Index Aspect Ratio 0 RESERVE 1 1.000 2 0.6735 3 0.7031 4 0.7615 5 0.8055 6 0.8437 7 0.8935 8 0.9375 9 0.9815 10 1.0255 11 1.0695 12 1.1250 13 1.1575 14 1.2015 15 RESERVE
- picture_rate
- Frame rate, as an index into the picture rate table.
Index Aspect Ratio 0 RESERVE 1 23.976 2 24 3 25 4 29.97 5 30 6 50 7 59.94 8 60 9 RESERVE 10 RESERVE 11 RESERVE 12 RESERVE 13 RESERVE 14 RESERVE 15 RESERVE
- constrained
- true if this stream uses contrained parameters. Using constrained parameters implies that the following constraints are met:
- width ≤ 768
- height ≤ 576
- mb_width*mb_height ≤ 396
- frame_rate ≤ 30 frames/second
- mb_width*mb_height*frame_rate ≤ 396*25
- all motion vectors ≤ ±128
- vbv_size ≤ 40*1024 bytes
- bit_rate ≤ 1856000 bits/second
- default_qt
- indicates if iqt and niqt use default values, or are specified in the bitstream. 0 if both tables use default values, 1 if only iqt is defined in the bitstream, 2 if only niqt is defined, 3 if both are defined.
- iqt[64]
- intra-quantization table
- niqt[64]
- non-intra quantization table.
The MpegGopHdr structure contains all of the parameters contained in the GOP header of an MPEG stream.
typedef struct MpegGopHdr {
char drop_frame_flag;
char time_code_hours;
char time_code_minutes;
char time_code_seconds;
char time_code_pictures;
char closed_gop;
char broken_link;
} MpegGopHdr;
- drop_frame_flag, time_code_hours, time_code_minutes, time_code_seconds , time_code_pictures
- These fields correspond the the fields defined in the IEC standard 461 ("time and control codes for video tape recorders"). The code refers to the first picture in the group of pictures that has a temporal_reference of zero.
The drop_frame_flag is 1 only if the pic rate is 29.97Hz. If drop_frame_flag = 0 then pictures are counted assuming rounding to the nearest integral number of pictures per second. If If drop_frame_flag = 1 then picture numbers 0 and 1 at the start of every minute except minutes 0, 10, 20, 30, 40, 50 are ommitted from the count.
- closed_gop
- If closed_gop = 1, then this GOP is encoded without vectors pointing to pictures in previous GOP. Closed_gop = 0 otherwise.
- broken_link
- if broken_link = 1, then the first B-frame that follows the first I-frame in this GOP cannot be decoded because the other frame used for prediction is not available. This can be used to avoid decoding pictures that cannot be correctly decoded due to editing.
The MpegPicHdr structure contains all of the parameters contained in the picture header of an MPEG stream.
typedef struct MpegPicHdr {
short temporal_reference;
char type;
unsigned short vbv_delay;
char full_pel_forward_vector;
char forward_r_size, forward_f;
char full_pel_backward_vector;
char backward_r_size, backward_f;
} MpegPicHdr;
- temporal_reference
- an integer associated with each picture, start from 0 for first (in display order) picture of each GOP, increase by one modulo 1024 for every picture (in display order).
- type
- indicates the type of encoding for this picture : could be I_FRAME, P_FRAME, B_FRAME or D_FRAME.
- full_pel_forward_vector
- If this slot is 1, the forward motion vectors are in full-pixel units. If this slot is 0, the forward motion vectors are in half-pixel units.
- forward_r_size
- Used internally for decoding motion vectors from the bitstream. See MPEG-1 Video standard for details.
- forward_f
- Used internally for decoding motion vectors from the bitstream. See MPEG-1 Video standard for details.
- full_pel_backward_vector
- If this slot is 1, the backward motion vectors are in full-pixel units. If this slot is 0, the backward motion vectors are in half-pixel units.
- backward_r_size
- Used internally for decoding motion vectors from the bitstream. See MPEG-1 Video standard for details.
- backward_f
- Used internally for decoding motion vectors from the bitstream. See MPEG-1 Video standard for details.
The MpegVideoIndex structure is essentially a table to organize MpegVideoIndexElements. More information about MpegVideoIndexElements can be found below.
typedef struct MpegVideoIndex {
MpegVideoIndexElement *table;
int numElements;
int maxElements;
} MpegVideoIndex;
- table
- an array of maxElements to store indices into a MPEG video.
- numElements
- the number of MpegVideoIndexElements stored in the MpegVideoIndex.
- maxElements
- the maximum number of MpegVideoIndexElements that can be stored in the MpegVideoIndex.
The MpegVideoIndex structure contains all information necessary to decode either an individual frame, or a group of frames starting from an arbitrary frame in the MPEG video stream.
typedef struct MpegVideoIndexElement {
char refCount;
char type;
char pastOffset;
char forOffset;
int offset;
int length;
} MpegVideoIndexElement;
- refCount
- the number of reference frames needed to decode the current frame
- type
- the type of encoding for this picture. One of the characters I_FRAME, P_FRAME, or B_FRAME.
- pastOffset
- the number of frames to skip going in reverse order to find the reference frame for the current frame (always 0 for I frames)
- forOffset
- the number of frames to skip in the forward direction to find the next reference frame for the current frame (always 0 for I and P frames)
- offset
- the bit offset of the bitparser from the start of MPEG video file (useful for skipping to pic hdrs of known frames)
- length
- the length (in bits) of the current frame in the encoded bitstream.
Indicates the type of frame. Return values are I_FRAME, P_FRAME, B_FRAME, D_FRAME.
#define I_FRAME 1
#define P_FRAME 2
#define B_FRAME 3
#define D_FRAME 4
These codes represent the possible starting and ending codes for different structures in the MPEG stream. Values are: SEQ_START_CODE, SEQ_END_CODE, ISO_11172_END_CODE, PACK_START_CODE, SYS_START_CODE, PIC_START_CODE, GOP_START_CODE, EXT_START_CODE, USER_START_CODE, SLICE_MIN_START_CODE, SLICE_MAX_START_CODE, PACKET_MIN_START_CODE, PACKET_MIN_START_CODE
#define SEQ_START_CODE 0x000001b3
#define SEQ_END_CODE 0x000001b7
#define ISO_11172_END_CODE 0x000001b9
#define PACK_START_CODE 0x000001ba
#define SYS_START_CODE 0x000001bb
#define PIC_START_CODE 0x00000100
#define GOP_START_CODE 0x000001b8
#define EXT_START_CODE 0x000001b5
#define USER_START_CODE 0x000001b2
#define SLICE_MIN_START_CODE 0x00000101
#define SLICE_MAX_START_CODE 0x000001af
#define PACKET_MIN_START_CODE 0x0000001bc
#define PACKET_MAX_START_CODE 0x0000001f0
These represent the possible return values from Dali MPEG functions. DVM_MPEG_OK is returned if all goes well. Error codes are: DVM_MPEG_NOT_FOUND, DVM_MPEG_INVALID_START_CODE, DVM_MPEG_INDEX_FULL
#define DVM_MPEG_OK 0
#define DVM_MPEG_NOT_FOUND -1
#define DVM_MPEG_INVALID_START_CODE -2
#define DVM_MPEG_INDEX_FULL 1
MpegSeqHdr *MpegSeqHdrNew ()
Allocate a new MpegSeqHdr, and return a pointer to it. Return Null if allocation falied.
void MpegSeqHdrFree (MpegSeqHdr *hdr)
Deallocates the MpegSeqHdr pointed to bye hdr
int MpegSeqHdrFind (BitParser *bp)
Advance the BitParser bp to the beginning of a sequence header (by finding SEQ_START_CODE in the corrsponding bitstream). Return the number of bytes skipped during the find. Returns DVM_MPEG_NOT_FOUND if it cannot find any header.
int MpegSeqHdrDump (BitParser *inbp, BitParser *outbp)
Dump a sequence header from inbp to outbp without interpreting it. Inbp's cursor will be pointing to the beginning of the GOP header that follows the sequence header. Return the number of bytes dumped, or DVM_MPEG_INVALID_START_CODE if inbp is not pointing to a sequence header.
int MpegSeqHdrSkip (BitParser *bp)
Assuming that the input BitParser bp is at the beginning of a MPEG sequence header, skip the sequence header and advance bp's cursors to the beginning of GOP header immediately following the sequence header. Return the number of bytes skipped, or DVM_MPEG_INVALID_START_CODE if bp is not pointing to a sequence header.
int MpegSeqHdrParse (BitParser *bp)
Assuming the BitParser bp is pointing to the beginning of a sequence header in the bitstream, parse the header and initialize hdr. Note: Header extension and user data are ignored. When this function completes, bp's cursor will be pointing to the beginning of the GOP header that follows the sequence header. This function returns the number of bytes parsed, or DVM_MPEG_INVALID_START_CODE if bp is not pointing to a sequence header.
int MpegSeqHdrEncode (BitParser *bp)
Encode the content of the sequence header hdr to the output bitstream attached to BitParser bp and return the number of bytes encoded.
#define MpegSeqHdrGetWidth(MpegSeqHdr *hdr)
#define MpegSeqHdrGetHeight(MpegSeqHdr *hdr)
#define MpegSeqHdrGetAspectRatio(MpegSeqHdr *hdr)
#define MpegSeqHdrGetBitRate(MpegSeqHdr *hdr)
#define MpegSeqHdrGetPicRate(MpegSeqHdr *hdr)
#define MpegSeqHdrGetBufferSize(MpegSeqHdr *hdr)
#define MpegSeqHdrGetIQT(MpegSeqHdr *hdr)
#define MpegSeqHdrGetNIQT(MpegSeqHdr *hdr)
These query primatives return the fields in the MPEG seqence header:
- the width of the video(in pixels)
- the height of the video(in pixels)
- the sequence picture rate (as a floating point value, in frames/second)
- the sequence bit rate (in units of 400 bits/second) or the string "variable" if the bit rate is variable
- the intra quntizer table (8x8 matrix)
- the non-intra quantizer table (8x8 matrix)
#define MpegSeqHdrSetWidth(MpegSeqHdr *hdr, int x)
#define MpegSeqHdrSetHeight(MpegSeqHdr *hdr, int x)
void MpegSeqHdrSetAspectRatio(MpegSeqHdr *hdr, double x)
void MpegSeqHdrSetPicRate(MpegSeqHdr *hdr, double x)
#define MpegSeqHdrSetBitRate(MpegSeqHdr *hdr, int x)
#define MpegSeqHdrSetBufferSize(MpegSeqHdr *hdr, int x)
#define MpegSeqHdrSetConstrained(MpegSeqHdr *hdr, int x)
void MpegSeqHdrSetIQT(MpegSeqHdr *hdr, int *qTable)
void MpegSeqHdrSetNIQT(MpegSeqHdr *hdr, int *niqTable)
void MpegSeqHdrSetDefaultIQT(MpegSeqHdr *hdr)
void MpegSeqHdrSetDefaultNIQT(MpegSeqHdr *hdr)
These query primitives initialize the fields in the MPEG seqence header.
Notes:
- Setting the width or height also sets the mb_width or mb_height.
- Currently only variable bit rate (-1) is supported for encoding.
- Setting the pic rate or aspect ratio to an unsupported value has no effect. For a list of suported values, see above.
- MpegSeqHdrSetDefaultIQT and MpegSeqHdrSetDefaultNIQT can be used to initialize the quantizer tables to default ones.
MpegGopHdr *MpegGopHdrNew ();
Allocates a new MpegGopHdr, and return a pointer to it. This function returns NULL if allocation failed.
void MpegGopHdrFree (MpegGopHdr *hdr)
Deallocates the MpegGopHdr pointed to by hdr.
int MpegGopHdrFind (BitParser *bp)
Advance the BitParser bp to the beginning of a GOP header (by finding GOP_START_CODE in the bitstream it is attached to). Return the number of bytes skipped during the find, or return DVM_MPEG_NOT_FOUND if it cannot find any header.
int MpegGopHdrDump (BitParser *inbp, BitParser *outbp)
Assuming the BitParser inbp is pointing to the beginning of a GOP header in the bitstream, dump the header from the input bitstream to the output bitstream attached to BitParser outbp. After dumping, the current bit position is at the beginning of picture header. Return the number of bytes dumped, or return DVM_MPEG_INVALID_START_CODE if inbp is not pointing to a GOP header.
int MpegGopHdrSkip (BitParser *bp);
Assuming that bp is pointing to the begining of a GOP header in the bitstream, skip the header and move bp to point to the beginning of the picture header immediately following the GOP header. Return the number of bytes skipped, or return DVM_MPEG_INVALID_START_CODE if bp is not pointing to a GOP header. Note: This has the same functionality as MpegPicHdrFind, but is more efficient since we assume we are at the beginning of a GOP header and know exactly how many bytes to skip to get to the next MpegPicHdr in the bitstream .
int MpegGopHdrParse (BitParser *bp, MpegGopHdr *);
Assuming that the bp position is at the beginning of a MPEG GOP header, parse the bitstream using BitParser bp and initilize the GOP header hdr. After parsing, bp current bit position is at the beginning of next picture header. Return the number of bytes parsed, or DVM_MPEG_INVALID_START_CODE if inbp is not pointing to a GOP header.
int MpegGopHdrEncode (MpegGopHdr *hdr, BitParser *bp);
Encode the content of the GOP header hdr to the output bitstream attached to BitParser bp and return the number of bytes encoded.
#define MpegGopHdrGetClosedGop(MpegGopHdr *hdr)
#define MpegGopHdrGetBrokenLink(MpegGopHdr *hdr)
These queries return the fields in the MPEG Gop Header:
- the broken link field of the gop: 1 or 0
- the closed gop field of the gop: 1 or 0
#define MpegGopHdrSetDropFrameFlag(MpegGopHdr *hdr, int x)
#define MpegGopHdrSetHours(MpegGopHdr *hdr, int x)
#define MpegGopHdrSetMinutes(MpegGopHdr *hdr, int x)
#define MpegGopHdrSetSeconds(MpegGopHdr *hdr, int x)
#define MpegGopHdrSetPictures(MpegGopHdr *hdr, int x)
#define MpegGopHdrSetClosedGop(MpegGopHdr *hdr, int x)
#define MpegGopHdrSetBrokenLink(MpegGopHdr *hdr, int x)
These queries initialize the fields in the MPEG Gop Header:
- the drop frame flag of the gop: 1 or 0
- the time code hours, minutes, seconds, pictures.
- the broken link field of the gop: 1 or 0
- the closed gop field of the gop: 1 or 0
MpegPicHdr *MpegPicHdrNew ();
Allocate a new MPEG picture header structure and return a pointer to it. Return NULL if allocation failed.
void MpegPicHdrFree (MpegPicHdr *hdr);
Deallocate the MpegPicHdr hdr.
int MpegPicHdrFind (BitParser *bp);
Scan forward in the bitstream using BitParser bp, looking for the next picture header, and position bp's cursor at the beginning of the picture header. Return the number of bytes skipped, or DVM_MPEG_NOT_FOUND if cannot find any header.
int MpegPicHdrDump (BitParser *inbp, BitParser *outbp);
Assuming the BitParser inbp is pointing to the beginning of a picture header in the bitstream, dump the header (without parsing it) from the input bitstream to the output bitstream attached to BitParser outbp. After dumping, the current bitparser cursor position is at the end of the picture header and beginning of a slice header ("picture body"). Return the number of bytes dumped, or DVM_MPEG_INVALID_START_CODE if inbp is not pointing to a picture header.
int MpegPicHdrSkip (BitParser *bp);
Assuming that the bitstream position is at the beginning of a MPEG pic header, skip the bitstream using BitParser bp without parsing and return the number of bytes skipped. After skipping the current bitparser position is at the end of the picture header and beginning of a slice header. Return the number of bytes skipped, or Return DVM_MPEG_INVALID_START_CODE if bp is not pointing to a picture header.
int MpegPicHdrParse (BitParser *bp, MpegPicHdr *hdr);
Assuming the BitParser bp is pointing to the beginning of a picture header in the bitstream, parse the header and initialized\ the structure pointed to by hdr. After parsing bp's current bit position is at the end of the picture header and beginning of a slice header (picture body). Return the number of bytes parsed, or DVM_MPEG_INVALID_START_CODE if bp is not pointing to a picture header.
int MpegPicHdrEncode (MpegPicHdr *, BitParser *);
Encode the content of pic header hdr into bitstream using BitParser bp. Return the number of bytes encoded into the bitstream.
#define MpegPicHdrGetTemporalRef(MpegPicHdr *hdr)
#define MpegPicHdrGetType(MpegPicHdr *hdr)
These queries return the fields in the MPEG Picture Header:
- the temporal reference of the frame: an integer
- the picture coding type of the frame: one of the strings "i", "p", "b", or "d"
#define MpegPicHdrSetTemporalRef(MpegPicHdr *hdr, int x)
#define MpegPicHdrSetType(MpegPicHdr *hdr, int x)
#define MpegPicHdrSetVBVDelay(MpegPicHdr *hdr, int x)
#define MpegPicHdrSetFullPelForward(MpegPicHdr *hdr, int x)
void MpegPicHdrSetForwarddFCode(MpegPicHdr *hdr, int x) #define MpegPicHdrSetFullPelBackward(MpegPicHdr *hdr, int x)
void MpegPicHdrSetBackwardFCode(MpegPicHdr *hdr, int x)
These functions/macros initialize the fields in the MPEG Picture Header:
- the temporal reference of the frame.
- the VBV delay of the frame.
- the full pel forward flag of the frame: 0 or 1.
- the forward f code which sets the forward_r_size and forward_f of the frame: 1 to 7.
- the full pel backward flag of the frame: 0 or 1.
- the backward f code which sets the backward_r_size and backward_f of the frame: 1 to 7.
- the picture coding type of the frame: one of the constants I_FRAME, P_FRAME, B_FRAME, or D_FRAME.
int MpegPicDump (BitParser *inbp, BitParser *outbp)
Dump the whole picture from input bitstream using inbp to output bitstream using outbp. Inbp must be positioned at the beginning of the picture (i.e., at a slice start code). When this function completes, the cursor will be positioned at the beginning of the picture header or GOP header immediately following this picture. Return the total number of bytes dumped.
int MpegPicSkip (BitParser *inbp)
Skip the whole picture from input bitstream using inbp. Inbp must be positioned at the beginning of the picture (i.e., at a slice start code). When this function completes, the cursor will be positioned at the beginning of the picture header or GOP header immediately following this picture. Return the total number of bytes dumped.
int MpegPicIParse (BitParser *bp, MpegSeqHdr *seqHdr, MpegPicHdr *picHdr, ScImage *scY, ScImage *scU, ScImage *scV)
Parse an I-frame from a bitstream using bp into three SmImages scY, scU and scV. The ScImages contain dequantized coefficients. Bp must be positioned at the beginning of the picture (i.e., at a slice start code). When this function completes, the cursor will be positioned at the beginning of the picture header or GOP header immediately following this picture. Returns 0 on error, 1 if successful.
int MpegPicPParse (BitParser *bp, MpegSeqHdr *seqHdr, MpegPicHdr *picHdr, ScImage *scY, ScImage *scU, ScImage *scV, VectorImage *fmv)
Parse a P-frame from a bitstream using bp into three SmImages scY, scU, and scV, and the VectorImage fmv. The ScImages contain dequantized coefficients. Bp must be positioned at the beginning of the picture (i.e., at a slice start code). When this function completes, the cursor will be positioned at the beginning of the picture header or GOP header immediately following this picture. Returns 0 on error, 1 if successful.
int MpegPicBParse (BitParser *bp, MpegSeqHdr *seqHdr, MpegPicHdr *picHdr, ScImage *scY, ScImage *scU, ScImage *scV, VectorImage *fmv, VectorImage *bmv)
Parse a B-frame from a bitstream using bp into three SmImages scY, scU, and scV, and the VectorImage fmv and bmv (which contain the forward and backward motion vectors, repectively). The ScImages contain dequantized coefficients. Bp must be positioned at the beginning of the picture (i.e., at a slice start code). When this function completes, the cursor will be positioned at the beginning of the picture header or GOP header immediately following this picture. Returns 0 on error, 1 if successful.
void MpegPicIEncode (MpegPicHdr *picHdr, ScImage *scY, ScImage *scU, ScImage *scV, ByteImage *qScale, int *sliceInfo, int sliceInfoLen, BitParser *bp)
Encode the ScImage scY, scU, and scV into the bitstream. The ScImages should be quantized. Slice headers are inserted according to the array sliceInfo (size sliceInfoLen) which contains the number of macroblocks in each slice. sliceInfo is repeated if there are more macroblocks than the sum of the number of macroblocks in each slice of sliceInfo.
void MpegPicPEncode (MpegPicHdr *picHdr, ScImage *scY, ScImage *scU, ScImage *scV, VectorImage *fmv, ByteImage *qScale, int *sliceInfo, int sliceInfoLen, BitParser *bp)
Huffman encode the ScImage scY, scU, and scV that contain I-blocks for intra-coded macroblocks and difference blocks for non-intra macroblocks. The ScImages should be quantized. For macroblocks with a valid vector in VectorImage fmv, the motion vector information is encoded in the macroblock header. Slice headers are inserted according to the array sliceInfo (size sliceInfoLen) which contains the number of macroblocks in each slice. sliceInfo is repeated if there are more macroblocks than the sum of the number of macroblocks in each slice of sliceInfo.
void MpegPicBEncode (MpegPicHdr *picHdr, ScImage *scY, ScImage *scU, ScImage *scV, VectorImage *fmv, VectorImage *bmv, ByteImage *qScale, int *sliceInfo, int sliceInfoLen, BitParser *bp)
Huffman encode the ScImage scY, scU, and scV that contain I-blocks for intra-coded macroblocks and difference blocks for non-intra macroblocks. The ScImages should be quantized. For macroblocks with a valid forward or backward vector in fmv and bmv, the motion vector information is encoded in the macroblock header. Slice headers are inserted according to the array sliceInfo (size sliceInfoLen) which contains the number of macroblocks in each slice. sliceInfo is repeated if there are more macroblocks than the sum of the number of macroblocks in each slice of sliceInfo.
void BytePMotionVecSearch (MpegPicHdr *picHdr, ByteImage *y, ByteImage *prevY, ByteImage **intermediates, VectorImage *fmv)
Compute the predictive motion vectors from ByteImage prevY to scY using the parameters in picHdr. For half pixel precision, intermediates is an array of three ByteImages which should be computed beforehand using ComputeIntermediatePixels. For each macroblock if the motion vector coding should be used the resultant vector is stored in fmv. Otherwise if the macroblock is intra coded, the exists field of the Vector is set to 0 and the vector values are undefined. Currently supports logarithmic searching only.
void ByteBMotionVecSearch (MpegPicHdr *picHdr, ByteImage *currY, ByteImage *prevY, ByteImage *nextY, ByteImage **interPrev, ByteImage **interNext, int *sliceInfo, int sliceInfoLen, VectorImage *fmv, VectorImage *bmv)
Analogous to BytePMotionVecSearch. Determines the best of forward, backward, and interpolative predictions and finds the appropriate motion vectors from currY, prevY, and nextY. Two arrays of the type described below in ComputeIntermediatePixels are used for searching in half pixel precision. Slice information is necessary to determine if a macroblock can be skipped, in which case the exists field of both Vectors in fmv and bmv are set to 2. For interpolative prediction, both exists fields are set to 1; for forward prediction, only the Vector of fmv is set to exists; for backward prediction, only the Vector of bmv. If the exists fields in both fmv and bmv are 0, the macroblock should be intracoded. Currently supports logarithmic searching only.
void ByteComputeIntermediates (ByteImage *original, ByteImage **intermediates)
Use this function to pre-compute the intermediate values between pixels when using half-pixel precision motion search. intermediates should be an array of three ByteImages corresponding to the intermediate x values, intermediate y values, and intermediate xy values. If the dimensions of original is w x h, intermediates[0] is (w-1) x h, intermediates[1] is w x (h-1), and intermediates[2] is (w-1) x (h-1).
MpegVideoIndex *MpegVideoIndexNew (int size);
Allocate a new MpegVideoIndex, and return a pointer to it. Return NULL if allocation failed.
void MpegVideoIndexFree (MpegPicHdr *hdr);
Deallocate the video index index.
#define MpegVideoIndexGetType(index, fnum) index->table[fnum].type
#define MpegVideoIndexGetNext(index, fnum) index->table[fnum].forOffset
#define MpegVideoIndexGetPast(index, fnum) index->table[fnum].pastOffset
#define MpegVideoIndexGetOffset(index, fnum) index->table[fnum].offset
#define MpegVideoIndexGetLength(index, fnum) index->table[fnum].length
#define MpegVideoIndexNumRefs(index, fnum) index->table[fnum].refCount
These functions query the specific fields of the current video index element:
- the frame number of the current element
- the number of frames to skip to get the next forward reference frame (for B frames only)
- the number of frames to skip to get the previous reference frame (for B and P frames)
- the bit offset in the bitstream of frameNum
- the length of frameNum in bits
void MpegVideoIndexParse (BitParser *bp, MpegVideoIndex *index);
Assuming an MpegVideoIndex is encoded in the bitstream which bp is attached to, parse the bitstream and store the index in index.
void MpegVideoIndexEncode (MpegVideoIndex *index, BitParser *bp);
Encode the contents of index into the output bitstream using the bitparser bp.
int MpegVideoIndexFindRefs (MpegVideoIndex *index, MpegVideoIndex *result, int frameNum);
Returns DVM_MPEG_OK if successful or DVM_MPEG_INDEX_FULL if unsuccessful.
int MpegVideoIndexTableAdd (MpegVideoIndex *index, int frameNum, int bitOffset, char ftype, int flength, int past, int next);
Add an element to the video index index. The user must ensure that index is large enough to hold another element. See MpegVideoIndexElement for more information. Returns DVM_MPEG_OK if successful or DVM_MPEG_INDEX_FULL if unsuccessful.
void MpegVideoIndexResize (MpegVideoIndex *index, unsigned int newSize);
Resize index to hold more elements. newSize represents the size of the index as a whole, not just the number of elements to add. This function changes the maxElements slot of index.
int MpegGetCurrStartCode(BitParser *bp)
Return the start code the BitParser bp in positioned at. (It simply peeks four bytes and return the value, which may not be a valid start code)
int MpegAnyHdrFind(BitParser *bp)
Advance the BitParser bp's cursor to the next MPEG start code (0x000001??). Return the number of bytes skipped.
int MpegSeqEndCodeEncode(BitParser *bp)
Encode the sequence end code (0x000001b7) to the bitstream using BitParser bp.
Last updated : Saturday, November 14, 1998, 07:50 PM