2001-06-19 23:20:59 +00:00
|
|
|
/*
|
2001-06-15 16:31:19 +00:00
|
|
|
vo_ggi.c - General Graphics Interface (GGI) Renderer for MPlayer
|
|
|
|
|
|
|
|
(C) Alex Beregszaszi <alex@naxine.org>
|
|
|
|
|
|
|
|
Uses libGGI - http://www.ggi-project.org/
|
|
|
|
|
2001-06-17 12:24:52 +00:00
|
|
|
Many thanks to Atmosfear, he hacked this driver to working with Planar
|
|
|
|
formats, and he fixed the RGB handling.
|
|
|
|
*/
|
2001-06-15 16:31:19 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
#include "../config.h"
|
2001-06-15 16:31:19 +00:00
|
|
|
#include "video_out.h"
|
|
|
|
#include "video_out_internal.h"
|
|
|
|
|
2001-06-17 12:24:52 +00:00
|
|
|
#include "fastmemcpy.h"
|
2001-06-15 16:31:19 +00:00
|
|
|
|
|
|
|
#include <ggi/ggi.h>
|
2001-06-17 12:24:52 +00:00
|
|
|
|
2001-06-17 14:33:06 +00:00
|
|
|
#undef GGI_OST
|
2001-06-19 23:20:59 +00:00
|
|
|
#undef GII_BUGGY_KEYCODES
|
2001-06-17 16:12:47 +00:00
|
|
|
#define GGI_OSD
|
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
#undef get_db_info
|
|
|
|
|
|
|
|
/* do not make conversions from planar formats */
|
|
|
|
#undef GGI_PLANAR_NOCONV
|
|
|
|
|
|
|
|
#ifndef GGI_PLANAR_NOCONV
|
|
|
|
#include "yuv2rgb.h"
|
|
|
|
#endif
|
|
|
|
|
2001-06-15 16:31:19 +00:00
|
|
|
LIBVO_EXTERN (ggi)
|
|
|
|
|
|
|
|
static vo_info_t vo_info =
|
|
|
|
{
|
|
|
|
"General Graphics Interface (GGI) output",
|
|
|
|
"ggi",
|
|
|
|
"Alex Beregszaszi <alex@naxine.org>",
|
2001-06-17 12:24:52 +00:00
|
|
|
"under developement"
|
2001-06-15 16:31:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern int verbose;
|
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
/* idea stolen from vo_sdl.c :) */
|
|
|
|
static struct ggi_conf_s {
|
|
|
|
char *driver;
|
|
|
|
|
|
|
|
ggi_visual_t vis;
|
|
|
|
ggi_directbuffer *buffer;
|
|
|
|
|
|
|
|
uint8_t bpp;
|
|
|
|
uint8_t bppmul;
|
|
|
|
|
|
|
|
uint8_t mode;
|
|
|
|
#define YUV 0
|
|
|
|
#define RGB 1
|
|
|
|
#define BGR 2
|
|
|
|
|
|
|
|
/* YUV */
|
|
|
|
int framePlaneY, framePlaneUV, framePlaneYUY;
|
|
|
|
int stridePlaneY, stridePlaneUV, stridePlaneYUY;
|
|
|
|
|
|
|
|
/* RGB */
|
|
|
|
int framePlaneRGB;
|
|
|
|
int stridePlaneRGB;
|
|
|
|
|
|
|
|
/* original */
|
|
|
|
int width, height;
|
|
|
|
|
|
|
|
/* destination */
|
|
|
|
int dstwidth, dstheight;
|
|
|
|
|
|
|
|
/* source image format */
|
|
|
|
int format;
|
|
|
|
|
|
|
|
/* direct buffer */
|
|
|
|
uint8_t *dbuff;
|
|
|
|
|
|
|
|
/* i.e. need lock */
|
|
|
|
int need_acquire;
|
|
|
|
|
2001-06-17 12:24:52 +00:00
|
|
|
#ifdef GGI_OST
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_pixel white;
|
|
|
|
ggi_pixel black;
|
2001-06-17 12:24:52 +00:00
|
|
|
#endif
|
2001-06-19 23:20:59 +00:00
|
|
|
} ggi_conf;
|
2001-06-15 16:31:19 +00:00
|
|
|
|
2001-06-17 18:32:14 +00:00
|
|
|
static int ggi_setmode(uint32_t d_width, uint32_t d_height, int d_depth)
|
2001-06-15 16:31:19 +00:00
|
|
|
{
|
|
|
|
ggi_mode mode =
|
|
|
|
{
|
|
|
|
1, /* frames */
|
|
|
|
{ GGI_AUTO, GGI_AUTO }, /* visible */
|
|
|
|
{ GGI_AUTO, GGI_AUTO }, /* virt */
|
|
|
|
{ GGI_AUTO, GGI_AUTO }, /* size */
|
|
|
|
GT_AUTO, /* graphtype */
|
|
|
|
{ GGI_AUTO, GGI_AUTO } /* dots per pixel */
|
|
|
|
};
|
|
|
|
ggi_color pal[256];
|
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
if (verbose)
|
|
|
|
printf("ggi-setmode: requested: %dx%d (%d depth)\n",
|
|
|
|
d_width, d_height, d_depth);
|
|
|
|
|
|
|
|
mode.size.x = vo_screenwidth;
|
|
|
|
mode.size.y = vo_screenheight;
|
2001-06-15 16:31:19 +00:00
|
|
|
mode.visible.x = mode.virt.x = d_width;
|
|
|
|
mode.visible.y = mode.virt.y = d_height;
|
|
|
|
|
|
|
|
switch(d_depth)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
mode.graphtype = GT_1BIT;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
mode.graphtype = GT_2BIT;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
mode.graphtype = GT_4BIT;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
mode.graphtype = GT_8BIT;
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
mode.graphtype = GT_15BIT;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
mode.graphtype = GT_16BIT;
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
mode.graphtype = GT_24BIT;
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
mode.graphtype = GT_32BIT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("ggi-setmode: unknown bit depth - using auto\n");
|
|
|
|
mode.graphtype = GT_AUTO;
|
|
|
|
}
|
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
ggiCheckMode(ggi_conf.vis, &mode);
|
2001-06-15 16:31:19 +00:00
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
if (ggiSetMode(ggi_conf.vis, &mode) != 0)
|
2001-06-15 16:31:19 +00:00
|
|
|
{
|
|
|
|
printf("ggi-setmode: unable to set mode\n");
|
2001-06-19 23:20:59 +00:00
|
|
|
ggiClose(ggi_conf.vis);
|
2001-06-15 16:31:19 +00:00
|
|
|
ggiExit();
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
if (ggiGetMode(ggi_conf.vis, &mode) != 0)
|
2001-06-17 18:32:14 +00:00
|
|
|
{
|
|
|
|
printf("ggi-setmode: unable to get mode\n");
|
2001-06-19 23:20:59 +00:00
|
|
|
ggiClose(ggi_conf.vis);
|
2001-06-17 18:32:14 +00:00
|
|
|
ggiExit();
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.width = mode.virt.x;
|
|
|
|
ggi_conf.height = mode.virt.y;
|
2001-06-15 16:31:19 +00:00
|
|
|
vo_screenwidth = mode.visible.x;
|
|
|
|
vo_screenheight = mode.visible.y;
|
2001-06-17 12:24:52 +00:00
|
|
|
vo_depthonscreen = d_depth;
|
2001-06-17 18:32:14 +00:00
|
|
|
// vo_depthonscreen = GT_DEPTH(mode.graphtype);
|
|
|
|
// ggi_bpp = GT_SIZE(mode.graphtype);
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.bpp = vo_depthonscreen;
|
2001-06-15 16:31:19 +00:00
|
|
|
|
|
|
|
#ifdef get_db_info
|
|
|
|
{
|
2001-06-19 23:20:59 +00:00
|
|
|
const ggi_directbuffer *db = ggiDBGetBuffer(ggi_conf.vis, 0);
|
2001-06-15 16:31:19 +00:00
|
|
|
|
|
|
|
if (db)
|
|
|
|
{
|
|
|
|
vo_depthonscreen = db->buffer.plb.pixelformat->depth;
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.bpp = db->buffer.plb.pixelformat->size / 8;
|
2001-06-15 16:31:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (GT_SCHEME(mode.graphtype) == GT_PALETTE)
|
|
|
|
{
|
2001-06-19 23:20:59 +00:00
|
|
|
ggiSetColorfulPalette(ggi_conf.vis);
|
|
|
|
ggiGetPalette(ggi_conf.vis, 0, 1 << ggi_conf.bpp, pal);
|
2001-06-15 16:31:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (verbose)
|
2001-06-19 23:20:59 +00:00
|
|
|
printf("ggi-setmode: %dx%d (virt: %dx%d) (size: %dx%d) screen depth: %d, bpp: %d\n",
|
|
|
|
vo_screenwidth, vo_screenheight, ggi_conf.width, ggi_conf.height,
|
|
|
|
mode.size.x, mode.size.y,
|
|
|
|
vo_depthonscreen, ggi_conf.bpp);
|
2001-06-15 16:31:19 +00:00
|
|
|
|
2001-06-23 13:28:28 +00:00
|
|
|
ggi_conf.bppmul = (ggi_conf.bpp+7)/8;
|
2001-06-17 16:12:47 +00:00
|
|
|
|
2001-06-15 16:31:19 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
typedef struct ggi_aspect_ret_s { int w, h, x, y; } ggi_aspect_ret;
|
|
|
|
|
|
|
|
/* stolen from vo_sdl.c */
|
|
|
|
#define MONITOR_ASPECT 4.0/3.0
|
|
|
|
static ggi_aspect_ret aspect_size(int srcw, int srch, int dstw, int dsth)
|
|
|
|
{
|
|
|
|
ggi_aspect_ret ret;
|
|
|
|
float float_h;
|
|
|
|
|
|
|
|
if (verbose)
|
|
|
|
printf("ggi-aspectsize: src: %dx%d dst: %dx%d\n",
|
|
|
|
srcw, srch, dstw, dsth);
|
|
|
|
|
|
|
|
float_h = ((float)dsth / (float)srcw * (float)srch) * ((float)dsth /
|
|
|
|
((float)dstw / (MONITOR_ASPECT)));
|
|
|
|
|
|
|
|
if (float_h > dsth)
|
|
|
|
{
|
|
|
|
ret.w = (int)((float)dsth / (float)float_h) * dstw;
|
|
|
|
ret.h = dsth;
|
|
|
|
ret.x = (dstw - ret.w) / 2;
|
|
|
|
ret.y = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret.h = (int)float_h;
|
|
|
|
ret.w = dstw;
|
|
|
|
ret.x = 0;
|
|
|
|
ret.y = (dsth - ret.h) / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("ggi-aspectsize: %dx%d (x: %d, y: %d)\n", ret.w, ret.h, ret.x, ret.y);
|
|
|
|
return(ret);
|
|
|
|
}
|
2001-06-15 16:31:19 +00:00
|
|
|
|
|
|
|
static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width,
|
|
|
|
uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
|
|
|
|
{
|
2001-06-17 12:24:52 +00:00
|
|
|
vo_depthonscreen = 32;
|
2001-06-17 16:12:47 +00:00
|
|
|
printf("ggi-init: This driver has got bugs, if you can, fix them.\n");
|
2001-06-17 12:24:52 +00:00
|
|
|
|
2001-06-15 16:31:19 +00:00
|
|
|
if (ggiInit() != 0)
|
|
|
|
{
|
|
|
|
printf("ggi-init: unable to initialize GGI\n");
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.driver = NULL;
|
|
|
|
|
|
|
|
if ((ggi_conf.vis = ggiOpen(ggi_conf.driver)) == NULL)
|
2001-06-15 16:31:19 +00:00
|
|
|
{
|
|
|
|
printf("ggi-init: unable to open GGI for %s output\n",
|
2001-06-19 23:20:59 +00:00
|
|
|
(ggi_conf.driver == NULL) ? "default" : ggi_conf.driver);
|
2001-06-15 16:31:19 +00:00
|
|
|
ggiExit();
|
|
|
|
return(-1);
|
|
|
|
}
|
2001-06-17 12:24:52 +00:00
|
|
|
|
|
|
|
printf("ggi-init: using %s GGI output\n",
|
2001-06-19 23:20:59 +00:00
|
|
|
(ggi_conf.driver == NULL) ? "default" : ggi_conf.driver);
|
2001-06-15 16:31:19 +00:00
|
|
|
|
2001-06-17 16:12:47 +00:00
|
|
|
switch(format)
|
2001-06-15 16:31:19 +00:00
|
|
|
{
|
|
|
|
case IMGFMT_RGB8:
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.bpp = 8;
|
|
|
|
ggi_conf.mode = RGB;
|
2001-06-15 16:31:19 +00:00
|
|
|
break;
|
|
|
|
case IMGFMT_RGB15:
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.bpp = 15;
|
|
|
|
ggi_conf.mode = RGB;
|
2001-06-15 16:31:19 +00:00
|
|
|
break;
|
|
|
|
case IMGFMT_RGB16:
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.bpp = 16;
|
|
|
|
ggi_conf.mode = RGB;
|
2001-06-15 16:31:19 +00:00
|
|
|
break;
|
|
|
|
case IMGFMT_RGB24:
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.bpp = 24;
|
|
|
|
ggi_conf.mode = RGB;
|
2001-06-15 16:31:19 +00:00
|
|
|
break;
|
|
|
|
case IMGFMT_RGB32:
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.bpp = 32;
|
|
|
|
ggi_conf.mode = RGB;
|
2001-06-15 16:31:19 +00:00
|
|
|
break;
|
|
|
|
case IMGFMT_BGR8:
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.bpp = 8;
|
|
|
|
ggi_conf.mode = BGR;
|
2001-06-15 16:31:19 +00:00
|
|
|
break;
|
|
|
|
case IMGFMT_BGR15:
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.bpp = 15;
|
|
|
|
ggi_conf.mode = BGR;
|
2001-06-15 16:31:19 +00:00
|
|
|
break;
|
|
|
|
case IMGFMT_BGR16:
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.bpp = 16;
|
|
|
|
ggi_conf.mode = BGR;
|
2001-06-15 16:31:19 +00:00
|
|
|
break;
|
|
|
|
case IMGFMT_BGR24:
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.bpp = 24;
|
|
|
|
ggi_conf.mode = BGR;
|
2001-06-15 16:31:19 +00:00
|
|
|
break;
|
|
|
|
case IMGFMT_BGR32:
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.bpp = 32;
|
|
|
|
ggi_conf.mode = BGR;
|
2001-06-15 16:31:19 +00:00
|
|
|
break;
|
|
|
|
case IMGFMT_YV12: /* rgb, 24bit */
|
2001-06-19 23:20:59 +00:00
|
|
|
case IMGFMT_I420:
|
|
|
|
case IMGFMT_IYUV:
|
|
|
|
ggi_conf.bpp = 16;
|
|
|
|
ggi_conf.mode = YUV;
|
|
|
|
#ifndef GGI_PLANAR_NOCONV
|
2001-06-17 18:32:14 +00:00
|
|
|
yuv2rgb_init(32/*vo_depthonscreen*/, MODE_RGB);
|
2001-06-19 23:20:59 +00:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case IMGFMT_YUY2:
|
|
|
|
ggi_conf.bpp = 24;
|
|
|
|
ggi_conf.mode = YUV;
|
|
|
|
#ifndef GGI_PLANAR_NOCONV
|
|
|
|
yuv2rgb_init(32, MODE_RGB);
|
|
|
|
#endif
|
2001-06-15 16:31:19 +00:00
|
|
|
break;
|
|
|
|
default:
|
2001-06-17 16:12:47 +00:00
|
|
|
printf("ggi-init: no suitable image format found (requested: %s)\n",
|
|
|
|
vo_format_name(format));
|
2001-06-15 16:31:19 +00:00
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.format = format;
|
|
|
|
|
2001-06-23 13:28:28 +00:00
|
|
|
ggi_conf.framePlaneRGB = width * height * ((ggi_conf.bpp+7)/8); /* fix it! */
|
|
|
|
ggi_conf.stridePlaneRGB = width * ((ggi_conf.bpp+7)/8);
|
2001-06-19 23:20:59 +00:00
|
|
|
#ifdef GGI_PLANAR_NOCONV
|
|
|
|
ggi_conf.framePlaneY = width * height;
|
|
|
|
ggi_conf.framePlaneUV = (width * height) >> 2;
|
|
|
|
ggi_conf.framePlaneYUY = width * height * 2;
|
|
|
|
ggi_conf.stridePlaneY = width;
|
|
|
|
ggi_conf.stridePlaneUV = width/2;
|
|
|
|
ggi_conf.stridePlaneYUY = width * 2;
|
|
|
|
#endif
|
|
|
|
ggi_conf.width = width;
|
|
|
|
ggi_conf.height = height;
|
|
|
|
ggi_conf.dstwidth = d_width ? d_width : width;
|
|
|
|
ggi_conf.dstheight = d_height ? d_height : height;
|
|
|
|
|
2001-06-15 16:31:19 +00:00
|
|
|
{
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_aspect_ret asp;
|
|
|
|
|
|
|
|
if (width != d_width || height != d_height)
|
|
|
|
asp = aspect_size(width, height, d_width, d_height);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
asp.w = width;
|
|
|
|
asp.h = height;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ggi_setmode(asp.w, asp.h, vo_depthonscreen) != 0)
|
|
|
|
{
|
|
|
|
printf("ggi-init: setmode returned with error\n");
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
}
|
2001-06-15 16:31:19 +00:00
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
printf("ggi-init: input: %d bpp %s - screen depth: %d\n", ggi_conf.bpp,
|
|
|
|
vo_format_name(ggi_conf.format), vo_depthonscreen);
|
2001-06-17 18:32:14 +00:00
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
ggiSetFlags(ggi_conf.vis, GGIFLAG_ASYNC);
|
2001-06-17 18:32:14 +00:00
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.buffer = (ggi_directbuffer *)ggiDBGetBuffer(ggi_conf.vis, 0);
|
2001-06-15 16:31:19 +00:00
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
if (ggi_conf.buffer == NULL)
|
2001-06-15 16:31:19 +00:00
|
|
|
{
|
|
|
|
printf("ggi-init: double buffering is not available\n");
|
2001-06-19 23:20:59 +00:00
|
|
|
ggiClose(ggi_conf.vis);
|
2001-06-15 16:31:19 +00:00
|
|
|
ggiExit();
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
if (!(ggi_conf.buffer->type & GGI_DB_SIMPLE_PLB) ||
|
|
|
|
(ggi_conf.buffer->page_size != 0) ||
|
|
|
|
(ggi_conf.buffer->write == NULL) ||
|
|
|
|
(ggi_conf.buffer->noaccess != 0) ||
|
|
|
|
(ggi_conf.buffer->align != 0) ||
|
|
|
|
(ggi_conf.buffer->layout != blPixelLinearBuffer))
|
2001-06-15 16:31:19 +00:00
|
|
|
{
|
|
|
|
printf("ggi-init: incorrect video memory type\n");
|
2001-06-19 23:20:59 +00:00
|
|
|
ggiClose(ggi_conf.vis);
|
2001-06-15 16:31:19 +00:00
|
|
|
ggiExit();
|
|
|
|
return(-1);
|
|
|
|
}
|
2001-06-19 23:20:59 +00:00
|
|
|
|
|
|
|
if (ggi_conf.buffer->resource != NULL)
|
|
|
|
ggi_conf.need_acquire = 1;
|
|
|
|
|
|
|
|
if (verbose && ggi_conf.need_acquire)
|
|
|
|
printf("ggi-init: ggi needs acquire\n");
|
|
|
|
|
|
|
|
ggi_conf.dbuff = ggi_conf.buffer->write;
|
2001-06-15 16:31:19 +00:00
|
|
|
|
2001-06-17 12:24:52 +00:00
|
|
|
#ifdef GGI_OST
|
2001-06-15 16:31:19 +00:00
|
|
|
/* just for fun */
|
|
|
|
{
|
|
|
|
ggi_color col;
|
|
|
|
|
|
|
|
/* set black */
|
|
|
|
col.r = col.g = col.b = 0x0000;
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.black = ggiMapColor(ggi_conf.vis, &col);
|
2001-06-15 16:31:19 +00:00
|
|
|
|
|
|
|
/* set white */
|
|
|
|
col.r = col.g = col.b = 0xffff;
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.white = ggiMapColor(ggi_conf.vis, &col);
|
2001-06-15 16:31:19 +00:00
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
ggiSetGCForeground(ggi_conf.vis, ggi_conf.white);
|
|
|
|
ggiSetGCBackground(ggi_conf.vis, ggi_conf.black);
|
2001-06-15 16:31:19 +00:00
|
|
|
}
|
2001-06-17 12:24:52 +00:00
|
|
|
#endif
|
2001-06-15 16:31:19 +00:00
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
static const vo_info_t *get_info(void)
|
2001-06-15 16:31:19 +00:00
|
|
|
{
|
|
|
|
return &vo_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t draw_frame(uint8_t *src[])
|
|
|
|
{
|
2001-06-19 23:20:59 +00:00
|
|
|
if (ggi_conf.need_acquire)
|
|
|
|
ggiResourceAcquire(ggi_conf.buffer->resource, GGI_ACTYPE_WRITE);
|
2001-06-17 12:24:52 +00:00
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
// ggiSetDisplayFrame(ggi_conf.vis, ggi_conf.buffer->frame);
|
|
|
|
// ggiSetWriteFrame(ggi_conf.vis, ggi_conf.buffer->frame);
|
|
|
|
|
|
|
|
#ifdef GGI_PLANAR_NOCONV
|
|
|
|
switch(ggi_conf.format)
|
|
|
|
{
|
|
|
|
case IMGFMT_YV12:
|
|
|
|
case IMGFMT_I420:
|
|
|
|
case IMGFMT_IYUV:
|
|
|
|
memcpy(ggi_conf.dbuff, src[0], ggi_conf.framePlaneY);
|
|
|
|
ggi_conf.dbuff += ggi_conf.framePlaneY;
|
|
|
|
memcpy(ggi_conf.dbuff, src[2], ggi_conf.framePlaneUV);
|
|
|
|
ggi_conf.dbuff += ggi_conf.framePlaneUV;
|
|
|
|
memcpy(ggi_conf.dbuff, src[1], ggi_conf.framePlaneUV);
|
|
|
|
printf("yv12 img written");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
memcpy(ggi_conf.dbuff, src[0], ggi_conf.framePlaneRGB);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
memcpy(ggi_conf.dbuff, src[0], ggi_conf.framePlaneRGB);
|
2001-06-17 12:24:52 +00:00
|
|
|
#endif
|
2001-06-15 16:31:19 +00:00
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
if (ggi_conf.need_acquire)
|
|
|
|
ggiResourceRelease(ggi_conf.buffer->resource);
|
2001-06-17 12:24:52 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2001-06-17 16:12:47 +00:00
|
|
|
#ifdef GGI_OSD
|
2001-06-17 12:24:52 +00:00
|
|
|
static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
|
|
|
|
unsigned char *srca, int stride)
|
|
|
|
{
|
2001-06-19 23:20:59 +00:00
|
|
|
switch(ggi_conf.format)
|
2001-06-17 12:24:52 +00:00
|
|
|
{
|
2001-06-17 16:12:47 +00:00
|
|
|
case IMGFMT_YV12:
|
|
|
|
case IMGFMT_I420:
|
|
|
|
case IMGFMT_IYUV:
|
2001-06-19 23:20:59 +00:00
|
|
|
#ifdef GGI_PLANAR_NOCONV
|
|
|
|
vo_draw_alpha_yv12(w, h, src, srca, stride,
|
|
|
|
ggi_conf.dbuff+(ggi_conf.width*y0+x0),
|
|
|
|
ggi_conf.width);
|
|
|
|
#else
|
2001-06-17 18:32:14 +00:00
|
|
|
switch (vo_depthonscreen)
|
|
|
|
{
|
|
|
|
case 32:
|
|
|
|
vo_draw_alpha_rgb32(w, h, src, srca, stride,
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.dbuff+4*(ggi_conf.width*y0+x0), 4*ggi_conf.width);
|
2001-06-17 18:32:14 +00:00
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
vo_draw_alpha_rgb24(w, h, src, srca, stride,
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.dbuff+3*(ggi_conf.width*y0+x0), 3*ggi_conf.width);
|
2001-06-17 18:32:14 +00:00
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
vo_draw_alpha_rgb16(w, h, src, srca, stride,
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.dbuff+2*(ggi_conf.width*y0+x0), 2*ggi_conf.width);
|
2001-06-17 18:32:14 +00:00
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
vo_draw_alpha_rgb15(w, h, src, srca, stride,
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.dbuff+2*(ggi_conf.width*y0+x0), 2*ggi_conf.width);
|
2001-06-17 18:32:14 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-06-19 23:20:59 +00:00
|
|
|
#endif
|
2001-06-17 16:12:47 +00:00
|
|
|
break;
|
|
|
|
case IMGFMT_YUY2:
|
|
|
|
case IMGFMT_YVYU:
|
|
|
|
vo_draw_alpha_yuy2(w, h, src, srca, stride,
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.dbuff+2*(ggi_conf.width*y0+x0),
|
|
|
|
2*ggi_conf.width);
|
2001-06-17 16:12:47 +00:00
|
|
|
break;
|
|
|
|
case IMGFMT_UYVY:
|
|
|
|
vo_draw_alpha_yuy2(w, h, src, srca, stride,
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.dbuff+2*(ggi_conf.width*y0+x0)+1,
|
|
|
|
2*ggi_conf.width);
|
2001-06-17 16:12:47 +00:00
|
|
|
break;
|
2001-06-17 12:24:52 +00:00
|
|
|
case IMGFMT_RGB15:
|
|
|
|
case IMGFMT_BGR15:
|
2001-06-17 16:12:47 +00:00
|
|
|
vo_draw_alpha_rgb15(w, h, src, srca, stride,
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.dbuff+2*(ggi_conf.width*y0+x0), 2*ggi_conf.width);
|
2001-06-17 12:24:52 +00:00
|
|
|
break;
|
|
|
|
case IMGFMT_RGB16:
|
|
|
|
case IMGFMT_BGR16:
|
2001-06-17 16:12:47 +00:00
|
|
|
vo_draw_alpha_rgb16(w, h, src, srca, stride,
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.dbuff+2*(ggi_conf.width*y0+x0), 2*ggi_conf.width);
|
2001-06-17 12:24:52 +00:00
|
|
|
break;
|
|
|
|
case IMGFMT_RGB24:
|
|
|
|
case IMGFMT_BGR24:
|
2001-06-17 16:12:47 +00:00
|
|
|
vo_draw_alpha_rgb24(w, h, src, srca, stride,
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.dbuff+3*(ggi_conf.width*y0+x0), 3*ggi_conf.width);
|
2001-06-17 12:24:52 +00:00
|
|
|
break;
|
|
|
|
case IMGFMT_RGB32:
|
|
|
|
case IMGFMT_BGR32:
|
2001-06-17 16:12:47 +00:00
|
|
|
vo_draw_alpha_rgb32(w, h, src, srca, stride,
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.dbuff+4*(ggi_conf.width*y0+x0), 4*ggi_conf.width);
|
2001-06-17 12:24:52 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-06-15 16:31:19 +00:00
|
|
|
}
|
2001-06-17 16:12:47 +00:00
|
|
|
#endif
|
2001-06-15 16:31:19 +00:00
|
|
|
|
2001-08-13 11:08:18 +00:00
|
|
|
static void draw_osd(void)
|
2001-06-15 16:31:19 +00:00
|
|
|
{
|
2001-06-17 16:12:47 +00:00
|
|
|
#ifdef GGI_OSD
|
2001-06-19 23:20:59 +00:00
|
|
|
vo_draw_text(ggi_conf.width, ggi_conf.height, draw_alpha);
|
2001-06-17 16:12:47 +00:00
|
|
|
#endif
|
2001-08-13 11:08:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void flip_page(void)
|
|
|
|
{
|
2001-06-19 23:20:59 +00:00
|
|
|
ggiFlush(ggi_conf.vis);
|
2001-06-15 16:31:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h,
|
|
|
|
int x, int y)
|
|
|
|
{
|
2001-06-19 23:20:59 +00:00
|
|
|
if (ggi_conf.need_acquire)
|
|
|
|
ggiResourceAcquire(ggi_conf.buffer->resource, GGI_ACTYPE_WRITE);
|
|
|
|
#ifndef GGI_PLANAR_NOCONV
|
|
|
|
yuv2rgb(((uint8_t *) ggi_conf.dbuff)+(ggi_conf.width*y+x)*ggi_conf.bppmul,
|
|
|
|
src[0], src[1], src[2], w, h, ggi_conf.width*ggi_conf.bppmul, stride[0],
|
2001-06-17 16:12:47 +00:00
|
|
|
stride[1]);
|
2001-06-19 23:20:59 +00:00
|
|
|
#else
|
|
|
|
int i;
|
2001-06-15 16:31:19 +00:00
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
ggi_conf.dbuff += (ggi_conf.stridePlaneY * y + x);
|
|
|
|
for (i = 0; i < h; i++)
|
|
|
|
{
|
|
|
|
memcpy(ggi_conf.dbuff, src[0], w);
|
|
|
|
src[0] += stride[0];
|
|
|
|
ggi_conf.dbuff += ggi_conf.stridePlaneY;
|
|
|
|
}
|
|
|
|
|
|
|
|
x /= 2;
|
|
|
|
y /= 2;
|
|
|
|
w /= 2;
|
|
|
|
h /= 2;
|
|
|
|
|
|
|
|
ggi_conf.dbuff += ggi_conf.stridePlaneY + (ggi_conf.stridePlaneUV * y + x);
|
|
|
|
for (i = 0; i < h; i++)
|
|
|
|
{
|
|
|
|
memcpy(ggi_conf.dbuff, src[1], w);
|
|
|
|
src[1] += stride[1];
|
|
|
|
ggi_conf.dbuff += ggi_conf.stridePlaneUV;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (ggi_conf.need_acquire)
|
|
|
|
ggiResourceRelease(ggi_conf.buffer->resource);
|
2001-06-15 16:31:19 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t query_format(uint32_t format)
|
|
|
|
{
|
2001-06-17 12:24:52 +00:00
|
|
|
switch(format)
|
|
|
|
{
|
|
|
|
case IMGFMT_YV12:
|
2001-06-19 23:20:59 +00:00
|
|
|
case IMGFMT_I420:
|
2001-06-17 16:12:47 +00:00
|
|
|
case IMGFMT_IYUV:
|
2001-06-19 23:20:59 +00:00
|
|
|
/* case IMGFMT_YUY2:
|
2001-06-17 18:33:05 +00:00
|
|
|
case IMGFMT_YVYU:
|
2001-06-17 16:12:47 +00:00
|
|
|
case IMGFMT_UYVY:*/
|
2001-06-19 23:20:59 +00:00
|
|
|
return(0x6);
|
2001-06-17 12:24:52 +00:00
|
|
|
case IMGFMT_RGB8:
|
|
|
|
case IMGFMT_RGB15:
|
|
|
|
case IMGFMT_RGB16:
|
|
|
|
case IMGFMT_RGB24:
|
|
|
|
case IMGFMT_RGB32:
|
|
|
|
case IMGFMT_BGR8:
|
|
|
|
case IMGFMT_BGR15:
|
|
|
|
case IMGFMT_BGR16:
|
|
|
|
case IMGFMT_BGR24:
|
|
|
|
case IMGFMT_BGR32:
|
2001-06-19 23:20:59 +00:00
|
|
|
return(0x5);
|
2001-06-15 16:31:19 +00:00
|
|
|
}
|
2001-06-17 12:24:52 +00:00
|
|
|
return(0);
|
2001-06-15 16:31:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void uninit(void)
|
|
|
|
{
|
2001-06-19 23:20:59 +00:00
|
|
|
ggiResourceRelease(ggi_conf.buffer->resource);
|
|
|
|
ggiClose(ggi_conf.vis);
|
2001-06-15 16:31:19 +00:00
|
|
|
ggiExit();
|
|
|
|
}
|
|
|
|
|
2001-06-17 14:33:06 +00:00
|
|
|
#include "../linux/keycodes.h"
|
2001-06-19 23:20:59 +00:00
|
|
|
extern void mplayer_put_key(int code);
|
|
|
|
|
2001-06-15 16:31:19 +00:00
|
|
|
static void check_events(void)
|
|
|
|
{
|
2001-06-17 14:33:06 +00:00
|
|
|
struct timeval tv = {0, 0};
|
|
|
|
ggi_event event;
|
|
|
|
ggi_event_mask mask;
|
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
if ((mask = ggiEventPoll(ggi_conf.vis, emAll, &tv)))
|
|
|
|
if (ggiEventRead(ggi_conf.vis, &event, emAll) != 0)
|
2001-06-17 14:33:06 +00:00
|
|
|
{
|
2001-06-19 23:20:59 +00:00
|
|
|
#if 0 /* debug ;) */
|
|
|
|
printf("type: %4x, origin: %4x, sym: %4x, label: %4x, button=%4x\n",
|
|
|
|
event.any.origin, event.any.type, event.key.sym, event.key.label, event.key.button);
|
|
|
|
#endif
|
2001-06-17 14:33:06 +00:00
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
if (event.key.type == evKeyPress)
|
2001-06-17 14:33:06 +00:00
|
|
|
{
|
|
|
|
#ifdef GII_BUGGY_KEYCODES
|
|
|
|
switch(event.key.button)
|
|
|
|
{
|
|
|
|
case 0x37:
|
|
|
|
mplayer_put_key('*');
|
|
|
|
break;
|
|
|
|
case 0x68:
|
|
|
|
mplayer_put_key('/');
|
|
|
|
break;
|
|
|
|
case 0x4e:
|
|
|
|
mplayer_put_key('+');
|
|
|
|
break;
|
|
|
|
case 0x4a:
|
|
|
|
mplayer_put_key('-');
|
|
|
|
break;
|
2001-06-19 23:20:59 +00:00
|
|
|
case 0x18: /* o */
|
2001-06-17 14:33:06 +00:00
|
|
|
mplayer_put_key('o');
|
|
|
|
break;
|
2001-06-19 23:20:59 +00:00
|
|
|
case 0x22: /* g */
|
2001-06-17 14:33:06 +00:00
|
|
|
mplayer_put_key('g');
|
|
|
|
break;
|
2001-06-19 23:20:59 +00:00
|
|
|
case 0x15: /* z */
|
2001-06-17 14:33:06 +00:00
|
|
|
mplayer_put_key('z');
|
|
|
|
break;
|
2001-06-19 23:20:59 +00:00
|
|
|
case 0x2d: /* x */
|
2001-06-17 14:33:06 +00:00
|
|
|
mplayer_put_key('x');
|
|
|
|
break;
|
2001-06-19 23:20:59 +00:00
|
|
|
case 0x32: /* m */
|
2001-06-17 14:33:06 +00:00
|
|
|
mplayer_put_key('m');
|
|
|
|
break;
|
2001-06-19 23:20:59 +00:00
|
|
|
case 0x20: /* d */
|
2001-06-17 14:33:06 +00:00
|
|
|
mplayer_put_key('d');
|
|
|
|
break;
|
2001-06-19 23:20:59 +00:00
|
|
|
case 0x10: /* q */
|
2001-06-17 14:33:06 +00:00
|
|
|
mplayer_put_key('q');
|
|
|
|
break;
|
2001-06-19 23:20:59 +00:00
|
|
|
case 0x39: /* space */
|
|
|
|
case 0x19: /* p */
|
2001-06-17 14:33:06 +00:00
|
|
|
mplayer_put_key('p');
|
|
|
|
break;
|
|
|
|
case 0x5a:
|
|
|
|
mplayer_put_key(KEY_UP);
|
|
|
|
break;
|
|
|
|
case 0x60:
|
|
|
|
mplayer_put_key(KEY_DOWN);
|
|
|
|
break;
|
|
|
|
case 0x5c:
|
|
|
|
mplayer_put_key(KEY_LEFT);
|
|
|
|
break;
|
|
|
|
case 0x5e:
|
|
|
|
mplayer_put_key(KEY_RIGHT);
|
|
|
|
break;
|
|
|
|
case 0x5b:
|
|
|
|
mplayer_put_key(KEY_PAGE_UP);
|
|
|
|
break;
|
|
|
|
case 0x61:
|
|
|
|
mplayer_put_key(KEY_PAGE_DOWN);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#else
|
2001-06-19 23:20:59 +00:00
|
|
|
switch(event.key.sym)
|
2001-06-17 14:33:06 +00:00
|
|
|
{
|
|
|
|
case GIIK_PAsterisk: /* PStar */
|
|
|
|
case GIIUC_Asterisk:
|
|
|
|
mplayer_put_key('*');
|
|
|
|
break;
|
|
|
|
case GIIK_PSlash:
|
|
|
|
case GIIUC_Slash:
|
|
|
|
mplayer_put_key('/');
|
|
|
|
break;
|
|
|
|
case GIIK_PPlus:
|
|
|
|
case GIIUC_Plus:
|
|
|
|
mplayer_put_key('+');
|
|
|
|
break;
|
|
|
|
case GIIK_PMinus:
|
|
|
|
case GIIUC_Minus:
|
|
|
|
mplayer_put_key('-');
|
|
|
|
break;
|
|
|
|
case GIIUC_o:
|
|
|
|
case GIIUC_O:
|
|
|
|
mplayer_put_key('o');
|
|
|
|
break;
|
|
|
|
case GIIUC_g:
|
|
|
|
case GIIUC_G:
|
|
|
|
mplayer_put_key('g');
|
|
|
|
break;
|
|
|
|
case GIIUC_z:
|
|
|
|
case GIIUC_Z:
|
|
|
|
mplayer_put_key('z');
|
|
|
|
break;
|
|
|
|
case GIIUC_x:
|
|
|
|
case GIIUC_X:
|
|
|
|
mplayer_put_key('x');
|
|
|
|
break;
|
|
|
|
case GIIUC_m:
|
|
|
|
case GIIUC_M:
|
|
|
|
mplayer_put_key('m');
|
|
|
|
break;
|
|
|
|
case GIIUC_d:
|
|
|
|
case GIIUC_D:
|
|
|
|
mplayer_put_key('d');
|
|
|
|
break;
|
|
|
|
case GIIUC_q:
|
|
|
|
case GIIUC_Q:
|
|
|
|
mplayer_put_key('q');
|
|
|
|
break;
|
|
|
|
case GIIUC_Space:
|
|
|
|
case GIIUC_p:
|
|
|
|
case GIIUC_P:
|
|
|
|
mplayer_put_key('p');
|
|
|
|
break;
|
|
|
|
case GIIK_Up:
|
|
|
|
mplayer_put_key(KEY_UP);
|
|
|
|
break;
|
|
|
|
case GIIK_Down:
|
|
|
|
mplayer_put_key(KEY_DOWN);
|
|
|
|
break;
|
|
|
|
case GIIK_Left:
|
|
|
|
mplayer_put_key(KEY_LEFT);
|
|
|
|
break;
|
|
|
|
case GIIK_Right:
|
|
|
|
mplayer_put_key(KEY_RIGHT);
|
|
|
|
break;
|
|
|
|
case GIIK_PageUp:
|
|
|
|
mplayer_put_key(KEY_PAGE_UP);
|
|
|
|
break;
|
|
|
|
case GIIK_PageDown:
|
|
|
|
mplayer_put_key(KEY_PAGE_DOWN);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
2001-06-15 16:31:19 +00:00
|
|
|
}
|