1 /* ------------------------------------------------------------------ 2 * Copyright (C) 1998-2009 PacketVideo 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13 * express or implied. 14 * See the License for the specific language governing permissions 15 * and limitations under the License. 16 * ------------------------------------------------------------------- 17 */ 18 #ifndef _MP4LIB_INT_H_ 19 #define _MP4LIB_INT_H_ 20 21 #include "mp4def.h" 22 #include "mp4dec_api.h" // extra structure 23 24 #undef ENABLE_LOG 25 #define BITRATE_AVERAGE_WINDOW 4 26 #define FRAMERATE_SCALE ((BITRATE_AVERAGE_WINDOW-1)*10000L) 27 #define FAST_IDCT /* , for fast Variable complexity IDCT */ 28 //#define PV_DEC_EXTERNAL_IDCT /* for separate IDCT (i.e. no direct access to output frame) */ 29 #define PV_ANNEX_IJKT_SUPPORT 30 #define mid_gray 1024 31 32 typedef struct tagBitstream 33 { 34 /* function that reteive data from outside the library. 04/11/2000 */ 35 /* In frame-based decoding mode, this shall be NULL. 08/29/2000 */ 36 uint32 curr_word; 37 uint32 next_word; 38 uint8 *bitstreamBuffer; /* pointer to buffer memory */ 39 int32 read_point; /* starting point in the buffer to be read to cache */ 40 int incnt; /* bit left in cached */ 41 int incnt_next; 42 uint32 bitcnt; /* total bit read so-far (from inbfr)*/ 43 int32 data_end_pos; /*should be added , 06/07/2000 */ 44 int searched_frame_boundary; 45 } BitstreamDecVideo, *LPBitstreamDecVideo; 46 47 /* complexity estimation parameters */ 48 typedef struct tagComplexity_Est 49 { 50 uint8 text_1; /* texture_complexity_estimation_set_1 */ 51 uint8 text_2; /* texture_complexity_estimation_set_2 */ 52 uint8 mc; /* motion_compensation_complexity */ 53 } Complexity_Est; 54 55 56 typedef struct tagVop 57 { 58 PIXEL *yChan; /* The Y component */ 59 PIXEL *uChan; /* The U component */ 60 PIXEL *vChan; /* The V component */ 61 62 uint32 timeStamp; /* Vop TimeStamp in msec */ 63 64 /* Actual syntax elements for VOP (standard) */ 65 int predictionType; /* VOP prediction type */ 66 uint timeInc; /* VOP time increment (relative to last mtb) */ 67 int vopCoded; 68 int roundingType; 69 int intraDCVlcThr; 70 int16 quantizer; /* VOP quantizer */ 71 int fcodeForward; /* VOP dynamic range of motion vectors */ 72 int fcodeBackward; /* VOP dynamic range of motion vectors */ 73 int refSelectCode; /* enhancement layer reference select code */ 74 75 /* H.263 parameters */ 76 int gobNumber; 77 int gobFrameID; 78 int temporalRef; /* temporal reference, roll over at 256 */ 79 int ETR; 80 } Vop; 81 82 typedef struct tagVol 83 { 84 int volID; /* VOL identifier (for tracking) */ 85 uint timeIncrementResolution;/* VOL time increment */ 86 int nbitsTimeIncRes; /* number of bits for time increment */ 87 uint timeInc_offset; /* timeInc offset for multiple VOP in a packet */ 88 uint32 moduloTimeBase; /* internal decoder clock */ 89 int fixedVopRate; 90 BitstreamDecVideo *bitstream; /* library bitstream buffer (input buffer) */ 91 92 int complexity_estDisable; /* VOL disable complexity estimation */ 93 int complexity_estMethod; /* VOL complexity estimation method */ 94 Complexity_Est complexity; /* complexity estimation flags */ 95 96 /* Error Resilience Flags */ 97 int errorResDisable; /* VOL disable error resilence mode */ 98 /* (Use Resynch markers) */ 99 int useReverseVLC; /* VOL reversible VLCs */ 100 int dataPartitioning; /* VOL data partitioning */ 101 102 /* Bit depth */ 103 uint bitsPerPixel; 104 // int mid_gray; /* 2^(bits_per_pixel+2) */ 105 106 /* Quantization related parameters */ 107 int quantPrecision; /* Quantizer precision */ 108 uint quantType; /* MPEG-4 or H.263 Quantization Type */ 109 /* Added loaded quant mat, 05/22/2000 */ 110 int loadIntraQuantMat; /* Load intra quantization matrix */ 111 int loadNonIntraQuantMat; /* Load nonintra quantization matrix */ 112 int iqmat[64]; /* Intra quant.matrix */ 113 int niqmat[64]; /* Non-intra quant.matrix */ 114 115 /* Parameters used for scalability */ 116 int scalability; /* VOL scalability (flag) */ 117 int scalType; /* temporal = 0, spatial = 1, both = 2 */ 118 119 int refVolID; /* VOL id of reference VOL */ 120 int refSampDir; /* VOL resol. of ref. VOL */ 121 int horSamp_n; /* VOL hor. resampling of ref. VOL given by */ 122 int horSamp_m; /* sampfac = hor_samp_n/hor_samp_m */ 123 int verSamp_n; /* VOL ver. resampling of ref. VOL given by */ 124 int verSamp_m; /* sampfac = ver_samp_n/ver_samp_m */ 125 int enhancementType; /* VOL type of enhancement layer */ 126 /* profile and level */ 127 int32 profile_level_id; /* 8-bit profile and level */ // 6/17/04 128 129 } Vol; 130 131 132 typedef int16 typeMBStore[6][NCOEFF_BLOCK]; 133 134 typedef struct tagMacroBlock 135 { 136 typeMBStore block; /* blocks */ /* ACDC */ 137 uint8 pred_block[384]; /* prediction block, Aug 3,2005 */ 138 uint8 bitmapcol[6][8]; 139 uint8 bitmaprow[6]; 140 int no_coeff[6]; 141 int DCScalarLum; /* Luminance DC Scalar */ 142 int DCScalarChr; /* Chrominance DC Scalar */ 143 #ifdef PV_ANNEX_IJKT_SUPPORT 144 int direction; 145 #endif 146 } MacroBlock; 147 148 typedef struct tagHeaderInfoDecVideo 149 { 150 uint8 *Mode; /* Modes INTRA/INTER/etc. */ 151 uint8 *CBP; /* MCBPC/CBPY stuff */ 152 } HeaderInfoDecVideo; 153 154 155 /************************************************************/ 156 /* VLC structures */ 157 /************************************************************/ 158 typedef struct tagTcoef 159 { 160 uint last; 161 uint run; 162 int level; 163 uint sign; 164 } Tcoef, *LPTcoef; 165 166 167 168 typedef struct tagVLCtab 169 { 170 int32 val; 171 int32 len; 172 } VLCtab, *LPVLCtab; 173 174 typedef struct tagVLCshorttab 175 { 176 int16 val; 177 int16 len; 178 } VLCshorttab, *LPVLCshorttab ; /* for space saving, Antoine Nguyen*/ 179 180 typedef struct tagVLCtab2 181 { 182 uint8 run; 183 uint8 level; 184 uint8 last; 185 uint8 len; 186 } VLCtab2, *LPVLCtab2; /* 10/24/2000 */ 187 188 /* This type is designed for fast access of DC/AC */ 189 /* prediction data. If the compiler is smart */ 190 /* enough, it will use shifting for indexing. */ 191 /* 04/14/2000. */ 192 193 typedef int16 typeDCStore[6]; /* ACDC */ 194 typedef int16 typeDCACStore[4][8]; 195 196 197 198 /* Global structure that can be passed around */ 199 typedef struct tagVideoDecData 200 { 201 BitstreamDecVideo *bitstream; /* library bitstream buffer (input buffer) */ 202 /* Data For Layers (Scalability) */ 203 Vol **vol; /* Data stored for each VOL */ 204 205 /* Data used for reconstructing frames */ 206 Vop *currVop; /* Current VOP (frame) */ 207 Vop *prevVop; /* Previous VOP (frame) */ 208 /* Data used to facilitate multiple layer decoding. 05/04/2000 */ 209 Vop *prevEnhcVop; /* New change to rid of memcpy(). 04/24/2001 */ 210 Vop **vopHeader; /* one for each layer. 08/29/2000 */ 211 212 /* I/O structures */ 213 MacroBlock *mblock; /* Macroblock data structure */ 214 uint8 *acPredFlag; /* */ 215 216 /* scratch memory used in data partitioned mode */ 217 typeDCStore *predDC; /* The DC coeffs for each MB */ 218 typeDCACStore *predDCAC_row; 219 typeDCACStore *predDCAC_col; 220 221 int usePrevQP; /* running QP decision switch */ 222 uint8 *sliceNo; /* Slice indicator for each MB */ 223 /* changed this to a 1D */ 224 /* array for optimization */ 225 MOT *motX; /* Motion vector in X direction */ 226 MOT *motY; /* Motion vector in Y direction */ 227 HeaderInfoDecVideo headerInfo; /* MB Header information */ 228 int16 *QPMB; /* Quantizer value for each MB */ 229 230 uint8 *pstprcTypCur; /* Postprocessing type for current frame */ 231 uint8 *pstprcTypPrv; /* Postprocessing type for previous frame */ 232 /* scratch memory used in all modes */ 233 int mbnum; /* Macroblock number */ 234 uint mbnum_row; 235 int mbnum_col; 236 /* I added these variables since they are used a lot. 04/13/2000 */ 237 int nMBPerRow, nMBPerCol; /* number of MBs in each row & column */ 238 int nTotalMB; 239 /* for short video header */ 240 int nMBinGOB; /* number of MBs in GOB, 05/22/00 */ 241 int nGOBinVop; /* number of GOB in Vop 05/22/00 */ 242 /* VOL Dimensions */ 243 int width; /* Width */ 244 int height; /* Height */ 245 int displayWidth; /* Handle image whose size is not a multiple of 16. */ 246 int displayHeight; /* This is the actual size. 08/09/2000 */ 247 int32 size; 248 /* Miscellaneous data points to be passed */ 249 int frame_idx; /* Current frame ID */ 250 int frameRate; /* Output frame Rate (over 10 seconds) */ 251 int32 duration; 252 uint32 currTimestamp; 253 int currLayer; /* Current frame layer */ 254 int shortVideoHeader; /* shortVideoHeader mode */ 255 int intra_acdcPredDisable; /* VOL disable INTRA DC prediction */ 256 int numberOfLayers; /* Number of Layers */ 257 /* Frame to be used for concealment 07/07/2001 */ 258 uint8 *concealFrame; 259 int vop_coding_type; 260 /* framerate and bitrate statistics counters. 08/23/2000 */ 261 int32 nBitsPerVop[BITRATE_AVERAGE_WINDOW]; 262 uint32 prevTimestamp[BITRATE_AVERAGE_WINDOW]; 263 int nBitsForMBID; /* how many bits required for MB number? */ 264 /* total data memory used by the docder library. 08/23/2000 */ 265 int32 memoryUsage; 266 267 /* flag to turn on/off error concealment or soft decoding */ 268 int errorConcealment; 269 270 /* Application controls */ 271 VideoDecControls *videoDecControls; 272 int postFilterType; /* Postfilter mode 04/25/00 */ 273 274 275 276 PV_STATUS(*vlcDecCoeffIntra)(BitstreamDecVideo *stream, Tcoef *pTcoef/*, int intra_luma*/); 277 PV_STATUS(*vlcDecCoeffInter)(BitstreamDecVideo *stream, Tcoef *pTcoef); 278 int initialized; 279 280 /* Annex IJKT */ 281 int deblocking; 282 int slice_structure; 283 int modified_quant; 284 int advanced_INTRA; 285 int16 QP_CHR; /* ANNEX_T */ 286 } VideoDecData; 287 288 /* for fast VLC+Dequant 10/12/2000*/ 289 typedef int (*VlcDequantBlockFuncP)(void *video, int comp, int switched, 290 uint8 *bitmaprow, uint8 *bitmapcol); 291 292 ////////////////////////////////////////////////////////////// 293 // Decoder structures // 294 ////////////////////////////////////////////////////////////// 295 #endif /* _MP4LIB_INT_H_ */ 296 297