missed some part fix clip value update according to wayne's suggestion
Showing the changes to codec/decoder (6 of 6 files). Show all
Unified · Split
| @@ -102,13 +102,16 @@ struct TagDqLayer { · 101 unmodified lines | ||
| 102 | 102 | int32_t iInterLayerSliceBetaOffset; |
| 103 | 103 | //SPosOffset sScaledRefLayer; |
| 104 | 104 | int32_t iSliceGroupChangeCycle; |
| 105 | + | |
| 105 | 106 | PRefPicListReorderSyn pRefPicListReordering; |
| 107 | + PPredWeightTabSyn pPredWeightTable; | |
| 106 | 108 | PRefPicMarking pRefPicMarking; // Decoded reference picture marking syntaxs |
| 107 | 109 | PRefBasePicMarking pRefPicBaseMarking; |
| 108 | 110 | |
| 109 | 111 | PPicture pRef; // reference picture pointer |
| 110 | 112 | PPicture pDec; // reconstruction picture pointer for layer |
| 111 | 113 | |
| 114 | + bool bUseWeightPredictionFlag; | |
| 112 | 115 | bool bStoreRefBasePicFlag; // iCurTid == 0 && iCurQid = 0 && bEncodeKeyPic = 1 |
| 113 | 116 | bool bTCoeffLevelPredFlag; |
| 114 | 117 | bool bConstrainedIntraResamplingFlag; |
| @@ -147,6 +147,13 @@ ERR_INFO_INVALID_I4x4_PRED_MODE, · 146 unmodified lines | ||
| 147 | 147 | ERR_INFO_INVALID_I16x16_PRED_MODE, |
| 148 | 148 | ERR_INFO_INVALID_I_CHROMA_PRED_MODE, |
| 149 | 149 | |
| 150 | +ERR_INFO_INVALID_LUMA_LOG2_WEIGHT_DENOM, | |
| 151 | +ERR_INFO_INVALID_CHROMA_LOG2_WEIGHT_DENOM, | |
| 152 | +ERR_INFO_INVALID_LUMA_WEIGHT, | |
| 153 | +ERR_INFO_INVALID_CHROMA_WEIGHT, | |
| 154 | +ERR_INFO_INVALID_LUMA_OFFSET, | |
| 155 | +ERR_INFO_INVALID_CHROMA_OFFSET, | |
| 156 | + | |
| 150 | 157 | ERR_INFO_UNSUPPORTED_NON_BASELINE, |
| 151 | 158 | ERR_INFO_UNSUPPORTED_FMOTYPE, |
| 152 | 159 | ERR_INFO_UNSUPPORTED_MBAFF, |
| @@ -68,7 +68,7 @@ struct { · 67 unmodified lines | ||
| 68 | 68 | bool bLumaWeightFlag; |
| 69 | 69 | bool bChromaWeightFlag; |
| 70 | 70 | } sPredList[LIST_A]; |
| 71 | −} SPredWeightTabSyn; | |
| 71 | +} SPredWeightTabSyn,*PPredWeightTabSyn; | |
| 72 | 72 | |
| 73 | 73 | /* Decoded reference picture marking syntax, refer to Page 66 in JVT X201wcm */ |
| 74 | 74 | typedef struct TagRefPicMarking { |
| @@ -1342,10 +1342,10 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux, · 1341 unmodified lines | ||
| 1342 | 1342 | pPps->bWeightedPredFlag = !!uiCode; |
| 1343 | 1343 | WELS_READ_VERIFY (BsGetBits (pBsAux, 2, &uiCode)); //weighted_bipred_idc |
| 1344 | 1344 | pPps->uiWeightedBipredIdc = uiCode; |
| 1345 | − if (pPps->bWeightedPredFlag || pPps->uiWeightedBipredIdc != 0) { | |
| 1345 | + if (pPps->uiWeightedBipredIdc != 0) { | |
| 1346 | 1346 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, |
| 1347 | − "ParsePps(): weighted_pred_flag (%d) weighted_bipred_idc (%d) neither supported.\n", | |
| 1348 | − pPps->bWeightedPredFlag, pPps->uiWeightedBipredIdc); | |
| 1347 | + "ParsePps(): weighted_bipred_idc (%d) not supported.\n", | |
| 1348 | + pPps->uiWeightedBipredIdc); | |
| 1349 | 1349 | return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_WP); |
| 1350 | 1350 | } |
| 1351 | 1351 | |
| @@ -179,6 +179,78 @@ inline int32_t WelsDecodeConstructSlice (PWelsDecoderContext pCtx, PNalUnit pCu · 178 unmodified lines | ||
| 179 | 179 | return iRet; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | +int32_t ParsePredWeightedTable (PBitStringAux pBs, PSliceHeader pSh) { | |
| 183 | + uint32_t uiCode; | |
| 184 | + int32_t iList = 0; | |
| 185 | + int32_t iCode; | |
| 186 | + | |
| 187 | + WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); | |
| 188 | + WELS_CHECK_SE_BOTH_ERROR_NOLOG (uiCode, 0, 7, "luma_log2_weight_denom", | |
| 189 | + GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_LUMA_LOG2_WEIGHT_DENOM)); | |
| 190 | + pSh->sPredWeightTable.uiLumaLog2WeightDenom = uiCode; | |
| 191 | + if (pSh->pSps->uiChromaArrayType != 0) { | |
| 192 | + WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); | |
| 193 | + WELS_CHECK_SE_BOTH_ERROR_NOLOG (uiCode, 0, 7, "chroma_log2_weight_denom", | |
| 194 | + GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_CHROMA_LOG2_WEIGHT_DENOM)); | |
| 195 | + pSh->sPredWeightTable.uiChromaLog2WeightDenom = uiCode; | |
| 196 | + } | |
| 197 | + | |
| 198 | + | |
| 199 | + do { | |
| 200 | + | |
| 201 | + for (int i = 0; i < pSh->uiRefCount[iList]; i++) { | |
| 202 | + //luma | |
| 203 | + WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); | |
| 204 | + if (!!uiCode) { | |
| 205 | + | |
| 206 | + WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); | |
| 207 | + WELS_CHECK_SE_BOTH_ERROR_NOLOG (iCode, -128, 127, "luma_weight", | |
| 208 | + GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_LUMA_WEIGHT)); | |
| 209 | + pSh->sPredWeightTable.sPredList[iList].iLumaWeight[i] = iCode; | |
| 210 | + | |
| 211 | + WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); | |
| 212 | + WELS_CHECK_SE_BOTH_ERROR_NOLOG (iCode, -128, 127, "luma_offset", | |
| 213 | + GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_LUMA_OFFSET)); | |
| 214 | + pSh->sPredWeightTable.sPredList[iList].iLumaOffset[i] = iCode; | |
| 215 | + } else { | |
| 216 | + pSh->sPredWeightTable.sPredList[iList].iLumaWeight[i] = 1 << (pSh->sPredWeightTable.uiLumaLog2WeightDenom); | |
| 217 | + pSh->sPredWeightTable.sPredList[iList].iLumaOffset[i] = 0; | |
| 218 | + | |
| 219 | + } | |
| 220 | + //chroma | |
| 221 | + if (pSh->pSps->uiChromaArrayType == 0) | |
| 222 | + continue; | |
| 223 | + | |
| 224 | + WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); | |
| 225 | + if (!!uiCode) { | |
| 226 | + for (int j = 0; j < 2; j++) { | |
| 227 | + | |
| 228 | + | |
| 229 | + WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); | |
| 230 | + WELS_CHECK_SE_BOTH_ERROR_NOLOG (iCode, -128, 127, "chroma_weight", | |
| 231 | + GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_CHROMA_WEIGHT)); | |
| 232 | + pSh->sPredWeightTable.sPredList[iList].iChromaWeight[i][j] = iCode; | |
| 233 | + | |
| 234 | + WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); | |
| 235 | + WELS_CHECK_SE_BOTH_ERROR_NOLOG (iCode, -128, 127, "chroma_offset", | |
| 236 | + GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_CHROMA_OFFSET)); | |
| 237 | + pSh->sPredWeightTable.sPredList[iList].iChromaOffset[i][j] = iCode; | |
| 238 | + } | |
| 239 | + } else { | |
| 240 | + for (int j = 0; j < 2; j++) { | |
| 241 | + | |
| 242 | + | |
| 243 | + pSh->sPredWeightTable.sPredList[iList].iChromaWeight[i][j] = 1 << (pSh->sPredWeightTable.uiChromaLog2WeightDenom); | |
| 244 | + pSh->sPredWeightTable.sPredList[iList].iChromaOffset[i][j] = 0; | |
| 245 | + } | |
| 246 | + } | |
| 247 | + | |
| 248 | + } | |
| 249 | + ++iList; | |
| 250 | + } while (iList < LIST_1);//TODO: SUPPORT LIST_A | |
| 251 | + return ERR_NONE; | |
| 252 | +} | |
| 253 | + | |
| 182 | 254 | /* |
| 183 | 255 | * Predeclared function routines .. |
| 184 | 256 | */ |
| @@ -701,6 +773,14 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 516 unmodified lines | ||
| 701 | 773 | return iRet; |
| 702 | 774 | } |
| 703 | 775 | |
| 776 | + if (pPps->bWeightedPredFlag && (uiSliceType == P_SLICE)) { | |
| 777 | + iRet = ParsePredWeightedTable (pBs, pSliceHead); | |
| 778 | + if (iRet != ERR_NONE) { | |
| 779 | + WelsLog (pLogCtx, WELS_LOG_WARNING, "invalid weighted prediction syntaxs!"); | |
| 780 | + return iRet; | |
| 781 | + } | |
| 782 | + } | |
| 783 | + | |
| 704 | 784 | if (kbExtensionFlag) { |
| 705 | 785 | if (pNalHeaderExt->iNoInterLayerPredFlag || pNalHeaderExt->uiQualityId > 0) |
| 706 | 786 | pSliceHeadExt->bBasePredWeightTableFlag = false; |
| @@ -1042,7 +1122,8 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid · 335 unmodified lines | ||
| 1042 | 1122 | "pCtx->sMb.pMbType[]"); |
| 1043 | 1123 | pCtx->sMb.pMv[i][0] = (int16_t (*)[16][2])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( |
| 1044 | 1124 | int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMv[][]"); |
| 1045 | − pCtx->sMb.pRefIndex[i][0] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( | |
| 1125 | + pCtx->sMb.pRefIndex[i][0] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * | |
| 1126 | + sizeof ( | |
| 1046 | 1127 | int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pRefIndex[][]"); |
| 1047 | 1128 | pCtx->sMb.pLumaQp[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), |
| 1048 | 1129 | "pCtx->sMb.pLumaQp[]"); |
| @@ -1058,7 +1139,8 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid · 9 unmodified lines | ||
| 1058 | 1139 | "pCtx->sMb.pNzcRs[]"); |
| 1059 | 1140 | pCtx->sMb.pScaledTCoeff[i] = (int16_t (*)[MB_COEFF_LIST_SIZE])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * |
| 1060 | 1141 | sizeof (int16_t) * MB_COEFF_LIST_SIZE, "pCtx->sMb.pScaledTCoeff[]"); |
| 1061 | − pCtx->sMb.pIntraPredMode[i] = (int8_t (*)[8])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 8, | |
| 1142 | + pCtx->sMb.pIntraPredMode[i] = (int8_t (*)[8])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( | |
| 1143 | + int8_t) * 8, | |
| 1062 | 1144 | "pCtx->sMb.pIntraPredMode[]"); |
| 1063 | 1145 | pCtx->sMb.pIntra4x4FinalMode[i] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * |
| 1064 | 1146 | sizeof (int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pIntra4x4FinalMode[]"); |
| @@ -1066,7 +1148,8 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid · 1 unmodified line | ||
| 1066 | 1148 | "pCtx->sMb.pChromaPredMode[]"); |
| 1067 | 1149 | pCtx->sMb.pCbp[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), |
| 1068 | 1150 | "pCtx->sMb.pCbp[]"); |
| 1069 | − pCtx->sMb.pSubMbType[i] = (int8_t (*)[MB_PARTITION_SIZE])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( | |
| 1151 | + pCtx->sMb.pSubMbType[i] = (int8_t (*)[MB_PARTITION_SIZE])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * | |
| 1152 | + sizeof ( | |
| 1070 | 1153 | int8_t) * MB_PARTITION_SIZE, "pCtx->sMb.pSubMbType[]"); |
| 1071 | 1154 | pCtx->sMb.pSliceIdc[i] = (int32_t*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t), |
| 1072 | 1155 | "pCtx->sMb.pSliceIdc[]"); // using int32_t for slice_idc, 4/21/2010 |
| @@ -1846,6 +1929,14 @@ static inline void InitDqLayerInfo (PDqLayer pDqLayer, PLayerInfo pLayerInfo, PN · 773 unmodified lines | ||
| 1846 | 1929 | if (kuiQualityId == BASE_QUALITY_ID) { |
| 1847 | 1930 | pDqLayer->pRefPicListReordering = &pSh->pRefPicListReordering; |
| 1848 | 1931 | pDqLayer->pRefPicMarking = &pSh->sRefMarking; |
| 1932 | + | |
| 1933 | + if (pSh->pPps->bWeightedPredFlag) { | |
| 1934 | + pDqLayer->bUseWeightPredictionFlag = true; | |
| 1935 | + pDqLayer->pPredWeightTable = &pSh->sPredWeightTable; | |
| 1936 | + | |
| 1937 | + } else | |
| 1938 | + pDqLayer->bUseWeightPredictionFlag = false; | |
| 1939 | + | |
| 1849 | 1940 | pDqLayer->pRefPicBaseMarking = &pShExt->sRefBasePicMarking; |
| 1850 | 1941 | } |
| 1851 | 1942 | |
| @@ -186,7 +186,7 @@ static inline void GetRefPic (sMCRefMember* pMCRefMem, PWelsDecoderContext pCtx, · 185 unmodified lines | ||
| 186 | 186 | #define MC_FLOW_SIMPLE_JUDGE 1 |
| 187 | 187 | #endif //MC_FLOW_SIMPLE_JUDGE |
| 188 | 188 | void BaseMC (sMCRefMember* pMCRefMem, int32_t iXOffset, int32_t iYOffset, SMcFunc* pMCFunc, |
| 189 | − int32_t iBlkWidth, int32_t iBlkHeight, int16_t iMVs[2]) { | |
| 189 | + int32_t iBlkWidth, int32_t iBlkHeight, int16_t iMVs[2]) { | |
| 190 | 190 | int32_t iFullMVx = (iXOffset << 2) + iMVs[0]; //quarter pixel |
| 191 | 191 | int32_t iFullMVy = (iYOffset << 2) + iMVs[1]; |
| 192 | 192 | iFullMVx = WELS_CLIP3 (iFullMVx, ((-PADDING_LENGTH + 2) << 2), ((pMCRefMem->iPicWidth + PADDING_LENGTH - 19) << 2)); |
| @@ -214,6 +214,74 @@ void BaseMC (sMCRefMember* pMCRefMem, int32_t iXOffset, int32_t iYOffset, SMcFun · 21 unmodified lines | ||
| 214 | 214 | |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | +void WeightPrediction (PDqLayer pCurDqLayer, sMCRefMember* pMCRefMem, int32_t iRefIdx, int32_t iBlkWidth, | |
| 218 | + int32_t iBlkHeight) { | |
| 219 | + | |
| 220 | + | |
| 221 | + int32_t iLog2denom, iWoc, iOoc; | |
| 222 | + int32_t iPredTemp, iLineStride; | |
| 223 | + int32_t iPixel = 0; | |
| 224 | + uint8_t* pDst; | |
| 225 | + //luma | |
| 226 | + iLog2denom = pCurDqLayer->pPredWeightTable->uiLumaLog2WeightDenom; | |
| 227 | + iWoc = pCurDqLayer->pPredWeightTable->sPredList[LIST_0].iLumaWeight[iRefIdx]; | |
| 228 | + iOoc = pCurDqLayer->pPredWeightTable->sPredList[LIST_0].iLumaOffset[iRefIdx]; | |
| 229 | + iLineStride = pMCRefMem->iDstLineLuma; | |
| 230 | + | |
| 231 | + for (int i = 0; i < iBlkHeight; i++) { | |
| 232 | + for (int j = 0; j < iBlkWidth; j++) { | |
| 233 | + iPixel = j + i * (iLineStride); | |
| 234 | + if (iLog2denom >= 1) { | |
| 235 | + iPredTemp = ((pMCRefMem->pDstY[iPixel] * iWoc + (1 << (iLog2denom - 1))) >> iLog2denom) + iOoc; | |
| 236 | + | |
| 237 | + pMCRefMem->pDstY[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255); | |
| 238 | + } else { | |
| 239 | + iPredTemp = pMCRefMem->pDstY[iPixel] * iWoc + iOoc; | |
| 240 | + | |
| 241 | + pMCRefMem->pDstY[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255); | |
| 242 | + | |
| 243 | + } | |
| 244 | + } | |
| 245 | + } | |
| 246 | + | |
| 247 | + | |
| 248 | + //UV | |
| 249 | + iBlkWidth = iBlkWidth >> 2; | |
| 250 | + iBlkHeight = iBlkHeight >> 2; | |
| 251 | + iLog2denom = pCurDqLayer->pPredWeightTable->uiChromaLog2WeightDenom; | |
| 252 | + iLineStride = pMCRefMem->iDstLineChroma; | |
| 253 | + | |
| 254 | + for (int i = 0; i < 2; i++) { | |
| 255 | + | |
| 256 | + | |
| 257 | + //iLog2denom = pCurDqLayer->pPredWeightTable->uiChromaLog2WeightDenom; | |
| 258 | + iWoc = pCurDqLayer->pPredWeightTable->sPredList[LIST_0].iChromaWeight[iRefIdx][i]; | |
| 259 | + iOoc = pCurDqLayer->pPredWeightTable->sPredList[LIST_0].iChromaOffset[iRefIdx][i]; | |
| 260 | + pDst = i ? pMCRefMem->pDstV : pMCRefMem->pDstU; | |
| 261 | + //iLineStride = pMCRefMem->iDstLineChroma; | |
| 262 | + | |
| 263 | + for (int i = 0; i < iBlkHeight ; i++) { | |
| 264 | + for (int j = 0; j < iBlkWidth; j++) { | |
| 265 | + iPixel = j + i * (iLineStride); | |
| 266 | + if (iLog2denom >= 1) { | |
| 267 | + iPredTemp = ((pDst[iPixel] * iWoc + (1 << (iLog2denom - 1))) >> iLog2denom) + iOoc; | |
| 268 | + | |
| 269 | + pDst[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255); | |
| 270 | + } else { | |
| 271 | + iPredTemp = pDst[iPixel] * iWoc + iOoc; | |
| 272 | + | |
| 273 | + pDst[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255); | |
| 274 | + | |
| 275 | + } | |
| 276 | + } | |
| 277 | + | |
| 278 | + } | |
| 279 | + | |
| 280 | + | |
| 281 | + } | |
| 282 | +} | |
| 283 | + | |
| 284 | + | |
| 217 | 285 | void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDecoderContext pCtx) { |
| 218 | 286 | sMCRefMember pMCRefMem; |
| 219 | 287 | PDqLayer pCurDqLayer = pCtx->pCurDqLayer; |
| @@ -242,6 +310,9 @@ void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDec · 22 unmodified lines | ||
| 242 | 310 | |
| 243 | 311 | pMCRefMem.iDstLineLuma = iDstLineLuma; |
| 244 | 312 | pMCRefMem.iDstLineChroma = iDstLineChroma; |
| 313 | + | |
| 314 | + int32_t iRefIndex = 0; | |
| 315 | + | |
| 245 | 316 | switch (iMBType) { |
| 246 | 317 | case MB_TYPE_SKIP: |
| 247 | 318 | case MB_TYPE_16x16: |
| @@ -249,6 +320,11 @@ void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDec · 1 unmodified line | ||
| 249 | 320 | iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1]; |
| 250 | 321 | GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0); |
| 251 | 322 | BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs); |
| 323 | + | |
| 324 | + if (pCurDqLayer->bUseWeightPredictionFlag) { | |
| 325 | + iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][0]; | |
| 326 | + WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 16, 16); | |
| 327 | + } | |
| 252 | 328 | break; |
| 253 | 329 | case MB_TYPE_16x8: |
| 254 | 330 | iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0]; |
| @@ -256,6 +332,11 @@ void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDec · 1 unmodified line | ||
| 256 | 332 | GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0); |
| 257 | 333 | BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 8, iMVs); |
| 258 | 334 | |
| 335 | + if (pCurDqLayer->bUseWeightPredictionFlag) { | |
| 336 | + iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][0]; | |
| 337 | + WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 16, 8); | |
| 338 | + } | |
| 339 | + | |
| 259 | 340 | iMVs[0] = pCurDqLayer->pMv[0][iMBXY][8][0]; |
| 260 | 341 | iMVs[1] = pCurDqLayer->pMv[0][iMBXY][8][1]; |
| 261 | 342 | GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 8); |
| @@ -263,12 +344,21 @@ void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDec · 1 unmodified line | ||
| 263 | 344 | pMCRefMem.pDstU = pPredCb + (iDstLineChroma << 2); |
| 264 | 345 | pMCRefMem.pDstV = pPredCr + (iDstLineChroma << 2); |
| 265 | 346 | BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY + 8, pMCFunc, 16, 8, iMVs); |
| 347 | + | |
| 348 | + if (pCurDqLayer->bUseWeightPredictionFlag) { | |
| 349 | + iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][8]; | |
| 350 | + WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 16, 8); | |
| 351 | + } | |
| 266 | 352 | break; |
| 267 | 353 | case MB_TYPE_8x16: |
| 268 | 354 | iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0]; |
| 269 | 355 | iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1]; |
| 270 | 356 | GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0); |
| 271 | 357 | BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 8, 16, iMVs); |
| 358 | + if (pCurDqLayer->bUseWeightPredictionFlag) { | |
| 359 | + iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][0]; | |
| 360 | + WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 8, 16); | |
| 361 | + } | |
| 272 | 362 | |
| 273 | 363 | iMVs[0] = pCurDqLayer->pMv[0][iMBXY][2][0]; |
| 274 | 364 | iMVs[1] = pCurDqLayer->pMv[0][iMBXY][2][1]; |
| @@ -277,6 +367,11 @@ void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDec · 2 unmodified lines | ||
| 277 | 367 | pMCRefMem.pDstU = pPredCb + 4; |
| 278 | 368 | pMCRefMem.pDstV = pPredCr + 4; |
| 279 | 369 | BaseMC (&pMCRefMem, iMBOffsetX + 8, iMBOffsetY, pMCFunc, 8, 16, iMVs); |
| 370 | + | |
| 371 | + if (pCurDqLayer->bUseWeightPredictionFlag) { | |
| 372 | + iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][2]; | |
| 373 | + WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 8, 16); | |
| 374 | + } | |
| 280 | 375 | break; |
| 281 | 376 | case MB_TYPE_8x8: |
| 282 | 377 | case MB_TYPE_8x8_REF0: { |
| @@ -292,6 +387,7 @@ void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDec · 9 unmodified lines | ||
| 292 | 387 | |
| 293 | 388 | iIIdx = ((i >> 1) << 3) + ((i & 1) << 1); |
| 294 | 389 | GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], iIIdx); |
| 390 | + iRefIndex = pCurDqLayer->bUseWeightPredictionFlag ? pCurDqLayer->pRefIndex[0][iMBXY][iIIdx] : 0; | |
| 295 | 391 | |
| 296 | 392 | pDstY = pPredY + iBlk8X + iBlk8Y * iDstLineLuma; |
| 297 | 393 | pDstU = pPredCb + (iBlk8X >> 1) + (iBlk8Y >> 1) * iDstLineChroma; |
| @@ -304,11 +400,21 @@ void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDec · 6 unmodified lines | ||
| 304 | 400 | iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0]; |
| 305 | 401 | iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1]; |
| 306 | 402 | BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs); |
| 403 | + if (pCurDqLayer->bUseWeightPredictionFlag) { | |
| 404 | + | |
| 405 | + WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 8, 8); | |
| 406 | + } | |
| 407 | + | |
| 307 | 408 | break; |
| 308 | 409 | case SUB_MB_TYPE_8x4: |
| 309 | 410 | iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0]; |
| 310 | 411 | iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1]; |
| 311 | 412 | BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs); |
| 413 | + if (pCurDqLayer->bUseWeightPredictionFlag) { | |
| 414 | + | |
| 415 | + WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 8, 4); | |
| 416 | + } | |
| 417 | + | |
| 312 | 418 | |
| 313 | 419 | iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 4][0]; |
| 314 | 420 | iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 4][1]; |
| @@ -316,11 +422,21 @@ void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDec · 1 unmodified line | ||
| 316 | 422 | pMCRefMem.pDstU += (iDstLineChroma << 1); |
| 317 | 423 | pMCRefMem.pDstV += (iDstLineChroma << 1); |
| 318 | 424 | BaseMC (&pMCRefMem, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs); |
| 425 | + if (pCurDqLayer->bUseWeightPredictionFlag) { | |
| 426 | + | |
| 427 | + WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 8, 4); | |
| 428 | + } | |
| 429 | + | |
| 319 | 430 | break; |
| 320 | 431 | case SUB_MB_TYPE_4x8: |
| 321 | 432 | iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0]; |
| 322 | 433 | iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1]; |
| 323 | 434 | BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs); |
| 435 | + if (pCurDqLayer->bUseWeightPredictionFlag) { | |
| 436 | + | |
| 437 | + WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 4, 8); | |
| 438 | + } | |
| 439 | + | |
| 324 | 440 | |
| 325 | 441 | iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 1][0]; |
| 326 | 442 | iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 1][1]; |
| @@ -328,6 +444,11 @@ void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDec · 1 unmodified line | ||
| 328 | 444 | pMCRefMem.pDstU += 2; |
| 329 | 445 | pMCRefMem.pDstV += 2; |
| 330 | 446 | BaseMC (&pMCRefMem, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs); |
| 447 | + if (pCurDqLayer->bUseWeightPredictionFlag) { | |
| 448 | + | |
| 449 | + WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 4, 8); | |
| 450 | + } | |
| 451 | + | |
| 331 | 452 | break; |
| 332 | 453 | case SUB_MB_TYPE_4x4: { |
| 333 | 454 | for (j = 0; j < 4; j++) { |
| @@ -345,6 +466,11 @@ void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDec · 11 unmodified lines | ||
| 345 | 466 | iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + iJIdx][0]; |
| 346 | 467 | iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + iJIdx][1]; |
| 347 | 468 | BaseMC (&pMCRefMem, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs); |
| 469 | + if (pCurDqLayer->bUseWeightPredictionFlag) { | |
| 470 | + | |
| 471 | + WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 4, 4); | |
| 472 | + } | |
| 473 | + | |
| 348 | 474 | } |
| 349 | 475 | } |
| 350 | 476 | break; |