www.pudn.com > MPEG2systemsrc.rar > PES.H
/* Copyright (C) 1995, Tektronix Inc. All Rights Reserved.
*
* Usage Restrictions
*
* License is granted to copy, to use, and to make and to use derivative
* works for research and evaluation purposes only.
*
* Disclaimer of Warranty
*
* These software programs are available to the user without any license
* fee or royalty on an "as is" basis. Tektronix Inc. disclaims any and
* all warranties, whether express, implied, or statuary, including any
* implied warranties or merchantability or of fitness for a particular
* purpose. In no event shall the copyright-holder be liable for any
* incidental, punitive, or consequential damages of any kind whatsoever
* arising from the use of these programs.
*
* This disclaimer of warranty extends to the user of these programs and
* user's customers, employees, agents, transferees, successors, and
* assigns.
*
* The Tektronix Inc. does not represent or warrant that the programs
* furnished hereunder are free of infringement of any third-party
* patents.
*/
/* PES class, TrickMode class and PESExtension class */
#ifndef pes_h
#define pes_h
#include "TimeStamp.H"
class TrickMode;
class PESExtension;
// stream_id values
enum StreamId
{
id_program_stream_map = 188,
id_private_stream_1,
id_padding_stream,
id_private_stream_2,
id_audio_stream_0 = 192,
id_video_stream_0 = 224,
id_ECM = 256,
id_EMM,
id_DSMCC,
id_MHEG,
id_private_0,
id_program_stream_dir = 511
};
#define NOLENGTH -1
class PES
{
public:
int stream_id; // see table above
int PES_packet_length; // NULL or calculated
char scrambling_code; // (S,0) - Scrambled
char priority_code; // (H,L) - High or Low
char alignment_indicator_code; // (A,0) - Aligned
char copyright_code; // (C,0) - Copyrighted
char original_code; // (O,C) - Original or Copy
TimeStamp90* DTS; // may be NULL
TimeStamp90* PTS; // may be NULL
TimeStamp27* ESCR; // may be NULL
int ES_rate; // may be 0
TrickMode* trick_mode; // may be NULL
char additional_copy_info; // 7 bit copy info or NULL
int previous_CRC; // 16 bit CRC or NULL
PESExtension* extension; // may be NULL
int number_stuffing_bytes; // 0..32
char* file_name; // for test files
PES ();
PES (PES*);
int get_length (); // total: PES_packet_length + 6
int get_header_length (); // includes stuffing bytes; includes flags
int get_header_data_length (); // excludes stuffing bytes; includes flags
void config_basic (int, int, char, char, char, char, char,
TimeStamp90*, TimeStamp90*, TimeStamp27*,
int, char, int, int);
// StreamId, PES_packet_length, Scrambling, Priority, Alignment,
// Copyright, Original, DTS, PTS, ESCR, ES_rate,
// additional_copy_info, prev_CRC, num_stuff
void config_trick (char, char, char, char, int);
// trick_mode_control, field_id, intra_slice, freq_truc, field_rep
void config_extension ();
void print ();
};
class TrickMode
{
public:
char trick_mode_control_code; // (F,S,Z,R) or NULL
char field_id_code; // (1,2,B)
char intra_slice_refresh_code; // (I,0)
char frequency_truncation_code; // (D,3,6,A)
int field_rep_control; // 0..31
void print ();
};
/* TrickMode mnumonics
F: Fastmotion; S: Slowmotion; Z: Freeze; R: Fast Reverse
(1,2,B) means field 1, field 2 or both are displayed
(I,0) means only I frames are being sent or not
(D,3,6,A) denotes only DC coefs, first 3, first 6 or all coefs are sent
*/
class PESExtension
{
public:
char* PES_private_data; // 16 bytes or NULL
int pack_field_length; // 0..255
char* pack_header; // a pack_header or NULL
char pp_seq_counter_code; // (P,0) - Program packet counter included
int pp_seq_counter; // 0..127
int original_stuff_length; // 0..127
char P_STD_buffer_code; // (B,0) - Buffer parameters included
char P_STD_buffer_scale; // (0,1)
int P_STD_buffer_size; // 0..2^13-1
int PES_extension_field_length; // 0..127
PESExtension ();
int get_length (); // total
void print();
};
/*
DOCUMENTATION
PES and its associated classes, TrickMode and PESExtension, are
examples of syntax classes; its objects encapsulate the structure of
a PES syntax. When generating packets (say in an encoder
application) PES objects are used as templates. Changing the
template will change the structure of the packets being generated.
When parsing packets (say in a decoder application) PES objects are
set to reflect the structure of the packet being parsed and can then
be examined by the application.
Mnemonic chars are used to represent the various values of the fields (e.g.
the priority_code can be 'H' or 'L' for High or Low). These are
listed in the above comments.
All the fields are exposed as public members for simplicity.
Various configure methods are provided to easily set multiple fields.
*/
#endif