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