summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_out/video_out_xv.c244
1 files changed, 145 insertions, 99 deletions
diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c
index c64fc3325..a9410e1db 100644
--- a/src/video_out/video_out_xv.c
+++ b/src/video_out/video_out_xv.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: video_out_xv.c,v 1.137 2002/10/16 14:19:40 guenter Exp $
+ * $Id: video_out_xv.c,v 1.138 2002/10/16 21:11:50 guenter Exp $
*
* video_out_xv.c, X11 video extension interface for xine
*
@@ -98,7 +98,7 @@ typedef struct {
struct xv_driver_s {
- xine_vo_driver_t vo_driver;
+ xine_vo_driver_t vo_driver;
config_values_t *config;
@@ -136,6 +136,13 @@ struct xv_driver_s {
int (*x11_old_error_handler) (Display *, XErrorEvent *);
};
+typedef struct {
+ config_values_t *config;
+ XvPortID xv_port;
+ XvAdaptorInfo *adaptor_info;
+ unsigned int adaptor_num;
+} xv_class_t;
+
int gX11Fail;
static uint32_t xv_get_capabilities (xine_vo_driver_t *this_gen) {
@@ -763,7 +770,8 @@ static int xv_set_property (xine_vo_driver_t *this_gen,
this->props[property].atom,
&this->props[property].value);
- this->props[property].entry->num_value = this->props[property].value;
+ if (this->props[property].entry)
+ this->props[property].entry->num_value = this->props[property].value;
return this->props[property].value;
} else {
@@ -981,7 +989,9 @@ static int xv_check_yv12 (Display *display, XvPortID port) {
static void xv_check_capability (xv_driver_t *this,
uint32_t capability,
int property, XvAttribute attr,
- int base_id, char *str_prop) {
+ int base_id, char *str_prop,
+ char *config_name,
+ char *config_desc) {
int int_default;
cfg_entry_t *entry;
@@ -1004,30 +1014,30 @@ static void xv_check_capability (xv_driver_t *this,
printf ("video_out_xv: port attribute %s value is %d\n",
str_prop, int_default);
- sprintf (this->scratch, "video.%s", str_prop);
-
- /* is this a boolean property ? */
- if ((attr.min_value == 0) && (attr.max_value == 1)) {
- this->config->register_bool (this->config, this->scratch, int_default,
- _("Xv property"),
- NULL, 10, xv_property_callback, &this->props[property]);
-
- } else {
- this->config->register_range (this->config, this->scratch, int_default,
- this->props[property].min, this->props[property].max,
- _("Xv property"),
- NULL, 10, xv_property_callback, &this->props[property]);
- }
-
- entry = this->config->lookup_entry (this->config, this->scratch);
-
- this->props[property].entry = entry;
+ if (config_name) {
+ /* is this a boolean property ? */
+ if ((attr.min_value == 0) && (attr.max_value == 1)) {
+ this->config->register_bool (this->config, config_name, int_default,
+ config_desc,
+ NULL, 10, xv_property_callback, &this->props[property]);
+
+ } else {
+ this->config->register_range (this->config, config_name, int_default,
+ this->props[property].min, this->props[property].max,
+ config_desc,
+ NULL, 10, xv_property_callback, &this->props[property]);
+ }
+
+ entry = this->config->lookup_entry (this->config, this->scratch);
+
+ this->props[property].entry = entry;
- xv_set_property (&this->vo_driver, property, entry->num_value);
+ xv_set_property (&this->vo_driver, property, entry->num_value);
- if (capability == VO_CAP_COLORKEY) {
- this->use_colorkey = 1;
- this->colorkey = entry->num_value;
+ if (capability == VO_CAP_COLORKEY) {
+ this->use_colorkey = 1;
+ this->colorkey = entry->num_value;
+ }
}
}
@@ -1064,79 +1074,26 @@ static void xv_update_XV_DOUBLE_BUFFER(void *this_gen, xine_cfg_entry_t *entry)
}
-static void *init_video_out_plugin (xine_t *xine, void *visual_gen) {
+static void *open_plugin (void *class_gen, xine_stream_t *stream,
+ const void *visual_gen) {
- config_values_t *config = xine->config;
+ xv_class_t *class = (xv_class_t *) class_gen;
+ config_values_t *config = class->config;
xv_driver_t *this;
+ int i, formats;
Display *display = NULL;
- unsigned int adaptor_num, adaptors, i, j, formats;
- unsigned int ver,rel,req,ev,err;
- XvPortID xv_port;
XvAttribute *attr;
- XvAdaptorInfo *adaptor_info;
XvImageFormatValues *fo;
int nattr;
x11_visual_t *visual = (x11_visual_t *) visual_gen;
XColor dummy;
XvImage *myimage;
XShmSegmentInfo myshminfo;
+ XvPortID xv_port = class->xv_port;
display = visual->display;
- /*
- * check for Xvideo support
- */
-
- if (Success != XvQueryExtension(display,&ver,&rel,&req,&ev,&err)) {
- printf ("video_out_xv: Xv extension not present.\n");
- return NULL;
- }
-
- /*
- * check adaptors, search for one that supports (at least) yuv12
- */
-
- if (Success != XvQueryAdaptors(display,DefaultRootWindow(display),
- &adaptors,&adaptor_info)) {
- printf("video_out_xv: XvQueryAdaptors failed.\n");
- return NULL;
- }
-
- xv_port = 0;
-
- for ( adaptor_num = 0; (adaptor_num < adaptors) && !xv_port; adaptor_num++ ) {
-
- if (adaptor_info[adaptor_num].type & XvImageMask) {
-
- for (j = 0; j < adaptor_info[adaptor_num].num_ports && !xv_port; j++)
- if (( !(xv_check_yv12 (display,
- adaptor_info[adaptor_num].base_id + j)))
- && (XvGrabPort (display,
- adaptor_info[adaptor_num].base_id + j,
- 0) == Success)) {
- xv_port = adaptor_info[adaptor_num].base_id + j;
- }
-
- if( xv_port )
- break;
- }
- }
-
- if (!xv_port) {
- printf ("video_out_xv: Xv extension is present but "
- "I couldn't find a usable yuv12 port.\n");
- printf (" Looks like your graphics hardware "
- "driver doesn't support Xv?!\n");
- /* XvFreeAdaptorInfo (adaptor_info); this crashed on me (gb)*/
- return NULL;
- } else
- printf ("video_out_xv: using Xv port %ld from adaptor %s for hardware "
- "colorspace conversion and scaling.\n", xv_port,
- adaptor_info[adaptor_num].name);
-
- /*
- * from this point on, nothing should go wrong anymore; so let's start initializing this driver
- */
+ printf ("video_out_xv: open_plugin\n");
this = malloc (sizeof (xv_driver_t));
@@ -1147,10 +1104,11 @@ static void *init_video_out_plugin (xine_t *xine, void *visual_gen) {
memset (this, 0, sizeof(xv_driver_t));
- this->config = config;
this->display = visual->display;
this->overlay = NULL;
this->screen = visual->screen;
+ this->xv_port = class->xv_port;
+ this->config = config;
vo_scale_init (&this->sc, 1, 0 );
this->sc.frame_output_cb = visual->frame_output_cb;
@@ -1158,7 +1116,6 @@ static void *init_video_out_plugin (xine_t *xine, void *visual_gen) {
this->drawable = visual->d;
this->gc = XCreateGC (this->display, this->drawable, 0, NULL);
- this->xv_port = xv_port;
this->capabilities = 0;
this->expecting_event = 0;
this->use_shm = 1;
@@ -1168,9 +1125,9 @@ static void *init_video_out_plugin (xine_t *xine, void *visual_gen) {
this->colorkey = 0;
this->x11_old_error_handler = NULL;
- XAllocNamedColor(this->display,
- DefaultColormap(this->display, this->screen),
- "black", &this->black, &dummy);
+ XAllocNamedColor (this->display,
+ DefaultColormap(this->display, this->screen),
+ "black", &this->black, &dummy);
this->vo_driver.get_capabilities = xv_get_capabilities;
this->vo_driver.alloc_frame = xv_alloc_frame;
@@ -1217,32 +1174,40 @@ static void *init_video_out_plugin (xine_t *xine, void *visual_gen) {
if(!strcmp(attr[k].name, "XV_HUE")) {
xv_check_capability (this, VO_CAP_HUE,
VO_PROP_HUE, attr[k],
- adaptor_info[adaptor_num].base_id, "XV_HUE");
+ class->adaptor_info[class->adaptor_num].base_id, "XV_HUE",
+ NULL, NULL);
} else if(!strcmp(attr[k].name, "XV_SATURATION")) {
xv_check_capability (this, VO_CAP_SATURATION,
VO_PROP_SATURATION, attr[k],
- adaptor_info[adaptor_num].base_id, "XV_SATURATION");
+ class->adaptor_info[class->adaptor_num].base_id, "XV_SATURATION",
+ NULL, NULL);
} else if(!strcmp(attr[k].name, "XV_BRIGHTNESS")) {
xv_check_capability (this, VO_CAP_BRIGHTNESS,
VO_PROP_BRIGHTNESS, attr[k],
- adaptor_info[adaptor_num].base_id, "XV_BRIGHTNESS");
+ class->adaptor_info[class->adaptor_num].base_id, "XV_BRIGHTNESS",
+ NULL, NULL);
} else if(!strcmp(attr[k].name, "XV_CONTRAST")) {
xv_check_capability (this, VO_CAP_CONTRAST,
VO_PROP_CONTRAST, attr[k],
- adaptor_info[adaptor_num].base_id, "XV_CONTRAST");
+ class->adaptor_info[class->adaptor_num].base_id, "XV_CONTRAST",
+ NULL, NULL);
} else if(!strcmp(attr[k].name, "XV_COLORKEY")) {
xv_check_capability (this, VO_CAP_COLORKEY,
VO_PROP_COLORKEY, attr[k],
- adaptor_info[adaptor_num].base_id, "XV_COLORKEY");
+ class->adaptor_info[class->adaptor_num].base_id, "XV_COLORKEY",
+ "video.xv_colorkey",
+ _("Colorkey used for Xv video overlay"));
} else if(!strcmp(attr[k].name, "XV_AUTOPAINT_COLORKEY")) {
xv_check_capability (this, VO_CAP_AUTOPAINT_COLORKEY,
VO_PROP_AUTOPAINT_COLORKEY, attr[k],
- adaptor_info[adaptor_num].base_id, "XV_AUTOPAINT_COLORKEY");
+ class->adaptor_info[class->adaptor_num].base_id, "XV_AUTOPAINT_COLORKEY",
+ "video.xv_autopaint_colorkey",
+ _("Make Xv autopaint it's colorket"));
} else if(!strcmp(attr[k].name, "XV_FILTER")) {
int xv_filter;
@@ -1266,7 +1231,10 @@ static void *init_video_out_plugin (xine_t *xine, void *visual_gen) {
printf("video_out_xv: no port attributes defined.\n");
}
- XvFreeAdaptorInfo (adaptor_info);
+ /*
+ * FIXME: move to class dispose
+ * XvFreeAdaptorInfo (class->adaptor_info);
+ */
/*
* check supported image formats
@@ -1311,6 +1279,84 @@ static void *init_video_out_plugin (xine_t *xine, void *visual_gen) {
return &this->vo_driver;
}
+static void *init_class (xine_t *xine, void *visual_gen) {
+
+ x11_visual_t *visual = (x11_visual_t *) visual_gen;
+ xv_class_t *this;
+ Display *display = NULL;
+ unsigned int adaptors, j;
+ unsigned int ver,rel,req,ev,err;
+ XvPortID xv_port;
+ XvAdaptorInfo *adaptor_info;
+ unsigned int adaptor_num;
+
+ display = visual->display;
+
+ /*
+ * check for Xvideo support
+ */
+
+ if (Success != XvQueryExtension(display,&ver,&rel,&req,&ev,&err)) {
+ printf ("video_out_xv: Xv extension not present.\n");
+ return NULL;
+ }
+
+ /*
+ * check adaptors, search for one that supports (at least) yuv12
+ */
+
+ if (Success != XvQueryAdaptors(display,DefaultRootWindow(display),
+ &adaptors,&adaptor_info)) {
+ printf("video_out_xv: XvQueryAdaptors failed.\n");
+ return NULL;
+ }
+
+ xv_port = 0;
+
+ for ( adaptor_num = 0; (adaptor_num < adaptors) && !xv_port; adaptor_num++ ) {
+
+ if (adaptor_info[adaptor_num].type & XvImageMask) {
+
+ for (j = 0; j < adaptor_info[adaptor_num].num_ports && !xv_port; j++)
+ if (( !(xv_check_yv12 (display,
+ adaptor_info[adaptor_num].base_id + j)))
+ && (XvGrabPort (display,
+ adaptor_info[adaptor_num].base_id + j,
+ 0) == Success)) {
+ xv_port = adaptor_info[adaptor_num].base_id + j;
+ }
+
+ if( xv_port )
+ break;
+ }
+ }
+
+ if (!xv_port) {
+ printf ("video_out_xv: Xv extension is present but "
+ "I couldn't find a usable yuv12 port.\n");
+ printf (" Looks like your graphics hardware "
+ "driver doesn't support Xv?!\n");
+ /* XvFreeAdaptorInfo (adaptor_info); this crashed on me (gb)*/
+ return NULL;
+ } else
+ printf ("video_out_xv: using Xv port %ld from adaptor %s for hardware "
+ "colorspace conversion and scaling.\n", xv_port,
+ adaptor_info[adaptor_num].name);
+
+
+ /*
+ * from this point on, nothing should go wrong anymore
+ */
+ this = (xv_class_t *) malloc (sizeof (xv_class_t));
+
+ this->config = xine->config;
+ this->xv_port = xv_port;
+ this->adaptor_info = adaptor_info;
+ this->adaptor_num = adaptor_num;
+
+ return this;
+}
+
static vo_info_t vo_info_xv = {
9, /* priority */
"xine video output plugin using the MIT X video extension", /* description */
@@ -1328,7 +1374,7 @@ vo_info_t *get_video_out_plugin_info() {
plugin_info_t xine_plugin_info[] = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_VIDEO_OUT, 9, "xv", XINE_VERSION_CODE, &vo_info_xv, init_video_out_plugin },
+ { PLUGIN_VIDEO_OUT, 10, "xv", XINE_VERSION_CODE, &vo_info_xv, init_class, open_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};