changeset 363:abca84921371 src

read_cell_playback() removes another conditional bitfield. We're almost there!
author nicodvb
date Sun, 11 May 2008 19:07:25 +0000
parents 3d8edef37c7e
children 23607807ff65
files dvdread/ifo_read.c dvdread/ifo_types.h
diffstat 2 files changed, 30 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/dvdread/ifo_read.c	Sun May 11 09:43:48 2008 +0000
+++ b/dvdread/ifo_read.c	Sun May 11 19:07:25 2008 +0000
@@ -228,6 +228,35 @@
   ps->pgc_start_byte                 = dvdread_getbits(&state, 32);
 }
 
+static void read_cell_playback(cell_playback_t *cp) {
+  getbits_state_t state;
+  uint8_t buf[sizeof(cell_playback_t)];
+  
+  memcpy(buf, cp, sizeof(cell_playback_t));
+  if (!dvdread_getbits_init(&state, buf)) abort();
+  cp->block_mode                      = dvdread_getbits(&state, 2);
+  cp->block_type                      = dvdread_getbits(&state, 2);
+  cp->seamless_play                   = dvdread_getbits(&state, 1);
+  cp->interleaved                     = dvdread_getbits(&state, 1);
+  cp->stc_discontinuity               = dvdread_getbits(&state, 1);
+  cp->seamless_angle                  = dvdread_getbits(&state, 1);
+  cp->playback_mode                   = dvdread_getbits(&state, 1);
+  cp->restricted                      = dvdread_getbits(&state, 1);
+  cp->unknown2                        = dvdread_getbits(&state, 6);
+  cp->still_time                      = dvdread_getbits(&state, 8);
+  cp->cell_cmd_nr                     = dvdread_getbits(&state, 8);
+  
+  cp->playback_time.hour              = dvdread_getbits(&state, 8);
+  cp->playback_time.minute            = dvdread_getbits(&state, 8);
+  cp->playback_time.second            = dvdread_getbits(&state, 8);
+  cp->playback_time.frame_u           = dvdread_getbits(&state, 8);
+  
+  cp->first_sector                    = dvdread_getbits(&state, 32);
+  cp->first_ilvu_end_sector           = dvdread_getbits(&state, 32);
+  cp->last_vobu_start_sector          = dvdread_getbits(&state, 32);
+  cp->last_sector                     = dvdread_getbits(&state, 32);
+}
+
 ifo_handle_t *ifoOpen(dvd_reader_t *dvd, int title) {
   ifo_handle_t *ifofile;
 
@@ -724,11 +753,7 @@
     return 0;
 
   for(i = 0; i < nr; i++) {
-    B2N_32(cell_playback[i].first_sector);
-    B2N_32(cell_playback[i].first_ilvu_end_sector);
-    B2N_32(cell_playback[i].last_vobu_start_sector);
-    B2N_32(cell_playback[i].last_sector);
-    
+    read_cell_playback(&cell_playback[i]);
     /* Changed < to <= because this was false in the movie 'Pi'. */
     CHECK_VALUE(cell_playback[i].last_vobu_start_sector <= 
            cell_playback[i].last_sector);
--- a/dvdread/ifo_types.h	Sun May 11 09:43:48 2008 +0000
+++ b/dvdread/ifo_types.h	Sun May 11 19:07:25 2008 +0000
@@ -203,29 +203,15 @@
  * Cell Playback Information.
  */
 typedef struct {
-#ifdef WORDS_BIGENDIAN
   unsigned int block_mode       : 2;
   unsigned int block_type       : 2;
   unsigned int seamless_play    : 1;
   unsigned int interleaved      : 1;
   unsigned int stc_discontinuity: 1;
   unsigned int seamless_angle   : 1;
-  
   unsigned int playback_mode    : 1;  /**< When set, enter StillMode after each VOBU */
   unsigned int restricted       : 1;  /**< ?? drop out of fastforward? */
   unsigned int unknown2         : 6;
-#else
-  unsigned char seamless_angle   : 1;
-  unsigned char stc_discontinuity: 1;
-  unsigned char interleaved      : 1;
-  unsigned char seamless_play    : 1;
-  unsigned char block_type       : 2;
-  unsigned char block_mode       : 2;
-  
-  unsigned char unknown2         : 6;
-  unsigned char restricted       : 1;
-  unsigned char playback_mode    : 1;
-#endif
   uint8_t still_time;
   uint8_t cell_cmd_nr;
   dvd_time_t playback_time;