summaryrefslogtreecommitdiff
path: root/src/libspudec
diff options
context:
space:
mode:
authorDaniel Caujolle-Bert <f1rmb@users.sourceforge.net>2003-12-05 15:54:56 +0000
committerDaniel Caujolle-Bert <f1rmb@users.sourceforge.net>2003-12-05 15:54:56 +0000
commit7958ce62d6ae127ee9b8664c8afae5754063389f (patch)
tree658e11edf004b0ae3ac3114ffe8ed5f8604ccefd /src/libspudec
parentb529e4b1f1668c03d3cb35c0c742f301b8c415db (diff)
downloadxine-lib-7958ce62d6ae127ee9b8664c8afae5754063389f.tar.gz
xine-lib-7958ce62d6ae127ee9b8664c8afae5754063389f.tar.bz2
cleanup phase II. use xprintf when it's relevant, use xine_xmalloc when it's relevant too. Small other little fix (can't remember). Change few internal function prototype because it xine_t pointer need to be used if some xine's internal sections. NOTE: libdvd{nav,read} is still too noisy, i will take a look to made it quit, without invasive changes. To be continued...
CVS patchset: 5844 CVS date: 2003/12/05 15:54:56
Diffstat (limited to 'src/libspudec')
-rw-r--r--src/libspudec/spu.c64
-rw-r--r--src/libspudec/spu.h6
-rw-r--r--src/libspudec/xine_decoder.c26
3 files changed, 52 insertions, 44 deletions
diff --git a/src/libspudec/spu.c b/src/libspudec/spu.c
index cd4219781..d363cfabd 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.72 2003/11/26 01:03:31 miguelfreitas Exp $
+ * $Id: spu.c,v 1.73 2003/12/05 15:55:00 f1rmb Exp $
*
*/
@@ -70,9 +70,9 @@
#define LOG_NAV 1
*/
-static void spudec_do_commands (spudec_state_t *state, spudec_seq_t* seq, vo_overlay_t *ovl);
-static void spudec_draw_picture (spudec_state_t *state, spudec_seq_t* seq, vo_overlay_t *ovl);
-static void spudec_discover_clut (spudec_state_t *state, vo_overlay_t *ovl);
+static void spudec_do_commands (xine_t *xine, spudec_state_t *state, spudec_seq_t* seq, vo_overlay_t *ovl);
+static void spudec_draw_picture (xine_t *xine, spudec_state_t *state, spudec_seq_t* seq, vo_overlay_t *ovl);
+static void spudec_discover_clut (xine_t *xine, spudec_state_t *state, vo_overlay_t *ovl);
#ifdef LOG_DEBUG
static void spudec_print_overlay( vo_overlay_t *overlay );
#endif
@@ -88,7 +88,8 @@ void spudec_decode_nav(spudec_decoder_t *this, buf_element_t *buf) {
p = buf->content;
if (p[0] || p[1] || (p[2] != 1)) {
- printf("libspudec:spudec_decode_nav:nav demux error! %02x %02x %02x (should be 0x000001) \n",p[0],p[1],p[2]);
+ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "libspudec:spudec_decode_nav:nav demux error! %02x %02x %02x (should be 0x000001) \n",p[0],p[1],p[2]);
return;
}
@@ -168,7 +169,7 @@ void spudec_decode_nav(spudec_decoder_t *this, buf_element_t *buf) {
this->event.vpts = 0;
ovl_manager->add_event(ovl_manager, (void *)&this->event);
} else {
- printf("libspudec: No video_overlay handles left for menu\n");
+ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "libspudec: No video_overlay handles left for menu\n");
}
}
xine_fast_memcpy(&this->pci, &pci, sizeof(pci_t));
@@ -229,14 +230,15 @@ void spudec_decode_nav(spudec_decoder_t *this, buf_element_t *buf) {
/* FIXME: Add command copying here */
break;
default:
- printf("libspudec: unknown pci.hli.hl_gi.hli_ss = %d\n", pci.hli.hl_gi.hli_ss );
+ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "libspudec: unknown pci.hli.hl_gi.hli_ss = %d\n", pci.hli.hl_gi.hli_ss );
break;
}
pthread_mutex_unlock(&this->nav_pci_lock);
return;
}
-void spudec_reassembly (spudec_seq_t *seq, uint8_t *pkt_data, u_int pkt_len)
+void spudec_reassembly (xine_t *xine, spudec_seq_t *seq, uint8_t *pkt_data, u_int pkt_len)
{
#ifdef LOG_DEBUG
printf ("libspudec: seq->complete = %d\n", seq->complete);
@@ -250,7 +252,7 @@ void spudec_reassembly (spudec_seq_t *seq, uint8_t *pkt_data, u_int pkt_len)
seq->seq_len = (((uint32_t)pkt_data[0])<<8) | pkt_data[1];
seq->cmd_offs = (((uint32_t)pkt_data[2])<<8) | pkt_data[3];
if (seq->cmd_offs >= seq->seq_len) {
- printf("libspudec:faulty stream\n");
+ xprintf(xine, XINE_VERBOSITY_DEBUG, "libspudec:faulty stream\n");
seq->broken = 1;
}
if (seq->buf_len < seq->seq_len) {
@@ -289,7 +291,7 @@ void spudec_reassembly (spudec_seq_t *seq, uint8_t *pkt_data, u_int pkt_len)
memcpy (seq->buf + seq->ra_offs, pkt_data, pkt_len);
seq->ra_offs += pkt_len;
} else {
- printf("libspudec:faulty stream\n");
+ xprintf(xine, XINE_VERBOSITY_DEBUG, "libspudec:faulty stream\n");
seq->broken = 1;
}
@@ -333,13 +335,13 @@ void spudec_process (spudec_decoder_t *this, int stream_id) {
}
/* parse SPU command sequence, this will update forced_display, so it must come
* before the check for it */
- spudec_do_commands(&this->state, cur_seq, &this->overlay);
+ spudec_do_commands(this->stream->xine, &this->state, cur_seq, &this->overlay);
/* FIXME: Check for Forced-display or subtitle stream
* For subtitles, open event.
* For menus, store it for later.
*/
if (cur_seq->broken) {
- printf("libspudec: dropping broken SPU\n");
+ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "libspudec: dropping broken SPU\n");
cur_seq->broken = 0;
return;
}
@@ -377,8 +379,9 @@ void spudec_process (spudec_decoder_t *this, int stream_id) {
#ifdef LOG_BUTTON
fprintf(stderr, "libspudec:Full Overlay\n");
#endif
- if (!spudec_copy_nav_to_overlay(&this->pci, this->state.clut, this->buttonN, 0,
- &this->overlay, &this->overlay)) {
+ if (!spudec_copy_nav_to_overlay(this->stream->xine,
+ &this->pci, this->state.clut,
+ this->buttonN, 0, &this->overlay, &this->overlay)) {
/* current button does not exist -> use another one */
xine_event_t event;
@@ -391,8 +394,9 @@ void spudec_process (spudec_decoder_t *this, int stream_id) {
event.data = &this->buttonN;
event.data_length = sizeof(this->buttonN);
xine_event_send(this->stream, &event);
- spudec_copy_nav_to_overlay(&this->pci, this->state.clut, this->buttonN, 0,
- &this->overlay, &this->overlay);
+ spudec_copy_nav_to_overlay(this->stream->xine,
+ &this->pci, this->state.clut,
+ this->buttonN, 0, &this->overlay, &this->overlay);
}
} else {
/* Subtitle and not a menu button */
@@ -405,11 +409,11 @@ void spudec_process (spudec_decoder_t *this, int stream_id) {
pthread_mutex_unlock(&this->nav_pci_lock);
if ((this->state.modified) ) {
- spudec_draw_picture(&this->state, cur_seq, &this->overlay);
+ spudec_draw_picture(this->stream->xine, &this->state, cur_seq, &this->overlay);
}
if (this->state.need_clut) {
- spudec_discover_clut(&this->state, &this->overlay);
+ spudec_discover_clut(this->stream->xine, &this->state, &this->overlay);
}
/* Subtitle */
@@ -418,7 +422,8 @@ void spudec_process (spudec_decoder_t *this, int stream_id) {
}
if( this->menu_handle < 0 ) {
- printf("libspudec: No video_overlay handles left for menu\n");
+ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "libspudec: No video_overlay handles left for menu\n");
return;
}
this->event.object.handle = this->menu_handle;
@@ -472,7 +477,7 @@ void spudec_process (spudec_decoder_t *this, int stream_id) {
#define CMD_SPU_WIPE 0x07 /* Not currently implemented */
#define CMD_SPU_EOF 0xff
-static void spudec_do_commands(spudec_state_t *state, spudec_seq_t* seq, vo_overlay_t *ovl)
+static void spudec_do_commands(xine_t *xine, spudec_state_t *state, spudec_seq_t* seq, vo_overlay_t *ovl)
{
uint8_t *buf = state->cmd_ptr;
uint8_t *next_seq;
@@ -594,7 +599,7 @@ static void spudec_do_commands(spudec_state_t *state, spudec_seq_t* seq, vo_over
if ((state->field_offs[0] >= seq->seq_len) ||
(state->field_offs[1] >= seq->seq_len)) {
- printf("libspudec:faulty stream\n");
+ xprintf(xine, XINE_VERBOSITY_DEBUG, "libspudec:faulty stream\n");
seq->broken = 1;
}
state->modified = 1;
@@ -618,7 +623,7 @@ static void spudec_do_commands(spudec_state_t *state, spudec_seq_t* seq, vo_over
break;
default:
- printf("libspudec: unknown seqence command (%02x)\n", buf[0]);
+ xprintf(xine, XINE_VERBOSITY_DEBUG, "libspudec: unknown seqence command (%02x)\n", buf[0]);
/* FIXME: SPU should be dropped, and buffers resynced */
buf = next_seq;
seq->broken = 1;
@@ -682,7 +687,7 @@ static int spudec_next_line (vo_overlay_t *spu)
return 0;
}
-static void spudec_draw_picture (spudec_state_t *state, spudec_seq_t* seq, vo_overlay_t *ovl)
+static void spudec_draw_picture (xine_t *xine, spudec_state_t *state, spudec_seq_t* seq, vo_overlay_t *ovl)
{
rle_elem_t *rle;
field = 0;
@@ -706,7 +711,9 @@ 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);
if (ovl->rle) {
- printf ("libspudec: spudec_draw_picture: ovl->rle is not empty!!!! It should be!!! You should never see this message.\n");
+ xprintf (xine, XINE_VERBOSITY_DEBUG,
+ "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;
}
@@ -767,7 +774,7 @@ static void spudec_draw_picture (spudec_state_t *state, spudec_seq_t* seq, vo_ov
MINFOUND is the number of ocurrences threshold.
*/
#define MINFOUND 20
-static void spudec_discover_clut(spudec_state_t *state, vo_overlay_t *ovl)
+static void spudec_discover_clut(xine_t *xine, spudec_state_t *state, vo_overlay_t *ovl)
{
int bg,c;
int seqcolor[10];
@@ -867,8 +874,8 @@ static void spudec_print_overlay( vo_overlay_t *ovl ) {
}
#endif
-int spudec_copy_nav_to_overlay(pci_t* nav_pci, uint32_t* clut, int32_t button, int32_t mode,
- vo_overlay_t * overlay, vo_overlay_t * base ) {
+int spudec_copy_nav_to_overlay(xine_t *xine, pci_t* nav_pci, uint32_t* clut,
+ int32_t button, int32_t mode, vo_overlay_t * overlay, vo_overlay_t * base ) {
btni_t *button_ptr = NULL;
unsigned int btns_per_group;
int i;
@@ -887,7 +894,8 @@ int spudec_copy_nav_to_overlay(pci_t* nav_pci, uint32_t* clut, int32_t button, i
if (!button_ptr && nav_pci->hli.hl_gi.btngr_ns >= 3 && !(nav_pci->hli.hl_gi.btngr3_dsp_ty & 6))
button_ptr = &nav_pci->hli.btnit[2 * btns_per_group + button - 1];
if (!button_ptr) {
- printf("libspudec: No suitable menu button group found, using group 1.\n");
+ xprintf(xine, XINE_VERBOSITY_DEBUG,
+ "libspudec: No suitable menu button group found, using group 1.\n");
button_ptr = &nav_pci->hli.btnit[button - 1];
}
diff --git a/src/libspudec/spu.h b/src/libspudec/spu.h
index 71ecd99c9..3aa55ba0a 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.23 2003/11/09 21:49:36 mroi Exp $
+ * $Id: spu.h,v 1.24 2003/12/05 15:55:00 f1rmb Exp $
*
* This file was originally part of the OMS program.
*
@@ -125,10 +125,10 @@ typedef struct spudec_decoder_s {
int64_t last_event_vpts;
} spudec_decoder_t;
-void spudec_reassembly (spudec_seq_t *seq, uint8_t *pkt_data, u_int pkt_len);
+void spudec_reassembly (xine_t *xine, spudec_seq_t *seq, uint8_t *pkt_data, u_int pkt_len);
void spudec_process( spudec_decoder_t *this, int stream_id);
void spudec_decode_nav( spudec_decoder_t *this, buf_element_t *buf);
-int spudec_copy_nav_to_overlay(pci_t* nav_pci, uint32_t* clut, int32_t button, int32_t mode,
+int spudec_copy_nav_to_overlay(xine_t *xine, pci_t* nav_pci, uint32_t* clut, int32_t button, int32_t mode,
vo_overlay_t * overlay, vo_overlay_t * base );
#endif
diff --git a/src/libspudec/xine_decoder.c b/src/libspudec/xine_decoder.c
index 3207f78dc..09b4c5795 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.101 2003/11/26 01:03:32 miguelfreitas Exp $
+ * $Id: xine_decoder.c,v 1.102 2003/12/05 15:55:00 f1rmb Exp $
*
* stuff needed to turn libspu into a xine decoder plugin
*/
@@ -135,12 +135,11 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) {
this->spudec_stream_state[stream_id].pts = buf->pts; /* Required to match up with NAV packets */
}
- spudec_reassembly(&this->spudec_stream_state[stream_id].ra_seq,
- buf->content,
- buf->size);
+ spudec_reassembly(this->stream->xine,
+ &this->spudec_stream_state[stream_id].ra_seq, buf->content, buf->size);
if(this->spudec_stream_state[stream_id].ra_seq.complete == 1) {
if(this->spudec_stream_state[stream_id].ra_seq.broken) {
- printf("libspudec: dropping broken SPU\n");
+ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "libspudec: dropping broken SPU\n");
this->spudec_stream_state[stream_id].ra_seq.broken = 0;
} else
spudec_process(this,stream_id);
@@ -266,14 +265,15 @@ static void spudec_set_button (spu_decoder_t *this_gen, int32_t button, int32_t
#ifdef LOG_BUTTON
fprintf(stderr, "libspudec:Button Overlay\n");
#endif
- spudec_copy_nav_to_overlay(&this->pci, this->state.clut, this->buttonN, show-1,
- overlay, &this->overlay );
+ spudec_copy_nav_to_overlay(this->stream->xine, &this->pci, this->state.clut,
+ this->buttonN, show-1, overlay, &this->overlay );
pthread_mutex_unlock(&this->nav_pci_lock);
} else {
- fprintf (stderr,"libspudec:xine_decoder.c:spudec_event_listener:HIDE ????\n");
- XINE_ASSERT(0, "We dropped out here for some reason");
- overlay_event->object.handle = this->menu_handle;
- overlay_event->event_type = OVERLAY_EVENT_HIDE;
+ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "libspudec:xine_decoder.c:spudec_event_listener:HIDE ????\n");
+ XINE_ASSERT(0, "We dropped out here for some reason");
+ overlay_event->object.handle = this->menu_handle;
+ overlay_event->event_type = OVERLAY_EVENT_HIDE;
}
overlay_event->vpts = 0;
if (this->stream->video_out) {
@@ -358,14 +358,14 @@ static void *init_plugin (xine_t *xine, void *data) {
spudec_class_t *this;
- this = (spudec_class_t *) malloc (sizeof (spudec_class_t));
+ this = (spudec_class_t *) xine_xmalloc (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;
- printf ("libspudec:init_plugin called\n");
+ lprintf ("libspudec:init_plugin called\n");
return this;
}