Mercurial > mplayer.hg
comparison stream/stream_dvd.c @ 31815:61517b367d31
Fix the incorrect assumption that the number of chapters of a DVD title
is equal to the number of cells.
patch by Olivier Rolland, billl users.sourceforge net
author | diego |
---|---|
date | Sun, 01 Aug 2010 22:48:01 +0000 |
parents | 74a6c2a3dcce |
children | ab9824b6acc7 |
comparison
equal
deleted
inserted
replaced
31814:6b430d228c07 | 31815:61517b367d31 |
---|---|
91 return M_OPT_MISSING_PARAM; | 91 return M_OPT_MISSING_PARAM; |
92 s = range; | 92 s = range; |
93 dvd_chapter = 1; | 93 dvd_chapter = 1; |
94 dvd_last_chapter = 0; | 94 dvd_last_chapter = 0; |
95 if(*range && isdigit(*range)) { | 95 if(*range && isdigit(*range)) { |
96 dvd_chapter = strtol(range, &s, 10); | 96 dvd_chapter = strtol(range, (char **) &s, 10); |
97 if(range == s) { | 97 if(range == s) { |
98 mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_DVDinvalidChapterRange, range); | 98 mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_DVDinvalidChapterRange, range); |
99 return M_OPT_INVALID; | 99 return M_OPT_INVALID; |
100 } | 100 } |
101 } | 101 } |
486 } | 486 } |
487 ifoClose(vts_file); | 487 ifoClose(vts_file); |
488 return 1; | 488 return 1; |
489 } | 489 } |
490 | 490 |
491 static int get_num_chapter(ifo_handle_t *vts_file, tt_srpt_t *tt_srpt, int title_no) | |
492 { | |
493 if(!vts_file || !tt_srpt) | |
494 return 0; | |
495 | |
496 if(title_no < 0 || title_no >= tt_srpt->nr_of_srpts) | |
497 return 0; | |
498 | |
499 // map global title to vts title | |
500 title_no = tt_srpt->title[title_no].vts_ttn - 1; | |
501 | |
502 if(title_no < 0 || title_no >= vts_file->vts_ptt_srpt->nr_of_srpts) | |
503 return 0; | |
504 | |
505 return vts_file->vts_ptt_srpt->title[title_no].nr_of_ptts; | |
506 } | |
507 | |
491 static int seek_to_chapter(stream_t *stream, ifo_handle_t *vts_file, tt_srpt_t *tt_srpt, int title_no, int chapter) | 508 static int seek_to_chapter(stream_t *stream, ifo_handle_t *vts_file, tt_srpt_t *tt_srpt, int title_no, int chapter) |
492 { | 509 { |
493 int cell; | 510 int cell; |
494 ptt_info_t ptt; | 511 ptt_info_t ptt; |
495 pgc_t *pgc; | 512 pgc_t *pgc; |
520 stream_seek(stream, pos); | 537 stream_seek(stream, pos); |
521 | 538 |
522 return chapter; | 539 return chapter; |
523 } | 540 } |
524 | 541 |
525 static void list_chapters(pgc_t *pgc) | 542 static void list_chapters(ifo_handle_t *vts_file, tt_srpt_t *tt_srpt, int title_no) |
526 { | 543 { |
527 unsigned int i, cell; | 544 unsigned int i, cell, last_cell; |
528 unsigned int t=0, t2=0; | 545 unsigned int t=0, t2=0; |
529 | 546 ptt_info_t *ptt; |
530 if(pgc->nr_of_programs < 2) | 547 pgc_t *pgc; |
548 | |
549 title_no = tt_srpt->title[title_no].vts_ttn - 1; | |
550 if(vts_file->vts_ptt_srpt->title[title_no].nr_of_ptts < 2) | |
531 return; | 551 return; |
552 ptt = vts_file->vts_ptt_srpt->title[title_no].ptt; | |
532 | 553 |
533 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "CHAPTERS: "); | 554 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "CHAPTERS: "); |
534 for(i=0; i<pgc->nr_of_programs; i++) | 555 for(i=0; i<vts_file->vts_ptt_srpt->title[title_no].nr_of_ptts; i++) |
535 { | 556 { |
536 cell = pgc->program_map[i]; //here the cell is 1-based | 557 pgc = vts_file->vts_pgcit->pgci_srp[ptt[i].pgcn-1].pgc; |
558 cell = pgc->program_map[ptt[i].pgn-1]; //here the cell is 1-based | |
559 if(ptt[i].pgn<pgc->nr_of_programs) | |
560 last_cell = pgc->program_map[ptt[i].pgn]; | |
561 else | |
562 last_cell = 0; | |
537 t2 = t/1000; | 563 t2 = t/1000; |
538 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "%02d:%02d:%02d,", t2/3600, (t2/60)%60, t2%60); | 564 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "%02d:%02d:%02d,", t2/3600, (t2/60)%60, t2%60); |
539 while(i+1<pgc->nr_of_programs && cell < pgc->program_map[i+1]) { | 565 do { |
540 if(!(pgc->cell_playback[cell-1].block_type == BLOCK_TYPE_ANGLE_BLOCK && | 566 if(!(pgc->cell_playback[cell-1].block_type == BLOCK_TYPE_ANGLE_BLOCK && |
541 pgc->cell_playback[cell-1].block_mode != BLOCK_MODE_FIRST_CELL) | 567 pgc->cell_playback[cell-1].block_mode != BLOCK_MODE_FIRST_CELL) |
542 ) | 568 ) |
543 t += mp_dvdtimetomsec(&pgc->cell_playback[cell-1].playback_time); | 569 t += mp_dvdtimetomsec(&pgc->cell_playback[cell-1].playback_time); |
544 cell++; | 570 cell++; |
545 } | 571 } while(cell < last_cell); |
546 } | 572 } |
547 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "\n"); | 573 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "\n"); |
548 } | 574 } |
549 | 575 |
550 static double dvd_get_current_time(stream_t *stream, int cell) | 576 static double dvd_get_current_time(stream_t *stream, int cell) |
640 *((double *)arg) = (double) mp_get_titleset_length(d->vts_file, d->tt_srpt, d->cur_title-1)/1000.0; | 666 *((double *)arg) = (double) mp_get_titleset_length(d->vts_file, d->tt_srpt, d->cur_title-1)/1000.0; |
641 return 1; | 667 return 1; |
642 } | 668 } |
643 case STREAM_CTRL_GET_NUM_CHAPTERS: | 669 case STREAM_CTRL_GET_NUM_CHAPTERS: |
644 { | 670 { |
645 if(! d->cur_pgc->nr_of_programs) return STREAM_UNSUPPORTED; | 671 int r; |
646 *((unsigned int *)arg) = d->cur_pgc->nr_of_programs; | 672 r = get_num_chapter(d->vts_file, d->tt_srpt, d->cur_title-1); |
673 if(! r) return STREAM_UNSUPPORTED; | |
674 *((unsigned int *)arg) = r; | |
647 return 1; | 675 return 1; |
648 } | 676 } |
649 case STREAM_CTRL_SEEK_TO_CHAPTER: | 677 case STREAM_CTRL_SEEK_TO_CHAPTER: |
650 { | 678 { |
651 int r; | 679 int r; |
989 d->cell_times_table = malloc(sizeof(unsigned int) * d->cur_pgc->nr_of_cells); | 1017 d->cell_times_table = malloc(sizeof(unsigned int) * d->cur_pgc->nr_of_cells); |
990 if(d->cell_times_table == NULL) | 1018 if(d->cell_times_table == NULL) |
991 return STREAM_UNSUPPORTED; | 1019 return STREAM_UNSUPPORTED; |
992 for(k=0; k<d->cur_pgc->nr_of_cells; k++) | 1020 for(k=0; k<d->cur_pgc->nr_of_cells; k++) |
993 d->cell_times_table[k] = mp_dvdtimetomsec(&d->cur_pgc->cell_playback[k].playback_time); | 1021 d->cell_times_table[k] = mp_dvdtimetomsec(&d->cur_pgc->cell_playback[k].playback_time); |
994 list_chapters(d->cur_pgc); | 1022 list_chapters(vts_file,tt_srpt,dvd_title); |
995 | 1023 |
996 // ... (unimplemented) | 1024 // ... (unimplemented) |
997 // return NULL; | 1025 // return NULL; |
998 stream->type = STREAMTYPE_DVD; | 1026 stream->type = STREAMTYPE_DVD; |
999 stream->sector_size = 2048; | 1027 stream->sector_size = 2048; |