[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.cpp |
---|
| 37 | \brief general YUV buffer class |
---|
| 38 | \todo this should be merged with TComPicYuv |
---|
| 39 | */ |
---|
| 40 | |
---|
| 41 | #include <stdlib.h> |
---|
| 42 | #include <memory.h> |
---|
| 43 | #include <assert.h> |
---|
| 44 | #include <math.h> |
---|
| 45 | |
---|
| 46 | #include "CommonDef.h" |
---|
| 47 | #include "TComYuv.h" |
---|
| 48 | |
---|
| 49 | TComYuv::TComYuv() |
---|
| 50 | { |
---|
| 51 | m_apiBufY = NULL; |
---|
| 52 | m_apiBufU = NULL; |
---|
| 53 | m_apiBufV = NULL; |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | TComYuv::~TComYuv() |
---|
| 57 | { |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | Void TComYuv::printout() |
---|
| 61 | { |
---|
| 62 | Int x, y; |
---|
| 63 | |
---|
| 64 | Pel* pSrc = getLumaAddr( ); |
---|
| 65 | Int iStride = getStride(); |
---|
| 66 | |
---|
| 67 | |
---|
| 68 | printf("\nY ..."); |
---|
| 69 | for ( y = 0; y < iStride; y++ ) |
---|
| 70 | { |
---|
| 71 | printf ("\n"); |
---|
| 72 | for ( x = 0; x < iStride; x++ ) |
---|
| 73 | { |
---|
| 74 | printf ("%d ", pSrc[x]); |
---|
| 75 | } |
---|
| 76 | pSrc += iStride; |
---|
| 77 | } |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | Void TComYuv::create( UInt iWidth, UInt iHeight ) |
---|
| 81 | { |
---|
| 82 | // memory allocation |
---|
| 83 | m_apiBufY = (Pel*)xMalloc( Pel, iWidth*iHeight ); |
---|
| 84 | m_apiBufU = (Pel*)xMalloc( Pel, iWidth*iHeight >> 2 ); |
---|
| 85 | m_apiBufV = (Pel*)xMalloc( Pel, iWidth*iHeight >> 2 ); |
---|
| 86 | |
---|
| 87 | // set width and height |
---|
| 88 | m_iWidth = iWidth; |
---|
| 89 | m_iHeight = iHeight; |
---|
| 90 | m_iCWidth = iWidth >> 1; |
---|
| 91 | m_iCHeight = iHeight >> 1; |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | Void TComYuv::destroy() |
---|
| 95 | { |
---|
| 96 | // memory free |
---|
| 97 | xFree( m_apiBufY ); m_apiBufY = NULL; |
---|
| 98 | xFree( m_apiBufU ); m_apiBufU = NULL; |
---|
| 99 | xFree( m_apiBufV ); m_apiBufV = NULL; |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | Void TComYuv::clear() |
---|
| 103 | { |
---|
| 104 | ::memset( m_apiBufY, 0, ( m_iWidth * m_iHeight )*sizeof(Pel) ); |
---|
| 105 | ::memset( m_apiBufU, 0, ( m_iCWidth * m_iCHeight )*sizeof(Pel) ); |
---|
| 106 | ::memset( m_apiBufV, 0, ( m_iCWidth * m_iCHeight )*sizeof(Pel) ); |
---|
| 107 | } |
---|
| 108 | |
---|
| 109 | Void TComYuv::copyToPicYuv ( TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth, UInt uiPartIdx ) |
---|
| 110 | { |
---|
| 111 | copyToPicLuma ( pcPicYuvDst, iCuAddr, uiAbsZorderIdx, uiPartDepth, uiPartIdx ); |
---|
| 112 | copyToPicChroma( pcPicYuvDst, iCuAddr, uiAbsZorderIdx, uiPartDepth, uiPartIdx ); |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | Void TComYuv::copyToPicLuma ( TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth, UInt uiPartIdx ) |
---|
| 116 | { |
---|
| 117 | Int y, iWidth, iHeight; |
---|
| 118 | iWidth = m_iWidth >>uiPartDepth; |
---|
| 119 | iHeight = m_iHeight>>uiPartDepth; |
---|
| 120 | |
---|
| 121 | Pel* pSrc = getLumaAddr(uiPartIdx, iWidth); |
---|
| 122 | Pel* pDst = pcPicYuvDst->getLumaAddr ( iCuAddr, uiAbsZorderIdx ); |
---|
| 123 | |
---|
| 124 | UInt iSrcStride = getStride(); |
---|
| 125 | UInt iDstStride = pcPicYuvDst->getStride(); |
---|
| 126 | |
---|
| 127 | for ( y = iHeight; y != 0; y-- ) |
---|
| 128 | { |
---|
| 129 | ::memcpy( pDst, pSrc, sizeof(Pel)*iWidth); |
---|
| 130 | pDst += iDstStride; |
---|
| 131 | pSrc += iSrcStride; |
---|
| 132 | } |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | Void TComYuv::copyToPicChroma( TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth, UInt uiPartIdx ) |
---|
| 136 | { |
---|
| 137 | Int y, iWidth, iHeight; |
---|
| 138 | iWidth = m_iCWidth >>uiPartDepth; |
---|
| 139 | iHeight = m_iCHeight>>uiPartDepth; |
---|
| 140 | |
---|
| 141 | Pel* pSrcU = getCbAddr(uiPartIdx, iWidth); |
---|
| 142 | Pel* pSrcV = getCrAddr(uiPartIdx, iWidth); |
---|
| 143 | Pel* pDstU = pcPicYuvDst->getCbAddr( iCuAddr, uiAbsZorderIdx ); |
---|
| 144 | Pel* pDstV = pcPicYuvDst->getCrAddr( iCuAddr, uiAbsZorderIdx ); |
---|
| 145 | |
---|
| 146 | UInt iSrcStride = getCStride(); |
---|
| 147 | UInt iDstStride = pcPicYuvDst->getCStride(); |
---|
| 148 | for ( y = iHeight; y != 0; y-- ) |
---|
| 149 | { |
---|
| 150 | ::memcpy( pDstU, pSrcU, sizeof(Pel)*(iWidth) ); |
---|
| 151 | ::memcpy( pDstV, pSrcV, sizeof(Pel)*(iWidth) ); |
---|
| 152 | pSrcU += iSrcStride; |
---|
| 153 | pSrcV += iSrcStride; |
---|
| 154 | pDstU += iDstStride; |
---|
| 155 | pDstV += iDstStride; |
---|
| 156 | } |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | Void TComYuv::copyFromPicYuv ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx ) |
---|
| 160 | { |
---|
| 161 | copyFromPicLuma ( pcPicYuvSrc, iCuAddr, uiAbsZorderIdx ); |
---|
| 162 | copyFromPicChroma( pcPicYuvSrc, iCuAddr, uiAbsZorderIdx ); |
---|
| 163 | } |
---|
| 164 | |
---|
| 165 | Void TComYuv::copyFromPicLuma ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx ) |
---|
| 166 | { |
---|
| 167 | Int y; |
---|
| 168 | |
---|
| 169 | Pel* pDst = m_apiBufY; |
---|
| 170 | Pel* pSrc = pcPicYuvSrc->getLumaAddr ( iCuAddr, uiAbsZorderIdx ); |
---|
| 171 | |
---|
| 172 | UInt iDstStride = getStride(); |
---|
| 173 | UInt iSrcStride = pcPicYuvSrc->getStride(); |
---|
| 174 | for ( y = m_iHeight; y != 0; y-- ) |
---|
| 175 | { |
---|
| 176 | ::memcpy( pDst, pSrc, sizeof(Pel)*m_iWidth); |
---|
| 177 | pDst += iDstStride; |
---|
| 178 | pSrc += iSrcStride; |
---|
| 179 | } |
---|
| 180 | } |
---|
| 181 | |
---|
| 182 | Void TComYuv::copyFromPicChroma( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx ) |
---|
| 183 | { |
---|
| 184 | Int y; |
---|
| 185 | |
---|
| 186 | Pel* pDstU = m_apiBufU; |
---|
| 187 | Pel* pDstV = m_apiBufV; |
---|
| 188 | Pel* pSrcU = pcPicYuvSrc->getCbAddr( iCuAddr, uiAbsZorderIdx ); |
---|
| 189 | Pel* pSrcV = pcPicYuvSrc->getCrAddr( iCuAddr, uiAbsZorderIdx ); |
---|
| 190 | |
---|
| 191 | UInt iDstStride = getCStride(); |
---|
| 192 | UInt iSrcStride = pcPicYuvSrc->getCStride(); |
---|
| 193 | for ( y = m_iCHeight; y != 0; y-- ) |
---|
| 194 | { |
---|
| 195 | ::memcpy( pDstU, pSrcU, sizeof(Pel)*(m_iCWidth) ); |
---|
| 196 | ::memcpy( pDstV, pSrcV, sizeof(Pel)*(m_iCWidth) ); |
---|
| 197 | pSrcU += iSrcStride; |
---|
| 198 | pSrcV += iSrcStride; |
---|
| 199 | pDstU += iDstStride; |
---|
| 200 | pDstV += iDstStride; |
---|
| 201 | } |
---|
| 202 | } |
---|
| 203 | |
---|
| 204 | Void TComYuv::copyToPartYuv( TComYuv* pcYuvDst, UInt uiDstPartIdx ) |
---|
| 205 | { |
---|
| 206 | copyToPartLuma ( pcYuvDst, uiDstPartIdx ); |
---|
| 207 | copyToPartChroma( pcYuvDst, uiDstPartIdx ); |
---|
| 208 | } |
---|
| 209 | |
---|
| 210 | Void TComYuv::copyToPartLuma( TComYuv* pcYuvDst, UInt uiDstPartIdx ) |
---|
| 211 | { |
---|
| 212 | Int y; |
---|
| 213 | |
---|
| 214 | Pel* pSrc = m_apiBufY; |
---|
| 215 | Pel* pDst = pcYuvDst->getLumaAddr( uiDstPartIdx ); |
---|
| 216 | |
---|
| 217 | UInt iSrcStride = getStride(); |
---|
| 218 | UInt iDstStride = pcYuvDst->getStride(); |
---|
| 219 | for ( y = m_iHeight; y != 0; y-- ) |
---|
| 220 | { |
---|
| 221 | ::memcpy( pDst, pSrc, sizeof(Pel)*m_iWidth); |
---|
| 222 | pDst += iDstStride; |
---|
| 223 | pSrc += iSrcStride; |
---|
| 224 | } |
---|
| 225 | } |
---|
| 226 | |
---|
| 227 | Void TComYuv::copyToPartChroma( TComYuv* pcYuvDst, UInt uiDstPartIdx ) |
---|
| 228 | { |
---|
| 229 | Int y; |
---|
| 230 | |
---|
| 231 | Pel* pSrcU = m_apiBufU; |
---|
| 232 | Pel* pSrcV = m_apiBufV; |
---|
| 233 | Pel* pDstU = pcYuvDst->getCbAddr( uiDstPartIdx ); |
---|
| 234 | Pel* pDstV = pcYuvDst->getCrAddr( uiDstPartIdx ); |
---|
| 235 | |
---|
| 236 | UInt iSrcStride = getCStride(); |
---|
| 237 | UInt iDstStride = pcYuvDst->getCStride(); |
---|
| 238 | for ( y = m_iCHeight; y != 0; y-- ) |
---|
| 239 | { |
---|
| 240 | ::memcpy( pDstU, pSrcU, sizeof(Pel)*(m_iCWidth) ); |
---|
| 241 | ::memcpy( pDstV, pSrcV, sizeof(Pel)*(m_iCWidth) ); |
---|
| 242 | pSrcU += iSrcStride; |
---|
| 243 | pSrcV += iSrcStride; |
---|
| 244 | pDstU += iDstStride; |
---|
| 245 | pDstV += iDstStride; |
---|
| 246 | } |
---|
| 247 | } |
---|
| 248 | |
---|
| 249 | Void TComYuv::copyPartToYuv( TComYuv* pcYuvDst, UInt uiSrcPartIdx ) |
---|
| 250 | { |
---|
| 251 | copyPartToLuma ( pcYuvDst, uiSrcPartIdx ); |
---|
| 252 | copyPartToChroma( pcYuvDst, uiSrcPartIdx ); |
---|
| 253 | } |
---|
| 254 | |
---|
| 255 | Void TComYuv::copyPartToLuma( TComYuv* pcYuvDst, UInt uiSrcPartIdx ) |
---|
| 256 | { |
---|
| 257 | Int y; |
---|
| 258 | |
---|
| 259 | Pel* pSrc = getLumaAddr(uiSrcPartIdx); |
---|
| 260 | Pel* pDst = pcYuvDst->getLumaAddr( 0 ); |
---|
| 261 | |
---|
| 262 | UInt iSrcStride = getStride(); |
---|
| 263 | UInt iDstStride = pcYuvDst->getStride(); |
---|
| 264 | |
---|
| 265 | UInt uiHeight = pcYuvDst->getHeight(); |
---|
| 266 | UInt uiWidth = pcYuvDst->getWidth(); |
---|
| 267 | |
---|
| 268 | for ( y = uiHeight; y != 0; y-- ) |
---|
| 269 | { |
---|
| 270 | ::memcpy( pDst, pSrc, sizeof(Pel)*uiWidth); |
---|
| 271 | pDst += iDstStride; |
---|
| 272 | pSrc += iSrcStride; |
---|
| 273 | } |
---|
| 274 | } |
---|
| 275 | |
---|
| 276 | Void TComYuv::copyPartToChroma( TComYuv* pcYuvDst, UInt uiSrcPartIdx ) |
---|
| 277 | { |
---|
| 278 | Int y; |
---|
| 279 | |
---|
| 280 | Pel* pSrcU = getCbAddr( uiSrcPartIdx ); |
---|
| 281 | Pel* pSrcV = getCrAddr( uiSrcPartIdx ); |
---|
| 282 | Pel* pDstU = pcYuvDst->getCbAddr( 0 ); |
---|
| 283 | Pel* pDstV = pcYuvDst->getCrAddr( 0 ); |
---|
| 284 | |
---|
| 285 | UInt iSrcStride = getCStride(); |
---|
| 286 | UInt iDstStride = pcYuvDst->getCStride(); |
---|
| 287 | |
---|
| 288 | UInt uiCHeight = pcYuvDst->getCHeight(); |
---|
| 289 | UInt uiCWidth = pcYuvDst->getCWidth(); |
---|
| 290 | |
---|
| 291 | for ( y = uiCHeight; y != 0; y-- ) |
---|
| 292 | { |
---|
| 293 | ::memcpy( pDstU, pSrcU, sizeof(Pel)*(uiCWidth) ); |
---|
| 294 | ::memcpy( pDstV, pSrcV, sizeof(Pel)*(uiCWidth) ); |
---|
| 295 | pSrcU += iSrcStride; |
---|
| 296 | pSrcV += iSrcStride; |
---|
| 297 | pDstU += iDstStride; |
---|
| 298 | pDstV += iDstStride; |
---|
| 299 | } |
---|
| 300 | } |
---|
| 301 | |
---|
[20] | 302 | #if DEPTH_MAP_GENERATION |
---|
| 303 | Void TComYuv::copyPartToPartYuvPdm ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY ) |
---|
| 304 | { |
---|
| 305 | copyPartToPartLumaPdm (pcYuvDst, uiPartIdx, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY ); |
---|
| 306 | } |
---|
| 307 | #endif |
---|
| 308 | |
---|
[2] | 309 | Void TComYuv::copyPartToPartYuv ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight ) |
---|
| 310 | { |
---|
| 311 | copyPartToPartLuma (pcYuvDst, uiPartIdx, iWidth, iHeight ); |
---|
| 312 | copyPartToPartChroma (pcYuvDst, uiPartIdx, iWidth>>1, iHeight>>1 ); |
---|
| 313 | } |
---|
| 314 | |
---|
[20] | 315 | #if DEPTH_MAP_GENERATION |
---|
| 316 | Void TComYuv::copyPartToPartLumaPdm ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY ) |
---|
| 317 | { |
---|
| 318 | UInt uiBlkX = g_auiRasterToPelX[ g_auiZscanToRaster[ uiPartIdx ] ] >> uiSubSampExpX; |
---|
| 319 | UInt uiBlkY = g_auiRasterToPelY[ g_auiZscanToRaster[ uiPartIdx ] ] >> uiSubSampExpY; |
---|
| 320 | Pel* pSrc = getLumaAddr(uiPartIdx); |
---|
| 321 | Pel* pDst = pcYuvDst->getLumaAddr() + uiBlkY * pcYuvDst->getStride() + uiBlkX; |
---|
| 322 | |
---|
| 323 | if( pSrc == pDst ) |
---|
| 324 | { |
---|
| 325 | //th not a good idea |
---|
| 326 | //th best would be to fix the caller |
---|
| 327 | return ; |
---|
| 328 | } |
---|
| 329 | |
---|
| 330 | UInt iSrcStride = getStride(); |
---|
| 331 | UInt iDstStride = pcYuvDst->getStride(); |
---|
| 332 | for ( UInt y = iHeight; y != 0; y-- ) |
---|
| 333 | { |
---|
| 334 | ::memcpy( pDst, pSrc, iWidth * sizeof(Pel) ); |
---|
| 335 | pSrc += iSrcStride; |
---|
| 336 | pDst += iDstStride; |
---|
| 337 | } |
---|
| 338 | } |
---|
| 339 | #endif |
---|
| 340 | |
---|
[2] | 341 | Void TComYuv::copyPartToPartLuma ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight ) |
---|
| 342 | { |
---|
| 343 | Pel* pSrc = getLumaAddr(uiPartIdx); |
---|
| 344 | Pel* pDst = pcYuvDst->getLumaAddr(uiPartIdx); |
---|
| 345 | if( pSrc == pDst ) |
---|
| 346 | { |
---|
| 347 | //th not a good idea |
---|
| 348 | //th best would be to fix the caller |
---|
| 349 | return ; |
---|
| 350 | } |
---|
| 351 | |
---|
| 352 | UInt iSrcStride = getStride(); |
---|
| 353 | UInt iDstStride = pcYuvDst->getStride(); |
---|
| 354 | for ( UInt y = iHeight; y != 0; y-- ) |
---|
| 355 | { |
---|
| 356 | ::memcpy( pDst, pSrc, iWidth * sizeof(Pel) ); |
---|
| 357 | pSrc += iSrcStride; |
---|
| 358 | pDst += iDstStride; |
---|
| 359 | } |
---|
| 360 | } |
---|
| 361 | |
---|
| 362 | Void TComYuv::copyPartToPartChroma( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight ) |
---|
| 363 | { |
---|
| 364 | Pel* pSrcU = getCbAddr(uiPartIdx); |
---|
| 365 | Pel* pSrcV = getCrAddr(uiPartIdx); |
---|
| 366 | Pel* pDstU = pcYuvDst->getCbAddr(uiPartIdx); |
---|
| 367 | Pel* pDstV = pcYuvDst->getCrAddr(uiPartIdx); |
---|
| 368 | |
---|
| 369 | if( pSrcU == pDstU && pSrcV == pDstV) |
---|
| 370 | { |
---|
| 371 | //th not a good idea |
---|
| 372 | //th best would be to fix the caller |
---|
| 373 | return ; |
---|
| 374 | } |
---|
| 375 | |
---|
| 376 | UInt iSrcStride = getCStride(); |
---|
| 377 | UInt iDstStride = pcYuvDst->getCStride(); |
---|
| 378 | for ( UInt y = iHeight; y != 0; y-- ) |
---|
| 379 | { |
---|
| 380 | ::memcpy( pDstU, pSrcU, iWidth * sizeof(Pel) ); |
---|
| 381 | ::memcpy( pDstV, pSrcV, iWidth * sizeof(Pel) ); |
---|
| 382 | pSrcU += iSrcStride; |
---|
| 383 | pSrcV += iSrcStride; |
---|
| 384 | pDstU += iDstStride; |
---|
| 385 | pDstV += iDstStride; |
---|
| 386 | } |
---|
| 387 | } |
---|
| 388 | |
---|
| 389 | Void TComYuv::addClipPartLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
| 390 | { |
---|
| 391 | Int x, y; |
---|
| 392 | |
---|
| 393 | Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiTrUnitIdx); |
---|
| 394 | Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiTrUnitIdx); |
---|
| 395 | Pel* pDst = getLumaAddr( uiTrUnitIdx); |
---|
| 396 | |
---|
| 397 | UInt iSrc0Stride = pcYuvSrc0->getStride(); |
---|
| 398 | UInt iSrc1Stride = pcYuvSrc1->getStride(); |
---|
| 399 | UInt iDstStride = getStride(); |
---|
| 400 | for ( y = uiPartSize-1; y >= 0; y-- ) |
---|
| 401 | { |
---|
| 402 | for ( x = uiPartSize-1; x >= 0; x-- ) |
---|
| 403 | { |
---|
| 404 | pDst[x] = xClip( pSrc0[x] + pSrc1[x] ); |
---|
| 405 | } |
---|
| 406 | pSrc0 += iSrc0Stride; |
---|
| 407 | pSrc1 += iSrc1Stride; |
---|
| 408 | pDst += iDstStride; |
---|
| 409 | } |
---|
| 410 | } |
---|
| 411 | |
---|
| 412 | Void |
---|
| 413 | TComYuv::add( TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract ) |
---|
| 414 | { |
---|
| 415 | addLuma ( pcYuvAdd, iWidth, iHeight, bSubtract ); |
---|
| 416 | addChroma ( pcYuvAdd, iWidth>>1, iHeight>>1, bSubtract ); |
---|
| 417 | } |
---|
| 418 | |
---|
| 419 | Void |
---|
| 420 | TComYuv::addLuma( TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract ) |
---|
| 421 | { |
---|
| 422 | Int iScale = ( bSubtract ? -1 : 1 ); |
---|
| 423 | Int iAddStride = pcYuvAdd->getStride(); |
---|
| 424 | Int iDstStride = getStride(); |
---|
| 425 | Pel* pAddSamples = pcYuvAdd->getLumaAddr(); |
---|
| 426 | Pel* pDstSamples = getLumaAddr(); |
---|
| 427 | for( Int iY = 0; iY < iHeight; iY++, pDstSamples += iDstStride, pAddSamples += iAddStride ) |
---|
| 428 | { |
---|
| 429 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
| 430 | { |
---|
| 431 | pDstSamples[iX] += iScale * pAddSamples[iX]; |
---|
| 432 | } |
---|
| 433 | } |
---|
| 434 | } |
---|
| 435 | |
---|
| 436 | Void |
---|
| 437 | TComYuv::addChroma( TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract ) |
---|
| 438 | { |
---|
| 439 | Int iScale = ( bSubtract ? -1 : 1 ); |
---|
| 440 | Int iAddStride = pcYuvAdd->getCStride(); |
---|
| 441 | Int iDstStride = getCStride(); |
---|
| 442 | Pel* pAddSamplesCb = pcYuvAdd->getCbAddr(); |
---|
| 443 | Pel* pAddSamplesCr = pcYuvAdd->getCrAddr(); |
---|
| 444 | Pel* pDstSamplesCb = getCbAddr(); |
---|
| 445 | Pel* pDstSamplesCr = getCrAddr(); |
---|
| 446 | for( Int iY = 0; iY < iHeight; iY++, pDstSamplesCb += iDstStride, pAddSamplesCb += iAddStride, |
---|
| 447 | pDstSamplesCr += iDstStride, pAddSamplesCr += iAddStride ) |
---|
| 448 | { |
---|
| 449 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
| 450 | { |
---|
| 451 | pDstSamplesCb[iX] += iScale * pAddSamplesCb[iX]; |
---|
| 452 | pDstSamplesCr[iX] += iScale * pAddSamplesCr[iX]; |
---|
| 453 | } |
---|
| 454 | } |
---|
| 455 | } |
---|
| 456 | |
---|
| 457 | Void |
---|
| 458 | TComYuv::clip( Int iWidth, Int iHeight ) |
---|
| 459 | { |
---|
| 460 | clipLuma ( iWidth, iHeight ); |
---|
| 461 | clipChroma ( iWidth>>1, iHeight>>1 ); |
---|
| 462 | } |
---|
| 463 | |
---|
| 464 | Void |
---|
| 465 | TComYuv::clipLuma( Int iWidth, Int iHeight ) |
---|
| 466 | { |
---|
| 467 | Int iStride = getStride(); |
---|
| 468 | Pel* pSamples = getLumaAddr(); |
---|
| 469 | for( Int iY = 0; iY < iHeight; iY++, pSamples += iStride ) |
---|
| 470 | { |
---|
| 471 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
| 472 | { |
---|
| 473 | pSamples[iX] = xClip( pSamples[iX] ); |
---|
| 474 | } |
---|
| 475 | } |
---|
| 476 | } |
---|
| 477 | |
---|
| 478 | Void |
---|
| 479 | TComYuv::clipChroma( Int iWidth, Int iHeight ) |
---|
| 480 | { |
---|
| 481 | Int iStride = getCStride(); |
---|
| 482 | Pel* pSamplesCb = getCbAddr(); |
---|
| 483 | Pel* pSamplesCr = getCrAddr(); |
---|
| 484 | for( Int iY = 0; iY < iHeight; iY++, pSamplesCb += iStride, pSamplesCr += iStride ) |
---|
| 485 | { |
---|
| 486 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
| 487 | { |
---|
| 488 | pSamplesCb[iX] = xClip( pSamplesCb[iX] ); |
---|
| 489 | pSamplesCr[iX] = xClip( pSamplesCr[iX] ); |
---|
| 490 | } |
---|
| 491 | } |
---|
| 492 | } |
---|
| 493 | |
---|
| 494 | |
---|
| 495 | Void TComYuv::addClip( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
| 496 | { |
---|
| 497 | addClipLuma ( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize ); |
---|
| 498 | addClipChroma ( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize>>1 ); |
---|
| 499 | } |
---|
| 500 | |
---|
| 501 | Void TComYuv::addClipLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
| 502 | { |
---|
| 503 | Int x, y; |
---|
| 504 | |
---|
| 505 | Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 506 | Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 507 | Pel* pDst = getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 508 | |
---|
| 509 | UInt iSrc0Stride = pcYuvSrc0->getStride(); |
---|
| 510 | UInt iSrc1Stride = pcYuvSrc1->getStride(); |
---|
| 511 | UInt iDstStride = getStride(); |
---|
| 512 | for ( y = uiPartSize-1; y >= 0; y-- ) |
---|
| 513 | { |
---|
| 514 | for ( x = uiPartSize-1; x >= 0; x-- ) |
---|
| 515 | { |
---|
| 516 | pDst[x] = xClip( pSrc0[x] + pSrc1[x] ); |
---|
| 517 | } |
---|
| 518 | pSrc0 += iSrc0Stride; |
---|
| 519 | pSrc1 += iSrc1Stride; |
---|
| 520 | pDst += iDstStride; |
---|
| 521 | } |
---|
| 522 | } |
---|
| 523 | |
---|
| 524 | Void TComYuv::addClipChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
| 525 | { |
---|
| 526 | Int x, y; |
---|
| 527 | |
---|
| 528 | Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 529 | Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 530 | Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 531 | Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 532 | Pel* pDstU = getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 533 | Pel* pDstV = getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 534 | |
---|
| 535 | UInt iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
| 536 | UInt iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
| 537 | UInt iDstStride = getCStride(); |
---|
| 538 | for ( y = uiPartSize-1; y >= 0; y-- ) |
---|
| 539 | { |
---|
| 540 | for ( x = uiPartSize-1; x >= 0; x-- ) |
---|
| 541 | { |
---|
| 542 | pDstU[x] = xClip( pSrcU0[x] + pSrcU1[x] ); |
---|
| 543 | pDstV[x] = xClip( pSrcV0[x] + pSrcV1[x] ); |
---|
| 544 | } |
---|
| 545 | |
---|
| 546 | pSrcU0 += iSrc0Stride; |
---|
| 547 | pSrcU1 += iSrc1Stride; |
---|
| 548 | pSrcV0 += iSrc0Stride; |
---|
| 549 | pSrcV1 += iSrc1Stride; |
---|
| 550 | pDstU += iDstStride; |
---|
| 551 | pDstV += iDstStride; |
---|
| 552 | } |
---|
| 553 | } |
---|
| 554 | |
---|
| 555 | Void TComYuv::subtract( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
| 556 | { |
---|
| 557 | subtractLuma ( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize ); |
---|
| 558 | subtractChroma( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize>>1 ); |
---|
| 559 | } |
---|
| 560 | |
---|
| 561 | Void TComYuv::subtractLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
| 562 | { |
---|
| 563 | Int x, y; |
---|
| 564 | |
---|
| 565 | Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 566 | Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 567 | Pel* pDst = getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 568 | |
---|
| 569 | Int iSrc0Stride = pcYuvSrc0->getStride(); |
---|
| 570 | Int iSrc1Stride = pcYuvSrc1->getStride(); |
---|
| 571 | Int iDstStride = getStride(); |
---|
| 572 | for ( y = uiPartSize-1; y >= 0; y-- ) |
---|
| 573 | { |
---|
| 574 | for ( x = uiPartSize-1; x >= 0; x-- ) |
---|
| 575 | { |
---|
| 576 | pDst[x] = pSrc0[x] - pSrc1[x]; |
---|
| 577 | } |
---|
| 578 | pSrc0 += iSrc0Stride; |
---|
| 579 | pSrc1 += iSrc1Stride; |
---|
| 580 | pDst += iDstStride; |
---|
| 581 | } |
---|
| 582 | } |
---|
| 583 | |
---|
| 584 | Void TComYuv::subtractChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
| 585 | { |
---|
| 586 | Int x, y; |
---|
| 587 | |
---|
| 588 | Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 589 | Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 590 | Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 591 | Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 592 | Pel* pDstU = getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 593 | Pel* pDstV = getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 594 | |
---|
| 595 | Int iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
| 596 | Int iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
| 597 | Int iDstStride = getCStride(); |
---|
| 598 | for ( y = uiPartSize-1; y >= 0; y-- ) |
---|
| 599 | { |
---|
| 600 | for ( x = uiPartSize-1; x >= 0; x-- ) |
---|
| 601 | { |
---|
| 602 | pDstU[x] = pSrcU0[x] - pSrcU1[x]; |
---|
| 603 | pDstV[x] = pSrcV0[x] - pSrcV1[x]; |
---|
| 604 | } |
---|
| 605 | pSrcU0 += iSrc0Stride; |
---|
| 606 | pSrcU1 += iSrc1Stride; |
---|
| 607 | pSrcV0 += iSrc0Stride; |
---|
| 608 | pSrcV1 += iSrc1Stride; |
---|
| 609 | pDstU += iDstStride; |
---|
| 610 | pDstV += iDstStride; |
---|
| 611 | } |
---|
| 612 | } |
---|
| 613 | |
---|
| 614 | #ifdef ROUNDING_CONTROL_BIPRED |
---|
| 615 | |
---|
| 616 | Void TComYuv::addAvg( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, Bool bRound ) |
---|
| 617 | { |
---|
| 618 | Int x, y; |
---|
| 619 | |
---|
| 620 | Pel* pSrcY0 = pcYuvSrc0->getLumaAddr( iPartUnitIdx ); |
---|
| 621 | Pel* pSrcU0 = pcYuvSrc0->getCbAddr ( iPartUnitIdx ); |
---|
| 622 | Pel* pSrcV0 = pcYuvSrc0->getCrAddr ( iPartUnitIdx ); |
---|
| 623 | |
---|
| 624 | Pel* pSrcY1 = pcYuvSrc1->getLumaAddr( iPartUnitIdx ); |
---|
| 625 | Pel* pSrcU1 = pcYuvSrc1->getCbAddr ( iPartUnitIdx ); |
---|
| 626 | Pel* pSrcV1 = pcYuvSrc1->getCrAddr ( iPartUnitIdx ); |
---|
| 627 | |
---|
| 628 | Pel* pDstY = getLumaAddr( iPartUnitIdx ); |
---|
| 629 | Pel* pDstU = getCbAddr ( iPartUnitIdx ); |
---|
| 630 | Pel* pDstV = getCrAddr ( iPartUnitIdx ); |
---|
| 631 | |
---|
| 632 | UInt iSrc0Stride = pcYuvSrc0->getStride(); |
---|
| 633 | UInt iSrc1Stride = pcYuvSrc1->getStride(); |
---|
| 634 | UInt iDstStride = getStride(); |
---|
| 635 | |
---|
| 636 | #if HIGH_ACCURACY_BI |
---|
| 637 | Int shiftNum = 15 - (g_uiBitDepth + g_uiBitIncrement); |
---|
| 638 | Int offset = (1<<(shiftNum - 1)); |
---|
| 639 | |
---|
| 640 | for ( y = iHeight-1; y >= 0; y-- ) |
---|
| 641 | { |
---|
| 642 | for ( x = iWidth-1; x >= 0; ) |
---|
| 643 | { |
---|
| 644 | // note: luma min width is 4 |
---|
| 645 | pDstY[x] = Clip((pSrcY0[x] + pSrcY1[x] + offset) >> shiftNum ); x--; |
---|
| 646 | pDstY[x] = Clip((pSrcY0[x] + pSrcY1[x] + offset) >> shiftNum); x--; |
---|
| 647 | pDstY[x] = Clip((pSrcY0[x] + pSrcY1[x] + offset) >> shiftNum); x--; |
---|
| 648 | pDstY[x] = Clip((pSrcY0[x] + pSrcY1[x] + offset) >> shiftNum); x--; |
---|
| 649 | } |
---|
| 650 | pSrcY0 += iSrc0Stride; |
---|
| 651 | pSrcY1 += iSrc1Stride; |
---|
| 652 | pDstY += iDstStride; |
---|
| 653 | } |
---|
| 654 | |
---|
| 655 | iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
| 656 | iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
| 657 | iDstStride = getCStride(); |
---|
| 658 | |
---|
| 659 | iWidth >>=1; |
---|
| 660 | iHeight >>=1; |
---|
| 661 | |
---|
| 662 | for ( y = iHeight-1; y >= 0; y-- ) |
---|
| 663 | { |
---|
| 664 | for ( x = iWidth-1; x >= 0; ) |
---|
| 665 | { |
---|
| 666 | // note: chroma min width is 2 |
---|
| 667 | pDstU[x] = Clip((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum); |
---|
| 668 | pDstV[x] = Clip((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum); x--; |
---|
| 669 | pDstU[x] = Clip((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum); |
---|
| 670 | pDstV[x] = Clip((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum); x--; |
---|
| 671 | } |
---|
| 672 | |
---|
| 673 | pSrcU0 += iSrc0Stride; |
---|
| 674 | pSrcU1 += iSrc1Stride; |
---|
| 675 | pSrcV0 += iSrc0Stride; |
---|
| 676 | pSrcV1 += iSrc1Stride; |
---|
| 677 | pDstU += iDstStride; |
---|
| 678 | pDstV += iDstStride; |
---|
| 679 | } |
---|
| 680 | |
---|
| 681 | #else |
---|
| 682 | |
---|
| 683 | for ( y = iHeight-1; y >= 0; y-- ) |
---|
| 684 | { |
---|
| 685 | for ( x = iWidth-1; x >= 0; ) |
---|
| 686 | { |
---|
| 687 | // note: luma min width is 4 |
---|
| 688 | pDstY[x] = (pSrcY0[x] + pSrcY1[x] + bRound) >> 1; x--; |
---|
| 689 | pDstY[x] = (pSrcY0[x] + pSrcY1[x] + bRound) >> 1; x--; |
---|
| 690 | pDstY[x] = (pSrcY0[x] + pSrcY1[x] + bRound) >> 1; x--; |
---|
| 691 | pDstY[x] = (pSrcY0[x] + pSrcY1[x] + bRound) >> 1; x--; |
---|
| 692 | } |
---|
| 693 | pSrcY0 += iSrc0Stride; |
---|
| 694 | pSrcY1 += iSrc1Stride; |
---|
| 695 | pDstY += iDstStride; |
---|
| 696 | } |
---|
| 697 | |
---|
| 698 | iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
| 699 | iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
| 700 | iDstStride = getCStride(); |
---|
| 701 | |
---|
| 702 | iWidth >>=1; |
---|
| 703 | iHeight >>=1; |
---|
| 704 | |
---|
| 705 | for ( y = iHeight-1; y >= 0; y-- ) |
---|
| 706 | { |
---|
| 707 | for ( x = iWidth-1; x >= 0; ) |
---|
| 708 | { |
---|
| 709 | // note: chroma min width is 2 |
---|
| 710 | pDstU[x] = (pSrcU0[x] + pSrcU1[x] + bRound) >> 1; |
---|
| 711 | pDstV[x] = (pSrcV0[x] + pSrcV1[x] + bRound) >> 1; x--; |
---|
| 712 | pDstU[x] = (pSrcU0[x] + pSrcU1[x] + bRound) >> 1; |
---|
| 713 | pDstV[x] = (pSrcV0[x] + pSrcV1[x] + bRound) >> 1; x--; |
---|
| 714 | } |
---|
| 715 | |
---|
| 716 | pSrcU0 += iSrc0Stride; |
---|
| 717 | pSrcU1 += iSrc1Stride; |
---|
| 718 | pSrcV0 += iSrc0Stride; |
---|
| 719 | pSrcV1 += iSrc1Stride; |
---|
| 720 | pDstU += iDstStride; |
---|
| 721 | pDstV += iDstStride; |
---|
| 722 | } |
---|
| 723 | #endif |
---|
| 724 | } |
---|
| 725 | |
---|
| 726 | #endif |
---|
| 727 | |
---|
| 728 | Void TComYuv::addAvg( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight ) |
---|
| 729 | { |
---|
| 730 | Int x, y; |
---|
| 731 | |
---|
| 732 | Pel* pSrcY0 = pcYuvSrc0->getLumaAddr( iPartUnitIdx ); |
---|
| 733 | Pel* pSrcU0 = pcYuvSrc0->getCbAddr ( iPartUnitIdx ); |
---|
| 734 | Pel* pSrcV0 = pcYuvSrc0->getCrAddr ( iPartUnitIdx ); |
---|
| 735 | |
---|
| 736 | Pel* pSrcY1 = pcYuvSrc1->getLumaAddr( iPartUnitIdx ); |
---|
| 737 | Pel* pSrcU1 = pcYuvSrc1->getCbAddr ( iPartUnitIdx ); |
---|
| 738 | Pel* pSrcV1 = pcYuvSrc1->getCrAddr ( iPartUnitIdx ); |
---|
| 739 | |
---|
| 740 | Pel* pDstY = getLumaAddr( iPartUnitIdx ); |
---|
| 741 | Pel* pDstU = getCbAddr ( iPartUnitIdx ); |
---|
| 742 | Pel* pDstV = getCrAddr ( iPartUnitIdx ); |
---|
| 743 | |
---|
| 744 | UInt iSrc0Stride = pcYuvSrc0->getStride(); |
---|
| 745 | UInt iSrc1Stride = pcYuvSrc1->getStride(); |
---|
| 746 | UInt iDstStride = getStride(); |
---|
| 747 | #if HIGH_ACCURACY_BI |
---|
| 748 | Int shiftNum = 15 - (g_uiBitDepth + g_uiBitIncrement); |
---|
| 749 | Int offset = (1<<(shiftNum - 1)); |
---|
| 750 | |
---|
| 751 | for ( y = iHeight-1; y >= 0; y-- ) |
---|
| 752 | { |
---|
| 753 | for ( x = iWidth-1; x >= 0; ) |
---|
| 754 | { |
---|
| 755 | // note: luma min width is 4 |
---|
| 756 | pDstY[x] = Clip((pSrcY0[x] + pSrcY1[x] + offset) >> shiftNum ); x--; |
---|
| 757 | pDstY[x] = Clip((pSrcY0[x] + pSrcY1[x] + offset) >> shiftNum); x--; |
---|
| 758 | pDstY[x] = Clip((pSrcY0[x] + pSrcY1[x] + offset) >> shiftNum); x--; |
---|
| 759 | pDstY[x] = Clip((pSrcY0[x] + pSrcY1[x] + offset) >> shiftNum); x--; |
---|
| 760 | } |
---|
| 761 | pSrcY0 += iSrc0Stride; |
---|
| 762 | pSrcY1 += iSrc1Stride; |
---|
| 763 | pDstY += iDstStride; |
---|
| 764 | } |
---|
| 765 | |
---|
| 766 | iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
| 767 | iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
| 768 | iDstStride = getCStride(); |
---|
| 769 | |
---|
| 770 | iWidth >>=1; |
---|
| 771 | iHeight >>=1; |
---|
| 772 | |
---|
| 773 | for ( y = iHeight-1; y >= 0; y-- ) |
---|
| 774 | { |
---|
| 775 | for ( x = iWidth-1; x >= 0; ) |
---|
| 776 | { |
---|
| 777 | // note: chroma min width is 2 |
---|
| 778 | pDstU[x] = Clip((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum); |
---|
| 779 | pDstV[x] = Clip((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum); x--; |
---|
| 780 | pDstU[x] = Clip((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum); |
---|
| 781 | pDstV[x] = Clip((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum); x--; |
---|
| 782 | } |
---|
| 783 | |
---|
| 784 | pSrcU0 += iSrc0Stride; |
---|
| 785 | pSrcU1 += iSrc1Stride; |
---|
| 786 | pSrcV0 += iSrc0Stride; |
---|
| 787 | pSrcV1 += iSrc1Stride; |
---|
| 788 | pDstU += iDstStride; |
---|
| 789 | pDstV += iDstStride; |
---|
| 790 | } |
---|
| 791 | |
---|
| 792 | #else |
---|
| 793 | for ( y = iHeight-1; y >= 0; y-- ) |
---|
| 794 | { |
---|
| 795 | for ( x = iWidth-1; x >= 0; ) |
---|
| 796 | { |
---|
| 797 | // note: luma min width is 4 |
---|
| 798 | pDstY[x] = (pSrcY0[x] + pSrcY1[x] + 1) >> 1; x--; |
---|
| 799 | pDstY[x] = (pSrcY0[x] + pSrcY1[x] + 1) >> 1; x--; |
---|
| 800 | pDstY[x] = (pSrcY0[x] + pSrcY1[x] + 1) >> 1; x--; |
---|
| 801 | pDstY[x] = (pSrcY0[x] + pSrcY1[x] + 1) >> 1; x--; |
---|
| 802 | } |
---|
| 803 | pSrcY0 += iSrc0Stride; |
---|
| 804 | pSrcY1 += iSrc1Stride; |
---|
| 805 | pDstY += iDstStride; |
---|
| 806 | } |
---|
| 807 | |
---|
| 808 | iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
| 809 | iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
| 810 | iDstStride = getCStride(); |
---|
| 811 | |
---|
| 812 | iWidth >>=1; |
---|
| 813 | iHeight >>=1; |
---|
| 814 | |
---|
| 815 | for ( y = iHeight-1; y >= 0; y-- ) |
---|
| 816 | { |
---|
| 817 | for ( x = iWidth-1; x >= 0; ) |
---|
| 818 | { |
---|
| 819 | // note: chroma min width is 2 |
---|
| 820 | pDstU[x] = (pSrcU0[x] + pSrcU1[x] + 1) >> 1; |
---|
| 821 | pDstV[x] = (pSrcV0[x] + pSrcV1[x] + 1) >> 1; x--; |
---|
| 822 | pDstU[x] = (pSrcU0[x] + pSrcU1[x] + 1) >> 1; |
---|
| 823 | pDstV[x] = (pSrcV0[x] + pSrcV1[x] + 1) >> 1; x--; |
---|
| 824 | } |
---|
| 825 | |
---|
| 826 | pSrcU0 += iSrc0Stride; |
---|
| 827 | pSrcU1 += iSrc1Stride; |
---|
| 828 | pSrcV0 += iSrc0Stride; |
---|
| 829 | pSrcV1 += iSrc1Stride; |
---|
| 830 | pDstU += iDstStride; |
---|
| 831 | pDstV += iDstStride; |
---|
| 832 | } |
---|
| 833 | #endif |
---|
| 834 | } |
---|
| 835 | |
---|
[20] | 836 | #if DEPTH_MAP_GENERATION |
---|
| 837 | Void TComYuv::addAvgPdm( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY ) |
---|
| 838 | { |
---|
| 839 | Int x, y; |
---|
| 840 | |
---|
| 841 | UInt uiBlkX = g_auiRasterToPelX[ g_auiZscanToRaster[ iPartUnitIdx ] ] >> uiSubSampExpX; |
---|
| 842 | UInt uiBlkY = g_auiRasterToPelY[ g_auiZscanToRaster[ iPartUnitIdx ] ] >> uiSubSampExpY; |
---|
| 843 | Pel* pSrcY0 = pcYuvSrc0->getLumaAddr( iPartUnitIdx ); |
---|
| 844 | Pel* pSrcY1 = pcYuvSrc1->getLumaAddr( iPartUnitIdx ); |
---|
| 845 | Pel* pDstY = getLumaAddr() + uiBlkY * getStride() + uiBlkX; |
---|
| 846 | |
---|
| 847 | UInt iSrc0Stride = pcYuvSrc0->getStride(); |
---|
| 848 | UInt iSrc1Stride = pcYuvSrc1->getStride(); |
---|
| 849 | UInt iDstStride = getStride(); |
---|
| 850 | |
---|
| 851 | for ( y = iHeight-1; y >= 0; y-- ) |
---|
| 852 | { |
---|
| 853 | for ( x = iWidth-1; x >= 0; x-- ) |
---|
| 854 | { |
---|
| 855 | pDstY[x] = (pSrcY0[x] + pSrcY1[x] + 1) >> 1; |
---|
| 856 | } |
---|
| 857 | pSrcY0 += iSrc0Stride; |
---|
| 858 | pSrcY1 += iSrc1Stride; |
---|
| 859 | pDstY += iDstStride; |
---|
| 860 | } |
---|
| 861 | } |
---|
| 862 | #endif |
---|
| 863 | |
---|
| 864 | |
---|
[2] | 865 | Void TComYuv::removeHighFreq( TComYuv* pcYuvSrc, UInt uiWidht, UInt uiHeight ) |
---|
| 866 | { |
---|
| 867 | Int x, y; |
---|
| 868 | |
---|
| 869 | Pel* pSrc = pcYuvSrc->getLumaAddr(); |
---|
| 870 | Pel* pSrcU = pcYuvSrc->getCbAddr(); |
---|
| 871 | Pel* pSrcV = pcYuvSrc->getCrAddr(); |
---|
| 872 | |
---|
| 873 | Pel* pDst = m_apiBufY; |
---|
| 874 | Pel* pDstU = m_apiBufU; |
---|
| 875 | Pel* pDstV = m_apiBufV; |
---|
| 876 | |
---|
| 877 | Int iSrcStride = pcYuvSrc->getStride(); |
---|
| 878 | Int iDstStride = getStride(); |
---|
| 879 | |
---|
| 880 | for ( y = uiHeight-1; y >= 0; y-- ) |
---|
| 881 | { |
---|
| 882 | for ( x = uiWidht-1; x >= 0; x-- ) |
---|
| 883 | { |
---|
| 884 | pDst[x ] = xClip( (pDst[x ]<<1) - pSrc[x ] ); |
---|
| 885 | } |
---|
| 886 | pSrc += iSrcStride; |
---|
| 887 | pDst += iDstStride; |
---|
| 888 | } |
---|
| 889 | |
---|
| 890 | iSrcStride = pcYuvSrc->getCStride(); |
---|
| 891 | iDstStride = getCStride(); |
---|
| 892 | |
---|
| 893 | uiHeight >>= 1; |
---|
| 894 | uiWidht >>= 1; |
---|
| 895 | |
---|
| 896 | for ( y = uiHeight-1; y >= 0; y-- ) |
---|
| 897 | { |
---|
| 898 | for ( x = uiWidht-1; x >= 0; x-- ) |
---|
| 899 | { |
---|
| 900 | pDstU[x ] = xClip( (pDstU[x ]<<1) - pSrcU[x ] ); |
---|
| 901 | pDstV[x ] = xClip( (pDstV[x ]<<1) - pSrcV[x ] ); |
---|
| 902 | } |
---|
| 903 | pSrcU += iSrcStride; |
---|
| 904 | pSrcV += iSrcStride; |
---|
| 905 | pDstU += iDstStride; |
---|
| 906 | pDstV += iDstStride; |
---|
| 907 | } |
---|
| 908 | } |
---|
| 909 | |
---|
| 910 | Void TComYuv::removeHighFreq( TComYuv* pcYuvSrc, UInt uiPartIdx, UInt uiWidht, UInt uiHeight ) |
---|
| 911 | { |
---|
| 912 | Int x, y; |
---|
| 913 | |
---|
| 914 | Pel* pSrc = pcYuvSrc->getLumaAddr(uiPartIdx); |
---|
| 915 | Pel* pSrcU = pcYuvSrc->getCbAddr(uiPartIdx); |
---|
| 916 | Pel* pSrcV = pcYuvSrc->getCrAddr(uiPartIdx); |
---|
| 917 | |
---|
| 918 | Pel* pDst = getLumaAddr(uiPartIdx); |
---|
| 919 | Pel* pDstU = getCbAddr(uiPartIdx); |
---|
| 920 | Pel* pDstV = getCrAddr(uiPartIdx); |
---|
| 921 | |
---|
| 922 | Int iSrcStride = pcYuvSrc->getStride(); |
---|
| 923 | Int iDstStride = getStride(); |
---|
| 924 | |
---|
| 925 | for ( y = uiHeight-1; y >= 0; y-- ) |
---|
| 926 | { |
---|
| 927 | for ( x = uiWidht-1; x >= 0; x-- ) |
---|
| 928 | { |
---|
| 929 | pDst[x ] = xClip( (pDst[x ]<<1) - pSrc[x ] ); |
---|
| 930 | } |
---|
| 931 | pSrc += iSrcStride; |
---|
| 932 | pDst += iDstStride; |
---|
| 933 | } |
---|
| 934 | |
---|
| 935 | iSrcStride = pcYuvSrc->getCStride(); |
---|
| 936 | iDstStride = getCStride(); |
---|
| 937 | |
---|
| 938 | uiHeight >>= 1; |
---|
| 939 | uiWidht >>= 1; |
---|
| 940 | |
---|
| 941 | for ( y = uiHeight-1; y >= 0; y-- ) |
---|
| 942 | { |
---|
| 943 | for ( x = uiWidht-1; x >= 0; x-- ) |
---|
| 944 | { |
---|
| 945 | pDstU[x ] = xClip( (pDstU[x ]<<1) - pSrcU[x ] ); |
---|
| 946 | pDstV[x ] = xClip( (pDstV[x ]<<1) - pSrcV[x ] ); |
---|
| 947 | } |
---|
| 948 | pSrcU += iSrcStride; |
---|
| 949 | pSrcV += iSrcStride; |
---|
| 950 | pDstU += iDstStride; |
---|
| 951 | pDstV += iDstStride; |
---|
| 952 | } |
---|
| 953 | } |
---|
| 954 | |
---|
| 955 | |
---|
| 956 | Pel* TComYuv::getLumaAddr( UInt uiPartUnitIdx ) |
---|
| 957 | { |
---|
| 958 | UInt iBlkX; |
---|
| 959 | UInt iBlkY; |
---|
| 960 | iBlkX = g_auiRasterToPelX[g_auiZscanToRaster[uiPartUnitIdx]]; |
---|
| 961 | iBlkY = g_auiRasterToPelY[g_auiZscanToRaster[uiPartUnitIdx]]; |
---|
| 962 | |
---|
| 963 | return m_apiBufY + iBlkY*getStride() + iBlkX; |
---|
| 964 | } |
---|
| 965 | |
---|
| 966 | Pel* TComYuv::getCbAddr( UInt uiPartUnitIdx ) |
---|
| 967 | { |
---|
| 968 | UInt iBlkX; |
---|
| 969 | UInt iBlkY; |
---|
| 970 | iBlkX = g_auiRasterToPelX[g_auiZscanToRaster[uiPartUnitIdx]] >> 1; |
---|
| 971 | iBlkY = g_auiRasterToPelY[g_auiZscanToRaster[uiPartUnitIdx]] >> 1; |
---|
| 972 | |
---|
| 973 | return m_apiBufU + iBlkY*getCStride() + iBlkX; |
---|
| 974 | } |
---|
| 975 | |
---|
| 976 | Pel* TComYuv::getCrAddr( UInt uiPartUnitIdx ) |
---|
| 977 | { |
---|
| 978 | UInt iBlkX; |
---|
| 979 | UInt iBlkY; |
---|
| 980 | iBlkX = g_auiRasterToPelX[g_auiZscanToRaster[uiPartUnitIdx]] >> 1; |
---|
| 981 | iBlkY = g_auiRasterToPelY[g_auiZscanToRaster[uiPartUnitIdx]] >> 1; |
---|
| 982 | |
---|
| 983 | return m_apiBufV + iBlkY*getCStride() + iBlkX; |
---|
| 984 | } |
---|
| 985 | |
---|
| 986 | Pel* TComYuv::getLumaAddr( UInt iTransUnitIdx, UInt iBlkSize ) |
---|
| 987 | { |
---|
| 988 | UInt uiNumTrInWidth = m_iWidth / iBlkSize; |
---|
| 989 | UInt iBlkX = iTransUnitIdx % uiNumTrInWidth; |
---|
| 990 | UInt iBlkY = iTransUnitIdx / uiNumTrInWidth; |
---|
| 991 | |
---|
| 992 | return m_apiBufY + (iBlkX + iBlkY * getStride()) * iBlkSize; |
---|
| 993 | } |
---|
| 994 | |
---|
| 995 | Pel* TComYuv::getCbAddr( UInt iTransUnitIdx, UInt iBlkSize ) |
---|
| 996 | { |
---|
| 997 | UInt uiNumTrInWidth = m_iCWidth / iBlkSize; |
---|
| 998 | UInt iBlkX = iTransUnitIdx % uiNumTrInWidth; |
---|
| 999 | UInt iBlkY = iTransUnitIdx / uiNumTrInWidth; |
---|
| 1000 | |
---|
| 1001 | return m_apiBufU + (iBlkX + iBlkY * getCStride()) * iBlkSize; |
---|
| 1002 | } |
---|
| 1003 | |
---|
| 1004 | Pel* TComYuv::getCrAddr( UInt iTransUnitIdx, UInt iBlkSize ) |
---|
| 1005 | { |
---|
| 1006 | UInt uiNumTrInWidth = m_iCWidth / iBlkSize; |
---|
| 1007 | UInt iBlkX = iTransUnitIdx % uiNumTrInWidth; |
---|
| 1008 | UInt iBlkY = iTransUnitIdx / uiNumTrInWidth; |
---|
| 1009 | |
---|
| 1010 | return m_apiBufV + (iBlkX + iBlkY * getCStride()) * iBlkSize; |
---|
| 1011 | } |
---|