HEVC Test Model (HM)  HM-16.3
TComChromaFormat.cpp
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-2015, 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 #include "TComChromaFormat.h"
36 #include "TComPic.h"
37 #include "TComDataCU.h"
38 #include "TComTrQuant.h"
39 #include "TComTU.h"
40 
41 
42 
43 
44 //----------------------------------------------------------------------------------------------------------------------
45 
46 InputColourSpaceConversion stringToInputColourSpaceConvert(const std::string &value, const Bool bIsForward)
47 {
48  if (value.empty() || value=="UNCHANGED")
49  {
51  }
52  if (bIsForward)
53  {
54  if (value=="YCbCrtoYYY")
55  {
57  }
58  if (value=="YCbCrtoYCrCb")
59  {
61  }
62  if (value=="RGBtoGBR")
63  {
65  }
66  }
67  else
68  {
69  if (value=="YCrCbtoYCbCr")
70  {
72  }
73  if (value=="GBRtoRGB")
74  {
76  }
77  }
79 }
80 
81 std::string getListOfColourSpaceConverts(const Bool bIsForward)
82 {
83  if (bIsForward)
84  {
85  return "UNCHANGED, YCbCrtoYCrCb, YCbCrtoYYY or RGBtoGBR";
86  }
87  else
88  {
89  return "UNCHANGED, YCrCbtoYCbCr or GBRtoRGB";
90  }
91 }
92 
93 
94 //----------------------------------------------------------------------------------------------------------------------
95 
97  TComTU &rTu,
98  const ComponentID component)
99 {
100  //------------------------------------------------
101 
102  //set the local parameters
103 
104  TComDataCU *const pcCU = rTu.getCU();
105  const TComRectangle & area = rTu.getRect(component);
106  const UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(component);
107  const UInt log2BlockWidth = g_aucConvertToBit[area.width] + 2;
108  const UInt log2BlockHeight = g_aucConvertToBit[area.height] + 2;
109  const ChannelType channelType = toChannelType(component);
110 
111  result.scanType = COEFF_SCAN_TYPE(pcCU->getCoefScanIdx(uiAbsPartIdx, area.width, area.height, component));
112 
113  //------------------------------------------------
114 
115  //set the group layout
116 
117  result.widthInGroups = area.width >> MLS_CG_LOG2_WIDTH;
118  result.heightInGroups = area.height >> MLS_CG_LOG2_HEIGHT;
119 
120  //------------------------------------------------
121 
122  //set the scan orders
123 
124  const UInt log2WidthInGroups = g_aucConvertToBit[result.widthInGroups * 4];
125  const UInt log2HeightInGroups = g_aucConvertToBit[result.heightInGroups * 4];
126 
127  result.scan = g_scanOrder[ SCAN_GROUPED_4x4 ][ result.scanType ][ log2BlockWidth ][ log2BlockHeight ];
128  result.scanCG = g_scanOrder[ SCAN_UNGROUPED ][ result.scanType ][ log2WidthInGroups ][ log2HeightInGroups ];
129 
130  //------------------------------------------------
131 
132  //set the significance map context selection parameters
133 
135  && (pcCU->getCUTransquantBypass(uiAbsPartIdx) || (pcCU->getTransformSkip(uiAbsPartIdx, component) != 0)))
136  {
138  }
139  else
140  {
141  if ((area.width == 4) && (area.height == 4))
142  {
144  }
145  else if ((area.width == 8) && (area.height == 8))
146  {
148  if (result.scanType != SCAN_DIAG)
149  {
151  }
152  }
153  else
154  {
156  }
157  }
158 
159  //------------------------------------------------
160 }
161 
162 
163 //----------------------------------------------------------------------------------------------------------------------
UInt * g_scanOrder[SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][6][6]
Definition: TComRom.cpp:573
CU data structure class.
Definition: TComDataCU.h:64
ChannelType
Definition: TypeDef.h:361
void Void
Definition: TypeDef.h:285
Char g_aucConvertToBit[(1<<(6))+1]
Definition: TComRom.cpp:558
unsigned int UInt
Definition: TypeDef.h:297
Bool getUseSingleSignificanceMapContext() const
Definition: TComSlice.h:898
picture class (header)
UInt GetAbsPartIdxTU() const
Definition: TComTU.h:119
const UInt * scanCG
Definition: TypeDef.h:753
InputColourSpaceConversion stringToInputColourSpaceConvert(const std::string &value, const Bool bIsForward)
static const UInt nonDiagonalScan8x8ContextOffset[MAX_NUM_CHANNEL_TYPE]
Definition: ContextTables.h:87
bool Bool
Definition: TypeDef.h:286
#define MLS_CG_LOG2_HEIGHT
Definition: TypeDef.h:145
up-right diagonal scan
Definition: TypeDef.h:523
Void getTUEntropyCodingParameters(TUEntropyCodingParameters &result, TComTU &rTu, const ComponentID component)
static ChannelType toChannelType(const ComponentID id)
const TComRectangle & getRect(const ComponentID compID) const
Definition: TComTU.h:96
COEFF_SCAN_TYPE
coefficient scanning type used in ACS
Definition: TypeDef.h:521
static const UInt significanceMapContextSetStart[MAX_NUM_CHANNEL_TYPE][CONTEXT_NUMBER_OF_TYPES]
Definition: ContextTables.h:85
UChar * getTransformSkip(ComponentID compID)
Definition: TComDataCU.h:278
UInt getCoefScanIdx(const UInt uiAbsPartIdx, const UInt uiWidth, const UInt uiHeight, const ComponentID compID) const
TComDataCU * getCU()
Definition: TComTU.h:126
COEFF_SCAN_TYPE scanType
Definition: TypeDef.h:754
std::string getListOfColourSpaceConverts(const Bool bIsForward)
Bool * getCUTransquantBypass()
Definition: TComDataCU.h:242
InputColourSpaceConversion
Definition: TypeDef.h:376
Definition: TComTU.h:48
ComponentID
Definition: TypeDef.h:368
transform and quantization class (header)
CU data structure (header)
TComSlice * getSlice()
Definition: TComDataCU.h:205
const TComSPS * getSPS() const
Definition: TComSlice.h:1306
#define MLS_CG_LOG2_WIDTH
Definition: TypeDef.h:144