source: 3DVCSoftware/branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/TComPicYuv.h @ 1390

Last change on this file since 1390 was 1390, checked in by tech, 9 years ago

Removed 3D.

  • Property svn:eol-style set to native
File size: 10.2 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-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/** \file     TComPicYuv.h
35    \brief    picture YUV buffer class (header)
36*/
37
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
47//! \ingroup TLibCommon
48//! \{
49
50// ====================================================================================================================
51// Class definition
52// ====================================================================================================================
53
54/// picture YUV buffer class
55class TComPicYuv
56{
57private:
58
59  // ------------------------------------------------------------------------------------------------
60  //  YUV buffer
61  // ------------------------------------------------------------------------------------------------
62
63  Pel*  m_apiPicBuf[MAX_NUM_COMPONENT];             ///< Buffer (including margin)
64
65  Pel*  m_piPicOrg[MAX_NUM_COMPONENT];              ///< m_apiPicBufY + m_iMarginLuma*getStride() + m_iMarginLuma
66
67  // ------------------------------------------------------------------------------------------------
68  //  Parameter for general YUV buffer usage
69  // ------------------------------------------------------------------------------------------------
70
71  Int   m_picWidth;                                 ///< Width of picture in pixels
72  Int   m_picHeight;                                ///< Height of picture in pixels
73  ChromaFormat m_chromaFormatIDC;                   ///< Chroma Format
74
75  Int*  m_ctuOffsetInBuffer[MAX_NUM_CHANNEL_TYPE];  ///< Gives an offset in the buffer for a given CTU (and channel)
76  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
77
78  Int   m_marginX;                                  ///< margin of Luma channel (chroma's may be smaller, depending on ratio)
79  Int   m_marginY;                                  ///< margin of Luma channel (chroma's may be smaller, depending on ratio)
80
81  Bool  m_bIsBorderExtended;
82
83
84public:
85               TComPicYuv         ();
86  virtual     ~TComPicYuv         ();
87
88  // ------------------------------------------------------------------------------------------------
89  //  Memory management
90  // ------------------------------------------------------------------------------------------------
91
92  Void          create            (const Int picWidth,
93                                   const Int picHeight,
94                                   const ChromaFormat chromaFormatIDC,
95                                   const UInt maxCUWidth,  ///< used for generating offsets to CUs.
96                                   const UInt maxCUHeight, ///< used for generating offsets to CUs.
97                                   const UInt maxCUDepth,  ///< used for generating offsets to CUs.
98                                   const Bool bUseMargin);   ///< if true, then a margin of uiMaxCUWidth+16 and uiMaxCUHeight+16 is created around the image.
99
100  Void          createWithoutCUInfo(const Int picWidth,
101                                    const Int picHeight,
102                                    const ChromaFormat chromaFormatIDC,
103                                    const Bool bUseMargin=false, ///< if true, then a margin of uiMaxCUWidth+16 and uiMaxCUHeight+16 is created around the image.
104                                    const UInt maxCUWidth=0,   ///< used for margin only
105                                    const UInt maxCUHeight=0); ///< used for margin only
106
107  Void          destroy           ();
108
109  // The following have been removed - Use CHROMA_400 in the above function call.
110  //Void  createLuma  ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uhMaxCUDepth );
111  //Void  destroyLuma ();
112
113  // ------------------------------------------------------------------------------------------------
114  //  Get information of picture
115  // ------------------------------------------------------------------------------------------------
116
117  Int           getWidth          (const ComponentID id) const { return  m_picWidth >> getComponentScaleX(id);   }
118  Int           getHeight         (const ComponentID id) const { return  m_picHeight >> getComponentScaleY(id);  }
119  ChromaFormat  getChromaFormat   ()                     const { return m_chromaFormatIDC; }
120  UInt          getNumberValidComponents() const { return ::getNumberValidComponents(m_chromaFormatIDC); }
121
122  Int           getStride         (const ComponentID id) const { return ((m_picWidth     ) + (m_marginX  <<1)) >> getComponentScaleX(id); }
123private:
124  Int           getStride         (const ChannelType id) const { return ((m_picWidth     ) + (m_marginX  <<1)) >> getChannelTypeScaleX(id); }
125public:
126  Int           getTotalHeight    (const ComponentID id) const { return ((m_picHeight    ) + (m_marginY  <<1)) >> getComponentScaleY(id); }
127
128  Int           getMarginX        (const ComponentID id) const { return m_marginX >> getComponentScaleX(id);  }
129  Int           getMarginY        (const ComponentID id) const { return m_marginY >> getComponentScaleY(id);  }
130
131  // ------------------------------------------------------------------------------------------------
132  //  Access function for picture buffer
133  // ------------------------------------------------------------------------------------------------
134
135  //  Access starting position of picture buffer with margin
136  Pel*          getBuf            (const ComponentID ch)       { return  m_apiPicBuf[ch];   }
137  const Pel*    getBuf            (const ComponentID ch) const { return  m_apiPicBuf[ch];   }
138
139  //  Access starting position of original picture
140  Pel*          getAddr           (const ComponentID ch)       { return  m_piPicOrg[ch];   }
141  const Pel*    getAddr           (const ComponentID ch) const { return  m_piPicOrg[ch];   }
142
143  //  Access starting position of original picture for specific coding unit (CU) or partition unit (PU)
144  Pel*          getAddr           (const ComponentID ch, const Int ctuRSAddr )       { return m_piPicOrg[ch] + m_ctuOffsetInBuffer[ch==0?0:1][ ctuRSAddr ]; }
145  const Pel*    getAddr           (const ComponentID ch, const Int ctuRSAddr ) const { return m_piPicOrg[ch] + m_ctuOffsetInBuffer[ch==0?0:1][ ctuRSAddr ]; }
146  Pel*          getAddr           (const ComponentID ch, const Int ctuRSAddr, const Int uiAbsZorderIdx )
147                                     { return m_piPicOrg[ch] + m_ctuOffsetInBuffer[ch==0?0:1][ctuRSAddr] + m_subCuOffsetInBuffer[ch==0?0:1][g_auiZscanToRaster[uiAbsZorderIdx]]; }
148  const Pel*    getAddr           (const ComponentID ch, const Int ctuRSAddr, const Int uiAbsZorderIdx ) const
149                                     { return m_piPicOrg[ch] + m_ctuOffsetInBuffer[ch==0?0:1][ctuRSAddr] + m_subCuOffsetInBuffer[ch==0?0:1][g_auiZscanToRaster[uiAbsZorderIdx]]; }
150
151  UInt          getComponentScaleX(const ComponentID id) const { return ::getComponentScaleX(id, m_chromaFormatIDC); }
152  UInt          getComponentScaleY(const ComponentID id) const { return ::getComponentScaleY(id, m_chromaFormatIDC); }
153
154  UInt          getChannelTypeScaleX(const ChannelType id) const { return ::getChannelTypeScaleX(id, m_chromaFormatIDC); }
155  UInt          getChannelTypeScaleY(const ChannelType id) const { return ::getChannelTypeScaleY(id, m_chromaFormatIDC); }
156
157  // ------------------------------------------------------------------------------------------------
158  //  Miscellaneous
159  // ------------------------------------------------------------------------------------------------
160
161  //  Copy function to picture
162  Void          copyToPic         ( TComPicYuv*  pcPicYuvDst ) const ;
163
164  //  Extend function of picture buffer
165  Void          extendPicBorder   ();
166
167  //  Dump picture
168  Void          dump              (const std::string &fileName, const BitDepths &bitDepths, const Bool bAppend=false, const Bool bForceTo8Bit=false) const ;
169
170  // Set border extension flag
171  Void          setBorderExtension(Bool b) { m_bIsBorderExtended = b; }
172#if NH_MV
173  Bool          getBorderExtension( )     { return m_bIsBorderExtended; }
174#endif
175
176};// END CLASS DEFINITION TComPicYuv
177
178
179// These functions now return the length of the digest strings.
180UInt calcChecksum(const TComPicYuv& pic, TComPictureHash &digest, const BitDepths &bitDepths);
181UInt calcCRC     (const TComPicYuv& pic, TComPictureHash &digest, const BitDepths &bitDepths);
182UInt calcMD5     (const TComPicYuv& pic, TComPictureHash &digest, const BitDepths &bitDepths);
183std::string hashToString(const TComPictureHash &digest, Int numChar);
184//! \}
185
186#endif // __TCOMPICYUV__
Note: See TracBrowser for help on using the repository browser.