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

Last change on this file since 1183 was 28, checked in by seregin, 12 years ago

Reintegrate SHM-1.0-dev branch

File size: 8.7 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-2012, 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#if SVC_UPSAMPLING
45#include "TComSlice.h"
46#endif
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_apiPicBufY;           ///< Buffer (including margin)
64  Pel*  m_apiPicBufU;
65  Pel*  m_apiPicBufV;
66 
67  Pel*  m_piPicOrgY;            ///< m_apiPicBufY + m_iMarginLuma*getStride() + m_iMarginLuma
68  Pel*  m_piPicOrgU;
69  Pel*  m_piPicOrgV;
70 
71  // ------------------------------------------------------------------------------------------------
72  //  Parameter for general YUV buffer usage
73  // ------------------------------------------------------------------------------------------------
74 
75  Int   m_iPicWidth;            ///< Width of picture
76  Int   m_iPicHeight;           ///< Height of picture
77 
78  Int   m_iCuWidth;             ///< Width of Coding Unit (CU)
79  Int   m_iCuHeight;            ///< Height of Coding Unit (CU)
80  Int*  m_cuOffsetY;
81  Int*  m_cuOffsetC;
82  Int*  m_buOffsetY;
83  Int*  m_buOffsetC;
84 
85  Int   m_iLumaMarginX;
86  Int   m_iLumaMarginY;
87  Int   m_iChromaMarginX;
88  Int   m_iChromaMarginY;
89 
90#if SVC_UPSAMPLING
91  Int   m_picCropLeftOffset;
92  Int   m_picCropRightOffset;
93  Int   m_picCropTopOffset;
94  Int   m_picCropBottomOffset;
95#endif
96
97  Bool  m_bIsBorderExtended;
98 
99protected:
100  Void  xExtendPicCompBorder (Pel* piTxt, Int iStride, Int iWidth, Int iHeight, Int iMarginX, Int iMarginY);
101 
102public:
103  TComPicYuv         ();
104  virtual ~TComPicYuv();
105 
106  // ------------------------------------------------------------------------------------------------
107  //  Memory management
108  // ------------------------------------------------------------------------------------------------
109#if SVC_UPSAMPLING
110  Void  create      ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps = NULL);
111#else
112  Void  create      ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth );
113#endif 
114 
115  Void  destroy     ();
116 
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    ()     { return  m_iPicWidth;    }
125  Int   getHeight   ()     { return  m_iPicHeight;   }
126
127#if SVC_EXTENSION
128  Void   setHeight   ( Int iPicHeight )     { m_iPicHeight = iPicHeight; }
129#endif
130
131#if JCTVC_L0178
132  Void   setWidth   ( Int iPicWidth )     { m_iPicWidth = iPicWidth; }
133#endif
134  Int   getStride   ()     { return (m_iPicWidth     ) + (m_iLumaMarginX  <<1); }
135  Int   getCStride  ()     { return (m_iPicWidth >> 1) + (m_iChromaMarginX<<1); }
136 
137  Int   getLumaMargin   () { return m_iLumaMarginX;  }
138  Int   getChromaMargin () { return m_iChromaMarginX;}
139 
140  Void  getLumaMinMax( Int* pMin, Int* pMax );
141 
142  // ------------------------------------------------------------------------------------------------
143  //  Access function for picture buffer
144  // ------------------------------------------------------------------------------------------------
145 
146  //  Access starting position of picture buffer with margin
147  Pel*  getBufY     ()     { return  m_apiPicBufY;   }
148  Pel*  getBufU     ()     { return  m_apiPicBufU;   }
149  Pel*  getBufV     ()     { return  m_apiPicBufV;   }
150 
151  //  Access starting position of original picture
152  Pel*  getLumaAddr ()     { return  m_piPicOrgY;    }
153  Pel*  getCbAddr   ()     { return  m_piPicOrgU;    }
154  Pel*  getCrAddr   ()     { return  m_piPicOrgV;    }
155 
156  //  Access starting position of original picture for specific coding unit (CU) or partition unit (PU)
157  Pel*  getLumaAddr ( Int iCuAddr ) { return m_piPicOrgY + m_cuOffsetY[ iCuAddr ]; }
158  Pel*  getCbAddr   ( Int iCuAddr ) { return m_piPicOrgU + m_cuOffsetC[ iCuAddr ]; }
159  Pel*  getCrAddr   ( Int iCuAddr ) { return m_piPicOrgV + m_cuOffsetC[ iCuAddr ]; }
160  Pel*  getLumaAddr ( Int iCuAddr, Int uiAbsZorderIdx ) { return m_piPicOrgY + m_cuOffsetY[iCuAddr] + m_buOffsetY[g_auiZscanToRaster[uiAbsZorderIdx]]; }
161  Pel*  getCbAddr   ( Int iCuAddr, Int uiAbsZorderIdx ) { return m_piPicOrgU + m_cuOffsetC[iCuAddr] + m_buOffsetC[g_auiZscanToRaster[uiAbsZorderIdx]]; }
162  Pel*  getCrAddr   ( Int iCuAddr, Int uiAbsZorderIdx ) { return m_piPicOrgV + m_cuOffsetC[iCuAddr] + m_buOffsetC[g_auiZscanToRaster[uiAbsZorderIdx]]; }
163 
164#if SVC_UPSAMPLING
165  Int  getPicCropLeftOffset() const        { return m_picCropLeftOffset; }
166  Void setPicCropLeftOffset(Int val)       { m_picCropLeftOffset = val; }
167  Int  getPicCropRightOffset() const       { return m_picCropRightOffset; }
168  Void setPicCropRightOffset(Int val)      { m_picCropRightOffset = val; }
169  Int  getPicCropTopOffset() const         { return m_picCropTopOffset; }
170  Void setPicCropTopOffset(Int val)        { m_picCropTopOffset = val; }
171  Int  getPicCropBottomOffset() const      { return m_picCropBottomOffset; }
172  Void setPicCropBottomOffset(Int val)     { m_picCropBottomOffset = val; }
173#endif
174
175  // ------------------------------------------------------------------------------------------------
176  //  Miscellaneous
177  // ------------------------------------------------------------------------------------------------
178 
179  //  Copy function to picture
180  Void  copyToPic       ( TComPicYuv*  pcPicYuvDst );
181  Void  copyToPicLuma   ( TComPicYuv*  pcPicYuvDst );
182  Void  copyToPicCb     ( TComPicYuv*  pcPicYuvDst );
183  Void  copyToPicCr     ( TComPicYuv*  pcPicYuvDst );
184 
185  //  Extend function of picture buffer
186  Void  extendPicBorder      ();
187 
188  //  Dump picture
189  Void  dump (char* pFileName, Bool bAdd = false);
190 
191  // Set border extension flag
192  Void  setBorderExtension(Bool b) { m_bIsBorderExtended = b; }
193#if FIXED_ROUNDING_FRAME_MEMORY
194  Void  xFixedRoundingPic();
195#endif 
196};// END CLASS DEFINITION TComPicYuv
197
198void calcChecksum(TComPicYuv& pic, unsigned char digest[3][16]);
199void calcCRC(TComPicYuv& pic, unsigned char digest[3][16]);
200void calcMD5(TComPicYuv& pic, unsigned char digest[3][16]);
201//! \}
202
203#endif // __TCOMPICYUV__
Note: See TracBrowser for help on using the repository browser.