diff --git a/sub/osd.c b/sub/osd.c index d33aabdd53..58cc859a94 100644 --- a/sub/osd.c +++ b/sub/osd.c @@ -515,10 +515,16 @@ void osd_rescale_bitmaps(struct sub_bitmaps *imgs, int frame_w, int frame_h, int cy = vidh / 2 - (int)(frame_h * yscale) / 2; for (int i = 0; i < imgs->num_parts; i++) { struct sub_bitmap *bi = &imgs->parts[i]; - bi->x = (int)(bi->x * xscale) + cx + res.ml; - bi->y = (int)(bi->y * yscale) + cy + res.mt; - bi->dw = (int)(bi->w * xscale + 0.5); - bi->dh = (int)(bi->h * yscale + 0.5); + struct mp_rect rc = { + .x0 = lrint(bi->x * xscale), + .y0 = lrint(bi->y * yscale), + .x1 = lrint((bi->x + bi->w) * xscale), + .y1 = lrint((bi->y + bi->h) * yscale), + }; + bi->x = rc.x0 + cx + res.ml; + bi->y = rc.y0 + cy + res.mt; + bi->dw = mp_rect_w(rc); + bi->dh = mp_rect_h(rc); } }