Index: libvo/Makefile.am
===================================================================
RCS file: /cvs/livid/mpeg2dec/libvo/Makefile.am,v
retrieving revision 1.11
diff -u -r1.11 Makefile.am
--- libvo/Makefile.am	2000/06/29 00:25:47	1.11
+++ libvo/Makefile.am	2000/07/22 22:02:18
@@ -19,7 +19,8 @@
 	video_out_mga.c\
 	video_out_x11.c\
 	video_out_3dfx.c\
-	video_out_sdl.c
+	video_out_sdl.c\
+	video_out_ggi.c
 
 EXTRA_libvo_la_SOURCES = yuv2rgb_mmx.c yuv2rgb_mlib.c
 
Index: libvo/configure.incl
===================================================================
RCS file: /cvs/livid/mpeg2dec/libvo/configure.incl,v
retrieving revision 1.3
diff -u -r1.3 configure.incl
--- libvo/configure.incl	2000/06/29 00:25:47	1.3
+++ libvo/configure.incl	2000/07/22 22:02:18
@@ -69,6 +69,13 @@
   fi
 fi
 
+AC_ARG_ENABLE(ggi, [  --enable-ggi            make a version using GGI],
+  enable_ggi=yes, enable_ggi=no)
+if test "x$enable_ggi" = xyes; then
+  AC_DEFINE(HAVE_GGI)
+  LIBVO_CONFIG_LIBS="$LIBVO_CONFIG_LIBS -lggi"
+fi
+
 dnl FIXME check for X actually existing
 AC_DEFINE(HAVE_X11)
 
Index: libvo/video_out.c
===================================================================
RCS file: /cvs/livid/mpeg2dec/libvo/video_out.c,v
retrieving revision 1.4
diff -u -r1.4 video_out.c
--- libvo/video_out.c	2000/06/18 22:31:22	1.4
+++ libvo/video_out.c	2000/07/22 22:02:18
@@ -33,6 +33,7 @@
 extern vo_functions_t video_out_mga;
 extern vo_functions_t video_out_x11;
 extern vo_functions_t video_out_sdl;
+extern vo_functions_t video_out_ggi;
 extern vo_functions_t video_out_3dfx;
 extern vo_functions_t video_out_null;
 
@@ -49,6 +50,9 @@
 #endif
 #ifdef HAVE_SDL
 	&video_out_sdl,
+#endif
+#ifdef HAVE_GGI
+	&video_out_ggi,
 #endif
 	&video_out_null,
 	NULL
