Showing the changes to codec/decoder/core/src/parse_mb_syn_cavlc.cpp (1 of 25 files). Show all
Unified · Split
| @@ -151,7 +151,7 @@ void WelsFillCacheNonZeroCount (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCo · 150 unmodified lines | ||
| 151 | 151 | pNonZeroCount[5 + 8 * 5] = -1;//unavailable |
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | −void WelsFillCacheConstrain1Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode, | |
| 154 | +void WelsFillCacheConstrain1IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode, | |
| 155 | 155 | PDqLayer pCurLayer) { //no matter slice type |
| 156 | 156 | int32_t iCurXy = pCurLayer->iMbXyIndex; |
| 157 | 157 | int32_t iTopXy = 0; |
| @@ -197,7 +197,7 @@ void WelsFillCacheConstrain1Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNon · 39 unmodified lines | ||
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | −void WelsFillCacheConstrain0Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode, | |
| 200 | +void WelsFillCacheConstrain0IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode, | |
| 201 | 201 | PDqLayer pCurLayer) { //no matter slice type |
| 202 | 202 | int32_t iCurXy = pCurLayer->iMbXyIndex; |
| 203 | 203 | int32_t iTopXy = 0; |
| @@ -214,7 +214,7 @@ void WelsFillCacheConstrain0Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNon · 10 unmodified lines | ||
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | //intra4x4_pred_mode |
| 217 | − if (pNeighAvail->iTopAvail && IS_INTRA4x4 (pNeighAvail->iTopType)) { //top | |
| 217 | + if (pNeighAvail->iTopAvail && IS_INTRANxN (pNeighAvail->iTopType)) { //top | |
| 218 | 218 | ST32 (pIntraPredMode + 1, LD32 (&pCurLayer->pIntraPredMode[iTopXy][0])); |
| 219 | 219 | } else { |
| 220 | 220 | int32_t iPred; |
| @@ -225,7 +225,7 @@ void WelsFillCacheConstrain0Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNon · 4 unmodified lines | ||
| 225 | 225 | ST32 (pIntraPredMode + 1, iPred); |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | − if (pNeighAvail->iLeftAvail && IS_INTRA4x4 (pNeighAvail->iLeftType)) { //left | |
| 228 | + if (pNeighAvail->iLeftAvail && IS_INTRANxN (pNeighAvail->iLeftType)) { //left | |
| 229 | 229 | pIntraPredMode[ 0 + 8 * 1] = pCurLayer->pIntraPredMode[iLeftXy][4]; |
| 230 | 230 | pIntraPredMode[ 0 + 8 * 2] = pCurLayer->pIntraPredMode[iLeftXy][5]; |
| 231 | 231 | pIntraPredMode[ 0 + 8 * 3] = pCurLayer->pIntraPredMode[iLeftXy][6]; |
| @@ -565,12 +565,13 @@ int32_t CheckIntraChromaPredMode (uint8_t uiSampleAvail, int8_t* pMode) { · 333 unmodified lines | ||
| 565 | 565 | return 0; |
| 566 | 566 | } |
| 567 | 567 | |
| 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) { | |
| 569 | 569 | int8_t iIdx = g_kuiCache30ScanIdx[iIndex]; |
| 570 | + | |
| 570 | 571 | int32_t iLeftAvail = pSampleAvail[iIdx - 1]; |
| 571 | 572 | int32_t iTopAvail = pSampleAvail[iIdx - 6]; |
| 572 | 573 | 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 | |
| 574 | 575 | |
| 575 | 576 | int8_t iFinalMode; |
| 576 | 577 | |
| @@ -900,6 +901,93 @@ int32_t WelsResidualBlockCavlc (SVlcTable* pVlcTable, uint8_t* pNonZeroCountCach · 323 unmodified lines | ||
| 900 | 901 | return 0; |
| 901 | 902 | } |
| 902 | 903 | |
| 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 | + | |
| 903 | 991 | int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], |
| 904 | 992 | PBitStringAux pBs) { |
| 905 | 993 | 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 | ||
| 941 | 1029 | return ERR_INFO_INVALID_REF_INDEX; |
| 942 | 1030 | } |
| 943 | 1031 | } |
| 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); | |
| 945 | 1034 | } else { |
| 946 | 1035 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "inter parse: iMotionPredFlag = 1 not supported. "); |
| 947 | 1036 | 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 | ||
| 981 | 1070 | return ERR_INFO_INVALID_REF_INDEX; |
| 982 | 1071 | } |
| 983 | 1072 | } |
| 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); | |
| 985 | 1075 | } |
| 986 | 1076 | for (i = 0; i < 2; i++) { |
| 987 | 1077 | 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 | ||
| 1017 | 1107 | return ERR_INFO_INVALID_REF_INDEX; |
| 1018 | 1108 | } |
| 1019 | 1109 | } |
| 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); | |
| 1021 | 1112 | } else { |
| 1022 | 1113 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "inter parse: iMotionPredFlag = 1 not supported. "); |
| 1023 | 1114 | 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 | ||
| 1056 | 1147 | pCurDqLayer->pSubMbType[iMbXy][i] = g_ksInterSubMbTypeInfo[uiSubMbType].iType; |
| 1057 | 1148 | iSubPartCount[i] = g_ksInterSubMbTypeInfo[uiSubMbType].iPartCount; |
| 1058 | 1149 | 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); | |
| 1059 | 1153 | } |
| 1060 | 1154 | |
| 1061 | 1155 | if (pSlice->sSliceHeaderExt.bAdaptiveMotionPredFlag) { |
| @@ -1085,7 +1179,8 @@ int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][M · 23 unmodified lines | ||
| 1085 | 1179 | return ERR_INFO_INVALID_REF_INDEX; |
| 1086 | 1180 | } |
| 1087 | 1181 | } |
| 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); | |
| 1089 | 1184 | |
| 1090 | 1185 | pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx ] = pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx + 1] = |
| 1091 | 1186 | pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx + 4] = pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx + 5] = iRefIdx[i]; |