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/video_out.c | |
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/video_out.c')
-rw-r--r-- | libvo/video_out.c | 60 |
1 files changed, 60 insertions, 0 deletions
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*/ |