Changeset 916 in SHVCSoftware for branches/SHM-upgrade/source/Lib/TLibCommon/TComYuv.h
- Timestamp:
- 12 Nov 2014, 08:09:17 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-upgrade/source/Lib/TLibCommon/TComYuv.h
r595 r916 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. 4 * granted under this license. 5 5 * 6 6 * Copyright (c) 2010-2014, ITU/ISO/IEC … … 43 43 #include "CommonDef.h" 44 44 #include "TComPicYuv.h" 45 #include "TComRectangle.h" 45 46 46 47 //! \ingroup TLibCommon … … 55 56 { 56 57 private: 57 58 58 59 // ------------------------------------------------------------------------------------------------------------------ 59 60 // YUV buffer 60 61 // ------------------------------------------------------------------------------------------------------------------ 61 62 Pel* m_apiBufY; 63 Pel* m_apiBufU; 64 Pel* m_apiBufV; 65 62 63 Pel* m_apiBuf[MAX_NUM_COMPONENT]; 64 66 65 // ------------------------------------------------------------------------------------------------------------------ 67 66 // Parameter for general YUV buffer usage 68 67 // ------------------------------------------------------------------------------------------------------------------ 69 68 70 69 UInt m_iWidth; 71 70 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 71 ChromaFormat m_chromaFormatIDC; ////< Chroma Format 72 73 // dims 16x16 74 // blkSize=4x4 75 76 // these functions assume a square CU, of size width*width, split into square TUs each of size blkSize*blkSize. 77 // iTransUnitIdx is the raster-scanned index of the sub-block (TU) in question. 78 // eg for a 16x16 CU, with 4x4 TUs: 79 // 0 1 2 3 80 // 4 5 6 7 81 // 8 9 10 11 82 // 12 13 14 15 83 84 // So, for iTransUnitIdx=14, 14*4 & 15 =8=X offset. 85 // 14*4 / 16 =3=Y block offset 86 // 3*4*16 = Y offset within buffer 87 88 91 89 public: 92 93 TComYuv();94 virtual ~TComYuv();95 90 91 TComYuv (); 92 virtual ~TComYuv (); 93 96 94 // ------------------------------------------------------------------------------------------------------------------ 97 95 // Memory management 98 96 // ------------------------------------------------------------------------------------------------------------------ 99 100 Void create ( UInt iWidth, UInt iHeight); ///< Create YUV buffer101 Void destroy(); ///< Destroy YUV buffer102 Void clear(); ///< clear YUV buffer103 97 98 Void create ( const UInt iWidth, const UInt iHeight, const ChromaFormat chromaFormatIDC ); ///< Create YUV buffer 99 Void destroy (); ///< Destroy YUV buffer 100 Void clear (); ///< clear YUV buffer 101 104 102 // ------------------------------------------------------------------------------------------------------------------ 105 103 // Copy, load, store YUV buffer 106 104 // ------------------------------------------------------------------------------------------------------------------ 107 105 108 106 // 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 107 Void copyToPicYuv ( TComPicYuv* pcPicYuvDst, const UInt ctuRsAddr, const UInt uiAbsZorderIdx, const UInt uiPartDepth = 0, const UInt uiPartIdx = 0 ) const ; 108 Void copyToPicComponent ( const ComponentID id, TComPicYuv* pcPicYuvDst, const UInt iCtuRsAddr, const UInt uiAbsZorderIdx, const UInt uiPartDepth = 0, const UInt uiPartIdx = 0 ) const ; 109 113 110 // 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 111 Void copyFromPicYuv ( const TComPicYuv* pcPicYuvSrc, const UInt ctuRsAddr, const UInt uiAbsZorderIdx ); 112 Void copyFromPicComponent ( const ComponentID id, const TComPicYuv* pcPicYuvSrc, const UInt iCtuRsAddr, const UInt uiAbsZorderIdx ); 113 118 114 // 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 115 Void copyToPartYuv ( TComYuv* pcYuvDst, const UInt uiDstPartIdx ) const ; 116 Void copyToPartComponent ( const ComponentID id, TComYuv* pcYuvDst, const UInt uiDstPartIdx ) const ; 117 123 118 // 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 119 Void copyPartToYuv ( TComYuv* pcYuvDst, const UInt uiSrcPartIdx ) const; 120 Void copyPartToComponent ( const ComponentID id, TComYuv* pcYuvDst, const UInt uiSrcPartIdx ) const; 121 128 122 // 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);123 Void copyPartToPartYuv ( TComYuv* pcYuvDst, const UInt uiPartIdx, const UInt uiWidth, const UInt uiHeight ) const; 124 Void copyPartToPartComponent ( const ComponentID id, TComYuv* pcYuvDst, const UInt uiPartIdx, const UInt uiWidthComponent, const UInt uiHeightComponent ) const; 125 126 // Copy YUV partition buffer to other YUV partition buffer for non-square blocks 127 Void copyPartToPartComponentMxN ( const ComponentID id, TComYuv* pcYuvDst, const TComRectangle &rect ) const; 134 128 135 129 // ------------------------------------------------------------------------------------------------------------------ 136 130 // Algebraic operation for YUV buffer 137 131 // ------------------------------------------------------------------------------------------------------------------ 138 132 139 133 // 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 134 Void addClip ( const TComYuv* pcYuvSrc0, const TComYuv* pcYuvSrc1, const UInt uiTrUnitIdx, const UInt uiPartSize ); 135 144 136 // 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 137 Void subtract ( const TComYuv* pcYuvSrc0, const TComYuv* pcYuvSrc1, const UInt uiTrUnitIdx, const UInt uiPartSize ); 138 149 139 // (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 140 Void addAvg ( const TComYuv* pcYuvSrc0, const TComYuv* pcYuvSrc1, const UInt iPartUnitIdx, const UInt iWidth, const UInt iHeight ); 141 142 Void removeHighFreq ( const TComYuv* pcYuvSrc, const UInt uiPartIdx, const UInt uiWidth, const UInt uiHeight ); 143 155 144 // ------------------------------------------------------------------------------------------------------------------ 156 145 // Access function for YUV buffer 157 146 // ------------------------------------------------------------------------------------------------------------------ 158 147 159 148 // 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 149 Pel* getAddr (const ComponentID id) { return m_apiBuf[id]; } 150 const Pel* getAddr (const ComponentID id) const { return m_apiBuf[id]; } 151 164 152 // 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 153 Pel* getAddr (const ComponentID id, const UInt uiPartUnitIdx) 154 { 155 Int blkX = g_auiRasterToPelX[ g_auiZscanToRaster[ uiPartUnitIdx ] ] >> getComponentScaleX(id); 156 Int blkY = g_auiRasterToPelY[ g_auiZscanToRaster[ uiPartUnitIdx ] ] >> getComponentScaleY(id); 157 assert((blkX<getWidth(id) && blkY<getHeight(id))); 158 return m_apiBuf[id] + blkX + blkY * getStride(id); 159 } 160 const Pel* getAddr (const ComponentID id, const UInt uiPartUnitIdx) const 161 { 162 Int blkX = g_auiRasterToPelX[ g_auiZscanToRaster[ uiPartUnitIdx ] ] >> getComponentScaleX(id); 163 Int blkY = g_auiRasterToPelY[ g_auiZscanToRaster[ uiPartUnitIdx ] ] >> getComponentScaleY(id); 164 assert((blkX<getWidth(id) && blkY<getHeight(id))); 165 return m_apiBuf[id] + blkX + blkY * getStride(id); 166 } 167 169 168 // 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 ); } 169 Pel* getAddr (const ComponentID id, const UInt iTransUnitIdx, const UInt iBlkSizeForComponent) 170 { 171 UInt width=getWidth(id); 172 Int blkX = ( iTransUnitIdx * iBlkSizeForComponent ) & ( width - 1 ); 173 Int blkY = ( iTransUnitIdx * iBlkSizeForComponent ) &~ ( width - 1 ); 174 if (m_chromaFormatIDC==CHROMA_422 && id!=COMPONENT_Y) blkY<<=1; 175 // assert((blkX<getWidth(id) && blkY<getHeight(id))); 176 return m_apiBuf[id] + blkX + blkY * iBlkSizeForComponent; 177 } 178 179 const Pel* getAddr (const ComponentID id, const UInt iTransUnitIdx, const UInt iBlkSizeForComponent) const 180 { 181 UInt width=getWidth(id); 182 Int blkX = ( iTransUnitIdx * iBlkSizeForComponent ) & ( width - 1 ); 183 Int blkY = ( iTransUnitIdx * iBlkSizeForComponent ) &~ ( width - 1 ); 184 if (m_chromaFormatIDC==CHROMA_422 && id!=COMPONENT_Y) blkY<<=1; 185 // UInt w=getWidth(id), h=getHeight(id); 186 // assert((blkX<w && blkY<h)); 187 return m_apiBuf[id] + blkX + blkY * iBlkSizeForComponent; 188 } 189 190 // Access starting position of YUV transform unit buffer by pix offset for square & non-square blocks 191 Pel* getAddrPix (const ComponentID id, const UInt iPixX, const UInt iPixY ) { return m_apiBuf[id] + iPixY * getStride(id) + iPixX; } 192 const Pel* getAddrPix (const ComponentID id, const UInt iPixX, const UInt iPixY ) const { return m_apiBuf[id] + iPixY * getStride(id) + iPixX; } 173 193 174 194 // 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; } 195 UInt getStride (const ComponentID id) const { return m_iWidth >> getComponentScaleX(id); } 196 UInt getHeight (const ComponentID id) const { return m_iHeight >> getComponentScaleY(id); } 197 UInt getWidth (const ComponentID id) const { return m_iWidth >> getComponentScaleX(id); } 198 ChromaFormat getChromaFormat () const { return m_chromaFormatIDC; } 199 UInt getNumberValidComponents () const { return ::getNumberValidComponents(m_chromaFormatIDC); } 200 UInt getComponentScaleX (const ComponentID id) const { return ::getComponentScaleX(id, m_chromaFormatIDC); } 201 UInt getComponentScaleY (const ComponentID id) const { return ::getComponentScaleY(id, m_chromaFormatIDC); } 202 182 203 };// END CLASS DEFINITION TComYuv 183 204
Note: See TracChangeset for help on using the changeset viewer.