1 /*! 2 * \copy 3 * Copyright (c) 2013, Cisco Systems 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 13 * * Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the 16 * distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 28 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 * 31 */ 32 33 #ifndef WELS_VIDEO_CODEC_DEFINITION_H__ 34 #define WELS_VIDEO_CODEC_DEFINITION_H__ 35 36 /** 37 * @file codec_def.h 38 */ 39 40 /** 41 * @brief Enumerate the type of video format 42 */ 43 typedef enum { 44 videoFormatRGB = 1, ///< rgb color formats 45 videoFormatRGBA = 2, 46 videoFormatRGB555 = 3, 47 videoFormatRGB565 = 4, 48 videoFormatBGR = 5, 49 videoFormatBGRA = 6, 50 videoFormatABGR = 7, 51 videoFormatARGB = 8, 52 53 videoFormatYUY2 = 20, ///< yuv color formats 54 videoFormatYVYU = 21, 55 videoFormatUYVY = 22, 56 videoFormatI420 = 23, ///< the same as IYUV 57 videoFormatYV12 = 24, 58 videoFormatInternal = 25, ///< only used in SVC decoder testbed 59 60 videoFormatNV12 = 26, ///< new format for output by DXVA decoding 61 62 videoFormatVFlip = 0x80000000 63 } EVideoFormatType; 64 65 /** 66 * @brief Enumerate video frame type 67 */ 68 typedef enum { 69 videoFrameTypeInvalid, ///< encoder not ready or parameters are invalidate 70 videoFrameTypeIDR, ///< IDR frame in H.264 71 videoFrameTypeI, ///< I frame type 72 videoFrameTypeP, ///< P frame type 73 videoFrameTypeSkip, ///< skip the frame based encoder kernel 74 videoFrameTypeIPMixed ///< a frame where I and P slices are mixing, not supported yet 75 } EVideoFrameType; 76 77 /** 78 * @brief Enumerate return type 79 */ 80 typedef enum { 81 cmResultSuccess, ///< successful 82 cmInitParaError, ///< parameters are invalid 83 cmUnknownReason, 84 cmMallocMemeError, ///< malloc a memory error 85 cmInitExpected, ///< initial action is expected 86 cmUnsupportedData 87 } CM_RETURN; 88 89 /** 90 * @brief Enumulate the nal unit type 91 */ 92 enum ENalUnitType { 93 NAL_UNKNOWN = 0, 94 NAL_SLICE = 1, 95 NAL_SLICE_DPA = 2, 96 NAL_SLICE_DPB = 3, 97 NAL_SLICE_DPC = 4, 98 NAL_SLICE_IDR = 5, ///< ref_idc != 0 99 NAL_SEI = 6, ///< ref_idc == 0 100 NAL_SPS = 7, 101 NAL_PPS = 8 102 ///< ref_idc == 0 for 6,9,10,11,12 103 }; 104 105 /** 106 * @brief NRI: eNalRefIdc 107 */ 108 enum ENalPriority { 109 NAL_PRIORITY_DISPOSABLE = 0, 110 NAL_PRIORITY_LOW = 1, 111 NAL_PRIORITY_HIGH = 2, 112 NAL_PRIORITY_HIGHEST = 3 113 }; 114 115 #define IS_PARAMETER_SET_NAL(eNalRefIdc, eNalType) \ 116 ( (eNalRefIdc == NAL_PRIORITY_HIGHEST) && (eNalType == (NAL_SPS|NAL_PPS) || eNalType == NAL_SPS) ) 117 118 #define IS_IDR_NAL(eNalRefIdc, eNalType) \ 119 ( (eNalRefIdc == NAL_PRIORITY_HIGHEST) && (eNalType == NAL_SLICE_IDR) ) 120 121 #define FRAME_NUM_PARAM_SET (-1) 122 #define FRAME_NUM_IDR 0 123 124 /** 125 * @brief eDeblockingIdc 126 */ 127 enum { 128 DEBLOCKING_IDC_0 = 0, 129 DEBLOCKING_IDC_1 = 1, 130 DEBLOCKING_IDC_2 = 2 131 }; 132 #define DEBLOCKING_OFFSET (6) 133 #define DEBLOCKING_OFFSET_MINUS (-6) 134 135 /* Error Tools definition */ 136 typedef unsigned short ERR_TOOL; 137 138 /** 139 @brief to do 140 */ 141 enum { 142 ET_NONE = 0x00, ///< NONE Error Tools 143 ET_IP_SCALE = 0x01, ///< IP Scalable 144 ET_FMO = 0x02, ///< Flexible Macroblock Ordering 145 ET_IR_R1 = 0x04, ///< Intra Refresh in predifined 2% MB 146 ET_IR_R2 = 0x08, ///< Intra Refresh in predifined 5% MB 147 ET_IR_R3 = 0x10, ///< Intra Refresh in predifined 10% MB 148 ET_FEC_HALF = 0x20, ///< Forward Error Correction in 50% redundency mode 149 ET_FEC_FULL = 0x40, ///< Forward Error Correction in 100% redundency mode 150 ET_RFS = 0x80 ///< Reference Frame Selection 151 }; 152 153 /** 154 * @brief Information of coded Slice(=NAL)(s) 155 */ 156 typedef struct SliceInformation { 157 unsigned char* pBufferOfSlices; ///< base buffer of coded slice(s) 158 int iCodedSliceCount; ///< number of coded slices 159 unsigned int* pLengthOfSlices; ///< array of slices length accordingly by number of slice 160 int iFecType; ///< FEC type[0, 50%FEC, 100%FEC] 161 unsigned char uiSliceIdx; ///< index of slice in frame [FMO: 0,..,uiSliceCount-1; No FMO: 0] 162 unsigned char uiSliceCount; ///< count number of slice in frame [FMO: 2-8; No FMO: 1] 163 char iFrameIndex; ///< index of frame[-1, .., idr_interval-1] 164 unsigned char uiNalRefIdc; ///< NRI, priority level of slice(NAL) 165 unsigned char uiNalType; ///< NAL type 166 unsigned char 167 uiContainingFinalNal; ///< whether final NAL is involved in buffer of coded slices, flag used in Pause feature in T27 168 } SliceInfo, *PSliceInfo; 169 170 /** 171 * @brief thresholds of the initial, maximal and minimal rate 172 */ 173 typedef struct { 174 int iWidth; ///< frame width 175 int iHeight; ///< frame height 176 int iThresholdOfInitRate; ///< threshold of initial rate 177 int iThresholdOfMaxRate; ///< threshold of maximal rate 178 int iThresholdOfMinRate; ///< threshold of minimal rate 179 int iMinThresholdFrameRate; ///< min frame rate min 180 int iSkipFrameRate; ///< skip to frame rate min 181 int iSkipFrameStep; ///< how many frames to skip 182 } SRateThresholds, *PRateThresholds; 183 184 /** 185 * @brief Structure for decoder memery 186 */ 187 typedef struct TagSysMemBuffer { 188 int iWidth; ///< width of decoded pic for display 189 int iHeight; ///< height of decoded pic for display 190 int iFormat; ///< type is "EVideoFormatType" 191 int iStride[2]; ///< stride of 2 component 192 } SSysMEMBuffer; 193 194 /** 195 * @brief Buffer info 196 */ 197 typedef struct TagBufferInfo { 198 int iBufferStatus; ///< 0: one frame data is not ready; 1: one frame data is ready 199 unsigned long long uiInBsTimeStamp; ///< input BS timestamp 200 unsigned long long uiOutYuvTimeStamp; ///< output YUV timestamp, when bufferstatus is 1 201 union { 202 SSysMEMBuffer sSystemBuffer; ///< memory info for one picture 203 } UsrData; ///< output buffer info 204 unsigned char* pDst[3]; //point to picture YUV data 205 } SBufferInfo; 206 207 208 /** 209 * @brief In a GOP, multiple of the key frame number, derived from 210 * the number of layers(index or array below) 211 */ 212 static const char kiKeyNumMultiple[] = { 213 1, 1, 2, 4, 8, 16, 214 }; 215 216 #endif//WELS_VIDEO_CODEC_DEFINITION_H__ 217