mirror of
				https://git.code.sf.net/p/libpng/code.git
				synced 2025-07-10 18:04:09 +02:00 
			
		
		
		
	[devel] Enable the strip16 tests in pngvalid
This commit is contained in:
		
							parent
							
								
									ba851ccd9f
								
							
						
					
					
						commit
						b54498edea
					
				
							
								
								
									
										66
									
								
								pngvalid.c
									
									
									
									
									
								
							
							
						
						
									
										66
									
								
								pngvalid.c
									
									
									
									
									
								
							@ -1169,10 +1169,20 @@ typedef struct png_modifier
 | 
				
			|||||||
   /* Whether or not to interlace. */
 | 
					   /* Whether or not to interlace. */
 | 
				
			||||||
   int                      interlace_type :9; /* int, but must store '1' */
 | 
					   int                      interlace_type :9; /* int, but must store '1' */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   /* Run the standard tests? */
 | 
				
			||||||
 | 
					   unsigned int             test_standard :1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   /* When to use the use_input_precision option: */
 | 
					   /* When to use the use_input_precision option: */
 | 
				
			||||||
   unsigned int             use_input_precision :1;
 | 
					   unsigned int             use_input_precision :1;
 | 
				
			||||||
   unsigned int             use_input_precision_sbit :1;
 | 
					   unsigned int             use_input_precision_sbit :1;
 | 
				
			||||||
   unsigned int             use_input_precision_16to8 :1;
 | 
					   unsigned int             use_input_precision_16to8 :1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   /* Which gamma tests to run: */
 | 
				
			||||||
 | 
					   unsigned int             test_threshold :1;
 | 
				
			||||||
 | 
					   unsigned int             test_transform :1; /* main tests */
 | 
				
			||||||
 | 
					   unsigned int             test_sbit :1;
 | 
				
			||||||
 | 
					   unsigned int             test_strip16 :1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   unsigned int             log :1;   /* Log max error */
 | 
					   unsigned int             log :1;   /* Log max error */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   /* Buffer information, the buffer size limits the size of the chunks that can
 | 
					   /* Buffer information, the buffer size limits the size of the chunks that can
 | 
				
			||||||
@ -1235,9 +1245,14 @@ modifier_init(png_modifier *pm)
 | 
				
			|||||||
   pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 = 0;
 | 
					   pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 = 0;
 | 
				
			||||||
   pm->error_gray_16 = pm->error_color_8 = pm->error_color_16 = 0;
 | 
					   pm->error_gray_16 = pm->error_color_8 = pm->error_color_16 = 0;
 | 
				
			||||||
   pm->interlace_type = PNG_INTERLACE_NONE;
 | 
					   pm->interlace_type = PNG_INTERLACE_NONE;
 | 
				
			||||||
 | 
					   pm->test_standard = 1;
 | 
				
			||||||
   pm->use_input_precision = 0;
 | 
					   pm->use_input_precision = 0;
 | 
				
			||||||
   pm->use_input_precision_sbit = 0;
 | 
					   pm->use_input_precision_sbit = 0;
 | 
				
			||||||
   pm->use_input_precision_16to8 = 0;
 | 
					   pm->use_input_precision_16to8 = 0;
 | 
				
			||||||
 | 
					   pm->test_threshold = 1;
 | 
				
			||||||
 | 
					   pm->test_transform = 1;
 | 
				
			||||||
 | 
					   pm->test_sbit = 1;
 | 
				
			||||||
 | 
					   pm->test_strip16 = 1;
 | 
				
			||||||
   pm->log = 0;
 | 
					   pm->log = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   /* Rely on the memset for all the other fields - there are no pointers */
 | 
					   /* Rely on the memset for all the other fields - there are no pointers */
 | 
				
			||||||
@ -2792,7 +2807,7 @@ gamma_info_imp(gamma_display *dp, png_structp pp, png_infop pi)
 | 
				
			|||||||
    * PNG_MAX_GAMMA_8 when doing the following.
 | 
					    * PNG_MAX_GAMMA_8 when doing the following.
 | 
				
			||||||
    */
 | 
					    */
 | 
				
			||||||
   if (dp->strip16)
 | 
					   if (dp->strip16)
 | 
				
			||||||
