aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--help/help_mp-en.h4
-rw-r--r--libvo/vo_xv.c11
-rw-r--r--libvo/x11_common.c39
-rw-r--r--libvo/x11_common.h2
4 files changed, 56 insertions, 0 deletions
diff --git a/help/help_mp-en.h b/help/help_mp-en.h
index b548caf638..228f4348c2 100644
--- a/help/help_mp-en.h
+++ b/help/help_mp-en.h
@@ -1012,6 +1012,10 @@ static char help_text[]=
#define MSGTR_VO_SUB_Brightness "Brightness"
#define MSGTR_VO_SUB_Hue "Hue"
+// vo_xv.c
+#define MSGTR_VO_XV_ImagedimTooHigh "Source image dimensions are " \
+ "too high: %ux%u (maximum is %ux%u)\n"
+
// Old vo drivers that have been replaced
#define MSGTR_VO_PGM_HasBeenReplaced "The pgm video output driver has been replaced by -vo pnm:pgmyuv.\n"
diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c
index fd074c19e1..08d5e958f1 100644
--- a/libvo/vo_xv.c
+++ b/libvo/vo_xv.c
@@ -22,6 +22,7 @@ Buffer allocation:
#include "config.h"
#include "mp_msg.h"
+#include "help_mp.h"
#include "video_out.h"
#include "video_out_internal.h"
@@ -89,6 +90,7 @@ static int int_pause;
static Window mRoot;
static uint32_t drwX, drwY, drwBorderWidth, drwDepth;
static uint32_t dwidth, dheight;
+static uint32_t max_width = 0, max_height = 0; // zero means: not set
static void (*draw_alpha_fnc) (int x0, int y0, int w, int h,
unsigned char *src, unsigned char *srca,
@@ -175,6 +177,14 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
image_width = width;
image_format = format;
+ if ((max_width != 0 && max_height != 0) &&
+ (image_width > max_width || image_height > max_height))
+ {
+ mp_msg( MSGT_VO, MSGL_ERR, "[xv] " MSGTR_VO_XV_ImagedimTooHigh,
+ image_width, image_height, max_width, max_height);
+ return -1;
+ }
+
vo_mouse_autohide = 1;
int_pause = 0;
@@ -918,6 +928,7 @@ static int preinit(const char *arg)
return -1; // bail out, colorkey setup failed
}
vo_xv_enable_vsync();
+ vo_xv_get_max_img_dim( &max_width, &max_height );
fo = XvListImageFormats(mDisplay, xv_port, (int *) &formats);
diff --git a/libvo/x11_common.c b/libvo/x11_common.c
index e1272a090d..ed84a69c40 100644
--- a/libvo/x11_common.c
+++ b/libvo/x11_common.c
@@ -2277,6 +2277,45 @@ int vo_xv_enable_vsync()
}
/**
+ * \brief Get maximum supported source image dimensions.
+ *
+ * This function does not set the variables pointed to by
+ * width and height if the information could not be retreived.
+ * So the caller is reponsible for initing them properly.
+ *
+ * \param width [out] The maximum width gets stored here.
+ * \param height [out] The maximum height gets stored here.
+ *
+ */
+void vo_xv_get_max_img_dim( uint32_t * width, uint32_t * height )
+{
+ XvEncodingInfo * encodings;
+ //unsigned long num_encodings, idx; to int or too long?!
+ unsigned int num_encodings, idx;
+
+ XvQueryEncodings( mDisplay, xv_port, &num_encodings, &encodings);
+
+ if ( encodings )
+ {
+ for ( idx = 0; idx < num_encodings; ++idx )
+ {
+ if ( strcmp( encodings[idx].name, "XV_IMAGE" ) == 0 )
+ {
+ *width = encodings[idx].width;
+ *height = encodings[idx].height;
+ break;
+ }
+ }
+ }
+
+ mp_msg( MSGT_VO, MSGL_V,
+ "[xv common] Maximum source image dimensions: %ux%u\n",
+ *width, *height );
+
+ XvFreeEncodingInfo( encodings );
+}
+
+/**
* \brief Print information about the colorkey method and source.
*
* \param ck_handling Integer value containing the information about
diff --git a/libvo/x11_common.h b/libvo/x11_common.h
index a68994e588..2c2c4b2d74 100644
--- a/libvo/x11_common.h
+++ b/libvo/x11_common.h
@@ -77,6 +77,8 @@ extern int vo_xv_get_eq(uint32_t xv_port, char * name, int *value);
extern int vo_xv_enable_vsync();
+extern void vo_xv_get_max_img_dim( uint32_t * width, uint32_t * height );
+
/*** colorkey handling ***/
typedef struct xv_ck_info_s
{