--- /dev/null	Thu Jan  1 01:00:00 1970
+++ libvo/video_out_ggi.c	Sun Jul 23 02:06:30 2000
@@ -0,0 +1,241 @@
+/* 
+ *  video_out_ggi.c
+ *
+ *  Copyright 2000 Marcus Sundberg	[marcus@ggi-project.org]
+ *
+ *  This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
+ *	
+ *  mpeg2dec 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, or (at your option)
+ *  any later version.
+ *   
+ *  mpeg2dec 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 GNU Make; see the file COPYING.  If not, write to
+ *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
+ *
+ */
+
+#ifdef HAVE_GGI
+
+#include "config.h"
+#include "video_out.h"
+#include "video_out_internal.h"
+
+#include <ggi/ggi.h>
+#include "yuv2rgb.h"
+
+
+LIBVO_EXTERN(ggi)
+
+static vo_info_t vo_info = 
+{
+	"LibGGI video output",
+	"ggi",
+	"Marcus Sundberg <marcus@ggi-project.org>",
+	""
+};
+
+
+static ggi_visual_t vis = NULL;
+static ggi_mode mode;
+static int doublebuffer = 0;
+static const ggi_directbuffer *db[2] = { NULL, NULL };
+static int curdb = 0;
+static int pixelsize;
+static uint_32 image_width, image_height;
+
+
+static void
+ggi_cleanup(void)
+{
+	if (vis) {
+		ggiClose(vis);
+		vis = NULL;
+	}
+	ggiExit();
+}
+
+
+static int
+ggi_start(uint_32 width, uint_32 height, uint_32 fullscreen, char *title)
+{
+	if (ggiInit() < 0) {
+		fprintf(stderr, "GGI: Unable to initialize LibGGI.\n");
+		return -1;
+	}
+
+	vis = ggiOpen(NULL);
+	if (!vis) {
+		fprintf(stderr, "GGI: Unable to open default visual.\n");
+		ggiExit();
+		return -1;
+	}
+	ggiSetFlags(vis, GGIFLAG_ASYNC);
+
+	/* Get suitable mode */
+	if (ggiCheckSimpleMode(vis, width, height, 2, GT_16BIT, &mode) != 0) {
+		if (mode.visible.x >= width && mode.visible.y >= height
+		    && GT_SIZE(mode.graphtype) >= 16 &&
+		    GT_SCHEME(mode.graphtype) == GT_TRUECOLOR) {
+		} else {
+			fprintf(stderr, "GGI: Unable to find mode.\n");
+			ggi_cleanup();
+			return -1;
+		}
+	}
+
+	if (ggiSetMode(vis, &mode) != 0) {
+		fprintf(stderr, "GGI: Unable to set checked mode!?\n");
+		ggi_cleanup();
+		return -1;
+	}
+
+	if (mode.frames >= 2) {
+		doublebuffer = 1;
+	} else {
+		doublebuffer = 0;
+	}
+
+	db[0] = ggiDBGetBuffer(vis, 0);
+	db[1] = ggiDBGetBuffer(vis, 1);
+	if (db[0] == NULL || !(db[0]->type & GGI_DB_SIMPLE_PLB) ||
+	    (doublebuffer &&
+	     (db[1] == NULL || !(db[1]->type & GGI_DB_SIMPLE_PLB)))) {
+		fprintf(stderr, "GGI: Suitable DirectBuffer not available.\n");
+		ggi_cleanup();
+		return -1;
+	}
+
+	curdb = 0;
+
+	return 0;
+}
+
+
+static void 
+do_blit(uint_8 *src[], uint_32 slice_num, int lines)
+{
+	uint_8 *dst;
+	int stride;
+
+	if (ggiResourceAcquire(db[curdb]->resource, GGI_ACTYPE_WRITE) != 0) {
+		return;
+	}
+
+	stride = db[curdb]->buffer.plb.stride;
+	dst = db[curdb]->write;
+	dst += stride * lines * slice_num;
+	yuv2rgb(dst, src[0], src[1], src[2], image_width, lines, 
+		stride, image_width, image_width/2);
+	ggiResourceRelease(db[curdb]->resource);
+}
+
+
+static uint_32
+draw_slice(uint_8 *src[], uint_32 slice_num)
+{
+	do_blit(src, slice_num, 16);
+
+	return 0;
+}
+
+
+static uint_32
+draw_frame(uint_8 *src[])
+{
+	do_blit(src, 0, image_height);
+
+	return 0;
+}
+
+
+static void
+flip_page(void)
+{
+	struct timeval tv = { 0, 0 };
+
+	while (ggiEventPoll(vis, emKey, &tv)) {
+		ggi_event ev;
+
+		ggiEventRead(vis, &ev, emKey);
+		switch (ev.any.type) {
+		case evKeyPress:
+			if (ev.key.label == 'Q' ||
+			    ev.key.label == GIIUC_Escape) {
+				ggi_cleanup();
+				exit(0);
+			}
+			break;
+		default:
+			break;
+		}
+	}
+
+	if (doublebuffer) {
+		ggiSetDisplayFrame(vis, curdb);
+		curdb = (curdb + 1) & 1;
+		ggiSetWriteFrame(vis, curdb);
+	}
+
+	ggiFlush(vis);
+}
+
+
+static uint_32
+init(uint_32 width, uint_32 height, uint_32 fullscreen, char *title)
+{
+	static int started = 0;
+	int rgbtype;
+
+	if (started) {
+		fprintf(stderr, "GGI: Already running!\n");
+		exit(1);
+	}
+
+	if (ggi_start(width, height, fullscreen, title) != 0) {
+		return -1;
+	}
+
+	started = 1;
+
+	pixelsize = GT_SIZE(mode.graphtype);
+	image_height = height;
+	image_width = width;
+
+	if (pixelsize == 24) {
+		rgbtype = MODE_BGR;
+	} else {
+		rgbtype = MODE_RGB;
+	}
+
+	yuv2rgb_init(pixelsize, rgbtype);
+
+	return 0;
+}
+
+static const vo_info_t*
+get_info(void)
+{
+	return &vo_info;
+}
+
+static vo_image_buffer_t* 
+allocate_image_buffer(uint_32 height, uint_32 width, uint_32 format)
+{
+	//use the generic fallback
+	return allocate_image_buffer_common(height,width,format);
+}
+
+static void	
+free_image_buffer(vo_image_buffer_t* image)
+{
+	//use the generic fallback
+	free_image_buffer_common(image);
+}
+#endif /* HAVE_GGI */
