summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-05-31 21:24:00 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-05-31 21:24:00 +0000
commite629ec20bc9dc5538e2defb8eca94b2a85b8c2a1 (patch)
tree7f469ab53a6ab3fca0aed1a58cea8d16c5d778fc /libvo
parentad7448b623929adb1f42fc05922283612ed028b1 (diff)
downloadmpv-e629ec20bc9dc5538e2defb8eca94b2a85b8c2a1.tar.bz2
mpv-e629ec20bc9dc5538e2defb8eca94b2a85b8c2a1.tar.xz
Factor out some common code and ensure we will not try to draw OSD
elements outside the streams and thus crash. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31297 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r--libvo/vo_xv.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c
index 6f1f7b6a36..f921c4dfe3 100644
--- a/libvo/vo_xv.c
+++ b/libvo/vo_xv.c
@@ -114,11 +114,20 @@ static void (*draw_alpha_fnc) (int x0, int y0, int w, int h,
unsigned char *src, unsigned char *srca,
int stride);
+static void fixup_osd_position(int *x0, int *y0, int *w, int *h)
+{
+ *x0 += image_width * (vo_panscan_x >> 1) / (vo_dwidth + vo_panscan_x);
+ *w = av_clip(*w, 0, image_width);
+ *h = av_clip(*h, 0, image_height);
+ *x0 = FFMIN(*x0, image_width - *w);
+ *y0 = FFMIN(*y0, image_height - *h);
+}
+
static void draw_alpha_yv12(int x0, int y0, int w, int h,
unsigned char *src, unsigned char *srca,
int stride)
{
- x0 += image_width * (vo_panscan_x >> 1) / (vo_dwidth + vo_panscan_x);
+ fixup_osd_position(&x0, &y0, &w, &h);
vo_draw_alpha_yv12(w, h, src, srca, stride,
xvimage[current_buf]->data +
xvimage[current_buf]->offsets[0] +
@@ -130,7 +139,7 @@ static void draw_alpha_yuy2(int x0, int y0, int w, int h,
unsigned char *src, unsigned char *srca,
int stride)
{
- x0 += image_width * (vo_panscan_x >> 1) / (vo_dwidth + vo_panscan_x);
+ fixup_osd_position(&x0, &y0, &w, &h);
vo_draw_alpha_yuy2(w, h, src, srca, stride,
xvimage[current_buf]->data +
xvimage[current_buf]->offsets[0] +
@@ -142,7 +151,7 @@ static void draw_alpha_uyvy(int x0, int y0, int w, int h,
unsigned char *src, unsigned char *srca,
int stride)
{
- x0 += image_width * (vo_panscan_x >> 1) / (vo_dwidth + vo_panscan_x);
+ fixup_osd_position(&x0, &y0, &w, &h);
vo_draw_alpha_yuy2(w, h, src, srca, stride,
xvimage[current_buf]->data +
xvimage[current_buf]->offsets[0] +