source: SHVCSoftware/trunk/source/Lib/TLibCommon/TComSampleAdaptiveOffset.h @ 567

Last change on this file since 567 was 540, checked in by seregin, 11 years ago

merge SHM-4.1-dev branch

  • Property svn:eol-style set to native
File size: 8.8 KB
RevLine 
[313]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-2013, 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
[540]47
48#if HM_CLEANUP_SAO
[313]49// ====================================================================================================================
50// Constants
51// ====================================================================================================================
52
[540]53#define MAX_SAO_TRUNCATED_BITDEPTH     10
54// ====================================================================================================================
55// Class definition
56// ====================================================================================================================
57extern UInt g_saoMaxOffsetQVal[NUM_SAO_COMPONENTS]; 
58
59class TComSampleAdaptiveOffset
60{
61public:
62  TComSampleAdaptiveOffset();
63  virtual ~TComSampleAdaptiveOffset();
64  Void SAOProcess(TComPic* pDecPic);
65#if AUXILIARY_PICTURES
66  Void create( Int picWidth, Int picHeight, ChromaFormat chromaFormatIDC, UInt maxCUWidth, UInt maxCUHeight, UInt maxCUDepth );
67#else
68  Void create( Int picWidth, Int picHeight, UInt maxCUWidth, UInt maxCUHeight, UInt maxCUDepth );
69#endif
70  Void destroy();
71  Void reconstructBlkSAOParams(TComPic* pic, SAOBlkParam* saoBlkParams);
72  Void PCMLFDisableProcess (TComPic* pcPic);
73protected:
74  Void offsetBlock(Int compIdx, Int typeIdx, Int* offset, Pel* srcBlk, Pel* resBlk, Int srcStride, Int resStride,  Int width, Int height
75                  , Bool isLeftAvail, Bool isRightAvail, Bool isAboveAvail, Bool isBelowAvail, Bool isAboveLeftAvail, Bool isAboveRightAvail, Bool isBelowLeftAvail, Bool isBelowRightAvail);
76  Pel* getPicBuf(TComPicYuv* pPicYuv, Int compIdx);
77  Void invertQuantOffsets(Int compIdx, Int typeIdc, Int typeAuxInfo, Int* dstOffsets, Int* srcOffsets);
78  Void reconstructBlkSAOParam(SAOBlkParam& recParam, std::vector<SAOBlkParam*>& mergeList);
79  Int  getMergeList(TComPic* pic, Int ctu, SAOBlkParam* blkParams, std::vector<SAOBlkParam*>& mergeList);
80  Void offsetCTU(Int ctu, TComPicYuv* srcYuv, TComPicYuv* resYuv, SAOBlkParam& saoblkParam, TComPic* pPic);
81  Void xPCMRestoration(TComPic* pcPic);
82  Void xPCMCURestoration ( TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth );
83  Void xPCMSampleRestoration (TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth, TextType ttText);
84protected:
85  UInt m_offsetStepLog2[NUM_SAO_COMPONENTS]; //offset step 
86  Int* m_offsetClip[NUM_SAO_COMPONENTS]; //clip table for fast operation
87  Short* m_sign; //sign table for fast operation
88  TComPicYuv*   m_tempPicYuv; //temporary buffer
89  Int m_picWidth;
90  Int m_picHeight;
91  Int m_maxCUWidth;
92  Int m_maxCUHeight;
93  Int m_numCTUInWidth;
94  Int m_numCTUInHeight;
95  Int m_numCTUsPic;
96 
97 
98  Int m_lineBufWidth;
99  Char* m_signLineBuf1;
100  Char* m_signLineBuf2;
101private:
102  Bool m_picSAOEnabled[NUM_SAO_COMPONENTS];
103  Int*   m_offsetClipTable[NUM_SAO_COMPONENTS];
104  Short* m_signTable;
105
106};
107#else
108
109// ====================================================================================================================
110// Constants
111// ====================================================================================================================
112
[313]113#define SAO_MAX_DEPTH                 4
114#define SAO_BO_BITS                   5
115#define LUMA_GROUP_NUM                (1<<SAO_BO_BITS)
116#define MAX_NUM_SAO_OFFSETS           4
117#define MAX_NUM_SAO_CLASS             33
118// ====================================================================================================================
119// Class definition
120// ====================================================================================================================
121
122/// Sample Adaptive Offset class
123class TComSampleAdaptiveOffset
124{
125protected:
126  TComPic*          m_pcPic;
127
128  static const UInt m_uiMaxDepth;
129  static const Int m_aiNumCulPartsLevel[5];
130  static const UInt m_auiEoTable[9];
131  Int *m_iOffsetBo;
132  Int *m_iChromaOffsetBo;
133  Int m_iOffsetEo[LUMA_GROUP_NUM];
134
135  Int  m_iPicWidth;
136  Int  m_iPicHeight;
137  UInt m_uiMaxSplitLevel;
138  UInt m_uiMaxCUWidth;
139  UInt m_uiMaxCUHeight;
140  Int  m_iNumCuInWidth;
141  Int  m_iNumCuInHeight;
142  Int  m_iNumTotalParts;
143  static const Int m_iNumClass[MAX_NUM_SAO_TYPE];
144
145  UInt m_uiSaoBitIncreaseY;
146  UInt m_uiSaoBitIncreaseC;  //for chroma
147  UInt m_uiQP;
148
149  Pel   *m_pClipTable;
150  Pel   *m_pClipTableBase;
151  Pel   *m_lumaTableBo;
152  Pel   *m_pChromaClipTable;
153  Pel   *m_pChromaClipTableBase;
154  Pel   *m_chromaTableBo;
155  Int   *m_iUpBuff1;
156  Int   *m_iUpBuff2;
157  Int   *m_iUpBufft;
158  Int   *ipSwap;
159  Bool  m_bUseNIF;       //!< true for performing non-cross slice boundary ALF
160  TComPicYuv* m_pcYuvTmp;    //!< temporary picture buffer pointer when non-across slice/tile boundary SAO is enabled
161
162  Pel* m_pTmpU1;
163  Pel* m_pTmpU2;
164  Pel* m_pTmpL1;
165  Pel* m_pTmpL2;
166  Int     m_maxNumOffsetsPerPic;
167  Bool    m_saoLcuBoundary;
168  Bool    m_saoLcuBasedOptimization;
169
170  Void xPCMRestoration        (TComPic* pcPic);
171  Void xPCMCURestoration      (TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth);
172  Void xPCMSampleRestoration  (TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth, TextType ttText);
173public:
174  TComSampleAdaptiveOffset         ();
175  virtual ~TComSampleAdaptiveOffset();
176
177  Void create( UInt uiSourceWidth, UInt uiSourceHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight );
178  Void destroy ();
179
180  Int  convertLevelRowCol2Idx(Int level, Int row, Int col);
181
182  Void initSAOParam   (SAOParam *pcSaoParam, Int iPartLevel, Int iPartRow, Int iPartCol, Int iParentPartIdx, Int StartCUX, Int EndCUX, Int StartCUY, Int EndCUY, Int iYCbCr);
183  Void allocSaoParam  (SAOParam* pcSaoParam);
184  Void resetSAOParam  (SAOParam *pcSaoParam);
185  static Void freeSaoParam   (SAOParam *pcSaoParam);
186 
187  Void SAOProcess(SAOParam* pcSaoParam);
188  Void processSaoCu(Int iAddr, Int iSaoType, Int iYCbCr);
189  Pel* getPicYuvAddr(TComPicYuv* pcPicYuv, Int iYCbCr,Int iAddr = 0);
190
191  Void processSaoCuOrg(Int iAddr, Int iPartIdx, Int iYCbCr);  //!< LCU-basd SAO process without slice granularity
192  Void createPicSaoInfo(TComPic* pcPic);
193  Void destroyPicSaoInfo();
194  Void processSaoBlock(Pel* pDec, Pel* pRest, Int stride, Int iSaoType, UInt width, UInt height, Bool* pbBorderAvail, Int iYCbCr);
195
196  Void resetLcuPart(SaoLcuParam* saoLcuParam);
197  Void convertQT2SaoUnit(SAOParam* saoParam, UInt partIdx, Int yCbCr);
198  Void convertOnePart2SaoUnit(SAOParam *saoParam, UInt partIdx, Int yCbCr);
199  Void processSaoUnitAll(SaoLcuParam* saoLcuParam, Bool oneUnitFlag, Int yCbCr);
200  Void setSaoLcuBoundary (Bool bVal)  {m_saoLcuBoundary = bVal;}
201  Bool getSaoLcuBoundary ()           {return m_saoLcuBoundary;}
202  Void setSaoLcuBasedOptimization (Bool bVal)  {m_saoLcuBasedOptimization = bVal;}
203  Bool getSaoLcuBasedOptimization ()           {return m_saoLcuBasedOptimization;}
204  Void resetSaoUnit(SaoLcuParam* saoUnit);
205  Void copySaoUnit(SaoLcuParam* saoUnitDst, SaoLcuParam* saoUnitSrc );
206  Void PCMLFDisableProcess    ( TComPic* pcPic);                        ///< interface function for ALF process
207};
208
[540]209#endif
210
[313]211//! \}
212#endif
213
Note: See TracBrowser for help on using the repository browser.