diff options
author | uid32519 <none@none> | 2001-07-04 17:10:24 +0000 |
---|---|---|
committer | uid32519 <none@none> | 2001-07-04 17:10:24 +0000 |
commit | 507e81ddf0454a0b740a69f69d917ce67075065f (patch) | |
tree | d935d772f266ee49a6a73341e1a34afda4b383d8 /src/video_out | |
parent | c8d64e87f29e42dc2f6f0068e575dd10188999af (diff) | |
download | xine-lib-507e81ddf0454a0b740a69f69d917ce67075065f.tar.gz xine-lib-507e81ddf0454a0b740a69f69d917ce67075065f.tar.bz2 |
spu support updated (unfinished) from James
CVS patchset: 250
CVS date: 2001/07/04 17:10:24
Diffstat (limited to 'src/video_out')
-rw-r--r-- | src/video_out/Makefile.am | 2 | ||||
-rw-r--r-- | src/video_out/alphablend.c | 350 | ||||
-rw-r--r-- | src/video_out/alphablend.h | 39 | ||||
-rw-r--r-- | src/video_out/video_out_aa.c | 8 | ||||
-rw-r--r-- | src/video_out/video_out_syncfb.c | 4 | ||||
-rw-r--r-- | src/video_out/video_out_xshm.c | 14 | ||||
-rw-r--r-- | src/video_out/video_out_xv.c | 55 |
7 files changed, 428 insertions, 44 deletions
diff --git a/src/video_out/Makefile.am b/src/video_out/Makefile.am index b946f20e9..5070d63b9 100644 --- a/src/video_out/Makefile.am +++ b/src/video_out/Makefile.am @@ -25,7 +25,7 @@ endif # lib_LTLIBRARIES = $(xv_module) $(syncfb_module) $(xshm_module) $(aa_module) -xineplug_vo_out_xv_la_SOURCES = video_out_xv.c +xineplug_vo_out_xv_la_SOURCES = alphablend.c video_out_xv.c xineplug_vo_out_xv_la_LIBADD = $(XV_LIB) $(X_LIBS) -lXext xineplug_vo_out_xv_la_LDFLAGS = -avoid-version -module diff --git a/src/video_out/alphablend.c b/src/video_out/alphablend.c new file mode 100644 index 000000000..ac77fbbce --- /dev/null +++ b/src/video_out/alphablend.c @@ -0,0 +1,350 @@ +//TOAST_SPU will define ALL spu entries - no matter the tranparency +//#define TOAST_SPU +/* #define PRIV_CLUT */ + +/* + * + * Copyright (C) 2000 Thomas Mirlacher + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * The author may be reached as <dent@linuxvideo.org> + * + *------------------------------------------------------------ + * + */ + +#include <string.h> +#include <stdlib.h> +#include <inttypes.h> + +#include "video_out.h" + +#define BLEND_COLOR(dst, src, mask, o) ((((src&mask)*o + ((dst&mask)*(0x0f-o)))/0xf) & mask) + +static inline uint16_t blendpixel_rgb16 (uint16_t dst, uint16_t src, + uint8_t o) +{ + return BLEND_COLOR (dst, src, 0xf800, o) | + BLEND_COLOR (dst, src, 0x07e0, o) | + BLEND_COLOR (dst, src, 0x001f, o); +} + +static inline uint32_t blendpixel_rgb24 (uint32_t dst, uint32_t src, + uint8_t o) +{ + return BLEND_COLOR (dst, src, 0xff0000, o) | + BLEND_COLOR (dst, src, 0x00ff00, o) | + BLEND_COLOR (dst, src, 0x0000ff, o); +} + +static inline uint32_t blendpixel_rgb32 (uint32_t dst, uint32_t src, + uint8_t o) +{ + return BLEND_COLOR (dst, src, 0xff0000, o) | + BLEND_COLOR (dst, src, 0x00ff00, o) | + BLEND_COLOR (dst, src, 0x0000ff, o); +} +/* +void blend_tux_rgb16 (uint8_t * img, int dst_width, int dst_height) +{ + int src_width = bg_width; + int src_height = bg_height; + uint8_t *src = (uint8_t *) bg_img_data; + static int x_off; + static int y_off; + static int x_dir = 1; + static int y_dir = 1; + static int o = 5; + static int o_dir = 1; + +// align right bottom + x_off += x_dir; + if (x_off > (dst_width - src_width)) + x_dir = -x_dir; + if (x_off <= 0) + x_dir = -x_dir; + + y_off += y_dir; + if (y_off > (dst_height - src_height)) + y_dir = -y_dir; + if (y_off <= 0) + y_dir = -y_dir; + +// cycle parameters + o += o_dir; + if (o >= 0xf) + o_dir = -o_dir; + if (o <= 1) + o_dir = -o_dir; +// + { + uint16_t *dst = (uint16_t *) img; + int x, + y; + + dst += y_off * dst_width; + for (y = 0; y < src_height; y++) { + dst += x_off; + for (x = 0; x < src_width; x++) { + if ((*src) - bg_start_index) + *dst = blendpixel_rgb16 (bg_palette_to_rgb [(*src) - bg_start_index], *dst, o); + src++; + dst++; + } + dst += dst_width - x - x_off; + } + } +} +*/ +// convenience + +#define uint24_t uint32_t + +#define BLEND(bpp, img, img_overl, dst_width, dst_height)\ +{ \ + static int o=5; \ + uint8_t *src = (uint8_t *) img_overl->data; \ + uint##bpp##_t *dst = (uint##bpp##_t *) img; \ + int x, y; \ + \ + dst += img_overl->y*dst_width; \ + for (y=0; y<img_overl->height; y++) { \ + dst += img_overl->x; \ + for (x=0; x<img_overl->width; x++) { \ + o = img_overl->trans[*src&0x0f]; \ + \ +/* if ((*src&0x0f) != 0) if alpha is != 0 */ \ + if (o) /* if alpha is != 0 */ \ + *dst = blendpixel_rgb##bpp (*dst, img_overl->clut[(*src&0x0f)]/*.y*/, o); \ +/* *dst = blendpixel_rgb##bpp (*dst, myclut[img_overl->clut[(*src&0x0f)]], o);*/\ + src++; \ + dst++; \ + } \ + dst += dst_width - x - img_overl->x; \ + } \ +} + +//void blend_rgb16 (uint8_t *img, overlay_buf_t *img_overl, int dst_width, int dst_height) +void blend_rgb (uint8_t * img, vo_overlay_t * img_overl, int dst_width, + int dst_height) +{ +#ifdef PRIV_CLUT + u_int myclut[] = { + 0x0000, + 0x20e2, + 0x83ac, + 0x4227, + 0xa381, + 0xad13, + 0xbdf8, + 0xd657, + 0xee67, + 0x6a40, + 0xd4c1, + 0xf602, + 0xf664, + 0xe561, + 0xad13, + 0xffdf, + }; +#endif + + BLEND (16, img, img_overl, dst_width, dst_height); + //blend_tux_rgb16 (img, dst_width, dst_height); +} + +void blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, int dst_width, + int dst_height) +{ +//FIXME CLUT +#ifdef PRIV_CLUT + u_int myclut[] = { + 0x0000, + 0x20e2, + 0x83ac, + 0x4227, + 0xa381, + 0xad13, + 0xbdf8, + 0xd657, + 0xee67, + 0x6a40, + 0xd4c1, + 0xf602, + 0xf664, + 0xe561, + 0xad13, + 0xffdf, + }; +#endif + BLEND (24, img, img_overl, dst_width, dst_height); +} + +void blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl, int dst_width, + int dst_height) +{ +//FIXME CLUT +#ifdef PRIV_CLUT + u_int myclut[] = { + 0x0000, + 0x20e2, + 0x83ac, + 0x4227, + 0xa381, + 0xad13, + 0xbdf8, + 0xd657, + 0xee67, + 0x6a40, + 0xd4c1, + 0xf602, + 0xf664, + 0xe561, + 0xad13, + 0xffdf, + }; +#endif + BLEND (32, img, img_overl, dst_width, dst_height); +} + +#define BLEND_YUV(dst, src, o) (((src)*o + ((dst)*(0xf-o)))/0xf) + +void blend_yuv (uint8_t * dst_img, vo_overlay_t * img_overl, + int dst_width, int dst_height) +{ +#ifdef PRIV_CLUT + clut_t my_clut[] = { + {y: 0x51, cr: 0xef, cb:0x5a}, + {y: 0xbf, cr: 0x80, cb:0x80}, + {y: 0x10, cr: 0x80, cb:0x80}, + {y: 0x28, cr: 0x6d, cb:0xef}, + {y: 0x51, cr: 0xef, cb:0x5a}, + {y: 0xbf, cr: 0x80, cb:0x80}, + {y: 0x36, cr: 0x80, cb:0x80}, + {y: 0x28, cr: 0x6d, cb:0xef}, + {y: 0x5c, cr: 0x80, cb:0x80}, + {y: 0xbf, cr: 0x80, cb:0x80}, + {y: 0x10, cr: 0x80, cb:0x80}, + {y: 0x28, cr: 0x6d, cb:0xef}, + {y: 0x5c, cr: 0x80, cb:0x80}, + {y: 0xbf, cr: 0x80, cb:0x80}, + {y: 0x1c, cr: 0x80, cb:0x80}, + {y: 0x28, cr: 0x6d, cb:0xef} + }; +#endif + + int src_width = img_overl->width; + int src_height = img_overl->height; + uint8_t *src_data = img_overl->data; + + int x_off = img_overl->x; + int y_off = img_overl->y; + + uint8_t *dst_y = dst_img + dst_width * y_off + x_off; + uint8_t *dst_cr = dst_img + dst_width * dst_height + + (y_off / 2) * (dst_width / 2) + (x_off / 2); + uint8_t *dst_cb = dst_img + (dst_width * dst_height * 5) / 4 + + (y_off / 2) * (dst_width / 2) + (x_off / 2); + + int x, + y; + + for (y = 0; y < src_height; y++) { + for (x = 0; x < src_width; x++) { + uint8_t clr; + uint8_t o; + + clr = img_overl->clut[*src_data & 0x0f]; + o = img_overl->trans[*src_data & 0x0f]; + + if (clr) +// *INDENT-OFF* +#ifdef PRIV_CLUT + *dst_y = BLEND_YUV (*dst_y, my_clut[clr].y, o); +#else + *dst_y = BLEND_YUV (*dst_y, img_overl->clut[clr]/*.y*/, o); +#endif +// *INDENT-ON* + dst_y++; + + if (y & x & 1) { + if (clr) { +// *INDENT-OFF* +#ifdef PRIV_CLUT + *dst_cr = BLEND_YUV (*dst_cr, my_clut[clr].cr, o); + *dst_cb = BLEND_YUV (*dst_cb, my_clut[clr].cb, o); +#else + *dst_cr = BLEND_YUV (*dst_cr, img_overl->clut [clr]/*.cr*/, o); + *dst_cb = BLEND_YUV (*dst_cb, img_overl->clut [clr]/*.cb*/, o); +#endif +// *INDENT-ON* + } + dst_cr++; + dst_cb++; + } + src_data++; + } + + dst_y += dst_width - src_width; + + if (y & 1) { + dst_cr += (dst_width - src_width) / 2; + dst_cb += (dst_width - src_width) / 2; + } + } +} + +inline int is_blank (uint8_t * ptr, int width) +{ + int x; + + for (x = 0; x < width; x++) { + if ((*ptr & 0x0f) && (*ptr >> 4)) + return 0; // color != 0 && alpha != 0 + ptr++; + } + + return 1; // blank line +} + +void crop_overlay (vo_overlay_t * overlay) +{ + uint8_t *data = overlay->data; + int height = overlay->height; + int width = overlay->width; + int y; + + /* + * Shrink from bottom + */ + + for (y=height - 1;y >= 0 && is_blank (&data[y * width], width); y--); + height = y + 1; + + /* + * Shrink from top + */ + for (y=0; y < height && is_blank (&data[y * width], width); y++); + height -= y; + + /* + * Shift data + */ + overlay->y -= y; + overlay->height = height; + + memcpy (data, &data[y * width], height * width); +} diff --git a/src/video_out/alphablend.h b/src/video_out/alphablend.h new file mode 100644 index 000000000..7afa470f7 --- /dev/null +++ b/src/video_out/alphablend.h @@ -0,0 +1,39 @@ + +/* + * + * Copyright (C) 2000 Thomas Mirlacher + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * The author may be reached as <dent@linuxvideo.org> + * + *------------------------------------------------------------ + * + */ + +#ifndef __ALPHABLEND_H__ +#define __ALPHABLEND_H__ + +#include "video_out.h" + +void blend_rgb (uint8_t * img, vo_overlay_t * overlay, int width, + + int height); +void blend_yuv (uint8_t * img, vo_overlay_t * overlay, int width, + + int height); +void crop_overlay (vo_overlay_t * overlay); + +#endif diff --git a/src/video_out/video_out_aa.c b/src/video_out/video_out_aa.c index 179157e7c..1ab490ee2 100644 --- a/src/video_out/video_out_aa.c +++ b/src/video_out/video_out_aa.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: video_out_aa.c,v 1.7 2001/06/14 18:32:57 guenter Exp $ + * $Id: video_out_aa.c,v 1.8 2001/07/04 17:10:24 uid32519 Exp $ * * video_out_aa.c, ascii-art output plugin for xine * @@ -261,6 +261,9 @@ static void aa_get_property_min_max (vo_driver_t *this_gen, *max = 0; } +static void aa_set_overlay (vo_driver_t *this, vo_overlay_t *overlay) { +} + static void aa_exit (vo_driver_t *this_gen) { } @@ -283,12 +286,13 @@ vo_driver_t *init_video_out_plugin (config_values_t *config, void *visual_gen) { this->vo_driver.get_property_min_max = aa_get_property_min_max; this->vo_driver.gui_data_exchange = NULL; this->vo_driver.exit = aa_exit; + this->vo_driver.set_overlay = aa_set_overlay; return (vo_driver_t*) this; } static vo_info_t vo_info_aa = { - VIDEO_OUT_IFACE_VERSION, + 2, "aa", "xine video output plugin using the ascii-art library", VISUAL_TYPE_AA, diff --git a/src/video_out/video_out_syncfb.c b/src/video_out/video_out_syncfb.c index a7ec000a1..f3a4d52c8 100644 --- a/src/video_out/video_out_syncfb.c +++ b/src/video_out/video_out_syncfb.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: video_out_syncfb.c,v 1.7 2001/07/04 14:01:50 uid56437 Exp $ + * $Id: video_out_syncfb.c,v 1.8 2001/07/04 17:10:24 uid32519 Exp $ * * video_out_syncfb.c, Matrox G400 video extension interface for xine * @@ -866,7 +866,7 @@ vo_driver_t *init_video_out_plugin (config_values_t *config, void *visual) { static vo_info_t vo_info_mga = { - VIDEO_OUT_IFACE_VERSION, + 1, "Syncfb", "xine video output plugin using MGA Teletux (syncfb) video extension", VISUAL_TYPE_X11, diff --git a/src/video_out/video_out_xshm.c b/src/video_out/video_out_xshm.c index b4f9d5e65..63168b852 100644 --- a/src/video_out/video_out_xshm.c +++ b/src/video_out/video_out_xshm.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: video_out_xshm.c,v 1.13 2001/07/04 14:01:50 uid56437 Exp $ + * $Id: video_out_xshm.c,v 1.14 2001/07/04 17:10:24 uid32519 Exp $ * * video_out_xshm.c, X11 shared memory extension interface for xine * @@ -94,6 +94,7 @@ typedef struct xshm_driver_s { yuv2rgb_t *yuv2rgb; xshm_frame_t *cur_frame; + vo_overlay_t *overlay; /* size / aspect ratio calculations */ int delivered_width; /* everything is set up for these frame dimensions */ @@ -652,6 +653,13 @@ static void xshm_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) { } } +/* Stores an overlay in the Video Out driver */ +static void xshm_set_overlay (vo_driver_t *this_gen, vo_overlay_t *overlay) { + xshm_driver_t *this = (xshm_driver_t *) this_gen; + + this->overlay = overlay; +} + static int xshm_get_property (vo_driver_t *this_gen, int property) { xshm_driver_t *this = (xshm_driver_t *) this_gen; @@ -823,12 +831,14 @@ vo_driver_t *init_video_out_plugin (config_values_t *config, void *visual_gen) { this->vo_driver.alloc_frame = xshm_alloc_frame; this->vo_driver.update_frame_format = xshm_update_frame_format; this->vo_driver.display_frame = xshm_display_frame; + this->vo_driver.set_overlay = xshm_set_overlay; this->vo_driver.get_property = xshm_get_property; this->vo_driver.set_property = xshm_set_property; this->vo_driver.get_property_min_max = xshm_get_property_min_max; this->vo_driver.gui_data_exchange = xshm_gui_data_exchange; this->vo_driver.exit = xshm_exit; + /* * * depth in X11 terminology land is the number of bits used to @@ -924,7 +934,7 @@ vo_driver_t *init_video_out_plugin (config_values_t *config, void *visual_gen) { } static vo_info_t vo_info_shm = { - VIDEO_OUT_IFACE_VERSION, + 2, "XShm", "xine video output plugin using the MIT X shared memory extension", VISUAL_TYPE_X11, diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c index 741bfdd20..ed49b6324 100644 --- a/src/video_out/video_out_xv.c +++ b/src/video_out/video_out_xv.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: video_out_xv.c,v 1.47 2001/06/25 09:51:47 guenter Exp $ + * $Id: video_out_xv.c,v 1.48 2001/07/04 17:10:24 uid32519 Exp $ * * video_out_xv.c, X11 video extension interface for xine * @@ -54,6 +54,8 @@ #include "video_out.h" #include "video_out_x11.h" #include "xine_internal.h" +/* #include "overlay.h" */ +#include "alphablend.h" uint32_t xine_debug; @@ -102,6 +104,7 @@ typedef struct { uint32_t capabilities; xv_frame_t *cur_frame; + vo_overlay_t *overlay; /* size / aspect ratio calculations */ int delivered_width; /* everything is set up for @@ -135,8 +138,6 @@ static uint32_t xv_get_capabilities (vo_driver_t *this_gen) { xv_driver_t *this = (xv_driver_t *) this_gen; - printf ("video_out_xv: get capabilities\n"); - return this->capabilities; } @@ -396,9 +397,6 @@ static void xv_update_frame_format (vo_driver_t *this_gen, frame->ratio_code = ratio_code; } -/* - * - */ static void xv_adapt_to_output_area (xv_driver_t *this, int dest_x, int dest_y, int dest_width, int dest_height) { @@ -447,9 +445,6 @@ static void xv_adapt_to_output_area (xv_driver_t *this, XUnlockDisplay (this->display); } -/* - * - */ static void xv_calc_format (xv_driver_t *this, int width, int height, int ratio_code) { @@ -567,6 +562,10 @@ static void xv_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) { xv_calc_format (this, frame->width, frame->height, frame->ratio_code); } +// Alpha Blend here + if (this->overlay) { + blend_yuv( frame->image->data, this->overlay, frame->width, frame->height); + } XLockDisplay (this->display); @@ -595,9 +594,13 @@ static void xv_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) { } } -/* - * - */ +/* Stores an overlay in the Video Out driver */ +static void xv_set_overlay (vo_driver_t *this_gen, vo_overlay_t *overlay) { + xv_driver_t *this = (xv_driver_t *) this_gen; + + this->overlay = overlay; +} + static int xv_get_property (vo_driver_t *this_gen, int property) { xv_driver_t *this = (xv_driver_t *) this_gen; @@ -605,9 +608,6 @@ static int xv_get_property (vo_driver_t *this_gen, int property) { return this->props[property].value; } -/* - * - */ static int xv_set_property (vo_driver_t *this_gen, int property, int value) { @@ -649,9 +649,6 @@ static int xv_set_property (vo_driver_t *this_gen, return value; } -/* - * - */ static void xv_get_property_min_max (vo_driver_t *this_gen, int property, int *min, int *max) { @@ -661,9 +658,6 @@ static void xv_get_property_min_max (vo_driver_t *this_gen, *max = this->props[property].max; } -/* - * - */ static int xv_gui_data_exchange (vo_driver_t *this_gen, int data_type, void *data) { @@ -730,9 +724,6 @@ static int xv_gui_data_exchange (vo_driver_t *this_gen, return 0; } -/* - * - */ static void xv_exit (vo_driver_t *this_gen) { xv_driver_t *this = (xv_driver_t *) this_gen; @@ -744,9 +735,6 @@ static void xv_exit (vo_driver_t *this_gen) { XUnlockDisplay (this->display); } -/* - * - */ static int xv_check_yv12 (Display *display, XvPortID port) { XvImageFormatValues * formatValues; int formats; @@ -763,9 +751,6 @@ static int xv_check_yv12 (Display *display, XvPortID port) { return 1; } -/* - * - */ static void xv_check_capability (xv_driver_t *this, uint32_t capability, int property, XvAttribute attr, @@ -786,9 +771,6 @@ static void xv_check_capability (xv_driver_t *this, this->config->lookup_int (this->config, str_prop, nDefault)); } -/* - * - */ vo_driver_t *init_video_out_plugin (config_values_t *config, void *visual_gen) { xv_driver_t *this; @@ -875,6 +857,7 @@ vo_driver_t *init_video_out_plugin (config_values_t *config, void *visual_gen) { this->config = config; this->display = visual->display; + this->overlay = NULL; this->screen = visual->screen; this->display_ratio = visual->display_ratio; this->request_dest_size = visual->request_dest_size; @@ -897,6 +880,7 @@ vo_driver_t *init_video_out_plugin (config_values_t *config, void *visual_gen) { this->vo_driver.alloc_frame = xv_alloc_frame; this->vo_driver.update_frame_format = xv_update_frame_format; this->vo_driver.display_frame = xv_display_frame; + this->vo_driver.set_overlay = xv_set_overlay; this->vo_driver.get_property = xv_get_property; this->vo_driver.set_property = xv_set_property; this->vo_driver.get_property_min_max = xv_get_property_min_max; @@ -1010,11 +994,8 @@ vo_driver_t *init_video_out_plugin (config_values_t *config, void *visual_gen) { return &this->vo_driver; } -/* - * - */ static vo_info_t vo_info_xv = { - VIDEO_OUT_IFACE_VERSION, + 2, "Xv", "xine video output plugin using the MIT X video extension", VISUAL_TYPE_X11, |