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