source: SHVCSoftware/branches/SHM-upgrade/source/Lib/TLibCommon/TComTU.h @ 1165

Last change on this file since 1165 was 919, checked in by seregin, 10 years ago

add RExt files

File size: 8.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-2014, 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
37class TComTU; // forward declaration
38
39#include "CommonDef.h"
40#include "TComRectangle.h"
41#include "TComChromaFormat.h"
42
43class TComDataCU; // forward declaration
44
45//----------------------------------------------------------------------------------------------------------------------
46
47
48class TComTU
49{
50  public:
51    typedef enum TU_SPLIT_MODE { DONT_SPLIT=0, VERTICAL_SPLIT=1, QUAD_SPLIT=2, NUMBER_OF_SPLIT_MODES=3 } SPLIT_MODE;
52
53    static const UInt NUMBER_OF_SECTIONS[NUMBER_OF_SPLIT_MODES];
54
55  protected:
56    ChromaFormat  mChromaFormat;
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.
58    UInt          mCuDepth;
59    UInt          mTrDepthRelCU[MAX_NUM_COMPONENT];
60    UInt          mSection;
61    TU_SPLIT_MODE mSplitMode;
62    TComRectangle mRect[MAX_NUM_COMPONENT];
63    Bool          mCodeAll[MAX_NUM_COMPONENT];
64    UInt          mOrigWidth[MAX_NUM_COMPONENT];
65    UInt          mOffsets[MAX_NUM_COMPONENT];
66    UInt          mAbsPartIdxCU;
67    UInt          mAbsPartIdxTURelCU;
68    UInt          mAbsPartIdxStep;
69    TComDataCU   *mpcCU;
70    UInt          mLog2TrLumaSize;
71    TComTU       *mpParent;
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
105    UInt GetTransformDepthTotal()                              const { return mCuDepth+GetTransformDepthRel(); }
106    UInt GetTransformDepthTotalAdj(const ComponentID compID)   const { return mCuDepth+GetTransformDepthRelAdj(compID); }
107
108    UInt GetTransformDepthRel()                                const { return mTrDepthRelCU[COMPONENT_Y]; }
109    UInt GetTransformDepthRelAdj(const ComponentID compID)     const { return mTrDepthRelCU[compID]; }
110    UInt GetTransformDepthRelAdj(const ChannelType chType)     const
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; }
117    UInt GetRelPartIdxTU()                                     const { return mAbsPartIdxTURelCU; }
118    UInt GetRelPartIdxTU(const ComponentID compID)             const { return ProcessingAllQuadrants(compID) ? mAbsPartIdxTURelCU : (mAbsPartIdxTURelCU & (~0x3)); }
119    UInt GetAbsPartIdxTU()                                     const { return GetAbsPartIdxCU() + GetRelPartIdxTU(); }
120    UInt GetAbsPartIdxTU(const ComponentID compID)             const { return GetAbsPartIdxCU() + GetRelPartIdxTU(compID); }
121    UInt GetAbsPartIdxNumParts()                               const { return mAbsPartIdxStep; }
122    UInt GetAbsPartIdxNumParts(const ComponentID compID)       const { return ProcessingAllQuadrants(compID) ? mAbsPartIdxStep : (mAbsPartIdxStep * NUMBER_OF_SECTIONS[mSplitMode]); }
123
124    ChromaFormat GetChromaFormat()                             const { return mChromaFormat; }
125
126    TComDataCU *getCU()                                              { return mpcCU; }
127    const TComDataCU *getCU()                                  const { return mpcCU; }
128    Bool IsLastSection() const { return mSection+1>=((1<<mSplitMode)); }
129
130    UInt GetLog2LumaTrSize()                                   const { return mLog2TrLumaSize; }
131    UInt GetEquivalentLog2TrSize(const ComponentID compID)     const;
132    TU_SPLIT_MODE GetSplitMode()                               const { return mSplitMode; }
133
134    Bool useDST(const ComponentID compID);
135    Bool isNonTransformedResidualRotated(const ComponentID compID);
136
137    UInt getGolombRiceStatisticsIndex(const ComponentID compID);
138};
139
140
141
142class TComTURecurse : public TComTU
143{
144  public:
145
146    TComTURecurse(      TComDataCU *pcCU,
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
Note: See TracBrowser for help on using the repository browser.