[DVDnav-discuss] r1221 - in trunk/libdvdread/src: dvdread/ifo_types.h ifo_read.c

erik subversion at mplayerhq.hu
Mon Jan 31 00:44:13 CET 2011


Author: erik
Date: Mon Jan 31 00:44:13 2011
New Revision: 1221

Log:
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.

Modified:
   trunk/libdvdread/src/dvdread/ifo_types.h
   trunk/libdvdread/src/ifo_read.c

Modified: trunk/libdvdread/src/dvdread/ifo_types.h
==============================================================================
--- trunk/libdvdread/src/dvdread/ifo_types.h	Mon Jan 31 00:44:09 2011	(r1220)
+++ trunk/libdvdread/src/dvdread/ifo_types.h	Mon Jan 31 00:44:13 2011	(r1221)
@@ -475,7 +475,8 @@ typedef struct {
  * 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.

Modified: trunk/libdvdread/src/ifo_read.c
==============================================================================
--- trunk/libdvdread/src/ifo_read.c	Mon Jan 31 00:44:09 2011	(r1220)
+++ trunk/libdvdread/src/ifo_read.c	Mon Jan 31 00:44:13 2011	(r1221)
@@ -1348,7 +1348,7 @@ int ifoRead_PTL_MAIT(ifo_handle_t *ifofi
     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 @@ int ifoRead_PTL_MAIT(ifo_handle_t *ifofi
     }
     { /* 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];


More information about the DVDnav-discuss mailing list