diff vm/vm.c @ 388:90ca650854e0 src

Remove all trailing whitespace, patch by Erik Hovland *erik$hovland dot org%
author rathann
date Sat, 06 Sep 2008 21:55:51 +0000
parents 579a3538d284
children d3c273ced49c
line wrap: on
line diff
--- a/vm/vm.c	Sun Aug 31 18:13:23 2008 +0000
+++ b/vm/vm.c	Sat Sep 06 21:55:51 2008 +0000
@@ -2,20 +2,20 @@
  * Copyright (C) 2000, 2001 Håkan Hjort
  * Copyright (C) 2001 Rich Wareham <richwareham@users.sourceforge.net>
  *               2002-2004 the dvdnav project
- * 
+ *
  * This file is part of libdvdnav, a DVD navigation library. It is modified
  * from a file originally part of the Ogle DVD player.
- * 
+ *
  * libdvdnav is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * libdvdnav is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
@@ -114,7 +114,7 @@
       fprintf(MSG_OUT, "libdvdnav: Video Manager Menu Domain: -\n");
       break;
 
-    case FP_DOMAIN: 
+    case FP_DOMAIN:
       fprintf(MSG_OUT, "libdvdnav: First Play Domain: -\n");
       break;
 
@@ -122,7 +122,7 @@
       fprintf(MSG_OUT, "libdvdnav: Unknown Domain: -\n");
       break;
   }
