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/parse_mb_syn_cavlc.cpp (1 of 25 files). Show all

Unified · Split

codec/decoder/core/src/parse_mb_syn_cavlc.cpp+105−10
@@ -151,7 +151,7 @@ void WelsFillCacheNonZeroCount (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCo · 150 unmodified lines
151151 pNonZeroCount[5 + 8 * 5] = -1;//unavailable
152152 }
153153 }
154−void WelsFillCacheConstrain1Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
154+void WelsFillCacheConstrain1IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
155155 PDqLayer pCurLayer) { //no matter slice type
156156 int32_t iCurXy = pCurLayer->iMbXyIndex;
157157 int32_t iTopXy = 0;
@@ -197,7 +197,7 @@ void WelsFillCacheConstrain1Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNon · 39 unmodified lines
197197 }
198198 }
199199
200−void WelsFillCacheConstrain0Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
200+void WelsFillCacheConstrain0IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
201201 PDqLayer pCurLayer) { //no matter slice type
202202 int32_t iCurXy = pCurLayer->iMbXyIndex;
203203 int32_t iTopXy = 0;
@@ -214,7 +214,7 @@ void WelsFillCacheConstrain0Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNon · 10 unmodified lines
214214 }
215215
216216 //intra4x4_pred_mode
217− if (pNeighAvail->iTopAvail && IS_INTRA4x4 (pNeighAvail->iTopType)) { //top
217+ if (pNeighAvail->iTopAvail && IS_INTRANxN (pNeighAvail->iTopType)) { //top
218218 ST32 (pIntraPredMode + 1, LD32 (&pCurLayer->pIntraPredMode[iTopXy][0]));
219219 } else {
220220 int32_t iPred;
@@ -225,7 +225,7 @@ void WelsFillCacheConstrain0Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNon · 4 unmodified lines
225225 ST32 (pIntraPredMode + 1, iPred);
226226 }
227227
228− if (pNeighAvail->iLeftAvail && IS_INTRA4x4 (pNeighAvail->iLeftType)) { //left
228+ if (pNeighAvail->iLeftAvail && IS_INTRANxN (pNeighAvail->iLeftType)) { //left
229229 pIntraPredMode[ 0 + 8 * 1] = pCurLayer->pIntraPredMode[iLeftXy][4];
230230 pIntraPredMode[ 0 + 8 * 2] = pCurLayer->pIntraPredMode[iLeftXy][5];
231231 pIntraPredMode[ 0 + 8 * 3] = pCurLayer->pIntraPredMode[iLeftXy][6];
@@ -565,12 +565,13 @@ int32_t CheckIntraChromaPredMode (uint8_t uiSampleAvail, int8_t* pMode) { · 333 unmodified lines
565565 return 0;
566566 }
567567
568−int32_t CheckIntra4x4PredMode (int32_t* pSampleAvail, int8_t* pMode, int32_t iIndex) {
568+int32_t CheckIntraNxNPredMode (int32_t* pSampleAvail, int8_t* pMode, int32_t iIndex, bool b8x8) {
569569 int8_t iIdx = g_kuiCache30ScanIdx[iIndex];
570+
570571 int32_t iLeftAvail = pSampleAvail[iIdx - 1];
571572 int32_t iTopAvail = pSampleAvail[iIdx - 6];
572573 int32_t bLeftTopAvail = pSampleAvail[iIdx - 7];
573− int32_t bRightTopAvail = pSampleAvail[iIdx - 5];
574+ int32_t bRightTopAvail = pSampleAvail[iIdx - (b8x8 ? 4 : 5)]; // Diff with 4x4 Pred
574575
575576 int8_t iFinalMode;
576577
@@ -900,6 +901,93 @@ int32_t WelsResidualBlockCavlc (SVlcTable* pVlcTable, uint8_t* pNonZeroCountCach · 323 unmodified lines
900901 return 0;
901902 }
902903
904+int32_t WelsResidualBlockCavlc8x8 (SVlcTable* pVlcTable, uint8_t* pNonZeroCountCache, PBitStringAux pBs, int32_t iIndex,
905+ int32_t iMaxNumCoeff, const uint8_t* kpZigzagTable, int32_t iResidualProperty,
906+ int16_t* pTCoeff, int32_t iIdx4x4, uint8_t uiQp,
907+ PWelsDecoderContext pCtx) {
908+ int32_t iLevel[16], iZerosLeft, iCoeffNum;
909+ int32_t iRun[16];
910+ int32_t iCurNonZeroCacheIdx, i;
911+
912+ int32_t iMbResProperty = 0;
913+ GetMbResProperty (&iMbResProperty, &iResidualProperty, 1);
914+
915+ const uint16_t* kpDequantCoeff = pCtx->bUseScalingList ? pCtx->pDequant_coeff8x8[iMbResProperty - 6][uiQp] :
916+ g_kuiDequantCoeff8x8[uiQp];
917+
918+ int8_t nA, nB, nC;
919+ uint8_t uiTotalCoeff, uiTrailingOnes;
920+ int32_t iUsedBits = 0;
921+ intX_t iCurIdx = pBs->iIndex;
922+ uint8_t* pBuf = ((uint8_t*)pBs->pStartBuf) + (iCurIdx >> 3);
923+ bool bChromaDc = (CHROMA_DC == iResidualProperty);
924+ uint8_t bChroma = (bChromaDc || CHROMA_AC == iResidualProperty);
925+ SReadBitsCache sReadBitsCache;
926+
927+ uint32_t uiCache32Bit = (uint32_t) ((((pBuf[0] << 8) | pBuf[1]) << 16) | (pBuf[2] << 8) | pBuf[3]);
928+ sReadBitsCache.uiCache32Bit = uiCache32Bit << (iCurIdx & 0x07);
929+ sReadBitsCache.uiRemainBits = 32 - (iCurIdx & 0x07);
930+ sReadBitsCache.pBuf = pBuf;
931+ //////////////////////////////////////////////////////////////////////////
932+
933+ if (bChroma) {
934+ iCurNonZeroCacheIdx = g_kuiCache48CountScan4Idx[iIndex];
935+ nA = pNonZeroCountCache[iCurNonZeroCacheIdx - 1];
936+ nB = pNonZeroCountCache[iCurNonZeroCacheIdx - 8];
937+ } else { //luma
938+ iCurNonZeroCacheIdx = g_kuiCache48CountScan4Idx[iIndex];
939+ nA = pNonZeroCountCache[iCurNonZeroCacheIdx - 1];
940+ nB = pNonZeroCountCache[iCurNonZeroCacheIdx - 8];
941+ }
942+
943+ WELS_NON_ZERO_COUNT_AVERAGE (nC, nA, nB);
944+
945+ iUsedBits += CavlcGetTrailingOnesAndTotalCoeff (uiTotalCoeff, uiTrailingOnes, &sReadBitsCache, pVlcTable, bChromaDc,
946+ nC);
947+
948+ if (iResidualProperty != CHROMA_DC && iResidualProperty != I16_LUMA_DC) {
949+ pNonZeroCountCache[iCurNonZeroCacheIdx] = uiTotalCoeff;
950+ //////////////////////////////////////////////////////////////////////////
951+ }
952+ if (0 == uiTotalCoeff) {
953+ pBs->iIndex += iUsedBits;
954+ return 0;
955+ }
956+ if ((uiTrailingOnes > 3) || (uiTotalCoeff > 16)) { /////////////////check uiTrailingOnes and uiTotalCoeff
957+ return ERR_INFO_CAVLC_INVALID_TOTAL_COEFF_OR_TRAILING_ONES;
958+ }
959+ if ((i = CavlcGetLevelVal (iLevel, &sReadBitsCache, uiTotalCoeff, uiTrailingOnes)) == -1) {
960+ return ERR_INFO_CAVLC_INVALID_LEVEL;
961+ }
962+ iUsedBits += i;
963+ if (uiTotalCoeff < iMaxNumCoeff) {
964+ iUsedBits += CavlcGetTotalZeros (iZerosLeft, &sReadBitsCache, uiTotalCoeff, pVlcTable, bChromaDc);
965+ } else {
966+ iZerosLeft = 0;
967+ }
968+
969+ if ((iZerosLeft < 0) || ((iZerosLeft + uiTotalCoeff) > iMaxNumCoeff)) {
970+ return ERR_INFO_CAVLC_INVALID_ZERO_LEFT;
971+ }
972+ if ((i = CavlcGetRunBefore (iRun, &sReadBitsCache, uiTotalCoeff, pVlcTable, iZerosLeft)) == -1) {
973+ return ERR_INFO_CAVLC_INVALID_RUN_BEFORE;
974+ }
975+ iUsedBits += i;
976+ pBs->iIndex += iUsedBits;
977+ iCoeffNum = -1;
978+
979+ for (i = uiTotalCoeff - 1; i >= 0; --i) { //FIXME merge into rundecode?
980+ int32_t j;
981+ iCoeffNum += iRun[i] + 1; //FIXME add 1 earlier ?
982+ j = (iCoeffNum << 2) + iIdx4x4;
983+ j = kpZigzagTable[ j ];
984+ pTCoeff[j] = uiQp >= 36 ? ((iLevel[i] * kpDequantCoeff[j]) << (uiQp / 6 - 6))
985+ : ((iLevel[i] * kpDequantCoeff[j] + (1 << (5 - uiQp / 6))) >> (6 - uiQp / 6));
986+ }
987+
988+ return 0;
989+}
990+
903991 int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30],
904992 PBitStringAux pBs) {
905993 PSlice pSlice = &pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer;
@@ -941,7 +1029,8 @@ int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][M · 35 unmodified lines
9411029 return ERR_INFO_INVALID_REF_INDEX;
9421030 }
9431031 }
944− pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || !(ppRefPic[iRefIdx]&&ppRefPic[iRefIdx]->bIsComplete);
1032+ pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[iRefIdx]
1033+ && ppRefPic[iRefIdx]->bIsComplete);
9451034 } else {
9461035 WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "inter parse: iMotionPredFlag = 1 not supported. ");
9471036 return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_UNSUPPORTED_ILP);
@@ -981,7 +1070,8 @@ int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][M · 33 unmodified lines
9811070 return ERR_INFO_INVALID_REF_INDEX;
9821071 }
9831072 }
984− pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || !(ppRefPic[iRefIdx[i]]&&ppRefPic[iRefIdx[i]]->bIsComplete);
1073+ pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[iRefIdx[i]]
1074+ && ppRefPic[iRefIdx[i]]->bIsComplete);
9851075 }
9861076 for (i = 0; i < 2; i++) {
9871077 PredInter16x8Mv (iMvArray, iRefIdxArray, i << 3, iRefIdx[i], iMv);
@@ -1017,7 +1107,8 @@ int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][M · 29 unmodified lines
10171107 return ERR_INFO_INVALID_REF_INDEX;
10181108 }
10191109 }
1020− pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || !(ppRefPic[iRefIdx[i]]&&ppRefPic[iRefIdx[i]]->bIsComplete);
1110+ pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[iRefIdx[i]]
1111+ && ppRefPic[iRefIdx[i]]->bIsComplete);
10211112 } else {
10221113 WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "inter parse: iMotionPredFlag = 1 not supported. ");
10231114 return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_UNSUPPORTED_ILP);
@@ -1056,6 +1147,9 @@ int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][M · 32 unmodified lines
10561147 pCurDqLayer->pSubMbType[iMbXy][i] = g_ksInterSubMbTypeInfo[uiSubMbType].iType;
10571148 iSubPartCount[i] = g_ksInterSubMbTypeInfo[uiSubMbType].iPartCount;
10581149 iPartWidth[i] = g_ksInterSubMbTypeInfo[uiSubMbType].iPartWidth;
1150+
1151+ // Need modification when B picture add in, reference to 7.3.5
1152+ pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] &= (uiSubMbType == 0);
10591153 }
10601154
10611155 if (pSlice->sSliceHeaderExt.bAdaptiveMotionPredFlag) {
@@ -1085,7 +1179,8 @@ int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][M · 23 unmodified lines
10851179 return ERR_INFO_INVALID_REF_INDEX;
10861180 }
10871181 }
1088− pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || !(ppRefPic[iRefIdx[i]]&&ppRefPic[iRefIdx[i]]->bIsComplete);
1182+ pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[iRefIdx[i]]
1183+ && ppRefPic[iRefIdx[i]]->bIsComplete);
10891184
10901185 pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx ] = pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx + 1] =
10911186 pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx + 4] = pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx + 5] = iRefIdx[i];

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