Showing the changes to codec/decoder/core/src/decode_slice.cpp (1 of 25 files). Show all
Unified · Split
| @@ -144,7 +144,6 @@ int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) { · 143 unmodified lines | ||
| 144 | 144 | return 0;//NO_SUPPORTED_FILTER_IDX |
| 145 | 145 | } else { |
| 146 | 146 | WelsDeblockingFilterSlice (pCtx, pDeblockMb); |
| 147 | − | |
| 148 | 147 | } |
| 149 | 148 | // any other filter_idc not supported here, 7/22/2010 |
| 150 | 149 | |
| @@ -159,11 +158,22 @@ int32_t WelsMbInterSampleConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLa · 8 unmodified lines | ||
| 159 | 158 | WelsChromaDcIdct (pCurLayer->pScaledTCoeff[iMbXy] + 256); // 256 = 16*16 |
| 160 | 159 | WelsChromaDcIdct (pCurLayer->pScaledTCoeff[iMbXy] + 320); // 320 = 16*16 + 16*4 |
| 161 | 160 | |
| 162 | − for (i = 0; i < 16; i++) { //luma | |
| 163 | − iIndex = g_kuiMbCountScan4Idx[i]; | |
| 164 | − if (pCurLayer->pNzc[iMbXy][iIndex]) { | |
| 165 | − iOffset = ((iIndex >> 2) << 2) * iStrideL + ((iIndex % 4) << 2); | |
| 166 | − pCtx->pIdctResAddPredFunc (pDstY + iOffset, iStrideL, pCurLayer->pScaledTCoeff[iMbXy] + (i << 4)); | |
| 161 | + if (pCurLayer->pTransformSize8x8Flag[iMbXy]) { | |
| 162 | + for (i = 0; i < 4; i++) { | |
| 163 | + iIndex = g_kuiMbCountScan4Idx[i << 2]; | |
| 164 | + if (pCurLayer->pNzc[iMbXy][iIndex] || pCurLayer->pNzc[iMbXy][iIndex + 1] || pCurLayer->pNzc[iMbXy][iIndex + 4] | |
| 165 | + || pCurLayer->pNzc[iMbXy][iIndex + 5]) { | |
| 166 | + iOffset = ((iIndex >> 2) << 2) * iStrideL + ((iIndex % 4) << 2); | |
| 167 | + pCtx->pIdctResAddPredFunc8x8 (pDstY + iOffset, iStrideL, pCurLayer->pScaledTCoeff[iMbXy] + (i << 6)); | |
| 168 | + } | |
| 169 | + } | |
| 170 | + } else { | |
| 171 | + for (i = 0; i < 16; i++) { //luma | |
| 172 | + iIndex = g_kuiMbCountScan4Idx[i]; | |
| 173 | + if (pCurLayer->pNzc[iMbXy][iIndex]) { | |
| 174 | + iOffset = ((iIndex >> 2) << 2) * iStrideL + ((iIndex % 4) << 2); | |
| 175 | + pCtx->pIdctResAddPredFunc (pDstY + iOffset, iStrideL, pCurLayer->pScaledTCoeff[iMbXy] + (i << 4)); | |
| 176 | + } | |
| 167 | 177 | } |
| 168 | 178 | } |
| 169 | 179 | |
| @@ -258,6 +268,10 @@ int32_t WelsMbIntraPredictionConstruction (PWelsDecoderContext pCtx, PDqLayer pC · 88 unmodified lines | ||
| 258 | 268 | return 0; |
| 259 | 269 | } |
| 260 | 270 | |
| 271 | + if (IS_INTRA8x8 (pCurLayer->pMbType[iMbXy])) { | |
| 272 | + RecI8x8Mb (iMbXy, pCtx, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer); | |
| 273 | + } | |
| 274 | + | |
| 261 | 275 | if (IS_INTRA4x4 (pCurLayer->pMbType[iMbXy])) |
| 262 | 276 | RecI4x4Mb (iMbXy, pCtx, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer); |
| 263 | 277 | |
| @@ -326,7 +340,7 @@ void WelsChromaDcIdct (int16_t* pBlock) { · 62 unmodified lines | ||
| 326 | 340 | pBlk[iStride1] = (iE - iB) >> 1; |
| 327 | 341 | } |
| 328 | 342 | |
| 329 | −void WelsMap4x4NeighToSampleNormal (PWelsNeighAvail pNeighAvail, int32_t* pSampleAvail) { | |
| 343 | +void WelsMapNxNNeighToSampleNormal (PWelsNeighAvail pNeighAvail, int32_t* pSampleAvail) { | |
| 330 | 344 | if (pNeighAvail->iLeftAvail) { //left |
| 331 | 345 | pSampleAvail[ 6] = |
| 332 | 346 | pSampleAvail[12] = |
| @@ -347,7 +361,7 @@ void WelsMap4x4NeighToSampleNormal (PWelsNeighAvail pNeighAvail, int32_t* pSampl · 14 unmodified lines | ||
| 347 | 361 | } |
| 348 | 362 | } |
| 349 | 363 | |
| 350 | −void WelsMap4x4NeighToSampleConstrain1 (PWelsNeighAvail pNeighAvail, int32_t* pSampleAvail) { | |
| 364 | +void WelsMapNxNNeighToSampleConstrain1 (PWelsNeighAvail pNeighAvail, int32_t* pSampleAvail) { | |
| 351 | 365 | if (pNeighAvail->iLeftAvail && IS_INTRA (pNeighAvail->iLeftType)) { //left |
| 352 | 366 | pSampleAvail[ 6] = |
| 353 | 367 | pSampleAvail[12] = |
| @@ -401,7 +415,7 @@ int32_t ParseIntra4x4Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail · 47 unmodified lines | ||
| 401 | 415 | uint8_t uiNeighAvail = 0; |
| 402 | 416 | uint32_t uiCode; |
| 403 | 417 | int32_t iCode; |
| 404 | − pCtx->pMap4x4NeighToSampleFunc (pNeighAvail, iSampleAvail); | |
| 418 | + pCtx->pMapNxNNeighToSampleFunc (pNeighAvail, iSampleAvail); | |
| 405 | 419 | uiNeighAvail = (iSampleAvail[6] << 2) | (iSampleAvail[0] << 1) | (iSampleAvail[1]); |
| 406 | 420 | for (i = 0; i < 16; i++) { |
| 407 | 421 | int32_t iPrevIntra4x4PredMode = 0; |
| @@ -429,7 +443,7 @@ int32_t ParseIntra4x4Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail · 21 unmodified lines | ||
| 429 | 443 | } |
| 430 | 444 | } |
| 431 | 445 | |
| 432 | − iFinalMode = CheckIntra4x4PredMode (&iSampleAvail[0], &iBestMode, i); | |
| 446 | + iFinalMode = CheckIntraNxNPredMode (&iSampleAvail[0], &iBestMode, i, false); | |
| 433 | 447 | if (iFinalMode == ERR_INVALID_INTRA4X4_MODE) { |
| 434 | 448 | return ERR_INFO_INVALID_I4x4_PRED_MODE; |
| 435 | 449 | } |
| @@ -469,6 +483,87 @@ int32_t ParseIntra4x4Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail · 33 unmodified lines | ||
| 469 | 483 | return ERR_NONE; |
| 470 | 484 | } |
| 471 | 485 | |
| 486 | +int32_t ParseIntra8x8Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, int8_t* pIntraPredMode, | |
| 487 | + PBitStringAux pBs, | |
| 488 | + PDqLayer pCurDqLayer) { | |
| 489 | + // Similar with Intra_4x4, can put them together when needed | |
| 490 | + int32_t iSampleAvail[5 * 6] = { 0 }; //initialize as 0 | |
| 491 | + int32_t iMbXy = pCurDqLayer->iMbXyIndex; | |
| 492 | + int32_t iFinalMode, i; | |
| 493 | + | |
| 494 | + uint8_t uiNeighAvail = 0; | |
| 495 | + uint32_t uiCode; | |
| 496 | + int32_t iCode; | |
| 497 | + pCtx->pMapNxNNeighToSampleFunc (pNeighAvail, iSampleAvail); | |
| 498 | + // Top-Right : Left : Top-Left : Top | |
| 499 | + uiNeighAvail = (iSampleAvail[5] << 3) | (iSampleAvail[6] << 2) | (iSampleAvail[0] << 1) | (iSampleAvail[1]); | |
| 500 | + | |
| 501 | + pCurDqLayer->pIntraNxNAvailFlag[iMbXy] = uiNeighAvail; | |
| 502 | + | |
| 503 | + for (i = 0; i < 4; i++) { | |
| 504 | + int32_t iPrevIntra4x4PredMode = 0; | |
| 505 | + if (pCurDqLayer->sLayerInfo.pPps->bEntropyCodingModeFlag) { | |
| 506 | + WELS_READ_VERIFY (ParseIntraPredModeLumaCabac (pCtx, iCode)); | |
| 507 | + iPrevIntra4x4PredMode = iCode; | |
| 508 | + } else { | |
| 509 | + WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); | |
| 510 | + iPrevIntra4x4PredMode = uiCode; | |
| 511 | + } | |
| 512 | + const int32_t kiPredMode = PredIntra4x4Mode (pIntraPredMode, i << 2); | |
| 513 | + | |
| 514 | + int8_t iBestMode; | |
| 515 | + if (pCurDqLayer->sLayerInfo.pPps->bEntropyCodingModeFlag) { | |
| 516 | + if (iPrevIntra4x4PredMode == -1) | |
| 517 | + iBestMode = kiPredMode; | |
| 518 | + else | |
| 519 | + iBestMode = iPrevIntra4x4PredMode + (iPrevIntra4x4PredMode >= kiPredMode); | |
| 520 | + } else { | |
| 521 | + if (iPrevIntra4x4PredMode) { | |
| 522 | + iBestMode = kiPredMode; | |
| 523 | + } else { | |
| 524 | + WELS_READ_VERIFY (BsGetBits (pBs, 3, &uiCode)); | |
| 525 | + iBestMode = uiCode + ((int32_t) uiCode >= kiPredMode); | |
| 526 | + } | |
| 527 | + } | |
| 528 | + | |
| 529 | + iFinalMode = CheckIntraNxNPredMode (&iSampleAvail[0], &iBestMode, i << 2, true); | |
| 530 | + | |
| 531 | + if (iFinalMode == ERR_INVALID_INTRA4X4_MODE) { | |
| 532 | + return ERR_INFO_INVALID_I4x4_PRED_MODE; | |
| 533 | + } | |
| 534 | + | |
| 535 | + for (int j = 0; j < 4; j++) { | |
| 536 | + pCurDqLayer->pIntra4x4FinalMode[iMbXy][g_kuiScan4[ (i << 2) + j]] = iFinalMode; | |
| 537 | + pIntraPredMode[g_kuiScan8[ (i << 2) + j]] = iBestMode; | |
| 538 | + iSampleAvail[g_kuiCache30ScanIdx[ (i << 2) + j]] = 1; | |
| 539 | + } | |
| 540 | + } | |
| 541 | + ST32 (&pCurDqLayer->pIntraPredMode[iMbXy][0], LD32 (&pIntraPredMode[1 + 8 * 4])); | |
| 542 | + pCurDqLayer->pIntraPredMode[iMbXy][4] = pIntraPredMode[4 + 8 * 1]; | |
| 543 | + pCurDqLayer->pIntraPredMode[iMbXy][5] = pIntraPredMode[4 + 8 * 2]; | |
| 544 | + pCurDqLayer->pIntraPredMode[iMbXy][6] = pIntraPredMode[4 + 8 * 3]; | |
| 545 | + if (pCurDqLayer->sLayerInfo.pPps->bEntropyCodingModeFlag) { | |
| 546 | + WELS_READ_VERIFY (ParseIntraPredModeChromaCabac (pCtx, uiNeighAvail, iCode)); | |
| 547 | + if (iCode > MAX_PRED_MODE_ID_CHROMA) { | |
| 548 | + return ERR_INFO_INVALID_I_CHROMA_PRED_MODE; | |
| 549 | + } | |
| 550 | + pCurDqLayer->pChromaPredMode[iMbXy] = iCode; | |
| 551 | + } else { | |
| 552 | + WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //intra_chroma_pred_mode | |
| 553 | + if (uiCode > MAX_PRED_MODE_ID_CHROMA) { | |
| 554 | + return ERR_INFO_INVALID_I_CHROMA_PRED_MODE; | |
| 555 | + } | |
| 556 | + pCurDqLayer->pChromaPredMode[iMbXy] = uiCode; | |
| 557 | + } | |
| 558 | + | |
| 559 | + if (-1 == pCurDqLayer->pChromaPredMode[iMbXy] | |
| 560 | + || CheckIntraChromaPredMode (uiNeighAvail, &pCurDqLayer->pChromaPredMode[iMbXy])) { | |
| 561 | + return ERR_INFO_INVALID_I_CHROMA_PRED_MODE; | |
| 562 | + } | |
| 563 | + | |
| 564 | + return ERR_NONE; | |
| 565 | +} | |
| 566 | + | |
| 472 | 567 | int32_t ParseIntra16x16Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, PBitStringAux pBs, |
| 473 | 568 | PDqLayer pCurDqLayer) { |
| 474 | 569 | int32_t iMbXy = pCurDqLayer->iMbXyIndex; |
| @@ -519,6 +614,9 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 44 unmodified lines | ||
| 519 | 614 | |
| 520 | 615 | ENFORCE_STACK_ALIGN_1D (uint8_t, pNonZeroCount, 48, 16); |
| 521 | 616 | |
| 617 | + pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; | |
| 618 | + pCurLayer->pTransformSize8x8Flag[iMbXy] = false; | |
| 619 | + | |
| 522 | 620 | pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0; |
| 523 | 621 | pCurLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag; |
| 524 | 622 | GetNeighborAvailMbType (&sNeighAvail, pCurLayer); |
| @@ -539,8 +637,18 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 14 unmodified lines | ||
| 539 | 637 | } else if (0 == uiMbType) { //I4x4 |
| 540 | 638 | ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16); |
| 541 | 639 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4; |
| 542 | − pCtx->pFillInfoCacheIntra4x4Func (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); | |
| 543 | − WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBsAux, pCurLayer)); | |
| 640 | + if (pCtx->pPps->bTransform8x8ModeFlag) { | |
| 641 | + // Transform 8x8 cabac will be added soon | |
| 642 | + WELS_READ_VERIFY (ParseTransformSize8x8FlagCabac (pCtx, &sNeighAvail, pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy])); | |
| 643 | + } | |
| 644 | + if (pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { | |
| 645 | + uiMbType = pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA8x8; | |
| 646 | + pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); | |
| 647 | + WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, &sNeighAvail, pIntraPredMode, pBsAux, pCurLayer)); | |
| 648 | + } else { | |
| 649 | + pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); | |
| 650 | + WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBsAux, pCurLayer)); | |
| 651 | + } | |
| 544 | 652 | //get uiCbp for I4x4 |
| 545 | 653 | WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, &sNeighAvail, uiCbp)); |
| 546 | 654 | pCurLayer->pCbp[iMbXy] = uiCbp; |
| @@ -549,6 +657,8 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 2 unmodified lines | ||
| 549 | 657 | uiCbpLuma = uiCbp & 15; |
| 550 | 658 | } else { //I16x16; |
| 551 | 659 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16; |
| 660 | + pCurLayer->pTransformSize8x8Flag[iMbXy] = false; | |
| 661 | + pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; | |
| 552 | 662 | pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; |
| 553 | 663 | pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; |
| 554 | 664 | uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0 ; |
| @@ -565,7 +675,7 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 10 unmodified lines | ||
| 565 | 675 | ST32 (&pCurLayer->pNzc[iMbXy][20], 0); |
| 566 | 676 | pCurLayer->pCbfDc[iMbXy] = 0; |
| 567 | 677 | |
| 568 | − if (pCurLayer->pCbp[iMbXy] == 0 && IS_INTRA4x4 (pCurLayer->pMbType[iMbXy])) { | |
| 678 | + if (pCurLayer->pCbp[iMbXy] == 0 && IS_INTRANxN (pCurLayer->pMbType[iMbXy])) { | |
| 569 | 679 | pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; |
| 570 | 680 | for (i = 0; i < 2; i++) { |
| 571 | 681 | pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 ((pCurLayer->pLumaQp[iMbXy] + |
| @@ -608,26 +718,43 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 36 unmodified lines | ||
| 608 | 718 | ST32 (&pCurLayer->pNzc[iMbXy][12], 0); |
| 609 | 719 | } |
| 610 | 720 | } else { //non-MB_TYPE_INTRA16x16 |
| 611 | − for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { | |
| 612 | − if (uiCbpLuma & (1 << iId8x8)) { | |
| 613 | − int32_t iIdx = (iId8x8 << 2); | |
| 614 | − for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { | |
| 615 | − //Luma (DC and AC decoding together) | |
| 616 | − WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - iScanIdxStart + 1, | |
| 617 | − g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC_INTRA, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), | |
| 618 | − pCurLayer->pLumaQp[iMbXy], | |
| 619 | − pCtx)); | |
| 620 | − iIdx++; | |
| 721 | + if (pCurLayer->pTransformSize8x8Flag[iMbXy]) { | |
| 722 | + // Transform 8x8 support for CABAC | |
| 723 | + for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { | |
| 724 | + if (uiCbpLuma & (1 << iId8x8)) { | |
| 725 | + WELS_READ_VERIFY (ParseResidualBlockCabac8x8 (&sNeighAvail, pNonZeroCount, pBsAux, (iId8x8 << 2), | |
| 726 | + iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart, LUMA_DC_AC_INTRA_8, | |
| 727 | + pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), pCurLayer->pLumaQp[iMbXy], pCtx)); | |
| 728 | + } else { | |
| 729 | + ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2)]], 0); | |
| 730 | + ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0); | |
| 621 | 731 | } |
| 622 | − } else { | |
| 623 | − ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2)]], 0); | |
| 624 | − ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0); | |
| 625 | 732 | } |
| 733 | + ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); | |
| 734 | + ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); | |
| 735 | + ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); | |
| 736 | + ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); | |
| 737 | + } else { | |
| 738 | + for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { | |
| 739 | + if (uiCbpLuma & (1 << iId8x8)) { | |
| 740 | + int32_t iIdx = (iId8x8 << 2); | |
| 741 | + for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { | |
| 742 | + //Luma (DC and AC decoding together) | |
| 743 | + WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - iScanIdxStart + 1, | |
| 744 | + g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC_INTRA, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), | |
| 745 | + pCurLayer->pLumaQp[iMbXy], pCtx)); | |
| 746 | + iIdx++; | |
| 747 | + } | |
| 748 | + } else { | |
| 749 | + ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2)]], 0); | |
| 750 | + ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0); | |
| 751 | + } | |
| 752 | + } | |
| 753 | + ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); | |
| 754 | + ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); | |
| 755 | + ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); | |
| 756 | + ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); | |
| 626 | 757 | } |
| 627 | − ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); | |
| 628 | − ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); | |
| 629 | − ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); | |
| 630 | − ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); | |
| 631 | 758 | } |
| 632 | 759 | int32_t iMbResProperty; |
| 633 | 760 | //chroma |
| @@ -730,10 +857,21 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 96 unmodified lines | ||
| 730 | 857 | if (0 == uiMbType) { //Intra4x4 |
| 731 | 858 | ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16); |
| 732 | 859 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4; |
| 733 | − pCtx->pFillInfoCacheIntra4x4Func (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); | |
| 734 | − WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurLayer)); | |
| 860 | + if (pCtx->pPps->bTransform8x8ModeFlag) { | |
| 861 | + WELS_READ_VERIFY (ParseTransformSize8x8FlagCabac (pCtx, pNeighAvail, pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy])); | |
| 862 | + } | |
| 863 | + if (pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { | |
| 864 | + uiMbType = pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA8x8; | |
| 865 | + pCtx->pFillInfoCacheIntraNxNFunc (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); | |
| 866 | + WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurLayer)); | |
| 867 | + } else { | |
| 868 | + pCtx->pFillInfoCacheIntraNxNFunc (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); | |
| 869 | + WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurLayer)); | |
| 870 | + } | |
| 735 | 871 | } else { //Intra16x16 |
| 736 | 872 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16; |
| 873 | + pCurLayer->pTransformSize8x8Flag[iMbXy] = false; | |
| 874 | + pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; | |
| 737 | 875 | pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; |
| 738 | 876 | pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; |
| 739 | 877 | uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0; |
| @@ -761,6 +899,23 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 21 unmodified lines | ||
| 761 | 899 | } |
| 762 | 900 | |
| 763 | 901 | if (pCurLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) { |
| 902 | + | |
| 903 | + if (MB_TYPE_INTRA16x16 != pCurLayer->pMbType[iMbXy]) { | |
| 904 | + // Need modification when B picutre add in | |
| 905 | + bool bNeedParseTransformSize8x8Flag = | |
| 906 | + (((pCurLayer->pMbType[iMbXy] >= MB_TYPE_16x16 && pCurLayer->pMbType[iMbXy] <= MB_TYPE_8x16) | |
| 907 | + || pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy]) | |
| 908 | + && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA8x8) | |
| 909 | + && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA4x4) | |
| 910 | + && ((pCurLayer->pCbp[iMbXy] & 0x0F) > 0) | |
| 911 | + && (pCtx->pPps->bTransform8x8ModeFlag)); | |
| 912 | + | |
| 913 | + if (bNeedParseTransformSize8x8Flag) { | |
| 914 | + WELS_READ_VERIFY (ParseTransformSize8x8FlagCabac (pCtx, pNeighAvail, | |
| 915 | + pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy])); //transform_size_8x8_flag | |
| 916 | + } | |
| 917 | + } | |
| 918 | + | |
| 764 | 919 | memset (pCurLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurLayer->pScaledTCoeff[iMbXy][0])); |
| 765 | 920 | |
| 766 | 921 | int32_t iQpDelta, iId8x8, iId4x4; |
| @@ -798,27 +953,46 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 31 unmodified lines | ||
| 798 | 953 | ST32 (&pCurLayer->pNzc[iMbXy][12], 0); |
| 799 | 954 | } |
| 800 | 955 | } else { //non-MB_TYPE_INTRA16x16 |
| 801 | − iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER; | |
| 802 | − for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { | |
| 803 | − if (uiCbpLuma & (1 << iId8x8)) { | |
| 804 | − int32_t iIdx = (iId8x8 << 2); | |
| 805 | − for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { | |
| 806 | − //Luma (DC and AC decoding together) | |
| 807 | − WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - iScanIdxStart + 1, | |
| 808 | − g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), | |
| 809 | − pCurLayer->pLumaQp[iMbXy], | |
| 810 | − pCtx)); | |
| 811 | − iIdx++; | |
| 956 | + if (pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { | |
| 957 | + // Transform 8x8 support for CABAC | |
| 958 | + for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { | |
| 959 | + if (uiCbpLuma & (1 << iId8x8)) { | |
| 960 | + WELS_READ_VERIFY (ParseResidualBlockCabac8x8 (pNeighAvail, pNonZeroCount, pBsAux, (iId8x8 << 2), | |
| 961 | + iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart, | |
| 962 | + IS_INTRA (pCurLayer->pMbType[iMbXy]) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8, | |
| 963 | + pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), pCurLayer->pLumaQp[iMbXy], pCtx)); | |
| 964 | + } else { | |
| 965 | + ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2)]], 0); | |
| 966 | + ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0); | |
| 967 | + } | |
| 968 | + } | |
| 969 | + ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); | |
| 970 | + ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); | |
| 971 | + ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); | |
| 972 | + ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); | |
| 973 | + } else { | |
| 974 | + iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER; | |
| 975 | + for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { | |
| 976 | + if (uiCbpLuma & (1 << iId8x8)) { | |
| 977 | + int32_t iIdx = (iId8x8 << 2); | |
| 978 | + for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { | |
| 979 | + //Luma (DC and AC decoding together) | |
| 980 | + WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - iScanIdxStart + 1, | |
| 981 | + g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), | |
| 982 | + pCurLayer->pLumaQp[iMbXy], | |
| 983 | + pCtx)); | |
| 984 | + iIdx++; | |
| 985 | + } | |
| 986 | + } else { | |
| 987 | + ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[iId8x8 << 2]], 0); | |
| 988 | + ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0); | |
| 812 | 989 | } |
| 813 | − } else { | |
| 814 | − ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[iId8x8 << 2]], 0); | |
| 815 | − ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0); | |
| 816 | 990 | } |
| 991 | + ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); | |
| 992 | + ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); | |
| 993 | + ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); | |
| 994 | + ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); | |
| 817 | 995 | } |
| 818 | − ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1])); | |
| 819 | − ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2])); | |
| 820 | − ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3])); | |
| 821 | − ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4])); | |
| 822 | 996 | } |
| 823 | 997 | |
| 824 | 998 | //chroma |
| @@ -886,8 +1060,12 @@ int32_t WelsDecodeMbCabacPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin · 61 unmodified lines | ||
| 886 | 1060 | pCurLayer->pCbfDc[iMbXy] = 0; |
| 887 | 1061 | pCurLayer->pChromaPredMode[iMbXy] = C_PRED_DC; |
| 888 | 1062 | |
| 1063 | + pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; | |
| 1064 | + pCurLayer->pTransformSize8x8Flag[iMbXy] = false; | |
| 1065 | + | |
| 889 | 1066 | GetNeighborAvailMbType (&uiNeighAvail, pCurLayer); |
| 890 | 1067 | WELS_READ_VERIFY (ParseSkipFlagCabac (pCtx, &uiNeighAvail, uiCode)); |
| 1068 | + | |
| 891 | 1069 | if (uiCode) { |
| 892 | 1070 | int16_t pMv[2] = {0}; |
| 893 | 1071 | pCurLayer->pMbType[iMbXy] = MB_TYPE_SKIP; |
| @@ -943,30 +1121,23 @@ int32_t WelsCalcDeqCoeffScalingList (PWelsDecoderContext pCtx) { · 49 unmodified lines | ||
| 943 | 1121 | //if (!pCtx->pSps->bSeqScalingListPresentFlag[i]) { |
| 944 | 1122 | if (!pCtx->pPps->bPicScalingListPresentFlag[i]) { |
| 945 | 1123 | if (i < 6) { |
| 946 | − | |
| 947 | − | |
| 948 | 1124 | if (i == 0 || i == 3) |
| 949 | 1125 | memcpy (pCtx->pPps->iScalingList4x4[i], pCtx->pSps->iScalingList4x4[i], 16 * sizeof (uint8_t)); |
| 950 | 1126 | else |
| 951 | 1127 | memcpy (pCtx->pPps->iScalingList4x4[i], pCtx->pPps->iScalingList4x4[i - 1], 16 * sizeof (uint8_t)); |
| 952 | 1128 | } else { |
| 953 | − | |
| 954 | 1129 | if (i == 6 || i == 7) |
| 955 | 1130 | memcpy (pCtx->pPps->iScalingList8x8[ i - 6 ], pCtx->pSps->iScalingList8x8[ i - 6 ], 64 * sizeof (uint8_t)); |
| 956 | 1131 | else |
| 957 | 1132 | memcpy (pCtx->pPps->iScalingList8x8[ i - 6 ], pCtx->pPps->iScalingList8x8[i - 8], 64 * sizeof (uint8_t)); |
| 958 | − | |
| 959 | − | |
| 960 | 1133 | } |
| 961 | − | |
| 962 | 1134 | } |
| 963 | 1135 | } |
| 964 | − | |
| 965 | − | |
| 966 | 1136 | } |
| 967 | 1137 | //Init dequant coeff value for different QP |
| 968 | 1138 | for (i = 0; i < 6; i++) { |
| 969 | 1139 | pCtx->pDequant_coeff4x4[i] = pCtx->pDequant_coeff_buffer4x4[i]; |
| 1140 | + pCtx->pDequant_coeff8x8[i] = pCtx->pDequant_coeff_buffer8x8[i]; | |
| 970 | 1141 | for (q = 0; q < 51; q++) { |
| 971 | 1142 | for (x = 0; x < 16; x++) { |
| 972 | 1143 | pCtx->pDequant_coeff4x4[i][q][x] = pCtx->pPps->bPicScalingMatrixPresentFlag ? pCtx->pPps->iScalingList4x4[i][x] * |
| @@ -974,13 +1145,10 @@ int32_t WelsCalcDeqCoeffScalingList (PWelsDecoderContext pCtx) { · 1 unmodified line | ||
| 974 | 1145 | } |
| 975 | 1146 | for (y = 0; y < 64; y++) { |
| 976 | 1147 | pCtx->pDequant_coeff8x8[i][q][y] = pCtx->pPps->bPicScalingMatrixPresentFlag ? pCtx->pPps->iScalingList8x8[i][y] * |
| 977 | − g_kuiDequantCoeff[q][x & 0x07] : pCtx->pSps->iScalingList8x8[i][y] * g_kuiDequantCoeff[q][x & | |
| 978 | − 0x07];//pseudo-code ,holding for 8x8transform into | |
| 1148 | + g_kuiMatrixV[q % 6][y / 8][y % 8] : pCtx->pSps->iScalingList8x8[i][y] * g_kuiMatrixV[q % 6][y / 8][y % 8]; | |
| 979 | 1149 | } |
| 980 | 1150 | } |
| 981 | 1151 | } |
| 982 | − | |
| 983 | − | |
| 984 | 1152 | pCtx->bDequantCoeff4x4Init = true; |
| 985 | 1153 | pCtx->iDequantCoeffPpsid = pCtx->pPps->iPpsId; |
| 986 | 1154 | } |
| @@ -1027,12 +1195,12 @@ int32_t WelsDecodeSlice (PWelsDecoderContext pCtx, bool bFirstSliceInLayer, PNal · 40 unmodified lines | ||
| 1027 | 1195 | } |
| 1028 | 1196 | |
| 1029 | 1197 | if (pSliceHeader->pPps->bConstainedIntraPredFlag) { |
| 1030 | − pCtx->pFillInfoCacheIntra4x4Func = WelsFillCacheConstrain1Intra4x4; | |
| 1031 | − pCtx->pMap4x4NeighToSampleFunc = WelsMap4x4NeighToSampleConstrain1; | |
| 1198 | + pCtx->pFillInfoCacheIntraNxNFunc = WelsFillCacheConstrain1IntraNxN; | |
| 1199 | + pCtx->pMapNxNNeighToSampleFunc = WelsMapNxNNeighToSampleConstrain1; | |
| 1032 | 1200 | pCtx->pMap16x16NeighToSampleFunc = WelsMap16x16NeighToSampleConstrain1; |
| 1033 | 1201 | } else { |
| 1034 | − pCtx->pFillInfoCacheIntra4x4Func = WelsFillCacheConstrain0Intra4x4; | |
| 1035 | − pCtx->pMap4x4NeighToSampleFunc = WelsMap4x4NeighToSampleNormal; | |
| 1202 | + pCtx->pFillInfoCacheIntraNxNFunc = WelsFillCacheConstrain0IntraNxN; | |
| 1203 | + pCtx->pMapNxNNeighToSampleFunc = WelsMapNxNNeighToSampleNormal; | |
| 1036 | 1204 | pCtx->pMap16x16NeighToSampleFunc = WelsMap16x16NeighToSampleNormal; |
| 1037 | 1205 | } |
| 1038 | 1206 | |
| @@ -1117,6 +1285,9 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 78 unmodified lines | ||
| 1117 | 1285 | pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0; |
| 1118 | 1286 | pCurLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag; |
| 1119 | 1287 | |
| 1288 | + pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; | |
| 1289 | + pCurLayer->pTransformSize8x8Flag[iMbXy] = false; | |
| 1290 | + | |
| 1120 | 1291 | WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //uiMbType |
| 1121 | 1292 | uiMbType = uiCode; |
| 1122 | 1293 | if (uiMbType > 25) |
| @@ -1178,8 +1349,20 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 55 unmodified lines | ||
| 1178 | 1349 | } else if (0 == uiMbType) { //reference to JM |
| 1179 | 1350 | ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16); |
| 1180 | 1351 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4; |
| 1181 | − pCtx->pFillInfoCacheIntra4x4Func (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); | |
| 1182 | − WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer)); | |
| 1352 | + if (pCtx->pPps->bTransform8x8ModeFlag) { | |
| 1353 | + WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //transform_size_8x8_flag | |
| 1354 | + pCurLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode; | |
| 1355 | + if (pCurLayer->pTransformSize8x8Flag[iMbXy]) { | |
| 1356 | + uiMbType = pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA8x8; | |
| 1357 | + } | |
| 1358 | + } | |
| 1359 | + if (!pCurLayer->pTransformSize8x8Flag[iMbXy]) { | |
| 1360 | + pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); | |
| 1361 | + WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer)); | |
| 1362 | + } else { | |
| 1363 | + pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); | |
| 1364 | + WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer)); | |
| 1365 | + } | |
| 1183 | 1366 | |
| 1184 | 1367 | //uiCbp |
| 1185 | 1368 | WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //coded_block_pattern |
| @@ -1199,6 +1382,8 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 13 unmodified lines | ||
| 1199 | 1382 | uiCbpL = uiCbp & 15; |
| 1200 | 1383 | } else { //I_PCM exclude, we can ignore it |
| 1201 | 1384 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16; |
| 1385 | + pCurLayer->pTransformSize8x8Flag[iMbXy] = false; | |
| 1386 | + pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; | |
| 1202 | 1387 | pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; |
| 1203 | 1388 | pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; |
| 1204 | 1389 | uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0; |
| @@ -1266,27 +1451,51 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 61 unmodified lines | ||
| 1266 | 1451 | ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4])); |
| 1267 | 1452 | } |
| 1268 | 1453 | } else { //non-MB_TYPE_INTRA16x16 |
| 1269 | − for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { | |
| 1270 | − if (uiCbpL & (1 << iId8x8)) { | |
| 1271 | − int32_t iIndex = (iId8x8 << 2); | |
| 1272 | − for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { | |
| 1273 | − //Luma (DC and AC decoding together) | |
| 1274 | − if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex, | |
| 1275 | − iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan + iScanIdxStart, | |
| 1276 | − LUMA_DC_AC_INTRA, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pLumaQp[iMbXy], pCtx)) { | |
| 1277 | − return -1;//abnormal | |
| 1454 | + if (pCurLayer->pTransformSize8x8Flag[iMbXy]) { | |
| 1455 | + for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { | |
| 1456 | + iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER; | |
| 1457 | + if (uiCbpL & (1 << iId8x8)) { | |
| 1458 | + int32_t iIndex = (iId8x8 << 2); | |
| 1459 | + for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { | |
| 1460 | + if (WelsResidualBlockCavlc8x8 (pVlcTable, pNonZeroCount, pBs, iIndex, | |
| 1461 | + iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty, | |
| 1462 | + pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4, pCurLayer->pLumaQp[iMbXy], pCtx)) { | |
| 1463 | + return -1; | |
| 1464 | + } | |
| 1465 | + iIndex++; | |
| 1278 | 1466 | } |
| 1279 | − iIndex++; | |
| 1467 | + } else { | |
| 1468 | + ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[iId8x8 << 2]], 0); | |
| 1469 | + ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2) + 2]], 0); | |
| 1280 | 1470 | } |
| 1281 | − } else { | |
| 1282 | − ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2)]], 0); | |
| 1283 | − ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2) + 2]], 0); | |
| 1284 | 1471 | } |
| 1472 | + ST32A4 (&pNzc[0], LD32 (&pNonZeroCount[1 + 8 * 1])); | |
| 1473 | + ST32A4 (&pNzc[4], LD32 (&pNonZeroCount[1 + 8 * 2])); | |
| 1474 | + ST32A4 (&pNzc[8], LD32 (&pNonZeroCount[1 + 8 * 3])); | |
| 1475 | + ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4])); | |
| 1476 | + } else { | |
| 1477 | + for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { | |
| 1478 | + if (uiCbpL & (1 << iId8x8)) { | |
| 1479 | + int32_t iIndex = (iId8x8 << 2); | |
| 1480 | + for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { | |
| 1481 | + //Luma (DC and AC decoding together) | |
| 1482 | + if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex, | |
| 1483 | + iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan + iScanIdxStart, | |
| 1484 | + LUMA_DC_AC_INTRA, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pLumaQp[iMbXy], pCtx)) { | |
| 1485 | + return -1;//abnormal | |
| 1486 | + } | |
| 1487 | + iIndex++; | |
| 1488 | + } | |
| 1489 | + } else { | |
| 1490 | + ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2)]], 0); | |
| 1491 | + ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2) + 2]], 0); | |
| 1492 | + } | |
| 1493 | + } | |
| 1494 | + ST32A4 (&pNzc[0], LD32 (&pNonZeroCount[1 + 8 * 1])); | |
| 1495 | + ST32A4 (&pNzc[4], LD32 (&pNonZeroCount[1 + 8 * 2])); | |
| 1496 | + ST32A4 (&pNzc[8], LD32 (&pNonZeroCount[1 + 8 * 3])); | |
| 1497 | + ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4])); | |
| 1285 | 1498 | } |
| 1286 | − ST32A4 (&pNzc[0], LD32 (&pNonZeroCount[1 + 8 * 1])); | |
| 1287 | − ST32A4 (&pNzc[4], LD32 (&pNonZeroCount[1 + 8 * 2])); | |
| 1288 | − ST32A4 (&pNzc[8], LD32 (&pNonZeroCount[1 + 8 * 3])); | |
| 1289 | − ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4])); | |
| 1290 | 1499 | } |
| 1291 | 1500 | |
| 1292 | 1501 | //chroma |
| @@ -1399,6 +1608,7 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 106 unmodified lines | ||
| 1399 | 1608 | int8_t iRefIndex[LIST_A][30]; |
| 1400 | 1609 | pCurLayer->pMbType[iMbXy] = g_ksInterMbTypeInfo[uiMbType].iType; |
| 1401 | 1610 | WelsFillCacheInter (&sNeighAvail, pNonZeroCount, iMotionVector, iRefIndex, pCurLayer); |
| 1611 | + | |
| 1402 | 1612 | if (ParseInterInfo (pCtx, iMotionVector, iRefIndex, pBs)) { |
| 1403 | 1613 | return -1;//abnormal |
| 1404 | 1614 | } |
| @@ -1484,12 +1694,24 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 79 unmodified lines | ||
| 1484 | 1694 | if (0 == uiMbType) { |
| 1485 | 1695 | ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16); |
| 1486 | 1696 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4; |
| 1487 | − pCtx->pFillInfoCacheIntra4x4Func (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); | |
| 1488 | − if (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer)) { | |
| 1489 | − return -1; | |
| 1697 | + if (pCtx->pPps->bTransform8x8ModeFlag) { | |
| 1698 | + WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //transform_size_8x8_flag | |
| 1699 | + pCurLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode; | |
| 1700 | + if (pCurLayer->pTransformSize8x8Flag[iMbXy]) { | |
| 1701 | + uiMbType = pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA8x8; | |
| 1702 | + } | |
| 1703 | + } | |
| 1704 | + if (!pCurLayer->pTransformSize8x8Flag[iMbXy]) { | |
| 1705 | + pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); | |
| 1706 | + WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer)); | |
| 1707 | + } else { | |
| 1708 | + pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); | |
| 1709 | + WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer)); | |
| 1490 | 1710 | } |
| 1491 | 1711 | } else { //I_PCM exclude, we can ignore it |
| 1492 | 1712 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16; |
| 1713 | + pCurLayer->pTransformSize8x8Flag[iMbXy] = false; | |
| 1714 | + pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; | |
| 1493 | 1715 | pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; |
| 1494 | 1716 | pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; |
| 1495 | 1717 | uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0; |
| @@ -1510,7 +1732,7 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 14 unmodified lines | ||
| 1510 | 1732 | return ERR_INFO_INVALID_CBP; |
| 1511 | 1733 | if (!pCtx->pSps->uiChromaFormatIdc && (uiCbp > 15)) |
| 1512 | 1734 | return ERR_INFO_INVALID_CBP; |
| 1513 | − if (MB_TYPE_INTRA4x4 == pCurLayer->pMbType[iMbXy]) { | |
| 1735 | + if (MB_TYPE_INTRA4x4 == pCurLayer->pMbType[iMbXy] || MB_TYPE_INTRA8x8 == pCurLayer->pMbType[iMbXy]) { | |
| 1514 | 1736 | |
| 1515 | 1737 | uiCbp = pCtx->pSps->uiChromaFormatIdc ? g_kuiIntra4x4CbpTable[uiCbp] : g_kuiIntra4x4CbpTable400[uiCbp]; |
| 1516 | 1738 | } else //inter |
| @@ -1520,6 +1742,20 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 3 unmodified lines | ||
| 1520 | 1742 | pCurLayer->pCbp[iMbXy] = uiCbp; |
| 1521 | 1743 | uiCbpC = pCurLayer->pCbp[iMbXy] >> 4; |
| 1522 | 1744 | uiCbpL = pCurLayer->pCbp[iMbXy] & 15; |
| 1745 | + | |
| 1746 | + // Need modification when B picutre add in | |
| 1747 | + bool bNeedParseTransformSize8x8Flag = | |
| 1748 | + (((pCurLayer->pMbType[iMbXy] >= MB_TYPE_16x16 && pCurLayer->pMbType[iMbXy] <= MB_TYPE_8x16) | |
| 1749 | + || pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy]) | |
| 1750 | + && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA8x8) | |
| 1751 | + && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA4x4) | |
| 1752 | + && (uiCbpL > 0) | |
| 1753 | + && (pCtx->pPps->bTransform8x8ModeFlag)); | |
| 1754 | + | |
| 1755 | + if (bNeedParseTransformSize8x8Flag) { | |
| 1756 | + WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //transform_size_8x8_flag | |
| 1757 | + pCurLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode; | |
| 1758 | + } | |
| 1523 | 1759 | } |
| 1524 | 1760 | |
| 1525 | 1761 | ST32A4 (&pNzc[0], 0); |
| @@ -1577,28 +1813,52 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 51 unmodified lines | ||
| 1577 | 1813 | ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4])); |
| 1578 | 1814 | } |
| 1579 | 1815 | } else { //non-MB_TYPE_INTRA16x16 |
| 1580 | − for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { | |
| 1581 | − iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER; | |
| 1582 | − if (uiCbpL & (1 << iId8x8)) { | |
| 1583 | − int32_t iIndex = (iId8x8 << 2); | |
| 1584 | − for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { | |
| 1585 | − //Luma (DC and AC decoding together) | |
| 1586 | − if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex, | |
| 1587 | − iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan + iScanIdxStart, iMbResProperty, | |
| 1588 | − pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pLumaQp[iMbXy], pCtx)) { | |
| 1589 | − return -1;//abnormal | |
| 1816 | + if (pCurLayer->pTransformSize8x8Flag[iMbXy]) { | |
| 1817 | + for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { | |
| 1818 | + iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER; | |
| 1819 | + if (uiCbpL & (1 << iId8x8)) { | |
| 1820 | + int32_t iIndex = (iId8x8 << 2); | |
| 1821 | + for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { | |
| 1822 | + if (WelsResidualBlockCavlc8x8 (pVlcTable, pNonZeroCount, pBs, iIndex, | |
| 1823 | + iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty, | |
| 1824 | + pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4, pCurLayer->pLumaQp[iMbXy], pCtx)) { | |
| 1825 | + return -1; | |
| 1826 | + } | |
| 1827 | + iIndex++; | |
| 1590 | 1828 | } |
| 1591 | − iIndex++; | |
| 1829 | + } else { | |
| 1830 | + ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[iId8x8 << 2]], 0); | |
| 1831 | + ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2) + 2]], 0); | |
| 1832 | + } | |
| 1833 | + } | |
| 1834 | + ST32A4 (&pNzc[0], LD32 (&pNonZeroCount[1 + 8 * 1])); | |
| 1835 | + ST32A4 (&pNzc[4], LD32 (&pNonZeroCount[1 + 8 * 2])); | |
| 1836 | + ST32A4 (&pNzc[8], LD32 (&pNonZeroCount[1 + 8 * 3])); | |
| 1837 | + ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4])); | |
| 1838 | + } else { // Normal T4x4 | |
| 1839 | + for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { | |
| 1840 | + iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER; | |
| 1841 | + if (uiCbpL & (1 << iId8x8)) { | |
| 1842 | + int32_t iIndex = (iId8x8 << 2); | |
| 1843 | + for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { | |
| 1844 | + //Luma (DC and AC decoding together) | |
| 1845 | + if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex, | |
| 1846 | + iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan + iScanIdxStart, iMbResProperty, | |
| 1847 | + pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pLumaQp[iMbXy], pCtx)) { | |
| 1848 | + return -1;//abnormal | |
| 1849 | + } | |
| 1850 | + iIndex++; | |
| 1851 | + } | |
| 1852 | + } else { | |
| 1853 | + ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[iId8x8 << 2]], 0); | |
| 1854 | + ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2) + 2]], 0); | |
| 1592 | 1855 | } |
| 1593 | − } else { | |
| 1594 | − ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[iId8x8 << 2]], 0); | |
| 1595 | − ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2) + 2]], 0); | |
| 1596 | 1856 | } |
| 1857 | + ST32A4 (&pNzc[0], LD32 (&pNonZeroCount[1 + 8 * 1])); | |
| 1858 | + ST32A4 (&pNzc[4], LD32 (&pNonZeroCount[1 + 8 * 2])); | |
| 1859 | + ST32A4 (&pNzc[8], LD32 (&pNonZeroCount[1 + 8 * 3])); | |
| 1860 | + ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4])); | |
| 1597 | 1861 | } |
| 1598 | − ST32A4 (&pNzc[0], LD32 (&pNonZeroCount[1 + 8 * 1])); | |
| 1599 | − ST32A4 (&pNzc[4], LD32 (&pNonZeroCount[1 + 8 * 2])); | |
| 1600 | − ST32A4 (&pNzc[8], LD32 (&pNonZeroCount[1 + 8 * 3])); | |
| 1601 | − ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4])); | |
| 1602 | 1862 | } |
| 1603 | 1863 | |
| 1604 | 1864 | |
| @@ -1661,6 +1921,9 @@ int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin · 56 unmodified lines | ||
| 1661 | 1921 | int32_t iRet = 0; //should have the return value to indicate decoding error or not, It's NECESSARY--2010.4.15 |
| 1662 | 1922 | uint32_t uiCode; |
| 1663 | 1923 | |
| 1924 | + pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; | |
| 1925 | + pCurLayer->pTransformSize8x8Flag[iMbXy] = false; | |
| 1926 | + | |
| 1664 | 1927 | if (-1 == pSlice->iMbSkipRun) { |
| 1665 | 1928 | WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //mb_skip_run |
| 1666 | 1929 | pSlice->iMbSkipRun = uiCode; |