# HG changeset patch # User pontscho # Date 1035326730 0 # Node ID d6c29d863f15f8410d60df146a7d8fa6c740772c # Parent 974f7756c7e0bee046901c4b4a42323689e7575e dvd chapter detect function from Gregory Kovriga diff -r 974f7756c7e0 -r d6c29d863f15 libmpdemux/open.c --- a/libmpdemux/open.c Tue Oct 22 22:31:19 2002 +0000 +++ b/libmpdemux/open.c Tue Oct 22 22:45:30 2002 +0000 @@ -564,6 +564,34 @@ } #ifdef USE_DVDREAD +int dvd_chapter_from_cell(dvd_priv_t* dvd,int title,int cell) +{ + pgc_t * cur_pgc; + ptt_info_t* ptt; + int chapter = cell; + int pgc_id,pgn; + if(title < 0 || cell < 0){ + return 0; + } + /* for most DVD's chapter == cell */ + /* but there are more complecated cases... */ + if(chapter >= dvd->vmg_file->tt_srpt->title[title].nr_of_ptts){ + chapter = dvd->vmg_file->tt_srpt->title[title].nr_of_ptts-1; + } + title = dvd->tt_srpt->title[title].vts_ttn-1; + ptt = dvd->vts_file->vts_ptt_srpt->title[title].ptt; + while(chapter >= 0){ + pgc_id = ptt[chapter].pgcn; + pgn = ptt[chapter].pgn; + cur_pgc = dvd->vts_file->vts_pgcit->pgci_srp[pgc_id-1].pgc; + if(cell >= cur_pgc->program_map[pgn-1]-1){ + return chapter; + } + --chapter; + } + /* didn't find a chapter ??? */ + return chapter; +} int dvd_aid_from_lang(stream_t *stream, unsigned char* lang){ dvd_priv_t *d=stream->priv; diff -r 974f7756c7e0 -r d6c29d863f15 libmpdemux/stream.h --- a/libmpdemux/stream.h Tue Oct 22 22:31:19 2002 +0000 +++ b/libmpdemux/stream.h Tue Oct 22 22:45:30 2002 +0000 @@ -258,6 +258,7 @@ int dvd_aid_from_lang(stream_t *stream, unsigned char* lang); int dvd_sid_from_lang(stream_t *stream, unsigned char* lang); +int dvd_chapter_from_cell(dvd_priv_t *dvd,int title,int cell); #endif diff -r 974f7756c7e0 -r d6c29d863f15 mplayer.c --- a/mplayer.c Tue Oct 22 22:31:19 2002 +0000 +++ b/mplayer.c Tue Oct 22 22:45:30 2002 +0000 @@ -2565,7 +2565,8 @@ if ( stream->type == STREAMTYPE_DVD ) { dvd_priv_t * dvdp = stream->priv; - guiIntfStruct.DVD.current_chapter=dvdp->cur_cell + 1; + /*guiIntfStruct.DVD.current_chapter=dvdp->cur_cell + 1;*/ + guiIntfStruct.DVD.current_chapter=dvd_chapter_from_cell(dvdp,guiIntfStruct.DVD.current_title-1, dvdp->cur_cell)+1; } #endif }