History

to support monochroma

add mbtype judge logic

zhuiling committed 11 years ago

Commit 0a8a4f21 parent a00dd565 files · +65 −39Browse files

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

Unified · Split

codec/decoder/core/src/decode_slice.cpp+39−36
@@ -444,6 +444,10 @@ int32_t ParseIntra4x4Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail · 443 unmodified lines
444444 pCurDqLayer->pIntraPredMode[iMbXy][4] = pIntraPredMode[4 + 8 * 1];
445445 pCurDqLayer->pIntraPredMode[iMbXy][5] = pIntraPredMode[4 + 8 * 2];
446446 pCurDqLayer->pIntraPredMode[iMbXy][6] = pIntraPredMode[4 + 8 * 3];
447+
448+ if (pCtx->pSps->uiChromaFormatIdc == 0)//no need parse chroma
449+ return ERR_NONE;
450+
447451 if (pCurDqLayer->sLayerInfo.pPps->bEntropyCodingModeFlag) {
448452 WELS_READ_VERIFY (ParseIntraPredModeChromaCabac (pCtx, uiNeighAvail, iCode));
449453 if (iCode > MAX_PRED_MODE_ID_CHROMA) {
@@ -462,7 +466,6 @@ int32_t ParseIntra4x4Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail · 12 unmodified lines
462466 || CheckIntraChromaPredMode (uiNeighAvail, &pCurDqLayer->pChromaPredMode[iMbXy])) {
463467 return ERR_INFO_INVALID_I_CHROMA_PRED_MODE;
464468 }
465−
466469 return ERR_NONE;
467470 }
468471
@@ -478,6 +481,9 @@ int32_t ParseIntra16x16Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAva · 9 unmodified lines
478481 &pCurDqLayer->pIntraPredMode[iMbXy][7])) { //invalid iPredMode, must stop decoding
479482 return ERR_INFO_INVALID_I16x16_PRED_MODE;
480483 }
484+ if (pCtx->pSps->uiChromaFormatIdc == 0)
485+ return ERR_NONE;
486+
481487 if (pCurDqLayer->sLayerInfo.pPps->bEntropyCodingModeFlag) {
482488 WELS_READ_VERIFY (ParseIntraPredModeChromaCabac (pCtx, uiNeighAvail, iCode));
483489 if (iCode > MAX_PRED_MODE_ID_CHROMA) {
@@ -519,6 +525,9 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 35 unmodified lines
519525 WELS_READ_VERIFY (ParseMBTypeISliceCabac (pCtx, &sNeighAvail, uiMbType));
520526 if (uiMbType > 25) {
521527 return ERR_INFO_INVALID_MB_TYPE;
528+ } else if (!pCtx->pSps->uiChromaFormatIdc && ((uiMbType >= 5 && uiMbType <= 12) || (uiMbType >= 17
529+ && uiMbType <= 24))) {
530+ return ERR_INFO_INVALID_MB_TYPE;
522531 } else if (25 == uiMbType) { //I_PCM
523532 WELS_READ_VERIFY (ParseIPCMInfoCabac (pCtx));
524533 pSlice->iLastDeltaQp = 0;
@@ -536,19 +545,18 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 11 unmodified lines
536545 WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, &sNeighAvail, uiCbp));
537546 pCurLayer->pCbp[iMbXy] = uiCbp;
538547 pSlice->iLastDeltaQp = uiCbp == 0 ? 0 : pSlice->iLastDeltaQp;
539− uiCbpChroma = uiCbp >> 4;
548+ uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? uiCbp >> 4 : 0;
540549 uiCbpLuma = uiCbp & 15;
541550 } else { //I16x16;
542551 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
543552 pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
544553 pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
545− uiCbpChroma = pCurLayer->pCbp[iMbXy] >> 4;
554+ uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0 ;
546555 uiCbpLuma = pCurLayer->pCbp[iMbXy] & 15;
547556 WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurLayer);
548557 WELS_READ_VERIFY (ParseIntra16x16Mode (pCtx, &sNeighAvail, pBsAux, pCurLayer));
549558 }
550559
551−
552560 ST32 (&pCurLayer->pNzc[iMbXy][0], 0);
553561 ST32 (&pCurLayer->pNzc[iMbXy][4], 0);
554562 ST32 (&pCurLayer->pNzc[iMbXy][8], 0);
@@ -705,9 +713,10 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 150 unmodified lines
705713 pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;
706714 } else { //Intra mode
707715 uiMbType -= 5;
708− if (uiMbType > 25) {
716+ if (uiMbType > 25)
717+ return ERR_INFO_INVALID_MB_TYPE;
718+ if (!pCtx->pSps->uiChromaFormatIdc && ((uiMbType >= 5 && uiMbType <= 12) || (uiMbType >= 17 && uiMbType <= 24)))
709719 return ERR_INFO_INVALID_MB_TYPE;
710− }
711720
712721 if (25 == uiMbType) { //I_PCM
713722 WELS_READ_VERIFY (ParseIPCMInfoCabac (pCtx));
@@ -727,7 +736,7 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 13 unmodified lines
727736 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
728737 pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
729738 pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
730− uiCbpChroma = pCurLayer->pCbp[iMbXy] >> 4;
739+ uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;
731740 uiCbpLuma = pCurLayer->pCbp[iMbXy] & 15;
732741 WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurLayer);
733742 WELS_READ_VERIFY (ParseIntra16x16Mode (pCtx, pNeighAvail, pBsAux, pCurLayer));
@@ -735,21 +744,6 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 1 unmodified line
735744 }
736745 }
737746
738−
739−
740−
741−
742−
743−
744−
745−
746−
747−
748−
749−
750−
751−
752−
753747 ST32 (&pCurLayer->pNzc[iMbXy][0], 0);
754748 ST32 (&pCurLayer->pNzc[iMbXy][4], 0);
755749 ST32 (&pCurLayer->pNzc[iMbXy][8], 0);
@@ -759,9 +753,10 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 3 unmodified lines
759753
760754 if (MB_TYPE_INTRA16x16 != pCurLayer->pMbType[iMbXy]) {
761755 WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, pNeighAvail, uiCbp));
756+
762757 pCurLayer->pCbp[iMbXy] = uiCbp;
763758 pSlice->iLastDeltaQp = uiCbp == 0 ? 0 : pSlice->iLastDeltaQp;
764− uiCbpChroma = pCurLayer->pCbp[iMbXy] >> 4;
759+ uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0 ;
765760 uiCbpLuma = pCurLayer->pCbp[iMbXy] & 15;
766761 }
767762
@@ -1104,9 +1099,10 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 336 unmodified lines
11041099
11051100 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //uiMbType
11061101 uiMbType = uiCode;
1107− if (uiMbType > 25) {
1102+ if (uiMbType > 25)
1103+ return ERR_INFO_INVALID_MB_TYPE;
1104+ if (!pCtx->pSps->uiChromaFormatIdc && ((uiMbType >= 5 && uiMbType <= 12) || (uiMbType >= 17 && uiMbType <= 24)))
11081105 return ERR_INFO_INVALID_MB_TYPE;
1109− }
11101106
11111107 if (25 == uiMbType) {
11121108 int32_t iDecStrideL = pCurLayer->pDec->iLinesize[0];
@@ -1169,11 +1165,15 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 56 unmodified lines
11691165 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //coded_block_pattern
11701166 uiCbp = uiCode;
11711167 //G.9.1 Alternative parsing process for coded pBlock pattern
1172− if (uiCbp > 47)
1168+ if (pCtx->pSps->uiChromaFormatIdc && (uiCbp > 47))
1169+ return ERR_INFO_INVALID_CBP;
1170+ if (!pCtx->pSps->uiChromaFormatIdc && (uiCbp > 15))
11731171 return ERR_INFO_INVALID_CBP;
11741172
1175− uiCbp = g_kuiIntra4x4CbpTable[uiCbp];
1176−
1173+ if (pCtx->pSps->uiChromaFormatIdc)
1174+ uiCbp = g_kuiIntra4x4CbpTable[uiCbp];
1175+ else
1176+ uiCbp = g_kuiIntra4x4CbpTable400[uiCbp];
11771177 pCurLayer->pCbp[iMbXy] = uiCbp;
11781178 uiCbpC = uiCbp >> 4;
11791179 uiCbpL = uiCbp & 15;
@@ -1181,7 +1181,7 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 1 unmodified line
11811181 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
11821182 pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
11831183 pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
1184− uiCbpC = pCurLayer->pCbp[iMbXy] >> 4;
1184+ uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;
11851185 uiCbpL = pCurLayer->pCbp[iMbXy] & 15;
11861186 WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurLayer);
11871187 WELS_READ_VERIFY (ParseIntra16x16Mode (pCtx, &sNeighAvail, pBs, pCurLayer));
@@ -1398,9 +1398,10 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 210 unmodified lines
13981398 }
13991399 } else { //intra MB type
14001400 uiMbType -= 5;
1401− if (uiMbType > 25) {
1401+ if (uiMbType > 25)
1402+ return ERR_INFO_INVALID_MB_TYPE;
1403+ if (!pCtx->pSps->uiChromaFormatIdc && ((uiMbType >= 5 && uiMbType <= 12) || (uiMbType >= 17 && uiMbType <= 24)))
14021404 return ERR_INFO_INVALID_MB_TYPE;
1403− }
14041405
14051406 if (25 == uiMbType) {
14061407 int32_t iDecStrideL = pCurLayer->pDec->iLinesize[0];
@@ -1471,7 +1472,7 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 64 unmodified lines
14711472 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
14721473 pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
14731474 pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
1474− uiCbpC = pCurLayer->pCbp[iMbXy] >> 4;
1475+ uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;
14751476 uiCbpL = pCurLayer->pCbp[iMbXy] & 15;
14761477 WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurLayer);
14771478 if (ParseIntra16x16Mode (pCtx, &sNeighAvail, pBs, pCurLayer)) {
@@ -1485,13 +1486,15 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 7 unmodified lines
14851486 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //coded_block_pattern
14861487 uiCbp = uiCode;
14871488 {
1488− if (uiCbp > 47)
1489+ if (pCtx->pSps->uiChromaFormatIdc && (uiCbp > 47))
1490+ return ERR_INFO_INVALID_CBP;
1491+ if (!pCtx->pSps->uiChromaFormatIdc && (uiCbp > 15))
14891492 return ERR_INFO_INVALID_CBP;
1490−
14911493 if (MB_TYPE_INTRA4x4 == pCurLayer->pMbType[iMbXy]) {
1492− uiCbp = g_kuiIntra4x4CbpTable[uiCbp];
1494+
1495+ uiCbp = pCtx->pSps->uiChromaFormatIdc ? g_kuiIntra4x4CbpTable[uiCbp] : g_kuiIntra4x4CbpTable400[uiCbp];
14931496 } else //inter
1494− uiCbp = g_kuiInterCbpTable[uiCbp];
1497+ uiCbp = pCtx->pSps->uiChromaFormatIdc ? g_kuiInterCbpTable[uiCbp] : g_kuiInterCbpTable400[uiCbp];
14951498 }
14961499
14971500 pCurLayer->pCbp[iMbXy] = uiCbp;

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