HEVC Test Model (HM)  HM-16.18
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TComPicYuv.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 
38 #ifndef __TCOMPICYUV__
39 #define __TCOMPICYUV__
40 
41 #include <stdio.h>
42 #include "CommonDef.h"
43 #include "TComRom.h"
44 #include "TComChromaFormat.h"
45 #include "SEI.h"
46 
49 
50 // ====================================================================================================================
51 // Class definition
52 // ====================================================================================================================
53 
56 {
57 private:
58 
59  // ------------------------------------------------------------------------------------------------
60  // YUV buffer
61  // ------------------------------------------------------------------------------------------------
62 
64 
66 
67  // ------------------------------------------------------------------------------------------------
68  // Parameter for general YUV buffer usage
69  // ------------------------------------------------------------------------------------------------
70 
74 
77 
80 
82 
83 public:
84  TComPicYuv ();
85  virtual ~TComPicYuv ();
86 
87  // ------------------------------------------------------------------------------------------------
88  // Memory management
89  // ------------------------------------------------------------------------------------------------
90 
91  Void create (const Int picWidth,
92  const Int picHeight,
93  const ChromaFormat chromaFormatIDC,
94  const UInt maxCUWidth,
95  const UInt maxCUHeight,
96  const UInt maxCUDepth,
97  const Bool bUseMargin);
98 
99  Void createWithoutCUInfo(const Int picWidth,
100  const Int picHeight,
101  const ChromaFormat chromaFormatIDC,
102  const Bool bUseMargin=false,
103  const UInt maxCUWidth=0,
104  const UInt maxCUHeight=0);
105 
106  Void destroy ();
107 
108  // The following have been removed - Use CHROMA_400 in the above function call.
109  //Void createLuma ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uhMaxCUDepth );
110  //Void destroyLuma ();
111 
112  // ------------------------------------------------------------------------------------------------
113  // Get information of picture
114  // ------------------------------------------------------------------------------------------------
115 
116  Int getWidth (const ComponentID id) const { return m_picWidth >> getComponentScaleX(id); }
117  Int getHeight (const ComponentID id) const { return m_picHeight >> getComponentScaleY(id); }
120 
121  Int getStride (const ComponentID id) const { return ((m_picWidth ) + (m_marginX <<1)) >> getComponentScaleX(id); }
122 private:
123  Int getStride (const ChannelType id) const { return ((m_picWidth ) + (m_marginX <<1)) >> getChannelTypeScaleX(id); }
124 public:
125  Int getTotalHeight (const ComponentID id) const { return ((m_picHeight ) + (m_marginY <<1)) >> getComponentScaleY(id); }
126 
127  Int getMarginX (const ComponentID id) const { return m_marginX >> getComponentScaleX(id); }
128  Int getMarginY (const ComponentID id) const { return m_marginY >> getComponentScaleY(id); }
129 
130  // ------------------------------------------------------------------------------------------------
131  // Access function for picture buffer
132  // ------------------------------------------------------------------------------------------------
133 
134  // Access starting position of picture buffer with margin
135  Pel* getBuf (const ComponentID ch) { return m_apiPicBuf[ch]; }
136  const Pel* getBuf (const ComponentID ch) const { return m_apiPicBuf[ch]; }
137 
138  // Access starting position of original picture
139  Pel* getAddr (const ComponentID ch) { return m_piPicOrg[ch]; }
140  const Pel* getAddr (const ComponentID ch) const { return m_piPicOrg[ch]; }
141 
142  // Access starting position of original picture for specific coding unit (CU) or partition unit (PU)
143  Pel* getAddr (const ComponentID ch, const Int ctuRSAddr ) { return m_piPicOrg[ch] + m_ctuOffsetInBuffer[ch==0?0:1][ ctuRSAddr ]; }
144  const Pel* getAddr (const ComponentID ch, const Int ctuRSAddr ) const { return m_piPicOrg[ch] + m_ctuOffsetInBuffer[ch==0?0:1][ ctuRSAddr ]; }
145  Pel* getAddr (const ComponentID ch, const Int ctuRSAddr, const Int uiAbsZorderIdx )
146  { return m_piPicOrg[ch] + m_ctuOffsetInBuffer[ch==0?0:1][ctuRSAddr] + m_subCuOffsetInBuffer[ch==0?0:1][g_auiZscanToRaster[uiAbsZorderIdx]]; }
147  const Pel* getAddr (const ComponentID ch, const Int ctuRSAddr, const Int uiAbsZorderIdx ) const
148  { return m_piPicOrg[ch] + m_ctuOffsetInBuffer[ch==0?0:1][ctuRSAddr] + m_subCuOffsetInBuffer[ch==0?0:1][g_auiZscanToRaster[uiAbsZorderIdx]]; }
149 
152 
155 
156  // ------------------------------------------------------------------------------------------------
157  // Miscellaneous
158  // ------------------------------------------------------------------------------------------------
159 
160  // Copy function to picture
161  Void copyToPic ( TComPicYuv* pcPicYuvDst ) const ;
162 
163  // Extend function of picture buffer
165 
166  // Dump picture
167  Void dump (const std::string &fileName, const BitDepths &bitDepths, const Bool bAppend=false, const Bool bForceTo8Bit=false) const ;
168 
169  // Set border extension flag
171 };// END CLASS DEFINITION TComPicYuv
172 
173 
174 // These functions now return the length of the digest strings.
175 UInt calcChecksum(const TComPicYuv& pic, TComPictureHash &digest, const BitDepths &bitDepths);
176 UInt calcCRC (const TComPicYuv& pic, TComPictureHash &digest, const BitDepths &bitDepths);
177 UInt calcMD5 (const TComPicYuv& pic, TComPictureHash &digest, const BitDepths &bitDepths);
178 std::string hashToString(const TComPictureHash &digest, Int numChar);
180 
181 #endif // __TCOMPICYUV__
Int m_marginX
margin of Luma channel (chroma&#39;s may be smaller, depending on ratio)
Definition: TComPicYuv.h:78
Int getStride(const ChannelType id) const
Definition: TComPicYuv.h:123
Int m_picHeight
Height of picture in pixels.
Definition: TComPicYuv.h:72
Void extendPicBorder()
Definition: TComPicYuv.cpp:229
picture YUV buffer class
Definition: TComPicYuv.h:55
Pel * getAddr(const ComponentID ch, const Int ctuRSAddr, const Int uiAbsZorderIdx)
Definition: TComPicYuv.h:145
ChannelType
Definition: TypeDef.h:301
Defines version information, constants and small in-line functions.
void Void
Definition: TypeDef.h:203
UInt calcChecksum(const TComPicYuv &pic, TComPictureHash &digest, const BitDepths &bitDepths)
Int getStride(const ComponentID id) const
Definition: TComPicYuv.h:121
Pel * getAddr(const ComponentID ch, const Int ctuRSAddr)
Definition: TComPicYuv.h:143
global variables &amp; functions (header)
Void createWithoutCUInfo(const Int picWidth, const Int picHeight, const ChromaFormat chromaFormatIDC, const Bool bUseMargin=false, const UInt maxCUWidth=0, const UInt maxCUHeight=0)
used for margin only
Definition: TComPicYuv.cpp:81
Int getHeight(const ComponentID id) const
Definition: TComPicYuv.h:117
static UInt getComponentScaleY(const ComponentID id, const ChromaFormat fmt)
unsigned int UInt
Definition: TypeDef.h:212
Pel * m_apiPicBuf[MAX_NUM_COMPONENT]
Buffer (including margin)
Definition: TComPicYuv.h:63
static UInt getComponentScaleX(const ComponentID id, const ChromaFormat fmt)
Short Pel
pixel type
Definition: TypeDef.h:249
const Pel * getBuf(const ComponentID ch) const
Definition: TComPicYuv.h:136
UInt calcMD5(const TComPicYuv &pic, TComPictureHash &digest, const BitDepths &bitDepths)
UInt getChannelTypeScaleY(const ChannelType id) const
Definition: TComPicYuv.h:154
Int * m_ctuOffsetInBuffer[MAX_NUM_CHANNEL_TYPE]
Gives an offset in the buffer for a given CTU (and channel)
Definition: TComPicYuv.h:75
const Pel * getAddr(const ComponentID ch, const Int ctuRSAddr) const
Definition: TComPicYuv.h:144
Int getWidth(const ComponentID id) const
Definition: TComPicYuv.h:116
UInt getComponentScaleY(const ComponentID id) const
Definition: TComPicYuv.h:151
UInt getComponentScaleX(const ComponentID id) const
Definition: TComPicYuv.h:150
bool Bool
Definition: TypeDef.h:204
Void copyToPic(TComPicYuv *pcPicYuvDst) const
Definition: TComPicYuv.cpp:198
static UInt getChannelTypeScaleY(const ChannelType id, const ChromaFormat fmt)
virtual ~TComPicYuv()
Definition: TComPicYuv.cpp:74
Pel * m_piPicOrg[MAX_NUM_COMPONENT]
m_apiPicBufY + m_iMarginLuma*getStride() + m_iMarginLuma
Definition: TComPicYuv.h:65
Int getTotalHeight(const ComponentID id) const
Definition: TComPicYuv.h:125
ChromaFormat
chroma formats (according to semantics of chroma_format_idc)
Definition: TypeDef.h:292
Int m_marginY
margin of Luma channel (chroma&#39;s may be smaller, depending on ratio)
Definition: TComPicYuv.h:79
UInt g_auiZscanToRaster[MAX_NUM_PART_IDXS_IN_CTU_WIDTH *MAX_NUM_PART_IDXS_IN_CTU_WIDTH]
Definition: TComRom.cpp:284
const Pel * getAddr(const ComponentID ch, const Int ctuRSAddr, const Int uiAbsZorderIdx) const
Definition: TComPicYuv.h:147
UInt getNumberValidComponents() const
Definition: TComPicYuv.h:119
Int * m_subCuOffsetInBuffer[MAX_NUM_CHANNEL_TYPE]
Gives an offset in the buffer for a given sub-CU (and channel), relative to start of CTU...
Definition: TComPicYuv.h:76
Int getMarginX(const ComponentID id) const
Definition: TComPicYuv.h:127
UInt getChannelTypeScaleX(const ChannelType id) const
Definition: TComPicYuv.h:153
Void dump(const std::string &fileName, const BitDepths &bitDepths, const Bool bAppend=false, const Bool bForceTo8Bit=false) const
Definition: TComPicYuv.cpp:281
Pel * getAddr(const ComponentID ch)
Definition: TComPicYuv.h:139
Void create(const Int picWidth, const Int picHeight, const ChromaFormat chromaFormatIDC, const UInt maxCUWidth, const UInt maxCUHeight, const UInt maxCUDepth, const Bool bUseMargin)
if true, then a margin of uiMaxCUWidth+16 and uiMaxCUHeight+16 is created around the image...
Definition: TComPicYuv.cpp:121
int Int
Definition: TypeDef.h:211
ComponentID
Definition: TypeDef.h:308
Int getMarginY(const ComponentID id) const
Definition: TComPicYuv.h:128
Int m_picWidth
Width of picture in pixels.
Definition: TComPicYuv.h:71
Void setBorderExtension(Bool b)
Definition: TComPicYuv.h:170
std::string hashToString(const TComPictureHash &digest, Int numChar)
static UInt getNumberValidComponents(const ChromaFormat fmt)
Pel * getBuf(const ComponentID ch)
Definition: TComPicYuv.h:135
ChromaFormat m_chromaFormatIDC
Chroma Format.
Definition: TComPicYuv.h:73
Void destroy()
Definition: TComPicYuv.cpp:168
static UInt getChannelTypeScaleX(const ChannelType id, const ChromaFormat fmt)
UInt calcCRC(const TComPicYuv &pic, TComPictureHash &digest, const BitDepths &bitDepths)
const Pel * getAddr(const ComponentID ch) const
Definition: TComPicYuv.h:140
Bool m_bIsBorderExtended
Definition: TComPicYuv.h:81
ChromaFormat getChromaFormat() const
Definition: TComPicYuv.h:118