changeset 64:70c34d162e6e src

Replaces the hard-coded values The parental management structure has ratings levels. The size of the bit mask is constant but magic values were being used instead of named constants. This commit changes them to named constants. This is based on a patch submitted by Frederic Marchal, fmarchal at perso dot be. Thanks for this tidy cleanup.
author erik
date Sun, 30 Jan 2011 23:44:13 +0000
parents 46c05a214511
children fb0ccb03eb7d
files dvdread/ifo_types.h ifo_read.c
diffstat 2 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/dvdread/ifo_types.h	Sun Jan 30 23:44:09 2011 +0000
+++ b/dvdread/ifo_types.h	Sun Jan 30 23:44:13 2011 +0000
@@ -475,7 +475,8 @@
  * Parental Management Information Unit Table.
  * Level 1 (US: G), ..., 7 (US: NC-17), 8
  */
-typedef uint16_t pf_level_t[8];
+#define PTL_MAIT_NUM_LEVEL 8
+typedef uint16_t pf_level_t[PTL_MAIT_NUM_LEVEL];
 
 /**
  * Parental Management Information Unit Table.
--- a/ifo_read.c	Sun Jan 30 23:44:09 2011 +0000
+++ b/ifo_read.c	Sun Jan 30 23:44:13 2011 +0000
@@ -1348,7 +1348,7 @@
     CHECK_ZERO(ptl_mait->countries[i].zero_1);
     CHECK_ZERO(ptl_mait->countries[i].zero_2);
     CHECK_VALUE(ptl_mait->countries[i].pf_ptl_mai_start_byte
-                + 8*2 * (ptl_mait->nr_of_vtss + 1) <= ptl_mait->last_byte + 1);
+                + sizeof(pf_level_t) * (ptl_mait->nr_of_vtss + 1) <= ptl_mait->last_byte + 1);
   }
 
   for(i = 0; i < ptl_mait->nr_of_countries; i++) {
@@ -1389,7 +1389,7 @@
     }
     { /* Transpose the array so we can use C indexing. */
       int level, vts;
-      for(level = 0; level < 8; level++) {
+      for(level = 0; level < PTL_MAIT_NUM_LEVEL; level++) {
         for(vts = 0; vts <= ptl_mait->nr_of_vtss; vts++) {
           ptl_mait->countries[i].pf_ptl_mai[vts][level] =
             pf_temp[(7-level)*(ptl_mait->nr_of_vtss+1) + vts];