Mercurial > mplayer.hg
changeset 1141:c33f8b7488d1
cleaned up, and merged with my version, also code will be faster too
author | al3x |
---|---|
date | Sun, 17 Jun 2001 12:24:52 +0000 |
parents | 40ebb676bd73 |
children | 6b6c173d050f |
files | libvo/vo_ggi.c |
diffstat | 1 files changed, 99 insertions(+), 74 deletions(-) [+] |
line wrap: on
line diff
--- a/libvo/vo_ggi.c Sun Jun 17 06:34:13 2001 +0000 +++ b/libvo/vo_ggi.c Sun Jun 17 12:24:52 2001 +0000 @@ -4,10 +4,11 @@ (C) Alex Beregszaszi <alex@naxine.org> Uses libGGI - http://www.ggi-project.org/ + + Many thanks to Atmosfear, he hacked this driver to working with Planar + formats, and he fixed the RGB handling. */ -#define DISP - #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -18,9 +19,11 @@ #include "video_out_internal.h" #include "yuv2rgb.h" +#include "fastmemcpy.h" #include <ggi/ggi.h> -#include "fastmemcpy.h" + +#define GGI_OST LIBVO_EXTERN (ggi) @@ -29,7 +32,7 @@ "General Graphics Interface (GGI) output", "ggi", "Alex Beregszaszi <alex@naxine.org>", - "" + "under developement" }; extern int verbose; @@ -37,11 +40,14 @@ static char *ggi_output_name = NULL; static ggi_visual_t ggi_vis; static ggi_directbuffer *ggi_buffer; -static int bpp = 0; +static int ggi_format = 0; +static int ggi_bpp = 0; static uint32_t virt_width; static uint32_t virt_height; +#ifdef GGI_OST static ggi_pixel white; static ggi_pixel black; +#endif static int ggi_setmode(uint32_t d_width, uint32_t d_height, int d_depth, int format) { @@ -54,8 +60,9 @@ GT_AUTO, /* graphtype */ { GGI_AUTO, GGI_AUTO } /* dots per pixel */ }; +#ifdef GGI_OST ggi_color pal[256]; - int depth; +#endif mode.visible.x = mode.virt.x = d_width; mode.visible.y = mode.virt.y = d_height; @@ -64,35 +71,27 @@ { case 1: mode.graphtype = GT_1BIT; - depth = 1; break; case 2: mode.graphtype = GT_2BIT; - depth = 2; break; case 4: mode.graphtype = GT_4BIT; - depth = 4; break; case 8: mode.graphtype = GT_8BIT; - depth = 8; break; case 15: mode.graphtype = GT_15BIT; - depth = 15; break; case 16: mode.graphtype = GT_16BIT; - depth = 16; break; case 24: mode.graphtype = GT_24BIT; - depth = 24; break; case 32: mode.graphtype = GT_32BIT; - depth = 32; break; default: printf("ggi-setmode: unknown bit depth - using auto\n"); @@ -113,9 +112,8 @@ virt_height = mode.virt.y; vo_screenwidth = mode.visible.x; vo_screenheight = mode.visible.y; - vo_depthonscreen = depth; - bpp = depth; /* byte per pixel = depth ? */ - + vo_depthonscreen = d_depth; + ggi_bpp = d_depth; /* why ? */ #ifdef get_db_info { @@ -124,7 +122,7 @@ if (db) { vo_depthonscreen = db->buffer.plb.pixelformat->depth; - bpp = db->buffer.plb.pixelformat->size / 8; + ggi_bpp = db->buffer.plb.pixelformat->size / 8; } } #endif @@ -132,12 +130,13 @@ if (GT_SCHEME(mode.graphtype) == GT_PALETTE) { ggiSetColorfulPalette(ggi_vis); - ggiGetPalette(ggi_vis, 0, 1 << bpp, pal); + ggiGetPalette(ggi_vis, 0, 1 << ggi_bpp, pal); } if (verbose) - printf("ggi-setmode: %dx%d (virt: %dx%d) %d depth, %d bpp\n", vo_screenwidth, - vo_screenheight, virt_width, virt_height, vo_depthonscreen, bpp); + printf("ggi-setmode: %dx%d (virt: %dx%d) screen depth: %d, bpp: %d, format: %s\n", + vo_screenwidth, vo_screenheight, virt_width, virt_height, + vo_depthonscreen, ggi_bpp, vo_format_name(ggi_format)); return(0); } @@ -146,7 +145,10 @@ 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) { - printf("\nggi: THIS DRIVER IS IN PRE-ALPHA PHASE, DO NOT USE!\n\n"); + vo_depthonscreen = 32; + + printf("\nggi-init: THIS DRIVER IS IN PRE-ALPHA PHASE, DO NOT USE!\n\n"); + if (ggiInit() != 0) { printf("ggi-init: unable to initialize GGI\n"); @@ -160,42 +162,47 @@ ggiExit(); return(-1); } + + printf("ggi-init: using %s GGI output\n", + (ggi_output_name == NULL) ? "default" : ggi_output_name); - switch(format) + ggi_format = format; + + switch(ggi_format) { case IMGFMT_RGB8: - bpp = 8; + ggi_bpp = 8; break; case IMGFMT_RGB15: - bpp = 15; + ggi_bpp = 15; break; case IMGFMT_RGB16: - bpp = 16; + ggi_bpp = 16; break; case IMGFMT_RGB24: - bpp = 24; + ggi_bpp = 24; break; case IMGFMT_RGB32: - bpp = 32; + ggi_bpp = 32; break; case IMGFMT_BGR8: - bpp = 8; + ggi_bpp = 8; break; case IMGFMT_BGR15: - bpp = 15; + ggi_bpp = 15; break; case IMGFMT_BGR16: - bpp = 16; + ggi_bpp = 16; break; case IMGFMT_BGR24: - bpp = 24; + ggi_bpp = 24; break; case IMGFMT_BGR32: - bpp = 32; + ggi_bpp = 32; break; case IMGFMT_YV12: /* rgb, 24bit */ - bpp = 16; - yuv2rgb_init(32/*screendepth*/, MODE_RGB); + ggi_bpp = 16; + yuv2rgb_init(vo_depthonscreen, MODE_RGB); break; default: printf("ggi-init: no suitable image format found\n"); @@ -204,7 +211,7 @@ ggiSetFlags(ggi_vis, GGIFLAG_ASYNC); - if (ggi_setmode(d_width, d_height, 32/*bpp*/, format) != 0) + if (ggi_setmode(d_width, d_height, vo_depthonscreen, ggi_format) != 0) { printf("ggi-init: setmode returned with error\n"); return(-1); @@ -224,7 +231,8 @@ (ggi_buffer->page_size != 0) || (ggi_buffer->write == NULL) || (ggi_buffer->noaccess != 0) || - (ggi_buffer->align != 0)) + (ggi_buffer->align != 0) || + (ggi_buffer->layout != blPixelLinearBuffer)) { printf("ggi-init: incorrect video memory type\n"); ggiClose(ggi_vis); @@ -232,6 +240,7 @@ return(-1); } +#ifdef GGI_OST /* just for fun */ { ggi_color col; @@ -247,6 +256,7 @@ ggiSetGCForeground(ggi_vis, white); ggiSetGCBackground(ggi_vis, black); } +#endif return(0); } @@ -258,67 +268,83 @@ static uint32_t draw_frame(uint8_t *src[]) { - uint8_t *ptr; - int y, x, i; - /*int bppmul = vo_depthonscreen/8;*/ - ggiResourceAcquire(ggi_buffer->resource, GGI_ACTYPE_WRITE); ggiSetDisplayFrame(ggi_vis, ggi_buffer->frame); ggiSetWriteFrame(ggi_vis, ggi_buffer->frame); - ptr = ggi_buffer->write; - -// for (i = 1; i < 3; i++) -/* for (x = 0; x < virt_width; x++) - for (y = 0; y < virt_height; y++) - *ptr++ = src[0][x*virt_height+y];*/ - memcpy(ptr,src[0],virt_width*virt_height*(bpp/8)); + memcpy(ggi_buffer->write, src[0], virt_width*virt_height*(ggi_bpp/8)); + +#ifdef GGI_OST + ggiPuts(ggi_vis, virt_width/2, virt_height-10, "MPlayer GGI"); +#endif + + ggiResourceRelease(ggi_buffer->resource); + return(0); +} - ggiPuts(ggi_vis, x/2, y-10, "MPlayer GGI"); - - ggiResourceRelease(ggi_buffer->resource); +static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, + unsigned char *srca, int stride) +{ +#warning "draw_alpha needs to be fixed!" + switch(ggi_format) + { + case IMGFMT_RGB15: + case IMGFMT_BGR15: + vo_draw_alpha_rgb15(w, h, src, srca, stride, 0, 2*virt_width); + break; + case IMGFMT_RGB16: + case IMGFMT_BGR16: + vo_draw_alpha_rgb16(w, h, src, srca, stride, 0, 2*virt_width); + break; + case IMGFMT_RGB24: + case IMGFMT_BGR24: + vo_draw_alpha_rgb24(w, h, src, srca, stride, 0, 3*virt_width); + break; + case IMGFMT_RGB32: + case IMGFMT_BGR32: + vo_draw_alpha_rgb32(w, h, src, srca, stride, 0, 4*virt_width); + break; + } } static void flip_page(void) { check_events(); + vo_draw_text(virt_width, virt_height, draw_alpha); ggiFlush(ggi_vis); } static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y) { - uint8_t *dst; + register uint8_t *dst; - dst = ggi_buffer->write + (virt_width * y + x) * (bpp/8); - yuv2rgb(dst, src[0], src[1], src[2], w, h, virt_width*(bpp/8), + dst = ggi_buffer->write + (virt_width * y + x) * (ggi_bpp/8); + yuv2rgb(dst, src[0], src[1], src[2], w, h, virt_width*(ggi_bpp/8), stride[0], stride[1]); - //draw_frame(dst); -// dst = image_data + (virt_width * y + x) * (bpp/8); -// yuv2rgb(dst, src[0], src[1], src[2], w, h, virt_width*(bpp/8), -// stride[0], stride[1]); return(0); } static uint32_t query_format(uint32_t format) { - switch(format){ - case IMGFMT_YV12: - return 1; - 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: - return 1; + switch(format) + { + case IMGFMT_YV12: + return(1); + 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: + return(1); } - return 0; + return(0); } static void uninit(void) @@ -332,4 +358,3 @@ { /* add ggiPollEvent stuff */ } -