#     ifdef PNG_READ_16_TO_8
 | 
					#     ifdef PNG_READ_16_TO_8_SUPPORTED
 | 
				
			||||||
         png_set_strip_16(pp);
 | 
					         png_set_strip_16(pp);
 | 
				
			||||||
#     else
 | 
					#     else
 | 
				
			||||||
         png_error(pp, "strip16 (16 to 8 bit conversion) not supported");
 | 
					         png_error(pp, "strip16 (16 to 8 bit conversion) not supported");
 | 
				
			||||||
@ -3391,7 +3406,7 @@ static void perform_gamma_sbit_tests(png_modifier *pm, int speed)
 | 
				
			|||||||
/* Note that this requires a 16 bit source image but produces 8 bit output, so
 | 
					/* Note that this requires a 16 bit source image but produces 8 bit output, so
 | 
				
			||||||
 * we only need the 16bit write support.
 | 
					 * we only need the 16bit write support.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
#ifdef PNG_16_TO_8_SUPPORTED
 | 
					#ifdef PNG_READ_16_TO_8_SUPPORTED
 | 
				
			||||||
static void perform_gamma_strip16_tests(png_modifier *pm, int speed)
 | 
					static void perform_gamma_strip16_tests(png_modifier *pm, int speed)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
#  ifndef PNG_MAX_GAMMA_8
 | 
					#  ifndef PNG_MAX_GAMMA_8
 | 
				
			||||||
@ -3450,7 +3465,7 @@ static void
 | 
				
			|||||||
perform_gamma_test(png_modifier *pm, int speed, int summary)
 | 
					perform_gamma_test(png_modifier *pm, int speed, int summary)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
   /* First some arbitrary no-transform tests: */
 | 
					   /* First some arbitrary no-transform tests: */
 | 
				
			||||||
   if (!speed)
 | 
					   if (!speed && pm->test_threshold)
 | 
				
			||||||
   {
 | 
					   {
 | 
				
			||||||
      perform_gamma_threshold_tests(pm);
 | 
					      perform_gamma_threshold_tests(pm);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -3459,6 +3474,8 @@ perform_gamma_test(png_modifier *pm, int speed, int summary)
 | 
				
			|||||||
   }
 | 
					   }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   /* Now some real transforms. */
 | 
					   /* Now some real transforms. */
 | 
				
			||||||
 | 
					   if (pm->test_transform)
 | 
				
			||||||
 | 
					   {
 | 
				
			||||||
      perform_gamma_transform_tests(pm, speed);
 | 
					      perform_gamma_transform_tests(pm, speed);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (summary)
 | 
					      if (summary)
 | 
				
			||||||
@ -3485,10 +3502,13 @@ perform_gamma_test(png_modifier *pm, int speed, int summary)
 | 
				
			|||||||
         printf(" 16 bit color: %.5f\n", pm->error_color_16);
 | 
					         printf(" 16 bit color: %.5f\n", pm->error_color_16);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   /* The sbit tests produce much larger errors: */
 | 
					   /* The sbit tests produce much larger errors: */
 | 
				
			||||||
   pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 = pm->error_gray_16 =
 | 
					   if (pm->test_sbit)
 | 
				
			||||||
   pm->error_color_8 = pm->error_color_16 = 0;
 | 
					   {
 | 
				
			||||||
 | 
					      pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 =
 | 
				
			||||||
 | 
					      pm->error_gray_16 = pm->error_color_8 = pm->error_color_16 = 0;
 | 
				
			||||||
      perform_gamma_sbit_tests(pm, speed);
 | 
					      perform_gamma_sbit_tests(pm, speed);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (summary)
 | 
					      if (summary)
 | 
				
			||||||
@ -3508,11 +3528,14 @@ perform_gamma_test(png_modifier *pm, int speed, int summary)
 | 
				
			|||||||
         printf(" 16 bit color: %.5f\n", pm->error_color_16);
 | 
					         printf(" 16 bit color: %.5f\n", pm->error_color_16);
 | 
				
			||||||
   #endif
 | 
					   #endif
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef PNG_16_TO_8_SUPPORTED
 | 
					#ifdef PNG_READ_16_TO_8_SUPPORTED
 | 
				
			||||||
 | 
					   if (pm->test_strip16)
 | 
				
			||||||
 | 
					   {
 | 
				
			||||||
      /* The 16 to 8 bit strip operations: */
 | 
					      /* The 16 to 8 bit strip operations: */
 | 
				
			||||||
   pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 = pm->error_gray_16 =
 | 
					      pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 =
 | 
				
			||||||
   pm->error_color_8 = pm->error_color_16 = 0;
 | 
					      pm->error_gray_16 = pm->error_color_8 = pm->error_color_16 = 0;
 | 
				
			||||||
      perform_gamma_strip16_tests(pm, speed);
 | 
					      perform_gamma_strip16_tests(pm, speed);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (summary)
 | 
					      if (summary)
 | 
				
			||||||
@ -3521,6 +3544,7 @@ perform_gamma_test(png_modifier *pm, int speed, int summary)
 | 
				
			|||||||
         printf(" 16 bit gray:  %.5f\n", pm->error_gray_16);
 | 
					         printf(" 16 bit gray:  %.5f\n", pm->error_gray_16);
 | 
				
			||||||
         printf(" 16 bit color: %.5f\n", pm->error_color_16);
 | 
					         printf(" 16 bit color: %.5f\n", pm->error_color_16);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -3577,7 +3601,7 @@ int main(int argc, PNG_CONST char **argv)
 | 
				
			|||||||
    */
 | 
					    */
 | 
				
			||||||
   pm.maxout8 = .1;     /* Arithmetic error in *encoded* value */
 | 
					   pm.maxout8 = .1;     /* Arithmetic error in *encoded* value */
 | 
				
			||||||
   pm.maxabs8 = .00005; /* 1/20000 */
 | 
					   pm.maxabs8 = .00005; /* 1/20000 */
 | 
				
			||||||
   pm.maxpc8 = .499;    /* I.e. .499% fractional error */
 | 
					   pm.maxpc8 = .499;    /* I.e., .499% fractional error */
 | 
				
			||||||
   pm.maxout16 = .499;  /* Error in *encoded* value */
 | 
					   pm.maxout16 = .499;  /* Error in *encoded* value */
 | 
				
			||||||
   pm.maxabs16 = .00005;/* 1/20000 */
 | 
					   pm.maxabs16 = .00005;/* 1/20000 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -3610,11 +3634,27 @@ int main(int argc, PNG_CONST char **argv)
 | 
				
			|||||||
         pm.this.treat_warnings_as_errors = 0;
 | 
					         pm.this.treat_warnings_as_errors = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      else if (strcmp(*argv, "--speed") == 0)
 | 
					      else if (strcmp(*argv, "--speed") == 0)
 | 
				
			||||||
         pm.this.speed = 1, pm.ngammas = (sizeof gammas)/(sizeof gammas[0]);
 | 
					         pm.this.speed = 1, pm.ngammas = (sizeof gammas)/(sizeof gammas[0]),
 | 
				
			||||||
 | 
					            pm.test_standard = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      else if (strcmp(*argv, "--nostandard") == 0)
 | 
				
			||||||
 | 
					         pm.test_standard = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      else if (strcmp(*argv, "--nogamma") == 0)
 | 
					      else if (strcmp(*argv, "--nogamma") == 0)
 | 
				
			||||||
         pm.ngammas = 0;
 | 
					         pm.ngammas = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      else if (strcmp(*argv, "--nogamma-threshold") == 0)
 | 
				
			||||||
 | 
					         pm.test_threshold = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      else if (strcmp(*argv, "--nogamma-transform") == 0)
 | 
				
			||||||
 | 
					         pm.test_transform = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      else if (strcmp(*argv, "--nogamma-sbit") == 0)
 | 
				
			||||||
 | 
					         pm.test_sbit = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      else if (strcmp(*argv, "--nogamma-16-to-8") == 0)
 | 
				
			||||||
 | 
					         pm.test_strip16 = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      else if (strcmp(*argv, "--progressive-read") == 0)
 | 
					      else if (strcmp(*argv, "--progressive-read") == 0)
 | 
				
			||||||
         pm.this.progressive = 1;
 | 
					         pm.this.progressive = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -3669,13 +3709,15 @@ int main(int argc, PNG_CONST char **argv)
 | 
				
			|||||||
      make_standard_images(&pm.this);
 | 
					      make_standard_images(&pm.this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      /* Perform the standard and gamma tests. */
 | 
					      /* Perform the standard and gamma tests. */
 | 
				
			||||||
      if (!pm.this.speed)
 | 
					      if (pm.test_standard)
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
         perform_standard_test(&pm);
 | 
					         perform_standard_test(&pm);
 | 
				
			||||||
         perform_error_test(&pm);
 | 
					         perform_error_test(&pm);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      perform_gamma_test(&pm, pm.this.speed != 0, summary && !pm.this.speed);
 | 
					      if (pm.ngammas > 0)
 | 
				
			||||||
 | 
					         perform_gamma_test(&pm, pm.this.speed != 0,
 | 
				
			||||||
 | 
					            summary && !pm.this.speed);
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Catch(fault)
 | 
					   Catch(fault)
 | 
				
			||||||
 | 
				
			|||||||
@ -1,3 +1,22 @@
 | 
				
			|||||||
#!/bin/sh
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# Run a sequence of gamma tests quietly
 | 
				
			||||||
 | 
					err=0
 | 
				
			||||||
 | 
					for gamma in threshold transform sbit 16-to-8
 | 
				
			||||||
 | 
					do
 | 
				
			||||||
 | 
					   opts=
 | 
				
			||||||
 | 
					   test "$gamma" = threshold || opts="$opts --nogamma-threshold"
 | 
				
			||||||
 | 
					   test "$gamma" = transform || opts="$opts --nogamma-transform"
 | 
				
			||||||
 | 
					   test "$gamma" = sbit      || opts="$opts --nogamma-sbit"
 | 
				
			||||||
 | 
					   test "$gamma" = 16-to-8   || opts="$opts --nogamma-16-to-8"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
./pngvalid -q
 | 
					   if ./pngvalid -q --nostandard $opts
 | 
				
			||||||
 | 
					   then
 | 
				
			||||||
 | 
					      echo "PASS:" pngvalid "(gamma-$gamma)"
 | 
				
			||||||
 | 
					   else
 | 
				
			||||||
 | 
					      echo "FAIL:" pngvalid "(gamma-$gamma)"
 | 
				
			||||||
 | 
					      err=1
 | 
				
			||||||
 | 
					   fi
 | 
				
			||||||
 | 
					done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					exit $err
 | 
				
			||||||
 | 
				
			|||||||
@ -1,3 +1,19 @@
 | 
				
			|||||||
#!/bin/sh
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# Run a sequence of tests quietly, without the slow
 | 
				
			||||||
 | 
					# gamma tests
 | 
				
			||||||
 | 
					err=0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
./pngvalid -q --speed
 | 
					for opts in "" --progressive-read --interlace \
 | 
				
			||||||
 | 
					   "--progressive-read --interlace"
 | 
				
			||||||
 | 
					do
 | 
				
			||||||
 | 
					   if ./pngvalid -q --nogamma $opts
 | 
				
			||||||
 | 
					   then
 | 
				
			||||||
 | 
					      echo "PASS:" pngvalid --nogamma $opts
 | 
				
			||||||
 | 
					   else
 | 
				
			||||||
 | 
					      echo "FAIL:" pngvalid --nogamma $opts
 | 
				
			||||||
 | 
					      err=1
 | 
				
			||||||
 | 
					   fi
 | 
				
			||||||
 | 
					done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					exit $err
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user