[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 |
---|
[56] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[872] | 6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
---|
[5] | 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. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 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 | /** \file TEncEntropy.cpp |
---|
| 35 | \brief entropy encoder class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include "TEncEntropy.h" |
---|
[56] | 39 | #include "TLibCommon/TypeDef.h" |
---|
| 40 | #include "TLibCommon/TComSampleAdaptiveOffset.h" |
---|
[2] | 41 | |
---|
[56] | 42 | //! \ingroup TLibEncoder |
---|
| 43 | //! \{ |
---|
| 44 | |
---|
[2] | 45 | Void TEncEntropy::setEntropyCoder ( TEncEntropyIf* e, TComSlice* pcSlice ) |
---|
| 46 | { |
---|
| 47 | m_pcEntropyCoderIf = e; |
---|
| 48 | m_pcEntropyCoderIf->setSlice ( pcSlice ); |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | Void TEncEntropy::encodeSliceHeader ( TComSlice* pcSlice ) |
---|
| 52 | { |
---|
| 53 | m_pcEntropyCoderIf->codeSliceHeader( pcSlice ); |
---|
| 54 | return; |
---|
| 55 | } |
---|
| 56 | |
---|
[56] | 57 | Void TEncEntropy::encodeTilesWPPEntryPoint( TComSlice* pSlice ) |
---|
| 58 | { |
---|
| 59 | m_pcEntropyCoderIf->codeTilesWPPEntryPoint( pSlice ); |
---|
| 60 | } |
---|
| 61 | |
---|
[2] | 62 | Void TEncEntropy::encodeTerminatingBit ( UInt uiIsLast ) |
---|
| 63 | { |
---|
| 64 | m_pcEntropyCoderIf->codeTerminatingBit( uiIsLast ); |
---|
| 65 | |
---|
| 66 | return; |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | Void TEncEntropy::encodeSliceFinish() |
---|
| 70 | { |
---|
| 71 | m_pcEntropyCoderIf->codeSliceFinish(); |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | Void TEncEntropy::encodePPS( TComPPS* pcPPS ) |
---|
| 75 | { |
---|
| 76 | m_pcEntropyCoderIf->codePPS( pcPPS ); |
---|
| 77 | return; |
---|
| 78 | } |
---|
| 79 | |
---|
[1106] | 80 | #if HHI_TOOL_PARAMETERS_I2_J0107 |
---|
| 81 | Void TEncEntropy::encodeSPS( TComSPS* pcSPS ) |
---|
| 82 | { |
---|
| 83 | m_pcEntropyCoderIf->codeSPS( pcSPS ); |
---|
| 84 | return; |
---|
| 85 | } |
---|
| 86 | #else |
---|
[608] | 87 | #if H_3D |
---|
| 88 | Void TEncEntropy::encodeSPS( TComSPS* pcSPS, Int viewIndex, Bool depthFlag ) |
---|
[77] | 89 | { |
---|
[608] | 90 | m_pcEntropyCoderIf->codeSPS( pcSPS, viewIndex, depthFlag ); |
---|
[77] | 91 | return; |
---|
| 92 | } |
---|
[56] | 93 | #else |
---|
[2] | 94 | Void TEncEntropy::encodeSPS( TComSPS* pcSPS ) |
---|
| 95 | { |
---|
| 96 | m_pcEntropyCoderIf->codeSPS( pcSPS ); |
---|
| 97 | return; |
---|
| 98 | } |
---|
[56] | 99 | #endif |
---|
[1106] | 100 | #endif |
---|
[2] | 101 | |
---|
[608] | 102 | Void TEncEntropy::encodeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
[2] | 103 | { |
---|
| 104 | if( bRD ) |
---|
[56] | 105 | { |
---|
[2] | 106 | uiAbsPartIdx = 0; |
---|
[56] | 107 | } |
---|
[608] | 108 | m_pcEntropyCoderIf->codeCUTransquantBypassFlag( pcCU, uiAbsPartIdx ); |
---|
[2] | 109 | } |
---|
| 110 | |
---|
[608] | 111 | Void TEncEntropy::encodeVPS( TComVPS* pcVPS ) |
---|
[189] | 112 | { |
---|
[608] | 113 | m_pcEntropyCoderIf->codeVPS( pcVPS ); |
---|
| 114 | return; |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | Void TEncEntropy::encodeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
| 118 | { |
---|
| 119 | if ( pcCU->getSlice()->isIntra() ) |
---|
[189] | 120 | { |
---|
| 121 | return; |
---|
| 122 | } |
---|
| 123 | if( bRD ) |
---|
| 124 | { |
---|
| 125 | uiAbsPartIdx = 0; |
---|
| 126 | } |
---|
[608] | 127 | m_pcEntropyCoderIf->codeSkipFlag( pcCU, uiAbsPartIdx ); |
---|
[189] | 128 | } |
---|
[1084] | 129 | #if H_3D_SINGLE_DEPTH |
---|
[1039] | 130 | Void TEncEntropy::encodeSingleDepthMode( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
| 131 | { |
---|
| 132 | if ( !pcCU->getSlice()->getIsDepth() ) |
---|
| 133 | { |
---|
| 134 | return; |
---|
| 135 | } |
---|
[1118] | 136 | #if MTK_SINGLE_DEPTH_VPS_FLAG_J0060 |
---|
[1120] | 137 | // if(!pcCU->getSlice()->getVPS()->getSingleDepthModeFlag(pcCU->getSlice()->getLayerIdInVps())) |
---|
[1118] | 138 | { |
---|
| 139 | return; |
---|
| 140 | } |
---|
| 141 | #else |
---|
[1039] | 142 | if(!pcCU->getSlice()->getApplySingleDepthMode()) |
---|
| 143 | { |
---|
| 144 | return; |
---|
| 145 | } |
---|
[1118] | 146 | #endif |
---|
[1039] | 147 | if( bRD ) |
---|
| 148 | { |
---|
| 149 | uiAbsPartIdx = 0; |
---|
| 150 | } |
---|
| 151 | m_pcEntropyCoderIf->codeSingleDepthMode( pcCU, uiAbsPartIdx ); |
---|
| 152 | } |
---|
| 153 | #endif |
---|
[2] | 154 | /** encode merge flag |
---|
| 155 | * \param pcCU |
---|
| 156 | * \param uiAbsPartIdx |
---|
| 157 | * \returns Void |
---|
| 158 | */ |
---|
[608] | 159 | Void TEncEntropy::encodeMergeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
[2] | 160 | { |
---|
[56] | 161 | // at least one merge candidate exists |
---|
| 162 | m_pcEntropyCoderIf->codeMergeFlag( pcCU, uiAbsPartIdx ); |
---|
[2] | 163 | } |
---|
| 164 | |
---|
| 165 | /** encode merge index |
---|
| 166 | * \param pcCU |
---|
| 167 | * \param uiAbsPartIdx |
---|
| 168 | * \param uiPUIdx |
---|
| 169 | * \param bRD |
---|
| 170 | * \returns Void |
---|
| 171 | */ |
---|
[608] | 172 | Void TEncEntropy::encodeMergeIndex( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
[2] | 173 | { |
---|
| 174 | if( bRD ) |
---|
| 175 | { |
---|
| 176 | uiAbsPartIdx = 0; |
---|
| 177 | assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); |
---|
| 178 | } |
---|
[608] | 179 | m_pcEntropyCoderIf->codeMergeIndex( pcCU, uiAbsPartIdx ); |
---|
[2] | 180 | } |
---|
| 181 | |
---|
[608] | 182 | #if H_3D_IC |
---|
| 183 | Void TEncEntropy::encodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
[443] | 184 | { |
---|
[833] | 185 | if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() || pcCU->getARPW( uiAbsPartIdx ) > 0 ) |
---|
[443] | 186 | { |
---|
| 187 | return; |
---|
| 188 | } |
---|
[608] | 189 | |
---|
| 190 | if( !pcCU->getSlice()->getApplyIC() ) |
---|
[976] | 191 | { |
---|
[608] | 192 | return; |
---|
[976] | 193 | } |
---|
[608] | 194 | |
---|
[443] | 195 | if( bRD ) |
---|
| 196 | { |
---|
| 197 | uiAbsPartIdx = 0; |
---|
| 198 | } |
---|
[950] | 199 | else |
---|
| 200 | { |
---|
[1066] | 201 | Int ICEnableCandidate = pcCU->getSlice()->getICEnableCandidate(pcCU->getSlice()->getDepth()); |
---|
| 202 | Int ICEnableNum = pcCU->getSlice()->getICEnableNum(pcCU->getSlice()->getDepth()); |
---|
| 203 | ICEnableCandidate++; |
---|
| 204 | if(pcCU->getICFlag(uiAbsPartIdx)) |
---|
| 205 | { |
---|
| 206 | ICEnableNum++; |
---|
| 207 | } |
---|
| 208 | pcCU->getSlice()->setICEnableCandidate(pcCU->getSlice()->getDepth(), ICEnableCandidate); |
---|
| 209 | pcCU->getSlice()->setICEnableNum(pcCU->getSlice()->getDepth(), ICEnableNum); |
---|
[950] | 210 | } |
---|
[608] | 211 | if( pcCU->isICFlagRequired( uiAbsPartIdx ) ) |
---|
[976] | 212 | { |
---|
[608] | 213 | m_pcEntropyCoderIf->codeICFlag( pcCU, uiAbsPartIdx ); |
---|
[976] | 214 | } |
---|
[443] | 215 | } |
---|
| 216 | #endif |
---|
[2] | 217 | |
---|
[608] | 218 | #if H_3D_ARP |
---|
| 219 | Void TEncEntropy::encodeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
[56] | 220 | { |
---|
[608] | 221 | if( !pcCU->getSlice()->getARPStepNum() || pcCU->isIntra( uiAbsPartIdx ) ) |
---|
[56] | 222 | { |
---|
[608] | 223 | return; |
---|
[56] | 224 | } |
---|
| 225 | |
---|
[608] | 226 | if ( pcCU->getPartitionSize(uiAbsPartIdx)!=SIZE_2Nx2N ) |
---|
[56] | 227 | { |
---|
[608] | 228 | assert(pcCU->getARPW (uiAbsPartIdx) == 0); |
---|
[56] | 229 | } |
---|
[608] | 230 | else |
---|
[56] | 231 | { |
---|
[608] | 232 | m_pcEntropyCoderIf->codeARPW( pcCU, uiAbsPartIdx ); |
---|
[56] | 233 | } |
---|
| 234 | } |
---|
[608] | 235 | #endif |
---|
[56] | 236 | |
---|
[2] | 237 | /** encode prediction mode |
---|
| 238 | * \param pcCU |
---|
| 239 | * \param uiAbsPartIdx |
---|
| 240 | * \param bRD |
---|
| 241 | * \returns Void |
---|
| 242 | */ |
---|
| 243 | Void TEncEntropy::encodePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
| 244 | { |
---|
| 245 | if( bRD ) |
---|
[56] | 246 | { |
---|
[2] | 247 | uiAbsPartIdx = 0; |
---|
[56] | 248 | } |
---|
[2] | 249 | if ( pcCU->getSlice()->isIntra() ) |
---|
| 250 | { |
---|
| 251 | return; |
---|
| 252 | } |
---|
[56] | 253 | |
---|
[2] | 254 | m_pcEntropyCoderIf->codePredMode( pcCU, uiAbsPartIdx ); |
---|
| 255 | } |
---|
| 256 | |
---|
| 257 | // Split mode |
---|
| 258 | Void TEncEntropy::encodeSplitFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD ) |
---|
| 259 | { |
---|
| 260 | if( bRD ) |
---|
[56] | 261 | { |
---|
[2] | 262 | uiAbsPartIdx = 0; |
---|
[56] | 263 | } |
---|
[2] | 264 | m_pcEntropyCoderIf->codeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 265 | } |
---|
| 266 | |
---|
| 267 | /** encode partition size |
---|
| 268 | * \param pcCU |
---|
| 269 | * \param uiAbsPartIdx |
---|
| 270 | * \param uiDepth |
---|
| 271 | * \param bRD |
---|
| 272 | * \returns Void |
---|
| 273 | */ |
---|
| 274 | Void TEncEntropy::encodePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD ) |
---|
| 275 | { |
---|
| 276 | if( bRD ) |
---|
[56] | 277 | { |
---|
[2] | 278 | uiAbsPartIdx = 0; |
---|
[56] | 279 | } |
---|
[833] | 280 | |
---|
[2] | 281 | m_pcEntropyCoderIf->codePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[833] | 282 | |
---|
| 283 | #if H_3D_DBBP |
---|
[1100] | 284 | #if SEC_DBBP_VIEW_REF_CHECK_J0037 |
---|
[1106] | 285 | #if HHI_TOOL_PARAMETERS_I2_J0107 |
---|
| 286 | if( pcCU->getSlice()->getDepthBasedBlkPartFlag() && (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) && pcCU->getWidth(uiAbsPartIdx) > 8 && pcCU->getSlice()->getDefaultRefViewIdxAvailableFlag() ) |
---|
| 287 | #else |
---|
[1100] | 288 | if( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) && (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) && pcCU->getWidth(uiAbsPartIdx) > 8 && pcCU->getSlice()->getDefaultRefViewIdxAvailableFlag() ) |
---|
[1106] | 289 | #endif |
---|
[1100] | 290 | #else |
---|
[1039] | 291 | if( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) && (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) && pcCU->getWidth(uiAbsPartIdx) > 8 ) |
---|
[1100] | 292 | #endif |
---|
[833] | 293 | { |
---|
| 294 | encodeDBBPFlag(pcCU, uiAbsPartIdx, bRD); |
---|
| 295 | } |
---|
| 296 | #endif |
---|
[2] | 297 | } |
---|
| 298 | |
---|
[56] | 299 | /** Encode I_PCM information. |
---|
| 300 | * \param pcCU pointer to CU |
---|
| 301 | * \param uiAbsPartIdx CU index |
---|
| 302 | * \param bRD flag indicating estimation or encoding |
---|
| 303 | * \returns Void |
---|
| 304 | */ |
---|
| 305 | Void TEncEntropy::encodeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
[2] | 306 | { |
---|
[56] | 307 | if(!pcCU->getSlice()->getSPS()->getUsePCM() |
---|
| 308 | || pcCU->getWidth(uiAbsPartIdx) > (1<<pcCU->getSlice()->getSPS()->getPCMLog2MaxSize()) |
---|
| 309 | || pcCU->getWidth(uiAbsPartIdx) < (1<<pcCU->getSlice()->getSPS()->getPCMLog2MinSize())) |
---|
| 310 | { |
---|
| 311 | return; |
---|
| 312 | } |
---|
[189] | 313 | |
---|
[56] | 314 | if( bRD ) |
---|
| 315 | { |
---|
| 316 | uiAbsPartIdx = 0; |
---|
| 317 | } |
---|
| 318 | |
---|
[608] | 319 | m_pcEntropyCoderIf->codeIPCMInfo ( pcCU, uiAbsPartIdx ); |
---|
[56] | 320 | } |
---|
| 321 | |
---|
[608] | 322 | Void TEncEntropy::xEncodeTransform( TComDataCU* pcCU,UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP ) |
---|
[56] | 323 | { |
---|
[2] | 324 | const UInt uiSubdiv = pcCU->getTransformIdx( uiAbsPartIdx ) + pcCU->getDepth( uiAbsPartIdx ) > uiDepth; |
---|
| 325 | const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth; |
---|
[56] | 326 | UInt cbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA , uiTrIdx ); |
---|
| 327 | UInt cbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); |
---|
| 328 | UInt cbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); |
---|
| 329 | |
---|
| 330 | if(uiTrIdx==0) |
---|
[2] | 331 | { |
---|
[56] | 332 | m_bakAbsPartIdxCU = uiAbsPartIdx; |
---|
[2] | 333 | } |
---|
[56] | 334 | if( uiLog2TrafoSize == 2 ) |
---|
[2] | 335 | { |
---|
[56] | 336 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
| 337 | if( ( uiAbsPartIdx % partNum ) == 0 ) |
---|
| 338 | { |
---|
| 339 | m_uiBakAbsPartIdx = uiAbsPartIdx; |
---|
| 340 | m_uiBakChromaOffset = offsetChroma; |
---|
| 341 | } |
---|
| 342 | else if( ( uiAbsPartIdx % partNum ) == (partNum - 1) ) |
---|
| 343 | { |
---|
| 344 | cbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); |
---|
| 345 | cbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); |
---|
| 346 | } |
---|
[2] | 347 | } |
---|
[608] | 348 | |
---|
| 349 | if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) ) |
---|
| 350 | { |
---|
| 351 | assert( uiSubdiv ); |
---|
| 352 | } |
---|
| 353 | else if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER && (pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N) && uiDepth == pcCU->getDepth(uiAbsPartIdx) && (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) ) |
---|
| 354 | { |
---|
| 355 | if ( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ) |
---|
[2] | 356 | { |
---|
| 357 | assert( uiSubdiv ); |
---|
| 358 | } |
---|
[608] | 359 | else |
---|
[56] | 360 | { |
---|
[608] | 361 | assert(!uiSubdiv ); |
---|
[56] | 362 | } |
---|
[608] | 363 | } |
---|
| 364 | else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
| 365 | { |
---|
| 366 | assert( uiSubdiv ); |
---|
| 367 | } |
---|
| 368 | else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
| 369 | { |
---|
| 370 | assert( !uiSubdiv ); |
---|
| 371 | } |
---|
| 372 | else if( uiLog2TrafoSize == pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ) |
---|
| 373 | { |
---|
| 374 | assert( !uiSubdiv ); |
---|
| 375 | } |
---|
| 376 | else |
---|
| 377 | { |
---|
| 378 | assert( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ); |
---|
| 379 | m_pcEntropyCoderIf->codeTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize ); |
---|
| 380 | } |
---|
| 381 | |
---|
| 382 | const UInt uiTrDepthCurr = uiDepth - pcCU->getDepth( uiAbsPartIdx ); |
---|
| 383 | const Bool bFirstCbfOfCU = uiTrDepthCurr == 0; |
---|
| 384 | if( bFirstCbfOfCU || uiLog2TrafoSize > 2 ) |
---|
| 385 | { |
---|
| 386 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr - 1 ) ) |
---|
[56] | 387 | { |
---|
[608] | 388 | m_pcEntropyCoderIf->codeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr ); |
---|
[56] | 389 | } |
---|
[608] | 390 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr - 1 ) ) |
---|
[2] | 391 | { |
---|
[608] | 392 | m_pcEntropyCoderIf->codeQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr ); |
---|
[2] | 393 | } |
---|
[608] | 394 | } |
---|
| 395 | else if( uiLog2TrafoSize == 2 ) |
---|
| 396 | { |
---|
| 397 | assert( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr ) == pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepthCurr - 1 ) ); |
---|
| 398 | assert( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr ) == pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepthCurr - 1 ) ); |
---|
| 399 | } |
---|
| 400 | |
---|
| 401 | if( uiSubdiv ) |
---|
| 402 | { |
---|
| 403 | UInt size; |
---|
| 404 | width >>= 1; |
---|
| 405 | height >>= 1; |
---|
| 406 | size = width*height; |
---|
| 407 | uiTrIdx++; |
---|
| 408 | ++uiDepth; |
---|
| 409 | const UInt partNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
| 410 | |
---|
| 411 | xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP ); |
---|
| 412 | |
---|
| 413 | uiAbsPartIdx += partNum; offsetLuma += size; offsetChroma += (size>>2); |
---|
| 414 | xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP ); |
---|
| 415 | |
---|
| 416 | uiAbsPartIdx += partNum; offsetLuma += size; offsetChroma += (size>>2); |
---|
| 417 | xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP ); |
---|
| 418 | |
---|
| 419 | uiAbsPartIdx += partNum; offsetLuma += size; offsetChroma += (size>>2); |
---|
| 420 | xEncodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP ); |
---|
| 421 | } |
---|
| 422 | else |
---|
| 423 | { |
---|
| 424 | #if !H_MV_ENC_DEC_TRAC |
---|
[2] | 425 | { |
---|
[608] | 426 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
| 427 | DTRACE_CABAC_T( "\tTrIdx: abspart=" ); |
---|
| 428 | DTRACE_CABAC_V( uiAbsPartIdx ); |
---|
| 429 | DTRACE_CABAC_T( "\tdepth=" ); |
---|
| 430 | DTRACE_CABAC_V( uiDepth ); |
---|
| 431 | DTRACE_CABAC_T( "\ttrdepth=" ); |
---|
| 432 | DTRACE_CABAC_V( pcCU->getTransformIdx( uiAbsPartIdx ) ); |
---|
| 433 | DTRACE_CABAC_T( "\n" ); |
---|
[2] | 434 | } |
---|
[608] | 435 | #endif |
---|
| 436 | |
---|
| 437 | if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) ) |
---|
| 438 | { |
---|
| 439 | assert( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, 0 ) ); |
---|
| 440 | // printf( "saved one bin! " ); |
---|
| 441 | } |
---|
[2] | 442 | else |
---|
| 443 | { |
---|
[608] | 444 | m_pcEntropyCoderIf->codeQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, pcCU->getTransformIdx( uiAbsPartIdx ) ); |
---|
[2] | 445 | } |
---|
[56] | 446 | |
---|
[608] | 447 | |
---|
| 448 | if ( cbfY || cbfU || cbfV ) |
---|
[2] | 449 | { |
---|
[608] | 450 | // dQP: only for LCU once |
---|
| 451 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
[2] | 452 | { |
---|
[608] | 453 | if ( bCodeDQP ) |
---|
[2] | 454 | { |
---|
[608] | 455 | encodeQP( pcCU, m_bakAbsPartIdxCU ); |
---|
| 456 | bCodeDQP = false; |
---|
[2] | 457 | } |
---|
| 458 | } |
---|
| 459 | } |
---|
[608] | 460 | if( cbfY ) |
---|
[2] | 461 | { |
---|
[608] | 462 | Int trWidth = width; |
---|
| 463 | Int trHeight = height; |
---|
| 464 | m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffY()+offsetLuma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA ); |
---|
[2] | 465 | } |
---|
[608] | 466 | if( uiLog2TrafoSize > 2 ) |
---|
[2] | 467 | { |
---|
[608] | 468 | Int trWidth = width >> 1; |
---|
| 469 | Int trHeight = height >> 1; |
---|
| 470 | if( cbfU ) |
---|
[2] | 471 | { |
---|
[608] | 472 | m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffCb()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); |
---|
[2] | 473 | } |
---|
[608] | 474 | if( cbfV ) |
---|
[56] | 475 | { |
---|
[608] | 476 | m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffCr()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); |
---|
[56] | 477 | } |
---|
[608] | 478 | } |
---|
| 479 | else |
---|
| 480 | { |
---|
| 481 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
| 482 | if( ( uiAbsPartIdx % partNum ) == (partNum - 1) ) |
---|
[2] | 483 | { |
---|
[56] | 484 | Int trWidth = width; |
---|
| 485 | Int trHeight = height; |
---|
| 486 | if( cbfU ) |
---|
[2] | 487 | { |
---|
[608] | 488 | m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); |
---|
[2] | 489 | } |
---|
[56] | 490 | if( cbfV ) |
---|
| 491 | { |
---|
[608] | 492 | m_pcEntropyCoderIf->codeCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); |
---|
[56] | 493 | } |
---|
[2] | 494 | } |
---|
| 495 | } |
---|
| 496 | } |
---|
| 497 | } |
---|
| 498 | |
---|
| 499 | // Intra direction for Luma |
---|
[608] | 500 | Void TEncEntropy::encodeIntraDirModeLuma ( TComDataCU* pcCU, UInt absPartIdx, Bool isMultiplePU ) |
---|
[2] | 501 | { |
---|
[608] | 502 | m_pcEntropyCoderIf->codeIntraDirLumaAng( pcCU, absPartIdx , isMultiplePU); |
---|
[2] | 503 | } |
---|
| 504 | |
---|
| 505 | // Intra direction for Chroma |
---|
| 506 | Void TEncEntropy::encodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
| 507 | { |
---|
| 508 | if( bRD ) |
---|
[56] | 509 | { |
---|
[2] | 510 | uiAbsPartIdx = 0; |
---|
[56] | 511 | } |
---|
[2] | 512 | |
---|
| 513 | m_pcEntropyCoderIf->codeIntraDirChroma( pcCU, uiAbsPartIdx ); |
---|
| 514 | } |
---|
| 515 | |
---|
[608] | 516 | Void TEncEntropy::encodePredInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
[2] | 517 | { |
---|
| 518 | if( bRD ) |
---|
[56] | 519 | { |
---|
[2] | 520 | uiAbsPartIdx = 0; |
---|
[56] | 521 | } |
---|
[2] | 522 | if( pcCU->isIntra( uiAbsPartIdx ) ) // If it is Intra mode, encode intra prediction mode. |
---|
| 523 | { |
---|
[608] | 524 | encodeIntraDirModeLuma ( pcCU, uiAbsPartIdx,true ); |
---|
| 525 | #if H_3D_DIM_SDC |
---|
| 526 | if(!pcCU->getSDCFlag(uiAbsPartIdx)) |
---|
[443] | 527 | #endif |
---|
[608] | 528 | encodeIntraDirModeChroma( pcCU, uiAbsPartIdx, bRD ); |
---|
[2] | 529 | } |
---|
| 530 | else // if it is Inter mode, encode motion vector and reference index |
---|
| 531 | { |
---|
[56] | 532 | encodePUWise( pcCU, uiAbsPartIdx, bRD ); |
---|
[2] | 533 | } |
---|
| 534 | } |
---|
| 535 | |
---|
| 536 | /** encode motion information for every PU block |
---|
| 537 | * \param pcCU |
---|
| 538 | * \param uiAbsPartIdx |
---|
| 539 | * \param bRD |
---|
| 540 | * \returns Void |
---|
| 541 | */ |
---|
| 542 | Void TEncEntropy::encodePUWise( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
| 543 | { |
---|
| 544 | if ( bRD ) |
---|
[56] | 545 | { |
---|
[2] | 546 | uiAbsPartIdx = 0; |
---|
[56] | 547 | } |
---|
| 548 | |
---|
[2] | 549 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
| 550 | UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) ); |
---|
| 551 | UInt uiDepth = pcCU->getDepth( uiAbsPartIdx ); |
---|
| 552 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
| 553 | |
---|
| 554 | for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset ) |
---|
| 555 | { |
---|
[608] | 556 | #if H_MV_ENC_DEC_TRAC |
---|
| 557 | DTRACE_PU_S("=========== prediction_unit ===========\n") |
---|
| 558 | //Todo: |
---|
| 559 | //DTRACE_PU("x0", uiLPelX) |
---|
| 560 | //DTRACE_PU("x1", uiTPelY) |
---|
| 561 | #endif |
---|
| 562 | encodeMergeFlag( pcCU, uiSubPartIdx ); |
---|
[2] | 563 | if ( pcCU->getMergeFlag( uiSubPartIdx ) ) |
---|
| 564 | { |
---|
[608] | 565 | encodeMergeIndex( pcCU, uiSubPartIdx ); |
---|
[2] | 566 | } |
---|
| 567 | else |
---|
| 568 | { |
---|
| 569 | encodeInterDirPU( pcCU, uiSubPartIdx ); |
---|
| 570 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 571 | { |
---|
| 572 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
| 573 | { |
---|
| 574 | encodeRefFrmIdxPU ( pcCU, uiSubPartIdx, RefPicList( uiRefListIdx ) ); |
---|
| 575 | encodeMvdPU ( pcCU, uiSubPartIdx, RefPicList( uiRefListIdx ) ); |
---|
| 576 | encodeMVPIdxPU ( pcCU, uiSubPartIdx, RefPicList( uiRefListIdx ) ); |
---|
| 577 | } |
---|
| 578 | } |
---|
| 579 | } |
---|
| 580 | } |
---|
| 581 | |
---|
| 582 | return; |
---|
| 583 | } |
---|
| 584 | |
---|
| 585 | Void TEncEntropy::encodeInterDirPU( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 586 | { |
---|
| 587 | if ( !pcCU->getSlice()->isInterB() ) |
---|
| 588 | { |
---|
| 589 | return; |
---|
| 590 | } |
---|
| 591 | |
---|
| 592 | m_pcEntropyCoderIf->codeInterDir( pcCU, uiAbsPartIdx ); |
---|
| 593 | return; |
---|
| 594 | } |
---|
| 595 | |
---|
| 596 | /** encode reference frame index for a PU block |
---|
| 597 | * \param pcCU |
---|
| 598 | * \param uiAbsPartIdx |
---|
| 599 | * \param eRefList |
---|
| 600 | * \returns Void |
---|
| 601 | */ |
---|
| 602 | Void TEncEntropy::encodeRefFrmIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
| 603 | { |
---|
| 604 | assert( !pcCU->isIntra( uiAbsPartIdx ) ); |
---|
| 605 | { |
---|
[56] | 606 | if ( ( pcCU->getSlice()->getNumRefIdx( eRefList ) == 1 ) ) |
---|
| 607 | { |
---|
| 608 | return; |
---|
| 609 | } |
---|
[2] | 610 | |
---|
[56] | 611 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
| 612 | { |
---|
| 613 | m_pcEntropyCoderIf->codeRefFrmIdx( pcCU, uiAbsPartIdx, eRefList ); |
---|
| 614 | } |
---|
[2] | 615 | } |
---|
| 616 | |
---|
| 617 | return; |
---|
| 618 | } |
---|
| 619 | |
---|
| 620 | /** encode motion vector difference for a PU block |
---|
| 621 | * \param pcCU |
---|
| 622 | * \param uiAbsPartIdx |
---|
| 623 | * \param eRefList |
---|
| 624 | * \returns Void |
---|
| 625 | */ |
---|
| 626 | Void TEncEntropy::encodeMvdPU( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
| 627 | { |
---|
| 628 | assert( !pcCU->isIntra( uiAbsPartIdx ) ); |
---|
| 629 | |
---|
| 630 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
| 631 | { |
---|
| 632 | m_pcEntropyCoderIf->codeMvd( pcCU, uiAbsPartIdx, eRefList ); |
---|
| 633 | } |
---|
| 634 | return; |
---|
| 635 | } |
---|
| 636 | |
---|
| 637 | Void TEncEntropy::encodeMVPIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
| 638 | { |
---|
[608] | 639 | if ( (pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList )) ) |
---|
[2] | 640 | { |
---|
| 641 | m_pcEntropyCoderIf->codeMVPIdx( pcCU, uiAbsPartIdx, eRefList ); |
---|
| 642 | } |
---|
| 643 | |
---|
| 644 | return; |
---|
| 645 | } |
---|
| 646 | |
---|
| 647 | Void TEncEntropy::encodeQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) |
---|
| 648 | { |
---|
| 649 | m_pcEntropyCoderIf->codeQtCbf( pcCU, uiAbsPartIdx, eType, uiTrDepth ); |
---|
| 650 | } |
---|
| 651 | |
---|
| 652 | Void TEncEntropy::encodeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ) |
---|
| 653 | { |
---|
| 654 | m_pcEntropyCoderIf->codeTransformSubdivFlag( uiSymbol, uiCtx ); |
---|
| 655 | } |
---|
| 656 | |
---|
| 657 | Void TEncEntropy::encodeQtRootCbf( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 658 | { |
---|
| 659 | m_pcEntropyCoderIf->codeQtRootCbf( pcCU, uiAbsPartIdx ); |
---|
| 660 | } |
---|
| 661 | |
---|
[608] | 662 | Void TEncEntropy::encodeQtCbfZero( TComDataCU* pcCU, TextType eType, UInt uiTrDepth ) |
---|
| 663 | { |
---|
| 664 | m_pcEntropyCoderIf->codeQtCbfZero( pcCU, eType, uiTrDepth ); |
---|
| 665 | } |
---|
| 666 | Void TEncEntropy::encodeQtRootCbfZero( TComDataCU* pcCU ) |
---|
| 667 | { |
---|
| 668 | m_pcEntropyCoderIf->codeQtRootCbfZero( pcCU ); |
---|
| 669 | } |
---|
| 670 | |
---|
[2] | 671 | // dQP |
---|
| 672 | Void TEncEntropy::encodeQP( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
| 673 | { |
---|
| 674 | if( bRD ) |
---|
[56] | 675 | { |
---|
[2] | 676 | uiAbsPartIdx = 0; |
---|
[56] | 677 | } |
---|
[2] | 678 | |
---|
[56] | 679 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
[2] | 680 | { |
---|
| 681 | m_pcEntropyCoderIf->codeDeltaQP( pcCU, uiAbsPartIdx ); |
---|
| 682 | } |
---|
| 683 | } |
---|
| 684 | |
---|
| 685 | |
---|
| 686 | // texture |
---|
| 687 | /** encode coefficients |
---|
| 688 | * \param pcCU |
---|
| 689 | * \param uiAbsPartIdx |
---|
| 690 | * \param uiDepth |
---|
| 691 | * \param uiWidth |
---|
| 692 | * \param uiHeight |
---|
| 693 | */ |
---|
[56] | 694 | Void TEncEntropy::encodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP ) |
---|
[2] | 695 | { |
---|
| 696 | UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); |
---|
| 697 | UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; |
---|
| 698 | UInt uiChromaOffset = uiLumaOffset>>2; |
---|
[833] | 699 | #if H_3D_DIM_SDC |
---|
| 700 | if( pcCU->getSDCFlag( uiAbsPartIdx ) && pcCU->isIntra( uiAbsPartIdx ) ) |
---|
| 701 | { |
---|
| 702 | assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); |
---|
| 703 | assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 ); |
---|
| 704 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 ); |
---|
| 705 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 ); |
---|
| 706 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 ); |
---|
| 707 | } |
---|
| 708 | |
---|
| 709 | if( pcCU->getSDCFlag( uiAbsPartIdx ) && !pcCU->isIntra( uiAbsPartIdx ) ) |
---|
| 710 | { |
---|
| 711 | assert( !pcCU->isSkipped( uiAbsPartIdx ) ); |
---|
| 712 | assert( !pcCU->isIntra( uiAbsPartIdx) ); |
---|
| 713 | assert( pcCU->getSlice()->getIsDepth() ); |
---|
| 714 | } |
---|
[884] | 715 | |
---|
[833] | 716 | if( pcCU->getSlice()->getIsDepth() && ( pcCU->getSDCFlag( uiAbsPartIdx ) || pcCU->isIntra( uiAbsPartIdx ) ) ) |
---|
| 717 | { |
---|
| 718 | Int iPartNum = ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ? 4 : 1; |
---|
| 719 | UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth( uiAbsPartIdx ) << 1 ) ) >> 2; |
---|
[608] | 720 | |
---|
[833] | 721 | if( !pcCU->getSDCFlag( uiAbsPartIdx ) ) |
---|
| 722 | { |
---|
| 723 | for( Int iPart = 0; iPart < iPartNum; iPart++ ) |
---|
| 724 | { |
---|
| 725 | if( getDimType( pcCU->getLumaIntraDir( uiAbsPartIdx + uiPartOffset*iPart ) ) < DIM_NUM_TYPE ) |
---|
| 726 | { |
---|
| 727 | m_pcEntropyCoderIf->codeDeltaDC( pcCU, uiAbsPartIdx + uiPartOffset*iPart ); |
---|
| 728 | } |
---|
| 729 | } |
---|
| 730 | } |
---|
| 731 | else |
---|
| 732 | { |
---|
| 733 | m_pcEntropyCoderIf->codeDeltaDC( pcCU, uiAbsPartIdx ); |
---|
| 734 | return; |
---|
| 735 | } |
---|
| 736 | } |
---|
[443] | 737 | #endif |
---|
[608] | 738 | |
---|
[2] | 739 | if( pcCU->isIntra(uiAbsPartIdx) ) |
---|
| 740 | { |
---|
[608] | 741 | #if !H_MV |
---|
[56] | 742 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
[2] | 743 | DTRACE_CABAC_T( "\tdecodeTransformIdx()\tCUDepth=" ) |
---|
| 744 | DTRACE_CABAC_V( uiDepth ) |
---|
| 745 | DTRACE_CABAC_T( "\n" ) |
---|
[608] | 746 | #endif |
---|
[2] | 747 | } |
---|
| 748 | else |
---|
| 749 | { |
---|
[608] | 750 | if( !(pcCU->getMergeFlag( uiAbsPartIdx ) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ) ) |
---|
[2] | 751 | { |
---|
[608] | 752 | m_pcEntropyCoderIf->codeQtRootCbf( pcCU, uiAbsPartIdx ); |
---|
[2] | 753 | } |
---|
[608] | 754 | if ( !pcCU->getQtRootCbf( uiAbsPartIdx ) ) |
---|
[189] | 755 | { |
---|
[608] | 756 | return; |
---|
[189] | 757 | } |
---|
| 758 | } |
---|
[608] | 759 | |
---|
| 760 | xEncodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, bCodeDQP); |
---|
[2] | 761 | } |
---|
| 762 | |
---|
[56] | 763 | Void TEncEntropy::encodeCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoeff, UInt uiAbsPartIdx, UInt uiTrWidth, UInt uiTrHeight, UInt uiDepth, TextType eType ) |
---|
[608] | 764 | { |
---|
| 765 | // This is for Transform unit processing. This may be used at mode selection stage for Inter. |
---|
[56] | 766 | m_pcEntropyCoderIf->codeCoeffNxN( pcCU, pcCoeff, uiAbsPartIdx, uiTrWidth, uiTrHeight, uiDepth, eType ); |
---|
[2] | 767 | } |
---|
| 768 | |
---|
[56] | 769 | Void TEncEntropy::estimateBit (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, TextType eTType) |
---|
| 770 | { |
---|
| 771 | eTType = eTType == TEXT_LUMA ? TEXT_LUMA : TEXT_CHROMA; |
---|
| 772 | |
---|
| 773 | m_pcEntropyCoderIf->estBit ( pcEstBitsSbac, width, height, eTType ); |
---|
| 774 | } |
---|
| 775 | |
---|
| 776 | Int TEncEntropy::countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize ) |
---|
| 777 | { |
---|
| 778 | Int count = 0; |
---|
| 779 | |
---|
| 780 | for ( Int i = 0; i < uiSize; i++ ) |
---|
[2] | 781 | { |
---|
[56] | 782 | count += pcCoef[i] != 0; |
---|
[2] | 783 | } |
---|
[56] | 784 | |
---|
| 785 | return count; |
---|
| 786 | } |
---|
[2] | 787 | |
---|
[56] | 788 | /** encode quantization matrix |
---|
| 789 | * \param scalingList quantization matrix information |
---|
| 790 | */ |
---|
| 791 | Void TEncEntropy::encodeScalingList( TComScalingList* scalingList ) |
---|
| 792 | { |
---|
| 793 | m_pcEntropyCoderIf->codeScalingList( scalingList ); |
---|
[2] | 794 | } |
---|
| 795 | |
---|
[655] | 796 | #if H_3D_INTER_SDC |
---|
[833] | 797 | Void TEncEntropy::encodeDeltaDC ( TComDataCU* pcCU, UInt absPartIdx ) |
---|
| 798 | { |
---|
| 799 | m_pcEntropyCoderIf->codeDeltaDC( pcCU, absPartIdx ); |
---|
| 800 | } |
---|
| 801 | |
---|
| 802 | Void TEncEntropy::encodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
| 803 | { |
---|
[1106] | 804 | #if HHI_TOOL_PARAMETERS_I2_J0107 |
---|
| 805 | if( ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getInterSdcFlag() ) || |
---|
| 806 | ( pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getIntraSdcWedgeFlag() ) ) |
---|
| 807 | #else |
---|
[833] | 808 | if( ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getVPS()->getInterSDCFlag( pcCU->getSlice()->getLayerIdInVps() ) ) || |
---|
| 809 | ( pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getVPS()->getVpsDepthModesFlag( pcCU->getSlice()->getLayerIdInVps() ) ) ) |
---|
[1106] | 810 | #endif |
---|
[833] | 811 | { |
---|
| 812 | return; |
---|
| 813 | } |
---|
| 814 | |
---|
| 815 | if( !pcCU->getSlice()->getIsDepth() || pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_2Nx2N || pcCU->isSkipped( uiAbsPartIdx ) ) |
---|
| 816 | { |
---|
| 817 | return; |
---|
| 818 | } |
---|
| 819 | |
---|
| 820 | assert( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N || ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->isSkipped( uiAbsPartIdx ) ) ); |
---|
| 821 | |
---|
| 822 | if( bRD ) |
---|
| 823 | { |
---|
| 824 | uiAbsPartIdx = 0; |
---|
| 825 | } |
---|
| 826 | |
---|
| 827 | m_pcEntropyCoderIf->codeSDCFlag( pcCU, uiAbsPartIdx ); |
---|
| 828 | } |
---|
[2] | 829 | |
---|
[189] | 830 | #endif |
---|
[833] | 831 | #if H_3D_DBBP |
---|
| 832 | Void TEncEntropy::encodeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) |
---|
| 833 | { |
---|
| 834 | if( bRD ) |
---|
| 835 | { |
---|
| 836 | uiAbsPartIdx = 0; |
---|
| 837 | } |
---|
| 838 | m_pcEntropyCoderIf->codeDBBPFlag( pcCU, uiAbsPartIdx ); |
---|
| 839 | } |
---|
| 840 | #endif |
---|
[56] | 841 | //! \} |
---|