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 _PVDECDEF_H_ 19#define _PVDECDEF_H_ 20 21#include "mp4dec_api.h" 22 23typedef enum 24{ 25 PV_SUCCESS, 26 PV_FAIL, 27 PV_MB_STUFFING, /* hit Macroblock_Stuffing */ 28 PV_END_OF_VOP, /* hit End_of_Video_Object_Plane */ 29 PV_END_OF_MB /* hit End_of_Macroblock */ 30#ifdef PV_TOLERATE_VOL_ERRORS 31 , PV_BAD_VOLHEADER 32#endif 33} PV_STATUS; 34 35typedef uint8 PIXEL; 36typedef int16 MOT; /* : "int" type runs faster on RISC machine */ 37 38#define TRUE 1 39#define FALSE 0 40 41#define PV_ABS(x) (((x)<0)? -(x) : (x)) 42#define PV_SIGN(x) (((x)<0)? -1 : 1) 43#define PV_SIGN0(a) (((a)<0)? -1 : (((a)>0) ? 1 : 0)) 44#define PV_MAX(a,b) ((a)>(b)? (a):(b)) 45#define PV_MIN(a,b) ((a)<(b)? (a):(b)) 46#define PV_MEDIAN(A,B,C) ((A) > (B) ? ((A) < (C) ? (A) : (B) > (C) ? (B) : (C)): (B) < (C) ? (B) : (C) > (A) ? (C) : (A)) 47/* You don't want to use ((x>UB)?UB:(x<LB)?LB:x) for the clipping */ 48/* because it will use one extra comparison if the compiler is */ 49/* not well-optimized. 04/19/2000. */ 50#define CLIP_THE_RANGE(x,LB,UB) if (x<LB) x = LB; else if (x>UB) x = UB 51 52#define MODE_INTRA 0x08 //01000 53#define MODE_INTRA_Q 0x09 //01001 54#define MODE_SKIPPED 0x10 //10000 55#define MODE_INTER4V 0x14 //10100 56#define MODE_INTER 0x16 //10110 57#define MODE_INTER_Q 0x17 //10111 58#define MODE_INTER4V_Q 0x15 //10101 59#define INTER_1VMASK 0x2 60#define Q_MASK 0x1 61#define INTRA_MASK 0x8 62#define INTER_MASK 0x4 63 64 65#define I_VOP 0 66#define P_VOP 1 67#define B_VOP 2 68 69#define LUMINANCE_DC_TYPE 1 70#define CHROMINANCE_DC_TYPE 2 71 72#define START_CODE_LENGTH 32 73 74/* 11/30/98 */ 75#define NoMarkerFound -1 76#define FoundRM 1 /* Resync Marker */ 77#define FoundVSC 2 /* VOP_START_CODE. */ 78#define FoundGSC 3 /* GROUP_START_CODE */ 79#define FoundEOB 4 /* EOB_CODE */ 80 81/* PacketVideo "absolution timestamp" object. 06/13/2000 */ 82#define PVTS_START_CODE 0x01C4 83#define PVTS_START_CODE_LENGTH 32 84 85/* session layer and vop layer start codes */ 86 87#define VISUAL_OBJECT_SEQUENCE_START_CODE 0x01B0 88#define VISUAL_OBJECT_SEQUENCE_END_CODE 0x01B1 89 90#define VISUAL_OBJECT_START_CODE 0x01B5 91#define VO_START_CODE 0x8 92#define VO_HEADER_LENGTH 32 /* lengtho of VO header: VO_START_CODE + VO_ID */ 93 94#define SOL_START_CODE 0x01BE 95#define SOL_START_CODE_LENGTH 32 96 97#define VOL_START_CODE 0x12 98#define VOL_START_CODE_LENGTH 28 99 100#define VOP_START_CODE 0x1B6 101#define VOP_START_CODE_LENGTH 32 102 103#define GROUP_START_CODE 0x01B3 104#define GROUP_START_CODE_LENGTH 32 105 106#define VOP_ID_CODE_LENGTH 5 107#define VOP_TEMP_REF_CODE_LENGTH 16 108 109#define USER_DATA_START_CODE 0x01B2 110#define USER_DATA_START_CODE_LENGTH 32 111 112#define START_CODE_PREFIX 0x01 113#define START_CODE_PREFIX_LENGTH 24 114 115#define SHORT_VIDEO_START_MARKER 0x20 116#define SHORT_VIDEO_START_MARKER_LENGTH 22 117#define SHORT_VIDEO_END_MARKER 0x3F 118#define GOB_RESYNC_MARKER 0x01 119#define GOB_RESYNC_MARKER_LENGTH 17 120 121/* motion and resync markers used in error resilient mode */ 122 123#define DC_MARKER 438273 124#define DC_MARKER_LENGTH 19 125 126#define MOTION_MARKER_COMB 126977 127#define MOTION_MARKER_COMB_LENGTH 17 128 129#define MOTION_MARKER_SEP 81921 130#define MOTION_MARKER_SEP_LENGTH 17 131 132#define RESYNC_MARKER 1 133#define RESYNC_MARKER_LENGTH 17 134 135#define SPRITE_NOT_USED 0 136#define STATIC_SPRITE 1 137#define ONLINE_SPRITE 2 138#define GMC_SPRITE 3 139 140/* macroblock and block size */ 141#define MB_SIZE 16 142#define NCOEFF_MB (MB_SIZE*MB_SIZE) 143#define B_SIZE 8 144#define NCOEFF_BLOCK (B_SIZE*B_SIZE) 145#define NCOEFF_Y NCOEFF_MB 146#define NCOEFF_U NCOEFF_BLOCK 147#define NCOEFF_V NCOEFF_BLOCK 148#define BLK_PER_MB 4 /* Number of blocks per MB */ 149 150/* VLC decoding related definitions */ 151#define VLC_ERROR (-1) 152#define VLC_ESCAPE 7167 153 154 155/* macro utility */ 156#define ZERO_OUT_64BYTES(x) { *((uint32*)x) = *(((uint32*)(x))+1) = \ 157 *(((uint32*)(x))+2) = *(((uint32*)(x))+3) = \ 158 *(((uint32*)(x))+4) = *(((uint32*)(x))+5) = \ 159 *(((uint32*)(x))+6) = *(((uint32*)(x))+7) = \ 160 *(((uint32*)(x))+8) = *(((uint32*)(x))+9) = \ 161 *(((uint32*)(x))+10) = *(((uint32*)(x))+11) = \ 162 *(((uint32*)(x))+12) = *(((uint32*)(x))+13) = \ 163 *(((uint32*)(x))+14) = *(((uint32*)(x))+15) = 0; } 164 165 166 167#endif /* _PVDECDEF_H_ */ 168