1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-18 04:45:33 +00:00

stream_dvd: fix incorrect assumption about chapter count

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

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31893 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
diego 2010-08-01 22:48:01 +00:00 committed by Uoti Urpala
parent 91565a3d77
commit fdb6ce15df

View File

@ -449,6 +449,23 @@ static int mp_describe_titleset(dvd_reader_t *dvd, tt_srpt_t *tt_srpt, int vts_n
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;
@ -483,27 +500,36 @@ static int seek_to_chapter(stream_t *stream, ifo_handle_t *vts_file, tt_srpt_t *
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");
}
@ -603,8 +629,10 @@ static int control(stream_t *stream,int cmd,void* arg)
}
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:
@ -952,7 +980,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
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;