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