[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 | |
---|
[21] | 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 | |
---|
[21] | 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 | |
---|
[28] | 389 | #if POZNAN_DBMP |
---|
| 390 | |
---|
| 391 | Void TComYuv::copyPartToPartYuv_DBMP ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY ) |
---|
| 392 | { |
---|
| 393 | copyPartToPartLuma_DBMP (pcYuvDst, uiPartIdx, uiPosX, uiPosY ); |
---|
| 394 | copyPartToPartChroma_DBMP (pcYuvDst, uiPartIdx, uiPosX>>1, uiPosY>>1 ); |
---|
| 395 | } |
---|
| 396 | |
---|
| 397 | Void TComYuv::copyPartToPartLuma_DBMP ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY ) |
---|
| 398 | { |
---|
| 399 | Pel* pSrc = getLumaAddr(uiPartIdx); |
---|
| 400 | Pel* pDst = pcYuvDst->getLumaAddr(uiPartIdx); |
---|
| 401 | if( pSrc == pDst ) |
---|
| 402 | { |
---|
| 403 | //th not a good idea |
---|
| 404 | //th best would be to fix the caller |
---|
| 405 | return ; |
---|
| 406 | } |
---|
| 407 | |
---|
| 408 | UInt iSrcStride = getStride(); |
---|
| 409 | UInt iDstStride = pcYuvDst->getStride(); |
---|
| 410 | |
---|
| 411 | ::memcpy( pDst+uiPosY*iDstStride+uiPosX, pSrc+uiPosY*iSrcStride+uiPosX, sizeof(Pel) ); |
---|
| 412 | } |
---|
| 413 | |
---|
| 414 | Void TComYuv::copyPartToPartChroma_DBMP( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY ) |
---|
| 415 | { |
---|
| 416 | Pel* pSrcU = getCbAddr(uiPartIdx); |
---|
| 417 | Pel* pSrcV = getCrAddr(uiPartIdx); |
---|
| 418 | Pel* pDstU = pcYuvDst->getCbAddr(uiPartIdx); |
---|
| 419 | Pel* pDstV = pcYuvDst->getCrAddr(uiPartIdx); |
---|
| 420 | |
---|
| 421 | if( getCbAddr() == NULL || getCrAddr() == NULL || pcYuvDst->getCbAddr() == NULL || pcYuvDst->getCrAddr() == NULL ) //KUBA CHROMA |
---|
| 422 | { |
---|
| 423 | return ; |
---|
| 424 | } |
---|
| 425 | if( pSrcU == pDstU && pSrcV == pDstV) |
---|
| 426 | { |
---|
| 427 | //th not a good idea |
---|
| 428 | //th best would be to fix the caller |
---|
| 429 | return ; |
---|
| 430 | } |
---|
| 431 | |
---|
| 432 | UInt iSrcStride = getCStride(); |
---|
| 433 | UInt iDstStride = pcYuvDst->getCStride(); |
---|
| 434 | |
---|
| 435 | ::memcpy( pDstU+uiPosY*iDstStride+uiPosX, pSrcU+uiPosY*iSrcStride+uiPosX, sizeof(Pel) ); |
---|
| 436 | ::memcpy( pDstV+uiPosY*iDstStride+uiPosX, pSrcV+uiPosY*iSrcStride+uiPosX, sizeof(Pel) ); |
---|
| 437 | } |
---|
| 438 | |
---|
| 439 | #if DEPTH_MAP_GENERATION |
---|
| 440 | Void TComYuv::copyPartToPartYuvPdm_DBMP ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY, UInt uiSubSampExpX, UInt uiSubSampExpY ) |
---|
| 441 | { |
---|
| 442 | copyPartToPartLumaPdm_DBMP (pcYuvDst, uiPartIdx, uiPosX, uiPosY, uiSubSampExpX, uiSubSampExpY ); |
---|
| 443 | } |
---|
| 444 | |
---|
| 445 | Void TComYuv::copyPartToPartLumaPdm_DBMP ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt uiPosX, UInt uiPosY, UInt uiSubSampExpX, UInt uiSubSampExpY ) |
---|
| 446 | { |
---|
| 447 | UInt uiBlkX = g_auiRasterToPelX[ g_auiZscanToRaster[ uiPartIdx ] ] >> uiSubSampExpX; |
---|
| 448 | UInt uiBlkY = g_auiRasterToPelY[ g_auiZscanToRaster[ uiPartIdx ] ] >> uiSubSampExpY; |
---|
| 449 | Pel* pSrc = getLumaAddr(uiPartIdx); |
---|
| 450 | Pel* pDst = pcYuvDst->getLumaAddr() + uiBlkY * pcYuvDst->getStride() + uiBlkX; |
---|
| 451 | |
---|
| 452 | if( pSrc == pDst ) |
---|
| 453 | { |
---|
| 454 | //th not a good idea |
---|
| 455 | //th best would be to fix the caller |
---|
| 456 | return ; |
---|
| 457 | } |
---|
| 458 | |
---|
| 459 | UInt iSrcStride = getStride(); |
---|
| 460 | UInt iDstStride = pcYuvDst->getStride(); |
---|
| 461 | |
---|
| 462 | ::memcpy( pDst+uiPosY*iDstStride+uiPosX, pSrc+uiPosY*iSrcStride+uiPosX, sizeof(Pel) ); |
---|
| 463 | } |
---|
| 464 | |
---|
| 465 | #endif |
---|
| 466 | |
---|
| 467 | #endif |
---|
| 468 | |
---|
[2] | 469 | Void TComYuv::addClipPartLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
| 470 | { |
---|
| 471 | Int x, y; |
---|
| 472 | |
---|
| 473 | Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiTrUnitIdx); |
---|
| 474 | Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiTrUnitIdx); |
---|
| 475 | Pel* pDst = getLumaAddr( uiTrUnitIdx); |
---|
| 476 | |
---|
| 477 | UInt iSrc0Stride = pcYuvSrc0->getStride(); |
---|
| 478 | UInt iSrc1Stride = pcYuvSrc1->getStride(); |
---|
| 479 | UInt iDstStride = getStride(); |
---|
| 480 | for ( y = uiPartSize-1; y >= 0; y-- ) |
---|
| 481 | { |
---|
| 482 | for ( x = uiPartSize-1; x >= 0; x-- ) |
---|
| 483 | { |
---|
| 484 | pDst[x] = xClip( pSrc0[x] + pSrc1[x] ); |
---|
| 485 | } |
---|
| 486 | pSrc0 += iSrc0Stride; |
---|
| 487 | pSrc1 += iSrc1Stride; |
---|
| 488 | pDst += iDstStride; |
---|
| 489 | } |
---|
| 490 | } |
---|
| 491 | |
---|
| 492 | Void |
---|
| 493 | TComYuv::add( TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract ) |
---|
| 494 | { |
---|
| 495 | addLuma ( pcYuvAdd, iWidth, iHeight, bSubtract ); |
---|
| 496 | addChroma ( pcYuvAdd, iWidth>>1, iHeight>>1, bSubtract ); |
---|
| 497 | } |
---|
| 498 | |
---|
| 499 | Void |
---|
| 500 | TComYuv::addLuma( TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract ) |
---|
| 501 | { |
---|
| 502 | Int iScale = ( bSubtract ? -1 : 1 ); |
---|
| 503 | Int iAddStride = pcYuvAdd->getStride(); |
---|
| 504 | Int iDstStride = getStride(); |
---|
| 505 | Pel* pAddSamples = pcYuvAdd->getLumaAddr(); |
---|
| 506 | Pel* pDstSamples = getLumaAddr(); |
---|
| 507 | for( Int iY = 0; iY < iHeight; iY++, pDstSamples += iDstStride, pAddSamples += iAddStride ) |
---|
| 508 | { |
---|
| 509 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
| 510 | { |
---|
| 511 | pDstSamples[iX] += iScale * pAddSamples[iX]; |
---|
| 512 | } |
---|
| 513 | } |
---|
| 514 | } |
---|
| 515 | |
---|
| 516 | Void |
---|
| 517 | TComYuv::addChroma( TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract ) |
---|
| 518 | { |
---|
| 519 | Int iScale = ( bSubtract ? -1 : 1 ); |
---|
| 520 | Int iAddStride = pcYuvAdd->getCStride(); |
---|
| 521 | Int iDstStride = getCStride(); |
---|
| 522 | Pel* pAddSamplesCb = pcYuvAdd->getCbAddr(); |
---|
| 523 | Pel* pAddSamplesCr = pcYuvAdd->getCrAddr(); |
---|
| 524 | Pel* pDstSamplesCb = getCbAddr(); |
---|
| 525 | Pel* pDstSamplesCr = getCrAddr(); |
---|
| 526 | for( Int iY = 0; iY < iHeight; iY++, pDstSamplesCb += iDstStride, pAddSamplesCb += iAddStride, |
---|
| 527 | pDstSamplesCr += iDstStride, pAddSamplesCr += iAddStride ) |
---|
| 528 | { |
---|
| 529 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
| 530 | { |
---|
| 531 | pDstSamplesCb[iX] += iScale * pAddSamplesCb[iX]; |
---|
| 532 | pDstSamplesCr[iX] += iScale * pAddSamplesCr[iX]; |
---|
| 533 | } |
---|
| 534 | } |
---|
| 535 | } |
---|
| 536 | |
---|
| 537 | Void |
---|
| 538 | TComYuv::clip( Int iWidth, Int iHeight ) |
---|
| 539 | { |
---|
| 540 | clipLuma ( iWidth, iHeight ); |
---|
| 541 | clipChroma ( iWidth>>1, iHeight>>1 ); |
---|
| 542 | } |
---|
| 543 | |
---|
| 544 | Void |
---|
| 545 | TComYuv::clipLuma( Int iWidth, Int iHeight ) |
---|
| 546 | { |
---|
| 547 | Int iStride = getStride(); |
---|
| 548 | Pel* pSamples = getLumaAddr(); |
---|
| 549 | for( Int iY = 0; iY < iHeight; iY++, pSamples += iStride ) |
---|
| 550 | { |
---|
| 551 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
| 552 | { |
---|
| 553 | pSamples[iX] = xClip( pSamples[iX] ); |
---|
| 554 | } |
---|
| 555 | } |
---|
| 556 | } |
---|
| 557 | |
---|
| 558 | Void |
---|
| 559 | TComYuv::clipChroma( Int iWidth, Int iHeight ) |
---|
| 560 | { |
---|
| 561 | Int iStride = getCStride(); |
---|
| 562 | Pel* pSamplesCb = getCbAddr(); |
---|
| 563 | Pel* pSamplesCr = getCrAddr(); |
---|
| 564 | for( Int iY = 0; iY < iHeight; iY++, pSamplesCb += iStride, pSamplesCr += iStride ) |
---|
| 565 | { |
---|
| 566 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
| 567 | { |
---|
| 568 | pSamplesCb[iX] = xClip( pSamplesCb[iX] ); |
---|
| 569 | pSamplesCr[iX] = xClip( pSamplesCr[iX] ); |
---|
| 570 | } |
---|
| 571 | } |
---|
| 572 | } |
---|
| 573 | |
---|
| 574 | |
---|
| 575 | Void TComYuv::addClip( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
| 576 | { |
---|
| 577 | addClipLuma ( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize ); |
---|
| 578 | addClipChroma ( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize>>1 ); |
---|
| 579 | } |
---|
| 580 | |
---|
| 581 | Void TComYuv::addClipLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
| 582 | { |
---|
| 583 | Int x, y; |
---|
| 584 | |
---|
| 585 | Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 586 | Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 587 | Pel* pDst = getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 588 | |
---|
| 589 | UInt iSrc0Stride = pcYuvSrc0->getStride(); |
---|
| 590 | UInt iSrc1Stride = pcYuvSrc1->getStride(); |
---|
| 591 | UInt iDstStride = getStride(); |
---|
| 592 | for ( y = uiPartSize-1; y >= 0; y-- ) |
---|
| 593 | { |
---|
| 594 | for ( x = uiPartSize-1; x >= 0; x-- ) |
---|
| 595 | { |
---|
| 596 | pDst[x] = xClip( pSrc0[x] + pSrc1[x] ); |
---|
| 597 | } |
---|
| 598 | pSrc0 += iSrc0Stride; |
---|
| 599 | pSrc1 += iSrc1Stride; |
---|
| 600 | pDst += iDstStride; |
---|
| 601 | } |
---|
| 602 | } |
---|
| 603 | |
---|
| 604 | Void TComYuv::addClipChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
| 605 | { |
---|
| 606 | Int x, y; |
---|
| 607 | |
---|
| 608 | Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 609 | Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 610 | Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 611 | Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 612 | Pel* pDstU = getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 613 | Pel* pDstV = getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 614 | |
---|
| 615 | UInt iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
| 616 | UInt iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
| 617 | UInt iDstStride = getCStride(); |
---|
| 618 | for ( y = uiPartSize-1; y >= 0; y-- ) |
---|
| 619 | { |
---|
| 620 | for ( x = uiPartSize-1; x >= 0; x-- ) |
---|
| 621 | { |
---|
| 622 | pDstU[x] = xClip( pSrcU0[x] + pSrcU1[x] ); |
---|
| 623 | pDstV[x] = xClip( pSrcV0[x] + pSrcV1[x] ); |
---|
| 624 | } |
---|
| 625 | |
---|
| 626 | pSrcU0 += iSrc0Stride; |
---|
| 627 | pSrcU1 += iSrc1Stride; |
---|
| 628 | pSrcV0 += iSrc0Stride; |
---|
| 629 | pSrcV1 += iSrc1Stride; |
---|
| 630 | pDstU += iDstStride; |
---|
| 631 | pDstV += iDstStride; |
---|
| 632 | } |
---|
| 633 | } |
---|
| 634 | |
---|
| 635 | Void TComYuv::subtract( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
| 636 | { |
---|
| 637 | subtractLuma ( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize ); |
---|
| 638 | subtractChroma( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize>>1 ); |
---|
| 639 | } |
---|
| 640 | |
---|
| 641 | Void TComYuv::subtractLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
| 642 | { |
---|
| 643 | Int x, y; |
---|
| 644 | |
---|
| 645 | Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 646 | Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 647 | Pel* pDst = getLumaAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 648 | |
---|
| 649 | Int iSrc0Stride = pcYuvSrc0->getStride(); |
---|
| 650 | Int iSrc1Stride = pcYuvSrc1->getStride(); |
---|
| 651 | Int iDstStride = getStride(); |
---|
| 652 | for ( y = uiPartSize-1; y >= 0; y-- ) |
---|
| 653 | { |
---|
| 654 | for ( x = uiPartSize-1; x >= 0; x-- ) |
---|
| 655 | { |
---|
| 656 | pDst[x] = pSrc0[x] - pSrc1[x]; |
---|
| 657 | } |
---|
| 658 | pSrc0 += iSrc0Stride; |
---|
| 659 | pSrc1 += iSrc1Stride; |
---|
| 660 | pDst += iDstStride; |
---|
| 661 | } |
---|
| 662 | } |
---|
| 663 | |
---|
| 664 | Void TComYuv::subtractChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) |
---|
| 665 | { |
---|
| 666 | Int x, y; |
---|
| 667 | |
---|
| 668 | Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 669 | Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 670 | Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 671 | Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 672 | Pel* pDstU = getCbAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 673 | Pel* pDstV = getCrAddr( uiTrUnitIdx, uiPartSize ); |
---|
| 674 | |
---|
| 675 | Int iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
| 676 | Int iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
| 677 | Int iDstStride = getCStride(); |
---|
| 678 | for ( y = uiPartSize-1; y >= 0; y-- ) |
---|
| 679 | { |
---|
| 680 | for ( x = uiPartSize-1; x >= 0; x-- ) |
---|
| 681 | { |
---|
| 682 | pDstU[x] = pSrcU0[x] - pSrcU1[x]; |
---|
| 683 | pDstV[x] = pSrcV0[x] - pSrcV1[x]; |
---|
| 684 | } |
---|
| 685 | pSrcU0 += iSrc0Stride; |
---|
| 686 | pSrcU1 += iSrc1Stride; |
---|
| 687 | pSrcV0 += iSrc0Stride; |
---|
| 688 | pSrcV1 += iSrc1Stride; |
---|
| 689 | pDstU += iDstStride; |
---|
| 690 | pDstV += iDstStride; |
---|
| 691 | } |
---|
| 692 | } |
---|
| 693 | |
---|
| 694 | #ifdef ROUNDING_CONTROL_BIPRED |
---|
| 695 | |
---|
| 696 | Void TComYuv::addAvg( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, Bool bRound ) |
---|
| 697 | { |
---|
| 698 | Int x, y; |
---|
| 699 | |
---|
| 700 | Pel* pSrcY0 = pcYuvSrc0->getLumaAddr( iPartUnitIdx ); |
---|
| 701 | Pel* pSrcU0 = pcYuvSrc0->getCbAddr ( iPartUnitIdx ); |
---|
| 702 | Pel* pSrcV0 = pcYuvSrc0->getCrAddr ( iPartUnitIdx ); |
---|
| 703 | |
---|
| 704 | Pel* pSrcY1 = pcYuvSrc1->getLumaAddr( iPartUnitIdx ); |
---|
| 705 | Pel* pSrcU1 = pcYuvSrc1->getCbAddr ( iPartUnitIdx ); |
---|
| 706 | Pel* pSrcV1 = pcYuvSrc1->getCrAddr ( iPartUnitIdx ); |
---|
| 707 | |
---|
| 708 | Pel* pDstY = getLumaAddr( iPartUnitIdx ); |
---|
| 709 | Pel* pDstU = getCbAddr ( iPartUnitIdx ); |
---|
| 710 | Pel* pDstV = getCrAddr ( iPartUnitIdx ); |
---|
| 711 | |
---|
| 712 | UInt iSrc0Stride = pcYuvSrc0->getStride(); |
---|
| 713 | UInt iSrc1Stride = pcYuvSrc1->getStride(); |
---|
| 714 | UInt iDstStride = getStride(); |
---|
| 715 | |
---|
| 716 | #if HIGH_ACCURACY_BI |
---|
| 717 | Int shiftNum = 15 - (g_uiBitDepth + g_uiBitIncrement); |
---|
| 718 | Int offset = (1<<(shiftNum - 1)); |
---|
| 719 | |
---|
| 720 | for ( y = iHeight-1; y >= 0; y-- ) |
---|
| 721 | { |
---|
| 722 | for ( x = iWidth-1; x >= 0; ) |
---|
| 723 | { |
---|
| 724 | // note: luma min width is 4 |
---|
| 725 | pDstY[x] = Clip((pSrcY0[x] + pSrcY1[x] + offset) >> shiftNum ); x--; |
---|
| 726 | pDstY[x] = Clip((pSrcY0[x] + pSrcY1[x] + offset) >> shiftNum); x--; |
---|
| 727 | pDstY[x] = Clip((pSrcY0[x] + pSrcY1[x] + offset) >> shiftNum); x--; |
---|
| 728 | pDstY[x] = Clip((pSrcY0[x] + pSrcY1[x] + offset) >> shiftNum); x--; |
---|
| 729 | } |
---|
| 730 | pSrcY0 += iSrc0Stride; |
---|
| 731 | pSrcY1 += iSrc1Stride; |
---|
| 732 | pDstY += iDstStride; |
---|
| 733 | } |
---|
| 734 | |
---|
| 735 | iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
| 736 | iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
| 737 | iDstStride = getCStride(); |
---|
| 738 | |
---|
| 739 | iWidth >>=1; |
---|
| 740 | iHeight >>=1; |
---|
| 741 | |
---|
| 742 | for ( y = iHeight-1; y >= 0; y-- ) |
---|
| 743 | { |
---|
| 744 | for ( x = iWidth-1; x >= 0; ) |
---|
| 745 | { |
---|
| 746 | // note: chroma min width is 2 |
---|
| 747 | pDstU[x] = Clip((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum); |
---|
| 748 | pDstV[x] = Clip((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum); x--; |
---|
| 749 | pDstU[x] = Clip((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum); |
---|
| 750 | pDstV[x] = Clip((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum); x--; |
---|
| 751 | } |
---|
| 752 | |
---|
| 753 | pSrcU0 += iSrc0Stride; |
---|
| 754 | pSrcU1 += iSrc1Stride; |
---|
| 755 | pSrcV0 += iSrc0Stride; |
---|
| 756 | pSrcV1 += iSrc1Stride; |
---|
| 757 | pDstU += iDstStride; |
---|
| 758 | pDstV += iDstStride; |
---|
| 759 | } |
---|
| 760 | |
---|
| 761 | #else |
---|
| 762 | |
---|
| 763 | for ( y = iHeight-1; y >= 0; y-- ) |
---|
| 764 | { |
---|
| 765 | for ( x = iWidth-1; x >= 0; ) |
---|
| 766 | { |
---|
| 767 | // note: luma min width is 4 |
---|
| 768 | pDstY[x] = (pSrcY0[x] + pSrcY1[x] + bRound) >> 1; x--; |
---|
| 769 | pDstY[x] = (pSrcY0[x] + pSrcY1[x] + bRound) >> 1; x--; |
---|
| 770 | pDstY[x] = (pSrcY0[x] + pSrcY1[x] + bRound) >> 1; x--; |
---|
| 771 | pDstY[x] = (pSrcY0[x] + pSrcY1[x] + bRound) >> 1; x--; |
---|
| 772 | } |
---|
| 773 | pSrcY0 += iSrc0Stride; |
---|
| 774 | pSrcY1 += iSrc1Stride; |
---|
| 775 | pDstY += iDstStride; |
---|
| 776 | } |
---|
| 777 | |
---|
| 778 | iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
| 779 | iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
| 780 | iDstStride = getCStride(); |
---|
| 781 | |
---|
| 782 | iWidth >>=1; |
---|
| 783 | iHeight >>=1; |
---|
| 784 | |
---|
| 785 | for ( y = iHeight-1; y >= 0; y-- ) |
---|
| 786 | { |
---|
| 787 | for ( x = iWidth-1; x >= 0; ) |
---|
| 788 | { |
---|
| 789 | // note: chroma min width is 2 |
---|
| 790 | pDstU[x] = (pSrcU0[x] + pSrcU1[x] + bRound) >> 1; |
---|
| 791 | pDstV[x] = (pSrcV0[x] + pSrcV1[x] + bRound) >> 1; x--; |
---|
| 792 | pDstU[x] = (pSrcU0[x] + pSrcU1[x] + bRound) >> 1; |
---|
| 793 | pDstV[x] = (pSrcV0[x] + pSrcV1[x] + bRound) >> 1; x--; |
---|
| 794 | } |
---|
| 795 | |
---|
| 796 | pSrcU0 += iSrc0Stride; |
---|
| 797 | pSrcU1 += iSrc1Stride; |
---|
| 798 | pSrcV0 += iSrc0Stride; |
---|
| 799 | pSrcV1 += iSrc1Stride; |
---|
| 800 | pDstU += iDstStride; |
---|
| 801 | pDstV += iDstStride; |
---|
| 802 | } |
---|
| 803 | #endif |
---|
| 804 | } |
---|
| 805 | |
---|
| 806 | #endif |
---|
| 807 | |
---|
| 808 | Void TComYuv::addAvg( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight ) |
---|
| 809 | { |
---|
| 810 | Int x, y; |
---|
| 811 | |
---|
| 812 | Pel* pSrcY0 = pcYuvSrc0->getLumaAddr( iPartUnitIdx ); |
---|
| 813 | Pel* pSrcU0 = pcYuvSrc0->getCbAddr ( iPartUnitIdx ); |
---|
| 814 | Pel* pSrcV0 = pcYuvSrc0->getCrAddr ( iPartUnitIdx ); |
---|
| 815 | |
---|
| 816 | Pel* pSrcY1 = pcYuvSrc1->getLumaAddr( iPartUnitIdx ); |
---|
| 817 | Pel* pSrcU1 = pcYuvSrc1->getCbAddr ( iPartUnitIdx ); |
---|
| 818 | Pel* pSrcV1 = pcYuvSrc1->getCrAddr ( iPartUnitIdx ); |
---|
| 819 | |
---|
| 820 | Pel* pDstY = getLumaAddr( iPartUnitIdx ); |
---|
| 821 | Pel* pDstU = getCbAddr ( iPartUnitIdx ); |
---|
| 822 | Pel* pDstV = getCrAddr ( iPartUnitIdx ); |
---|
| 823 | |
---|
| 824 | UInt iSrc0Stride = pcYuvSrc0->getStride(); |
---|
| 825 | UInt iSrc1Stride = pcYuvSrc1->getStride(); |
---|
| 826 | UInt iDstStride = getStride(); |
---|
| 827 | #if HIGH_ACCURACY_BI |
---|
| 828 | Int shiftNum = 15 - (g_uiBitDepth + g_uiBitIncrement); |
---|
| 829 | Int offset = (1<<(shiftNum - 1)); |
---|
| 830 | |
---|
| 831 | for ( y = iHeight-1; y >= 0; y-- ) |
---|
| 832 | { |
---|
| 833 | for ( x = iWidth-1; x >= 0; ) |
---|
| 834 | { |
---|
| 835 | // note: luma min width is 4 |
---|
| 836 | pDstY[x] = Clip((pSrcY0[x] + pSrcY1[x] + offset) >> shiftNum ); x--; |
---|
| 837 | pDstY[x] = Clip((pSrcY0[x] + pSrcY1[x] + offset) >> shiftNum); x--; |
---|
| 838 | pDstY[x] = Clip((pSrcY0[x] + pSrcY1[x] + offset) >> shiftNum); x--; |
---|
| 839 | pDstY[x] = Clip((pSrcY0[x] + pSrcY1[x] + offset) >> shiftNum); x--; |
---|
| 840 | } |
---|
| 841 | pSrcY0 += iSrc0Stride; |
---|
| 842 | pSrcY1 += iSrc1Stride; |
---|
| 843 | pDstY += iDstStride; |
---|
| 844 | } |
---|
| 845 | |
---|
| 846 | iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
| 847 | iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
| 848 | iDstStride = getCStride(); |
---|
| 849 | |
---|
| 850 | iWidth >>=1; |
---|
| 851 | iHeight >>=1; |
---|
| 852 | |
---|
| 853 | for ( y = iHeight-1; y >= 0; y-- ) |
---|
| 854 | { |
---|
| 855 | for ( x = iWidth-1; x >= 0; ) |
---|
| 856 | { |
---|
| 857 | // note: chroma min width is 2 |
---|
| 858 | pDstU[x] = Clip((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum); |
---|
| 859 | pDstV[x] = Clip((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum); x--; |
---|
| 860 | pDstU[x] = Clip((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum); |
---|
| 861 | pDstV[x] = Clip((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum); x--; |
---|
| 862 | } |
---|
| 863 | |
---|
| 864 | pSrcU0 += iSrc0Stride; |
---|
| 865 | pSrcU1 += iSrc1Stride; |
---|
| 866 | pSrcV0 += iSrc0Stride; |
---|
| 867 | pSrcV1 += iSrc1Stride; |
---|
| 868 | pDstU += iDstStride; |
---|
| 869 | pDstV += iDstStride; |
---|
| 870 | } |
---|
| 871 | |
---|
| 872 | #else |
---|
| 873 | for ( y = iHeight-1; y >= 0; y-- ) |
---|
| 874 | { |
---|
| 875 | for ( x = iWidth-1; x >= 0; ) |
---|
| 876 | { |
---|
| 877 | // note: luma min width is 4 |
---|
| 878 | pDstY[x] = (pSrcY0[x] + pSrcY1[x] + 1) >> 1; x--; |
---|
| 879 | pDstY[x] = (pSrcY0[x] + pSrcY1[x] + 1) >> 1; x--; |
---|
| 880 | pDstY[x] = (pSrcY0[x] + pSrcY1[x] + 1) >> 1; x--; |
---|
| 881 | pDstY[x] = (pSrcY0[x] + pSrcY1[x] + 1) >> 1; x--; |
---|
| 882 | } |
---|
| 883 | pSrcY0 += iSrc0Stride; |
---|
| 884 | pSrcY1 += iSrc1Stride; |
---|
| 885 | pDstY += iDstStride; |
---|
| 886 | } |
---|
| 887 | |
---|
| 888 | iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
| 889 | iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
| 890 | iDstStride = getCStride(); |
---|
| 891 | |
---|
| 892 | iWidth >>=1; |
---|
| 893 | iHeight >>=1; |
---|
| 894 | |
---|
| 895 | for ( y = iHeight-1; y >= 0; y-- ) |
---|
| 896 | { |
---|
| 897 | for ( x = iWidth-1; x >= 0; ) |
---|
| 898 | { |
---|
| 899 | // note: chroma min width is 2 |
---|
| 900 | pDstU[x] = (pSrcU0[x] + pSrcU1[x] + 1) >> 1; |
---|
| 901 | pDstV[x] = (pSrcV0[x] + pSrcV1[x] + 1) >> 1; x--; |
---|
| 902 | pDstU[x] = (pSrcU0[x] + pSrcU1[x] + 1) >> 1; |
---|
| 903 | pDstV[x] = (pSrcV0[x] + pSrcV1[x] + 1) >> 1; x--; |
---|
| 904 | } |
---|
| 905 | |
---|
| 906 | pSrcU0 += iSrc0Stride; |
---|
| 907 | pSrcU1 += iSrc1Stride; |
---|
| 908 | pSrcV0 += iSrc0Stride; |
---|
| 909 | pSrcV1 += iSrc1Stride; |
---|
| 910 | pDstU += iDstStride; |
---|
| 911 | pDstV += iDstStride; |
---|
| 912 | } |
---|
| 913 | #endif |
---|
| 914 | } |
---|
| 915 | |
---|
[21] | 916 | #if DEPTH_MAP_GENERATION |
---|
| 917 | Void TComYuv::addAvgPdm( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY ) |
---|
| 918 | { |
---|
| 919 | Int x, y; |
---|
| 920 | |
---|
| 921 | UInt uiBlkX = g_auiRasterToPelX[ g_auiZscanToRaster[ iPartUnitIdx ] ] >> uiSubSampExpX; |
---|
| 922 | UInt uiBlkY = g_auiRasterToPelY[ g_auiZscanToRaster[ iPartUnitIdx ] ] >> uiSubSampExpY; |
---|
| 923 | Pel* pSrcY0 = pcYuvSrc0->getLumaAddr( iPartUnitIdx ); |
---|
| 924 | Pel* pSrcY1 = pcYuvSrc1->getLumaAddr( iPartUnitIdx ); |
---|
| 925 | Pel* pDstY = getLumaAddr() + uiBlkY * getStride() + uiBlkX; |
---|
| 926 | |
---|
| 927 | UInt iSrc0Stride = pcYuvSrc0->getStride(); |
---|
| 928 | UInt iSrc1Stride = pcYuvSrc1->getStride(); |
---|
| 929 | UInt iDstStride = getStride(); |
---|
| 930 | |
---|
| 931 | for ( y = iHeight-1; y >= 0; y-- ) |
---|
| 932 | { |
---|
| 933 | for ( x = iWidth-1; x >= 0; x-- ) |
---|
| 934 | { |
---|
| 935 | pDstY[x] = (pSrcY0[x] + pSrcY1[x] + 1) >> 1; |
---|
| 936 | } |
---|
| 937 | pSrcY0 += iSrc0Stride; |
---|
| 938 | pSrcY1 += iSrc1Stride; |
---|
| 939 | pDstY += iDstStride; |
---|
| 940 | } |
---|
| 941 | } |
---|
| 942 | #endif |
---|
| 943 | |
---|
[28] | 944 | #if POZNAN_DBMP |
---|
[21] | 945 | |
---|
[28] | 946 | #ifdef ROUNDING_CONTROL_BIPRED |
---|
| 947 | |
---|
| 948 | Void TComYuv::addAvg_DBMP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iPosX, UInt iPosY, Bool bRound ) |
---|
| 949 | { |
---|
| 950 | Pel* pSrcY0 = pcYuvSrc0->getLumaAddr( iPartUnitIdx ); |
---|
| 951 | Pel* pSrcU0 = pcYuvSrc0->getCbAddr ( iPartUnitIdx ); |
---|
| 952 | Pel* pSrcV0 = pcYuvSrc0->getCrAddr ( iPartUnitIdx ); |
---|
| 953 | |
---|
| 954 | Pel* pSrcY1 = pcYuvSrc1->getLumaAddr( iPartUnitIdx ); |
---|
| 955 | Pel* pSrcU1 = pcYuvSrc1->getCbAddr ( iPartUnitIdx ); |
---|
| 956 | Pel* pSrcV1 = pcYuvSrc1->getCrAddr ( iPartUnitIdx ); |
---|
| 957 | |
---|
| 958 | Pel* pDstY = getLumaAddr( iPartUnitIdx ); |
---|
| 959 | Pel* pDstU = getCbAddr ( iPartUnitIdx ); |
---|
| 960 | Pel* pDstV = getCrAddr ( iPartUnitIdx ); |
---|
| 961 | |
---|
| 962 | UInt iSrc0Stride = pcYuvSrc0->getStride(); |
---|
| 963 | UInt iSrc1Stride = pcYuvSrc1->getStride(); |
---|
| 964 | UInt iDstStride = getStride(); |
---|
| 965 | |
---|
| 966 | #if HIGH_ACCURACY_BI |
---|
| 967 | Int shiftNum = 15 - (g_uiBitDepth + g_uiBitIncrement); |
---|
| 968 | Int offset = (1<<(shiftNum - 1)); |
---|
| 969 | |
---|
| 970 | //Luma |
---|
| 971 | (pDstY+iPosY*iDstStride)[iPosX] = Clip(((pSrcY0+iPosY*iSrc0Stride)[iPosX] + (pSrcY1+iPosY*iSrc1Stride)[iPosX] + offset) >> shiftNum ); |
---|
| 972 | |
---|
| 973 | iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
| 974 | iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
| 975 | iDstStride = getCStride(); |
---|
| 976 | |
---|
| 977 | //Chroma |
---|
| 978 | (pDstU+(iPosY>>1)*iDstStride)[(iPosX>>1)] = Clip(((pSrcU0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcU1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + offset) >> shiftNum ); |
---|
| 979 | (pDstV+(iPosY>>1)*iDstStride)[(iPosX>>1)] = Clip(((pSrcV0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcV1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + offset) >> shiftNum ); |
---|
| 980 | |
---|
| 981 | #else |
---|
| 982 | |
---|
| 983 | //Luma |
---|
| 984 | (pDstY+iPosY*iDstStride)[iPosX] = ((pSrcY0+iPosY*iSrc0Stride)[iPosX] + (pSrcY1+iPosY*iSrc1Stride)[iPosX] + bRound) >> 1; |
---|
| 985 | |
---|
| 986 | iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
| 987 | iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
| 988 | iDstStride = getCStride(); |
---|
| 989 | |
---|
| 990 | //Chroma |
---|
| 991 | (pDstU+(iPosY>>1)*iDstStride)[(iPosX>>1)] = ((pSrcU0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcU1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + bRound) >> 1; |
---|
| 992 | (pDstV+(iPosY>>1)*iDstStride)[(iPosX>>1)] = ((pSrcV0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcV1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + bRound) >> 1; |
---|
| 993 | #endif |
---|
| 994 | } |
---|
| 995 | |
---|
| 996 | #endif |
---|
| 997 | |
---|
| 998 | Void TComYuv::addAvg_DBMP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iPosX, UInt iPosY ) |
---|
| 999 | { |
---|
| 1000 | Pel* pSrcY0 = pcYuvSrc0->getLumaAddr( iPartUnitIdx ); |
---|
| 1001 | Pel* pSrcU0 = pcYuvSrc0->getCbAddr ( iPartUnitIdx ); |
---|
| 1002 | Pel* pSrcV0 = pcYuvSrc0->getCrAddr ( iPartUnitIdx ); |
---|
| 1003 | |
---|
| 1004 | Pel* pSrcY1 = pcYuvSrc1->getLumaAddr( iPartUnitIdx ); |
---|
| 1005 | Pel* pSrcU1 = pcYuvSrc1->getCbAddr ( iPartUnitIdx ); |
---|
| 1006 | Pel* pSrcV1 = pcYuvSrc1->getCrAddr ( iPartUnitIdx ); |
---|
| 1007 | |
---|
| 1008 | Pel* pDstY = getLumaAddr( iPartUnitIdx ); |
---|
| 1009 | Pel* pDstU = getCbAddr ( iPartUnitIdx ); |
---|
| 1010 | Pel* pDstV = getCrAddr ( iPartUnitIdx ); |
---|
| 1011 | |
---|
| 1012 | UInt iSrc0Stride = pcYuvSrc0->getStride(); |
---|
| 1013 | UInt iSrc1Stride = pcYuvSrc1->getStride(); |
---|
| 1014 | UInt iDstStride = getStride(); |
---|
| 1015 | #if HIGH_ACCURACY_BI |
---|
| 1016 | Int shiftNum = 15 - (g_uiBitDepth + g_uiBitIncrement); |
---|
| 1017 | Int offset = (1<<(shiftNum - 1)); |
---|
| 1018 | |
---|
| 1019 | //Luma |
---|
| 1020 | (pDstY+iPosY*iDstStride)[iPosX] = Clip(((pSrcY0+iPosY*iSrc0Stride)[iPosX] + (pSrcY1+iPosY*iSrc1Stride)[iPosX] + offset) >> shiftNum ); |
---|
| 1021 | |
---|
| 1022 | iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
| 1023 | iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
| 1024 | iDstStride = getCStride(); |
---|
| 1025 | |
---|
| 1026 | //Chroma |
---|
| 1027 | (pDstU+(iPosY>>1)*iDstStride)[(iPosX>>1)] = Clip(((pSrcU0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcU1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + offset) >> shiftNum ); |
---|
| 1028 | (pDstV+(iPosY>>1)*iDstStride)[(iPosX>>1)] = Clip(((pSrcV0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcV1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + offset) >> shiftNum ); |
---|
| 1029 | |
---|
| 1030 | #else |
---|
| 1031 | //Luma |
---|
| 1032 | (pDstY+iPosY*iDstStride)[iPosX] = ((pSrcY0+iPosY*iSrc0Stride)[iPosX] + (pSrcY1+iPosY*iSrc1Stride)[iPosX] + 1) >> 1; |
---|
| 1033 | |
---|
| 1034 | iSrc0Stride = pcYuvSrc0->getCStride(); |
---|
| 1035 | iSrc1Stride = pcYuvSrc1->getCStride(); |
---|
| 1036 | iDstStride = getCStride(); |
---|
| 1037 | |
---|
| 1038 | //Chroma |
---|
| 1039 | (pDstU+(iPosY>>1)*iDstStride)[(iPosX>>1)] = ((pSrcU0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcU1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + 1) >> 1; |
---|
| 1040 | (pDstV+(iPosY>>1)*iDstStride)[(iPosX>>1)] = ((pSrcV0+(iPosY>>1)*iSrc0Stride)[(iPosX>>1)] + (pSrcV1+(iPosY>>1)*iSrc1Stride)[(iPosX>>1)] + 1) >> 1; |
---|
| 1041 | #endif |
---|
| 1042 | } |
---|
| 1043 | |
---|
| 1044 | #if DEPTH_MAP_GENERATION |
---|
| 1045 | Void TComYuv::addAvgPdm_DBMP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iPosX, UInt iPosY, UInt uiSubSampExpX, UInt uiSubSampExpY ) |
---|
| 1046 | { |
---|
| 1047 | UInt uiBlkX = g_auiRasterToPelX[ g_auiZscanToRaster[ iPartUnitIdx ] ] >> uiSubSampExpX; |
---|
| 1048 | UInt uiBlkY = g_auiRasterToPelY[ g_auiZscanToRaster[ iPartUnitIdx ] ] >> uiSubSampExpY; |
---|
| 1049 | Pel* pSrcY0 = pcYuvSrc0->getLumaAddr( iPartUnitIdx ); |
---|
| 1050 | Pel* pSrcY1 = pcYuvSrc1->getLumaAddr( iPartUnitIdx ); |
---|
| 1051 | Pel* pDstY = getLumaAddr() + uiBlkY * getStride() + uiBlkX; |
---|
| 1052 | |
---|
| 1053 | UInt iSrc0Stride = pcYuvSrc0->getStride(); |
---|
| 1054 | UInt iSrc1Stride = pcYuvSrc1->getStride(); |
---|
| 1055 | UInt iDstStride = getStride(); |
---|
| 1056 | |
---|
| 1057 | pDstY[iPosY*iDstStride+iPosX] = (pSrcY0[iPosY*iSrc0Stride+iPosX] + pSrcY1[iPosY*iSrc1Stride+iPosX] + 1) >> 1; |
---|
| 1058 | } |
---|
| 1059 | #endif |
---|
| 1060 | |
---|
| 1061 | #endif |
---|
| 1062 | |
---|
[2] | 1063 | Void TComYuv::removeHighFreq( TComYuv* pcYuvSrc, UInt uiWidht, UInt uiHeight ) |
---|
| 1064 | { |
---|
| 1065 | Int x, y; |
---|
| 1066 | |
---|
| 1067 | Pel* pSrc = pcYuvSrc->getLumaAddr(); |
---|
| 1068 | Pel* pSrcU = pcYuvSrc->getCbAddr(); |
---|
| 1069 | Pel* pSrcV = pcYuvSrc->getCrAddr(); |
---|
| 1070 | |
---|
| 1071 | Pel* pDst = m_apiBufY; |
---|
| 1072 | Pel* pDstU = m_apiBufU; |
---|
| 1073 | Pel* pDstV = m_apiBufV; |
---|
| 1074 | |
---|
| 1075 | Int iSrcStride = pcYuvSrc->getStride(); |
---|
| 1076 | Int iDstStride = getStride(); |
---|
| 1077 | |
---|
| 1078 | for ( y = uiHeight-1; y >= 0; y-- ) |
---|
| 1079 | { |
---|
| 1080 | for ( x = uiWidht-1; x >= 0; x-- ) |
---|
| 1081 | { |
---|
| 1082 | pDst[x ] = xClip( (pDst[x ]<<1) - pSrc[x ] ); |
---|
| 1083 | } |
---|
| 1084 | pSrc += iSrcStride; |
---|
| 1085 | pDst += iDstStride; |
---|
| 1086 | } |
---|
| 1087 | |
---|
| 1088 | iSrcStride = pcYuvSrc->getCStride(); |
---|
| 1089 | iDstStride = getCStride(); |
---|
| 1090 | |
---|
| 1091 | uiHeight >>= 1; |
---|
| 1092 | uiWidht >>= 1; |
---|
| 1093 | |
---|
| 1094 | for ( y = uiHeight-1; y >= 0; y-- ) |
---|
| 1095 | { |
---|
| 1096 | for ( x = uiWidht-1; x >= 0; x-- ) |
---|
| 1097 | { |
---|
| 1098 | pDstU[x ] = xClip( (pDstU[x ]<<1) - pSrcU[x ] ); |
---|
| 1099 | pDstV[x ] = xClip( (pDstV[x ]<<1) - pSrcV[x ] ); |
---|
| 1100 | } |
---|
| 1101 | pSrcU += iSrcStride; |
---|
| 1102 | pSrcV += iSrcStride; |
---|
| 1103 | pDstU += iDstStride; |
---|
| 1104 | pDstV += iDstStride; |
---|
| 1105 | } |
---|
| 1106 | } |
---|
| 1107 | |
---|
| 1108 | Void TComYuv::removeHighFreq( TComYuv* pcYuvSrc, UInt uiPartIdx, UInt uiWidht, UInt uiHeight ) |
---|
| 1109 | { |
---|
| 1110 | Int x, y; |
---|
| 1111 | |
---|
| 1112 | Pel* pSrc = pcYuvSrc->getLumaAddr(uiPartIdx); |
---|
| 1113 | Pel* pSrcU = pcYuvSrc->getCbAddr(uiPartIdx); |
---|
| 1114 | Pel* pSrcV = pcYuvSrc->getCrAddr(uiPartIdx); |
---|
| 1115 | |
---|
| 1116 | Pel* pDst = getLumaAddr(uiPartIdx); |
---|
| 1117 | Pel* pDstU = getCbAddr(uiPartIdx); |
---|
| 1118 | Pel* pDstV = getCrAddr(uiPartIdx); |
---|
| 1119 | |
---|
| 1120 | Int iSrcStride = pcYuvSrc->getStride(); |
---|
| 1121 | Int iDstStride = getStride(); |
---|
| 1122 | |
---|
| 1123 | for ( y = uiHeight-1; y >= 0; y-- ) |
---|
| 1124 | { |
---|
| 1125 | for ( x = uiWidht-1; x >= 0; x-- ) |
---|
| 1126 | { |
---|
| 1127 | pDst[x ] = xClip( (pDst[x ]<<1) - pSrc[x ] ); |
---|
| 1128 | } |
---|
| 1129 | pSrc += iSrcStride; |
---|
| 1130 | pDst += iDstStride; |
---|
| 1131 | } |
---|
| 1132 | |
---|
| 1133 | iSrcStride = pcYuvSrc->getCStride(); |
---|
| 1134 | iDstStride = getCStride(); |
---|
| 1135 | |
---|
| 1136 | uiHeight >>= 1; |
---|
| 1137 | uiWidht >>= 1; |
---|
| 1138 | |
---|
| 1139 | for ( y = uiHeight-1; y >= 0; y-- ) |
---|
| 1140 | { |
---|
| 1141 | for ( x = uiWidht-1; x >= 0; x-- ) |
---|
| 1142 | { |
---|
| 1143 | pDstU[x ] = xClip( (pDstU[x ]<<1) - pSrcU[x ] ); |
---|
| 1144 | pDstV[x ] = xClip( (pDstV[x ]<<1) - pSrcV[x ] ); |
---|
| 1145 | } |
---|
| 1146 | pSrcU += iSrcStride; |
---|
| 1147 | pSrcV += iSrcStride; |
---|
| 1148 | pDstU += iDstStride; |
---|
| 1149 | pDstV += iDstStride; |
---|
| 1150 | } |
---|
| 1151 | } |
---|
| 1152 | |
---|
| 1153 | |
---|
| 1154 | Pel* TComYuv::getLumaAddr( UInt uiPartUnitIdx ) |
---|
| 1155 | { |
---|
| 1156 | UInt iBlkX; |
---|
| 1157 | UInt iBlkY; |
---|
| 1158 | iBlkX = g_auiRasterToPelX[g_auiZscanToRaster[uiPartUnitIdx]]; |
---|
| 1159 | iBlkY = g_auiRasterToPelY[g_auiZscanToRaster[uiPartUnitIdx]]; |
---|
| 1160 | |
---|
| 1161 | return m_apiBufY + iBlkY*getStride() + iBlkX; |
---|
| 1162 | } |
---|
| 1163 | |
---|
| 1164 | Pel* TComYuv::getCbAddr( UInt uiPartUnitIdx ) |
---|
| 1165 | { |
---|
| 1166 | UInt iBlkX; |
---|
| 1167 | UInt iBlkY; |
---|
| 1168 | iBlkX = g_auiRasterToPelX[g_auiZscanToRaster[uiPartUnitIdx]] >> 1; |
---|
| 1169 | iBlkY = g_auiRasterToPelY[g_auiZscanToRaster[uiPartUnitIdx]] >> 1; |
---|
| 1170 | |
---|
| 1171 | return m_apiBufU + iBlkY*getCStride() + iBlkX; |
---|
| 1172 | } |
---|
| 1173 | |
---|
| 1174 | Pel* TComYuv::getCrAddr( UInt uiPartUnitIdx ) |
---|
| 1175 | { |
---|
| 1176 | UInt iBlkX; |
---|
| 1177 | UInt iBlkY; |
---|
| 1178 | iBlkX = g_auiRasterToPelX[g_auiZscanToRaster[uiPartUnitIdx]] >> 1; |
---|
| 1179 | iBlkY = g_auiRasterToPelY[g_auiZscanToRaster[uiPartUnitIdx]] >> 1; |
---|
| 1180 | |
---|
| 1181 | return m_apiBufV + iBlkY*getCStride() + iBlkX; |
---|
| 1182 | } |
---|
| 1183 | |
---|
| 1184 | Pel* TComYuv::getLumaAddr( UInt iTransUnitIdx, UInt iBlkSize ) |
---|
| 1185 | { |
---|
| 1186 | UInt uiNumTrInWidth = m_iWidth / iBlkSize; |
---|
| 1187 | UInt iBlkX = iTransUnitIdx % uiNumTrInWidth; |
---|
| 1188 | UInt iBlkY = iTransUnitIdx / uiNumTrInWidth; |
---|
| 1189 | |
---|
| 1190 | return m_apiBufY + (iBlkX + iBlkY * getStride()) * iBlkSize; |
---|
| 1191 | } |
---|
| 1192 | |
---|
| 1193 | Pel* TComYuv::getCbAddr( UInt iTransUnitIdx, UInt iBlkSize ) |
---|
| 1194 | { |
---|
| 1195 | UInt uiNumTrInWidth = m_iCWidth / iBlkSize; |
---|
| 1196 | UInt iBlkX = iTransUnitIdx % uiNumTrInWidth; |
---|
| 1197 | UInt iBlkY = iTransUnitIdx / uiNumTrInWidth; |
---|
| 1198 | |
---|
| 1199 | return m_apiBufU + (iBlkX + iBlkY * getCStride()) * iBlkSize; |
---|
| 1200 | } |
---|
| 1201 | |
---|
| 1202 | Pel* TComYuv::getCrAddr( UInt iTransUnitIdx, UInt iBlkSize ) |
---|
| 1203 | { |
---|
| 1204 | UInt uiNumTrInWidth = m_iCWidth / iBlkSize; |
---|
| 1205 | UInt iBlkX = iTransUnitIdx % uiNumTrInWidth; |
---|
| 1206 | UInt iBlkY = iTransUnitIdx / uiNumTrInWidth; |
---|
| 1207 | |
---|
| 1208 | return m_apiBufV + (iBlkX + iBlkY * getCStride()) * iBlkSize; |
---|
| 1209 | } |
---|