changeset 4291:e889d37f25b2

Add option -last-chapter for DVD playing/encoding
author kmkaplan
date Mon, 21 Jan 2002 09:44:31 +0000
parents 1f8ceb12284d
children 1cee88ee8db5
files cfg-common.h libmpdemux/open.c libmpdemux/stream.h
diffstat 3 files changed, 23 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/cfg-common.h	Mon Jan 21 03:56:47 2002 +0000
+++ b/cfg-common.h	Mon Jan 21 09:44:31 2002 +0000
@@ -17,6 +17,7 @@
 	{"dvd", &dvd_title, CONF_TYPE_INT, CONF_RANGE, 1, 99, NULL},
 	{"dvdangle", &dvd_angle, CONF_TYPE_INT, CONF_RANGE, 1, 99, NULL},
 	{"chapter", &dvd_chapter, CONF_TYPE_INT, CONF_RANGE, 1, 99, NULL},
+	{"last-chapter", &dvd_last_chapter, CONF_TYPE_INT, CONF_RANGE, 1, 99, NULL},
 #else
 	{"dvd", "MPlayer was compiled WITHOUT libdvdread support!\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
 #endif
--- a/libmpdemux/open.c	Mon Jan 21 03:56:47 2002 +0000
+++ b/libmpdemux/open.c	Mon Jan 21 09:44:31 2002 +0000
@@ -24,6 +24,7 @@
 
 int dvd_title=0;
 int dvd_chapter=1;
+int dvd_last_chapter=0;
 int dvd_angle=1;
 char* dvd_device=NULL;
 char* cdrom_device=NULL;
@@ -162,7 +163,16 @@
         DVDClose( dvd );
         return NULL;
     }
+    if( dvd_last_chapter>0 ) {
+	if ( dvd_last_chapter<dvd_chapter || dvd_last_chapter>tt_srpt->title[dvd_title].nr_of_ptts ) {
+	    mp_msg(MSGT_OPEN,MSGL_ERR, "Invalid DVD last chapter number: %d\n", dvd_last_chapter);
+	    ifoClose( vmg_file );
+	    DVDClose( dvd );
+	    return NULL;
+	}
+    }
     --dvd_chapter; // remap 1.. -> 0..
+    /* XXX No need to remap dvd_last_chapter */
     /**
      * Make sure the angle number is valid for this title.
      */
@@ -315,6 +325,13 @@
     d->cur_cell = d->cur_pgc->program_map[pgn-1] - 1; // start playback here
     d->packs_left=-1;      // for Navi stuff
     d->angle_seek=0;
+    /* XXX dvd_last_chapter is in the range 1..nr_of_ptts */
+    if ( dvd_last_chapter > 0 && dvd_last_chapter < tt_srpt->title[ttn-1].nr_of_ptts ) {
+	pgn=vts_file->vts_ptt_srpt->title[ttn-1].ptt[dvd_last_chapter].pgn;
+	d->last_cell=d->cur_pgc->program_map[pgn-1] - 1;
+    }
+    else
+	d->last_cell=d->cur_pgc->nr_of_cells;
     
     if( d->cur_pgc->cell_playback[d->cur_cell].block_type 
 	== BLOCK_TYPE_ANGLE_BLOCK ) d->cur_cell+=dvd_angle;
@@ -450,7 +467,7 @@
     
     if( d->cur_pgc->cell_playback[ next_cell ].block_type
                                         == BLOCK_TYPE_ANGLE_BLOCK ) {
-	    while(next_cell<d->cur_pgc->nr_of_cells){
+	    while(next_cell<d->last_cell){
                 if( d->cur_pgc->cell_playback[next_cell].block_mode
                                           == BLOCK_MODE_LAST_CELL ) break;
 		++next_cell;
@@ -459,10 +476,10 @@
     mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next2=0x%X  \n",next_cell);
     
     ++next_cell;
-    if(next_cell>=d->cur_pgc->nr_of_cells) return -1; // EOF
+    if(next_cell>=d->last_cell) return -1; // EOF
     if( d->cur_pgc->cell_playback[next_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ){
 	next_cell+=dvd_angle;
-	if(next_cell>=d->cur_pgc->nr_of_cells) return -1; // EOF
+	if(next_cell>=d->last_cell) return -1; // EOF
     }
     mp_msg(MSGT_DVD,MSGL_V, "dvd_next_cell: next3=0x%X  \n",next_cell);
     return next_cell;
--- a/libmpdemux/stream.h	Mon Jan 21 03:56:47 2002 +0000
+++ b/libmpdemux/stream.h	Mon Jan 21 09:44:31 2002 +0000
@@ -182,6 +182,7 @@
 //#ifdef USE_DVDREAD
 extern int dvd_title;
 extern int dvd_chapter;
+extern int dvd_last_chapter;
 extern int dvd_angle;
 //#endif
 
@@ -207,6 +208,7 @@
   pgc_t *cur_pgc;
 //
   int cur_cell;
+  int last_cell;
   int cur_pack;
   int cell_last_pack;
 // Navi: