source: SHVCSoftware/branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComYuv.h @ 1430

Last change on this file since 1430 was 54, checked in by seregin, 12 years ago

port simulcast

File size: 9.6 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-2013, 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     TComYuv.h
35    \brief    general YUV buffer class (header)
36    \todo     this should be merged with TComPicYuv \n
37              check usage of removeHighFreq function
38*/
39
40#ifndef __TCOMYUV__
41#define __TCOMYUV__
42#include <assert.h>
43#include "CommonDef.h"
44#include "TComPicYuv.h"
45
46//! \ingroup TLibCommon
47//! \{
48
49// ====================================================================================================================
50// Class definition
51// ====================================================================================================================
52
53/// general YUV buffer class
54class TComYuv
55{
56private:
57 
58  // ------------------------------------------------------------------------------------------------------------------
59  //  YUV buffer
60  // ------------------------------------------------------------------------------------------------------------------
61 
62  Pel*    m_apiBufY;
63  Pel*    m_apiBufU;
64  Pel*    m_apiBufV;
65 
66  // ------------------------------------------------------------------------------------------------------------------
67  //  Parameter for general YUV buffer usage
68  // ------------------------------------------------------------------------------------------------------------------
69 
70  UInt     m_iWidth;
71  UInt     m_iHeight;
72  UInt     m_iCWidth;
73  UInt     m_iCHeight;
74 
75  static Int getAddrOffset( UInt uiPartUnitIdx, UInt width )
76  {
77    Int blkX = g_auiRasterToPelX[ g_auiZscanToRaster[ uiPartUnitIdx ] ];
78    Int blkY = g_auiRasterToPelY[ g_auiZscanToRaster[ uiPartUnitIdx ] ];
79   
80    return blkX + blkY * width;
81  }
82
83  static Int getAddrOffset( UInt iTransUnitIdx, UInt iBlkSize, UInt width )
84  {
85    Int blkX = ( iTransUnitIdx * iBlkSize ) &  ( width - 1 );
86    Int blkY = ( iTransUnitIdx * iBlkSize ) &~ ( width - 1 );
87   
88    return blkX + blkY * iBlkSize;
89  }
90 
91public:
92 
93  TComYuv();
94  virtual ~TComYuv();
95 
96  // ------------------------------------------------------------------------------------------------------------------
97  //  Memory management
98  // ------------------------------------------------------------------------------------------------------------------
99 
100  Void    create            ( UInt iWidth, UInt iHeight );  ///< Create  YUV buffer
101  Void    destroy           ();                             ///< Destroy YUV buffer
102  Void    clear             ();                             ///< clear   YUV buffer
103 
104  // ------------------------------------------------------------------------------------------------------------------
105  //  Copy, load, store YUV buffer
106  // ------------------------------------------------------------------------------------------------------------------
107 
108  //  Copy YUV buffer to picture buffer
109  Void    copyToPicYuv         ( TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth = 0, UInt uiPartIdx = 0 );
110  Void    copyToPicLuma        ( TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth = 0, UInt uiPartIdx = 0 );
111  Void    copyToPicChroma      ( TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth = 0, UInt uiPartIdx = 0 );
112 
113  //  Copy YUV buffer from picture buffer
114  Void    copyFromPicYuv       ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx );
115  Void    copyFromPicLuma      ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx );
116  Void    copyFromPicChroma    ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx );
117#if NO_RESIDUAL_FLAG_FOR_BLPRED
118  Void    copyFromPicLuma  ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiZorderIdxInCU, UInt uiAbsZorderIdx, UInt uiWidth, UInt uiHeight );
119  Void    copyFromPicChroma( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiZorderIdxInCU, UInt uiAbsZorderIdx, UInt uiCWidth, UInt uiCHeight, UInt uiChromaId  );
120#endif
121 
122  //  Copy Small YUV buffer to the part of other Big YUV buffer
123  Void    copyToPartYuv         ( TComYuv*    pcYuvDst,    UInt uiDstPartIdx );
124  Void    copyToPartLuma        ( TComYuv*    pcYuvDst,    UInt uiDstPartIdx );
125  Void    copyToPartChroma      ( TComYuv*    pcYuvDst,    UInt uiDstPartIdx );
126 
127  //  Copy the part of Big YUV buffer to other Small YUV buffer
128  Void    copyPartToYuv         ( TComYuv*    pcYuvDst,    UInt uiSrcPartIdx );
129  Void    copyPartToLuma        ( TComYuv*    pcYuvDst,    UInt uiSrcPartIdx );
130  Void    copyPartToChroma      ( TComYuv*    pcYuvDst,    UInt uiSrcPartIdx );
131 
132  //  Copy YUV partition buffer to other YUV partition buffer
133  Void    copyPartToPartYuv     ( TComYuv*    pcYuvDst, UInt uiPartIdx, UInt uiWidth, UInt uiHeight );
134  Void    copyPartToPartLuma    ( TComYuv*    pcYuvDst, UInt uiPartIdx, UInt uiWidth, UInt uiHeight );
135  Void    copyPartToPartChroma  ( TComYuv*    pcYuvDst, UInt uiPartIdx, UInt uiWidth, UInt uiHeight );
136 
137  Void    copyPartToPartChroma  ( TComYuv*    pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight, UInt chromaId);
138
139  // ------------------------------------------------------------------------------------------------------------------
140  //  Algebraic operation for YUV buffer
141  // ------------------------------------------------------------------------------------------------------------------
142 
143  //  Clip(pcYuvSrc0 + pcYuvSrc1) -> m_apiBuf
144  Void    addClip           ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize );
145  Void    addClipLuma       ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize );
146  Void    addClipChroma     ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize );
147 
148  //  pcYuvSrc0 - pcYuvSrc1 -> m_apiBuf
149  Void    subtract          ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize );
150  Void    subtractLuma      ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize );
151  Void    subtractChroma    ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize );
152 
153  //  (pcYuvSrc0 + pcYuvSrc1)/2 for YUV partition
154  Void    addAvg            ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight );
155
156  //   Remove High frequency
157  Void    removeHighFreq    ( TComYuv* pcYuvSrc, UInt uiPartIdx, UInt uiWidht, UInt uiHeight );
158 
159  // ------------------------------------------------------------------------------------------------------------------
160  //  Access function for YUV buffer
161  // ------------------------------------------------------------------------------------------------------------------
162 
163  //  Access starting position of YUV buffer
164  Pel*    getLumaAddr ()    { return m_apiBufY; }
165  Pel*    getCbAddr   ()    { return m_apiBufU; }
166  Pel*    getCrAddr   ()    { return m_apiBufV; }
167 
168  //  Access starting position of YUV partition unit buffer
169  Pel* getLumaAddr( UInt iPartUnitIdx ) { return m_apiBufY +   getAddrOffset( iPartUnitIdx, m_iWidth  )       ; }
170  Pel* getCbAddr  ( UInt iPartUnitIdx ) { return m_apiBufU + ( getAddrOffset( iPartUnitIdx, m_iCWidth ) >> 1 ); }
171  Pel* getCrAddr  ( UInt iPartUnitIdx ) { return m_apiBufV + ( getAddrOffset( iPartUnitIdx, m_iCWidth ) >> 1 ); }
172 
173  //  Access starting position of YUV transform unit buffer
174  Pel* getLumaAddr( UInt iTransUnitIdx, UInt iBlkSize ) { return m_apiBufY + getAddrOffset( iTransUnitIdx, iBlkSize, m_iWidth  ); }
175  Pel* getCbAddr  ( UInt iTransUnitIdx, UInt iBlkSize ) { return m_apiBufU + getAddrOffset( iTransUnitIdx, iBlkSize, m_iCWidth ); }
176  Pel* getCrAddr  ( UInt iTransUnitIdx, UInt iBlkSize ) { return m_apiBufV + getAddrOffset( iTransUnitIdx, iBlkSize, m_iCWidth ); }
177
178  //  Get stride value of YUV buffer
179  UInt    getStride   ()    { return  m_iWidth;   }
180  UInt    getCStride  ()    { return  m_iCWidth;  }
181  UInt    getHeight   ()    { return  m_iHeight;  }
182 
183  UInt    getWidth    ()    { return  m_iWidth;   }
184  UInt    getCHeight  ()    { return  m_iCHeight; }
185  UInt    getCWidth   ()    { return  m_iCWidth;  } 
186};// END CLASS DEFINITION TComYuv
187
188//! \}
189
190#endif // __TCOMYUV__
Note: See TracBrowser for help on using the repository browser.