# HG changeset patch # User reimar # Date 1275341040 0 # Node ID 77bdb012aaaeac299a2cff68a0a6309608524ba9 # Parent 0a182f029587954e9fa5953a5d1e76b0915f6374 Factor out some common code and ensure we will not try to draw OSD elements outside the streams and thus crash. diff -r 0a182f029587 -r 77bdb012aaae libvo/vo_xv.c --- a/libvo/vo_xv.c Mon May 31 21:16:02 2010 +0000 +++ b/libvo/vo_xv.c Mon May 31 21:24:00 2010 +0000 @@ -114,11 +114,20 @@ 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 @@ 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 @@ 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] +