2001-04-05 08:42:02 +00:00
|
|
|
/*
|
2001-04-06 10:25:47 +00:00
|
|
|
Video driver for SVGAlib - alpha, slow
|
2001-04-05 08:42:02 +00:00
|
|
|
by Zoltan Mark Vician <se7en@sch.bme.hu>
|
2001-04-12 22:10:28 +00:00
|
|
|
Code started: Mon Apr 1 23:25:47 2001
|
2001-04-14 17:51:37 +00:00
|
|
|
|
|
|
|
Uses HW acceleration if your card is supported by SVGAlib.
|
2001-04-05 08:42:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <vga.h>
|
|
|
|
#include <vgagl.h>
|
|
|
|
|
2001-04-17 17:35:27 +00:00
|
|
|
#include <limits.h>
|
|
|
|
|
2001-04-05 08:42:02 +00:00
|
|
|
#include "config.h"
|
|
|
|
#include "video_out.h"
|
|
|
|
#include "video_out_internal.h"
|
|
|
|
|
|
|
|
#include "yuv2rgb.h"
|
2001-04-12 17:30:50 +00:00
|
|
|
#include "mmx.h"
|
2001-04-05 08:42:02 +00:00
|
|
|
|
2001-04-24 11:42:04 +00:00
|
|
|
#include "sub.h"
|
|
|
|
|
2001-04-14 17:51:37 +00:00
|
|
|
extern void rgb15to16_mmx(char* s0,char* d0,int count);
|
2001-04-17 17:35:27 +00:00
|
|
|
extern int vo_dbpp;
|
2001-04-18 18:14:11 +00:00
|
|
|
extern int verbose;
|
2001-04-14 17:51:37 +00:00
|
|
|
|
2001-04-05 08:42:02 +00:00
|
|
|
LIBVO_EXTERN(svga)
|
|
|
|
|
|
|
|
static vo_info_t vo_info = {
|
|
|
|
"SVGAlib",
|
|
|
|
"svga",
|
|
|
|
"Zoltan Mark Vician <se7en@sch.bme.hu>",
|
|
|
|
""
|
|
|
|
};
|
|
|
|
|
|
|
|
// SVGAlib definitions
|
|
|
|
|
|
|
|
GraphicsContext *screen;
|
|
|
|
GraphicsContext *virt;
|
|
|
|
|
2001-04-14 17:51:37 +00:00
|
|
|
static uint8_t *scalebuf = NULL, *yuvbuf = NULL, *bppbuf = NULL;
|
2001-04-05 08:42:02 +00:00
|
|
|
|
|
|
|
static uint32_t orig_w, orig_h, maxw, maxh; // Width, height
|
2001-04-12 17:30:50 +00:00
|
|
|
static float scaling = 1.0;
|
2001-04-05 08:42:02 +00:00
|
|
|
static uint32_t x_pos, y_pos; // Position
|
|
|
|
|
2001-04-17 06:22:48 +00:00
|
|
|
// SVGAlib - list of detected modes
|
|
|
|
typedef struct vga_modelist_s {
|
|
|
|
uint16_t modenum;
|
|
|
|
vga_modeinfo modeinfo;
|
|
|
|
struct vga_modelist_s *next;
|
|
|
|
} vga_modelist_t;
|
|
|
|
|
|
|
|
vga_modelist_t *modelist = NULL;
|
2001-04-05 08:42:02 +00:00
|
|
|
|
2001-04-17 06:22:48 +00:00
|
|
|
static uint8_t bpp;
|
|
|
|
static uint8_t bpp_conv = 0;
|
2001-04-15 20:31:58 +00:00
|
|
|
static uint32_t pformat;
|
2001-04-15 19:35:34 +00:00
|
|
|
|
2001-04-17 06:22:48 +00:00
|
|
|
#define BPP_15 1
|
|
|
|
#define BPP_16 2
|
|
|
|
#define BPP_24 4
|
|
|
|
#define BPP_32 8
|
|
|
|
static uint8_t bpp_avail = 0;
|
|
|
|
|
2001-04-05 08:42:02 +00:00
|
|
|
static uint8_t checked = 0;
|
|
|
|
|
2001-04-17 17:35:27 +00:00
|
|
|
static uint32_t add_mode(uint16_t mode, vga_modeinfo minfo) {
|
2001-04-17 06:22:48 +00:00
|
|
|
vga_modelist_t *list;
|
|
|
|
|
|
|
|
if (modelist == NULL) {
|
2001-04-17 17:35:27 +00:00
|
|
|
modelist = (vga_modelist_t *) malloc(sizeof(vga_modelist_t));
|
2001-04-17 06:22:48 +00:00
|
|
|
if (modelist == NULL) {
|
|
|
|
printf("vo_svga: add_mode() failed. Not enough memory for modelist.");
|
|
|
|
return(1); // error
|
|
|
|
}
|
2001-04-17 17:35:27 +00:00
|
|
|
modelist->modenum = mode;
|
|
|
|
modelist->modeinfo = minfo;
|
|
|
|
modelist->next = NULL;
|
2001-04-17 06:22:48 +00:00
|
|
|
} else {
|
|
|
|
list = modelist;
|
|
|
|
while (list->next != NULL)
|
|
|
|
list = list->next;
|
2001-04-17 17:35:27 +00:00
|
|
|
list->next = (vga_modelist_t *) malloc(sizeof(vga_modelist_t));
|
2001-04-17 06:22:48 +00:00
|
|
|
if (list->next == NULL) {
|
|
|
|
printf("vo_svga: add_mode() failed. Not enough memory for modelist.");
|
|
|
|
return(1); // error
|
|
|
|
}
|
|
|
|
list = list->next;
|
|
|
|
list->modenum = mode;
|
|
|
|
list->modeinfo = minfo;
|
|
|
|
list->next = NULL;
|
|
|
|
}
|
2001-04-17 17:35:27 +00:00
|
|
|
return (0);
|
2001-04-17 06:22:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int checksupportedmodes() {
|
2001-04-17 17:35:27 +00:00
|
|
|
uint16_t i, max;
|
2001-04-17 06:22:48 +00:00
|
|
|
vga_modeinfo *minfo;
|
2001-04-05 08:42:02 +00:00
|
|
|
|
|
|
|
checked = 1;
|
|
|
|
vga_init();
|
|
|
|
vga_disabledriverreport();
|
2001-04-17 17:35:27 +00:00
|
|
|
max = vga_lastmodenumber();
|
|
|
|
for (i = 1; i < max; i++)
|
2001-04-17 06:22:48 +00:00
|
|
|
if (vga_hasmode(i) > 0) {
|
|
|
|
minfo = vga_getmodeinfo(i);
|
|
|
|
switch (minfo->colors) {
|
|
|
|
case 32768: bpp_avail |= BPP_15; break;
|
|
|
|
case 65536: bpp_avail |= BPP_16; break;
|
|
|
|
}
|
|
|
|
switch (minfo->bytesperpixel) {
|
|
|
|
case 3: bpp_avail |= BPP_24; break;
|
|
|
|
case 4: bpp_avail |= BPP_32; break;
|
|
|
|
}
|
2001-04-18 18:14:11 +00:00
|
|
|
if (verbose >= 2)
|
|
|
|
printf("vo_svga: Mode found: %s\n",vga_getmodename(i));
|
2001-04-17 06:22:48 +00:00
|
|
|
if (add_mode(i, *minfo))
|
|
|
|
return(1);
|
|
|
|
}
|
2001-04-17 17:35:27 +00:00
|
|
|
return(0);
|
2001-04-05 08:42:02 +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-04-17 06:22:48 +00:00
|
|
|
uint32_t req_w = (d_width > 0 ? d_width : width);
|
|
|
|
uint32_t req_h = (d_height > 0 ? d_height : height);
|
|
|
|
uint16_t vid_mode = 0;
|
2001-06-03 23:10:37 +00:00
|
|
|
uint8_t res_widescr, vid_widescr = (((req_w*1.0)/req_h) > (4.0/3)) ? 1 : 0;
|
2001-04-17 17:35:27 +00:00
|
|
|
uint16_t buf_w = USHRT_MAX, buf_h = USHRT_MAX;
|
2001-04-17 06:22:48 +00:00
|
|
|
vga_modelist_t *list = modelist;
|
2001-04-13 13:02:13 +00:00
|
|
|
|
2001-04-05 08:42:02 +00:00
|
|
|
if (!checked) {
|
2001-04-17 17:35:27 +00:00
|
|
|
if (checksupportedmodes()) // Looking for available video modes
|
2001-04-17 06:22:48 +00:00
|
|
|
return(1);
|
2001-04-05 08:42:02 +00:00
|
|
|
}
|
2001-04-14 17:51:37 +00:00
|
|
|
|
2001-04-17 06:22:48 +00:00
|
|
|
bpp_avail = 0;
|
|
|
|
while (list != NULL) {
|
|
|
|
if ((list->modeinfo.width >= req_w) && (list->modeinfo.height >= req_h)) {
|
|
|
|
switch (list->modeinfo.colors) {
|
|
|
|
case 32768: bpp_avail |= BPP_15; break;
|
|
|
|
case 65536: bpp_avail |= BPP_16; break;
|
|
|
|
}
|
|
|
|
switch (list->modeinfo.bytesperpixel) {
|
|
|
|
case 3: bpp_avail |= BPP_24; break;
|
|
|
|
case 4: bpp_avail |= BPP_32; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
|
2001-04-05 08:42:02 +00:00
|
|
|
pformat = format;
|
2001-04-14 18:19:40 +00:00
|
|
|
|
2001-04-17 06:22:48 +00:00
|
|
|
// bpp check
|
|
|
|
bpp_conv = 0;
|
2001-04-14 18:19:40 +00:00
|
|
|
if (!vo_dbpp) {
|
|
|
|
if (format == IMGFMT_YV12) bpp = 32;
|
|
|
|
else bpp = format & 255;
|
2001-04-18 18:14:11 +00:00
|
|
|
if (verbose)
|
|
|
|
printf("vo_svga: vo_dbpp == 0, bpp: %d\n",bpp);
|
2001-04-17 06:22:48 +00:00
|
|
|
switch (bpp) {
|
|
|
|
case 32: if (!(bpp_avail & BPP_32)) {
|
|
|
|
printf("vo_svga: Haven't found video mode which fit to: %dx%d %dbpp\n",req_w,req_h,bpp);
|
2001-04-17 17:35:27 +00:00
|
|
|
printf("vo_svga: Maybe you should try -bpp\n");
|
2001-04-17 06:22:48 +00:00
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
break;
|
2001-04-24 12:34:08 +00:00
|
|
|
case 24: if (!(bpp_avail & BPP_24)) {
|
2001-04-17 06:22:48 +00:00
|
|
|
if (!(bpp_avail & BPP_32)) {
|
|
|
|
printf("vo_svga: Haven't found video mode which fit to: %dx%d %dbpp\n",req_w,req_h,bpp);
|
2001-04-17 17:35:27 +00:00
|
|
|
printf("vo_svga: Maybe you should try -bpp\n");
|
2001-04-17 06:22:48 +00:00
|
|
|
return(1);
|
|
|
|
} else {
|
|
|
|
bpp = 32;
|
|
|
|
bpp_conv = 1;
|
2001-04-24 12:21:42 +00:00
|
|
|
printf("vo_svga: BPP conversion 24->32\n");
|
2001-04-24 12:34:08 +00:00
|
|
|
}
|
|
|
|
}
|
2001-04-17 06:22:48 +00:00
|
|
|
break;
|
|
|
|
case 16: if (!(bpp_avail & BPP_16)) {
|
|
|
|
printf("vo_svga: Haven't found video mode which fit to: %dx%d %dbpp\n",req_w,req_h,bpp);
|
|
|
|
printf("vo_svga: Maybe you should try -bpp\n");
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
break;
|
2001-04-24 12:34:08 +00:00
|
|
|
case 15: if (!(bpp_avail & BPP_15)) {
|
2001-04-17 06:22:48 +00:00
|
|
|
if (!(bpp_avail & BPP_16)) {
|
|
|
|
printf("vo_svga: Haven't found video mode which fit to: %dx%d %dbpp\n",req_w,req_h,bpp);
|
|
|
|
printf("vo_svga: Maybe you should try -bpp\n");
|
|
|
|
return(1);
|
|
|
|
} else {
|
|
|
|
bpp = 16;
|
|
|
|
bpp_conv = 1;
|
2001-04-24 12:21:42 +00:00
|
|
|
printf("vo_svga: BPP conversion 15->16\n");
|
2001-04-17 06:22:48 +00:00
|
|
|
}
|
2001-04-24 12:34:08 +00:00
|
|
|
}
|
2001-04-17 06:22:48 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-04-14 18:19:40 +00:00
|
|
|
} else {
|
|
|
|
bpp = vo_dbpp;
|
2001-04-18 18:14:11 +00:00
|
|
|
if (verbose)
|
|
|
|
printf("vo_svga: vo_dbpp == %d\n",bpp);
|
2001-04-14 18:19:40 +00:00
|
|
|
switch (bpp) {
|
2001-04-17 06:22:48 +00:00
|
|
|
case 32: if (!(bpp_avail & BPP_32)) {
|
2001-04-17 17:35:27 +00:00
|
|
|
printf("vo_svga: %dbpp not supported in %dx%d (or larger resoltuion) by HW or SVGAlib\n",bpp,req_w,req_h);
|
2001-04-14 18:19:40 +00:00
|
|
|
return(1);
|
|
|
|
}
|
2001-04-17 17:35:27 +00:00
|
|
|
break;
|
2001-04-17 06:22:48 +00:00
|
|
|
case 24: if (!(bpp_avail & BPP_24)) {
|
2001-04-17 17:35:27 +00:00
|
|
|
printf("vo_svga: %dbpp not supported in %dx%d (or larger resoltuion) by HW or SVGAlib\n",bpp,req_w,req_h);
|
2001-04-14 18:19:40 +00:00
|
|
|
return(1);
|
|
|
|
}
|
2001-04-17 17:35:27 +00:00
|
|
|
break;
|
2001-04-17 06:22:48 +00:00
|
|
|
case 16: if (!(bpp_avail & BPP_16)) {
|
2001-04-17 17:35:27 +00:00
|
|
|
printf("vo_svga: %dbpp not supported in %dx%d (or larger resoltuion) by HW or SVGAlib\n",bpp,req_w,req_h);
|
2001-04-14 18:19:40 +00:00
|
|
|
return(1);
|
|
|
|
}
|
2001-04-17 17:35:27 +00:00
|
|
|
break;
|
2001-04-17 06:22:48 +00:00
|
|
|
case 15: if (!(bpp_avail & BPP_15)) {
|
2001-04-17 17:35:27 +00:00
|
|
|
printf("vo_svga: %dbpp not supported in %dx%d (or larger resoltuion) by HW or SVGAlib\n",bpp,req_w,req_h);
|
2001-04-14 18:19:40 +00:00
|
|
|
return(1);
|
|
|
|
}
|
2001-04-17 17:35:27 +00:00
|
|
|
break;
|
2001-04-14 18:19:40 +00:00
|
|
|
}
|
|
|
|
}
|
2001-04-17 06:22:48 +00:00
|
|
|
|
|
|
|
list = modelist;
|
2001-04-18 18:14:11 +00:00
|
|
|
if (verbose) {
|
|
|
|
printf("vo_svga: Looking for the best resolution...\n");
|
|
|
|
printf("vo_svga: req_w: %d, req_h: %d, bpp: %d\n",req_w,req_h,bpp);
|
|
|
|
}
|
2001-04-17 17:35:27 +00:00
|
|
|
while (list != NULL) {
|
2001-04-17 06:22:48 +00:00
|
|
|
if ((list->modeinfo.width >= req_w) && (list->modeinfo.height >= req_h)) {
|
2001-04-18 18:14:11 +00:00
|
|
|
if (verbose) {
|
|
|
|
switch (list->modeinfo.colors) {
|
|
|
|
case 32768: printf("vo_svga: vid_mode: %d, %dx%d 15bpp\n",list->modenum,list->modeinfo.width,list->modeinfo.height);
|
|
|
|
break;
|
|
|
|
case 65536: printf("vo_svga: vid_mode: %d, %dx%d 16bpp\n",list->modenum,list->modeinfo.width,list->modeinfo.height);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch (list->modeinfo.bytesperpixel) {
|
|
|
|
case 3: printf("vo_svga: vid_mode: %d, %dx%d 24bpp\n",list->modenum,list->modeinfo.width,list->modeinfo.height);
|
|
|
|
break;
|
|
|
|
case 4: printf("vo_svga: vid_mode: %d, %dx%d 32bpp\n",list->modenum,list->modeinfo.width,list->modeinfo.height);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-04-15 20:31:58 +00:00
|
|
|
switch (bpp) {
|
2001-04-17 06:22:48 +00:00
|
|
|
case 32: if (list->modeinfo.bytesperpixel == 4)
|
2001-04-17 17:35:27 +00:00
|
|
|
if ((list->modeinfo.width < buf_w) || (list->modeinfo.height < buf_h)) {
|
|
|
|
vid_mode = list->modenum;
|
|
|
|
buf_w = list->modeinfo.width;
|
|
|
|
buf_h = list->modeinfo.height;
|
2001-06-03 23:10:37 +00:00
|
|
|
res_widescr = (((buf_w*1.0)/buf_h) > (4.0/3)) ? 1 : 0;
|
2001-04-17 17:35:27 +00:00
|
|
|
}
|
|
|
|
break;
|
2001-04-17 06:22:48 +00:00
|
|
|
case 24: if (list->modeinfo.bytesperpixel == 3)
|
2001-04-17 17:35:27 +00:00
|
|
|
if ((list->modeinfo.width < buf_w) || (list->modeinfo.height < buf_h)) {
|
|
|
|
vid_mode = list->modenum;
|
|
|
|
buf_w = list->modeinfo.width;
|
|
|
|
buf_h = list->modeinfo.height;
|
2001-06-03 23:10:37 +00:00
|
|
|
res_widescr = (((buf_w*1.0)/buf_h) > (4.0/3)) ? 1 : 0;
|
2001-04-17 17:35:27 +00:00
|
|
|
}
|
|
|
|
break;
|
2001-04-17 06:22:48 +00:00
|
|
|
case 16: if (list->modeinfo.colors == 65536)
|
2001-04-17 17:35:27 +00:00
|
|
|
if ((list->modeinfo.width < buf_w) || (list->modeinfo.height < buf_h)) {
|
|
|
|
vid_mode = list->modenum;
|
|
|
|
buf_w = list->modeinfo.width;
|
|
|
|
buf_h = list->modeinfo.height;
|
2001-06-03 23:10:37 +00:00
|
|
|
res_widescr = (((buf_w*1.0)/buf_h) > (4.0/3)) ? 1 : 0;
|
2001-04-17 17:35:27 +00:00
|
|
|
}
|
|
|
|
break;
|
2001-04-17 06:22:48 +00:00
|
|
|
case 15: if (list->modeinfo.colors == 32768)
|
2001-04-17 17:35:27 +00:00
|
|
|
if ((list->modeinfo.width < buf_w) || (list->modeinfo.height < buf_h)) {
|
|
|
|
vid_mode = list->modenum;
|
|
|
|
buf_w = list->modeinfo.width;
|
|
|
|
buf_h = list->modeinfo.height;
|
2001-06-03 23:10:37 +00:00
|
|
|
res_widescr = (((buf_w*1.0)/buf_h) > (4.0/3)) ? 1 : 0;
|
2001-04-17 17:35:27 +00:00
|
|
|
}
|
|
|
|
break;
|
2001-04-15 20:31:58 +00:00
|
|
|
}
|
2001-04-17 06:22:48 +00:00
|
|
|
}
|
|
|
|
list = list->next;
|
2001-04-14 17:51:37 +00:00
|
|
|
}
|
2001-04-17 17:35:27 +00:00
|
|
|
|
2001-04-18 18:14:11 +00:00
|
|
|
if (verbose)
|
|
|
|
printf("vo_svga: vid_mode: %d\n",vid_mode);
|
2001-04-14 17:51:37 +00:00
|
|
|
vga_setlinearaddressing();
|
2001-04-17 17:35:27 +00:00
|
|
|
if (vga_setmode(vid_mode) == -1) {
|
2001-04-05 19:01:27 +00:00
|
|
|
printf("vo_svga: vga_setmode(%d) failed.\n",vid_mode);
|
2001-04-17 06:22:48 +00:00
|
|
|
uninit();
|
2001-04-05 08:42:02 +00:00
|
|
|
return(1); // error
|
2001-04-17 17:35:27 +00:00
|
|
|
}
|
|
|
|
if (gl_setcontextvga(vid_mode)) {
|
2001-04-05 19:01:27 +00:00
|
|
|
printf("vo_svga: gl_setcontextvga(%d) failed.\n",vid_mode);
|
2001-04-17 06:22:48 +00:00
|
|
|
uninit();
|
2001-04-05 08:42:02 +00:00
|
|
|
return(1); // error
|
2001-04-05 19:01:27 +00:00
|
|
|
}
|
2001-04-05 08:42:02 +00:00
|
|
|
screen = gl_allocatecontext();
|
|
|
|
gl_getcontext(screen);
|
2001-04-17 17:35:27 +00:00
|
|
|
if (gl_setcontextvgavirtual(vid_mode)) {
|
2001-04-05 19:01:27 +00:00
|
|
|
printf("vo_svga: gl_setcontextvgavirtual(%d) failed.\n",vid_mode);
|
2001-04-17 06:22:48 +00:00
|
|
|
uninit();
|
2001-04-05 08:42:02 +00:00
|
|
|
return(1); // error
|
2001-04-05 19:01:27 +00:00
|
|
|
}
|
2001-04-05 08:42:02 +00:00
|
|
|
virt = gl_allocatecontext();
|
|
|
|
gl_getcontext(virt);
|
|
|
|
gl_setcontext(virt);
|
|
|
|
gl_clearscreen(0);
|
|
|
|
|
2001-04-17 17:35:27 +00:00
|
|
|
if (bpp_conv) {
|
2001-04-17 06:22:48 +00:00
|
|
|
bppbuf = malloc(maxw * maxh * BYTESPERPIXEL);
|
2001-04-17 17:35:27 +00:00
|
|
|
if (bppbuf == NULL) {
|
|
|
|
printf("vo_svga: bppbuf -> Not enough memory for buffering!\n");
|
|
|
|
uninit();
|
|
|
|
return (1);
|
|
|
|
}
|
2001-04-17 06:22:48 +00:00
|
|
|
}
|
|
|
|
|
2001-04-05 08:42:02 +00:00
|
|
|
orig_w = width;
|
|
|
|
orig_h = height;
|
2001-06-03 23:10:37 +00:00
|
|
|
if ((fullscreen & 0x04) && (WIDTH != orig_w) && (HEIGHT != orig_h)) {
|
|
|
|
if (!vid_widescr || !res_widescr) {
|
2001-04-06 10:25:47 +00:00
|
|
|
maxh = HEIGHT;
|
|
|
|
scaling = maxh / (orig_h * 1.0);
|
|
|
|
maxw = (uint32_t) (orig_w * scaling);
|
|
|
|
scalebuf = malloc(maxw * maxh * BYTESPERPIXEL);
|
2001-04-17 06:22:48 +00:00
|
|
|
if (scalebuf == NULL) {
|
2001-04-17 17:35:27 +00:00
|
|
|
printf("vo_svga: scalebuf -> Not enough memory for buffering!\n");
|
2001-04-14 17:51:37 +00:00
|
|
|
uninit();
|
|
|
|
return (1);
|
|
|
|
}
|
2001-04-06 10:25:47 +00:00
|
|
|
} else {
|
|
|
|
maxw = WIDTH;
|
|
|
|
scaling = maxw / (orig_w * 1.0);
|
|
|
|
maxh = (uint32_t) (orig_h * scaling);
|
|
|
|
scalebuf = malloc(maxw * maxh * BYTESPERPIXEL);
|
2001-04-17 06:22:48 +00:00
|
|
|
if (scalebuf == NULL) {
|
2001-04-17 17:35:27 +00:00
|
|
|
printf("vo_svga: scalebuf -> Not enough memory for buffering!\n");
|
2001-04-14 17:51:37 +00:00
|
|
|
uninit();
|
|
|
|
return (1);
|
|
|
|
}
|
2001-04-06 10:25:47 +00:00
|
|
|
}
|
2001-04-05 08:42:02 +00:00
|
|
|
} else {
|
|
|
|
maxw = orig_w;
|
|
|
|
maxh = orig_h;
|
|
|
|
}
|
|
|
|
x_pos = (WIDTH - maxw) / 2;
|
|
|
|
y_pos = (HEIGHT - maxh) / 2;
|
|
|
|
|
|
|
|
if (pformat == IMGFMT_YV12) {
|
|
|
|
yuv2rgb_init(bpp, MODE_RGB);
|
|
|
|
yuvbuf = malloc(maxw * maxh * BYTESPERPIXEL);
|
2001-04-17 06:22:48 +00:00
|
|
|
if (yuvbuf == NULL) {
|
2001-04-17 17:35:27 +00:00
|
|
|
printf("vo_svga: yuvbuf -> Not enough memory for buffering!\n");
|
2001-04-14 17:51:37 +00:00
|
|
|
uninit();
|
|
|
|
return (1);
|
|
|
|
}
|
2001-04-05 08:42:02 +00:00
|
|
|
}
|
2001-04-12 17:30:50 +00:00
|
|
|
|
2001-04-18 18:14:11 +00:00
|
|
|
printf("vo_svga: SVGAlib resolution: %dx%d %dbpp - ", WIDTH, HEIGHT, bpp);
|
2001-04-06 10:30:29 +00:00
|
|
|
if (maxw != orig_w || maxh != orig_h) printf("Video scaled to: %dx%d\n",maxw,maxh);
|
2001-04-05 08:42:02 +00:00
|
|
|
else printf("No video scaling\n");
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t query_format(uint32_t format) {
|
2001-04-17 17:35:27 +00:00
|
|
|
uint32_t res = 0;
|
2001-04-14 17:51:37 +00:00
|
|
|
|
2001-04-17 06:22:48 +00:00
|
|
|
if (!checked) {
|
|
|
|
if (checksupportedmodes()) // Looking for available video modes
|
|
|
|
return(0);
|
|
|
|
}
|
2001-04-17 17:35:27 +00:00
|
|
|
|
|
|
|
// if (vo_dbpp) => There is NO conversion!!!
|
|
|
|
if (vo_dbpp) {
|
2001-05-06 19:38:57 +00:00
|
|
|
if (format == IMGFMT_YV12) return (1);
|
2001-04-17 17:35:27 +00:00
|
|
|
switch (vo_dbpp) {
|
2001-04-17 19:05:59 +00:00
|
|
|
case 32: if ((format == IMGFMT_RGB32) || (format == IMGFMT_BGR32))
|
2001-04-17 17:35:27 +00:00
|
|
|
return ((bpp_avail & BPP_32) ? 1 : 0);
|
|
|
|
break;
|
2001-04-17 19:05:59 +00:00
|
|
|
case 24: if ((format == IMGFMT_RGB24) || (format == IMGFMT_BGR24))
|
2001-04-17 17:35:27 +00:00
|
|
|
return ((bpp_avail & BPP_24) ? 1 : 0);
|
|
|
|
break;
|
2001-04-17 19:05:59 +00:00
|
|
|
case 16: if ((format == IMGFMT_RGB16) || (format == IMGFMT_BGR16))
|
2001-04-17 17:35:27 +00:00
|
|
|
return ((bpp_avail & BPP_16) ? 1 : 0);
|
|
|
|
break;
|
2001-04-17 19:05:59 +00:00
|
|
|
case 15: if ((format == IMGFMT_RGB15) || (format == IMGFMT_BGR15))
|
2001-04-17 17:35:27 +00:00
|
|
|
return ((bpp_avail & BPP_15) ? 1 : 0);
|
|
|
|
break;
|
2001-04-14 17:51:37 +00:00
|
|
|
}
|
2001-04-17 19:05:59 +00:00
|
|
|
} else {
|
2001-04-17 17:35:27 +00:00
|
|
|
switch (format) {
|
|
|
|
case IMGFMT_RGB32:
|
2001-04-17 19:05:59 +00:00
|
|
|
case IMGFMT_BGR32: return ((bpp_avail & BPP_32) ? 1 : 0); break;
|
2001-04-17 17:35:27 +00:00
|
|
|
case IMGFMT_RGB24:
|
2001-04-17 19:05:59 +00:00
|
|
|
case IMGFMT_BGR24: {
|
2001-04-17 17:35:27 +00:00
|
|
|
res = (bpp_avail & BPP_24) ? 1 : 0;
|
|
|
|
if (!res)
|
|
|
|
res = (bpp_avail & BPP_32) ? 1 : 0;
|
|
|
|
return (res);
|
|
|
|
} break;
|
|
|
|
case IMGFMT_RGB16:
|
2001-04-17 19:05:59 +00:00
|
|
|
case IMGFMT_BGR16: return ((bpp_avail & BPP_16) ? 1 : 0); break;
|
2001-04-17 17:35:27 +00:00
|
|
|
case IMGFMT_RGB15:
|
2001-04-17 19:05:59 +00:00
|
|
|
case IMGFMT_BGR15: {
|
2001-04-17 17:35:27 +00:00
|
|
|
res = (bpp_avail & BPP_15) ? 1 : 0;
|
|
|
|
if (!res)
|
|
|
|
res = (bpp_avail & BPP_16) ? 1 : 0;
|
|
|
|
return (res);
|
|
|
|
} break;
|
|
|
|
case IMGFMT_YV12: return (1); break;
|
2001-04-05 08:42:02 +00:00
|
|
|
}
|
2001-04-17 19:05:59 +00:00
|
|
|
}
|
2001-04-05 08:42:02 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const vo_info_t* get_info(void) {
|
|
|
|
return (&vo_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
|
|
|
|
unsigned char *srca, int stride) {
|
2001-04-10 09:51:09 +00:00
|
|
|
switch (bpp) {
|
|
|
|
case 32:
|
|
|
|
vo_draw_alpha_rgb32(w, h, src, srca, stride, virt->vbuf+4*(y0*WIDTH+x0), 4*WIDTH);
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
vo_draw_alpha_rgb24(w, h, src, srca, stride, virt->vbuf+3*(y0*WIDTH+x0), 3*WIDTH);
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
vo_draw_alpha_rgb16(w, h, src, srca, stride, virt->vbuf+2*(y0*WIDTH+x0), 2*WIDTH);
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
vo_draw_alpha_rgb15(w, h, src, srca, stride, virt->vbuf+2*(y0*WIDTH+x0), 2*WIDTH);
|
|
|
|
break;
|
|
|
|
}
|
2001-04-05 08:42:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t draw_frame(uint8_t *src[]) {
|
|
|
|
if (pformat == IMGFMT_YV12) {
|
|
|
|
yuv2rgb(yuvbuf, src[0], src[1], src[2], orig_w, orig_h, orig_w * BYTESPERPIXEL, orig_w, orig_w / 2);
|
|
|
|
src[0] = yuvbuf;
|
|
|
|
}
|
2001-04-17 06:22:48 +00:00
|
|
|
if (scalebuf != NULL) {
|
2001-04-05 08:42:02 +00:00
|
|
|
gl_scalebox(orig_w, orig_h, src[0], maxw, maxh, scalebuf);
|
|
|
|
src[0] = scalebuf;
|
|
|
|
}
|
2001-04-14 17:51:37 +00:00
|
|
|
if (bpp_conv) {
|
|
|
|
switch(bpp) {
|
2001-04-17 17:35:27 +00:00
|
|
|
case 32: {
|
2001-04-24 15:56:41 +00:00
|
|
|
uint8_t *source = src[0];
|
|
|
|
uint8_t *dest = bppbuf;
|
|
|
|
register uint32_t i = 0;
|
2001-04-18 10:37:09 +00:00
|
|
|
|
2001-04-24 15:56:41 +00:00
|
|
|
while (i < (maxw * maxh * 4)) {
|
|
|
|
dest[i] = source[i];
|
|
|
|
dest[i+1] = source[i+1];
|
|
|
|
dest[i+2] = source[i+2];
|
|
|
|
dest[i+3] = 0;
|
|
|
|
i += 4;
|
2001-04-14 17:51:37 +00:00
|
|
|
}
|
2001-04-17 17:35:27 +00:00
|
|
|
} break;
|
|
|
|
case 16: {
|
2001-04-14 17:51:37 +00:00
|
|
|
#ifdef HAVE_MMX
|
|
|
|
rgb15to16_mmx(src[0],bppbuf,maxw * maxh * 2);
|
|
|
|
#else
|
2001-04-18 10:37:09 +00:00
|
|
|
uint16_t *source = (uint16_t *) src[0];
|
|
|
|
uint16_t *dest = (uint16_t *) bppbuf;
|
2001-04-24 15:56:41 +00:00
|
|
|
register uint32_t i = 0;
|
2001-04-14 17:51:37 +00:00
|
|
|
register uint16_t srcdata;
|
|
|
|
|
2001-04-24 15:56:41 +00:00
|
|
|
while (i < (maxw * maxh)) {
|
|
|
|
srcdata = source[i];
|
|
|
|
dest[i++] = (srcdata & 0x1f) | ((srcdata & 0x7fe0) << 1);
|
2001-04-14 17:51:37 +00:00
|
|
|
}
|
|
|
|
#endif
|
2001-04-17 17:35:27 +00:00
|
|
|
} break;
|
2001-04-14 17:51:37 +00:00
|
|
|
}
|
|
|
|
src[0] = bppbuf;
|
|
|
|
}
|
2001-04-05 08:42:02 +00:00
|
|
|
gl_putbox(x_pos, y_pos, maxw, maxh, src[0]);
|
2001-04-24 12:21:42 +00:00
|
|
|
|
|
|
|
return (0);
|
2001-04-05 08:42:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t draw_slice(uint8_t *image[], int stride[],
|
|
|
|
int w, int h, int x, int y) {
|
|
|
|
uint8_t *src = yuvbuf;
|
2001-04-12 17:30:50 +00:00
|
|
|
uint32_t sw, sh;
|
|
|
|
|
2001-05-25 15:45:35 +00:00
|
|
|
yuv2rgb(yuvbuf, image[0], image[1], image[2], w, h, orig_w * BYTESPERPIXEL, stride[0], stride[1]);
|
2001-04-12 17:30:50 +00:00
|
|
|
sw = (uint32_t) (w * scaling);
|
|
|
|
sh = (uint32_t) (h * scaling);
|
2001-04-17 06:22:48 +00:00
|
|
|
if (scalebuf != NULL) {
|
2001-04-12 17:30:50 +00:00
|
|
|
gl_scalebox(w, h, yuvbuf, sw, sh, scalebuf);
|
2001-04-05 08:42:02 +00:00
|
|
|
src = scalebuf;
|
|
|
|
}
|
2001-04-12 17:30:50 +00:00
|
|
|
gl_putbox((int)(x * scaling) + x_pos, (int)(y * scaling) + y_pos, sw, sh, src);
|
2001-04-24 12:21:42 +00:00
|
|
|
|
|
|
|
return (0);
|
2001-04-05 08:42:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void flip_page(void) {
|
2001-04-06 10:25:47 +00:00
|
|
|
if (y_pos) {
|
|
|
|
gl_fillbox(0, 0, WIDTH, y_pos, 0);
|
|
|
|
gl_fillbox(0, HEIGHT - y_pos, WIDTH, y_pos, 0);
|
|
|
|
} else {
|
|
|
|
gl_fillbox(0, 0, x_pos, HEIGHT, 0);
|
|
|
|
gl_fillbox(WIDTH - x_pos, 0, x_pos, HEIGHT, 0);
|
2001-04-10 09:51:09 +00:00
|
|
|
}
|
2001-04-17 17:43:40 +00:00
|
|
|
vo_draw_text(WIDTH, HEIGHT, draw_alpha);
|
2001-04-05 08:42:02 +00:00
|
|
|
gl_copyscreen(screen);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void check_events(void) {
|
|
|
|
}
|
|
|
|
|
|
|
|
static void uninit(void) {
|
2001-04-17 06:22:48 +00:00
|
|
|
vga_modelist_t *list = modelist;
|
|
|
|
|
2001-04-05 08:42:02 +00:00
|
|
|
gl_freecontext(screen);
|
|
|
|
gl_freecontext(virt);
|
|
|
|
vga_setmode(TEXT);
|
2001-04-17 06:22:48 +00:00
|
|
|
if (bppbuf != NULL)
|
2001-04-14 17:51:37 +00:00
|
|
|
free(bppbuf);
|
2001-04-17 06:22:48 +00:00
|
|
|
if (scalebuf != NULL)
|
2001-04-05 08:42:02 +00:00
|
|
|
free(scalebuf);
|
2001-04-17 06:22:48 +00:00
|
|
|
if (yuvbuf != NULL)
|
2001-04-05 08:42:02 +00:00
|
|
|
free(yuvbuf);
|
2001-04-17 06:22:48 +00:00
|
|
|
if (modelist != NULL) {
|
|
|
|
while (modelist->next != NULL) {
|
|
|
|
list = modelist;
|
|
|
|
while (list->next != NULL)
|
|
|
|
list = list->next;
|
|
|
|
free(list);
|
|
|
|
}
|
|
|
|
free(modelist);
|
|
|
|
}
|
2001-04-05 08:42:02 +00:00
|
|
|
}
|
2001-04-24 12:21:42 +00:00
|
|
|
|