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

Last change on this file since 1510 was 1460, checked in by seregin, 9 years ago

port rev 4594

  • Property svn:eol-style set to native
File size: 11.2 KB
RevLine 
[313]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
[1029]4 * granted under this license.
[313]5 *
[1259]6 * Copyright (c) 2010-2015, ITU/ISO/IEC
[313]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"
[1029]44#include "TComChromaFormat.h"
45#include "SEI.h"
[815]46#if SVC_EXTENSION
[313]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:
[1029]60
[313]61  // ------------------------------------------------------------------------------------------------
62  //  YUV buffer
63  // ------------------------------------------------------------------------------------------------
[1029]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
[313]69  // ------------------------------------------------------------------------------------------------
70  //  Parameter for general YUV buffer usage
71  // ------------------------------------------------------------------------------------------------
[1029]72
[1427]73  Int   m_picWidth;                                 ///< Width of picture in pixels
74  Int   m_picHeight;                                ///< Height of picture in pixels
[1029]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
[1427]80  Int   m_marginX;                                  ///< margin of Luma channel (chroma's may be smaller, depending on ratio)
81  Int   m_marginY;                                  ///< margin of Luma channel (chroma's may be smaller, depending on ratio)
[1029]82
[595]83  Bool  m_bIsBorderExtended;
84
85#if SVC_EXTENSION
[313]86  Window  m_conformanceWindow;
87  Bool    m_isReconstructed;
88#endif
[1029]89 
[313]90public:
[1029]91               TComPicYuv         ();
92  virtual     ~TComPicYuv         ();
93
[313]94  // ------------------------------------------------------------------------------------------------
95  //  Memory management
96  // ------------------------------------------------------------------------------------------------
[1289]97
[1427]98  Void          create            (const Int picWidth,
99                                   const Int picHeight,
[1029]100                                   const ChromaFormat chromaFormatIDC,
[1427]101                                   const UInt maxCUWidth,  ///< used for generating offsets to CUs.
102                                   const UInt maxCUHeight, ///< used for generating offsets to CUs.
103                                   const UInt maxCUDepth,  ///< used for generating offsets to CUs.
104                                   const Bool bUseMargin   ///< if true, then a margin of uiMaxCUWidth+16 and uiMaxCUHeight+16 is created around the image.
[1289]105#if SVC_EXTENSION
[1427]106                                 , const Window* conformanceWindow = NULL
[1130]107#endif
[1427]108                                  );
109
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#if SVC_EXTENSION
117                                  , const Window* conformanceWindow = NULL
118#endif
119                                  );
120
[1029]121  Void          destroy           ();
122
123  // The following have been removed - Use CHROMA_400 in the above function call.
124  //Void  createLuma  ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uhMaxCUDepth );
125  //Void  destroyLuma ();
126
[313]127  // ------------------------------------------------------------------------------------------------
128  //  Get information of picture
129  // ------------------------------------------------------------------------------------------------
130
[1427]131  Int           getWidth          (const ComponentID id) const { return  m_picWidth >> getComponentScaleX(id);   }
132  Int           getHeight         (const ComponentID id) const { return  m_picHeight >> getComponentScaleY(id);  }
[1029]133  ChromaFormat  getChromaFormat   ()                     const { return m_chromaFormatIDC; }
134  UInt          getNumberValidComponents() const { return ::getNumberValidComponents(m_chromaFormatIDC); }
135
[1427]136  Int           getStride         (const ComponentID id) const { return ((m_picWidth     ) + (m_marginX  <<1)) >> getComponentScaleX(id); }
137private:
138  Int           getStride         (const ChannelType id) const { return ((m_picWidth     ) + (m_marginX  <<1)) >> getChannelTypeScaleX(id); }
139public:
140  Int           getTotalHeight    (const ComponentID id) const { return ((m_picHeight    ) + (m_marginY  <<1)) >> getComponentScaleY(id); }
[1029]141
[1427]142  Int           getMarginX        (const ComponentID id) const { return m_marginX >> getComponentScaleX(id);  }
143  Int           getMarginY        (const ComponentID id) const { return m_marginY >> getComponentScaleY(id);  }
[1029]144
[313]145  // ------------------------------------------------------------------------------------------------
146  //  Access function for picture buffer
147  // ------------------------------------------------------------------------------------------------
[1029]148
[313]149  //  Access starting position of picture buffer with margin
[1029]150  Pel*          getBuf            (const ComponentID ch)       { return  m_apiPicBuf[ch];   }
[1427]151  const Pel*    getBuf            (const ComponentID ch) const { return  m_apiPicBuf[ch];   }
[1029]152
[313]153  //  Access starting position of original picture
[1029]154  Pel*          getAddr           (const ComponentID ch)       { return  m_piPicOrg[ch];   }
155  const Pel*    getAddr           (const ComponentID ch) const { return  m_piPicOrg[ch];   }
156
[313]157  //  Access starting position of original picture for specific coding unit (CU) or partition unit (PU)
[1029]158  Pel*          getAddr           (const ComponentID ch, const Int ctuRSAddr )       { return m_piPicOrg[ch] + m_ctuOffsetInBuffer[ch==0?0:1][ ctuRSAddr ]; }
159  const Pel*    getAddr           (const ComponentID ch, const Int ctuRSAddr ) const { return m_piPicOrg[ch] + m_ctuOffsetInBuffer[ch==0?0:1][ ctuRSAddr ]; }
160  Pel*          getAddr           (const ComponentID ch, const Int ctuRSAddr, const Int uiAbsZorderIdx )
161                                     { return m_piPicOrg[ch] + m_ctuOffsetInBuffer[ch==0?0:1][ctuRSAddr] + m_subCuOffsetInBuffer[ch==0?0:1][g_auiZscanToRaster[uiAbsZorderIdx]]; }
162  const Pel*    getAddr           (const ComponentID ch, const Int ctuRSAddr, const Int uiAbsZorderIdx ) const
163                                     { return m_piPicOrg[ch] + m_ctuOffsetInBuffer[ch==0?0:1][ctuRSAddr] + m_subCuOffsetInBuffer[ch==0?0:1][g_auiZscanToRaster[uiAbsZorderIdx]]; }
164
165  UInt          getComponentScaleX(const ComponentID id) const { return ::getComponentScaleX(id, m_chromaFormatIDC); }
166  UInt          getComponentScaleY(const ComponentID id) const { return ::getComponentScaleY(id, m_chromaFormatIDC); }
167
[1427]168  UInt          getChannelTypeScaleX(const ChannelType id) const { return ::getChannelTypeScaleX(id, m_chromaFormatIDC); }
169  UInt          getChannelTypeScaleY(const ChannelType id) const { return ::getChannelTypeScaleY(id, m_chromaFormatIDC); }
170
[313]171  // ------------------------------------------------------------------------------------------------
172  //  Miscellaneous
173  // ------------------------------------------------------------------------------------------------
[1029]174
[313]175  //  Copy function to picture
[1029]176  Void          copyToPic         ( TComPicYuv*  pcPicYuvDst ) const ;
177
[313]178  //  Extend function of picture buffer
[1029]179  Void          extendPicBorder   ();
180
[313]181  //  Dump picture
[1460]182  Void          dump              (const std::string &fileName, const BitDepths &bitDepths, const Bool bAppend=false, const Bool bForceTo8Bit=false) const ;
[313]183
[595]184  // Set border extension flag
[1029]185  Void          setBorderExtension(Bool b) { m_bIsBorderExtended = b; }
[595]186 
187#if SVC_EXTENSION
[1428]188  Void          setHeight( Int picHeight )                       { m_picHeight = picHeight;                 }
[1029]189  Window&       getConformanceWindow()                           { return  m_conformanceWindow;             }
190  Void          setConformanceWindow(Window& conformanceWindow ) { m_conformanceWindow = conformanceWindow; }
[1130]191  Void          setReconstructed(Bool x)                         { m_isReconstructed = x;                   }
192  Bool          isReconstructed()                                { return m_isReconstructed;                }
[1029]193#if AUXILIARY_PICTURES 
[1442]194  Void          convertToMonochrome(const Int bitDepthChroma);
[494]195#endif
[1130]196#endif
197
[313]198};// END CLASS DEFINITION TComPicYuv
199
[1029]200
201// These functions now return the length of the digest strings.
[1287]202UInt calcChecksum(const TComPicYuv& pic, TComPictureHash &digest, const BitDepths &bitDepths);
203UInt calcCRC     (const TComPicYuv& pic, TComPictureHash &digest, const BitDepths &bitDepths);
204UInt calcMD5     (const TComPicYuv& pic, TComPictureHash &digest, const BitDepths &bitDepths);
[1273]205std::string hashToString(const TComPictureHash &digest, Int numChar);
[313]206//! \}
207
208#endif // __TCOMPICYUV__
Note: See TracBrowser for help on using the repository browser.