source: 3DVCSoftware/trunk/source/Lib/TLibCommon/TComPicYuv.h @ 1417

Last change on this file since 1417 was 1413, checked in by tech, 6 years ago

Merged HTM-16.2-dev@1412

  • Property svn:eol-style set to native
File size: 11.1 KB
RevLine 
[5]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
[1313]4 * granted under this license.
[5]5 *
[1413]6 * Copyright (c) 2010-2017, ITU/ISO/IEC
[5]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.
[56]17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
[5]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 */
[2]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"
[56]43#include "TComRom.h"
[1313]44#include "TComChromaFormat.h"
45#include "SEI.h"
[2]46
[56]47//! \ingroup TLibCommon
48//! \{
49
[2]50// ====================================================================================================================
51// Class definition
52// ====================================================================================================================
53
54/// picture YUV buffer class
55class TComPicYuv
56{
57private:
[1313]58
[2]59  // ------------------------------------------------------------------------------------------------
60  //  YUV buffer
61  // ------------------------------------------------------------------------------------------------
[1313]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
[2]67  // ------------------------------------------------------------------------------------------------
68  //  Parameter for general YUV buffer usage
69  // ------------------------------------------------------------------------------------------------
[1313]70
[1386]71  Int   m_picWidth;                                 ///< Width of picture in pixels
72  Int   m_picHeight;                                ///< Height of picture in pixels
[1313]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
[1386]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)
[1313]80
[2]81  Bool  m_bIsBorderExtended;
[1413]82#if NH_3D
[608]83  Int   m_iBaseUnitWidth;       ///< Width of Base Unit (with maximum depth or minimum size, m_iCuWidth >> Max. Depth)
84  Int   m_iBaseUnitHeight;      ///< Height of Base Unit (with maximum depth or minimum size, m_iCuHeight >> Max. Depth)
85  Int   m_iNumCuInWidth;
[1313]86  Int   m_iCuWidth;             ///< Width of Coding Unit (CU)
87  Int   m_iCuHeight;            ///< Height of Coding Unit (CU)
[608]88#endif
[1313]89
90#if NH_3D_VSO
[2]91  Void  xSetPels( Pel* piPelSource , Int iSourceStride, Int iWidth, Int iHeight, Pel iVal );
[608]92#endif
[1313]93
[2]94public:
[1313]95               TComPicYuv         ();
96  virtual     ~TComPicYuv         ();
97
[2]98  // ------------------------------------------------------------------------------------------------
99  //  Memory management
100  // ------------------------------------------------------------------------------------------------
[1313]101
[1386]102  Void          create            (const Int picWidth,
103                                   const Int picHeight,
[1313]104                                   const ChromaFormat chromaFormatIDC,
[1386]105                                   const UInt maxCUWidth,  ///< used for generating offsets to CUs.
106                                   const UInt maxCUHeight, ///< used for generating offsets to CUs.
107                                   const UInt maxCUDepth,  ///< used for generating offsets to CUs.
[1313]108                                   const Bool bUseMargin);   ///< if true, then a margin of uiMaxCUWidth+16 and uiMaxCUHeight+16 is created around the image.
109
[1386]110  Void          createWithoutCUInfo(const Int picWidth,
111                                    const Int picHeight,
112                                    const ChromaFormat chromaFormatIDC,
113                                    const Bool bUseMargin=false, ///< if true, then a margin of uiMaxCUWidth+16 and uiMaxCUHeight+16 is created around the image.
114                                    const UInt maxCUWidth=0,   ///< used for margin only
115                                    const UInt maxCUHeight=0); ///< used for margin only
116
[1313]117  Void          destroy           ();
118
119  // The following have been removed - Use CHROMA_400 in the above function call.
120  //Void  createLuma  ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uhMaxCUDepth );
121  //Void  destroyLuma ();
122
[2]123  // ------------------------------------------------------------------------------------------------
124  //  Get information of picture
125  // ------------------------------------------------------------------------------------------------
[1313]126
[1386]127  Int           getWidth          (const ComponentID id) const { return  m_picWidth >> getComponentScaleX(id);   }
128  Int           getHeight         (const ComponentID id) const { return  m_picHeight >> getComponentScaleY(id);  }
[1313]129  ChromaFormat  getChromaFormat   ()                     const { return m_chromaFormatIDC; }
130  UInt          getNumberValidComponents() const { return ::getNumberValidComponents(m_chromaFormatIDC); }
131
[1386]132  Int           getStride         (const ComponentID id) const { return ((m_picWidth     ) + (m_marginX  <<1)) >> getComponentScaleX(id); }
133private:
134  Int           getStride         (const ChannelType id) const { return ((m_picWidth     ) + (m_marginX  <<1)) >> getChannelTypeScaleX(id); }
135public:
136  Int           getTotalHeight    (const ComponentID id) const { return ((m_picHeight    ) + (m_marginY  <<1)) >> getComponentScaleY(id); }
[1313]137
[1386]138  Int           getMarginX        (const ComponentID id) const { return m_marginX >> getComponentScaleX(id);  }
139  Int           getMarginY        (const ComponentID id) const { return m_marginY >> getComponentScaleY(id);  }
[1313]140
[2]141  // ------------------------------------------------------------------------------------------------
142  //  Access function for picture buffer
143  // ------------------------------------------------------------------------------------------------
[1313]144
[2]145  //  Access starting position of picture buffer with margin
[1313]146  Pel*          getBuf            (const ComponentID ch)       { return  m_apiPicBuf[ch];   }
[1386]147  const Pel*    getBuf            (const ComponentID ch) const { return  m_apiPicBuf[ch];   }
[1313]148
[2]149  //  Access starting position of original picture
[1313]150  Pel*          getAddr           (const ComponentID ch)       { return  m_piPicOrg[ch];   }
151  const Pel*    getAddr           (const ComponentID ch) const { return  m_piPicOrg[ch];   }
152
[2]153  //  Access starting position of original picture for specific coding unit (CU) or partition unit (PU)
[1313]154  Pel*          getAddr           (const ComponentID ch, const Int ctuRSAddr )       { return m_piPicOrg[ch] + m_ctuOffsetInBuffer[ch==0?0:1][ ctuRSAddr ]; }
155  const Pel*    getAddr           (const ComponentID ch, const Int ctuRSAddr ) const { return m_piPicOrg[ch] + m_ctuOffsetInBuffer[ch==0?0:1][ ctuRSAddr ]; }
156  Pel*          getAddr           (const ComponentID ch, const Int ctuRSAddr, const Int uiAbsZorderIdx )
157                                     { return m_piPicOrg[ch] + m_ctuOffsetInBuffer[ch==0?0:1][ctuRSAddr] + m_subCuOffsetInBuffer[ch==0?0:1][g_auiZscanToRaster[uiAbsZorderIdx]]; }
158  const Pel*    getAddr           (const ComponentID ch, const Int ctuRSAddr, const Int uiAbsZorderIdx ) const
159                                     { return m_piPicOrg[ch] + m_ctuOffsetInBuffer[ch==0?0:1][ctuRSAddr] + m_subCuOffsetInBuffer[ch==0?0:1][g_auiZscanToRaster[uiAbsZorderIdx]]; }
160
161  UInt          getComponentScaleX(const ComponentID id) const { return ::getComponentScaleX(id, m_chromaFormatIDC); }
162  UInt          getComponentScaleY(const ComponentID id) const { return ::getComponentScaleY(id, m_chromaFormatIDC); }
163
[1386]164  UInt          getChannelTypeScaleX(const ChannelType id) const { return ::getChannelTypeScaleX(id, m_chromaFormatIDC); }
165  UInt          getChannelTypeScaleY(const ChannelType id) const { return ::getChannelTypeScaleY(id, m_chromaFormatIDC); }
166
[2]167  // ------------------------------------------------------------------------------------------------
168  //  Miscellaneous
169  // ------------------------------------------------------------------------------------------------
[1313]170
[2]171  //  Copy function to picture
[1313]172  Void          copyToPic         ( TComPicYuv*  pcPicYuvDst ) const ;
173
[2]174  //  Extend function of picture buffer
[1313]175  Void          extendPicBorder   ();
176
[2]177  //  Dump picture
[1386]178  Void          dump              (const std::string &fileName, const BitDepths &bitDepths, const Bool bAppend=false, const Bool bForceTo8Bit=false) const ;
[1313]179
[2]180  // Set border extension flag
[1313]181  Void          setBorderExtension(Bool b) { m_bIsBorderExtended = b; }
[1321]182#if NH_MV
183  Bool          getBorderExtension( )     { return m_bIsBorderExtended; }
184#endif
[1386]185#if NH_3D_VSO
[2]186  // Set Function
187  Void  setLumaTo    ( Pel pVal ); 
188  Void  setChromaTo  ( Pel pVal ); 
[1386]189#endif
190#if NH_3D
[608]191  // sample to block and block to sample conversion
192  Void  getTopLeftSamplePos( Int iCuAddr, Int iAbsZorderIdx, Int& riX, Int& riY );
193  Void  getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx );
[443]194#endif
[1313]195
[2]196};// END CLASS DEFINITION TComPicYuv
197
[1313]198
199// These functions now return the length of the digest strings.
200UInt calcChecksum(const TComPicYuv& pic, TComPictureHash &digest, const BitDepths &bitDepths);
201UInt calcCRC     (const TComPicYuv& pic, TComPictureHash &digest, const BitDepths &bitDepths);
202UInt calcMD5     (const TComPicYuv& pic, TComPictureHash &digest, const BitDepths &bitDepths);
203std::string hashToString(const TComPictureHash &digest, Int numChar);
[56]204//! \}
205
[2]206#endif // __TCOMPICYUV__
Note: See TracBrowser for help on using the repository browser.