History

Decoder WP suppor

missed some part fix clip value update according to wayne's suggestion

zhuiling committed 11 years ago

Commit 9ef0c741 parent 2da0ce66 files · +235 −8Browse files

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

Unified · Split

codec/decoder/core/src/rec_mb.cpp+127−1
@@ -186,7 +186,7 @@ static inline void GetRefPic (sMCRefMember* pMCRefMem, PWelsDecoderContext pCtx, · 185 unmodified lines
186#define MC_FLOW_SIMPLE_JUDGE 1186#define MC_FLOW_SIMPLE_JUDGE 1
187#endif //MC_FLOW_SIMPLE_JUDGE187#endif //MC_FLOW_SIMPLE_JUDGE
188void BaseMC (sMCRefMember* pMCRefMem, int32_t iXOffset, int32_t iYOffset, SMcFunc* pMCFunc,188void 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 int32_t iFullMVx = (iXOffset << 2) + iMVs[0]; //quarter pixel190 int32_t iFullMVx = (iXOffset << 2) + iMVs[0]; //quarter pixel
191 int32_t iFullMVy = (iYOffset << 2) + iMVs[1];191 int32_t iFullMVy = (iYOffset << 2) + iMVs[1];
192 iFullMVx = WELS_CLIP3 (iFullMVx, ((-PADDING_LENGTH + 2) << 2), ((pMCRefMem->iPicWidth + PADDING_LENGTH - 19) << 2));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
217void 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
217void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDecoderContext pCtx) {285void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDecoderContext pCtx) {
218 sMCRefMember pMCRefMem;286 sMCRefMember pMCRefMem;
219 PDqLayer pCurDqLayer = pCtx->pCurDqLayer;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 pMCRefMem.iDstLineLuma = iDstLineLuma;311 pMCRefMem.iDstLineLuma = iDstLineLuma;
244 pMCRefMem.iDstLineChroma = iDstLineChroma;312 pMCRefMem.iDstLineChroma = iDstLineChroma;
313
314 int32_t iRefIndex = 0;
315
245 switch (iMBType) {316 switch (iMBType) {
246 case MB_TYPE_SKIP:317 case MB_TYPE_SKIP:
247 case MB_TYPE_16x16: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 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1];320 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1];
250 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0);321 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0);
251 BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs);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 break;328 break;
253 case MB_TYPE_16x8:329 case MB_TYPE_16x8:
254 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0];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 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0);332 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0);
257 BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 8, iMVs);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 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][8][0];340 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][8][0];
260 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][8][1];341 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][8][1];
261 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 8);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 pMCRefMem.pDstU = pPredCb + (iDstLineChroma << 2);344 pMCRefMem.pDstU = pPredCb + (iDstLineChroma << 2);
264 pMCRefMem.pDstV = pPredCr + (iDstLineChroma << 2);345 pMCRefMem.pDstV = pPredCr + (iDstLineChroma << 2);
265 BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY + 8, pMCFunc, 16, 8, iMVs);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 break;352 break;
267 case MB_TYPE_8x16:353 case MB_TYPE_8x16:
268 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0];354 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0];
269 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1];355 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1];
270 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0);356 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0);
271 BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 8, 16, iMVs);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 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][2][0];363 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][2][0];
274 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][2][1];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 pMCRefMem.pDstU = pPredCb + 4;367 pMCRefMem.pDstU = pPredCb + 4;
278 pMCRefMem.pDstV = pPredCr + 4;368 pMCRefMem.pDstV = pPredCr + 4;
279 BaseMC (&pMCRefMem, iMBOffsetX + 8, iMBOffsetY, pMCFunc, 8, 16, iMVs);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 break;375 break;
281 case MB_TYPE_8x8:376 case MB_TYPE_8x8:
282 case MB_TYPE_8x8_REF0: {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 iIIdx = ((i >> 1) << 3) + ((i & 1) << 1);388 iIIdx = ((i >> 1) << 3) + ((i & 1) << 1);
294 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], iIIdx);389 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], iIIdx);
390 iRefIndex = pCurDqLayer->bUseWeightPredictionFlag ? pCurDqLayer->pRefIndex[0][iMBXY][iIIdx] : 0;
295 391
296 pDstY = pPredY + iBlk8X + iBlk8Y * iDstLineLuma;392 pDstY = pPredY + iBlk8X + iBlk8Y * iDstLineLuma;
297 pDstU = pPredCb + (iBlk8X >> 1) + (iBlk8Y >> 1) * iDstLineChroma;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 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];400 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];
305 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];401 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];
306 BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs);402 BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs);
403 if (pCurDqLayer->bUseWeightPredictionFlag) {
404
405 WeightPrediction (pCurDqLayer, &pMCRefMem, iRefIndex, 8, 8);
406 }
407
307 break;408 break;
308 case SUB_MB_TYPE_8x4:409 case SUB_MB_TYPE_8x4:
309 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];410 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];
310 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];411 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];
311 BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs);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 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 4][0];419 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 4][0];
314 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 4][1];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 pMCRefMem.pDstU += (iDstLineChroma << 1);422 pMCRefMem.pDstU += (iDstLineChroma << 1);
317 pMCRefMem.pDstV += (iDstLineChroma << 1);423 pMCRefMem.pDstV += (iDstLineChroma << 1);
318 BaseMC (&pMCRefMem, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs);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 break;430 break;
320 case SUB_MB_TYPE_4x8:431 case SUB_MB_TYPE_4x8:
321 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];432 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];
322 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];433 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];
323 BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs);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 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 1][0];441 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 1][0];
326 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 1][1];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 pMCRefMem.pDstU += 2;444 pMCRefMem.pDstU += 2;
329 pMCRefMem.pDstV += 2;445 pMCRefMem.pDstV += 2;
330 BaseMC (&pMCRefMem, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs);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 break;452 break;
332 case SUB_MB_TYPE_4x4: {453 case SUB_MB_TYPE_4x4: {
333 for (j = 0; j < 4; j++) {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 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + iJIdx][0];466 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + iJIdx][0];
346 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + iJIdx][1];467 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + iJIdx][1];
347 BaseMC (&pMCRefMem, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs);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 break;476 break;

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