HEVC Test Model (HM)  HM-16.18
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TComTU.h
Go to the documentation of this file.
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-2017, 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 #ifndef __TCOMTU__
35 #define __TCOMTU__
36 
37 class TComTU; // forward declaration
38 
39 #include "CommonDef.h"
40 #include "TComRectangle.h"
41 #include "TComChromaFormat.h"
42 
43 class TComDataCU; // forward declaration
44 
45 //----------------------------------------------------------------------------------------------------------------------
46 
47 
48 class TComTU
49 {
50  public:
52 
54 
55  protected:
57  Bool mbProcessLastOfLevel; // if true, then if size n/2 x n/2 is invalid, the nxn block for a channel is processed only for the last block, not the first.
72 
73  TComTU(const TComTU &); // not defined - do not use
74  TComTU&operator=(const TComTU &); // not defined - do not use
75 
76  public:
77  TComTU( TComDataCU *pcCU,
78  const UInt absPartIdxCU,
79  const UInt cuDepth,
80  const UInt initTrDepthRelCU);
81 
82  protected:
83  TComTU( TComTU &parentLevel,
84  const Bool bProcessLastOfLevel,
85  const TU_SPLIT_MODE splitMode = QUAD_SPLIT,
86  const Bool splitAtCurrentDepth = false,
87  const ComponentID absPartIdxSourceComponent = COMPONENT_Y
88  );
89 
90  public:
91  TComTU *Parent() { return mpParent; }
92  const TComTU *Parent() const { return mpParent; }
93 
94  UInt getCoefficientOffset(const ComponentID compID) const { return mOffsets[compID]; }
95 
96  const TComRectangle &getRect(const ComponentID compID) const { return mRect[compID]; }
97 
98  Bool ProcessingAllQuadrants(const ComponentID compID) const { return mCodeAll[compID]; }
99  Bool ProcessComponentSection(const ComponentID compID) const { return mRect[compID].width != 0; }
100  Bool ProcessChannelSection(const ChannelType chType) const { return mRect[chType].width != 0; }
101  UInt GetSectionNumber() const { return mSection; }
102 
103  UInt getCUDepth() const { return mCuDepth; }
104 
107 
109  UInt GetTransformDepthRelAdj(const ComponentID compID) const { return mTrDepthRelCU[compID]; }
111  {
112  assert(isLuma(chType) || (mTrDepthRelCU[COMPONENT_Cb] == mTrDepthRelCU[COMPONENT_Cr]));
113  return mTrDepthRelCU[isLuma(chType) ? COMPONENT_Y : COMPONENT_Cb];
114  }
115 
116  UInt GetAbsPartIdxCU() const { return mAbsPartIdxCU; }
118  UInt GetRelPartIdxTU(const ComponentID compID) const { return ProcessingAllQuadrants(compID) ? mAbsPartIdxTURelCU : (mAbsPartIdxTURelCU & (~0x3)); }
120  UInt GetAbsPartIdxTU(const ComponentID compID) const { return GetAbsPartIdxCU() + GetRelPartIdxTU(compID); }
123 
125 
126  TComDataCU *getCU() { return mpcCU; }
127  const TComDataCU *getCU() const { return mpcCU; }
128  Bool IsLastSection() const { return mSection+1>=((1<<mSplitMode)); }
129 
131  UInt GetEquivalentLog2TrSize(const ComponentID compID) const;
133 
134  Bool useDST(const ComponentID compID);
136 
138 };
139 
140 
141 
142 class TComTURecurse : public TComTU
143 {
144  public:
145 
147  const UInt absPartIdxCU,
148  const UInt forcedDepthOfCU)
149  : TComTU(pcCU, absPartIdxCU, forcedDepthOfCU, 0) { }
150 
151  TComTURecurse( TComDataCU *pcCU,
152  const UInt absPartIdxCU); // CU's depth is taken from CU->getDepth(idx)
153 
154  TComTURecurse( TComTU &parentLevel, //Parent TU from which recursion children are derived
155  const Bool bProcessLastOfLevel, //If true (and the split results in a "step-up" for chroma), the chroma TU is colocated with the last luma TU instead of the first
156  const TU_SPLIT_MODE splitMode = QUAD_SPLIT, //DONT_SPLIT = create one new TU as a copy of its parent, VERTICAL_SPLIT = split the TU into top and bottom halves, QUAD_SPLIT = split the TU into four equal quadrants
157  const Bool splitAtCurrentDepth = false, //Set true to keep the current depth when applying a vertical or quad split
158  const ComponentID absPartIdxSourceComponent = COMPONENT_Y //Specifies which component of the parent TU should be used to initialise the absPartIdx of the first child and the absPartIdx step (this is needed when splitting a "stepped-up" chroma TU)
159  )
160  : TComTU(parentLevel, bProcessLastOfLevel, splitMode, splitAtCurrentDepth, absPartIdxSourceComponent) { }
161 
162  Bool nextSection(const TComTU &parent); // returns true if there is another section to process, and prepares internal structures, else returns false
163 };
164 
165 //----------------------------------------------------------------------------------------------------------------------
166 
167 #endif
Bool ProcessChannelSection(const ChannelType chType) const
Definition: TComTU.h:100
CU data structure class.
Definition: TComDataCU.h:64
ChannelType
Definition: TypeDef.h:301
Bool useDST(const ComponentID compID)
Definition: TComTU.cpp:227
Defines version information, constants and small in-line functions.
TComTU & operator=(const TComTU &)
ChromaFormat mChromaFormat
Definition: TComTU.h:56
UInt GetRelPartIdxTU(const ComponentID compID) const
Definition: TComTU.h:118
TComTU * mpParent
Definition: TComTU.h:71
ChromaFormat GetChromaFormat() const
Definition: TComTU.h:124
unsigned int UInt
Definition: TypeDef.h:212
const TComTU * Parent() const
Definition: TComTU.h:92
UInt GetTransformDepthRel() const
Definition: TComTU.h:108
TComTURecurse(TComTU &parentLevel, const Bool bProcessLastOfLevel, const TU_SPLIT_MODE splitMode=QUAD_SPLIT, const Bool splitAtCurrentDepth=false, const ComponentID absPartIdxSourceComponent=COMPONENT_Y)
Definition: TComTU.h:154
Bool IsLastSection() const
Definition: TComTU.h:128
UInt GetTransformDepthRelAdj(const ChannelType chType) const
Definition: TComTU.h:110
Bool nextSection(const TComTU &parent)
Definition: TComTU.cpp:178
Bool mCodeAll[MAX_NUM_COMPONENT]
Definition: TComTU.h:63
UInt GetSectionNumber() const
Definition: TComTU.h:101
UInt GetAbsPartIdxTU() const
Definition: TComTU.h:119
TU_SPLIT_MODE GetSplitMode() const
Definition: TComTU.h:132
UInt mOffsets[MAX_NUM_COMPONENT]
Definition: TComTU.h:65
UInt getGolombRiceStatisticsIndex(const ComponentID compID)
Definition: TComTU.cpp:245
UInt mAbsPartIdxTURelCU
Definition: TComTU.h:67
TU_SPLIT_MODE mSplitMode
Definition: TComTU.h:61
bool Bool
Definition: TypeDef.h:204
TComTU(const TComTU &)
UInt GetEquivalentLog2TrSize(const ComponentID compID) const
Definition: TComTU.cpp:221
Bool ProcessingAllQuadrants(const ComponentID compID) const
Definition: TComTU.h:98
UInt getCUDepth() const
Definition: TComTU.h:103
static const UInt NUMBER_OF_SECTIONS[NUMBER_OF_SPLIT_MODES]
Definition: TComTU.h:53
enum TComTU::TU_SPLIT_MODE SPLIT_MODE
UInt GetLog2LumaTrSize() const
Definition: TComTU.h:130
ChromaFormat
chroma formats (according to semantics of chroma_format_idc)
Definition: TypeDef.h:292
UInt getCoefficientOffset(const ComponentID compID) const
Definition: TComTU.h:94
UInt GetAbsPartIdxNumParts(const ComponentID compID) const
Definition: TComTU.h:122
UInt GetAbsPartIdxTU(const ComponentID compID) const
Definition: TComTU.h:120
const TComRectangle & getRect(const ComponentID compID) const
Definition: TComTU.h:96
Bool mbProcessLastOfLevel
Definition: TComTU.h:57
TComDataCU * mpcCU
Definition: TComTU.h:69
TComDataCU * getCU()
Definition: TComTU.h:126
TComTU * Parent()
Definition: TComTU.h:91
Bool ProcessComponentSection(const ComponentID compID) const
Definition: TComTU.h:99
UInt GetAbsPartIdxNumParts() const
Definition: TComTU.h:121
UInt mCuDepth
Definition: TComTU.h:58
Definition: TComTU.h:48
UInt mSection
Definition: TComTU.h:60
UInt mAbsPartIdxCU
Definition: TComTU.h:66
ComponentID
Definition: TypeDef.h:308
UInt GetAbsPartIdxCU() const
Definition: TComTU.h:116
TU_SPLIT_MODE
Definition: TComTU.h:51
Bool isNonTransformedResidualRotated(const ComponentID compID)
Definition: TComTU.cpp:236
UInt GetTransformDepthRelAdj(const ComponentID compID) const
Definition: TComTU.h:109
TComTURecurse(TComDataCU *pcCU, const UInt absPartIdxCU, const UInt forcedDepthOfCU)
Definition: TComTU.h:146
UInt mTrDepthRelCU[MAX_NUM_COMPONENT]
Definition: TComTU.h:59
const TComDataCU * getCU() const
Definition: TComTU.h:127
TComRectangle mRect[MAX_NUM_COMPONENT]
Definition: TComTU.h:62
UInt mAbsPartIdxStep
Definition: TComTU.h:68
UInt mOrigWidth[MAX_NUM_COMPONENT]
Definition: TComTU.h:64
static Bool isLuma(const ComponentID id)
UInt GetTransformDepthTotal() const
Definition: TComTU.h:105
UInt mLog2TrLumaSize
Definition: TComTU.h:70
UInt GetRelPartIdxTU() const
Definition: TComTU.h:117
UInt GetTransformDepthTotalAdj(const ComponentID compID) const
Definition: TComTU.h:106