[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 | |
---|
[296] | 46 | #if H3D_IVRP |
---|
[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 | |
---|
[296] | 186 | #if MTK_MDIVRP_C0138 |
---|
| 187 | if (pcPic->getSPS()->getViewId() != 0) |
---|
| 188 | { |
---|
| 189 | return; |
---|
| 190 | } |
---|
| 191 | #endif |
---|
| 192 | |
---|
[2] | 193 | if( pcPic->getPOC() == 0 ) |
---|
| 194 | { |
---|
| 195 | if( pcPic->getSPS()->getViewId() == 0 || m_pcSPSAccess->getResPrd() != 0 ) |
---|
| 196 | { |
---|
| 197 | // set residual picture |
---|
| 198 | AOT( pcPic->getResidual() ); |
---|
| 199 | if( !pcPic->getResidual() ) |
---|
| 200 | { |
---|
| 201 | pcPic->addResidualBuffer(); |
---|
| 202 | } |
---|
| 203 | xSetRecResidualPic( pcPic ); |
---|
| 204 | } |
---|
| 205 | } |
---|
| 206 | else |
---|
| 207 | { |
---|
| 208 | if( m_pcSPSAccess->getResPrd() != 0 && pcPic->getSPS()->getViewId() < m_pcAUPicAccess->getMaxVId() ) |
---|
| 209 | { |
---|
| 210 | // set residual picture |
---|
| 211 | AOT( pcPic->getResidual() ); |
---|
| 212 | if( !pcPic->getResidual() ) |
---|
| 213 | { |
---|
| 214 | pcPic->addResidualBuffer(); |
---|
| 215 | } |
---|
| 216 | xSetRecResidualPic( pcPic ); |
---|
| 217 | |
---|
| 218 | #if OUTPUT_RESIDUAL_PICTURES |
---|
| 219 | // dump reconstructed residual picture |
---|
| 220 | Char acFilenameBase[1024]; |
---|
| 221 | ::sprintf( acFilenameBase, "RecResidual_%s", ( m_bDecoder ? "Dec" : "Enc" ) ); |
---|
| 222 | xDumpResidual( pcPic, acFilenameBase ); |
---|
| 223 | #endif |
---|
| 224 | } |
---|
| 225 | } |
---|
| 226 | } |
---|
| 227 | |
---|
[296] | 228 | #if H3D_NBDV |
---|
| 229 | #if MTK_RELEASE_DV_CONSTRAINT_C0129 |
---|
[2] | 230 | Bool |
---|
[296] | 231 | TComResidualGenerator::getResidualSamples( TComDataCU* pcCU, UInt uiPUIdx, TComYuv* pcYuv, TComMv iDisp, Bool bRecon ) |
---|
| 232 | #else |
---|
| 233 | Bool |
---|
| 234 | TComResidualGenerator::getResidualSamples( TComDataCU* pcCU, UInt uiPUIdx, TComYuv* pcYuv, Int iDisp, Bool bRecon ) |
---|
[100] | 235 | #endif |
---|
| 236 | #else |
---|
| 237 | Bool |
---|
[296] | 238 | TComResidualGenerator::getResidualSamples( TComDataCU* pcCU, UInt uiPUIdx, TComYuv* pcYuv, Bool bRecon ) |
---|
| 239 | #endif //H3D_NBDV |
---|
[2] | 240 | { |
---|
| 241 | AOF( pcCU ); |
---|
| 242 | UInt uiPartAddr; |
---|
| 243 | Int iBlkWidth, iBlkHeight, iXPos, iYPos; |
---|
| 244 | AOT( uiPUIdx ); |
---|
| 245 | uiPartAddr = 0; |
---|
| 246 | iBlkWidth = pcCU->getWidth ( 0 ); |
---|
| 247 | iBlkHeight = pcCU->getHeight ( 0 ); |
---|
| 248 | pcCU->getPic()->getPicYuvRec()->getTopLeftSamplePos( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr, iXPos, iYPos ); |
---|
[296] | 249 | #if H3D_NBDV |
---|
| 250 | #if MTK_RELEASE_DV_CONSTRAINT_C0129 |
---|
| 251 | return getResidualSamples( pcCU->getPic(), (UInt)iXPos, (UInt)iYPos, (UInt)iBlkWidth, (UInt)iBlkHeight, pcYuv, iDisp, bRecon); |
---|
| 252 | #else |
---|
| 253 | return getResidualSamples( pcCU->getPic(), (UInt)iXPos, (UInt)iYPos, (UInt)iBlkWidth, (UInt)iBlkHeight, pcYuv, iDisp, bRecon); |
---|
[100] | 254 | #endif |
---|
| 255 | #else |
---|
[296] | 256 | return getResidualSamples( pcCU->getPic(), (UInt)iXPos, (UInt)iYPos, (UInt)iBlkWidth, (UInt)iBlkHeight, pcYuv, bRecon); |
---|
| 257 | #endif // H3D_NBDV |
---|
[2] | 258 | } |
---|
| 259 | |
---|
[296] | 260 | #if H3D_NBDV |
---|
| 261 | #if MTK_RELEASE_DV_CONSTRAINT_C0129 |
---|
[2] | 262 | Bool |
---|
[296] | 263 | TComResidualGenerator::getResidualSamples( TComPic* pcPic, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv, TComMv iDisp, Bool bRecon) |
---|
| 264 | #else |
---|
| 265 | Bool |
---|
| 266 | TComResidualGenerator::getResidualSamples( TComPic* pcPic, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv, Int iDisp, Bool bRecon) |
---|
[100] | 267 | #endif |
---|
| 268 | #else |
---|
| 269 | Bool |
---|
[296] | 270 | TComResidualGenerator::getResidualSamples( TComPic* pcPic, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv, Bool bRecon) |
---|
[77] | 271 | #endif |
---|
[2] | 272 | { |
---|
[296] | 273 | #if MTK_C0138_FIXED |
---|
| 274 | UInt uiBaseViewId = 0; |
---|
| 275 | #else |
---|
[2] | 276 | UInt uiBaseViewId = m_pcDepthMapGenerator->getBaseViewId( 0 ); |
---|
[296] | 277 | #endif |
---|
[2] | 278 | if( !pcYuv ) |
---|
| 279 | { |
---|
| 280 | pcYuv = m_ppcYuvTmp[1]; |
---|
| 281 | } |
---|
[77] | 282 | UInt uiXPosInRefView = uiXPos , uiYPosInRefView = uiYPos; |
---|
[296] | 283 | #if H3D_NBDV |
---|
| 284 | #if MTK_RELEASE_DV_CONSTRAINT_C0129 |
---|
| 285 | xSetPredResidualBlock( pcPic, uiBaseViewId, uiXPos, uiYPos, uiBlkWidth, uiBlkHeight, pcYuv, iDisp, &uiXPosInRefView , &uiYPosInRefView , bRecon ); |
---|
| 286 | #else |
---|
| 287 | xSetPredResidualBlock( pcPic, uiBaseViewId, uiXPos, uiYPos, uiBlkWidth, uiBlkHeight, pcYuv, iDisp, &uiXPosInRefView , &uiYPosInRefView , bRecon ); |
---|
[77] | 288 | #endif |
---|
[100] | 289 | #else |
---|
[296] | 290 | xSetPredResidualBlock( pcPic, uiBaseViewId, uiXPos, uiYPos, uiBlkWidth, uiBlkHeight, pcYuv, &uiXPosInRefView , &uiYPosInRefView , bRecon ); |
---|
[77] | 291 | #endif |
---|
[296] | 292 | #if MTK_MDIVRP_C0138 |
---|
| 293 | return true; |
---|
| 294 | #else |
---|
[77] | 295 | return xIsNonZeroByCBF( uiBaseViewId , uiXPosInRefView , uiYPosInRefView , uiBlkWidth , uiBlkHeight ); |
---|
| 296 | #endif |
---|
[2] | 297 | } |
---|
| 298 | |
---|
[77] | 299 | Bool TComResidualGenerator::xIsNonZeroByCBF( UInt uiBaseViewId , UInt uiXPos , UInt uiYPos, UInt uiBlkWidth , UInt uiBlkHeight ) |
---|
| 300 | { |
---|
| 301 | TComPic* pcBasePic = m_pcAUPicAccess->getPic( uiBaseViewId ); |
---|
| 302 | const Int nMaxPicX = pcBasePic->getSPS()->getPicWidthInLumaSamples() - 1; |
---|
| 303 | const Int nMaxPicY = pcBasePic->getSPS()->getPicHeightInLumaSamples() - 1; |
---|
| 304 | for( UInt y = 0 ; y < uiBlkHeight ; y +=4 ) |
---|
| 305 | { |
---|
| 306 | for( UInt x = 0 ; x <= uiBlkWidth ; x += 4 ) |
---|
| 307 | { // to cover both the mapped CU and the 1-pixel-right-shifted mapped CU |
---|
| 308 | Int iCuAddr = 0, iAbsZorderIdx = 0; |
---|
| 309 | pcBasePic->getPicYuvRec()->getCUAddrAndPartIdx( Min( uiXPos + x , nMaxPicX ) , Min( uiYPos + y , nMaxPicY ) , iCuAddr , iAbsZorderIdx ); |
---|
| 310 | TComDataCU *pCUInRefView = pcBasePic->getCU( iCuAddr ); |
---|
| 311 | if( pCUInRefView->isIntra( iAbsZorderIdx ) ) |
---|
| 312 | // no inter-view residual pred from a intra CU |
---|
| 313 | continue; |
---|
| 314 | UInt uiTempTrDepth = pCUInRefView->getTransformIdx( iAbsZorderIdx ); |
---|
| 315 | if( pCUInRefView->getCbf( iAbsZorderIdx , TEXT_LUMA , uiTempTrDepth ) |
---|
| 316 | || pCUInRefView->getCbf( iAbsZorderIdx , TEXT_CHROMA_U , uiTempTrDepth ) |
---|
| 317 | || pCUInRefView->getCbf( iAbsZorderIdx , TEXT_CHROMA_V , uiTempTrDepth ) ) |
---|
| 318 | return( true ); |
---|
| 319 | } |
---|
| 320 | } |
---|
[2] | 321 | |
---|
[77] | 322 | return( false ); |
---|
| 323 | } |
---|
[2] | 324 | |
---|
[77] | 325 | |
---|
| 326 | |
---|
[2] | 327 | Void |
---|
| 328 | TComResidualGenerator::xSetRecResidualPic( TComPic* pcPic ) |
---|
| 329 | { |
---|
| 330 | AOF( pcPic ); |
---|
| 331 | AOF( pcPic->getResidual() ); |
---|
| 332 | for( UInt uiCUAddr = 0; uiCUAddr < pcPic->getPicSym()->getNumberOfCUsInFrame(); uiCUAddr++ ) |
---|
| 333 | { |
---|
| 334 | TComDataCU* pcCU = pcPic->getCU( uiCUAddr ); |
---|
| 335 | xSetRecResidualCU( pcCU, 0, 0 ); |
---|
| 336 | } |
---|
| 337 | pcPic->getResidual()->setBorderExtension( false ); |
---|
| 338 | pcPic->getResidual()->extendPicBorder (); |
---|
| 339 | } |
---|
| 340 | |
---|
| 341 | |
---|
| 342 | Void |
---|
| 343 | TComResidualGenerator::xSetRecResidualCU( TComDataCU* pcCU, UInt uiDepth, UInt uiAbsPartIdx ) |
---|
| 344 | { |
---|
| 345 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
| 346 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
| 347 | UInt uiRPelX = uiLPelX + ( g_uiMaxCUWidth >> uiDepth ) - 1; |
---|
| 348 | UInt uiBPelY = uiTPelY + ( g_uiMaxCUHeight >> uiDepth ) - 1; |
---|
[56] | 349 | Bool bBoundary = ( uiRPelX >= pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() || uiBPelY >= pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ); |
---|
[2] | 350 | Bool bSplit = ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) && uiDepth < ( g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ); |
---|
| 351 | if( bSplit ) |
---|
| 352 | { |
---|
| 353 | UInt uiQNumParts = ( pcCU->getPic()->getNumPartInCU() >> ( uiDepth << 1 ) ) >> 2; |
---|
| 354 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++, uiAbsPartIdx += uiQNumParts ) |
---|
| 355 | { |
---|
| 356 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
| 357 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ]; |
---|
[56] | 358 | Bool bInside = ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() && uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ); |
---|
[2] | 359 | if( bInside ) |
---|
| 360 | { |
---|
| 361 | xSetRecResidualCU( pcCU, uiDepth + 1, uiAbsPartIdx ); |
---|
| 362 | } |
---|
| 363 | } |
---|
| 364 | return; |
---|
| 365 | } |
---|
| 366 | |
---|
| 367 | //--- set sub-CU and sub-residual --- |
---|
| 368 | TComDataCU* pcSubCU = m_ppcCU [ uiDepth ]; |
---|
| 369 | TComYuv* pcSubRes = m_ppcYuv[ uiDepth ]; |
---|
| 370 | TComPicYuv* pcPicRes = pcCU->getPic()->getResidual(); |
---|
| 371 | UInt uiCUAddr = pcCU->getAddr(); |
---|
| 372 | pcSubCU->copySubCU( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 373 | |
---|
| 374 | //--- set residual --- |
---|
| 375 | switch( pcSubCU->getPredictionMode( 0 ) ) |
---|
| 376 | { |
---|
| 377 | case MODE_INTRA: |
---|
| 378 | xSetRecResidualIntraCU( pcSubCU, pcSubRes ); |
---|
| 379 | break; |
---|
| 380 | case MODE_SKIP: |
---|
| 381 | case MODE_INTER: |
---|
| 382 | xSetRecResidualInterCU( pcSubCU, pcSubRes ); |
---|
| 383 | break; |
---|
| 384 | default: |
---|
| 385 | AOT( true ); |
---|
| 386 | break; |
---|
| 387 | } |
---|
| 388 | |
---|
| 389 | //--- copy sub-residual --- |
---|
| 390 | pcSubRes->copyToPicYuv( pcPicRes, uiCUAddr, uiAbsPartIdx ); |
---|
| 391 | } |
---|
| 392 | |
---|
| 393 | |
---|
| 394 | Void |
---|
| 395 | TComResidualGenerator::xSetRecResidualIntraCU( TComDataCU* pcCU, TComYuv* pcCUResidual ) |
---|
| 396 | { |
---|
| 397 | //===== set residual to zero for entire CU ===== |
---|
| 398 | xClearResidual( pcCUResidual, 0, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) ); |
---|
| 399 | } |
---|
| 400 | |
---|
| 401 | |
---|
| 402 | Void |
---|
| 403 | TComResidualGenerator::xSetRecResidualInterCU( TComDataCU* pcCU, TComYuv* pcCUResidual ) |
---|
| 404 | { |
---|
| 405 | //===== reconstruct residual from coded transform coefficient levels ===== |
---|
| 406 | xClearResidual( pcCUResidual, 0, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) ); |
---|
| 407 | // luma |
---|
| 408 | UInt uiWidth = pcCU->getWidth ( 0 ); |
---|
| 409 | UInt uiHeight = pcCU->getHeight ( 0 ); |
---|
| 410 | TCoeff* piCoeff = pcCU->getCoeffY (); |
---|
| 411 | Pel* pRes = pcCUResidual->getLumaAddr(); |
---|
| 412 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
[296] | 413 | #if LG_RESTRICTEDRESPRED_M24766 && !MTK_MDIVRP_C0138 |
---|
[77] | 414 | Int iPUPredResiShift[4]; |
---|
| 415 | #endif |
---|
[2] | 416 | pcCU->convertTransIdx ( 0, pcCU->getTransformIdx( 0 ), uiLumaTrMode, uiChromaTrMode ); |
---|
[56] | 417 | m_pcTrQuant->setQPforQuant ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
[2] | 418 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pRes, 0, pcCUResidual->getStride(), uiWidth, uiHeight, uiLumaTrMode, 0, piCoeff ); |
---|
| 419 | // chroma Cb |
---|
| 420 | uiWidth >>= 1; |
---|
| 421 | uiHeight >>= 1; |
---|
| 422 | piCoeff = pcCU->getCoeffCb(); |
---|
| 423 | pRes = pcCUResidual->getCbAddr(); |
---|
[56] | 424 | m_pcTrQuant->setQPforQuant ( pcCU->getQP( 0 ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset() ); |
---|
[2] | 425 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pRes, 0, pcCUResidual->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff ); |
---|
| 426 | // chroma Cr |
---|
| 427 | piCoeff = pcCU->getCoeffCr(); |
---|
| 428 | pRes = pcCUResidual->getCrAddr(); |
---|
| 429 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pRes, 0, pcCUResidual->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff ); |
---|
| 430 | |
---|
[296] | 431 | #if !MTK_MDIVRP_C0138 |
---|
[2] | 432 | if( pcCU->getResPredFlag( 0 ) ) |
---|
| 433 | { |
---|
| 434 | AOF( pcCU->getResPredAvail( 0 ) ); |
---|
[296] | 435 | Bool bOK = pcCU->getResidualSamples( 0, true, m_ppcYuvTmp[0] ); |
---|
[2] | 436 | AOF( bOK ); |
---|
[77] | 437 | #if LG_RESTRICTEDRESPRED_M24766 |
---|
[100] | 438 | pcCU->getPUResiPredShift(iPUPredResiShift, 0); |
---|
| 439 | pcCUResidual->add(iPUPredResiShift, pcCU->getPartitionSize(0), m_ppcYuvTmp[0], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) ); |
---|
[77] | 440 | #else |
---|
[2] | 441 | pcCUResidual->add( m_ppcYuvTmp[0], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) ); |
---|
[77] | 442 | #endif |
---|
[2] | 443 | } |
---|
[296] | 444 | #endif |
---|
[2] | 445 | |
---|
| 446 | //===== clear inter-view predicted parts ===== |
---|
| 447 | for( UInt uiPartIdx = 0; uiPartIdx < pcCU->getNumPartInter(); uiPartIdx++ ) |
---|
| 448 | { |
---|
| 449 | xClearIntViewResidual( pcCU, pcCUResidual, uiPartIdx ); |
---|
| 450 | } |
---|
| 451 | } |
---|
| 452 | |
---|
| 453 | |
---|
| 454 | Void |
---|
| 455 | TComResidualGenerator::xClearIntViewResidual( TComDataCU* pcCU, TComYuv* pcCUResidual, UInt uiPartIdx ) |
---|
| 456 | { |
---|
| 457 | UInt uiCurrViewId = pcCU->getSlice()->getSPS()->getViewId(); |
---|
| 458 | if( uiCurrViewId ) |
---|
| 459 | { |
---|
| 460 | Int iWidth; |
---|
| 461 | Int iHeight; |
---|
| 462 | UInt uiAbsPartIdx; |
---|
| 463 | pcCU->getPartIndexAndSize( uiPartIdx, uiAbsPartIdx, iWidth, iHeight ); |
---|
| 464 | TComCUMvField* aiCurrMvField[2] = { pcCU->getCUMvField( REF_PIC_LIST_0 ), pcCU->getCUMvField( REF_PIC_LIST_1 ) }; |
---|
| 465 | Int aiCurrRefIdx [2] = { aiCurrMvField[0]->getRefIdx( uiAbsPartIdx ), aiCurrMvField[1]->getRefIdx( uiAbsPartIdx ) }; |
---|
| 466 | Bool abCurrIntView[2] = { aiCurrRefIdx[0] >= 0 && pcCU->getSlice()->getRefPic( REF_PIC_LIST_0, aiCurrRefIdx[0] )->getSPS()->getViewId() != uiCurrViewId, |
---|
| 467 | aiCurrRefIdx[1] >= 0 && pcCU->getSlice()->getRefPic( REF_PIC_LIST_1, aiCurrRefIdx[1] )->getSPS()->getViewId() != uiCurrViewId }; |
---|
| 468 | Bool bUsesInterViewPrd = ( abCurrIntView[0] || abCurrIntView[1] ); |
---|
| 469 | if( bUsesInterViewPrd ) |
---|
| 470 | { //===== set resiudal to zero ===== |
---|
| 471 | xClearResidual( pcCUResidual, uiAbsPartIdx, (UInt)iWidth, (UInt)iHeight ); |
---|
| 472 | } |
---|
| 473 | } |
---|
| 474 | } |
---|
| 475 | |
---|
| 476 | |
---|
| 477 | Void |
---|
| 478 | TComResidualGenerator::xClearResidual( TComYuv* pcCUResidual, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight ) |
---|
| 479 | { |
---|
| 480 | // luma |
---|
| 481 | Pel* pSamplesY = pcCUResidual->getLumaAddr( uiAbsPartIdx ); |
---|
| 482 | Int iStrideY = pcCUResidual->getStride (); |
---|
| 483 | for( UInt uiY = 0; uiY < uiHeight; uiY++, pSamplesY += iStrideY ) |
---|
| 484 | { |
---|
| 485 | ::memset( pSamplesY, 0x00, uiWidth * sizeof( Pel ) ); |
---|
| 486 | } |
---|
| 487 | // chroma |
---|
| 488 | uiWidth >>= 1; |
---|
| 489 | uiHeight >>= 1; |
---|
| 490 | Pel* pSamplesU = pcCUResidual->getCbAddr ( uiAbsPartIdx ); |
---|
| 491 | Pel* pSamplesV = pcCUResidual->getCrAddr ( uiAbsPartIdx ); |
---|
| 492 | Int iStrideC = pcCUResidual->getCStride(); |
---|
| 493 | for( UInt uiY = 0; uiY < uiHeight; uiY++, pSamplesU += iStrideC, pSamplesV += iStrideC ) |
---|
| 494 | { |
---|
| 495 | ::memset( pSamplesU, 0x00, uiWidth * sizeof( Pel ) ); |
---|
| 496 | ::memset( pSamplesV, 0x00, uiWidth * sizeof( Pel ) ); |
---|
| 497 | } |
---|
| 498 | } |
---|
| 499 | |
---|
| 500 | |
---|
[296] | 501 | #if H3D_NBDV |
---|
| 502 | #if MTK_RELEASE_DV_CONSTRAINT_C0129 |
---|
[2] | 503 | Void |
---|
[296] | 504 | TComResidualGenerator::xSetPredResidualBlock( TComPic* pcPic, UInt uiBaseViewId, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv, TComMv iDisp |
---|
| 505 | ,UInt * puiXPosInRefView , UInt * puiYPosInRefView , Bool bRecon ) |
---|
| 506 | #else // MTK_RELEASE_DV_CONSTRAINT_C0129 |
---|
| 507 | Void |
---|
[100] | 508 | TComResidualGenerator::xSetPredResidualBlock( TComPic* pcPic, UInt uiBaseViewId, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv, Int iDisp |
---|
[296] | 509 | ,UInt * puiXPosInRefView , UInt * puiYPosInRefView , Bool bRecon) |
---|
| 510 | #endif // MTK_RELEASE_DV_CONSTRAINT_C0129 |
---|
| 511 | #else // H3D_NBDV |
---|
[100] | 512 | Void |
---|
[77] | 513 | TComResidualGenerator::xSetPredResidualBlock( TComPic* pcPic, UInt uiBaseViewId, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv |
---|
[296] | 514 | , UInt * puiXPosInRefView , UInt * puiYPosInRefView , Bool bRecon ) |
---|
| 515 | #endif // H3D_NBDV |
---|
[2] | 516 | { |
---|
| 517 | //===== set and check some basic variables ===== |
---|
| 518 | AOF( pcYuv ); |
---|
| 519 | TComPic* pcBasePic = m_pcAUPicAccess->getPic( uiBaseViewId ); |
---|
| 520 | AOF( pcPic ); |
---|
| 521 | AOF( pcBasePic ); |
---|
| 522 | TComPicYuv* pcBaseRes = pcBasePic->getResidual (); |
---|
| 523 | TComPicYuv* pcPdmMap = pcPic ->getPredDepthMap(); |
---|
| 524 | AOF( pcBaseRes ); |
---|
| 525 | AOF( pcPdmMap ); |
---|
| 526 | UInt uiPicWidth = pcBaseRes->getWidth (); |
---|
| 527 | UInt uiPicHeight = pcBaseRes->getHeight(); |
---|
| 528 | AOT( uiXPos + uiBlkWidth > uiPicWidth ); |
---|
| 529 | AOT( uiYPos + uiBlkHeight > uiPicHeight ); |
---|
| 530 | |
---|
| 531 | //===== get disparity ===== |
---|
[296] | 532 | #if H3D_NBDV |
---|
| 533 | #if MTK_RELEASE_DV_CONSTRAINT_C0129 |
---|
| 534 | Int iDisparity_y = iDisp.getVer(); |
---|
| 535 | Int iDisparity = iDisp.getHor(); |
---|
| 536 | #else |
---|
[100] | 537 | Int iDisparity = iDisp; |
---|
[296] | 538 | #endif |
---|
| 539 | #else //H3D_NBDV |
---|
[21] | 540 | Int iMidPosX = Int( uiXPos + ( ( uiBlkWidth - 1 ) >> 1 ) ) >> m_pcDepthMapGenerator->getSubSampExpX(); |
---|
| 541 | Int iMidPosY = Int( uiYPos + ( ( uiBlkHeight - 1 ) >> 1 ) ) >> m_pcDepthMapGenerator->getSubSampExpY(); |
---|
[2] | 542 | Int iDisparity = m_pcDepthMapGenerator->getDisparity( pcPic, iMidPosX, iMidPosY, uiBaseViewId ); |
---|
[296] | 543 | #endif //H3D_NBDV |
---|
[2] | 544 | //===== compensate luma ===== |
---|
| 545 | Int iYWidth = Int( uiBlkWidth ); |
---|
| 546 | Int iYHeight = Int( uiBlkHeight ); |
---|
| 547 | Int iYWeight1 = ( iDisparity & 3 ); |
---|
| 548 | Int iYWeight0 = 4 - iYWeight1; |
---|
| 549 | Int iYRefPosX0 = Int( uiXPos ) + ( iDisparity >> 2 ); |
---|
| 550 | Int iYRefPosX1 = iYRefPosX0 + 1; |
---|
[296] | 551 | #if MTK_RELEASE_DV_CONSTRAINT_C0129 |
---|
| 552 | Int iYMaxPosY = Int( uiPicHeight ) - 1; |
---|
| 553 | Int iYWeight3 = ( iDisparity_y & 3 ); |
---|
| 554 | Int iYWeight2 = 4 - iYWeight3; |
---|
| 555 | Int iYRefPosY0 = Max( 0, Min( iYMaxPosY, Int( uiYPos ) + ( iDisparity_y >> 2 )) ); |
---|
| 556 | Int iYRefPosY1 = Max( 0, Min( iYMaxPosY, iYRefPosY0 + 1 )); |
---|
| 557 | #endif |
---|
[2] | 558 | Int iYMaxPosX = Int( uiPicWidth ) - 1; |
---|
| 559 | Int iSrcStrideY = pcBaseRes->getStride (); |
---|
| 560 | Int iDesStrideY = pcYuv ->getStride (); |
---|
[296] | 561 | #if MTK_RELEASE_DV_CONSTRAINT_C0129 |
---|
| 562 | Pel* pSrcSamplesY0= pcBaseRes->getLumaAddr ( 0 ) + iYRefPosY0 * iSrcStrideY; |
---|
| 563 | Pel* pSrcSamplesY1= pcBaseRes->getLumaAddr ( 0 ) + iYRefPosY1 * iSrcStrideY; |
---|
| 564 | #else |
---|
[2] | 565 | Pel* pSrcSamplesY= pcBaseRes->getLumaAddr ( 0 ) + uiYPos * iSrcStrideY; |
---|
[296] | 566 | #endif |
---|
[2] | 567 | Pel* pDesSamplesY= pcYuv ->getLumaAddr (); |
---|
[77] | 568 | |
---|
[296] | 569 | |
---|
[77] | 570 | if( puiXPosInRefView != NULL ) |
---|
| 571 | *puiXPosInRefView = Max( 0, Min( iYMaxPosX, iYRefPosX0 ) ); |
---|
| 572 | if( puiYPosInRefView != NULL ) |
---|
| 573 | *puiYPosInRefView = uiYPos; |
---|
| 574 | if( bRecon == false ) |
---|
| 575 | return; |
---|
| 576 | |
---|
[296] | 577 | #if MTK_RELEASE_DV_CONSTRAINT_C0129 |
---|
| 578 | for( Int iY = 0; iY < iYHeight; iY++, pSrcSamplesY0 += iSrcStrideY, pSrcSamplesY1 += iSrcStrideY, pDesSamplesY += iDesStrideY ) |
---|
| 579 | #else |
---|
[2] | 580 | for( Int iY = 0; iY < iYHeight; iY++, pSrcSamplesY += iSrcStrideY, pDesSamplesY += iDesStrideY ) |
---|
[296] | 581 | #endif |
---|
[2] | 582 | { |
---|
| 583 | for( Int iX = 0; iX < iYWidth; iX++ ) |
---|
| 584 | { |
---|
| 585 | Int iXPic0 = Max( 0, Min( iYMaxPosX, iYRefPosX0 + iX ) ); |
---|
| 586 | Int iXPic1 = Max( 0, Min( iYMaxPosX, iYRefPosX1 + iX ) ); |
---|
[296] | 587 | #if MTK_RELEASE_DV_CONSTRAINT_C0129 |
---|
| 588 | Pel Temp1,Temp2; |
---|
| 589 | Temp1 =( iYWeight0 * pSrcSamplesY0[iXPic0] + iYWeight1 * pSrcSamplesY0[iXPic1] + 2 ) >> 2; |
---|
| 590 | Temp2 =( iYWeight0 * pSrcSamplesY1[iXPic0] + iYWeight1 * pSrcSamplesY1[iXPic1] + 2 ) >> 2; |
---|
| 591 | pDesSamplesY[iX] = ( iYWeight2 * Temp1 + iYWeight3 * Temp2 + 2 ) >> 2; |
---|
| 592 | #else |
---|
[2] | 593 | pDesSamplesY[iX] = ( iYWeight0 * pSrcSamplesY[iXPic0] + iYWeight1 * pSrcSamplesY[iXPic1] + 2 ) >> 2; |
---|
[296] | 594 | #endif |
---|
[2] | 595 | } |
---|
| 596 | } |
---|
| 597 | |
---|
| 598 | //===== compensate chroma ===== |
---|
| 599 | Int iCWidth = Int( uiBlkWidth >> 1 ); |
---|
| 600 | Int iCHeight = Int( uiBlkHeight >> 1 ); |
---|
| 601 | Int iCWeight1 = ( iDisparity & 7 ); |
---|
| 602 | Int iCWeight0 = 8 - iCWeight1; |
---|
| 603 | Int iCRefPosX0 = Int( uiXPos >> 1 ) + ( iDisparity >> 3 ); |
---|
| 604 | Int iCRefPosX1 = iCRefPosX0 + 1; |
---|
[296] | 605 | #if MTK_RELEASE_DV_CONSTRAINT_C0129 |
---|
| 606 | Int iCMaxPosY = Int( uiPicHeight >> 1 ) - 1; |
---|
| 607 | Int iCWeight3 = ( iDisparity_y & 7 ); |
---|
| 608 | Int iCWeight2 = 8 - iCWeight3; |
---|
| 609 | Int iCRefPosY0 = Max( 0, Min( iCMaxPosY, Int( uiYPos >> 1 ) + ( iDisparity_y >> 3 )) ); |
---|
| 610 | Int iCRefPosY1 = Max( 0, Min( iCMaxPosY, iCRefPosY0 + 1 )); |
---|
| 611 | #endif |
---|
[2] | 612 | Int iCMaxPosX = Int( uiPicWidth >> 1 ) - 1; |
---|
| 613 | Int iSrcStrideC = pcBaseRes->getCStride(); |
---|
| 614 | Int iDesStrideC = pcYuv ->getCStride(); |
---|
[296] | 615 | #if MTK_RELEASE_DV_CONSTRAINT_C0129 |
---|
[313] | 616 | #if FIX_CHROMA_RESIDUAL_C0129 |
---|
| 617 | Pel* pSrcSamplesU0= pcBaseRes->getCbAddr ( 0 ) + iCRefPosY0 * iSrcStrideC; |
---|
| 618 | Pel* pSrcSamplesU1= pcBaseRes->getCbAddr ( 0 ) + iCRefPosY1 * iSrcStrideC; |
---|
| 619 | Pel* pSrcSamplesV0= pcBaseRes->getCrAddr ( 0 ) + iCRefPosY0 * iSrcStrideC; |
---|
| 620 | Pel* pSrcSamplesV1= pcBaseRes->getCrAddr ( 0 ) + iCRefPosY1 * iSrcStrideC; |
---|
| 621 | #else |
---|
[296] | 622 | Pel* pSrcSamplesU0= pcBaseRes->getCbAddr ( 0 ) + ( iCRefPosY0 >> 1 ) * iSrcStrideC; |
---|
| 623 | Pel* pSrcSamplesU1= pcBaseRes->getCbAddr ( 0 ) + ( iCRefPosY1 >> 1 ) * iSrcStrideC; |
---|
| 624 | Pel* pSrcSamplesV0= pcBaseRes->getCrAddr ( 0 ) + ( iCRefPosY0 >> 1 ) * iSrcStrideC; |
---|
| 625 | Pel* pSrcSamplesV1= pcBaseRes->getCrAddr ( 0 ) + ( iCRefPosY1 >> 1 ) * iSrcStrideC; |
---|
[313] | 626 | #endif |
---|
[296] | 627 | #else |
---|
[2] | 628 | Pel* pSrcSamplesU= pcBaseRes->getCbAddr ( 0 ) + ( uiYPos >> 1 ) * iSrcStrideC; |
---|
| 629 | Pel* pSrcSamplesV= pcBaseRes->getCrAddr ( 0 ) + ( uiYPos >> 1 ) * iSrcStrideC; |
---|
[296] | 630 | #endif |
---|
[2] | 631 | Pel* pDesSamplesU= pcYuv ->getCbAddr (); |
---|
| 632 | Pel* pDesSamplesV= pcYuv ->getCrAddr (); |
---|
[296] | 633 | #if MTK_RELEASE_DV_CONSTRAINT_C0129 |
---|
| 634 | for( Int iY = 0; iY < iCHeight; iY++, pSrcSamplesU0 += iSrcStrideC, pSrcSamplesU1 += iSrcStrideC, pDesSamplesU += iDesStrideC, |
---|
| 635 | pSrcSamplesV0 += iSrcStrideC, pSrcSamplesV1 += iSrcStrideC, pDesSamplesV += iDesStrideC ) |
---|
| 636 | #else |
---|
[2] | 637 | for( Int iY = 0; iY < iCHeight; iY++, pSrcSamplesU += iSrcStrideC, pDesSamplesU += iDesStrideC, |
---|
| 638 | pSrcSamplesV += iSrcStrideC, pDesSamplesV += iDesStrideC ) |
---|
[296] | 639 | #endif |
---|
[2] | 640 | { |
---|
| 641 | for( Int iX = 0; iX < iCWidth; iX++ ) |
---|
| 642 | { |
---|
| 643 | Int iXPic0 = Max( 0, Min( iCMaxPosX, iCRefPosX0 + iX ) ); |
---|
| 644 | Int iXPic1 = Max( 0, Min( iCMaxPosX, iCRefPosX1 + iX ) ); |
---|
[296] | 645 | #if MTK_RELEASE_DV_CONSTRAINT_C0129 |
---|
| 646 | Pel Temp1,Temp2; |
---|
| 647 | Temp1 =( iCWeight0 * pSrcSamplesU0[iXPic0] + iCWeight1 * pSrcSamplesU0[iXPic1] + 4 ) >> 3; |
---|
| 648 | Temp2 =( iCWeight0 * pSrcSamplesU1[iXPic0] + iCWeight1 * pSrcSamplesU1[iXPic1] + 4 ) >> 3; |
---|
| 649 | pDesSamplesU[iX] = ( iCWeight2 * Temp1 + iCWeight3 * Temp2 + 4 ) >> 3; |
---|
| 650 | Temp1 =( iCWeight0 * pSrcSamplesV0[iXPic0] + iCWeight1 * pSrcSamplesV0[iXPic1] + 4 ) >> 3; |
---|
| 651 | Temp2 =( iCWeight0 * pSrcSamplesV1[iXPic0] + iCWeight1 * pSrcSamplesV1[iXPic1] + 4 ) >> 3; |
---|
| 652 | pDesSamplesV[iX] = ( iCWeight2 * Temp1 + iCWeight3 * Temp2 + 4 ) >> 3; |
---|
| 653 | #else |
---|
[2] | 654 | pDesSamplesU[iX] = ( iCWeight0 * pSrcSamplesU[iXPic0] + iCWeight1 * pSrcSamplesU[iXPic1] + 4 ) >> 3; |
---|
| 655 | pDesSamplesV[iX] = ( iCWeight0 * pSrcSamplesV[iXPic0] + iCWeight1 * pSrcSamplesV[iXPic1] + 4 ) >> 3; |
---|
[296] | 656 | #endif |
---|
[2] | 657 | } |
---|
| 658 | } |
---|
| 659 | } |
---|
| 660 | |
---|
| 661 | |
---|
| 662 | Bool |
---|
| 663 | TComResidualGenerator::xIsNonZero( TComYuv* pcYuv, UInt uiBlkWidth, UInt uiBlkHeight ) |
---|
| 664 | { |
---|
| 665 | AOF( pcYuv ); |
---|
| 666 | //===== check luma ===== |
---|
| 667 | Int iYWidth = Int( uiBlkWidth ); |
---|
| 668 | Int iYHeight = Int( uiBlkHeight ); |
---|
| 669 | Int iStrideY = pcYuv->getStride (); |
---|
| 670 | Pel* pSamplesY = pcYuv->getLumaAddr (); |
---|
| 671 | for( Int iY = 0; iY < iYHeight; iY++, pSamplesY += iStrideY ) |
---|
| 672 | { |
---|
| 673 | for( Int iX = 0; iX < iYWidth; iX++ ) |
---|
| 674 | { |
---|
| 675 | ROTRS( pSamplesY[iX], true ); |
---|
| 676 | } |
---|
| 677 | } |
---|
| 678 | //===== compensate chroma ===== |
---|
| 679 | Int iCWidth = Int( uiBlkWidth >> 1 ); |
---|
| 680 | Int iCHeight = Int( uiBlkHeight >> 1 ); |
---|
| 681 | Int iStrideC = pcYuv->getCStride(); |
---|
| 682 | Pel* pSamplesU = pcYuv->getCbAddr (); |
---|
| 683 | Pel* pSamplesV = pcYuv->getCrAddr (); |
---|
| 684 | for( Int iY = 0; iY < iCHeight; iY++, pSamplesU += iStrideC, pSamplesV += iStrideC ) |
---|
| 685 | { |
---|
| 686 | for( Int iX = 0; iX < iCWidth; iX++ ) |
---|
| 687 | { |
---|
| 688 | ROTRS( pSamplesU[iX], true ); |
---|
| 689 | ROTRS( pSamplesV[iX], true ); |
---|
| 690 | } |
---|
| 691 | } |
---|
| 692 | return false; |
---|
| 693 | } |
---|
| 694 | |
---|
| 695 | |
---|
| 696 | |
---|
| 697 | Void |
---|
| 698 | TComResidualGenerator::xDumpResidual( TComPic* pcPic, char* pFilenameBase ) |
---|
| 699 | { |
---|
| 700 | AOF( m_bCreated && m_bInit ); |
---|
| 701 | AOF( pcPic ); |
---|
| 702 | AOF( pFilenameBase ); |
---|
| 703 | AOF( m_uiOrgDepthBitDepth == 8 + g_uiBitIncrement ); |
---|
| 704 | |
---|
| 705 | // convert to output format (just clip high absolute values, since they are very unlikely) |
---|
| 706 | Int iMin = 0; |
---|
| 707 | Int iMax = ( 1 << m_uiOrgDepthBitDepth ) - 1; |
---|
| 708 | Int iMid = ( 1 << m_uiOrgDepthBitDepth ) >> 1; |
---|
| 709 | UInt uiViewId = pcPic ->getSPS ()->getViewId(); |
---|
| 710 | TComPicYuv* pcPicYuv = pcPic ->getResidual (); |
---|
| 711 | // luma |
---|
| 712 | Int iWidth = pcPicYuv->getWidth (); |
---|
| 713 | Int iHeight = pcPicYuv->getHeight (); |
---|
| 714 | Int iSrcStride = pcPicYuv->getStride (); |
---|
| 715 | Int iDstStride = m_cTmpPic.getStride (); |
---|
| 716 | Pel* pSrcSamples = pcPicYuv->getLumaAddr ( 0 ); |
---|
| 717 | Pel* pDstSamples = m_cTmpPic.getLumaAddr ( 0 ); |
---|
| 718 | AOF( m_cTmpPic.getWidth () == iWidth ); |
---|
| 719 | AOF( m_cTmpPic.getHeight() == iHeight ); |
---|
| 720 | for( Int iY = 0; iY < iHeight; iY++, pSrcSamples += iSrcStride, pDstSamples += iDstStride ) |
---|
| 721 | { |
---|
| 722 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
| 723 | { |
---|
| 724 | pDstSamples[ iX ] = Max( iMin, Min( iMax, iMid + pSrcSamples[ iX ] ) ); |
---|
| 725 | } |
---|
| 726 | } |
---|
| 727 | // chroma |
---|
| 728 | iWidth >>= 1; |
---|
| 729 | iHeight >>= 1; |
---|
| 730 | iSrcStride = pcPicYuv->getCStride(); |
---|
| 731 | iDstStride = m_cTmpPic.getCStride(); |
---|
| 732 | Pel* pSrcCb = pcPicYuv->getCbAddr ( 0 ); |
---|
| 733 | Pel* pSrcCr = pcPicYuv->getCrAddr ( 0 ); |
---|
| 734 | Pel* pDstCb = m_cTmpPic.getCbAddr ( 0 ); |
---|
| 735 | Pel* pDstCr = m_cTmpPic.getCrAddr ( 0 ); |
---|
| 736 | for( Int iY = 0; iY < iHeight; iY++, pSrcCb += iSrcStride, pSrcCr += iSrcStride, pDstCb += iDstStride, pDstCr += iDstStride ) |
---|
| 737 | { |
---|
| 738 | for( Int iX = 0; iX < iWidth; iX++ ) |
---|
| 739 | { |
---|
| 740 | pDstCb[ iX ] = Max( iMin, Min( iMax, iMid + pSrcCb[ iX ] ) ); |
---|
| 741 | pDstCr[ iX ] = Max( iMin, Min( iMax, iMid + pSrcCr[ iX ] ) ); |
---|
| 742 | } |
---|
| 743 | } |
---|
| 744 | |
---|
| 745 | // output |
---|
| 746 | Char acFilename[1024]; |
---|
| 747 | ::sprintf ( acFilename, "%s_V%d.yuv", pFilenameBase, uiViewId ); |
---|
| 748 | m_cTmpPic.dump( acFilename, ( pcPic->getPOC() != 0 ) ); |
---|
| 749 | } |
---|
| 750 | |
---|
| 751 | |
---|
[296] | 752 | #endif // H3D_IVRP |
---|
[2] | 753 | |
---|