[313] | 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 |
---|
[1029] | 4 | * granted under this license. |
---|
[313] | 5 | * |
---|
[1259] | 6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
---|
[313] | 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.cpp |
---|
| 35 | \brief general YUV buffer class |
---|
| 36 | \todo this should be merged with TComPicYuv |
---|
| 37 | */ |
---|
| 38 | |
---|
| 39 | #include <stdlib.h> |
---|
| 40 | #include <memory.h> |
---|
| 41 | #include <assert.h> |
---|
| 42 | #include <math.h> |
---|
| 43 | |
---|
| 44 | #include "CommonDef.h" |
---|
| 45 | #include "TComYuv.h" |
---|
| 46 | #include "TComInterpolationFilter.h" |
---|
| 47 | |
---|
| 48 | //! \ingroup TLibCommon |
---|
| 49 | //! \{ |
---|
| 50 | |
---|
| 51 | TComYuv::TComYuv() |
---|
| 52 | { |
---|
[1029] | 53 | for(Int comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
| 54 | { |
---|
| 55 | m_apiBuf[comp] = NULL; |
---|
| 56 | } |
---|
[313] | 57 | } |
---|
| 58 | |
---|
| 59 | TComYuv::~TComYuv() |
---|
| 60 | { |
---|
| 61 | } |
---|
| 62 | |
---|
[1029] | 63 | Void TComYuv::create( UInt iWidth, UInt iHeight, ChromaFormat chromaFormatIDC ) |
---|
[313] | 64 | { |
---|
| 65 | // set width and height |
---|
| 66 | m_iWidth = iWidth; |
---|
| 67 | m_iHeight = iHeight; |
---|
[1029] | 68 | m_chromaFormatIDC = chromaFormatIDC; |
---|
| 69 | |
---|
[1313] | 70 | for(Int comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
[1029] | 71 | { |
---|
| 72 | // memory allocation |
---|
[1313] | 73 | m_apiBuf[comp] = (Pel*)xMalloc( Pel, getWidth(ComponentID(comp))*getHeight(ComponentID(comp)) ); |
---|
[1029] | 74 | } |
---|
[313] | 75 | } |
---|
| 76 | |
---|
| 77 | Void TComYuv::destroy() |
---|
| 78 | { |
---|
| 79 | // memory free |
---|
[1313] | 80 | for(Int comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
[1029] | 81 | { |
---|
[1313] | 82 | if (m_apiBuf[comp]!=NULL) |
---|
[1246] | 83 | { |
---|
[1313] | 84 | xFree( m_apiBuf[comp] ); |
---|
| 85 | m_apiBuf[comp] = NULL; |
---|
[1246] | 86 | } |
---|
[1029] | 87 | } |
---|
[313] | 88 | } |
---|
| 89 | |
---|
| 90 | Void TComYuv::clear() |
---|
| 91 | { |
---|
[1313] | 92 | for(Int comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
[1029] | 93 | { |
---|
[1313] | 94 | if (m_apiBuf[comp]!=NULL) |
---|
[1246] | 95 | { |
---|
[1313] | 96 | ::memset( m_apiBuf[comp], 0, ( getWidth(ComponentID(comp)) * getHeight(ComponentID(comp)) )*sizeof(Pel) ); |
---|
[1246] | 97 | } |
---|
[1029] | 98 | } |
---|
[313] | 99 | } |
---|
| 100 | |
---|
[1029] | 101 | |
---|
| 102 | |
---|
| 103 | |
---|
| 104 | Void TComYuv::copyToPicYuv ( TComPicYuv* pcPicYuvDst, const UInt ctuRsAddr, const UInt uiAbsZorderIdx, const UInt uiPartDepth, const UInt uiPartIdx ) const |
---|
[313] | 105 | { |
---|
[1313] | 106 | for(Int comp=0; comp<getNumberValidComponents(); comp++) |
---|
[1246] | 107 | { |
---|
[1313] | 108 | copyToPicComponent ( ComponentID(comp), pcPicYuvDst, ctuRsAddr, uiAbsZorderIdx, uiPartDepth, uiPartIdx ); |
---|
[1246] | 109 | } |
---|
[313] | 110 | } |
---|
| 111 | |
---|
[1313] | 112 | Void TComYuv::copyToPicComponent ( const ComponentID compID, TComPicYuv* pcPicYuvDst, const UInt ctuRsAddr, const UInt uiAbsZorderIdx, const UInt uiPartDepth, const UInt uiPartIdx ) const |
---|
[313] | 113 | { |
---|
[1313] | 114 | const Int iWidth = getWidth(compID) >>uiPartDepth; |
---|
| 115 | const Int iHeight = getHeight(compID)>>uiPartDepth; |
---|
[1029] | 116 | |
---|
[1313] | 117 | const Pel* pSrc = getAddr(compID, uiPartIdx, iWidth); |
---|
| 118 | Pel* pDst = pcPicYuvDst->getAddr ( compID, ctuRsAddr, uiAbsZorderIdx ); |
---|
[1029] | 119 | |
---|
[1313] | 120 | const UInt iSrcStride = getStride(compID); |
---|
| 121 | const UInt iDstStride = pcPicYuvDst->getStride(compID); |
---|
[1029] | 122 | |
---|
| 123 | for ( Int y = iHeight; y != 0; y-- ) |
---|
[313] | 124 | { |
---|
| 125 | ::memcpy( pDst, pSrc, sizeof(Pel)*iWidth); |
---|
| 126 | pDst += iDstStride; |
---|
| 127 | pSrc += iSrcStride; |
---|
| 128 | } |
---|
| 129 | } |
---|
| 130 | |
---|
[1029] | 131 | |
---|
| 132 | |
---|
| 133 | |
---|
| 134 | Void TComYuv::copyFromPicYuv ( const TComPicYuv* pcPicYuvSrc, const UInt ctuRsAddr, const UInt uiAbsZorderIdx ) |
---|
[313] | 135 | { |
---|
[1313] | 136 | for(Int comp=0; comp<getNumberValidComponents(); comp++) |
---|
[1246] | 137 | { |
---|
[1313] | 138 | copyFromPicComponent ( ComponentID(comp), pcPicYuvSrc, ctuRsAddr, uiAbsZorderIdx ); |
---|
[1246] | 139 | } |
---|
[313] | 140 | } |
---|
| 141 | |
---|
[1313] | 142 | Void TComYuv::copyFromPicComponent ( const ComponentID compID, const TComPicYuv* pcPicYuvSrc, const UInt ctuRsAddr, const UInt uiAbsZorderIdx ) |
---|
[313] | 143 | { |
---|
[1313] | 144 | Pel* pDst = getAddr(compID); |
---|
| 145 | const Pel* pSrc = pcPicYuvSrc->getAddr ( compID, ctuRsAddr, uiAbsZorderIdx ); |
---|
[313] | 146 | |
---|
[1313] | 147 | const UInt iDstStride = getStride(compID); |
---|
| 148 | const UInt iSrcStride = pcPicYuvSrc->getStride(compID); |
---|
| 149 | const Int iWidth=getWidth(compID); |
---|
| 150 | const Int iHeight=getHeight(compID); |
---|
[1029] | 151 | |
---|
| 152 | for (Int y = iHeight; y != 0; y-- ) |
---|
[313] | 153 | { |
---|
[1029] | 154 | ::memcpy( pDst, pSrc, sizeof(Pel)*iWidth); |
---|
[313] | 155 | pDst += iDstStride; |
---|
| 156 | pSrc += iSrcStride; |
---|
| 157 | } |
---|
| 158 | } |
---|
| 159 | |
---|
[1029] | 160 | |
---|
| 161 | |
---|
| 162 | |
---|
| 163 | Void TComYuv::copyToPartYuv( TComYuv* pcYuvDst, const UInt uiDstPartIdx ) const |
---|
[313] | 164 | { |
---|
[1313] | 165 | for(Int comp=0; comp<getNumberValidComponents(); comp++) |
---|
[1246] | 166 | { |
---|
[1313] | 167 | copyToPartComponent ( ComponentID(comp), pcYuvDst, uiDstPartIdx ); |
---|
[1246] | 168 | } |
---|
[313] | 169 | } |
---|
| 170 | |
---|
[1313] | 171 | Void TComYuv::copyToPartComponent( const ComponentID compID, TComYuv* pcYuvDst, const UInt uiDstPartIdx ) const |
---|
[313] | 172 | { |
---|
[1313] | 173 | const Pel* pSrc = getAddr(compID); |
---|
| 174 | Pel* pDst = pcYuvDst->getAddr( compID, uiDstPartIdx ); |
---|
[313] | 175 | |
---|
[1313] | 176 | const UInt iSrcStride = getStride(compID); |
---|
| 177 | const UInt iDstStride = pcYuvDst->getStride(compID); |
---|
| 178 | const Int iWidth=getWidth(compID); |
---|
| 179 | const Int iHeight=getHeight(compID); |
---|
[1029] | 180 | |
---|
| 181 | for (Int y = iHeight; y != 0; y-- ) |
---|
[313] | 182 | { |
---|
[1029] | 183 | ::memcpy( pDst, pSrc, sizeof(Pel)*iWidth); |
---|
[313] | 184 | pDst += iDstStride; |
---|
| 185 | pSrc += iSrcStride; |
---|
| 186 | } |
---|
| 187 | } |
---|
| 188 | |
---|
[1029] | 189 | |
---|
| 190 | |
---|
| 191 | |
---|
| 192 | Void TComYuv::copyPartToYuv( TComYuv* pcYuvDst, const UInt uiSrcPartIdx ) const |
---|
[313] | 193 | { |
---|
[1313] | 194 | for(Int comp=0; comp<getNumberValidComponents(); comp++) |
---|
[1246] | 195 | { |
---|
[1313] | 196 | copyPartToComponent ( ComponentID(comp), pcYuvDst, uiSrcPartIdx ); |
---|
[1246] | 197 | } |
---|
[313] | 198 | } |
---|
| 199 | |
---|
[1313] | 200 | Void TComYuv::copyPartToComponent( const ComponentID compID, TComYuv* pcYuvDst, const UInt uiSrcPartIdx ) const |
---|
[313] | 201 | { |
---|
[1313] | 202 | const Pel* pSrc = getAddr(compID, uiSrcPartIdx); |
---|
| 203 | Pel* pDst = pcYuvDst->getAddr(compID, 0 ); |
---|
[313] | 204 | |
---|
[1313] | 205 | const UInt iSrcStride = getStride(compID); |
---|
| 206 | const UInt iDstStride = pcYuvDst->getStride(compID); |
---|
[1029] | 207 | |
---|
[1313] | 208 | const UInt uiHeight = pcYuvDst->getHeight(compID); |
---|
| 209 | const UInt uiWidth = pcYuvDst->getWidth(compID); |
---|
[1029] | 210 | |
---|
| 211 | for ( UInt y = uiHeight; y != 0; y-- ) |
---|
[313] | 212 | { |
---|
| 213 | ::memcpy( pDst, pSrc, sizeof(Pel)*uiWidth); |
---|
| 214 | pDst += iDstStride; |
---|
| 215 | pSrc += iSrcStride; |
---|
| 216 | } |
---|
| 217 | } |
---|
| 218 | |
---|
| 219 | |
---|
[1029] | 220 | |
---|
| 221 | |
---|
| 222 | Void TComYuv::copyPartToPartYuv ( TComYuv* pcYuvDst, const UInt uiPartIdx, const UInt iWidth, const UInt iHeight ) const |
---|
[313] | 223 | { |
---|
[1313] | 224 | for(Int comp=0; comp<getNumberValidComponents(); comp++) |
---|
[1246] | 225 | { |
---|
[1313] | 226 | copyPartToPartComponent (ComponentID(comp), pcYuvDst, uiPartIdx, iWidth>>getComponentScaleX(ComponentID(comp)), iHeight>>getComponentScaleY(ComponentID(comp)) ); |
---|
[1246] | 227 | } |
---|
[313] | 228 | } |
---|
| 229 | |
---|
[1313] | 230 | Void TComYuv::copyPartToPartComponent ( const ComponentID compID, TComYuv* pcYuvDst, const UInt uiPartIdx, const UInt iWidthComponent, const UInt iHeightComponent ) const |
---|
[313] | 231 | { |
---|
[1315] | 232 | const Pel* pSrc = getAddr(compID, uiPartIdx); |
---|
[1313] | 233 | Pel* pDst = pcYuvDst->getAddr(compID, uiPartIdx); |
---|
[313] | 234 | if( pSrc == pDst ) |
---|
| 235 | { |
---|
| 236 | //th not a good idea |
---|
[1029] | 237 | //th best would be to fix the caller |
---|
[313] | 238 | return ; |
---|
| 239 | } |
---|
[1029] | 240 | |
---|
[1313] | 241 | const UInt iSrcStride = getStride(compID); |
---|
| 242 | const UInt iDstStride = pcYuvDst->getStride(compID); |
---|
[1029] | 243 | for ( UInt y = iHeightComponent; y != 0; y-- ) |
---|
[313] | 244 | { |
---|
[1029] | 245 | ::memcpy( pDst, pSrc, iWidthComponent * sizeof(Pel) ); |
---|
[313] | 246 | pSrc += iSrcStride; |
---|
| 247 | pDst += iDstStride; |
---|
| 248 | } |
---|
| 249 | } |
---|
| 250 | |
---|
[1029] | 251 | |
---|
| 252 | |
---|
| 253 | |
---|
[1313] | 254 | Void TComYuv::copyPartToPartComponentMxN ( const ComponentID compID, TComYuv* pcYuvDst, const TComRectangle &rect) const |
---|
[313] | 255 | { |
---|
[1313] | 256 | const Pel* pSrc = getAddrPix( compID, rect.x0, rect.y0 ); |
---|
| 257 | Pel* pDst = pcYuvDst->getAddrPix( compID, rect.x0, rect.y0 ); |
---|
[1029] | 258 | if( pSrc == pDst ) |
---|
[313] | 259 | { |
---|
| 260 | //th not a good idea |
---|
[1029] | 261 | //th best would be to fix the caller |
---|
[313] | 262 | return ; |
---|
| 263 | } |
---|
[1029] | 264 | |
---|
[1313] | 265 | const UInt iSrcStride = getStride(compID); |
---|
| 266 | const UInt iDstStride = pcYuvDst->getStride(compID); |
---|
[1029] | 267 | const UInt uiHeightComponent=rect.height; |
---|
| 268 | const UInt uiWidthComponent=rect.width; |
---|
| 269 | for ( UInt y = uiHeightComponent; y != 0; y-- ) |
---|
[313] | 270 | { |
---|
[1029] | 271 | ::memcpy( pDst, pSrc, uiWidthComponent * sizeof( Pel ) ); |
---|
| 272 | pSrc += iSrcStride; |
---|
| 273 | pDst += iDstStride; |
---|
[313] | 274 | } |
---|
| 275 | } |
---|
| 276 | |
---|
[1029] | 277 | |
---|
| 278 | |
---|
| 279 | |
---|
[1287] | 280 | Void TComYuv::addClip( const TComYuv* pcYuvSrc0, const TComYuv* pcYuvSrc1, const UInt uiTrUnitIdx, const UInt uiPartSize, const BitDepths &clipBitDepths ) |
---|
[313] | 281 | { |
---|
[1313] | 282 | for(Int comp=0; comp<getNumberValidComponents(); comp++) |
---|
[313] | 283 | { |
---|
[1313] | 284 | const ComponentID compID=ComponentID(comp); |
---|
| 285 | const Int uiPartWidth =uiPartSize>>getComponentScaleX(compID); |
---|
| 286 | const Int uiPartHeight=uiPartSize>>getComponentScaleY(compID); |
---|
[1029] | 287 | |
---|
[1313] | 288 | const Pel* pSrc0 = pcYuvSrc0->getAddr(compID, uiTrUnitIdx, uiPartWidth ); |
---|
| 289 | const Pel* pSrc1 = pcYuvSrc1->getAddr(compID, uiTrUnitIdx, uiPartWidth ); |
---|
| 290 | Pel* pDst = getAddr(compID, uiTrUnitIdx, uiPartWidth ); |
---|
[1029] | 291 | |
---|
[1313] | 292 | const UInt iSrc0Stride = pcYuvSrc0->getStride(compID); |
---|
| 293 | const UInt iSrc1Stride = pcYuvSrc1->getStride(compID); |
---|
| 294 | const UInt iDstStride = getStride(compID); |
---|
| 295 | const Int clipbd = clipBitDepths.recon[toChannelType(compID)]; |
---|
[1029] | 296 | #if O0043_BEST_EFFORT_DECODING |
---|
[1313] | 297 | const Int bitDepthDelta = clipBitDepths.stream[toChannelType(compID)] - clipbd; |
---|
[1029] | 298 | #endif |
---|
| 299 | |
---|
| 300 | for ( Int y = uiPartHeight-1; y >= 0; y-- ) |
---|
[313] | 301 | { |
---|
[1029] | 302 | for ( Int x = uiPartWidth-1; x >= 0; x-- ) |
---|
| 303 | { |
---|
| 304 | #if O0043_BEST_EFFORT_DECODING |
---|
| 305 | pDst[x] = Pel(ClipBD<Int>( Int(pSrc0[x]) + rightShiftEvenRounding<Pel>(pSrc1[x], bitDepthDelta), clipbd)); |
---|
| 306 | #else |
---|
| 307 | pDst[x] = Pel(ClipBD<Int>( Int(pSrc0[x]) + Int(pSrc1[x]), clipbd)); |
---|
| 308 | #endif |
---|
| 309 | } |
---|
| 310 | pSrc0 += iSrc0Stride; |
---|
| 311 | pSrc1 += iSrc1Stride; |
---|
| 312 | pDst += iDstStride; |
---|
[313] | 313 | } |
---|
| 314 | } |
---|
| 315 | } |
---|
| 316 | |
---|
| 317 | |
---|
[1029] | 318 | |
---|
| 319 | |
---|
| 320 | Void TComYuv::subtract( const TComYuv* pcYuvSrc0, const TComYuv* pcYuvSrc1, const UInt uiTrUnitIdx, const UInt uiPartSize ) |
---|
[313] | 321 | { |
---|
[1313] | 322 | for(Int comp=0; comp<getNumberValidComponents(); comp++) |
---|
[313] | 323 | { |
---|
[1313] | 324 | const ComponentID compID=ComponentID(comp); |
---|
| 325 | const Int uiPartWidth =uiPartSize>>getComponentScaleX(compID); |
---|
| 326 | const Int uiPartHeight=uiPartSize>>getComponentScaleY(compID); |
---|
[313] | 327 | |
---|
[1313] | 328 | const Pel* pSrc0 = pcYuvSrc0->getAddr( compID, uiTrUnitIdx, uiPartWidth ); |
---|
| 329 | const Pel* pSrc1 = pcYuvSrc1->getAddr( compID, uiTrUnitIdx, uiPartWidth ); |
---|
| 330 | Pel* pDst = getAddr( compID, uiTrUnitIdx, uiPartWidth ); |
---|
[1029] | 331 | |
---|
[1313] | 332 | const Int iSrc0Stride = pcYuvSrc0->getStride(compID); |
---|
| 333 | const Int iSrc1Stride = pcYuvSrc1->getStride(compID); |
---|
| 334 | const Int iDstStride = getStride(compID); |
---|
[1029] | 335 | |
---|
| 336 | for (Int y = uiPartHeight-1; y >= 0; y-- ) |
---|
[313] | 337 | { |
---|
[1029] | 338 | for (Int x = uiPartWidth-1; x >= 0; x-- ) |
---|
| 339 | { |
---|
| 340 | pDst[x] = pSrc0[x] - pSrc1[x]; |
---|
| 341 | } |
---|
| 342 | pSrc0 += iSrc0Stride; |
---|
| 343 | pSrc1 += iSrc1Stride; |
---|
| 344 | pDst += iDstStride; |
---|
[313] | 345 | } |
---|
| 346 | } |
---|
| 347 | } |
---|
| 348 | |
---|
| 349 | |
---|
[1029] | 350 | |
---|
| 351 | |
---|
[1287] | 352 | Void TComYuv::addAvg( const TComYuv* pcYuvSrc0, const TComYuv* pcYuvSrc1, const UInt iPartUnitIdx, const UInt uiWidth, const UInt uiHeight, const BitDepths &clipBitDepths ) |
---|
[313] | 353 | { |
---|
[1313] | 354 | for(Int comp=0; comp<getNumberValidComponents(); comp++) |
---|
[313] | 355 | { |
---|
[1313] | 356 | const ComponentID compID=ComponentID(comp); |
---|
| 357 | const Pel* pSrc0 = pcYuvSrc0->getAddr( compID, iPartUnitIdx ); |
---|
| 358 | const Pel* pSrc1 = pcYuvSrc1->getAddr( compID, iPartUnitIdx ); |
---|
| 359 | Pel* pDst = getAddr( compID, iPartUnitIdx ); |
---|
[313] | 360 | |
---|
[1313] | 361 | const UInt iSrc0Stride = pcYuvSrc0->getStride(compID); |
---|
| 362 | const UInt iSrc1Stride = pcYuvSrc1->getStride(compID); |
---|
| 363 | const UInt iDstStride = getStride(compID); |
---|
| 364 | const Int clipbd = clipBitDepths.recon[toChannelType(compID)]; |
---|
[1029] | 365 | const Int shiftNum = std::max<Int>(2, (IF_INTERNAL_PREC - clipbd)) + 1; |
---|
| 366 | const Int offset = ( 1 << ( shiftNum - 1 ) ) + 2 * IF_INTERNAL_OFFS; |
---|
| 367 | |
---|
[1313] | 368 | const Int iWidth = uiWidth >> getComponentScaleX(compID); |
---|
| 369 | const Int iHeight = uiHeight >> getComponentScaleY(compID); |
---|
[1029] | 370 | |
---|
| 371 | if (iWidth&1) |
---|
[313] | 372 | { |
---|
[1029] | 373 | assert(0); |
---|
| 374 | exit(-1); |
---|
[313] | 375 | } |
---|
[1029] | 376 | else if (iWidth&2) |
---|
[313] | 377 | { |
---|
[1029] | 378 | for ( Int y = 0; y < iHeight; y++ ) |
---|
| 379 | { |
---|
| 380 | for (Int x=0 ; x < iWidth; x+=2 ) |
---|
| 381 | { |
---|
| 382 | pDst[ x + 0 ] = ClipBD( rightShift(( pSrc0[ x + 0 ] + pSrc1[ x + 0 ] + offset ), shiftNum), clipbd ); |
---|
| 383 | pDst[ x + 1 ] = ClipBD( rightShift(( pSrc0[ x + 1 ] + pSrc1[ x + 1 ] + offset ), shiftNum), clipbd ); |
---|
| 384 | } |
---|
| 385 | pSrc0 += iSrc0Stride; |
---|
| 386 | pSrc1 += iSrc1Stride; |
---|
| 387 | pDst += iDstStride; |
---|
| 388 | } |
---|
[313] | 389 | } |
---|
[1029] | 390 | else |
---|
[313] | 391 | { |
---|
[1029] | 392 | for ( Int y = 0; y < iHeight; y++ ) |
---|
| 393 | { |
---|
| 394 | for (Int x=0 ; x < iWidth; x+=4 ) |
---|
| 395 | { |
---|
| 396 | pDst[ x + 0 ] = ClipBD( rightShift(( pSrc0[ x + 0 ] + pSrc1[ x + 0 ] + offset ), shiftNum), clipbd ); |
---|
| 397 | pDst[ x + 1 ] = ClipBD( rightShift(( pSrc0[ x + 1 ] + pSrc1[ x + 1 ] + offset ), shiftNum), clipbd ); |
---|
| 398 | pDst[ x + 2 ] = ClipBD( rightShift(( pSrc0[ x + 2 ] + pSrc1[ x + 2 ] + offset ), shiftNum), clipbd ); |
---|
| 399 | pDst[ x + 3 ] = ClipBD( rightShift(( pSrc0[ x + 3 ] + pSrc1[ x + 3 ] + offset ), shiftNum), clipbd ); |
---|
| 400 | } |
---|
| 401 | pSrc0 += iSrc0Stride; |
---|
| 402 | pSrc1 += iSrc1Stride; |
---|
| 403 | pDst += iDstStride; |
---|
| 404 | } |
---|
[313] | 405 | } |
---|
| 406 | } |
---|
| 407 | } |
---|
| 408 | |
---|
[1313] | 409 | Void TComYuv::removeHighFreq( const TComYuv* pcYuvSrc, |
---|
| 410 | const UInt uiPartIdx, |
---|
| 411 | const UInt uiWidth, |
---|
[1324] | 412 | const UInt uiHeight, |
---|
| 413 | const Int bitDepths[MAX_NUM_CHANNEL_TYPE], |
---|
| 414 | const Bool bClipToBitDepths |
---|
[1313] | 415 | ) |
---|
[313] | 416 | { |
---|
[1313] | 417 | for(Int comp=0; comp<getNumberValidComponents(); comp++) |
---|
[313] | 418 | { |
---|
[1313] | 419 | const ComponentID compID=ComponentID(comp); |
---|
| 420 | const Pel* pSrc = pcYuvSrc->getAddr(compID, uiPartIdx); |
---|
| 421 | Pel* pDst = getAddr(compID, uiPartIdx); |
---|
[1029] | 422 | |
---|
[1313] | 423 | const Int iSrcStride = pcYuvSrc->getStride(compID); |
---|
| 424 | const Int iDstStride = getStride(compID); |
---|
| 425 | const Int iWidth = uiWidth >>getComponentScaleX(compID); |
---|
| 426 | const Int iHeight = uiHeight>>getComponentScaleY(compID); |
---|
[1324] | 427 | if (bClipToBitDepths) |
---|
[313] | 428 | { |
---|
[1324] | 429 | const Int clipBd=bitDepths[toChannelType(compID)]; |
---|
| 430 | for ( Int y = iHeight-1; y >= 0; y-- ) |
---|
[1029] | 431 | { |
---|
[1324] | 432 | for ( Int x = iWidth-1; x >= 0; x-- ) |
---|
| 433 | { |
---|
| 434 | pDst[x ] = ClipBD((2 * pDst[x]) - pSrc[x], clipBd); |
---|
| 435 | } |
---|
| 436 | pSrc += iSrcStride; |
---|
| 437 | pDst += iDstStride; |
---|
[1029] | 438 | } |
---|
[313] | 439 | } |
---|
[1324] | 440 | else |
---|
| 441 | { |
---|
| 442 | for ( Int y = iHeight-1; y >= 0; y-- ) |
---|
| 443 | { |
---|
| 444 | for ( Int x = iWidth-1; x >= 0; x-- ) |
---|
| 445 | { |
---|
| 446 | pDst[x ] = (2 * pDst[x]) - pSrc[x]; |
---|
| 447 | } |
---|
| 448 | pSrc += iSrcStride; |
---|
| 449 | pDst += iDstStride; |
---|
| 450 | } |
---|
| 451 | } |
---|
[313] | 452 | } |
---|
| 453 | } |
---|
[1029] | 454 | |
---|
[313] | 455 | //! \} |
---|