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 //wels_common_basis.h 34 #ifndef WELS_COMMON_BASIS_H__ 35 #define WELS_COMMON_BASIS_H__ 36 37 #include "typedefs.h" 38 #include "macros.h" 39 40 #include "wels_const.h" 41 42 #include "wels_common_defs.h" 43 44 using namespace WelsCommon; 45 46 namespace WelsEnc { 47 48 typedef int32_t WelsErrorType; 49 50 struct SMVUnitXY { // each 4 Bytes 51 int16_t iMvX; 52 int16_t iMvY; 53 public: sDeltaMvSMVUnitXY54 SMVUnitXY& sDeltaMv (const SMVUnitXY& _v0, const SMVUnitXY& _v1) { 55 iMvX = _v0.iMvX - _v1.iMvX; 56 iMvY = _v0.iMvY - _v1.iMvY; 57 return (*this); 58 }; sAssignMvSMVUnitXY59 SMVUnitXY& sAssignMv (const SMVUnitXY& _v0) { 60 iMvX = _v0.iMvX; 61 iMvY = _v0.iMvY; 62 return (*this); 63 }; 64 }; 65 66 typedef struct TagMVComponentUnit { // each LIST_0/LIST_1 67 SMVUnitXY sMotionVectorCache[5 * 6 - 1]; // Luma only: 5 x 6 - 1 = 29 D-Words 68 int8_t iRefIndexCache[5 * 6]; // Luma only: 5 x 6 = 30 bytes 69 } SMVComponentUnit, *PMVComponentUnit; 70 71 72 typedef struct TagParaSetOffsetVariable { 73 int32_t iParaSetIdDelta[MAX_DQ_LAYER_NUM/*+1*/];//mark delta between SPS_ID_in_bs and sps_id_in_encoder, can be minus, for each dq-layer 74 //need not extra +1 due no MGS and FMO case so far 75 bool bUsedParaSetIdInBs[MAX_PPS_COUNT]; //mark the used SPS_ID with 1 76 uint32_t uiNextParaSetIdToUseInBs; //mark the next SPS_ID_in_bs, for all layers 77 } SParaSetOffsetVariable; 78 79 typedef struct TagParaSetOffset { 80 //in PS0 design, "sParaSetOffsetVariable" record the previous paras before current IDR, AND NEED to be stacked and recover across IDR 81 SParaSetOffsetVariable 82 sParaSetOffsetVariable[PARA_SET_TYPE]; //PARA_SET_TYPE=3; paraset_type = 0: AVC_SPS; =1: Subset_SPS; =2: PPS 83 //in PSO design, "bPpsIdMappingIntoSubsetsps" uses the current para of current IDR period 84 bool 85 bPpsIdMappingIntoSubsetsps[MAX_DQ_LAYER_NUM/*+1*/]; // need not extra +1 due no MGS and FMO case so far 86 87 int32_t iPpsIdList[MAX_DQ_LAYER_NUM][MAX_PPS_COUNT]; //index0: max pps types; index1: for differnt IDRs, if only index0=1, index1 can reach MAX_PPS_COUNT 88 89 #if _DEBUG 90 int32_t eSpsPpsIdStrategy; 91 #endif 92 93 uint32_t uiNeededSpsNum; 94 uint32_t uiNeededSubsetSpsNum; 95 uint32_t uiNeededPpsNum; 96 97 uint32_t uiInUseSpsNum; 98 uint32_t uiInUseSubsetSpsNum; 99 uint32_t uiInUsePpsNum; 100 } SParaSetOffset; 101 102 103 104 /* Position Offset structure */ 105 typedef struct TagCropOffset { 106 int16_t iCropLeft; 107 int16_t iCropRight; 108 int16_t iCropTop; 109 int16_t iCropBottom; 110 } SCropOffset; 111 112 113 /* Transform Type */ 114 115 enum ETransType { 116 T_4x4 = 0, 117 T_8x8 = 1, 118 T_16x16 = 2, 119 T_PCM = 3 120 }; 121 122 enum EMbPosition { 123 LEFT_MB_POS = 0x01, // A 124 TOP_MB_POS = 0x02, // B 125 TOPRIGHT_MB_POS = 0x04, // C 126 TOPLEFT_MB_POS = 0x08, // D, 127 RIGHT_MB_POS = 0x10, // add followed four case to reuse when intra up-sample 128 BOTTOM_MB_POS = 0x20, // 129 BOTTOMRIGHT_MB_POS = 0x40, // 130 BOTTOMLEFT_MB_POS = 0x80, // 131 MB_POS_A = 0x100 132 }; 133 134 /* MB Type & Sub-MB Type */ 135 typedef uint32_t Mb_Type; 136 137 #define MB_LEFT_BIT 0// add to use in intra up-sample 138 #define MB_TOP_BIT 1 139 #define MB_TOPRIGHT_BIT 2 140 #define MB_TOPLEFT_BIT 3 141 #define MB_RIGHT_BIT 4 142 #define MB_BOTTOM_BIT 5 143 #define MB_BTMRIGHT_BIT 6 144 #define MB_BTMLEFT_BIT 7 145 146 #define MB_TYPE_BACKGROUND 0x00010000 // conditional BG skip_mb 147 148 enum { 149 Intra4x4 = 0, 150 Intra16x16 = 1, 151 Inter16x16 = 2, 152 Inter16x8 = 3, 153 Inter8x16 = 4, 154 Inter8x8 = 5, 155 PSkip = 6 156 }; 157 158 159 } 160 #endif//WELS_COMMON_BASIS_H__ 161