From 0553f19ca2e0c262362e3ba8f827906c553418e8 Mon Sep 17 00:00:00 2001 From: Michael Roitzsch Date: Wed, 4 Sep 2002 11:07:47 +0000 Subject: sync to libdvdnav cvs CVS patchset: 2603 CVS date: 2002/09/04 11:07:47 --- src/input/libdvdnav/decoder.c | 5 +- src/input/libdvdnav/decoder.h | 4 +- src/input/libdvdnav/diff_against_cvs.patch | 35 +++--- src/input/libdvdnav/dvdnav.c | 34 +++--- src/input/libdvdnav/highlight.c | 169 +++++++++++++++++++++++++++- src/input/libdvdnav/navigation.c | 50 +++------ src/input/libdvdnav/searching.c | 51 +-------- src/input/libdvdnav/vm.c | 170 ++++++++++++++++++++++++----- src/input/libdvdnav/vm.h | 5 +- 9 files changed, 361 insertions(+), 162 deletions(-) (limited to 'src') diff --git a/src/input/libdvdnav/decoder.c b/src/input/libdvdnav/decoder.c index 6fb771ef1..c7d27eeb0 100644 --- a/src/input/libdvdnav/decoder.c +++ b/src/input/libdvdnav/decoder.c @@ -18,7 +18,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: decoder.c,v 1.4 2002/08/27 19:24:33 mroi Exp $ + * $Id: decoder.c,v 1.5 2002/09/04 11:07:47 mroi Exp $ * */ @@ -581,14 +581,13 @@ int32_t vmEval_CMD(vm_cmd_t commands[], int32_t num_commands, /* DEBUG */ fprintf(MSG_OUT, "libdvdnav: Registers before transaction\n"); vmPrint_registers( registers ); - int32_t i; fprintf(MSG_OUT, "libdvdnav: Full list of commands to execute\n"); for(i = 0; i < num_commands; i++) vmPrint_CMD(i, &commands[i]); fprintf(MSG_OUT, "libdvdnav: --------------------------------------------\n"); fprintf(MSG_OUT, "libdvdnav: Single stepping commands\n"); #endif - + i = 0; while(i < num_commands && total < 100000) { int32_t line; diff --git a/src/input/libdvdnav/decoder.h b/src/input/libdvdnav/decoder.h index 9b2c45a47..24657e889 100644 --- a/src/input/libdvdnav/decoder.h +++ b/src/input/libdvdnav/decoder.h @@ -18,7 +18,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: decoder.h,v 1.3 2002/08/09 22:52:14 mroi Exp $ + * $Id: decoder.h,v 1.4 2002/09/04 11:07:47 mroi Exp $ * */ @@ -31,7 +31,7 @@ #include "ifo_types.h" /* vm_cmd_t */ /* Uncomment for tracing */ -/* #define TRACE */ +/* #define TRACE */ typedef enum { LinkNoLink = 0, diff --git a/src/input/libdvdnav/diff_against_cvs.patch b/src/input/libdvdnav/diff_against_cvs.patch index d1855aefc..331435d00 100644 --- a/src/input/libdvdnav/diff_against_cvs.patch +++ b/src/input/libdvdnav/diff_against_cvs.patch @@ -9,8 +9,8 @@ #include #include "vmcmd.h" #include "decoder.h" ---- src/input/libdvdnav/decoder.h Fri Jul 12 17:49:16 2002 -+++ src/input/libdvdnav/decoder.h Fri Aug 9 22:00:14 2002 +--- src/input/libdvdnav/decoder.h Wed Sep 4 12:50:34 2002 ++++ src/input/libdvdnav/decoder.h Wed Sep 4 12:50:42 2002 @@ -28,7 +28,7 @@ #include #include @@ -19,9 +19,9 @@ +#include "ifo_types.h" /* vm_cmd_t */ /* Uncomment for tracing */ - /* #define TRACE */ ---- src/input/libdvdnav/dvdnav.c Fri Aug 9 22:05:04 2002 -+++ src/input/libdvdnav/dvdnav.c Fri Aug 9 22:00:50 2002 + /* #define TRACE */ +--- src/input/libdvdnav/dvdnav.c Wed Sep 4 12:50:34 2002 ++++ src/input/libdvdnav/dvdnav.c Wed Sep 4 12:50:42 2002 @@ -30,11 +30,11 @@ */ @@ -36,12 +36,12 @@ #include #include -@@ -177,7 +177,7 @@ - dvdnav_t *this; +@@ -179,7 +179,7 @@ + struct timeval time; /* Create a new structure */ -- fprintf(MSG_OUT, "libdvdnav: Using dvdnav version from http://dvd.sf.net\n"); -+ fprintf(MSG_OUT, "libdvdnav: Using dvdnav version from http://xine.sf.net\n"); +- fprintf(MSG_OUT, "libdvdnav: Using dvdnav version (devel-ref:jcd1) from http://dvd.sf.net\n"); ++ fprintf(MSG_OUT, "libdvdnav: Using dvdnav version (devel-ref:jcd1) from http://xine.sf.net\n"); /* FIXME: We malloc() here, but if an error occurs inside dvdnav_open(), * we return but never free() it. @@ -91,17 +91,8 @@ /* Maximum length of an error string */ -@@ -60,7 +61,7 @@ - #endif - - /* where should libdvdnav write its messages (stdout/stderr) */ --#define MSG_OUT stderr -+#define MSG_OUT stdout - - typedef struct read_cache_s read_cache_t; - ---- src/input/libdvdnav/highlight.c Fri Jul 26 12:58:10 2002 -+++ src/input/libdvdnav/highlight.c Fri Aug 9 22:02:46 2002 +--- src/input/libdvdnav/highlight.c Wed Sep 4 12:50:34 2002 ++++ src/input/libdvdnav/highlight.c Wed Sep 4 12:55:44 2002 @@ -34,10 +34,10 @@ #include "dvdnav_internal.h" @@ -112,9 +103,9 @@ #ifdef BUTTON_TESTING -#include +#include "nav_print.h" - #endif + #include "vmcmd.h" - /* Highlighting API calls */ + static void print_time(dvd_time_t *dtime) { --- src/input/libdvdnav/searching.c Fri Jul 26 12:58:10 2002 +++ src/input/libdvdnav/searching.c Fri Aug 9 22:03:20 2002 @@ -25,11 +25,11 @@ diff --git a/src/input/libdvdnav/dvdnav.c b/src/input/libdvdnav/dvdnav.c index 010821c3b..d1a4e7318 100644 --- a/src/input/libdvdnav/dvdnav.c +++ b/src/input/libdvdnav/dvdnav.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: dvdnav.c,v 1.6 2002/08/31 02:48:13 jcdutton Exp $ + * $Id: dvdnav.c,v 1.7 2002/09/04 11:07:47 mroi Exp $ * */ @@ -38,6 +38,7 @@ #include #include +#include /* * NOTE: @@ -175,17 +176,20 @@ dvdnav_status_t dvdnav_clear(dvdnav_t * this) { dvdnav_status_t dvdnav_open(dvdnav_t** dest, char *path) { dvdnav_t *this; + struct timeval time; /* Create a new structure */ - fprintf(MSG_OUT, "libdvdnav: Using dvdnav version from http://xine.sf.net\n"); + fprintf(MSG_OUT, "libdvdnav: Using dvdnav version (devel-ref:jcd1) from http://xine.sf.net\n"); /* FIXME: We malloc() here, but if an error occurs inside dvdnav_open(), * we return but never free() it. */ + (*dest) = NULL; this = (dvdnav_t*)malloc(sizeof(dvdnav_t)); if(!this) return S_ERR; memset(this, 0, (sizeof(dvdnav_t) ) ); /* Make sure this structure is clean */ + (*dest) = this; pthread_mutex_init(&this->vm_lock, NULL); /* Initialise the error string */ @@ -212,16 +216,15 @@ dvdnav_status_t dvdnav_open(dvdnav_t** dest, char *path) { if (this->file) DVDCloseFile(this->file); this->file = NULL; - //if(!this->started) { - // /* Start the VM */ - // vm_start(this->vm); - // this->started = 1; - //} - /* Start the read-ahead cache. */ this->cache = dvdnav_read_cache_new(this); - - (*dest) = this; + + /* Seed the random numbers. So that the DVD VM Command rand()i + * gives a different start value each time a DVD is played. + */ + gettimeofday(&time,NULL); + srand(time.tv_usec); + return S_OK; } @@ -291,14 +294,6 @@ dvdnav_status_t dvdnav_reset(dvdnav_t *this) { fprintf(MSG_OUT, "libdvdnav: clearing dvdnav\n"); #endif result=dvdnav_clear(this); -#ifdef LOG_DEBUG - fprintf(MSG_OUT, "libdvdnav: starting vm\n"); -#endif -// if(!this->started) { -// /* Start the VM */ -// vm_start(this->vm); -// this->started = 1; -// } #ifdef LOG_DEBUG fprintf(MSG_OUT, "libdvdnav: unlocking\n"); #endif @@ -1003,6 +998,9 @@ uint32_t dvdnav_get_next_still_flag(dvdnav_t *this) { /* * $Log: dvdnav.c,v $ + * Revision 1.7 2002/09/04 11:07:47 mroi + * sync to libdvdnav cvs + * * Revision 1.6 2002/08/31 02:48:13 jcdutton * Add a printf so we can tell if a user is using xine's libdvdnav or the one from * dvd.sf.net. diff --git a/src/input/libdvdnav/highlight.c b/src/input/libdvdnav/highlight.c index 2863f2441..8beacd2ca 100644 --- a/src/input/libdvdnav/highlight.c +++ b/src/input/libdvdnav/highlight.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: highlight.c,v 1.4 2002/08/27 19:24:33 mroi Exp $ + * $Id: highlight.c,v 1.5 2002/09/04 11:07:47 mroi Exp $ * */ @@ -38,10 +38,175 @@ #ifdef BUTTON_TESTING #include "nav_print.h" +#include "vmcmd.h" + +static 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); + assert((dtime->second>>4) < 0x7 && (dtime->second&0xf) < 0xa); + assert((dtime->frame_u&0xf) < 0xa); + + fprintf(MSG_OUT,"%02x:%02x:%02x.%02x", + dtime->hour, + dtime->minute, + dtime->second, + dtime->frame_u & 0x3f); + switch((dtime->frame_u & 0xc0) >> 6) { + case 1: + rate = "25.00"; + break; + case 3: + rate = "29.97"; + break; + default: + rate = "(please send a bug report)"; + break; + } + fprintf(MSG_OUT," @ %s fps", rate); +} + +static void nav_print_PCI_GI(pci_gi_t *pci_gi) { + int i; + + fprintf(MSG_OUT,"pci_gi:\n"); + fprintf(MSG_OUT,"nv_pck_lbn 0x%08x\n", pci_gi->nv_pck_lbn); + fprintf(MSG_OUT,"vobu_cat 0x%04x\n", pci_gi->vobu_cat); + fprintf(MSG_OUT,"vobu_uop_ctl 0x%08x\n", *(uint32_t*)&pci_gi->vobu_uop_ctl); + fprintf(MSG_OUT,"vobu_s_ptm 0x%08x\n", pci_gi->vobu_s_ptm); + fprintf(MSG_OUT,"vobu_e_ptm 0x%08x\n", pci_gi->vobu_e_ptm); + fprintf(MSG_OUT,"vobu_se_e_ptm 0x%08x\n", pci_gi->vobu_se_e_ptm); + fprintf(MSG_OUT,"e_eltm "); + print_time(&pci_gi->e_eltm); + fprintf(MSG_OUT,"\n"); + + fprintf(MSG_OUT,"vobu_isrc \""); + for(i = 0; i < 32; i++) { + char c = pci_gi->vobu_isrc[i]; + if((c >= ' ') && (c <= '~')) + fprintf(MSG_OUT,"%c", c); + else + fprintf(MSG_OUT,"."); + } + fprintf(MSG_OUT,"\"\n"); +} + +static void nav_print_NSML_AGLI(nsml_agli_t *nsml_agli) { + int i, j = 0; + + for(i = 0; i < 9; i++) + j |= nsml_agli->nsml_agl_dsta[i]; + if(j == 0) + return; + + fprintf(MSG_OUT,"nsml_agli:\n"); + for(i = 0; i < 9; i++) + if(nsml_agli->nsml_agl_dsta[i]) + fprintf(MSG_OUT,"nsml_agl_c%d_dsta 0x%08x\n", i + 1, + nsml_agli->nsml_agl_dsta[i]); +} + +static void nav_print_HL_GI(hl_gi_t *hl_gi, int *btngr_ns, int *btn_ns) { + + if((hl_gi->hli_ss & 0x03) == 0) + return; + + fprintf(MSG_OUT,"hl_gi:\n"); + fprintf(MSG_OUT,"hli_ss 0x%01x\n", hl_gi->hli_ss & 0x03); + fprintf(MSG_OUT,"hli_s_ptm 0x%08x\n", hl_gi->hli_s_ptm); + fprintf(MSG_OUT,"hli_e_ptm 0x%08x\n", hl_gi->hli_e_ptm); + fprintf(MSG_OUT,"btn_se_e_ptm 0x%08x\n", hl_gi->btn_se_e_ptm); + + *btngr_ns = hl_gi->btngr_ns; + fprintf(MSG_OUT,"btngr_ns %d\n", hl_gi->btngr_ns); + fprintf(MSG_OUT,"btngr%d_dsp_ty 0x%02x\n", 1, hl_gi->btngr1_dsp_ty); + fprintf(MSG_OUT,"btngr%d_dsp_ty 0x%02x\n", 2, hl_gi->btngr2_dsp_ty); + fprintf(MSG_OUT,"btngr%d_dsp_ty 0x%02x\n", 3, hl_gi->btngr3_dsp_ty); + + fprintf(MSG_OUT,"btn_ofn %d\n", hl_gi->btn_ofn); + *btn_ns = hl_gi->btn_ns; + fprintf(MSG_OUT,"btn_ns %d\n", hl_gi->btn_ns); + fprintf(MSG_OUT,"nsl_btn_ns %d\n", hl_gi->nsl_btn_ns); + fprintf(MSG_OUT,"fosl_btnn %d\n", hl_gi->fosl_btnn); + fprintf(MSG_OUT,"foac_btnn %d\n", hl_gi->foac_btnn); +} + +static void nav_print_BTN_COLIT(btn_colit_t *btn_colit) { + int i, j; + + j = 0; + for(i = 0; i < 6; i++) + j |= btn_colit->btn_coli[i/2][i&1]; + if(j == 0) + return; + + fprintf(MSG_OUT,"btn_colit:\n"); + for(i = 0; i < 3; i++) + for(j = 0; j < 2; j++) + fprintf(MSG_OUT,"btn_cqoli %d %s_coli: %08x\n", + i, (j == 0) ? "sl" : "ac", + btn_colit->btn_coli[i][j]); +} + +static void nav_print_BTNIT(btni_t *btni_table, int btngr_ns, int btn_ns) { + int i, j, k; + + fprintf(MSG_OUT,"btnit:\n"); + fprintf(MSG_OUT,"btngr_ns: %i\n", btngr_ns); + fprintf(MSG_OUT,"btn_ns: %i\n", btn_ns); + + if(btngr_ns == 0) + return; + + for(i = 0; i < btngr_ns; i++) { + for(j = 0; j < (36 / btngr_ns); j++) { + if(j < btn_ns) { + btni_t *btni = &btni_table[(36 / btngr_ns) * i + j]; + + fprintf(MSG_OUT,"group %d btni %d: ", i+1, j+1); + fprintf(MSG_OUT,"btn_coln %d, auto_action_mode %d\n", + btni->btn_coln, btni->auto_action_mode); + fprintf(MSG_OUT,"coords (%d, %d) .. (%d, %d)\n", + btni->x_start, btni->y_start, btni->x_end, btni->y_end); + + fprintf(MSG_OUT,"up %d, ", btni->up); + fprintf(MSG_OUT,"down %d, ", btni->down); + fprintf(MSG_OUT,"left %d, ", btni->left); + fprintf(MSG_OUT,"right %d\n", btni->right); + for(k = 0; k < 8; k++) { + fprintf(MSG_OUT, "%02x ", btni->cmd.bytes[k]); + } + fprintf(MSG_OUT, "| "); + vmPrint_mnemonic(&btni->cmd); + fprintf(MSG_OUT, "\n\n"); + } + } + } +} + +static void nav_print_HLI(hli_t *hli) { + int btngr_ns = 0, btn_ns = 0; + + fprintf(MSG_OUT,"hli:\n"); + nav_print_HL_GI(&hli->hl_gi, & btngr_ns, & btn_ns); + nav_print_BTN_COLIT(&hli->btn_colit); + nav_print_BTNIT(hli->btnit, btngr_ns, btn_ns); +} + +void nav_print_PCI(pci_t *pci) { + fprintf(MSG_OUT,"pci packet:\n"); + nav_print_PCI_GI(&pci->pci_gi); + nav_print_NSML_AGLI(&pci->nsml_agli); + nav_print_HLI(&pci->hli); +} + + #endif /* Highlighting API calls */ + + dvdnav_status_t dvdnav_get_current_highlight(dvdnav_t *this, int* button) { if(!this) return S_ERR; @@ -60,7 +225,7 @@ btni_t *__get_current_button(dvdnav_t *this) { return NULL; } #ifdef BUTTON_TESTING - navPrint_PCI(&(this->pci)); + nav_print_PCI(&(this->pci)); #endif return &(this->pci.hli.btnit[button-1]); diff --git a/src/input/libdvdnav/navigation.c b/src/input/libdvdnav/navigation.c index ba04b88c4..748cb7f52 100644 --- a/src/input/libdvdnav/navigation.c +++ b/src/input/libdvdnav/navigation.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: navigation.c,v 1.1 2002/08/08 17:49:21 richwareham Exp $ + * $Id: navigation.c,v 1.2 2002/09/04 11:07:47 mroi Exp $ * */ @@ -56,6 +56,7 @@ dvdnav_status_t dvdnav_get_number_of_titles(dvdnav_t *this, int *titles) { return S_OK; } +/* This function should not be used. FIXME: Suggest alternative */ dvdnav_status_t dvdnav_get_number_of_programs(dvdnav_t *this, int *programs) { if(!this) return S_ERR; @@ -70,55 +71,34 @@ dvdnav_status_t dvdnav_get_number_of_programs(dvdnav_t *this, int *programs) { return S_OK; } -dvdnav_status_t dvdnav_title_play(dvdnav_t *this, int title) { - int num_titles; - - if(!this) { - return S_ERR; - } +dvdnav_status_t dvdnav_current_title_info(dvdnav_t *this, int *title, int *part) { + if(!this || !this->vm) + return S_ERR; - /* Check number of titles */ - dvdnav_get_number_of_titles(this, &num_titles); - if((title > num_titles) || (title <= 0)) { - printerrf("Invalid title passed (%i, maximum %i)", title, - num_titles); + if(!title || !part) { + printerr("Passed a NULL pointer"); return S_ERR; } - - vm_start_title(this->vm, title); - return S_OK; + return vm_get_current_title_part(this->vm, title, part); } -dvdnav_status_t dvdnav_part_play(dvdnav_t *this, int title, int part) { - int num_titles, num_progs; +dvdnav_status_t dvdnav_title_play(dvdnav_t *this, int title) { if(!this) { return S_ERR; } - /* Check number of titles */ - dvdnav_get_number_of_titles(this, &num_titles); - if((title > num_titles) || (title <= 0)) { - printerrf("Invalid title passed (%i, maximum %i)", title, - num_titles); - return S_ERR; - } - - vm_start_title(this->vm, title); + return dvdnav_part_play(this, title, 1); +} +dvdnav_status_t dvdnav_part_play(dvdnav_t *this, int title, int part) { - /* Check number of parts */ - num_progs = this->vm->state.pgc->nr_of_programs; - if((part > num_progs) || (part <= 0)) { - printerrf("Invalid program passed (%i, maximum %i)", part, - num_progs); + if(!this) { return S_ERR; } - - vm_jump_prog(this->vm, part); - - return S_OK; + + return vm_jump_title_part(this->vm, title, part); } dvdnav_status_t dvdnav_part_play_auto_stop(dvdnav_t *this, int title, diff --git a/src/input/libdvdnav/searching.c b/src/input/libdvdnav/searching.c index b1c1141f7..503b9925d 100644 --- a/src/input/libdvdnav/searching.c +++ b/src/input/libdvdnav/searching.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: searching.c,v 1.4 2002/08/27 19:24:33 mroi Exp $ + * $Id: searching.c,v 1.5 2002/09/04 11:07:47 mroi Exp $ * */ @@ -298,55 +298,6 @@ dvdnav_status_t dvdnav_menu_call(dvdnav_t *this, DVDMenuID_t menu) { return S_OK; } -dvdnav_status_t dvdnav_current_title_info(dvdnav_t *this, int *tt, int *pr) { -int vts_ttn = 0; - int vts, i; - domain_t domain; - tt_srpt_t* srpt; - - if(!this) - return S_ERR; - - if(!tt || !pr) { - printerr("Passed a NULL pointer"); - } - - if(tt) - *tt = -1; - if(*pr) - *pr = -1; - - domain = this->vm->state.domain; - if((domain == FP_DOMAIN) || (domain == VMGM_DOMAIN)) { - /* Not in a title */ - return S_OK; - } - - vts_ttn = this->vm->state.VTS_TTN_REG; - vts = this->vm->state.vtsN; - - if(pr) { - *pr = this->vm->state.pgN; - } - - /* Search TT_SRPT for title */ - if(!(vm_get_vmgi(this->vm))) { - printerr("Oh poo, no SRPT"); - return S_ERR; - } - - srpt = vm_get_vmgi(this->vm)->tt_srpt; - for(i=0; inr_of_srpts; i++) { - title_info_t* info = &(srpt->title[i]); - if((info->title_set_nr == vts) && (info->vts_ttn == vts_ttn)) { - if(tt) - *tt = i+1; - } - } - - return S_OK; -} - static char __title_str[] = "DVDNAV"; dvdnav_status_t dvdnav_get_title_string(dvdnav_t *this, char **title_str) { diff --git a/src/input/libdvdnav/vm.c b/src/input/libdvdnav/vm.c index 21f976ef8..10b9f9f32 100644 --- a/src/input/libdvdnav/vm.c +++ b/src/input/libdvdnav/vm.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: vm.c,v 1.4 2002/08/27 19:24:33 mroi Exp $ + * $Id: vm.c,v 1.5 2002/09/04 11:07:47 mroi Exp $ * */ @@ -42,9 +42,9 @@ #include "vm.h" #include "dvdnav_internal.h" -/* + #define STRICT -*/ + /* Local prototypes */ @@ -110,8 +110,9 @@ static void vm_print_current_domain_state(vm_t *vm) { fprintf(MSG_OUT, "libdvdnav: Unknown Domain: -\n"); break; } - fprintf(MSG_OUT, "libdvdnav: VTS:%d PG:%u CELL:%u BLOCK:%u VTS_TTN:%u TTN:%u TT_PGCN:%u\n", + fprintf(MSG_OUT, "libdvdnav: VTS:%d PGC:%d PG:%u CELL:%u BLOCK:%u VTS_TTN:%u TTN:%u TT_PGCN:%u\n", (vm->state).vtsN, + get_PGCN(vm), (vm->state).pgN, (vm->state).cellN, (vm->state).blockN, @@ -437,6 +438,96 @@ int vm_prev_pg(vm_t *vm) return vm_top_pg(vm); } +/* Get the current title and part from the current playing position. */ +/* returns S_ERR if not in the VTS_DOMAIN */ +/* FIXME: Should we do some locking here ? */ +int vm_get_current_title_part(vm_t *vm, int *title_result, int *part_result) +{ + vts_ptt_srpt_t *vts_ptt_srpt; + int title=0, part=0; + int found = 0; + int16_t pgcN, pgN; + + if((!vm) || (!vm->vtsi) ) + return S_ERR; + + if(!title_result || !part_result) { + fprintf(MSG_OUT, "libdvdnav:vm_get_current_title_part: Passed a NULL pointer"); + return S_ERR; + } + + if(!(vm->state.pgc) ) + return S_ERR; + if (vm->state.domain != VTS_DOMAIN) + return S_ERR; + vts_ptt_srpt = vm->vtsi->vts_ptt_srpt; + pgcN = get_PGCN(vm); + pgN = vm->state.pgN; + printf("VTS_PTT_SRPT - PGC: %3i PG: %3i\n", + pgcN, pgN); + for(title=0;( (title < vts_ptt_srpt->nr_of_srpts) && (found == 0) );title++) { + for(part=0;((part < vts_ptt_srpt->title[title].nr_of_ptts) && (found == 0));part++) { + if ( (vts_ptt_srpt->title[title].ptt[part].pgcn == pgcN) && + (vts_ptt_srpt->title[title].ptt[part].pgn == pgN ) ) { + found = 1; + break; + } + } + if (found != 0) break; + } + title++; + part++; + if (found == 1) { + fprintf(MSG_OUT, "libdvdnav: ************ this chapter FOUND!\n"); + printf("VTS_PTT_SRPT - Title %3i part %3i: PGC: %3i PG: %3i\n", + title, part, + vts_ptt_srpt->title[title-1].ptt[part-1].pgcn , + vts_ptt_srpt->title[title-1].ptt[part-1].pgn ); + } else { + fprintf(MSG_OUT, "libdvdnav: ************ this chapter NOT FOUND!\n"); + return S_ERR; + } + *title_result = title; + *part_result = part; + return 1; +} + +/* Jump to a particlar part of a particlar title on this vts */ +/* returns S_ERR if not in the VTS_DOMAIN */ +/* FIXME: Should we do some locking here ? */ +int vm_jump_title_part(vm_t *vm, int title, int part) { + link_t link_values; + int vtsN; + + if((!vm) || (!vm->vtsi) || (!vm->vmgi) ) + return S_ERR; + + if(!(vm->state.pgc) ) + return S_ERR; +/* if ( (title < 1) || (title > vm->vtsi->vts_ptt_srpt->nr_of_srpts) || + (part < 1) || (part > vm->vtsi->vts_ptt_srpt->title[title].nr_of_ptts) ) { + return S_ERR; + } + */ + if( (title < 1) || (title > vm->vmgi->tt_srpt->nr_of_srpts) ) { + return S_ERR; + } + vtsN = vm->vmgi->tt_srpt->title[title - 1].title_set_nr; + + if(set_VTS_PTT(vm, vtsN, title, part) == -1) { + return S_ERR; + } + link_values = play_PGC_PG( vm, (vm->state).pgN ); + link_values = process_command(vm,link_values); + assert(link_values.command == PlayThis); + (vm->state).blockN = link_values.data1; + assert( (vm->state).blockN == 0 ); + vm->hop_channel++; + + fprintf(MSG_OUT, "libdvdnav: previous chapter done\n"); + + return 1; +} static domain_t menuid2domain(DVDMenuID_t menuid) { @@ -854,7 +945,11 @@ static int set_PGN(vm_t *vm) { assert(1 == ptt_srpt->title[(vm->state).VTS_TTN_REG - 1].ptt[0].pgn); #endif (vm->state).PTTN_REG = (vm->state).pgN; + } else { + /* FIXME: Handle RANDOM or SHUFFLE titles. */ + fprintf(MSG_OUT, "libdvdnav: RANDOM or SHUFFLE titles are NOT handled yet.\n"); } + } return 0; @@ -949,10 +1044,10 @@ static link_t play_PG(vm_t *vm) assert((vm->state).pgN > 0); if((vm->state).pgN > (vm->state).pgc->nr_of_programs) { #ifdef TRACE - fprintf(MSG_OUT, "libdvdnav: (vm->state).pgN (%i) == pgc->nr_of_programs + 1 (%i)\n", - (vm->state).pgN, (vm->state).pgc->nr_of_programs + 1); + fprintf(MSG_OUT, "libdvdnav: play_PG: (vm->state).pgN (%i) > pgc->nr_of_programs (%i)\n", + (vm->state).pgN, (vm->state).pgc->nr_of_programs ); #endif - /*assert((vm->state).pgN == (vm->state).pgc->nr_of_programs + 1);*/ + assert((vm->state).pgN == (vm->state).pgc->nr_of_programs + 1); return play_PGC_post(vm); } @@ -971,8 +1066,8 @@ static link_t play_Cell(vm_t *vm) assert((vm->state).cellN > 0); if((vm->state).cellN > (vm->state).pgc->nr_of_cells) { #ifdef TRACE - fprintf(MSG_OUT, "libdvdnav: (vm->state).cellN (%i) == pgc->nr_of_cells + 1 (%i)\n", - (vm->state).cellN, (vm->state).pgc->nr_of_cells + 1); + fprintf(MSG_OUT, "libdvdnav: (vm->state).cellN (%i) > pgc->nr_of_cells (%i)\n", + (vm->state).cellN, (vm->state).pgc->nr_of_cells ); #endif assert((vm->state).cellN == (vm->state).pgc->nr_of_cells + 1); return play_PGC_post(vm); @@ -1050,10 +1145,15 @@ static link_t play_Cell_post(vm_t *vm) if(cell->cell_cmd_nr != 0) { link_t link_values; -#ifdef STRICT - assert((vm->state).pgc->command_tbl != NULL); - assert((vm->state).pgc->command_tbl->nr_of_cell >= cell->cell_cmd_nr); -#endif +/* These asserts are now not needed. + * Some DVDs have no cell commands listed in the PGC, + * but the Cell itself points to a cell command that does not exist. + * For this situation, just ignore the cell command and continue. + * + * assert((vm->state).pgc->command_tbl != NULL); + * assert((vm->state).pgc->command_tbl->nr_of_cell >= cell->cell_cmd_nr); + */ + if ((vm->state).pgc->command_tbl != NULL && (vm->state).pgc->command_tbl->nr_of_cell >= cell->cell_cmd_nr) { #ifdef TRACE @@ -1068,6 +1168,7 @@ static link_t play_Cell_post(vm_t *vm) } } else { fprintf(MSG_OUT, "libdvdnav: Invalid Cell command\n"); + } } @@ -1125,7 +1226,8 @@ static link_t play_PGC_post(vm_t *vm) fprintf(MSG_OUT, "libdvdnav: play_PGC_post:\n"); #endif - assert((vm->state).pgc->still_time == 0); /* FIXME $$$ */ + /* FIXME Implement PGC Stills. Currently only Cell stills work */ + assert((vm->state).pgc->still_time == 0); /* eval -> updates the state and returns either - some kind of jump (Jump(TT/SS/VTS_TTN/CallSS/link C/PG/PGC/PTTN) @@ -1153,17 +1255,18 @@ static link_t process_command(vm_t *vm, link_t link_values) { /* FIXME $$$ Move this to a separate function? */ vm->badness_counter++; - if (vm->badness_counter > 1) fprintf(MSG_OUT, "libdvdnav: **** process_command re-entered %d*****\n",vm->badness_counter); + if (vm->badness_counter > 1) fprintf(MSG_OUT, "libdvdnav: **** WARNING: process_command re-entered %d*****\n",vm->badness_counter); while(link_values.command != PlayThis) { #ifdef TRACE + fprintf(MSG_OUT, "libdvdnav: Before printout starts:\n"); vmPrint_LINK(link_values); fprintf(MSG_OUT, "libdvdnav: Link values %i %i %i %i\n", link_values.command, link_values.data1, link_values.data2, link_values.data3); - fprintf(MSG_OUT, "libdvdnav: Before:"); vm_print_current_domain_state(vm); + fprintf(MSG_OUT, "libdvdnav: Before printout ends.\n"); #endif switch(link_values.command) { @@ -1381,7 +1484,7 @@ static link_t process_command(vm_t *vm, link_t link_values) assert((vm->state).domain == VTSM_DOMAIN || (vm->state).domain == VTS_DOMAIN); /* ?? */ if(set_VTS_PTT(vm,(vm->state).vtsN, link_values.data1, link_values.data2) == -1) assert(0); - link_values = play_PGC_PG(vm, link_values.data2); + link_values = play_PGC_PG( vm, (vm->state).pgN ); break; case JumpSS_FP: @@ -1495,8 +1598,9 @@ static link_t process_command(vm_t *vm, link_t link_values) } #ifdef TRACE - fprintf(MSG_OUT, "libdvdnav: After:"); + fprintf(MSG_OUT, "libdvdnav: After printout starts:\n"); vm_print_current_domain_state(vm); + fprintf(MSG_OUT, "libdvdnav: After printout ends.\n"); #endif } @@ -1558,8 +1662,10 @@ static int set_VTS_PTT(vm_t *vm, int vtsN, int /* is this really */ vts_ttn, int if(vtsN != (vm->state).vtsN) ifoOpenNewVTSI(vm, vm->dvd, vtsN); /* Also sets (vm->state).vtsN */ - assert(vts_ttn <= vm->vtsi->vts_ptt_srpt->nr_of_srpts); - assert(part <= vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].nr_of_ptts); + if ((vts_ttn < 1) || (vts_ttn > vm->vtsi->vts_ptt_srpt->nr_of_srpts) || + (part < 1) || (part > vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].nr_of_ptts) ) { + return S_ERR; + } pgcN = vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].ptt[part - 1].pgcn; pgN = vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].ptt[part - 1].pgn; @@ -1608,21 +1714,24 @@ static int get_ID(vm_t *vm, int id) pgcit = get_PGCIT(vm); assert(pgcit != NULL); fprintf(MSG_OUT, "libdvdnav: ** Searching for menu (0x%x) entry PGC\n", id); - + + /* Force high bit set. */ + id |=0x80; /* Get menu/title */ for(i = 0; i < pgcit->nr_of_pgci_srp; i++) { - if((pgcit->pgci_srp[i].entry_id & 0x7f) == id) { - assert((pgcit->pgci_srp[i].entry_id & 0x80) == 0x80); + if( (pgcit->pgci_srp[i].entry_id) == id) { pgcN = i + 1; + fprintf(MSG_OUT, "libdvdnav: Found menu.\n"); return pgcN; } } - fprintf(MSG_OUT, "libdvdnav: ** No such id/menu (%d) entry PGC\n", id); + fprintf(MSG_OUT, "libdvdnav: ** No such id/menu (0x%02x) entry PGC\n", id & 0x7f); for(i = 0; i < pgcit->nr_of_pgci_srp; i++) { - fprintf(MSG_OUT, "libdvdnav: Available menus: 0x%x\n", - pgcit->pgci_srp[i].entry_id); + if ( (pgcit->pgci_srp[i].entry_id & 0x80) == 0x80) { + fprintf(MSG_OUT, "libdvdnav: Available menus: 0x%x\n", + pgcit->pgci_srp[i].entry_id & 0x7f); + } } - assert(0); /* Use assert for now, until the error is handled. */ return -1; /* error */ } @@ -1639,7 +1748,6 @@ static int set_PGC(vm_t *vm, int pgcN) assert(pgcit != NULL); /* ?? Make this return -1 instead */ if(pgcN < 1 || pgcN > pgcit->nr_of_pgci_srp) { fprintf(MSG_OUT, "libdvdnav: ** No such pgcN = %d\n", pgcN); - assert(0); return -1; /* error */ } @@ -1669,7 +1777,7 @@ static int get_PGCN(vm_t *vm) } fprintf(MSG_OUT, "libdvdnav: get_PGCN failed. Trying to find pgcN in domain %d \n", (vm->state).domain); - assert(0); + /* assert(0);*/ return -1; /* error */ } @@ -1802,6 +1910,7 @@ static pgcit_t* get_PGCIT(vm_t *vm) { pgcit = get_MENU_PGCIT(vm, vm->vtsi, (vm->state).registers.SPRM[0]); break; case VMGM_DOMAIN: + case FP_DOMAIN: pgcit = get_MENU_PGCIT(vm, vm->vmgi, (vm->state).registers.SPRM[0]); break; default: @@ -1817,6 +1926,9 @@ static pgcit_t* get_PGCIT(vm_t *vm) { /* * $Log: vm.c,v $ + * Revision 1.5 2002/09/04 11:07:47 mroi + * sync to libdvdnav cvs + * * Revision 1.4 2002/08/27 19:24:33 mroi * sync to libdvdnav cvs, this should now conform to the way xine outputs * its console messages (write to stdout, "libdvdnav: " in front each line) diff --git a/src/input/libdvdnav/vm.h b/src/input/libdvdnav/vm.h index a4ba8fb83..99da87a73 100644 --- a/src/input/libdvdnav/vm.h +++ b/src/input/libdvdnav/vm.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: vm.h,v 1.1 2002/08/08 17:49:21 richwareham Exp $ + * $Id: vm.h,v 1.2 2002/09/04 11:07:47 mroi Exp $ * */ @@ -123,6 +123,7 @@ dvd_reader_t *vm_get_dvd_reader(vm_t *vm); /* Jumping */ int vm_start_title(vm_t *vm, int tt); int vm_jump_prog(vm_t *vm, int pr); +int vm_jump_title_part(vm_t *vm, int title, int part); /* Other calls */ int vm_reset(vm_t *vm, char *dvdroot); /* , register_t regs); */ @@ -144,6 +145,8 @@ int vm_get_subp_active_stream(vm_t *vm, int mode); void vm_get_angle_info(vm_t *vm, int *num_avail, int *current); void vm_get_audio_info(vm_t *vm, int *num_avail, int *current); void vm_get_subp_info(vm_t *vm, int *num_avail, int *current); +int vm_get_current_title_part(vm_t *vm, int *title_result, int *part_result); + subp_attr_t vm_get_subp_attr(vm_t *vm, int streamN); audio_attr_t vm_get_audio_attr(vm_t *vm, int streamN); void vm_get_video_res(vm_t *vm, int *width, int *height); -- cgit v1.2.3