source: SHVCSoftware/branches/SHM-dev/source/Lib/TLibCommon/TComPicYuv.h @ 1115

Last change on this file since 1115 was 1029, checked in by seregin, 10 years ago

merge with SHM-upgrade branch

  • Property svn:eol-style set to native
File size: 10.0 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/** \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#if SVC_EXTENSION
47#include "TComSlice.h"
48#endif
49//! \ingroup TLibCommon
50//! \{
51
52// ====================================================================================================================
53// Class definition
54// ====================================================================================================================
55
56/// picture YUV buffer class
57class TComPicYuv
58{
59private:
60
61  // ------------------------------------------------------------------------------------------------
62  //  YUV buffer
63  // ------------------------------------------------------------------------------------------------
64
65  Pel*  m_apiPicBuf[MAX_NUM_COMPONENT];             ///< Buffer (including margin)
66
67  Pel*  m_piPicOrg[MAX_NUM_COMPONENT];              ///< m_apiPicBufY + m_iMarginLuma*getStride() + m_iMarginLuma
68
69  // ------------------------------------------------------------------------------------------------
70  //  Parameter for general YUV buffer usage
71  // ------------------------------------------------------------------------------------------------
72
73  Int   m_iPicWidth;                                ///< Width of picture in pixels
74  Int   m_iPicHeight;                               ///< Height of picture in pixels
75  ChromaFormat m_chromaFormatIDC;                   ///< Chroma Format
76
77  Int*  m_ctuOffsetInBuffer[MAX_NUM_CHANNEL_TYPE];  ///< Gives an offset in the buffer for a given CTU (and channel)
78  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
79
80  Int   m_iMarginX;                                 ///< margin of Luma channel (chroma's may be smaller, depending on ratio)
81  Int   m_iMarginY;                                 ///< margin of Luma channel (chroma's may be smaller, depending on ratio)
82
83  Bool  m_bIsBorderExtended;
84
85#if SVC_EXTENSION
86  Window  m_conformanceWindow;
87#if M0040_ADAPTIVE_RESOLUTION_CHANGE
88  Bool    m_isReconstructed;
89#endif
90#endif //SVC_EXTENSION
91 
92public:
93               TComPicYuv         ();
94  virtual     ~TComPicYuv         ();
95
96  // ------------------------------------------------------------------------------------------------
97  //  Memory management
98  // ------------------------------------------------------------------------------------------------
99#if SVC_EXTENSION
100#if R0156_CONF_WINDOW_IN_REP_FORMAT
101  Void  create      ( Int iPicWidth, Int iPicHeight, ChromaFormat chromaFormatIDC, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, Window* conformanceWindow = NULL);
102#else
103  Void  create      ( Int iPicWidth, Int iPicHeight, ChromaFormat chromaFormatIDC, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps = NULL);
104#endif
105#else
106  Void          create            (const Int iPicWidth,
107                                   const Int iPicHeight,
108                                   const ChromaFormat chromaFormatIDC,
109                                   const UInt uiMaxCUWidth,
110                                   const UInt uiMaxCUHeight,
111                                   const UInt uiMaxCUDepth );
112#endif //SVC_EXTENSION
113 
114  Void          destroy           ();
115
116  // The following have been removed - Use CHROMA_400 in the above function call.
117  //Void  createLuma  ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uhMaxCUDepth );
118  //Void  destroyLuma ();
119
120  // ------------------------------------------------------------------------------------------------
121  //  Get information of picture
122  // ------------------------------------------------------------------------------------------------
123
124  Int           getWidth          (const ComponentID id) const { return  m_iPicWidth >> getComponentScaleX(id);   }
125  Int           getHeight         (const ComponentID id) const { return  m_iPicHeight >> getComponentScaleY(id);  }
126  ChromaFormat  getChromaFormat   ()                     const { return m_chromaFormatIDC; }
127  UInt          getNumberValidComponents() const { return ::getNumberValidComponents(m_chromaFormatIDC); }
128
129  Int           getStride         (const ComponentID id) const { return ((m_iPicWidth     ) + (m_iMarginX  <<1)) >> getComponentScaleX(id); }
130  Int           getTotalHeight    (const ComponentID id) const { return ((m_iPicHeight    ) + (m_iMarginY  <<1)) >> getComponentScaleY(id); }
131
132  Int           getMarginX        (const ComponentID id) const { return m_iMarginX >> getComponentScaleX(id);  }
133  Int           getMarginY        (const ComponentID id) const { return m_iMarginY >> getComponentScaleY(id);  }
134
135  // ------------------------------------------------------------------------------------------------
136  //  Access function for picture buffer
137  // ------------------------------------------------------------------------------------------------
138
139  //  Access starting position of picture buffer with margin
140  Pel*          getBuf            (const ComponentID ch)       { return  m_apiPicBuf[ch];   }
141
142  //  Access starting position of original picture
143  Pel*          getAddr           (const ComponentID ch)       { return  m_piPicOrg[ch];   }
144  const Pel*    getAddr           (const ComponentID ch) const { return  m_piPicOrg[ch];   }
145
146  //  Access starting position of original picture for specific coding unit (CU) or partition unit (PU)
147  Pel*          getAddr           (const ComponentID ch, const Int ctuRSAddr )       { return m_piPicOrg[ch] + m_ctuOffsetInBuffer[ch==0?0:1][ ctuRSAddr ]; }
148  const Pel*    getAddr           (const ComponentID ch, const Int ctuRSAddr ) const { return m_piPicOrg[ch] + m_ctuOffsetInBuffer[ch==0?0:1][ ctuRSAddr ]; }
149  Pel*          getAddr           (const ComponentID ch, const Int ctuRSAddr, const Int uiAbsZorderIdx )
150                                     { return m_piPicOrg[ch] + m_ctuOffsetInBuffer[ch==0?0:1][ctuRSAddr] + m_subCuOffsetInBuffer[ch==0?0:1][g_auiZscanToRaster[uiAbsZorderIdx]]; }
151  const Pel*    getAddr           (const ComponentID ch, const Int ctuRSAddr, const Int uiAbsZorderIdx ) const
152                                     { return m_piPicOrg[ch] + m_ctuOffsetInBuffer[ch==0?0:1][ctuRSAddr] + m_subCuOffsetInBuffer[ch==0?0:1][g_auiZscanToRaster[uiAbsZorderIdx]]; }
153
154  UInt          getComponentScaleX(const ComponentID id) const { return ::getComponentScaleX(id, m_chromaFormatIDC); }
155  UInt          getComponentScaleY(const ComponentID id) const { return ::getComponentScaleY(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 Char* pFileName, Bool bAdd = false) const ;
169
170  // Set border extension flag
171  Void          setBorderExtension(Bool b) { m_bIsBorderExtended = b; }
172 
173#if SVC_EXTENSION
174  Void          setHeight   ( Int iPicHeight )     { m_iPicHeight = iPicHeight; }
175  Window&       getConformanceWindow()                           { return  m_conformanceWindow;             }
176  Void          setConformanceWindow(Window& conformanceWindow ) { m_conformanceWindow = conformanceWindow; }
177#if M0040_ADAPTIVE_RESOLUTION_CHANGE
178  Void          setReconstructed(Bool x) { m_isReconstructed = x;    }
179  Bool          isReconstructed()        { return m_isReconstructed; }
180#endif
181#if AUXILIARY_PICTURES 
182  Void          convertToMonochrome();
183#endif
184#endif //SVC_EXTENSION
185  Void          dump( Char* pFileName, Bool bAdd, Int bitDepth );
186
187};// END CLASS DEFINITION TComPicYuv
188
189
190// These functions now return the length of the digest strings.
191UInt calcChecksum(const TComPicYuv& pic, TComDigest &digest);
192UInt calcCRC     (const TComPicYuv& pic, TComDigest &digest);
193UInt calcMD5     (const TComPicYuv& pic, TComDigest &digest);
194std::string digestToString(const TComDigest &digest, Int numChar);
195//! \}
196
197#endif // __TCOMPICYUV__
Note: See TracBrowser for help on using the repository browser.