summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordurchflieger <durchflieger>2011-03-10 10:03:12 +0000
committerdurchflieger <durchflieger>2011-03-10 10:03:12 +0000
commita3edbb1371e6427d315b1b60564367d055c1ff1e (patch)
treea36855d165afba46423b7e92faefdcc0999ae42b
parentfb033e13236cabda753622bb232ab63a4981184f (diff)
downloadxineliboutput-a3edbb1371e6427d315b1b60564367d055c1ff1e.tar.gz
xineliboutput-a3edbb1371e6427d315b1b60564367d055c1ff1e.tar.bz2
Add support for new frame grabbing feature of xine-lib-1.2 with df-xine-lib-extensions patch >= v21.
Thanks to the new frame grab feature grabbing of color correct fully scaled RGB images is now supported for a wide range of output drivers like xv, vdpau and others replacing most of the grab implementation in xineliboutput. Support for the (older) vdpau-extensions-patch and xine-lib without extension patches is still retained.
-rw-r--r--xine/vo_hook.c10
-rw-r--r--xine_frontend.c50
2 files changed, 46 insertions, 14 deletions
diff --git a/xine/vo_hook.c b/xine/vo_hook.c
index 89190b9c..4dade7e2 100644
--- a/xine/vo_hook.c
+++ b/xine/vo_hook.c
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: vo_hook.c,v 1.5 2009-05-09 16:05:06 phintuka Exp $
+ * $Id: vo_hook.c,v 1.6 2011-03-10 10:03:11 durchflieger Exp $
*
*/
@@ -78,6 +78,9 @@ DEF_HANDLER2(int, set_property, int, int);
DEF_HANDLER3(void, get_property_min_max, int, int*, int*);
DEF_HANDLER2(int, gui_data_exchange, int, void * );
DEF_HANDLER0(int, redraw_needed );
+#ifdef HAVE_XINE_GRAB_VIDEO_FRAME
+DEF_HANDLER0(xine_grab_video_frame_t*, new_grab_video_frame );
+#endif
void vo_def_dispose(vo_driver_t *self)
{
@@ -107,6 +110,11 @@ static void vo_proxy_hooks_init(vo_driver_t *drv, vo_driver_t *next_driver)
drv->redraw_needed = drv->redraw_needed ?: vo_def_redraw_needed;
drv->dispose = drv->dispose ?: vo_def_dispose;
+#ifdef HAVE_XINE_GRAB_VIDEO_FRAME
+ if (!drv->new_grab_video_frame && next_driver->new_grab_video_frame)
+ drv->new_grab_video_frame = vo_def_new_grab_video_frame;
+#endif
+
/* drop old default handlers for OSD (OSD handlers are optional) */
if (drv->overlay_begin == vo_def_overlay_begin)
drv->overlay_begin = NULL;
diff --git a/xine_frontend.c b/xine_frontend.c
index 27d1af1d..376c101e 100644
--- a/xine_frontend.c
+++ b/xine_frontend.c
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: xine_frontend.c,v 1.118 2011-01-08 15:11:05 phintuka Exp $
+ * $Id: xine_frontend.c,v 1.119 2011-03-10 10:03:12 durchflieger Exp $
*
*/
@@ -1624,6 +1624,7 @@ static void *fe_control(frontend_t *this_gen, const char *cmd)
return NULL;
}
+
/*
* --- RgbToJpeg -------------------------------------------------------------
*
@@ -1680,6 +1681,8 @@ static void JpegCompressTermDestination(const j_compress_ptr cinfo)
}
}
+#ifndef HAVE_XINE_GRAB_VIDEO_FRAME
+
static vo_frame_t *yuy2_to_yv12_frame(xine_stream_t *stream, vo_frame_t *frame)
{
/* convert yuy12 frames to yv12 */
@@ -1810,9 +1813,10 @@ static char *frame_compress_jpeg(fe_t *this, int *size, int quality, vo_frame_t
*size = jcd.size;
return (char*) jcd.mem;
}
-
+#endif /* HAVE_XINE_GRAB_VIDEO_FRAME */
#endif /* HAVE_LIBJPEG */
+#ifndef HAVE_XINE_GRAB_VIDEO_FRAME
static vo_frame_t *yv12_to_yuy2_frame(xine_stream_t *stream, vo_frame_t *frame)
{
/* convert yv12 frames to yuy2 */
@@ -1895,15 +1899,15 @@ static char *frame_compress_pnm(fe_t *this, int *size, vo_frame_t *frame)
return (char*)pnm;
}
+#endif /* HAVE_XINE_GRAB_VIDEO_FRAME */
-#ifdef XINE_GUI_SEND_GRAB_FRAME
-static char *fe_grab_raw_frame(fe_t *this, int *size, int jpeg, int quality, int width, int height, xine_grab_frame_t *frame)
+#if defined(XINE_GUI_SEND_GRAB_FRAME) || defined(HAVE_XINE_GRAB_VIDEO_FRAME)
+#ifdef XINE_GUI_SEND_GRAB_FRAME
+static char *fe_compress_grab_frame(fe_t *this, int *size, int jpeg, int quality, int width, int height, xine_grab_frame_t *frame)
+#else
+static char *fe_compress_grab_frame(fe_t *this, int *size, int jpeg, int quality, int width, int height, xine_grab_video_frame_t *frame)
+#endif
{
- frame->width = width;
- frame->height = height;
- if (xine_port_send_gui_data(this->stream->video_out, XINE_GUI_SEND_GRAB_FRAME, frame))
- return NULL;
-
#ifdef HAVE_LIBJPEG
if (jpeg) {
/* Compress JPEG */
@@ -1963,13 +1967,13 @@ static char *fe_grab_raw_frame(fe_t *this, int *size, int jpeg, int quality, int
*size = bytes + hdrlen;
return (char*)pnm;
}
-#endif
+#endif /* defined(XINE_GUI_SEND_GRAB_FRAME) || defined(HAVE_XINE_GRAB_VIDEO_FRAME) */
+
static char *fe_grab(frontend_t *this_gen, int *size, int jpeg,
int quality, int width, int height)
{
fe_t *this = (fe_t*)this_gen;
- vo_frame_t *frame;
#ifndef HAVE_LIBJPEG
if(jpeg) {
@@ -1992,16 +1996,35 @@ static char *fe_grab(frontend_t *this_gen, int *size, int jpeg,
/* get last frame */
this->stream->xine->port_ticket->acquire(this->stream->xine->port_ticket, 0);
+
#ifdef XINE_GUI_SEND_GRAB_FRAME
xine_grab_frame_t *grab_frame;
if (!xine_port_send_gui_data(this->stream->video_out, XINE_GUI_SEND_ALLOC_GRAB_FRAME, &grab_frame)) {
- char *img = fe_grab_raw_frame(this, size, jpeg, quality, width, height, grab_frame);
+ grab_frame->width = width;
+ grab_frame->height = height;
+ char *img = NULL;
+ if (!xine_port_send_gui_data(this->stream->video_out, XINE_GUI_SEND_GRAB_FRAME, grab_frame))
+ img = fe_compress_grab_frame(this, size, jpeg, quality, width, height, grab_frame);
xine_port_send_gui_data(this->stream->video_out, XINE_GUI_SEND_FREE_GRAB_FRAME, grab_frame);
this->stream->xine->port_ticket->release(this->stream->xine->port_ticket, 0);
return img;
}
#endif
- frame = this->stream->video_out->get_last_frame (this->stream->video_out);
+
+#ifdef HAVE_XINE_GRAB_VIDEO_FRAME
+ char *img = NULL;
+ xine_grab_video_frame_t *grab_frame = xine_new_grab_video_frame(this->stream);
+ if (grab_frame) {
+ grab_frame->width = width;
+ grab_frame->height = height;
+ if (!grab_frame->grab(grab_frame))
+ img = fe_compress_grab_frame(this, size, jpeg, quality, width, height, grab_frame);
+ grab_frame->dispose(grab_frame);
+ }
+ this->stream->xine->port_ticket->release(this->stream->xine->port_ticket, 0);
+ return img;
+#else
+ vo_frame_t *frame = this->stream->video_out->get_last_frame (this->stream->video_out);
if(frame)
frame->lock(frame);
this->stream->xine->port_ticket->release(this->stream->xine->port_ticket, 0);
@@ -2025,6 +2048,7 @@ static char *fe_grab(frontend_t *this_gen, int *size, int jpeg,
#else /* HAVE_LIBJPEG */
return NULL;
#endif
+#endif /* HAVE_XINE_GRAB_VIDEO_FRAME */
}
/*