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
144144 return 0;//NO_SUPPORTED_FILTER_IDX
145145 } else {
146146 WelsDeblockingFilterSlice (pCtx, pDeblockMb);
147−
148147 }
149148 // any other filter_idc not supported here, 7/22/2010
150149
@@ -159,11 +158,22 @@ int32_t WelsMbInterSampleConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLa · 8 unmodified lines
159158 WelsChromaDcIdct (pCurLayer->pScaledTCoeff[iMbXy] + 256); // 256 = 16*16
160159 WelsChromaDcIdct (pCurLayer->pScaledTCoeff[iMbXy] + 320); // 320 = 16*16 + 16*4
161160
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+ }
167177 }
168178 }
169179
@@ -258,6 +268,10 @@ int32_t WelsMbIntraPredictionConstruction (PWelsDecoderContext pCtx, PDqLayer pC · 88 unmodified lines
258268 return 0;
259269 }
260270
271+ if (IS_INTRA8x8 (pCurLayer->pMbType[iMbXy])) {
272+ RecI8x8Mb (iMbXy, pCtx, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer);
273+ }
274+
261275 if (IS_INTRA4x4 (pCurLayer->pMbType[iMbXy]))
262276 RecI4x4Mb (iMbXy, pCtx, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer);
263277
@@ -326,7 +340,7 @@ void WelsChromaDcIdct (int16_t* pBlock) { · 62 unmodified lines
326340 pBlk[iStride1] = (iE - iB) >> 1;
327341 }
328342
329−void WelsMap4x4NeighToSampleNormal (PWelsNeighAvail pNeighAvail, int32_t* pSampleAvail) {
343+void WelsMapNxNNeighToSampleNormal (PWelsNeighAvail pNeighAvail, int32_t* pSampleAvail) {
330344 if (pNeighAvail->iLeftAvail) { //left
331345 pSampleAvail[ 6] =
332346 pSampleAvail[12] =
@@ -347,7 +361,7 @@ void WelsMap4x4NeighToSampleNormal (PWelsNeighAvail pNeighAvail, int32_t* pSampl · 14 unmodified lines
347361 }
348362 }
349363
350−void WelsMap4x4NeighToSampleConstrain1 (PWelsNeighAvail pNeighAvail, int32_t* pSampleAvail) {
364+void WelsMapNxNNeighToSampleConstrain1 (PWelsNeighAvail pNeighAvail, int32_t* pSampleAvail) {
351365 if (pNeighAvail->iLeftAvail && IS_INTRA (pNeighAvail->iLeftType)) { //left
352366 pSampleAvail[ 6] =
353367 pSampleAvail[12] =
@@ -401,7 +415,7 @@ int32_t ParseIntra4x4Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail · 47 unmodified lines
401415 uint8_t uiNeighAvail = 0;
402416 uint32_t uiCode;
403417 int32_t iCode;
404− pCtx->pMap4x4NeighToSampleFunc (pNeighAvail, iSampleAvail);
418+ pCtx->pMapNxNNeighToSampleFunc (pNeighAvail, iSampleAvail);
405419 uiNeighAvail = (iSampleAvail[6] << 2) | (iSampleAvail[0] << 1) | (iSampleAvail[1]);
406420 for (i = 0; i < 16; i++) {
407421 int32_t iPrevIntra4x4PredMode = 0;
@@ -429,7 +443,7 @@ int32_t ParseIntra4x4Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail · 21 unmodified lines
429443 }
430444 }
431445
432− iFinalMode = CheckIntra4x4PredMode (&iSampleAvail[0], &iBestMode, i);
446+ iFinalMode = CheckIntraNxNPredMode (&iSampleAvail[0], &iBestMode, i, false);
433447 if (iFinalMode == ERR_INVALID_INTRA4X4_MODE) {
434448 return ERR_INFO_INVALID_I4x4_PRED_MODE;
435449 }
@@ -469,6 +483,87 @@ int32_t ParseIntra4x4Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail · 33 unmodified lines
469483 return ERR_NONE;
470484 }
471485
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+
472567 int32_t ParseIntra16x16Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, PBitStringAux pBs,
473568 PDqLayer pCurDqLayer) {
474569 int32_t iMbXy = pCurDqLayer->iMbXyIndex;
@@ -519,6 +614,9 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 44 unmodified lines
519614
520615 ENFORCE_STACK_ALIGN_1D (uint8_t, pNonZeroCount, 48, 16);
521616
617+ pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
618+ pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
619+
522620 pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;
523621 pCurLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag;
524622 GetNeighborAvailMbType (&sNeighAvail, pCurLayer);
@@ -539,8 +637,18 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 14 unmodified lines
539637 } else if (0 == uiMbType) { //I4x4
540638 ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
541639 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+ }
544652 //get uiCbp for I4x4
545653 WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, &sNeighAvail, uiCbp));
546654 pCurLayer->pCbp[iMbXy] = uiCbp;
@@ -549,6 +657,8 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 2 unmodified lines
549657 uiCbpLuma = uiCbp & 15;
550658 } else { //I16x16;
551659 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
660+ pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
661+ pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
552662 pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
553663 pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
554664 uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0 ;
@@ -565,7 +675,7 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 10 unmodified lines
565675 ST32 (&pCurLayer->pNzc[iMbXy][20], 0);
566676 pCurLayer->pCbfDc[iMbXy] = 0;
567677
568− if (pCurLayer->pCbp[iMbXy] == 0 && IS_INTRA4x4 (pCurLayer->pMbType[iMbXy])) {
678+ if (pCurLayer->pCbp[iMbXy] == 0 && IS_INTRANxN (pCurLayer->pMbType[iMbXy])) {
569679 pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
570680 for (i = 0; i < 2; i++) {
571681 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
608718 ST32 (&pCurLayer->pNzc[iMbXy][12], 0);
609719 }
610720 } 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);
621731 }
622− } else {
623− ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2)]], 0);
624− ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0);
625732 }
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]));
626757 }
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]));
631758 }
632759 int32_t iMbResProperty;
633760 //chroma
@@ -730,10 +857,21 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 96 unmodified lines
730857 if (0 == uiMbType) { //Intra4x4
731858 ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
732859 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+ }
735871 } else { //Intra16x16
736872 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
873+ pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
874+ pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
737875 pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
738876 pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
739877 uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;
@@ -761,6 +899,23 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 21 unmodified lines
761899 }
762900
763901 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+
764919 memset (pCurLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurLayer->pScaledTCoeff[iMbXy][0]));
765920
766921 int32_t iQpDelta, iId8x8, iId4x4;
@@ -798,27 +953,46 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 31 unmodified lines
798953 ST32 (&pCurLayer->pNzc[iMbXy][12], 0);
799954 }
800955 } 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);
812989 }
813− } else {
814− ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[iId8x8 << 2]], 0);
815− ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0);
816990 }
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]));
817995 }
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]));
822996 }
823997
824998 //chroma
@@ -886,8 +1060,12 @@ int32_t WelsDecodeMbCabacPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin · 61 unmodified lines
8861060 pCurLayer->pCbfDc[iMbXy] = 0;
8871061 pCurLayer->pChromaPredMode[iMbXy] = C_PRED_DC;
8881062
1063+ pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
1064+ pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
1065+
8891066 GetNeighborAvailMbType (&uiNeighAvail, pCurLayer);
8901067 WELS_READ_VERIFY (ParseSkipFlagCabac (pCtx, &uiNeighAvail, uiCode));
1068+
8911069 if (uiCode) {
8921070 int16_t pMv[2] = {0};
8931071 pCurLayer->pMbType[iMbXy] = MB_TYPE_SKIP;
@@ -943,30 +1121,23 @@ int32_t WelsCalcDeqCoeffScalingList (PWelsDecoderContext pCtx) { · 49 unmodified lines
9431121 //if (!pCtx->pSps->bSeqScalingListPresentFlag[i]) {
9441122 if (!pCtx->pPps->bPicScalingListPresentFlag[i]) {
9451123 if (i < 6) {
946−
947−
9481124 if (i == 0 || i == 3)
9491125 memcpy (pCtx->pPps->iScalingList4x4[i], pCtx->pSps->iScalingList4x4[i], 16 * sizeof (uint8_t));
9501126 else
9511127 memcpy (pCtx->pPps->iScalingList4x4[i], pCtx->pPps->iScalingList4x4[i - 1], 16 * sizeof (uint8_t));
9521128 } else {
953−
9541129 if (i == 6 || i == 7)
9551130 memcpy (pCtx->pPps->iScalingList8x8[ i - 6 ], pCtx->pSps->iScalingList8x8[ i - 6 ], 64 * sizeof (uint8_t));
9561131 else
9571132 memcpy (pCtx->pPps->iScalingList8x8[ i - 6 ], pCtx->pPps->iScalingList8x8[i - 8], 64 * sizeof (uint8_t));
958−
959−
9601133 }
961−
9621134 }
9631135 }
964−
965−
9661136 }
9671137 //Init dequant coeff value for different QP
9681138 for (i = 0; i < 6; i++) {
9691139 pCtx->pDequant_coeff4x4[i] = pCtx->pDequant_coeff_buffer4x4[i];
1140+ pCtx->pDequant_coeff8x8[i] = pCtx->pDequant_coeff_buffer8x8[i];
9701141 for (q = 0; q < 51; q++) {
9711142 for (x = 0; x < 16; x++) {
9721143 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
9741145 }
9751146 for (y = 0; y < 64; y++) {
9761147 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];
9791149 }
9801150 }
9811151 }
982−
983−
9841152 pCtx->bDequantCoeff4x4Init = true;
9851153 pCtx->iDequantCoeffPpsid = pCtx->pPps->iPpsId;
9861154 }
@@ -1027,12 +1195,12 @@ int32_t WelsDecodeSlice (PWelsDecoderContext pCtx, bool bFirstSliceInLayer, PNal · 40 unmodified lines
10271195 }
10281196
10291197 if (pSliceHeader->pPps->bConstainedIntraPredFlag) {
1030− pCtx->pFillInfoCacheIntra4x4Func = WelsFillCacheConstrain1Intra4x4;
1031− pCtx->pMap4x4NeighToSampleFunc = WelsMap4x4NeighToSampleConstrain1;
1198+ pCtx->pFillInfoCacheIntraNxNFunc = WelsFillCacheConstrain1IntraNxN;
1199+ pCtx->pMapNxNNeighToSampleFunc = WelsMapNxNNeighToSampleConstrain1;
10321200 pCtx->pMap16x16NeighToSampleFunc = WelsMap16x16NeighToSampleConstrain1;
10331201 } else {
1034− pCtx->pFillInfoCacheIntra4x4Func = WelsFillCacheConstrain0Intra4x4;
1035− pCtx->pMap4x4NeighToSampleFunc = WelsMap4x4NeighToSampleNormal;
1202+ pCtx->pFillInfoCacheIntraNxNFunc = WelsFillCacheConstrain0IntraNxN;
1203+ pCtx->pMapNxNNeighToSampleFunc = WelsMapNxNNeighToSampleNormal;
10361204 pCtx->pMap16x16NeighToSampleFunc = WelsMap16x16NeighToSampleNormal;
10371205 }
10381206
@@ -1117,6 +1285,9 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 78 unmodified lines
11171285 pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;
11181286 pCurLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag;
11191287
1288+ pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
1289+ pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
1290+
11201291 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //uiMbType
11211292 uiMbType = uiCode;
11221293 if (uiMbType > 25)
@@ -1178,8 +1349,20 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 55 unmodified lines
11781349 } else if (0 == uiMbType) { //reference to JM
11791350 ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
11801351 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+ }
11831366
11841367 //uiCbp
11851368 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //coded_block_pattern
@@ -1199,6 +1382,8 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 13 unmodified lines
11991382 uiCbpL = uiCbp & 15;
12001383 } else { //I_PCM exclude, we can ignore it
12011384 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
1385+ pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
1386+ pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
12021387 pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
12031388 pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
12041389 uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;
@@ -1266,27 +1451,51 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 61 unmodified lines
12661451 ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4]));
12671452 }
12681453 } 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++;
12781466 }
1279− iIndex++;
1467+ } else {
1468+ ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[iId8x8 << 2]], 0);
1469+ ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2) + 2]], 0);
12801470 }
1281− } else {
1282− ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2)]], 0);
1283− ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2) + 2]], 0);
12841471 }
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]));
12851498 }
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]));
12901499 }
12911500
12921501 //chroma
@@ -1399,6 +1608,7 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 106 unmodified lines
13991608 int8_t iRefIndex[LIST_A][30];
14001609 pCurLayer->pMbType[iMbXy] = g_ksInterMbTypeInfo[uiMbType].iType;
14011610 WelsFillCacheInter (&sNeighAvail, pNonZeroCount, iMotionVector, iRefIndex, pCurLayer);
1611+
14021612 if (ParseInterInfo (pCtx, iMotionVector, iRefIndex, pBs)) {
14031613 return -1;//abnormal
14041614 }
@@ -1484,12 +1694,24 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 79 unmodified lines
14841694 if (0 == uiMbType) {
14851695 ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
14861696 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));
14901710 }
14911711 } else { //I_PCM exclude, we can ignore it
14921712 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
1713+ pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
1714+ pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
14931715 pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
14941716 pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
14951717 uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;
@@ -1510,7 +1732,7 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 14 unmodified lines
15101732 return ERR_INFO_INVALID_CBP;
15111733 if (!pCtx->pSps->uiChromaFormatIdc && (uiCbp > 15))
15121734 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]) {
15141736
15151737 uiCbp = pCtx->pSps->uiChromaFormatIdc ? g_kuiIntra4x4CbpTable[uiCbp] : g_kuiIntra4x4CbpTable400[uiCbp];
15161738 } else //inter
@@ -1520,6 +1742,20 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 3 unmodified lines
15201742 pCurLayer->pCbp[iMbXy] = uiCbp;
15211743 uiCbpC = pCurLayer->pCbp[iMbXy] >> 4;
15221744 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+ }
15231759 }
15241760
15251761 ST32A4 (&pNzc[0], 0);
@@ -1577,28 +1813,52 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 51 unmodified lines
15771813 ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4]));
15781814 }
15791815 } 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++;
15901828 }
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);
15921855 }
1593− } else {
1594− ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[iId8x8 << 2]], 0);
1595− ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2) + 2]], 0);
15961856 }
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]));
15971861 }
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]));
16021862 }
16031863
16041864
@@ -1661,6 +1921,9 @@ int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin · 56 unmodified lines
16611921 int32_t iRet = 0; //should have the return value to indicate decoding error or not, It's NECESSARY--2010.4.15
16621922 uint32_t uiCode;
16631923
1924+ pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
1925+ pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
1926+
16641927 if (-1 == pSlice->iMbSkipRun) {
16651928 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //mb_skip_run
16661929 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