diff options
-rw-r--r-- | src/dxr3/dxr3_decoder.c | 4 | ||||
-rw-r--r-- | src/libspucc/cc_decoder.c | 4 | ||||
-rw-r--r-- | src/libspudec/nav_print.c | 26 | ||||
-rw-r--r-- | src/libspudec/nav_print.h | 8 | ||||
-rw-r--r-- | src/libspudec/spu.c | 151 | ||||
-rw-r--r-- | src/libspudec/xine_decoder.c | 17 | ||||
-rw-r--r-- | src/xine-engine/metronom.c | 22 | ||||
-rw-r--r-- | src/xine-engine/metronom.h | 4 |
8 files changed, 149 insertions, 87 deletions
diff --git a/src/dxr3/dxr3_decoder.c b/src/dxr3/dxr3_decoder.c index c3eae1c5c..3780e3afe 100644 --- a/src/dxr3/dxr3_decoder.c +++ b/src/dxr3/dxr3_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: dxr3_decoder.c,v 1.73 2002/04/23 15:45:19 esnel Exp $ + * $Id: dxr3_decoder.c,v 1.74 2002/04/24 20:26:06 jcdutton Exp $ * * dxr3 video and spu decoder plugin. Accepts the video and spu data * from XINE and sends it directly to the corresponding dxr3 devices. @@ -1029,7 +1029,7 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) uint32_t vpts32; vpts = this->spu_decoder.metronom->got_spu_packet - (this->spu_decoder.metronom, buf->pts, 0); + (this->spu_decoder.metronom, buf->pts); #if LOG_SPU printf ("dxr3_spu: pts=%lld vpts=%lld\n", buf->pts, vpts); #endif diff --git a/src/libspucc/cc_decoder.c b/src/libspucc/cc_decoder.c index 44690689d..154991c68 100644 --- a/src/libspucc/cc_decoder.c +++ b/src/libspucc/cc_decoder.c @@ -20,7 +20,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: cc_decoder.c,v 1.14 2002/03/31 23:14:48 cvogler Exp $ + * $Id: cc_decoder.c,v 1.15 2002/04/24 20:26:07 jcdutton Exp $ * * stuff needed to provide closed captioning decoding and display * @@ -829,7 +829,7 @@ static int64_t cc_renderer_calc_vpts(cc_renderer_t *this, int64_t pts, uint32_t ntsc_frame_offset) { metronom_t *metronom = this->metronom; - int64_t vpts = metronom->got_spu_packet(metronom, pts, 0); + int64_t vpts = metronom->got_spu_packet(metronom, pts); return vpts + ntsc_frame_offset * NTSC_FRAME_DURATION; } diff --git a/src/libspudec/nav_print.c b/src/libspudec/nav_print.c index c72e64444..81cc44394 100644 --- a/src/libspudec/nav_print.c +++ b/src/libspudec/nav_print.c @@ -32,7 +32,7 @@ #include "nav_print.h" -static void print_time(dvd_time_t *dtime) { +void print_time(dvd_time_t *dtime) { const char *rate; assert((dtime->hour>>4) < 0xa && (dtime->hour&0xf) < 0xa); assert((dtime->minute>>4) < 0x7 && (dtime->minute&0xf) < 0xa); @@ -59,16 +59,16 @@ static void print_time(dvd_time_t *dtime) { } -static void navPrint_PCI_GI(pci_gi_t *pci_gi) { +void navPrint_PCI_GI(pci_gi_t *pci_gi) { int i; printf("pci_gi:\n"); printf("nv_pck_lbn 0x%08x\n", pci_gi->nv_pck_lbn); printf("vobu_cat 0x%04x\n", pci_gi->vobu_cat); printf("vobu_uop_ctl 0x%08x\n", *(uint32_t*)&pci_gi->vobu_uop_ctl); - printf("vobu_s_ptm %u\n", pci_gi->vobu_s_ptm); - printf("vobu_e_ptm %u\n", pci_gi->vobu_e_ptm); - printf("vobu_se_e_ptm %u\n", pci_gi->vobu_se_e_ptm); + printf("vobu_s_ptm 0x%08x\n", pci_gi->vobu_s_ptm); + printf("vobu_e_ptm 0x%08x\n", pci_gi->vobu_e_ptm); + printf("vobu_se_e_ptm 0x%08x\n", pci_gi->vobu_se_e_ptm); printf("e_eltm "); print_time(&pci_gi->e_eltm); printf("\n"); @@ -84,7 +84,7 @@ static void navPrint_PCI_GI(pci_gi_t *pci_gi) { printf("\"\n"); } -static void navPrint_NSML_AGLI(nsml_agli_t *nsml_agli) { +void navPrint_NSML_AGLI(nsml_agli_t *nsml_agli) { int i, j = 0; for(i = 0; i < 9; i++) @@ -99,16 +99,16 @@ static void navPrint_NSML_AGLI(nsml_agli_t *nsml_agli) { nsml_agli->nsml_agl_dsta[i]); } -static void navPrint_HL_GI(hl_gi_t *hl_gi, int *btngr_ns, int *btn_ns) { +void navPrint_HL_GI(hl_gi_t *hl_gi, int *btngr_ns, int *btn_ns) { if((hl_gi->hli_ss & 0x03) == 0) return; printf("hl_gi:\n"); printf("hli_ss 0x%01x\n", hl_gi->hli_ss & 0x03); - printf("hli_s_ptm %u\n", hl_gi->hli_s_ptm); - printf("hli_e_ptm %u\n", hl_gi->hli_e_ptm); - printf("btn_se_e_ptm %u\n", hl_gi->btn_se_e_ptm); + printf("hli_s_ptm 0x%08x\n", hl_gi->hli_s_ptm); + printf("hli_e_ptm 0x%08x\n", hl_gi->hli_e_ptm); + printf("btn_se_e_ptm 0x%08x\n", hl_gi->btn_se_e_ptm); *btngr_ns = hl_gi->btngr_ns; printf("btngr_ns %d\n", hl_gi->btngr_ns); @@ -124,7 +124,7 @@ static void navPrint_HL_GI(hl_gi_t *hl_gi, int *btngr_ns, int *btn_ns) { printf("foac_btnn %d\n", hl_gi->foac_btnn); } -static void navPrint_BTN_COLIT(btn_colit_t *btn_colit) { +void navPrint_BTN_COLIT(btn_colit_t *btn_colit) { int i, j; j = 0; @@ -141,7 +141,7 @@ static void navPrint_BTN_COLIT(btn_colit_t *btn_colit) { btn_colit->btn_coli[i][j]); } -static void navPrint_BTNIT(btni_t *btni_table, int btngr_ns, int btn_ns) { +void navPrint_BTNIT(btni_t *btni_table, int btngr_ns, int btn_ns) { int i, j; printf("btnit:\n"); @@ -174,7 +174,7 @@ static void navPrint_BTNIT(btni_t *btni_table, int btngr_ns, int btn_ns) { } } -static void navPrint_HLI(hli_t *hli) { +void navPrint_HLI(hli_t *hli) { int btngr_ns = 0, btn_ns = 0; printf("hli:\n"); diff --git a/src/libspudec/nav_print.h b/src/libspudec/nav_print.h index e70835631..96bad19cd 100644 --- a/src/libspudec/nav_print.h +++ b/src/libspudec/nav_print.h @@ -34,6 +34,14 @@ extern "C" { void navPrint_PCI(pci_t *pci); void navPrint_DSI(dsi_t *dsi); +void print_time(dvd_time_t *dtime); +void navPrint_PCI_GI(pci_gi_t *pci_gi); +void navPrint_NSML_AGLI(nsml_agli_t *nsml_agli); +void navPrint_HL_GI(hl_gi_t *hl_gi, int *btngr_ns, int *btn_ns); +void navPrint_BTN_COLIT(btn_colit_t *btn_colit); +void navPrint_BTNIT(btni_t *btni_table, int btngr_ns, int btn_ns); +void navPrint_HLI(hli_t *hli); + #ifdef __cplusplus }; diff --git a/src/libspudec/spu.c b/src/libspudec/spu.c index 8f7356052..ea4b65cfb 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.38 2002/04/24 13:42:17 jcdutton Exp $ + * $Id: spu.c,v 1.39 2002/04/24 20:26:07 jcdutton Exp $ * */ @@ -64,9 +64,9 @@ /* #define LOG_DEBUG 1 #define LOG_NAV 1 +#define LOG_BUTTON 1 */ - void spudec_reassembly (spudec_seq_t *seq, uint8_t *pkt_data, u_int pkt_len); void spudec_process( spudec_decoder_t *this, uint32_t stream_id); void spudec_decode_nav( spudec_decoder_t *this, buf_element_t *buf); @@ -106,6 +106,7 @@ void spudec_decode_nav(spudec_decoder_t *this, buf_element_t *buf) { */ if(p[0] == 0x00) { #ifdef LOG_NAV + int btngr_ns = 0, btn_ns = 0; printf("libspudec:nav_PCI\n"); #endif nav_read_pci(&pci, p+1); @@ -124,7 +125,10 @@ void spudec_decode_nav(spudec_decoder_t *this, buf_element_t *buf) { printf("btngr%d_dsp_ty 0x%02x\n", 2, pci.hli.hl_gi.btngr2_dsp_ty); printf("btngr%d_dsp_ty 0x%02x\n", 3, pci.hli.hl_gi.btngr3_dsp_ty); //navPrint_PCI(&pci); - + navPrint_PCI_GI(&pci.pci_gi); + navPrint_NSML_AGLI(&pci.nsml_agli); + //navPrint_HLI(&pci.hli); + navPrint_HL_GI(&pci.hli.hl_gi, & btngr_ns, & btn_ns); #endif } @@ -144,55 +148,84 @@ void spudec_decode_nav(spudec_decoder_t *this, buf_element_t *buf) { // self->vobu_length = self->dsi.dsi_gi.vobu_ea; } } - if (pci.hli.hl_gi.hli_ss == 1) { - pthread_mutex_lock(&this->nav_pci_lock); - xine_fast_memcpy(&this->pci, &pci, sizeof(pci_t)); - this->button_filter=1; - pthread_mutex_unlock(&this->nav_pci_lock); - /******************************* - * We should do something about fosl_btnn, but - * until we can send the info to dvdnav, ignore it. - * if( pci.hli.hl_gi.fosl_btnn) { - * this->buttonN = pci.hli.hl_gi.fosl_btnn; - * } - *******************************/ - } - if ( (pci.hli.hl_gi.hli_ss == 0) && - (this->pci.hli.hl_gi.hli_ss == 1) ) { - pthread_mutex_lock(&this->nav_pci_lock); - xine_fast_memcpy(&this->pci, &pci, sizeof(pci_t)); - this->button_filter=0; - pthread_mutex_unlock(&this->nav_pci_lock); - /* Hide menu spu between menus */ - printf("libspudec:nav:SHOULD HIDE SPU here\n"); - if( this->menu_handle < 0 ) { - this->menu_handle = ovl_instance->get_handle(ovl_instance,1); - } - if( this->menu_handle >= 0 ) { - metronom_t *metronom = this->xine->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 - it yet and we cannot provide correct vpts values. use current_time - instead as an aproximation. - */ - this->event.vpts = metronom->got_spu_packet(metronom, pci.pci_gi.vobu_s_ptm, 0); - /* Keep all the events in the correct order. */ - /* This corrects for errors during estimation around discontinuity */ - if( this->event.vpts < this->last_event_vpts ) { - this->event.vpts = this->last_event_vpts + 1; + pthread_mutex_lock(&this->nav_pci_lock); + switch (pci.hli.hl_gi.hli_ss) { + case 0: + /* No Highlight information for this VOBU */ + if ( this->pci.hli.hl_gi.hli_ss == 1) { + /* Hide menu spu between menus */ +#ifdef LOG_BUTTON + printf("libspudec:nav:SHOULD HIDE SPU here\n"); +#endif + if( this->menu_handle < 0 ) { + this->menu_handle = ovl_instance->get_handle(ovl_instance,1); + } + if( this->menu_handle >= 0 ) { + int64_t vpts_offset; + metronom_t *metronom = this->xine->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 + it yet and we cannot provide correct vpts values. use current_time + instead as an aproximation. + */ + vpts_offset = metronom->got_spu_packet(metronom, -1); + this->event.vpts = metronom->got_spu_packet(metronom, this->pci.pci_gi.vobu_e_ptm); + /* Keep all the events in the correct order. */ + /* This corrects for errors during estimation around discontinuity */ + if( this->event.vpts < this->last_event_vpts ) { +#ifdef LOG_BUTTON + fprintf(stdout, "libspudec: add_event estimation correction. vpts was %lld\n", this->event.vpts); +#endif + this->event.vpts = this->last_event_vpts + 1; + } + this->last_event_vpts = this->event.vpts; +#ifdef LOG_BUTTON + fprintf(stdout, "libspudec: add_event HIDE_MENU type=%d : current time=%lld, spu vpts=%lld, vpts_offset=%lld\n", + this->event.event_type, + this->xine->metronom->get_current_time(this->xine->metronom), + this->event.vpts, + vpts_offset); +#endif + ovl_instance->add_event(ovl_instance, (void *)&this->event); + } else { + printf("libspudec: No video_overlay handles left for menu\n"); + } } - this->last_event_vpts = this->event.vpts; - fprintf(stderr, "libspudec: add_event type=%d : current time=%lld, spu vpts=%lld\n", - this->event.event_type, - this->xine->metronom->get_current_time(this->xine->metronom), - this->event.vpts); - assert(this->event.event_type != 2); - ovl_instance->add_event(ovl_instance, (void *)&this->event); - } else { - printf("libspudec: No video_overlay handles left for menu\n"); - } + xine_fast_memcpy(&this->pci, &pci, sizeof(pci_t)); + this->button_filter=0; + + break; + case 1: + /* All New Highlight information for this VOBU */ + xine_fast_memcpy(&this->pci, &pci, sizeof(pci_t)); + this->button_filter=1; + /******************************* + * We should do something about fosl_btnn, but + * until we can send the info to dvdnav, ignore it. + * if( pci.hli.hl_gi.fosl_btnn) { + * this->buttonN = pci.hli.hl_gi.fosl_btnn; + * } + *******************************/ + break; + case 2: + /* Use Highlight information from previous VOBU */ + this->pci.pci_gi.vobu_s_ptm = pci.pci_gi.vobu_s_ptm; + this->pci.pci_gi.vobu_e_ptm = pci.pci_gi.vobu_e_ptm; + this->pci.pci_gi.vobu_se_e_ptm = pci.pci_gi.vobu_se_e_ptm; + break; + case 3: + /* Use Highlight information from previous VOBU except commands, which come from this VOBU */ + this->pci.pci_gi.vobu_s_ptm = pci.pci_gi.vobu_s_ptm; + this->pci.pci_gi.vobu_e_ptm = pci.pci_gi.vobu_e_ptm; + this->pci.pci_gi.vobu_se_e_ptm = pci.pci_gi.vobu_se_e_ptm; + /* FIXME: Add command copying here */ + break; + default: + assert(0); + break; } + pthread_mutex_unlock(&this->nav_pci_lock); return; } @@ -299,7 +332,9 @@ void spudec_process (spudec_decoder_t *this, uint32_t stream_id) { spu_button.buttonN = this->buttonN; xine_send_event(this->xine, &spu_event.event); } +#ifdef LOG_BUTTON fprintf(stderr, "libspudec:Full Overlay\n"); +#endif spudec_copy_nav_to_overlay(&this->pci, this->state.clut, this->buttonN, 0, &this->overlay ); } else { /* Subtitle and not a menu button */ @@ -355,7 +390,9 @@ void spudec_process (spudec_decoder_t *this, uint32_t stream_id) { } else { this->event.vpts = this->xine->metronom->get_current_time(this->xine->metronom) + (this->state.delay*1000); +#ifdef LOG_BUTTON printf("libspudec: vpts current time estimation around discontinuity\n"); +#endif } /* Keep all the events in the correct order. */ /* This corrects for errors during estimation around discontinuity */ @@ -364,12 +401,12 @@ void spudec_process (spudec_decoder_t *this, uint32_t stream_id) { } this->last_event_vpts = this->event.vpts; +#ifdef LOG_BUTTON fprintf(stderr, "libspudec: add_event type=%d : current time=%lld, spu vpts=%lld\n", this->event.event_type, this->xine->metronom->get_current_time(this->xine->metronom), this->event.vpts); - assert(this->event.event_type != 2); - +#endif ovl_instance->add_event(ovl_instance, (void *)&this->event); } else { pending = 0; @@ -538,6 +575,8 @@ static void spudec_do_commands(spudec_state_t *state, spudec_seq_t* seq, vo_over default: printf("libspudec: unknown seqence command (%02x)\n", buf[0]); + /* FIXME: SPU should be dropped, and buffers resynced */ + assert(0); buf++; break; } @@ -809,22 +848,30 @@ void spudec_copy_nav_to_overlay(pci_t* nav_pci, uint32_t* clut, int32_t button, overlay->clip_right = button_ptr->x_end; overlay->clip_bottom = button_ptr->y_end; if(button_ptr->btn_coln != 0) { +#ifdef LOG_BUTTON fprintf(stderr, "libspudec: normal button clut\n"); +#endif for (i = 0;i < 4; i++) { overlay->clip_color[i] = clut[0xf & (nav_pci->hli.btn_colit.btn_coli[button_ptr->btn_coln-1][mode] >> (16 + 4*i))]; overlay->clip_trans[i] = 0xf & (nav_pci->hli.btn_colit.btn_coli[button_ptr->btn_coln-1][mode] >> (4*i)); } } else { +#ifdef LOG_BUTTON fprintf(stderr, "libspudec: abnormal button clut\n"); +#endif for (i = 0;i < 4; i++) { +#ifdef LOG_BUTTON printf("libspudec:btn_coln = 0, clip_color = color\n"); +#endif overlay->clip_color[i] = overlay->color[i]; overlay->clip_trans[i] = overlay->trans[i]; } } /* spudec_print_overlay( overlay ); */ +#ifdef LOG_BUTTON printf("libspudec:xine_decoder.c:NAV to SPU pts match!\n"); +#endif } diff --git a/src/libspudec/xine_decoder.c b/src/libspudec/xine_decoder.c index 86f6c001e..818b10959 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.65 2002/04/24 13:42:17 jcdutton Exp $ + * $Id: xine_decoder.c,v 1.66 2002/04/24 20:26:07 jcdutton Exp $ * * stuff needed to turn libspu into a xine decoder plugin */ @@ -45,6 +45,7 @@ /* #define LOG_DEBUG 1 +#define LOG_BUTTON 1 */ static clut_t __default_clut[] = { @@ -140,7 +141,7 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) { if (buf->pts) { metronom_t *metronom = this->xine->metronom; - int64_t vpts = metronom->got_spu_packet(metronom, buf->pts, 0); + int64_t vpts = metronom->got_spu_packet(metronom, buf->pts); this->spudec_stream_state[stream_id].vpts = vpts; /* Show timer */ this->spudec_stream_state[stream_id].pts = buf->pts; /* Required to match up with NAV packets */ @@ -220,11 +221,16 @@ static void spudec_event_listener(void *this_gen, xine_event_t *event_gen) { #endif if (but->show > 0) { +#ifdef LOG_NAV fprintf (stderr,"libspudec:xine_decoder.c:spudec_event_listener:buttonN = %u show=%d\n", but->buttonN, but->show); +#endif this->buttonN = but->buttonN; if (this->button_filter != 1) { +#ifdef LOG_NAV + fprintf (stdout,"libspudec:xine_decoder.c:spudec_event_listener:buttonN updates not allowed\n"); +#endif /* Only update highlight is the menu will let us */ free(overlay_event); free(overlay); @@ -238,7 +244,9 @@ static void spudec_event_listener(void *this_gen, xine_event_t *event_gen) { overlay_event->object.pts = this->pci.hli.hl_gi.hli_s_ptm; overlay_event->object.overlay=overlay; overlay_event->event_type = EVENT_MENU_BUTTON; - fprintf(stderr, "libspudec:Button Overlay\n"); +#ifdef LOG_NAV + fprintf(stderr, "libspudec:Button Overlay\n"); +#endif spudec_copy_nav_to_overlay(&this->pci, this->state.clut, this->buttonN, but->show-1, overlay ); pthread_mutex_unlock(&this->nav_pci_lock); } else { @@ -250,11 +258,12 @@ static void spudec_event_listener(void *this_gen, xine_event_t *event_gen) { overlay_event->vpts = 0; if (this->vo_out) { ovl_instance = this->vo_out->get_overlay_instance (this->vo_out); +#ifdef LOG_NAV fprintf(stderr, "libspudec: add_event type=%d : current time=%lld, spu vpts=%lld\n", overlay_event->event_type, this->xine->metronom->get_current_time(this->xine->metronom), overlay_event->vpts); - assert(overlay_event->event_type != 2); +#endif ovl_instance->add_event (ovl_instance, (void *)overlay_event); } else { free(overlay_event); diff --git a/src/xine-engine/metronom.c b/src/xine-engine/metronom.c index eaf93bf33..e1e3d79c2 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.81 2002/04/17 22:02:13 miguelfreitas Exp $ + * $Id: metronom.c,v 1.82 2002/04/24 20:26:07 jcdutton Exp $ */ #ifdef HAVE_CONFIG_H @@ -254,22 +254,20 @@ static void metronom_set_audio_rate (metronom_t *this, int64_t pts_per_smpls) { } -static int64_t metronom_got_spu_packet (metronom_t *this, int64_t pts, - int64_t duration) { +static int64_t metronom_got_spu_packet (metronom_t *this, int64_t pts) { int64_t vpts; pthread_mutex_lock (&this->lock); - if (pts) { - this->spu_vpts=pts; - } else { - pts=this->spu_vpts; - } - - if ( !this->in_discontinuity ) { - vpts = pts + this->vpts_offset; + if (pts >= 0 ) { + if ( !this->in_discontinuity ) { + vpts = pts + this->vpts_offset; + } else { + vpts = 0; + } } else { - vpts = 0; + /* pts < 0 */ + vpts = this->vpts_offset; } pthread_mutex_unlock (&this->lock); diff --git a/src/xine-engine/metronom.h b/src/xine-engine/metronom.h index 4fb0c7667..f7fa8281a 100644 --- a/src/xine-engine/metronom.h +++ b/src/xine-engine/metronom.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: metronom.h,v 1.29 2002/04/07 12:09:38 miguelfreitas Exp $ + * $Id: metronom.h,v 1.30 2002/04/24 20:26:07 jcdutton Exp $ * * metronom: general pts => virtual calculation/assoc * @@ -115,7 +115,7 @@ struct metronom_s { * due to the lack of regularity on spu packets) */ - int64_t (*got_spu_packet) (metronom_t *this, int64_t pts, int64_t duration); + int64_t (*got_spu_packet) (metronom_t *this, int64_t pts); /* * tell metronom about discontinuities. |