diff options
author | Marco Migliori <sgerwk@aol.com> | 2018-01-24 14:19:40 +0100 |
---|---|---|
committer | Kevin Mitchell <kevmitch@gmail.com> | 2018-02-11 17:51:15 -0800 |
commit | 3a2bc158bb0988af0024014a7a39d6f5c943b6be (patch) | |
tree | 1ad4de3b2a1d510043f1a4ee9f6b6fb897ed294e /video/out/vo_drm.c | |
parent | 9f595f3a80eeaa0bfbda5702031f054f684f6123 (diff) | |
download | mpv-3a2bc158bb0988af0024014a7a39d6f5c943b6be.tar.bz2 mpv-3a2bc158bb0988af0024014a7a39d6f5c943b6be.tar.xz |
vo_drm: make the osd as large as the screen
Before this commit, the drm vo drew the osd over the scaled image, and
then copied the result onto the framebuffer, shifted. This made the
frame centered, but forced the osd to be only as large as the image.
This was inconsistent with other vo's, covered the image with the
progress indicator even when a black band was at the top of the screen,
made the progress indicator wrap on narrow videos, etc.
The change is to always use an image as large as the screen. The frame
is copied scaled and shifted to it, and the osd drawn over it. The
result is finally copied to the framebuffer without any shift, since it
is already as large as it.
Technically, cur_frame is an image as large as the screen and
cur_frame_cropped is a dummy reference to it, cropped to the size of
the scaled video. This way, copying the scaled image to
cur_frame_cropped positions the image in the right place in cur_frame,
which can then have the osd added to it and copied to the framebuffer.
Diffstat (limited to 'video/out/vo_drm.c')
-rw-r--r-- | video/out/vo_drm.c | 36 |
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) |