source: SHVCSoftware/branches/SHM-1.0-dev/source/Lib/TLibCommon/TComSampleAdaptiveOffset.h @ 569

Last change on this file since 569 was 2, checked in by seregin, 12 years ago

Initial import by Vadim Seregin <vseregin@…>

File size: 6.5 KB
Line 
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
61class TComSampleAdaptiveOffset
62{
63protected:
64  TComPic*          m_pcPic;
65
66  static const UInt m_uiMaxDepth;
67  static const Int m_aiNumCulPartsLevel[5];
68  static const UInt m_auiEoTable[9];
69  Int *m_iOffsetBo;
70  Int m_iOffsetEo[LUMA_GROUP_NUM];
71
72  Int  m_iPicWidth;
73  Int  m_iPicHeight;
74  UInt m_uiMaxSplitLevel;
75  UInt m_uiMaxCUWidth;
76  UInt m_uiMaxCUHeight;
77  Int  m_iNumCuInWidth;
78  Int  m_iNumCuInHeight;
79  Int  m_iNumTotalParts;
80  static const Int m_iNumClass[MAX_NUM_SAO_TYPE];
81  SliceType  m_eSliceType;
82  Int        m_iPicNalReferenceIdc;
83
84  UInt m_uiSaoBitIncrease;
85  UInt m_uiQP;
86
87  Pel   *m_pClipTable;
88  Pel   *m_pClipTableBase;
89  Pel   *m_lumaTableBo;
90  Int   *m_iUpBuff1;
91  Int   *m_iUpBuff2;
92  Int   *m_iUpBufft;
93  Int   *ipSwap;
94  Bool  m_bUseNIF;       //!< true for performing non-cross slice boundary ALF
95  UInt  m_uiNumSlicesInPic;      //!< number of slices in picture
96  Int   m_iSGDepth;              //!< slice granularity depth
97  TComPicYuv* m_pcYuvTmp;    //!< temporary picture buffer pointer when non-across slice/tile boundary SAO is enabled
98
99  Pel* m_pTmpU1;
100  Pel* m_pTmpU2;
101  Pel* m_pTmpL1;
102  Pel* m_pTmpL2;
103  Int* m_iLcuPartIdx;
104  Int     m_maxNumOffsetsPerPic;
105#if SAO_LCU_BOUNDARY
106  Bool    m_saoLcuBoundary;
107#endif
108  Bool    m_saoLcuBasedOptimization;
109
110#if REMOVE_ALF
111  Void xPCMRestoration        (TComPic* pcPic);
112  Void xPCMCURestoration      (TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth);
113  Void xPCMSampleRestoration  (TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth, TextType ttText);
114#endif
115public:
116  TComSampleAdaptiveOffset         ();
117  virtual ~TComSampleAdaptiveOffset();
118
119  Void create( UInt uiSourceWidth, UInt uiSourceHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth );
120  Void destroy ();
121
122  Int  convertLevelRowCol2Idx(int level, int row, int col);
123
124  Void initSAOParam   (SAOParam *pcSaoParam, Int iPartLevel, Int iPartRow, Int iPartCol, Int iParentPartIdx, Int StartCUX, Int EndCUX, Int StartCUY, Int EndCUY, Int iYCbCr);
125  Void allocSaoParam  (SAOParam* pcSaoParam);
126  Void resetSAOParam  (SAOParam *pcSaoParam);
127#if REMOVE_APS
128  static Void freeSaoParam   (SAOParam *pcSaoParam);
129#else
130  Void freeSaoParam   (SAOParam *pcSaoParam);
131#endif
132 
133  Void SAOProcess(TComPic* pcPic, SAOParam* pcSaoParam);
134  Void processSaoCu(Int iAddr, Int iSaoType, Int iYCbCr);
135  Pel* getPicYuvAddr(TComPicYuv* pcPicYuv, Int iYCbCr,Int iAddr = 0);
136
137  Void processSaoCuOrg(Int iAddr, Int iPartIdx, Int iYCbCr);  //!< LCU-basd SAO process without slice granularity
138  Void createPicSaoInfo(TComPic* pcPic, Int numSlicesInPic = 1);
139  Void destroyPicSaoInfo();
140  Void processSaoBlock(Pel* pDec, Pel* pRest, Int stride, Int iSaoType, UInt xPos, UInt yPos, UInt width, UInt height, Bool* pbBorderAvail);
141
142  Void resetLcuPart(SaoLcuParam* saoLcuParam);
143  Void convertQT2SaoUnit(SAOParam* saoParam, UInt partIdx, Int yCbCr);
144  Void convertOnePart2SaoUnit(SAOParam *saoParam, UInt partIdx, Int yCbCr);
145  Void processSaoUnitAll(SaoLcuParam* saoLcuParam, Bool oneUnitFlag, Int yCbCr);
146#if SAO_LCU_BOUNDARY
147  Void setSaoLcuBoundary (Bool bVal)  {m_saoLcuBoundary = bVal;}
148  Bool getSaoLcuBoundary ()           {return m_saoLcuBoundary;}
149#endif
150  Void setSaoLcuBasedOptimization (Bool bVal)  {m_saoLcuBasedOptimization = bVal;}
151  Bool getSaoLcuBasedOptimization ()           {return m_saoLcuBasedOptimization;}
152  Void resetSaoUnit(SaoLcuParam* saoUnit);
153#if SAO_SINGLE_MERGE
154  Void copySaoUnit(SaoLcuParam* saoUnitDst, SaoLcuParam* saoUnitSrc );
155#endif
156#if REMOVE_ALF
157  Void PCMLFDisableProcess    ( TComPic* pcPic);                        ///< interface function for ALF process
158#endif
159};
160
161//! \}
162#endif
163
Note: See TracBrowser for help on using the repository browser.