Mercurial > mplayer.hg
changeset 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 | 6b430d228c07 |
children | ab9824b6acc7 |
files | stream/stream_dvd.c |
diffstat | 1 files changed, 39 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/stream/stream_dvd.c Sun Aug 01 21:06:51 2010 +0000 +++ b/stream/stream_dvd.c Sun Aug 01 22:48:01 2010 +0000 @@ -93,7 +93,7 @@ dvd_chapter = 1; dvd_last_chapter = 0; if(*range && isdigit(*range)) { - dvd_chapter = strtol(range, &s, 10); + dvd_chapter = strtol(range, (char **) &s, 10); if(range == s) { mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_DVDinvalidChapterRange, range); return M_OPT_INVALID; @@ -488,6 +488,23 @@ return 1; } +static int get_num_chapter(ifo_handle_t *vts_file, tt_srpt_t *tt_srpt, int title_no) +{ + if(!vts_file || !tt_srpt) + return 0; + + if(title_no < 0 || title_no >= tt_srpt->nr_of_srpts) + return 0; + + // map global title to vts title + title_no = tt_srpt->title[title_no].vts_ttn - 1; + + if(title_no < 0 || title_no >= vts_file->vts_ptt_srpt->nr_of_srpts) + return 0; + + return vts_file->vts_ptt_srpt->title[title_no].nr_of_ptts; +} + static int seek_to_chapter(stream_t *stream, ifo_handle_t *vts_file, tt_srpt_t *tt_srpt, int title_no, int chapter) { int cell; @@ -522,27 +539,36 @@ return chapter; } -static void list_chapters(pgc_t *pgc) +static void list_chapters(ifo_handle_t *vts_file, tt_srpt_t *tt_srpt, int title_no) { - unsigned int i, cell; + unsigned int i, cell, last_cell; unsigned int t=0, t2=0; + ptt_info_t *ptt; + pgc_t *pgc; - if(pgc->nr_of_programs < 2) + title_no = tt_srpt->title[title_no].vts_ttn - 1; + if(vts_file->vts_ptt_srpt->title[title_no].nr_of_ptts < 2) return; + ptt = vts_file->vts_ptt_srpt->title[title_no].ptt; mp_msg(MSGT_IDENTIFY, MSGL_INFO, "CHAPTERS: "); - for(i=0; i<pgc->nr_of_programs; i++) + for(i=0; i<vts_file->vts_ptt_srpt->title[title_no].nr_of_ptts; i++) { - cell = pgc->program_map[i]; //here the cell is 1-based + pgc = vts_file->vts_pgcit->pgci_srp[ptt[i].pgcn-1].pgc; + cell = pgc->program_map[ptt[i].pgn-1]; //here the cell is 1-based + if(ptt[i].pgn<pgc->nr_of_programs) + last_cell = pgc->program_map[ptt[i].pgn]; + else + last_cell = 0; t2 = t/1000; mp_msg(MSGT_IDENTIFY, MSGL_INFO, "%02d:%02d:%02d,", t2/3600, (t2/60)%60, t2%60); - while(i+1<pgc->nr_of_programs && cell < pgc->program_map[i+1]) { + do { if(!(pgc->cell_playback[cell-1].block_type == BLOCK_TYPE_ANGLE_BLOCK && pgc->cell_playback[cell-1].block_mode != BLOCK_MODE_FIRST_CELL) ) t += mp_dvdtimetomsec(&pgc->cell_playback[cell-1].playback_time); cell++; - } + } while(cell < last_cell); } mp_msg(MSGT_IDENTIFY, MSGL_INFO, "\n"); } @@ -642,8 +668,10 @@ } case STREAM_CTRL_GET_NUM_CHAPTERS: { - if(! d->cur_pgc->nr_of_programs) return STREAM_UNSUPPORTED; - *((unsigned int *)arg) = d->cur_pgc->nr_of_programs; + int r; + r = get_num_chapter(d->vts_file, d->tt_srpt, d->cur_title-1); + if(! r) return STREAM_UNSUPPORTED; + *((unsigned int *)arg) = r; return 1; } case STREAM_CTRL_SEEK_TO_CHAPTER: @@ -991,7 +1019,7 @@ return STREAM_UNSUPPORTED; for(k=0; k<d->cur_pgc->nr_of_cells; k++) d->cell_times_table[k] = mp_dvdtimetomsec(&d->cur_pgc->cell_playback[k].playback_time); - list_chapters(d->cur_pgc); + list_chapters(vts_file,tt_srpt,dvd_title); // ... (unimplemented) // return NULL;