Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[livid-dev] porting mpeg2dec to microwindow( playing video on frame buffer)



    [ The following text is in the "big5" character set. ]
    [ Your display is set for the "ISO-8859-1" character set.  ]
    [ Some characters may be displayed incorrectly. ]

Hi all,

We checked out the mpeg2dec module on  0112/2001 and we addeded a file
in ./libvo
called video_out_nanox.c and modified the associated Makefile.
            ^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^
By  doing this,  we can play mpeg2 file ( or .vob) under frame buffer
device.
Our environment is based on nano-X under microwindows which is an Open
Source project aimed at bringingthe features of modern graphical
windowing environments to smaller devices.

The detail about nano-X can be viewed in http://microwindows.org

We done in the following step :
    1. under nano-x server
    2. with the attached file (diff_video_out )

Hope everyone enjoy it  and  oms/omi can also show DVD image on frame
buffer  in the futurefile.  :->

    [ Part 2: "Attached Text" ]

    [ The following text is in the "big5" character set. ]
    [ Your display is set for the "ISO-8859-1" character set.  ]
    [ Some characters may be displayed incorrectly. ]

diff -urN mpeg2dec_offical/include/config.h mpeg2dec_nanox/include/config.h
--- mpeg2dec_offical/include/config.h	Wed Jan 17 10:16:42 2001
+++ mpeg2dec_nanox/include/config.h	Wed Jan 17 10:38:13 2001
@@ -32,6 +32,9 @@
 /* libvo NANOX support */
 #define LIBVO_NANOX
 
+/* libvo X11 support */
+//#define LIBVO_X11 
+
 /* libvo SDL support */
 //#define LIBVO_SDL 
 
diff -urN mpeg2dec_offical/libvo/.deps/video_out_nanox.P mpeg2dec_nanox/libvo/.deps/video_out_nanox.P
--- mpeg2dec_offical/libvo/.deps/video_out_nanox.P	Mon Jan 15 20:06:13 2001
+++ mpeg2dec_nanox/libvo/.deps/video_out_nanox.P	Wed Jan 17 10:38:30 2001
@@ -18,7 +18,8 @@
  /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/fcntl.h \
  /usr/include/bits/fcntl.h /usr/include/unistd.h \
  /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \
- /usr/include/getopt.h nano-X.h mwtypes.h ../include/video_out.h \
+ /usr/include/getopt.h /usr/include/microwin/nano-X.h \
+ /usr/include/microwin/mwtypes.h ../include/video_out.h \
  video_out_internal.h yuv2rgb.h
 video_out_nanox.c :
 ../include/config.h :
@@ -61,8 +62,8 @@
 /usr/include/bits/posix_opt.h :
 /usr/include/bits/confname.h :
 /usr/include/getopt.h :
-nano-X.h :
-mwtypes.h :
+/usr/include/microwin/nano-X.h :
+/usr/include/microwin/mwtypes.h :
 ../include/video_out.h :
 video_out_internal.h :
 yuv2rgb.h :
diff -urN mpeg2dec_offical/libvo/Makefile mpeg2dec_nanox/libvo/Makefile
--- mpeg2dec_offical/libvo/Makefile	Wed Jan 17 10:14:17 2001
+++ mpeg2dec_nanox/libvo/Makefile	Mon Jan 15 19:49:27 2001
@@ -62,7 +62,7 @@
 AS = @AS@
 CC = gcc
 DLLTOOL = @DLLTOOL@
-INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include
+INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include 
 LIBTOOL = $(SHELL) $(top_builddir)/libtool
 LN_S = ln -s
 MAINT = #
@@ -72,14 +72,16 @@
 RANLIB = ranlib
 VERSION = 0.1.8-cvs
 
