source: 3DVCSoftware/branches/HTM-3.0-Vidyo/source/Lib/TLibCommon/TComSampleAdaptiveOffset.h @ 353

Last change on this file since 353 was 56, checked in by hschwarz, 13 years ago

updated trunk (move to HM6.1)

File size: 6.6 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#if SAO_UNIT_INTERLEAVING
55#define MAX_NUM_SAO_OFFSETS           4
56#define MAX_NUM_SAO_CLASS             33
57#else
58#define MAX_NUM_SAO_CLASS             32
59#endif
60// ====================================================================================================================
61// Class definition
62// ====================================================================================================================
63
64/// Sample Adaptive Offset class
65class TComSampleAdaptiveOffset
66{
67protected:
68  TComPic*          m_pcPic;
69
70  static UInt m_uiMaxDepth;
71  static const Int m_aiNumPartsInRow[5];
72  static const Int m_aiNumPartsLevel[5];
73  static const Int m_aiNumCulPartsLevel[5];
74  static const UInt m_auiEoTable[9];
75  static const UInt m_auiEoTable2D[9];
76  static const UInt m_iWeightSao[MAX_NUM_SAO_TYPE];
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#if SAO_UNIT_INTERLEAVING
98  Pel   *m_lumaTableBo;
99#else
100  Pel   *m_ppLumaTableBo0;
101  Pel   *m_ppLumaTableBo1;
102#endif
103  Int   *m_iUpBuff1;
104  Int   *m_iUpBuff2;
105  Int   *m_iUpBufft;
106  Int   *ipSwap;
107  Bool  m_bUseNIF;       //!< true for performing non-cross slice boundary ALF
108  UInt  m_uiNumSlicesInPic;      //!< number of slices in picture
109  Int   m_iSGDepth;              //!< slice granularity depth
110  TComPicYuv* m_pcYuvTmp;    //!< temporary picture buffer pointer when non-across slice/tile boundary SAO is enabled
111
112  Pel* m_pTmpU1;
113  Pel* m_pTmpU2;
114  Pel* m_pTmpL1;
115  Pel* m_pTmpL2;
116  Int* m_iLcuPartIdx;
117#if SAO_UNIT_INTERLEAVING
118  Int     m_maxNumOffsetsPerPic;
119  Bool    m_saoInterleavingFlag;
120#else
121  Void initTmpSaoQuadTree(SAOQTPart *psQTPart, Int iYCbCr);
122  Void disableSaoOnePart(SAOQTPart *psQTPart, UInt uiPartIdx, Int iYCbCr);
123  Void xSaoQt2Lcu(SAOQTPart *psQTPart,UInt uiPartIdx);
124  Void convertSaoQt2Lcu(SAOQTPart *psQTPart,UInt uiPartIdx);
125  Void xSaoAllPart(SAOQTPart *psQTPart, Int iYCbCr);
126#endif
127public:
128  TComSampleAdaptiveOffset         ();
129  virtual ~TComSampleAdaptiveOffset();
130
131  Void create( UInt uiSourceWidth, UInt uiSourceHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth );
132  Void destroy ();
133
134  Int  convertLevelRowCol2Idx(int level, int row, int col);
135  void convertIdx2LevelRowCol(int idx, int *level, int *row, int *col);
136
137  Void initSAOParam   (SAOParam *pcSaoParam, Int iPartLevel, Int iPartRow, Int iPartCol, Int iParentPartIdx, Int StartCUX, Int EndCUX, Int StartCUY, Int EndCUY, Int iYCbCr);
138  Void allocSaoParam  (SAOParam* pcSaoParam);
139  Void resetSAOParam  (SAOParam *pcSaoParam);
140  Void freeSaoParam   (SAOParam *pcSaoParam);
141
142  Void SAOProcess(TComPic* pcPic, SAOParam* pcSaoParam);
143  Void processSaoCu(Int iAddr, Int iSaoType, Int iYCbCr);
144  Void processSaoOnePart(SAOQTPart *psQTPart, UInt uiPartIdx, Int iYCbCr);
145  Void processSaoQuadTree(SAOQTPart *psQTPart, UInt uiPartIdx, Int iYCbCr);
146  Pel* getPicYuvAddr(TComPicYuv* pcPicYuv, Int iYCbCr,Int iAddr = 0);
147
148  Void processSaoCuOrg(Int iAddr, Int iPartIdx, Int iYCbCr);  //!< LCU-basd SAO process without slice granularity
149  Void createPicSaoInfo(TComPic* pcPic, Int numSlicesInPic = 1);
150  Void destroyPicSaoInfo();
151  Void processSaoBlock(Pel* pDec, Pel* pRest, Int stride, Int iSaoType, UInt xPos, UInt yPos, UInt width, UInt height, Bool* pbBorderAvail);
152
153#if SAO_UNIT_INTERLEAVING
154  Void resetLcuPart(SaoLcuParam* saoLcuParam);
155  Void convertQT2SaoUnit(SAOParam* saoParam, UInt partIdx, Int yCbCr);
156  Void convertOnePart2SaoUnit(SAOParam *saoParam, UInt partIdx, Int yCbCr);
157  Void processSaoUnitAll(SaoLcuParam* saoLcuParam, Bool oneUnitFlag, Int yCbCr);
158  Void setSaoInterleavingFlag (Bool bVal)  {m_saoInterleavingFlag = bVal;}
159  Bool getSaoInterleavingFlag ()           {return m_saoInterleavingFlag;}
160#endif
161};
162
163//! \}
164#endif
165
Note: See TracBrowser for help on using the repository browser.