From d9f60caf72be3e16538ac3215b4996932813d205 Mon Sep 17 00:00:00 2001 From: John Bowler Date: Mon, 30 Sep 2013 08:07:18 -0500 Subject: [PATCH] [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. --- ANNOUNCE | 6 ++- CHANGES | 4 +- arm/arm_init.c | 17 ++++-- contrib/libtests/pngvalid.c | 101 ++++++++++++++++++++++++++++++------ 4 files changed, 105 insertions(+), 23 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 3750b5250..baf3bbaf2 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -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 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 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' 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 (subscription required; visit diff --git a/CHANGES b/CHANGES index 7b5f89038..189cf3324 100644 --- a/CHANGES +++ b/CHANGES @@ -4646,9 +4646,11 @@ Version 1.7.0beta18 [September 16, 2013] prototype, definition, and usage. Made it depend on 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' 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 (subscription required; visit diff --git a/arm/arm_init.c b/arm/arm_init.c index 8f3377545..098771781 100644 --- a/arm/arm_init.c +++ b/arm/arm_init.c @@ -154,6 +154,16 @@ png_have_neon(png_structp png_ptr) void 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 switch ((pp->options >> PNG_ARM_NEON) & 3) { @@ -178,13 +188,14 @@ png_init_filter_functions_neon(png_structp pp, unsigned int bpp) break; #endif #endif /* PNG_ARM_NEON_CHECK_SUPPORTED */ + #ifdef PNG_ARM_NEON_API_SUPPORTED + default: /* OFF or INVALID */ + return; + case PNG_OPTION_ON: /* Option turned on */ break; - - default: /* OFF or INVALID */ - return; } #endif diff --git a/contrib/libtests/pngvalid.c b/contrib/libtests/pngvalid.c index 87487da7e..15d8fa24e 100644 --- a/contrib/libtests/pngvalid.c +++ b/contrib/libtests/pngvalid.c @@ -621,7 +621,12 @@ typedef struct png_store unsigned int validated :1; /* used as a temporary flag */ int nerrors; 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]; /* Read fields */ @@ -722,6 +727,7 @@ store_init(png_store* ps) ps->new.prev = NULL; ps->palette = NULL; ps->npalette = 0; + ps->noptions = 0; } 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); +# ifdef PNG_SET_OPTION_SUPPORTED + { + int opt; + for (opt=0; optnoptions; ++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) *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; } - { + { size_t pos; char msg[FILE_NAME_SIZE+64]; pos = standard_name_from_id(msg, sizeof msg, 0, id); pos = safecat(msg, sizeof msg, pos, ": file not found"); png_error(ps->pread, msg); - } + } } /* 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; } +# ifdef PNG_SET_OPTION_SUPPORTED + { + int opt; + for (opt=0; optnoptions; ++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); if (ppi != NULL) @@ -7267,7 +7293,7 @@ transform_enable(PNG_CONST char *name) { fprintf(stderr, "pngvalid: --transform-enable=%s: unknown transform\n", name); - exit(1); + exit(99); } } @@ -7289,7 +7315,7 @@ transform_disable(PNG_CONST char *name) fprintf(stderr, "pngvalid: --transform-disable=%s: unknown transform\n", name); - exit(1); + exit(99); } static void @@ -9640,7 +9666,7 @@ perform_interlace_macro_validation(void) if (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); @@ -9648,7 +9674,7 @@ perform_interlace_macro_validation(void) if (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); @@ -9656,7 +9682,7 @@ perform_interlace_macro_validation(void) if (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); @@ -9664,7 +9690,7 @@ perform_interlace_macro_validation(void) if (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: @@ -9685,7 +9711,7 @@ perform_interlace_macro_validation(void) { fprintf(stderr, "PNG_ROW_FROM_PASS_ROW(%u, %d) = %u != %x\n", v, pass, m, f); - exit(1); + exit(99); } 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", v, pass, m, f); - exit(1); + exit(99); } 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", v, pass, m, f); - exit(1); + exit(99); } 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", v, pass, m, f); - exit(1); + exit(99); } /* Then the base 1 stuff: */ @@ -9723,7 +9749,7 @@ perform_interlace_macro_validation(void) { fprintf(stderr, "PNG_PASS_ROWS(%u, %d) = %u != %x\n", v, pass, m, f); - exit(1); + exit(99); } 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", v, pass, m, f); - exit(1); + exit(99); } /* Move to the next v - the stepping algorithm starts skipping @@ -10156,7 +10182,7 @@ int main(int argc, char **argv) else { fprintf(stderr, "pngvalid: %s: unknown 'max' option\n", *argv); - exit(1); + exit(99); } catmore = 1; @@ -10168,10 +10194,51 @@ int main(int argc, char **argv) else if (strcmp(*argv, "--log16") == 0) --argc, pm.log16 = atof(*++argv), catmore = 1; +#ifdef PNG_SET_OPTION_SUPPORTED + else if (strncmp(*argv, "--option=", 9) == 0) + { + /* Syntax of the argument is