From: Zhao Yakui Subject: [Patch] More libva surfaces are allocated for MPEG2 It seems that ffmpeg updates the picture structure for decoding. In such case the current allocated libva surface can't meet with the requirement for MPEG2 and it will crash. Signed-off-by: Zhao Yakui --- libvo/vo_vaapi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) Index: mplayer/libvo/vo_vaapi.c =================================================================== --- mplayer.orig/libvo/vo_vaapi.c 2013-09-12 13:01:12.000000000 +0800 +++ mplayer/libvo/vo_vaapi.c 2013-11-19 16:43:36.323978601 +0800 @@ -119,7 +119,7 @@ /* Numbers of video surfaces */ #define MAX_OUTPUT_SURFACES 2 /* Maintain synchronisation points in flip_page() */ #define MAX_VIDEO_SURFACES 21 /* Maintain free surfaces in a queue (use least-recently-used) */ -#define NUM_VIDEO_SURFACES_MPEG2 3 /* 1 decode frame, up to 2 references */ +#define NUM_VIDEO_SURFACES_MPEG2 4 /* 1 decode frame, up to 2 references */ #define NUM_VIDEO_SURFACES_MPEG4 3 /* 1 decode frame, up to 2 references */ #define NUM_VIDEO_SURFACES_H264 21 /* 1 decode frame, up to 20 references */ #define NUM_VIDEO_SURFACES_VC1 3 /* 1 decode frame, up to 2 references */ @@ -953,11 +953,13 @@ #if VA_CHECK_VERSION(0,34,0) attr.type = VADisplayAttribRenderMode; attr.flags = VA_DISPLAY_ATTRIB_GETTABLE; + attr.value = 0; status = vaGetDisplayAttributes(va_context->display, &attr, 1); if (status == VA_STATUS_SUCCESS) - return !(attr.value & (VA_RENDER_MODE_LOCAL_OVERLAY| - VA_RENDER_MODE_EXTERNAL_OVERLAY)); + return !((attr.flags != VA_DISPLAY_ATTRIB_NOT_SUPPORTED) && + (attr.value & (VA_RENDER_MODE_LOCAL_OVERLAY| + VA_RENDER_MODE_EXTERNAL_OVERLAY))); #else /* If the driver doesn't make a copy of the VA surface for display, then we have to retain it until it's no longer the