Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 6322e81

Browse files
kelvinhu325tianjunwork
authored andcommitted
Fix mv out of bounds issue for high motion cases with umv0(#352)
Signed-off-by: Hu, Kelvin <[email protected]>
1 parent 705f36d commit 6322e81

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

Source/Lib/Codec/EbModeDecision.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -418,40 +418,42 @@ static void LimitMvOverBound(
418418
EB_S32 endY = lcuPtr->tileInfoPtr->tilePxlEndY << 2;
419419
EB_S32 cuSize = (EB_S32)ctxtPtr->cuStats->size << 2;
420420
EB_S32 pad = (4 << 2);
421-
EB_S32 deltaX = 0;
422-
EB_S32 deltaY = 0;
423-
EB_S32 deltaX16 = 0;
424-
EB_S32 deltaY16 = 0;
421+
EB_S32 mvxFL = mvxF;
422+
EB_S32 mvxFR = mvxF;
423+
EB_S32 mvyFT = mvyF;
424+
EB_S32 mvyFB = mvyF;
425425

426426
//if MV is quarter/half, the 7,8 tap interpolation will cross the boundary
427427
//calculate delta for luma/chroma MVs to be integer values
428428
// Horizontal
429429
if (((mvxF % 16) != 0) &&
430430
(cuOriginX + mvxF + cuSize > (endX - pad) || (cuOriginX + mvxF < (startX + pad)))) {
431-
deltaX = (mvxF % 16);
432-
deltaX16 = 16 - deltaX;
431+
//half/quarter interpolation, and cross the boundary, clamp to integer first
432+
mvxFL = ((mvxF >> 4) << 4);
433+
mvxFR = (((mvxF+15) >> 4) << 4);
433434
}
434435

435-
if (cuOriginX + mvxF + deltaX16 + cuSize >= endX) {
436+
if (cuOriginX + mvxFR + cuSize >= endX) {
436437
*mvx = endX - cuSize - cuOriginX;
437438
}
438439

439-
if (cuOriginX + mvxF - deltaX <= startX) {
440+
if (cuOriginX + mvxFL <= startX) {
440441
*mvx = startX - cuOriginX;
441442
}
442443

443444
// Vertical
444445
if (((mvyF % 16) != 0) &&
445446
(cuOriginY + mvyF + cuSize > (endY - pad) || (cuOriginY + mvyF < (startY + pad)))) {
446-
deltaY = (mvyF % 16);
447-
deltaY16 = 16 - deltaY;
447+
//half/quarter interpolation, and cross the boundary, clamp to integer first
448+
mvyFT = ((mvyF >> 4) << 4);
449+
mvyFB = (((mvyF+15) >> 4) << 4);
448450
}
449451

450-
if (cuOriginY + mvyF + deltaY16 + cuSize >= endY) {
452+
if (cuOriginY + mvyFB + cuSize >= endY) {
451453
*mvy = endY - cuSize - cuOriginY;
452454
}
453455

454-
if (cuOriginY + mvyF - deltaY <= startY) {
456+
if (cuOriginY + mvyFT <= startY) {
455457
*mvy = startY - cuOriginY;
456458
}
457459
}

0 commit comments

Comments
 (0)