Horus Doc || C++ Reference || Class Overview   Pixels   Images   Detector   Geometry   Registry || Doxygen's quick Index  

mpvdata.h

00001 // mpvdata.h : interface of data definition
00002 //
00003 // This file defines data for MPEG video sequence layer;
00004 //
00005 //*****************************************************************************
00006 // 
00007 //                  MPEG Developing Classes
00008 //
00009 // Copyright (C) 1998, Vision and Neural Networks Laboratory, Computer Science 
00010 // Department, Wayne State University, All Rights Reserved; 
00011 //
00012 //                  Disclaimer of Warranty
00013 //
00014 // MPEG Developing Classes, both binary and source (hereafter, Software)
00015 // is copyrighted by Vision and Neural Networks Laboratory, Computer Science 
00016 // Department, Wayne State University (WSU), and ownership remains with WSU.
00017 //
00018 // Permission is hereby granted, free of charge, to any person obtaining
00019 // a copy of this software and associated documentation files to use, copy,
00020 // and distribute the software, provided that no charge is associated with 
00021 // such copies and that the copyright notice and this statement appears on 
00022 // all copies.
00023 //
00024 // THE SOFTWARE IS AVAILABLE TO THE USER ON AN "AS IS" BASIS, WITHOUT WARRANTY
00025 // OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, THE 
00026 // IMPLIED WARRANTIES OR MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
00027 // IN NO EVENT SHALL THE COPYRIGHT-HOLDER BE LIABLE FOR ANY CLAIMS, DAMAGES, OR
00028 // OTHER LIABILITIES OF ANY KIND WHATSOEVER ARISING FROM, OUT OF OR IN CONNECTION
00029 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. THIS 
00030 // DISCLAIMAER OF WARRANTY EXTENDS TO THE USER OF THIS SOFTWARE. ALSO THE WSU 
00031 // DOES NOT REPRESENT OR WARRANT THAT THE SOFTWARE FURNISHED HEREUNDER ARE FREE OF
00032 // INFRINGMENT OF ANY THIRD-PARTY PATENTS.
00033 //
00034 // Many patents of MPEG-1 and MPEG-2 are general enough such that commercial
00035 // implementations, including shareware, are unavoidable subject to royalty fees to
00036 // patent holders, regardless of implementation design.
00037 //
00038 //
00039 // Vision and Neural Networks Laboratory,
00040 // Computer Science Department,
00041 // Wayne State University,
00042 // Detroit, MI 48202.
00043 // Dongge Li(dil@cs.wayne.edu) and Ishwar K. Sethi(sethi@cs.wayne.edu).
00044 //
00046 
00047 #if !defined MPVDATA_H
00048 #define MPVDATA_H
00049 
00050 #include "datatype.h"
00051 #include "mpegdata.h"
00052 #include "cstrmbuf.h"
00053 
00054 
00055 // constants
00056 const DWORD VIDEO_STREAM_BUF_SIZE=2048;
00057 const WORD FAST_IDCT_COEF_NUM=1024;
00058 const WORD MIN_SEQUENCE_HEADER_SIZE=8;  //for MPEG-1;(64 BITS)
00059 const WORD MIN_GOP_HEADER_SIZE=8;       //MPEG-1 and MPEG-2 are the same (59 BITS);
00060 const WORD MIN_PICTURE_HEADER_SIZE=8;   //for MPEG-1 (62 BITS);
00061 const WORD MIN_SLICE_HEADER_SIZE=4;     //MPEG-1 and MPEG-2 are the same (38 BITS), must be 4(not 5), otherwise use 38 bits;
00062 const WORD MPEG2_MIN_SEQUENCE_HEADER_SIZE=18; // (144 BITS)
00063 const WORD MPEG2_MIN_GOP_HEADER_SIZE=8; // (59 BITS)
00064 const WORD MPEG2_MIN_PICTURE_HEADER_SIZE=16;  // (126 BITS)
00065 
00066 // data types and constants defined for sequence layer;
00067 const BYTE BLOCK_SIZE=8;
00068 const BYTE BLOCK_ITEM_NUM=BLOCK_SIZE*BLOCK_SIZE;
00069 // profiles and levels;
00070 const BYTE PROFILE_422=133;  // 128+5;
00071 const BYTE MAIN_LEVEL=8;
00072 // scalable_mode
00073 const BYTE SC_NONE=0;
00074 const BYTE SC_DP=1;
00075 const BYTE SC_SPAT=2;
00076 const BYTE SC_SNR=3;
00077 const BYTE SC_TEMP=4;
00078 // picture coding type
00079 const BYTE I_TYPE=1;
00080 const BYTE P_TYPE=2;
00081 const BYTE B_TYPE=3;
00082 const BYTE D_TYPE=4;
00083 // picture structure
00084 const BYTE TOP_FIELD=1;
00085 const BYTE BOTTOM_FIELD=2;
00086 const BYTE FRAME_PICTURE=3;
00087 // macroblock type, 0 for invalid type;
00088 const char MACROBLOCK_INTRA=1;
00089 const char MACROBLOCK_PATTERN=2;
00090 const char MACROBLOCK_MOTION_BACKWARD=4;
00091 const char MACROBLOCK_MOTION_FORWARD=8;
00092 const char MACROBLOCK_QUANT=16;
00093 const char SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG=32;
00094 const char PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS=64;
00095 // motion_type, 0 and -1 for invalid type;
00096 const char MC_FIELD=1;
00097 const char MC_FRAME=2;
00098 const char MC_16X8=2;
00099 const char MC_DMV=3;
00100 // mv_format
00101 const BYTE MV_FIELD=0;
00102 const BYTE MV_FRAME=1;
00103 // chroma_format
00104 const BYTE CHROMA420=1;
00105 const BYTE CHROMA422=2;
00106 const BYTE CHROMA444=3;
00107 // interpolation mode
00108 const BYTE DUPLICATE_MODE=1;
00109 const BYTE DOUBLE_MODE1=2;
00110 const BYTE DOUBLE_MODE2=3;
00111 const BYTE PROGRESSIVE_MODE=4;
00112 const BYTE INTERLACE_MODE=5;
00113 const BYTE FIELD_MODE=6;
00114 // Ohter constants
00115 const BYTE ZIG_ZAG=0;
00116 const BYTE MB_WEIGHT=32;
00117 const BYTE MB_CLASS4=64;
00118 const long INVALID_FRAME_NUM=-1;
00119 
00120 // frame rate table
00121 const double RESERVED=-1;
00122 const double FRAME_RATE_TABLE[16]=
00123 {
00124   0.0,
00125   ((23.0*1000.0)/1001.0),
00126   24.0,
00127   25.0,
00128   ((30.0*1000.0)/1001.0),
00129   30.0,
00130   50.0,
00131   ((60.0*1000.0)/1001.0),
00132   60.0,
00133   RESERVED,
00134   RESERVED,
00135   RESERVED,
00136   RESERVED,
00137   RESERVED,
00138   RESERVED,
00139   RESERVED
00140 };
00141 
00142 // zig-zag and alternate scan patterns
00143 const BYTE SCAN[2][64]=
00144 {
00145   { // Zig-Zag scan pattern;
00146     0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,
00147     12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,
00148     35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,
00149     58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63
00150   },
00151   { // Alternate scan pattern;
00152     0,8,16,24,1,9,2,10,17,25,32,40,48,56,57,49,
00153     41,33,26,18,3,11,4,12,19,27,34,42,50,58,35,43,
00154     51,59,20,28,5,13,6,14,21,29,36,44,52,60,37,45,
00155     53,61,22,30,7,15,23,31,38,46,54,62,39,47,55,63
00156   }
00157 };
00158 
00159 // default intra quantization matrix
00160 const BYTE DEFAULT_INTRA_QUANTIZER_MATRIX[64]=
00161 {
00162   8, 16, 19, 22, 26, 27, 29, 34,
00163   16, 16, 22, 24, 27, 29, 34, 37,
00164   19, 22, 26, 27, 29, 34, 34, 38,
00165   22, 22, 26, 27, 29, 34, 37, 40,
00166   22, 26, 27, 29, 32, 35, 40, 48,
00167   26, 27, 29, 32, 35, 40, 48, 58,
00168   26, 27, 29, 34, 38, 46, 56, 69,
00169   27, 29, 35, 38, 46, 56, 69, 83
00170 };
00171 
00172 // non-linear quantization coefficient table
00173 const BYTE NON_LINEAR_QUANTIZER_SCALE[32]=
00174 {
00175    0, 1, 2, 3, 4, 5, 6, 7,
00176    8,10,12,14,16,18,20,22,
00177   24,28,32,36,40,44,48,52,
00178   56,64,72,80,88,96,104,112
00179 };
00180 
00181 // ISO/IEC 13818-2 section 6.3.6 sequence_display_extension()
00182 const long INVERSE_TABLE_6_9[8][4]=
00183 {
00184   {117504, 138453, 13954, 34903}, /* no sequence_display_extension */
00185   {117504, 138453, 13954, 34903}, /* ITU-R Rec. 709 (1990) */
00186   {104597, 132201, 25675, 53279}, /* unspecified */
00187   {104597, 132201, 25675, 53279}, /* reserved */
00188   {104448, 132798, 24759, 53109}, /* FCC */
00189   {104597, 132201, 25675, 53279}, /* ITU-R Rec. 624-4 System B, G */
00190   {104597, 132201, 25675, 53279}, /* SMPTE 170M */
00191   {117579, 136230, 16907, 35559}  /* SMPTE 240M (1987) */
00192 };
00193 
00194 // compressed information;
00195 typedef struct MB_block_tag
00196 {
00197     short shDCTBlock[12][BLOCK_ITEM_NUM];
00198     BYTE nQuantizerScale;
00199     short shPMV[2][2][2];
00200     BYTE nMotionVerticalFieldSelect[2][2];
00201 } MBBLOCK;
00202 
00203 typedef short DCTBLOCK [BLOCK_ITEM_NUM];
00204 
00205 typedef struct compressedpic_tag
00206 {
00207     WORD wMBWidth;
00208     WORD wMBHeight;
00209     BYTE *pnQuantizerScale;
00210     short *pshSet1FwdPMVx;  //shPMV[0][0][0];
00211     short *pshSet1FwdPMVy; //shPMV[0][0][1];
00212     short *pshSet1BackPMVx;  //shPMV[0][1][0];
00213     short *pshSet1BackPMVy; //shPMV[0][1][1];
00214     short *pshSet2FwdPMVx;  //shPMV[1][0][0];
00215     short *pshSet2FwdPMVy; //shPMV[1][0][1];
00216     short *pshSet2BackPMVx;  //shPMV[1][1][0];
00217     short *pshSet2BackPMVy; //shPMV[1][1][1];
00218     BYTE *pnMotionVerticalFieldSelect00;
00219     BYTE *pnMotionVerticalFieldSelect01;
00220     BYTE *pnMotionVerticalFieldSelect10;
00221     BYTE *pnMotionVerticalFieldSelect11;
00222     WORD wYBlockWidth;
00223     WORD wYBlockHeight;
00224     DCTBLOCK *pshYDCTBlock;
00225     WORD wCbBlockWidth;
00226     WORD wCbBlockHeight;
00227     DCTBLOCK *pshCbDCTBlock;
00228     WORD wCrBlockWidth;
00229     WORD wCrBlockHeight;
00230     DCTBLOCK *pshCrDCTBlock;
00231 } COMPRESSEDPIC;
00232 
00233 // Data structure
00234 typedef struct sequence_header_tag
00235 {
00236     WORD wHorizontalSize;   //frame horizontal size;
00237     WORD wVerticalSize;     //frame vertical size;
00238     BYTE nPelAspectRatio;
00239     BYTE nFrameRate;
00240     DWORD dwBitRate;
00241     DWORD dwVbvBufferSize;
00242     BYTE nConstrainedParametersFlag;
00243     // currently we just overlook user data;
00244 } SEQUENCEHEADER;
00245 
00246 typedef struct sequence_extension_tag
00247 {  // ISO/IEC 13818-2 section 6.2.2.3:  sequence_extension()
00248     BYTE nProfileAndLevelIndication;
00249     BYTE nProgressiveSequence;
00250     BYTE nChromaFormat;
00251     BYTE nLowDelay;
00252     WORD wFrameRateExtension_n;
00253     WORD wFrameRateExtension_d;
00254 } SEQUENCEEXTENSION;
00255 
00256 typedef struct sequence_display_extension_tag
00257 {  // ISO/IEC 13818-2 section 6.2.2.4:  sequence_display_extension()
00258     BYTE nVideoFormat;
00259     BYTE nColorDescription;
00260     BYTE nColorPrimaries;
00261     BYTE nTransferCharacteristics;
00262     BYTE nMatrixCoefficients;
00263     WORD wDisplayHorizontalSize;
00264     WORD wDisplayVerticalSize;
00265 } SEQUENCEDISPLAYEXT;
00266 
00267 typedef struct sequence_scalable_extension_tag
00268 {  // ISO/IEC 13818-2 section 6.2.2.5: sequence_scalable_extension() header
00269     BYTE nScalableMode;
00270     BYTE nLayerID;
00271     WORD wLowerLayerPredHSize;  // Lower layer prediction horizontal size
00272     WORD wLowerLayerPredVSize;  // Lower layer prediction vertical size
00273     BYTE nHorizontalSubsamplingFactor_m;
00274     BYTE nHorizontalSubsamplingFactor_n;
00275     BYTE nVerticalSubsamplingFactor_m;
00276     BYTE nVerticalSubsamplingFactor_n;
00277 } SEQUENCESCALABLEEXT;
00278 
00279 typedef struct group_of_picture_header_tag
00280 {  // ISO/IEC 13818-2 section 6.2.2.6: group_of_pictures_header()
00281     BYTE nDropFlag;
00282     BYTE nHour;
00283     BYTE nMinute;
00284     BYTE nSecond;
00285     BYTE nFrame;
00286     BYTE nClosedGOP;
00287     BYTE nBrokenLink;
00288 } GOPHEADER;
00289 
00290 // common for sequence header and picture extension;
00291 typedef struct quant_matrix_tag
00292 {
00293     BYTE nLoadIntraQuantizerMatrix;
00294     BYTE nIntraQuantizerMatrix[64];
00295     BYTE nLoadNonIntraQuantizerMatrix;
00296     BYTE nNonIntraQuantizerMatrix[64];
00297     BYTE nLoadChromaIntraQuantizerMatrix;  
00298     BYTE nChromaIntraQuantizerMatrix[64];  
00299     BYTE nLoadChromaNonIntraQuantizerMatrix; 
00300     BYTE nChromaNonIntraQuantizerMatrix[64];
00301 } QUANTMATRIX;
00302 
00303 typedef struct picture_header_tag
00304 {  // ISO/IEC 13818-2 section 6.2.3: picture_header()
00305     short shTemporalReference;
00306     BYTE nPictureCodingType;
00307     WORD wVbvDelay;
00308     BYTE nFullPelForwardVector;
00309     BYTE nForwardFCode;
00310     BYTE nFullPelBackwardVector;
00311     BYTE nBackwardFCode;
00312 } PICTUREHEADER;
00313 
00314 typedef struct picture_extension_tag
00315 {  // ISO/IEC 13818-2 section 6.2.3.1: picture_coding_extension() header
00316     BYTE nFCode[2][2];
00317     BYTE nIntraDCPrecision;
00318     BYTE nPictureStructure;
00319     BYTE nTopFieldFirst;
00320     BYTE nFramePredFrameDCT;
00321     BYTE nConcealmentMotionVectors;
00322     BYTE nQScaleType;
00323     BYTE nIntraVlcFormat;
00324     BYTE nAlternateScan;
00325     BYTE nRepeatFirstField;
00326     BYTE nChroma420Type;
00327     BYTE nProgressiveFrame;
00328     BYTE nCompositeDisplayFlag;
00329     BYTE nVAxis;
00330     BYTE nFieldSequence;
00331     BYTE nSubCarrier;
00332     BYTE nBurstAmplitude;
00333     BYTE nSubCarrierPhase;
00334 } PICTUREEXTENSION;
00335 
00336 typedef struct picture_display_extension_tag
00337 {  // ISO/IEC 13818-2 section 6.2.3.3: picture_display_extension() header
00338     long lFrameCenterHorizontalOffset[3]; //range: -32768 to 32767;
00339     long lFrameCenterVerticalOffset[3]; //range: -32768 to 32767;
00340 } PICTUREDISPLAYEXT;
00341 
00342 typedef struct picture_spatial_scalable_extension_tag
00343 {  // ISO/IEC 13818-2 section 6.2.3.5: picture_spatial_scalable_extension() header
00344     short shLowerLayerTemporalReference;
00345     short shLowerLayerHorizontalOffset; //range: -16384 to 16383;
00346     short shLowerLayerVerticalOffset; //range: -16384 to 16383;
00347     BYTE nSpatialTemporalWeightCodeTableIndex;
00348     BYTE nLowerLayerProgressiveFrame;
00349     BYTE nLowerLayerDeinterlacedFieldSelect;
00350 } PICTURESPATIALEXT;
00351 
00352 typedef struct copyright_extension_tag
00353 {  // ISO/IEC 13818-2 section 6.2.3.6: copyright_extension() header
00354     BYTE nCopyrightFlag;
00355     BYTE nCopyrightIdentifier;
00356     BYTE nOriginalOrCopy;
00357     DWORD dwCopyrightNumber1;
00358     DWORD dwCopyrightNumber2;
00359     DWORD dwCopyrightNumber3;
00360 } COPYRIGHTEXT;
00361 
00362 typedef struct header_data_tag
00363 {
00364     bool bGOPValid;
00365     // for sequence extension headers
00366     bool bSequenceExtension;
00367     bool bSequenceDisplayExt;
00368     bool bSequenceScalableExt;
00369     // for picture extension headers;
00370     bool bPictureExtension;
00371     bool bPictureDisplayExt;
00372     bool bPictureSpatialExt;
00373     bool bCopyrightExt;
00374     bool bQuantMatrixExt;
00375     // headers;
00376     SEQUENCEHEADER SequenceHeader;
00377     SEQUENCEEXTENSION SequenceExtension;
00378     SEQUENCEDISPLAYEXT SequenceDisplayExt;
00379     SEQUENCESCALABLEEXT SequenceScalableExt;
00380     GOPHEADER GOPHeader;
00381     QUANTMATRIX QuantMatrix;
00382     PICTUREHEADER PictureHeader;
00383     PICTUREEXTENSION PictureExtension;
00384     PICTUREDISPLAYEXT PictureDisplayExt;
00385     PICTURESPATIALEXT PictureSpatialExt;
00386     COPYRIGHTEXT CopyrightExt;
00387 } HEADERDATA;
00388 
00389 typedef struct decoder_info_tag
00390 {
00391     bool bTwoStream;  // has second stream for Data Partitioning (DP) or SNR Scalability enhancment;
00392     bool bSpeedFlag; //higher speed but lower quality;
00393     int iStatus;
00394 } DECODERINFO;
00395 
00396 typedef struct picture_info_tag
00397 {
00398     // picture variables;
00399     bool bSecondField;  //to indicate if current field is the second field of the same picture (frames are always first fields);    
00400     PACKETPOS CurPicturePckPos;//packet position;
00401     long lCurPicturePckOffset;//packet position, not include picture_start_code(four bytes);
00402     // GOP related variables;
00403     long lUnwrappedFrameNum; //associated with bGOPValid, for counting picture number;
00404 } PICTUREINFO;
00405 
00406 typedef struct picture_record_tag
00407 {
00408     bool bGOPValid;
00409     PICTUREINFO PicInfo;
00410     GOPHEADER GOPHeader;
00411 } PICTURERECORD;
00412 
00413 typedef struct coding_picture_parameter_tag
00414 {
00415     WORD wCodedFrameWidth; // Y component row increasement;
00416     WORD wCodedFrameHeight; // Y component (row) height;
00417     WORD wCodedChromaWidth; // Cb/Cr component row increasement;
00418     WORD wCodedChromaHeight; // Cb/Cr component (row) height;
00419     WORD wMBWidth; // MB row increasement;
00420     WORD wMBHeight; // MB (row) height;
00421 } CODINGPICPARA;
00422 
00423 typedef struct decoder_status_tag
00424 {
00425     int iMpvDecoderStatus;
00426     int iBaseParserStatus;
00427     int iEnhanParserStatus;
00428     int iPicDecoderStatus;
00429 } DECODERSTATUS;
00430 
00431 #endif  //MPVDATA_H

Generated on Tue Feb 3 14:18:44 2004 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001