[libpng17] Fixed default behavior of ARM_NEON_API. If the ARM NEON API option is

compiled without the CHECK option it defaulted to on, not off.
This commit is contained in:
John Bowler 2013-09-30 08:07:18 -05:00 committed by Glenn Randers-Pehrson
parent 88c20ada06
commit d9f60caf72
4 changed files with 105 additions and 23 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.7.0beta19 - September 20, 2013 Libpng 1.7.0beta19 - September 30, 2013
This is not intended to be a public release. It will be replaced This is not intended to be a public release. It will be replaced
within a few weeks by a public version or by another test version. within a few weeks by a public version or by another test version.
@ -357,9 +357,11 @@ Version 1.7.0beta18 [September 16, 2013]
prototype, definition, and usage. Made it depend on prototype, definition, and usage. Made it depend on
PNG_HANDLE_AS_UNKNOWN_SUPPORTED everywhere. PNG_HANDLE_AS_UNKNOWN_SUPPORTED everywhere.
Version 1.7.0beta19 [September 20, 2013] Version 1.7.0beta19 [September 30, 2013]
Reverted the change to unknown handling #defines; the change breaks 'NOREAD' Reverted the change to unknown handling #defines; the change breaks 'NOREAD'
builds. builds.
Fixed default behavior of ARM_NEON_API. If the ARM NEON API option is
compiled without the CHECK option it defaulted to on, not off.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

View File

@ -4646,9 +4646,11 @@ Version 1.7.0beta18 [September 16, 2013]
prototype, definition, and usage. Made it depend on prototype, definition, and usage. Made it depend on
PNG_HANDLE_AS_UNKNOWN_SUPPORTED everywhere. PNG_HANDLE_AS_UNKNOWN_SUPPORTED everywhere.
Version 1.7.0beta19 [September 20, 2013] Version 1.7.0beta19 [September 30, 2013]
Reverted the change to unknown handling #defines; the change breaks 'NOREAD' Reverted the change to unknown handling #defines; the change breaks 'NOREAD'
builds. builds.
Fixed default behavior of ARM_NEON_API. If the ARM NEON API option is
compiled without the CHECK option it defaulted to on, not off.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

View File

