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_slice.h 34 #ifndef WELS_SLICE_H__ 35 #define WELS_SLICE_H__ 36 37 #include "typedefs.h" 38 #include "wels_const.h" 39 #include "wels_common_basis.h" 40 #include "picture.h" 41 #include "parameter_sets.h" 42 43 namespace WelsDec { 44 45 /* 46 * Reference picture list reordering syntax, refer to page 64 in JVT X201wcm 47 */ 48 typedef struct TagRefPicListReorderSyntax { 49 struct { 50 uint32_t uiAbsDiffPicNumMinus1; 51 uint16_t uiLongTermPicNum; 52 uint16_t uiReorderingOfPicNumsIdc; 53 } sReorderingSyn[LIST_A][MAX_REF_PIC_COUNT + 1]; 54 bool bRefPicListReorderingFlag[LIST_A]; 55 } SRefPicListReorderSyn, *PRefPicListReorderSyn; 56 57 /* 58 * Prediction weight table syntax, refer to page 65 in JVT X201wcm 59 */ 60 typedef struct TagPredWeightTabSyntax { 61 uint32_t uiLumaLog2WeightDenom; 62 uint32_t uiChromaLog2WeightDenom; 63 struct { 64 int32_t iLumaWeight[MAX_REF_PIC_COUNT]; 65 int32_t iLumaOffset[MAX_REF_PIC_COUNT]; 66 int32_t iChromaWeight[MAX_REF_PIC_COUNT][2]; 67 int32_t iChromaOffset[MAX_REF_PIC_COUNT][2]; 68 bool bLumaWeightFlag; 69 bool bChromaWeightFlag; 70 } sPredList[LIST_A]; 71 int32_t iImplicitWeight[MAX_REF_PIC_COUNT][MAX_REF_PIC_COUNT]; 72 } SPredWeightTabSyn, *PPredWeightTabSyn; 73 74 /* Decoded reference picture marking syntax, refer to Page 66 in JVT X201wcm */ 75 typedef struct TagRefPicMarking { 76 struct { 77 uint32_t uiMmcoType; 78 int32_t iShortFrameNum; 79 int32_t iDiffOfPicNum; 80 uint32_t uiLongTermPicNum; 81 int32_t iLongTermFrameIdx; 82 int32_t iMaxLongTermFrameIdx; 83 } sMmcoRef[MAX_MMCO_COUNT]; 84 85 bool bNoOutputOfPriorPicsFlag; 86 bool bLongTermRefFlag; 87 bool bAdaptiveRefPicMarkingModeFlag; 88 } SRefPicMarking, *PRefPicMarking; 89 90 /* Decode reference base picture marking syntax in Page 396 of JVT X201wcm */ 91 typedef struct TagRefBasePicMarkingSyn { 92 struct { 93 uint32_t uiMmcoType; 94 int32_t iShortFrameNum; 95 uint32_t uiDiffOfPicNums; 96 uint32_t uiLongTermPicNum; //should uint32_t, cover larger range of iFrameNum. 97 } mmco_base[MAX_MMCO_COUNT]; // MAX_REF_PIC for reference picture based on frame 98 99 bool bAdaptiveRefBasePicMarkingModeFlag; 100 } SRefBasePicMarking, *PRefBasePicMarking; 101 102 /* Header of slice syntax elements, refer to Page 63 in JVT X201wcm */ 103 typedef struct TagSliceHeaders { 104 /*****************************slice header syntax and generated****************************/ 105 int32_t iFirstMbInSlice; 106 int32_t iFrameNum; 107 int32_t iPicOrderCntLsb; 108 int32_t iDeltaPicOrderCntBottom; 109 int32_t iDeltaPicOrderCnt[2]; 110 int32_t iRedundantPicCnt; 111 int32_t iDirectSpatialMvPredFlag; //!< Direct Mode type to be used (0: Temporal, 1: Spatial) 112 int32_t uiRefCount[LIST_A]; 113 int32_t iSliceQpDelta; //no use for iSliceQp is used directly 114 int32_t iSliceQp; 115 int32_t iSliceQsDelta; // For SP/SI slices 116 uint32_t uiDisableDeblockingFilterIdc; 117 int32_t iSliceAlphaC0Offset; 118 int32_t iSliceBetaOffset; 119 int32_t iSliceGroupChangeCycle; 120 121 PSps pSps; 122 PPps pPps; 123 int32_t iSpsId; 124 int32_t iPpsId; 125 bool bIdrFlag; 126 127 /*********************got from other layer for efficency if possible*********************/ 128 SRefPicListReorderSyn pRefPicListReordering; // Reference picture list reordering syntaxs 129 SPredWeightTabSyn sPredWeightTable; 130 int32_t iCabacInitIdc; 131 int32_t iMbWidth; //from? 132 int32_t iMbHeight; //from? 133 SRefPicMarking sRefMarking; // Decoded reference picture marking syntaxs 134 135 uint16_t uiIdrPicId; 136 EWelsSliceType eSliceType; 137 bool bNumRefIdxActiveOverrideFlag; 138 bool bFieldPicFlag; //not supported in base profile 139 bool bBottomFiledFlag; //not supported in base profile 140 uint8_t uiPadding1Byte; 141 bool bSpForSwitchFlag; // For SP/SI slices 142 int16_t iPadding2Bytes; 143 } SSliceHeader, *PSliceHeader; 144 145 146 /* Slice header in scalable extension syntax, refer to Page 394 in JVT X201wcm */ 147 typedef struct TagSliceHeaderExt { 148 SSliceHeader sSliceHeader; 149 PSubsetSps pSubsetSps; 150 151 uint32_t uiDisableInterLayerDeblockingFilterIdc; 152 int32_t iInterLayerSliceAlphaC0Offset; 153 int32_t iInterLayerSliceBetaOffset; 154 155 //SPosOffset sScaledRefLayer; 156 int32_t iScaledRefLayerPicWidthInSampleLuma; 157 int32_t iScaledRefLayerPicHeightInSampleLuma; 158 159 SRefBasePicMarking sRefBasePicMarking; 160 bool bBasePredWeightTableFlag; 161 bool bStoreRefBasePicFlag; 162 bool bConstrainedIntraResamplingFlag; 163 bool bSliceSkipFlag; 164 165 bool bAdaptiveBaseModeFlag; 166 bool bDefaultBaseModeFlag; 167 bool bAdaptiveMotionPredFlag; 168 bool bDefaultMotionPredFlag; 169 bool bAdaptiveResidualPredFlag; 170 bool bDefaultResidualPredFlag; 171 bool bTCoeffLevelPredFlag; 172 uint8_t uiRefLayerChromaPhaseXPlus1Flag; 173 174 uint8_t uiRefLayerChromaPhaseYPlus1; 175 uint8_t uiRefLayerDqId; 176 uint8_t uiScanIdxStart; 177 uint8_t uiScanIdxEnd; 178 } SSliceHeaderExt, *PSliceHeaderExt; 179 180 181 typedef struct TagSlice { 182 /*******************************slice_header****************************/ 183 SSliceHeaderExt sSliceHeaderExt; 184 185 /*******************************use for future****************************/ 186 // for Macroblock coding within slice 187 int32_t iLastMbQp; // stored qp for last mb coded, maybe more efficient for mb skip detection etc. 188 189 /*******************************slice_data****************************/ 190 /*slice_data_ext()*/ 191 int32_t iMbSkipRun; 192 int32_t iTotalMbInCurSlice; //record the total number of MB in current slice. 193 194 /*slice_data_ext() generate*/ 195 196 /*******************************misc use****************************/ 197 bool bSliceHeaderExtFlag; // Indicate which slice header is used, avc or ext? 198 /*************got from other layer for effiency if possible***************/ 199 /*from lower layer: slice header*/ 200 uint8_t eSliceType; 201 uint8_t uiPadding[2]; 202 int32_t iLastDeltaQp; 203 int16_t iMvScale[LIST_A][MAX_DPB_COUNT]; //Moton vector scale For Temporal Direct Mode Type 204 } SSlice, *PSlice; 205 206 } // namespace WelsDec 207 208 #endif//WELS_SLICE_H__ 209