[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 TComResidualGenerator.cpp |
---|
| 37 | \brief residual picture generator class |
---|
| 38 | */ |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | #include "CommonDef.h" |
---|
| 43 | #include "TComResidualGenerator.h" |
---|
| 44 | |
---|
| 45 | |
---|
[5] | 46 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 47 | |
---|
[5] | 48 | |
---|
[2] | 49 | TComResidualGenerator::TComResidualGenerator() |
---|
| 50 | { |
---|
| 51 | m_bCreated = false; |
---|
| 52 | m_bInit = false; |
---|
| 53 | m_bDecoder = false; |
---|
| 54 | m_pcTrQuant = 0; |
---|
| 55 | m_pcDepthMapGenerator = 0; |
---|
| 56 | m_pcSPSAccess = 0; |
---|
| 57 | m_pcAUPicAccess = 0; |
---|
| 58 | m_uiMaxDepth = 0; |
---|
| 59 | m_uiOrgDepthBitDepth = 0; |
---|
| 60 | m_ppcYuvTmp = 0; |
---|
| 61 | m_ppcYuv = 0; |
---|
| 62 | m_ppcCU = 0; |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | TComResidualGenerator::~TComResidualGenerator() |
---|
| 66 | { |
---|
| 67 | destroy (); |
---|
| 68 | uninit (); |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | Void |
---|
| 72 | TComResidualGenerator::create( Bool bDecoder, UInt uiPicWidth, UInt uiPicHeight, UInt uiMaxCUDepth, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiOrgBitDepth ) |
---|
| 73 | { |
---|
| 74 | destroy(); |
---|
| 75 | m_bDecoder = bDecoder; |
---|
| 76 | m_uiMaxDepth = uiMaxCUDepth; |
---|
| 77 | m_uiOrgDepthBitDepth = uiOrgBitDepth; |
---|
| 78 | m_ppcYuvTmp = new TComYuv* [ NUM_TMP_YUV_BUFFERS ]; |
---|
| 79 | m_ppcYuv = new TComYuv* [ m_uiMaxDepth ]; |
---|
| 80 | m_ppcCU = new TComDataCU* [ m_uiMaxDepth ]; |
---|
| 81 | for( UInt uiIdx = 0; uiIdx < NUM_TMP_YUV_BUFFERS; uiIdx++ ) |
---|
| 82 | { |
---|
| 83 | m_ppcYuvTmp[uiIdx] = new TComYuv; m_ppcYuvTmp[uiIdx]->create( uiMaxCUWidth, uiMaxCUHeight ); |
---|
| 84 | } |
---|
| 85 | for( UInt uiDepth = 0; uiDepth < m_uiMaxDepth; uiDepth++ ) |
---|
| 86 | { |
---|
| 87 | UInt uiNumPart = 1 << ( ( m_uiMaxDepth - uiDepth ) << 1 ); |
---|
| 88 | UInt uiWidth = uiMaxCUWidth >> uiDepth; |
---|
| 89 | UInt uiHeight = uiMaxCUHeight >> uiDepth; |
---|
| 90 | |
---|
[56] | 91 | m_ppcYuv[ uiDepth ] = new TComYuv; m_ppcYuv[ uiDepth ]->create( uiWidth, uiHeight ); |
---|
| 92 | m_ppcCU [ uiDepth ] = new TComDataCU; m_ppcCU [ uiDepth ]->create( uiNumPart, uiWidth, uiHeight, true, uiMaxCUWidth >> (uiMaxCUDepth - 1) ); |
---|
[2] | 93 | } |
---|
| 94 | m_cTmpPic.create( uiPicWidth, uiPicHeight, uiMaxCUWidth, uiMaxCUHeight, uiMaxCUDepth ); |
---|
| 95 | m_bCreated = true; |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | Void |
---|
| 99 | TComResidualGenerator::destroy() |
---|
| 100 | { |
---|
| 101 | if( m_bCreated ) |
---|
| 102 | { |
---|
| 103 | m_bCreated = false; |
---|
| 104 | for( UInt uiIdx = 0; uiIdx < NUM_TMP_YUV_BUFFERS; uiIdx++ ) |
---|
| 105 | { |
---|
| 106 | m_ppcYuvTmp[uiIdx]->destroy(); delete m_ppcYuvTmp[uiIdx]; m_ppcYuvTmp[uiIdx] = 0; |
---|
| 107 | } |
---|
| 108 | for( UInt uiDepth = 0; uiDepth < m_uiMaxDepth; uiDepth++ ) |
---|
| 109 | { |
---|
| 110 | m_ppcYuv[ uiDepth ]->destroy(); delete m_ppcYuv[ uiDepth ]; m_ppcYuv[ uiDepth ] = 0; |
---|
| 111 | m_ppcCU [ uiDepth ]->destroy(); delete m_ppcCU [ uiDepth ]; m_ppcCU [ uiDepth ] = 0; |
---|
| 112 | } |
---|
| 113 | delete [] m_ppcYuvTmp; m_ppcYuvTmp = 0; |
---|
| 114 | delete [] m_ppcYuv; m_ppcYuv = 0; |
---|
| 115 | delete [] m_ppcCU; m_ppcCU = 0; |
---|
| 116 | m_cTmpPic.destroy(); |
---|
| 117 | m_uiMaxDepth = 0; |
---|
| 118 | m_uiOrgDepthBitDepth = 0; |
---|
| 119 | m_bDecoder = false; |
---|
| 120 | } |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | Void |
---|
| 124 | TComResidualGenerator::init( TComTrQuant* pcTrQuant, TComDepthMapGenerator* pcDepthMapGenerator ) |
---|
| 125 | { |
---|
| 126 | AOF( pcTrQuant ); |
---|
| 127 | AOF( pcDepthMapGenerator ); |
---|
| 128 | AOF( pcDepthMapGenerator->getSPSAccess () ); |
---|
| 129 | AOF( pcDepthMapGenerator->getAUPicAccess() ); |
---|
| 130 | uninit(); |
---|
| 131 | m_pcTrQuant = pcTrQuant; |
---|
| 132 | m_pcDepthMapGenerator = pcDepthMapGenerator; |
---|
| 133 | m_pcSPSAccess = pcDepthMapGenerator->getSPSAccess (); |
---|
| 134 | m_pcAUPicAccess = pcDepthMapGenerator->getAUPicAccess(); |
---|
| 135 | m_bInit = true; |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | Void |
---|
| 139 | TComResidualGenerator::uninit() |
---|
| 140 | { |
---|
| 141 | if( m_bInit ) |
---|
| 142 | { |
---|
| 143 | m_bInit = false; |
---|
| 144 | m_pcTrQuant = 0; |
---|
| 145 | m_pcDepthMapGenerator = 0; |
---|
| 146 | m_pcSPSAccess = 0; |
---|
| 147 | m_pcAUPicAccess = 0; |
---|
| 148 | } |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | |
---|
| 152 | |
---|
| 153 | Void |
---|
| 154 | TComResidualGenerator::initViewComponent( TComPic* pcPic ) |
---|
| 155 | { |
---|
| 156 | AOF ( m_bCreated && m_bInit ); |
---|
| 157 | AOF ( pcPic ); |
---|
| 158 | |
---|
| 159 | // set pointer in SPS |
---|
| 160 | pcPic->getSPS()->setResidualGenerator( this ); |
---|
| 161 | ROFVS( pcPic->getSPS()->getMultiviewResPredMode() ); |
---|
| 162 | |
---|
| 163 | #if OUTPUT_RESIDUAL_PICTURES |
---|
| 164 | // dump reconstructed residual picture for first AU |
---|
| 165 | if( pcPic->getPOC() == 0 ) |
---|
| 166 | { |
---|
| 167 | AOF( pcPic->getSPS()->getViewId() ); |
---|
| 168 | UInt uiBaseViewId = pcPic->getSPS()->getViewId() - 1; |
---|
| 169 | TComPic* pcBasePic = m_pcAUPicAccess->getPic( uiBaseViewId ); |
---|
| 170 | AOF( pcBasePic ); |
---|
| 171 | Char acFilenameBase[1024]; |
---|
| 172 | ::sprintf( acFilenameBase, "RecResidual_%s", ( m_bDecoder ? "Dec" : "Enc" ) ); |
---|
| 173 | xDumpResidual( pcBasePic, acFilenameBase ); |
---|
| 174 | } |
---|
| 175 | #endif |
---|
| 176 | } |
---|
| 177 | |
---|
| 178 | |
---|
| 179 | |
---|
| 180 | Void |
---|
| 181 | TComResidualGenerator::setRecResidualPic( TComPic* pcPic ) |
---|
| 182 | { |
---|
| 183 | AOF ( m_bCreated && m_bInit ); |
---|
| 184 | AOF ( pcPic ); |
---|
| 185 | |
---|
| 186 | if( pcPic->getPOC() == 0 ) |
---|
| 187 | { |
---|
| 188 | if( pcPic->getSPS()->getViewId() == 0 || m_pcSPSAccess->getResPrd() != 0 ) |
---|
| 189 | { |
---|
| 190 | // set residual picture |
---|
| 191 | AOT( pcPic->getResidual() ); |
---|
| 192 | if( !pcPic->getResidual() ) |
---|
| 193 | { |
---|
| 194 | pcPic->addResidualBuffer(); |
---|
| 195 | } |
---|
| 196 | xSetRecResidualPic( pcPic ); |
---|
| 197 | } |
---|
| 198 | } |
---|
| 199 | else |
---|
| 200 | { |
---|
| 201 | if( m_pcSPSAccess->getResPrd() != 0 && pcPic->getSPS()->getViewId() < m_pcAUPicAccess->getMaxVId() ) |
---|
| 202 | { |
---|
| 203 | // set residual picture |
---|
| 204 | AOT( pcPic->getResidual() ); |
---|
| 205 | if( !pcPic->getResidual() ) |
---|
| 206 | { |
---|
| 207 | pcPic->addResidualBuffer(); |
---|
| 208 | } |
---|
| 209 | xSetRecResidualPic( pcPic ); |
---|
| 210 | |
---|
| 211 | #if OUTPUT_RESIDUAL_PICTURES |
---|
| 212 | // dump reconstructed residual picture |
---|
| 213 | Char acFilenameBase[1024]; |
---|
| 214 | ::sprintf( acFilenameBase, "RecResidual_%s", ( m_bDecoder ? "Dec" : "Enc" ) ); |
---|
| 215 | xDumpResidual( pcPic, acFilenameBase ); |
---|
| 216 | #endif |
---|
| 217 | } |
---|
| 218 | } |
---|
| 219 | } |
---|
| 220 | |
---|
[100] | 221 | #if QC_MULTI_DIS_CAN |
---|
[2] | 222 | Bool |
---|
[100] | 223 | TComResidualGenerator::getResidualSamples( TComDataCU* pcCU, UInt uiPUIdx, TComYuv* pcYuv, Int iDisp |
---|
| 224 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
| 225 | , Bool bRecon |
---|
| 226 | #endif |
---|
| 227 | ) |
---|
| 228 | #else |
---|
| 229 | Bool |
---|
[77] | 230 | TComResidualGenerator::getResidualSamples( TComDataCU* pcCU, UInt uiPUIdx, TComYuv* pcYuv |
---|
| 231 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
| 232 | , Bool bRecon |
---|
| 233 | #endif |
---|
| 234 | ) |
---|
[100] | 235 | #endif |
---|
[2] | 236 | { |
---|
| 237 | AOF( pcCU ); |
---|
| 238 | UInt uiPartAddr; |
---|
| 239 | Int iBlkWidth, iBlkHeight, iXPos, iYPos; |
---|
| 240 | AOT( uiPUIdx ); |
---|
| 241 | uiPartAddr = 0; |
---|
| 242 | iBlkWidth = pcCU->getWidth ( 0 ); |
---|
| 243 | iBlkHeight = pcCU->getHeight ( 0 ); |
---|
| 244 | pcCU->getPic()->getPicYuvRec()->getTopLeftSamplePos( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr, iXPos, iYPos ); |
---|
[100] | 245 | #if QC_MULTI_DIS_CAN |
---|
| 246 | return getResidualSamples( pcCU->getPic(), (UInt)iXPos, (UInt)iYPos, (UInt)iBlkWidth, (UInt)iBlkHeight, pcYuv, iDisp |
---|
| 247 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
| 248 | , bRecon |
---|
| 249 | #endif |
---|
| 250 | ); |
---|
| 251 | #else |
---|
[77] | 252 | return getResidualSamples( pcCU->getPic(), (UInt)iXPos, (UInt)iYPos, (UInt)iBlkWidth, (UInt)iBlkHeight, pcYuv |
---|
| 253 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
| 254 | , bRecon |
---|
| 255 | #endif |
---|
| 256 | ); |
---|
[100] | 257 | #endif |
---|
[2] | 258 | } |
---|
| 259 | |
---|
[100] | 260 | #if QC_MULTI_DIS_CAN |
---|
[2] | 261 | Bool |
---|
[100] | 262 | TComResidualGenerator::getResidualSamples( TComPic* pcPic, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv, Int iDisp |
---|
| 263 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
| 264 | , Bool bRecon |
---|
| 265 | #endif |
---|
| 266 | ) |
---|
| 267 | #else |
---|
| 268 | Bool |
---|
[77] | 269 | TComResidualGenerator::getResidualSamples( TComPic* pcPic, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv |
---|
| 270 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
| 271 | , Bool bRecon |
---|
| 272 | #endif |
---|
| 273 | ) |
---|
[100] | 274 | #endif |
---|
[2] | 275 | { |
---|
| 276 | UInt uiBaseViewId = m_pcDepthMapGenerator->getBaseViewId( 0 ); |
---|
| 277 | |
---|
| 278 | if( !pcYuv ) |
---|
| 279 | { |
---|
| 280 | pcYuv = m_ppcYuvTmp[1]; |
---|
| 281 | } |
---|
[77] | 282 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
| 283 | UInt uiXPosInRefView = uiXPos , uiYPosInRefView = uiYPos; |
---|
| 284 | #endif |
---|
[100] | 285 | #if QC_MULTI_DIS_CAN |
---|
| 286 | xSetPredResidualBlock( pcPic, uiBaseViewId, uiXPos, uiYPos, uiBlkWidth, uiBlkHeight, pcYuv, iDisp |
---|
| 287 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
| 288 | , &uiXPosInRefView , &uiYPosInRefView , bRecon |
---|
| 289 | #endif |
---|
| 290 | ); |
---|
| 291 | #else |
---|
[77] | 292 | xSetPredResidualBlock( pcPic, uiBaseViewId, uiXPos, uiYPos, uiBlkWidth, uiBlkHeight, pcYuv |
---|
| 293 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
| 294 | , &uiXPosInRefView , &uiYPosInRefView , bRecon |
---|
| 295 | #endif |
---|
| 296 | ); |
---|
[100] | 297 | #endif |
---|
[77] | 298 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
| 299 | return xIsNonZeroByCBF( uiBaseViewId , uiXPosInRefView , uiYPosInRefView , uiBlkWidth , uiBlkHeight ); |
---|
| 300 | #else |
---|
[2] | 301 | return xIsNonZero( pcYuv, uiBlkWidth, uiBlkHeight ); |
---|
[77] | 302 | #endif |
---|
[2] | 303 | } |
---|
| 304 | |
---|
[77] | 305 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
| 306 | Bool TComResidualGenerator::xIsNonZeroByCBF( UInt uiBaseViewId , UInt uiXPos , UInt uiYPos, UInt uiBlkWidth , UInt uiBlkHeight ) |
---|
| 307 | { |
---|
| 308 | TComPic* pcBasePic = m_pcAUPicAccess->getPic( uiBaseViewId ); |
---|
| 309 | const Int nMaxPicX = pcBasePic->getSPS()->getPicWidthInLumaSamples() - 1; |
---|
| 310 | const Int nMaxPicY = pcBasePic->getSPS()->getPicHeightInLumaSamples() - 1; |
---|
| 311 | for( UInt y = 0 ; y < uiBlkHeight ; y +=4 ) |
---|
| 312 | { |
---|
| 313 | for( UInt x = 0 ; x <= uiBlkWidth ; x += 4 ) |
---|
| 314 | { // to cover both the mapped CU and the 1-pixel-right-shifted mapped CU |
---|
| 315 | Int iCuAddr = 0, iAbsZorderIdx = 0; |
---|
| 316 | pcBasePic->getPicYuvRec()->getCUAddrAndPartIdx( Min( uiXPos + x , nMaxPicX ) , Min( uiYPos + y , nMaxPicY ) , iCuAddr , iAbsZorderIdx ); |
---|
| 317 | TComDataCU *pCUInRefView = pcBasePic->getCU( iCuAddr ); |
---|
| 318 | if( pCUInRefView->isIntra( iAbsZorderIdx ) ) |
---|
| 319 | // no inter-view residual pred from a intra CU |
---|
| 320 | continue; |
---|
| 321 | UInt uiTempTrDepth = pCUInRefView->getTransformIdx( iAbsZorderIdx ); |
---|
| 322 | if( pCUInRefView->getCbf( iAbsZorderIdx , TEXT_LUMA , uiTempTrDepth ) |
---|
| 323 | || pCUInRefView->getCbf( iAbsZorderIdx , TEXT_CHROMA_U , uiTempTrDepth ) |
---|
| 324 | || pCUInRefView->getCbf( iAbsZorderIdx , TEXT_CHROMA_V , uiTempTrDepth ) ) |
---|
| 325 | return( true ); |
---|
| 326 | } |
---|
| 327 | } |
---|
[2] | 328 | |
---|
[77] | 329 | return( false ); |
---|
| 330 | } |
---|
| 331 | #endif |
---|
[2] | 332 | |
---|
[77] | 333 | |
---|
| 334 | |
---|
[2] | 335 | Void |
---|
| 336 | TComResidualGenerator::xSetRecResidualPic( TComPic* pcPic ) |
---|
| 337 | { |
---|
| 338 | AOF( pcPic ); |
---|
| 339 | AOF( pcPic->getResidual() ); |
---|
| 340 | for( UInt uiCUAddr = 0; uiCUAddr < pcPic->getPicSym()->getNumberOfCUsInFrame(); uiCUAddr++ ) |
---|
| 341 | { |
---|
| 342 | TComDataCU* pcCU = pcPic->getCU( uiCUAddr ); |
---|
| 343 | xSetRecResidualCU( pcCU, 0, 0 ); |
---|
| 344 | } |
---|
| 345 | pcPic->getResidual()->setBorderExtension( false ); |
---|
| 346 | pcPic->getResidual()->extendPicBorder (); |
---|
| 347 | } |
---|
| 348 | |
---|
| 349 | |
---|
| 350 | Void |
---|
| 351 | TComResidualGenerator::xSetRecResidualCU( TComDataCU* pcCU, UInt uiDepth, UInt uiAbsPartIdx ) |
---|
| 352 | { |
---|
| 353 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
| 354 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
| 355 | UInt uiRPelX = uiLPelX + ( g_uiMaxCUWidth >> uiDepth ) - 1; |
---|
| 356 | UInt uiBPelY = uiTPelY + ( g_uiMaxCUHeight >> uiDepth ) - 1; |
---|
[56] | 357 | Bool bBoundary = ( uiRPelX >= pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() || uiBPelY >= pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ); |
---|
[2] | 358 | Bool bSplit = ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) && uiDepth < ( g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ); |
---|
| 359 | if( bSplit ) |
---|
| 360 | { |
---|
| 361 | UInt uiQNumParts = ( pcCU->getPic()->getNumPartInCU() >> ( uiDepth << 1 ) ) >> 2; |
---|
| 362 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++, uiAbsPartIdx += uiQNumParts ) |
---|
| 363 | { |
---|
| 364 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
| 365 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
[56] | 366 | Bool bInside = ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() && uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ); |
---|
[2] | 367 | if( bInside ) |
---|
| 368 | { |
---|
| 369 | xSetRecResidualCU( pcCU, uiDepth + 1, uiAbsPartIdx ); |
---|
| 370 | } |
---|
| 371 | } |
---|
| 372 | return; |
---|
| 373 | } |
---|
| 374 | |
---|
| 375 | //--- set sub-CU and sub-residual --- |
---|
| 376 | TComDataCU* pcSubCU = m_ppcCU [ uiDepth ]; |
---|
| 377 | TComYuv* pcSubRes = m_ppcYuv[ uiDepth ]; |
---|
| 378 | TComPicYuv* pcPicRes = pcCU->getPic()->getResidual(); |
---|
| 379 | UInt uiCUAddr = pcCU->getAddr(); |
---|
| 380 | pcSubCU->copySubCU( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 381 | |
---|
| 382 | //--- set residual --- |
---|
| 383 | switch( pcSubCU->getPredictionMode( 0 ) ) |
---|
| 384 | { |
---|
| 385 | case MODE_INTRA: |
---|
| 386 | xSetRecResidualIntraCU( pcSubCU, pcSubRes ); |
---|
| 387 | break; |
---|
| 388 | case MODE_SKIP: |
---|
| 389 | case MODE_INTER: |
---|
| 390 | xSetRecResidualInterCU( pcSubCU, pcSubRes ); |
---|
| 391 | break; |
---|
| 392 | default: |
---|
| 393 | AOT( true ); |
---|
| 394 | break; |
---|
| 395 | } |
---|
| 396 | |
---|
| 397 | //--- copy sub-residual --- |
---|
| 398 | pcSubRes->copyToPicYuv( pcPicRes, uiCUAddr, uiAbsPartIdx ); |
---|
| 399 | } |
---|
| 400 | |
---|
| 401 | |
---|
| 402 | Void |
---|
| 403 | TComResidualGenerator::xSetRecResidualIntraCU( TComDataCU* pcCU, TComYuv* pcCUResidual ) |
---|
| 404 | { |
---|
| 405 | //===== set residual to zero for entire CU ===== |
---|
| 406 | xClearResidual( pcCUResidual, 0, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) ); |
---|
| 407 | } |
---|
| 408 | |
---|
| 409 | |
---|
| 410 | Void |
---|
| 411 | TComResidualGenerator::xSetRecResidualInterCU( TComDataCU* pcCU, TComYuv* pcCUResidual ) |
---|
| 412 | { |
---|
| 413 | //===== reconstruct residual from coded transform coefficient levels ===== |
---|
| 414 | xClearResidual( pcCUResidual, 0, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) ); |
---|
| 415 | // luma |
---|
| 416 | UInt uiWidth = pcCU->getWidth ( 0 ); |
---|
| 417 | UInt uiHeight = pcCU->getHeight ( 0 ); |
---|
| 418 | TCoeff* piCoeff = pcCU->getCoeffY (); |
---|
| 419 | Pel* pRes = pcCUResidual->getLumaAddr(); |
---|
| 420 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
[77] | 421 | #if LG_RESTRICTEDRESPRED_M24766 |
---|
| 422 | Int iPUPredResiShift[4]; |
---|
| 423 | #endif |
---|
[2] | 424 | pcCU->convertTransIdx ( 0, pcCU->getTransformIdx( 0 ), uiLumaTrMode, uiChromaTrMode ); |
---|
[56] | 425 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 426 | m_pcTrQuant->setQPforQuant ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
| 427 | #else |
---|
| 428 | m_pcTrQuant->setQPforQuant ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, 0 ); |
---|
| 429 | #endif |
---|
[2] | 430 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pRes, 0, pcCUResidual->getStride(), uiWidth, uiHeight, uiLumaTrMode, 0, piCoeff ); |
---|
| 431 | // chroma Cb |
---|
| 432 | uiWidth >>= 1; |
---|
| 433 | uiHeight >>= 1; |
---|
| 434 | piCoeff = pcCU->getCoeffCb(); |
---|
| 435 | pRes = pcCUResidual->getCbAddr(); |
---|
[56] | 436 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 437 | m_pcTrQuant->setQPforQuant ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset() ); |
---|
| 438 | #else |
---|
| 439 | m_pcTrQuant->setQPforQuant ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC() ); |
---|
| 440 | #endif |
---|
[2] | 441 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pRes, 0, pcCUResidual->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff ); |
---|
| 442 | // chroma Cr |
---|
| 443 | piCoeff = pcCU->getCoeffCr(); |
---|
| 444 | pRes = pcCUResidual->getCrAddr(); |
---|
| 445 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pRes, 0, pcCUResidual->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff ); |
---|
| 446 | |
---|
| 447 | if( pcCU->getResPredFlag( 0 ) ) |
---|
| 448 | { |
---|
| 449 | AOF( pcCU->getResPredAvail( 0 ) ); |
---|
[77] | 450 | Bool bOK = pcCU->getResidualSamples( 0, |
---|
| 451 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
| 452 | true, |
---|
| 453 | #endif |
---|
| 454 | m_ppcYuvTmp[0] ); |
---|
[2] | 455 | AOF( bOK ); |
---|
[77] | 456 | #if LG_RESTRICTEDRESPRED_M24766 |
---|
[100] | 457 | pcCU->getPUResiPredShift(iPUPredResiShift, 0); |
---|
| 458 | pcCUResidual->add(iPUPredResiShift, pcCU->getPartitionSize(0), m_ppcYuvTmp[0], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) ); |
---|
[77] | 459 | #else |
---|
[2] | 460 | pcCUResidual->add( m_ppcYuvTmp[0], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) ); |
---|
[77] | 461 | #endif |
---|
[2] | 462 | } |
---|
| 463 | |
---|
| 464 | //===== clear inter-view predicted parts ===== |
---|
| 465 | for( UInt uiPartIdx = 0; uiPartIdx < pcCU->getNumPartInter(); uiPartIdx++ ) |
---|
| 466 | { |
---|
| 467 | xClearIntViewResidual( pcCU, pcCUResidual, uiPartIdx ); |
---|
| 468 | } |
---|
| 469 | } |
---|
| 470 | |
---|
| 471 | |
---|
| 472 | Void |
---|
| 473 | TComResidualGenerator::xClearIntViewResidual( TComDataCU* pcCU, TComYuv* pcCUResidual, UInt uiPartIdx ) |
---|
| 474 | { |
---|
| 475 | UInt uiCurrViewId = pcCU->getSlice()->getSPS()->getViewId(); |
---|
| 476 | if( uiCurrViewId ) |
---|
| 477 | { |
---|
| 478 | Int iWidth; |
---|
| 479 | Int iHeight; |
---|
| 480 | UInt uiAbsPartIdx; |
---|
| 481 | pcCU->getPartIndexAndSize( uiPartIdx, uiAbsPartIdx, iWidth, iHeight ); |
---|
| 482 | TComCUMvField* aiCurrMvField[2] = { pcCU->getCUMvField( REF_PIC_LIST_0 ), pcCU->getCUMvField( REF_PIC_LIST_1 ) }; |
---|
| 483 | Int aiCurrRefIdx [2] = { aiCurrMvField[0]->getRefIdx( uiAbsPartIdx ), aiCurrMvField[1]->getRefIdx( uiAbsPartIdx ) }; |
---|
| 484 | Bool abCurrIntView[2] = { aiCurrRefIdx[0] >= 0 && pcCU->getSlice()->getRefPic( REF_PIC_LIST_0, aiCurrRefIdx[0] )->getSPS()->getViewId() != uiCurrViewId, |
---|
| 485 | aiCurrRefIdx[1] >= 0 && pcCU->getSlice()->getRefPic( REF_PIC_LIST_1, aiCurrRefIdx[1] )->getSPS()->getViewId() != uiCurrViewId }; |
---|
| 486 | Bool bUsesInterViewPrd = ( abCurrIntView[0] || abCurrIntView[1] ); |
---|
| 487 | if( bUsesInterViewPrd ) |
---|
| 488 | { //===== set resiudal to zero ===== |
---|
| 489 | xClearResidual( pcCUResidual, uiAbsPartIdx, (UInt)iWidth, (UInt)iHeight ); |
---|
| 490 | } |
---|
| 491 | } |
---|
| 492 | } |
---|
| 493 | |
---|
| 494 | |
---|
| 495 | Void |
---|
| 496 | TComResidualGenerator::xClearResidual( TComYuv* pcCUResidual, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight ) |
---|
| 497 | { |
---|
| 498 | // luma |
---|
| 499 | Pel* pSamplesY = pcCUResidual->getLumaAddr( uiAbsPartIdx ); |
---|
| 500 | Int iStrideY = pcCUResidual->getStride (); |
---|
| 501 | for( UInt uiY = 0; uiY < uiHeight; uiY++, pSamplesY += iStrideY ) |
---|
| 502 | { |
---|
| 503 | ::memset( pSamplesY, 0x00, uiWidth * sizeof( Pel ) ); |
---|
| 504 | } |
---|
| 505 | // chroma |
---|
| 506 | uiWidth >>= 1; |
---|
| 507 | uiHeight >>= 1; |
---|
| 508 | Pel* pSamplesU = pcCUResidual->getCbAddr ( uiAbsPartIdx ); |
---|
| 509 | Pel* pSamplesV = pcCUResidual->getCrAddr ( uiAbsPartIdx ); |
---|
| 510 | Int iStrideC = pcCUResidual->getCStride(); |
---|
| 511 | for( UInt uiY = 0; uiY < uiHeight; uiY++, pSamplesU += iStrideC, pSamplesV += iStrideC ) |
---|
| 512 | { |
---|
| 513 | ::memset( pSamplesU, 0x00, uiWidth * sizeof( Pel ) ); |
---|
| 514 | ::memset( pSamplesV, 0x00, uiWidth * sizeof( Pel ) ); |
---|
| 515 | } |
---|
| 516 | } |
---|
| 517 | |
---|
| 518 | |
---|
[100] | 519 | #if QC_MULTI_DIS_CAN |
---|
[2] | 520 | Void |
---|
[100] | 521 | TComResidualGenerator::xSetPredResidualBlock( TComPic* pcPic, UInt uiBaseViewId, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv, Int iDisp |
---|
| 522 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
| 523 | , UInt * puiXPosInRefView , UInt * puiYPosInRefView , Bool bRecon |
---|
| 524 | #endif |
---|
| 525 | ) |
---|
| 526 | #else |
---|
| 527 | Void |
---|
[77] | 528 | TComResidualGenerator::xSetPredResidualBlock( TComPic* pcPic, UInt uiBaseViewId, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv |
---|
| 529 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
| 530 | , UInt * puiXPosInRefView , UInt * puiYPosInRefView , Bool bRecon |
---|
| 531 | #endif |
---|
| 532 | ) |
---|
[100] | 533 | #endif |
---|
[2] | 534 | { |
---|
| 535 | //===== set and check some basic variables ===== |
---|
| 536 | AOF( pcYuv ); |
---|
| 537 | TComPic* pcBasePic = m_pcAUPicAccess->getPic( uiBaseViewId ); |
---|
| 538 | AOF( pcPic ); |
---|
| 539 | AOF( pcBasePic ); |
---|
| 540 | TComPicYuv* pcBaseRes = pcBasePic->getResidual (); |
---|
| 541 | TComPicYuv* pcPdmMap = pcPic ->getPredDepthMap(); |
---|
| 542 | AOF( pcBaseRes ); |
---|
| 543 | AOF( pcPdmMap ); |
---|
| 544 | UInt uiPicWidth = pcBaseRes->getWidth (); |
---|
| 545 | UInt uiPicHeight = pcBaseRes->getHeight(); |
---|
| 546 | AOT( uiXPos + uiBlkWidth > uiPicWidth ); |
---|
| 547 | AOT( uiYPos + uiBlkHeight > uiPicHeight ); |
---|
| 548 | |
---|
| 549 | //===== get disparity ===== |
---|
[100] | 550 | #if QC_MULTI_DIS_CAN |
---|
| 551 | Int iDisparity = iDisp; |
---|
| 552 | #else |
---|
[21] | 553 | Int iMidPosX = Int( uiXPos + ( ( uiBlkWidth - 1 ) >> 1 ) ) >> m_pcDepthMapGenerator->getSubSampExpX(); |
---|
| 554 | Int iMidPosY = Int( uiYPos + ( ( uiBlkHeight - 1 ) >> 1 ) ) >> m_pcDepthMapGenerator->getSubSampExpY(); |
---|
[2] | 555 | Int iDisparity = m_pcDepthMapGenerator->getDisparity( pcPic, iMidPosX, iMidPosY, uiBaseViewId ); |
---|
[100] | 556 | #endif |
---|
[2] | 557 | //===== compensate luma ===== |
---|
| 558 | Int iYWidth = Int( uiBlkWidth ); |
---|
| 559 | Int iYHeight = Int( uiBlkHeight ); |
---|
| 560 | Int iYWeight1 = ( iDisparity & 3 ); |
---|
| 561 | Int iYWeight0 = 4 - iYWeight1; |
---|
| 562 | Int iYRefPosX0 = Int( uiXPos ) + ( iDisparity >> 2 ); |
---|
| 563 | Int iYRefPosX1 = iYRefPosX0 + 1; |
---|
| 564 | Int iYMaxPosX = Int( uiPicWidth ) - 1; |
---|
| 565 | Int iSrcStrideY = pcBaseRes->getStride (); |
---|
| 566 | Int iDesStrideY = pcYuv ->getStride (); |
---|
| 567 | Pel* pSrcSamplesY= pcBaseRes->getLumaAddr ( 0 ) + uiYPos * iSrcStrideY; |
---|
| 568 | Pel* pDesSamplesY= pcYuv ->getLumaAddr (); |
---|
[77] | 569 | |
---|
| 570 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
| 571 | if( puiXPosInRefView != NULL ) |
---|
| 572 | *puiXPosInRefView = Max( 0, Min( iYMaxPosX, iYRefPosX0 ) ); |
---|
| 573 | if( puiYPosInRefView != NULL ) |
---|
| 574 | *puiYPosInRefView = uiYPos; |
---|
| 575 | if( bRecon == false ) |
---|
| 576 | return; |
---|
| 577 | #endif |
---|
| 578 | |
---|
[2] | 579 | for( Int iY = 0; iY < iYHeight; iY++, pSrcSamplesY += iSrcStrideY, pDesSamplesY += iDesStrideY ) |
---|
| 580 | { |
---|
| 581 | for( Int iX = 0; iX < iYWidth; iX++ ) |
---|
| 582 | { |
---|
| 583 | Int iXPic0 = Max( 0, Min( iYMaxPosX, iYRefPosX0 + iX ) ); |
---|
| 584 | Int iXPic1 = Max( 0, Min( iYMaxPosX, iYRefPosX1 + iX ) ); |
---|
| 585 | pDesSamplesY[iX] = ( iYWeight0 * pSrcSamplesY[iXPic0] + iYWeight1 * pSrcSamplesY[iXPic1] + 2 ) >> 2; |
---|
| 586 | } |
---|
| 587 | } |
---|
| 588 | |
---|
| 589 | //===== compensate chroma ===== |
---|
| 590 | Int iCWidth = Int( uiBlkWidth >> 1 ); |
---|
| 591 | Int iCHeight = Int( uiBlkHeight >> 1 ); |
---|
| 592 | Int iCWeight1 = ( iDisparity & 7 ); |
---|
| 593 | Int iCWeight0 = 8 - iCWeight1; |
---|
| 594 | Int iCRefPosX0 = Int( uiXPos >> 1 ) + ( iDisparity >> 3 ); |
---|
| 595 | Int iCRefPosX1 = iCRefPosX0 + 1; |
---|
| 596 | Int iCMaxPosX = Int( uiPicWidth >> 1 ) - 1; |
---|
| 597 | Int iSrcStrideC = pcBaseRes->getCStride(); |
---|
| 598 | Int iDesStrideC = pcYuv ->getCStride(); |
---|
| 599 | Pel* pSrcSamplesU= pcBaseRes->getCbAddr ( 0 ) + ( uiYPos >> 1 ) * iSrcStrideC; |
---|
| 600 | Pel* pSrcSamplesV= pcBaseRes->getCrAddr ( 0 ) + ( uiYPos >> 1 ) * iSrcStrideC; |
---|
| 601 | Pel* pDesSamplesU= pcYuv ->getCbAddr (); |
---|
| 602 | Pel* pDesSamplesV= pcYuv ->getCrAddr (); |
---|
| 603 | for( Int iY = 0; iY < iCHeight; iY++, pSrcSamplesU += iSrcStrideC, pDesSamplesU += iDesStrideC, |
---|
| 604 | pSrcSamplesV += iSrcStrideC, pDesSamplesV += iDesStrideC ) |
---|
| 605 | { |
---|
| 606 | for( Int iX = 0; iX < iCWidth; iX++ ) |
---|
| 607 | { |
---|
| 608 | Int iXPic0 = Max( 0, Min( iCMaxPosX, iCRefPosX0 + iX ) ); |
---|
| 609 | Int iXPic1 = Max( 0, Min( iCMaxPosX, iCRefPosX1 + iX ) ); |
---|
| 610 | pDesSamplesU[iX] = ( iCWeight0 * pSrcSamplesU[iXPic0] + iCWeight1 * pSrcSamplesU[iXPic1] + 4 ) >> 3; |
---|
| 611 | pDesSamplesV[iX] = ( iCWeight0 * pSrcSamplesV[iXPic0] + iCWeight1 * pSrcSamplesV[iXPic1] + 4 ) >> 3; |
---|
| 612 | } |
---|
| 613 | } |
---|
| 614 | } |
---|
| 615 | |
---|
| 616 | |
---|
| 617 | Bool |
---|
| 618 | TComResidualGenerator::xIsNonZero( TComYuv* pcYuv, UInt uiBlkWidth, UInt uiBlkHeight ) |
---|
| 619 | { |
---|
| 620 | AOF( pcYuv ); |
---|
| 621 | //===== check luma ===== |
---|
| 622 | Int iYWidth = Int( uiBlkWidth ); |
---|
| 623 | Int iYHeight = Int( uiBlkHeight ); |
---|
| 624 | Int iStrideY = pcYuv->getStride (); |
---|
| 625 | Pel* pSamplesY = pcYuv->getLumaAddr (); |
---|
| 626 | for( Int iY = 0; iY < iYHeight; iY++, pSamplesY += iStrideY ) |
---|
| 627 | { |
---|
| 628 | for( Int iX = 0; iX < iYWidth; iX++ ) |
---|
| 629 | { |
---|
| 630 | ROTRS( pSamplesY[iX], true ); |
---|
| 631 | } |
---|
| 632 | } |
---|
| 633 | //===== compensate chroma ===== |
---|
| 634 | Int iCWidth = Int( uiBlkWidth >> 1 ); |
---|
| 635 | Int iCHeight = Int( uiBlkHeight >> 1 ); |
---|
| 636 | Int iStrideC = pcYuv->getCStride(); |
---|
| 637 | Pel* pSamplesU = pcYuv->getCbAddr (); |
---|
| 638 | Pel* pSamplesV = pcYuv->getCrAddr (); |
---|
| 639 | for( Int iY = 0; iY < iCHeight; iY++, pSamplesU += iStrideC, pSamplesV += iStrideC ) |
---|
| 640 | { |
---|
| 641 | for( Int iX = 0; iX < iCWidth; iX++ ) |
---|
| 642 | { |
---|
| 643 | ROTRS( pSamplesU[iX], true ); |
---|
| 644 | ROTRS( pSamplesV[iX], true ); |
---|
| 645 | } |
---|
| 646 | } |
---|
| 647 | return false; |
---|
| 648 | } |
---|
| 649 | |
---|
| 650 | |
---|
| 651 | |
---|
| 652 | Void |
---|
| 653 | TComResidualGenerator::xDumpResidual( TComPic* pcPic, char* pFilenameBase ) |
---|
| 654 | { |
---|
| 655 | AOF( m_bCreated && m_bInit ); |
---|
| 656 | AOF( pcPic ); |
---|
| 657 | AOF( pFilenameBase ); |
---|
| 658 | AOF( m_uiOrgDepthBitDepth == 8 + g_uiBitIncrement ); |
---|
| 659 | |
---|
| 660 | // convert to output format (just clip high absolute values, since they are very unlikely) |
---|
| 661 | Int iMin = 0; |
---|
| 662 | Int iMax = ( 1 << m_uiOrgDepthBitDepth ) - 1; |
---|
| 663 | Int iMid = ( 1 << m_uiOrgDepthBitDepth ) >> 1; |
---|
| 664 | UInt uiViewId = pcPic ->getSPS ()->getViewId(); |
---|
| 665 | TComPicYuv* pcPicYuv = pcPic ->getResidual (); |
---|
| 666 | // luma |
---|
| 667 | Int iWidth = pcPicYuv->getWidth (); |
---|
| 668 | Int iHeight = pcPicYuv->getHeight (); |
---|
| 669 | Int iSrcStride = pcPicYuv->getStride (); |
---|
| 670 | Int iDstStride = m_cTmpPic.getStride (); |
---|
| 671 | Pel* pSrcSamples = pcPicYuv->getLumaAddr ( 0 ); |
---|
| 672 | Pel* pDstSamples = m_cTmpPic.getLumaAddr ( 0 ); |
---|
| 673 | AOF( m_cTmpPic.getWidth () == iWidth ); |
---|
| 674 | AOF( m_cTmpPic.getHeight() == iHeight ); |
---|
| 675 | for( Int iY = 0; iY < iHeight; iY++, pSrcSamples += iSrcStride, pDstSamples += iDstStride ) |
---|
| 676 | { |
---|
| 677 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
| 678 | { |
---|
| 679 | pDstSamples[ iX ] = Max( iMin, Min( iMax, iMid + pSrcSamples[ iX ] ) ); |
---|
| 680 | } |
---|
| 681 | } |
---|
| 682 | // chroma |
---|
| 683 | iWidth >>= 1; |
---|
| 684 | iHeight >>= 1; |
---|
| 685 | iSrcStride = pcPicYuv->getCStride(); |
---|
| 686 | iDstStride = m_cTmpPic.getCStride(); |
---|
| 687 | Pel* pSrcCb = pcPicYuv->getCbAddr ( 0 ); |
---|
| 688 | Pel* pSrcCr = pcPicYuv->getCrAddr ( 0 ); |
---|
| 689 | Pel* pDstCb = m_cTmpPic.getCbAddr ( 0 ); |
---|
| 690 | Pel* pDstCr = m_cTmpPic.getCrAddr ( 0 ); |
---|
| 691 | for( Int iY = 0; iY < iHeight; iY++, pSrcCb += iSrcStride, pSrcCr += iSrcStride, pDstCb += iDstStride, pDstCr += iDstStride ) |
---|
| 692 | { |
---|
| 693 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
| 694 | { |
---|
| 695 | pDstCb[ iX ] = Max( iMin, Min( iMax, iMid + pSrcCb[ iX ] ) ); |
---|
| 696 | pDstCr[ iX ] = Max( iMin, Min( iMax, iMid + pSrcCr[ iX ] ) ); |
---|
| 697 | } |
---|
| 698 | } |
---|
| 699 | |
---|
| 700 | // output |
---|
| 701 | Char acFilename[1024]; |
---|
| 702 | ::sprintf ( acFilename, "%s_V%d.yuv", pFilenameBase, uiViewId ); |
---|
| 703 | m_cTmpPic.dump( acFilename, ( pcPic->getPOC() != 0 ) ); |
---|
| 704 | } |
---|
| 705 | |
---|
| 706 | |
---|
[5] | 707 | #endif // HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 708 | |
---|