From a77bbcfbd72eb77d1eb8ace960762be1a1228f8d Mon Sep 17 00:00:00 2001 From: Guenter Bartsch Date: Sun, 2 Dec 2001 15:27:19 +0000 Subject: avi subtitles centered and at bottom of frame CVS patchset: 1160 CVS date: 2001/12/02 15:27:19 --- src/demuxers/demux_avi.c | 6 +++- src/libsputext/xine_decoder.c | 81 +++++++++++++++++++++++++++++++------------ 2 files changed, 63 insertions(+), 24 deletions(-) diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c index 781a45df7..ba6d201ef 100644 --- a/src/demuxers/demux_avi.c +++ b/src/demuxers/demux_avi.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: demux_avi.c,v 1.55 2001/12/01 22:38:31 guenter Exp $ + * $Id: demux_avi.c,v 1.56 2001/12/02 15:27:19 guenter Exp $ * * demultiplexer for avi streams * @@ -1005,6 +1005,10 @@ static void demux_avi_start (demux_plugin_t *this_gen, buf->type = BUF_SPU_TEXT; + buf->decoder_info[0] = 0; + buf->decoder_info[1] = this->avi->width; + buf->decoder_info[2] = this->avi->height; + this->video_fifo->put (this->video_fifo, buf); printf ("demux_avi: text subtitle file available\n"); diff --git a/src/libsputext/xine_decoder.c b/src/libsputext/xine_decoder.c index 73e8b7770..7da65b241 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.1 2001/12/01 22:38:32 guenter Exp $ + * $Id: xine_decoder.c,v 1.2 2001/12/02 15:27:20 guenter Exp $ * * code based on mplayer module: * @@ -44,12 +44,14 @@ #include "osd.h" /* -#define LOG_DEBUG 1 +#define LOG 1 */ #define ERR (void *)-1 -#define SUB_MAX_TEXT 5 +#define SUB_MAX_TEXT 5 +#define LINE_HEIGHT 20 +#define LINE_WIDTH 300 typedef struct { @@ -737,8 +739,10 @@ static void spudec_init (spu_decoder_t *this_gen, vo_instance_t *vo_out) { this->format = 0; this->previous_aqt_sub = NULL; - this->osd = osd_open (this->xine->osd_renderer, 500, 100); + this->osd = osd_open (this->xine->osd_renderer, LINE_WIDTH, SUB_MAX_TEXT * LINE_HEIGHT); + osd_renderer_load_font (this->xine->osd_renderer, "vga"); + osd_set_font (this->osd,"vga"); osd_render_text (this->osd, 0, 0, "sputext decoder"); osd_set_position (this->osd, 10, 30); @@ -773,7 +777,7 @@ static void *spudec_loop (void *this_gen) { while (current && this->running) { - int32_t diff, sub_pts, wrap_offset, pts; + int32_t diff, sub_pts, pts; pts = this->xine->metronom->get_current_time (this->xine->metronom); @@ -783,7 +787,7 @@ static void *spudec_loop (void *this_gen) { pts_factor = this->xine->metronom->get_video_rate (this->xine->metronom); #ifdef LOG - printf ("pts_factor : %d\n", pts_factor); + printf ("sputext: pts_factor : %d\n", pts_factor); #endif if (!pts_factor) { @@ -817,12 +821,22 @@ static void *spudec_loop (void *this_gen) { if (diff < 30000) { - int line; + int line, y; + + osd_filled_rect (this->osd, 0, 0, LINE_WIDTH-1, LINE_HEIGHT * SUB_MAX_TEXT - 1, 0); + + y = (SUB_MAX_TEXT - current->lines) * LINE_HEIGHT; + + for (line=0; linelines; line++) { + int w,h,x; + + osd_get_text_size( this->osd, current->text[line], + & w, &h); - osd_filled_rect (this->osd, 0, 0, 499, 99, 0); + x = (LINE_WIDTH - w) / 2; - for (line=0; linelines; line++) - osd_render_text (this->osd, 0, line*20, current->text[line]); + osd_render_text (this->osd, x, y + line*20, current->text[line]); + } osd_show (this->osd, sub_pts); osd_hide (this->osd, current->end * pts_factor + this->xine->metronom->video_wrap_offset); @@ -848,22 +862,37 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) { sputext_decoder_t *this = (sputext_decoder_t *) this_gen; int err; - this->fd = (FILE *) buf->content; - - this->subtitles = sub_read_file (this); + if (buf->decoder_info[0] == 0) { + + int x, y; + + x = buf->decoder_info[1] / 2 - LINE_WIDTH / 2; + if (x<0) + x = 0; + + y = buf->decoder_info[2] - (SUB_MAX_TEXT * LINE_HEIGHT) - 5; - printf ("sputext: subtitle format %s time.\n", this->uses_time?"uses":"doesn't use"); - printf ("sputext: read %i subtitles, %i errors.\n", this->num, this->errs); + osd_set_position (this->osd, x, y); - /* start thread */ + printf ("sputext: position is %d / %d\n", x, y); - this->running = 1; + this->fd = (FILE *) buf->content; + + this->subtitles = sub_read_file (this); + + printf ("sputext: subtitle format %s time.\n", this->uses_time?"uses":"doesn't use"); + printf ("sputext: read %i subtitles, %i errors.\n", this->num, this->errs); + + /* start thread */ - if ((err = pthread_create (&this->spu_thread, - NULL, spudec_loop, this)) != 0) { - printf ("sputext: can't create new thread (%s)\n", - strerror(err)); - exit (1); + this->running = 1; + + if ((err = pthread_create (&this->spu_thread, + NULL, spudec_loop, this)) != 0) { + printf ("sputext: can't create new thread (%s)\n", + strerror(err)); + exit (1); + } } } @@ -880,6 +909,12 @@ static void spudec_close (spu_decoder_t *this_gen) { pthread_join (this->spu_thread, &p); printf ("sputext: ...thread stopped\n"); + + if (this->osd) { + osd_close (this->osd); + this->osd = NULL; + } + } static char *spudec_get_id(void) { @@ -908,7 +943,7 @@ spu_decoder_t *init_spu_decoder_plugin (int iface_version, xine_t *xine) { this->spu_decoder.priority = 1; this->xine = xine; - + return (spu_decoder_t *) this; } -- cgit v1.2.3