From 7580770c5ff6df373c6056626abae7328ae5ab48 Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Tue, 19 Nov 2002 00:45:41 +0000 Subject: spu and overlay cleanups, mostly cosmetic CVS patchset: 3298 CVS date: 2002/11/19 00:45:41 --- src/libspudec/spu.c | 27 ++++------ src/libspudec/spu_decoder_api.h | 4 +- src/libspudec/xine_decoder.c | 21 ++++++-- src/xine-engine/metronom.c | 17 +++--- src/xine-engine/osd.c | 6 +-- src/xine-engine/video_overlay.c | 111 +++++++++------------------------------- src/xine-engine/video_overlay.h | 16 +++--- 7 files changed, 71 insertions(+), 131 deletions(-) (limited to 'src') diff --git a/src/libspudec/spu.c b/src/libspudec/spu.c index 9a3afa727..eb8ab4e1d 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.52 2002/11/18 13:42:50 mroi Exp $ + * $Id: spu.c,v 1.53 2002/11/19 00:45:41 miguelfreitas Exp $ * */ @@ -163,7 +163,7 @@ void spudec_decode_nav(spudec_decoder_t *this, buf_element_t *buf) { } if( this->menu_handle >= 0 ) { this->event.object.handle = this->menu_handle; - this->event.event_type = EVENT_HIDE_MENU; + this->event.event_type = OVERLAY_EVENT_HIDE; /* hide menu right now */ this->event.vpts = 0; ovl_instance->add_event(ovl_instance, (void *)&this->event); @@ -287,7 +287,7 @@ void spudec_process (spudec_decoder_t *this, uint32_t stream_id) { #endif this->state.cmd_ptr = cur_seq->buf + cur_seq->cmd_offs; this->state.modified = 1; /* Only draw picture if = 1 on first event of SPU */ - this->state.visible = EVENT_SHOW_MENU; /* 0 - No value, 1 - Show, 2 - Hide. */ + this->state.visible = OVERLAY_EVENT_SHOW; this->state.forced_display = 0; /* 0 - No value, 1 - Forced Display. */ this->state.delay = 0; cur_seq->finished=0; @@ -322,7 +322,7 @@ void spudec_process (spudec_decoder_t *this, uint32_t stream_id) { #endif pthread_mutex_lock(&this->nav_pci_lock); if (this->pci.hli.hl_gi.hli_s_ptm == this->spudec_stream_state[stream_id].pts) { - if (this->state.visible == EVENT_HIDE_MENU) { + if (this->state.visible == OVERLAY_EVENT_HIDE) { /* menus are hidden via nav packet decoding, not here */ /* FIXME: James is not sure about this solution and may want to look this over. * I'm commiting it, because I haven't found a disc it breaks, but it fixes @@ -386,7 +386,7 @@ void spudec_process (spudec_decoder_t *this, uint32_t stream_id) { this->overlay.rle=NULL; /* For force display menus */ //if ( !(this->state.visible) ) { - // this->state.visible = EVENT_SHOW_MENU; + // this->state.visible = OVERLAY_EVENT_SHOW; //} this->event.event_type = this->state.visible; @@ -461,7 +461,7 @@ static void spudec_do_commands(spudec_state_t *state, spudec_seq_t* seq, vo_over #ifdef LOG_DEBUG printf ("spu: \tshow subpicture\n"); #endif - state->visible = EVENT_SHOW_MENU; + state->visible = OVERLAY_EVENT_SHOW; buf++; break; @@ -469,7 +469,7 @@ static void spudec_do_commands(spudec_state_t *state, spudec_seq_t* seq, vo_over #ifdef LOG_DEBUG printf ("spu: \thide subpicture\n"); #endif - state->visible = EVENT_HIDE_MENU; + state->visible = OVERLAY_EVENT_HIDE; buf++; break; @@ -574,7 +574,7 @@ static void spudec_do_commands(spudec_state_t *state, spudec_seq_t* seq, vo_over case CMD_SPU_WIPE: #ifdef LOG_DEBUG - printf ("spu: \tSPU_WIPE not implemented yet\n"); + printf ("libspudec: \tSPU_WIPE not implemented yet\n"); #endif param_length = (buf[1] << 8) | (buf[2]); buf += 1 + param_length; @@ -582,7 +582,7 @@ static void spudec_do_commands(spudec_state_t *state, spudec_seq_t* seq, vo_over case CMD_SPU_FORCE_DISPLAY: #ifdef LOG_DEBUG - printf ("spu: \tForce Display/Menu\n"); + printf ("libspudec: \tForce Display/Menu\n"); #endif state->forced_display = 1; buf++; @@ -674,23 +674,18 @@ static void spudec_draw_picture (spudec_state_t *state, spudec_seq_t* seq, vo_ov ovl->data_size = seq->cmd_offs * 2 * sizeof(rle_elem_t); -#ifdef LOG_DEBUG - printf ("spu: MALLOC1: ovl->rle %p, len=%d\n", ovl->rle,ovl->data_size); -#endif + if (ovl->rle) { printf ("libspudec: spudec_draw_picture: ovl->rle is not empty!!!! It should be!!! You should never see this message.\n"); free(ovl->rle); ovl->rle=NULL; } ovl->rle = malloc(ovl->data_size); -#ifdef LOG_DEBUG - printf ("spu: MALLOC2: ovl->rle %p, len=%d\n", ovl->rle,ovl->data_size); -#endif state->modified = 0; /* mark as already processed */ rle = ovl->rle; #ifdef LOG_DEBUG - printf ("spu: Draw RLE=%p\n",rle); + printf ("libspudec: Draw RLE=%p\n",rle); #endif while (bit_ptr[1] < seq->buf + seq->cmd_offs) { diff --git a/src/libspudec/spu_decoder_api.h b/src/libspudec/spu_decoder_api.h index 09d4094f3..e0a64c6ed 100644 --- a/src/libspudec/spu_decoder_api.h +++ b/src/libspudec/spu_decoder_api.h @@ -24,7 +24,7 @@ #ifndef HAVE_SPU_API_H #define HAVE_SPU_API_H -#define SPU_DECODER_IFACE_VERSION 10 +#define SPU_DECODER_IFACE_VERSION 11 /* FIXME: Needed for spu_button_t */ /* But will not be on all users's systems. (From the libspudec directory or libdvdread). */ /*#include "nav_types.h" */ @@ -69,7 +69,7 @@ struct spu_decoder_s { void (*reset) (spu_decoder_t *this); -/* void (*close) (spu_decoder_t *this); */ + void (*discontinuity) (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 36e6cae72..2da1241d0 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.86 2002/11/17 16:18:33 mroi Exp $ + * $Id: xine_decoder.c,v 1.87 2002/11/19 00:45:41 miguelfreitas Exp $ * * stuff needed to turn libspu into a xine decoder plugin */ @@ -83,7 +83,9 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) { return; if ( buf->decoder_info[2] == SPU_DVD_SUBTYPE_CLUT ) { +#ifdef LOG_DEBUG printf("libspudec: SPU CLUT\n"); +#endif if (buf->content[0]) { /* cheap endianess detection */ xine_fast_memcpy(this->state.clut, buf->content, sizeof(uint32_t)*16); } else { @@ -141,6 +143,10 @@ 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_discontinuity (spu_decoder_t *this_gen) { +} + + static void spudec_dispose (spu_decoder_t *this_gen) { spudec_decoder_t *this = (spudec_decoder_t *) this_gen; @@ -224,7 +230,7 @@ static void spudec_set_button (spu_decoder_t *this_gen, int32_t button, int32_t overlay_event->object.handle = this->menu_handle; overlay_event->object.pts = this->pci.hli.hl_gi.hli_s_ptm; overlay_event->object.overlay=overlay; - overlay_event->event_type = EVENT_MENU_BUTTON; + overlay_event->event_type = OVERLAY_EVENT_MENU_BUTTON; #ifdef LOG_BUTTON fprintf(stderr, "libspudec:Button Overlay\n"); #endif @@ -235,7 +241,7 @@ static void spudec_set_button (spu_decoder_t *this_gen, int32_t button, int32_t fprintf (stderr,"libspudec:xine_decoder.c:spudec_event_listener:HIDE ????\n"); assert(0); overlay_event->object.handle = this->menu_handle; - overlay_event->event_type = EVENT_HIDE_MENU; + overlay_event->event_type = OVERLAY_EVENT_HIDE; } overlay_event->vpts = 0; if (this->vo_out) { @@ -265,6 +271,7 @@ static spu_decoder_t *open_plugin (spu_decoder_class_t *class_gen, xine_stream_t this->spu_decoder.decode_data = spudec_decode_data; this->spu_decoder.reset = spudec_reset; + this->spu_decoder.discontinuity = spudec_discontinuity; this->spu_decoder.dispose = spudec_dispose; this->spu_decoder.get_nav_pci = spudec_get_nav_pci; this->spu_decoder.set_button = spudec_set_button; @@ -295,17 +302,23 @@ static spu_decoder_t *open_plugin (spu_decoder_class_t *class_gen, xine_stream_t } static char *get_identifier (spu_decoder_class_t *this) { +#ifdef LOG_DEBUG printf ("libspudec:get_identifier called\n"); +#endif return "spudec"; } static char *get_description (spu_decoder_class_t *this) { +#ifdef LOG_DEBUG printf ("libspudec:get_description called\n"); +#endif return "DVD/VOB SPU decoder plugin"; } static void dispose_class (spu_decoder_class_t *this) { +#ifdef LOG_DEBUG printf ("libspudec:dispose_class called\n"); +#endif free (this); } @@ -335,6 +348,6 @@ static decoder_info_t dec_info_data = { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_SPU_DECODER, 10, "spudec", XINE_VERSION_CODE, &dec_info_data, &init_plugin }, + { PLUGIN_SPU_DECODER, 11, "spudec", XINE_VERSION_CODE, &dec_info_data, &init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/xine-engine/metronom.c b/src/xine-engine/metronom.c index 78b044b05..a8ab454b6 100644 --- a/src/xine-engine/metronom.c +++ b/src/xine-engine/metronom.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: metronom.c,v 1.100 2002/11/12 18:40:54 miguelfreitas Exp $ + * $Id: metronom.c,v 1.101 2002/11/19 00:45:42 miguelfreitas Exp $ */ #ifdef HAVE_CONFIG_H @@ -264,13 +264,14 @@ static int64_t metronom_got_spu_packet (metronom_t *this, int64_t pts) { pthread_mutex_lock (&this->lock); - if (pts >= 0 ) { - vpts = pts + this->vpts_offset; - } else { - /* pts < 0 */ - vpts = this->vpts_offset; - } - + vpts = pts + this->vpts_offset; + + /* no vpts going backwards please */ + if( vpts < this->spu_vpts ) + vpts = this->spu_vpts; + + this->spu_vpts = vpts; + pthread_mutex_unlock (&this->lock); return vpts; } diff --git a/src/xine-engine/osd.c b/src/xine-engine/osd.c index 302e0ac8d..1db60b349 100644 --- a/src/xine-engine/osd.c +++ b/src/xine-engine/osd.c @@ -216,7 +216,7 @@ static int osd_show (osd_object_t *osd, int64_t vpts ) { memcpy(this->event.object.overlay->clip_color, osd->color, sizeof(osd->color)); memcpy(this->event.object.overlay->clip_trans, osd->trans, sizeof(osd->trans)); - this->event.event_type = EVENT_SHOW_SPU; + this->event.event_type = OVERLAY_EVENT_SHOW; this->event.vpts = vpts; this->video_overlay->add_event(this->video_overlay,(void *)&this->event); } @@ -247,7 +247,7 @@ static int osd_hide (osd_object_t *osd, int64_t vpts) { /* not really needed this, but good pratice to clean it up */ memset( this->event.object.overlay, 0, sizeof(this->event.object.overlay) ); - this->event.event_type = EVENT_HIDE_SPU; + this->event.event_type = OVERLAY_EVENT_HIDE; this->event.vpts = vpts; this->video_overlay->add_event(this->video_overlay,(void *)&this->event); @@ -784,7 +784,7 @@ static void osd_free_object (osd_object_t *osd_to_close) { /* not really needed this, but good pratice to clean it up */ memset( this->event.object.overlay, 0, sizeof(this->event.object.overlay) ); - this->event.event_type = EVENT_FREE_HANDLE; + this->event.event_type = OVERLAY_EVENT_FREE_HANDLE; this->event.vpts = 0; this->video_overlay->add_event(this->video_overlay,(void *)&this->event); diff --git a/src/xine-engine/video_overlay.c b/src/xine-engine/video_overlay.c index f38c79890..56409e63a 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.25 2002/10/21 12:11:03 jcdutton Exp $ + * $Id: video_overlay.c,v 1.26 2002/11/19 00:45:42 miguelfreitas Exp $ * */ @@ -130,7 +130,7 @@ static void remove_events_handle( video_overlay_t *this, int32_t handle, int loc /* mark as free */ this->events[this_event].next_event = 0; - this->events[this_event].event->event_type = EVENT_NULL; + this->events[this_event].event->event_type = OVERLAY_EVENT_NULL; this_event=this->events[last_event].next_event; } @@ -252,7 +252,6 @@ 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); @@ -310,8 +309,8 @@ static int32_t video_overlay_add_event(video_overlay_instance_t *this_gen, void /* not currently used. James might need this for debugging menu stuff */ -static void video_overlay_print_overlay( vo_overlay_t *ovl ) { #ifdef LOG_DEBUG +static void video_overlay_print_overlay( vo_overlay_t *ovl ) { printf ("video_overlay: OVERLAY to show\n"); printf ("video_overlay: \tx = %d y = %d width = %d height = %d\n", ovl->x, ovl->y, ovl->width, ovl->height ); @@ -325,9 +324,9 @@ static void video_overlay_print_overlay( vo_overlay_t *ovl ) { ovl->clip_color[0], ovl->clip_color[1], ovl->clip_color[2], ovl->clip_color[3]); printf ("video_overlay: \tclip_trans [%d %d %d %d]\n", ovl->clip_trans[0], ovl->clip_trans[1], ovl->clip_trans[2], ovl->clip_trans[3]); -#endif return; } +#endif /* process overlay events @@ -347,7 +346,7 @@ static int video_overlay_event( video_overlay_t *this, int64_t vpts ) { processed++; handle=this->events[this_event].event->object.handle; switch( this->events[this_event].event->event_type ) { - case EVENT_SHOW_SPU: + case OVERLAY_EVENT_SHOW: #ifdef LOG_DEBUG printf ("video_overlay: SHOW SPU NOW\n"); #endif @@ -378,28 +377,8 @@ static int video_overlay_event( video_overlay_t *this, int64_t vpts ) { add_showing_handle( this, handle ); } break; - - case EVENT_FREE_HANDLE: -#ifdef LOG_DEBUG - printf ("video_overlay: FREE SPU NOW\n"); -#endif - /* free any overlay associated with this event */ - if (this->events[this_event].event->object.overlay != NULL) { - free(this->events[this_event].event->object.overlay); - this->events[this_event].event->object.overlay = NULL; - } - /* this avoid removing this_event from the queue - * (it will be removed at the end of this loop) */ - this->events[this_event].event->object.handle = -1; - remove_showing_handle(this,handle); - remove_events_handle(this,handle,0); - internal_video_overlay_free_handle( this, handle ); - break; - - /* implementation for HIDE_SPU and HIDE_MENU is the same. - i will keep them separated in case we need something special... - */ - case EVENT_HIDE_SPU: + + case OVERLAY_EVENT_HIDE: #ifdef LOG_DEBUG printf ("video_overlay: HIDE SPU NOW\n"); #endif @@ -410,51 +389,26 @@ static int video_overlay_event( video_overlay_t *this, int64_t vpts ) { } remove_showing_handle( this, handle ); break; - - case EVENT_HIDE_MENU: + + case OVERLAY_EVENT_FREE_HANDLE: #ifdef LOG_DEBUG - printf ("video_overlay: HIDE MENU NOW %d\n",handle); + printf ("video_overlay: FREE SPU NOW\n"); #endif + /* free any overlay associated with this event */ if (this->events[this_event].event->object.overlay != NULL) { free(this->events[this_event].event->object.overlay); this->events[this_event].event->object.overlay = NULL; } - remove_showing_handle( this, handle ); - break; - - case EVENT_SHOW_MENU: -#ifdef LOG_DEBUG - printf ("video_overlay: SHOW MENU NOW\n"); -#endif - if (this->events[this_event].event->object.overlay != NULL) { -#ifdef LOG_DEBUG - video_overlay_print_overlay( this->events[this_event].event->object.overlay ) ; -#endif - /* this->objects[handle].overlay is about to be - * overwritten by this event data. make sure we free it if needed. - */ - if( this->objects[handle].overlay ) { - if( this->objects[handle].overlay->rle ) - free( this->objects[handle].overlay->rle ); - free( this->objects[handle].overlay ); - this->objects[handle].overlay = NULL; - } - - this->objects[handle].handle = handle; - if( this->objects[handle].overlay ) { - printf("video_overlay: error: object->overlay was not freed!\n"); - } - this->objects[handle].overlay = - this->events[this_event].event->object.overlay; - this->objects[handle].pts = - this->events[this_event].event->object.pts; - this->events[this_event].event->object.overlay = NULL; - - add_showing_handle( this, handle ); - } + /* this avoid removing this_event from the queue + * (it will be removed at the end of this loop) */ + this->events[this_event].event->object.handle = -1; + remove_showing_handle(this,handle); + remove_events_handle(this,handle,0); + internal_video_overlay_free_handle( this, handle ); break; - - case EVENT_MENU_BUTTON: + + + case OVERLAY_EVENT_MENU_BUTTON: /* mixes palette and copy clip coords */ #ifdef LOG_DEBUG printf ("video_overlay:MENU BUTTON NOW\n"); @@ -465,7 +419,10 @@ static int video_overlay_event( video_overlay_t *this, int64_t vpts ) { this->objects[handle].pts) ) { vo_overlay_t *overlay = this->objects[handle].overlay; vo_overlay_t *event_overlay = this->events[this_event].event->object.overlay; + +#ifdef LOG_DEBUG printf ("video_overlay:overlay present\n"); +#endif this->objects[handle].handle = handle; overlay->clip_top = event_overlay->clip_top; overlay->clip_bottom = event_overlay->clip_bottom; @@ -480,28 +437,6 @@ static int video_overlay_event( video_overlay_t *this, int64_t vpts ) { overlay->clip_trans[2] = event_overlay->clip_trans[2]; overlay->clip_trans[3] = event_overlay->clip_trans[3]; overlay->clip_rgb_clut = event_overlay->clip_rgb_clut; -/*********************************** - if((event_overlay->color[0] + - event_overlay->color[1] + - event_overlay->color[2] + - event_overlay->color[3]) > 0 ) { - overlay->color[0] = event_overlay->color[0]; - overlay->color[1] = event_overlay->color[1]; - overlay->color[2] = event_overlay->color[2]; - overlay->color[3] = event_overlay->color[3]; - - overlay->rgb_clut = event_overlay->rgb_clut; - } - if((event_overlay->trans[0] + - event_overlay->trans[1] + - event_overlay->trans[2] + - event_overlay->trans[3]) > 0 ) { - overlay->trans[0] = event_overlay->trans[0]; - overlay->trans[1] = event_overlay->trans[1]; - overlay->trans[2] = event_overlay->trans[2]; - overlay->trans[3] = event_overlay->trans[3]; - } -***********************************/ #ifdef LOG_DEBUG video_overlay_print_overlay( this->events[this_event].event->object.overlay ) ; #endif diff --git a/src/xine-engine/video_overlay.h b/src/xine-engine/video_overlay.h index 79088d62a..052d9a38f 100644 --- a/src/xine-engine/video_overlay.h +++ b/src/xine-engine/video_overlay.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_overlay.h,v 1.11 2002/10/23 17:12:35 guenter Exp $ + * $Id: video_overlay.h,v 1.12 2002/11/19 00:45:42 miguelfreitas Exp $ * */ @@ -36,15 +36,11 @@ #define MAX_EVENTS 50 #define MAX_SHOWING 5 -#define EVENT_NULL 0 -#define EVENT_SHOW_SPU 1 -#define EVENT_HIDE_SPU 2 -#define EVENT_SHOW_MENU 3 -#define EVENT_HIDE_MENU 4 -#define EVENT_MENU_BUTTON 5 -#define EVENT_DELETE_RESOURCE 6 /* Maybe release handle will do this */ -#define EVENT_SHOW_OSD 7 /* Not yet implemented */ -#define EVENT_FREE_HANDLE 8 /* Frees a handle, previous allocated via get_handle */ +#define OVERLAY_EVENT_NULL 0 +#define OVERLAY_EVENT_SHOW 1 +#define OVERLAY_EVENT_HIDE 2 +#define OVERLAY_EVENT_MENU_BUTTON 3 +#define OVERLAY_EVENT_FREE_HANDLE 8 /* Frees a handle, previous allocated via get_handle */ /* number of colors in the overlay palette. Currently limited to 256 at most, because some alphablend functions use an 8-bit index into -- cgit v1.2.3