00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
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
00056 const DWORD VIDEO_STREAM_BUF_SIZE=2048;
00057 const WORD FAST_IDCT_COEF_NUM=1024;
00058 const WORD MIN_SEQUENCE_HEADER_SIZE=8;
00059 const WORD MIN_GOP_HEADER_SIZE=8;
00060 const WORD MIN_PICTURE_HEADER_SIZE=8;
00061 const WORD MIN_SLICE_HEADER_SIZE=4;
00062 const WORD MPEG2_MIN_SEQUENCE_HEADER_SIZE=18;
00063 const WORD MPEG2_MIN_GOP_HEADER_SIZE=8;
00064 const WORD MPEG2_MIN_PICTURE_HEADER_SIZE=16;
00065
00066
00067 const BYTE BLOCK_SIZE=8;
00068 const BYTE BLOCK_ITEM_NUM=BLOCK_SIZE*BLOCK_SIZE;
00069
00070 const BYTE PROFILE_422=133;
00071 const BYTE MAIN_LEVEL=8;
00072
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
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
00084 const BYTE TOP_FIELD=1;
00085 const BYTE BOTTOM_FIELD=2;
00086 const BYTE FRAME_PICTURE=3;
00087
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
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
00101 const BYTE MV_FIELD=0;
00102 const BYTE MV_FRAME=1;
00103
00104 const BYTE CHROMA420=1;
00105 const BYTE CHROMA422=2;
00106 const BYTE CHROMA444=3;
00107
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
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
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
00143 const BYTE SCAN[2][64]=
00144 {
00145 {
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 {
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
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
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
00182 const long INVERSE_TABLE_6_9[8][4]=
00183 {
00184 {117504, 138453, 13954, 34903},
00185 {117504, 138453, 13954, 34903},
00186 {104597, 132201, 25675, 53279},
00187 {104597, 132201, 25675, 53279},
00188 {104448, 132798, 24759, 53109},
00189 {104597, 132201, 25675, 53279},
00190 {104597, 132201, 25675, 53279},
00191 {117579, 136230, 16907, 35559}
00192 };
00193
00194
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;
00211 short *pshSet1FwdPMVy;
00212 short *pshSet1BackPMVx;
00213 short *pshSet1BackPMVy;
00214 short *pshSet2FwdPMVx;
00215 short *pshSet2FwdPMVy;
00216 short *pshSet2BackPMVx;
00217 short *pshSet2BackPMVy;
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
00234 typedef struct sequence_header_tag
00235 {
00236 WORD wHorizontalSize;
00237 WORD wVerticalSize;
00238 BYTE nPelAspectRatio;
00239 BYTE nFrameRate;
00240 DWORD dwBitRate;
00241 DWORD dwVbvBufferSize;
00242 BYTE nConstrainedParametersFlag;
00243
00244 } SEQUENCEHEADER;
00245
00246 typedef struct sequence_extension_tag
00247 {
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 {
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 {
00269 BYTE nScalableMode;
00270 BYTE nLayerID;
00271 WORD wLowerLayerPredHSize;
00272 WORD wLowerLayerPredVSize;
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 {
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
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 {
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 {
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 {
00338 long lFrameCenterHorizontalOffset[3];
00339 long lFrameCenterVerticalOffset[3];
00340 } PICTUREDISPLAYEXT;
00341
00342 typedef struct picture_spatial_scalable_extension_tag
00343 {
00344 short shLowerLayerTemporalReference;
00345 short shLowerLayerHorizontalOffset;
00346 short shLowerLayerVerticalOffset;
00347 BYTE nSpatialTemporalWeightCodeTableIndex;
00348 BYTE nLowerLayerProgressiveFrame;
00349 BYTE nLowerLayerDeinterlacedFieldSelect;
00350 } PICTURESPATIALEXT;
00351
00352 typedef struct copyright_extension_tag
00353 {
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
00366 bool bSequenceExtension;
00367 bool bSequenceDisplayExt;
00368 bool bSequenceScalableExt;
00369
00370 bool bPictureExtension;
00371 bool bPictureDisplayExt;
00372 bool bPictureSpatialExt;
00373 bool bCopyrightExt;
00374 bool bQuantMatrixExt;
00375
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;
00392 bool bSpeedFlag;
00393 int iStatus;
00394 } DECODERINFO;
00395
00396 typedef struct picture_info_tag
00397 {
00398
00399 bool bSecondField;
00400 PACKETPOS CurPicturePckPos;
00401 long lCurPicturePckOffset;
00402
00403 long lUnwrappedFrameNum;
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;
00416 WORD wCodedFrameHeight;
00417 WORD wCodedChromaWidth;
00418 WORD wCodedChromaHeight;
00419 WORD wMBWidth;
00420 WORD wMBHeight;
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