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