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