History

Add Transform 8x8 support Add Intra 8x8 support Add no_deblocking support inside T8x8 Add CABAC parse support Add static data sheet for dequant Fix bugs and clean/astyle the code Remove build warnings Modify the UT cases Fix the ParseNalHeader bug

Haibo committed 11 years ago

Commit e9916c71 parent 473f2e325 files · +1808 −270Browse files

Showing the changes to codec/decoder/core/src/decode_slice.cpp (1 of 25 files). Show all

Unified · Split

codec/decoder/core/src/decode_slice.cpp+370−107
@@ -144,7 +144,6 @@ int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) { · 143 unmodified lines
144 return 0;//NO_SUPPORTED_FILTER_IDX144 return 0;//NO_SUPPORTED_FILTER_IDX
145 } else {145 } else {
146 WelsDeblockingFilterSlice (pCtx, pDeblockMb);146 WelsDeblockingFilterSlice (pCtx, pDeblockMb);
147
148 }147 }
149 // any other filter_idc not supported here, 7/22/2010148 // 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 WelsChromaDcIdct (pCurLayer->pScaledTCoeff[iMbXy] + 256); // 256 = 16*16158 WelsChromaDcIdct (pCurLayer->pScaledTCoeff[iMbXy] + 256); // 256 = 16*16
160 WelsChromaDcIdct (pCurLayer->pScaledTCoeff[iMbXy] + 320); // 320 = 16*16 + 16*4159 WelsChromaDcIdct (pCurLayer->pScaledTCoeff[iMbXy] + 320); // 320 = 16*16 + 16*4
161 160
162 for (i = 0; i < 16; i++) { //luma161 if (pCurLayer->pTransformSize8x8Flag[iMbXy]) {
163 iIndex = g_kuiMbCountScan4Idx[i];162 for (i = 0; i < 4; i++) {
164 if (pCurLayer->pNzc[iMbXy][iIndex]) {163 iIndex = g_kuiMbCountScan4Idx[i << 2];
165 iOffset = ((iIndex >> 2) << 2) * iStrideL + ((iIndex % 4) << 2);164 if (pCurLayer->pNzc[iMbXy][iIndex] || pCurLayer->pNzc[iMbXy][iIndex + 1] || pCurLayer->pNzc[iMbXy][iIndex + 4]
166 pCtx->pIdctResAddPredFunc (pDstY + iOffset, iStrideL, pCurLayer->pScaledTCoeff[iMbXy] + (i << 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 return 0;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 if (IS_INTRA4x4 (pCurLayer->pMbType[iMbXy]))275 if (IS_INTRA4x4 (pCurLayer->pMbType[iMbXy]))
262 RecI4x4Mb (iMbXy, pCtx, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer);276 RecI4x4Mb (iMbXy, pCtx, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer);
263 277
@@ -326,7 +340,7 @@ void WelsChromaDcIdct (int16_t* pBlock) { · 62 unmodified lines
326 pBlk[iStride1] = (iE - iB) >> 1;340 pBlk[iStride1] = (iE - iB) >> 1;
327}341}
328 342
329void WelsMap4x4NeighToSampleNormal (PWelsNeighAvail pNeighAvail, int32_t* pSampleAvail) {343void WelsMapNxNNeighToSampleNormal (PWelsNeighAvail pNeighAvail, int32_t* pSampleAvail) {
330 if (pNeighAvail->iLeftAvail) { //left344 if (pNeighAvail->iLeftAvail) { //left
331 pSampleAvail[ 6] =345 pSampleAvail[ 6] =
332 pSampleAvail[12] =346 pSampleAvail[12] =
@@ -347,7 +361,7 @@ void WelsMap4x4NeighToSampleNormal (PWelsNeighAvail pNeighAvail, int32_t* pSampl · 14 unmodified lines
347 }361 }
348}362}
349 363
350void WelsMap4x4NeighToSampleConstrain1 (PWelsNeighAvail pNeighAvail, int32_t* pSampleAvail) {364void WelsMapNxNNeighToSampleConstrain1 (PWelsNeighAvail pNeighAvail, int32_t* pSampleAvail) {
351 if (pNeighAvail->iLeftAvail && IS_INTRA (pNeighAvail->iLeftType)) { //left365 if (pNeighAvail->iLeftAvail && IS_INTRA (pNeighAvail->iLeftType)) { //left
352 pSampleAvail[ 6] =366 pSampleAvail[ 6] =
353 pSampleAvail[12] =367 pSampleAvail[12] =
@@ -401,7 +415,7 @@ int32_t ParseIntra4x4Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail · 47 unmodified lines
401 uint8_t uiNeighAvail = 0;415 uint8_t uiNeighAvail = 0;
402 uint32_t uiCode;416 uint32_t uiCode;
403 int32_t iCode;417 int32_t iCode;
404 pCtx->pMap4x4NeighToSampleFunc (pNeighAvail, iSampleAvail);418 pCtx->pMapNxNNeighToSampleFunc (pNeighAvail, iSampleAvail);
405 uiNeighAvail = (iSampleAvail[6] << 2) | (iSampleAvail[0] << 1) | (iSampleAvail[1]);419 uiNeighAvail = (iSampleAvail[6] << 2) | (iSampleAvail[0] << 1) | (iSampleAvail[1]);
406 for (i = 0; i < 16; i++) {420 for (i = 0; i < 16; i++) {
407 int32_t iPrevIntra4x4PredMode = 0;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 if (iFinalMode == ERR_INVALID_INTRA4X4_MODE) {447 if (iFinalMode == ERR_INVALID_INTRA4X4_MODE) {
434 return ERR_INFO_INVALID_I4x4_PRED_MODE;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 return ERR_NONE;483 return ERR_NONE;
470}484}
471 485
486int32_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
472int32_t ParseIntra16x16Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, PBitStringAux pBs,567int32_t ParseIntra16x16Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, PBitStringAux pBs,
473 PDqLayer pCurDqLayer) {568 PDqLayer pCurDqLayer) {
474 int32_t iMbXy = pCurDqLayer->iMbXyIndex;569 int32_t iMbXy = pCurDqLayer->iMbXyIndex;
@@ -519,6 +614,9 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 44 unmodified lines
519 614
520 ENFORCE_STACK_ALIGN_1D (uint8_t, pNonZeroCount, 48, 16);615 ENFORCE_STACK_ALIGN_1D (uint8_t, pNonZeroCount, 48, 16);
521 616
617 pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
618 pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
619
522 pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;620 pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;
523 pCurLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag;621 pCurLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag;
524 GetNeighborAvailMbType (&sNeighAvail, pCurLayer);622 GetNeighborAvailMbType (&sNeighAvail, pCurLayer);
@@ -539,8 +637,18 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 14 unmodified lines
539 } else if (0 == uiMbType) { //I4x4637 } else if (0 == uiMbType) { //I4x4
540 ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);638 ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
541 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4;639 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
542 pCtx->pFillInfoCacheIntra4x4Func (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);640 if (pCtx->pPps->bTransform8x8ModeFlag) {
543 WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBsAux, pCurLayer));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 //get uiCbp for I4x4652 //get uiCbp for I4x4
545 WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, &sNeighAvail, uiCbp));653 WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, &sNeighAvail, uiCbp));
546 pCurLayer->pCbp[iMbXy] = uiCbp;654 pCurLayer->pCbp[iMbXy] = uiCbp;
@@ -549,6 +657,8 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 2 unmodified lines
549 uiCbpLuma = uiCbp & 15;657 uiCbpLuma = uiCbp & 15;
550 } else { //I16x16;658 } else { //I16x16;
551 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;659 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
660 pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
661 pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
552 pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;662 pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
553 pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];663 pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
554 uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0 ;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 ST32 (&pCurLayer->pNzc[iMbXy][20], 0);675 ST32 (&pCurLayer->pNzc[iMbXy][20], 0);
566 pCurLayer->pCbfDc[iMbXy] = 0;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 pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;679 pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
570 for (i = 0; i < 2; i++) {680 for (i = 0; i < 2; i++) {
571 pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 ((pCurLayer->pLumaQp[iMbXy] +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 ST32 (&pCurLayer->pNzc[iMbXy][12], 0);718 ST32 (&pCurLayer->pNzc[iMbXy][12], 0);
609 }719 }
610 } else { //non-MB_TYPE_INTRA16x16720 } else { //non-MB_TYPE_INTRA16x16
611 for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {721 if (pCurLayer->pTransformSize8x8Flag[iMbXy]) {
612 if (uiCbpLuma & (1 << iId8x8)) {722 // Transform 8x8 support for CABAC
613 int32_t iIdx = (iId8x8 << 2);723 for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
614 for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {724 if (uiCbpLuma & (1 << iId8x8)) {
615 //Luma (DC and AC decoding together)725 WELS_READ_VERIFY (ParseResidualBlockCabac8x8 (&sNeighAvail, pNonZeroCount, pBsAux, (iId8x8 << 2),
616 WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - iScanIdxStart + 1,726 iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart, LUMA_DC_AC_INTRA_8,
617 g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC_INTRA, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4),727 pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), pCurLayer->pLumaQp[iMbXy], pCtx));
618 pCurLayer->pLumaQp[iMbXy],728 } else {
619 pCtx));729 ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2)]], 0);
620 iIdx++;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 int32_t iMbResProperty;759 int32_t iMbResProperty;
633 //chroma760 //chroma
@@ -730,10 +857,21 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 96 unmodified lines
730 if (0 == uiMbType) { //Intra4x4857 if (0 == uiMbType) { //Intra4x4
731 ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);858 ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
732 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4;859 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
733 pCtx->pFillInfoCacheIntra4x4Func (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);860 if (pCtx->pPps->bTransform8x8ModeFlag) {
734 WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurLayer));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 } else { //Intra16x16871 } else { //Intra16x16
736 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;872 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
873 pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
874 pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
737 pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;875 pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
738 pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];876 pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
739 uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;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 if (pCurLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) {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 memset (pCurLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurLayer->pScaledTCoeff[iMbXy][0]));919 memset (pCurLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurLayer->pScaledTCoeff[iMbXy][0]));
765 920
766 int32_t iQpDelta, iId8x8, iId4x4;921 int32_t iQpDelta, iId8x8, iId4x4;
@@ -798,27 +953,46 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 31 unmodified lines
798 ST32 (&pCurLayer->pNzc[iMbXy][12], 0);953 ST32 (&pCurLayer->pNzc[iMbXy][12], 0);
799 }954 }
800 } else { //non-MB_TYPE_INTRA16x16955 } else { //non-MB_TYPE_INTRA16x16
801 iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER;956 if (pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
802 for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {957 // Transform 8x8 support for CABAC
803 if (uiCbpLuma & (1 << iId8x8)) {958 for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
804 int32_t iIdx = (iId8x8 << 2);959 if (uiCbpLuma & (1 << iId8x8)) {
805 for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {960 WELS_READ_VERIFY (ParseResidualBlockCabac8x8 (pNeighAvail, pNonZeroCount, pBsAux, (iId8x8 << 2),
806 //Luma (DC and AC decoding together)961 iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart,
807 WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - iScanIdxStart + 1,962 IS_INTRA (pCurLayer->pMbType[iMbXy]) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8,
808 g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4),963 pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), pCurLayer->pLumaQp[iMbXy], pCtx));
809 pCurLayer->pLumaQp[iMbXy],964 } else {
810 pCtx));965 ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2)]], 0);
811 iIdx++;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 //chroma998 //chroma
@@ -886,8 +1060,12 @@ int32_t WelsDecodeMbCabacPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin · 61 unmodified lines
886 pCurLayer->pCbfDc[iMbXy] = 0;1060 pCurLayer->pCbfDc[iMbXy] = 0;
887 pCurLayer->pChromaPredMode[iMbXy] = C_PRED_DC;1061 pCurLayer->pChromaPredMode[iMbXy] = C_PRED_DC;
888 1062
1063 pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
1064 pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
1065
889 GetNeighborAvailMbType (&uiNeighAvail, pCurLayer);1066 GetNeighborAvailMbType (&uiNeighAvail, pCurLayer);
890 WELS_READ_VERIFY (ParseSkipFlagCabac (pCtx, &uiNeighAvail, uiCode));1067 WELS_READ_VERIFY (ParseSkipFlagCabac (pCtx, &uiNeighAvail, uiCode));
1068
891 if (uiCode) {1069 if (uiCode) {
892 int16_t pMv[2] = {0};1070 int16_t pMv[2] = {0};
893 pCurLayer->pMbType[iMbXy] = MB_TYPE_SKIP;1071 pCurLayer->pMbType[iMbXy] = MB_TYPE_SKIP;
@@ -943,30 +1121,23 @@ int32_t WelsCalcDeqCoeffScalingList (PWelsDecoderContext pCtx) { · 49 unmodified lines
943 //if (!pCtx->pSps->bSeqScalingListPresentFlag[i]) {1121 //if (!pCtx->pSps->bSeqScalingListPresentFlag[i]) {
944 if (!pCtx->pPps->bPicScalingListPresentFlag[i]) {1122 if (!pCtx->pPps->bPicScalingListPresentFlag[i]) {
945 if (i < 6) {1123 if (i < 6) {
946
947
948 if (i == 0 || i == 3)1124 if (i == 0 || i == 3)
949 memcpy (pCtx->pPps->iScalingList4x4[i], pCtx->pSps->iScalingList4x4[i], 16 * sizeof (uint8_t));1125 memcpy (pCtx->pPps->iScalingList4x4[i], pCtx->pSps->iScalingList4x4[i], 16 * sizeof (uint8_t));
950 else1126 else
951 memcpy (pCtx->pPps->iScalingList4x4[i], pCtx->pPps->iScalingList4x4[i - 1], 16 * sizeof (uint8_t));1127 memcpy (pCtx->pPps->iScalingList4x4[i], pCtx->pPps->iScalingList4x4[i - 1], 16 * sizeof (uint8_t));
952 } else {1128 } else {
953
954 if (i == 6 || i == 7)1129 if (i == 6 || i == 7)
955 memcpy (pCtx->pPps->iScalingList8x8[ i - 6 ], pCtx->pSps->iScalingList8x8[ i - 6 ], 64 * sizeof (uint8_t));1130 memcpy (pCtx->pPps->iScalingList8x8[ i - 6 ], pCtx->pSps->iScalingList8x8[ i - 6 ], 64 * sizeof (uint8_t));
956 else1131 else
957 memcpy (pCtx->pPps->iScalingList8x8[ i - 6 ], pCtx->pPps->iScalingList8x8[i - 8], 64 * sizeof (uint8_t));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 //Init dequant coeff value for different QP1137 //Init dequant coeff value for different QP
968 for (i = 0; i < 6; i++) {1138 for (i = 0; i < 6; i++) {
969 pCtx->pDequant_coeff4x4[i] = pCtx->pDequant_coeff_buffer4x4[i];1139 pCtx->pDequant_coeff4x4[i] = pCtx->pDequant_coeff_buffer4x4[i];
1140 pCtx->pDequant_coeff8x8[i] = pCtx->pDequant_coeff_buffer8x8[i];
970 for (q = 0; q < 51; q++) {1141 for (q = 0; q < 51; q++) {
971 for (x = 0; x < 16; x++) {1142 for (x = 0; x < 16; x++) {
972 pCtx->pDequant_coeff4x4[i][q][x] = pCtx->pPps->bPicScalingMatrixPresentFlag ? pCtx->pPps->iScalingList4x4[i][x] *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 for (y = 0; y < 64; y++) {1146 for (y = 0; y < 64; y++) {
976 pCtx->pDequant_coeff8x8[i][q][y] = pCtx->pPps->bPicScalingMatrixPresentFlag ? pCtx->pPps->iScalingList8x8[i][y] *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 &1148 g_kuiMatrixV[q % 6][y / 8][y % 8] : pCtx->pSps->iScalingList8x8[i][y] * g_kuiMatrixV[q % 6][y / 8][y % 8];
978 0x07];//pseudo-code ,holding for 8x8transform into
979 }1149 }
980 }1150 }
981 }1151 }
982
983
984 pCtx->bDequantCoeff4x4Init = true;1152 pCtx->bDequantCoeff4x4Init = true;
985 pCtx->iDequantCoeffPpsid = pCtx->pPps->iPpsId;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 if (pSliceHeader->pPps->bConstainedIntraPredFlag) {1197 if (pSliceHeader->pPps->bConstainedIntraPredFlag) {
1030 pCtx->pFillInfoCacheIntra4x4Func = WelsFillCacheConstrain1Intra4x4;1198 pCtx->pFillInfoCacheIntraNxNFunc = WelsFillCacheConstrain1IntraNxN;
1031 pCtx->pMap4x4NeighToSampleFunc = WelsMap4x4NeighToSampleConstrain1;1199 pCtx->pMapNxNNeighToSampleFunc = WelsMapNxNNeighToSampleConstrain1;
1032 pCtx->pMap16x16NeighToSampleFunc = WelsMap16x16NeighToSampleConstrain1;1200 pCtx->pMap16x16NeighToSampleFunc = WelsMap16x16NeighToSampleConstrain1;
1033 } else {1201 } else {
1034 pCtx->pFillInfoCacheIntra4x4Func = WelsFillCacheConstrain0Intra4x4;1202 pCtx->pFillInfoCacheIntraNxNFunc = WelsFillCacheConstrain0IntraNxN;
1035 pCtx->pMap4x4NeighToSampleFunc = WelsMap4x4NeighToSampleNormal;1203 pCtx->pMapNxNNeighToSampleFunc = WelsMapNxNNeighToSampleNormal;
1036 pCtx->pMap16x16NeighToSampleFunc = WelsMap16x16NeighToSampleNormal;1204 pCtx->pMap16x16NeighToSampleFunc = WelsMap16x16NeighToSampleNormal;
1037 }1205 }
1038 1206
@@ -1117,6 +1285,9 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 78 unmodified lines
1117 pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;1285 pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;
1118 pCurLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag;1286 pCurLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag;
1119 1287
1288 pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
1289 pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
1290
1120 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //uiMbType1291 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //uiMbType
1121 uiMbType = uiCode;1292 uiMbType = uiCode;
1122 if (uiMbType > 25)1293 if (uiMbType > 25)
@@ -1178,8 +1349,20 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 55 unmodified lines
1178 } else if (0 == uiMbType) { //reference to JM1349 } else if (0 == uiMbType) { //reference to JM
1179 ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);1350 ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
1180 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4;1351 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
1181 pCtx->pFillInfoCacheIntra4x4Func (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);1352 if (pCtx->pPps->bTransform8x8ModeFlag) {
1182 WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer));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 //uiCbp1367 //uiCbp
1185 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //coded_block_pattern1368 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //coded_block_pattern
@@ -1199,6 +1382,8 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 13 unmodified lines
1199 uiCbpL = uiCbp & 15;1382 uiCbpL = uiCbp & 15;
1200 } else { //I_PCM exclude, we can ignore it1383 } else { //I_PCM exclude, we can ignore it
1201 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;1384 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
1385 pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
1386 pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
1202 pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;1387 pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
1203 pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];1388 pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
1204 uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;1389 uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;
@@ -1266,27 +1451,51 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 61 unmodified lines
1266 ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4]));1451 ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4]));
1267 }1452 }
1268 } else { //non-MB_TYPE_INTRA16x161453 } else { //non-MB_TYPE_INTRA16x16
1269 for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {1454 if (pCurLayer->pTransformSize8x8Flag[iMbXy]) {
1270 if (uiCbpL & (1 << iId8x8)) {1455 for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
1271 int32_t iIndex = (iId8x8 << 2);1456 iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER;
1272 for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {1457 if (uiCbpL & (1 << iId8x8)) {
1273 //Luma (DC and AC decoding together)1458 int32_t iIndex = (iId8x8 << 2);
1274 if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex,1459 for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
1275 iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan + iScanIdxStart,1460 if (WelsResidualBlockCavlc8x8 (pVlcTable, pNonZeroCount, pBs, iIndex,
1276 LUMA_DC_AC_INTRA, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pLumaQp[iMbXy], pCtx)) {1461 iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty,
1277 return -1;//abnormal1462 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 //chroma1501 //chroma
@@ -1399,6 +1608,7 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 106 unmodified lines
1399 int8_t iRefIndex[LIST_A][30];1608 int8_t iRefIndex[LIST_A][30];
1400 pCurLayer->pMbType[iMbXy] = g_ksInterMbTypeInfo[uiMbType].iType;1609 pCurLayer->pMbType[iMbXy] = g_ksInterMbTypeInfo[uiMbType].iType;
1401 WelsFillCacheInter (&sNeighAvail, pNonZeroCount, iMotionVector, iRefIndex, pCurLayer);1610 WelsFillCacheInter (&sNeighAvail, pNonZeroCount, iMotionVector, iRefIndex, pCurLayer);
1611
1402 if (ParseInterInfo (pCtx, iMotionVector, iRefIndex, pBs)) {1612 if (ParseInterInfo (pCtx, iMotionVector, iRefIndex, pBs)) {
1403 return -1;//abnormal1613 return -1;//abnormal
1404 }1614 }
@@ -1484,12 +1694,24 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 79 unmodified lines
1484 if (0 == uiMbType) {1694 if (0 == uiMbType) {
1485 ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);1695 ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
1486 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4;1696 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
1487 pCtx->pFillInfoCacheIntra4x4Func (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);1697 if (pCtx->pPps->bTransform8x8ModeFlag) {
1488 if (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer)) {1698 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //transform_size_8x8_flag
1489 return -1;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 } else { //I_PCM exclude, we can ignore it1711 } else { //I_PCM exclude, we can ignore it
1492 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;1712 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
1713 pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
1714 pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
1493 pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;1715 pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
1494 pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];1716 pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
1495 uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;1717 uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;
@@ -1510,7 +1732,7 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 14 unmodified lines
1510 return ERR_INFO_INVALID_CBP;1732 return ERR_INFO_INVALID_CBP;
1511 if (!pCtx->pSps->uiChromaFormatIdc && (uiCbp > 15))1733 if (!pCtx->pSps->uiChromaFormatIdc && (uiCbp > 15))
1512 return ERR_INFO_INVALID_CBP;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 uiCbp = pCtx->pSps->uiChromaFormatIdc ? g_kuiIntra4x4CbpTable[uiCbp] : g_kuiIntra4x4CbpTable400[uiCbp];1737 uiCbp = pCtx->pSps->uiChromaFormatIdc ? g_kuiIntra4x4CbpTable[uiCbp] : g_kuiIntra4x4CbpTable400[uiCbp];
1516 } else //inter1738 } else //inter
@@ -1520,6 +1742,20 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 3 unmodified lines
1520 pCurLayer->pCbp[iMbXy] = uiCbp;1742 pCurLayer->pCbp[iMbXy] = uiCbp;
1521 uiCbpC = pCurLayer->pCbp[iMbXy] >> 4;1743 uiCbpC = pCurLayer->pCbp[iMbXy] >> 4;
1522 uiCbpL = pCurLayer->pCbp[iMbXy] & 15;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 ST32A4 (&pNzc[0], 0);1761 ST32A4 (&pNzc[0], 0);
@@ -1577,28 +1813,52 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 51 unmodified lines
1577 ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4]));1813 ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4]));
1578 }1814 }
1579 } else { //non-MB_TYPE_INTRA16x161815 } else { //non-MB_TYPE_INTRA16x16
1580 for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {1816 if (pCurLayer->pTransformSize8x8Flag[iMbXy]) {
1581 iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER;1817 for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
1582 if (uiCbpL & (1 << iId8x8)) {1818 iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER;
1583 int32_t iIndex = (iId8x8 << 2);1819 if (uiCbpL & (1 << iId8x8)) {
1584 for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {1820 int32_t iIndex = (iId8x8 << 2);
1585 //Luma (DC and AC decoding together)1821 for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
1586 if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex,1822 if (WelsResidualBlockCavlc8x8 (pVlcTable, pNonZeroCount, pBs, iIndex,
1587 iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan + iScanIdxStart, iMbResProperty,1823 iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty,
1588 pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pLumaQp[iMbXy], pCtx)) {1824 pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4, pCurLayer->pLumaQp[iMbXy], pCtx)) {
1589 return -1;//abnormal1825 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 int32_t iRet = 0; //should have the return value to indicate decoding error or not, It's NECESSARY--2010.4.151921 int32_t iRet = 0; //should have the return value to indicate decoding error or not, It's NECESSARY--2010.4.15
1662 uint32_t uiCode;1922 uint32_t uiCode;
1663 1923
1924 pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
1925 pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
1926
1664 if (-1 == pSlice->iMbSkipRun) {1927 if (-1 == pSlice->iMbSkipRun) {
1665 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //mb_skip_run1928 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //mb_skip_run
1666 pSlice->iMbSkipRun = uiCode;1929 pSlice->iMbSkipRun = uiCode;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t