-  fprintf(MSG_OUT, "libdvdnav: VTS:%d PGC:%d PG:%u CELL:%u BLOCK:%u VTS_TTN:%u TTN:%u TT_PGCN:%u\n", 
+  fprintf(MSG_OUT, "libdvdnav: VTS:%d PGC:%d PG:%u CELL:%u BLOCK:%u VTS_TTN:%u TTN:%u TT_PGCN:%u\n",
                    (vm->state).vtsN,
                    get_PGCN(vm),
                    (vm->state).pgN,
@@ -144,10 +144,10 @@
 
     /* Read DVD name */
     fd = open(device, O_RDONLY);
-    if (fd > 0) { 
+    if (fd > 0) {
       off = lseek( fd, 32 * (off_t) DVD_VIDEO_LB_LEN, SEEK_SET );
       if( off == ( 32 * (off_t) DVD_VIDEO_LB_LEN ) ) {
-        off = read( fd, data, DVD_VIDEO_LB_LEN ); 
+        off = read( fd, data, DVD_VIDEO_LB_LEN );
         close(fd);
         if (off == ( (off_t) DVD_VIDEO_LB_LEN )) {
           fprintf(MSG_OUT, "libdvdnav: DVD Title: ");
@@ -168,7 +168,7 @@
               fprintf(MSG_OUT, "%c", data[i]);
             } else {
               fprintf(MSG_OUT, " ");
-            } 
+            }
           }
           fprintf(MSG_OUT, "\nlibdvdnav: DVD Title (Alternative): ");
           for(i=89; i < 128; i++ ) {
@@ -196,10 +196,10 @@
   if((vm->state).vtsN == vtsN) {
     return 1; /*  We alread have it */
   }
-  
+
   if(vm->vtsi != NULL)
     ifoClose(vm->vtsi);
-  
+
   vm->vtsi = ifoOpenVTSI(dvd, vtsN);
   if(vm->vtsi == NULL) {
     fprintf(MSG_OUT, "libdvdnav: ifoOpenVTSI failed\n");
@@ -226,7 +226,7 @@
     return 0;
   }
   (vm->state).vtsN = vtsN;
-  
+
   return 1;
 }
 
@@ -285,7 +285,7 @@
   }
   vm->stopped = 1;
 }
- 
+
 int vm_reset(vm_t *vm, const char *dvdroot) {
   /*  Setup State */
   memset((vm->state).registers.SPRM, 0, sizeof((vm->state).registers.SPRM));
@@ -308,7 +308,7 @@
   (vm->state).registers.SPRM[18] = ('e'<<8)|'n'; /* Initial Language Code for Spu */
   (vm->state).registers.SPRM[20] = 0x1;          /* Player Regional Code Mask. Region free! */
   (vm->state).registers.SPRM[14] = 0x100;        /* Try Pan&Scan */
-   
+
   (vm->state).pgN                = 0;
   (vm->state).cellN              = 0;
   (vm->state).cell_restart       = 0;
@@ -317,9 +317,9 @@
   (vm->state).rsm_vtsN           = 0;
   (vm->state).rsm_cellN          = 0;
   (vm->state).rsm_blockN         = 0;
-  
+
   (vm->state).vtsN               = -1;
-  
+
   if (vm->dvd && dvdroot) {
     /* a new dvd device has been requested */
     vm_stop(vm);
@@ -383,11 +383,11 @@
   int vtsN;
   int pgcN = get_PGCN(source);
   int pgN  = (source->state).pgN;
-  
+
   assert(pgcN);
-  
+
   memcpy(target, source, sizeof(vm_t));
-  
+
   /* open a new vtsi handle, because the copy might switch to another VTS */
   target->vtsi = NULL;
   vtsN = (target->state).vtsN;
@@ -395,13 +395,13 @@
     (target->state).vtsN = 0;
     if (!ifoOpenNewVTSI(target, target->dvd, vtsN))
       assert(0);
-  
+
     /* restore pgc pointer into the new vtsi */
     if (!set_PGCN(target, pgcN))
       assert(0);
     (target->state).pgN = pgN;
   }
-  
+
   return target;
 }
 
@@ -423,8 +423,8 @@
 
 void vm_position_get(vm_t *vm, vm_position_t *position) {
   position->button = (vm->state).HL_BTNN_REG >> 10;
-  position->vts = (vm->state).vtsN; 
-  position->domain = (vm->state).domain; 
+  position->vts = (vm->state).vtsN;
+  position->domain = (vm->state).domain;
   position->spu_channel = (vm->state).SPST_REG;
   position->audio_channel = (vm->state).AST_REG;
   position->angle_channel = (vm->state).AGL_REG;
@@ -494,7 +494,7 @@
 
 int vm_jump_title_part(vm_t *vm, int title, int part) {
   link_t link;
-  
+
   if(!set_PTT(vm, title, part))
     return 0;
   /* Some DVDs do not want us to jump directly into a title and have
@@ -551,7 +551,7 @@
 
 int vm_jump_menu(vm_t *vm, DVDMenuID_t menuid) {
   domain_t old_domain = (vm->state).domain;
-  
+
   switch ((vm->state).domain) {
   case VTS_DOMAIN:
     set_RSMinfo(vm, 0, (vm->state).blockN);
@@ -581,7 +581,7 @@
   case FP_DOMAIN: /* FIXME XXX $$$ What should we do here? */
     break;
   }
-  
+
   return 0;
 }
 
@@ -597,7 +597,7 @@
 
 int vm_exec_cmd(vm_t *vm, vm_cmd_t *cmd) {
   link_t link_values;
-  
+
   if(vmEval_CMD(cmd, 1, &(vm->state).registers, &link_values))
     return process_command(vm, link_values);
   else
@@ -647,7 +647,7 @@
   }
   vts_ttn++;
   part++;
-  
+
   if (!found) {
     fprintf(MSG_OUT, "libdvdnav: chapter NOT FOUND!\n");
     return 0;
@@ -677,17 +677,17 @@
 
   if((vm->state).domain != VTS_DOMAIN)
     audioN = 0;
-  
+
   if(audioN < 8) {
-    /* Is there any control info for this logical stream */ 
+    /* Is there any control info for this logical stream */
     if((vm->state).pgc->audio_control[audioN] & (1<<15)) {
-      streamN = ((vm->state).pgc->audio_control[audioN] >> 8) & 0x07;  
+      streamN = ((vm->state).pgc->audio_control[audioN] >> 8) & 0x07;
     }
   }
-  
+
   if((vm->state).domain != VTS_DOMAIN && streamN == -1)
     streamN = 0;
-  
+
   /* FIXME: Should also check in vtsi/vmgi status what kind of stream
    * it is (ac3/lpcm/dts/sdds...) to find the right (sub)stream id */
   return streamN;
@@ -702,15 +702,15 @@
 int vm_get_subp_stream(vm_t *vm, int subpN, int mode) {
   int streamN = -1;
   int source_aspect = vm_get_video_aspect(vm);
-  
+
   if((vm->state).domain != VTS_DOMAIN)
     subpN = 0;
-  
+
   if(subpN < 32) { /* a valid logical stream */
-    /* Is this logical stream present */ 
+    /* Is this logical stream present */
     if((vm->state).pgc->subp_control[subpN] & (1<<31)) {
-      if(source_aspect == 0) /* 4:3 */	     
-	streamN = ((vm->state).pgc->subp_control[subpN] >> 24) & 0x1f;  
+      if(source_aspect == 0) /* 4:3 */
+	streamN = ((vm->state).pgc->subp_control[subpN] >> 24) & 0x1f;
       if(source_aspect == 3) /* 16:9 */
         switch (mode) {
 	case 0:
@@ -724,7 +724,7 @@
 	}
     }
   }
-  
+
   if((vm->state).domain != VTS_DOMAIN && streamN == -1)
     streamN = 0;
 
@@ -737,7 +737,7 @@
   int streamN;
   audioN = (vm->state).AST_REG ;
   streamN = vm_get_audio_stream(vm, audioN);
-  
+
   /* If no such stream, then select the first one that exists. */
   if(streamN == -1) {
     for(audioN = 0; audioN < 8; audioN++) {
@@ -756,7 +756,7 @@
   int streamN;
   subpN = (vm->state).SPST_REG & ~0x40;
   streamN = vm_get_subp_stream(vm, subpN, mode);
-  
+
   /* If no such stream, then select the first one that exists. */
   if(streamN == -1) {
     for(subpN = 0; subpN < 32; subpN++) {
@@ -777,16 +777,16 @@
 void vm_get_angle_info(vm_t *vm, int *current, int *num_avail) {
   *num_avail = 1;
   *current = 1;
-  
+
   if((vm->state).domain == VTS_DOMAIN) {
     title_info_t *title;
     /* TTN_REG does not allways point to the correct title.. */
     if((vm->state).TTN_REG > vm->vmgi->tt_srpt->nr_of_srpts)
       return;
     title = &vm->vmgi->tt_srpt->title[(vm->state).TTN_REG - 1];
-    if(title->title_set_nr != (vm->state).vtsN || 
+    if(title->title_set_nr != (vm->state).vtsN ||
        title->vts_ttn != (vm->state).VTS_TTN_REG)
-      return; 
+      return;
     *num_avail = title->nr_of_angles;
     *current = (vm->state).AGL_REG;
   }
@@ -834,8 +834,8 @@
 /* currently unused */
 void vm_get_video_res(vm_t *vm, int *width, int *height) {
   video_attr_t attr = vm_get_video_attr(vm);
-  
-  if(attr.video_format != 0) 
+
+  if(attr.video_format != 0)
     *height = 576;
   else
     *height = 480;
@@ -859,11 +859,11 @@
 
 int vm_get_video_aspect(vm_t *vm) {
   int aspect = vm_get_video_attr(vm).display_aspect_ratio;
-  
+
   assert(aspect == 0 || aspect == 3);
   (vm->state).registers.SPRM[14] &= ~(0x3 << 10);
   (vm->state).registers.SPRM[14] |= aspect << 10;
-  
+
   return aspect;
 }
 
@@ -918,7 +918,7 @@
 
 static link_t play_PGC(vm_t *vm) {
   link_t link_values;
-  
+
 #ifdef TRACE
   fprintf(MSG_OUT, "libdvdnav: play_PGC:");
   if((vm->state).domain != FP_DOMAIN) {
@@ -936,14 +936,14 @@
   (vm->state).cellN = 0;
   (vm->state).blockN = 0;
 
-  /* eval -> updates the state and returns either 
+  /* eval -> updates the state and returns either
      - some kind of jump (Jump(TT/SS/VTS_TTN/CallSS/link C/PG/PGC/PTTN)
      - just play video i.e first PG
        (This is what happens if you fall of the end of the pre_cmds)
      - or an error (are there more cases?) */
   if((vm->state).pgc->command_tbl && (vm->state).pgc->command_tbl->nr_of_pre) {
-    if(vmEval_CMD((vm->state).pgc->command_tbl->pre_cmds, 
-		  (vm->state).pgc->command_tbl->nr_of_pre, 
+    if(vmEval_CMD((vm->state).pgc->command_tbl->pre_cmds,
+		  (vm->state).pgc->command_tbl->nr_of_pre,
 		  &(vm->state).registers, &link_values)) {
       /*  link_values contains the 'jump' return value */
       return link_values;
@@ -954,11 +954,11 @@
     }
   }
   return play_PG(vm);
-}  
+}
 
-static link_t play_PGC_PG(vm_t *vm, int pgN) {    
+static link_t play_PGC_PG(vm_t *vm, int pgN) {
   link_t link_values;
-  
+
 #ifdef TRACE
   fprintf(MSG_OUT, "libdvdnav: play_PGC_PG:");
   if((vm->state).domain != FP_DOMAIN) {
@@ -976,14 +976,14 @@
   (vm->state).cellN = 0;
   (vm->state).blockN = 0;
 
-  /* eval -> updates the state and returns either 
+  /* eval -> updates the state and returns either
      - some kind of jump (Jump(TT/SS/VTS_TTN/CallSS/link C/PG/PGC/PTTN)
      - just play video i.e first PG
        (This is what happens if you fall of the end of the pre_cmds)
      - or an error (are there more cases?) */
   if((vm->state).pgc->command_tbl && (vm->state).pgc->command_tbl->nr_of_pre) {
-    if(vmEval_CMD((vm->state).pgc->command_tbl->pre_cmds, 
-		  (vm->state).pgc->command_tbl->nr_of_pre, 
+    if(vmEval_CMD((vm->state).pgc->command_tbl->pre_cmds,
+		  (vm->state).pgc->command_tbl->nr_of_pre,
 		  &(vm->state).registers, &link_values)) {
       /*  link_values contains the 'jump' return value */
       return link_values;
@@ -994,7 +994,7 @@
     }
   }
   return play_PG(vm);
-}  
+}
 
 static link_t play_PGC_post(vm_t *vm) {
   link_t link_values;
@@ -1002,19 +1002,19 @@
 #ifdef TRACE
   fprintf(MSG_OUT, "libdvdnav: play_PGC_post:\n");
 #endif
-  
-  /* eval -> updates the state and returns either 
+
+  /* eval -> updates the state and returns either
      - some kind of jump (Jump(TT/SS/VTS_TTN/CallSS/link C/PG/PGC/PTTN)
      - just go to next PGC
        (This is what happens if you fall of the end of the post_cmds)
      - or an error (are there more cases?) */
   if((vm->state).pgc->command_tbl && (vm->state).pgc->command_tbl->nr_of_post &&
      vmEval_CMD((vm->state).pgc->command_tbl->post_cmds,
-		(vm->state).pgc->command_tbl->nr_of_post, 
+		(vm->state).pgc->command_tbl->nr_of_post,
 		&(vm->state).registers, &link_values)) {
     return link_values;
   }
-  
+
 #ifdef TRACE
   fprintf(MSG_OUT, "libdvdnav: ** Fell of the end of the pgc, continuing in NextPGC\n");
 #endif
@@ -1030,19 +1030,19 @@
 #ifdef TRACE
   fprintf(MSG_OUT, "libdvdnav: play_PG: (vm->state).pgN (%i)\n", (vm->state).pgN);
 #endif
-  
+
   assert((vm->state).pgN > 0);
   if((vm->state).pgN > (vm->state).pgc->nr_of_programs) {
 #ifdef TRACE
-    fprintf(MSG_OUT, "libdvdnav: play_PG: (vm->state).pgN (%i) > pgc->nr_of_programs (%i)\n", 
+    fprintf(MSG_OUT, "libdvdnav: play_PG: (vm->state).pgN (%i) > pgc->nr_of_programs (%i)\n",
 	    (vm->state).pgN, (vm->state).pgc->nr_of_programs );
 #endif
-    assert((vm->state).pgN == (vm->state).pgc->nr_of_programs + 1); 
+    assert((vm->state).pgN == (vm->state).pgc->nr_of_programs + 1);
     return play_PGC_post(vm);
   }
-  
+
   (vm->state).cellN = (vm->state).pgc->program_map[(vm->state).pgN - 1];
-  
+
   return play_Cell(vm);
 }
 
@@ -1052,17 +1052,17 @@
 #ifdef TRACE
   fprintf(MSG_OUT, "libdvdnav: play_Cell: (vm->state).cellN (%i)\n", (vm->state).cellN);
 #endif
-  
+
   assert((vm->state).cellN > 0);
   if((vm->state).cellN > (vm->state).pgc->nr_of_cells) {
 #ifdef TRACE
-    fprintf(MSG_OUT, "libdvdnav: (vm->state).cellN (%i) > pgc->nr_of_cells (%i)\n", 
+    fprintf(MSG_OUT, "libdvdnav: (vm->state).cellN (%i) > pgc->nr_of_cells (%i)\n",
 	    (vm->state).cellN, (vm->state).pgc->nr_of_cells );
 #endif
-    assert((vm->state).cellN == (vm->state).pgc->nr_of_cells + 1); 
+    assert((vm->state).cellN == (vm->state).pgc->nr_of_cells + 1);
     return play_PGC_post(vm);
   }
-  
+
   /* Multi angle/Interleaved */
   switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode) {
   case 0: /*  Normal */
@@ -1104,7 +1104,7 @@
   default:
     fprintf(MSG_OUT, "libdvdnav: Cell is in block but did not enter at first cell!\n");
   }
-  
+
   /* Updates (vm->state).pgN and PTTN_REG */
   if(!set_PGN(vm)) {
     /* Should not happen */
@@ -1121,19 +1121,19 @@
 
 static link_t play_Cell_post(vm_t *vm) {
   cell_playback_t *cell;
-  
+
 #ifdef TRACE
   fprintf(MSG_OUT, "libdvdnav: play_Cell_post: (vm->state).cellN (%i)\n", (vm->state).cellN);
 #endif
-  
+
   cell = &(vm->state).pgc->cell_playback[(vm->state).cellN - 1];
-  
+
   /* Still time is already taken care of before we get called. */
-  
+
   /* Deal with a Cell command, if any */
   if(cell->cell_cmd_nr != 0) {
     link_t link_values;
-    
+
 /*  These asserts are now not needed.
  *  Some DVDs have no cell commands listed in the PGC,
  *  but the Cell itself points to a cell command that does not exist.
@@ -1162,7 +1162,7 @@
 #endif
     }
   }
-  
+
   /* Where to continue after playing the cell... */
   /* Multi angle/Interleaved */
   switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode) {
@@ -1196,8 +1196,8 @@
     }
     break;
   }
-  
-  /* Figure out the correct pgN for the new cell */ 
+
+  /* Figure out the correct pgN for the new cell */
   if(!set_PGN(vm)) {
 #ifdef TRACE
     fprintf(MSG_OUT, "libdvdnav: last cell in this PGC\n");
@@ -1211,18 +1211,18 @@
 /* link processing */
 
 static int process_command(vm_t *vm, link_t link_values) {
-  
+
   while(link_values.command != PlayThis) {
-    
+
 #ifdef TRACE
     fprintf(MSG_OUT, "libdvdnav: Before printout starts:\n");
     vm_print_link(link_values);
-    fprintf(MSG_OUT, "libdvdnav: Link values %i %i %i %i\n", link_values.command, 
+    fprintf(MSG_OUT, "libdvdnav: Link values %i %i %i %i\n", link_values.command,
 	    link_values.data1, link_values.data2, link_values.data3);
     vm_print_current_domain_state(vm);
     fprintf(MSG_OUT, "libdvdnav: Before printout ends.\n");
 #endif
-    
+
     switch(link_values.command) {
     case LinkNoLink:
       /* BUTTON number:data1 */
@@ -1254,7 +1254,7 @@
       (vm->state).cellN -= 1;
       link_values = play_Cell(vm);
       break;
-      
+
     case LinkTopPG:
       /* Link to Top of current Program */
       /* BUTTON number:data1 */
@@ -1332,34 +1332,34 @@
       {
 	/* Link to Resume point */
 	int i;
-	
+
 	/* Check and see if there is any rsm info!! */
 	if (!(vm->state).rsm_vtsN) {
 	  fprintf(MSG_OUT, "libdvdnav: trying to resume without any resume info set\n");
 	  link_values.command = Exit;
 	  break;
 	}
-	
+
 	(vm->state).domain = VTS_DOMAIN;
 	if (!ifoOpenNewVTSI(vm, vm->dvd, (vm->state).rsm_vtsN))
 	  assert(0);
 	set_PGCN(vm, (vm->state).rsm_pgcN);
-	
-	/* These should never be set in SystemSpace and/or MenuSpace */ 
+
+	/* These should never be set in SystemSpace and/or MenuSpace */
 	/* (vm->state).TTN_REG = rsm_tt; ?? */
 	/* (vm->state).TT_PGCN_REG = (vm->state).rsm_pgcN; ?? */
 	for(i = 0; i < 5; i++) {
 	  (vm->state).registers.SPRM[4 + i] = (vm->state).rsm_regs[i];
 	}
-	
+
 	if(link_values.data1 != 0)
 	  (vm->state).HL_BTNN_REG = link_values.data1 << 10;
-	
+
 	if((vm->state).rsm_cellN == 0) {
 	  assert((vm->state).cellN); /*  Checking if this ever happens */
 	  (vm->state).pgN = 1;
 	  link_values = play_PG(vm);
-	} else { 
+	} else {
 	  /* (vm->state).pgN = ?? this gets the right value in set_PGN() below */
 	  (vm->state).cellN = (vm->state).rsm_cellN;
 	  link_values.command = PlayThis;
@@ -1409,11 +1409,11 @@
       (vm->state).cellN = link_values.data1;
       link_values = play_Cell(vm);
       break;
-      
+
     case Exit:
       vm->stopped = 1;
       return 0;
-      
+
     case JumpTT:
       /* Jump to VTS Title Domain */
       /* Only allowed from the First Play domain(PGC) */
@@ -1448,7 +1448,7 @@
 	assert(0);
       link_values = play_PGC_PG(vm, (vm->state).pgN);
       break;
-      
+
     case JumpSS_FP:
       /* Jump to First Play Domain */
       /* Only allowed from the VTS Menu Domain(VTSM) */
@@ -1475,7 +1475,7 @@
       /* Stop SPRM9 Timer and any GPRM counters */
       /* ifoOpenNewVTSI:data1 */
       /* VTS_TTN_REG:data2 */
-      /* get_MENU:data3 */ 
+      /* get_MENU:data3 */
       if(link_values.data1 != 0) {
 	if (link_values.data1 != (vm->state).vtsN) {
 	  /* the normal case */
@@ -1514,7 +1514,7 @@
 	assert(0);
       link_values = play_PGC(vm);
       break;
-      
+
     case CallSS_FP:
       /* set_RSMinfo:data1 */
       assert((vm->state).domain == VTS_DOMAIN); /* ?? */
@@ -1524,18 +1524,18 @@
       link_values = play_PGC(vm);
       break;
     case CallSS_VMGM_MENU:
-      /* set_MENU:data1 */ 
+      /* set_MENU:data1 */
       /* set_RSMinfo:data2 */
       assert((vm->state).domain == VTS_DOMAIN); /* ?? */
       /* Must be called before domain is changed */
-      set_RSMinfo(vm, link_values.data2, /* We dont have block info */ 0);      
+      set_RSMinfo(vm, link_values.data2, /* We dont have block info */ 0);
       (vm->state).domain = VMGM_DOMAIN;
       if(!set_MENU(vm, link_values.data1))
 	assert(0);
       link_values = play_PGC(vm);
       break;
     case CallSS_VTSM:
-      /* set_MENU:data1 */ 
+      /* set_MENU:data1 */
       /* set_RSMinfo:data2 */
       assert((vm->state).domain == VTS_DOMAIN); /* ?? */
       /* Must be called before domain is changed */
@@ -1567,7 +1567,7 @@
     vm_print_current_domain_state(vm);
     fprintf(MSG_OUT, "libdvdnav: After printout ends.\n");
 #endif
-    
+
   }
   (vm->state).blockN = link_values.data1 | (link_values.data2 << 16);
   return 1;
@@ -1576,7 +1576,7 @@
 
 /* Set functions */
 
-static int set_TT(vm_t *vm, int tt) {  
+static int set_TT(vm_t *vm, int tt) {
   return set_PTT(vm, tt, 1);
 }
 
@@ -1592,21 +1592,21 @@
 
 static int set_VTS_PTT(vm_t *vm, int vtsN, int vts_ttn, int part) {
   int pgcN, pgN, res;
-  
+
   (vm->state).domain = VTS_DOMAIN;
 
   if (vtsN != (vm->state).vtsN)
     if (!ifoOpenNewVTSI(vm, vm->dvd, vtsN))  /* Also sets (vm->state).vtsN */
       return 0;
-  
+
   if ((vts_ttn < 1) || (vts_ttn > vm->vtsi->vts_ptt_srpt->nr_of_srpts) ||
       (part < 1) || (part > vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].nr_of_ptts) ) {
     return 0;
   }
-  
+
   pgcN = vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].ptt[part - 1].pgcn;
   pgN = vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].ptt[part - 1].pgn;
- 
+
   (vm->state).TT_PGCN_REG = pgcN;
   (vm->state).PTTN_REG    = part;
   (vm->state).TTN_REG     = get_TT(vm, vtsN, vts_ttn);
@@ -1614,13 +1614,13 @@
   (vm->state).VTS_TTN_REG = vts_ttn;
   (vm->state).vtsN        = vtsN;  /* Not sure about this one. We can get to it easily from TTN_REG */
   /* Any other registers? */
-  
+
   res = set_PGCN(vm, pgcN);   /* This clobber's state.pgN (sets it to 1), but we don't want clobbering here. */
   (vm->state).pgN = pgN;
   return res;
 }
 
-static int set_FP_PGC(vm_t *vm) {  
+static int set_FP_PGC(vm_t *vm) {
   (vm->state).domain = FP_DOMAIN;
   if (!vm->vmgi->first_play_pgc) {
     return set_PGCN(vm, 1);
@@ -1638,7 +1638,7 @@
 
 static int set_PGCN(vm_t *vm, int pgcN) {
   pgcit_t *pgcit;
-  
+
   pgcit = get_PGCIT(vm);
   assert(pgcit != NULL);  /* ?? Make this return -1 instead */
 
@@ -1648,31 +1648,31 @@
 #endif
     return 0;
   }
-  
+
   (vm->state).pgc = pgcit->pgci_srp[pgcN - 1].pgc;
   (vm->state).pgcN = pgcN;
   (vm->state).pgN = 1;
- 
+
   if((vm->state).domain == VTS_DOMAIN)
     (vm->state).TT_PGCN_REG = pgcN;
 
   return 1;
 }
 
-/* Figure out the correct pgN from the cell and update (vm->state). */ 
+/* Figure out the correct pgN from the cell and update (vm->state). */
 static int set_PGN(vm_t *vm) {
   int new_pgN = 0;
-  
-  while(new_pgN < (vm->state).pgc->nr_of_programs 
+
+  while(new_pgN < (vm->state).pgc->nr_of_programs
 	&& (vm->state).cellN >= (vm->state).pgc->program_map[new_pgN])
     new_pgN++;
-  
+
   if(new_pgN == (vm->state).pgc->nr_of_programs) /* We are at the last program */
     if((vm->state).cellN > (vm->state).pgc->nr_of_cells)
       return 0; /* We are past the last cell */
-  
+
   (vm->state).pgN = new_pgN;
-  
+
   if((vm->state).domain == VTS_DOMAIN) {
     playback_type_t *pb_ty;
     if((vm->state).TTN_REG > vm->vmgi->tt_srpt->nr_of_srpts)
@@ -1693,7 +1693,7 @@
 /* Must be called before domain is changed (set_PGCN()) */
 static void set_RSMinfo(vm_t *vm, int cellN, int blockN) {
   int i;
-  
+
   if(cellN) {
     (vm->state).rsm_cellN = cellN;
     (vm->state).rsm_blockN = blockN;
@@ -1703,9 +1703,9 @@
   }
   (vm->state).rsm_vtsN = (vm->state).vtsN;
   (vm->state).rsm_pgcN = get_PGCN(vm);
-  
+
   /* assert((vm->state).rsm_pgcN == (vm->state).TT_PGCN_REG);  for VTS_DOMAIN */
-  
+
   for(i = 0; i < 5; i++) {
     (vm->state).rsm_regs[i] = (vm->state).registers.SPRM[4 + i];
   }
@@ -1723,7 +1723,7 @@
   int tt=0;
 
   for(i = 1; i <= vm->vmgi->tt_srpt->nr_of_srpts; i++) {
-    if( vm->vmgi->tt_srpt->title[i - 1].title_set_nr == vtsN && 
+    if( vm->vmgi->tt_srpt->title[i - 1].title_set_nr == vtsN &&
         vm->vmgi->tt_srpt->title[i - 1].vts_ttn == vts_ttn) {
       tt=i;
       break;
@@ -1738,7 +1738,7 @@
 static int get_ID(vm_t *vm, int id) {
   int pgcN, i;
   pgcit_t *pgcit;
-  
+
   /* Relies on state to get the correct pgcit. */
   pgcit = get_PGCIT(vm);
   assert(pgcit != NULL);
@@ -1777,7 +1777,7 @@
   int pgcN = 1;
 
   pgcit = get_PGCIT(vm);
-  
+
   if (pgcit) {
     while(pgcN <= pgcit->nr_of_pgci_srp) {
       if(pgcit->pgci_srp[pgcN - 1].pgc == (vm->state).pgc) {
@@ -1787,19 +1787,19 @@
       pgcN++;
     }
   }
-  fprintf(MSG_OUT, "libdvdnav: get_PGCN failed. Was trying to find pgcN in domain %d\n", 
+  fprintf(MSG_OUT, "libdvdnav: get_PGCN failed. Was trying to find pgcN in domain %d\n",
          (vm->state).domain);
   return 0; /*  error */
 }
 
 static pgcit_t* get_MENU_PGCIT(vm_t *vm, ifo_handle_t *h, uint16_t lang) {
   int i;
-  
+
   if(h == NULL || h->pgci_ut == NULL) {
     fprintf(MSG_OUT, "libdvdnav: *** pgci_ut handle is NULL ***\n");
     return NULL; /*  error? */
   }
-  
+
   i = 0;
   while(i < h->pgci_ut->nr_of_lus
 	&& h->pgci_ut->lu[i].lang_code != lang)
@@ -1818,14 +1818,14 @@
     fprintf(MSG_OUT, "\n");
     i = 0; /*  error? */
   }
-  
+
   return h->pgci_ut->lu[i].pgcit;
 }
 
 /* Uses state to decide what to return */
 static pgcit_t* get_PGCIT(vm_t *vm) {
   pgcit_t *pgcit = NULL;
-  
+
   switch ((vm->state).domain) {
   case VTS_DOMAIN:
     if(!vm->vtsi) return NULL;
@@ -1842,11 +1842,11 @@
   default:
     abort();
   }
-  
+
   return pgcit;
 }
 
-//return the ifo_handle_t describing required title, used to 
+//return the ifo_handle_t describing required title, used to
 //identify chapters
 ifo_handle_t *vm_get_title_ifo(vm_t *vm, uint32_t title)
 {