-CFLAGS = -g  -Wall -Werror -O3 -fomit-frame-pointer -mcpu=pentiumpro   -I/usr/X11R6/include
+CFLAGS = -g  -Wall -Werror -O3 -fomit-frame-pointer -mcpu=pentiumpro   -I/usr/X11R6/include -I/usr/local/include -I/usr/local/include/SDL -D_REENTRANT
 
 noinst_LTLIBRARIES = libvo.la
-libvo_la_SOURCES = video_out.c video_out_x11.c video_out_sdl.c 		   video_out_null.c video_out_pgm.c video_out_md5.c 		   yuv2rgb.c yuv2rgb_mlib.c yuv2rgb_mmx.c
+libvo_la_SOURCES = video_out.c video_out_nanox.c yuv2rgb.c yuv2rgb_mlib.c yuv2rgb_mmx.c \
+			video_out_x11.c video_out_null.c video_out_pgm.c video_out_md5.c
 
-libvo_la_LIBADD =   -lSM -lICE  -L/usr/X11R6/lib -lX11  -lXext
+libvo_la_LIBADD =  -lnano-X -L/usr/local/lib -Wl,-rpath,/usr/local/lib -lpthread \
+		-lSM -lICE  -L/usr/X11R6/lib -lX11  -lXext
 
-EXTRA_DIST = configure.incl video_out_internal.h yuv2rgb.h yuv2rgb_mmx.h
+EXTRA_DIST = configure.incl video_out_internal.h yuv2rgb.h yuv2rgb_mmx.h log.h
 mkinstalldirs = $(SHELL) $(top_srcdir)/autotools/mkinstalldirs
 CONFIG_HEADER = ../include/config.h
 CONFIG_CLEAN_FILES = 
@@ -92,9 +94,10 @@
 LIBS = 
 libvo_la_LDFLAGS = 
 libvo_la_DEPENDENCIES = 
-libvo_la_OBJECTS =  video_out.lo video_out_x11.lo video_out_sdl.lo \
-video_out_null.lo video_out_pgm.lo video_out_md5.lo yuv2rgb.lo \
-yuv2rgb_mlib.lo yuv2rgb_mmx.lo
+
+libvo_la_OBJECTS =  video_out.lo video_out_nanox.lo yuv2rgb.lo yuv2rgb_mlib.lo yuv2rgb_mmx.lo \
+	video_out_x11.lo video_out_sdl.lo video_out_null.lo video_out_pgm.lo video_out_md5.lo
+
 COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
@@ -106,10 +109,11 @@
 
 TAR = gtar
 GZIP_ENV = --best
-DEP_FILES =  .deps/video_out.P .deps/video_out_md5.P \
-.deps/video_out_null.P .deps/video_out_pgm.P .deps/video_out_sdl.P \
-.deps/video_out_x11.P .deps/yuv2rgb.P .deps/yuv2rgb_mlib.P \
-.deps/yuv2rgb_mmx.P
+DEP_FILES =  .deps/video_out.P .deps/video_out_nanox.P .deps/yuv2rgb.P .deps/yuv2rgb_mlib.P \
+.deps/yuv2rgb_mmx.P .deps/video_out_null.P .deps/video_out_pgm.P .deps/video_out_sdl.P \
+.deps/video_out_md5.P 
+
+
 SOURCES = $(libvo_la_SOURCES)
 OBJECTS = $(libvo_la_OBJECTS)
 
diff -urN mpeg2dec_offical/libvo/video_out.c mpeg2dec_nanox/libvo/video_out.c
--- mpeg2dec_offical/libvo/video_out.c	Wed Jan 17 10:14:56 2001
+++ mpeg2dec_nanox/libvo/video_out.c	Wed Jan 17 10:37:22 2001
@@ -31,6 +31,7 @@
 // Externally visible list of all vo drivers
 //
 
+extern vo_output_video_t video_out_nanox;
 
 extern vo_output_video_t video_out_xvshm;
 extern vo_output_video_t video_out_xv;
