summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/xine.h.tmpl.in92
-rw-r--r--src/libspucc/cc_decoder.c7
-rw-r--r--src/libsputext/xine_decoder.c8
-rw-r--r--src/xine-engine/osd.c39
-rw-r--r--src/xine-engine/osd.h47
-rw-r--r--src/xine-engine/video_out.h10
-rw-r--r--src/xine-engine/xine.c8
7 files changed, 176 insertions, 35 deletions
diff --git a/include/xine.h.tmpl.in b/include/xine.h.tmpl.in
index 3b83ef708..3e9f59dd9 100644
--- a/include/xine.h.tmpl.in
+++ b/include/xine.h.tmpl.in
@@ -28,7 +28,7 @@
\endverbatim
*/
/*
- * $Id: xine.h.tmpl.in,v 1.72 2002/01/05 21:54:16 miguelfreitas Exp $
+ * $Id: xine.h.tmpl.in,v 1.73 2002/01/08 16:47:56 cvogler Exp $
*
*/
@@ -388,6 +388,12 @@ int xine_check_version(int major, int minor, int sub);
/** @} end of video_ratio */
/**
+ * \def OVL_PALETTE_SIZE
+ * The number of colors in the overlay palette.
+ */
+#define OVL_PALETTE_SIZE 256
+
+/**
* \struct vo_frame_t
* Opaque data type.
* \sa vo_driver_t
@@ -1612,6 +1618,74 @@ int xine_get_current_frame (xine_t *self, int *width, int *height,
* @{
*/
+ /**
+ * \defgroup osd_textgroup OSD text attributes
+ * @{
+ */
+
+/**
+ * \def TEXT_PALETTE_SIZE
+ * The size of an OSD text palette
+ */
+#define TEXT_PALETTE_SIZE 11
+
+/** Preassigned color index for text palettes and rendering text */
+#define OSD_TEXT1 (0 * TEXT_PALETTE_SIZE)
+
+/** Preassigned color index for text palettes and rendering text */
+#define OSD_TEXT2 (1 * TEXT_PALETTE_SIZE)
+
+/** Preassigned color index for text palettes and rendering text */
+#define OSD_TEXT3 (2 * TEXT_PALETTE_SIZE)
+
+/** Preassigned color index for text palettes and rendering text */
+#define OSD_TEXT4 (3 * TEXT_PALETTE_SIZE)
+
+/** Preassigned color index for text palettes and rendering text */
+#define OSD_TEXT5 (4 * TEXT_PALETTE_SIZE)
+
+/** Preassigned color index for text palettes and rendering text */
+#define OSD_TEXT6 (5 * TEXT_PALETTE_SIZE)
+
+/** Preassigned color index for text palettes and rendering text */
+#define OSD_TEXT7 (6 * TEXT_PALETTE_SIZE)
+
+/** Preassigned color index for text palettes and rendering text */
+#define OSD_TEXT8 (7 * TEXT_PALETTE_SIZE)
+
+/** Preassigned color index for text palettes and rendering text */
+#define OSD_TEXT9 (8 * TEXT_PALETTE_SIZE)
+
+/** Preassigned color index for text palettes and rendering text */
+#define OSD_TEXT10 (9 * TEXT_PALETTE_SIZE)
+
+/**
+ * \def TEXTPALETTE_WHITE_BLACK_TRANSPARENT
+ * White text, black border, transparent background
+ */
+#define TEXTPALETTE_WHITE_BLACK_TRANSPARENT 0
+
+/**
+ * \def TEXTPALETTE_WHITE_NONE_TRANSPARENT
+ * White text, noborder, transparent background
+ */
+#define TEXTPALETTE_WHITE_NONE_TRANSPARENT 1
+
+/**
+ * \def TEXTPALETTE_WHITE_NONE_TRANSLUCID
+ * White text, no border, translucid background
+ */
+#define TEXTPALETTE_WHITE_NONE_TRANSLUCID 2
+
+/**
+ * \def TEXTPALETTE_YELLOW_BLACK_TRANSPARENT
+ * Yellow text, black border, transparent background
+ */
+#define TEXTPALETTE_YELLOW_BLACK_TRANSPARENT 3
+
+ /** @} end of osd_textgroup */
+
+
typedef struct osd_object_s osd_object_t;
typedef struct osd_renderer_s osd_renderer_t;
typedef struct osd_font_s osd_font_t;
@@ -1666,8 +1740,15 @@ struct osd_renderer_s {
/*
* set on existing text palette
* (-1 to set used specified palette)
+ *
+ * color_base specifies the first color index to use for this text
+ * palette. The OSD palette is then modified starting at this
+ * color index, up to the size of the text palette.
+ *
+ * Use OSD_TEXT1, OSD_TEXT2, ... for some preasssigned color indices.
*/
- void (*set_text_palette) (osd_object_t *osd, int palette_number );
+ void (*set_text_palette) (osd_object_t *osd, int palette_number,
+ int color_base );
/*
* get palette (color and transparency)
@@ -1690,9 +1771,14 @@ struct osd_renderer_s {
/*
* render text on x,y position (8 bits version)
* no \n yet
+ *
+ * The text is assigned the colors starting at the index specified by
+ * color_base up to the size of the text palette.
+ *
+ * Use OSD_TEXT1, OSD_TEXT2, ... for some preasssigned color indices
*/
int (*render_text) (osd_object_t *osd, int x1, int y1,
- char *text);
+ char *text, int color_base);
/*
* get width and height of how text will be renderized
diff --git a/src/libspucc/cc_decoder.c b/src/libspucc/cc_decoder.c
index 2b07d58aa..e31735e7b 100644
--- a/src/libspucc/cc_decoder.c
+++ b/src/libspucc/cc_decoder.c
@@ -20,7 +20,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: cc_decoder.c,v 1.3 2002/01/07 23:09:38 cvogler Exp $
+ * $Id: cc_decoder.c,v 1.4 2002/01/08 16:47:56 cvogler Exp $
*
* stuff needed to provide closed captioning decoding and display
*
@@ -442,7 +442,8 @@ static void ccrow_render(cc_renderer_t *renderer, cc_row_t *this, int rownum)
buf[seg_pos[seg + 1] - seg_pos[seg]] = '\0';
ccrow_set_attributes(renderer, this, seg_pos[seg]);
osd_renderer->render_text(renderer->cap_display,
- x + cumulative_seg_width[seg], y, buf);
+ x + cumulative_seg_width[seg], y, buf,
+ OSD_TEXT1);
}
pos = ccrow_find_next_text_part(this, endpos);
@@ -667,7 +668,7 @@ static void cc_renderer_adjust_osd_object(cc_renderer_t *this)
this->cap_display = this->osd_renderer->new_object(this->osd_renderer,
this->width,
this->height);
- this->osd_renderer->set_text_palette(this->cap_display, 2);
+ this->osd_renderer->set_text_palette(this->cap_display, 2, OSD_TEXT1);
}
diff --git a/src/libsputext/xine_decoder.c b/src/libsputext/xine_decoder.c
index 26dadc827..2fb5725a9 100644
--- a/src/libsputext/xine_decoder.c
+++ b/src/libsputext/xine_decoder.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_decoder.c,v 1.10 2001/12/17 00:55:25 miguelfreitas Exp $
+ * $Id: xine_decoder.c,v 1.11 2002/01/08 16:47:56 cvogler Exp $
*
* code based on mplayer module:
*
@@ -776,7 +776,7 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) {
this->renderer->set_position (this->osd, 0, y);
- this->renderer->render_text (this->osd, 0, 0, "sputext decoder");
+ this->renderer->render_text (this->osd, 0, 0, "sputext decoder", OSD_TEXT1);
this->renderer->show (this->osd, 0);
this->renderer->hide (this->osd, 300000);
@@ -883,13 +883,13 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) {
}
}
- this->renderer->render_text (this->osd, x, y + line*this->line_height, subtitle->text[line]);
+ this->renderer->render_text (this->osd, x, y + line*this->line_height, subtitle->text[line], OSD_TEXT1);
}
if( font_size != this->font_size )
this->renderer->set_font (this->osd, this->font, this->font_size);
- this->renderer->set_text_palette (this->osd, -1);
+ this->renderer->set_text_palette (this->osd, -1, OSD_TEXT1);
this->renderer->show (this->osd, pts );
this->renderer->hide (this->osd, pts_end);
diff --git a/src/xine-engine/osd.c b/src/xine-engine/osd.c
index b7ada470a..c9d3f0458 100644
--- a/src/xine-engine/osd.c
+++ b/src/xine-engine/osd.c
@@ -67,8 +67,8 @@ struct osd_object_s {
int x1, y1;
int x2, y2;
- uint32_t color[16]; /* color lookup table */
- uint8_t trans[16]; /* mixer key table */
+ uint32_t color[OVL_PALETTE_SIZE]; /* color lookup table */
+ uint8_t trans[OVL_PALETTE_SIZE]; /* mixer key table */
int32_t handle;
@@ -432,15 +432,22 @@ static void osd_set_palette(osd_object_t *osd, uint32_t *color, uint8_t *trans )
* (-1 to set user specified palette)
*/
-static void osd_set_text_palette(osd_object_t *osd, int palette_number ) {
+static void osd_set_text_palette(osd_object_t *osd, int palette_number,
+ int color_base) {
if( palette_number < 0 )
palette_number = osd->renderer->textpalette;
-
- memcpy(osd->color, textpalettes_color[palette_number],
- sizeof(textpalettes_color[palette_number]));
- memcpy(osd->trans, textpalettes_trans[palette_number],
- sizeof(textpalettes_trans[palette_number]));
+
+ /* some sanity checks for the color indices */
+ if( color_base < 0 )
+ color_base = 0;
+ else if( color_base > OVL_PALETTE_SIZE - TEXT_PALETTE_SIZE )
+ color_base = OVL_PALETTE_SIZE - TEXT_PALETTE_SIZE;
+
+ memcpy(&osd->color[color_base], textpalettes_color[palette_number],
+ sizeof(textpalettes_color[palette_number]));
+ memcpy(&osd->trans[color_base], textpalettes_trans[palette_number],
+ sizeof(textpalettes_trans[palette_number]));
}
@@ -634,7 +641,8 @@ static int osd_set_font( osd_object_t *osd, char *fontname, int size) {
* render text on x,y position (8 bits version)
* no \n yet
*/
-static int osd_render_text (osd_object_t *osd, int x1, int y1, char *text) {
+static int osd_render_text (osd_object_t *osd, int x1, int y1,
+ char *text, int color_base) {
osd_renderer_t *this = osd->renderer;
osd_font_t *font;
@@ -645,7 +653,13 @@ static int osd_render_text (osd_object_t *osd, int x1, int y1, char *text) {
#ifdef LOG_DEBUG
printf("osd_render_text %p (%d,%d) \"%s\"\n", osd, x1, y1, text);
#endif
-
+
+ /* some sanity checks for the color indices */
+ if( color_base < 0 )
+ color_base = 0;
+ else if( color_base > OVL_PALETTE_SIZE - TEXT_PALETTE_SIZE )
+ color_base = OVL_PALETTE_SIZE - TEXT_PALETTE_SIZE;
+
pthread_mutex_lock (&this->osd_mutex);
font = osd->font;
@@ -672,7 +686,10 @@ static int osd_render_text (osd_object_t *osd, int x1, int y1, char *text) {
src = font->fontchar[i].bmp;
for( y = 0; y < font->fontchar[i].height; y++ ) {
- memcpy( dst, src, font->fontchar[i].width );
+ int width = font->fontchar[i].width;
+ uint8_t *s = src, *d = dst;
+ while (s < src + width)
+ *d++ = *s++ + (uint8_t) color_base;
src += font->fontchar[i].width;
dst += osd->width;
}
diff --git a/src/xine-engine/osd.h b/src/xine-engine/osd.h
index 177b9d817..ba75554a5 100644
--- a/src/xine-engine/osd.h
+++ b/src/xine-engine/osd.h
@@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
* OSD stuff (text and graphic primitives)
- * $Id: osd.h,v 1.6 2002/01/05 21:54:17 miguelfreitas Exp $
+ * $Id: osd.h,v 1.7 2002/01/08 16:47:57 cvogler Exp $
*/
#ifndef HAVE_OSD_H
@@ -84,8 +84,15 @@ struct osd_renderer_s {
/*
* set on existing text palette
* (-1 to set used specified palette)
+ *
+ * color_base specifies the first color index to use for this text
+ * palette. The OSD palette is then modified starting at this
+ * color index, up to the size of the text palette.
+ *
+ * Use OSD_TEXT1, OSD_TEXT2, ... for some preasssigned color indices.
*/
- void (*set_text_palette) (osd_object_t *osd, int palette_number );
+ void (*set_text_palette) (osd_object_t *osd, int palette_number,
+ int color_base );
/*
* get palette (color and transparency)
@@ -108,9 +115,14 @@ struct osd_renderer_s {
/*
* render text on x,y position (8 bits version)
* no \n yet
+ *
+ * The text is assigned the colors starting at the index specified by
+ * color_base up to the size of the text palette.
+ *
+ * Use OSD_TEXT1, OSD_TEXT2, ... for some preasssigned color indices.
*/
int (*render_text) (osd_object_t *osd, int x1, int y1,
- char *text);
+ char *text, int color_base);
/*
* get width and height of how text will be renderized
@@ -149,6 +161,27 @@ struct osd_renderer_s {
osd_renderer_t *osd_renderer_init( video_overlay_instance_t *video_overlay, config_values_t *config );
+/*
+ * The size of a text palette
+ */
+
+#define TEXT_PALETTE_SIZE 11
+
+/*
+ * Preassigned color indices for rendering text
+ * (more can be added, not exceeding OVL_PALETTE_SIZE)
+ */
+
+#define OSD_TEXT1 (0 * TEXT_PALETTE_SIZE)
+#define OSD_TEXT2 (1 * TEXT_PALETTE_SIZE)
+#define OSD_TEXT3 (2 * TEXT_PALETTE_SIZE)
+#define OSD_TEXT4 (3 * TEXT_PALETTE_SIZE)
+#define OSD_TEXT5 (4 * TEXT_PALETTE_SIZE)
+#define OSD_TEXT6 (5 * TEXT_PALETTE_SIZE)
+#define OSD_TEXT7 (6 * TEXT_PALETTE_SIZE)
+#define OSD_TEXT8 (7 * TEXT_PALETTE_SIZE)
+#define OSD_TEXT9 (8 * TEXT_PALETTE_SIZE)
+#define OSD_TEXT10 (9 * TEXT_PALETTE_SIZE)
/*
* Defined palettes for rendering osd text
@@ -157,8 +190,8 @@ osd_renderer_t *osd_renderer_init( video_overlay_instance_t *video_overlay, conf
#define NUMBER_OF_TEXT_PALETTES 4
#define TEXTPALETTE_WHITE_BLACK_TRANSPARENT 0
-#define TEXTPALETTE_WHITE_NONE_TRANSLUCID 1
-#define TEXTPALETTE_WHITE_NONE_TRANSPUCID 2
+#define TEXTPALETTE_WHITE_NONE_TRANSPARENT 1
+#define TEXTPALETTE_WHITE_NONE_TRANSLUCID 2
#define TEXTPALETTE_YELLOW_BLACK_TRANSPARENT 3
#ifdef __OSD_C__
@@ -192,7 +225,7 @@ static char *textpalettes_str[NUMBER_OF_TEXT_PALETTES+1] = {
This can surelly be improved a lot. [Miguel]
*/
-static clut_t textpalettes_color[NUMBER_OF_TEXT_PALETTES][11] = {
+static clut_t textpalettes_color[NUMBER_OF_TEXT_PALETTES][TEXT_PALETTE_SIZE] = {
/* white, black border, transparent */
{
CLUT_Y_CR_CB_INIT(0x00, 0x00, 0x00), //0
@@ -251,7 +284,7 @@ static clut_t textpalettes_color[NUMBER_OF_TEXT_PALETTES][11] = {
},
};
-static uint8_t textpalettes_trans[NUMBER_OF_TEXT_PALETTES][11] = {
+static uint8_t textpalettes_trans[NUMBER_OF_TEXT_PALETTES][TEXT_PALETTE_SIZE] = {
{0, 0, 3, 6, 8, 10, 12, 14, 15, 15, 15 },
{0, 0, 0, 0, 0, 0, 2, 6, 9, 12, 15 },
{0, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15 },
diff --git a/src/xine-engine/video_out.h b/src/xine-engine/video_out.h
index 69b808970..569b054d1 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.33 2001/12/24 00:45:03 guenter Exp $
+ * $Id: video_out.h,v 1.34 2002/01/08 16:47:57 cvogler Exp $
*
*
* xine version of video_out.h
@@ -195,6 +195,10 @@ struct vo_instance_s {
#define VO_ZOOM_MAX 400
#define VO_ZOOM_MIN -85
+/* number of colors in the overlay palette. Currently limited to 256
+ at most, because some alphablend functions use an 8-bit index into
+ the palette. This should probably be classified as a bug. */
+#define OVL_PALETTE_SIZE 256
/* number of recent frames to keep in memory
these frames are needed by some deinterlace algorithms
@@ -316,8 +320,8 @@ struct vo_overlay_s {
int width; /* width of subpicture area */
int height; /* height of subpicture area */
- uint32_t color[16]; /* color lookup table */
- uint8_t trans[16]; /* mixer key table */
+ uint32_t color[OVL_PALETTE_SIZE]; /* color lookup table */
+ uint8_t trans[OVL_PALETTE_SIZE]; /* mixer key table */
int rgb_clut; /* true if clut was converted to rgb*/
int clip_top;
diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c
index 60729e63e..a2485353b 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.95 2002/01/02 18:16:08 jkeil Exp $
+ * $Id: xine.c,v 1.96 2002/01/08 16:47:57 cvogler Exp $
*
* top-level xine functions
*
@@ -119,7 +119,7 @@ static void xine_internal_osd (xine_t *this, char *str,
if( this->osd_display ) {
this->osd_renderer->filled_rect (this->osd, 0, 0, 299, 99, 0);
- this->osd_renderer->render_text (this->osd, 0, 5, str);
+ this->osd_renderer->render_text (this->osd, 0, 5, str, OSD_TEXT1);
seconds = this->cur_input_time;
@@ -128,7 +128,7 @@ static void xine_internal_osd (xine_t *this, char *str,
(seconds % (60*60)) / 60,
seconds % 60);
- this->osd_renderer->render_text (this->osd, 70, 5, tstr);
+ this->osd_renderer->render_text (this->osd, 70, 5, tstr, OSD_TEXT1);
this->osd_renderer->show (this->osd, start_time);
this->osd_renderer->hide (this->osd, start_time+duration);
@@ -506,7 +506,7 @@ xine_t *xine_init (vo_driver_t *vo,
this->osd = this->osd_renderer->new_object (this->osd_renderer, 300, 100);
this->osd_renderer->set_font (this->osd, "cetus", 24);
- this->osd_renderer->set_text_palette (this->osd, TEXTPALETTE_WHITE_BLACK_TRANSPARENT );
+ this->osd_renderer->set_text_palette (this->osd, TEXTPALETTE_WHITE_BLACK_TRANSPARENT, OSD_TEXT1 );
this->osd_renderer->set_position (this->osd, 10,10);
this->osd_display = config->register_bool(config, "misc.osd_display", 1,