[56] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
| 6 | * Copyright (c) 2010-2012, ITU/ISO/IEC |
---|
| 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
| 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | /** \file TComSampleAdaptiveOffset.h |
---|
| 35 | \brief sample adaptive offset class (header) |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #ifndef __TCOMSAMPLEADAPTIVEOFFSET__ |
---|
| 39 | #define __TCOMSAMPLEADAPTIVEOFFSET__ |
---|
| 40 | |
---|
| 41 | #include "CommonDef.h" |
---|
| 42 | #include "TComPic.h" |
---|
| 43 | |
---|
| 44 | //! \ingroup TLibCommon |
---|
| 45 | //! \{ |
---|
| 46 | |
---|
| 47 | // ==================================================================================================================== |
---|
| 48 | // Constants |
---|
| 49 | // ==================================================================================================================== |
---|
| 50 | |
---|
| 51 | #define SAO_MAX_DEPTH 4 |
---|
| 52 | #define SAO_BO_BITS 5 |
---|
| 53 | #define LUMA_GROUP_NUM (1<<SAO_BO_BITS) |
---|
| 54 | #define MAX_NUM_SAO_OFFSETS 4 |
---|
| 55 | #define MAX_NUM_SAO_CLASS 33 |
---|
| 56 | // ==================================================================================================================== |
---|
| 57 | // Class definition |
---|
| 58 | // ==================================================================================================================== |
---|
| 59 | |
---|
| 60 | /// Sample Adaptive Offset class |
---|
| 61 | class TComSampleAdaptiveOffset |
---|
| 62 | { |
---|
| 63 | protected: |
---|
| 64 | TComPic* m_pcPic; |
---|
| 65 | |
---|
| 66 | static UInt m_uiMaxDepth; |
---|
[443] | 67 | #if !LGE_SAO_MIGRATION_D0091 |
---|
[56] | 68 | static const Int m_aiNumPartsInRow[5]; |
---|
| 69 | static const Int m_aiNumPartsLevel[5]; |
---|
[443] | 70 | #endif |
---|
[56] | 71 | static const Int m_aiNumCulPartsLevel[5]; |
---|
| 72 | static const UInt m_auiEoTable[9]; |
---|
[443] | 73 | #if !LGE_SAO_MIGRATION_D0091 |
---|
[56] | 74 | static const UInt m_auiEoTable2D[9]; |
---|
| 75 | static const UInt m_iWeightSao[MAX_NUM_SAO_TYPE]; |
---|
[443] | 76 | #endif |
---|
[56] | 77 | Int *m_iOffsetBo; |
---|
| 78 | Int m_iOffsetEo[LUMA_GROUP_NUM]; |
---|
| 79 | |
---|
| 80 | Int m_iPicWidth; |
---|
| 81 | Int m_iPicHeight; |
---|
| 82 | UInt m_uiMaxSplitLevel; |
---|
| 83 | UInt m_uiMaxCUWidth; |
---|
| 84 | UInt m_uiMaxCUHeight; |
---|
| 85 | Int m_iNumCuInWidth; |
---|
| 86 | Int m_iNumCuInHeight; |
---|
| 87 | Int m_iNumTotalParts; |
---|
| 88 | static Int m_iNumClass[MAX_NUM_SAO_TYPE]; |
---|
| 89 | SliceType m_eSliceType; |
---|
| 90 | Int m_iPicNalReferenceIdc; |
---|
| 91 | |
---|
| 92 | UInt m_uiSaoBitIncrease; |
---|
| 93 | UInt m_uiQP; |
---|
| 94 | |
---|
| 95 | Pel *m_pClipTable; |
---|
| 96 | Pel *m_pClipTableBase; |
---|
| 97 | Pel *m_lumaTableBo; |
---|
| 98 | Int *m_iUpBuff1; |
---|
| 99 | Int *m_iUpBuff2; |
---|
| 100 | Int *m_iUpBufft; |
---|
| 101 | Int *ipSwap; |
---|
| 102 | Bool m_bUseNIF; //!< true for performing non-cross slice boundary ALF |
---|
| 103 | UInt m_uiNumSlicesInPic; //!< number of slices in picture |
---|
| 104 | Int m_iSGDepth; //!< slice granularity depth |
---|
| 105 | TComPicYuv* m_pcYuvTmp; //!< temporary picture buffer pointer when non-across slice/tile boundary SAO is enabled |
---|
| 106 | |
---|
| 107 | Pel* m_pTmpU1; |
---|
| 108 | Pel* m_pTmpU2; |
---|
| 109 | Pel* m_pTmpL1; |
---|
| 110 | Pel* m_pTmpL2; |
---|
| 111 | Int* m_iLcuPartIdx; |
---|
| 112 | Int m_maxNumOffsetsPerPic; |
---|
[443] | 113 | #if LGE_SAO_MIGRATION_D0091 |
---|
| 114 | Bool m_saoLcuBoundary; |
---|
| 115 | Bool m_saoLcuBasedOptimization; |
---|
| 116 | |
---|
| 117 | Void xPCMRestoration (TComPic* pcPic); |
---|
| 118 | Void xPCMCURestoration (TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth); |
---|
| 119 | Void xPCMSampleRestoration (TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth, TextType ttText); |
---|
| 120 | #else |
---|
[56] | 121 | Bool m_saoInterleavingFlag; |
---|
[443] | 122 | #endif |
---|
[56] | 123 | public: |
---|
| 124 | TComSampleAdaptiveOffset (); |
---|
| 125 | virtual ~TComSampleAdaptiveOffset(); |
---|
| 126 | |
---|
| 127 | Void create( UInt uiSourceWidth, UInt uiSourceHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth ); |
---|
| 128 | Void destroy (); |
---|
| 129 | |
---|
| 130 | Int convertLevelRowCol2Idx(int level, int row, int col); |
---|
[443] | 131 | #if !LGE_SAO_MIGRATION_D0091 |
---|
[56] | 132 | void convertIdx2LevelRowCol(int idx, int *level, int *row, int *col); |
---|
[443] | 133 | #endif |
---|
[56] | 134 | |
---|
| 135 | Void initSAOParam (SAOParam *pcSaoParam, Int iPartLevel, Int iPartRow, Int iPartCol, Int iParentPartIdx, Int StartCUX, Int EndCUX, Int StartCUY, Int EndCUY, Int iYCbCr); |
---|
| 136 | Void allocSaoParam (SAOParam* pcSaoParam); |
---|
| 137 | Void resetSAOParam (SAOParam *pcSaoParam); |
---|
[443] | 138 | #if LGE_SAO_MIGRATION_D0091 |
---|
| 139 | static Void freeSaoParam (SAOParam *pcSaoParam); |
---|
| 140 | #else |
---|
[56] | 141 | Void freeSaoParam (SAOParam *pcSaoParam); |
---|
[443] | 142 | #endif |
---|
| 143 | |
---|
[56] | 144 | |
---|
| 145 | Void SAOProcess(TComPic* pcPic, SAOParam* pcSaoParam); |
---|
| 146 | Void processSaoCu(Int iAddr, Int iSaoType, Int iYCbCr); |
---|
[443] | 147 | #if !LGE_SAO_MIGRATION_D0091 |
---|
[56] | 148 | Void processSaoOnePart(SAOQTPart *psQTPart, UInt uiPartIdx, Int iYCbCr); |
---|
| 149 | Void processSaoQuadTree(SAOQTPart *psQTPart, UInt uiPartIdx, Int iYCbCr); |
---|
[443] | 150 | #endif |
---|
[56] | 151 | Pel* getPicYuvAddr(TComPicYuv* pcPicYuv, Int iYCbCr,Int iAddr = 0); |
---|
| 152 | |
---|
| 153 | Void processSaoCuOrg(Int iAddr, Int iPartIdx, Int iYCbCr); //!< LCU-basd SAO process without slice granularity |
---|
| 154 | Void createPicSaoInfo(TComPic* pcPic, Int numSlicesInPic = 1); |
---|
| 155 | Void destroyPicSaoInfo(); |
---|
| 156 | Void processSaoBlock(Pel* pDec, Pel* pRest, Int stride, Int iSaoType, UInt xPos, UInt yPos, UInt width, UInt height, Bool* pbBorderAvail); |
---|
| 157 | |
---|
| 158 | Void resetLcuPart(SaoLcuParam* saoLcuParam); |
---|
| 159 | Void convertQT2SaoUnit(SAOParam* saoParam, UInt partIdx, Int yCbCr); |
---|
| 160 | Void convertOnePart2SaoUnit(SAOParam *saoParam, UInt partIdx, Int yCbCr); |
---|
| 161 | Void processSaoUnitAll(SaoLcuParam* saoLcuParam, Bool oneUnitFlag, Int yCbCr); |
---|
[443] | 162 | #if LGE_SAO_MIGRATION_D0091 |
---|
| 163 | Void setSaoLcuBoundary (Bool bVal) {m_saoLcuBoundary = bVal;} |
---|
| 164 | Bool getSaoLcuBoundary () {return m_saoLcuBoundary;} |
---|
| 165 | Void setSaoLcuBasedOptimization (Bool bVal) {m_saoLcuBasedOptimization = bVal;} |
---|
| 166 | Bool getSaoLcuBasedOptimization () {return m_saoLcuBasedOptimization;} |
---|
| 167 | Void resetSaoUnit(SaoLcuParam* saoUnit); |
---|
| 168 | Void copySaoUnit(SaoLcuParam* saoUnitDst, SaoLcuParam* saoUnitSrc ); |
---|
| 169 | Void PCMLFDisableProcess ( TComPic* pcPic); ///< interface function for ALF process |
---|
| 170 | #else |
---|
[56] | 171 | Void setSaoInterleavingFlag (Bool bVal) {m_saoInterleavingFlag = bVal;} |
---|
| 172 | Bool getSaoInterleavingFlag () {return m_saoInterleavingFlag;} |
---|
[443] | 173 | #endif |
---|
[56] | 174 | }; |
---|
| 175 | |
---|
| 176 | //! \} |
---|
| 177 | #endif |
---|
| 178 | |
---|