diff --git a/sub/draw_bmp.c b/sub/draw_bmp.c index 2e19c6c3b8..58db162a56 100644 --- a/sub/draw_bmp.c +++ b/sub/draw_bmp.c @@ -968,7 +968,8 @@ static void mark_rcs(struct mp_draw_sub_cache *p, struct rc_grid *gr) rc->y0 = MPMIN(rc->y0, y); rc->y1 = MPMAX(rc->y1, y + 1); rc->x0 = MPMIN(rc->x0, xpos + s->x0); - rc->x1 = MPMAX(rc->x1, xpos + s->x1); + // Ensure this does not extend beyond the total width + rc->x1 = MPCLAMP(xpos + s->x1, rc->x1, p->w); } } } diff --git a/video/out/vo_dmabuf_wayland.c b/video/out/vo_dmabuf_wayland.c index a43b0fd180..ef1f767c1b 100644 --- a/video/out/vo_dmabuf_wayland.c +++ b/video/out/vo_dmabuf_wayland.c @@ -565,10 +565,6 @@ static bool draw_osd(struct vo *vo, struct mp_image *cur, double pts) void *src = mp_image_pixel_ptr(osd, 0, rc.x0, rc.y0); void *dst = cur->planes[0] + rc.x0 * 4 + rc.y0 * cur->stride[0]; - // Avoid overflowing if we have this special case. - if (n == num_mod_rc - 1) - --rh; - memcpy_pic(dst, src, rw * 4, rh, cur->stride[0], osd->stride[0]); } diff --git a/video/out/vo_vaapi.c b/video/out/vo_vaapi.c index 09f425e26c..4cc6ded00f 100644 --- a/video/out/vo_vaapi.c +++ b/video/out/vo_vaapi.c @@ -684,10 +684,6 @@ static void draw_osd(struct vo *vo) int rw = mp_rect_w(*rc); int rh = mp_rect_h(*rc); - // reduce width of last slice to prevent overflow - if (n == num_mod_rc - 1) - rw = w - rc->x0; - void *src = mp_image_pixel_ptr(osd, 0, rc->x0, rc->y0); void *dst = vaimg.planes[0] + rc->y0 * vaimg.stride[0] + rc->x0 * 4;