@@ -44,6 +45,9 @@
 vo_output_video_t* video_out_drivers[] = 
 {
 
+#ifdef LIBVO_NANOX
+	&video_out_nanox,
+#endif
 #ifdef LIBVO_XVSHM
 	&video_out_xvshm,
 #endif
diff -urN mpeg2dec_offical/libvo/video_out_nanox.c mpeg2dec_nanox/libvo/video_out_nanox.c
--- mpeg2dec_offical/libvo/video_out_nanox.c	Thu Jan  1 08:00:00 1970
+++ mpeg2dec_nanox/libvo/video_out_nanox.c	Wed Jan 17 10:27:48 2001
@@ -0,0 +1,252 @@
+/* 
+ * video_out_nanox.c, Nano-X interface
+ *
+ * Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. 
+ *
+ * Hacked into mpeg2dec by
+ * 
+ * Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
+ *
+ * This program is ported from the file video_out_x11.c for MPEG2 file to
+ * be played under framebuffer/Nano-X.
+ * 
+ * The detail about nano-X can be viewed in http://microwindows.org
+ *
+ * Nano-X suuport by
+ *	Erick    Huang <erick@sis.com.tw>, 
+ *	Lei-Chun Chang <lcchang@sis.com.tw>
+ */
+
+#include "config.h"
+
+#ifdef LIBVO_NANOX
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>		// memcmp, strcmp
+
+#include <inttypes.h>
+
+#include <linux/fb.h>
+#include <linux/sisfb.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>		// for open()
+#include <unistd.h>		// for write()
+
+#define  MWINCLUDECOLORS
+#include <microwin/nano-X.h>
+
+#include "video_out.h"
+#include "video_out_internal.h"
+#include "yuv2rgb.h"
+
+/** Private NANO-X Data structure **/
+
+static struct nanox_priv_s {
+	/* local data */
+	uint8_t *imagedata;
+	int width;
+	int height;
+	int stride;
+
+	/* nano-X related variables */
+	GR_WINDOW_ID window;
+	GR_GC_ID gc;
+	GR_SCREEN_INFO vinfo;
+	GR_PIXELVAL *grimage;
+
+} nanox_priv;
+
+static int nanox_get_visual_info(void)
+{
+	struct nanox_priv_s *priv = &nanox_priv;
+
+	GrGetScreenInfo(&priv->vinfo);
+
+	/* get resolution of framebuffer */
+	printf("###### vinfo.bpp  = %4d #####\n", priv->vinfo.bpp);
+	printf("###### vinfo.rows = %4d #####\n", priv->vinfo.rows);
+	printf("###### vinfo.cols = %4d #####\n", priv->vinfo.cols);
+	return 0;
+}
+
+static void nanox_create_window(int width, int height)
+{
+	struct nanox_priv_s *priv = &nanox_priv;
+
+	/* create a window for AP */
+	priv->window = GrNewWindow(GR_ROOT_WINDOW_ID,
+				   0 /* x */ , 0 /* y */ ,
+				   width, height,
+				   0 /* border_width */,
+				   BLACK, LTGRAY);
+	GrMapWindow(priv->window);
+}
+
+/* use Graphic Contexts (gc) for drawing objects */
+static void nanox_create_gc(void)
+{
+	struct nanox_priv_s *priv = &nanox_priv;
+
+	priv->gc = GrNewGC();
+}
+
+/* allocate buffer for decoding image out */
+static int nanox_create_image(int width, int height)
+{
+	struct nanox_priv_s *priv = &nanox_priv;
+
+	priv->grimage = (GR_PIXELVAL *) malloc(width * height * sizeof(GR_PIXELVAL));
+	if (priv->grimage == NULL)
+		return 1;
+
+	return 0;
+}
+
+/* YUV to RGB */
+static int nanox_yuv2rgb_init(void)
+{
+	struct nanox_priv_s *priv = &nanox_priv;
+	int mode;
+
+	mode = MODE_RGB;
+
+	yuv2rgb_init(priv->vinfo.bpp, mode);
+
+	return 0;
+}
+
+static int nanox_common_setup(int width, int height,
+			      int (*create_image) (int, int))
+{
+	struct nanox_priv_s *priv = &nanox_priv;
+
+	if (nanox_get_visual_info()) {
+		fprintf(stderr, "No truecolor visual\n");
+		return 1;
+	}
+
+	nanox_create_window(width, height);
+	nanox_create_gc();
+
+	if (create_image(width, height)) {
+		fprintf(stderr, "Cannot create image on Nano-X server !!!\n");
+		return 1;
+	}
+
+	if (nanox_yuv2rgb_init()) {
+		fprintf(stderr, "No support for non-native byte order\n");
+		return 1;
+	}
+
+	GrMapWindow(priv->window);
+
+	priv->width = width;
+	priv->height = height;
+	priv->imagedata = (unsigned char *) priv->grimage;
+	priv->stride = width * (priv->vinfo.bpp / 8);
+
+	return 0;
+}
+
+static void common_close(void)
+{
+	struct nanox_priv_s *priv = &nanox_priv;
+
+	if (priv->window) {
+		GrDestroyGC(priv->gc);
+		GrDestroyWindow(priv->window);
+	}
+}
+
+static int nanox_setup(int width, int height)
+{
+	if (GrOpen() < 0) {
+		fprintf(stderr, "Can not open display in nano-X \n");
+		return 1;
+	}
+	printf("GrOpen success\n");
+	return nanox_common_setup(width, height, nanox_create_image);
+}
+
+/* release buffer */
+static int nanox_close(void *dummy)
+{
+	struct nanox_priv_s *priv = &nanox_priv;
+
+	free(priv->grimage);
+	common_close();
+	GrClose();
+	return 0;
+}
+
+static void nanox_flip_page(void)
+{
+	struct nanox_priv_s *priv = &nanox_priv;
+	GR_WINDOW_INFO win_info;
+	GrGetWindowInfo(priv->window, &win_info);
+	
+	switch(priv->vinfo.bpp){
+	case 16: 
+		GrArea(priv->window, priv->gc, 0, 0, priv->width, priv->height,
+		       priv->grimage, MWPF_TRUECOLOR565);
+		GrFlush();
+		break;
+
+	case 32: 
+		GrArea(priv->window, priv->gc, 0, 0, priv->width, priv->height,
+		       priv->grimage, MWPF_TRUECOLOR0888);
+		GrFlush();
+		break;
+
+    	default:
+		fprintf (stderr, "not supported by fb\n");
+		exit (1);
+	}
+
+}
+
+static int nanox_draw_slice(uint8_t * src[], int slice_num)
+{
+	struct nanox_priv_s *priv = &nanox_priv;
+
+	yuv2rgb(priv->imagedata + priv->stride * 16 * slice_num,
+		src[0], src[1], src[2], priv->width, 16,
+		priv->stride, priv->width, priv->width >> 1);
+
+	return 0;
+}
+
+static int nanox_draw_frame(frame_t * frame)
+{
+	struct nanox_priv_s *priv = &nanox_priv;
+
+	yuv2rgb(priv->imagedata, frame->base[0], frame->base[1],
+		frame->base[2], priv->width, priv->height, priv->stride,
+		priv->width, priv->width >> 1);
+
+	return 0;
+}
+
+static frame_t *nanox_allocate_image_buffer(int width, int height)
+{
+	return libvo_common_alloc(width, height);
+}
+
+void nanox_free_image_buffer(frame_t * frame)
+{
+	libvo_common_free(frame);
+}
+
+vo_output_video_t video_out_nanox = {
+	"nanox",
+	nanox_setup,
+	nanox_close,
+	nanox_flip_page,
+	nanox_draw_slice,
+	nanox_draw_frame,
+	nanox_allocate_image_buffer,
+	nanox_free_image_buffer
+};
+#endif


Home | Main Index | Thread Index