summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--video/out/vo_drm.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/video/out/vo_drm.c b/video/out/vo_drm.c
index f32ed59b28..07cd1a53a6 100644
--- a/video/out/vo_drm.c
+++ b/video/out/vo_drm.c
@@ -71,6 +71,7 @@ struct priv {
int32_t screen_h;
struct mp_image *last_input;
struct mp_image *cur_frame;
+ struct mp_image *cur_frame_cropped;
struct mp_rect src;
struct mp_rect dst;
struct mp_osd_res osd;
@@ -273,16 +274,6 @@ static int reconfig(struct vo *vo, struct mp_image_params *params)
int w = p->dst.x1 - p->dst.x0;
int h = p->dst.y1 - p->dst.y0;
- // p->osd contains the parameters assuming OSD rendering in window
- // coordinates, but OSD can only be rendered in the intersection
- // between window and video rectangle (i.e. not into panscan borders).
- p->osd.w = w;
- p->osd.h = h;
- p->osd.mt = MPMIN(0, p->osd.mt);
- p->osd.mb = MPMIN(0, p->osd.mb);
- p->osd.mr = MPMIN(0, p->osd.mr);
- p->osd.ml = MPMIN(0, p->osd.ml);
-
mp_sws_set_from_cmdline(p->sws, vo->global);
p->sws->src = *params;
p->sws->dst = (struct mp_image_params) {
@@ -297,6 +288,12 @@ static int reconfig(struct vo *vo, struct mp_image_params *params)
p->cur_frame = mp_image_alloc(IMGFMT, p->screen_w, p->screen_h);
mp_image_params_guess_csp(&p->sws->dst);
mp_image_set_params(p->cur_frame, &p->sws->dst);
+ p->cur_frame[0].w = p->screen_w;
+ p->cur_frame[0].h = p->screen_h;
+
+ talloc_free(p->cur_frame_cropped);
+ p->cur_frame_cropped = mp_image_new_dummy_ref(p->cur_frame);
+ mp_image_crop_rc(p->cur_frame_cropped, p->dst);
struct framebuffer *buf = p->bufs;
for (unsigned int i = 0; i < BUF_COUNT; i++)
@@ -320,7 +317,13 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
src_rc.x0 = MP_ALIGN_DOWN(src_rc.x0, mpi->fmt.align_x);
src_rc.y0 = MP_ALIGN_DOWN(src_rc.y0, mpi->fmt.align_y);
mp_image_crop_rc(&src, src_rc);
- mp_sws_scale(p->sws, p->cur_frame, &src);
+
+ mp_image_clear(p->cur_frame, 0, 0, p->cur_frame->w, p->dst.y0);
+ mp_image_clear(p->cur_frame, 0, p->dst.y1, p->cur_frame->w, p->cur_frame->h);
+ mp_image_clear(p->cur_frame, 0, p->dst.y0, p->dst.x0, p->dst.y1);
+ mp_image_clear(p->cur_frame, p->dst.x1, p->dst.y0, p->cur_frame->w, p->dst.y1);
+
+ mp_sws_scale(p->sws, p->cur_frame_cropped, &src);
osd_draw_on_image(vo->osd, p->osd, src.pts, 0, p->cur_frame);
} else {
mp_image_clear(p->cur_frame, 0, 0, p->cur_frame->w, p->cur_frame->h);
@@ -328,13 +331,9 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
}
struct framebuffer *front_buf = &p->bufs[p->front_buf];
- int w = p->dst.x1 - p->dst.x0;
- int h = p->dst.y1 - p->dst.y0;
- int x = (p->screen_w - w) >> 1;
- int y = (p->screen_h - h) >> 1;
- int shift = y * front_buf->stride + x * BYTES_PER_PIXEL;
- memcpy_pic(front_buf->map + shift, p->cur_frame->planes[0],
- w * BYTES_PER_PIXEL, h, front_buf->stride,
+ memcpy_pic(front_buf->map, p->cur_frame->planes[0],
+ p->cur_frame->w * BYTES_PER_PIXEL, p->cur_frame->h,
+ front_buf->stride,
p->cur_frame->stride[0]);
}
@@ -394,6 +393,7 @@ static void uninit(struct vo *vo)
talloc_free(p->last_input);
talloc_free(p->cur_frame);
+ talloc_free(p->cur_frame_cropped);
}
static int preinit(struct vo *vo)