summaryrefslogtreecommitdiff
path: root/src/libspudec
diff options
context:
space:
mode:
Diffstat (limited to 'src/libspudec')
-rw-r--r--src/libspudec/spu.c100
-rw-r--r--src/libspudec/xine_decoder.c261
2 files changed, 254 insertions, 107 deletions
diff --git a/src/libspudec/spu.c b/src/libspudec/spu.c
index 4a95e0980..dcee56c55 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.22 2001/11/17 14:26:39 f1rmb Exp $
+ * $Id: spu.c,v 1.23 2001/11/18 03:53:24 guenter Exp $
*
*/
@@ -77,8 +77,10 @@
/* Return value: reassembly complete = 1 */
int spu_reassembly (spu_seq_t *seq, int start, uint8_t *pkt_data, u_int pkt_len)
{
- xprintf (VERBOSE|SPU, "pkt_len: %d\n", pkt_len);
- xprintf (VERBOSE|SPU, "Reassembly: start=%d seq=%p\n", start,seq);
+#ifdef LOG_DEBUG
+ printf ("spu: pkt_len: %d\n", pkt_len);
+ printf ("spu: Reassembly: start=%d seq=%p\n", start,seq);
+#endif
if (start) {
seq->seq_len = (((u_int)pkt_data[0])<<8) | pkt_data[1];
@@ -86,22 +88,32 @@ int spu_reassembly (spu_seq_t *seq, int start, uint8_t *pkt_data, u_int pkt_len)
if (seq->buf_len < seq->seq_len) {
if (seq->buf) {
- xprintf (VERBOSE|SPU, "FREE1: seq->buf %p\n", seq->buf);
+#ifdef LOG_DEBUG
+ printf ("spu: FREE1: seq->buf %p\n", seq->buf);
+#endif
free(seq->buf);
seq->buf = NULL;
- xprintf (VERBOSE|SPU, "FREE2: seq->buf %p\n", seq->buf);
+#ifdef LOG_DEBUG
+ printf ("spu: FREE2: seq->buf %p\n", seq->buf);
+#endif
}
seq->buf_len = seq->seq_len;
- xprintf (VERBOSE|SPU, "MALLOC1: seq->buf %p, len=%d\n", seq->buf,seq->buf_len);
+#ifdef LOG_DEBUG
+ printf ("spu: MALLOC1: seq->buf %p, len=%d\n", seq->buf,seq->buf_len);
+#endif
seq->buf = malloc(seq->buf_len);
- xprintf (VERBOSE|SPU, "MALLOC2: seq->buf %p, len=%d\n", seq->buf,seq->buf_len);
+#ifdef LOG_DEBUG
+ printf ("spu: MALLOC2: seq->buf %p, len=%d\n", seq->buf,seq->buf_len);
+#endif
}
seq->ra_offs = 0;
- xprintf (VERBOSE|SPU, "buf_len: %d\n", seq->buf_len);
- xprintf (VERBOSE|SPU, "cmd_off: %d\n", seq->cmd_offs);
+#ifdef LOG_DEBUG
+ printf ("spu: buf_len: %d\n", seq->buf_len);
+ printf ("spu: cmd_off: %d\n", seq->cmd_offs);
+#endif
}
if (seq->ra_offs < seq->buf_len) {
@@ -148,10 +160,14 @@ void spu_do_commands(spu_state_t *state, spu_seq_t* seq, vo_overlay_t *ovl)
uint8_t *buf = state->cmd_ptr;
uint8_t *next_seq;
- xprintf (VERBOSE|SPU, "SPU EVENT\n");
+#ifdef LOG_DEBUG
+ printf ("spu: SPU EVENT\n");
+#endif
state->delay = (buf[0] << 8) + buf[1];
- xprintf (VERBOSE|SPU, "\tdelay=%d\n",state->delay);
+#ifdef LOG_DEBUG
+ printf ("spu: \tdelay=%d\n",state->delay);
+#endif
next_seq = seq->buf + (buf[2] << 8) + buf[3];
buf += 4;
@@ -165,13 +181,17 @@ void spu_do_commands(spu_state_t *state, spu_seq_t* seq, vo_overlay_t *ovl)
while (buf < next_seq && *buf != CMD_SPU_EOF) {
switch (*buf) {
case CMD_SPU_SHOW: /* show subpicture */
- xprintf (VERBOSE|SPU, "\tshow subpicture\n");
+#ifdef LOG_DEBUG
+ printf ("spu: \tshow subpicture\n");
+#endif
state->visible = 1;
buf++;
break;
case CMD_SPU_HIDE: /* hide subpicture */
- xprintf (VERBOSE|SPU, "\thide subpicture\n");
+#ifdef LOG_DEBUG
+ printf ("spu: \thide subpicture\n");
+#endif
state->visible = 2;
buf++;
break;
@@ -189,8 +209,10 @@ void spu_do_commands(spu_state_t *state, spu_seq_t* seq, vo_overlay_t *ovl)
ovl->color[2] = state->clut[clut->entry1];
ovl->color[1] = state->clut[clut->entry2];
ovl->color[0] = state->clut[clut->entry3];
- xprintf (VERBOSE|SPU, "\tclut [%x %x %x %x]\n",
- ovl->color[0], ovl->color[1], ovl->color[2], ovl->color[3]);
+#ifdef LOG_DEBUG
+ printf ("spu: \tclut [%x %x %x %x]\n",
+ ovl->color[0], ovl->color[1], ovl->color[2], ovl->color[3]);
+#endif
state->modified = 1;
buf += 3;
break;
@@ -203,8 +225,10 @@ void spu_do_commands(spu_state_t *state, spu_seq_t* seq, vo_overlay_t *ovl)
ovl->trans[2] = trans->entry1;
ovl->trans[1] = trans->entry2;
ovl->trans[0] = trans->entry3;
- xprintf (VERBOSE|SPU, "\ttrans [%d %d %d %d]\n",
- ovl->trans[0], ovl->trans[1], ovl->trans[2], ovl->trans[3]);
+#ifdef LOG_DEBUG
+ printf ("spu: \ttrans [%d %d %d %d]\n",
+ ovl->trans[0], ovl->trans[1], ovl->trans[2], ovl->trans[3]);
+#endif
state->modified = 1;
buf += 3;
break;
@@ -226,8 +250,10 @@ void spu_do_commands(spu_state_t *state, spu_seq_t* seq, vo_overlay_t *ovl)
ovl->clip_left = 0;
ovl->clip_right = ovl->width - 1;
- xprintf (VERBOSE|SPU, "\tx = %d y = %d width = %d height = %d\n",
- ovl->x, ovl->y, ovl->width, ovl->height );
+#ifdef LOG_DEBUG
+ printf ("spu: \tx = %d y = %d width = %d height = %d\n",
+ ovl->x, ovl->y, ovl->width, ovl->height );
+#endif
state->modified = 1;
buf += 7;
break;
@@ -235,20 +261,24 @@ void spu_do_commands(spu_state_t *state, spu_seq_t* seq, vo_overlay_t *ovl)
case CMD_SPU_SET_PXD_OFFSET: /* image top[0] field / image bottom[1] field*/
state->field_offs[0] = (((u_int)buf[1]) << 8) | buf[2];
state->field_offs[1] = (((u_int)buf[3]) << 8) | buf[4];
- xprintf (VERBOSE|SPU, "\toffset[0] = %d offset[1] = %d\n",
- state->field_offs[0], state->field_offs[1]);
+#ifdef LOG_DEBUG
+ printf ("spu: \toffset[0] = %d offset[1] = %d\n",
+ state->field_offs[0], state->field_offs[1]);
+#endif
state->modified = 1;
buf += 5;
break;
case CMD_SPU_MENU:
- xprintf (VERBOSE|SPU, "\tForce Display/Menu\n");
+#ifdef LOG_DEBUG
+ printf ("spu: \tForce Display/Menu\n");
+#endif
state->menu = 1;
buf++;
break;
default:
- fprintf(stderr, "libspudec: unknown seqence command (%02x)\n", buf[0]);
+ printf("libspudec: unknown seqence command (%02x)\n", buf[0]);
buf++;
break;
}
@@ -305,7 +335,9 @@ static int spu_next_line (vo_overlay_t *spu)
field ^= 1; // Toggle fields
if (put_y >= spu->height) {
- xprintf (VERBOSE|SPU, "put_y >= spu->height\n");
+#ifdef LOG_DEBUG
+ printf ("spu: put_y >= spu->height\n");
+#endif
return -1;
}
return 0;
@@ -339,14 +371,20 @@ void spu_draw_picture (spu_state_t *state, spu_seq_t* seq, vo_overlay_t *ovl)
// if (ovl->rle)
// free(ovl->rle);
ovl->data_size = seq->cmd_offs * 2 * sizeof(rle_elem_t);
- xprintf (VERBOSE|SPU, "MALLOC1: ovl->rle %p, len=%d\n", ovl->rle,ovl->data_size);
+#ifdef LOG_DEBUG
+ printf ("spu: MALLOC1: ovl->rle %p, len=%d\n", ovl->rle,ovl->data_size);
+#endif
ovl->rle = malloc(ovl->data_size);
- xprintf (VERBOSE|SPU, "MALLOC2: ovl->rle %p, len=%d\n", ovl->rle,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;
- xprintf (VERBOSE|SPU, "Draw RLE=%p\n",rle);
+#ifdef LOG_DEBUG
+ printf ("spu: Draw RLE=%p\n",rle);
+#endif
while (bit_ptr[1] < seq->buf + seq->cmd_offs) {
u_int len;
@@ -382,9 +420,11 @@ void spu_draw_picture (spu_state_t *state, spu_seq_t* seq, vo_overlay_t *ovl)
ovl->num_rle = rle - ovl->rle;
ovl->rgb_clut = 0;
- xprintf (VERBOSE|SPU, "Num RLE=%d\n",ovl->num_rle);
- xprintf (VERBOSE|SPU, "Date size=%d\n",ovl->data_size);
- xprintf (VERBOSE|SPU, "sizeof RLE=%d\n",sizeof(rle_elem_t));
+#ifdef LOG_DEBUG
+ printf ("spu: Num RLE=%d\n",ovl->num_rle);
+ printf ("spu: Date size=%d\n",ovl->data_size);
+ printf ("spu: sizeof RLE=%d\n",sizeof(rle_elem_t));
+#endif
}
/* Heuristic to discover the colors used by the subtitles
diff --git a/src/libspudec/xine_decoder.c b/src/libspudec/xine_decoder.c
index 454b13034..1f05e3ede 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.34 2001/11/17 14:26:39 f1rmb Exp $
+ * $Id: xine_decoder.c,v 1.35 2001/11/18 03:53:24 guenter Exp $
*
* stuff needed to turn libspu into a xine decoder plugin
*/
@@ -41,7 +41,9 @@
static void spudec_print_overlay( vo_overlay_t *ovl );
+/*
#define LOG_DEBUG 1
+*/
#ifdef DEBUG
@@ -189,15 +191,19 @@ static void spudec_reset (spudec_decoder_t *this) {
for (i=0; i < MAX_EVENTS; i++) {
if (this->spu_events[i].event == NULL) {
- xprintf (VERBOSE|SPU, "MALLOC1: this->spu_events[%d].event %p, len=%d\n",
- i,
- this->spu_events[i].event,
- sizeof(spu_overlay_event_t));
+#ifdef LOG_DEBUG
+ printf ("spu: MALLOC1: this->spu_events[%d].event %p, len=%d\n",
+ i,
+ this->spu_events[i].event,
+ sizeof(spu_overlay_event_t));
+#endif
this->spu_events[i].event = xine_xmalloc (sizeof(spu_overlay_event_t));
- xprintf (VERBOSE|SPU, "MALLOC2: this->spu_events[%d].event %p, len=%d\n",
- i,
- this->spu_events[i].event,
- sizeof(spu_overlay_event_t));
+#ifdef LOG_DEBUG
+ printf ("spu: MALLOC2: this->spu_events[%d].event %p, len=%d\n",
+ i,
+ this->spu_events[i].event,
+ sizeof(spu_overlay_event_t));
+#endif
this->spu_events[i].event->event_type = 0; /* Empty slot */
}
}
@@ -208,11 +214,15 @@ static void spudec_reset (spudec_decoder_t *this) {
this->spu_objects[1].handle=1;
this->spu_objects[1].object_type=1;
this->spu_objects[1].pts=0;
- xprintf (VERBOSE|SPU, "MALLOC1: this->spu_objects[1].overlay %p, len=%d\n",
- this->spu_objects[1].overlay, sizeof(vo_overlay_t));
+#ifdef LOG_DEBUG
+ printf ("spu: MALLOC1: this->spu_objects[1].overlay %p, len=%d\n",
+ this->spu_objects[1].overlay, sizeof(vo_overlay_t));
+#endif
this->spu_objects[1].overlay = xine_xmalloc (sizeof(vo_overlay_t));
- xprintf (VERBOSE|SPU, "MALLOC2: this->spu_objects[1].overlay %p, len=%d\n",
- this->spu_objects[1].overlay, sizeof(vo_overlay_t));
+#ifdef LOG_DEBUG
+ printf ("spu: MALLOC2: this->spu_objects[1].overlay %p, len=%d\n",
+ this->spu_objects[1].overlay, sizeof(vo_overlay_t));
+#endif
/* xine_xmalloc does memset */
/* memset(this->spu_objects[1].overlay,0,sizeof(vo_overlay_t));
*/
@@ -281,9 +291,13 @@ static int32_t spu_add_event(spudec_decoder_t *this, spu_overlay_event_t *event
new_event=0;
/* We skip the 0 entry because that is used as a pointer to the first event.*/
/* Find a free event slot */
- xprintf (VERBOSE|SPU, "284MUTEX1:spu_events lock");
+#ifdef LOG_DEBUG
+ printf ("spu: 284MUTEX1:spu_events lock");
+#endif
pthread_mutex_lock (&this->spu_events_mutex);
- xprintf (VERBOSE|SPU, "->ok\n");
+#ifdef LOG_DEBUG
+ printf ("spu:->ok\n");
+#endif
do {
new_event++;
} while ((new_event<MAX_EVENTS) && (this->spu_events[new_event].event->event_type > 0));
@@ -302,7 +316,9 @@ static int32_t spu_add_event(spudec_decoder_t *this, spu_overlay_event_t *event
found=1;
break;
}
- xprintf (VERBOSE|SPU, "this_event=%d vpts %d\n",this_event, this->spu_events[this_event].event->vpts);
+#ifdef LOG_DEBUG
+ printf ("spu:this_event=%d vpts %d\n",this_event, this->spu_events[this_event].event->vpts);
+#endif
if (this->spu_events[this_event].event->vpts > event->vpts ) {
found=2;
break;
@@ -322,15 +338,19 @@ static int32_t spu_add_event(spudec_decoder_t *this, spu_overlay_event_t *event
this->spu_events[new_event].event->event_type=event->event_type;
this->spu_events[new_event].event->vpts=event->vpts;
this->spu_events[new_event].event->object.handle=event->object.handle;
- xprintf (VERBOSE|SPU, "323MALLOC1: this->spu_events[new_event=%d].event->object.overlay %p, len=%d\n",
- new_event,
- this->spu_events[new_event].event->object.overlay,
- sizeof(vo_overlay_t));
+#ifdef LOG_DEBUG
+ printf ("spu: 323MALLOC1: this->spu_events[new_event=%d].event->object.overlay %p, len=%d\n",
+ new_event,
+ this->spu_events[new_event].event->object.overlay,
+ sizeof(vo_overlay_t));
+#endif
this->spu_events[new_event].event->object.overlay = xine_xmalloc (sizeof(vo_overlay_t));
- xprintf (VERBOSE|SPU, "328MALLOC2: this->spu_events[new_event=%d].event->object.overlay %p, len=%d\n",
- new_event,
- this->spu_events[new_event].event->object.overlay,
- sizeof(vo_overlay_t));
+#ifdef LOG_DEBUG
+ printf ("spu: 328MALLOC2: this->spu_events[new_event=%d].event->object.overlay %p, len=%d\n",
+ new_event,
+ this->spu_events[new_event].event->object.overlay,
+ sizeof(vo_overlay_t));
+#endif
memcpy(this->spu_events[new_event].event->object.overlay,
event->object.overlay, sizeof(vo_overlay_t));
memset(event->object.overlay,0,sizeof(vo_overlay_t));
@@ -360,9 +380,11 @@ static void spu_process (spudec_decoder_t *this, uint32_t stream_id) {
/* FIXME:Get Handle after we have found if "Forced display" is set or not.
*/
- xprintf (VERBOSE|SPU, "Found SPU from stream %d pts=%d vpts=%d\n",stream_id,
+#ifdef LOG_DEBUG
+ printf ("spu: Found SPU from stream %d pts=%d vpts=%d\n",stream_id,
this->spu_stream_state[stream_id].pts,
this->spu_stream_state[stream_id].vpts);
+#endif
this->state.cmd_ptr = this->cur_seq->buf + this->cur_seq->cmd_offs;
this->state.next_pts = -1; /* invalidate timestamp */
this->state.modified = 1; /* Only draw picture if = 1 on first event of SPU */
@@ -389,7 +411,9 @@ static void spu_process (spudec_decoder_t *this, uint32_t stream_id) {
if ((this->xine->spu_channel != stream_id) &&
(this->state.menu == 0) ) {
- xprintf (VERBOSE|SPU, "Dropping SPU channel %d\n", stream_id);
+#ifdef LOG_DEBUG
+ printf ("spu: Dropping SPU channel %d\n", stream_id);
+#endif
spu_free_handle(this, handle);
return;
}
@@ -404,15 +428,19 @@ static void spu_process (spudec_decoder_t *this, uint32_t stream_id) {
/* Subtitle */
this->event.object.handle = handle;
/* FIXME: memcpy maybe. */
- xprintf (VERBOSE|SPU, "403MALLOC: this->event.object.overlay=%p\n",
- this->event.object.overlay);
+#ifdef LOG_DEBUG
+ printf ("spu: 403MALLOC: this->event.object.overlay=%p\n",
+ this->event.object.overlay);
+#endif
this->event.object.overlay = malloc(sizeof(vo_overlay_t));
memcpy(this->event.object.overlay,
&this->overlay,
sizeof(vo_overlay_t));
this->overlay.rle=NULL;
- xprintf (VERBOSE|SPU, "409MALLOC: this->event.object.overlay=%p\n",
- this->event.object.overlay);
+#ifdef LOG_DEBUG
+ printf ("spu: 409MALLOC: this->event.object.overlay=%p\n",
+ this->event.object.overlay);
+#endif
this->event.event_type = this->state.visible;
this->event.vpts = this->spu_stream_state[stream_id].vpts+(this->state.delay*1000);
} else {
@@ -420,15 +448,19 @@ static void spu_process (spudec_decoder_t *this, uint32_t stream_id) {
spu_free_handle(this, handle);
this->event.object.handle = spu_get_menu_handle(this);
/* FIXME: memcpy maybe. */
- xprintf (VERBOSE|SPU, "418MALLOC: this->event.object.overlay=%p\n",
- this->event.object.overlay);
+#ifdef LOG_DEBUG
+ printf ("spu:418MALLOC: this->event.object.overlay=%p\n",
+ this->event.object.overlay);
+#endif
this->event.object.overlay = malloc(sizeof(vo_overlay_t));
memcpy(this->event.object.overlay,
&this->overlay,
sizeof(vo_overlay_t));
this->overlay.rle=NULL;
- xprintf (VERBOSE|SPU, "424MALLOC: this->event.object.overlay=%p\n",
- this->event.object.overlay);
+#ifdef LOG_DEBUG
+ printf ("spu: 424MALLOC: this->event.object.overlay=%p\n",
+ this->event.object.overlay);
+#endif
this->event.event_type = EVENT_MENU_SPU;
this->event.vpts = this->spu_stream_state[stream_id].vpts+(this->state.delay*1000);
}
@@ -536,15 +568,17 @@ static void spudec_nextseq(spudec_decoder_t* this) {
}
static void spudec_print_overlay( vo_overlay_t *ovl ) {
- xprintf (VERBOSE|SPU, "OVERLAY to show\n");
- xprintf (VERBOSE|SPU, "\tx = %d y = %d width = %d height = %d\n",
- ovl->x, ovl->y, ovl->width, ovl->height );
- xprintf (VERBOSE|SPU, "\tclut [%x %x %x %x]\n",
- ovl->color[0], ovl->color[1], ovl->color[2], ovl->color[3]);
- xprintf (VERBOSE|SPU, "\ttrans [%d %d %d %d]\n",
- ovl->trans[0], ovl->trans[1], ovl->trans[2], ovl->trans[3]);
- xprintf (VERBOSE|SPU, "\tclip top=%d bottom=%d left=%d right=%d\n",
- ovl->clip_top, ovl->clip_bottom, ovl->clip_left, ovl->clip_right);
+#ifdef LOG_DEBUG
+ printf ("spu: OVERLAY to show\n");
+ printf ("spu: \tx = %d y = %d width = %d height = %d\n",
+ ovl->x, ovl->y, ovl->width, ovl->height );
+ printf ("spu: \tclut [%x %x %x %x]\n",
+ ovl->color[0], ovl->color[1], ovl->color[2], ovl->color[3]);
+ printf ("spu: \ttrans [%d %d %d %d]\n",
+ ovl->trans[0], ovl->trans[1], ovl->trans[2], ovl->trans[3]);
+ printf ("spu: \tclip top=%d bottom=%d left=%d right=%d\n",
+ ovl->clip_top, ovl->clip_bottom, ovl->clip_left, ovl->clip_right);
+#endif
return;
}
@@ -556,9 +590,13 @@ static void spu_process_event( spudec_decoder_t *this, int vpts ) {
// uint32_t pts;
// int i;
// vo_overlay_t overlay;
- xprintf (VERBOSE|SPU, "557MUTEX1:spu_events lock");
+#ifdef LOG_DEBUG
+ printf ("spu: 557MUTEX1:spu_events lock");
+#endif
pthread_mutex_lock (&this->spu_events_mutex);
- xprintf (VERBOSE|SPU, " -> ok.\n");
+#ifdef LOG_DEBUG
+ printf ("spu: -> ok.\n");
+#endif
this_event=this->spu_events[0].next_event;
if ((!this_event) || (vpts < this->spu_events[this_event].event->vpts) ) {
pthread_mutex_unlock (&this->spu_events_mutex);
@@ -568,60 +606,84 @@ static void spu_process_event( spudec_decoder_t *this, int vpts ) {
handle=this->spu_events[this_event].event->object.handle;
switch( this->spu_events[this_event].event->event_type ) {
case EVENT_SHOW_SPU:
- xprintf (VERBOSE|SPU, "SHOW SPU NOW\n");
+#ifdef LOG_DEBUG
+ printf ("spu: SHOW SPU NOW\n");
+#endif
if (this->spu_events[this_event].event->object.overlay != NULL) {
this->spu_objects[handle].handle = handle;
- xprintf (VERBOSE|SPU, "POINTER1: this->spu_objects[handle=%d].overlay=%p\n",
- handle,
- this->spu_objects[handle].overlay);
+#ifdef LOG_DEBUG
+ printf ("spu: POINTER1: this->spu_objects[handle=%d].overlay=%p\n",
+ handle,
+ this->spu_objects[handle].overlay);
+#endif
this->spu_objects[handle].overlay = this->spu_events[this_event].event->object.overlay;
- xprintf (VERBOSE|SPU, "POINTER2: this->spu_objects[handle=%d].overlay=%p\n",
- handle,
- this->spu_objects[handle].overlay);
+#ifdef LOG_DEBUG
+ printf ("spu: POINTER2: this->spu_objects[handle=%d].overlay=%p\n",
+ handle,
+ this->spu_objects[handle].overlay);
+#endif
this->spu_events[this_event].event->object.overlay = NULL;
}
this->spu_showing[1].handle = handle;
break;
case EVENT_HIDE_SPU:
- xprintf (VERBOSE|SPU, "HIDE SPU NOW\n");
+#ifdef LOG_DEBUG
+ printf ("spu: HIDE SPU NOW\n");
+#endif
this->spu_showing[1].handle = -1;
if(this->spu_objects[handle].overlay->rle) {
- xprintf (VERBOSE|SPU, "FREE1: this->spu_objects[%d].overlay->rle %p\n",
- handle,
- this->spu_objects[handle].overlay->rle);
+#ifdef LOG_DEBUG
+ printf ("spu: FREE1: this->spu_objects[%d].overlay->rle %p\n",
+ handle,
+ this->spu_objects[handle].overlay->rle);
+#endif
free(this->spu_objects[handle].overlay->rle);
this->spu_objects[handle].overlay->rle = NULL;
- xprintf (VERBOSE|SPU, "FREE2: this->spu_objects[%d].overlay->rle %p\n",
- handle,
- this->spu_objects[handle].overlay->rle);
+#ifdef LOG_DEBUG
+ printf ("spu: FREE2: this->spu_objects[%d].overlay->rle %p\n",
+ handle,
+ this->spu_objects[handle].overlay->rle);
+#endif
}
- xprintf (VERBOSE|SPU, "RLE clear=%08X\n",(uint32_t)this->spu_objects[handle].overlay->rle);
+#ifdef LOG_DEBUG
+ printf ("spu: RLE clear=%08X\n",(uint32_t)this->spu_objects[handle].overlay->rle);
+#endif
if (this->spu_objects[handle].overlay) {
- xprintf (VERBOSE|SPU, "FREE1: this->spu_objects[%d].overlay %p\n",
- handle,
- this->spu_objects[handle].overlay);
+#ifdef LOG_DEBUG
+ printf ("spu: FREE1: this->spu_objects[%d].overlay %p\n",
+ handle,
+ this->spu_objects[handle].overlay);
+#endif
free(this->spu_objects[handle].overlay);
this->spu_objects[handle].overlay = NULL;
- xprintf (VERBOSE|SPU, "FREE2: this->spu_objects[%d].overlay %p\n",
- handle,
- this->spu_objects[handle].overlay);
+#ifdef LOG_DEBUG
+ printf ("spu: FREE2: this->spu_objects[%d].overlay %p\n",
+ handle,
+ this->spu_objects[handle].overlay);
+#endif
}
spu_free_handle( this, handle );
break;
case EVENT_HIDE_MENU:
- xprintf (VERBOSE|SPU, "HIDE MENU NOW %d\n",handle);
+#ifdef LOG_DEBUG
+ printf ("spu: HIDE MENU NOW %d\n",handle);
+#endif
this->spu_showing[1].handle = -1;
if(this->spu_objects[handle].overlay->rle) {
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "FREE1: this->spu_objects[%d].overlay->rle %p\n",
- handle,
- this->spu_objects[handle].overlay->rle);
+ handle,
+ this->spu_objects[handle].overlay->rle);
+#endif
free(this->spu_objects[handle].overlay->rle);
this->spu_objects[handle].overlay->rle = NULL;
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "FREE2: this->spu_objects[%d].overlay->rle %p\n",
- handle,
- this->spu_objects[handle].overlay->rle);
+ handle,
+ this->spu_objects[handle].overlay->rle);
+#endif
}
/* FIXME: maybe free something here */
@@ -629,24 +691,34 @@ static void spu_process_event( spudec_decoder_t *this, int vpts ) {
break;
case EVENT_MENU_SPU:
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "MENU SPU NOW\n");
+#endif
if (this->spu_events[this_event].event->object.overlay != NULL) {
vo_overlay_t *overlay = this->spu_objects[handle].overlay;
vo_overlay_t *event_overlay = this->spu_events[this_event].event->object.overlay;
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "event_overlay\n");
+#endif
spudec_print_overlay(event_overlay);
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "overlay\n");
+#endif
spudec_print_overlay(overlay);
this->spu_objects[handle].handle = handle; /* This should not change for menus */
/* If rle is not empty, free it first */
if(overlay && overlay->rle) {
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "FREE1: overlay->rle %p\n",
- overlay->rle);
+ overlay->rle);
+#endif
free (overlay->rle);
overlay->rle = NULL;
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "FREE2: overlay->rle %p\n",
- overlay->rle);
+ overlay->rle);
+#endif
}
overlay->rle = event_overlay->rle;
overlay->data_size = event_overlay->data_size;
@@ -660,7 +732,9 @@ static void spu_process_event( spudec_decoder_t *this, int vpts ) {
event_overlay->color[1] +
event_overlay->color[2] +
event_overlay->color[3]) > 0 ) {
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "mixing clut\n");
+#endif
overlay->color[0] = event_overlay->color[0];
overlay->color[1] = event_overlay->color[1];
overlay->color[2] = event_overlay->color[2];
@@ -670,33 +744,47 @@ static void spu_process_event( spudec_decoder_t *this, int vpts ) {
event_overlay->trans[1] +
event_overlay->trans[2] +
event_overlay->trans[3]) > 0 ) {
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "mixing trans\n");
+#endif
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];
}
this->spu_showing[1].handle = handle;
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "overlay after\n");
+#endif
spudec_print_overlay(overlay);
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "FREE1: event_overlay %p\n",
this->spu_events[this_event].event->object.overlay = NULL);
+#endif
/* The null test was done at the start of this case statement */
free (this->spu_events[this_event].event->object.overlay);
this->spu_events[this_event].event->object.overlay = NULL;
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "FREE2: event_ovlerlay %p\n",
this->spu_events[this_event].event->object.overlay);
+#endif
}
break;
case EVENT_MENU_BUTTON:
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "MENU BUTTON NOW\n");
+#endif
if (this->spu_events[this_event].event->object.overlay != NULL) {
vo_overlay_t *overlay = this->spu_objects[handle].overlay;
vo_overlay_t *event_overlay = this->spu_events[this_event].event->object.overlay;
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "event_overlay\n");
+#endif
spudec_print_overlay(event_overlay);
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "overlay\n");
+#endif
spudec_print_overlay(overlay);
this->spu_objects[handle].handle = handle; /* This should not change for menus */
overlay->clip_top = event_overlay->clip_top;
@@ -708,7 +796,9 @@ static void spu_process_event( spudec_decoder_t *this, int vpts ) {
event_overlay->color[1] +
event_overlay->color[2] +
event_overlay->color[3]) > 0 ) {
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "mixing clut\n");
+#endif
overlay->color[0] = event_overlay->color[0];
overlay->color[1] = event_overlay->color[1];
overlay->color[2] = event_overlay->color[2];
@@ -718,27 +808,37 @@ static void spu_process_event( spudec_decoder_t *this, int vpts ) {
event_overlay->trans[1] +
event_overlay->trans[2] +
event_overlay->trans[3]) > 0 ) {
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "mixing trans\n");
+#endif
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];
}
this->spu_showing[1].handle = handle;
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "overlay after\n");
+#endif
spudec_print_overlay(overlay);
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "FREE1: event_overlay %p\n",
this->spu_events[this_event].event->object.overlay = NULL);
+#endif
/* The null test was done at the start of this case statement */
free (this->spu_events[this_event].event->object.overlay);
this->spu_events[this_event].event->object.overlay = NULL;
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "FREE2: event_ovlerlay %p\n",
this->spu_events[this_event].event->object.overlay);
+#endif
}
break;
default:
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "Unhandled event type\n");
+#endif
break;
}
@@ -793,22 +893,29 @@ static void spudec_event_listener(void *this_gen, xine_event_t *event_gen) {
spu_overlay_event_t *overlay_event = NULL;
vo_overlay_t *overlay = NULL;
spu_button_t *but = event->data;
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "MALLOC1: overlay_event %p, len=%d\n",
overlay_event,
sizeof(spu_overlay_event_t));
+#endif
overlay_event = xine_xmalloc (sizeof(spu_overlay_event_t));
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "MALLOC2: overlay_event %p, len=%d\n",
overlay_event,
sizeof(spu_overlay_event_t));
xprintf (VERBOSE|SPU, "MALLOC1: overlay %p, len=%d\n",
overlay,
sizeof(vo_overlay_t));
+#endif
overlay = xine_xmalloc (sizeof(vo_overlay_t));
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "MALLOC2: overlay %p, len=%d\n",
overlay,
sizeof(vo_overlay_t));
+#endif
overlay_event->object.overlay=overlay;
+#ifdef LOG_DEBUG
xprintf (VERBOSE|SPU, "BUTTON\n");
xprintf (VERBOSE|SPU, "\tshow=%d\n",but->show);
xprintf (VERBOSE|SPU, "\tclut [%x %x %x %x]\n",
@@ -817,6 +924,7 @@ static void spudec_event_listener(void *this_gen, xine_event_t *event_gen) {
but->trans[0], but->trans[1], but->trans[2], but->trans[3]);
xprintf (VERBOSE|SPU, "\tleft = %d right = %d top = %d bottom = %d\n",
but->left, but->right, but->top, but->bottom );
+#endif
if (!this->state.menu) return;
if (but->show) {
@@ -882,10 +990,9 @@ spu_decoder_t *init_spu_decoder_plugin (int iface_version, xine_t *xine) {
spudec_decoder_t *this ;
if (iface_version != 4) {
- fprintf(stderr,
- "libspudec: Doesn't support plugin API version %d.\n"
- "libspudec: This means there is a version mismatch between XINE and\n"
- "libspudec: this plugin.\n", iface_version);
+ printf("libspudec: Doesn't support plugin API version %d.\n"
+ "libspudec: This means there is a version mismatch between XINE and\n"
+ "libspudec: this plugin.\n", iface_version);
return NULL;
}