source: SHVCSoftware/branches/0.1.1-bugfix/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.h @ 1263

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

Initial import by Vadim Seregin <vseregin@…>

File size: 7.1 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     TEncAdaptiveLoopFilter.h
35 \brief    estimation part of sample adaptive offset class (header)
36 */
37
38#ifndef __TENCSAMPLEADAPTIVEOFFSET__
39#define __TENCSAMPLEADAPTIVEOFFSET__
40
41#include "TLibCommon/TComSampleAdaptiveOffset.h"
42#include "TLibCommon/TComPic.h"
43
44#include "TEncEntropy.h"
45#include "TEncSbac.h"
46#include "TLibCommon/TComBitCounter.h"
47
48//! \ingroup TLibEncoder
49//! \{
50
51// ====================================================================================================================
52// Class definition
53// ====================================================================================================================
54
55class TEncSampleAdaptiveOffset : public TComSampleAdaptiveOffset
56{
57private:
58  Double            m_dLambdaLuma;
59  Double            m_dLambdaChroma;
60
61  TEncEntropy*      m_pcEntropyCoder;
62  TEncSbac***       m_pppcRDSbacCoder;              ///< for CABAC
63  TEncSbac*         m_pcRDGoOnSbacCoder;
64#if FAST_BIT_EST
65  TEncBinCABACCounter*** m_pppcBinCoderCABAC;            ///< temporal CABAC state storage for RD computation
66#else
67  TEncBinCABAC***   m_pppcBinCoderCABAC;            ///< temporal CABAC state storage for RD computation
68#endif
69 
70  Int64  ***m_iCount;      //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];
71  Int64  ***m_iOffset;     //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];
72  Int64  ***m_iOffsetOrg;  //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];
73#if SAO_LCU_BOUNDARY
74  Int64  ****m_count_PreDblk;      //[LCU][YCbCr][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];
75  Int64  ****m_offsetOrg_PreDblk;  //[LCU][YCbCr][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];
76#endif
77  Int64  **m_iRate;        //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];
78  Int64  **m_iDist;        //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];
79  Double **m_dCost;        //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];
80  Double *m_dCostPartBest; //[MAX_NUM_SAO_PART];
81  Int64  *m_iDistOrg;      //[MAX_NUM_SAO_PART];
82  Int    *m_iTypePartBest; //[MAX_NUM_SAO_PART];
83  Int     m_iOffsetTh;
84  Bool    m_bUseSBACRD;
85#if SAO_ENCODING_CHOICE
86#if SAO_ENCODING_CHOICE_CHROMA
87  Double  m_depthSaoRate[2][4];
88#else
89  Double  m_depth0SaoRate;
90#endif
91#endif
92
93public:
94  TEncSampleAdaptiveOffset         ();
95  virtual ~TEncSampleAdaptiveOffset();
96
97  Void startSaoEnc( TComPic* pcPic, TEncEntropy* pcEntropyCoder, TEncSbac*** pppcRDSbacCoder, TEncSbac* pcRDGoOnSbacCoder);
98  Void endSaoEnc();
99  Void resetStats();
100#if SAO_CHROMA_LAMBDA
101#if SAO_ENCODING_CHOICE
102  Void SAOProcess(SAOParam *pcSaoParam, Double dLambda, Double dLambdaChroma, Int depth);
103#else
104  Void SAOProcess(SAOParam *pcSaoParam, Double dLambda, Double dLambdaChroma);
105#endif
106#else
107  Void SAOProcess(SAOParam *pcSaoParam, Double dLambda);
108#endif
109
110#if PICTURE_SAO_RDO_FIX 
111  Void runQuadTreeDecision(SAOQTPart *psQTPart, Int iPartIdx, Double &dCostFinal, Int iMaxLevel, Double dLambda, Int yCbCr);
112  Void rdoSaoOnePart(SAOQTPart *psQTPart, Int iPartIdx, Double dLambda, Int yCbCr);
113#else
114  Void runQuadTreeDecision(SAOQTPart *psQTPart, Int iPartIdx, Double &dCostFinal, Int iMaxLevel, Double dLambda);
115  Void rdoSaoOnePart(SAOQTPart *psQTPart, Int iPartIdx, Double dLambda);
116#endif
117 
118  Void disablePartTree(SAOQTPart *psQTPart, Int iPartIdx);
119  Void getSaoStats(SAOQTPart *psQTPart, Int iYCbCr);
120  Void calcSaoStatsCu(Int iAddr, Int iPartIdx, Int iYCbCr);
121  Void calcSaoStatsBlock( Pel* pRecStart, Pel* pOrgStart, Int stride, Int64** ppStats, Int64** ppCount, UInt width, UInt height, Bool* pbBorderAvail);
122  Void calcSaoStatsCuOrg(Int iAddr, Int iPartIdx, Int iYCbCr);
123#if SAO_LCU_BOUNDARY
124  Void calcSaoStatsCu_BeforeDblk( TComPic* pcPic );
125#endif
126  Void destroyEncBuffer();
127  Void createEncBuffer();
128  Void assignSaoUnitSyntax(SaoLcuParam* saoLcuParam,  SAOQTPart* saoPart, Bool &oneUnitFlag, Int yCbCr);
129  Void checkMerge(SaoLcuParam * lcuParamCurr,SaoLcuParam * lcuParamCheck, Int dir);
130#if SAO_ENCODING_CHOICE
131  Void rdoSaoUnitAll(SAOParam *saoParam, Double lambda, Double lambdaChroma, Int depth);
132#else
133  Void rdoSaoUnitAll(SAOParam *saoParam, Double lambda, Double lambdaChroma);
134#endif
135#if SAO_SINGLE_MERGE
136  Void saoComponentParamDist(Int allowMergeLeft, Int allowMergeUp, SAOParam *saoParam, Int addr, Int addrUp, Int addrLeft, Int yCbCr, Double lambda, SaoLcuParam *compSaoParam, Double *distortion);
137#if SAO_TYPE_SHARING
138  Void sao2ChromaParamDist(Int allowMergeLeft, Int allowMergeUp, SAOParam *saoParam, Int addr, Int addrUp, Int addrLeft, Double lambda, SaoLcuParam *crSaoParam, SaoLcuParam *cbSaoParam, Double *distortion);
139#endif
140#else
141  Void rdoSaoUnit(Int rx, Int ry, SAOParam *saoParam, Int addr, Int addrUp, Int addrLeft, Int yCbCr, Double lambda);
142#endif
143  inline Int64 estSaoDist(Int64 count, Int64 offset, Int64 offsetOrg, Int shift);
144  inline Int64 estIterOffset(Int typeIdx, Int classIdx, double lambda, Int64 offsetInput, Int64 count, Int64 offsetOrg, Int shift, Int bitIncrease, Int *currentDistortionTableBo, Double *currentRdCostTableBo );
145  inline Int64 estSaoTypeDist(Int compIdx, Int typeIdx, Int shift, Double lambda, Int *currentDistortionTableBo, Double *currentRdCostTableBo);
146  Void setMaxNumOffsetsPerPic(Int iVal) {m_maxNumOffsetsPerPic = iVal; }
147  Int  getMaxNumOffsetsPerPic() {return m_maxNumOffsetsPerPic; }
148};
149
150//! \}
151
152#endif
Note: See TracBrowser for help on using the repository browser.