From dc4e6262caacbdb7c36b82ba28b0157d00e466f1 Mon Sep 17 00:00:00 2001 From: Petri Hintukainen Date: Fri, 15 Jun 2012 11:18:52 +0300 Subject: Check allocated Xv iamge size. Adjust frame size if allocated frame is smaller than requested. Based on patch from http://bugs.xine-project.org/show_bug.cgi?id=108 --- src/video_out/video_out_xcbxv.c | 17 +++++++++++++---- src/video_out/video_out_xv.c | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/video_out/video_out_xcbxv.c b/src/video_out/video_out_xcbxv.c index a627c802b..68c39830b 100644 --- a/src/video_out/video_out_xcbxv.c +++ b/src/video_out/video_out_xcbxv.c @@ -100,6 +100,7 @@ typedef struct { unsigned int xv_pitches[3]; unsigned int xv_offsets[3]; + int req_width, req_height; } xv_frame_t; @@ -360,8 +361,8 @@ static void xv_update_frame_format (vo_driver_t *this_gen, width = (width + 7) & ~0x7; } - if ((frame->width != width) - || (frame->height != height) + if ((frame->req_width != width) + || (frame->req_height != height) || (frame->format != format)) { /* printf ("video_out_xcbxv: updating frame to %d x %d (ratio=%d, format=%08x)\n",width,height,ratio_code,format); */ @@ -390,13 +391,21 @@ static void xv_update_frame_format (vo_driver_t *this_gen, frame->vo_frame.base[2] = frame->image + frame->xv_offsets[1]; } - frame->width = width; - frame->height = height; + /* allocated frame size may not match requested size */ + frame->req_width = width; + frame->req_height = height; + frame->width = frame->xv_width; + frame->height = frame->xv_height; frame->format = format; pthread_mutex_unlock(&this->main_mutex); } + if (frame->vo_frame.width > frame->width) + frame->vo_frame.width = frame->width; + if (frame->vo_frame.height > frame->height) + frame->vo_frame.height = frame->height; + frame->ratio = ratio; } diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c index 0fd8ca89a..bea6e75e6 100644 --- a/src/video_out/video_out_xv.c +++ b/src/video_out/video_out_xv.c @@ -103,6 +103,7 @@ typedef struct { XvImage *image; XShmSegmentInfo shminfo; + int req_width, req_height; } xv_frame_t; @@ -444,8 +445,8 @@ static void xv_update_frame_format (vo_driver_t *this_gen, width = (width + 7) & ~0x7; } - if ((frame->width != width) - || (frame->height != height) + if ((frame->req_width != width) + || (frame->req_height != height) || (frame->format != format)) { /* printf ("video_out_xv: updating frame to %d x %d (ratio=%d, format=%08x)\n",width,height,ratio_code,format); */ @@ -476,13 +477,21 @@ static void xv_update_frame_format (vo_driver_t *this_gen, frame->vo_frame.base[2] = frame->image->data + frame->image->offsets[1]; } - frame->width = width; - frame->height = height; + /* allocated frame size may not match requested size */ + frame->req_width = width; + frame->req_height = height; + frame->width = frame->image->width; + frame->height = frame->image->height; frame->format = format; UNLOCK_DISPLAY(this); } + if (frame->vo_frame.width > frame->width) + frame->vo_frame.width = frame->width; + if (frame->vo_frame.height > frame->height) + frame->vo_frame.height = frame->height; + frame->ratio = ratio; } -- cgit v1.2.3