changeset 7854:d6c29d863f15

dvd chapter detect function from Gregory Kovriga
author pontscho
date Tue, 22 Oct 2002 22:45:30 +0000
parents 974f7756c7e0
children fe88f7403d64
files libmpdemux/open.c libmpdemux/stream.h mplayer.c
diffstat 3 files changed, 31 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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;
--- 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
 							    
--- 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
       }