diff options
author | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2009-02-13 03:52:51 +0200 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2009-02-13 03:52:51 +0200 |
commit | 738f66b1bc98073d74af7031c4454322157a15ec (patch) | |
tree | 25d69a5d92ea4440f7e08e3c82cc5bb3a1d4598e /libvo | |
parent | 1e869638280f962fb80f372d152234f21246c2af (diff) | |
parent | 9f8792e639fee0b706dc5ec83e9b9fa0cf432e61 (diff) | |
download | mpv-738f66b1bc98073d74af7031c4454322157a15ec.tar.bz2 mpv-738f66b1bc98073d74af7031c4454322157a15ec.tar.xz |
Merge svn changes up to r28549
Diffstat (limited to 'libvo')
-rw-r--r-- | libvo/old_vo_defines.h | 2 | ||||
-rw-r--r-- | libvo/video_out.c | 60 | ||||
-rw-r--r-- | libvo/video_out.h | 4 | ||||
-rw-r--r-- | libvo/vo_direct3d.c | 53 | ||||
-rw-r--r-- | libvo/vo_xv.c | 60 | ||||
-rw-r--r-- | libvo/vo_xvmc.c | 21 | ||||
-rw-r--r-- | libvo/x11_common.c | 26 | ||||
-rw-r--r-- | libvo/x11_common.h | 3 |
8 files changed, 113 insertions, 116 deletions
diff --git a/libvo/old_vo_defines.h b/libvo/old_vo_defines.h index fd266c1896..feded12d5b 100644 --- a/libvo/old_vo_defines.h +++ b/libvo/old_vo_defines.h @@ -19,4 +19,6 @@ #define vo_screenheight global_vo->opts->vo_screenheight #define vidmode global_vo->opts->vidmode #define movie_aspect global_vo->opts->movie_aspect + +#define calc_src_dst_rects(...) calc_src_dst_rects(global_vo, __VA_ARGS__) #endif diff --git a/libvo/video_out.c b/libvo/video_out.c index 5dc28522b5..6d177ecabe 100644 --- a/libvo/video_out.c +++ b/libvo/video_out.c @@ -416,6 +416,66 @@ int lookup_keymap_table(const struct keymap *map, int key) { return map->to; } +/** + * \brief helper function for the kind of panscan-scaling that needs a source + * and destination rectangle like Direct3D and VDPAU + */ +static void src_dst_split_scaling(int src_size, int dst_size, int scaled_src_size, + int *src_start, int *src_end, int *dst_start, int *dst_end) { + if (scaled_src_size > dst_size) { + int border = src_size * (scaled_src_size - dst_size) / scaled_src_size; + // round to a multiple of 2, this is at least needed for vo_direct3d and ATI cards + border = (border / 2 + 1) & ~1; + *src_start = border; + *src_end = src_size - border; + *dst_start = 0; + *dst_end = dst_size; + } else { + *src_start = 0; + *src_end = src_size; + *dst_start = (dst_size - scaled_src_size) / 2; + *dst_end = *dst_start + scaled_src_size; + } +} + +/** + * Calculate the appropriate source and destination rectangle to + * get a correctly scaled picture, including pan-scan. + * Can be extended to take future cropping support into account. + * + * \param crop specifies the cropping border size in the left, right, top and bottom members, may be NULL + */ +void calc_src_dst_rects(struct vo *vo, int src_width, int src_height, struct vo_rect *src, struct vo_rect *dst, struct vo_rect *crop) { + static const struct vo_rect no_crop = {0, 0, 0, 0, 0, 0}; + int scaled_width = 0; + int scaled_height = 0; + if (!crop) crop = &no_crop; + src_width -= crop->left + crop->right; + src_height -= crop->top + crop->bottom; + if (src_width < 2) src_width = 2; + if (src_height < 2) src_height = 2; + dst->left = 0; dst->right = vo->dwidth; + dst->top = 0; dst->bottom = vo->dheight; + src->left = 0; src->right = src_width; + src->top = 0; src->bottom = src_height; + if (vo_fs) { + aspect(vo, &scaled_width, &scaled_height, A_ZOOM); + panscan_calc(vo); + scaled_width += vo->panscan_x; + scaled_height += vo->panscan_y; + src_dst_split_scaling(src_width, vo->dwidth, scaled_width, + &src->left, &src->right, &dst->left, &dst->right); + src_dst_split_scaling(src_height, vo->dheight, scaled_height, + &src->top, &src->bottom, &dst->top, &dst->bottom); + } + src->left += crop->left; src->right += crop->left; + src->top += crop->top; src->bottom += crop->top; + src->width = src->right - src->left; + src->height = src->bottom - src->top; + dst->width = dst->right - dst->left; + dst->height = dst->bottom - dst->top; +} + #if defined(CONFIG_FBDEV) || defined(CONFIG_VESA) /* Borrowed from vo_fbdev.c Monitor ranges related functions*/ diff --git a/libvo/video_out.h b/libvo/video_out.h index a5f90305b4..64d4e1bb77 100644 --- a/libvo/video_out.h +++ b/libvo/video_out.h @@ -318,5 +318,9 @@ struct keymap { int to; }; int lookup_keymap_table(const struct keymap *map, int key); +struct vo_rect { + int left, right, top, bottom, width, height; +}; +void calc_src_dst_rects(struct vo *vo, int src_width, int src_height, struct vo_rect *src, struct vo_rect *dst, struct vo_rect *crop); #endif /* MPLAYER_VIDEO_OUT_H */ diff --git a/libvo/vo_direct3d.c b/libvo/vo_direct3d.c index f41102ab4b..ef1d0ba9dc 100644 --- a/libvo/vo_direct3d.c +++ b/libvo/vo_direct3d.c @@ -147,47 +147,18 @@ typedef enum back_buffer_action { */ static void calc_fs_rect(void) { - int scaled_height = 0; - int scaled_width = 0; - - // set default values - priv->fs_movie_rect.left = 0; - priv->fs_movie_rect.right = vo_dwidth; - priv->fs_movie_rect.top = 0; - priv->fs_movie_rect.bottom = vo_dheight; - priv->fs_panscan_rect.left = 0; - priv->fs_panscan_rect.right = priv->src_width; - priv->fs_panscan_rect.top = 0; - priv->fs_panscan_rect.bottom = priv->src_height; - if (!vo_fs) - return; - - // adjust for fullscreen aspect and panscan - aspect(&scaled_width, &scaled_height, A_ZOOM); - panscan_calc(); - scaled_width += vo_panscan_x; - scaled_height += vo_panscan_y; - - // note: border is rounded to a multiple of two since at least - // ATI drivers can not handle odd values with YV12 input - if (scaled_width > vo_dwidth) { - int border = priv->src_width * (scaled_width - vo_dwidth) / scaled_width; - border = (border / 2 + 1) & ~1; - priv->fs_panscan_rect.left = border; - priv->fs_panscan_rect.right = priv->src_width - border; - } else { - priv->fs_movie_rect.left = (vo_dwidth - scaled_width) / 2; - priv->fs_movie_rect.right = priv->fs_movie_rect.left + scaled_width; - } - if (scaled_height > vo_dheight) { - int border = priv->src_height * (scaled_height - vo_dheight) / scaled_height; - border = (border / 2 + 1) & ~1; - priv->fs_panscan_rect.top = border; - priv->fs_panscan_rect.bottom = priv->src_height - border; - } else { - priv->fs_movie_rect.top = (vo_dheight - scaled_height) / 2; - priv->fs_movie_rect.bottom = priv->fs_movie_rect.top + scaled_height; - } + struct vo_rect src_rect; + struct vo_rect dst_rect; + calc_src_dst_rects(priv->src_width, priv->src_height, &src_rect, &dst_rect, NULL); + + priv->fs_movie_rect.left = dst_rect.left; + priv->fs_movie_rect.right = dst_rect.right; + priv->fs_movie_rect.top = dst_rect.top; + priv->fs_movie_rect.bottom = dst_rect.bottom; + priv->fs_panscan_rect.left = src_rect.left; + priv->fs_panscan_rect.right = src_rect.right; + priv->fs_panscan_rect.top = src_rect.top; + priv->fs_panscan_rect.bottom = src_rect.bottom; mp_msg(MSGT_VO, MSGL_V, "<vo_direct3d>Fullscreen movie rectangle: t: %ld, l: %ld, r: %ld, b:%ld\n", diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c index 30f643477b..c6bbcdf347 100644 --- a/libvo/vo_xv.c +++ b/libvo/vo_xv.c @@ -106,7 +106,8 @@ struct xvctx { uint32_t image_height; uint32_t image_format; int is_paused; - uint32_t drwX, drwY; + struct vo_rect src_rect; + struct vo_rect dst_rect; uint32_t max_width, max_height; // zero means: not set int event_fd_registered; // for uninit called from preinit int mode_switched; @@ -180,6 +181,17 @@ static void draw_alpha_null(void *p, int x0, int y0, int w, int h, static void deallocate_xvimage(struct vo *vo, int foo); +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); + struct vo_rect *dst = &ctx->dst_rect; + vo_x11_clearwindow_part(vo, vo->x11->window, dst->width, dst->height, 1); + vo_xv_draw_colorkey(vo, dst->left, dst->top, dst->width, dst->height); +} + /* * connect to server, create and map window, * allocate colors and (shared) memory @@ -307,17 +319,8 @@ static int config(struct vo *vo, uint32_t width, uint32_t height, if ((flags & VOFLAG_FULLSCREEN) && WinID <= 0) vo_fs = 1; - vo_calc_drwXY(vo, &ctx->drwX, &ctx->drwY); - panscan_calc(vo); - - vo_xv_draw_colorkey(vo, ctx->drwX - (vo->panscan_x >> 1), - ctx->drwY - (vo->panscan_y >> 1), - vo->dwidth + vo->panscan_x - 1, - vo->dheight + vo->panscan_y - 1); - - mp_msg(MSGT_VO, MSGL_V, "[xv] dx: %d dy: %d dw: %d dh: %d\n", ctx->drwX, - ctx->drwY, vo->dwidth, vo->dheight); + resize(vo); return 0; } @@ -391,22 +394,20 @@ 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; #ifdef HAVE_SHM if (ctx->Shmem_Flag) { XvShmPutImage(x11->display, x11->xv_port, x11->window, x11->vo_gc, xvi, - 0, 0, ctx->image_width, ctx->image_height, - ctx->drwX - (vo->panscan_x >> 1), - ctx->drwY - (vo->panscan_y >> 1), - vo->dwidth + vo->panscan_x, vo->dheight + vo->panscan_y, + src->left, src->top, src->width, src->height, + dst->left, dst->top, dst->width, dst->height, False); } else #endif { - XvPutImage(x11->display, x11->xv_port, x11->window, x11->vo_gc, xvi, 0, - 0, ctx->image_width, ctx->image_height, - ctx->drwX - (vo->panscan_x >> 1), - ctx->drwY - (vo->panscan_y >> 1), - vo->dwidth + vo->panscan_x, vo->dheight + vo->panscan_y); + 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); } } @@ -428,15 +429,8 @@ static void check_events(struct vo *vo) struct vo_x11_state *x11 = vo->x11; int e = vo_x11_check_events(vo); - if (e & VO_EVENT_RESIZE) - vo_calc_drwXY(vo, &ctx->drwX, &ctx->drwY); - - if (e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE) { - vo_xv_draw_colorkey(vo, ctx->drwX - (vo->panscan_x >> 1), - ctx->drwY - (vo->panscan_y >> 1), - vo->dwidth + vo->panscan_x - 1, - vo->dheight + vo->panscan_y - 1); - } + if (e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE) + resize(vo); if ((e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE) && ctx->is_paused) { /* did we already draw a buffer */ @@ -831,13 +825,7 @@ static int control(struct vo *vo, uint32_t request, void *data) panscan_calc(vo); if (old_y != vo->panscan_y) { - vo_x11_clearwindow_part(vo, x11->window, - vo->dwidth + vo->panscan_x - 1, - vo->dheight + vo->panscan_y - 1, 1); - vo_xv_draw_colorkey(vo, ctx->drwX - (vo->panscan_x >> 1), - ctx->drwY - (vo->panscan_y >> 1), - vo->dwidth + vo->panscan_x - 1, - vo->dheight + vo->panscan_y - 1); + resize(vo); flip_page(vo); } } diff --git a/libvo/vo_xvmc.c b/libvo/vo_xvmc.c index 58ab9610c9..93e2957bca 100644 --- a/libvo/vo_xvmc.c +++ b/libvo/vo_xvmc.c @@ -81,7 +81,6 @@ static int top_field_first; static int image_width,image_height; static int image_format; -static uint32_t drwX,drwY; #define NO_SUBPICTURE 0 #define OVERLAY_SUBPICTURE 1 @@ -676,11 +675,6 @@ skip_surface_allocation: } if ((flags & VOFLAG_FULLSCREEN) && WinID <= 0) vo_fs = 1; - vo_calc_drwXY(&drwX, &drwY); - - panscan_calc(); - - mp_msg(MSGT_VO,MSGL_V, "[xvmc] dx: %d dy: %d dw: %d dh: %d\n",drwX,drwY,vo_dwidth,vo_dheight ); //end vo_xv @@ -950,19 +944,16 @@ int status,rez; static void put_xvmc_image(struct xvmc_render_state * p_render_surface, int draw_ck){ int rez; -int clipX,clipY,clipW,clipH; +struct vo_rect src_rect, dst_rect; int i; if(p_render_surface == NULL) return; - clipX = drwX-(vo_panscan_x>>1); - clipY = drwY-(vo_panscan_y>>1); - clipW = vo_dwidth+vo_panscan_x; - clipH = vo_dheight+vo_panscan_y; + calc_src_dst_rects(image_width, image_height, &src_rect, &dst_rect, NULL); if(draw_ck) - vo_xv_draw_colorkey(clipX,clipY,clipW,clipH); + vo_xv_draw_colorkey(dst_rect.left, dst_rect.top, dst_rect.width, dst_rect.height); if(benchmark) return; @@ -971,8 +962,8 @@ int i; int field = top_field_first ? i : i ^ 3; rez = XvMCPutSurface(mDisplay, p_render_surface->p_surface, vo_window, - 0, 0, image_width, image_height, - clipX, clipY, clipW, clipH, + src_rect.left, src_rect.top, src_rect.width, src_rect.height, + dst_rect.left, dst_rect.top, dst_rect.width, dst_rect.height, bob_deinterlace ? field : 3); //p_render_surface_to_show->display_flags); if(rez != Success){ @@ -1036,8 +1027,6 @@ int e=vo_x11_check_events(mDisplay); if(e&VO_EVENT_RESIZE) { e |= VO_EVENT_EXPOSE; - - vo_calc_drwXY(&drwX, &drwY); } if ( e & VO_EVENT_EXPOSE ) { diff --git a/libvo/x11_common.c b/libvo/x11_common.c index c7864b14dd..0b070a868b 100644 --- a/libvo/x11_common.c +++ b/libvo/x11_common.c @@ -811,8 +811,12 @@ int vo_x11_check_events(struct vo *vo) // if (vo_fs && Event.xconfigure.width != opts->vo_screenwidth && Event.xconfigure.height != opts->vo_screenheight) break; if (x11->window == None) break; - vo_x11_update_geometry(vo); - ret |= VO_EVENT_RESIZE; + { + int old_w = vo->dwidth, old_h = vo->dheight; + vo_x11_update_geometry(vo); + if (vo->dwidth != old_w || vo->dheight != old_h) + ret |= VO_EVENT_RESIZE; + } break; case KeyPress: { @@ -1868,24 +1872,6 @@ uint32_t vo_x11_get_equalizer(char *name, int *value) return VO_TRUE; } -void vo_calc_drwXY(struct vo *vo, uint32_t *drwX, uint32_t *drwY) -{ - struct MPOpts *opts = vo->opts; - *drwX = *drwY = 0; - if (vo_fs) { - aspect(vo, &vo->dwidth, &vo->dheight, A_ZOOM); - vo->dwidth = FFMIN(vo->dwidth, opts->vo_screenwidth); - vo->dheight = FFMIN(vo->dheight, opts->vo_screenheight); - *drwX = (opts->vo_screenwidth - vo->dwidth) / 2; - *drwY = (opts->vo_screenheight - vo->dheight) / 2; - mp_msg(MSGT_VO, MSGL_V, "[xv-fs] dx: %d dy: %d dw: %d dh: %d\n", *drwX, - *drwY, vo->dwidth, vo->dheight); - } else if (WinID == 0) { - *drwX = vo->dx; - *drwY = vo->dy; - } -} - #ifdef CONFIG_XV int vo_xv_set_eq(struct vo *vo, uint32_t xv_port, char *name, int value) { diff --git a/libvo/x11_common.h b/libvo/x11_common.h index 446a6903df..872e84e174 100644 --- a/libvo/x11_common.h +++ b/libvo/x11_common.h @@ -172,8 +172,6 @@ void vo_vm_close(struct vo *vo); void update_xinerama_info(struct vo *vo); int vo_find_depth_from_visuals(Display *dpy, int screen, Visual **visual_return); -void vo_calc_drwXY(struct vo *vo, uint32_t *drwX, uint32_t *drwY); - void xscreensaver_heartbeat(struct vo_x11_state *x11); // Old VOs use incompatible function calls, translate them to new @@ -204,7 +202,6 @@ void xscreensaver_heartbeat(struct vo_x11_state *x11); #define vo_x11_classhint(display, window, name) vo_x11_classhint(global_vo, window, name) #define vo_x11_setlayer(display, window, layer) vo_x11_setlayer(global_vo, window, layer) #define xv_setup_colorkeyhandling(a, b) xv_setup_colorkeyhandling(global_vo, a, b) -#define vo_calc_drwXY(drwX, drwY) vo_calc_drwXY(global_vo, drwX, drwY) #define mDisplay global_vo->x11->display #define vo_depthonscreen global_vo->x11->depthonscreen |