From 39b4b1968511ecc361d9bb6e627ca5ca47909b74 Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton Date: Mon, 21 Oct 2002 12:10:58 +0000 Subject: Enable DVD SPU subtitles. CLUT and timing do not seem to be working well yet. CVS patchset: 2897 CVS date: 2002/10/21 12:10:58 --- src/Makefile.am | 1 + src/libspudec/spu.c | 17 +++-- src/libspudec/spu.h | 9 ++- src/libspudec/spu_decoder_api.h | 4 +- src/libspudec/xine_decoder.c | 148 +++++++++++++++++++++++----------------- src/xine-engine/video_decoder.c | 18 ++--- src/xine-engine/video_overlay.c | 3 +- src/xine-engine/xine.c | 4 +- 8 files changed, 120 insertions(+), 84 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 9d8e61e4d..9daae3c64 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -34,6 +34,7 @@ SUBDIRS = \ libffmpeg \ libmpeg2 \ liba52 \ + libspudec \ libmad \ libw32dll diff --git a/src/libspudec/spu.c b/src/libspudec/spu.c index 1e2ffda49..d935f5e03 100644 --- a/src/libspudec/spu.c +++ b/src/libspudec/spu.c @@ -35,7 +35,7 @@ * along with this program; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: spu.c,v 1.48 2002/09/30 05:16:45 jcdutton Exp $ + * $Id: spu.c,v 1.49 2002/10/21 12:11:00 jcdutton Exp $ * */ @@ -162,7 +162,7 @@ void spudec_decode_nav(spudec_decoder_t *this, buf_element_t *buf) { } if( this->menu_handle >= 0 ) { int64_t vpts_offset; - metronom_t *metronom = this->xine->metronom; + metronom_t *metronom = this->stream->metronom; this->event.object.handle = this->menu_handle; this->event.event_type = EVENT_HIDE_MENU; /* if !vpts then we are near a discontinuity but video_out havent detected @@ -183,7 +183,7 @@ void spudec_decode_nav(spudec_decoder_t *this, buf_element_t *buf) { #ifdef LOG_BUTTON fprintf(stdout, "libspudec: add_event HIDE_MENU type=%d : current time=%lld, spu vpts=%lli, vpts_offset=%lli\n", this->event.event_type, - this->xine->metronom->get_current_time(this->xine->metronom), + this->stream->metronom->get_current_time(this->stream->metronom), this->event.vpts, vpts_offset); #endif @@ -304,13 +304,13 @@ void spudec_process (spudec_decoder_t *this, uint32_t stream_id) { */ /* spu_channel is now set based on whether we are in the menu or not. */ /* Bit 7 is set if only forced display SPUs should be shown */ - if ( (this->xine->spu_channel & 0x1f) != stream_id ) { + if ( (this->stream->spu_channel & 0x1f) != stream_id ) { #ifdef LOG_DEBUG printf ("spu: Dropping SPU channel %d. Not selected stream_id\n", stream_id); #endif return; } - if ( (this->state.forced_display == 0) && (this->xine->spu_channel & 0x80) ) { + if ( (this->state.forced_display == 0) && (this->stream->spu_channel & 0x80) ) { #ifdef LOG_DEBUG printf ("spu: Dropping SPU channel %d. Only allow forced display SPUs\n", stream_id); #endif @@ -333,6 +333,8 @@ void spudec_process (spudec_decoder_t *this, uint32_t stream_id) { } if ( this->pci.hli.hl_gi.fosl_btnn > 0) { spu_button_t spu_button; +#if 0 +/* FIXME: get events working again. */ xine_spu_event_t spu_event; this->buttonN = this->pci.hli.hl_gi.fosl_btnn ; spu_event.event.type = XINE_EVENT_INPUT_BUTTON_FORCE; @@ -342,6 +344,7 @@ void spudec_process (spudec_decoder_t *this, uint32_t stream_id) { so the nav_pci info has to be passed in the event instead. */ memcpy(&spu_button.nav_pci, &this->pci, sizeof(pci_t) ); xine_send_event(this->xine, &spu_event.event); +#endif } #ifdef LOG_BUTTON fprintf(stderr, "libspudec:Full Overlay\n"); @@ -400,7 +403,7 @@ void spudec_process (spudec_decoder_t *this, uint32_t stream_id) { if( this->spudec_stream_state[stream_id].vpts ) { this->event.vpts = this->spudec_stream_state[stream_id].vpts+(this->state.delay*1000); } else { - this->event.vpts = this->xine->metronom->get_current_time(this->xine->metronom) + this->event.vpts = this->stream->metronom->get_current_time(this->stream->metronom) + (this->state.delay*1000); #ifdef LOG_BUTTON printf("libspudec: vpts current time estimation around discontinuity\n"); @@ -416,7 +419,7 @@ void spudec_process (spudec_decoder_t *this, uint32_t stream_id) { #ifdef LOG_BUTTON fprintf(stderr, "libspudec: add_event type=%d : current time=%lld, spu vpts=%lli\n", this->event.event_type, - this->xine->metronom->get_current_time(this->xine->metronom), + this->stream->metronom->get_current_time(this->stream->metronom), this->event.vpts); #endif ovl_instance->add_event(ovl_instance, (void *)&this->event); diff --git a/src/libspudec/spu.h b/src/libspudec/spu.h index 27329a30a..dc5959498 100644 --- a/src/libspudec/spu.h +++ b/src/libspudec/spu.h @@ -19,7 +19,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: spu.h,v 1.15 2002/07/06 16:36:43 mroi Exp $ + * $Id: spu.h,v 1.16 2002/10/21 12:11:01 jcdutton Exp $ * * This file was originally part of the OMS program. * @@ -93,10 +93,15 @@ typedef struct spudec_stream_state_s { int32_t overlay_handle; } spudec_stream_state_t; +typedef struct { + spu_decoder_class_t decoder_class; +} spudec_class_t; + typedef struct spudec_decoder_s { spu_decoder_t spu_decoder; - xine_t *xine; + spudec_class_t *class; + xine_stream_t *stream; spudec_stream_state_t spudec_stream_state[MAX_STREAMS]; video_overlay_event_t event; diff --git a/src/libspudec/spu_decoder_api.h b/src/libspudec/spu_decoder_api.h index d17f32a7b..3374ef447 100644 --- a/src/libspudec/spu_decoder_api.h +++ b/src/libspudec/spu_decoder_api.h @@ -63,13 +63,13 @@ struct spu_decoder_class_s { struct spu_decoder_s { - void (*init) (spu_decoder_t *this, vo_instance_t *video_out); +/* void (*init) (spu_decoder_t *this, vo_instance_t *video_out);*/ void (*decode_data) (spu_decoder_t *this, buf_element_t *buf); void (*reset) (spu_decoder_t *this); - void (*close) (spu_decoder_t *this); +/* void (*close) (spu_decoder_t *this); */ void (*dispose) (spu_decoder_t *this); diff --git a/src/libspudec/xine_decoder.c b/src/libspudec/xine_decoder.c index fc6adeaaa..ba255b1ae 100644 --- a/src/libspudec/xine_decoder.c +++ b/src/libspudec/xine_decoder.c @@ -19,7 +19,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.78 2002/10/14 14:00:19 jcdutton Exp $ + * $Id: xine_decoder.c,v 1.79 2002/10/21 12:11:01 jcdutton Exp $ * * stuff needed to turn libspu into a xine decoder plugin */ @@ -67,28 +67,6 @@ static clut_t __default_clut[] = { CLUT_Y_CR_CB_INIT(0x28, 0x6d, 0xef) }; -static void spudec_init (spu_decoder_t *this_gen, vo_instance_t *vo_out) { - - spudec_decoder_t *this = (spudec_decoder_t *) this_gen; - int i; - - pthread_mutex_init(&this->nav_pci_lock, NULL); - - this->vo_out = vo_out; - this->ovl_caps = vo_out->get_capabilities(vo_out); - this->output_open = 0; - this->last_event_vpts = 0; - for (i=0; i < MAX_STREAMS; i++) { - this->spudec_stream_state[i].stream_filter = 1; /* So it works with non-navdvd plugins */ - this->spudec_stream_state[i].ra_seq.complete = 1; - this->spudec_stream_state[i].overlay_handle = -1; - } - -/* FIXME:Do we really need a default clut? */ - xine_fast_memcpy(this->state.clut, __default_clut, sizeof(this->state.clut)); - this->state.need_clut = 1; -} - static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) { uint32_t stream_id; spudec_seq_t *cur_seq; @@ -134,7 +112,7 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) { return; if (buf->pts) { - metronom_t *metronom = this->xine->metronom; + metronom_t *metronom = this->stream->metronom; int64_t vpts = metronom->got_spu_packet(metronom, buf->pts); this->spudec_stream_state[stream_id].vpts = vpts; /* Show timer */ @@ -152,29 +130,13 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) { static void spudec_reset (spu_decoder_t *this_gen) { } -static void spudec_close (spu_decoder_t *this_gen) { - spudec_decoder_t *this = (spudec_decoder_t *) this_gen; - int i; - video_overlay_instance_t *ovl_instance = this->vo_out->get_overlay_instance (this->vo_out); - - if( this->menu_handle >= 0 ) - ovl_instance->free_handle(ovl_instance, - this->menu_handle); - this->menu_handle = -1; - - - for (i=0; i < MAX_STREAMS; i++) { - if( this->spudec_stream_state[i].overlay_handle >= 0 ) - ovl_instance->free_handle(ovl_instance, - this->spudec_stream_state[i].overlay_handle); - this->spudec_stream_state[i].overlay_handle = -1; - } - pthread_mutex_destroy(&this->nav_pci_lock); -} - static void spudec_event_listener(void *this_gen, xine_event_t *event_gen) { spudec_decoder_t *this = (spudec_decoder_t *) this_gen; +#if 0 +/* FIXME: get events working again. */ + xine_spu_event_t *event = (xine_spu_event_t *) event_gen; + video_overlay_instance_t *ovl_instance; if((!this) || (!event)) { @@ -256,7 +218,7 @@ static void spudec_event_listener(void *this_gen, xine_event_t *event_gen) { #ifdef LOG_NAV fprintf(stderr, "libspudec: add_event type=%d : current time=%lld, spu vpts=%lli\n", overlay_event->event_type, - this->xine->metronom->get_current_time(this->xine->metronom), + this->stream->metronom->get_current_time(this->stream->metronom), overlay_event->vpts); #endif ovl_instance->add_event (ovl_instance, (void *)overlay_event); @@ -279,20 +241,35 @@ static void spudec_event_listener(void *this_gen, xine_event_t *event_gen) { } break; } -} - -static char *spudec_get_id(void) { - return "spudec"; +#endif } static void spudec_dispose (spu_decoder_t *this_gen) { - spudec_decoder_t *this = (spudec_decoder_t *) this_gen; - xine_remove_event_listener (this->xine, spudec_event_listener); + spudec_decoder_t *this = (spudec_decoder_t *) this_gen; + int i; + video_overlay_instance_t *ovl_instance = this->vo_out->get_overlay_instance (this->vo_out); + + if( this->menu_handle >= 0 ) + ovl_instance->free_handle(ovl_instance, + this->menu_handle); + this->menu_handle = -1; + + + for (i=0; i < MAX_STREAMS; i++) { + if( this->spudec_stream_state[i].overlay_handle >= 0 ) + ovl_instance->free_handle(ovl_instance, + this->spudec_stream_state[i].overlay_handle); + this->spudec_stream_state[i].overlay_handle = -1; + } + pthread_mutex_destroy(&this->nav_pci_lock); + /* FIXME: get events working. */ + /*xine_remove_event_listener (this->stream, spudec_event_listener);*/ free (this->event.object.overlay); free (this); } + /* gets the current already correctly processed nav_pci info */ /* This is not perfectly in sync with the display, but all the same, */ /* much closer than doing it at the input stage. */ @@ -310,41 +287,90 @@ static int spudec_get_nav_pci (spu_decoder_t *this_gen, pci_t *pci) { } -static void *init_spu_decoder_plugin (xine_t *xine, void *data) { +static spu_decoder_t *open_plugin (spu_decoder_class_t *class_gen, xine_stream_t *stream) { spudec_decoder_t *this ; + int i; this = (spudec_decoder_t *) xine_xmalloc (sizeof (spudec_decoder_t)); - this->spu_decoder.init = spudec_init; this->spu_decoder.decode_data = spudec_decode_data; this->spu_decoder.reset = spudec_reset; - this->spu_decoder.close = spudec_close; - this->spu_decoder.get_identifier = spudec_get_id; this->spu_decoder.dispose = spudec_dispose; this->spu_decoder.get_nav_pci = spudec_get_nav_pci; - - this->xine = xine; + this->stream = stream; + this->class = (spudec_class_t *) class_gen; this->menu_handle = -1; this->buttonN = 1; this->event.object.overlay = malloc(sizeof(vo_overlay_t)); - xine_register_event_listener(xine, spudec_event_listener, this); +/* FIXME: get events working again. */ + /*xine_register_event_listener(xine, spudec_event_listener, this);*/ + + pthread_mutex_init(&this->nav_pci_lock, NULL); + + this->vo_out = stream->video_out; + this->ovl_caps = stream->video_out->get_capabilities(stream->video_out); + this->output_open = 0; + this->last_event_vpts = 0; + for (i=0; i < MAX_STREAMS; i++) { + this->spudec_stream_state[i].stream_filter = 1; /* So it works with non-navdvd plugins */ + this->spudec_stream_state[i].ra_seq.complete = 1; + this->spudec_stream_state[i].overlay_handle = -1; + } + +/* FIXME:Do we really need a default clut? */ + xine_fast_memcpy(this->state.clut, __default_clut, sizeof(this->state.clut)); + this->state.need_clut = 1; + + return &this->spu_decoder; +} + +static char *get_identifier (spu_decoder_class_t *this) { + printf ("libspudec:get_identifier called\n"); + return "spudec"; +} + +static char *get_description (spu_decoder_class_t *this) { + printf ("libspudec:get_description called\n"); + return "DVD/VOB SPU decoder plugin"; +} + +static void dispose_class (spu_decoder_class_t *this) { + printf ("libspudec:dispose_class called\n"); + free (this); +} + + +static void *init_plugin (xine_t *xine, void *data) { + + spudec_class_t *this; + + this = (spudec_class_t *) malloc (sizeof (spudec_class_t)); + + this->decoder_class.open_plugin = open_plugin; + this->decoder_class.get_identifier = get_identifier; + this->decoder_class.get_description = get_description; + this->decoder_class.dispose = dispose_class; +/* FIXME: get config stuff working */ + +/* this->config = xine->config; */ - return (spu_decoder_t *) this; + printf ("libspudec:init_plugin called\n"); + return this; } /* plugin catalog information */ static uint32_t supported_types[] = { BUF_SPU_PACKAGE, BUF_SPU_CLUT, BUF_SPU_NAV, BUF_SPU_SUBP_CONTROL, 0 }; -static decoder_info_t spudec_info = { +static decoder_info_t dec_info_data = { supported_types, /* supported types */ 5 /* priority */ }; plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_SPU_DECODER, 9, "spudec", XINE_VERSION_CODE, &spudec_info, &init_spu_decoder_plugin }, + { PLUGIN_SPU_DECODER, 9, "spudec", XINE_VERSION_CODE, &dec_info_data, &init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/xine-engine/video_decoder.c b/src/xine-engine/video_decoder.c index dc461f6f0..e08a52a9b 100644 --- a/src/xine-engine/video_decoder.c +++ b/src/xine-engine/video_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: video_decoder.c,v 1.102 2002/10/19 18:51:22 guenter Exp $ + * $Id: video_decoder.c,v 1.103 2002/10/21 12:11:02 jcdutton Exp $ * */ @@ -37,18 +37,18 @@ #define LOG */ -static spu_decoder_t* update_spu_decoder (xine_stream_t *this, int type) { +static spu_decoder_t* update_spu_decoder (xine_stream_t *stream, int type) { int streamtype = (type>>16) & 0xFF; - if( this->spu_decoder_streamtype != streamtype || - !this->spu_decoder_plugin ) { + if( stream->spu_decoder_streamtype != streamtype || + !stream->spu_decoder_plugin ) { - if (this->spu_decoder_plugin) - this->spu_decoder_plugin->close (this->spu_decoder_plugin); + if (stream->spu_decoder_plugin) + free_spu_decoder (stream, stream->spu_decoder_plugin); - this->spu_decoder_streamtype = streamtype; - this->spu_decoder_plugin = get_spu_decoder (this, streamtype); + stream->spu_decoder_streamtype = streamtype; + stream->spu_decoder_plugin = get_spu_decoder (stream, streamtype); /* obsolete? if (this->spu_decoder_plugin ) @@ -56,7 +56,7 @@ static spu_decoder_t* update_spu_decoder (xine_stream_t *this, int type) { this->video_out); */ } - return this->spu_decoder_plugin; + return stream->spu_decoder_plugin; } void *video_decoder_loop (void *stream_gen) { diff --git a/src/xine-engine/video_overlay.c b/src/xine-engine/video_overlay.c index 11a520917..f38c79890 100644 --- a/src/xine-engine/video_overlay.c +++ b/src/xine-engine/video_overlay.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_overlay.c,v 1.24 2002/09/04 23:31:13 guenter Exp $ + * $Id: video_overlay.c,v 1.25 2002/10/21 12:11:03 jcdutton Exp $ * */ @@ -252,6 +252,7 @@ static int32_t video_overlay_add_event(video_overlay_instance_t *this_gen, void video_overlay_event_t *event = (video_overlay_event_t *) event_gen; video_overlay_t *this = (video_overlay_t *) this_gen; uint32_t last_event,this_event,new_event; + printf("xine-lib:video_overlay_add_event called\n"); pthread_mutex_lock (&this->events_mutex); diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 0718fe999..77b0d72d2 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.171 2002/10/20 23:55:23 guenter Exp $ + * $Id: xine.c,v 1.172 2002/10/21 12:11:03 jcdutton Exp $ * * top-level xine functions * @@ -654,7 +654,6 @@ void xine_init (xine_t *this) { void xine_select_spu_channel (xine_stream_t *stream, int channel) { pthread_mutex_lock (&stream->frontend_lock); - stream->spu_channel_user = (channel >= -2 ? channel : -2); switch (stream->spu_channel_user) { @@ -670,6 +669,7 @@ void xine_select_spu_channel (xine_stream_t *stream, int channel) { stream->spu_channel = stream->spu_channel_user; stream->video_out->enable_ovl (stream->video_out, 1); } + printf("xine-lib:xine_select_spu_channel:set to %d\n",stream->spu_channel); pthread_mutex_unlock (&stream->frontend_lock); } -- cgit v1.2.3