diff options
author | wm4 <wm4@nowhere> | 2012-10-27 22:10:32 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-11-01 02:07:46 +0100 |
commit | 6f408d0d9d6d0655faec75474bc3074812b41826 (patch) | |
tree | 973ef09419d166790c4d909eb2bd90d8709278ab /libvo/vo_xv.c | |
parent | 3466057febaf5790b3ce88db1726058d9852f28d (diff) | |
download | mpv-6f408d0d9d6d0655faec75474bc3074812b41826.tar.bz2 mpv-6f408d0d9d6d0655faec75474bc3074812b41826.tar.xz |
VO: remove code duplication for setting up mp_osd_res
vo_opengl, vo_vdpau, vo_direct3d had the code for setting up mp_osd_res
duplicated. Make things simpler by making calc_src_dst_rects() setup
the full mp_osd_res structure, instead of just "borders".
Also, rename that function to vo_get_src_dst_rects(), and make it use
mp_rect. Remove vo_rect, which was annoying because it contains
redundant members (width/height additional to right/bottom).
Add code to print the video rect etc. in verbose mode.
There should be no actual change how the video rects are calculated. The
only exception are the bottom/right subtitle margins, which are now
computed slightly differently, but that shouldn't matter.
Diffstat (limited to 'libvo/vo_xv.c')
-rw-r--r-- | libvo/vo_xv.c | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c index 90eda230b8..de14f039f4 100644 --- a/libvo/vo_xv.c +++ b/libvo/vo_xv.c @@ -77,8 +77,8 @@ struct xvctx { uint32_t image_height; uint32_t image_format; int is_paused; - struct vo_rect src_rect; - struct vo_rect dst_rect; + struct mp_rect src_rect; + struct mp_rect dst_rect; uint32_t max_width, max_height; // zero means: not set int mode_switched; #ifdef HAVE_SHM @@ -94,11 +94,16 @@ static void resize(struct vo *vo) { struct xvctx *ctx = vo->priv; - calc_src_dst_rects(vo, ctx->image_width, ctx->image_height, &ctx->src_rect, - &ctx->dst_rect, NULL, NULL); - struct vo_rect *dst = &ctx->dst_rect; - vo_x11_clearwindow_part(vo, vo->x11->window, dst->width, dst->height); - vo_xv_draw_colorkey(vo, dst->left, dst->top, dst->width, dst->height); + // Can't be used, because the function calculates screen-space coordinates, + // while we need video-space. + struct mp_osd_res unused; + + vo_get_src_dst_rects(vo, &ctx->src_rect, &ctx->dst_rect, &unused); + + struct mp_rect *dst = &ctx->dst_rect; + int dw = dst->x1 - dst->x0, dh = dst->y1 - dst->y0; + vo_x11_clearwindow_part(vo, vo->x11->window, dw, dh); + vo_xv_draw_colorkey(vo, dst->x0, dst->y0, dw, dh); } /* @@ -275,20 +280,22 @@ static inline void put_xvimage(struct vo *vo, XvImage *xvi) { struct xvctx *ctx = vo->priv; struct vo_x11_state *x11 = vo->x11; - struct vo_rect *src = &ctx->src_rect; - struct vo_rect *dst = &ctx->dst_rect; + struct mp_rect *src = &ctx->src_rect; + struct mp_rect *dst = &ctx->dst_rect; + int dw = dst->x1 - dst->x0, dh = dst->y1 - dst->y0; + int sw = src->x1 - src->x0, sh = src->y1 - src->y0; #ifdef HAVE_SHM if (ctx->Shmem_Flag) { XvShmPutImage(x11->display, x11->xv_port, x11->window, x11->vo_gc, xvi, - src->left, src->top, src->width, src->height, - dst->left, dst->top, dst->width, dst->height, + src->x0, src->y0, sw, sh, + dst->x0, dst->y0, dw, dh, False); } else #endif { XvPutImage(x11->display, x11->xv_port, x11->window, x11->vo_gc, xvi, - src->left, src->top, src->width, src->height, - dst->left, dst->top, dst->width, dst->height); + src->x0, src->y0, sw, sh, + dst->x0, dst->y0, dw, dh); } } @@ -340,9 +347,11 @@ static void draw_osd(struct vo *vo, struct osd_state *osd) struct mp_image img = get_xv_buffer(vo, ctx->current_buf); - struct vo_rect *src = &ctx->src_rect; - struct vo_rect *dst = &ctx->dst_rect; - double xvpar = (double)dst->width / dst->height * src->height / src->width; + struct mp_rect *src = &ctx->src_rect; + struct mp_rect *dst = &ctx->dst_rect; + int dw = dst->x1 - dst->x0, dh = dst->y1 - dst->y0; + int sw = src->x1 - src->x0, sh = src->y1 - src->y0; + double xvpar = (double)dw / dh * sh / sw; struct mp_osd_res res = { .w = ctx->image_width, |