comparison vm.c @ 128:69e1755625a1 src

- do not rely on 1:1 mappings between PTTs and PGs - fix get_PGCN for cases where get_PGCIT returns NULL
author mroi
date Sat, 15 Mar 2003 20:21:44 +0000
parents e404d210ff91
children d09a81cf65ce
comparison
equal deleted inserted replaced
127:f2e86078a5dc 128:69e1755625a1
569 569
570 /* getting information */ 570 /* getting information */
571 571
572 int vm_get_current_title_part(vm_t *vm, int *title_result, int *part_result) { 572 int vm_get_current_title_part(vm_t *vm, int *title_result, int *part_result) {
573 vts_ptt_srpt_t *vts_ptt_srpt; 573 vts_ptt_srpt_t *vts_ptt_srpt;
574 int title = (vm->state).TTN_REG; 574 int title, part = 0, vts_ttn;
575 int part = (vm->state).PTTN_REG;
576 int vts_ttn = (vm->state).VTS_TTN_REG;
577 int found; 575 int found;
578 int16_t pgcN, pgN; 576 int16_t pgcN, pgN;
579 577
580 vts_ptt_srpt = vm->vtsi->vts_ptt_srpt; 578 vts_ptt_srpt = vm->vtsi->vts_ptt_srpt;
581 pgcN = get_PGCN(vm); 579 pgcN = get_PGCN(vm);
582 pgN = vm->state.pgN; 580 pgN = vm->state.pgN;
583 581
584 found = 0; 582 found = 0;
585 for (vts_ttn = 0; (vts_ttn < vts_ptt_srpt->nr_of_srpts) && !found; vts_ttn++) { 583 for (vts_ttn = 0; (vts_ttn < vts_ptt_srpt->nr_of_srpts) && !found; vts_ttn++) {
586 for (part = 0; (part < vts_ptt_srpt->title[vts_ttn].nr_of_ptts) && !found; part++) { 584 for (part = 0; (part < vts_ptt_srpt->title[vts_ttn].nr_of_ptts) && !found; part++) {
587 if ((vts_ptt_srpt->title[vts_ttn].ptt[part].pgcn == pgcN) && 585 if (vts_ptt_srpt->title[vts_ttn].ptt[part].pgcn == pgcN) {
588 (vts_ptt_srpt->title[vts_ttn].ptt[part].pgn == pgN )) { 586 if (vts_ptt_srpt->title[vts_ttn].ptt[part].pgn == pgN) {
589 found = 1; 587 found = 1;
590 break; 588 break;
589 }
590 if (part > 0 && vts_ptt_srpt->title[vts_ttn].ptt[part].pgn > pgN &&
591 vts_ptt_srpt->title[vts_ttn].ptt[part - 1].pgn < pgN) {
592 part--;
593 found = 1;
594 break;
595 }
591 } 596 }
592 } 597 }
593 if (found) break; 598 if (found) break;
594 } 599 }
595 vts_ttn++; 600 vts_ttn++;
596 part++; 601 part++;
597 602
603 if (!found) {
604 fprintf(MSG_OUT, "libdvdnav: chapter NOT FOUND!\n");
605 return 0;
606 }
607
598 title = get_TT(vm, vm->state.vtsN, vts_ttn); 608 title = get_TT(vm, vm->state.vtsN, vts_ttn);
599 609
600 #ifdef TRACE 610 #ifdef TRACE
601 if (title) { 611 if (title) {
602 fprintf(MSG_OUT, "libdvdnav: ************ this chapter FOUND!\n"); 612 fprintf(MSG_OUT, "libdvdnav: ************ this chapter FOUND!\n");
603 fprintf(MSG_OUT, "libdvdnav: VTS_PTT_SRPT - Title %3i part %3i: PGC: %3i PG: %3i\n", 613 fprintf(MSG_OUT, "libdvdnav: VTS_PTT_SRPT - Title %3i part %3i: PGC: %3i PG: %3i\n",
604 title, part, 614 title, part,
605 vts_ptt_srpt->title[vts_ttn-1].ptt[part-1].pgcn , 615 vts_ptt_srpt->title[vts_ttn-1].ptt[part-1].pgcn ,
606 vts_ptt_srpt->title[vts_ttn-1].ptt[part-1].pgn ); 616 vts_ptt_srpt->title[vts_ttn-1].ptt[part-1].pgn );
607 } else { 617 }
608 fprintf(MSG_OUT, "libdvdnav: ************ this chapter NOT FOUND!\n"); 618 #endif
609 }
610 #endif
611 if (!title)
612 return 0;
613 *title_result = title; 619 *title_result = title;
614 *part_result = part; 620 *part_result = part;
615 return 1; 621 return 1;
616 } 622 }
617 623
618 /* Return the substream id for 'logical' audio stream audioN. 624 /* Return the substream id for 'logical' audio stream audioN.
619 * 0 <= audioN < 8 625 * 0 <= audioN < 8
620 */ 626 */
621 int vm_get_audio_stream(vm_t *vm, int audioN) { 627 int vm_get_audio_stream(vm_t *vm, int audioN) {
622 int streamN = -1; 628 int streamN = -1;
623
624 #ifdef TRACE
625 fprintf(MSG_OUT, "libdvdnav: vm.c:get_audio_stream audioN=%d\n",audioN);
626 #endif
627 629
628 if((vm->state).domain != VTS_DOMAIN) 630 if((vm->state).domain != VTS_DOMAIN)
629 audioN = 0; 631 audioN = 0;
630 632
631 if(audioN < 8) { 633 if(audioN < 8) {
956 /* eval -> updates the state and returns either 958 /* eval -> updates the state and returns either
957 - some kind of jump (Jump(TT/SS/VTS_TTN/CallSS/link C/PG/PGC/PTTN) 959 - some kind of jump (Jump(TT/SS/VTS_TTN/CallSS/link C/PG/PGC/PTTN)
958 - just go to next PGC 960 - just go to next PGC
959 (This is what happens if you fall of the end of the post_cmds) 961 (This is what happens if you fall of the end of the post_cmds)
960 - or an error (are there more cases?) */ 962 - or an error (are there more cases?) */
961 if((vm->state).pgc->command_tbl && 963 if((vm->state).pgc->command_tbl && (vm->state).pgc->command_tbl->nr_of_post &&
962 vmEval_CMD((vm->state).pgc->command_tbl->post_cmds, 964 vmEval_CMD((vm->state).pgc->command_tbl->post_cmds,
963 (vm->state).pgc->command_tbl->nr_of_post, 965 (vm->state).pgc->command_tbl->nr_of_post,
964 &(vm->state).registers, &link_values)) { 966 &(vm->state).registers, &link_values)) {
965 return link_values; 967 return link_values;
966 } 968 }
1702 static int get_PGCN(vm_t *vm) { 1704 static int get_PGCN(vm_t *vm) {
1703 pgcit_t *pgcit; 1705 pgcit_t *pgcit;
1704 int pgcN = 1; 1706 int pgcN = 1;
1705 1707
1706 pgcit = get_PGCIT(vm); 1708 pgcit = get_PGCIT(vm);
1707 assert(pgcit != NULL); 1709
1708 1710 if (pgcit) {
1709 while(pgcN <= pgcit->nr_of_pgci_srp) { 1711 while(pgcN <= pgcit->nr_of_pgci_srp) {
1710 if(pgcit->pgci_srp[pgcN - 1].pgc == (vm->state).pgc) 1712 if(pgcit->pgci_srp[pgcN - 1].pgc == (vm->state).pgc)
1711 return pgcN; 1713 return pgcN;
1712 pgcN++; 1714 pgcN++;
1715 }
1713 } 1716 }
1714 fprintf(MSG_OUT, "libdvdnav: get_PGCN failed. Was trying to find pgcN in domain %d\n", 1717 fprintf(MSG_OUT, "libdvdnav: get_PGCN failed. Was trying to find pgcN in domain %d\n",
1715 (vm->state).domain); 1718 (vm->state).domain);
1716 /* assert(0);*/
1717 return 0; /* error */ 1719 return 0; /* error */
1718 } 1720 }
1719 1721
1720 static pgcit_t* get_MENU_PGCIT(vm_t *vm, ifo_handle_t *h, uint16_t lang) { 1722 static pgcit_t* get_MENU_PGCIT(vm_t *vm, ifo_handle_t *h, uint16_t lang) {
1721 int i; 1723 int i;
1795 #endif 1797 #endif
1796 1798
1797 1799
1798 /* 1800 /*
1799 * $Log$ 1801 * $Log$
1802 * Revision 1.46 2003/03/15 20:21:44 mroi
1803 * - do not rely on 1:1 mappings between PTTs and PGs
1804 * - fix get_PGCN for cases where get_PGCIT returns NULL
1805 *
1800 * Revision 1.45 2003/03/14 18:47:51 mroi 1806 * Revision 1.45 2003/03/14 18:47:51 mroi
1801 * - fix vm copying when the vtsN has not yet been set 1807 * - fix vm copying when the vtsN has not yet been set
1802 * - change still detection heuristics 1808 * - change still detection heuristics
1803 * - small TRACE output beautification 1809 * - small TRACE output beautification
1804 * - fix handling of PTT register 1810 * - fix handling of PTT register