[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 |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
| 6 | * Copyright (c) 2010-2011, 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 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 | */ |
---|
[2] | 33 | |
---|
| 34 | |
---|
[5] | 35 | |
---|
[2] | 36 | /** \file TDecEntropy.cpp |
---|
| 37 | \brief entropy decoder class |
---|
| 38 | */ |
---|
| 39 | |
---|
| 40 | #include "TDecEntropy.h" |
---|
| 41 | |
---|
| 42 | Void TDecEntropy::setEntropyDecoder ( TDecEntropyIf* p ) |
---|
| 43 | { |
---|
| 44 | m_pcEntropyDecoderIf = p; |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | #include "../TLibCommon/TComAdaptiveLoopFilter.h" |
---|
| 48 | |
---|
| 49 | Void TDecEntropy::decodeAux(ALFParam* pAlfParam) |
---|
| 50 | { |
---|
| 51 | UInt uiSymbol; |
---|
| 52 | Int sqrFiltLengthTab[3] = {SQR_FILT_LENGTH_9SYM, SQR_FILT_LENGTH_7SYM, SQR_FILT_LENGTH_5SYM}; |
---|
| 53 | Int FiltTab[3] = {9, 7, 5}; |
---|
| 54 | |
---|
| 55 | pAlfParam->filters_per_group = 0; |
---|
| 56 | |
---|
| 57 | memset (pAlfParam->filterPattern, 0 , sizeof(Int)*NO_VAR_BINS); |
---|
| 58 | #if ENABLE_FORCECOEFF0 |
---|
| 59 | m_pcEntropyDecoderIf->parseAlfFlag(uiSymbol); |
---|
| 60 | if (!uiSymbol) pAlfParam->filtNo = -1; |
---|
| 61 | else pAlfParam->filtNo = uiSymbol; //nonZeroCoeffs |
---|
| 62 | #else |
---|
| 63 | pAlfParam->filtNo = 1; //nonZeroCoeffs |
---|
| 64 | #endif |
---|
| 65 | |
---|
| 66 | #if MQT_BA_RA |
---|
| 67 | m_pcEntropyDecoderIf->parseAlfFlag (uiSymbol); |
---|
| 68 | pAlfParam->alf_pcr_region_flag = uiSymbol; |
---|
| 69 | #endif |
---|
| 70 | |
---|
| 71 | m_pcEntropyDecoderIf->parseAlfUvlc(uiSymbol); |
---|
| 72 | Int TabIdx = uiSymbol; |
---|
| 73 | pAlfParam->realfiltNo = 2-TabIdx; |
---|
| 74 | pAlfParam->tap = FiltTab[pAlfParam->realfiltNo]; |
---|
| 75 | #if TI_ALF_MAX_VSIZE_7 |
---|
| 76 | pAlfParam->tapV = TComAdaptiveLoopFilter::ALFTapHToTapV(pAlfParam->tap); |
---|
| 77 | #endif |
---|
| 78 | pAlfParam->num_coeff = sqrFiltLengthTab[pAlfParam->realfiltNo]; |
---|
| 79 | |
---|
| 80 | if (pAlfParam->filtNo>=0) |
---|
| 81 | { |
---|
| 82 | if(pAlfParam->realfiltNo >= 0) |
---|
| 83 | { |
---|
| 84 | // filters_per_fr |
---|
| 85 | m_pcEntropyDecoderIf->parseAlfUvlc(uiSymbol); |
---|
| 86 | pAlfParam->noFilters = uiSymbol + 1; |
---|
| 87 | pAlfParam->filters_per_group = pAlfParam->noFilters; |
---|
| 88 | |
---|
| 89 | if(pAlfParam->noFilters == 2) |
---|
| 90 | { |
---|
| 91 | m_pcEntropyDecoderIf->parseAlfUvlc(uiSymbol); |
---|
| 92 | pAlfParam->startSecondFilter = uiSymbol; |
---|
| 93 | pAlfParam->filterPattern [uiSymbol] = 1; |
---|
| 94 | } |
---|
| 95 | else if (pAlfParam->noFilters > 2) |
---|
| 96 | { |
---|
| 97 | pAlfParam->filters_per_group = 1; |
---|
| 98 | for (int i=1; i<NO_VAR_BINS; i++) |
---|
| 99 | { |
---|
| 100 | m_pcEntropyDecoderIf->parseAlfFlag (uiSymbol); |
---|
| 101 | pAlfParam->filterPattern[i] = uiSymbol; |
---|
| 102 | pAlfParam->filters_per_group += uiSymbol; |
---|
| 103 | } |
---|
| 104 | } |
---|
| 105 | } |
---|
| 106 | } |
---|
| 107 | else |
---|
| 108 | { |
---|
| 109 | memset (pAlfParam->filterPattern, 0, NO_VAR_BINS*sizeof(Int)); |
---|
| 110 | } |
---|
| 111 | // Reconstruct varIndTab[] |
---|
| 112 | memset(pAlfParam->varIndTab, 0, NO_VAR_BINS * sizeof(int)); |
---|
| 113 | if(pAlfParam->filtNo>=0) |
---|
| 114 | { |
---|
| 115 | for(Int i = 1; i < NO_VAR_BINS; ++i) |
---|
| 116 | { |
---|
| 117 | if(pAlfParam->filterPattern[i]) |
---|
| 118 | pAlfParam->varIndTab[i] = pAlfParam->varIndTab[i-1] + 1; |
---|
| 119 | else |
---|
| 120 | pAlfParam->varIndTab[i] = pAlfParam->varIndTab[i-1]; |
---|
| 121 | } |
---|
| 122 | } |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | Void TDecEntropy::readFilterCodingParams(ALFParam* pAlfParam) |
---|
| 126 | { |
---|
| 127 | UInt uiSymbol; |
---|
| 128 | int ind, scanPos; |
---|
| 129 | int golombIndexBit; |
---|
| 130 | int kMin; |
---|
| 131 | int maxScanVal; |
---|
| 132 | int *pDepthInt; |
---|
| 133 | int fl; |
---|
| 134 | |
---|
| 135 | // Determine fl |
---|
| 136 | if(pAlfParam->num_coeff == SQR_FILT_LENGTH_9SYM) |
---|
| 137 | fl = 4; |
---|
| 138 | else if(pAlfParam->num_coeff == SQR_FILT_LENGTH_7SYM) |
---|
| 139 | fl = 3; |
---|
| 140 | else |
---|
| 141 | fl = 2; |
---|
| 142 | |
---|
| 143 | // Determine maxScanVal |
---|
| 144 | maxScanVal = 0; |
---|
| 145 | pDepthInt = pDepthIntTab[fl - 2]; |
---|
| 146 | for(ind = 0; ind < pAlfParam->num_coeff; ind++) |
---|
| 147 | maxScanVal = max(maxScanVal, pDepthInt[ind]); |
---|
| 148 | |
---|
| 149 | // Golomb parameters |
---|
| 150 | m_pcEntropyDecoderIf->parseAlfUvlc(uiSymbol); |
---|
| 151 | pAlfParam->minKStart = 1 + uiSymbol; |
---|
| 152 | |
---|
| 153 | kMin = pAlfParam->minKStart; |
---|
| 154 | for(scanPos = 0; scanPos < maxScanVal; scanPos++) |
---|
| 155 | { |
---|
| 156 | m_pcEntropyDecoderIf->parseAlfFlag(uiSymbol); |
---|
| 157 | golombIndexBit = uiSymbol; |
---|
| 158 | if(golombIndexBit) |
---|
| 159 | pAlfParam->kMinTab[scanPos] = kMin + 1; |
---|
| 160 | else |
---|
| 161 | pAlfParam->kMinTab[scanPos] = kMin; |
---|
| 162 | kMin = pAlfParam->kMinTab[scanPos]; |
---|
| 163 | } |
---|
| 164 | } |
---|
| 165 | |
---|
| 166 | Int TDecEntropy::golombDecode(Int k) |
---|
| 167 | { |
---|
| 168 | UInt uiSymbol; |
---|
| 169 | Int q = -1; |
---|
| 170 | Int nr = 0; |
---|
| 171 | Int m = (Int)pow(2.0, k); |
---|
| 172 | Int a; |
---|
| 173 | |
---|
| 174 | uiSymbol = 1; |
---|
| 175 | while (uiSymbol) |
---|
| 176 | { |
---|
| 177 | m_pcEntropyDecoderIf->parseAlfFlag(uiSymbol); |
---|
| 178 | q++; |
---|
| 179 | } |
---|
| 180 | for(a = 0; a < k; ++a) // read out the sequential log2(M) bits |
---|
| 181 | { |
---|
| 182 | m_pcEntropyDecoderIf->parseAlfFlag(uiSymbol); |
---|
| 183 | if(uiSymbol) |
---|
| 184 | nr += 1 << a; |
---|
| 185 | } |
---|
| 186 | nr += q * m; // add the bits and the multiple of M |
---|
| 187 | if(nr != 0) |
---|
| 188 | { |
---|
| 189 | m_pcEntropyDecoderIf->parseAlfFlag(uiSymbol); |
---|
| 190 | nr = (uiSymbol)? nr: -nr; |
---|
| 191 | } |
---|
| 192 | return nr; |
---|
| 193 | } |
---|
| 194 | |
---|
| 195 | |
---|
| 196 | |
---|
| 197 | Void TDecEntropy::readFilterCoeffs(ALFParam* pAlfParam) |
---|
| 198 | { |
---|
| 199 | int ind, scanPos, i; |
---|
| 200 | int *pDepthInt; |
---|
| 201 | int fl; |
---|
| 202 | |
---|
| 203 | if(pAlfParam->num_coeff == SQR_FILT_LENGTH_9SYM) |
---|
| 204 | fl = 4; |
---|
| 205 | else if(pAlfParam->num_coeff == SQR_FILT_LENGTH_7SYM) |
---|
| 206 | fl = 3; |
---|
| 207 | else |
---|
| 208 | fl = 2; |
---|
| 209 | |
---|
| 210 | pDepthInt = pDepthIntTab[fl - 2]; |
---|
| 211 | |
---|
| 212 | for(ind = 0; ind < pAlfParam->filters_per_group_diff; ++ind) |
---|
| 213 | { |
---|
| 214 | for(i = 0; i < pAlfParam->num_coeff; i++) |
---|
| 215 | { |
---|
| 216 | scanPos = pDepthInt[i] - 1; |
---|
| 217 | pAlfParam->coeffmulti[ind][i] = golombDecode(pAlfParam->kMinTab[scanPos]); |
---|
| 218 | } |
---|
| 219 | } |
---|
| 220 | |
---|
| 221 | } |
---|
| 222 | Void TDecEntropy::decodeFilterCoeff (ALFParam* pAlfParam) |
---|
| 223 | { |
---|
| 224 | readFilterCodingParams (pAlfParam); |
---|
| 225 | readFilterCoeffs (pAlfParam); |
---|
| 226 | } |
---|
| 227 | |
---|
| 228 | |
---|
| 229 | |
---|
| 230 | Void TDecEntropy::decodeFilt(ALFParam* pAlfParam) |
---|
| 231 | { |
---|
| 232 | UInt uiSymbol; |
---|
| 233 | |
---|
| 234 | if (pAlfParam->filtNo >= 0) |
---|
| 235 | { |
---|
| 236 | pAlfParam->filters_per_group_diff = pAlfParam->filters_per_group; |
---|
| 237 | if (pAlfParam->filters_per_group > 1) |
---|
| 238 | { |
---|
| 239 | #if ENABLE_FORCECOEFF0 |
---|
| 240 | m_pcEntropyDecoderIf->parseAlfFlag (uiSymbol); |
---|
| 241 | pAlfParam->forceCoeff0 = uiSymbol; |
---|
| 242 | |
---|
| 243 | if (pAlfParam->forceCoeff0) |
---|
| 244 | { |
---|
| 245 | pAlfParam->filters_per_group_diff = 0; |
---|
| 246 | for (int i=0; i<pAlfParam->filters_per_group; i++) |
---|
| 247 | { |
---|
| 248 | m_pcEntropyDecoderIf->parseAlfFlag (uiSymbol); |
---|
| 249 | pAlfParam->codedVarBins[i] = uiSymbol; |
---|
| 250 | pAlfParam->filters_per_group_diff += uiSymbol; |
---|
| 251 | } |
---|
| 252 | } |
---|
| 253 | else |
---|
| 254 | #else |
---|
| 255 | pAlfParam->forceCoeff0 = 0; |
---|
| 256 | #endif |
---|
| 257 | { |
---|
| 258 | for (int i=0; i<NO_VAR_BINS; i++) |
---|
| 259 | pAlfParam->codedVarBins[i] = 1; |
---|
| 260 | |
---|
| 261 | } |
---|
| 262 | m_pcEntropyDecoderIf->parseAlfFlag (uiSymbol); |
---|
| 263 | pAlfParam->predMethod = uiSymbol; |
---|
| 264 | } |
---|
| 265 | else |
---|
| 266 | { |
---|
| 267 | pAlfParam->forceCoeff0 = 0; |
---|
| 268 | pAlfParam->predMethod = 0; |
---|
| 269 | } |
---|
| 270 | |
---|
| 271 | decodeFilterCoeff (pAlfParam); |
---|
| 272 | } |
---|
| 273 | } |
---|
| 274 | |
---|
| 275 | Void TDecEntropy::decodeAlfParam(ALFParam* pAlfParam) |
---|
| 276 | { |
---|
| 277 | UInt uiSymbol; |
---|
| 278 | Int iSymbol; |
---|
| 279 | m_pcEntropyDecoderIf->parseAlfFlag(uiSymbol); |
---|
| 280 | pAlfParam->alf_flag = uiSymbol; |
---|
| 281 | |
---|
| 282 | if (!pAlfParam->alf_flag) |
---|
| 283 | { |
---|
| 284 | m_pcEntropyDecoderIf->setAlfCtrl(false); |
---|
| 285 | m_pcEntropyDecoderIf->setMaxAlfCtrlDepth(0); //unncessary |
---|
| 286 | return; |
---|
| 287 | } |
---|
| 288 | |
---|
| 289 | Int pos; |
---|
| 290 | decodeAux(pAlfParam); |
---|
| 291 | decodeFilt(pAlfParam); |
---|
| 292 | // filter parameters for chroma |
---|
| 293 | m_pcEntropyDecoderIf->parseAlfUvlc(uiSymbol); |
---|
| 294 | pAlfParam->chroma_idc = uiSymbol; |
---|
| 295 | |
---|
| 296 | if(pAlfParam->chroma_idc) |
---|
| 297 | { |
---|
| 298 | m_pcEntropyDecoderIf->parseAlfUvlc(uiSymbol); |
---|
| 299 | pAlfParam->tap_chroma = (uiSymbol<<1) + 5; |
---|
| 300 | pAlfParam->num_coeff_chroma = ((pAlfParam->tap_chroma*pAlfParam->tap_chroma+1)>>1) + 1; |
---|
| 301 | |
---|
| 302 | // filter coefficients for chroma |
---|
| 303 | for(pos=0; pos<pAlfParam->num_coeff_chroma; pos++) |
---|
| 304 | { |
---|
| 305 | m_pcEntropyDecoderIf->parseAlfSvlc(iSymbol); |
---|
| 306 | pAlfParam->coeff_chroma[pos] = iSymbol; |
---|
| 307 | } |
---|
| 308 | } |
---|
| 309 | |
---|
| 310 | // region control parameters for luma |
---|
| 311 | m_pcEntropyDecoderIf->parseAlfFlag(uiSymbol); |
---|
| 312 | pAlfParam->cu_control_flag = uiSymbol; |
---|
| 313 | if (pAlfParam->cu_control_flag) |
---|
| 314 | { |
---|
| 315 | m_pcEntropyDecoderIf->setAlfCtrl(true); |
---|
| 316 | m_pcEntropyDecoderIf->parseAlfCtrlDepth(uiSymbol); |
---|
| 317 | m_pcEntropyDecoderIf->setMaxAlfCtrlDepth(uiSymbol); |
---|
| 318 | #if TSB_ALF_HEADER |
---|
| 319 | pAlfParam->alf_max_depth = uiSymbol; |
---|
| 320 | decodeAlfCtrlParam(pAlfParam); |
---|
| 321 | #endif |
---|
| 322 | } |
---|
| 323 | else |
---|
| 324 | { |
---|
| 325 | m_pcEntropyDecoderIf->setAlfCtrl(false); |
---|
| 326 | m_pcEntropyDecoderIf->setMaxAlfCtrlDepth(0); //unncessary |
---|
| 327 | } |
---|
| 328 | } |
---|
| 329 | |
---|
| 330 | #if TSB_ALF_HEADER |
---|
| 331 | Void TDecEntropy::decodeAlfCtrlParam( ALFParam* pAlfParam ) |
---|
| 332 | { |
---|
| 333 | UInt uiSymbol; |
---|
| 334 | m_pcEntropyDecoderIf->parseAlfFlagNum( uiSymbol, pAlfParam->num_cus_in_frame, pAlfParam->alf_max_depth ); |
---|
| 335 | pAlfParam->num_alf_cu_flag = uiSymbol; |
---|
| 336 | |
---|
| 337 | for(UInt i=0; i<pAlfParam->num_alf_cu_flag; i++) |
---|
| 338 | { |
---|
| 339 | m_pcEntropyDecoderIf->parseAlfCtrlFlag( pAlfParam->alf_cu_flag[i] ); |
---|
| 340 | } |
---|
| 341 | } |
---|
| 342 | #endif |
---|
| 343 | |
---|
| 344 | Void TDecEntropy::decodeAlfCtrlFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 345 | { |
---|
| 346 | m_pcEntropyDecoderIf->parseAlfCtrlFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 347 | } |
---|
| 348 | |
---|
| 349 | Void TDecEntropy::decodeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 350 | { |
---|
| 351 | m_pcEntropyDecoderIf->parseSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 352 | } |
---|
| 353 | |
---|
| 354 | /** decode merge flag |
---|
| 355 | * \param pcSubCU |
---|
| 356 | * \param uiAbsPartIdx |
---|
| 357 | * \param uiDepth |
---|
| 358 | * \param uiPUIdx |
---|
| 359 | * \returns Void |
---|
| 360 | */ |
---|
| 361 | Void TDecEntropy::decodeMergeFlag( TComDataCU* pcSubCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) |
---|
| 362 | { |
---|
| 363 | #if !CHANGE_GET_MERGE_CANDIDATE |
---|
| 364 | UInt uiNumCand = 0; |
---|
| 365 | for(UInt uiIter = 0; uiIter < MRG_MAX_NUM_CANDS; uiIter++ ) |
---|
| 366 | { |
---|
| 367 | if( pcSubCU->getNeighbourCandIdx( uiIter, uiAbsPartIdx ) == ( uiIter + 1 ) ) |
---|
| 368 | { |
---|
| 369 | uiNumCand++; |
---|
| 370 | break; |
---|
| 371 | } |
---|
| 372 | } |
---|
| 373 | if( uiNumCand ) |
---|
| 374 | { |
---|
| 375 | #endif |
---|
| 376 | // at least one merge candidate exists |
---|
| 377 | m_pcEntropyDecoderIf->parseMergeFlag( pcSubCU, uiAbsPartIdx, uiDepth, uiPUIdx ); |
---|
| 378 | #if !CHANGE_GET_MERGE_CANDIDATE |
---|
| 379 | } |
---|
| 380 | else |
---|
| 381 | { |
---|
| 382 | assert( !pcSubCU->getMergeFlag( uiAbsPartIdx ) ); |
---|
| 383 | } |
---|
| 384 | #endif |
---|
| 385 | } |
---|
| 386 | |
---|
| 387 | /** decode merge index |
---|
| 388 | * \param pcCU |
---|
| 389 | * \param uiPartIdx |
---|
| 390 | * \param uiAbsPartIdx |
---|
| 391 | * \param puhInterDirNeighbours pointer to list of inter direction from the casual neighbours |
---|
| 392 | * \param pcMvFieldNeighbours pointer to list of motion vector field from the casual neighbours |
---|
| 393 | * \param uiDepth |
---|
| 394 | * \returns Void |
---|
| 395 | */ |
---|
| 396 | Void TDecEntropy::decodeMergeIndex( TComDataCU* pcCU, UInt uiPartIdx, UInt uiAbsPartIdx, PartSize eCUMode, UChar* puhInterDirNeighbours, TComMvField* pcMvFieldNeighbours, UInt uiDepth ) |
---|
| 397 | { |
---|
| 398 | UInt uiNumCand = 0; |
---|
| 399 | for(UInt uiIter = 0; uiIter < MRG_MAX_NUM_CANDS; uiIter++ ) |
---|
| 400 | { |
---|
| 401 | if( pcCU->getNeighbourCandIdx( uiIter, uiAbsPartIdx ) == ( uiIter + 1 ) ) |
---|
| 402 | { |
---|
| 403 | uiNumCand++; |
---|
| 404 | } |
---|
| 405 | } |
---|
[5] | 406 | #if HHI_MPI |
---|
[2] | 407 | if( pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) |
---|
| 408 | uiNumCand++; |
---|
| 409 | #endif |
---|
| 410 | // Merge to left or above depending on uiMergeIndex |
---|
| 411 | UInt uiMergeIndex = 0; |
---|
| 412 | if ( uiNumCand > 1 ) |
---|
| 413 | { |
---|
| 414 | // two different motion parameter sets exist |
---|
| 415 | // parse merge index. |
---|
| 416 | m_pcEntropyDecoderIf->parseMergeIndex( pcCU, uiMergeIndex, uiAbsPartIdx, uiDepth ); |
---|
| 417 | } |
---|
| 418 | else |
---|
| 419 | { |
---|
| 420 | for( UInt uiIter = 0; uiIter < MRG_MAX_NUM_CANDS; uiIter++ ) |
---|
| 421 | { |
---|
| 422 | if( pcCU->getNeighbourCandIdx( uiIter, uiAbsPartIdx ) == ( uiIter + 1 ) ) |
---|
| 423 | { |
---|
| 424 | uiMergeIndex = uiIter; |
---|
| 425 | break; |
---|
| 426 | } |
---|
| 427 | } |
---|
| 428 | } |
---|
| 429 | pcCU->setMergeIndexSubParts( uiMergeIndex, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
| 430 | pcCU->setInterDirSubParts( puhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
| 431 | |
---|
[12] | 432 | #if POZNAN_EIVD_CALC_PRED_DATA |
---|
| 433 | Int ref_idx0_EIVD,ref_idx1_EIVD; |
---|
| 434 | TComMv cMv0_EIVD( 0, 0 ),cMv1_EIVD( 0, 0 ); |
---|
| 435 | if(uiMergeIndex==POZNAN_EIVD_MRG_CAND) |
---|
| 436 | { |
---|
| 437 | pcCU->getCUMvField2nd( REF_PIC_LIST_0 )->setAllMvField( pcMvFieldNeighbours[ 2*uiMergeIndex ].getMv(), pcMvFieldNeighbours[ 2*uiMergeIndex ].getRefIdx(), eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
| 438 | pcCU->getCUMvField2nd( REF_PIC_LIST_1 )->setAllMvField( pcMvFieldNeighbours[ 2*uiMergeIndex + 1 ].getMv(), pcMvFieldNeighbours[ 2*uiMergeIndex + 1 ].getRefIdx(), eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
| 439 | pcCU->getSlice()->getMP()->calcEIVDPredData(pcCU, uiAbsPartIdx, ref_idx0_EIVD, cMv0_EIVD, ref_idx1_EIVD, cMv1_EIVD); |
---|
| 440 | } |
---|
| 441 | #endif |
---|
| 442 | |
---|
[2] | 443 | TComMv cTmpMv( 0, 0 ); |
---|
| 444 | if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) > 0 ) //if ( ref. frame list0 has at least 1 entry ) |
---|
| 445 | { |
---|
| 446 | pcCU->setMVPIdxSubParts( 0, REF_PIC_LIST_0, uiAbsPartIdx, uiPartIdx, uiDepth); |
---|
| 447 | pcCU->setMVPNumSubParts( 0, REF_PIC_LIST_0, uiAbsPartIdx, uiPartIdx, uiDepth); |
---|
| 448 | pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvd( cTmpMv, eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
[12] | 449 | #if POZNAN_EIVD_CALC_PRED_DATA |
---|
| 450 | if(uiMergeIndex==POZNAN_EIVD_MRG_CAND) |
---|
| 451 | pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMv0_EIVD, ref_idx0_EIVD, eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
| 452 | else |
---|
| 453 | #endif |
---|
[2] | 454 | pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( pcMvFieldNeighbours[ 2*uiMergeIndex ].getMv(), pcMvFieldNeighbours[ 2*uiMergeIndex ].getRefIdx(), eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
| 455 | |
---|
| 456 | } |
---|
| 457 | if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_1 ) > 0 ) //if ( ref. frame list1 has at least 1 entry ) |
---|
| 458 | { |
---|
| 459 | pcCU->setMVPIdxSubParts( 0, REF_PIC_LIST_1, uiAbsPartIdx, uiPartIdx, uiDepth); |
---|
| 460 | pcCU->setMVPNumSubParts( 0, REF_PIC_LIST_1, uiAbsPartIdx, uiPartIdx, uiDepth); |
---|
| 461 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvd( cTmpMv, eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
[12] | 462 | #if POZNAN_EIVD_CALC_PRED_DATA |
---|
| 463 | if(uiMergeIndex==POZNAN_EIVD_MRG_CAND) |
---|
| 464 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMv1_EIVD, ref_idx1_EIVD, eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
| 465 | else |
---|
| 466 | #endif |
---|
[2] | 467 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( pcMvFieldNeighbours[ 2*uiMergeIndex + 1 ].getMv(), pcMvFieldNeighbours[ 2*uiMergeIndex + 1 ].getRefIdx(), eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
| 468 | } |
---|
| 469 | } |
---|
| 470 | |
---|
| 471 | |
---|
[5] | 472 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 473 | Void |
---|
| 474 | TDecEntropy::decodeResPredFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU, UInt uiPUIdx ) |
---|
| 475 | { |
---|
| 476 | Bool bResPredAvailable = false; |
---|
| 477 | Bool bResPredFlag = false; |
---|
| 478 | |
---|
| 479 | Bool bResPredAllowed = (!pcCU->getSlice()->getSPS()->isDepth () ); |
---|
| 480 | bResPredAllowed = bResPredAllowed && ( pcCU->getSlice()->getSPS()->getViewId () ); |
---|
| 481 | bResPredAllowed = bResPredAllowed && ( pcCU->getSlice()->getSPS()->getMultiviewResPredMode() ); |
---|
| 482 | bResPredAllowed = bResPredAllowed && (!pcCU->isIntra ( uiAbsPartIdx ) ); |
---|
| 483 | |
---|
| 484 | // check if supported |
---|
| 485 | if( bResPredAllowed ) |
---|
| 486 | { |
---|
| 487 | bResPredAvailable = pcSubCU->getResidualSamples( uiPUIdx ); |
---|
| 488 | } |
---|
| 489 | |
---|
| 490 | // read from bitstream |
---|
| 491 | if( bResPredAvailable ) |
---|
| 492 | { |
---|
| 493 | m_pcEntropyDecoderIf->parseResPredFlag( pcCU, bResPredFlag, uiAbsPartIdx, uiDepth ); |
---|
| 494 | } |
---|
| 495 | |
---|
| 496 | // set data |
---|
| 497 | pcCU->setResPredAvailSubParts ( bResPredAvailable, uiAbsPartIdx, uiPUIdx, uiDepth ); |
---|
| 498 | pcCU->setResPredFlagSubParts ( bResPredFlag, uiAbsPartIdx, uiPUIdx, uiDepth ); |
---|
| 499 | } |
---|
[5] | 500 | #endif |
---|
[2] | 501 | |
---|
| 502 | |
---|
| 503 | Void TDecEntropy::decodeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 504 | { |
---|
| 505 | m_pcEntropyDecoderIf->parseSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 506 | } |
---|
| 507 | |
---|
| 508 | Void TDecEntropy::decodePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 509 | { |
---|
| 510 | m_pcEntropyDecoderIf->parsePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 511 | } |
---|
| 512 | |
---|
| 513 | Void TDecEntropy::decodePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 514 | { |
---|
| 515 | m_pcEntropyDecoderIf->parsePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 516 | } |
---|
| 517 | |
---|
| 518 | Void TDecEntropy::decodePredInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ) |
---|
| 519 | { |
---|
| 520 | PartSize eMode = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
| 521 | |
---|
| 522 | if( pcCU->isIntra( uiAbsPartIdx ) ) // If it is Intra mode, encode intra prediction mode. |
---|
| 523 | { |
---|
| 524 | if( eMode == SIZE_NxN ) // if it is NxN size, encode 4 intra directions. |
---|
| 525 | { |
---|
| 526 | UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth(uiAbsPartIdx) << 1 ) ) >> 2; |
---|
| 527 | // if it is NxN size, this size might be the smallest partition size. // if it is NxN size, this size might be the smallest partition size. |
---|
| 528 | decodeIntraDirModeLuma( pcCU, uiAbsPartIdx, uiDepth+1 ); |
---|
| 529 | decodeIntraDirModeLuma( pcCU, uiAbsPartIdx + uiPartOffset, uiDepth+1 ); |
---|
| 530 | decodeIntraDirModeLuma( pcCU, uiAbsPartIdx + uiPartOffset*2, uiDepth+1 ); |
---|
| 531 | decodeIntraDirModeLuma( pcCU, uiAbsPartIdx + uiPartOffset*3, uiDepth+1 ); |
---|
| 532 | decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 533 | } |
---|
| 534 | else // if it is not NxN size, encode 1 intra directions |
---|
| 535 | { |
---|
| 536 | decodeIntraDirModeLuma ( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 537 | decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 538 | } |
---|
| 539 | } |
---|
| 540 | else // if it is Inter mode, encode motion vector and reference index |
---|
| 541 | { |
---|
| 542 | if ( pcCU->getSlice()->getSPS()->getUseMRG() ) |
---|
| 543 | { |
---|
| 544 | decodePUWise( pcCU, uiAbsPartIdx, uiDepth, pcSubCU ); |
---|
| 545 | } |
---|
| 546 | else |
---|
| 547 | { |
---|
| 548 | #if MS_LCEC_LOOKUP_TABLE_EXCEPTION |
---|
| 549 | if ( pcCU->getSlice()->getSymbolMode() == 0 ) |
---|
| 550 | { |
---|
| 551 | if ( pcCU->isSuroundingRefIdxException( uiAbsPartIdx ) ) |
---|
| 552 | { |
---|
| 553 | pcCU->getSlice()->setRefIdxCombineCoding( false ); |
---|
| 554 | } |
---|
| 555 | else |
---|
| 556 | { |
---|
| 557 | pcCU->getSlice()->setRefIdxCombineCoding( true ); |
---|
| 558 | } |
---|
| 559 | } |
---|
| 560 | #endif |
---|
| 561 | decodeInterDir( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 562 | |
---|
| 563 | if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) > 0 ) //if ( ref. frame list0 has at least 1 entry ) |
---|
| 564 | { |
---|
| 565 | decodeRefFrmIdx ( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_0 ); |
---|
| 566 | decodeMvd ( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_0 ); |
---|
| 567 | decodeMVPIdx( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_0, pcSubCU); |
---|
| 568 | } |
---|
| 569 | |
---|
| 570 | if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_1 ) > 0 ) //if ( ref. frame list1 has at least 1 entry ) |
---|
| 571 | { |
---|
| 572 | decodeRefFrmIdx ( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_1 ); |
---|
| 573 | decodeMvd ( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_1 ); |
---|
| 574 | decodeMVPIdx( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_1, pcSubCU); |
---|
| 575 | } |
---|
| 576 | } |
---|
| 577 | } |
---|
| 578 | } |
---|
| 579 | |
---|
| 580 | Void TDecEntropy::decodeIntraDirModeLuma ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 581 | { |
---|
| 582 | m_pcEntropyDecoderIf->parseIntraDirLumaAng( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 583 | } |
---|
| 584 | |
---|
| 585 | Void TDecEntropy::decodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 586 | { |
---|
| 587 | m_pcEntropyDecoderIf->parseIntraDirChroma( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 588 | } |
---|
| 589 | |
---|
| 590 | Void TDecEntropy::decodeInterDir( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 591 | { |
---|
| 592 | if ( pcCU->getSlice()->isInterP() ) |
---|
| 593 | { |
---|
| 594 | memset( pcCU->getInterDir() + uiAbsPartIdx, 1, sizeof(UChar)*( pcCU->getTotalNumPart() >> (uiDepth << 1) ) ); |
---|
| 595 | return; |
---|
| 596 | } |
---|
| 597 | |
---|
| 598 | UInt uiInterDir; |
---|
| 599 | |
---|
| 600 | UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( uiDepth << 1 ) ) >> 2; |
---|
| 601 | |
---|
| 602 | switch ( pcCU->getPartitionSize( uiAbsPartIdx ) ) |
---|
| 603 | { |
---|
| 604 | |
---|
| 605 | case SIZE_2Nx2N: |
---|
| 606 | { |
---|
| 607 | m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth ); |
---|
| 608 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
| 609 | break; |
---|
| 610 | } |
---|
| 611 | |
---|
| 612 | case SIZE_2NxN: |
---|
| 613 | { |
---|
| 614 | m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth ); |
---|
| 615 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
| 616 | |
---|
| 617 | uiAbsPartIdx += uiPartOffset << 1; |
---|
| 618 | m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth ); |
---|
| 619 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
| 620 | break; |
---|
| 621 | } |
---|
| 622 | case SIZE_Nx2N: |
---|
| 623 | { |
---|
| 624 | m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth ); |
---|
| 625 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
| 626 | |
---|
| 627 | uiAbsPartIdx += uiPartOffset; |
---|
| 628 | m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth ); |
---|
| 629 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
| 630 | break; |
---|
| 631 | } |
---|
| 632 | case SIZE_NxN: |
---|
| 633 | { |
---|
| 634 | for ( Int iPartIdx = 0; iPartIdx < 4; iPartIdx++ ) |
---|
| 635 | { |
---|
| 636 | m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth ); |
---|
| 637 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
| 638 | uiAbsPartIdx += uiPartOffset; |
---|
| 639 | } |
---|
| 640 | break; |
---|
| 641 | } |
---|
| 642 | default: |
---|
| 643 | break; |
---|
| 644 | } |
---|
| 645 | |
---|
| 646 | return; |
---|
| 647 | } |
---|
| 648 | |
---|
| 649 | /** decode motion information for every PU block |
---|
| 650 | * \param pcCU |
---|
| 651 | * \param uiPartIdx |
---|
| 652 | * \param uiAbsPartIdx |
---|
| 653 | * \param uiDepth |
---|
| 654 | * \param pcSubCU |
---|
| 655 | * \returns Void |
---|
| 656 | */ |
---|
| 657 | Void TDecEntropy::decodePUWise( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ) |
---|
| 658 | { |
---|
| 659 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
| 660 | UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) ); |
---|
| 661 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
| 662 | |
---|
| 663 | pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
---|
| 664 | pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
---|
| 665 | for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset ) |
---|
| 666 | { |
---|
| 667 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
| 668 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
| 669 | UInt uiNeighbourCandIdx[MRG_MAX_NUM_CANDS]; //MVs with same idx => same cand |
---|
| 670 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ++ui ) |
---|
| 671 | { |
---|
| 672 | uhInterDirNeighbours[ui] = 0; |
---|
| 673 | uiNeighbourCandIdx[ui] = 0; |
---|
| 674 | } |
---|
| 675 | #if !CHANGE_GET_MERGE_CANDIDATE |
---|
| 676 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, uiNeighbourCandIdx ); |
---|
| 677 | for(UInt uiIter = 0; uiIter < MRG_MAX_NUM_CANDS; uiIter++ ) |
---|
| 678 | { |
---|
| 679 | pcCU->setNeighbourCandIdxSubParts( uiIter, uiNeighbourCandIdx[uiIter], uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
| 680 | } |
---|
| 681 | #endif |
---|
| 682 | #if PART_MRG |
---|
| 683 | if (pcCU->getWidth( uiAbsPartIdx ) > 8 && uiNumPU == 2 && uiPartIdx == 0) |
---|
| 684 | { |
---|
| 685 | pcCU->setMergeFlagSubParts( true, uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
| 686 | } |
---|
| 687 | else |
---|
| 688 | #endif |
---|
| 689 | decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
| 690 | if ( pcCU->getMergeFlag( uiSubPartIdx ) ) |
---|
| 691 | { |
---|
| 692 | #if CHANGE_GET_MERGE_CANDIDATE |
---|
| 693 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, uiNeighbourCandIdx ); |
---|
| 694 | for(UInt uiIter = 0; uiIter < MRG_MAX_NUM_CANDS; uiIter++ ) |
---|
| 695 | { |
---|
| 696 | pcCU->setNeighbourCandIdxSubParts( uiIter, uiNeighbourCandIdx[uiIter], uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
| 697 | } |
---|
| 698 | #endif |
---|
| 699 | decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, ePartSize, uhInterDirNeighbours, cMvFieldNeighbours, uiDepth ); |
---|
| 700 | } |
---|
| 701 | else |
---|
| 702 | { |
---|
| 703 | #if MS_LCEC_LOOKUP_TABLE_EXCEPTION |
---|
| 704 | if ( pcCU->getSlice()->getSymbolMode() == 0 ) |
---|
| 705 | { |
---|
| 706 | if ( pcCU->isSuroundingRefIdxException( uiAbsPartIdx ) ) |
---|
| 707 | { |
---|
| 708 | pcCU->getSlice()->setRefIdxCombineCoding( false ); |
---|
| 709 | } |
---|
| 710 | else |
---|
| 711 | { |
---|
| 712 | pcCU->getSlice()->setRefIdxCombineCoding( true ); |
---|
| 713 | } |
---|
| 714 | } |
---|
| 715 | #endif |
---|
| 716 | decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
| 717 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 718 | { |
---|
| 719 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
| 720 | { |
---|
| 721 | decodeRefFrmIdxPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
| 722 | decodeMvdPU ( pcCU, uiSubPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
| 723 | decodeMVPIdxPU ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
| 724 | } |
---|
| 725 | } |
---|
| 726 | } |
---|
| 727 | } |
---|
| 728 | return; |
---|
| 729 | } |
---|
| 730 | |
---|
| 731 | /** decode inter direction for a PU block |
---|
| 732 | * \param pcCU |
---|
| 733 | * \param uiAbsPartIdx |
---|
| 734 | * \param uiDepth |
---|
| 735 | * \param uiPartIdx |
---|
| 736 | * \returns Void |
---|
| 737 | */ |
---|
| 738 | Void TDecEntropy::decodeInterDirPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx ) |
---|
| 739 | { |
---|
| 740 | UInt uiInterDir; |
---|
| 741 | |
---|
| 742 | if ( pcCU->getSlice()->isInterP() ) |
---|
| 743 | { |
---|
| 744 | uiInterDir = 1; |
---|
| 745 | } |
---|
| 746 | else |
---|
| 747 | { |
---|
| 748 | m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth ); |
---|
| 749 | } |
---|
| 750 | |
---|
| 751 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
| 752 | } |
---|
| 753 | |
---|
| 754 | Void TDecEntropy::decodeRefFrmIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
| 755 | { |
---|
| 756 | #if DCM_COMB_LIST |
---|
| 757 | if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && pcCU->getInterDir( uiAbsPartIdx ) != 3) |
---|
| 758 | { |
---|
| 759 | if(eRefList == REF_PIC_LIST_1) |
---|
| 760 | { |
---|
| 761 | return; |
---|
| 762 | } |
---|
| 763 | |
---|
| 764 | Int iRefFrmIdx = 0; |
---|
| 765 | Int iRefFrmIdxTemp; |
---|
| 766 | UInt uiInterDir; |
---|
| 767 | RefPicList eRefListTemp; |
---|
| 768 | |
---|
| 769 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
| 770 | |
---|
| 771 | if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 ) |
---|
| 772 | { |
---|
| 773 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C ); |
---|
| 774 | }else{ |
---|
| 775 | iRefFrmIdx=0; |
---|
| 776 | } |
---|
| 777 | uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1; |
---|
| 778 | iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx); |
---|
| 779 | eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx); |
---|
| 780 | |
---|
| 781 | pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, ePartSize, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
| 782 | |
---|
| 783 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
| 784 | } |
---|
| 785 | else |
---|
| 786 | { |
---|
| 787 | #endif |
---|
| 788 | |
---|
| 789 | Int iRefFrmIdx = 0; |
---|
| 790 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
| 791 | |
---|
| 792 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx ) |
---|
| 793 | { |
---|
| 794 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
| 795 | } |
---|
| 796 | else if ( !iParseRefFrmIdx ) |
---|
| 797 | { |
---|
| 798 | iRefFrmIdx = NOT_VALID; |
---|
| 799 | } |
---|
| 800 | else |
---|
| 801 | { |
---|
| 802 | iRefFrmIdx = 0; |
---|
| 803 | } |
---|
| 804 | |
---|
| 805 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
| 806 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, ePartSize, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
| 807 | |
---|
| 808 | #if DCM_COMB_LIST |
---|
| 809 | } |
---|
| 810 | #endif |
---|
| 811 | } |
---|
| 812 | |
---|
| 813 | /** decode motion vector difference for a PU block |
---|
| 814 | * \param pcCU |
---|
| 815 | * \param uiAbsPartIdx |
---|
| 816 | * \param uiDepth |
---|
| 817 | * \param uiPartIdx |
---|
| 818 | * \param eRefList |
---|
| 819 | * \returns Void |
---|
| 820 | */ |
---|
| 821 | Void TDecEntropy::decodeMvdPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
| 822 | { |
---|
| 823 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
| 824 | { |
---|
| 825 | m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, uiPartIdx, uiDepth, eRefList ); |
---|
| 826 | } |
---|
| 827 | } |
---|
| 828 | |
---|
| 829 | Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
| 830 | { |
---|
| 831 | Int iMVPIdx; |
---|
| 832 | |
---|
| 833 | TComMv cZeroMv( 0, 0 ); |
---|
| 834 | TComMv cMv = cZeroMv; |
---|
| 835 | Int iRefIdx = -1; |
---|
| 836 | |
---|
| 837 | TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList ); |
---|
| 838 | AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo(); |
---|
| 839 | |
---|
| 840 | iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr); |
---|
| 841 | iMVPIdx = -1; |
---|
| 842 | cMv = cZeroMv; |
---|
| 843 | pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo); |
---|
| 844 | #if DCM_SIMPLIFIED_MVP==0 |
---|
| 845 | pcSubCU->clearMVPCand(pcSubCUMvField->getMvd(uiPartAddr), pAMVPInfo); |
---|
| 846 | #endif |
---|
| 847 | pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth); |
---|
| 848 | if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) && (pAMVPInfo->iN > 1) && (pcSubCU->getAMVPMode(uiPartAddr) == AM_EXPL) ) |
---|
| 849 | { |
---|
| 850 | m_pcEntropyDecoderIf->parseMVPIdx( pcSubCU, iMVPIdx, pAMVPInfo->iN, uiPartAddr, uiDepth, eRefList ); |
---|
| 851 | } |
---|
| 852 | pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth ); |
---|
| 853 | if ( iRefIdx >= 0 ) |
---|
| 854 | { |
---|
| 855 | m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, iRefIdx, cMv); |
---|
| 856 | cMv += pcSubCUMvField->getMvd( uiPartAddr ); |
---|
| 857 | } |
---|
| 858 | |
---|
| 859 | PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr ); |
---|
| 860 | pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, uiPartIdx, 0); |
---|
| 861 | } |
---|
| 862 | |
---|
| 863 | Void TDecEntropy::decodeMVPIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList, TComDataCU* pcSubCU ) |
---|
| 864 | { |
---|
| 865 | Int iMVPIdx; |
---|
| 866 | |
---|
| 867 | TComMv cZeroMv( 0, 0 ); |
---|
| 868 | TComMv cMv = cZeroMv; |
---|
| 869 | Int iRefIdx = -1; |
---|
| 870 | |
---|
| 871 | UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( uiDepth << 1 ) ) >> 2; |
---|
| 872 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
| 873 | |
---|
| 874 | pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, eRefList ); |
---|
| 875 | |
---|
| 876 | TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList ); |
---|
| 877 | AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo(); |
---|
| 878 | |
---|
| 879 | switch ( ePartSize ) |
---|
| 880 | { |
---|
| 881 | case SIZE_2Nx2N: |
---|
| 882 | { |
---|
| 883 | iRefIdx = pcSubCUMvField->getRefIdx(0); |
---|
| 884 | iMVPIdx =-1; |
---|
| 885 | cMv = cZeroMv; |
---|
| 886 | pcSubCU->fillMvpCand(0, 0, eRefList, iRefIdx, pAMVPInfo); |
---|
| 887 | #if DCM_SIMPLIFIED_MVP==0 |
---|
| 888 | pcSubCU->clearMVPCand(pcSubCUMvField->getMvd(0), pAMVPInfo); |
---|
| 889 | #endif |
---|
| 890 | pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, 0, 0, uiDepth); |
---|
| 891 | if ( (pcSubCU->getInterDir(0) & ( 1 << eRefList )) && (pAMVPInfo->iN > 1) && (pcSubCU->getAMVPMode(0) == AM_EXPL) ) |
---|
| 892 | { |
---|
| 893 | m_pcEntropyDecoderIf->parseMVPIdx( pcSubCU, iMVPIdx, pAMVPInfo->iN, uiAbsPartIdx, uiDepth, eRefList ); |
---|
| 894 | } |
---|
| 895 | pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, 0, 0, uiDepth ); |
---|
| 896 | |
---|
| 897 | if ( iRefIdx >= 0 ) |
---|
| 898 | { |
---|
| 899 | m_pcPrediction->getMvPredAMVP( pcSubCU, 0, 0, eRefList, iRefIdx, cMv); |
---|
| 900 | cMv += pcSubCUMvField->getMvd( 0 ); |
---|
| 901 | } |
---|
| 902 | |
---|
| 903 | pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, 0, 0, 0); |
---|
| 904 | break; |
---|
| 905 | } |
---|
| 906 | case SIZE_2NxN: |
---|
| 907 | { |
---|
| 908 | for ( UInt uiPartIdx = 0, uiPartAddr = 0; uiPartIdx < 2; uiPartIdx++, uiPartAddr+=(uiPartOffset << 1)) |
---|
| 909 | { |
---|
| 910 | iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr); |
---|
| 911 | iMVPIdx =-1; |
---|
| 912 | cMv = cZeroMv; |
---|
| 913 | pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo); |
---|
| 914 | #if DCM_SIMPLIFIED_MVP==0 |
---|
| 915 | pcSubCU->clearMVPCand(pcSubCUMvField->getMvd(uiPartAddr), pAMVPInfo); |
---|
| 916 | #endif |
---|
| 917 | pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth); |
---|
| 918 | if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) && (pAMVPInfo->iN > 1) && (pcSubCU->getAMVPMode(uiPartAddr) == AM_EXPL) ) |
---|
| 919 | { |
---|
| 920 | m_pcEntropyDecoderIf->parseMVPIdx( pcSubCU, iMVPIdx, pAMVPInfo->iN, uiPartAddr, uiDepth, eRefList ); |
---|
| 921 | } |
---|
| 922 | pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth ); |
---|
| 923 | if ( iRefIdx >= 0 ) |
---|
| 924 | { |
---|
| 925 | m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, iRefIdx, cMv); |
---|
| 926 | cMv += pcSubCUMvField->getMvd( uiPartAddr ); |
---|
| 927 | } |
---|
| 928 | |
---|
| 929 | pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, uiPartIdx, 0); |
---|
| 930 | |
---|
| 931 | } |
---|
| 932 | break; |
---|
| 933 | } |
---|
| 934 | case SIZE_Nx2N: |
---|
| 935 | { |
---|
| 936 | for ( UInt uiPartIdx = 0, uiPartAddr = 0; uiPartIdx < 2; uiPartIdx++, uiPartAddr+=uiPartOffset) |
---|
| 937 | { |
---|
| 938 | iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr); |
---|
| 939 | iMVPIdx =-1; |
---|
| 940 | cMv = cZeroMv; |
---|
| 941 | pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo); |
---|
| 942 | #if DCM_SIMPLIFIED_MVP==0 |
---|
| 943 | pcSubCU->clearMVPCand(pcSubCUMvField->getMvd(uiPartAddr), pAMVPInfo); |
---|
| 944 | #endif |
---|
| 945 | pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth); |
---|
| 946 | if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) && (pAMVPInfo->iN > 1) && (pcSubCU->getAMVPMode(uiPartAddr) == AM_EXPL) ) |
---|
| 947 | { |
---|
| 948 | m_pcEntropyDecoderIf->parseMVPIdx( pcSubCU, iMVPIdx, pAMVPInfo->iN, uiPartAddr, uiDepth, eRefList ); |
---|
| 949 | } |
---|
| 950 | pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth ); |
---|
| 951 | |
---|
| 952 | if ( iRefIdx >= 0 ) |
---|
| 953 | { |
---|
| 954 | m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, iRefIdx, cMv); |
---|
| 955 | cMv += pcSubCUMvField->getMvd( uiPartAddr ); |
---|
| 956 | } |
---|
| 957 | |
---|
| 958 | pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, uiPartIdx, 0); |
---|
| 959 | |
---|
| 960 | } |
---|
| 961 | break; |
---|
| 962 | } |
---|
| 963 | case SIZE_NxN: |
---|
| 964 | { |
---|
| 965 | for ( UInt uiPartIdx = 0, uiPartAddr = 0; uiPartIdx < 4; uiPartIdx++, uiPartAddr+=uiPartOffset) |
---|
| 966 | { |
---|
| 967 | iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr); |
---|
| 968 | iMVPIdx =-1; |
---|
| 969 | cMv = cZeroMv; |
---|
| 970 | pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo); |
---|
| 971 | #if DCM_SIMPLIFIED_MVP==0 |
---|
| 972 | pcSubCU->clearMVPCand(pcSubCUMvField->getMvd(uiPartAddr), pAMVPInfo); |
---|
| 973 | #endif |
---|
| 974 | pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth); |
---|
| 975 | if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) && (pAMVPInfo->iN > 1) && (pcSubCU->getAMVPMode(uiPartAddr) == AM_EXPL) ) |
---|
| 976 | { |
---|
| 977 | m_pcEntropyDecoderIf->parseMVPIdx( pcSubCU, iMVPIdx, pAMVPInfo->iN, uiPartAddr, uiDepth, eRefList ); |
---|
| 978 | } |
---|
| 979 | pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth ); |
---|
| 980 | if ( iRefIdx >= 0 ) |
---|
| 981 | { |
---|
| 982 | m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, iRefIdx, cMv); |
---|
| 983 | cMv += pcSubCUMvField->getMvd( uiPartAddr ); |
---|
| 984 | } |
---|
| 985 | |
---|
| 986 | pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, uiPartIdx, 0); |
---|
| 987 | } |
---|
| 988 | break; |
---|
| 989 | } |
---|
| 990 | default: |
---|
| 991 | break; |
---|
| 992 | } |
---|
| 993 | |
---|
| 994 | return; |
---|
| 995 | } |
---|
| 996 | |
---|
| 997 | /** decode reference frame index |
---|
| 998 | * \param pcCU |
---|
| 999 | * \param uiAbsPartIdx |
---|
| 1000 | * \param uiDepth |
---|
| 1001 | * \param eRefList |
---|
| 1002 | * \returns Void |
---|
| 1003 | */ |
---|
| 1004 | Void TDecEntropy::decodeRefFrmIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
| 1005 | { |
---|
| 1006 | #if DCM_COMB_LIST |
---|
| 1007 | if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0) |
---|
| 1008 | { |
---|
| 1009 | Int iRefFrmIdx = 0; |
---|
| 1010 | |
---|
| 1011 | Int iRefFrmIdxTemp; |
---|
| 1012 | UInt uiInterDir; |
---|
| 1013 | RefPicList eRefListTemp; |
---|
| 1014 | |
---|
| 1015 | UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( uiDepth << 1 ) ) >> 2; |
---|
| 1016 | |
---|
| 1017 | switch ( pcCU->getPartitionSize( uiAbsPartIdx ) ) |
---|
| 1018 | { |
---|
| 1019 | case SIZE_2Nx2N: |
---|
| 1020 | { |
---|
| 1021 | if( pcCU->getInterDir( uiAbsPartIdx ) != 3 && eRefList == REF_PIC_LIST_0) |
---|
| 1022 | { |
---|
| 1023 | if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 ) |
---|
| 1024 | { |
---|
| 1025 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C ); |
---|
| 1026 | } |
---|
| 1027 | else |
---|
| 1028 | { |
---|
| 1029 | iRefFrmIdx=0; |
---|
| 1030 | } |
---|
| 1031 | uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1; |
---|
| 1032 | iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx); |
---|
| 1033 | eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx); |
---|
| 1034 | |
---|
| 1035 | pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, SIZE_2Nx2N, uiAbsPartIdx, 0, uiDepth ); |
---|
| 1036 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
| 1037 | } |
---|
| 1038 | else if(pcCU->getInterDir( uiAbsPartIdx ) == 3) |
---|
| 1039 | { |
---|
| 1040 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
| 1041 | |
---|
| 1042 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
| 1043 | { |
---|
| 1044 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
| 1045 | } |
---|
| 1046 | else if ( !iParseRefFrmIdx ) |
---|
| 1047 | { |
---|
| 1048 | iRefFrmIdx = NOT_VALID; |
---|
| 1049 | } |
---|
| 1050 | else |
---|
| 1051 | { |
---|
| 1052 | iRefFrmIdx = 0; |
---|
| 1053 | } |
---|
| 1054 | |
---|
| 1055 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_2Nx2N, uiAbsPartIdx, 0, uiDepth ); |
---|
| 1056 | } |
---|
| 1057 | break; |
---|
| 1058 | } |
---|
| 1059 | case SIZE_2NxN: |
---|
| 1060 | { |
---|
| 1061 | if( pcCU->getInterDir( uiAbsPartIdx ) != 3 && eRefList == REF_PIC_LIST_0) |
---|
| 1062 | { |
---|
| 1063 | if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 ) |
---|
| 1064 | { |
---|
| 1065 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C ); |
---|
| 1066 | } |
---|
| 1067 | else |
---|
| 1068 | { |
---|
| 1069 | iRefFrmIdx=0; |
---|
| 1070 | } |
---|
| 1071 | uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1; |
---|
| 1072 | iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx); |
---|
| 1073 | eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx); |
---|
| 1074 | |
---|
| 1075 | pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, SIZE_2NxN, uiAbsPartIdx, 0, uiDepth ); |
---|
| 1076 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
| 1077 | } |
---|
| 1078 | else if(pcCU->getInterDir( uiAbsPartIdx ) == 3) |
---|
| 1079 | { |
---|
| 1080 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
| 1081 | |
---|
| 1082 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
| 1083 | { |
---|
| 1084 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
| 1085 | } |
---|
| 1086 | else if ( !iParseRefFrmIdx ) |
---|
| 1087 | { |
---|
| 1088 | iRefFrmIdx = NOT_VALID; |
---|
| 1089 | } |
---|
| 1090 | else |
---|
| 1091 | { |
---|
| 1092 | iRefFrmIdx = 0; |
---|
| 1093 | } |
---|
| 1094 | |
---|
| 1095 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_2NxN, uiAbsPartIdx, 0, uiDepth ); |
---|
| 1096 | } |
---|
| 1097 | |
---|
| 1098 | uiAbsPartIdx += uiPartOffset << 1; |
---|
| 1099 | |
---|
| 1100 | if( pcCU->getInterDir( uiAbsPartIdx ) != 3 && eRefList == REF_PIC_LIST_0) |
---|
| 1101 | { |
---|
| 1102 | if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 ) |
---|
| 1103 | { |
---|
| 1104 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C ); |
---|
| 1105 | } |
---|
| 1106 | else |
---|
| 1107 | { |
---|
| 1108 | iRefFrmIdx=0; |
---|
| 1109 | } |
---|
| 1110 | uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1; |
---|
| 1111 | iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx); |
---|
| 1112 | eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx); |
---|
| 1113 | |
---|
| 1114 | pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, SIZE_2NxN, uiAbsPartIdx, 1, uiDepth ); |
---|
| 1115 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
| 1116 | } |
---|
| 1117 | else if(pcCU->getInterDir( uiAbsPartIdx ) == 3) |
---|
| 1118 | { |
---|
| 1119 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
| 1120 | |
---|
| 1121 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
| 1122 | { |
---|
| 1123 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
| 1124 | } |
---|
| 1125 | else if ( !iParseRefFrmIdx ) |
---|
| 1126 | { |
---|
| 1127 | iRefFrmIdx = NOT_VALID; |
---|
| 1128 | } |
---|
| 1129 | else |
---|
| 1130 | { |
---|
| 1131 | iRefFrmIdx = 0; |
---|
| 1132 | } |
---|
| 1133 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_2NxN, uiAbsPartIdx, 1, uiDepth ); |
---|
| 1134 | } |
---|
| 1135 | break; |
---|
| 1136 | } |
---|
| 1137 | case SIZE_Nx2N: |
---|
| 1138 | { |
---|
| 1139 | if( pcCU->getInterDir( uiAbsPartIdx ) != 3 && eRefList == REF_PIC_LIST_0) |
---|
| 1140 | { |
---|
| 1141 | if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 ) |
---|
| 1142 | { |
---|
| 1143 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C ); |
---|
| 1144 | } |
---|
| 1145 | else |
---|
| 1146 | { |
---|
| 1147 | iRefFrmIdx=0; |
---|
| 1148 | } |
---|
| 1149 | uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1; |
---|
| 1150 | iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx); |
---|
| 1151 | eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx); |
---|
| 1152 | |
---|
| 1153 | pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, SIZE_Nx2N, uiAbsPartIdx, 0, uiDepth ); |
---|
| 1154 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
| 1155 | } |
---|
| 1156 | else if(pcCU->getInterDir( uiAbsPartIdx ) == 3) |
---|
| 1157 | { |
---|
| 1158 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
| 1159 | |
---|
| 1160 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
| 1161 | { |
---|
| 1162 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
| 1163 | } |
---|
| 1164 | else if ( !iParseRefFrmIdx ) |
---|
| 1165 | { |
---|
| 1166 | iRefFrmIdx = NOT_VALID; |
---|
| 1167 | } |
---|
| 1168 | else |
---|
| 1169 | { |
---|
| 1170 | iRefFrmIdx = 0; |
---|
| 1171 | } |
---|
| 1172 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_Nx2N, uiAbsPartIdx, 0, uiDepth ); |
---|
| 1173 | } |
---|
| 1174 | |
---|
| 1175 | uiAbsPartIdx += uiPartOffset; |
---|
| 1176 | |
---|
| 1177 | if( pcCU->getInterDir( uiAbsPartIdx ) != 3 && eRefList == REF_PIC_LIST_0) |
---|
| 1178 | { |
---|
| 1179 | if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 ) |
---|
| 1180 | { |
---|
| 1181 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C ); |
---|
| 1182 | } |
---|
| 1183 | else |
---|
| 1184 | { |
---|
| 1185 | iRefFrmIdx=0; |
---|
| 1186 | } |
---|
| 1187 | uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1; |
---|
| 1188 | iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx); |
---|
| 1189 | eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx); |
---|
| 1190 | |
---|
| 1191 | pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, SIZE_Nx2N, uiAbsPartIdx, 1, uiDepth ); |
---|
| 1192 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
| 1193 | } |
---|
| 1194 | else if(pcCU->getInterDir( uiAbsPartIdx ) == 3) |
---|
| 1195 | { |
---|
| 1196 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
| 1197 | |
---|
| 1198 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
| 1199 | { |
---|
| 1200 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
| 1201 | } |
---|
| 1202 | else if ( !iParseRefFrmIdx ) |
---|
| 1203 | { |
---|
| 1204 | iRefFrmIdx = NOT_VALID; |
---|
| 1205 | } |
---|
| 1206 | else |
---|
| 1207 | { |
---|
| 1208 | iRefFrmIdx = 0; |
---|
| 1209 | } |
---|
| 1210 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_Nx2N, uiAbsPartIdx, 1, uiDepth ); |
---|
| 1211 | } |
---|
| 1212 | break; |
---|
| 1213 | } |
---|
| 1214 | case SIZE_NxN: |
---|
| 1215 | { |
---|
| 1216 | for ( Int iPartIdx = 0; iPartIdx < 4; iPartIdx++ ) |
---|
| 1217 | { |
---|
| 1218 | if( pcCU->getInterDir( uiAbsPartIdx ) != 3 && eRefList == REF_PIC_LIST_0) |
---|
| 1219 | { |
---|
| 1220 | if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 ) |
---|
| 1221 | { |
---|
| 1222 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C ); |
---|
| 1223 | } |
---|
| 1224 | else |
---|
| 1225 | { |
---|
| 1226 | iRefFrmIdx=0; |
---|
| 1227 | } |
---|
| 1228 | uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1; |
---|
| 1229 | iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx); |
---|
| 1230 | eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx); |
---|
| 1231 | |
---|
| 1232 | pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, SIZE_NxN, uiAbsPartIdx, iPartIdx, uiDepth ); |
---|
| 1233 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
| 1234 | } |
---|
| 1235 | else if(pcCU->getInterDir( uiAbsPartIdx ) == 3) |
---|
| 1236 | { |
---|
| 1237 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
| 1238 | |
---|
| 1239 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
| 1240 | { |
---|
| 1241 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
| 1242 | } |
---|
| 1243 | else if ( !iParseRefFrmIdx ) |
---|
| 1244 | { |
---|
| 1245 | iRefFrmIdx = NOT_VALID; |
---|
| 1246 | } |
---|
| 1247 | else |
---|
| 1248 | { |
---|
| 1249 | iRefFrmIdx = 0; |
---|
| 1250 | } |
---|
| 1251 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_NxN, uiAbsPartIdx, iPartIdx, uiDepth ); |
---|
| 1252 | } |
---|
| 1253 | uiAbsPartIdx += uiPartOffset; |
---|
| 1254 | } |
---|
| 1255 | break; |
---|
| 1256 | } |
---|
| 1257 | default: |
---|
| 1258 | break; |
---|
| 1259 | } |
---|
| 1260 | } |
---|
| 1261 | else |
---|
| 1262 | { |
---|
| 1263 | #endif |
---|
| 1264 | |
---|
| 1265 | Int iRefFrmIdx = 0; |
---|
| 1266 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
| 1267 | UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth(uiAbsPartIdx) << 1 ) ) >> 2; |
---|
| 1268 | |
---|
| 1269 | switch ( pcCU->getPartitionSize( uiAbsPartIdx ) ) |
---|
| 1270 | { |
---|
| 1271 | case SIZE_2Nx2N: |
---|
| 1272 | { |
---|
| 1273 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
| 1274 | { |
---|
| 1275 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
| 1276 | } |
---|
| 1277 | else if ( !iParseRefFrmIdx ) |
---|
| 1278 | { |
---|
| 1279 | iRefFrmIdx = NOT_VALID; |
---|
| 1280 | } |
---|
| 1281 | else |
---|
| 1282 | { |
---|
| 1283 | iRefFrmIdx = 0; |
---|
| 1284 | } |
---|
| 1285 | |
---|
| 1286 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_2Nx2N, uiAbsPartIdx, 0, uiDepth ); |
---|
| 1287 | break; |
---|
| 1288 | } |
---|
| 1289 | case SIZE_2NxN: |
---|
| 1290 | { |
---|
| 1291 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
| 1292 | { |
---|
| 1293 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
| 1294 | } |
---|
| 1295 | else if ( !iParseRefFrmIdx ) |
---|
| 1296 | { |
---|
| 1297 | iRefFrmIdx = NOT_VALID; |
---|
| 1298 | } |
---|
| 1299 | else |
---|
| 1300 | { |
---|
| 1301 | iRefFrmIdx = 0; |
---|
| 1302 | } |
---|
| 1303 | |
---|
| 1304 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_2NxN, uiAbsPartIdx, 0, uiDepth ); |
---|
| 1305 | uiAbsPartIdx += (uiPartOffset << 1); |
---|
| 1306 | |
---|
| 1307 | iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
| 1308 | |
---|
| 1309 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
| 1310 | { |
---|
| 1311 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
| 1312 | } |
---|
| 1313 | else if ( !iParseRefFrmIdx ) |
---|
| 1314 | { |
---|
| 1315 | iRefFrmIdx = NOT_VALID; |
---|
| 1316 | } |
---|
| 1317 | else |
---|
| 1318 | { |
---|
| 1319 | iRefFrmIdx = 0; |
---|
| 1320 | } |
---|
| 1321 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_2NxN, uiAbsPartIdx, 1, uiDepth ); |
---|
| 1322 | break; |
---|
| 1323 | } |
---|
| 1324 | case SIZE_Nx2N: |
---|
| 1325 | { |
---|
| 1326 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
| 1327 | { |
---|
| 1328 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
| 1329 | } |
---|
| 1330 | else if ( !iParseRefFrmIdx ) |
---|
| 1331 | { |
---|
| 1332 | iRefFrmIdx = NOT_VALID; |
---|
| 1333 | } |
---|
| 1334 | else |
---|
| 1335 | { |
---|
| 1336 | iRefFrmIdx = 0; |
---|
| 1337 | } |
---|
| 1338 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_Nx2N, uiAbsPartIdx, 0, uiDepth ); |
---|
| 1339 | uiAbsPartIdx += uiPartOffset; |
---|
| 1340 | |
---|
| 1341 | iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
| 1342 | |
---|
| 1343 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
| 1344 | { |
---|
| 1345 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
| 1346 | } |
---|
| 1347 | else if ( !iParseRefFrmIdx ) |
---|
| 1348 | { |
---|
| 1349 | iRefFrmIdx = NOT_VALID; |
---|
| 1350 | } |
---|
| 1351 | else |
---|
| 1352 | { |
---|
| 1353 | iRefFrmIdx = 0; |
---|
| 1354 | } |
---|
| 1355 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_Nx2N, uiAbsPartIdx, 1, uiDepth ); |
---|
| 1356 | break; |
---|
| 1357 | } |
---|
| 1358 | case SIZE_NxN: |
---|
| 1359 | { |
---|
| 1360 | for ( Int iPartIdx = 0; iPartIdx < 4; iPartIdx++ ) |
---|
| 1361 | { |
---|
| 1362 | iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
| 1363 | |
---|
| 1364 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
| 1365 | { |
---|
| 1366 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
| 1367 | } |
---|
| 1368 | else if ( !iParseRefFrmIdx ) |
---|
| 1369 | { |
---|
| 1370 | iRefFrmIdx = NOT_VALID; |
---|
| 1371 | } |
---|
| 1372 | else |
---|
| 1373 | { |
---|
| 1374 | iRefFrmIdx = 0; |
---|
| 1375 | } |
---|
| 1376 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_NxN, uiAbsPartIdx, iPartIdx, uiDepth ); |
---|
| 1377 | uiAbsPartIdx += uiPartOffset; |
---|
| 1378 | } |
---|
| 1379 | break; |
---|
| 1380 | } |
---|
| 1381 | default: |
---|
| 1382 | break; |
---|
| 1383 | } |
---|
| 1384 | #if DCM_COMB_LIST |
---|
| 1385 | } |
---|
| 1386 | #endif |
---|
| 1387 | |
---|
| 1388 | return; |
---|
| 1389 | } |
---|
| 1390 | |
---|
| 1391 | Void TDecEntropy::decodeMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
| 1392 | { |
---|
| 1393 | UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( uiDepth << 1 ) ) >> 2; |
---|
| 1394 | |
---|
| 1395 | switch ( pcCU->getPartitionSize( uiAbsPartIdx ) ) |
---|
| 1396 | { |
---|
| 1397 | case SIZE_2Nx2N: |
---|
| 1398 | { |
---|
| 1399 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
| 1400 | { |
---|
| 1401 | m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, 0, uiDepth, eRefList ); |
---|
| 1402 | } |
---|
| 1403 | break; |
---|
| 1404 | } |
---|
| 1405 | case SIZE_2NxN: |
---|
| 1406 | { |
---|
| 1407 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
| 1408 | { |
---|
| 1409 | m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, 0, uiDepth, eRefList ); |
---|
| 1410 | } |
---|
| 1411 | |
---|
| 1412 | uiAbsPartIdx += (uiPartOffset << 1); |
---|
| 1413 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
| 1414 | { |
---|
| 1415 | m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, 0, uiDepth, eRefList ); |
---|
| 1416 | } |
---|
| 1417 | break; |
---|
| 1418 | } |
---|
| 1419 | case SIZE_Nx2N: |
---|
| 1420 | { |
---|
| 1421 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
| 1422 | { |
---|
| 1423 | m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, 0, uiDepth, eRefList ); |
---|
| 1424 | } |
---|
| 1425 | |
---|
| 1426 | uiAbsPartIdx += uiPartOffset; |
---|
| 1427 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
| 1428 | { |
---|
| 1429 | m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, 0, uiDepth, eRefList ); |
---|
| 1430 | } |
---|
| 1431 | break; |
---|
| 1432 | } |
---|
| 1433 | case SIZE_NxN: |
---|
| 1434 | { |
---|
| 1435 | for ( Int iPartIdx = 0; iPartIdx < 4; iPartIdx++ ) |
---|
| 1436 | { |
---|
| 1437 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
| 1438 | { |
---|
| 1439 | m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, 0, uiDepth, eRefList ); |
---|
| 1440 | } |
---|
| 1441 | uiAbsPartIdx += uiPartOffset; |
---|
| 1442 | } |
---|
| 1443 | break; |
---|
| 1444 | } |
---|
| 1445 | default: |
---|
| 1446 | break; |
---|
| 1447 | } |
---|
| 1448 | return; |
---|
| 1449 | } |
---|
| 1450 | |
---|
| 1451 | Void TDecEntropy::xDecodeTransformSubdiv( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3 ) |
---|
| 1452 | { |
---|
| 1453 | UInt uiSubdiv; |
---|
| 1454 | const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth; |
---|
| 1455 | |
---|
| 1456 | #if CAVLC_RQT_CBP |
---|
| 1457 | if(pcCU->getSlice()->getSymbolMode()==0) |
---|
| 1458 | { |
---|
| 1459 | // code CBP and transform split flag jointly |
---|
| 1460 | UInt uiTrDepth = uiDepth - pcCU->getDepth( uiAbsPartIdx ); |
---|
| 1461 | m_pcEntropyDecoderIf->parseCbfTrdiv( pcCU, uiAbsPartIdx, uiTrDepth, uiDepth, uiSubdiv ); |
---|
| 1462 | } |
---|
| 1463 | else |
---|
| 1464 | {//CABAC |
---|
| 1465 | #endif |
---|
| 1466 | if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) ) |
---|
| 1467 | { |
---|
| 1468 | uiSubdiv = 1; |
---|
| 1469 | } |
---|
| 1470 | else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
| 1471 | { |
---|
| 1472 | uiSubdiv = 1; |
---|
| 1473 | } |
---|
| 1474 | else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
| 1475 | { |
---|
| 1476 | uiSubdiv = 0; |
---|
| 1477 | } |
---|
| 1478 | else if( uiLog2TrafoSize == pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ) |
---|
| 1479 | { |
---|
| 1480 | uiSubdiv = 0; |
---|
| 1481 | } |
---|
| 1482 | else |
---|
| 1483 | { |
---|
| 1484 | assert( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ); |
---|
| 1485 | #if HHI_RQT_FORCE_SPLIT_ACC2_PU |
---|
| 1486 | const UInt uiTrMode = uiDepth - pcCU->getDepth( uiAbsPartIdx ); |
---|
| 1487 | UInt uiCtx = uiDepth; |
---|
| 1488 | #if HHI_RQT_FORCE_SPLIT_NxN |
---|
| 1489 | const Bool bNxNOK = pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN && uiTrMode > 0; |
---|
| 1490 | #else |
---|
| 1491 | const Bool bNxNOK = pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN; |
---|
| 1492 | #endif |
---|
| 1493 | #if HHI_RQT_FORCE_SPLIT_RECT |
---|
| 1494 | const Bool bSymmetricOK = pcCU->getPartitionSize( uiAbsPartIdx ) >= SIZE_2NxN && pcCU->getPartitionSize( uiAbsPartIdx ) < SIZE_NxN && uiTrMode > 0; |
---|
| 1495 | #else |
---|
| 1496 | const Bool bSymmetricOK = pcCU->getPartitionSize( uiAbsPartIdx ) >= SIZE_2NxN && pcCU->getPartitionSize( uiAbsPartIdx ) < SIZE_NxN; |
---|
| 1497 | #endif |
---|
| 1498 | const Bool bNeedSubdivFlag = pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N || pcCU->getPredictionMode( uiAbsPartIdx ) == MODE_INTRA || |
---|
| 1499 | bNxNOK || bSymmetricOK; |
---|
| 1500 | |
---|
| 1501 | if( ! bNeedSubdivFlag ) |
---|
| 1502 | { |
---|
| 1503 | uiSubdiv = 1; |
---|
| 1504 | } |
---|
| 1505 | else |
---|
| 1506 | m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, uiCtx ); |
---|
| 1507 | #else |
---|
| 1508 | m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, uiDepth ); |
---|
| 1509 | #endif |
---|
| 1510 | } |
---|
| 1511 | #if CAVLC_RQT_CBP |
---|
| 1512 | } |
---|
| 1513 | #endif |
---|
| 1514 | |
---|
| 1515 | const UInt uiTrDepth = uiDepth - pcCU->getDepth( uiAbsPartIdx ); |
---|
| 1516 | |
---|
| 1517 | if(pcCU->getSlice()->getSymbolMode()==0) |
---|
| 1518 | { |
---|
| 1519 | if( uiSubdiv ) |
---|
| 1520 | { |
---|
| 1521 | ++uiDepth; |
---|
| 1522 | const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
| 1523 | |
---|
| 1524 | for( Int i = 0; i < 4; i++ ) |
---|
| 1525 | { |
---|
| 1526 | UInt uiDummyCbfY = 0; |
---|
| 1527 | UInt uiDummyCbfU = 0; |
---|
| 1528 | UInt uiDummyCbfV = 0; |
---|
| 1529 | xDecodeTransformSubdiv( pcCU, uiAbsPartIdx, uiDepth, i, uiDummyCbfY, uiDummyCbfU, uiDummyCbfV ); |
---|
| 1530 | uiAbsPartIdx += uiQPartNum; |
---|
| 1531 | } |
---|
| 1532 | } |
---|
| 1533 | else |
---|
| 1534 | { |
---|
| 1535 | assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) ); |
---|
| 1536 | pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth ); |
---|
| 1537 | } |
---|
| 1538 | } |
---|
| 1539 | else |
---|
| 1540 | { |
---|
| 1541 | if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiLog2TrafoSize <= pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
| 1542 | { |
---|
| 1543 | const Bool bFirstCbfOfCU = uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() || uiTrDepth == 0; |
---|
| 1544 | if( bFirstCbfOfCU ) |
---|
| 1545 | { |
---|
| 1546 | pcCU->setCbfSubParts( 0, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth ); |
---|
| 1547 | pcCU->setCbfSubParts( 0, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth ); |
---|
| 1548 | } |
---|
| 1549 | if( bFirstCbfOfCU || uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
| 1550 | { |
---|
| 1551 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) ) |
---|
| 1552 | { |
---|
| 1553 | if ( uiInnerQuadIdx == 3 && uiUCbfFront3 == 0 && uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
| 1554 | { |
---|
| 1555 | uiUCbfFront3++; |
---|
| 1556 | pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth ); |
---|
| 1557 | //printf( " \nsave bits, U Cbf"); |
---|
| 1558 | } |
---|
| 1559 | else |
---|
| 1560 | { |
---|
| 1561 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth, uiDepth ); |
---|
| 1562 | uiUCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth ); |
---|
| 1563 | } |
---|
| 1564 | } |
---|
| 1565 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) ) |
---|
| 1566 | { |
---|
| 1567 | if ( uiInnerQuadIdx == 3 && uiVCbfFront3 == 0 && uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
| 1568 | { |
---|
| 1569 | uiVCbfFront3++; |
---|
| 1570 | pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth ); |
---|
| 1571 | //printf( " \nsave bits, V Cbf"); |
---|
| 1572 | } |
---|
| 1573 | else |
---|
| 1574 | { |
---|
| 1575 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth, uiDepth ); |
---|
| 1576 | uiVCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth ); |
---|
| 1577 | } |
---|
| 1578 | } |
---|
| 1579 | } |
---|
| 1580 | else |
---|
| 1581 | { |
---|
| 1582 | pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth ); |
---|
| 1583 | pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth ); |
---|
| 1584 | |
---|
| 1585 | if ( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
| 1586 | { |
---|
| 1587 | uiUCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth ); |
---|
| 1588 | uiVCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth ); |
---|
| 1589 | } |
---|
| 1590 | } |
---|
| 1591 | } |
---|
| 1592 | |
---|
| 1593 | if( uiSubdiv ) |
---|
| 1594 | { |
---|
| 1595 | ++uiDepth; |
---|
| 1596 | const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
| 1597 | const UInt uiStartAbsPartIdx = uiAbsPartIdx; |
---|
| 1598 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
| 1599 | pcCU->convertTransIdx( uiStartAbsPartIdx, uiTrDepth+1, uiLumaTrMode, uiChromaTrMode ); |
---|
| 1600 | UInt uiYCbf = 0; |
---|
| 1601 | UInt uiUCbf = 0; |
---|
| 1602 | UInt uiVCbf = 0; |
---|
| 1603 | |
---|
| 1604 | UInt uiCurrentCbfY = 0; |
---|
| 1605 | UInt uiCurrentCbfU = 0; |
---|
| 1606 | UInt uiCurrentCbfV = 0; |
---|
| 1607 | |
---|
| 1608 | for( Int i = 0; i < 4; i++ ) |
---|
| 1609 | { |
---|
| 1610 | xDecodeTransformSubdiv( pcCU, uiAbsPartIdx, uiDepth, i, uiCurrentCbfY, uiCurrentCbfU, uiCurrentCbfV ); |
---|
| 1611 | uiYCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode ); |
---|
| 1612 | uiUCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiChromaTrMode ); |
---|
| 1613 | uiVCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiChromaTrMode ); |
---|
| 1614 | uiAbsPartIdx += uiQPartNum; |
---|
| 1615 | } |
---|
| 1616 | |
---|
| 1617 | uiYCbfFront3 += uiCurrentCbfY; |
---|
| 1618 | uiUCbfFront3 += uiCurrentCbfU; |
---|
| 1619 | uiVCbfFront3 += uiCurrentCbfV; |
---|
| 1620 | |
---|
| 1621 | pcCU->convertTransIdx( uiStartAbsPartIdx, uiTrDepth, uiLumaTrMode, uiChromaTrMode ); |
---|
| 1622 | for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui ) |
---|
| 1623 | { |
---|
| 1624 | pcCU->getCbf( TEXT_LUMA )[uiStartAbsPartIdx + ui] |= uiYCbf << uiLumaTrMode; |
---|
| 1625 | pcCU->getCbf( TEXT_CHROMA_U )[uiStartAbsPartIdx + ui] |= uiUCbf << uiChromaTrMode; |
---|
| 1626 | pcCU->getCbf( TEXT_CHROMA_V )[uiStartAbsPartIdx + ui] |= uiVCbf << uiChromaTrMode; |
---|
| 1627 | } |
---|
| 1628 | } |
---|
| 1629 | else |
---|
| 1630 | { |
---|
| 1631 | assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) ); |
---|
| 1632 | pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth ); |
---|
| 1633 | |
---|
| 1634 | { |
---|
| 1635 | DTRACE_CABAC_V( g_nSymbolCounter++ ); |
---|
| 1636 | DTRACE_CABAC_T( "\tTrIdx: abspart=" ); |
---|
| 1637 | DTRACE_CABAC_V( uiAbsPartIdx ); |
---|
| 1638 | DTRACE_CABAC_T( "\tdepth=" ); |
---|
| 1639 | DTRACE_CABAC_V( uiDepth ); |
---|
| 1640 | DTRACE_CABAC_T( "\ttrdepth=" ); |
---|
| 1641 | DTRACE_CABAC_V( uiTrDepth ); |
---|
| 1642 | DTRACE_CABAC_T( "\n" ); |
---|
| 1643 | } |
---|
| 1644 | |
---|
| 1645 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
| 1646 | pcCU->convertTransIdx( uiAbsPartIdx, uiTrDepth, uiLumaTrMode, uiChromaTrMode ); |
---|
| 1647 | pcCU->setCbfSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiDepth ); |
---|
| 1648 | if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) ) |
---|
| 1649 | { |
---|
| 1650 | pcCU->setCbfSubParts( 1 << uiLumaTrMode, TEXT_LUMA, uiAbsPartIdx, uiDepth ); |
---|
| 1651 | } |
---|
| 1652 | else |
---|
| 1653 | { |
---|
| 1654 | if ( pcCU->getPredictionMode( uiAbsPartIdx ) != MODE_INTRA && uiInnerQuadIdx == 3 && uiYCbfFront3 == 0 && uiUCbfFront3 == 0 && uiVCbfFront3 == 0 && uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
| 1655 | { |
---|
| 1656 | pcCU->setCbfSubParts( 1 << uiLumaTrMode, TEXT_LUMA, uiAbsPartIdx, uiDepth ); |
---|
| 1657 | //printf( " \nsave bits, Y Cbf"); |
---|
| 1658 | uiYCbfFront3++; |
---|
| 1659 | } |
---|
| 1660 | else |
---|
| 1661 | { |
---|
| 1662 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode, uiDepth ); |
---|
| 1663 | uiYCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode ); |
---|
| 1664 | } |
---|
| 1665 | } |
---|
| 1666 | |
---|
| 1667 | if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA ) |
---|
| 1668 | { |
---|
| 1669 | Bool bCodeChroma = true; |
---|
| 1670 | UInt uiDepthChroma = uiDepth; |
---|
| 1671 | if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
| 1672 | { |
---|
| 1673 | UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
| 1674 | bCodeChroma = ( ( uiAbsPartIdx % uiQPDiv ) == 0 ); |
---|
| 1675 | uiDepthChroma--; |
---|
| 1676 | } |
---|
| 1677 | if( bCodeChroma ) |
---|
| 1678 | { |
---|
| 1679 | pcCU->setCbfSubParts( 0, TEXT_CHROMA_U, uiAbsPartIdx, uiDepthChroma ); |
---|
| 1680 | pcCU->setCbfSubParts( 0, TEXT_CHROMA_V, uiAbsPartIdx, uiDepthChroma ); |
---|
| 1681 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiChromaTrMode, uiDepthChroma ); |
---|
| 1682 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiChromaTrMode, uiDepthChroma ); |
---|
| 1683 | } |
---|
| 1684 | } |
---|
| 1685 | } |
---|
| 1686 | } |
---|
| 1687 | } |
---|
| 1688 | |
---|
| 1689 | Void TDecEntropy::decodeTransformIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1690 | { |
---|
| 1691 | DTRACE_CABAC_V( g_nSymbolCounter++ ) |
---|
| 1692 | DTRACE_CABAC_T( "\tdecodeTransformIdx()\tCUDepth=" ) |
---|
| 1693 | DTRACE_CABAC_V( uiDepth ) |
---|
| 1694 | DTRACE_CABAC_T( "\n" ) |
---|
| 1695 | UInt temp = 0; |
---|
| 1696 | UInt temp1 = 0; |
---|
| 1697 | UInt temp2 = 0; |
---|
| 1698 | xDecodeTransformSubdiv( pcCU, uiAbsPartIdx, uiDepth, 0, temp, temp1, temp2 ); |
---|
| 1699 | } |
---|
| 1700 | |
---|
| 1701 | Void TDecEntropy::decodeQP ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1702 | { |
---|
| 1703 | if ( pcCU->getSlice()->getSPS()->getUseDQP() ) |
---|
| 1704 | { |
---|
| 1705 | m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 1706 | } |
---|
| 1707 | } |
---|
| 1708 | |
---|
| 1709 | Void TDecEntropy::decodeViewidx(Int & riViewIdx) |
---|
| 1710 | { |
---|
| 1711 | m_pcEntropyDecoderIf->parseViewIdx( riViewIdx ); |
---|
| 1712 | } |
---|
| 1713 | |
---|
| 1714 | Void TDecEntropy::xDecodeCoeff( TComDataCU* pcCU, TCoeff* pcCoeff, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, UInt uiTrIdx, UInt uiCurrTrIdx, TextType eType ) |
---|
| 1715 | { |
---|
| 1716 | if ( pcCU->getCbf( uiAbsPartIdx, eType, uiTrIdx ) ) |
---|
| 1717 | { |
---|
| 1718 | #if SNY_DQP |
---|
| 1719 | // dQP: only for LCU |
---|
| 1720 | if ( pcCU->getSlice()->getSPS()->getUseDQP() ) |
---|
| 1721 | { |
---|
| 1722 | if ( pcCU->getdQPFlag())// non-skip |
---|
| 1723 | { |
---|
| 1724 | decodeQP( pcCU, 0, 0 ); |
---|
| 1725 | pcCU->setdQPFlag(false); |
---|
| 1726 | } |
---|
| 1727 | } |
---|
| 1728 | #endif//SNY_DQP |
---|
| 1729 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
| 1730 | pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx( uiAbsPartIdx ), uiLumaTrMode, uiChromaTrMode ); |
---|
| 1731 | const UInt uiStopTrMode = eType == TEXT_LUMA ? uiLumaTrMode : uiChromaTrMode; |
---|
| 1732 | |
---|
| 1733 | if( uiTrIdx == uiStopTrMode ) |
---|
| 1734 | { |
---|
| 1735 | UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiDepth ] + 2; |
---|
| 1736 | if( eType != TEXT_LUMA && uiLog2TrSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
| 1737 | { |
---|
| 1738 | UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
| 1739 | if( ( uiAbsPartIdx % uiQPDiv ) != 0 ) |
---|
| 1740 | { |
---|
| 1741 | return; |
---|
| 1742 | } |
---|
| 1743 | uiWidth <<= 1; |
---|
| 1744 | uiHeight <<= 1; |
---|
| 1745 | } |
---|
| 1746 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, pcCoeff, uiAbsPartIdx, uiWidth, uiHeight, uiDepth, eType ); |
---|
| 1747 | } |
---|
| 1748 | else |
---|
| 1749 | { |
---|
| 1750 | { |
---|
| 1751 | DTRACE_CABAC_V( g_nSymbolCounter++ ); |
---|
| 1752 | DTRACE_CABAC_T( "\tgoing down\tdepth=" ); |
---|
| 1753 | DTRACE_CABAC_V( uiDepth ); |
---|
| 1754 | DTRACE_CABAC_T( "\ttridx=" ); |
---|
| 1755 | DTRACE_CABAC_V( uiTrIdx ); |
---|
| 1756 | DTRACE_CABAC_T( "\n" ); |
---|
| 1757 | } |
---|
| 1758 | if( uiCurrTrIdx <= uiTrIdx ) |
---|
| 1759 | assert(1); |
---|
| 1760 | UInt uiSize; |
---|
| 1761 | uiWidth >>= 1; |
---|
| 1762 | uiHeight >>= 1; |
---|
| 1763 | uiSize = uiWidth*uiHeight; |
---|
| 1764 | uiDepth++; |
---|
| 1765 | uiTrIdx++; |
---|
| 1766 | |
---|
| 1767 | UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
| 1768 | UInt uiIdx = uiAbsPartIdx; |
---|
| 1769 | |
---|
| 1770 | #if !CAVLC_RQT_CBP |
---|
| 1771 | if(pcCU->getSlice()->getSymbolMode() == 0) |
---|
| 1772 | { |
---|
| 1773 | UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiDepth ] + 2; |
---|
| 1774 | if( eType == TEXT_LUMA || uiLog2TrSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
| 1775 | m_pcEntropyDecoderIf->parseBlockCbf(pcCU, uiIdx, eType, uiTrIdx, uiDepth, uiQPartNum); |
---|
| 1776 | else |
---|
| 1777 | { |
---|
| 1778 | UInt uiCbf = pcCU->getCbf( uiIdx, eType ); |
---|
| 1779 | pcCU->setCbfSubParts( uiCbf | ( 0x01 << uiTrIdx ), eType, uiIdx, uiDepth ); |
---|
| 1780 | uiCbf = pcCU->getCbf( uiIdx + uiQPartNum, eType ); |
---|
| 1781 | pcCU->setCbfSubParts( uiCbf | ( 0x01 << uiTrIdx ), eType, uiIdx + uiQPartNum, uiDepth ); |
---|
| 1782 | uiCbf = pcCU->getCbf( uiIdx + 2*uiQPartNum, eType ); |
---|
| 1783 | pcCU->setCbfSubParts( uiCbf | ( 0x01 << uiTrIdx ), eType, uiIdx + 2*uiQPartNum, uiDepth ); |
---|
| 1784 | uiCbf = pcCU->getCbf( uiIdx + 3*uiQPartNum, eType ); |
---|
| 1785 | pcCU->setCbfSubParts( uiCbf | ( 0x01 << uiTrIdx ), eType, uiIdx + 3*uiQPartNum, uiDepth ); |
---|
| 1786 | } |
---|
| 1787 | xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType ); pcCoeff += uiSize; uiIdx += uiQPartNum; |
---|
| 1788 | xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType ); pcCoeff += uiSize; uiIdx += uiQPartNum; |
---|
| 1789 | xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType ); pcCoeff += uiSize; uiIdx += uiQPartNum; |
---|
| 1790 | xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType ); |
---|
| 1791 | } |
---|
| 1792 | else |
---|
| 1793 | { |
---|
| 1794 | #endif |
---|
| 1795 | xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType ); pcCoeff += uiSize; uiIdx += uiQPartNum; |
---|
| 1796 | xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType ); pcCoeff += uiSize; uiIdx += uiQPartNum; |
---|
| 1797 | xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType ); pcCoeff += uiSize; uiIdx += uiQPartNum; |
---|
| 1798 | xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType ); |
---|
| 1799 | #if !CAVLC_RQT_CBP |
---|
| 1800 | } |
---|
| 1801 | #endif |
---|
| 1802 | { |
---|
| 1803 | DTRACE_CABAC_V( g_nSymbolCounter++ ); |
---|
| 1804 | DTRACE_CABAC_T( "\tgoing up\n" ); |
---|
| 1805 | } |
---|
| 1806 | } |
---|
| 1807 | } |
---|
| 1808 | } |
---|
| 1809 | |
---|
| 1810 | /** decode coefficients |
---|
| 1811 | * \param pcCU |
---|
| 1812 | * \param uiAbsPartIdx |
---|
| 1813 | * \param uiDepth |
---|
| 1814 | * \param uiWidth |
---|
| 1815 | * \param uiHeight |
---|
| 1816 | * \returns Void |
---|
| 1817 | */ |
---|
| 1818 | Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight ) |
---|
| 1819 | { |
---|
| 1820 | UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); |
---|
| 1821 | UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; |
---|
| 1822 | UInt uiChromaOffset = uiLumaOffset>>2; |
---|
| 1823 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
| 1824 | |
---|
| 1825 | if( pcCU->isIntra(uiAbsPartIdx) ) |
---|
| 1826 | { |
---|
| 1827 | decodeTransformIdx( pcCU, uiAbsPartIdx, pcCU->getDepth(uiAbsPartIdx) ); |
---|
| 1828 | |
---|
| 1829 | pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx(uiAbsPartIdx), uiLumaTrMode, uiChromaTrMode ); |
---|
| 1830 | |
---|
| 1831 | if (pcCU->getSlice()->getSymbolMode() == 0) |
---|
| 1832 | { |
---|
| 1833 | #if !CAVLC_RQT_CBP |
---|
| 1834 | m_pcEntropyDecoderIf->parseCbf( pcCU, uiAbsPartIdx, TEXT_ALL, 0, uiDepth ); |
---|
| 1835 | #endif |
---|
| 1836 | if(pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA, 0)==0 && pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U, 0)==0 |
---|
| 1837 | && pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V, 0)==0) |
---|
| 1838 | return; |
---|
| 1839 | } |
---|
| 1840 | } |
---|
| 1841 | else |
---|
| 1842 | { |
---|
| 1843 | if (pcCU->getSlice()->getSymbolMode()==0) |
---|
| 1844 | { |
---|
| 1845 | #if !CAVLC_RQT_CBP |
---|
| 1846 | m_pcEntropyDecoderIf->parseCbf( pcCU, uiAbsPartIdx, TEXT_ALL, 0, uiDepth ); |
---|
| 1847 | if(pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA, 0)==0 && pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U, 0)==0 |
---|
| 1848 | && pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V, 0)==0) |
---|
| 1849 | return; |
---|
| 1850 | #endif |
---|
| 1851 | } |
---|
| 1852 | else |
---|
| 1853 | { |
---|
| 1854 | #if HHI_MRG_SKIP |
---|
| 1855 | UInt uiQtRootCbf = 1; |
---|
[5] | 1856 | #if HHI_MPI |
---|
[2] | 1857 | if( !(pcCU->getMergeFlag( uiAbsPartIdx ) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N && |
---|
| 1858 | ( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth == pcCU->getTextureModeDepth( uiAbsPartIdx ) ) ) ) |
---|
| 1859 | #else |
---|
| 1860 | if( !( pcCU->getPartitionSize( uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getMergeFlag( uiAbsPartIdx ) ) ) |
---|
| 1861 | #endif |
---|
| 1862 | { |
---|
| 1863 | m_pcEntropyDecoderIf->parseQtRootCbf( pcCU, uiAbsPartIdx, uiDepth, uiQtRootCbf ); |
---|
| 1864 | } |
---|
| 1865 | #else |
---|
| 1866 | UInt uiQtRootCbf; |
---|
| 1867 | m_pcEntropyDecoderIf->parseQtRootCbf( pcCU, uiAbsPartIdx, uiDepth, uiQtRootCbf ); |
---|
| 1868 | #endif |
---|
| 1869 | if ( !uiQtRootCbf ) |
---|
| 1870 | { |
---|
| 1871 | pcCU->setCbfSubParts( 0, 0, 0, uiAbsPartIdx, uiDepth ); |
---|
| 1872 | pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth ); |
---|
| 1873 | return; |
---|
| 1874 | } |
---|
| 1875 | } |
---|
| 1876 | |
---|
| 1877 | decodeTransformIdx( pcCU, uiAbsPartIdx, pcCU->getDepth(uiAbsPartIdx) ); |
---|
| 1878 | |
---|
| 1879 | #if CAVLC_RQT_CBP |
---|
| 1880 | if (pcCU->getSlice()->getSymbolMode() == 0) |
---|
| 1881 | { |
---|
| 1882 | if(pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA, 0)==0 && pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U, 0)==0 |
---|
| 1883 | && pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V, 0)==0) |
---|
| 1884 | return; |
---|
| 1885 | } |
---|
| 1886 | #endif |
---|
| 1887 | pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx(uiAbsPartIdx), uiLumaTrMode, uiChromaTrMode ); |
---|
| 1888 | } |
---|
| 1889 | |
---|
| 1890 | xDecodeCoeff( pcCU, pcCU->getCoeffY() + uiLumaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, uiLumaTrMode, TEXT_LUMA ); |
---|
| 1891 | xDecodeCoeff( pcCU, pcCU->getCoeffCb() + uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth>>1, uiHeight>>1, 0, uiChromaTrMode, TEXT_CHROMA_U ); |
---|
| 1892 | xDecodeCoeff( pcCU, pcCU->getCoeffCr() + uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth>>1, uiHeight>>1, 0, uiChromaTrMode, TEXT_CHROMA_V ); |
---|
| 1893 | } |
---|
| 1894 | |
---|
| 1895 | #if MTK_SAO |
---|
| 1896 | /** decodeQAO One Part |
---|
| 1897 | * \param pQaoParam, iPartIdx |
---|
| 1898 | */ |
---|
| 1899 | Void TDecEntropy::decodeQAOOnePart(SAOParam* pQaoParam, Int iPartIdx) |
---|
| 1900 | { |
---|
| 1901 | UInt uiSymbol; |
---|
| 1902 | Int iSymbol; |
---|
| 1903 | |
---|
| 1904 | SAOQTPart* pAlfPart = &(pQaoParam->psSaoPart[iPartIdx]); |
---|
| 1905 | static Int iTypeLength[MAX_NUM_SAO_TYPE] = { |
---|
| 1906 | SAO_EO_LEN, |
---|
| 1907 | SAO_EO_LEN, |
---|
| 1908 | SAO_EO_LEN, |
---|
| 1909 | SAO_EO_LEN, |
---|
| 1910 | SAO_BO_LEN, |
---|
| 1911 | SAO_BO_LEN |
---|
| 1912 | }; |
---|
| 1913 | if(!pAlfPart->bSplit) |
---|
| 1914 | { |
---|
| 1915 | |
---|
| 1916 | m_pcEntropyDecoderIf->parseAoUvlc(uiSymbol); |
---|
| 1917 | |
---|
| 1918 | if (uiSymbol) |
---|
| 1919 | { |
---|
| 1920 | pAlfPart->iBestType = uiSymbol-1; |
---|
| 1921 | pAlfPart->bEnableFlag = true; |
---|
| 1922 | } |
---|
| 1923 | else |
---|
| 1924 | { |
---|
| 1925 | pAlfPart->iBestType = -1; |
---|
| 1926 | pAlfPart->bEnableFlag = false; |
---|
| 1927 | } |
---|
| 1928 | |
---|
| 1929 | if (pAlfPart->bEnableFlag) |
---|
| 1930 | { |
---|
| 1931 | |
---|
| 1932 | pAlfPart->iLength = iTypeLength[pAlfPart->iBestType]; |
---|
| 1933 | |
---|
| 1934 | for(Int i=0; i< pAlfPart->iLength; i++) |
---|
| 1935 | { |
---|
| 1936 | m_pcEntropyDecoderIf->parseAoSvlc(iSymbol); |
---|
| 1937 | pAlfPart->iOffset[i] = iSymbol; |
---|
| 1938 | } |
---|
| 1939 | |
---|
| 1940 | } |
---|
| 1941 | return; |
---|
| 1942 | } |
---|
| 1943 | |
---|
| 1944 | //split |
---|
| 1945 | if (pAlfPart->PartLevel < pQaoParam->iMaxSplitLevel) |
---|
| 1946 | { |
---|
| 1947 | for(Int i=0;i<NUM_DOWN_PART;i++) |
---|
| 1948 | { |
---|
| 1949 | decodeQAOOnePart(pQaoParam, pAlfPart->DownPartsIdx[i]); |
---|
| 1950 | } |
---|
| 1951 | } |
---|
| 1952 | } |
---|
| 1953 | /** decode QuadTree Split Flag |
---|
| 1954 | * \param pQaoParam, iPartIdx |
---|
| 1955 | */ |
---|
| 1956 | Void TDecEntropy::decodeQuadTreeSplitFlag(SAOParam* pQaoParam, Int iPartIdx) |
---|
| 1957 | { |
---|
| 1958 | UInt uiSymbol; |
---|
| 1959 | SAOQTPart* pAlfPart = &(pQaoParam->psSaoPart[iPartIdx]); |
---|
| 1960 | |
---|
| 1961 | if(pAlfPart->PartLevel < pQaoParam->iMaxSplitLevel) |
---|
| 1962 | { |
---|
| 1963 | |
---|
| 1964 | //send one flag |
---|
| 1965 | m_pcEntropyDecoderIf->parseAoFlag(uiSymbol); |
---|
| 1966 | pAlfPart->bSplit = uiSymbol? true:false; |
---|
| 1967 | if(pAlfPart->bSplit) |
---|
| 1968 | { |
---|
| 1969 | for (Int i=0;i<NUM_DOWN_PART;i++) |
---|
| 1970 | { |
---|
| 1971 | decodeQuadTreeSplitFlag(pQaoParam, pAlfPart->DownPartsIdx[i]); |
---|
| 1972 | } |
---|
| 1973 | } |
---|
| 1974 | } |
---|
| 1975 | |
---|
| 1976 | } |
---|
| 1977 | /** decode Sao Param |
---|
| 1978 | * \param pQaoParam |
---|
| 1979 | */ |
---|
| 1980 | Void TDecEntropy::decodeSaoParam(SAOParam* pQaoParam) |
---|
| 1981 | { |
---|
| 1982 | UInt uiSymbol; |
---|
| 1983 | |
---|
| 1984 | m_pcEntropyDecoderIf->parseAoFlag(uiSymbol); |
---|
| 1985 | if (uiSymbol) |
---|
| 1986 | { |
---|
| 1987 | pQaoParam->bSaoFlag = true; |
---|
| 1988 | } |
---|
| 1989 | else |
---|
| 1990 | { |
---|
| 1991 | pQaoParam->bSaoFlag = false; |
---|
| 1992 | } |
---|
| 1993 | if (pQaoParam->bSaoFlag) |
---|
| 1994 | { |
---|
| 1995 | decodeQuadTreeSplitFlag(pQaoParam, 0); |
---|
| 1996 | decodeQAOOnePart(pQaoParam, 0); |
---|
| 1997 | } |
---|
| 1998 | |
---|
| 1999 | } |
---|
| 2000 | |
---|
| 2001 | #endif |
---|