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