summaryrefslogtreecommitdiff
path: root/src/video_out
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_out')
-rw-r--r--src/video_out/Makefile.am10
-rw-r--r--src/video_out/video_out_fb.c10
-rw-r--r--src/video_out/video_out_opengl.c6
-rw-r--r--src/video_out/video_out_sdl.c15
-rw-r--r--src/video_out/video_out_syncfb.c11
-rw-r--r--src/video_out/video_out_vidix.c97
-rw-r--r--src/video_out/video_out_xshm.c124
-rw-r--r--src/video_out/video_out_xv.c91
-rw-r--r--src/video_out/video_out_xvmc.c11
-rw-r--r--src/video_out/x11osd.c375
-rw-r--r--src/video_out/x11osd.h20
11 files changed, 703 insertions, 67 deletions
diff --git a/src/video_out/Makefile.am b/src/video_out/Makefile.am
index 0f5936412..43489bf9c 100644
--- a/src/video_out/Makefile.am
+++ b/src/video_out/Makefile.am
@@ -17,6 +17,7 @@ libdir = $(XINE_PLUGINDIR)
if HAVE_X11
xshm_module = xineplug_vo_out_xshm.la
syncfb_module = xineplug_vo_out_syncfb.la
+X11OSD = x11osd.c
if HAVE_XV
xv_module = xineplug_vo_out_xv.la
endif
@@ -66,7 +67,8 @@ lib_LTLIBRARIES = $(xshm_module) $(xv_module) $(xvmc_module) $(aa_module) $(pgx6
$(vidix_module) $(fb_module) $(sdl_module) $(syncfb_module) \
$(stk_module) $(directfb_module) xineplug_vo_out_none.la
-xineplug_vo_out_xv_la_SOURCES = deinterlace.c alphablend.c video_out_xv.c
+xineplug_vo_out_xv_la_SOURCES = deinterlace.c alphablend.c video_out_xv.c \
+ $(X11OSD)
xineplug_vo_out_xv_la_LIBADD = \
$(XV_LIB) \
$(X_LIBS) \
@@ -84,7 +86,7 @@ xineplug_vo_out_xvmc_la_LIBADD = \
xineplug_vo_out_xvmc_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
xineplug_vo_out_xshm_la_SOURCES = yuv2rgb.c yuv2rgb_mmx.c yuv2rgb_mlib.c \
- alphablend.c video_out_xshm.c
+ alphablend.c video_out_xshm.c $(X11OSD)
xineplug_vo_out_xshm_la_LIBADD = $(MLIB_LIBS) $(X_LIBS) -lXext $(XINE_LIB)
xineplug_vo_out_xshm_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
@@ -115,7 +117,7 @@ xineplug_vo_out_sdl_la_SOURCES = alphablend.c video_out_sdl.c
xineplug_vo_out_sdl_la_LIBADD = $(SDL_LIBS) $(XINE_LIB)
xineplug_vo_out_sdl_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-xineplug_vo_out_vidix_la_SOURCES = alphablend.c video_out_vidix.c
+xineplug_vo_out_vidix_la_SOURCES = alphablend.c video_out_vidix.c $(X11OSD)
xineplug_vo_out_vidix_la_LIBADD = $(X_LIBS) \
$(top_builddir)/src/video_out/vidix/libvidix.la \
$(top_builddir)/src/video_out/libdha/libdha.la
@@ -133,4 +135,4 @@ xineplug_vo_out_stk_la_LIBADD = $(LIBSTK_LIBS)
xineplug_vo_out_stk_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
noinst_HEADERS = alphablend.h deinterlace.h video_out_syncfb.h \
- yuv2rgb.h video_out_win32.h
+ yuv2rgb.h video_out_win32.h x11osd.h
diff --git a/src/video_out/video_out_fb.c b/src/video_out/video_out_fb.c
index 0d7c8ff73..5fa3df6e6 100644
--- a/src/video_out/video_out_fb.c
+++ b/src/video_out/video_out_fb.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_fb.c,v 1.31 2003/11/11 18:45:00 f1rmb Exp $
+ * $Id: video_out_fb.c,v 1.32 2003/11/26 01:03:32 miguelfreitas Exp $
*
* video_out_fb.c, frame buffer xine driver by Miguel Freitas
*
@@ -617,8 +617,14 @@ static int fb_get_property(vo_driver_t *this_gen, int property)
return this->sc.user_ratio;
case VO_PROP_BRIGHTNESS:
- return this->yuv2rgb_gamma;
+ return this->yuv2rgb_gamma;
+ case VO_PROP_WINDOW_WIDTH:
+ return this->sc.gui_width;
+
+ case VO_PROP_WINDOW_HEIGHT:
+ return this->sc.gui_height;
+
default:
printf("video_out_fb: tried to get unsupported "
"property %d\n", property);
diff --git a/src/video_out/video_out_opengl.c b/src/video_out/video_out_opengl.c
index 42f4cc9e0..ffe00340d 100644
--- a/src/video_out/video_out_opengl.c
+++ b/src/video_out/video_out_opengl.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_opengl.c,v 1.31 2003/11/11 18:45:00 f1rmb Exp $
+ * $Id: video_out_opengl.c,v 1.32 2003/11/26 01:03:32 miguelfreitas Exp $
*
* video_out_glut.c, glut based OpenGL rendering interface for xine
* Matthias Hopf <mat@mshopf.de>
@@ -749,6 +749,10 @@ static int opengl_get_property (vo_driver_t *this_gen, int property) {
return this->sc.user_ratio ;
case VO_PROP_BRIGHTNESS:
return this->yuv2rgb_gamma;
+ case VO_PROP_WINDOW_WIDTH:
+ return this->sc.gui_width;
+ case VO_PROP_WINDOW_HEIGHT:
+ return this->sc.gui_height;
default:
printf ("video_out_opengl: tried to get unsupported property %d\n",
property);
diff --git a/src/video_out/video_out_sdl.c b/src/video_out/video_out_sdl.c
index 3711855d4..18c9c962d 100644
--- a/src/video_out/video_out_sdl.c
+++ b/src/video_out/video_out_sdl.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_sdl.c,v 1.31 2003/11/11 18:45:00 f1rmb Exp $
+ * $Id: video_out_sdl.c,v 1.32 2003/11/26 01:03:32 miguelfreitas Exp $
*
* video_out_sdl.c, Simple DirectMedia Layer
*
@@ -355,10 +355,15 @@ static void sdl_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) {
static int sdl_get_property (vo_driver_t *this_gen, int property) {
sdl_driver_t *this = (sdl_driver_t *) this_gen;
-
- if ( property == VO_PROP_ASPECT_RATIO)
- return this->sc.user_ratio ;
-
+
+ switch (property) {
+ case VO_PROP_WINDOW_WIDTH:
+ return this->sc.gui_width;
+ case VO_PROP_WINDOW_HEIGHT:
+ return this->sc.gui_height;
+ case VO_PROP_ASPECT_RATIO:
+ return this->sc.user_ratio;
+ }
return 0;
}
diff --git a/src/video_out/video_out_syncfb.c b/src/video_out/video_out_syncfb.c
index ea301fd99..4aa89fa69 100644
--- a/src/video_out/video_out_syncfb.c
+++ b/src/video_out/video_out_syncfb.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_syncfb.c,v 1.92 2003/11/11 18:45:00 f1rmb Exp $
+ * $Id: video_out_syncfb.c,v 1.93 2003/11/26 01:03:32 miguelfreitas Exp $
*
* video_out_syncfb.c, SyncFB (for Matrox G200/G400 cards) interface for xine
*
@@ -644,6 +644,15 @@ static int syncfb_get_property(vo_driver_t* this_gen, int property)
{
syncfb_driver_t* this = (syncfb_driver_t *) this_gen;
+ switch (property) {
+ case VO_PROP_WINDOW_WIDTH:
+ this->props[property].value = this->sc.gui_width;
+ break;
+ case VO_PROP_WINDOW_HEIGHT:
+ this->props[property].value = this->sc.gui_height;
+ break;
+ }
+
return this->props[property].value;
}
diff --git a/src/video_out/video_out_vidix.c b/src/video_out/video_out_vidix.c
index c6d32fa45..66bd8cf6d 100644
--- a/src/video_out/video_out_vidix.c
+++ b/src/video_out/video_out_vidix.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_vidix.c,v 1.51 2003/11/11 18:45:00 f1rmb Exp $
+ * $Id: video_out_vidix.c,v 1.52 2003/11/26 01:03:32 miguelfreitas Exp $
*
* video_out_vidix.c
*
@@ -58,6 +58,10 @@
#include "alphablend.h"
#include "xineutils.h"
#include "vo_scale.h"
+
+#ifdef HAVE_X11
+#include "x11osd.h"
+#endif
/*
#define LOG
@@ -122,6 +126,8 @@ struct vidix_driver_s {
int screen;
Drawable drawable;
GC gc;
+ x11osd *xoverlay;
+ int ovl_changed;
#endif
/* fb related stuff */
@@ -574,6 +580,34 @@ static void vidix_update_frame_format (vo_driver_t *this_gen,
frame->ratio = ratio;
}
+static void vidix_overlay_begin (vo_driver_t *this_gen,
+ vo_frame_t *frame_gen, int changed) {
+#ifdef HAVE_X11
+ vidix_driver_t *this = (vidix_driver_t *) this_gen;
+
+ this->ovl_changed = changed;
+
+ if( this->ovl_changed && this->xoverlay ) {
+ XLockDisplay (this->display);
+ x11osd_clear(this->xoverlay);
+ XUnlockDisplay (this->display);
+ }
+#endif
+}
+
+static void vidix_overlay_end (vo_driver_t *this_gen, vo_frame_t *vo_img) {
+#ifdef HAVE_X11
+ vidix_driver_t *this = (vidix_driver_t *) this_gen;
+
+ if( this->ovl_changed && this->xoverlay ) {
+ XLockDisplay (this->display);
+ x11osd_expose(this->xoverlay);
+ XUnlockDisplay (this->display);
+ }
+
+ this->ovl_changed = 0;
+#endif
+}
/*
*
@@ -581,12 +615,23 @@ static void vidix_update_frame_format (vo_driver_t *this_gen,
static void vidix_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_overlay_t *overlay) {
vidix_frame_t *frame = (vidix_frame_t *) frame_gen;
+ vidix_driver_t *this = (vidix_driver_t *) this_gen;
if (overlay->rle) {
- if( frame->format == XINE_IMGFMT_YV12 )
- blend_yuv( frame->vo_frame.base, overlay, frame->width, frame->height, frame->vo_frame.pitches);
- else
- blend_yuy2( frame->vo_frame.base[0], overlay, frame->width, frame->height, frame->vo_frame.pitches[0]);
+ if( overlay->unscaled ) {
+#ifdef HAVE_X11
+ if( this->ovl_changed && this->xoverlay ) {
+ XLockDisplay (this->display);
+ x11osd_blend(this->xoverlay, overlay);
+ XUnlockDisplay (this->display);
+ }
+#endif
+ } else {
+ if( frame->format == XINE_IMGFMT_YV12 )
+ blend_yuv( frame->vo_frame.base, overlay, frame->width, frame->height, frame->vo_frame.pitches);
+ else
+ blend_yuy2( frame->vo_frame.base[0], overlay, frame->width, frame->height, frame->vo_frame.pitches[0]);
+ }
}
}
@@ -658,6 +703,15 @@ static int vidix_get_property (vo_driver_t *this_gen, int property) {
vidix_driver_t *this = (vidix_driver_t *) this_gen;
+ switch (property) {
+ case VO_PROP_WINDOW_WIDTH:
+ this->props[property].value = this->sc.gui_width;
+ break;
+ case VO_PROP_WINDOW_HEIGHT:
+ this->props[property].value = this->sc.gui_height;
+ break;
+ }
+
#ifdef LOG
printf ("video_out_vidix: property #%d = %d\n", property,
this->props[property].value);
@@ -827,6 +881,8 @@ static int vidix_gui_data_exchange (vo_driver_t *this_gen,
XLockDisplay(this->display);
XFreeGC(this->display, this->gc);
this->gc = XCreateGC(this->display, this->drawable, 0, NULL);
+ if(this->xoverlay)
+ x11osd_drawable_changed(this->xoverlay, this->drawable);
XUnlockDisplay(this->display);
#endif
}
@@ -837,6 +893,14 @@ static int vidix_gui_data_exchange (vo_driver_t *this_gen,
printf ("video_out_vidix: GUI_DATA_EX_EXPOSE_EVENT\n");
#endif
vidix_clean_output_area(this);
+#ifdef HAVE_X11
+ XLockDisplay (this->display);
+ if(this->xoverlay)
+ x11osd_expose(this->xoverlay);
+
+ XSync(this->display, False);
+ XUnlockDisplay (this->display);
+#endif
break;
case XINE_GUI_SEND_TRANSLATE_GUI_TO_VIDEO:
@@ -871,6 +935,16 @@ static void vidix_exit (vo_driver_t *this_gen) {
vdlPlaybackOff(this->vidix_handler);
}
vdlClose(this->vidix_handler);
+
+#ifdef HAVE_X11
+ if( this->xoverlay ) {
+ XLockDisplay (this->display);
+ x11osd_destroy (this->xoverlay);
+ XUnlockDisplay (this->display);
+ }
+#endif
+
+ free (this);
}
static vidix_driver_t *open_plugin (video_driver_class_t *class_gen) {
@@ -975,9 +1049,9 @@ static vidix_driver_t *open_plugin (video_driver_class_t *class_gen) {
this->vo_driver.get_capabilities = vidix_get_capabilities;
this->vo_driver.alloc_frame = vidix_alloc_frame;
this->vo_driver.update_frame_format = vidix_update_frame_format;
- this->vo_driver.overlay_begin = NULL; /* not used */
+ this->vo_driver.overlay_begin = vidix_overlay_begin;
this->vo_driver.overlay_blend = vidix_overlay_blend;
- this->vo_driver.overlay_end = NULL; /* not used */
+ this->vo_driver.overlay_end = vidix_overlay_end;
this->vo_driver.display_frame = vidix_display_frame;
this->vo_driver.get_property = vidix_get_property;
this->vo_driver.set_property = vidix_set_property;
@@ -1079,6 +1153,8 @@ static vo_driver_t *vidix_open_plugin (video_driver_class_t *class_gen, const vo
this->screen = visual->screen;
this->drawable = visual->d;
this->gc = XCreateGC(this->display, this->drawable, 0, NULL);
+ this->xoverlay = NULL;
+ this->ovl_changed = 0;
XGetWindowAttributes(this->display, this->drawable, &window_attributes);
this->sc.gui_width = window_attributes.width;
@@ -1112,6 +1188,13 @@ static vo_driver_t *vidix_open_plugin (video_driver_class_t *class_gen, const vo
query_fourccs(this);
+ XLockDisplay (this->display);
+ this->xoverlay = x11osd_create (this->display, this->screen, this->drawable);
+ XUnlockDisplay (this->display);
+
+ if( this->xoverlay )
+ this->capabilities |= VO_CAP_UNSCALED_OVERLAY;
+
return &this->vo_driver;
}
diff --git a/src/video_out/video_out_xshm.c b/src/video_out/video_out_xshm.c
index 51193a0ef..5ec9b31aa 100644
--- a/src/video_out/video_out_xshm.c
+++ b/src/video_out/video_out_xshm.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_xshm.c,v 1.119 2003/11/11 18:45:00 f1rmb Exp $
+ * $Id: video_out_xshm.c,v 1.120 2003/11/26 01:03:32 miguelfreitas Exp $
*
* video_out_xshm.c, X11 shared memory extension interface for xine
*
@@ -59,6 +59,7 @@
#include "yuv2rgb.h"
#include "xineutils.h"
#include "vo_scale.h"
+#include "x11osd.h"
/*
#define LOG
@@ -110,7 +111,8 @@ typedef struct {
vo_scale_t sc;
xshm_frame_t *cur_frame;
- vo_overlay_t *overlay;
+ x11osd *xoverlay;
+ int ovl_changed;
int (*x11_old_error_handler) (Display *, XErrorEvent *);
@@ -303,7 +305,13 @@ static void dispose_ximage (xshm_driver_t *this,
*/
static uint32_t xshm_get_capabilities (vo_driver_t *this_gen) {
- return VO_CAP_YV12 | VO_CAP_YUY2;
+ xshm_driver_t *this = (xshm_driver_t *) this_gen;
+ uint32_t capabilities = VO_CAP_YV12 | VO_CAP_YUY2;
+
+ if( this->xoverlay )
+ capabilities |= VO_CAP_UNSCALED_OVERLAY;
+
+ return capabilities;
}
static void xshm_frame_proc_slice (vo_frame_t *vo_img, uint8_t **src) {
@@ -597,38 +605,71 @@ static void xshm_overlay_clut_yuv2rgb(xshm_driver_t *this, vo_overlay_t *overla
}
}
+static void xshm_overlay_begin (vo_driver_t *this_gen,
+ vo_frame_t *frame_gen, int changed) {
+ xshm_driver_t *this = (xshm_driver_t *) this_gen;
+
+ this->ovl_changed = changed;
+
+ if( this->ovl_changed && this->xoverlay ) {
+ XLockDisplay (this->display);
+ x11osd_clear(this->xoverlay);
+ XUnlockDisplay (this->display);
+ }
+}
+
+static void xshm_overlay_end (vo_driver_t *this_gen, vo_frame_t *vo_img) {
+ xshm_driver_t *this = (xshm_driver_t *) this_gen;
+
+ if( this->ovl_changed && this->xoverlay ) {
+ XLockDisplay (this->display);
+ x11osd_expose(this->xoverlay);
+ XUnlockDisplay (this->display);
+ }
+
+ this->ovl_changed = 0;
+}
+
static void xshm_overlay_blend (vo_driver_t *this_gen,
vo_frame_t *frame_gen, vo_overlay_t *overlay) {
xshm_driver_t *this = (xshm_driver_t *) this_gen;
xshm_frame_t *frame = (xshm_frame_t *) frame_gen;
/* Alpha Blend here */
- if (overlay->rle) {
- if (!overlay->rgb_clut || !overlay->clip_rgb_clut)
- xshm_overlay_clut_yuv2rgb (this, overlay, frame);
-
- switch (this->bpp) {
- case 16:
- blend_rgb16 ((uint8_t *)frame->image->data, overlay,
- frame->sc.output_width, frame->sc.output_height,
- frame->sc.delivered_width, frame->sc.delivered_height);
- break;
- case 24:
- blend_rgb24 ((uint8_t *)frame->image->data, overlay,
- frame->sc.output_width, frame->sc.output_height,
- frame->sc.delivered_width, frame->sc.delivered_height);
- break;
- case 32:
- blend_rgb32 ((uint8_t *)frame->image->data, overlay,
- frame->sc.output_width, frame->sc.output_height,
- frame->sc.delivered_width, frame->sc.delivered_height);
- break;
- default:
- printf("xine-lib:video_out_xshm:xshm_overlay_blend: Cannot blend bpp:%i\n", this->bpp);
+ if (overlay->rle) {
+ if( overlay->unscaled ) {
+ if( this->ovl_changed && this->xoverlay ) {
+ XLockDisplay (this->display);
+ x11osd_blend(this->xoverlay, overlay);
+ XUnlockDisplay (this->display);
+ }
+ } else {
+ if (!overlay->rgb_clut || !overlay->clip_rgb_clut)
+ xshm_overlay_clut_yuv2rgb (this, overlay, frame);
+
+ switch (this->bpp) {
+ case 16:
+ blend_rgb16 ((uint8_t *)frame->image->data, overlay,
+ frame->sc.output_width, frame->sc.output_height,
+ frame->sc.delivered_width, frame->sc.delivered_height);
+ break;
+ case 24:
+ blend_rgb24 ((uint8_t *)frame->image->data, overlay,
+ frame->sc.output_width, frame->sc.output_height,
+ frame->sc.delivered_width, frame->sc.delivered_height);
+ break;
+ case 32:
+ blend_rgb32 ((uint8_t *)frame->image->data, overlay,
+ frame->sc.output_width, frame->sc.output_height,
+ frame->sc.delivered_width, frame->sc.delivered_height);
+ break;
+ default:
+ printf("xine-lib:video_out_xshm:xshm_overlay_blend: Cannot blend bpp:%i\n", this->bpp);
/* it should never get here, unless a user tries to play in bpp:8 */
break;
- }
- }
+ }
+ }
+ }
}
static void clean_output_area (xshm_driver_t *this, xshm_frame_t *frame) {
@@ -742,6 +783,10 @@ static int xshm_get_property (vo_driver_t *this_gen, int property) {
return this->yuv2rgb_contrast;
case VO_PROP_SATURATION:
return this->yuv2rgb_saturation;
+ case VO_PROP_WINDOW_WIDTH:
+ return this->sc.gui_width;
+ case VO_PROP_WINDOW_HEIGHT:
+ return this->sc.gui_height;
default:
if (this->xine->verbosity >= XINE_VERBOSITY_LOG) {
printf ("video_out_xshm: tried to get unsupported property %d\n",
@@ -866,6 +911,9 @@ static int xshm_gui_data_exchange (vo_driver_t *this_gen,
this->sc.border[i].w, this->sc.border[i].h);
}
+ if(this->xoverlay)
+ x11osd_expose(this->xoverlay);
+
XSync(this->display, False);
XUnlockDisplay (this->display);
}
@@ -878,6 +926,8 @@ static int xshm_gui_data_exchange (vo_driver_t *this_gen,
XLockDisplay (this->display);
XFreeGC(this->display, this->gc);
this->gc = XCreateGC (this->display, this->drawable, 0, NULL);
+ if(this->xoverlay)
+ x11osd_drawable_changed(this->xoverlay, this->drawable);
XUnlockDisplay (this->display);
break;
@@ -915,6 +965,12 @@ static void xshm_dispose (vo_driver_t *this_gen) {
this->yuv2rgb_factory->dispose (this->yuv2rgb_factory);
+ if( this->xoverlay ) {
+ XLockDisplay (this->display);
+ x11osd_destroy (this->xoverlay);
+ XUnlockDisplay (this->display);
+ }
+
free (this);
}
@@ -1018,16 +1074,18 @@ static vo_driver_t *xshm_open_plugin (video_driver_class_t *class_gen, const voi
XLockDisplay(this->display);
this->gc = XCreateGC (this->display, this->drawable, 0, NULL);
XUnlockDisplay(this->display);
-
+ this->xoverlay = NULL;
+ this->ovl_changed = 0;
+
this->x11_old_error_handler = NULL;
this->xine = class->xine;
this->vo_driver.get_capabilities = xshm_get_capabilities;
this->vo_driver.alloc_frame = xshm_alloc_frame;
this->vo_driver.update_frame_format = xshm_update_frame_format;
- this->vo_driver.overlay_begin = NULL; /* not used */
+ this->vo_driver.overlay_begin = xshm_overlay_begin;
this->vo_driver.overlay_blend = xshm_overlay_blend;
- this->vo_driver.overlay_end = NULL; /* not used */
+ this->vo_driver.overlay_end = xshm_overlay_end;
this->vo_driver.display_frame = xshm_display_frame;
this->vo_driver.get_property = xshm_get_property;
this->vo_driver.set_property = xshm_set_property;
@@ -1177,7 +1235,11 @@ static vo_driver_t *xshm_open_plugin (video_driver_class_t *class_gen, const voi
this->yuv2rgb_brightness,
this->yuv2rgb_contrast,
this->yuv2rgb_saturation);
-
+
+ XLockDisplay (this->display);
+ this->xoverlay = x11osd_create (this->display, this->screen, this->drawable);
+ XUnlockDisplay (this->display);
+
return &this->vo_driver;
}
diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c
index 5c35d77be..cdb102b26 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.181 2003/11/11 18:45:00 f1rmb Exp $
+ * $Id: video_out_xv.c,v 1.182 2003/11/26 01:03:32 miguelfreitas Exp $
*
* video_out_xv.c, X11 video extension interface for xine
*
@@ -29,6 +29,7 @@
* xine-specific code by Guenter Bartsch <bartscgr@studbox.uni-stuttgart.de>
*
* overlay support by James Courtier-Dutton <James@superbug.demon.co.uk> - July 2001
+ * X11 unscaled overlay support by Miguel Freitas - Nov 2003
*/
#ifdef HAVE_CONFIG_H
@@ -71,6 +72,7 @@
#include "deinterlace.h"
#include "xineutils.h"
#include "vo_scale.h"
+#include "x11osd.h"
/*
#define LOG
@@ -126,7 +128,8 @@ struct xv_driver_s {
xv_frame_t *recent_frames[VO_NUM_RECENT_FRAMES];
xv_frame_t *cur_frame;
- vo_overlay_t *overlay;
+ x11osd *xoverlay;
+ int ovl_changed;
/* all scaling information goes here */
vo_scale_t sc;
@@ -607,21 +610,51 @@ static void xv_compute_output_size (xv_driver_t *this) {
}
}
+static void xv_overlay_begin (vo_driver_t *this_gen,
+ vo_frame_t *frame_gen, int changed) {
+ xv_driver_t *this = (xv_driver_t *) this_gen;
+
+ this->ovl_changed = changed;
+
+ if( this->ovl_changed && this->xoverlay ) {
+ XLockDisplay (this->display);
+ x11osd_clear(this->xoverlay);
+ XUnlockDisplay (this->display);
+ }
+}
+
+static void xv_overlay_end (vo_driver_t *this_gen, vo_frame_t *vo_img) {
+ xv_driver_t *this = (xv_driver_t *) this_gen;
+
+ if( this->ovl_changed && this->xoverlay ) {
+ XLockDisplay (this->display);
+ x11osd_expose(this->xoverlay);
+ XUnlockDisplay (this->display);
+ }
+
+ this->ovl_changed = 0;
+}
+
static void xv_overlay_blend (vo_driver_t *this_gen,
vo_frame_t *frame_gen, vo_overlay_t *overlay) {
+ xv_driver_t *this = (xv_driver_t *) this_gen;
xv_frame_t *frame = (xv_frame_t *) frame_gen;
- /* Alpha Blend here
- * As XV drivers improve to support Hardware overlay, we will change this function.
- */
-
if (overlay->rle) {
- if (frame->format == XINE_IMGFMT_YV12)
- blend_yuv(frame->vo_frame.base, overlay,
- frame->width, frame->height, frame->vo_frame.pitches);
- else
- blend_yuy2(frame->vo_frame.base[0], overlay,
- frame->width, frame->height, frame->vo_frame.pitches[0]);
+ if( overlay->unscaled ) {
+ if( this->ovl_changed && this->xoverlay ) {
+ XLockDisplay (this->display);
+ x11osd_blend(this->xoverlay, overlay);
+ XUnlockDisplay (this->display);
+ }
+ } else {
+ if (frame->format == XINE_IMGFMT_YV12)
+ blend_yuv(frame->vo_frame.base, overlay,
+ frame->width, frame->height, frame->vo_frame.pitches);
+ else
+ blend_yuy2(frame->vo_frame.base[0], overlay,
+ frame->width, frame->height, frame->vo_frame.pitches[0]);
+ }
}
}
@@ -756,6 +789,15 @@ static void xv_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) {
static int xv_get_property (vo_driver_t *this_gen, int property) {
xv_driver_t *this = (xv_driver_t *) this_gen;
+ switch (property) {
+ case VO_PROP_WINDOW_WIDTH:
+ this->props[property].value = this->sc.gui_width;
+ break;
+ case VO_PROP_WINDOW_HEIGHT:
+ this->props[property].value = this->sc.gui_height;
+ break;
+ }
+
if (this->xine->verbosity >= XINE_VERBOSITY_LOG)
printf ("video_out_xv: property #%d = %d\n", property,
this->props[property].value);
@@ -915,6 +957,9 @@ static int xv_gui_data_exchange (vo_driver_t *this_gen,
this->sc.border[i].w, this->sc.border[i].h);
}
+ if(this->xoverlay)
+ x11osd_expose(this->xoverlay);
+
XSync(this->display, False);
XUnlockDisplay (this->display);
}
@@ -927,6 +972,8 @@ static int xv_gui_data_exchange (vo_driver_t *this_gen,
XLockDisplay (this->display);
XFreeGC(this->display, this->gc);
this->gc = XCreateGC (this->display, this->drawable, 0, NULL);
+ if(this->xoverlay)
+ x11osd_drawable_changed(this->xoverlay, this->drawable);
XUnlockDisplay (this->display);
this->sc.force_redraw = 1;
break;
@@ -988,6 +1035,12 @@ static void xv_dispose (vo_driver_t *this_gen) {
this->recent_frames[i] = NULL;
}
+ if( this->xoverlay ) {
+ XLockDisplay (this->display);
+ x11osd_destroy (this->xoverlay);
+ XUnlockDisplay (this->display);
+ }
+
free (this);
}
@@ -1143,7 +1196,6 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi
memset (this, 0, sizeof(xv_driver_t));
this->display = visual->display;
- this->overlay = NULL;
this->screen = visual->screen;
this->xv_port = class->xv_port;
this->config = config;
@@ -1162,6 +1214,8 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi
this->deinterlace_frame.image = NULL;
this->use_colorkey = 0;
this->colorkey = 0;
+ this->xoverlay = NULL;
+ this->ovl_changed = 0;
this->x11_old_error_handler = NULL;
this->xine = class->xine;
@@ -1174,9 +1228,9 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi
this->vo_driver.get_capabilities = xv_get_capabilities;
this->vo_driver.alloc_frame = xv_alloc_frame;
this->vo_driver.update_frame_format = xv_update_frame_format;
- this->vo_driver.overlay_begin = NULL; /* not used */
+ this->vo_driver.overlay_begin = xv_overlay_begin;
this->vo_driver.overlay_blend = xv_overlay_blend;
- this->vo_driver.overlay_end = NULL; /* not used */
+ this->vo_driver.overlay_end = xv_overlay_end;
this->vo_driver.display_frame = xv_display_frame;
this->vo_driver.get_property = xv_get_property;
this->vo_driver.set_property = xv_set_property;
@@ -1322,6 +1376,13 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi
NULL, 10, xv_update_deinterlace, this);
this->deinterlace_enabled = 0;
+ XLockDisplay (this->display);
+ this->xoverlay = x11osd_create (this->display, this->screen, this->drawable);
+ XUnlockDisplay (this->display);
+
+ if( this->xoverlay )
+ this->capabilities |= VO_CAP_UNSCALED_OVERLAY;
+
return &this->vo_driver;
}
diff --git a/src/video_out/video_out_xvmc.c b/src/video_out/video_out_xvmc.c
index 91f90530d..547cf5804 100644
--- a/src/video_out/video_out_xvmc.c
+++ b/src/video_out/video_out_xvmc.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_xvmc.c,v 1.7 2003/11/11 18:45:00 f1rmb Exp $
+ * $Id: video_out_xvmc.c,v 1.8 2003/11/26 01:03:32 miguelfreitas Exp $
*
* video_out_xvmc.c, X11 video motion compensation extension interface for xine
*
@@ -1023,6 +1023,15 @@ static int xvmc_get_property (vo_driver_t *this_gen, int property) {
lprintf ("video_out_xvmc: xvmc_get_property\n");
+ switch (property) {
+ case VO_PROP_WINDOW_WIDTH:
+ this->props[property].value = this->sc.gui_width;
+ break;
+ case VO_PROP_WINDOW_HEIGHT:
+ this->props[property].value = this->sc.gui_height;
+ break;
+ }
+
return this->props[property].value;
}
diff --git a/src/video_out/x11osd.c b/src/video_out/x11osd.c
new file mode 100644
index 000000000..c94f2bd26
--- /dev/null
+++ b/src/video_out/x11osd.c
@@ -0,0 +1,375 @@
+/*
+ * Copyright (C) 2003 the xine project
+ *
+ * This file is part of xine, a free video player.
+ *
+ * xine is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * xine is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * $Id: x11osd.c,v 1.1 2003/11/26 01:03:32 miguelfreitas Exp $
+ *
+ * x11osd.c, use X11 Nonrectangular Window Shape Extension to draw xine OSD
+ *
+ * Nov 2003 - Miguel Freitas
+ *
+ * based on ideas and code of
+ * xosd Copyright (c) 2000 Andre Renaud (andre@ignavus.net)
+ */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <signal.h>
+#include <time.h>
+
+#include <assert.h>
+
+#include <netinet/in.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/shape.h>
+#include <X11/Xatom.h>
+
+#include "xine_internal.h"
+#include "alphablend.h"
+#include "x11osd.h"
+
+struct x11osd
+{
+ Display *display;
+ int screen;
+ Window window;
+ Window parent_window;
+ unsigned int depth;
+ Pixmap mask_bitmap;
+ Pixmap bitmap;
+ Visual *visual;
+ Colormap cmap;
+
+ GC gc;
+ GC mask_gc;
+ GC mask_gc_back;
+
+ int width;
+ int height;
+ int x;
+ int y;
+ int clean;
+ int mapped;
+};
+
+
+void
+x11osd_expose (x11osd * osd)
+{
+ assert (osd);
+
+ if( !osd->clean ) {
+
+ XShapeCombineMask (osd->display, osd->window, ShapeBounding, 0, 0,
+ osd->mask_bitmap, ShapeSet);
+
+ if( !osd->mapped )
+ XMapRaised (osd->display, osd->window);
+ osd->mapped = 1;
+
+ XCopyArea (osd->display, osd->bitmap, osd->window, osd->gc, 0, 0,
+ osd->width, osd->height, 0, 0);
+ } else {
+ if( osd->mapped )
+ XUnmapWindow (osd->display, osd->window);
+ osd->mapped = 0;
+ }
+}
+
+
+void
+x11osd_resize (x11osd * osd, int width, int height)
+{
+ assert (osd);
+ osd->width = width;
+ osd->height = height;
+
+ XResizeWindow (osd->display, osd->window, osd->width, osd->height);
+ XFreePixmap (osd->display, osd->mask_bitmap);
+ osd->mask_bitmap =
+ XCreatePixmap (osd->display, osd->window, osd->width, osd->height,
+ 1);
+ XFillRectangle (osd->display, osd->mask_bitmap, osd->mask_gc_back,
+ 0, 0, osd->width, osd->height);
+
+ XFreePixmap (osd->display, osd->bitmap);
+ osd->bitmap =
+ XCreatePixmap (osd->display, osd->window, osd->width,
+ osd->height, osd->depth);
+}
+
+void
+x11osd_drawable_changed (x11osd * osd, Window window)
+{
+ assert (osd);
+
+/*
+ Do I need to recreate the GC's??
+
+ XFreeGC (osd->display, osd->gc);
+ XFreeGC (osd->display, osd->mask_gc);
+ XFreeGC (osd->display, osd->mask_gc_back);
+*/
+ XFreePixmap (osd->display, osd->bitmap);
+ XFreePixmap (osd->display, osd->mask_bitmap);
+ XFreeColormap (osd->display, osd->cmap);
+ XDestroyWindow (osd->display, osd->window);
+
+
+ osd->parent_window = window;
+ osd->window = XCreateSimpleWindow (osd->display,
+ osd->parent_window,
+ 0, 0,
+ osd->width, osd->height, 1,
+ BlackPixel (osd->display, osd->screen),
+ BlackPixel (osd->display, osd->screen));
+
+ osd->mask_bitmap =
+ XCreatePixmap (osd->display, osd->window, osd->width, osd->height,
+ 1);
+ XFillRectangle (osd->display, osd->mask_bitmap, osd->mask_gc_back,
+ 0, 0, osd->width, osd->height);
+
+ osd->bitmap =
+ XCreatePixmap (osd->display, osd->window, osd->width,
+ osd->height, osd->depth);
+
+ osd->cmap = XCreateColormap(osd->display, osd->window,
+ osd->visual, AllocNone);
+
+ XSelectInput (osd->display, osd->window, ExposureMask);
+}
+
+
+x11osd *
+x11osd_create (Display *display, int screen, Window window)
+{
+ x11osd *osd;
+ int event_basep, error_basep;
+
+ osd = malloc (sizeof (x11osd));
+ memset (osd, 0, sizeof (x11osd));
+ if (osd == NULL)
+ return NULL;
+
+ osd->display = display;
+ osd->screen = screen;
+ osd->parent_window = window;
+
+ if (!XShapeQueryExtension (osd->display, &event_basep, &error_basep))
+ goto error2;
+
+ osd->visual = DefaultVisual (osd->display, osd->screen);
+ osd->depth = DefaultDepth (osd->display, osd->screen);
+ osd->width = XDisplayWidth (osd->display, osd->screen);
+ osd->height = XDisplayHeight (osd->display, osd->screen);
+
+ osd->window = XCreateSimpleWindow (osd->display,
+ osd->parent_window,
+ 0, 0,
+ osd->width, osd->height, 1,
+ BlackPixel (osd->display, osd->screen),
+ BlackPixel (osd->display, osd->screen));
+
+ osd->mask_bitmap =
+ XCreatePixmap (osd->display, osd->window, osd->width, osd->height,
+ 1);
+ osd->bitmap =
+ XCreatePixmap (osd->display, osd->window, osd->width,
+ osd->height, osd->depth);
+
+ osd->gc = XCreateGC (osd->display, osd->window, 0, NULL);
+ osd->mask_gc = XCreateGC (osd->display, osd->mask_bitmap, 0, NULL);
+ osd->mask_gc_back = XCreateGC (osd->display, osd->mask_bitmap, 0, NULL);
+
+ XSetForeground (osd->display, osd->mask_gc_back,
+ BlackPixel (osd->display, osd->screen));
+ XSetBackground (osd->display, osd->mask_gc_back,
+ WhitePixel (osd->display, osd->screen));
+
+ XSetForeground (osd->display, osd->mask_gc,
+ WhitePixel (osd->display, osd->screen));
+ XSetBackground (osd->display, osd->mask_gc,
+ BlackPixel (osd->display, osd->screen));
+
+ osd->cmap = XCreateColormap(osd->display, osd->window,
+ osd->visual, AllocNone);
+
+ XSelectInput (osd->display, osd->window, ExposureMask);
+
+ osd->clean = 0;
+ x11osd_clear(osd);
+ osd->mapped = 0;
+ x11osd_expose(osd);
+
+ return osd;
+
+/*
+error3:
+ XFreeGC (osd->display, osd->gc);
+ XFreeGC (osd->display, osd->mask_gc);
+ XFreeGC (osd->display, osd->mask_gc_back);
+ XFreePixmap (osd->display, osd->bitmap);
+ XFreePixmap (osd->display, osd->mask_bitmap);
+ XDestroyWindow (osd->display, osd->window);
+*/
+error2:
+ free (osd);
+ return NULL;
+}
+
+void
+x11osd_destroy (x11osd * osd)
+{
+
+ assert (osd);
+
+ XFreeGC (osd->display, osd->gc);
+ XFreeGC (osd->display, osd->mask_gc);
+ XFreeGC (osd->display, osd->mask_gc_back);
+ XFreePixmap (osd->display, osd->bitmap);
+ XFreePixmap (osd->display, osd->mask_bitmap);
+ XFreeColormap (osd->display, osd->cmap);
+ XDestroyWindow (osd->display, osd->window);
+
+ free (osd);
+}
+
+void x11osd_clear(x11osd *osd)
+{
+ if( !osd->clean )
+ XFillRectangle (osd->display, osd->mask_bitmap, osd->mask_gc_back,
+ 0, 0, osd->width, osd->height);
+ osd->clean = 1;
+}
+
+#define TRANSPARENT 0xffffffff
+
+#define saturate(n, l, u) ((n) < (l) ? (l) : ((n) > (u) ? (u) : (n)))
+
+void x11osd_blend(x11osd *osd, vo_overlay_t *overlay)
+{
+ if (overlay->rle) {
+ int i, x, y, len, width;
+ int use_clip_palette, max_palette_colour[2];
+ uint32_t palette[2][OVL_PALETTE_SIZE];
+
+ max_palette_colour[0] = -1;
+ max_palette_colour[1] = -1;
+
+ for (i=0, x=0, y=0; i<overlay->num_rle; i++) {
+ len = overlay->rle[i].len;
+
+ while (len > 0) {
+ use_clip_palette = 0;
+ if (len > overlay->width) {
+ width = overlay->width;
+ len -= overlay->width;
+ }
+ else {
+ width = len;
+ len = 0;
+ }
+ if ((y >= overlay->clip_top) && (y <= overlay->clip_bottom) && (x <= overlay->clip_right)) {
+ if ((x < overlay->clip_left) && (x + width - 1 >= overlay->clip_left)) {
+ width -= overlay->clip_left - x;
+ len += overlay->clip_left - x;
+ }
+ else if (x > overlay->clip_left) {
+ use_clip_palette = 1;
+ if (x + width - 1 > overlay->clip_right) {
+ width -= overlay->clip_right - x;
+ len += overlay->clip_right - x;
+ }
+ }
+ }
+
+ if (overlay->rle[i].color > max_palette_colour[use_clip_palette]) {
+ int j;
+ clut_t *src_clut;
+ uint8_t *src_trans;
+
+ if (use_clip_palette) {
+ src_clut = (clut_t *)&overlay->clip_color;
+ src_trans = (uint8_t *)&overlay->clip_trans;
+ }
+ else {
+ src_clut = (clut_t *)&overlay->color;
+ src_trans = (uint8_t *)&overlay->trans;
+ }
+ for (j=max_palette_colour[use_clip_palette]+1; j<=overlay->rle[i].color; j++) {
+ if (src_trans[j]) {
+ if (1) {
+ XColor xcolor;
+ int y, u, v, r, g, b;
+
+ y = saturate(src_clut[j].y, 16, 235);
+ u = saturate(src_clut[j].cb, 16, 240);
+ v = saturate(src_clut[j].cr, 16, 240);
+ y = (9 * y) / 8;
+ r = y + (25 * v) / 16 - 218;
+ xcolor.red = (65536 * saturate(r, 0, 255)) / 256;
+ g = y + (-13 * v) / 16 + (-25 * u) / 64 + 136;
+ xcolor.green = (65536 * saturate(g, 0, 255)) / 256;
+ b = y + 2 * u - 274;
+ xcolor.blue = (65536 * saturate(b, 0, 255)) / 256;
+
+ xcolor.flags = DoRed | DoBlue | DoGreen;
+
+ XAllocColor(osd->display, osd->cmap, &xcolor);
+
+ palette[use_clip_palette][j] = xcolor.pixel;
+ }
+ else {
+ if (src_clut[j].y > 127) {
+ palette[use_clip_palette][j] = WhitePixel(osd->display, osd->screen);
+ }
+ else {
+ palette[use_clip_palette][j] = BlackPixel(osd->display, osd->screen);
+ }
+ }
+ }
+ else {
+ palette[use_clip_palette][j] = TRANSPARENT;
+ }
+ }
+ max_palette_colour[use_clip_palette] = overlay->rle[i].color;
+ }
+
+ if(palette[use_clip_palette][overlay->rle[i].color] != TRANSPARENT) {
+ XSetForeground(osd->display, osd->gc, palette[use_clip_palette][overlay->rle[i].color]);
+ XFillRectangle(osd->display, osd->bitmap, osd->gc, overlay->x + x, overlay->y + y, width, 1);
+ XFillRectangle(osd->display, osd->mask_bitmap, osd->mask_gc, overlay->x + x, overlay->y + y, width, 1);
+ }
+
+ x += width;
+ if (x == overlay->width) {
+ x = 0;
+ y++;
+ }
+ }
+ }
+ }
+ osd->clean = 0;
+}
+
diff --git a/src/video_out/x11osd.h b/src/video_out/x11osd.h
new file mode 100644
index 000000000..3d74df780
--- /dev/null
+++ b/src/video_out/x11osd.h
@@ -0,0 +1,20 @@
+#ifndef X11OSD_H
+#define X11OSD_H
+
+ typedef struct x11osd x11osd;
+
+ x11osd *x11osd_create (Display *display, int screen, Window window);
+
+ void x11osd_destroy (x11osd * osd);
+
+ void x11osd_expose (x11osd * osd);
+
+ void x11osd_resize (x11osd * osd, int width, int height);
+
+ void x11osd_drawable_changed (x11osd * osd, Window window);
+
+ void x11osd_clear(x11osd *osd);
+
+ void x11osd_blend(x11osd *osd, vo_overlay_t *overlay);
+
+#endif