1
0
mirror of https://github.com/mpv-player/mpv synced 2025-04-01 00:07:33 +00:00

reworked :) should work on low bpp outputs

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4831 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
alex 2002-02-24 02:21:14 +00:00
parent 7ef7eddfc5
commit 21043e0d28

View File

@ -27,14 +27,10 @@
#undef GET_DB_INFO #undef GET_DB_INFO
/* max buffers */
#define GGI_FRAMES 4 #define GGI_FRAMES 4
/* do not make conversions from planar formats */
#undef GGI_YUV_SUPPORT
#ifndef GGI_YUV_SUPPORT
#include "../postproc/rgb2rgb.h" #include "../postproc/rgb2rgb.h"
#endif
LIBVO_EXTERN (ggi) LIBVO_EXTERN (ggi)
@ -56,91 +52,82 @@ static struct ggi_conf_s {
int frames; int frames;
int currframe; int currframe;
uint8_t bpp; /* source image format */
uint8_t bppmul; int srcwidth;
int srcheight;
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 srcwidth, srcheight;
int srcformat; int srcformat;
int srcdepth; int srcdepth;
int srctype;
/* destination */ /* destination */
int dstwidth, dstheight; int dstwidth;
int dstheight;
/* source image format */
int format;
} ggi_conf; } ggi_conf;
static int ggi_setmode(uint32_t d_width, uint32_t d_height, int d_depth) static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format,const vo_tune_info_t *info)
{ {
ggi_mode mode = ggi_mode mode =
{ {
GGI_FRAMES, /* frames */ GGI_FRAMES, /* frames */
{ GGI_AUTO, GGI_AUTO }, /* visible */ { width, height }, /* visible */
{ GGI_AUTO, GGI_AUTO }, /* virt */ { GGI_AUTO, GGI_AUTO }, /* virt */
{ GGI_AUTO, GGI_AUTO }, /* size */ { GGI_AUTO, GGI_AUTO }, /* size */
GT_AUTO, /* graphtype */ GT_AUTO, /* graphtype */
{ GGI_AUTO, GGI_AUTO } /* dots per pixel */ { GGI_AUTO, GGI_AUTO } /* dots per pixel */
}; };
ggi_color pal[256]; int i;
ggi_directbuffer *DB;
mp_msg(MSGT_VO, MSGL_V, "[ggi] mode requested: %dx%d (%d depth)\n", switch(format)
d_width, d_height, d_depth);
// mode.size.x = vo_screenwidth;
// mode.size.y = vo_screenheight;
mode.visible.x = d_width;
mode.visible.y = d_height;
switch(d_depth)
{ {
case 1: case IMGFMT_RGB|8:
mode.graphtype = GT_1BIT; case IMGFMT_BGR|8:
break;
case 2:
mode.graphtype = GT_2BIT;
break;
case 4:
mode.graphtype = GT_4BIT;
break;
case 8:
mode.graphtype = GT_8BIT; mode.graphtype = GT_8BIT;
break; break;
case 15: case IMGFMT_RGB|15:
case IMGFMT_BGR|15:
mode.graphtype = GT_15BIT; mode.graphtype = GT_15BIT;
break; break;
case 16: case IMGFMT_RGB|16:
case IMGFMT_BGR|16:
mode.graphtype = GT_16BIT; mode.graphtype = GT_16BIT;
break; break;
case 24: case IMGFMT_RGB|24:
case IMGFMT_BGR|24:
mode.graphtype = GT_24BIT; mode.graphtype = GT_24BIT;
break; break;
case 32: case IMGFMT_RGB|32:
case IMGFMT_BGR|32:
mode.graphtype = GT_32BIT; mode.graphtype = GT_32BIT;
break; break;
default:
mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unknown bit depth - using auto\n");
mode.graphtype = GT_AUTO;
} }
/* FIXME */ #if 1
printf("[ggi] mode: ");
ggiPrintMode(&mode);
printf("\n");
#endif
ggiCheckMode(ggi_conf.vis, &mode); ggiCheckMode(ggi_conf.vis, &mode);
if (ggiSetMode(ggi_conf.vis, &mode) != 0) switch(format)
{
case IMGFMT_YV12:
mode.graphtype = GT_32BIT;
if (!ggiSetMode(ggi_conf.vis, &mode))
break;
mode.graphtype = GT_24BIT;
if (!ggiSetMode(ggi_conf.vis, &mode))
break;
mode.graphtype = GT_16BIT;
if (!ggiSetMode(ggi_conf.vis, &mode))
break;
mode.graphtype = GT_15BIT;
if (!ggiSetMode(ggi_conf.vis, &mode))
break;
}
if (ggiSetMode(ggi_conf.vis, &mode))
{ {
mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to set mode\n"); mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to set mode\n");
uninit(); uninit();
@ -156,68 +143,33 @@ static int ggi_setmode(uint32_t d_width, uint32_t d_height, int d_depth)
ggi_conf.gmode = mode; ggi_conf.gmode = mode;
vo_screenwidth = mode.visible.x; #if 1
vo_screenheight = mode.visible.y;
vo_depthonscreen = d_depth;
// vo_depthonscreen = GT_DEPTH(mode.graphtype);
// ggi_bpp = GT_SIZE(mode.graphtype);
ggi_conf.bpp = vo_depthonscreen;
#ifdef GET_DB_INFO
{
const ggi_directbuffer *db = ggiDBGetBuffer(ggi_conf.vis, 0);
if (db)
{
vo_depthonscreen = db->buffer.plb.pixelformat->depth;
ggi_conf.bpp = db->buffer.plb.pixelformat->size / 8;
}
}
#endif
if (GT_SCHEME(mode.graphtype) == GT_PALETTE)
{
ggiSetColorfulPalette(ggi_conf.vis);
ggiGetPalette(ggi_conf.vis, 0, 1 << ggi_conf.bpp, pal);
}
#if 0
printf("[ggi] mode: "); printf("[ggi] mode: ");
ggiPrintMode(&ggi_conf.gmode); ggiPrintMode(&mode);
printf("\n"); printf("\n");
#endif #endif
mp_msg(MSGT_VO, MSGL_INFO, "[ggi] screen: %dx%dx%d frames: %d\n", vo_depthonscreen = GT_DEPTH(mode.graphtype);
vo_screenwidth, vo_screenheight, vo_depthonscreen, ggi_conf.gmode.frames); vo_screenwidth = mode.visible.x;
vo_screenheight = mode.visible.y;
ggi_conf.bppmul = (ggi_conf.bpp+7)/8; vo_dx = vo_dy = 0;
vo_dwidth = mode.virt.x;
vo_dheight = mode.virt.y;
vo_dbpp = GT_ByPP(mode.graphtype);
return(0);
}
static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format,const vo_tune_info_t *info)
{
int i;
vo_depthonscreen = 32;
mp_msg(MSGT_VO, MSGL_INFO, "[ggi] This driver has got bugs, if you can, fix them.\n");
/* source image parameters */
ggi_conf.srcwidth = width; ggi_conf.srcwidth = width;
ggi_conf.srcheight = height; ggi_conf.srcheight = height;
ggi_conf.srcformat = format; ggi_conf.srcformat = format;
if (IMGFMT_IS_RGB(ggi_conf.srcformat)) if (IMGFMT_IS_RGB(ggi_conf.srcformat))
{ {
ggi_conf.srcdepth = IMGFMT_RGB_DEPTH(ggi_conf.srcformat); ggi_conf.srcdepth = IMGFMT_RGB_DEPTH(ggi_conf.srcformat);
ggi_conf.srctype = RGB;
} }
else else
if (IMGFMT_IS_BGR(ggi_conf.srcformat)) if (IMGFMT_IS_BGR(ggi_conf.srcformat))
{ {
ggi_conf.srcdepth = IMGFMT_BGR_DEPTH(ggi_conf.srcformat); ggi_conf.srcdepth = IMGFMT_BGR_DEPTH(ggi_conf.srcformat);
ggi_conf.srctype = BGR;
} }
else else
switch(ggi_conf.srcformat) switch(ggi_conf.srcformat)
@ -225,25 +177,8 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
case IMGFMT_IYUV: case IMGFMT_IYUV:
case IMGFMT_I420: case IMGFMT_I420:
case IMGFMT_YV12: case IMGFMT_YV12:
#ifdef GGI_YUV_SUPPORT ggi_conf.srcdepth = vo_dbpp*8;
ggi_conf.srcdepth = 12; yuv2rgb_init(ggi_conf.srcdepth, MODE_RGB);
ggi_conf.srctype = YUV;
#else
ggi_conf.bpp = vo_depthonscreen;
ggi_conf.mode = RGB;
yuv2rgb_init(vo_depthonscreen, MODE_RGB);
#endif
break;
case IMGFMT_UYVY:
case IMGFMT_YUY2:
#ifdef GGI_YUV_SUPPORT
ggi_conf.srcdepth = 16;
ggi_conf.srctype = YUV;
#else
ggi_conf.bpp = vo_depthonscreen;
ggi_conf.mode = RGB;
yuv2rgb_init(vo_depthonscreen, MODE_RGB);
#endif
break; break;
default: default:
mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] Unknown image format: %s\n", mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] Unknown image format: %s\n",
@ -252,57 +187,16 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
return(-1); return(-1);
} }
ggi_conf.format = format; vo_dwidth = ggi_conf.dstwidth = ggi_conf.gmode.virt.x;
vo_dheight = ggi_conf.dstheight = ggi_conf.gmode.virt.y;
ggi_conf.framePlaneRGB = width * height * ((ggi_conf.bpp+7)/8); /* fix it! */
ggi_conf.stridePlaneRGB = width * ((ggi_conf.bpp+7)/8);
#ifdef GGI_YUV_SUPPORT
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;
{
#if 0
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;
}
#endif
if (ggi_setmode(width, height, vo_depthonscreen) != 0)
{
printf("ggi-init: setmode returned with error\n");
return(-1);
}
}
mp_msg(MSGT_VO, MSGL_INFO, "[ggi] input: %d bpp %s - screen depth: %d\n",
ggi_conf.bpp, vo_format_name(ggi_conf.format), vo_depthonscreen);
// ggiSetFlags(ggi_conf.vis, GGIFLAG_ASYNC);
{
ggi_directbuffer *DB;
for (i = 0; i < GGI_FRAMES; i++) for (i = 0; i < GGI_FRAMES; i++)
ggi_conf.buffer[i] = NULL; ggi_conf.buffer[i] = NULL;
ggi_conf.frames = ggi_conf.currframe = 0; ggi_conf.frames = ggi_conf.currframe = 0;
for (i = 0; DB = ggiDBGetBuffer(ggi_conf.vis, i); i++) /* get available number of buffers */
for (i = 0; DB = ggiDBGetBuffer(ggi_conf.vis, i), i < GGI_FRAMES; i++)
{ {
if (!(DB->type & GGI_DB_SIMPLE_PLB) || if (!(DB->type & GGI_DB_SIMPLE_PLB) ||
(DB->page_size != 0) || (DB->page_size != 0) ||
@ -315,12 +209,10 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
ggi_conf.buffer[DB->frame] = DB; ggi_conf.buffer[DB->frame] = DB;
ggi_conf.frames++; ggi_conf.frames++;
} }
}
if (ggi_conf.buffer[0] == NULL) if (ggi_conf.buffer[0] == NULL)
{ {
mp_msg(MSGT_VO, MSGL_ERR, "[ggi] direct buffer is not available\n"); mp_msg(MSGT_VO, MSGL_ERR, "[ggi] direct buffer unavailable\n");
uninit(); uninit();
return(-1); return(-1);
} }
@ -329,15 +221,18 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
{ {
if (ggi_conf.buffer[i] == NULL) if (ggi_conf.buffer[i] == NULL)
{ {
mp_msg(MSGT_VO, MSGL_ERR, "[ggi] direct buffer for doublbuffering is not available\n"); ggi_conf.frames = i-1;
uninit(); break;
return(-1);
} }
} }
ggiSetDisplayFrame(ggi_conf.vis, ggi_conf.currframe); ggiSetDisplayFrame(ggi_conf.vis, ggi_conf.currframe);
ggiSetWriteFrame(ggi_conf.vis, ggi_conf.currframe); ggiSetWriteFrame(ggi_conf.vis, ggi_conf.currframe);
mp_msg(MSGT_VO, MSGL_INFO, "[ggi] input: %dx%dx%d, output: %dx%dx%d, frames: %d\n",
ggi_conf.srcwidth, ggi_conf.srcheight, ggi_conf.srcdepth,
vo_dwidth, vo_dheight, vo_dbpp*8, ggi_conf.frames);
return(0); return(0);
} }
@ -356,7 +251,6 @@ static uint32_t draw_frame(uint8_t *src[])
ggiSetWriteFrame(ggi_conf.vis, ggi_conf.currframe); ggiSetWriteFrame(ggi_conf.vis, ggi_conf.currframe);
#if 1
ptr = ggi_conf.buffer[ggi_conf.currframe]->write; ptr = ggi_conf.buffer[ggi_conf.currframe]->write;
spt = src[0]; spt = src[0];
size = ggi_conf.buffer[ggi_conf.currframe]->buffer.plb.pixelformat->size/8; size = ggi_conf.buffer[ggi_conf.currframe]->buffer.plb.pixelformat->size/8;
@ -369,7 +263,7 @@ static uint32_t draw_frame(uint8_t *src[])
ptr2[0] = *spt++; ptr2[0] = *spt++;
ptr2[1] = *spt++; ptr2[1] = *spt++;
ptr2[2] = *spt++; ptr2[2] = *spt++;
switch(ggi_conf.format) switch(ggi_conf.srcformat)
{ {
case IMGFMT_BGR32: case IMGFMT_BGR32:
case IMGFMT_RGB32: case IMGFMT_RGB32:
@ -380,9 +274,6 @@ static uint32_t draw_frame(uint8_t *src[])
} }
ptr += ggi_conf.buffer[ggi_conf.currframe]->buffer.plb.stride; ptr += ggi_conf.buffer[ggi_conf.currframe]->buffer.plb.stride;
} }
#else
memcpy(ggi_conf.buffer[ggi_conf.currframe]->write, src[0], ggi_conf.framePlaneRGB);
#endif
ggiResourceRelease(ggi_conf.buffer[ggi_conf.currframe]->resource); ggiResourceRelease(ggi_conf.buffer[ggi_conf.currframe]->resource);
return(0); return(0);
@ -391,67 +282,23 @@ static uint32_t draw_frame(uint8_t *src[])
static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
unsigned char *srca, int stride) unsigned char *srca, int stride)
{ {
switch(ggi_conf.format) switch(vo_dbpp*8)
{
case IMGFMT_YV12:
case IMGFMT_I420:
case IMGFMT_IYUV:
#ifdef GGI_YUV_SUPPORT
vo_draw_alpha_yv12(w, h, src, srca, stride,
ggi_conf.buffer[ggi_conf.currframe]->write+(ggi_conf.srcwidth*y0+x0),
ggi_conf.srcwidth);
#else
switch (vo_depthonscreen)
{ {
case 32: case 32:
vo_draw_alpha_rgb32(w, h, src, srca, stride, vo_draw_alpha_rgb32(w, h, src, srca, stride,
ggi_conf.buffer[ggi_conf.currframe]->write+4*(ggi_conf.srcwidth*y0+x0), 4*ggi_conf.srcwidth); ggi_conf.buffer[ggi_conf.currframe]->write+4*(ggi_conf.dstwidth*y0+x0), 4*ggi_conf.dstwidth);
break; break;
case 24: case 24:
vo_draw_alpha_rgb24(w, h, src, srca, stride, vo_draw_alpha_rgb24(w, h, src, srca, stride,
ggi_conf.buffer[ggi_conf.currframe]->write+3*(ggi_conf.srcwidth*y0+x0), 3*ggi_conf.srcwidth); ggi_conf.buffer[ggi_conf.currframe]->write+3*(ggi_conf.dstwidth*y0+x0), 3*ggi_conf.dstwidth);
break; break;
case 16: case 16:
vo_draw_alpha_rgb16(w, h, src, srca, stride, vo_draw_alpha_rgb16(w, h, src, srca, stride,
ggi_conf.buffer[ggi_conf.currframe]->write+2*(ggi_conf.srcwidth*y0+x0), 2*ggi_conf.srcwidth); ggi_conf.buffer[ggi_conf.currframe]->write+2*(ggi_conf.dstwidth*y0+x0), 2*ggi_conf.dstwidth);
break; break;
case 15: case 15:
vo_draw_alpha_rgb15(w, h, src, srca, stride, vo_draw_alpha_rgb15(w, h, src, srca, stride,
ggi_conf.buffer[ggi_conf.currframe]->write+2*(ggi_conf.srcwidth*y0+x0), 2*ggi_conf.srcwidth); ggi_conf.buffer[ggi_conf.currframe]->write+2*(ggi_conf.dstwidth*y0+x0), 2*ggi_conf.dstwidth);
break;
}
#endif
break;
case IMGFMT_YUY2:
case IMGFMT_YVYU:
vo_draw_alpha_yuy2(w, h, src, srca, stride,
ggi_conf.buffer[ggi_conf.currframe]->write+2*(ggi_conf.srcwidth*y0+x0),
2*ggi_conf.srcwidth);
break;
case IMGFMT_UYVY:
vo_draw_alpha_yuy2(w, h, src, srca, stride,
ggi_conf.buffer[ggi_conf.currframe]->write+2*(ggi_conf.srcwidth*y0+x0)+1,
2*ggi_conf.srcwidth);
break;
case IMGFMT_RGB15:
case IMGFMT_BGR15:
vo_draw_alpha_rgb15(w, h, src, srca, stride,
ggi_conf.buffer[ggi_conf.currframe]->write+2*(ggi_conf.srcwidth*y0+x0), 2*ggi_conf.srcwidth);
break;
case IMGFMT_RGB16:
case IMGFMT_BGR16:
vo_draw_alpha_rgb16(w, h, src, srca, stride,
ggi_conf.buffer[ggi_conf.currframe]->write+2*(ggi_conf.srcwidth*y0+x0), 2*ggi_conf.srcwidth);
break;
case IMGFMT_RGB24:
case IMGFMT_BGR24:
vo_draw_alpha_rgb24(w, h, src, srca, stride,
ggi_conf.buffer[ggi_conf.currframe]->write+3*(ggi_conf.srcwidth*y0+x0), 3*ggi_conf.srcwidth);
break;
case IMGFMT_RGB32:
case IMGFMT_BGR32:
vo_draw_alpha_rgb32(w, h, src, srca, stride,
ggi_conf.buffer[ggi_conf.currframe]->write+4*(ggi_conf.srcwidth*y0+x0), 4*ggi_conf.srcwidth);
break; break;
} }
} }
@ -478,36 +325,11 @@ static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h,
ggiSetWriteFrame(ggi_conf.vis, ggi_conf.currframe); ggiSetWriteFrame(ggi_conf.vis, ggi_conf.currframe);
#ifndef GGI_YUV_SUPPORT
yuv2rgb(((uint8_t *) ggi_conf.buffer[ggi_conf.currframe]->write)+ yuv2rgb(((uint8_t *) ggi_conf.buffer[ggi_conf.currframe]->write)+
ggi_conf.buffer[ggi_conf.currframe]->buffer.plb.stride*y+ ggi_conf.buffer[ggi_conf.currframe]->buffer.plb.stride*y+
x*(ggi_conf.buffer[ggi_conf.currframe]->buffer.plb.pixelformat->size/8), x*(ggi_conf.buffer[ggi_conf.currframe]->buffer.plb.pixelformat->size/8),
src[0], src[1], src[2], w, h, ggi_conf.buffer[ggi_conf.currframe]->buffer.plb.stride, src[0], src[1], src[2], w, h, ggi_conf.buffer[ggi_conf.currframe]->buffer.plb.stride,
stride[0], stride[1]); stride[0], stride[1]);
#else
int i;
ggi_conf.buffer[ggi_conf.currframe]->write += (ggi_conf.stridePlaneY * y + x);
for (i = 0; i < h; i++)
{
memcpy(ggi_conf.buffer[ggi_conf.currframe]->write, src[0], w);
src[0] += stride[0];
ggi_conf.buffer[ggi_conf.currframe]->write += ggi_conf.stridePlaneY;
}
x /= 2;
y /= 2;
w /= 2;
h /= 2;
ggi_conf.buffer[ggi_conf.currframe]->write += ggi_conf.stridePlaneY + (ggi_conf.stridePlaneUV * y + x);
for (i = 0; i < h; i++)
{
memcpy(ggi_conf.buffer[ggi_conf.currframe]->write, src[1], w);
src[1] += stride[1];
ggi_conf.buffer[ggi_conf.currframe]->write += ggi_conf.stridePlaneUV;
}
#endif
ggiResourceRelease(ggi_conf.buffer[ggi_conf.currframe]->resource); ggiResourceRelease(ggi_conf.buffer[ggi_conf.currframe]->resource);
return(0); return(0);
@ -520,9 +342,6 @@ static uint32_t query_format(uint32_t format)
case IMGFMT_YV12: case IMGFMT_YV12:
case IMGFMT_I420: case IMGFMT_I420:
case IMGFMT_IYUV: case IMGFMT_IYUV:
/* case IMGFMT_YUY2:
case IMGFMT_YVYU:
case IMGFMT_UYVY:*/
return(0x6); return(0x6);
case IMGFMT_RGB8: case IMGFMT_RGB8:
case IMGFMT_RGB15: case IMGFMT_RGB15: