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

Commit 11ade49

Browse files
kelvinhu325lijing0010
authored andcommitted
fix umv0 out of bounds issue (#349)
Signed-off-by: Hu, Kelvin <[email protected]>
1 parent 9c4e34b commit 11ade49

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

Source/Lib/Codec/EbModeDecision.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -418,37 +418,40 @@ 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;
421425

422-
//Jing: if MV is quarter/half, the 7,8 tap interpolation will cross the boundary
423-
//Just clamp the MV to integer
424-
426+
//if MV is quarter/half, the 7,8 tap interpolation will cross the boundary
427+
//calculate delta for luma/chroma MVs to be integer values
425428
// Horizontal
426-
if (((mvxF % 4) != 0) &&
429+
if (((mvxF % 16) != 0) &&
427430
(cuOriginX + mvxF + cuSize > (endX - pad) || (cuOriginX + mvxF < (startX + pad)))) {
428-
//half/quarter interpolation, and cross the boundary, clamp to integer first
429-
mvxF = ((mvxF >> 2) << 2);
431+
deltaX = (mvxF % 16);
432+
deltaX16 = 16 - deltaX;
430433
}
431434

432-
if (cuOriginX + mvxF + cuSize >= endX) {
435+
if (cuOriginX + mvxF + deltaX16 + cuSize >= endX) {
433436
*mvx = endX - cuSize - cuOriginX;
434437
}
435438

436-
if (cuOriginX + mvxF < startX) {
439+
if (cuOriginX + mvxF - deltaX <= startX) {
437440
*mvx = startX - cuOriginX;
438441
}
439442

440443
// Vertical
441-
if (((mvyF % 4) != 0) &&
444+
if (((mvyF % 16) != 0) &&
442445
(cuOriginY + mvyF + cuSize > (endY - pad) || (cuOriginY + mvyF < (startY + pad)))) {
443-
//half/quarter interpolation, and cross the boundary, clamp to integer first
444-
mvyF = ((mvyF >> 2) << 2);
446+
deltaY = (mvyF % 16);
447+
deltaY16 = 16 - deltaY;
445448
}
446449

447-
if (cuOriginY + mvyF + cuSize >= endY) {
450+
if (cuOriginY + mvyF + deltaY16 + cuSize >= endY) {
448451
*mvy = endY - cuSize - cuOriginY;
449452
}
450453

451-
if (cuOriginY + mvyF < startY) {
454+
if (cuOriginY + mvyF - deltaY <= startY) {
452455
*mvy = startY - cuOriginY;
453456
}
454457
}

0 commit comments

Comments
 (0)