From 694c3dc03f157eb62442fb2f24118f2ae4432ec7 Mon Sep 17 00:00:00 2001 From: reimar Date: Thu, 12 Feb 2009 17:40:53 +0000 Subject: Add a calc_src_dst_rects that calculates from window size, panscan etc. which part of the video source must be scaled onto which part of the window. Direct3D and (future) VDPAU need this, for XvMC it makes it easier to add cropping support and Xv is changed to keep the diff to XvMC small. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28546 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_direct3d.c | 53 ++++++++++++----------------------------------------- 1 file changed, 12 insertions(+), 41 deletions(-) (limited to 'libvo/vo_direct3d.c') diff --git a/libvo/vo_direct3d.c b/libvo/vo_direct3d.c index 48287c238f..c2955f2d44 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, "Fullscreen movie rectangle: t: %ld, l: %ld, r: %ld, b:%ld\n", -- cgit v1.2.3