source: 3DVCSoftware/branches/HTM-DEV-0.2-dev/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.h @ 438

Last change on this file since 438 was 438, checked in by tech, 12 years ago

Integrated 3D encoder control, camera parameters, renderer and MV fixes.

  • Property svn:eol-style set to native
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-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/**
35 \file     TEncSampleAdaptiveOffset.h
36 \brief    estimation part of sample adaptive offset class (header)
37 */
38
39#ifndef __TENCSAMPLEADAPTIVEOFFSET__
40#define __TENCSAMPLEADAPTIVEOFFSET__
41
42#include "TLibCommon/TComSampleAdaptiveOffset.h"
43#include "TLibCommon/TComPic.h"
44
45#include "TEncEntropy.h"
46#include "TEncSbac.h"
47#include "TLibCommon/TComBitCounter.h"
48
49//! \ingroup TLibEncoder
50//! \{
51
52// ====================================================================================================================
53// Class definition
54// ====================================================================================================================
55
56class TEncSampleAdaptiveOffset : public TComSampleAdaptiveOffset
57{
58private:
59  Double            m_dLambdaLuma;
60  Double            m_dLambdaChroma;
61
62  TEncEntropy*      m_pcEntropyCoder;
63  TEncSbac***       m_pppcRDSbacCoder;              ///< for CABAC
64  TEncSbac*         m_pcRDGoOnSbacCoder;
65#if FAST_BIT_EST
66  TEncBinCABACCounter*** m_pppcBinCoderCABAC;            ///< temporal CABAC state storage for RD computation
67#else
68  TEncBinCABAC***   m_pppcBinCoderCABAC;            ///< temporal CABAC state storage for RD computation
69#endif
70 
71  Int64  ***m_iCount;      //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];
72  Int64  ***m_iOffset;     //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];
73  Int64  ***m_iOffsetOrg;  //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];
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  Int64  **m_iRate;        //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];
77  Int64  **m_iDist;        //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];
78  Double **m_dCost;        //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];
79  Double *m_dCostPartBest; //[MAX_NUM_SAO_PART];
80  Int64  *m_iDistOrg;      //[MAX_NUM_SAO_PART];
81  Int    *m_iTypePartBest; //[MAX_NUM_SAO_PART];
82  Int     m_iOffsetThY;
83  Int     m_iOffsetThC;
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  Void runQuadTreeDecision(SAOQTPart *psQTPart, Int iPartIdx, Double &dCostFinal, Int iMaxLevel, Double dLambda, Int yCbCr);
111  Void rdoSaoOnePart(SAOQTPart *psQTPart, Int iPartIdx, Double dLambda, Int yCbCr);
112 
113  Void disablePartTree(SAOQTPart *psQTPart, Int iPartIdx);
114  Void getSaoStats(SAOQTPart *psQTPart, Int iYCbCr);
115  Void calcSaoStatsCu(Int iAddr, Int iPartIdx, Int iYCbCr);
116  Void calcSaoStatsBlock( Pel* pRecStart, Pel* pOrgStart, Int stride, Int64** ppStats, Int64** ppCount, UInt width, UInt height, Bool* pbBorderAvail, Int iYCbCr);
117  Void calcSaoStatsCuOrg(Int iAddr, Int iPartIdx, Int iYCbCr);
118  Void calcSaoStatsCu_BeforeDblk( TComPic* pcPic );
119  Void destroyEncBuffer();
120  Void createEncBuffer();
121  Void assignSaoUnitSyntax(SaoLcuParam* saoLcuParam,  SAOQTPart* saoPart, Bool &oneUnitFlag, Int yCbCr);
122  Void checkMerge(SaoLcuParam * lcuParamCurr,SaoLcuParam * lcuParamCheck, Int dir);
123#if SAO_ENCODING_CHOICE
124  Void rdoSaoUnitAll(SAOParam *saoParam, Double lambda, Double lambdaChroma, Int depth);
125#else
126  Void rdoSaoUnitAll(SAOParam *saoParam, Double lambda, Double lambdaChroma);
127#endif
128  Void saoComponentParamDist(Int allowMergeLeft, Int allowMergeUp, SAOParam *saoParam, Int addr, Int addrUp, Int addrLeft, Int yCbCr, Double lambda, SaoLcuParam *compSaoParam, Double *distortion);
129  Void sao2ChromaParamDist(Int allowMergeLeft, Int allowMergeUp, SAOParam *saoParam, Int addr, Int addrUp, Int addrLeft, Double lambda, SaoLcuParam *crSaoParam, SaoLcuParam *cbSaoParam, Double *distortion);
130  inline Int64 estSaoDist(Int64 count, Int64 offset, Int64 offsetOrg, Int shift);
131  inline Int64 estIterOffset(Int typeIdx, Int classIdx, Double lambda, Int64 offsetInput, Int64 count, Int64 offsetOrg, Int shift, Int bitIncrease, Int *currentDistortionTableBo, Double *currentRdCostTableBo, Int offsetTh );
132  inline Int64 estSaoTypeDist(Int compIdx, Int typeIdx, Int shift, Double lambda, Int *currentDistortionTableBo, Double *currentRdCostTableBo);
133  Void setMaxNumOffsetsPerPic(Int iVal) {m_maxNumOffsetsPerPic = iVal; }
134  Int  getMaxNumOffsetsPerPic() {return m_maxNumOffsetsPerPic; }
135};
136
137//! \}
138
139#endif
Note: See TracBrowser for help on using the repository browser.