@ -154,6 +154,16 @@ png_have_neon(png_structp png_ptr)
void void
png_init_filter_functions_neon(png_structp pp, unsigned int bpp) png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
{ {
/* The switch statement is compiled in for ARM_NEON_API, the call to
* png_have_neon is compiled in for ARM_NEON_CHECK. If both are defined
* the check is only performed if the API has not set the NEON option on
* or off explicitly. In this case the check controls what happens.
*
* If the CHECK is not compiled in and the option is UNSET the behavior prior
* to 1.6.7 was to use the NEON code - this was a bug caused by having the
* wrong order of the 'ON' and 'default' cases. UNSET now defaults to OFF,
* as documented in png.h
*/
#ifdef PNG_ARM_NEON_API_SUPPORTED #ifdef PNG_ARM_NEON_API_SUPPORTED
switch ((pp->options >> PNG_ARM_NEON) & 3) switch ((pp->options >> PNG_ARM_NEON) & 3)
{ {
@ -178,13 +188,14 @@ png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
break; break;
#endif #endif
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */ #endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
#ifdef PNG_ARM_NEON_API_SUPPORTED #ifdef PNG_ARM_NEON_API_SUPPORTED
default: /* OFF or INVALID */
return;
case PNG_OPTION_ON: case PNG_OPTION_ON:
/* Option turned on */ /* Option turned on */
break; break;
default: /* OFF or INVALID */
return;
} }
#endif #endif

View File

@ -621,7 +621,12 @@ typedef struct png_store
unsigned int validated :1; /* used as a temporary flag */ unsigned int validated :1; /* used as a temporary flag */
int nerrors; int nerrors;
int nwarnings; int nwarnings;
char test[128]; /* Name of test */ int noptions; /* number of options below: */
struct {
unsigned char option; /* option number, 0..30 */
unsigned char setting; /* setting (unset,invalid,on,off) */
} options[16];
char test[128]; /* Name of test */
char error[256]; char error[256];
/* Read fields */ /* Read fields */
@ -722,6 +727,7 @@ store_init(png_store* ps)
ps->new.prev = NULL; ps->new.prev = NULL;
ps->palette = NULL; ps->palette = NULL;
ps->npalette = 0; ps->npalette = 0;
ps->noptions = 0;
} }
static void static void
@ -1523,6 +1529,16 @@ set_store_for_write(png_store *ps, png_infopp ppi,
png_set_write_fn(ps->pwrite, ps, store_write, store_flush); png_set_write_fn(ps->pwrite, ps, store_write, store_flush);
# ifdef PNG_SET_OPTION_SUPPORTED
{
int opt;
for (opt=0; opt<ps->noptions; ++opt)
if (png_set_option(ps->pwrite, ps->options[opt].option,
ps->options[opt].setting) == PNG_OPTION_INVALID)
png_error(ps->pwrite, "png option invalid");
}
# endif
if (ppi != NULL) if (ppi != NULL)
*ppi = ps->piwrite = png_create_info_struct(ps->pwrite); *ppi = ps->piwrite = png_create_info_struct(ps->pwrite);
} }
@ -1586,14 +1602,14 @@ store_read_set(png_store *ps, png_uint_32 id)
pf = pf->next; pf = pf->next;
} }
{ {
size_t pos; size_t pos;
char msg[FILE_NAME_SIZE+64]; char msg[FILE_NAME_SIZE+64];
pos = standard_name_from_id(msg, sizeof msg, 0, id); pos = standard_name_from_id(msg, sizeof msg, 0, id);
pos = safecat(msg, sizeof msg, pos, ": file not found"); pos = safecat(msg, sizeof msg, pos, ": file not found");
png_error(ps->pread, msg); png_error(ps->pread, msg);
} }
} }
/* The main interface for reading a saved file - pass the id number of the file /* The main interface for reading a saved file - pass the id number of the file
@ -1638,6 +1654,16 @@ set_store_for_read(png_store *ps, png_infopp ppi, png_uint_32 id,
Throw ps; Throw ps;
} }
# ifdef PNG_SET_OPTION_SUPPORTED
{
int opt;
for (opt=0; opt<ps->noptions; ++opt)
if (png_set_option(ps->pread, ps->options[opt].option,
ps->options[opt].setting) == PNG_OPTION_INVALID)
png_error(ps->pread, "png option invalid");
}
# endif
store_read_set(ps, id); store_read_set(ps, id);
if (ppi != NULL) if (ppi != NULL)
@ -7267,7 +7293,7 @@ transform_enable(PNG_CONST char *name)
{ {
fprintf(stderr, "pngvalid: --transform-enable=%s: unknown transform\n", fprintf(stderr, "pngvalid: --transform-enable=%s: unknown transform\n",
name); name);
exit(1); exit(99);
} }
} }
@ -7289,7 +7315,7 @@ transform_disable(PNG_CONST char *name)
fprintf(stderr, "pngvalid: --transform-disable=%s: unknown transform\n", fprintf(stderr, "pngvalid: --transform-disable=%s: unknown transform\n",
name); name);
exit(1); exit(99);
} }
static void static void
@ -9640,7 +9666,7 @@ perform_interlace_macro_validation(void)
if (m != f) if (m != f)
{ {
fprintf(stderr, "PNG_PASS_START_ROW(%d) = %u != %x\n", pass, m, f); fprintf(stderr, "PNG_PASS_START_ROW(%d) = %u != %x\n", pass, m, f);
exit(1); exit(99);
} }
m = PNG_PASS_START_COL(pass); m = PNG_PASS_START_COL(pass);
@ -9648,7 +9674,7 @@ perform_interlace_macro_validation(void)
if (m != f) if (m != f)
{ {
fprintf(stderr, "PNG_PASS_START_COL(%d) = %u != %x\n", pass, m, f); fprintf(stderr, "PNG_PASS_START_COL(%d) = %u != %x\n", pass, m, f);
exit(1); exit(99);
} }
m = PNG_PASS_ROW_SHIFT(pass); m = PNG_PASS_ROW_SHIFT(pass);
@ -9656,7 +9682,7 @@ perform_interlace_macro_validation(void)
if (m != f) if (m != f)
{ {
fprintf(stderr, "PNG_PASS_ROW_SHIFT(%d) = %u != %x\n", pass, m, f); fprintf(stderr, "PNG_PASS_ROW_SHIFT(%d) = %u != %x\n", pass, m, f);
exit(1); exit(99);
} }
m = PNG_PASS_COL_SHIFT(pass); m = PNG_PASS_COL_SHIFT(pass);
@ -9664,7 +9690,7 @@ perform_interlace_macro_validation(void)
if (m != f) if (m != f)
{ {
fprintf(stderr, "PNG_PASS_COL_SHIFT(%d) = %u != %x\n", pass, m, f); fprintf(stderr, "PNG_PASS_COL_SHIFT(%d) = %u != %x\n", pass, m, f);
exit(1); exit(99);
} }
/* Macros that depend on the image or sub-image height too: /* Macros that depend on the image or sub-image height too:
@ -9685,7 +9711,7 @@ perform_interlace_macro_validation(void)
{ {
fprintf(stderr, "PNG_ROW_FROM_PASS_ROW(%u, %d) = %u != %x\n", fprintf(stderr, "PNG_ROW_FROM_PASS_ROW(%u, %d) = %u != %x\n",
v, pass, m, f); v, pass, m, f);
exit(1); exit(99);
} }
m = PNG_COL_FROM_PASS_COL(v, pass); m = PNG_COL_FROM_PASS_COL(v, pass);
@ -9694,7 +9720,7 @@ perform_interlace_macro_validation(void)
{ {
fprintf(stderr, "PNG_COL_FROM_PASS_COL(%u, %d) = %u != %x\n", fprintf(stderr, "PNG_COL_FROM_PASS_COL(%u, %d) = %u != %x\n",
v, pass, m, f); v, pass, m, f);
exit(1); exit(99);
} }
m = PNG_ROW_IN_INTERLACE_PASS(v, pass); m = PNG_ROW_IN_INTERLACE_PASS(v, pass);
@ -9703,7 +9729,7 @@ perform_interlace_macro_validation(void)
{ {
fprintf(stderr, "PNG_ROW_IN_INTERLACE_PASS(%u, %d) = %u != %x\n", fprintf(stderr, "PNG_ROW_IN_INTERLACE_PASS(%u, %d) = %u != %x\n",
v, pass, m, f); v, pass, m, f);
exit(1); exit(99);
} }
m = PNG_COL_IN_INTERLACE_PASS(v, pass); m = PNG_COL_IN_INTERLACE_PASS(v, pass);
@ -9712,7 +9738,7 @@ perform_interlace_macro_validation(void)
{ {
fprintf(stderr, "PNG_COL_IN_INTERLACE_PASS(%u, %d) = %u != %x\n", fprintf(stderr, "PNG_COL_IN_INTERLACE_PASS(%u, %d) = %u != %x\n",
v, pass, m, f); v, pass, m, f);
exit(1); exit(99);
} }
/* Then the base 1 stuff: */ /* Then the base 1 stuff: */
@ -9723,7 +9749,7 @@ perform_interlace_macro_validation(void)
{ {
fprintf(stderr, "PNG_PASS_ROWS(%u, %d) = %u != %x\n", fprintf(stderr, "PNG_PASS_ROWS(%u, %d) = %u != %x\n",
v, pass, m, f); v, pass, m, f);
exit(1); exit(99);
} }
m = PNG_PASS_COLS(v, pass); m = PNG_PASS_COLS(v, pass);
@ -9732,7 +9758,7 @@ perform_interlace_macro_validation(void)
{ {
fprintf(stderr, "PNG_PASS_COLS(%u, %d) = %u != %x\n", fprintf(stderr, "PNG_PASS_COLS(%u, %d) = %u != %x\n",
v, pass, m, f); v, pass, m, f);
exit(1); exit(99);
} }
/* Move to the next v - the stepping algorithm starts skipping /* Move to the next v - the stepping algorithm starts skipping
@ -10156,7 +10182,7 @@ int main(int argc, char **argv)
else else
{ {
fprintf(stderr, "pngvalid: %s: unknown 'max' option\n", *argv); fprintf(stderr, "pngvalid: %s: unknown 'max' option\n", *argv);
exit(1); exit(99);
} }
catmore = 1; catmore = 1;
@ -10168,10 +10194,51 @@ int main(int argc, char **argv)
else if (strcmp(*argv, "--log16") == 0) else if (strcmp(*argv, "--log16") == 0)
--argc, pm.log16 = atof(*++argv), catmore = 1; --argc, pm.log16 = atof(*++argv), catmore = 1;
#ifdef PNG_SET_OPTION_SUPPORTED
else if (strncmp(*argv, "--option=", 9) == 0)
{
/* Syntax of the argument is <option>:{on|off} */
const char *arg = 9+*argv;
unsigned char option=0, setting=0;
#ifdef PNG_ARM_NEON_API_SUPPORTED
if (strncmp(arg, "arm-neon:", 9) == 0)
option = PNG_ARM_NEON, arg += 9;
else
#endif
if (strncmp(arg, "max-inflate-window:", 19) == 0)
option = PNG_MAXIMUM_INFLATE_WINDOW, arg += 19;
else
{
fprintf(stderr, "pngvalid: %s: %s: unknown option\n", *argv, arg);
exit(99);
}
if (strcmp(arg, "off") == 0)
setting = PNG_OPTION_OFF;
else if (strcmp(arg, "on") == 0)
setting = PNG_OPTION_ON;
else
{
fprintf(stderr,
"pngvalid: %s: %s: unknown setting (use 'on' or 'off')\n",
*argv, arg);
exit(99);
}
pm.this.options[pm.this.noptions].option = option;
pm.this.options[pm.this.noptions++].setting = setting;
}
#endif /* PNG_SET_OPTION_SUPPORTED */
else else
{ {
fprintf(stderr, "pngvalid: %s: unknown argument\n", *argv); fprintf(stderr, "pngvalid: %s: unknown argument\n", *argv);
exit(1); exit(99);
} }
if (catmore) /* consumed an extra *argv */ if (catmore) /* consumed an extra *argv */