Changeset 1313 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComYuv.h
- Timestamp:
- 13 Aug 2015, 17:38:13 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibCommon/TComYuv.h
r1179 r1313 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 5 * 6 * Copyright (c) 2010-2015, ITU/ISO/IEC4 * granted under this license. 5 * 6 * Copyright (c) 2010-2015, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 40 40 #ifndef __TCOMYUV__ 41 41 #define __TCOMYUV__ 42 #include <assert.h>43 42 #include "CommonDef.h" 44 43 #include "TComPicYuv.h" 44 #include "TComRectangle.h" 45 45 46 46 //! \ingroup TLibCommon … … 55 55 { 56 56 private: 57 57 58 58 // ------------------------------------------------------------------------------------------------------------------ 59 59 // YUV buffer 60 60 // ------------------------------------------------------------------------------------------------------------------ 61 62 Pel* m_apiBufY; 63 Pel* m_apiBufU; 64 Pel* m_apiBufV; 65 61 62 Pel* m_apiBuf[MAX_NUM_COMPONENT]; 63 66 64 // ------------------------------------------------------------------------------------------------------------------ 67 65 // Parameter for general YUV buffer usage 68 66 // ------------------------------------------------------------------------------------------------------------------ 69 67 70 68 UInt m_iWidth; 71 69 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 70 ChromaFormat m_chromaFormatIDC; ////< Chroma Format 71 72 // dims 16x16 73 // blkSize=4x4 74 75 // these functions assume a square CU, of size width*width, split into square TUs each of size blkSize*blkSize. 76 // iTransUnitIdx is the raster-scanned index of the sub-block (TU) in question. 77 // eg for a 16x16 CU, with 4x4 TUs: 78 // 0 1 2 3 79 // 4 5 6 7 80 // 8 9 10 11 81 // 12 13 14 15 82 83 // So, for iTransUnitIdx=14, 14*4 & 15 =8=X offset. 84 // 14*4 / 16 =3=Y block offset 85 // 3*4*16 = Y offset within buffer 86 87 91 88 public: 92 93 TComYuv();94 virtual ~TComYuv();95 89 90 TComYuv (); 91 virtual ~TComYuv (); 92 96 93 // ------------------------------------------------------------------------------------------------------------------ 97 94 // Memory management 98 95 // ------------------------------------------------------------------------------------------------------------------ 99 100 Void create ( UInt iWidth, UInt iHeight); ///< Create YUV buffer101 Void destroy(); ///< Destroy YUV buffer102 Void clear(); ///< clear YUV buffer103 96 97 Void create ( const UInt iWidth, const UInt iHeight, const ChromaFormat chromaFormatIDC ); ///< Create YUV buffer 98 Void destroy (); ///< Destroy YUV buffer 99 Void clear (); ///< clear YUV buffer 100 104 101 // ------------------------------------------------------------------------------------------------------------------ 105 102 // Copy, load, store YUV buffer 106 103 // ------------------------------------------------------------------------------------------------------------------ 107 104 108 105 // 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 106 Void copyToPicYuv ( TComPicYuv* pcPicYuvDst, const UInt ctuRsAddr, const UInt uiAbsZorderIdx, const UInt uiPartDepth = 0, const UInt uiPartIdx = 0 ) const ; 107 Void copyToPicComponent ( const ComponentID id, TComPicYuv* pcPicYuvDst, const UInt iCtuRsAddr, const UInt uiAbsZorderIdx, const UInt uiPartDepth = 0, const UInt uiPartIdx = 0 ) const ; 108 113 109 // 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 110 Void copyFromPicYuv ( const TComPicYuv* pcPicYuvSrc, const UInt ctuRsAddr, const UInt uiAbsZorderIdx ); 111 Void copyFromPicComponent ( const ComponentID id, const TComPicYuv* pcPicYuvSrc, const UInt iCtuRsAddr, const UInt uiAbsZorderIdx ); 112 118 113 // Copy Small YUV buffer to the part of other Big YUV buffer 119 Void copyToPartYuv ( TComYuv* pcYuvDst, UInt uiDstPartIdx ); 120 Void copyToPartLuma ( TComYuv* pcYuvDst, UInt uiDstPartIdx ); 121 Void copyToPartChroma ( TComYuv* pcYuvDst, UInt uiDstPartIdx ); 122 114 Void copyToPartYuv ( TComYuv* pcYuvDst, const UInt uiDstPartIdx ) const ; 115 Void copyToPartComponent ( const ComponentID id, TComYuv* pcYuvDst, const UInt uiDstPartIdx ) const ; 116 123 117 // Copy the part of Big YUV buffer to other Small YUV buffer 124 Void copyPartToYuv ( TComYuv* pcYuvDst, UInt uiSrcPartIdx ); 125 Void copyPartToLuma ( TComYuv* pcYuvDst, UInt uiSrcPartIdx ); 126 Void copyPartToChroma ( TComYuv* pcYuvDst, UInt uiSrcPartIdx ); 127 118 Void copyPartToYuv ( TComYuv* pcYuvDst, const UInt uiSrcPartIdx ) const; 119 Void copyPartToComponent ( const ComponentID id, TComYuv* pcYuvDst, const UInt uiSrcPartIdx ) const; 120 128 121 // Copy YUV partition buffer to other YUV partition buffer 129 Void copyPartToPartYuv ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiWidth, UInt uiHeight );130 Void copyPartToPartLuma ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiWidth, UInt uiHeight );131 Void copyPartToPartChroma ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiWidth, UInt uiHeight ); 132 133 Void copyPartToPartChroma ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight, UInt chromaId);122 Void copyPartToPartYuv ( TComYuv* pcYuvDst, const UInt uiPartIdx, const UInt uiWidth, const UInt uiHeight ) const; 123 Void copyPartToPartComponent ( const ComponentID id, TComYuv* pcYuvDst, const UInt uiPartIdx, const UInt uiWidthComponent, const UInt uiHeightComponent ) const; 124 125 // Copy YUV partition buffer to other YUV partition buffer for non-square blocks 126 Void copyPartToPartComponentMxN ( const ComponentID id, TComYuv* pcYuvDst, const TComRectangle &rect ) const; 134 127 135 128 // ------------------------------------------------------------------------------------------------------------------ 136 129 // Algebraic operation for YUV buffer 137 130 // ------------------------------------------------------------------------------------------------------------------ 138 131 139 132 // Clip(pcYuvSrc0 + pcYuvSrc1) -> m_apiBuf 140 Void addClip ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ); 141 Void addClipLuma ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ); 142 Void addClipChroma ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ); 143 133 Void addClip ( const TComYuv* pcYuvSrc0, const TComYuv* pcYuvSrc1, const UInt uiTrUnitIdx, const UInt uiPartSize, const BitDepths &clipBitDepths ); 134 144 135 // pcYuvSrc0 - pcYuvSrc1 -> m_apiBuf 145 Void subtract ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ); 146 Void subtractLuma ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ); 147 Void subtractChroma ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ); 148 136 Void subtract ( const TComYuv* pcYuvSrc0, const TComYuv* pcYuvSrc1, const UInt uiTrUnitIdx, const UInt uiPartSize ); 137 149 138 // (pcYuvSrc0 + pcYuvSrc1)/2 for YUV partition 150 Void addAvg ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight ); 151 152 // Remove High frequency 153 Void removeHighFreq ( TComYuv* pcYuvSrc, UInt uiPartIdx, UInt uiWidht, UInt uiHeight ); 154 139 Void addAvg ( const TComYuv* pcYuvSrc0, const TComYuv* pcYuvSrc1, const UInt iPartUnitIdx, const UInt iWidth, const UInt iHeight, const BitDepths &clipBitDepths ); 140 141 Void removeHighFreq ( const TComYuv* pcYuvSrc, const UInt uiPartIdx, const UInt uiWidth, const UInt uiHeight 142 , const Int bitDepths[MAX_NUM_CHANNEL_TYPE], const Bool bClipToBitDepths 143 ); 144 155 145 // ------------------------------------------------------------------------------------------------------------------ 156 146 // Access function for YUV buffer 157 147 // ------------------------------------------------------------------------------------------------------------------ 158 148 159 149 // Access starting position of YUV buffer 160 Pel* getLumaAddr () { return m_apiBufY; } 161 Pel* getCbAddr () { return m_apiBufU; } 162 Pel* getCrAddr () { return m_apiBufV; } 163 150 Pel* getAddr (const ComponentID id) { return m_apiBuf[id]; } 151 const Pel* getAddr (const ComponentID id) const { return m_apiBuf[id]; } 152 164 153 // Access starting position of YUV partition unit buffer 165 Pel* getLumaAddr( UInt iPartUnitIdx ) { return m_apiBufY + getAddrOffset( iPartUnitIdx, m_iWidth ) ; } 166 Pel* getCbAddr ( UInt iPartUnitIdx ) { return m_apiBufU + ( getAddrOffset( iPartUnitIdx, m_iCWidth ) >> 1 ); } 167 Pel* getCrAddr ( UInt iPartUnitIdx ) { return m_apiBufV + ( getAddrOffset( iPartUnitIdx, m_iCWidth ) >> 1 ); } 168 154 Pel* getAddr (const ComponentID id, const UInt uiPartUnitIdx) 155 { 156 Int blkX = g_auiRasterToPelX[ g_auiZscanToRaster[ uiPartUnitIdx ] ] >> getComponentScaleX(id); 157 Int blkY = g_auiRasterToPelY[ g_auiZscanToRaster[ uiPartUnitIdx ] ] >> getComponentScaleY(id); 158 assert((blkX<getWidth(id) && blkY<getHeight(id))); 159 return m_apiBuf[id] + blkX + blkY * getStride(id); 160 } 161 const Pel* getAddr (const ComponentID id, const UInt uiPartUnitIdx) const 162 { 163 Int blkX = g_auiRasterToPelX[ g_auiZscanToRaster[ uiPartUnitIdx ] ] >> getComponentScaleX(id); 164 Int blkY = g_auiRasterToPelY[ g_auiZscanToRaster[ uiPartUnitIdx ] ] >> getComponentScaleY(id); 165 assert((blkX<getWidth(id) && blkY<getHeight(id))); 166 return m_apiBuf[id] + blkX + blkY * getStride(id); 167 } 168 169 169 // Access starting position of YUV transform unit buffer 170 Pel* getLumaAddr( UInt iTransUnitIdx, UInt iBlkSize ) { return m_apiBufY + getAddrOffset( iTransUnitIdx, iBlkSize, m_iWidth ); } 171 Pel* getCbAddr ( UInt iTransUnitIdx, UInt iBlkSize ) { return m_apiBufU + getAddrOffset( iTransUnitIdx, iBlkSize, m_iCWidth ); } 172 Pel* getCrAddr ( UInt iTransUnitIdx, UInt iBlkSize ) { return m_apiBufV + getAddrOffset( iTransUnitIdx, iBlkSize, m_iCWidth ); } 170 Pel* getAddr (const ComponentID id, const UInt iTransUnitIdx, const UInt iBlkSizeForComponent) 171 { 172 UInt width=getWidth(id); 173 Int blkX = ( iTransUnitIdx * iBlkSizeForComponent ) & ( width - 1 ); 174 Int blkY = ( iTransUnitIdx * iBlkSizeForComponent ) &~ ( width - 1 ); 175 if (m_chromaFormatIDC==CHROMA_422 && id!=COMPONENT_Y) 176 { 177 blkY<<=1; 178 } 179 return m_apiBuf[id] + blkX + blkY * iBlkSizeForComponent; 180 } 181 182 const Pel* getAddr (const ComponentID id, const UInt iTransUnitIdx, const UInt iBlkSizeForComponent) const 183 { 184 UInt width=getWidth(id); 185 Int blkX = ( iTransUnitIdx * iBlkSizeForComponent ) & ( width - 1 ); 186 Int blkY = ( iTransUnitIdx * iBlkSizeForComponent ) &~ ( width - 1 ); 187 if (m_chromaFormatIDC==CHROMA_422 && id!=COMPONENT_Y) 188 { 189 blkY<<=1; 190 } 191 return m_apiBuf[id] + blkX + blkY * iBlkSizeForComponent; 192 } 193 194 // Access starting position of YUV transform unit buffer by pix offset for square & non-square blocks 195 Pel* getAddrPix (const ComponentID id, const UInt iPixX, const UInt iPixY ) { return m_apiBuf[id] + iPixY * getStride(id) + iPixX; } 196 const Pel* getAddrPix (const ComponentID id, const UInt iPixX, const UInt iPixY ) const { return m_apiBuf[id] + iPixY * getStride(id) + iPixX; } 173 197 174 198 // Get stride value of YUV buffer 175 UInt getStride () { return m_iWidth; } 176 UInt getCStride () { return m_iCWidth; } 177 UInt getHeight () { return m_iHeight; } 178 179 UInt getWidth () { return m_iWidth; } 180 UInt getCHeight () { return m_iCHeight; } 181 UInt getCWidth () { return m_iCWidth; } 182 #if H_3D 183 Void addClipPartLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ); 184 185 #if H_3D_ARP 186 Void addARP ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip ); 187 Void addARPLuma ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip ); 188 Void addARPChroma ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip ); 189 Void subtractARP ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight ); 190 Void subtractARPLuma ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight ); 191 Void subtractARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight ); 192 Void multiplyARP ( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW ); 193 Void multiplyARPLuma ( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW ); 194 Void multiplyARPChroma( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW ); 195 private: 196 Void xxMultiplyLine( Pel * pSrcDst , UInt uiWidth , UChar dW ); 199 UInt getStride (const ComponentID id) const { return m_iWidth >> getComponentScaleX(id); } 200 UInt getHeight (const ComponentID id) const { return m_iHeight >> getComponentScaleY(id); } 201 UInt getWidth (const ComponentID id) const { return m_iWidth >> getComponentScaleX(id); } 202 ChromaFormat getChromaFormat () const { return m_chromaFormatIDC; } 203 UInt getNumberValidComponents () const { return ::getNumberValidComponents(m_chromaFormatIDC); } 204 UInt getComponentScaleX (const ComponentID id) const { return ::getComponentScaleX(id, m_chromaFormatIDC); } 205 UInt getComponentScaleY (const ComponentID id) const { return ::getComponentScaleY(id, m_chromaFormatIDC); } 206 #if NH_3D 207 Void addClipPartLuma( Int bitDepth, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ); 208 #if NH_3D_ARP 209 Void addARP ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip, const BitDepths &clipBitDepths ); 210 Void addARPLuma ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip, const BitDepths &clipBitDepths ); 211 Void addARPChroma ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip, const BitDepths &clipBitDepths ); 212 Void subtractARP ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight ); 213 Void subtractARPLuma ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight ); 214 Void subtractARPChroma ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight ); 215 Void multiplyARP ( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW ); 216 Void multiplyARPLuma ( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW ); 217 Void multiplyARPChroma ( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW ); 218 private: 219 Void xxMultiplyLine ( Pel * pSrcDst , UInt uiWidth , UChar dW ); 197 220 #endif 198 221 #endif
Note: See TracChangeset for help on using the changeset viewer.