diff options
author | Rich J Wareham <richwareham@users.sourceforge.net> | 2001-07-25 23:26:14 +0000 |
---|---|---|
committer | Rich J Wareham <richwareham@users.sourceforge.net> | 2001-07-25 23:26:14 +0000 |
commit | 5720d1a5ca1544769c98f10c4032ffacd7c8ae9e (patch) | |
tree | f7edf8aaf13c36c3dbd6c7a02341a29398955f8e | |
parent | 1a8845d5b0190c82c32340433a6dd7f9d1d9660c (diff) | |
download | xine-lib-5720d1a5ca1544769c98f10c4032ffacd7c8ae9e.tar.gz xine-lib-5720d1a5ca1544769c98f10c4032ffacd7c8ae9e.tar.bz2 |
A few small changes to help in some specific cases. Also a nasty hack added temporarily
CVS patchset: 348
CVS date: 2001/07/25 23:26:14
-rw-r--r-- | src/video_out/alphablend.c | 150 | ||||
-rw-r--r-- | src/video_out/video_out_xv.c | 9 | ||||
-rw-r--r-- | src/xine-engine/events.h | 10 | ||||
-rw-r--r-- | src/xine-engine/video_out.c | 11 | ||||
-rw-r--r-- | src/xine-engine/video_out.h | 4 | ||||
-rw-r--r-- | src/xine-engine/xine.c | 32 |
6 files changed, 136 insertions, 80 deletions
diff --git a/src/video_out/alphablend.c b/src/video_out/alphablend.c index 21669e96a..641578f61 100644 --- a/src/video_out/alphablend.c +++ b/src/video_out/alphablend.c @@ -225,11 +225,8 @@ void blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl, int dst_width, 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) -{ +// #define BLEND_YUV(dst, src, o) (((src)*o + ((dst)*(0xf-o)))/0xf) +#define BLEND_YUV(dst, src, o) ( (((uint16_t)src)*o + ((uint16_t)dst)*(0xf-o)) >> 4 ) /* FIXME: my_clut should disappear once I find out how to get the clut from the MPEG2 stream. */ /* It looks like it comes from the ,IFO file, so will have to wait for IFO parser in xine. * Here is an extract of another DVD player (oms) @@ -237,73 +234,88 @@ void blend_yuv (uint8_t * dst_img, vo_overlay_t * img_overl, * codec->ctrl (codec, CTRL_SPU_SET_CLUT, clut); */ /* This happens to work with "The Matrix" using 0(edges), 8(white) */ - clut_t my_clut[] = { - {y: 0x00, cr: 0x80, cb:0x80}, - {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: 0xbf, cr: 0x80, cb:0x80}, - {y: 0x51, 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} - }; - - int src_width = img_overl->width; - int src_height = img_overl->height; - uint8_t *src_data = img_overl->data; - int step=dst_width - src_width; - 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) + 1; - uint8_t *dst_cb = dst_img + (dst_width * dst_height * 5) / 4 + - (y_off / 2) * (dst_width / 2) + (x_off / 2) + 1; - - int x, y; - for (y = 0; y < src_height; y++) { - for (x = 0; x < src_width; x++) { - uint8_t clr; - uint8_t mask; - uint8_t o; - - mask = (*src_data) >> 4 ; - - if (mask) { - clr = img_overl->clut[*src_data & 0x03]; - o = img_overl->trans[*src_data & 0x03]; - *dst_y = BLEND_YUV (*dst_y, my_clut[clr].y, o); - } - dst_y++; - - if (y & x & 1) { - if (mask) { - *dst_cr = BLEND_YUV (*dst_cr, my_clut[clr].cr, o); - *dst_cb = BLEND_YUV (*dst_cb, my_clut[clr].cb, o); - } - dst_cr++; - dst_cb++; - } - src_data++; - } - dst_y += step; +static clut_t __default_clut[] = { + {y: 0x00, cr: 0x80, cb:0x80}, + {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: 0xbf, cr: 0x80, cb:0x80}, + {y: 0x51, 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} +}; - if (y & 1) { - dst_cr += (step + 1) / 2; - dst_cb += (step + 1) / 2; - } +void blend_yuv (uint8_t * dst_img, vo_overlay_t * img_overl, + int dst_width, int dst_height) +{ + clut_t *my_clut; + + int src_width = img_overl->width; + int src_height = img_overl->height; + uint8_t *src_data = img_overl->data; + int step=dst_width - src_width; + 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) + 1; + uint8_t *dst_cb = dst_img + (dst_width * dst_height * 5) / 4 + + (y_off / 2) * (dst_width / 2) + (x_off / 2) + 1; + + int x, y; + + /* If there is a CLUT palette specified, use it instead. */ + if(img_overl->clut_tbl != NULL) { + my_clut = (clut_t*)img_overl->clut_tbl; + } else { + my_clut = __default_clut; + } + + for (y = 0; y < src_height; y++) { + for (x = 0; x < src_width; x++) { + uint8_t clr; + uint8_t mask; + uint16_t o; + + mask = (*src_data) >> 4 ; + + clr = img_overl->clut[*src_data & 0x03]; + o = img_overl->trans[*src_data & 0x03]; + if(o) + *dst_y = BLEND_YUV (*dst_y, my_clut[clr].y, o); + dst_y++; + + if (y & x & 1) { + if (mask) { + if(o) { + *dst_cr = BLEND_YUV (*dst_cr, my_clut[clr].cr, o); + *dst_cb = BLEND_YUV (*dst_cb, my_clut[clr].cb, o); + } } + dst_cr++; + dst_cb++; + } + src_data++; + } + + dst_y += step; + + if (y & 1) { + dst_cr += (step + 1) / 2; + dst_cb += (step + 1) / 2; + } + } } inline int is_blank (uint8_t * ptr, int width) diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c index 3a652b2a4..aebcd6730 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.55 2001/07/24 12:57:30 guenter Exp $ + * $Id: video_out_xv.c,v 1.56 2001/07/25 23:26:14 richwareham Exp $ * * video_out_xv.c, X11 video extension interface for xine * @@ -547,10 +547,9 @@ static void xv_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_o * As XV drivers improve to support Hardware overlay, we will change this function. */ - if (overlay->data) { - blend_yuv( frame->image->data, overlay, frame->width, frame->height); - } - + if (overlay->data) { + blend_yuv( frame->image->data, overlay, frame->width, frame->height); + } } /* diff --git a/src/xine-engine/events.h b/src/xine-engine/events.h index c812d7960..3eebe4b3d 100644 --- a/src/xine-engine/events.h +++ b/src/xine-engine/events.h @@ -53,6 +53,16 @@ typedef struct mouse_event_s { uint16_t x,y; /* In Image space */ } mouse_event_t; +/** + * Overlay event - used for plugins/UIs to request that a specific overlay be + * displayed. + */ +#define XINE_OVERLAY_EVENT 0x0002 +typedef struct overlay_event_s { + event_t event; + vo_overlay_t overlay; +} overlay_event_t; + #ifdef __cplusplus } #endif diff --git a/src/xine-engine/video_out.c b/src/xine-engine/video_out.c index 838423c42..f9ebefe15 100644 --- a/src/xine-engine/video_out.c +++ b/src/xine-engine/video_out.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.c,v 1.36 2001/07/24 12:57:30 guenter Exp $ + * $Id: video_out.c,v 1.37 2001/07/25 23:26:14 richwareham Exp $ * */ @@ -574,6 +574,7 @@ static vo_overlay_t *vo_get_overlay (vo_instance_t *this) { if (this->first_overlay==NULL) { this->first_overlay = this->last_overlay = xmalloc (sizeof (vo_overlay_t)) ; this->first_overlay->data=NULL; + this->first_overlay->clut_tbl=NULL; this->first_overlay->next=NULL; this->first_overlay->priv=NULL; this->first_overlay->state=OVERLAY_CREATING; @@ -601,10 +602,12 @@ static vo_overlay_t *vo_get_overlay (vo_instance_t *this) { } static void vo_queue_overlay (vo_instance_t *this, vo_overlay_t *overlay) { - overlay->PTS = this->metronom->got_spu_packet (this->metronom, overlay->PTS,overlay->duration); - if (overlay->data==NULL) overlay->state=OVERLAY_FREE; - else overlay->state=OVERLAY_READY_TO_SHOW; + if (overlay->data==NULL) { + overlay->state=OVERLAY_FREE; + } else { + overlay->state=OVERLAY_READY_TO_SHOW; + } } vo_instance_t *vo_new_instance (vo_driver_t *driver, metronom_t *metronom) { diff --git a/src/xine-engine/video_out.h b/src/xine-engine/video_out.h index a17b30f67..0e9c366d8 100644 --- a/src/xine-engine/video_out.h +++ b/src/xine-engine/video_out.h @@ -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.h,v 1.14 2001/07/24 12:57:30 guenter Exp $ + * $Id: video_out.h,v 1.15 2001/07/25 23:26:14 richwareham Exp $ * * * xine version of video_out.h @@ -279,6 +279,8 @@ struct vo_overlay_s { vo_overlay_t *priv; /* optionally more overlays */ int state; /* State:FREE,SHOWING etc. */ + uint32_t *clut_tbl; /* Pointer to CLUT palette */ + /* private stuff */ int _x; /* current destination x, y */ int _y; diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 4691bb071..cdb0f52b5 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.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: xine.c,v 1.35 2001/07/14 23:17:37 richwareham Exp $ + * $Id: xine.c,v 1.36 2001/07/25 23:26:14 richwareham Exp $ * * top-level xine functions * @@ -207,6 +207,12 @@ static void xine_play_internal (xine_t *this, char *mrl, printf ("xine: using input plugin >%s< for this MRL.\n", this->cur_input_plugin->get_identifier(this->cur_input_plugin)); + /* FIXME: This is almost certainly the WRONG way to do this but it is + * only temporary until a better way if found for plugins to send events. + */ + this->cur_input_plugin->get_optional_data(this->cur_input_plugin, + (void*)this, 0x1010); + /* * find demuxer plugin */ @@ -378,6 +384,30 @@ void event_handler(xine_t *xine, event_t *event, void *data) { } } break; + case XINE_OVERLAY_EVENT: + { + overlay_event_t *oevent = (overlay_event_t*)event; + if(xine->video_out != NULL) { + int i; + vo_overlay_t *overlay = xine->video_out->get_overlay (xine->video_out); + if(overlay != NULL) { + overlay->data = oevent->overlay.data; + overlay->x = oevent->overlay.x; + overlay->y = oevent->overlay.y; + overlay->width = oevent->overlay.width; + overlay->height = oevent->overlay.height; + for(i=0; i<4; i++) { + overlay->clut[i] = oevent->overlay.clut[i]; + overlay->trans[i] = oevent->overlay.trans[i]; + } + overlay->PTS = oevent->overlay.PTS; + overlay->clut_tbl = oevent->overlay.clut_tbl; + overlay->duration = oevent->overlay.duration; + xine->video_out->queue_overlay (xine->video_out, overlay); + } + } + } + break; } } |