# HG changeset patch # User erik # Date 1296431053 0 # Node ID 70c34d162e6ee6a37544b7c0e728eca11278222b # Parent 46c05a21451102bc0f9bb1c04d8954c53b4ef8fe 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. diff -r 46c05a214511 -r 70c34d162e6e dvdread/ifo_types.h --- 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. diff -r 46c05a214511 -r 70c34d162e6e ifo_read.c --- 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];