Merge remote-tracking branch 'refs/remotes/Itseez/master'
6
3rdparty/libjpeg/jquant2.c
vendored
@ -265,9 +265,9 @@ typedef struct {
|
||||
INT32 volume;
|
||||
/* The number of nonzero histogram cells within this box */
|
||||
long colorcount;
|
||||
} box;
|
||||
} _box;
|
||||
|
||||
typedef box * boxptr;
|
||||
typedef _box * boxptr;
|
||||
|
||||
|
||||
LOCAL(boxptr)
|
||||
@ -546,7 +546,7 @@ select_colors (j_decompress_ptr cinfo, int desired_colors)
|
||||
|
||||
/* Allocate workspace for box list */
|
||||
boxlist = (boxptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, desired_colors * SIZEOF(box));
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, desired_colors * SIZEOF(_box));
|
||||
/* Initialize one box containing whole space */
|
||||
numboxes = 1;
|
||||
boxlist[0].c0min = 0;
|
||||
|
1702
3rdparty/libpng/CHANGES
vendored
28
3rdparty/libpng/CMakeLists.txt
vendored
@ -3,10 +3,23 @@
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if(NEON)
|
||||
project(${PNG_LIBRARY} ASM)
|
||||
if(ENABLE_NEON)
|
||||
project(${PNG_LIBRARY} C ASM)
|
||||
else()
|
||||
project(${PNG_LIBRARY})
|
||||
project(${PNG_LIBRARY} C)
|
||||
endif()
|
||||
|
||||
if(NOT WIN32)
|
||||
find_library(M_LIBRARY
|
||||
NAMES m
|
||||
PATHS /usr/lib /usr/local/lib
|
||||
)
|
||||
if(NOT M_LIBRARY)
|
||||
message(STATUS "math lib 'libm' not found; floating point support disabled")
|
||||
endif()
|
||||
else()
|
||||
# not needed on windows
|
||||
set(M_LIBRARY "")
|
||||
endif()
|
||||
|
||||
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" ${ZLIB_INCLUDE_DIRS})
|
||||
@ -14,17 +27,16 @@ ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" ${ZLIB_INCLUDE_DIRS})
|
||||
file(GLOB lib_srcs *.c)
|
||||
file(GLOB lib_hdrs *.h)
|
||||
|
||||
if(NEON AND ARM)
|
||||
list(APPEND lib_srcs arm/filter_neon.S)
|
||||
add_definitions(-DPNG_ARM_NEON)
|
||||
|
||||
if(ENABLE_NEON)
|
||||
list(APPEND lib_srcs arm/arm_init.c arm/filter_neon.S arm/filter_neon_intrinsics.c)
|
||||
add_definitions(-DPNG_ARM_NEON_OPT=2)
|
||||
endif()
|
||||
|
||||
# ----------------------------------------------------------------------------------
|
||||
# Define the library target:
|
||||
# ----------------------------------------------------------------------------------
|
||||
|
||||
add_definitions(-DPNG_CONFIGURE_LIBPNG)
|
||||
|
||||
if(MSVC)
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
endif(MSVC)
|
||||
|
55
3rdparty/libpng/LICENSE
vendored
@ -10,21 +10,18 @@ this sentence.
|
||||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.5.12, July 11, 2012, are
|
||||
Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are
|
||||
distributed according to the same disclaimer and license as libpng-1.2.5
|
||||
with the following individual added to the list of Contributing Authors
|
||||
|
||||
Cosmin Truta
|
||||
|
||||
libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
|
||||
Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
|
||||
distributed according to the same disclaimer and license as libpng-1.0.6
|
||||
with the following individuals added to the list of Contributing Authors
|
||||
libpng versions 1.0.7, July 1, 2000, through 1.6.19, November 12, 2015, are
|
||||
Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, are
|
||||
derived from libpng-1.0.6, and are distributed according to the same
|
||||
disclaimer and license as libpng-1.0.6 with the following individuals
|
||||
added to the list of Contributing Authors:
|
||||
|
||||
Simon-Pierre Cadieux
|
||||
Eric S. Raymond
|
||||
Mans Rullgard
|
||||
Cosmin Truta
|
||||
Gilles Vollant
|
||||
James Yu
|
||||
|
||||
and with the following additions to the disclaimer:
|
||||
|
||||
@ -36,18 +33,20 @@ and with the following additions to the disclaimer:
|
||||
the user.
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
||||
Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are
|
||||
distributed according to the same disclaimer and license as libpng-0.96,
|
||||
with the following individuals added to the list of Contributing Authors:
|
||||
Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
|
||||
libpng-0.96, and are distributed according to the same disclaimer and
|
||||
license as libpng-0.96, with the following individuals added to the list
|
||||
of Contributing Authors:
|
||||
|
||||
Tom Lane
|
||||
Glenn Randers-Pehrson
|
||||
Willem van Schaik
|
||||
|
||||
libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
||||
Copyright (c) 1996, 1997 Andreas Dilger
|
||||
Distributed according to the same disclaimer and license as libpng-0.88,
|
||||
with the following individuals added to the list of Contributing Authors:
|
||||
Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
|
||||
and are distributed according to the same disclaimer and license as
|
||||
libpng-0.88, with the following individuals added to the list of
|
||||
Contributing Authors:
|
||||
|
||||
John Bowler
|
||||
Kevin Bracey
|
||||
@ -57,7 +56,7 @@ with the following individuals added to the list of Contributing Authors:
|
||||
Tom Tanner
|
||||
|
||||
libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
|
||||
For the purposes of this copyright and license, "Contributing Authors"
|
||||
is defined as the following set of individuals:
|
||||
@ -80,13 +79,13 @@ Permission is hereby granted to use, copy, modify, and distribute this
|
||||
source code, or portions hereof, for any purpose, without fee, subject
|
||||
to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented.
|
||||
1. The origin of this source code must not be misrepresented.
|
||||
|
||||
2. Altered versions must be plainly marked as such and must not
|
||||
be misrepresented as being the original source.
|
||||
2. Altered versions must be plainly marked as such and must not
|
||||
be misrepresented as being the original source.
|
||||
|
||||
3. This Copyright notice may not be removed or altered from any
|
||||
source or altered source distribution.
|
||||
3. This Copyright notice may not be removed or altered from any
|
||||
source or altered source distribution.
|
||||
|
||||
The Contributing Authors and Group 42, Inc. specifically permit, without
|
||||
fee, and encourage the use of this source code as a component to
|
||||
@ -94,18 +93,20 @@ supporting the PNG file format in commercial products. If you use this
|
||||
source code in a product, acknowledgment is not required but would be
|
||||
appreciated.
|
||||
|
||||
END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
|
||||
|
||||
A "png_get_copyright" function is available, for convenient use in "about"
|
||||
boxes and the like:
|
||||
|
||||
printf("%s",png_get_copyright(NULL));
|
||||
printf("%s", png_get_copyright(NULL));
|
||||
|
||||
Also, the PNG logo (in PNG format, of course) is supplied in the
|
||||
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
|
||||
|
||||
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
|
||||
certification mark of the Open Source Initiative.
|
||||
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
|
||||
a certification mark of the Open Source Initiative. OSI has not addressed
|
||||
the additional disclaimers inserted at version 1.0.7.
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
July 11, 2012
|
||||
November 12, 2015
|
||||
|
63
3rdparty/libpng/README
vendored
@ -1,11 +1,11 @@
|
||||
README for libpng version 1.5.12 - July 11, 2012 (shared library 15.0)
|
||||
README for libpng version 1.6.19 - November 12, 2015 (shared library 16.0)
|
||||
See the note about version numbers near the top of png.h
|
||||
|
||||
See INSTALL for instructions on how to install libpng.
|
||||
|
||||
Libpng comes in several distribution formats. Get libpng-*.tar.gz,
|
||||
libpng-*.tar.xz or libpng-*.tar.bz2 if you want UNIX-style line endings
|
||||
in the text files, or lpng*.zip if you want DOS-style line endings.
|
||||
Libpng comes in several distribution formats. Get libpng-*.tar.gz or
|
||||
libpng-*.tar.xz or if you want UNIX-style line endings in the text files,
|
||||
or lpng*.7z or lpng*.zip if you want DOS-style line endings.
|
||||
|
||||
Version 0.89 was the first official release of libpng. Don't let the
|
||||
fact that it's the first release fool you. The libpng library has been in
|
||||
@ -23,18 +23,25 @@ earlier versions if you are using a shared library. The type of the
|
||||
png_uint_32, which will affect shared-library applications that use
|
||||
this function.
|
||||
|
||||
To avoid problems with changes to the internals of png_info_struct,
|
||||
To avoid problems with changes to the internals of png info_struct,
|
||||
new APIs have been made available in 0.95 to avoid direct application
|
||||
access to info_ptr. These functions are the png_set_<chunk> and
|
||||
png_get_<chunk> functions. These functions should be used when
|
||||
accessing/storing the info_struct data, rather than manipulating it
|
||||
directly, to avoid such problems in the future.
|
||||
|
||||
It is important to note that the APIs do not make current programs
|
||||
It is important to note that the APIs did not make current programs
|
||||
that access the info struct directly incompatible with the new
|
||||
library. However, it is strongly suggested that new programs use
|
||||
the new APIs (as shown in example.c and pngtest.c), and older programs
|
||||
be converted to the new format, to facilitate upgrades in the future.
|
||||
library, through libpng-1.2.x. In libpng-1.4.x, which was meant to
|
||||
be a transitional release, members of the png_struct and the
|
||||
info_struct can still be accessed, but the compiler will issue a
|
||||
warning about deprecated usage. Since libpng-1.5.0, direct access
|
||||
to these structs is not allowed, and the definitions of the structs
|
||||
reside in private pngstruct.h and pnginfo.h header files that are not
|
||||
accessible to applications. It is strongly suggested that new
|
||||
programs use the new APIs (as shown in example.c and pngtest.c), and
|
||||
older programs be converted to the new format, to facilitate upgrades
|
||||
in the future.
|
||||
****
|
||||
|
||||
Additions since 0.90 include the ability to compile libpng as a
|
||||
@ -77,17 +84,21 @@ compression library that is useful for more things than just PNG files.
|
||||
You can use zlib as a drop-in replacement for fread() and fwrite() if
|
||||
you are so inclined.
|
||||
|
||||
zlib should be available at the same place that libpng is, or at.
|
||||
ftp://ftp.info-zip.org/pub/infozip/zlib
|
||||
zlib should be available at the same place that libpng is, or at zlib.net.
|
||||
|
||||
You may also want a copy of the PNG specification. It is available
|
||||
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
|
||||
these at http://www.libpng.org/pub/png/documents/
|
||||
|
||||
This code is currently being archived at libpng.sf.net in the
|
||||
[DOWNLOAD] area, and on CompuServe, Lib 20 (PNG SUPPORT)
|
||||
at GO GRAPHSUP. If you can't find it in any of those places,
|
||||
e-mail me, and I'll help you find it.
|
||||
[DOWNLOAD] area, and at ftp://ftp.simplesystems.org. If you can't find it
|
||||
in any of those places, e-mail me, and I'll help you find it.
|
||||
|
||||
I am not a lawyer, but I believe that the Export Control Classification
|
||||
Number (ECCN) for libpng is EAR99, which means not subject to export
|
||||
controls or International Traffic in Arms Regulations (ITAR) because it
|
||||
is open source, publicly available software, that does not contain any
|
||||
encryption software. See the EAR, paragraphs 734.3(b)(3) and 734.7(b).
|
||||
|
||||
If you have any code changes, requests, problems, etc., please e-mail
|
||||
them to me. Also, I'd appreciate any make files or project files,
|
||||
@ -105,7 +116,7 @@ based in a large way on Guy's and Andreas' earlier work), and the PNG
|
||||
development group.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at
|
||||
lists.sourceforge.net (subscription required; visit
|
||||
lists.sourceforge.net (subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
to subscribe) or to glennrp at users.sourceforge.net
|
||||
|
||||
@ -123,7 +134,7 @@ and ...". If in doubt, send questions to me. I'll bounce them
|
||||
to others, if necessary.
|
||||
|
||||
Please do not send suggestions on how to change PNG. We have
|
||||
been discussing PNG for sixteen years now, and it is official and
|
||||
been discussing PNG for twenty years now, and it is official and
|
||||
finished. If you have suggestions for libpng, however, I'll
|
||||
gladly listen. Even if your suggestion is not used immediately,
|
||||
it may be used later.
|
||||
@ -167,23 +178,25 @@ Files in this distribution:
|
||||
pngwrite.c => High-level write functions
|
||||
pngwtran.c => Write data transformations
|
||||
pngwutil.c => Write utility functions
|
||||
arm => Contains optimized code for the ARM platform
|
||||
contrib => Contributions
|
||||
examples => Example programs
|
||||
gregbook => source code for PNG reading and writing, from
|
||||
Greg Roelofs' "PNG: The Definitive Guide",
|
||||
O'Reilly, 1999
|
||||
msvctest => Builds and runs pngtest using a MSVC workspace
|
||||
pngminus => Simple pnm2png and png2pnm programs
|
||||
pngsuite => Test images
|
||||
visupng => Contains a MSVC workspace for VisualPng
|
||||
libtests => Test programs
|
||||
pngminim => Minimal decoder, encoder, and progressive decoder
|
||||
programs demonstrating use of pngusr.dfa
|
||||
pngminus => Simple pnm2png and png2pnm programs
|
||||
pngsuite => Test images
|
||||
tools => Various tools
|
||||
visupng => Contains a MSVC workspace for VisualPng
|
||||
projects => Contains project files and workspaces for
|
||||
building a DLL
|
||||
cbuilder5 => Contains a Borland workspace for building
|
||||
libpng and zlib
|
||||
visualc6 => Contains a Microsoft Visual C++ (MSVC)
|
||||
workspace for building libpng and zlib
|
||||
owatcom => Contains a WATCOM project for building libpng
|
||||
visualc71 => Contains a Microsoft Visual C++ (MSVC)
|
||||
workspace for building libpng and zlib
|
||||
xcode => Contains an Apple xcode
|
||||
vstudio => Contains a Microsoft Visual C++ (MSVC)
|
||||
workspace for building libpng and zlib
|
||||
scripts => Directory containing scripts for building libpng:
|
||||
(see scripts/README.txt for the list of scripts)
|
||||
|
134
3rdparty/libpng/arm/arm_init.c
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
|
||||
/* arm_init.c - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.6.16 [December 22, 2014]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
/* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are
|
||||
* called.
|
||||
*/
|
||||
#define _POSIX_SOURCE 1
|
||||
|
||||
#include "../pngpriv.h"
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED /* Do run-time checks */
|
||||
/* WARNING: it is strongly recommended that you do not build libpng with
|
||||
* run-time checks for CPU features if at all possible. In the case of the ARM
|
||||
* NEON instructions there is no processor-specific way of detecting the
|
||||
* presence of the required support, therefore run-time detection is extremely
|
||||
* OS specific.
|
||||
*
|
||||
* You may set the macro PNG_ARM_NEON_FILE to the file name of file containing
|
||||
* a fragment of C source code which defines the png_have_neon function. There
|
||||
* are a number of implementations in contrib/arm-neon, but the only one that
|
||||
* has partial support is contrib/arm-neon/linux.c - a generic Linux
|
||||
* implementation which reads /proc/cpufino.
|
||||
*/
|
||||
#ifndef PNG_ARM_NEON_FILE
|
||||
# ifdef __linux__
|
||||
# define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_ARM_NEON_FILE
|
||||
|
||||
#include <signal.h> /* for sig_atomic_t */
|
||||
static int png_have_neon(png_structp png_ptr);
|
||||
#include PNG_ARM_NEON_FILE
|
||||
|
||||
#else /* PNG_ARM_NEON_FILE */
|
||||
# error "PNG_ARM_NEON_FILE undefined: no support for run-time ARM NEON checks"
|
||||
#endif /* PNG_ARM_NEON_FILE */
|
||||
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
|
||||
|
||||
#ifndef PNG_ALIGNED_MEMORY_SUPPORTED
|
||||
# error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED"
|
||||
#endif
|
||||
|
||||
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)
|
||||
{
|
||||
case PNG_OPTION_UNSET:
|
||||
/* Allow the run-time check to execute if it has been enabled -
|
||||
* thus both API and CHECK can be turned on. If it isn't supported
|
||||
* this case will fall through to the 'default' below, which just
|
||||
* returns.
|
||||
*/
|
||||
#endif /* PNG_ARM_NEON_API_SUPPORTED */
|
||||
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED
|
||||
{
|
||||
static volatile sig_atomic_t no_neon = -1; /* not checked */
|
||||
|
||||
if (no_neon < 0)
|
||||
no_neon = !png_have_neon(pp);
|
||||
|
||||
if (no_neon)
|
||||
return;
|
||||
}
|
||||
#ifdef PNG_ARM_NEON_API_SUPPORTED
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* IMPORTANT: any new external functions used here must be declared using
|
||||
* PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the
|
||||
* 'prefix' option to configure works:
|
||||
*
|
||||
* ./configure --with-libpng-prefix=foobar_
|
||||
*
|
||||
* Verify you have got this right by running the above command, doing a build
|
||||
* and examining pngprefix.h; it must contain a #define for every external
|
||||
* function you add. (Notice that this happens automatically for the
|
||||
* initialization function.)
|
||||
*/
|
||||
pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_neon;
|
||||
|
||||
if (bpp == 3)
|
||||
{
|
||||
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_neon;
|
||||
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_neon;
|
||||
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
|
||||
png_read_filter_row_paeth3_neon;
|
||||
}
|
||||
|
||||
else if (bpp == 4)
|
||||
{
|
||||
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_neon;
|
||||
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_neon;
|
||||
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
|
||||
png_read_filter_row_paeth4_neon;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||
#endif /* READ */
|
58
3rdparty/libpng/arm/filter_neon.S
vendored
@ -1,18 +1,36 @@
|
||||
|
||||
/* filter_neon.S - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2011 Glenn Randers-Pehrson
|
||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.6.16 [December 22, 2014]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
/* This is required to get the symbol renames, which are #defines, and the
|
||||
* definitions (or not) of PNG_ARM_NEON_OPT and PNG_ARM_NEON_IMPLEMENTATION.
|
||||
*/
|
||||
#define PNG_VERSION_INFO_ONLY
|
||||
#include "../pngpriv.h"
|
||||
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
/* Assembler NEON support - only works for 32-bit ARM (i.e. it does not work for
|
||||
* ARM64). The code in arm/filter_neon_intrinsics.c supports ARM64, however it
|
||||
* only works if -mfpu=neon is specified on the GCC command line. See pngpriv.h
|
||||
* for the logic which sets PNG_USE_ARM_NEON_ASM:
|
||||
*/
|
||||
#if PNG_ARM_NEON_IMPLEMENTATION == 2 /* hand-coded assembler */
|
||||
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
|
||||
#ifdef __ELF__
|
||||
# define ELF
|
||||
#else
|
||||
@ -29,6 +47,13 @@ ELF .size \name, . - \name
|
||||
.purgem endfunc
|
||||
.endm
|
||||
.text
|
||||
|
||||
/* Explicitly specifying alignment here because some versions of
|
||||
* GAS don't align code correctly. This is harmless in correctly
|
||||
* written versions of GAS.
|
||||
*/
|
||||
.align 2
|
||||
|
||||
.if \export
|
||||
.global \name
|
||||
.endif
|
||||
@ -41,12 +66,12 @@ func png_read_filter_row_sub4_neon, export=1
|
||||
ldr r3, [r0, #4] @ rowbytes
|
||||
vmov.i8 d3, #0
|
||||
1:
|
||||
vld4.32 {d4[],d5[],d6[],d7[]}, [r1]
|
||||
vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128]
|
||||
vadd.u8 d0, d3, d4
|
||||
vadd.u8 d1, d0, d5
|
||||
vadd.u8 d2, d1, d6
|
||||
vadd.u8 d3, d2, d7
|
||||
vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1]!
|
||||
vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]!
|
||||
subs r3, r3, #16
|
||||
bgt 1b
|
||||
|
||||
@ -67,7 +92,7 @@ func png_read_filter_row_sub3_neon, export=1
|
||||
vadd.u8 d1, d0, d5
|
||||
vext.8 d7, d23, d23, #1
|
||||
vld1.8 {q11}, [r0], r12
|
||||
vst1.32 {d0[0]}, [r1], r2
|
||||
vst1.32 {d0[0]}, [r1,:32], r2
|
||||
vadd.u8 d2, d1, d6
|
||||
vst1.32 {d1[0]}, [r1], r2
|
||||
vadd.u8 d3, d2, d7
|
||||
@ -82,10 +107,10 @@ endfunc
|
||||
func png_read_filter_row_up_neon, export=1
|
||||
ldr r3, [r0, #4] @ rowbytes
|
||||
1:
|
||||
vld1.8 {q0}, [r1]
|
||||
vld1.8 {q1}, [r2]!
|
||||
vld1.8 {q0}, [r1,:128]
|
||||
vld1.8 {q1}, [r2,:128]!
|
||||
vadd.u8 q0, q0, q1
|
||||
vst1.8 {q0}, [r1]!
|
||||
vst1.8 {q0}, [r1,:128]!
|
||||
subs r3, r3, #16
|
||||
bgt 1b
|
||||
|
||||
@ -96,8 +121,8 @@ func png_read_filter_row_avg4_neon, export=1
|
||||
ldr r12, [r0, #4] @ rowbytes
|
||||
vmov.i8 d3, #0
|
||||
1:
|
||||
vld4.32 {d4[],d5[],d6[],d7[]}, [r1]
|
||||
vld4.32 {d16[],d17[],d18[],d19[]},[r2]!
|
||||
vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128]
|
||||
vld4.32 {d16[],d17[],d18[],d19[]},[r2,:128]!
|
||||
vhadd.u8 d0, d3, d16
|
||||
vadd.u8 d0, d0, d4
|
||||
vhadd.u8 d1, d0, d17
|
||||
@ -106,7 +131,7 @@ func png_read_filter_row_avg4_neon, export=1
|
||||
vadd.u8 d2, d2, d6
|
||||
vhadd.u8 d3, d2, d19
|
||||
vadd.u8 d3, d3, d7
|
||||
vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1]!
|
||||
vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]!
|
||||
subs r12, r12, #16
|
||||
bgt 1b
|
||||
|
||||
@ -133,7 +158,7 @@ func png_read_filter_row_avg3_neon, export=1
|
||||
vadd.u8 d1, d1, d5
|
||||
vext.8 d7, d23, d23, #1
|
||||
vld1.8 {q11}, [r0], lr
|
||||
vst1.32 {d0[0]}, [r1], r4
|
||||
vst1.32 {d0[0]}, [r1,:32], r4
|
||||
vhadd.u8 d2, d1, d18
|
||||
vst1.32 {d1[0]}, [r1], r4
|
||||
vext.8 d19, d21, d21, #1
|
||||
@ -169,8 +194,8 @@ func png_read_filter_row_paeth4_neon, export=1
|
||||
vmov.i8 d3, #0
|
||||
vmov.i8 d20, #0
|
||||
1:
|
||||
vld4.32 {d4[],d5[],d6[],d7[]}, [r1]
|
||||
vld4.32 {d16[],d17[],d18[],d19[]},[r2]!
|
||||
vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128]
|
||||
vld4.32 {d16[],d17[],d18[],d19[]},[r2,:128]!
|
||||
paeth d0, d3, d16, d20
|
||||
vadd.u8 d0, d0, d4
|
||||
paeth d1, d0, d17, d16
|
||||
@ -180,7 +205,7 @@ func png_read_filter_row_paeth4_neon, export=1
|
||||
paeth d3, d2, d19, d18
|
||||
vmov d20, d19
|
||||
vadd.u8 d3, d3, d7
|
||||
vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1]!
|
||||
vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]!
|
||||
subs r12, r12, #16
|
||||
bgt 1b
|
||||
|
||||
@ -203,7 +228,7 @@ func png_read_filter_row_paeth3_neon, export=1
|
||||
vadd.u8 d0, d0, d22
|
||||
vext.8 d17, d20, d21, #3
|
||||
paeth d1, d0, d17, d20
|
||||
vst1.32 {d0[0]}, [r1], r4
|
||||
vst1.32 {d0[0]}, [r1,:32], r4
|
||||
vext.8 d6, d22, d23, #6
|
||||
vadd.u8 d1, d1, d5
|
||||
vext.8 d18, d20, d21, #6
|
||||
@ -223,3 +248,6 @@ func png_read_filter_row_paeth3_neon, export=1
|
||||
|
||||
pop {r4,pc}
|
||||
endfunc
|
||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||
#endif /* PNG_ARM_NEON_IMPLEMENTATION == 2 (assembler) */
|
||||
#endif /* READ */
|
||||
|
373
3rdparty/libpng/arm/filter_neon_intrinsics.c
vendored
Normal file
@ -0,0 +1,373 @@
|
||||
|
||||
/* filter_neon_intrinsics.c - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||
* Written by James Yu <james.yu at linaro.org>, October 2013.
|
||||
* Based on filter_neon.S, written by Mans Rullgard, 2011.
|
||||
*
|
||||
* Last changed in libpng 1.6.16 [December 22, 2014]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
#include "../pngpriv.h"
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
/* This code requires -mfpu=neon on the command line: */
|
||||
#if PNG_ARM_NEON_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
|
||||
|
||||
#include <arm_neon.h>
|
||||
|
||||
/* libpng row pointers are not necessarily aligned to any particular boundary,
|
||||
* however this code will only work with appropriate alignment. arm/arm_init.c
|
||||
* checks for this (and will not compile unless it is done). This code uses
|
||||
* variants of png_aligncast to avoid compiler warnings.
|
||||
*/
|
||||
#define png_ptr(type,pointer) png_aligncast(type *,pointer)
|
||||
#define png_ptrc(type,pointer) png_aligncastconst(const type *,pointer)
|
||||
|
||||
/* The following relies on a variable 'temp_pointer' being declared with type
|
||||
* 'type'. This is written this way just to hide the GCC strict aliasing
|
||||
* warning; note that the code is safe because there never is an alias between
|
||||
* the input and output pointers.
|
||||
*/
|
||||
#define png_ldr(type,pointer)\
|
||||
(temp_pointer = png_ptr(type,pointer), *temp_pointer)
|
||||
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
|
||||
void
|
||||
png_read_filter_row_up_neon(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_bytep rp_stop = row + row_info->rowbytes;
|
||||
png_const_bytep pp = prev_row;
|
||||
|
||||
for (; rp < rp_stop; rp += 16, pp += 16)
|
||||
{
|
||||
uint8x16_t qrp, qpp;
|
||||
|
||||
qrp = vld1q_u8(rp);
|
||||
qpp = vld1q_u8(pp);
|
||||
qrp = vaddq_u8(qrp, qpp);
|
||||
vst1q_u8(rp, qrp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
png_read_filter_row_sub3_neon(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_bytep rp_stop = row + row_info->rowbytes;
|
||||
|
||||
uint8x16_t vtmp = vld1q_u8(rp);
|
||||
uint8x8x2_t *vrpt = png_ptr(uint8x8x2_t, &vtmp);
|
||||
uint8x8x2_t vrp = *vrpt;
|
||||
|
||||
uint8x8x4_t vdest;
|
||||
vdest.val[3] = vdup_n_u8(0);
|
||||
|
||||
for (; rp < rp_stop;)
|
||||
{
|
||||
uint8x8_t vtmp1, vtmp2;
|
||||
uint32x2_t *temp_pointer;
|
||||
|
||||
vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3);
|
||||
vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]);
|
||||
vtmp2 = vext_u8(vrp.val[0], vrp.val[1], 6);
|
||||
vdest.val[1] = vadd_u8(vdest.val[0], vtmp1);
|
||||
|
||||
vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1);
|
||||
vdest.val[2] = vadd_u8(vdest.val[1], vtmp2);
|
||||
vdest.val[3] = vadd_u8(vdest.val[2], vtmp1);
|
||||
|
||||
vtmp = vld1q_u8(rp + 12);
|
||||
vrpt = png_ptr(uint8x8x2_t, &vtmp);
|
||||
vrp = *vrpt;
|
||||
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0);
|
||||
rp += 3;
|
||||
}
|
||||
|
||||
PNG_UNUSED(prev_row)
|
||||
}
|
||||
|
||||
void
|
||||
png_read_filter_row_sub4_neon(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_bytep rp_stop = row + row_info->rowbytes;
|
||||
|
||||
uint8x8x4_t vdest;
|
||||
vdest.val[3] = vdup_n_u8(0);
|
||||
|
||||
for (; rp < rp_stop; rp += 16)
|
||||
{
|
||||
uint32x2x4_t vtmp = vld4_u32(png_ptr(uint32_t,rp));
|
||||
uint8x8x4_t *vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
||||
uint8x8x4_t vrp = *vrpt;
|
||||
uint32x2x4_t *temp_pointer;
|
||||
|
||||
vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]);
|
||||
vdest.val[1] = vadd_u8(vdest.val[0], vrp.val[1]);
|
||||
vdest.val[2] = vadd_u8(vdest.val[1], vrp.val[2]);
|
||||
vdest.val[3] = vadd_u8(vdest.val[2], vrp.val[3]);
|
||||
vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0);
|
||||
}
|
||||
|
||||
PNG_UNUSED(prev_row)
|
||||
}
|
||||
|
||||
void
|
||||
png_read_filter_row_avg3_neon(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_const_bytep pp = prev_row;
|
||||
png_bytep rp_stop = row + row_info->rowbytes;
|
||||
|
||||
uint8x16_t vtmp;
|
||||
uint8x8x2_t *vrpt;
|
||||
uint8x8x2_t vrp;
|
||||
uint8x8x4_t vdest;
|
||||
vdest.val[3] = vdup_n_u8(0);
|
||||
|
||||
vtmp = vld1q_u8(rp);
|
||||
vrpt = png_ptr(uint8x8x2_t,&vtmp);
|
||||
vrp = *vrpt;
|
||||
|
||||
for (; rp < rp_stop; pp += 12)
|
||||
{
|
||||
uint8x8_t vtmp1, vtmp2, vtmp3;
|
||||
|
||||
uint8x8x2_t *vppt;
|
||||
uint8x8x2_t vpp;
|
||||
|
||||
uint32x2_t *temp_pointer;
|
||||
|
||||
vtmp = vld1q_u8(pp);
|
||||
vppt = png_ptr(uint8x8x2_t,&vtmp);
|
||||
vpp = *vppt;
|
||||
|
||||
vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3);
|
||||
vdest.val[0] = vhadd_u8(vdest.val[3], vpp.val[0]);
|
||||
vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
|
||||
|
||||
vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 3);
|
||||
vtmp3 = vext_u8(vrp.val[0], vrp.val[1], 6);
|
||||
vdest.val[1] = vhadd_u8(vdest.val[0], vtmp2);
|
||||
vdest.val[1] = vadd_u8(vdest.val[1], vtmp1);
|
||||
|
||||
vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 6);
|
||||
vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1);
|
||||
|
||||
vtmp = vld1q_u8(rp + 12);
|
||||
vrpt = png_ptr(uint8x8x2_t,&vtmp);
|
||||
vrp = *vrpt;
|
||||
|
||||
vdest.val[2] = vhadd_u8(vdest.val[1], vtmp2);
|
||||
vdest.val[2] = vadd_u8(vdest.val[2], vtmp3);
|
||||
|
||||
vtmp2 = vext_u8(vpp.val[1], vpp.val[1], 1);
|
||||
|
||||
vdest.val[3] = vhadd_u8(vdest.val[2], vtmp2);
|
||||
vdest.val[3] = vadd_u8(vdest.val[3], vtmp1);
|
||||
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0);
|
||||
rp += 3;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
png_read_filter_row_avg4_neon(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_bytep rp_stop = row + row_info->rowbytes;
|
||||
png_const_bytep pp = prev_row;
|
||||
|
||||
uint8x8x4_t vdest;
|
||||
vdest.val[3] = vdup_n_u8(0);
|
||||
|
||||
for (; rp < rp_stop; rp += 16, pp += 16)
|
||||
{
|
||||
uint32x2x4_t vtmp;
|
||||
uint8x8x4_t *vrpt, *vppt;
|
||||
uint8x8x4_t vrp, vpp;
|
||||
uint32x2x4_t *temp_pointer;
|
||||
|
||||
vtmp = vld4_u32(png_ptr(uint32_t,rp));
|
||||
vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
||||
vrp = *vrpt;
|
||||
vtmp = vld4_u32(png_ptrc(uint32_t,pp));
|
||||
vppt = png_ptr(uint8x8x4_t,&vtmp);
|
||||
vpp = *vppt;
|
||||
|
||||
vdest.val[0] = vhadd_u8(vdest.val[3], vpp.val[0]);
|
||||
vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
|
||||
vdest.val[1] = vhadd_u8(vdest.val[0], vpp.val[1]);
|
||||
vdest.val[1] = vadd_u8(vdest.val[1], vrp.val[1]);
|
||||
vdest.val[2] = vhadd_u8(vdest.val[1], vpp.val[2]);
|
||||
vdest.val[2] = vadd_u8(vdest.val[2], vrp.val[2]);
|
||||
vdest.val[3] = vhadd_u8(vdest.val[2], vpp.val[3]);
|
||||
vdest.val[3] = vadd_u8(vdest.val[3], vrp.val[3]);
|
||||
|
||||
vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0);
|
||||
}
|
||||
}
|
||||
|
||||
static uint8x8_t
|
||||
paeth(uint8x8_t a, uint8x8_t b, uint8x8_t c)
|
||||
{
|
||||
uint8x8_t d, e;
|
||||
uint16x8_t p1, pa, pb, pc;
|
||||
|
||||
p1 = vaddl_u8(a, b); /* a + b */
|
||||
pc = vaddl_u8(c, c); /* c * 2 */
|
||||
pa = vabdl_u8(b, c); /* pa */
|
||||
pb = vabdl_u8(a, c); /* pb */
|
||||
pc = vabdq_u16(p1, pc); /* pc */
|
||||
|
||||
p1 = vcleq_u16(pa, pb); /* pa <= pb */
|
||||
pa = vcleq_u16(pa, pc); /* pa <= pc */
|
||||
pb = vcleq_u16(pb, pc); /* pb <= pc */
|
||||
|
||||
p1 = vandq_u16(p1, pa); /* pa <= pb && pa <= pc */
|
||||
|
||||
d = vmovn_u16(pb);
|
||||
e = vmovn_u16(p1);
|
||||
|
||||
d = vbsl_u8(d, b, c);
|
||||
e = vbsl_u8(e, a, d);
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
void
|
||||
png_read_filter_row_paeth3_neon(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_const_bytep pp = prev_row;
|
||||
png_bytep rp_stop = row + row_info->rowbytes;
|
||||
|
||||
uint8x16_t vtmp;
|
||||
uint8x8x2_t *vrpt;
|
||||
uint8x8x2_t vrp;
|
||||
uint8x8_t vlast = vdup_n_u8(0);
|
||||
uint8x8x4_t vdest;
|
||||
vdest.val[3] = vdup_n_u8(0);
|
||||
|
||||
vtmp = vld1q_u8(rp);
|
||||
vrpt = png_ptr(uint8x8x2_t,&vtmp);
|
||||
vrp = *vrpt;
|
||||
|
||||
for (; rp < rp_stop; pp += 12)
|
||||
{
|
||||
uint8x8x2_t *vppt;
|
||||
uint8x8x2_t vpp;
|
||||
uint8x8_t vtmp1, vtmp2, vtmp3;
|
||||
uint32x2_t *temp_pointer;
|
||||
|
||||
vtmp = vld1q_u8(pp);
|
||||
vppt = png_ptr(uint8x8x2_t,&vtmp);
|
||||
vpp = *vppt;
|
||||
|
||||
vdest.val[0] = paeth(vdest.val[3], vpp.val[0], vlast);
|
||||
vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
|
||||
|
||||
vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3);
|
||||
vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 3);
|
||||
vdest.val[1] = paeth(vdest.val[0], vtmp2, vpp.val[0]);
|
||||
vdest.val[1] = vadd_u8(vdest.val[1], vtmp1);
|
||||
|
||||
vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 6);
|
||||
vtmp3 = vext_u8(vpp.val[0], vpp.val[1], 6);
|
||||
vdest.val[2] = paeth(vdest.val[1], vtmp3, vtmp2);
|
||||
vdest.val[2] = vadd_u8(vdest.val[2], vtmp1);
|
||||
|
||||
vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1);
|
||||
vtmp2 = vext_u8(vpp.val[1], vpp.val[1], 1);
|
||||
|
||||
vtmp = vld1q_u8(rp + 12);
|
||||
vrpt = png_ptr(uint8x8x2_t,&vtmp);
|
||||
vrp = *vrpt;
|
||||
|
||||
vdest.val[3] = paeth(vdest.val[2], vtmp2, vtmp3);
|
||||
vdest.val[3] = vadd_u8(vdest.val[3], vtmp1);
|
||||
|
||||
vlast = vtmp2;
|
||||
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0);
|
||||
rp += 3;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
png_read_filter_row_paeth4_neon(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_bytep rp_stop = row + row_info->rowbytes;
|
||||
png_const_bytep pp = prev_row;
|
||||
|
||||
uint8x8_t vlast = vdup_n_u8(0);
|
||||
uint8x8x4_t vdest;
|
||||
vdest.val[3] = vdup_n_u8(0);
|
||||
|
||||
for (; rp < rp_stop; rp += 16, pp += 16)
|
||||
{
|
||||
uint32x2x4_t vtmp;
|
||||
uint8x8x4_t *vrpt, *vppt;
|
||||
uint8x8x4_t vrp, vpp;
|
||||
uint32x2x4_t *temp_pointer;
|
||||
|
||||
vtmp = vld4_u32(png_ptr(uint32_t,rp));
|
||||
vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
||||
vrp = *vrpt;
|
||||
vtmp = vld4_u32(png_ptrc(uint32_t,pp));
|
||||
vppt = png_ptr(uint8x8x4_t,&vtmp);
|
||||
vpp = *vppt;
|
||||
|
||||
vdest.val[0] = paeth(vdest.val[3], vpp.val[0], vlast);
|
||||
vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
|
||||
vdest.val[1] = paeth(vdest.val[0], vpp.val[1], vpp.val[0]);
|
||||
vdest.val[1] = vadd_u8(vdest.val[1], vrp.val[1]);
|
||||
vdest.val[2] = paeth(vdest.val[1], vpp.val[2], vpp.val[1]);
|
||||
vdest.val[2] = vadd_u8(vdest.val[2], vrp.val[2]);
|
||||
vdest.val[3] = paeth(vdest.val[2], vpp.val[3], vpp.val[2]);
|
||||
vdest.val[3] = vadd_u8(vdest.val[3], vrp.val[3]);
|
||||
|
||||
vlast = vpp.val[3];
|
||||
|
||||
vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||
#endif /* PNG_ARM_NEON_IMPLEMENTATION == 1 (intrinsics) */
|
||||
#endif /* READ */
|
13
3rdparty/libpng/opencv-libpng.patch
vendored
@ -1,8 +1,6 @@
|
||||
diff --git a/3rdparty/libpng/pngpriv.h b/3rdparty/libpng/pngpriv.h
|
||||
index 07b2b0b..e7824b8 100644
|
||||
--- a/3rdparty/libpng/pngpriv.h
|
||||
+++ b/3rdparty/libpng/pngpriv.h
|
||||
@@ -360,7 +360,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
|
||||
@@ -457,7 +457,7 @@
|
||||
|
||||
/* Memory model/platform independent fns */
|
||||
#ifndef PNG_ABORT
|
||||
@ -11,12 +9,3 @@ index 07b2b0b..e7824b8 100644
|
||||
# define PNG_ABORT() ExitProcess(0)
|
||||
# else
|
||||
# define PNG_ABORT() abort()
|
||||
@@ -378,7 +378,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
|
||||
# define png_memcpy _fmemcpy
|
||||
# define png_memset _fmemset
|
||||
#else
|
||||
-# ifdef _WINDOWS_ /* Favor Windows over C runtime fns */
|
||||
+# if defined(_WINDOWS_) && !defined(WINRT) /* Favor Windows over C runtime fns */
|
||||
# define CVT_PTR(ptr) (ptr)
|
||||
# define CVT_PTR_NOCHECK(ptr) (ptr)
|
||||
# define png_strlen lstrlenA
|
||||
|
2808
3rdparty/libpng/png.c
vendored
2314
3rdparty/libpng/png.h
vendored
486
3rdparty/libpng/pngconf.h
vendored
@ -1,9 +1,9 @@
|
||||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng version 1.5.12 - July 11, 2012
|
||||
* libpng version 1.6.19, July 23, 2015
|
||||
*
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -11,9 +11,7 @@
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
*/
|
||||
|
||||
/* Any machine specific code is near the front of this file, so if you
|
||||
* Any machine specific code is near the front of this file, so if you
|
||||
* are configuring libpng for a machine, you may want to read the section
|
||||
* starting here down to where it starts to typedef png_color, png_text,
|
||||
* and png_info.
|
||||
@ -22,34 +20,50 @@
|
||||
#ifndef PNGCONF_H
|
||||
#define PNGCONF_H
|
||||
|
||||
#ifndef PNG_BUILDING_SYMBOL_TABLE
|
||||
/* PNG_NO_LIMITS_H may be used to turn off the use of the standard C
|
||||
* definition file for machine specific limits, this may impact the
|
||||
* correctness of the definitions below (see uses of INT_MAX).
|
||||
*/
|
||||
# ifndef PNG_NO_LIMITS_H
|
||||
# include <limits.h>
|
||||
# endif
|
||||
#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */
|
||||
|
||||
/* For the memory copy APIs (i.e. the standard definitions of these),
|
||||
* because this file defines png_memcpy and so on the base APIs must
|
||||
* be defined here.
|
||||
/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C
|
||||
* compiler for correct compilation. The following header files are required by
|
||||
* the standard. If your compiler doesn't provide these header files, or they
|
||||
* do not match the standard, you will need to provide/improve them.
|
||||
*/
|
||||
# ifdef BSD
|
||||
# include <strings.h>
|
||||
# else
|
||||
# include <string.h>
|
||||
# endif
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/* For png_FILE_p - this provides the standard definition of a
|
||||
* FILE
|
||||
/* Library header files. These header files are all defined by ISOC90; libpng
|
||||
* expects conformant implementations, however, an ISOC90 conformant system need
|
||||
* not provide these header files if the functionality cannot be implemented.
|
||||
* In this case it will be necessary to disable the relevant parts of libpng in
|
||||
* the build of pnglibconf.h.
|
||||
*
|
||||
* Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not
|
||||
* include this unnecessary header file.
|
||||
*/
|
||||
# ifdef PNG_STDIO_SUPPORTED
|
||||
# include <stdio.h>
|
||||
# endif
|
||||
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
/* Required for the definition of FILE: */
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
/* This controls optimization of the reading of 16 and 32 bit values
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
/* Required for the definition of jmp_buf and the declaration of longjmp: */
|
||||
# include <setjmp.h>
|
||||
#endif
|
||||
|
||||
#ifdef PNG_CONVERT_tIME_SUPPORTED
|
||||
/* Required for struct tm: */
|
||||
# include <time.h>
|
||||
#endif
|
||||
|
||||
#endif /* PNG_BUILDING_SYMBOL_TABLE */
|
||||
|
||||
/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using
|
||||
* PNG_NO_CONST; this is no longer supported except for data declarations which
|
||||
* apparently still cause problems in 2011 on some compilers.
|
||||
*/
|
||||
#define PNG_CONST const /* backward compatibility only */
|
||||
|
||||
/* This controls optimization of the reading of 16-bit and 32-bit values
|
||||
* from PNG files. It can be set on a per-app-file basis - it
|
||||
* just changes whether a macro is used when the function is called.
|
||||
* The library builder sets the default; if read functions are not
|
||||
@ -72,28 +86,13 @@
|
||||
* may be changed on a per-file basis when compiling against libpng.
|
||||
*/
|
||||
|
||||
/* The PNGARG macro protects us against machines that don't have function
|
||||
* prototypes (ie K&R style headers). If your compiler does not handle
|
||||
* function prototypes, define this macro and use the included ansi2knr.
|
||||
* I've always been able to use _NO_PROTO as the indicator, but you may
|
||||
* need to drag the empty declaration out in front of here, or change the
|
||||
* ifdef to suit your own needs.
|
||||
/* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect
|
||||
* against legacy (pre ISOC90) compilers that did not understand function
|
||||
* prototypes. It is not required for modern C compilers.
|
||||
*/
|
||||
#ifndef PNGARG
|
||||
|
||||
# ifdef OF /* zlib prototype munger */
|
||||
# define PNGARG(arglist) OF(arglist)
|
||||
# else
|
||||
|
||||
# ifdef _NO_PROTO
|
||||
# define PNGARG(arglist) ()
|
||||
# else
|
||||
# define PNGARG(arglist) arglist
|
||||
# endif /* _NO_PROTO */
|
||||
|
||||
# endif /* OF */
|
||||
|
||||
#endif /* PNGARG */
|
||||
# define PNGARG(arglist) arglist
|
||||
#endif
|
||||
|
||||
/* Function calling conventions.
|
||||
* =============================
|
||||
@ -177,18 +176,16 @@
|
||||
* ==========================
|
||||
* This code is used at build time to find PNG_IMPEXP, the API settings
|
||||
* and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL
|
||||
* import processing is possible. On Windows/x86 systems it also sets
|
||||
* import processing is possible. On Windows systems it also sets
|
||||
* compiler-specific macros to the values required to change the calling
|
||||
* conventions of the various functions.
|
||||
*/
|
||||
#if ( defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
|
||||
defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) ) &&\
|
||||
( defined(_X86_) || defined(_X64_) || defined(_M_IX86) ||\
|
||||
defined(_M_X64) || defined(_M_IA64) )
|
||||
/* Windows system (DOS doesn't support DLLs) running on x86/x64. Includes
|
||||
* builds under Cygwin or MinGW. Also includes Watcom builds but these need
|
||||
* special treatment because they are not compatible with GCC or Visual C
|
||||
* because of different calling conventions.
|
||||
#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
|
||||
defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
/* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or
|
||||
* MinGW on any architecture currently supported by Windows. Also includes
|
||||
* Watcom builds but these need special treatment because they are not
|
||||
* compatible with GCC or Visual C because of different calling conventions.
|
||||
*/
|
||||
# if PNG_API_RULE == 2
|
||||
/* If this line results in an error, either because __watcall is not
|
||||
@ -199,9 +196,12 @@
|
||||
# define PNGCAPI __watcall
|
||||
# endif
|
||||
|
||||
# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
|
||||
# if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800))
|
||||
# define PNGCAPI __cdecl
|
||||
# if PNG_API_RULE == 1
|
||||
/* If this line results in an error __stdcall is not understood and
|
||||
* PNG_API_RULE should not have been set to '1'.
|
||||
*/
|
||||
# define PNGAPI __stdcall
|
||||
# endif
|
||||
# else
|
||||
@ -216,10 +216,11 @@
|
||||
# define PNGAPI _stdcall
|
||||
# endif
|
||||
# endif /* compiler/api */
|
||||
|
||||
/* NOTE: PNGCBAPI always defaults to PNGCAPI. */
|
||||
|
||||
# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)
|
||||
ERROR: PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed
|
||||
# error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed"
|
||||
# endif
|
||||
|
||||
# if (defined(_MSC_VER) && _MSC_VER < 800) ||\
|
||||
@ -239,7 +240,7 @@
|
||||
# endif
|
||||
# endif /* compiler */
|
||||
|
||||
#else /* !Windows/x86 */
|
||||
#else /* !Windows */
|
||||
# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
|
||||
# define PNGAPI _System
|
||||
# else /* !Windows/x86 && !OS/2 */
|
||||
@ -294,11 +295,11 @@
|
||||
* table entries, so we discard it here. See the .dfn files in the
|
||||
* scripts directory.
|
||||
*/
|
||||
#ifndef PNG_EXPORTA
|
||||
|
||||
# define PNG_EXPORTA(ordinal, type, name, args, attributes)\
|
||||
PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \
|
||||
extern attributes)
|
||||
#ifndef PNG_EXPORTA
|
||||
# define PNG_EXPORTA(ordinal, type, name, args, attributes) \
|
||||
PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), PNGARG(args), \
|
||||
PNG_LINKAGE_API attributes)
|
||||
#endif
|
||||
|
||||
/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
|
||||
@ -306,7 +307,7 @@
|
||||
*/
|
||||
#define PNG_EMPTY /*empty list*/
|
||||
|
||||
#define PNG_EXPORT(ordinal, type, name, args)\
|
||||
#define PNG_EXPORT(ordinal, type, name, args) \
|
||||
PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)
|
||||
|
||||
/* Use PNG_REMOVED to comment out a removed interface. */
|
||||
@ -333,40 +334,73 @@
|
||||
|
||||
#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED
|
||||
/* Support for compiler specific function attributes. These are used
|
||||
* so that where compiler support is available incorrect use of API
|
||||
* so that where compiler support is available, incorrect use of API
|
||||
* functions in png.h will generate compiler warnings. Added at libpng
|
||||
* version 1.2.41.
|
||||
* version 1.2.41. Disabling these removes the warnings but may also produce
|
||||
* less efficient code.
|
||||
*/
|
||||
# if defined(__GNUC__)
|
||||
# if defined(__clang__) && defined(__has_attribute)
|
||||
/* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */
|
||||
# if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__)
|
||||
# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
|
||||
# endif
|
||||
# if !defined(PNG_NORETURN) && __has_attribute(__noreturn__)
|
||||
# define PNG_NORETURN __attribute__((__noreturn__))
|
||||
# endif
|
||||
# if !defined(PNG_ALLOCATED) && __has_attribute(__malloc__)
|
||||
# define PNG_ALLOCATED __attribute__((__malloc__))
|
||||
# endif
|
||||
# if !defined(PNG_DEPRECATED) && __has_attribute(__deprecated__)
|
||||
# define PNG_DEPRECATED __attribute__((__deprecated__))
|
||||
# endif
|
||||
# if !defined(PNG_PRIVATE)
|
||||
# ifdef __has_extension
|
||||
# if __has_extension(attribute_unavailable_with_message)
|
||||
# define PNG_PRIVATE __attribute__((__unavailable__(\
|
||||
"This function is not exported by libpng.")))
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
# ifndef PNG_RESTRICT
|
||||
# define PNG_RESTRICT __restrict
|
||||
# endif
|
||||
|
||||
# elif defined(__GNUC__)
|
||||
# ifndef PNG_USE_RESULT
|
||||
# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
|
||||
# endif
|
||||
# ifndef PNG_NORETURN
|
||||
# define PNG_NORETURN __attribute__((__noreturn__))
|
||||
# endif
|
||||
# ifndef PNG_ALLOCATED
|
||||
# define PNG_ALLOCATED __attribute__((__malloc__))
|
||||
# endif
|
||||
# ifndef PNG_DEPRECATED
|
||||
# define PNG_DEPRECATED __attribute__((__deprecated__))
|
||||
# endif
|
||||
# ifndef PNG_PRIVATE
|
||||
# if 0 /* Doesn't work so we use deprecated instead*/
|
||||
# define PNG_PRIVATE \
|
||||
__attribute__((warning("This function is not exported by libpng.")))
|
||||
# else
|
||||
# define PNG_PRIVATE \
|
||||
__attribute__((__deprecated__))
|
||||
# if __GNUC__ >= 3
|
||||
# ifndef PNG_ALLOCATED
|
||||
# define PNG_ALLOCATED __attribute__((__malloc__))
|
||||
# endif
|
||||
# endif
|
||||
# endif /* __GNUC__ */
|
||||
# ifndef PNG_DEPRECATED
|
||||
# define PNG_DEPRECATED __attribute__((__deprecated__))
|
||||
# endif
|
||||
# ifndef PNG_PRIVATE
|
||||
# if 0 /* Doesn't work so we use deprecated instead*/
|
||||
# define PNG_PRIVATE \
|
||||
__attribute__((warning("This function is not exported by libpng.")))
|
||||
# else
|
||||
# define PNG_PRIVATE \
|
||||
__attribute__((__deprecated__))
|
||||
# endif
|
||||
# endif
|
||||
# if ((__GNUC__ > 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1))
|
||||
# ifndef PNG_RESTRICT
|
||||
# define PNG_RESTRICT __restrict
|
||||
# endif
|
||||
# endif /* __GNUC__.__GNUC_MINOR__ > 3.0 */
|
||||
# endif /* __GNUC__ >= 3 */
|
||||
|
||||
# if defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
# elif defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
# ifndef PNG_USE_RESULT
|
||||
# define PNG_USE_RESULT /* not supported */
|
||||
# endif
|
||||
# ifndef PNG_NORETURN
|
||||
# define PNG_NORETURN __declspec(noreturn)
|
||||
# define PNG_NORETURN __declspec(noreturn)
|
||||
# endif
|
||||
# ifndef PNG_ALLOCATED
|
||||
# if (_MSC_VER >= 1400)
|
||||
@ -379,7 +413,17 @@
|
||||
# ifndef PNG_PRIVATE
|
||||
# define PNG_PRIVATE __declspec(deprecated)
|
||||
# endif
|
||||
# endif /* _MSC_VER */
|
||||
# ifndef PNG_RESTRICT
|
||||
# if (_MSC_VER >= 1400)
|
||||
# define PNG_RESTRICT __restrict
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# elif defined(__WATCOMC__)
|
||||
# ifndef PNG_RESTRICT
|
||||
# define PNG_RESTRICT __restrict
|
||||
# endif
|
||||
# endif
|
||||
#endif /* PNG_PEDANTIC_WARNINGS */
|
||||
|
||||
#ifndef PNG_DEPRECATED
|
||||
@ -397,10 +441,14 @@
|
||||
#ifndef PNG_PRIVATE
|
||||
# define PNG_PRIVATE /* This is a private libpng function */
|
||||
#endif
|
||||
#ifndef PNG_RESTRICT
|
||||
# define PNG_RESTRICT /* The C99 "restrict" feature */
|
||||
#endif
|
||||
|
||||
#ifndef PNG_FP_EXPORT /* A floating point API. */
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
# define PNG_FP_EXPORT(ordinal, type, name, args)\
|
||||
PNG_EXPORT(ordinal, type, name, args)
|
||||
PNG_EXPORT(ordinal, type, name, args);
|
||||
# else /* No floating point APIs */
|
||||
# define PNG_FP_EXPORT(ordinal, type, name, args)
|
||||
# endif
|
||||
@ -408,189 +456,167 @@
|
||||
#ifndef PNG_FIXED_EXPORT /* A fixed point API. */
|
||||
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
# define PNG_FIXED_EXPORT(ordinal, type, name, args)\
|
||||
PNG_EXPORT(ordinal, type, name, args)
|
||||
PNG_EXPORT(ordinal, type, name, args);
|
||||
# else /* No fixed point APIs */
|
||||
# define PNG_FIXED_EXPORT(ordinal, type, name, args)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The following uses const char * instead of char * for error
|
||||
* and warning message functions, so some compilers won't complain.
|
||||
* If you do not want to use const, define PNG_NO_CONST here.
|
||||
#ifndef PNG_BUILDING_SYMBOL_TABLE
|
||||
/* Some typedefs to get us started. These should be safe on most of the common
|
||||
* platforms.
|
||||
*
|
||||
* This should not change how the APIs are called, so it can be done
|
||||
* on a per-file basis in the application.
|
||||
* png_uint_32 and png_int_32 may, currently, be larger than required to hold a
|
||||
* 32-bit value however this is not normally advisable.
|
||||
*
|
||||
* png_uint_16 and png_int_16 should always be two bytes in size - this is
|
||||
* verified at library build time.
|
||||
*
|
||||
* png_byte must always be one byte in size.
|
||||
*
|
||||
* The checks below use constants from limits.h, as defined by the ISOC90
|
||||
* standard.
|
||||
*/
|
||||
#ifndef PNG_CONST
|
||||
# ifndef PNG_NO_CONST
|
||||
# define PNG_CONST const
|
||||
# else
|
||||
# define PNG_CONST
|
||||
# endif
|
||||
#if CHAR_BIT == 8 && UCHAR_MAX == 255
|
||||
typedef unsigned char png_byte;
|
||||
#else
|
||||
# error "libpng requires 8-bit bytes"
|
||||
#endif
|
||||
|
||||
/* Some typedefs to get us started. These should be safe on most of the
|
||||
* common platforms. The typedefs should be at least as large as the
|
||||
* numbers suggest (a png_uint_32 must be at least 32 bits long), but they
|
||||
* don't have to be exactly that size. Some compilers dislike passing
|
||||
* unsigned shorts as function parameters, so you may be better off using
|
||||
* unsigned int for png_uint_16.
|
||||
*/
|
||||
|
||||
#if defined(INT_MAX) && (INT_MAX > 0x7ffffffeL)
|
||||
typedef unsigned int png_uint_32;
|
||||
typedef int png_int_32;
|
||||
#if INT_MIN == -32768 && INT_MAX == 32767
|
||||
typedef int png_int_16;
|
||||
#elif SHRT_MIN == -32768 && SHRT_MAX == 32767
|
||||
typedef short png_int_16;
|
||||
#else
|
||||
typedef unsigned long png_uint_32;
|
||||
typedef long png_int_32;
|
||||
# error "libpng requires a signed 16-bit type"
|
||||
#endif
|
||||
typedef unsigned short png_uint_16;
|
||||
typedef short png_int_16;
|
||||
typedef unsigned char png_byte;
|
||||
|
||||
#ifdef PNG_NO_SIZE_T
|
||||
typedef unsigned int png_size_t;
|
||||
#if UINT_MAX == 65535
|
||||
typedef unsigned int png_uint_16;
|
||||
#elif USHRT_MAX == 65535
|
||||
typedef unsigned short png_uint_16;
|
||||
#else
|
||||
# error "libpng requires an unsigned 16-bit type"
|
||||
#endif
|
||||
|
||||
#if INT_MIN < -2147483646 && INT_MAX > 2147483646
|
||||
typedef int png_int_32;
|
||||
#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646
|
||||
typedef long int png_int_32;
|
||||
#else
|
||||
# error "libpng requires a signed 32-bit (or more) type"
|
||||
#endif
|
||||
|
||||
#if UINT_MAX > 4294967294
|
||||
typedef unsigned int png_uint_32;
|
||||
#elif ULONG_MAX > 4294967294
|
||||
typedef unsigned long int png_uint_32;
|
||||
#else
|
||||
# error "libpng requires an unsigned 32-bit (or more) type"
|
||||
#endif
|
||||
|
||||
/* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however,
|
||||
* requires an ISOC90 compiler and relies on consistent behavior of sizeof.
|
||||
*/
|
||||
typedef size_t png_size_t;
|
||||
#endif
|
||||
#define png_sizeof(x) (sizeof (x))
|
||||
typedef ptrdiff_t png_ptrdiff_t;
|
||||
|
||||
/* The following is needed for medium model support. It cannot be in the
|
||||
* pngpriv.h header. Needs modification for other compilers besides
|
||||
* MSC. Model independent support declares all arrays and pointers to be
|
||||
* large using the far keyword. The zlib version used must also support
|
||||
* model independent data. As of version zlib 1.0.4, the necessary changes
|
||||
* have been made in zlib. The USE_FAR_KEYWORD define triggers other
|
||||
* changes that are needed. (Tim Wegner)
|
||||
/* libpng needs to know the maximum value of 'size_t' and this controls the
|
||||
* definition of png_alloc_size_t, below. This maximum value of size_t limits
|
||||
* but does not control the maximum allocations the library makes - there is
|
||||
* direct application control of this through png_set_user_limits().
|
||||
*/
|
||||
|
||||
/* Separate compiler dependencies (problem here is that zlib.h always
|
||||
* defines FAR. (SJT)
|
||||
*/
|
||||
#ifdef __BORLANDC__
|
||||
# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
|
||||
# define LDATA 1
|
||||
# else
|
||||
# define LDATA 0
|
||||
# endif
|
||||
/* GRR: why is Cygwin in here? Cygwin is not Borland C... */
|
||||
# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)
|
||||
# define PNG_MAX_MALLOC_64K /* only used in build */
|
||||
# if (LDATA != 1)
|
||||
# ifndef FAR
|
||||
# define FAR __far
|
||||
# endif
|
||||
# define USE_FAR_KEYWORD
|
||||
# endif /* LDATA != 1 */
|
||||
/* Possibly useful for moving data out of default segment.
|
||||
* Uncomment it if you want. Could also define FARDATA as
|
||||
* const if your compiler supports it. (SJT)
|
||||
# define FARDATA FAR
|
||||
*/
|
||||
# endif /* __WIN32__, __FLAT__, __CYGWIN__ */
|
||||
#endif /* __BORLANDC__ */
|
||||
|
||||
|
||||
/* Suggest testing for specific compiler first before testing for
|
||||
* FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM,
|
||||
* making reliance oncertain keywords suspect. (SJT)
|
||||
*/
|
||||
|
||||
/* MSC Medium model */
|
||||
#ifdef FAR
|
||||
# ifdef M_I86MM
|
||||
# define USE_FAR_KEYWORD
|
||||
# define FARDATA FAR
|
||||
# include <dos.h>
|
||||
#ifndef PNG_SMALL_SIZE_T
|
||||
/* Compiler specific tests for systems where size_t is known to be less than
|
||||
* 32 bits (some of these systems may no longer work because of the lack of
|
||||
* 'far' support; see above.)
|
||||
*/
|
||||
# if (defined(__TURBOC__) && !defined(__FLAT__)) ||\
|
||||
(defined(_MSC_VER) && defined(MAXSEG_64K))
|
||||
# define PNG_SMALL_SIZE_T
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* SJT: default case */
|
||||
#ifndef FAR
|
||||
# define FAR
|
||||
/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no
|
||||
* smaller than png_uint_32. Casts from png_size_t or png_uint_32 to
|
||||
* png_alloc_size_t are not necessary; in fact, it is recommended not to use
|
||||
* them at all so that the compiler can complain when something turns out to be
|
||||
* problematic.
|
||||
*
|
||||
* Casts in the other direction (from png_alloc_size_t to png_size_t or
|
||||
* png_uint_32) should be explicitly applied; however, we do not expect to
|
||||
* encounter practical situations that require such conversions.
|
||||
*
|
||||
* PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than
|
||||
* 4294967295 - i.e. less than the maximum value of png_uint_32.
|
||||
*/
|
||||
#ifdef PNG_SMALL_SIZE_T
|
||||
typedef png_uint_32 png_alloc_size_t;
|
||||
#else
|
||||
typedef png_size_t png_alloc_size_t;
|
||||
#endif
|
||||
|
||||
/* At this point FAR is always defined */
|
||||
#ifndef FARDATA
|
||||
# define FARDATA
|
||||
#endif
|
||||
/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler
|
||||
* implementations of Intel CPU specific support of user-mode segmented address
|
||||
* spaces, where 16-bit pointers address more than 65536 bytes of memory using
|
||||
* separate 'segment' registers. The implementation requires two different
|
||||
* types of pointer (only one of which includes the segment value.)
|
||||
*
|
||||
* If required this support is available in version 1.2 of libpng and may be
|
||||
* available in versions through 1.5, although the correctness of the code has
|
||||
* not been verified recently.
|
||||
*/
|
||||
|
||||
/* Typedef for floating-point numbers that are converted
|
||||
* to fixed-point with a multiple of 100,000, e.g., gamma
|
||||
/* Typedef for floating-point numbers that are converted to fixed-point with a
|
||||
* multiple of 100,000, e.g., gamma
|
||||
*/
|
||||
typedef png_int_32 png_fixed_point;
|
||||
|
||||
/* Add typedefs for pointers */
|
||||
typedef void FAR * png_voidp;
|
||||
typedef PNG_CONST void FAR * png_const_voidp;
|
||||
typedef png_byte FAR * png_bytep;
|
||||
typedef PNG_CONST png_byte FAR * png_const_bytep;
|
||||
typedef png_uint_32 FAR * png_uint_32p;
|
||||
typedef PNG_CONST png_uint_32 FAR * png_const_uint_32p;
|
||||
typedef png_int_32 FAR * png_int_32p;
|
||||
typedef PNG_CONST png_int_32 FAR * png_const_int_32p;
|
||||
typedef png_uint_16 FAR * png_uint_16p;
|
||||
typedef PNG_CONST png_uint_16 FAR * png_const_uint_16p;
|
||||
typedef png_int_16 FAR * png_int_16p;
|
||||
typedef PNG_CONST png_int_16 FAR * png_const_int_16p;
|
||||
typedef char FAR * png_charp;
|
||||
typedef PNG_CONST char FAR * png_const_charp;
|
||||
typedef png_fixed_point FAR * png_fixed_point_p;
|
||||
typedef PNG_CONST png_fixed_point FAR * png_const_fixed_point_p;
|
||||
typedef png_size_t FAR * png_size_tp;
|
||||
typedef PNG_CONST png_size_t FAR * png_const_size_tp;
|
||||
typedef void * png_voidp;
|
||||
typedef const void * png_const_voidp;
|
||||
typedef png_byte * png_bytep;
|
||||
typedef const png_byte * png_const_bytep;
|
||||
typedef png_uint_32 * png_uint_32p;
|
||||
typedef const png_uint_32 * png_const_uint_32p;
|
||||
typedef png_int_32 * png_int_32p;
|
||||
typedef const png_int_32 * png_const_int_32p;
|
||||
typedef png_uint_16 * png_uint_16p;
|
||||
typedef const png_uint_16 * png_const_uint_16p;
|
||||
typedef png_int_16 * png_int_16p;
|
||||
typedef const png_int_16 * png_const_int_16p;
|
||||
typedef char * png_charp;
|
||||
typedef const char * png_const_charp;
|
||||
typedef png_fixed_point * png_fixed_point_p;
|
||||
typedef const png_fixed_point * png_const_fixed_point_p;
|
||||
typedef png_size_t * png_size_tp;
|
||||
typedef const png_size_t * png_const_size_tp;
|
||||
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
typedef FILE * png_FILE_p;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
typedef double FAR * png_doublep;
|
||||
typedef PNG_CONST double FAR * png_const_doublep;
|
||||
typedef double * png_doublep;
|
||||
typedef const double * png_const_doublep;
|
||||
#endif
|
||||
|
||||
/* Pointers to pointers; i.e. arrays */
|
||||
typedef png_byte FAR * FAR * png_bytepp;
|
||||
typedef png_uint_32 FAR * FAR * png_uint_32pp;
|
||||
typedef png_int_32 FAR * FAR * png_int_32pp;
|
||||
typedef png_uint_16 FAR * FAR * png_uint_16pp;
|
||||
typedef png_int_16 FAR * FAR * png_int_16pp;
|
||||
typedef PNG_CONST char FAR * FAR * png_const_charpp;
|
||||
typedef char FAR * FAR * png_charpp;
|
||||
typedef png_fixed_point FAR * FAR * png_fixed_point_pp;
|
||||
typedef png_byte * * png_bytepp;
|
||||
typedef png_uint_32 * * png_uint_32pp;
|
||||
typedef png_int_32 * * png_int_32pp;
|
||||
typedef png_uint_16 * * png_uint_16pp;
|
||||
typedef png_int_16 * * png_int_16pp;
|
||||
typedef const char * * png_const_charpp;
|
||||
typedef char * * png_charpp;
|
||||
typedef png_fixed_point * * png_fixed_point_pp;
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
typedef double FAR * FAR * png_doublepp;
|
||||
typedef double * * png_doublepp;
|
||||
#endif
|
||||
|
||||
/* Pointers to pointers to pointers; i.e., pointer to array */
|
||||
typedef char FAR * FAR * FAR * png_charppp;
|
||||
typedef char * * * png_charppp;
|
||||
|
||||
/* png_alloc_size_t is guaranteed to be no smaller than png_size_t,
|
||||
* and no smaller than png_uint_32. Casts from png_size_t or png_uint_32
|
||||
* to png_alloc_size_t are not necessary; in fact, it is recommended
|
||||
* not to use them at all so that the compiler can complain when something
|
||||
* turns out to be problematic.
|
||||
* Casts in the other direction (from png_alloc_size_t to png_size_t or
|
||||
* png_uint_32) should be explicitly applied; however, we do not expect
|
||||
* to encounter practical situations that require such conversions.
|
||||
*/
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
typedef unsigned long png_alloc_size_t;
|
||||
#else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
typedef unsigned long png_alloc_size_t;
|
||||
# else
|
||||
/* This is an attempt to detect an old Windows system where (int) is
|
||||
* actually 16 bits, in that case png_malloc must have an argument with a
|
||||
* bigger size to accomodate the requirements of the library.
|
||||
*/
|
||||
# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_)) && \
|
||||
(!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
|
||||
typedef DWORD png_alloc_size_t;
|
||||
# else
|
||||
typedef png_size_t png_alloc_size_t;
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#endif /* PNG_BUILDING_SYMBOL_TABLE */
|
||||
|
||||
#endif /* PNGCONF_H */
|
||||
|
22
3rdparty/libpng/pngdebug.h
vendored
@ -1,12 +1,11 @@
|
||||
|
||||
/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c
|
||||
*
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
@ -25,7 +24,7 @@
|
||||
* (actually ((void)0)).
|
||||
*
|
||||
* level: level of detail of message, starting at 0. A level 'n'
|
||||
* message is preceded by 'n' tab characters (not implemented
|
||||
* message is preceded by 'n' 3-space indentations (not implemented
|
||||
* on Microsoft compilers unless PNG_DEBUG_FILE is also
|
||||
* defined, to allow debug DLL compilation with no standard IO).
|
||||
* message: a printf(3) style text string. A trailing '\n' is added
|
||||
@ -77,32 +76,29 @@
|
||||
# endif /* PNG_DEBUG_FILE */
|
||||
|
||||
# if (PNG_DEBUG > 1)
|
||||
/* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on
|
||||
* non-ISO compilers
|
||||
*/
|
||||
# ifdef __STDC__
|
||||
# ifndef png_debug
|
||||
# define png_debug(l,m) \
|
||||
do { \
|
||||
int num_tabs=l; \
|
||||
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
|
||||
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \
|
||||
fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
|
||||
(num_tabs==2 ? " " : (num_tabs>2 ? " " : "")))); \
|
||||
} while (0)
|
||||
# endif
|
||||
# ifndef png_debug1
|
||||
# define png_debug1(l,m,p1) \
|
||||
do { \
|
||||
int num_tabs=l; \
|
||||
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
|
||||
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \
|
||||
fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
|
||||
(num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1); \
|
||||
} while (0)
|
||||
# endif
|
||||
# ifndef png_debug2
|
||||
# define png_debug2(l,m,p1,p2) \
|
||||
do { \
|
||||
int num_tabs=l; \
|
||||
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
|
||||
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \
|
||||
fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
|
||||
(num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1,p2);\
|
||||
} while (0)
|
||||
# endif
|
||||
# else /* __STDC __ */
|
||||
|
436
3rdparty/libpng/pngerror.c
vendored
@ -1,8 +1,8 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.5.8 [February 1, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -20,14 +20,14 @@
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
|
||||
static PNG_FUNCTION(void, png_default_error,PNGARG((png_structp png_ptr,
|
||||
static PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr,
|
||||
png_const_charp error_message)),PNG_NORETURN);
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
static void /* PRIVATE */
|
||||
png_default_warning PNGARG((png_structp png_ptr,
|
||||
png_default_warning PNGARG((png_const_structrp png_ptr,
|
||||
png_const_charp warning_message));
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
#endif /* WARNINGS */
|
||||
|
||||
/* This function is called whenever there is a fatal error. This function
|
||||
* should not be changed. If there is a need to handle errors differently,
|
||||
@ -36,14 +36,15 @@ png_default_warning PNGARG((png_structp png_ptr,
|
||||
*/
|
||||
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
|
||||
png_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
{
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
char msg[16];
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
if (png_ptr->flags&
|
||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
||||
if ((png_ptr->flags &
|
||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0
|
||||
{
|
||||
if (*error_message == PNG_LITERAL_SHARP)
|
||||
{
|
||||
@ -53,7 +54,7 @@ png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
|
||||
if (error_message[offset] == ' ')
|
||||
break;
|
||||
|
||||
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
||||
if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < offset - 1; i++)
|
||||
@ -68,7 +69,7 @@ png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
|
||||
|
||||
else
|
||||
{
|
||||
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
||||
if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
|
||||
{
|
||||
msg[0] = '0';
|
||||
msg[1] = '\0';
|
||||
@ -79,7 +80,8 @@ png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
|
||||
}
|
||||
#endif
|
||||
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
||||
(*(png_ptr->error_fn))(png_ptr, error_message);
|
||||
(*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr),
|
||||
error_message);
|
||||
|
||||
/* If the custom handler doesn't exist, or if it returns,
|
||||
use the default handler, which will not return. */
|
||||
@ -87,7 +89,7 @@ png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
|
||||
}
|
||||
#else
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_err,(png_structp png_ptr),PNG_NORETURN)
|
||||
png_err,(png_const_structrp png_ptr),PNG_NORETURN)
|
||||
{
|
||||
/* Prior to 1.5.2 the error_fn received a NULL pointer, expressed
|
||||
* erroneously as '\0', instead of the empty string "". This was
|
||||
@ -95,13 +97,13 @@ png_err,(png_structp png_ptr),PNG_NORETURN)
|
||||
* will crash in this case.
|
||||
*/
|
||||
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
||||
(*(png_ptr->error_fn))(png_ptr, "");
|
||||
(*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr), "");
|
||||
|
||||
/* If the custom handler doesn't exist, or if it returns,
|
||||
use the default handler, which will not return. */
|
||||
png_default_error(png_ptr, "");
|
||||
}
|
||||
#endif /* PNG_ERROR_TEXT_SUPPORTED */
|
||||
#endif /* ERROR_TEXT */
|
||||
|
||||
/* Utility to safely appends strings to a buffer. This never errors out so
|
||||
* error checking is not required in the caller.
|
||||
@ -150,7 +152,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||
case PNG_NUMBER_FORMAT_fixed:
|
||||
/* Needs five digits (the fraction) */
|
||||
mincount = 5;
|
||||
if (output || number % 10 != 0)
|
||||
if (output != 0 || number % 10 != 0)
|
||||
{
|
||||
*--end = digits[number % 10];
|
||||
output = 1;
|
||||
@ -161,7 +163,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||
case PNG_NUMBER_FORMAT_02u:
|
||||
/* Expects at least 2 digits. */
|
||||
mincount = 2;
|
||||
/* fall through */
|
||||
/* FALL THROUGH */
|
||||
|
||||
case PNG_NUMBER_FORMAT_u:
|
||||
*--end = digits[number % 10];
|
||||
@ -171,7 +173,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||
case PNG_NUMBER_FORMAT_02x:
|
||||
/* This format expects at least two digits */
|
||||
mincount = 2;
|
||||
/* fall through */
|
||||
/* FALL THROUGH */
|
||||
|
||||
case PNG_NUMBER_FORMAT_x:
|
||||
*--end = digits[number & 0xf];
|
||||
@ -187,13 +189,13 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||
++count;
|
||||
|
||||
/* Float a fixed number here: */
|
||||
if (format == PNG_NUMBER_FORMAT_fixed) if (count == 5) if (end > start)
|
||||
if ((format == PNG_NUMBER_FORMAT_fixed) && (count == 5) && (end > start))
|
||||
{
|
||||
/* End of the fraction, but maybe nothing was output? In that case
|
||||
* drop the decimal point. If the number is a true zero handle that
|
||||
* here.
|
||||
*/
|
||||
if (output)
|
||||
if (output != 0)
|
||||
*--end = '.';
|
||||
else if (number == 0) /* and !output */
|
||||
*--end = '0';
|
||||
@ -211,14 +213,14 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||
* png_set_error_fn() to replace the warning function at run-time.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||
png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||
{
|
||||
int offset = 0;
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
if (png_ptr->flags&
|
||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
||||
if ((png_ptr->flags &
|
||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0)
|
||||
#endif
|
||||
{
|
||||
if (*warning_message == PNG_LITERAL_SHARP)
|
||||
@ -230,7 +232,8 @@ png_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||
}
|
||||
}
|
||||
if (png_ptr != NULL && png_ptr->warning_fn != NULL)
|
||||
(*(png_ptr->warning_fn))(png_ptr, warning_message + offset);
|
||||
(*(png_ptr->warning_fn))(png_constcast(png_structrp,png_ptr),
|
||||
warning_message + offset);
|
||||
else
|
||||
png_default_warning(png_ptr, warning_message + offset);
|
||||
}
|
||||
@ -278,7 +281,7 @@ png_warning_parameter_signed(png_warning_parameters p, int number, int format,
|
||||
}
|
||||
|
||||
void
|
||||
png_formatted_warning(png_structp png_ptr, png_warning_parameters p,
|
||||
png_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p,
|
||||
png_const_charp message)
|
||||
{
|
||||
/* The internal buffer is just 192 bytes - enough for all our messages,
|
||||
@ -346,29 +349,79 @@ png_formatted_warning(png_structp png_ptr, png_warning_parameters p,
|
||||
/* i is always less than (sizeof msg), so: */
|
||||
msg[i] = '\0';
|
||||
|
||||
/* And this is the formatted message, it may be larger than
|
||||
* PNG_MAX_ERROR_TEXT, but that is only used for 'chunk' errors and these are
|
||||
* not (currently) formatted.
|
||||
/* And this is the formatted message. It may be larger than
|
||||
* PNG_MAX_ERROR_TEXT, but that is only used for 'chunk' errors and these
|
||||
* are not (currently) formatted.
|
||||
*/
|
||||
png_warning(png_ptr, msg);
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
#endif /* WARNINGS */
|
||||
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_benign_error(png_structp png_ptr, png_const_charp error_message)
|
||||
png_benign_error(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
||||
if ((png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) != 0)
|
||||
{
|
||||
# ifdef PNG_READ_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
|
||||
png_ptr->chunk_name != 0)
|
||||
png_chunk_warning(png_ptr, error_message);
|
||||
else
|
||||
# endif
|
||||
png_warning(png_ptr, error_message);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
# ifdef PNG_READ_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
|
||||
png_ptr->chunk_name != 0)
|
||||
png_chunk_error(png_ptr, error_message);
|
||||
else
|
||||
# endif
|
||||
png_error(png_ptr, error_message);
|
||||
}
|
||||
|
||||
# ifndef PNG_ERROR_TEXT_SUPPORTED
|
||||
PNG_UNUSED(error_message)
|
||||
# endif
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_app_warning(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
if ((png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN) != 0)
|
||||
png_warning(png_ptr, error_message);
|
||||
else
|
||||
png_error(png_ptr, error_message);
|
||||
}
|
||||
#endif
|
||||
|
||||
# ifndef PNG_ERROR_TEXT_SUPPORTED
|
||||
PNG_UNUSED(error_message)
|
||||
# endif
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
if ((png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN) != 0)
|
||||
png_warning(png_ptr, error_message);
|
||||
else
|
||||
png_error(png_ptr, error_message);
|
||||
|
||||
# ifndef PNG_ERROR_TEXT_SUPPORTED
|
||||
PNG_UNUSED(error_message)
|
||||
# endif
|
||||
}
|
||||
#endif /* BENIGN_ERRORS */
|
||||
|
||||
#define PNG_MAX_ERROR_TEXT 196 /* Currently limited by profile_error in png.c */
|
||||
#if defined(PNG_WARNINGS_SUPPORTED) || \
|
||||
(defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED))
|
||||
/* These utilities are used internally to build an error message that relates
|
||||
* to the current chunk. The chunk name comes from png_ptr->chunk_name,
|
||||
* this is used to prefix the message. The message is limited in length
|
||||
* to 63 bytes, the name characters are output as hex digits wrapped in []
|
||||
* which is used to prefix the message. The message is limited in length
|
||||
* to 63 bytes. The name characters are output as hex digits wrapped in []
|
||||
* if the character is invalid.
|
||||
*/
|
||||
#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
|
||||
@ -377,10 +430,8 @@ static PNG_CONST char png_digit[16] = {
|
||||
'A', 'B', 'C', 'D', 'E', 'F'
|
||||
};
|
||||
|
||||
#define PNG_MAX_ERROR_TEXT 64
|
||||
#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||
static void /* PRIVATE */
|
||||
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
||||
png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp
|
||||
error_message)
|
||||
{
|
||||
png_uint_32 chunk_name = png_ptr->chunk_name;
|
||||
@ -391,7 +442,7 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
||||
int c = (int)(chunk_name >> ishift) & 0xff;
|
||||
|
||||
ishift -= 8;
|
||||
if (isnonalpha(c))
|
||||
if (isnonalpha(c) != 0)
|
||||
{
|
||||
buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET;
|
||||
buffer[iout++] = png_digit[(c & 0xf0) >> 4];
|
||||
@ -422,11 +473,11 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
||||
buffer[iout] = '\0';
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED || PNG_ERROR_TEXT_SUPPORTED */
|
||||
#endif /* WARNINGS || ERROR_TEXT */
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_chunk_error,(png_structp png_ptr, png_const_charp error_message),
|
||||
png_chunk_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
{
|
||||
char msg[18+PNG_MAX_ERROR_TEXT];
|
||||
@ -439,11 +490,11 @@ png_chunk_error,(png_structp png_ptr, png_const_charp error_message),
|
||||
png_error(png_ptr, msg);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED && PNG_ERROR_TEXT_SUPPORTED */
|
||||
#endif /* READ && ERROR_TEXT */
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||
png_chunk_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||
{
|
||||
char msg[18+PNG_MAX_ERROR_TEXT];
|
||||
if (png_ptr == NULL)
|
||||
@ -455,38 +506,83 @@ png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||
png_warning(png_ptr, msg);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
#endif /* WARNINGS */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_chunk_benign_error(png_structp png_ptr, png_const_charp error_message)
|
||||
png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp
|
||||
error_message)
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
||||
if ((png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) != 0)
|
||||
png_chunk_warning(png_ptr, error_message);
|
||||
|
||||
else
|
||||
png_chunk_error(png_ptr, error_message);
|
||||
|
||||
# ifndef PNG_ERROR_TEXT_SUPPORTED
|
||||
PNG_UNUSED(error_message)
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* READ */
|
||||
|
||||
void /* PRIVATE */
|
||||
png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)
|
||||
{
|
||||
# ifndef PNG_WARNINGS_SUPPORTED
|
||||
PNG_UNUSED(message)
|
||||
# endif
|
||||
|
||||
/* This is always supported, but for just read or just write it
|
||||
* unconditionally does the right thing.
|
||||
*/
|
||||
# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
|
||||
# endif
|
||||
|
||||
# ifdef PNG_READ_SUPPORTED
|
||||
{
|
||||
if (error < PNG_CHUNK_ERROR)
|
||||
png_chunk_warning(png_ptr, message);
|
||||
|
||||
else
|
||||
png_chunk_benign_error(png_ptr, message);
|
||||
}
|
||||
# endif
|
||||
|
||||
# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)
|
||||
else if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
|
||||
# endif
|
||||
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
{
|
||||
if (error < PNG_CHUNK_WRITE_ERROR)
|
||||
png_app_warning(png_ptr, message);
|
||||
|
||||
else
|
||||
png_app_error(png_ptr, message);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
PNG_FUNCTION(void,
|
||||
png_fixed_error,(png_structp png_ptr, png_const_charp name),PNG_NORETURN)
|
||||
png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN)
|
||||
{
|
||||
# define fixed_message "fixed point overflow in "
|
||||
# define fixed_message_ln ((sizeof fixed_message)-1)
|
||||
int iin;
|
||||
char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];
|
||||
png_memcpy(msg, fixed_message, fixed_message_ln);
|
||||
memcpy(msg, fixed_message, fixed_message_ln);
|
||||
iin = 0;
|
||||
if (name != NULL) while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0)
|
||||
{
|
||||
msg[fixed_message_ln + iin] = name[iin];
|
||||
++iin;
|
||||
}
|
||||
if (name != NULL)
|
||||
while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0)
|
||||
{
|
||||
msg[fixed_message_ln + iin] = name[iin];
|
||||
++iin;
|
||||
}
|
||||
msg[fixed_message_ln + iin] = 0;
|
||||
png_error(png_ptr, msg);
|
||||
}
|
||||
@ -498,14 +594,111 @@ png_fixed_error,(png_structp png_ptr, png_const_charp name),PNG_NORETURN)
|
||||
* otherwise it is necessary for png_default_error to be overridden.
|
||||
*/
|
||||
jmp_buf* PNGAPI
|
||||
png_set_longjmp_fn(png_structp png_ptr, png_longjmp_ptr longjmp_fn,
|
||||
png_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn,
|
||||
size_t jmp_buf_size)
|
||||
{
|
||||
if (png_ptr == NULL || jmp_buf_size != png_sizeof(jmp_buf))
|
||||
/* From libpng 1.6.0 the app gets one chance to set a 'jmpbuf_size' value
|
||||
* and it must not change after that. Libpng doesn't care how big the
|
||||
* buffer is, just that it doesn't change.
|
||||
*
|
||||
* If the buffer size is no *larger* than the size of jmp_buf when libpng is
|
||||
* compiled a built in jmp_buf is returned; this preserves the pre-1.6.0
|
||||
* semantics that this call will not fail. If the size is larger, however,
|
||||
* the buffer is allocated and this may fail, causing the function to return
|
||||
* NULL.
|
||||
*/
|
||||
if (png_ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
if (png_ptr->jmp_buf_ptr == NULL)
|
||||
{
|
||||
png_ptr->jmp_buf_size = 0; /* not allocated */
|
||||
|
||||
if (jmp_buf_size <= (sizeof png_ptr->jmp_buf_local))
|
||||
png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local;
|
||||
|
||||
else
|
||||
{
|
||||
png_ptr->jmp_buf_ptr = png_voidcast(jmp_buf *,
|
||||
png_malloc_warn(png_ptr, jmp_buf_size));
|
||||
|
||||
if (png_ptr->jmp_buf_ptr == NULL)
|
||||
return NULL; /* new NULL return on OOM */
|
||||
|
||||
png_ptr->jmp_buf_size = jmp_buf_size;
|
||||
}
|
||||
}
|
||||
|
||||
else /* Already allocated: check the size */
|
||||
{
|
||||
size_t size = png_ptr->jmp_buf_size;
|
||||
|
||||
if (size == 0)
|
||||
{
|
||||
size = (sizeof png_ptr->jmp_buf_local);
|
||||
if (png_ptr->jmp_buf_ptr != &png_ptr->jmp_buf_local)
|
||||
{
|
||||
/* This is an internal error in libpng: somehow we have been left
|
||||
* with a stack allocated jmp_buf when the application regained
|
||||
* control. It's always possible to fix this up, but for the moment
|
||||
* this is a png_error because that makes it easy to detect.
|
||||
*/
|
||||
png_error(png_ptr, "Libpng jmp_buf still allocated");
|
||||
/* png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local; */
|
||||
}
|
||||
}
|
||||
|
||||
if (size != jmp_buf_size)
|
||||
{
|
||||
png_warning(png_ptr, "Application jmp_buf size changed");
|
||||
return NULL; /* caller will probably crash: no choice here */
|
||||
}
|
||||
}
|
||||
|
||||
/* Finally fill in the function, now we have a satisfactory buffer. It is
|
||||
* valid to change the function on every call.
|
||||
*/
|
||||
png_ptr->longjmp_fn = longjmp_fn;
|
||||
return &png_ptr->longjmp_buffer;
|
||||
return png_ptr->jmp_buf_ptr;
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_free_jmpbuf(png_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
jmp_buf *jb = png_ptr->jmp_buf_ptr;
|
||||
|
||||
/* A size of 0 is used to indicate a local, stack, allocation of the
|
||||
* pointer; used here and in png.c
|
||||
*/
|
||||
if (jb != NULL && png_ptr->jmp_buf_size > 0)
|
||||
{
|
||||
|
||||
/* This stuff is so that a failure to free the error control structure
|
||||
* does not leave libpng in a state with no valid error handling: the
|
||||
* free always succeeds, if there is an error it gets ignored.
|
||||
*/
|
||||
if (jb != &png_ptr->jmp_buf_local)
|
||||
{
|
||||
/* Make an internal, libpng, jmp_buf to return here */
|
||||
jmp_buf free_jmp_buf;
|
||||
|
||||
if (!setjmp(free_jmp_buf))
|
||||
{
|
||||
png_ptr->jmp_buf_ptr = &free_jmp_buf; /* come back here */
|
||||
png_ptr->jmp_buf_size = 0; /* stack allocation */
|
||||
png_ptr->longjmp_fn = longjmp;
|
||||
png_free(png_ptr, jb); /* Return to setjmp on error */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* *Always* cancel everything out: */
|
||||
png_ptr->jmp_buf_size = 0;
|
||||
png_ptr->jmp_buf_ptr = NULL;
|
||||
png_ptr->longjmp_fn = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -515,7 +708,7 @@ png_set_longjmp_fn(png_structp png_ptr, png_longjmp_ptr longjmp_fn,
|
||||
* error function pointer in png_set_error_fn().
|
||||
*/
|
||||
static PNG_FUNCTION(void /* PRIVATE */,
|
||||
png_default_error,(png_structp png_ptr, png_const_charp error_message),
|
||||
png_default_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
{
|
||||
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
||||
@ -562,24 +755,23 @@ png_default_error,(png_structp png_ptr, png_const_charp error_message),
|
||||
}
|
||||
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_longjmp,(png_structp png_ptr, int val),PNG_NORETURN)
|
||||
png_longjmp,(png_const_structrp png_ptr, int val),PNG_NORETURN)
|
||||
{
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
if (png_ptr && png_ptr->longjmp_fn)
|
||||
{
|
||||
# ifdef USE_FAR_KEYWORD
|
||||
{
|
||||
jmp_buf tmp_jmpbuf;
|
||||
png_memcpy(tmp_jmpbuf, png_ptr->longjmp_buffer, png_sizeof(jmp_buf));
|
||||
png_ptr->longjmp_fn(tmp_jmpbuf, val);
|
||||
}
|
||||
|
||||
# else
|
||||
png_ptr->longjmp_fn(png_ptr->longjmp_buffer, val);
|
||||
# endif
|
||||
}
|
||||
if (png_ptr != NULL && png_ptr->longjmp_fn != NULL &&
|
||||
png_ptr->jmp_buf_ptr != NULL)
|
||||
png_ptr->longjmp_fn(*png_ptr->jmp_buf_ptr, val);
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(val)
|
||||
#endif
|
||||
/* Here if not setjmp support or if png_ptr is null. */
|
||||
|
||||
/* If control reaches this point, png_longjmp() must not return. The only
|
||||
* choice is to terminate the whole process (or maybe the thread); to do
|
||||
* this the ANSI-C abort() function is used unless a different method is
|
||||
* implemented by overriding the default configuration setting for
|
||||
* PNG_ABORT().
|
||||
*/
|
||||
PNG_ABORT();
|
||||
}
|
||||
|
||||
@ -590,7 +782,7 @@ png_longjmp,(png_structp png_ptr, int val),PNG_NORETURN)
|
||||
* not used, but it is passed in case it may be useful.
|
||||
*/
|
||||
static void /* PRIVATE */
|
||||
png_default_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||
png_default_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||
{
|
||||
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
||||
# ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
@ -632,15 +824,15 @@ png_default_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||
#endif
|
||||
PNG_UNUSED(png_ptr) /* Make compiler happy */
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
#endif /* WARNINGS */
|
||||
|
||||
/* This function is called when the application wants to use another method
|
||||
* of handling errors and warnings. Note that the error function MUST NOT
|
||||
* return to the calling routine or serious problems will occur. The return
|
||||
* method used in the default routine calls longjmp(png_ptr->longjmp_buffer, 1)
|
||||
* method used in the default routine calls longjmp(png_ptr->jmp_buf_ptr, 1)
|
||||
*/
|
||||
void PNGAPI
|
||||
png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
||||
png_set_error_fn(png_structrp png_ptr, png_voidp error_ptr,
|
||||
png_error_ptr error_fn, png_error_ptr warning_fn)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
@ -661,7 +853,7 @@ png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
||||
* pointer before png_write_destroy and png_read_destroy are called.
|
||||
*/
|
||||
png_voidp PNGAPI
|
||||
png_get_error_ptr(png_const_structp png_ptr)
|
||||
png_get_error_ptr(png_const_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return NULL;
|
||||
@ -672,7 +864,7 @@ png_get_error_ptr(png_const_structp png_ptr)
|
||||
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
|
||||
png_set_strip_error_numbers(png_structrp png_ptr, png_uint_32 strip_mode)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
@ -682,4 +874,90 @@ png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
|
||||
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\
|
||||
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
|
||||
/* Currently the above both depend on SETJMP_SUPPORTED, however it would be
|
||||
* possible to implement without setjmp support just so long as there is some
|
||||
* way to handle the error return here:
|
||||
*/
|
||||
PNG_FUNCTION(void /* PRIVATE */, (PNGCBAPI
|
||||
png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
{
|
||||
const png_const_structrp png_ptr = png_nonconst_ptr;
|
||||
png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
|
||||
|
||||
/* An error is always logged here, overwriting anything (typically a warning)
|
||||
* that is already there:
|
||||
*/
|
||||
if (image != NULL)
|
||||
{
|
||||
png_safecat(image->message, (sizeof image->message), 0, error_message);
|
||||
image->warning_or_error |= PNG_IMAGE_ERROR;
|
||||
|
||||
/* Retrieve the jmp_buf from within the png_control, making this work for
|
||||
* C++ compilation too is pretty tricky: C++ wants a pointer to the first
|
||||
* element of a jmp_buf, but C doesn't tell us the type of that.
|
||||
*/
|
||||
if (image->opaque != NULL && image->opaque->error_buf != NULL)
|
||||
longjmp(png_control_jmp_buf(image->opaque), 1);
|
||||
|
||||
/* Missing longjmp buffer, the following is to help debugging: */
|
||||
{
|
||||
size_t pos = png_safecat(image->message, (sizeof image->message), 0,
|
||||
"bad longjmp: ");
|
||||
png_safecat(image->message, (sizeof image->message), pos,
|
||||
error_message);
|
||||
}
|
||||
}
|
||||
|
||||
/* Here on an internal programming error. */
|
||||
abort();
|
||||
}
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
void /* PRIVATE */ PNGCBAPI
|
||||
png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)
|
||||
{
|
||||
const png_const_structrp png_ptr = png_nonconst_ptr;
|
||||
png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
|
||||
|
||||
/* A warning is only logged if there is no prior warning or error. */
|
||||
if (image->warning_or_error == 0)
|
||||
{
|
||||
png_safecat(image->message, (sizeof image->message), 0, warning_message);
|
||||
image->warning_or_error |= PNG_IMAGE_WARNING;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int /* PRIVATE */
|
||||
png_safe_execute(png_imagep image_in, int (*function)(png_voidp), png_voidp arg)
|
||||
{
|
||||
volatile png_imagep image = image_in;
|
||||
volatile int result;
|
||||
volatile png_voidp saved_error_buf;
|
||||
jmp_buf safe_jmpbuf;
|
||||
|
||||
/* Safely execute function(arg) with png_error returning to this function. */
|
||||
saved_error_buf = image->opaque->error_buf;
|
||||
result = setjmp(safe_jmpbuf) == 0;
|
||||
|
||||
if (result != 0)
|
||||
{
|
||||
|
||||
image->opaque->error_buf = safe_jmpbuf;
|
||||
result = function(arg);
|
||||
}
|
||||
|
||||
image->opaque->error_buf = saved_error_buf;
|
||||
|
||||
/* And do the cleanup prior to any failure return. */
|
||||
if (result == 0)
|
||||
png_image_free(image);
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif /* SIMPLIFIED READ || SIMPLIFIED_WRITE */
|
||||
#endif /* READ || WRITE */
|
||||
|
565
3rdparty/libpng/pngget.c
vendored
76
3rdparty/libpng/pnginfo.h
vendored
@ -1,12 +1,11 @@
|
||||
|
||||
/* pnginfo.h - header file for PNG reference library
|
||||
*
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
@ -55,7 +54,7 @@
|
||||
|
||||
struct png_info_def
|
||||
{
|
||||
/* the following are necessary for every PNG file */
|
||||
/* The following are necessary for every PNG file */
|
||||
png_uint_32 width; /* width of image in pixels (from IHDR) */
|
||||
png_uint_32 height; /* height of image in pixels (from IHDR) */
|
||||
png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
|
||||
@ -70,11 +69,17 @@ struct png_info_def
|
||||
png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
|
||||
png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
|
||||
|
||||
/* The following is informational only on read, and not used on writes. */
|
||||
/* The following are set by png_set_IHDR, called from the application on
|
||||
* write, but the are never actually used by the write code.
|
||||
*/
|
||||
png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */
|
||||
png_byte pixel_depth; /* number of bits per pixel */
|
||||
png_byte spare_byte; /* to align the data, and for future use */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* This is never set during write */
|
||||
png_byte signature[8]; /* magic bytes read by libpng from start of file */
|
||||
#endif
|
||||
|
||||
/* The rest of the data is optional. If you are reading, check the
|
||||
* valid field to see if the information in these are valid. If you
|
||||
@ -82,18 +87,25 @@ struct png_info_def
|
||||
* and initialize the appropriate fields below.
|
||||
*/
|
||||
|
||||
#if defined(PNG_gAMA_SUPPORTED)
|
||||
/* The gAMA chunk describes the gamma characteristics of the system
|
||||
* on which the image was created, normally in the range [1.0, 2.5].
|
||||
* Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
|
||||
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||
/* png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are
|
||||
* defined. When COLORSPACE is switched on all the colorspace-defining
|
||||
* chunks should be enabled, when GAMMA is switched on all the gamma-defining
|
||||
* chunks should be enabled. If this is not done it becomes possible to read
|
||||
* inconsistent PNG files and assign a probably incorrect interpretation to
|
||||
* the information. (In other words, by carefully choosing which chunks to
|
||||
* recognize the system configuration can select an interpretation for PNG
|
||||
* files containing ambiguous data and this will result in inconsistent
|
||||
* behavior between different libpng builds!)
|
||||
*/
|
||||
png_fixed_point gamma;
|
||||
png_colorspace colorspace;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sRGB_SUPPORTED
|
||||
/* GR-P, 0.96a */
|
||||
/* Data valid if (valid & PNG_INFO_sRGB) non-zero. */
|
||||
png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */
|
||||
#ifdef PNG_iCCP_SUPPORTED
|
||||
/* iCCP chunk data. */
|
||||
png_charp iccp_name; /* profile name */
|
||||
png_bytep iccp_profile; /* International Color Consortium profile data */
|
||||
png_uint_32 iccp_proflen; /* ICC profile data length */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
@ -108,7 +120,7 @@ struct png_info_def
|
||||
int num_text; /* number of comments read or comments to write */
|
||||
int max_text; /* current size of text array */
|
||||
png_textp text; /* array of comments read or comments to write */
|
||||
#endif /* PNG_TEXT_SUPPORTED */
|
||||
#endif /* TEXT */
|
||||
|
||||
#ifdef PNG_tIME_SUPPORTED
|
||||
/* The tIME chunk holds the last time the displayed image data was
|
||||
@ -183,23 +195,6 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
png_uint_16p hist;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_cHRM_SUPPORTED
|
||||
/* The cHRM chunk describes the CIE color characteristics of the monitor
|
||||
* on which the PNG was created. This data allows the viewer to do gamut
|
||||
* mapping of the input image to ensure that the viewer sees the same
|
||||
* colors in the image as the creator. Values are in the range
|
||||
* [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero.
|
||||
*/
|
||||
png_fixed_point x_white;
|
||||
png_fixed_point y_white;
|
||||
png_fixed_point x_red;
|
||||
png_fixed_point y_red;
|
||||
png_fixed_point x_green;
|
||||
png_fixed_point y_green;
|
||||
png_fixed_point x_blue;
|
||||
png_fixed_point y_blue;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_pCAL_SUPPORTED
|
||||
/* The pCAL chunk describes a transformation between the stored pixel
|
||||
* values and original physical data values used to create the image.
|
||||
@ -224,25 +219,20 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
/* New members added in libpng-1.0.6 */
|
||||
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \
|
||||
defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Storage for unknown chunks that the library doesn't recognize. */
|
||||
png_unknown_chunkp unknown_chunks;
|
||||
int unknown_chunks_num;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_iCCP_SUPPORTED
|
||||
/* iCCP chunk data. */
|
||||
png_charp iccp_name; /* profile name */
|
||||
png_bytep iccp_profile; /* International Color Consortium profile data */
|
||||
png_uint_32 iccp_proflen; /* ICC profile data length */
|
||||
png_byte iccp_compression; /* Always zero */
|
||||
/* The type of this field is limited by the type of
|
||||
* png_struct::user_chunk_cache_max, else overflow can occur.
|
||||
*/
|
||||
int unknown_chunks_num;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sPLT_SUPPORTED
|
||||
/* Data on sPLT chunks (there may be more than one). */
|
||||
png_sPLT_tp splt_palettes;
|
||||
png_uint_32 splt_palettes_num;
|
||||
int splt_palettes_num; /* Match type returned by png_get API */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sCAL_SUPPORTED
|
||||
|
182
3rdparty/libpng/pnglibconf.h
vendored
@ -1,48 +1,31 @@
|
||||
|
||||
/* libpng STANDARD API DEFINITION */
|
||||
/* libpng 1.6.19 STANDARD API DEFINITION */
|
||||
|
||||
/* pnglibconf.h - library build configuration */
|
||||
|
||||
/* Libpng 1.5.12 - July 11, 2012 */
|
||||
/* Libpng version 1.6.19 - November 12, 2015 */
|
||||
|
||||
/* Copyright (c) 1998-2012 Glenn Randers-Pehrson */
|
||||
/* Copyright (c) 1998-2015 Glenn Randers-Pehrson */
|
||||
|
||||
/* This code is released under the libpng license. */
|
||||
/* For conditions of distribution and use, see the disclaimer */
|
||||
/* and license in png.h */
|
||||
|
||||
/* pnglibconf.h */
|
||||
/* Machine generated file: DO NOT EDIT */
|
||||
/* Derived from: scripts/pnglibconf.dfa */
|
||||
/* If you edit this file by hand you must obey the rules expressed in */
|
||||
/* pnglibconf.dfa with respect to the dependencies between the following */
|
||||
/* symbols. It is much better to generate a new file using */
|
||||
/* scripts/libpngconf.mak */
|
||||
|
||||
#ifndef PNGLCONF_H
|
||||
#define PNGLCONF_H
|
||||
/* settings */
|
||||
#define PNG_API_RULE 0
|
||||
#define PNG_CALLOC_SUPPORTED
|
||||
#define PNG_COST_SHIFT 3
|
||||
#define PNG_DEFAULT_READ_MACROS 1
|
||||
#define PNG_GAMMA_THRESHOLD_FIXED 5000
|
||||
#define PNG_MAX_GAMMA_8 11
|
||||
#define PNG_QUANTIZE_BLUE_BITS 5
|
||||
#define PNG_QUANTIZE_GREEN_BITS 5
|
||||
#define PNG_QUANTIZE_RED_BITS 5
|
||||
#define PNG_sCAL_PRECISION 5
|
||||
#define PNG_WEIGHT_SHIFT 8
|
||||
#define PNG_ZBUF_SIZE 8192
|
||||
/* end of settings */
|
||||
/* options */
|
||||
#define PNG_16BIT_SUPPORTED
|
||||
#define PNG_ALIGN_MEMORY_SUPPORTED
|
||||
#define PNG_ALIGNED_MEMORY_SUPPORTED
|
||||
/*#undef PNG_ARM_NEON_API_SUPPORTED*/
|
||||
/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/
|
||||
#define PNG_BENIGN_ERRORS_SUPPORTED
|
||||
#define PNG_bKGD_SUPPORTED
|
||||
#define PNG_BENIGN_READ_ERRORS_SUPPORTED
|
||||
/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/
|
||||
#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
|
||||
#define PNG_CHECK_cHRM_SUPPORTED
|
||||
#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
#define PNG_cHRM_SUPPORTED
|
||||
#define PNG_COLORSPACE_SUPPORTED
|
||||
#define PNG_CONSOLE_IO_SUPPORTED
|
||||
#define PNG_CONVERT_tIME_SUPPORTED
|
||||
#define PNG_EASY_ACCESS_SUPPORTED
|
||||
@ -51,18 +34,15 @@
|
||||
#define PNG_FIXED_POINT_SUPPORTED
|
||||
#define PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
#define PNG_FLOATING_POINT_SUPPORTED
|
||||
#define PNG_gAMA_SUPPORTED
|
||||
#define PNG_FORMAT_AFIRST_SUPPORTED
|
||||
#define PNG_FORMAT_BGR_SUPPORTED
|
||||
#define PNG_GAMMA_SUPPORTED
|
||||
#define PNG_GET_PALETTE_MAX_SUPPORTED
|
||||
#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
#define PNG_hIST_SUPPORTED
|
||||
#define PNG_iCCP_SUPPORTED
|
||||
#define PNG_INCH_CONVERSIONS_SUPPORTED
|
||||
#define PNG_INFO_IMAGE_SUPPORTED
|
||||
#define PNG_IO_STATE_SUPPORTED
|
||||
#define PNG_iTXt_SUPPORTED
|
||||
#define PNG_MNG_FEATURES_SUPPORTED
|
||||
#define PNG_oFFs_SUPPORTED
|
||||
#define PNG_pCAL_SUPPORTED
|
||||
#define PNG_pHYs_SUPPORTED
|
||||
#define PNG_POINTER_INDEXING_SUPPORTED
|
||||
#define PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
#define PNG_READ_16BIT_SUPPORTED
|
||||
@ -70,68 +50,70 @@
|
||||
#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#define PNG_READ_BACKGROUND_SUPPORTED
|
||||
#define PNG_READ_BGR_SUPPORTED
|
||||
#define PNG_READ_bKGD_SUPPORTED
|
||||
#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
#define PNG_READ_cHRM_SUPPORTED
|
||||
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED
|
||||
#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
|
||||
#define PNG_READ_EXPAND_16_SUPPORTED
|
||||
#define PNG_READ_EXPAND_SUPPORTED
|
||||
#define PNG_READ_FILLER_SUPPORTED
|
||||
#define PNG_READ_gAMA_SUPPORTED
|
||||
#define PNG_READ_GAMMA_SUPPORTED
|
||||
#define PNG_READ_GET_PALETTE_MAX_SUPPORTED
|
||||
#define PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
#define PNG_READ_hIST_SUPPORTED
|
||||
#define PNG_READ_iCCP_SUPPORTED
|
||||
#define PNG_READ_INTERLACING_SUPPORTED
|
||||
#define PNG_READ_INT_FUNCTIONS_SUPPORTED
|
||||
#define PNG_READ_INVERT_ALPHA_SUPPORTED
|
||||
#define PNG_READ_INVERT_SUPPORTED
|
||||
#define PNG_READ_iTXt_SUPPORTED
|
||||
#define PNG_READ_oFFs_SUPPORTED
|
||||
#define PNG_READ_OPT_PLTE_SUPPORTED
|
||||
#define PNG_READ_PACK_SUPPORTED
|
||||
#define PNG_READ_PACKSWAP_SUPPORTED
|
||||
#define PNG_READ_pCAL_SUPPORTED
|
||||
#define PNG_READ_pHYs_SUPPORTED
|
||||
#define PNG_READ_PACK_SUPPORTED
|
||||
#define PNG_READ_QUANTIZE_SUPPORTED
|
||||
#define PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
#define PNG_READ_sBIT_SUPPORTED
|
||||
#define PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
#define PNG_READ_sCAL_SUPPORTED
|
||||
#define PNG_READ_SHIFT_SUPPORTED
|
||||
#define PNG_READ_sPLT_SUPPORTED
|
||||
#define PNG_READ_sRGB_SUPPORTED
|
||||
#define PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||
#define PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
#define PNG_READ_SUPPORTED
|
||||
#define PNG_READ_SWAP_ALPHA_SUPPORTED
|
||||
#define PNG_READ_SWAP_SUPPORTED
|
||||
#define PNG_READ_tEXt_SUPPORTED
|
||||
#define PNG_READ_TEXT_SUPPORTED
|
||||
#define PNG_READ_tIME_SUPPORTED
|
||||
#define PNG_READ_TRANSFORMS_SUPPORTED
|
||||
#define PNG_READ_tRNS_SUPPORTED
|
||||
#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
#define PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
#define PNG_READ_bKGD_SUPPORTED
|
||||
#define PNG_READ_cHRM_SUPPORTED
|
||||
#define PNG_READ_gAMA_SUPPORTED
|
||||
#define PNG_READ_hIST_SUPPORTED
|
||||
#define PNG_READ_iCCP_SUPPORTED
|
||||
#define PNG_READ_iTXt_SUPPORTED
|
||||
#define PNG_READ_oFFs_SUPPORTED
|
||||
#define PNG_READ_pCAL_SUPPORTED
|
||||
#define PNG_READ_pHYs_SUPPORTED
|
||||
#define PNG_READ_sBIT_SUPPORTED
|
||||
#define PNG_READ_sCAL_SUPPORTED
|
||||
#define PNG_READ_sPLT_SUPPORTED
|
||||
#define PNG_READ_sRGB_SUPPORTED
|
||||
#define PNG_READ_tEXt_SUPPORTED
|
||||
#define PNG_READ_tIME_SUPPORTED
|
||||
#define PNG_READ_tRNS_SUPPORTED
|
||||
#define PNG_READ_zTXt_SUPPORTED
|
||||
#define PNG_SAVE_INT_32_SUPPORTED
|
||||
#define PNG_sBIT_SUPPORTED
|
||||
#define PNG_sCAL_SUPPORTED
|
||||
#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
|
||||
#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
|
||||
#define PNG_SETJMP_SUPPORTED
|
||||
#define PNG_SET_OPTION_SUPPORTED
|
||||
#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_SET_USER_LIMITS_SUPPORTED
|
||||
#define PNG_sPLT_SUPPORTED
|
||||
#define PNG_sRGB_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_READ_BGR_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_READ_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||
#define PNG_STDIO_SUPPORTED
|
||||
#define PNG_tEXt_SUPPORTED
|
||||
#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_TEXT_SUPPORTED
|
||||
#define PNG_TIME_RFC1123_SUPPORTED
|
||||
#define PNG_tIME_SUPPORTED
|
||||
#define PNG_tRNS_SUPPORTED
|
||||
#define PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_USER_CHUNKS_SUPPORTED
|
||||
#define PNG_USER_LIMITS_SUPPORTED
|
||||
@ -142,45 +124,91 @@
|
||||
#define PNG_WRITE_16BIT_SUPPORTED
|
||||
#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#define PNG_WRITE_BGR_SUPPORTED
|
||||
#define PNG_WRITE_bKGD_SUPPORTED
|
||||
#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
#define PNG_WRITE_cHRM_SUPPORTED
|
||||
#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
|
||||
#define PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
|
||||
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
#define PNG_WRITE_FILLER_SUPPORTED
|
||||
#define PNG_WRITE_FILTER_SUPPORTED
|
||||
#define PNG_WRITE_FLUSH_SUPPORTED
|
||||
#define PNG_WRITE_gAMA_SUPPORTED
|
||||
#define PNG_WRITE_hIST_SUPPORTED
|
||||
#define PNG_WRITE_iCCP_SUPPORTED
|
||||
#define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED
|
||||
#define PNG_WRITE_INTERLACING_SUPPORTED
|
||||
#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED
|
||||
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
#define PNG_WRITE_INVERT_SUPPORTED
|
||||
#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
|
||||
#define PNG_WRITE_PACKSWAP_SUPPORTED
|
||||
#define PNG_WRITE_PACK_SUPPORTED
|
||||
#define PNG_WRITE_SHIFT_SUPPORTED
|
||||
#define PNG_WRITE_SUPPORTED
|
||||
#define PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
#define PNG_WRITE_SWAP_SUPPORTED
|
||||
#define PNG_WRITE_TEXT_SUPPORTED
|
||||
#define PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
#define PNG_WRITE_bKGD_SUPPORTED
|
||||
#define PNG_WRITE_cHRM_SUPPORTED
|
||||
#define PNG_WRITE_gAMA_SUPPORTED
|
||||
#define PNG_WRITE_hIST_SUPPORTED
|
||||
#define PNG_WRITE_iCCP_SUPPORTED
|
||||
#define PNG_WRITE_iTXt_SUPPORTED
|
||||
#define PNG_WRITE_oFFs_SUPPORTED
|
||||
#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
|
||||
#define PNG_WRITE_PACK_SUPPORTED
|
||||
#define PNG_WRITE_PACKSWAP_SUPPORTED
|
||||
#define PNG_WRITE_pCAL_SUPPORTED
|
||||
#define PNG_WRITE_pHYs_SUPPORTED
|
||||
#define PNG_WRITE_sBIT_SUPPORTED
|
||||
#define PNG_WRITE_sCAL_SUPPORTED
|
||||
#define PNG_WRITE_SHIFT_SUPPORTED
|
||||
#define PNG_WRITE_sPLT_SUPPORTED
|
||||
#define PNG_WRITE_sRGB_SUPPORTED
|
||||
#define PNG_WRITE_SUPPORTED
|
||||
#define PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
#define PNG_WRITE_SWAP_SUPPORTED
|
||||
#define PNG_WRITE_tEXt_SUPPORTED
|
||||
#define PNG_WRITE_TEXT_SUPPORTED
|
||||
#define PNG_WRITE_tIME_SUPPORTED
|
||||
#define PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
#define PNG_WRITE_tRNS_SUPPORTED
|
||||
#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
#define PNG_WRITE_zTXt_SUPPORTED
|
||||
#define PNG_bKGD_SUPPORTED
|
||||
#define PNG_cHRM_SUPPORTED
|
||||
#define PNG_gAMA_SUPPORTED
|
||||
#define PNG_hIST_SUPPORTED
|
||||
#define PNG_iCCP_SUPPORTED
|
||||
#define PNG_iTXt_SUPPORTED
|
||||
#define PNG_oFFs_SUPPORTED
|
||||
#define PNG_pCAL_SUPPORTED
|
||||
#define PNG_pHYs_SUPPORTED
|
||||
#define PNG_sBIT_SUPPORTED
|
||||
#define PNG_sCAL_SUPPORTED
|
||||
#define PNG_sPLT_SUPPORTED
|
||||
#define PNG_sRGB_SUPPORTED
|
||||
#define PNG_tEXt_SUPPORTED
|
||||
#define PNG_tIME_SUPPORTED
|
||||
#define PNG_tRNS_SUPPORTED
|
||||
#define PNG_zTXt_SUPPORTED
|
||||
/* end of options */
|
||||
/* settings */
|
||||
#define PNG_API_RULE 0
|
||||
#define PNG_DEFAULT_READ_MACROS 1
|
||||
#define PNG_GAMMA_THRESHOLD_FIXED 5000
|
||||
#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE
|
||||
#define PNG_INFLATE_BUF_SIZE 1024
|
||||
#define PNG_LINKAGE_API extern
|
||||
#define PNG_LINKAGE_CALLBACK extern
|
||||
#define PNG_LINKAGE_DATA extern
|
||||
#define PNG_LINKAGE_FUNCTION extern
|
||||
#define PNG_MAX_GAMMA_8 11
|
||||
#define PNG_QUANTIZE_BLUE_BITS 5
|
||||
#define PNG_QUANTIZE_GREEN_BITS 5
|
||||
#define PNG_QUANTIZE_RED_BITS 5
|
||||
#define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1)
|
||||
#define PNG_TEXT_Z_DEFAULT_STRATEGY 0
|
||||
#define PNG_USER_CHUNK_CACHE_MAX 1000
|
||||
#define PNG_USER_CHUNK_MALLOC_MAX 8000000
|
||||
#define PNG_USER_HEIGHT_MAX 1000000
|
||||
#define PNG_USER_WIDTH_MAX 1000000
|
||||
#define PNG_ZBUF_SIZE 8192
|
||||
#define PNG_ZLIB_VERNUM 0 /* unknown */
|
||||
#define PNG_Z_DEFAULT_COMPRESSION (-1)
|
||||
#define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0
|
||||
#define PNG_Z_DEFAULT_STRATEGY 1
|
||||
#define PNG_sCAL_PRECISION 5
|
||||
#define PNG_sRGB_PROFILE_CHECKS 2
|
||||
/* end of settings */
|
||||
#endif /* PNGLCONF_H */
|
||||
|
747
3rdparty/libpng/pngmem.c
vendored
@ -1,8 +1,8 @@
|
||||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.5.7 [December 15, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -20,627 +20,244 @@
|
||||
#include "pngpriv.h"
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
|
||||
/* Borland DOS special memory handler */
|
||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||
/* If you change this, be sure to change the one in png.h also */
|
||||
|
||||
/* Allocate memory for a png_struct. The malloc and memset can be replaced
|
||||
by a single call to calloc() if this is thought to improve performance. */
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_create_struct,(int type),PNG_ALLOCATED)
|
||||
{
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
return (png_create_struct_2(type, NULL, NULL));
|
||||
}
|
||||
|
||||
/* Alternate version of png_create_struct, for use with user-defined malloc. */
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_create_struct_2,(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr),
|
||||
PNG_ALLOCATED)
|
||||
{
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
png_size_t size;
|
||||
png_voidp struct_ptr;
|
||||
|
||||
if (type == PNG_STRUCT_INFO)
|
||||
size = png_sizeof(png_info);
|
||||
|
||||
else if (type == PNG_STRUCT_PNG)
|
||||
size = png_sizeof(png_struct);
|
||||
|
||||
else
|
||||
return (png_get_copyright(NULL));
|
||||
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (malloc_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
memset(&dummy_struct, 0, sizeof dummy_struct);
|
||||
dummy_struct.mem_ptr=mem_ptr;
|
||||
struct_ptr = (*(malloc_fn))(&dummy_struct, (png_alloc_size_t)size);
|
||||
}
|
||||
|
||||
else
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
struct_ptr = (png_voidp)farmalloc(size);
|
||||
if (struct_ptr != NULL)
|
||||
png_memset(struct_ptr, 0, size);
|
||||
|
||||
return (struct_ptr);
|
||||
}
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
/* Free a png_struct */
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct(png_voidp struct_ptr)
|
||||
png_destroy_png_struct(png_structrp png_ptr)
|
||||
{
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_destroy_struct_2(struct_ptr, NULL, NULL);
|
||||
}
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
||||
png_voidp mem_ptr)
|
||||
{
|
||||
# endif
|
||||
if (struct_ptr != NULL)
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (free_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
memset(&dummy_struct, 0, sizeof dummy_struct);
|
||||
dummy_struct.mem_ptr=mem_ptr;
|
||||
(*(free_fn))(&dummy_struct, struct_ptr);
|
||||
return;
|
||||
}
|
||||
/* png_free might call png_error and may certainly call
|
||||
* png_get_mem_ptr, so fake a temporary png_struct to support this.
|
||||
*/
|
||||
png_struct dummy_struct = *png_ptr;
|
||||
memset(png_ptr, 0, (sizeof *png_ptr));
|
||||
png_free(&dummy_struct, png_ptr);
|
||||
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
farfree (struct_ptr);
|
||||
# ifdef PNG_SETJMP_SUPPORTED
|
||||
/* We may have a jmp_buf left to deallocate. */
|
||||
png_free_jmpbuf(&dummy_struct);
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate memory. For reasonable files, size should never exceed
|
||||
* 64K. However, zlib may allocate more then 64K if you don't tell
|
||||
* it not to. See zconf.h and png.h for more information. zlib does
|
||||
* need to allocate exactly 64K, so whatever you call here must
|
||||
* have the ability to do that.
|
||||
*
|
||||
* Borland seems to have a problem in DOS mode for exactly 64K.
|
||||
* It gives you a segment with an offset of 8 (perhaps to store its
|
||||
* memory stuff). zlib doesn't like this at all, so we have to
|
||||
* detect and deal with it. This code should not be needed in
|
||||
* Windows or OS/2 modes, and only in 16 bit mode. This code has
|
||||
* been updated by Alexander Lehmann for version 0.89 to waste less
|
||||
* memory.
|
||||
*
|
||||
* Note that we can't use png_size_t for the "size" declaration,
|
||||
* since on some systems a png_size_t is a 16-bit quantity, and as a
|
||||
* result, we would be truncating potentially larger memory requests
|
||||
* (which should cause a fatal error) and introducing major problems.
|
||||
*/
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_calloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
ret = (png_malloc(png_ptr, size));
|
||||
|
||||
if (ret != NULL)
|
||||
png_memset(ret,0,(png_size_t)size);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return (NULL);
|
||||
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr->malloc_fn != NULL)
|
||||
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
|
||||
|
||||
else
|
||||
ret = (png_malloc_default(png_ptr, size));
|
||||
|
||||
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of memory");
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return (NULL);
|
||||
|
||||
# ifdef PNG_MAX_MALLOC_64K
|
||||
if (size > (png_uint_32)65536L)
|
||||
{
|
||||
png_warning(png_ptr, "Cannot Allocate > 64K");
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
else
|
||||
# endif
|
||||
|
||||
if (size != (size_t)size)
|
||||
ret = NULL;
|
||||
|
||||
else if (size == (png_uint_32)65536L)
|
||||
{
|
||||
if (png_ptr->offset_table == NULL)
|
||||
{
|
||||
/* Try to see if we need to do any of this fancy stuff */
|
||||
ret = farmalloc(size);
|
||||
if (ret == NULL || ((png_size_t)ret & 0xffff))
|
||||
{
|
||||
int num_blocks;
|
||||
png_uint_32 total_size;
|
||||
png_bytep table;
|
||||
int i, mem_level, window_bits;
|
||||
png_byte huge * hptr;
|
||||
int window_bits
|
||||
|
||||
if (ret != NULL)
|
||||
{
|
||||
farfree(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
window_bits =
|
||||
png_ptr->zlib_window_bits >= png_ptr->zlib_text_window_bits ?
|
||||
png_ptr->zlib_window_bits : png_ptr->zlib_text_window_bits;
|
||||
|
||||
if (window_bits > 14)
|
||||
num_blocks = (int)(1 << (window_bits - 14));
|
||||
|
||||
else
|
||||
num_blocks = 1;
|
||||
|
||||
mem_level =
|
||||
png_ptr->zlib_mem_level >= png_ptr->zlib_text_mem_level ?
|
||||
png_ptr->zlib_mem_level : png_ptr->zlib_text_mem_level;
|
||||
|
||||
if (mem_level >= 7)
|
||||
num_blocks += (int)(1 << (mem_level - 7));
|
||||
|
||||
else
|
||||
num_blocks++;
|
||||
|
||||
total_size = ((png_uint_32)65536L) * (png_uint_32)num_blocks+16;
|
||||
|
||||
table = farmalloc(total_size);
|
||||
|
||||
if (table == NULL)
|
||||
{
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out Of Memory"); /* Note "O", "M" */
|
||||
|
||||
else
|
||||
png_warning(png_ptr, "Out Of Memory");
|
||||
# endif
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if ((png_size_t)table & 0xfff0)
|
||||
{
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr,
|
||||
"Farmalloc didn't return normalized pointer");
|
||||
|
||||
else
|
||||
png_warning(png_ptr,
|
||||
"Farmalloc didn't return normalized pointer");
|
||||
# endif
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
png_ptr->offset_table = table;
|
||||
png_ptr->offset_table_ptr = farmalloc(num_blocks *
|
||||
png_sizeof(png_bytep));
|
||||
|
||||
if (png_ptr->offset_table_ptr == NULL)
|
||||
{
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out Of memory"); /* Note "O", "m" */
|
||||
|
||||
else
|
||||
png_warning(png_ptr, "Out Of memory");
|
||||
# endif
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
hptr = (png_byte huge *)table;
|
||||
if ((png_size_t)hptr & 0xf)
|
||||
{
|
||||
hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
|
||||
hptr = hptr + 16L; /* "hptr += 16L" fails on Turbo C++ 3.0 */
|
||||
}
|
||||
|
||||
for (i = 0; i < num_blocks; i++)
|
||||
{
|
||||
png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
|
||||
hptr = hptr + (png_uint_32)65536L; /* "+=" fails on TC++3.0 */
|
||||
}
|
||||
|
||||
png_ptr->offset_table_number = num_blocks;
|
||||
png_ptr->offset_table_count = 0;
|
||||
png_ptr->offset_table_count_free = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (png_ptr->offset_table_count >= png_ptr->offset_table_number)
|
||||
{
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of Memory"); /* Note "O" and "M" */
|
||||
|
||||
else
|
||||
png_warning(png_ptr, "Out of Memory");
|
||||
# endif
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++];
|
||||
}
|
||||
|
||||
else
|
||||
ret = farmalloc(size);
|
||||
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if (ret == NULL)
|
||||
{
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of memory"); /* Note "o" and "m" */
|
||||
|
||||
else
|
||||
png_warning(png_ptr, "Out of memory"); /* Note "o" and "m" */
|
||||
}
|
||||
# endif
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/* Free a pointer allocated by png_malloc(). In the default
|
||||
* configuration, png_ptr is not used, but is passed in case it
|
||||
* is needed. If ptr is NULL, return without taking any action.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_free(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr->free_fn != NULL)
|
||||
{
|
||||
(*(png_ptr->free_fn))(png_ptr, ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
else
|
||||
png_free_default(png_ptr, ptr);
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
|
||||
if (png_ptr->offset_table != NULL)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < png_ptr->offset_table_count; i++)
|
||||
{
|
||||
if (ptr == png_ptr->offset_table_ptr[i])
|
||||
{
|
||||
ptr = NULL;
|
||||
png_ptr->offset_table_count_free++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (png_ptr->offset_table_count_free == png_ptr->offset_table_count)
|
||||
{
|
||||
farfree(png_ptr->offset_table);
|
||||
farfree(png_ptr->offset_table_ptr);
|
||||
png_ptr->offset_table = NULL;
|
||||
png_ptr->offset_table_ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (ptr != NULL)
|
||||
farfree(ptr);
|
||||
}
|
||||
|
||||
#else /* Not the Borland DOS special memory handler */
|
||||
|
||||
/* Allocate memory for a png_struct or a png_info. The malloc and
|
||||
memset can be replaced by a single call to calloc() if this is thought
|
||||
to improve performance noticably. */
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_create_struct,(int type),PNG_ALLOCATED)
|
||||
{
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
return (png_create_struct_2(type, NULL, NULL));
|
||||
}
|
||||
|
||||
/* Allocate memory for a png_struct or a png_info. The malloc and
|
||||
memset can be replaced by a single call to calloc() if this is thought
|
||||
to improve performance noticably. */
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_create_struct_2,(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr),
|
||||
PNG_ALLOCATED)
|
||||
{
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
png_size_t size;
|
||||
png_voidp struct_ptr;
|
||||
|
||||
if (type == PNG_STRUCT_INFO)
|
||||
size = png_sizeof(png_info);
|
||||
|
||||
else if (type == PNG_STRUCT_PNG)
|
||||
size = png_sizeof(png_struct);
|
||||
|
||||
else
|
||||
return (NULL);
|
||||
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (malloc_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
png_ptr->mem_ptr=mem_ptr;
|
||||
struct_ptr = (*(malloc_fn))(png_ptr, size);
|
||||
|
||||
if (struct_ptr != NULL)
|
||||
png_memset(struct_ptr, 0, size);
|
||||
|
||||
return (struct_ptr);
|
||||
}
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
struct_ptr = (png_voidp)farmalloc(size);
|
||||
# else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
struct_ptr = (png_voidp)halloc(size, 1);
|
||||
# else
|
||||
struct_ptr = (png_voidp)malloc(size);
|
||||
# endif
|
||||
# endif
|
||||
|
||||
if (struct_ptr != NULL)
|
||||
png_memset(struct_ptr, 0, size);
|
||||
|
||||
return (struct_ptr);
|
||||
}
|
||||
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct(png_voidp struct_ptr)
|
||||
{
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_destroy_struct_2(struct_ptr, NULL, NULL);
|
||||
}
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
||||
png_voidp mem_ptr)
|
||||
{
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
if (struct_ptr != NULL)
|
||||
{
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (free_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
png_ptr->mem_ptr=mem_ptr;
|
||||
(*(free_fn))(png_ptr, struct_ptr);
|
||||
return;
|
||||
}
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
farfree(struct_ptr);
|
||||
|
||||
# else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
hfree(struct_ptr);
|
||||
|
||||
# else
|
||||
free(struct_ptr);
|
||||
|
||||
# endif
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate memory. For reasonable files, size should never exceed
|
||||
* 64K. However, zlib may allocate more then 64K if you don't tell
|
||||
* 64K. However, zlib may allocate more than 64K if you don't tell
|
||||
* it not to. See zconf.h and png.h for more information. zlib does
|
||||
* need to allocate exactly 64K, so whatever you call here must
|
||||
* have the ability to do that.
|
||||
*/
|
||||
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_calloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
png_calloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
ret = (png_malloc(png_ptr, size));
|
||||
ret = png_malloc(png_ptr, size);
|
||||
|
||||
if (ret != NULL)
|
||||
png_memset(ret,0,(png_size_t)size);
|
||||
memset(ret, 0, size);
|
||||
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
/* png_malloc_base, an internal function added at libpng 1.6.0, does the work of
|
||||
* allocating memory, taking into account limits and PNG_USER_MEM_SUPPORTED.
|
||||
* Checking and error handling must happen outside this routine; it returns NULL
|
||||
* if the allocation cannot be done (for any reason.)
|
||||
*/
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
/* Moved to png_malloc_base from png_malloc_default in 1.6.0; the DOS
|
||||
* allocators have also been removed in 1.6.0, so any 16-bit system now has
|
||||
* to implement a user memory handler. This checks to be sure it isn't
|
||||
* called with big numbers.
|
||||
*/
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
PNG_UNUSED(png_ptr)
|
||||
#endif
|
||||
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return (NULL);
|
||||
|
||||
if (png_ptr->malloc_fn != NULL)
|
||||
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
|
||||
|
||||
else
|
||||
ret = (png_malloc_default(png_ptr, size));
|
||||
|
||||
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return (NULL);
|
||||
|
||||
# ifdef PNG_MAX_MALLOC_64K
|
||||
if (size > (png_uint_32)65536L)
|
||||
/* Some compilers complain that this is always true. However, it
|
||||
* can be false when integer overflow happens.
|
||||
*/
|
||||
if (size > 0 && size <= PNG_SIZE_MAX
|
||||
# ifdef PNG_MAX_MALLOC_64K
|
||||
&& size <= 65536U
|
||||
# endif
|
||||
)
|
||||
{
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Cannot Allocate > 64K");
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr != NULL && png_ptr->malloc_fn != NULL)
|
||||
return png_ptr->malloc_fn(png_constcast(png_structrp,png_ptr), size);
|
||||
|
||||
else
|
||||
# endif
|
||||
return NULL;
|
||||
#endif
|
||||
return malloc((size_t)size); /* checked for truncation above */
|
||||
}
|
||||
# endif
|
||||
|
||||
/* Check for overflow */
|
||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
|
||||
if (size != (unsigned long)size)
|
||||
ret = NULL;
|
||||
|
||||
else
|
||||
ret = farmalloc(size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
# else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
if (size != (unsigned long)size)
|
||||
ret = NULL;
|
||||
#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\
|
||||
defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
/* This is really here only to work round a spurious warning in GCC 4.6 and 4.7
|
||||
* that arises because of the checks in png_realloc_array that are repeated in
|
||||
* png_malloc_array.
|
||||
*/
|
||||
static png_voidp
|
||||
png_malloc_array_checked(png_const_structrp png_ptr, int nelements,
|
||||
size_t element_size)
|
||||
{
|
||||
png_alloc_size_t req = nelements; /* known to be > 0 */
|
||||
|
||||
else
|
||||
ret = halloc(size, 1);
|
||||
if (req <= PNG_SIZE_MAX/element_size)
|
||||
return png_malloc_base(png_ptr, req * element_size);
|
||||
|
||||
# else
|
||||
if (size != (size_t)size)
|
||||
ret = NULL;
|
||||
/* The failure case when the request is too large */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
else
|
||||
ret = malloc((size_t)size);
|
||||
# endif
|
||||
# endif
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_malloc_array,(png_const_structrp png_ptr, int nelements,
|
||||
size_t element_size),PNG_ALLOCATED)
|
||||
{
|
||||
if (nelements <= 0 || element_size == 0)
|
||||
png_error(png_ptr, "internal error: array alloc");
|
||||
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
# endif
|
||||
return png_malloc_array_checked(png_ptr, nelements, element_size);
|
||||
}
|
||||
|
||||
return (ret);
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array,
|
||||
int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED)
|
||||
{
|
||||
/* These are internal errors: */
|
||||
if (add_elements <= 0 || element_size == 0 || old_elements < 0 ||
|
||||
(old_array == NULL && old_elements > 0))
|
||||
png_error(png_ptr, "internal error: array realloc");
|
||||
|
||||
/* Check for overflow on the elements count (so the caller does not have to
|
||||
* check.)
|
||||
*/
|
||||
if (add_elements <= INT_MAX - old_elements)
|
||||
{
|
||||
png_voidp new_array = png_malloc_array_checked(png_ptr,
|
||||
old_elements+add_elements, element_size);
|
||||
|
||||
if (new_array != NULL)
|
||||
{
|
||||
/* Because png_malloc_array worked the size calculations below cannot
|
||||
* overflow.
|
||||
*/
|
||||
if (old_elements > 0)
|
||||
memcpy(new_array, old_array, element_size*(unsigned)old_elements);
|
||||
|
||||
memset((char*)new_array + element_size*(unsigned)old_elements, 0,
|
||||
element_size*(unsigned)add_elements);
|
||||
|
||||
return new_array;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL; /* error */
|
||||
}
|
||||
#endif /* TEXT || sPLT || STORE_UNKNOWN_CHUNKS */
|
||||
|
||||
/* Various functions that have different error handling are derived from this.
|
||||
* png_malloc always exists, but if PNG_USER_MEM_SUPPORTED is defined a separate
|
||||
* function png_malloc_default is also provided.
|
||||
*/
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
ret = png_malloc_base(png_ptr, size);
|
||||
|
||||
if (ret == NULL)
|
||||
png_error(png_ptr, "Out of memory"); /* 'm' means png_malloc */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
PNG_ALLOCATED PNG_DEPRECATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Passing 'NULL' here bypasses the application provided memory handler. */
|
||||
ret = png_malloc_base(NULL/*use malloc*/, size);
|
||||
|
||||
if (ret == NULL)
|
||||
png_error(png_ptr, "Out of Memory"); /* 'M' means png_malloc_default */
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* USER_MEM */
|
||||
|
||||
/* This function was added at libpng version 1.2.3. The png_malloc_warn()
|
||||
* function will issue a png_warning and return NULL instead of issuing a
|
||||
* png_error, if it fails to allocate the requested memory.
|
||||
*/
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc_warn,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
PNG_ALLOCATED)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
png_voidp ret = png_malloc_base(png_ptr, size);
|
||||
|
||||
if (ret != NULL)
|
||||
return ret;
|
||||
|
||||
png_warning(png_ptr, "Out of memory");
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Free a pointer allocated by png_malloc(). If ptr is NULL, return
|
||||
* without taking any action.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_free(png_structp png_ptr, png_voidp ptr)
|
||||
png_free(png_const_structrp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr->free_fn != NULL)
|
||||
{
|
||||
(*(png_ptr->free_fn))(png_ptr, ptr);
|
||||
return;
|
||||
}
|
||||
png_ptr->free_fn(png_constcast(png_structrp,png_ptr), ptr);
|
||||
|
||||
else
|
||||
png_free_default(png_ptr, ptr);
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_free_default,(png_const_structrp png_ptr, png_voidp ptr),PNG_DEPRECATED)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
#endif /* USER_MEM */
|
||||
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
farfree(ptr);
|
||||
|
||||
# else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
hfree(ptr);
|
||||
|
||||
# else
|
||||
free(ptr);
|
||||
|
||||
# endif
|
||||
# endif
|
||||
}
|
||||
#endif /* Not Borland DOS special memory handler */
|
||||
|
||||
/* This function was added at libpng version 1.2.3. The png_malloc_warn()
|
||||
* function will set up png_malloc() to issue a png_warning and return NULL
|
||||
* instead of issuing a png_error, if it fails to allocate the requested
|
||||
* memory.
|
||||
*/
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc_warn,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ptr;
|
||||
png_uint_32 save_flags;
|
||||
if (png_ptr == NULL)
|
||||
return (NULL);
|
||||
|
||||
save_flags = png_ptr->flags;
|
||||
png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
|
||||
ptr = (png_voidp)png_malloc((png_structp)png_ptr, size);
|
||||
png_ptr->flags=save_flags;
|
||||
return(ptr);
|
||||
}
|
||||
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
/* This function is called when the application wants to use another method
|
||||
* of allocating and freeing memory.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
||||
png_set_mem_fn(png_structrp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
||||
malloc_fn, png_free_ptr free_fn)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
@ -656,12 +273,12 @@ png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
||||
* pointer before png_write_destroy and png_read_destroy are called.
|
||||
*/
|
||||
png_voidp PNGAPI
|
||||
png_get_mem_ptr(png_const_structp png_ptr)
|
||||
png_get_mem_ptr(png_const_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return (NULL);
|
||||
return NULL;
|
||||
|
||||
return ((png_voidp)png_ptr->mem_ptr);
|
||||
return png_ptr->mem_ptr;
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
#endif /* USER_MEM */
|
||||
#endif /* READ || WRITE */
|
||||
|
512
3rdparty/libpng/pngpread.c
vendored
1672
3rdparty/libpng/pngpriv.h
vendored
3708
3rdparty/libpng/pngread.c
vendored
74
3rdparty/libpng/pngrio.c
vendored
@ -1,8 +1,8 @@
|
||||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -26,10 +26,10 @@
|
||||
* reads from a file pointer. Note that this routine sometimes gets called
|
||||
* with very small lengths, so you should implement some kind of simple
|
||||
* buffering if you are using unbuffered reads. This should never be asked
|
||||
* to read more then 64K on a 16 bit machine.
|
||||
* to read more than 64K on a 16-bit machine.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
png_read_data(png_structrp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_debug1(4, "reading %d bytes", (int)length);
|
||||
|
||||
@ -46,7 +46,6 @@ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
* read_data function and use it at run time with png_set_read_fn(), rather
|
||||
* than changing the library.
|
||||
*/
|
||||
# ifndef USE_FAR_KEYWORD
|
||||
void PNGCBAPI
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
@ -58,68 +57,11 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
|
||||
* instead of an int, which is what fread() actually returns.
|
||||
*/
|
||||
check = fread(data, 1, length, (png_FILE_p)png_ptr->io_ptr);
|
||||
check = fread(data, 1, length, png_voidcast(png_FILE_p, png_ptr->io_ptr));
|
||||
|
||||
if (check != length)
|
||||
png_error(png_ptr, "Read Error");
|
||||
}
|
||||
# else
|
||||
/* This is the model-independent version. Since the standard I/O library
|
||||
can't handle far buffers in the medium and small models, we have to copy
|
||||
the data.
|
||||
*/
|
||||
|
||||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
static void PNGCBAPI
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_size_t check;
|
||||
png_byte *n_data;
|
||||
png_FILE_p io_ptr;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* Check if data really is near. If so, use usual code. */
|
||||
n_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
||||
|
||||
if ((png_bytep)n_data == data)
|
||||
{
|
||||
check = fread(n_data, 1, length, io_ptr);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_byte buf[NEAR_BUF_SIZE];
|
||||
png_size_t read, remaining, err;
|
||||
check = 0;
|
||||
remaining = length;
|
||||
|
||||
do
|
||||
{
|
||||
read = MIN(NEAR_BUF_SIZE, remaining);
|
||||
err = fread(buf, 1, read, io_ptr);
|
||||
png_memcpy(data, buf, read); /* copy far buffer to near buffer */
|
||||
|
||||
if (err != read)
|
||||
break;
|
||||
|
||||
else
|
||||
check += err;
|
||||
|
||||
data += read;
|
||||
remaining -= read;
|
||||
}
|
||||
while (remaining != 0);
|
||||
}
|
||||
|
||||
if ((png_uint_32)check != (png_uint_32)length)
|
||||
png_error(png_ptr, "read Error");
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* This function allows the application to supply a new input function
|
||||
@ -142,7 +84,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
* be used.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr read_data_fn)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
@ -160,6 +102,7 @@ png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
png_ptr->read_data_fn = read_data_fn;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
/* It is an error to write to a read device */
|
||||
if (png_ptr->write_data_fn != NULL)
|
||||
{
|
||||
@ -168,9 +111,10 @@ png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
"Can't set both read_data_fn and write_data_fn in the"
|
||||
" same structure");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
png_ptr->output_flush_fn = NULL;
|
||||
#endif
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* READ */
|
||||
|
1526
3rdparty/libpng/pngrtran.c
vendored
3453
3rdparty/libpng/pngrutil.c
vendored
1146
3rdparty/libpng/pngset.c
vendored
234
3rdparty/libpng/pngstruct.h
vendored
@ -1,12 +1,11 @@
|
||||
|
||||
/* pngstruct.h - header file for PNG reference library
|
||||
*
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* Last changed in libpng 1.5.9 [February 18, 2012]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
@ -24,13 +23,130 @@
|
||||
* in this structure and is required for decompressing the LZ compressed
|
||||
* data in PNG files.
|
||||
*/
|
||||
#ifndef ZLIB_CONST
|
||||
/* We must ensure that zlib uses 'const' in declarations. */
|
||||
# define ZLIB_CONST
|
||||
#endif
|
||||
#include "zlib.h"
|
||||
#ifdef const
|
||||
/* zlib.h sometimes #defines const to nothing, undo this. */
|
||||
# undef const
|
||||
#endif
|
||||
|
||||
/* zlib.h has mediocre z_const use before 1.2.6, this stuff is for compatibility
|
||||
* with older builds.
|
||||
*/
|
||||
#if ZLIB_VERNUM < 0x1260
|
||||
# define PNGZ_MSG_CAST(s) png_constcast(char*,s)
|
||||
# define PNGZ_INPUT_CAST(b) png_constcast(png_bytep,b)
|
||||
#else
|
||||
# define PNGZ_MSG_CAST(s) (s)
|
||||
# define PNGZ_INPUT_CAST(b) (b)
|
||||
#endif
|
||||
|
||||
/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib
|
||||
* can handle at once. This type need be no larger than 16 bits (so maximum of
|
||||
* 65535), this define allows us to discover how big it is, but limited by the
|
||||
* maximuum for png_size_t. The value can be overriden in a library build
|
||||
* (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably
|
||||
* lower value (e.g. 255 works). A lower value may help memory usage (slightly)
|
||||
* and may even improve performance on some systems (and degrade it on others.)
|
||||
*/
|
||||
#ifndef ZLIB_IO_MAX
|
||||
# define ZLIB_IO_MAX ((uInt)-1)
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
/* The type of a compression buffer list used by the write code. */
|
||||
typedef struct png_compression_buffer
|
||||
{
|
||||
struct png_compression_buffer *next;
|
||||
png_byte output[1]; /* actually zbuf_size */
|
||||
} png_compression_buffer, *png_compression_bufferp;
|
||||
|
||||
#define PNG_COMPRESSION_BUFFER_SIZE(pp)\
|
||||
(offsetof(png_compression_buffer, output) + (pp)->zbuffer_size)
|
||||
#endif
|
||||
|
||||
/* Colorspace support; structures used in png_struct, png_info and in internal
|
||||
* functions to hold and communicate information about the color space.
|
||||
*
|
||||
* PNG_COLORSPACE_SUPPORTED is only required if the application will perform
|
||||
* colorspace corrections, otherwise all the colorspace information can be
|
||||
* skipped and the size of libpng can be reduced (significantly) by compiling
|
||||
* out the colorspace support.
|
||||
*/
|
||||
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||
/* The chromaticities of the red, green and blue colorants and the chromaticity
|
||||
* of the corresponding white point (i.e. of rgb(1.0,1.0,1.0)).
|
||||
*/
|
||||
typedef struct png_xy
|
||||
{
|
||||
png_fixed_point redx, redy;
|
||||
png_fixed_point greenx, greeny;
|
||||
png_fixed_point bluex, bluey;
|
||||
png_fixed_point whitex, whitey;
|
||||
} png_xy;
|
||||
|
||||
/* The same data as above but encoded as CIE XYZ values. When this data comes
|
||||
* from chromaticities the sum of the Y values is assumed to be 1.0
|
||||
*/
|
||||
typedef struct png_XYZ
|
||||
{
|
||||
png_fixed_point red_X, red_Y, red_Z;
|
||||
png_fixed_point green_X, green_Y, green_Z;
|
||||
png_fixed_point blue_X, blue_Y, blue_Z;
|
||||
} png_XYZ;
|
||||
#endif /* COLORSPACE */
|
||||
|
||||
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||
/* A colorspace is all the above plus, potentially, profile information;
|
||||
* however at present libpng does not use the profile internally so it is only
|
||||
* stored in the png_info struct (if iCCP is supported.) The rendering intent
|
||||
* is retained here and is checked.
|
||||
*
|
||||
* The file gamma encoding information is also stored here and gamma correction
|
||||
* is done by libpng, whereas color correction must currently be done by the
|
||||
* application.
|
||||
*/
|
||||
typedef struct png_colorspace
|
||||
{
|
||||
#ifdef PNG_GAMMA_SUPPORTED
|
||||
png_fixed_point gamma; /* File gamma */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||
png_xy end_points_xy; /* End points as chromaticities */
|
||||
png_XYZ end_points_XYZ; /* End points as CIE XYZ colorant values */
|
||||
png_uint_16 rendering_intent; /* Rendering intent of a profile */
|
||||
#endif
|
||||
|
||||
/* Flags are always defined to simplify the code. */
|
||||
png_uint_16 flags; /* As defined below */
|
||||
} png_colorspace, * PNG_RESTRICT png_colorspacerp;
|
||||
|
||||
typedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp;
|
||||
|
||||
/* General flags for the 'flags' field */
|
||||
#define PNG_COLORSPACE_HAVE_GAMMA 0x0001
|
||||
#define PNG_COLORSPACE_HAVE_ENDPOINTS 0x0002
|
||||
#define PNG_COLORSPACE_HAVE_INTENT 0x0004
|
||||
#define PNG_COLORSPACE_FROM_gAMA 0x0008
|
||||
#define PNG_COLORSPACE_FROM_cHRM 0x0010
|
||||
#define PNG_COLORSPACE_FROM_sRGB 0x0020
|
||||
#define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040
|
||||
#define PNG_COLORSPACE_MATCHES_sRGB 0x0080 /* exact match on profile */
|
||||
#define PNG_COLORSPACE_INVALID 0x8000
|
||||
#define PNG_COLORSPACE_CANCEL(flags) (0xffff ^ (flags))
|
||||
#endif /* COLORSPACE || GAMMA */
|
||||
|
||||
struct png_struct_def
|
||||
{
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
jmp_buf longjmp_buffer; /* used in png_error */
|
||||
jmp_buf jmp_buf_local; /* New name in 1.6.0 for jmp_buf in png_struct */
|
||||
png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */
|
||||
jmp_buf *jmp_buf_ptr; /* passed to longjmp_fn */
|
||||
size_t jmp_buf_size; /* size of the above, if allocated */
|
||||
#endif
|
||||
png_error_ptr error_fn; /* function for printing errors and aborting */
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
@ -63,22 +179,12 @@ struct png_struct_def
|
||||
png_uint_32 flags; /* flags indicating various things to libpng */
|
||||
png_uint_32 transformations; /* which transformations to perform */
|
||||
|
||||
z_stream zstream; /* pointer to decompression structure (below) */
|
||||
png_bytep zbuf; /* buffer for zlib */
|
||||
uInt zbuf_size; /* size of zbuf (typically 65536) */
|
||||
png_uint_32 zowner; /* ID (chunk type) of zstream owner, 0 if none */
|
||||
z_stream zstream; /* decompression structure */
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
|
||||
/* Added in 1.5.4: state to keep track of whether the zstream has been
|
||||
* initialized and if so whether it is for IDAT or some other chunk.
|
||||
*/
|
||||
#define PNG_ZLIB_UNINITIALIZED 0
|
||||
#define PNG_ZLIB_FOR_IDAT 1
|
||||
#define PNG_ZLIB_FOR_TEXT 2 /* anything other than IDAT */
|
||||
#define PNG_ZLIB_USE_MASK 3 /* bottom two bits */
|
||||
#define PNG_ZLIB_IN_USE 4 /* a flag value */
|
||||
|
||||
png_uint_32 zlib_state; /* State of zlib initialization */
|
||||
/* End of material added at libpng 1.5.4 */
|
||||
png_compression_bufferp zbuffer_list; /* Created on demand during write */
|
||||
uInt zbuffer_size; /* size of the actual buffer */
|
||||
|
||||
int zlib_level; /* holds zlib compression level */
|
||||
int zlib_method; /* holds zlib compression method */
|
||||
@ -87,8 +193,7 @@ struct png_struct_def
|
||||
int zlib_strategy; /* holds zlib compression strategy */
|
||||
#endif
|
||||
/* Added at libpng 1.5.4 */
|
||||
#if defined(PNG_WRITE_COMPRESSED_TEXT_SUPPORTED) || \
|
||||
defined(PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED)
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
int zlib_text_level; /* holds zlib compression level */
|
||||
int zlib_text_method; /* holds zlib compression method */
|
||||
int zlib_text_window_bits; /* holds zlib compression window bits */
|
||||
@ -96,6 +201,14 @@ struct png_struct_def
|
||||
int zlib_text_strategy; /* holds zlib compression strategy */
|
||||
#endif
|
||||
/* End of material added at libpng 1.5.4 */
|
||||
/* Added at libpng 1.6.0 */
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
int zlib_set_level; /* Actual values set into the zstream on write */
|
||||
int zlib_set_method;
|
||||
int zlib_set_window_bits;
|
||||
int zlib_set_mem_level;
|
||||
int zlib_set_strategy;
|
||||
#endif
|
||||
|
||||
png_uint_32 width; /* width of image in pixels */
|
||||
png_uint_32 height; /* height of image in pixels */
|
||||
@ -106,15 +219,19 @@ struct png_struct_def
|
||||
png_uint_32 row_number; /* current row in interlace pass */
|
||||
png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */
|
||||
png_bytep prev_row; /* buffer to save previous (unfiltered) row.
|
||||
* This is a pointer into big_prev_row
|
||||
* While reading this is a pointer into
|
||||
* big_prev_row; while writing it is separately
|
||||
* allocated if needed.
|
||||
*/
|
||||
png_bytep row_buf; /* buffer to save current (unfiltered) row.
|
||||
* This is a pointer into big_row_buf
|
||||
* While reading, this is a pointer into
|
||||
* big_row_buf; while writing it is separately
|
||||
* allocated.
|
||||
*/
|
||||
png_bytep sub_row; /* buffer to save "sub" row when filtering */
|
||||
png_bytep up_row; /* buffer to save "up" row when filtering */
|
||||
png_bytep avg_row; /* buffer to save "avg" row when filtering */
|
||||
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
png_bytep try_row; /* buffer to save trial row when filtering */
|
||||
png_bytep tst_row; /* buffer to save best trial row when filtering */
|
||||
#endif
|
||||
png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */
|
||||
|
||||
png_uint_32 idat_size; /* current IDAT size for read */
|
||||
@ -138,15 +255,14 @@ struct png_struct_def
|
||||
png_byte usr_bit_depth; /* bit depth of users row: write only */
|
||||
png_byte pixel_depth; /* number of bits per pixel */
|
||||
png_byte channels; /* number of channels in file */
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
png_byte usr_channels; /* channels at start of write: write only */
|
||||
#endif
|
||||
png_byte sig_bytes; /* magic bytes read/written from start of file */
|
||||
png_byte maximum_pixel_depth;
|
||||
/* pixel depth used for the row buffers */
|
||||
png_byte transformed_pixel_depth;
|
||||
/* pixel depth after read/write transforms */
|
||||
png_byte io_chunk_string[5];
|
||||
/* string name of chunk */
|
||||
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||
png_uint_16 filler; /* filler bytes for pixel expansion */
|
||||
#endif
|
||||
@ -159,7 +275,7 @@ struct png_struct_def
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
png_color_16 background_1; /* background normalized to gamma 1.0 */
|
||||
#endif
|
||||
#endif /* PNG_bKGD_SUPPORTED */
|
||||
#endif /* bKGD */
|
||||
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
png_flush_ptr output_flush_fn; /* Function for flushing output */
|
||||
@ -169,7 +285,6 @@ struct png_struct_def
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */
|
||||
png_fixed_point gamma; /* file gamma value */
|
||||
png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */
|
||||
|
||||
png_bytep gamma_table; /* gamma table for 8-bit depth files */
|
||||
@ -217,7 +332,7 @@ struct png_struct_def
|
||||
int process_mode; /* what push library is currently doing */
|
||||
int cur_palette; /* current push library palette index */
|
||||
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
#endif /* PROGRESSIVE_READ */
|
||||
|
||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||
/* For the Borland special 64K segment handler */
|
||||
@ -233,24 +348,17 @@ struct png_struct_def
|
||||
png_bytep quantize_index; /* index translation for palette files */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_QUANTIZE_SUPPORTED) || defined(PNG_hIST_SUPPORTED)
|
||||
png_uint_16p hist; /* histogram */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
png_byte heuristic_method; /* heuristic for row filter selection */
|
||||
png_byte num_prev_filters; /* number of weights for previous rows */
|
||||
png_bytep prev_filters; /* filter type(s) of previous row(s) */
|
||||
png_uint_16p filter_weights; /* weight(s) for previous line(s) */
|
||||
png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */
|
||||
png_uint_16p filter_costs; /* relative filter calculation cost */
|
||||
png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
|
||||
/* Options */
|
||||
#ifdef PNG_SET_OPTION_SUPPORTED
|
||||
png_byte options; /* On/off state (up to 4 options) */
|
||||
#endif
|
||||
|
||||
#if PNG_LIBPNG_VER < 10700
|
||||
/* To do: remove this from libpng-1.7 */
|
||||
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||
/* This is going to be unused in libpng16 and removed from libpng17 */
|
||||
char time_buffer[29]; /* String to hold RFC 1123 time text */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.0.6 */
|
||||
|
||||
@ -258,17 +366,16 @@ struct png_struct_def
|
||||
|
||||
#ifdef PNG_USER_CHUNKS_SUPPORTED
|
||||
png_voidp user_chunk_ptr;
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
int num_chunk_list;
|
||||
png_bytep chunk_list;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_sRGB_SUPPORTED
|
||||
/* Added in 1.5.5 to record an sRGB chunk in the png. */
|
||||
png_byte is_sRGB;
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
int unknown_default; /* As PNG_HANDLE_* */
|
||||
unsigned int num_chunk_list; /* Number of entries in the list */
|
||||
png_bytep chunk_list; /* List of png_byte[5]; the textual chunk name
|
||||
* followed by a PNG_HANDLE_* byte */
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.0.3 */
|
||||
@ -333,16 +440,24 @@ struct png_struct_def
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.0.25 and 1.2.17 */
|
||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Storage for unknown chunk that the library doesn't recognize. */
|
||||
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Temporary storage for unknown chunk that the library doesn't recognize,
|
||||
* used while reading the chunk.
|
||||
*/
|
||||
png_unknown_chunk unknown_chunk;
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.2.26 */
|
||||
png_size_t old_big_row_buf_size;
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* New member added in libpng-1.2.30 */
|
||||
png_charp chunkdata; /* buffer for reading chunk data */
|
||||
png_bytep read_buffer; /* buffer for reading chunk data */
|
||||
png_alloc_size_t read_buffer_size; /* current size of the buffer */
|
||||
#endif
|
||||
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
uInt IDAT_read_size; /* limit on read buffer size for IDAT */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
/* New member added in libpng-1.4.0 */
|
||||
@ -352,7 +467,14 @@ struct png_struct_def
|
||||
/* New member added in libpng-1.5.6 */
|
||||
png_bytep big_prev_row;
|
||||
|
||||
/* New member added in libpng-1.5.7 */
|
||||
void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
|
||||
png_bytep row, png_const_bytep prev_row);
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||
png_colorspace colorspace;
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
#endif /* PNGSTRUCT_H */
|
||||
|
182
3rdparty/libpng/pngtrans.c
vendored
@ -1,8 +1,8 @@
|
||||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* Last changed in libpng 1.5.11 [June 14, 2012]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -18,7 +18,7 @@
|
||||
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
||||
/* Turn on BGR-to-RGB mapping */
|
||||
void PNGAPI
|
||||
png_set_bgr(png_structp png_ptr)
|
||||
png_set_bgr(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_bgr");
|
||||
|
||||
@ -30,9 +30,9 @@ png_set_bgr(png_structp png_ptr)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||
/* Turn on 16 bit byte swapping */
|
||||
/* Turn on 16-bit byte swapping */
|
||||
void PNGAPI
|
||||
png_set_swap(png_structp png_ptr)
|
||||
png_set_swap(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_swap");
|
||||
|
||||
@ -47,7 +47,7 @@ png_set_swap(png_structp png_ptr)
|
||||
#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
/* Turn on pixel packing */
|
||||
void PNGAPI
|
||||
png_set_packing(png_structp png_ptr)
|
||||
png_set_packing(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_packing");
|
||||
|
||||
@ -57,7 +57,9 @@ png_set_packing(png_structp png_ptr)
|
||||
if (png_ptr->bit_depth < 8)
|
||||
{
|
||||
png_ptr->transformations |= PNG_PACK;
|
||||
png_ptr->usr_bit_depth = 8;
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
png_ptr->usr_bit_depth = 8;
|
||||
# endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -65,7 +67,7 @@ png_set_packing(png_structp png_ptr)
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
||||
/* Turn on packed pixel swapping */
|
||||
void PNGAPI
|
||||
png_set_packswap(png_structp png_ptr)
|
||||
png_set_packswap(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_packswap");
|
||||
|
||||
@ -79,7 +81,7 @@ png_set_packswap(png_structp png_ptr)
|
||||
|
||||
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_shift(png_structp png_ptr, png_const_color_8p true_bits)
|
||||
png_set_shift(png_structrp png_ptr, png_const_color_8p true_bits)
|
||||
{
|
||||
png_debug(1, "in png_set_shift");
|
||||
|
||||
@ -94,11 +96,11 @@ png_set_shift(png_structp png_ptr, png_const_color_8p true_bits)
|
||||
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
|
||||
defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||
int PNGAPI
|
||||
png_set_interlace_handling(png_structp png_ptr)
|
||||
png_set_interlace_handling(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_interlace handling");
|
||||
|
||||
if (png_ptr && png_ptr->interlaced)
|
||||
if (png_ptr != 0 && png_ptr->interlaced != 0)
|
||||
{
|
||||
png_ptr->transformations |= PNG_INTERLACE;
|
||||
return (7);
|
||||
@ -115,44 +117,91 @@ png_set_interlace_handling(png_structp png_ptr)
|
||||
* that don't like bytes as parameters.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
{
|
||||
png_debug(1, "in png_set_filler");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* In libpng 1.6 it is possible to determine whether this is a read or write
|
||||
* operation and therefore to do more checking here for a valid call.
|
||||
*/
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
|
||||
{
|
||||
# ifdef PNG_READ_FILLER_SUPPORTED
|
||||
/* On read png_set_filler is always valid, regardless of the base PNG
|
||||
* format, because other transformations can give a format where the
|
||||
* filler code can execute (basically an 8 or 16-bit component RGB or G
|
||||
* format.)
|
||||
*
|
||||
* NOTE: usr_channels is not used by the read code! (This has led to
|
||||
* confusion in the past.) The filler is only used in the read code.
|
||||
*/
|
||||
png_ptr->filler = (png_uint_16)filler;
|
||||
# else
|
||||
png_app_error(png_ptr, "png_set_filler not supported on read");
|
||||
PNG_UNUSED(filler) /* not used in the write case */
|
||||
return;
|
||||
# endif
|
||||
}
|
||||
|
||||
else /* write */
|
||||
{
|
||||
# ifdef PNG_WRITE_FILLER_SUPPORTED
|
||||
/* On write the usr_channels parameter must be set correctly at the
|
||||
* start to record the number of channels in the app-supplied data.
|
||||
*/
|
||||
switch (png_ptr->color_type)
|
||||
{
|
||||
case PNG_COLOR_TYPE_RGB:
|
||||
png_ptr->usr_channels = 4;
|
||||
break;
|
||||
|
||||
case PNG_COLOR_TYPE_GRAY:
|
||||
if (png_ptr->bit_depth >= 8)
|
||||
{
|
||||
png_ptr->usr_channels = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* There simply isn't any code in libpng to strip out bits
|
||||
* from bytes when the components are less than a byte in
|
||||
* size!
|
||||
*/
|
||||
png_app_error(png_ptr,
|
||||
"png_set_filler is invalid for low bit depth gray output");
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
png_app_error(png_ptr,
|
||||
"png_set_filler: inappropriate color type");
|
||||
return;
|
||||
}
|
||||
# else
|
||||
png_app_error(png_ptr, "png_set_filler not supported on write");
|
||||
return;
|
||||
# endif
|
||||
}
|
||||
|
||||
/* Here on success - libpng supports the operation, set the transformation
|
||||
* and the flag to say where the filler channel is.
|
||||
*/
|
||||
png_ptr->transformations |= PNG_FILLER;
|
||||
png_ptr->filler = (png_uint_16)filler;
|
||||
|
||||
if (filler_loc == PNG_FILLER_AFTER)
|
||||
png_ptr->flags |= PNG_FLAG_FILLER_AFTER;
|
||||
|
||||
else
|
||||
png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER;
|
||||
|
||||
/* This should probably go in the "do_read_filler" routine.
|
||||
* I attempted to do that in libpng-1.0.1a but that caused problems
|
||||
* so I restored it in libpng-1.0.2a
|
||||
*/
|
||||
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
|
||||
{
|
||||
png_ptr->usr_channels = 4;
|
||||
}
|
||||
|
||||
/* Also I added this in libpng-1.0.2a (what happens when we expand
|
||||
* a less-than-8-bit grayscale to GA?) */
|
||||
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8)
|
||||
{
|
||||
png_ptr->usr_channels = 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* Added to libpng-1.2.7 */
|
||||
void PNGAPI
|
||||
png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
png_set_add_alpha(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
{
|
||||
png_debug(1, "in png_set_add_alpha");
|
||||
|
||||
@ -160,7 +209,9 @@ png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
return;
|
||||
|
||||
png_set_filler(png_ptr, filler, filler_loc);
|
||||
png_ptr->transformations |= PNG_ADD_ALPHA;
|
||||
/* The above may fail to do anything. */
|
||||
if ((png_ptr->transformations & PNG_FILLER) != 0)
|
||||
png_ptr->transformations |= PNG_ADD_ALPHA;
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -168,7 +219,7 @@ png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
|
||||
defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_swap_alpha(png_structp png_ptr)
|
||||
png_set_swap_alpha(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_swap_alpha");
|
||||
|
||||
@ -182,7 +233,7 @@ png_set_swap_alpha(png_structp png_ptr)
|
||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
|
||||
defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_invert_alpha(png_structp png_ptr)
|
||||
png_set_invert_alpha(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_invert_alpha");
|
||||
|
||||
@ -195,7 +246,7 @@ png_set_invert_alpha(png_structp png_ptr)
|
||||
|
||||
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_invert_mono(png_structp png_ptr)
|
||||
png_set_invert_mono(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_invert_mono");
|
||||
|
||||
@ -262,7 +313,7 @@ png_do_invert(png_row_infop row_info, png_bytep row)
|
||||
|
||||
#ifdef PNG_16BIT_SUPPORTED
|
||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||
/* Swaps byte order on 16 bit depth images */
|
||||
/* Swaps byte order on 16-bit depth images */
|
||||
void /* PRIVATE */
|
||||
png_do_swap(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
@ -276,9 +327,16 @@ png_do_swap(png_row_infop row_info, png_bytep row)
|
||||
|
||||
for (i = 0; i < istop; i++, rp += 2)
|
||||
{
|
||||
#ifdef PNG_BUILTIN_BSWAP16_SUPPORTED
|
||||
/* Feature added to libpng-1.6.11 for testing purposes, not
|
||||
* enabled by default.
|
||||
*/
|
||||
*(png_uint_16*)rp = __builtin_bswap16(*(png_uint_16*)rp);
|
||||
#else
|
||||
png_byte t = *rp;
|
||||
*rp = *(rp + 1);
|
||||
*(rp + 1) = t;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -420,7 +478,7 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
|
||||
*rp = table[*rp];
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */
|
||||
#endif /* PACKSWAP || WRITE_PACKSWAP */
|
||||
|
||||
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
|
||||
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||
@ -452,7 +510,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
if (at_start) /* Skip initial filler */
|
||||
if (at_start != 0) /* Skip initial filler */
|
||||
++sp;
|
||||
else /* Skip initial channel and, for sp, the filler */
|
||||
sp += 2, ++dp;
|
||||
@ -466,7 +524,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
||||
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
if (at_start) /* Skip initial filler */
|
||||
if (at_start != 0) /* Skip initial filler */
|
||||
sp += 2;
|
||||
else /* Skip initial channel and, for sp, the filler */
|
||||
sp += 4, dp += 2;
|
||||
@ -492,7 +550,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
if (at_start) /* Skip initial filler */
|
||||
if (at_start != 0) /* Skip initial filler */
|
||||
++sp;
|
||||
else /* Skip initial channels and, for sp, the filler */
|
||||
sp += 4, dp += 3;
|
||||
@ -506,7 +564,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
||||
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
if (at_start) /* Skip initial filler */
|
||||
if (at_start != 0) /* Skip initial filler */
|
||||
sp += 2;
|
||||
else /* Skip initial channels and, for sp, the filler */
|
||||
sp += 8, dp += 6;
|
||||
@ -547,7 +605,7 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_bgr");
|
||||
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
{
|
||||
png_uint_32 row_width = row_info->width;
|
||||
if (row_info->bit_depth == 8)
|
||||
@ -617,13 +675,13 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */
|
||||
#endif /* READ_BGR || WRITE_BGR */
|
||||
|
||||
#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \
|
||||
defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
|
||||
/* Added at libpng-1.5.10 */
|
||||
void /* PRIVATE */
|
||||
png_do_check_palette_indexes(png_structp png_ptr, png_row_infop row_info)
|
||||
png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
|
||||
{
|
||||
if (png_ptr->num_palette < (1 << row_info->bit_depth) &&
|
||||
png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */
|
||||
@ -646,7 +704,7 @@ png_do_check_palette_indexes(png_structp png_ptr, png_row_infop row_info)
|
||||
*/
|
||||
for (; rp > png_ptr->row_buf; rp--)
|
||||
{
|
||||
if (*rp >> padding != 0)
|
||||
if ((*rp >> padding) != 0)
|
||||
png_ptr->num_palette_max = 1;
|
||||
padding = 0;
|
||||
}
|
||||
@ -720,19 +778,30 @@ png_do_check_palette_indexes(png_structp png_ptr, png_row_infop row_info)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED */
|
||||
#endif /* CHECK_FOR_INVALID_INDEX */
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_user_transform_info(png_structp png_ptr, png_voidp
|
||||
png_set_user_transform_info(png_structrp png_ptr, png_voidp
|
||||
user_transform_ptr, int user_transform_depth, int user_transform_channels)
|
||||
{
|
||||
png_debug(1, "in png_set_user_transform_info");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
|
||||
(png_ptr->flags & PNG_FLAG_ROW_INIT) != 0)
|
||||
{
|
||||
png_app_error(png_ptr,
|
||||
"info change after png_start_read_image or png_read_update_info");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
png_ptr->user_transform_ptr = user_transform_ptr;
|
||||
png_ptr->user_transform_depth = (png_byte)user_transform_depth;
|
||||
png_ptr->user_transform_channels = (png_byte)user_transform_channels;
|
||||
@ -746,20 +815,20 @@ png_set_user_transform_info(png_structp png_ptr, png_voidp
|
||||
*/
|
||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
png_voidp PNGAPI
|
||||
png_get_user_transform_ptr(png_const_structp png_ptr)
|
||||
png_get_user_transform_ptr(png_const_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return (NULL);
|
||||
|
||||
return ((png_voidp)png_ptr->user_transform_ptr);
|
||||
return png_ptr->user_transform_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_current_row_number(png_const_structp png_ptr)
|
||||
png_get_current_row_number(png_const_structrp png_ptr)
|
||||
{
|
||||
/* See the comments in png.h - this is the sub-image row when reading and
|
||||
/* See the comments in png.h - this is the sub-image row when reading an
|
||||
* interlaced image.
|
||||
*/
|
||||
if (png_ptr != NULL)
|
||||
@ -769,13 +838,12 @@ png_get_current_row_number(png_const_structp png_ptr)
|
||||
}
|
||||
|
||||
png_byte PNGAPI
|
||||
png_get_current_pass_number(png_const_structp png_ptr)
|
||||
png_get_current_pass_number(png_const_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
return png_ptr->pass;
|
||||
return 8; /* invalid */
|
||||
}
|
||||
#endif /* PNG_USER_TRANSFORM_INFO_SUPPORTED */
|
||||
#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED ||
|
||||
PNG_WRITE_USER_TRANSFORM_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
#endif /* USER_TRANSFORM_INFO */
|
||||
#endif /* READ_USER_TRANSFORM || WRITE_USER_TRANSFORM */
|
||||
#endif /* READ || WRITE */
|
||||
|
116
3rdparty/libpng/pngwio.c
vendored
@ -1,8 +1,8 @@
|
||||
|
||||
/* pngwio.c - functions for data output
|
||||
*
|
||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -26,15 +26,16 @@
|
||||
* writes to a file pointer. Note that this routine sometimes gets called
|
||||
* with very small lengths, so you should implement some kind of simple
|
||||
* buffering if you are using unbuffered writes. This should never be asked
|
||||
* to write more than 64K on a 16 bit machine.
|
||||
* to write more than 64K on a 16-bit machine.
|
||||
*/
|
||||
|
||||
void /* PRIVATE */
|
||||
png_write_data(png_structp png_ptr, png_const_bytep data, png_size_t length)
|
||||
png_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length)
|
||||
{
|
||||
/* NOTE: write_data_fn must not change the buffer! */
|
||||
if (png_ptr->write_data_fn != NULL )
|
||||
(*(png_ptr->write_data_fn))(png_ptr, (png_bytep)data, length);
|
||||
(*(png_ptr->write_data_fn))(png_ptr, png_constcast(png_bytep,data),
|
||||
length);
|
||||
|
||||
else
|
||||
png_error(png_ptr, "Call to NULL write function");
|
||||
@ -46,7 +47,6 @@ png_write_data(png_structp png_ptr, png_const_bytep data, png_size_t length)
|
||||
* write_data function and use it at run time with png_set_write_fn(), rather
|
||||
* than changing the library.
|
||||
*/
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
void PNGCBAPI
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
@ -60,64 +60,6 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
if (check != length)
|
||||
png_error(png_ptr, "Write Error");
|
||||
}
|
||||
#else
|
||||
/* This is the model-independent version. Since the standard I/O library
|
||||
* can't handle far buffers in the medium and small models, we have to copy
|
||||
* the data.
|
||||
*/
|
||||
|
||||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
void PNGCBAPI
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_uint_32 check;
|
||||
png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */
|
||||
png_FILE_p io_ptr;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* Check if data really is near. If so, use usual code. */
|
||||
near_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
||||
|
||||
if ((png_bytep)near_data == data)
|
||||
{
|
||||
check = fwrite(near_data, 1, length, io_ptr);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_byte buf[NEAR_BUF_SIZE];
|
||||
png_size_t written, remaining, err;
|
||||
check = 0;
|
||||
remaining = length;
|
||||
|
||||
do
|
||||
{
|
||||
written = MIN(NEAR_BUF_SIZE, remaining);
|
||||
png_memcpy(buf, data, written); /* Copy far buffer to near buffer */
|
||||
err = fwrite(buf, 1, written, io_ptr);
|
||||
|
||||
if (err != written)
|
||||
break;
|
||||
|
||||
else
|
||||
check += err;
|
||||
|
||||
data += written;
|
||||
remaining -= written;
|
||||
}
|
||||
while (remaining != 0);
|
||||
}
|
||||
|
||||
if (check != length)
|
||||
png_error(png_ptr, "Write Error");
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* This function is called to output any data pending writing (normally
|
||||
@ -126,7 +68,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
*/
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
png_flush(png_structp png_ptr)
|
||||
png_flush(png_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr->output_flush_fn != NULL)
|
||||
(*(png_ptr->output_flush_fn))(png_ptr);
|
||||
@ -141,7 +83,7 @@ png_default_flush(png_structp png_ptr)
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
|
||||
io_ptr = png_voidcast(png_FILE_p, (png_ptr->io_ptr));
|
||||
fflush(io_ptr);
|
||||
}
|
||||
# endif
|
||||
@ -177,7 +119,7 @@ png_default_flush(png_structp png_ptr)
|
||||
* *FILE structure.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
@ -207,8 +149,11 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
# else
|
||||
png_ptr->output_flush_fn = output_flush_fn;
|
||||
# endif
|
||||
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
#else
|
||||
PNG_UNUSED(output_flush_fn)
|
||||
#endif /* WRITE_FLUSH */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* It is an error to read while writing a png file */
|
||||
if (png_ptr->read_data_fn != NULL)
|
||||
{
|
||||
@ -218,37 +163,6 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
"Can't set both read_data_fn and write_data_fn in the"
|
||||
" same structure");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
# ifdef _MSC_VER
|
||||
void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
|
||||
{
|
||||
void *near_ptr;
|
||||
void FAR *far_ptr;
|
||||
FP_OFF(near_ptr) = FP_OFF(ptr);
|
||||
far_ptr = (void FAR *)near_ptr;
|
||||
|
||||
if (check != 0)
|
||||
if (FP_SEG(ptr) != FP_SEG(far_ptr))
|
||||
png_error(png_ptr, "segment lost in conversion");
|
||||
|
||||
return(near_ptr);
|
||||
}
|
||||
# else
|
||||
void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
|
||||
{
|
||||
void *near_ptr;
|
||||
void FAR *far_ptr;
|
||||
near_ptr = (void FAR *)ptr;
|
||||
far_ptr = (void FAR *)near_ptr;
|
||||
|
||||
if (check != 0)
|
||||
if (far_ptr != ptr)
|
||||
png_error(png_ptr, "segment lost in conversion");
|
||||
|
||||
return(near_ptr);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
}
|
||||
#endif /* WRITE */
|
||||
|
2112
3rdparty/libpng/pngwrite.c
vendored
267
3rdparty/libpng/pngwtran.c
vendored
@ -1,8 +1,8 @@
|
||||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* Last changed in libpng 1.5.6 [November 3, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -14,90 +14,14 @@
|
||||
#include "pngpriv.h"
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
|
||||
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
/* Transform the data according to the user's wishes. The order of
|
||||
* transformations is significant.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_do_write_transformations(png_structp png_ptr, png_row_infop row_info)
|
||||
{
|
||||
png_debug(1, "in png_do_write_transformations");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_USER_TRANSFORM)
|
||||
if (png_ptr->write_user_transform_fn != NULL)
|
||||
(*(png_ptr->write_user_transform_fn)) /* User write transform
|
||||
function */
|
||||
(png_ptr, /* png_ptr */
|
||||
row_info, /* row_info: */
|
||||
/* png_uint_32 width; width of row */
|
||||
/* png_size_t rowbytes; number of bytes in row */
|
||||
/* png_byte color_type; color type of pixels */
|
||||
/* png_byte bit_depth; bit depth of samples */
|
||||
/* png_byte channels; number of channels (1-4) */
|
||||
/* png_byte pixel_depth; bits per pixel (depth*channels) */
|
||||
png_ptr->row_buf + 1); /* start of pixel data for row */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_FILLER_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_FILLER)
|
||||
png_do_strip_channel(row_info, png_ptr->row_buf + 1,
|
||||
!(png_ptr->flags & PNG_FLAG_FILLER_AFTER));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_PACKSWAP)
|
||||
png_do_packswap(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_PACK_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_PACK)
|
||||
png_do_pack(row_info, png_ptr->row_buf + 1,
|
||||
(png_uint_32)png_ptr->bit_depth);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SWAP_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_SWAP_BYTES)
|
||||
png_do_swap(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SHIFT_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_SHIFT)
|
||||
png_do_shift(row_info, png_ptr->row_buf + 1,
|
||||
&(png_ptr->shift));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_SWAP_ALPHA)
|
||||
png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_INVERT_ALPHA)
|
||||
png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_BGR_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_BGR)
|
||||
png_do_bgr(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_INVERT_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_INVERT_MONO)
|
||||
png_do_invert(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_PACK_SUPPORTED
|
||||
/* Pack pixels into bytes. Pass the true bit depth in bit_depth. The
|
||||
* row_info bit depth should be 8 (one pixel per byte). The channels
|
||||
* should be 1 (this only happens on grayscale and paletted images).
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
static void
|
||||
png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
{
|
||||
png_debug(1, "in png_do_pack");
|
||||
@ -147,7 +71,8 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
case 2:
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
int shift, v;
|
||||
unsigned int shift;
|
||||
int v;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
@ -186,7 +111,8 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
case 4:
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
int shift, v;
|
||||
unsigned int shift;
|
||||
int v;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
@ -242,7 +168,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
* would pass 3 as bit_depth, and this routine would translate the
|
||||
* data to 0 to 15.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
static void
|
||||
png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
png_const_color_8p bit_depth)
|
||||
{
|
||||
@ -253,7 +179,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
int shift_start[4], shift_dec[4];
|
||||
int channels = 0;
|
||||
|
||||
if (row_info->color_type & PNG_COLOR_MASK_COLOR)
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
{
|
||||
shift_start[channels] = row_info->bit_depth - bit_depth->red;
|
||||
shift_dec[channels] = bit_depth->red;
|
||||
@ -275,7 +201,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
channels++;
|
||||
}
|
||||
|
||||
if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0)
|
||||
{
|
||||
shift_start[channels] = row_info->bit_depth - bit_depth->alpha;
|
||||
shift_dec[channels] = bit_depth->alpha;
|
||||
@ -287,7 +213,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
png_bytep bp = row;
|
||||
png_size_t i;
|
||||
png_byte mask;
|
||||
unsigned int mask;
|
||||
png_size_t row_bytes = row_info->rowbytes;
|
||||
|
||||
if (bit_depth->gray == 1 && row_info->bit_depth == 2)
|
||||
@ -301,20 +227,22 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
|
||||
for (i = 0; i < row_bytes; i++, bp++)
|
||||
{
|
||||
png_uint_16 v;
|
||||
int j;
|
||||
unsigned int v, out;
|
||||
|
||||
v = *bp;
|
||||
*bp = 0;
|
||||
out = 0;
|
||||
|
||||
for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0])
|
||||
{
|
||||
if (j > 0)
|
||||
*bp |= (png_byte)((v << j) & 0xff);
|
||||
out |= v << j;
|
||||
|
||||
else
|
||||
*bp |= (png_byte)((v >> (-j)) & mask);
|
||||
out |= (v >> (-j)) & mask;
|
||||
}
|
||||
|
||||
*bp = (png_byte)(out & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
@ -327,21 +255,23 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
for (i = 0; i < istop; i++, bp++)
|
||||
{
|
||||
|
||||
png_uint_16 v;
|
||||
const unsigned int c = i%channels;
|
||||
int j;
|
||||
int c = (int)(i%channels);
|
||||
unsigned int v, out;
|
||||
|
||||
v = *bp;
|
||||
*bp = 0;
|
||||
out = 0;
|
||||
|
||||
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
||||
{
|
||||
if (j > 0)
|
||||
*bp |= (png_byte)((v << j) & 0xff);
|
||||
out |= v << j;
|
||||
|
||||
else
|
||||
*bp |= (png_byte)((v >> (-j)) & 0xff);
|
||||
out |= v >> (-j);
|
||||
}
|
||||
|
||||
*bp = (png_byte)(out & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
@ -353,22 +283,22 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
|
||||
for (bp = row, i = 0; i < istop; i++)
|
||||
{
|
||||
int c = (int)(i%channels);
|
||||
png_uint_16 value, v;
|
||||
const unsigned int c = i%channels;
|
||||
int j;
|
||||
unsigned int value, v;
|
||||
|
||||
v = (png_uint_16)(((png_uint_16)(*bp) << 8) + *(bp + 1));
|
||||
v = png_get_uint_16(bp);
|
||||
value = 0;
|
||||
|
||||
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
||||
{
|
||||
if (j > 0)
|
||||
value |= (png_uint_16)((v << j) & (png_uint_16)0xffff);
|
||||
value |= v << j;
|
||||
|
||||
else
|
||||
value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff);
|
||||
value |= v >> (-j);
|
||||
}
|
||||
*bp++ = (png_byte)(value >> 8);
|
||||
*bp++ = (png_byte)((value >> 8) & 0xff);
|
||||
*bp++ = (png_byte)(value & 0xff);
|
||||
}
|
||||
}
|
||||
@ -377,7 +307,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
static void
|
||||
png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_write_swap_alpha");
|
||||
@ -425,7 +355,7 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
*(dp++) = save[1];
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
#endif /* WRITE_16BIT */
|
||||
}
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
@ -464,14 +394,14 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
*(dp++) = save[1];
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
#endif /* WRITE_16BIT */
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
static void
|
||||
png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_write_invert_alpha");
|
||||
@ -494,7 +424,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
*(dp++) = *(sp++);
|
||||
*/
|
||||
sp+=3; dp = sp;
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
*dp = (png_byte)(255 - *(sp++));
|
||||
}
|
||||
}
|
||||
|
||||
@ -518,10 +448,10 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
*/
|
||||
sp+=6; dp = sp;
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
*dp = (png_byte)(255 - *(sp++));
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
#endif /* WRITE_16BIT */
|
||||
}
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
@ -556,78 +486,91 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
*/
|
||||
sp+=2; dp = sp;
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
*dp = (png_byte)(255 - *(sp++));
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
#endif /* WRITE_16BIT */
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
|
||||
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
/* Undoes intrapixel differencing */
|
||||
/* Transform the data according to the user's wishes. The order of
|
||||
* transformations is significant.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
|
||||
png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
{
|
||||
png_debug(1, "in png_do_write_intrapixel");
|
||||
png_debug(1, "in png_do_write_transformations");
|
||||
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
{
|
||||
int bytes_per_pixel;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_uint_32 i;
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||
bytes_per_pixel = 3;
|
||||
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
|
||||
if (png_ptr->write_user_transform_fn != NULL)
|
||||
(*(png_ptr->write_user_transform_fn)) /* User write transform
|
||||
function */
|
||||
(png_ptr, /* png_ptr */
|
||||
row_info, /* row_info: */
|
||||
/* png_uint_32 width; width of row */
|
||||
/* png_size_t rowbytes; number of bytes in row */
|
||||
/* png_byte color_type; color type of pixels */
|
||||
/* png_byte bit_depth; bit depth of samples */
|
||||
/* png_byte channels; number of channels (1-4) */
|
||||
/* png_byte pixel_depth; bits per pixel (depth*channels) */
|
||||
png_ptr->row_buf + 1); /* start of pixel data for row */
|
||||
#endif
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
bytes_per_pixel = 4;
|
||||
#ifdef PNG_WRITE_FILLER_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_FILLER) != 0)
|
||||
png_do_strip_channel(row_info, png_ptr->row_buf + 1,
|
||||
!(png_ptr->flags & PNG_FLAG_FILLER_AFTER));
|
||||
#endif
|
||||
|
||||
else
|
||||
return;
|
||||
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
|
||||
png_do_packswap(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||
{
|
||||
*(rp) = (png_byte)((*rp - *(rp + 1)) & 0xff);
|
||||
*(rp + 2) = (png_byte)((*(rp + 2) - *(rp + 1)) & 0xff);
|
||||
}
|
||||
}
|
||||
#ifdef PNG_WRITE_PACK_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_PACK) != 0)
|
||||
png_do_pack(row_info, png_ptr->row_buf + 1,
|
||||
(png_uint_32)png_ptr->bit_depth);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_uint_32 i;
|
||||
#ifdef PNG_WRITE_SWAP_SUPPORTED
|
||||
# ifdef PNG_16BIT_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
|
||||
png_do_swap(row_info, png_ptr->row_buf + 1);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||
bytes_per_pixel = 6;
|
||||
#ifdef PNG_WRITE_SHIFT_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_SHIFT) != 0)
|
||||
png_do_shift(row_info, png_ptr->row_buf + 1,
|
||||
&(png_ptr->shift));
|
||||
#endif
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
bytes_per_pixel = 8;
|
||||
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0)
|
||||
png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
else
|
||||
return;
|
||||
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
|
||||
png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||
{
|
||||
png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1);
|
||||
png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3);
|
||||
png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5);
|
||||
png_uint_32 red = (png_uint_32)((s0 - s1) & 0xffffL);
|
||||
png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL);
|
||||
*(rp ) = (png_byte)((red >> 8) & 0xff);
|
||||
*(rp + 1) = (png_byte)(red & 0xff);
|
||||
*(rp + 4) = (png_byte)((blue >> 8) & 0xff);
|
||||
*(rp + 5) = (png_byte)(blue & 0xff);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
}
|
||||
#ifdef PNG_WRITE_BGR_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_BGR) != 0)
|
||||
png_do_bgr(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_INVERT_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
|
||||
png_do_invert(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
}
|
||||
#endif /* PNG_MNG_FEATURES_SUPPORTED */
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
#endif /* WRITE_TRANSFORMS */
|
||||
#endif /* WRITE */
|
||||
|
2748
3rdparty/libpng/pngwutil.c
vendored
1
3rdparty/libwebp/CMakeLists.txt
vendored
@ -10,6 +10,7 @@ ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/cpu-features")
|
||||
file(GLOB lib_srcs dec/*.c dsp/*.c enc/*.c mux/*.c utils/*.c webp/*.c)
|
||||
file(GLOB lib_hdrs dec/*.h dsp/*.h enc/*.h mux/*.h utils/*.h webp/*.h)
|
||||
|
||||
# FIXIT
|
||||
if(ANDROID AND ARMEABI_V7A AND NOT NEON)
|
||||
foreach(file ${lib_srcs})
|
||||
if("${file}" MATCHES "_neon.c")
|
||||
|
2
3rdparty/readme.txt
vendored
@ -14,7 +14,7 @@ libjpeg The Independent JPEG Group's JPEG software.
|
||||
WITH_JPEG CMake option must be ON to add libjpeg support to imgcodecs.
|
||||
------------------------------------------------------------------------------------
|
||||
libpng Portable Network Graphics library.
|
||||
Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson.
|
||||
The license and copyright notes can be found in libpng/LICENSE.
|
||||
See libpng home page http://www.libpng.org
|
||||
for details and links to the source code
|
||||
|
||||
|
38
3rdparty/tbb/CMakeLists.txt
vendored
@ -5,21 +5,26 @@ if (WIN32 AND NOT ARM)
|
||||
message(FATAL_ERROR "BUILD_TBB option supports Windows on ARM only!\nUse regular official TBB build instead of the BUILD_TBB option!")
|
||||
endif()
|
||||
|
||||
if (WIN32 AND ARM)
|
||||
# 4.1 update 4 - The first release that supports Windows RT. Hangs on some Android devices
|
||||
set(tbb_ver "tbb41_20130613oss")
|
||||
set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130613oss_src.tgz")
|
||||
set(tbb_md5 "108c8c1e481b0aaea61878289eb28b6a")
|
||||
set(tbb_version_file "version_string.ver")
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4702)
|
||||
else()
|
||||
# 4.1 update 2 - works fine
|
||||
set(tbb_ver "tbb41_20130116oss")
|
||||
set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130116oss_src.tgz")
|
||||
set(tbb_md5 "3809790e1001a1b32d59c9fee590ee85")
|
||||
set(tbb_version_file "version_string.ver")
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow)
|
||||
endif()
|
||||
set(tbb_ver "tbb43_20141204oss")
|
||||
set(tbb_url "http://www.threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb43_20141204oss_src.tgz")
|
||||
set(tbb_md5 "e903dd92d9433701f097fa7ca29a3c1f")
|
||||
set(tbb_version_file "version_string.ver")
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4702)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow)
|
||||
|
||||
# 4.1 update 4 - The first release that supports Windows RT. Hangs on some Android devices
|
||||
#set(tbb_ver "tbb41_20130613oss")
|
||||
#set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130613oss_src.tgz")
|
||||
#set(tbb_md5 "108c8c1e481b0aaea61878289eb28b6a")
|
||||
#set(tbb_version_file "version_string.ver")
|
||||
#ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4702)
|
||||
|
||||
# 4.1 update 2 - works fine
|
||||
#set(tbb_ver "tbb41_20130116oss")
|
||||
#set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130116oss_src.tgz")
|
||||
#set(tbb_md5 "3809790e1001a1b32d59c9fee590ee85")
|
||||
#set(tbb_version_file "version_string.ver")
|
||||
#ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow)
|
||||
|
||||
# 4.1 update 3 dev - Hangs on some Android devices
|
||||
#set(tbb_ver "tbb41_20130401oss")
|
||||
@ -97,7 +102,7 @@ if(NOT EXISTS "${tbb_tarball}")
|
||||
message(STATUS "Downloading ${tbb_ver}_src.tgz")
|
||||
file(DOWNLOAD "${tbb_url}" "${tbb_tarball}" TIMEOUT 600 STATUS __statvar)
|
||||
if(NOT __statvar EQUAL 0)
|
||||
message(FATAL_ERROR "Failed to download TBB sources: ${tbb_url}")
|
||||
message(FATAL_ERROR "Failed to download TBB sources (${__statvar}): ${tbb_url}")
|
||||
endif()
|
||||
file(MD5 "${tbb_tarball}" tbb_local_md5)
|
||||
if(NOT tbb_local_md5 STREQUAL tbb_md5)
|
||||
@ -153,6 +158,7 @@ if (WIN32)
|
||||
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} /APPCONTAINER")
|
||||
else()
|
||||
add_definitions(-D__TBB_DYNAMIC_LOAD_ENABLED=0 #required
|
||||
-D__TBB_WEAK_SYMBOLS_PRESENT=0 #required for 4.3
|
||||
-D__TBB_BUILD=1 #required
|
||||
-D__TBB_SURVIVE_THREAD_SWITCH=0 #no cilk support
|
||||
-DTBB_USE_DEBUG=0 #just to be sure
|
||||
|
2
3rdparty/zlib/gzread.c
vendored
@ -27,7 +27,7 @@ local int gz_load(state, buf, len, have)
|
||||
|
||||
*have = 0;
|
||||
do {
|
||||
ret = read(state->fd, buf + *have, len - *have);
|
||||
ret = (int) read(state->fd, buf + *have, len - *have);
|
||||
if (ret <= 0)
|
||||
break;
|
||||
*have += ret;
|
||||
|
4
3rdparty/zlib/gzwrite.c
vendored
@ -81,7 +81,7 @@ local int gz_comp(state, flush)
|
||||
|
||||
/* write directly if requested */
|
||||
if (state->direct) {
|
||||
got = write(state->fd, strm->next_in, strm->avail_in);
|
||||
got = (int) write(state->fd, strm->next_in, strm->avail_in);
|
||||
if (got < 0 || (unsigned)got != strm->avail_in) {
|
||||
gz_error(state, Z_ERRNO, zstrerror());
|
||||
return -1;
|
||||
@ -98,7 +98,7 @@ local int gz_comp(state, flush)
|
||||
if (strm->avail_out == 0 || (flush != Z_NO_FLUSH &&
|
||||
(flush != Z_FINISH || ret == Z_STREAM_END))) {
|
||||
have = (unsigned)(strm->next_out - state->x.next);
|
||||
if (have && ((got = write(state->fd, state->x.next, have)) < 0 ||
|
||||
if (have && ((got = (int) write(state->fd, state->x.next, have)) < 0 ||
|
||||
(unsigned)got != have)) {
|
||||
gz_error(state, Z_ERRNO, zstrerror());
|
||||
return -1;
|
||||
|
141
CMakeLists.txt
@ -56,7 +56,10 @@ if(WINRT)
|
||||
add_definitions(-DWINRT_STORE)
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_VERSION MATCHES 8.1)
|
||||
if(CMAKE_SYSTEM_VERSION MATCHES 10)
|
||||
set(WINRT_10 TRUE)
|
||||
add_definitions(-DWINRT_10)
|
||||
elseif(CMAKE_SYSTEM_VERSION MATCHES 8.1)
|
||||
set(WINRT_8_1 TRUE)
|
||||
add_definitions(-DWINRT_8_1)
|
||||
elseif(CMAKE_SYSTEM_VERSION MATCHES 8.0)
|
||||
@ -95,6 +98,8 @@ endif()
|
||||
|
||||
include(cmake/OpenCVUtils.cmake)
|
||||
|
||||
ocv_cmake_eval(DEBUG_PRE ONCE)
|
||||
|
||||
ocv_clear_vars(OpenCVModules_TARGETS)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
@ -169,7 +174,7 @@ OCV_OPTION(WITH_NVCUVID "Include NVidia Video Decoding library support"
|
||||
OCV_OPTION(WITH_EIGEN "Include Eigen2/Eigen3 support" ON IF (NOT WINRT) )
|
||||
OCV_OPTION(WITH_VFW "Include Video for Windows support" ON IF WIN32 )
|
||||
OCV_OPTION(WITH_FFMPEG "Include FFMPEG support" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
||||
OCV_OPTION(WITH_GSTREAMER "Include Gstreamer support" ON IF (UNIX AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_GSTREAMER "Include Gstreamer support" ON IF (NOT ANDROID) )
|
||||
OCV_OPTION(WITH_GSTREAMER_0_10 "Enable Gstreamer 0.10 support (instead of 1.x)" OFF )
|
||||
OCV_OPTION(WITH_GTK "Include GTK support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_GTK_2_X "Use GTK version 2" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID) )
|
||||
@ -182,8 +187,8 @@ OCV_OPTION(WITH_OPENGL "Include OpenGL support" OFF
|
||||
OCV_OPTION(WITH_OPENNI "Include OpenNI support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
||||
OCV_OPTION(WITH_OPENNI2 "Include OpenNI2 support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
||||
OCV_OPTION(WITH_PNG "Include PNG support" ON)
|
||||
OCV_OPTION(WITH_PVAPI "Include Prosilica GigE support" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
||||
OCV_OPTION(WITH_GIGEAPI "Include Smartek GigE support" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
||||
OCV_OPTION(WITH_PVAPI "Include Prosilica GigE support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
||||
OCV_OPTION(WITH_GIGEAPI "Include Smartek GigE support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
||||
OCV_OPTION(WITH_QT "Build with Qt Backend support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
||||
OCV_OPTION(WITH_WIN32UI "Build with Win32 UI Backend support" ON IF WIN32 AND NOT WINRT)
|
||||
OCV_OPTION(WITH_QUICKTIME "Use QuickTime for Video I/O insted of QTKit" OFF IF APPLE )
|
||||
@ -194,7 +199,7 @@ OCV_OPTION(WITH_PTHREADS_PF "Use pthreads-based parallel_for" ON
|
||||
OCV_OPTION(WITH_TIFF "Include TIFF support" ON IF (NOT IOS) )
|
||||
OCV_OPTION(WITH_UNICAP "Include Unicap support (GPL)" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON IF (UNIX AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_LIBV4L "Use libv4l for Video 4 Linux support" ON IF (UNIX AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_LIBV4L "Use libv4l for Video 4 Linux support" OFF IF (UNIX AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_DSHOW "Build VideoIO with DirectShow support" ON IF (WIN32 AND NOT ARM AND NOT WINRT) )
|
||||
OCV_OPTION(WITH_MSMF "Build VideoIO with Media Foundation support" OFF IF WIN32 )
|
||||
OCV_OPTION(WITH_XIMEA "Include XIMEA cameras support" OFF IF (NOT ANDROID AND NOT WINRT) )
|
||||
@ -207,6 +212,7 @@ OCV_OPTION(WITH_OPENCLAMDBLAS "Include AMD OpenCL BLAS library support" ON
|
||||
OCV_OPTION(WITH_DIRECTX "Include DirectX support" ON IF (WIN32 AND NOT WINRT) )
|
||||
OCV_OPTION(WITH_INTELPERC "Include Intel Perceptual Computing support" OFF IF (WIN32 AND NOT WINRT) )
|
||||
OCV_OPTION(WITH_IPP_A "Include Intel IPP_A support" OFF IF (MSVC OR X86 OR X86_64) )
|
||||
OCV_OPTION(WITH_MATLAB "Include Matlab support" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT))
|
||||
OCV_OPTION(WITH_VA "Include VA support" OFF IF (UNIX AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_VA_INTEL "Include Intel VA-API/OpenCL support" OFF IF (UNIX AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_GDAL "Include GDAL Support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
||||
@ -214,20 +220,20 @@ OCV_OPTION(WITH_GPHOTO2 "Include gPhoto2 library support" ON
|
||||
|
||||
# OpenCV build components
|
||||
# ===================================================
|
||||
OCV_OPTION(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" NOT (ANDROID OR IOS) )
|
||||
OCV_OPTION(BUILD_opencv_apps "Build utility applications (used for example to train classifiers)" (NOT ANDROID AND NOT WINRT) IF (NOT IOS) )
|
||||
OCV_OPTION(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" NOT (ANDROID OR APPLE_FRAMEWORK) )
|
||||
OCV_OPTION(BUILD_opencv_apps "Build utility applications (used for example to train classifiers)" (NOT ANDROID AND NOT WINRT) IF (NOT APPLE_FRAMEWORK) )
|
||||
OCV_OPTION(BUILD_ANDROID_EXAMPLES "Build examples for Android platform" ON IF ANDROID )
|
||||
OCV_OPTION(BUILD_DOCS "Create build rules for OpenCV Documentation" ON IF NOT WINRT)
|
||||
OCV_OPTION(BUILD_DOCS "Create build rules for OpenCV Documentation" ON IF (NOT WINRT OR APPLE_FRAMEWORK))
|
||||
OCV_OPTION(BUILD_EXAMPLES "Build all examples" OFF )
|
||||
OCV_OPTION(BUILD_PACKAGE "Enables 'make package_source' command" ON IF NOT WINRT)
|
||||
OCV_OPTION(BUILD_PERF_TESTS "Build performance tests" ON IF (NOT IOS) )
|
||||
OCV_OPTION(BUILD_TESTS "Build accuracy & regression tests" ON IF (NOT IOS) )
|
||||
OCV_OPTION(BUILD_PERF_TESTS "Build performance tests" ON IF (NOT APPLE_FRAMEWORK) )
|
||||
OCV_OPTION(BUILD_TESTS "Build accuracy & regression tests" ON IF (NOT APPLE_FRAMEWORK) )
|
||||
OCV_OPTION(BUILD_WITH_DEBUG_INFO "Include debug info into debug libs (not MSCV only)" ON )
|
||||
OCV_OPTION(BUILD_WITH_STATIC_CRT "Enables use of staticaly linked CRT for staticaly linked OpenCV" ON IF MSVC )
|
||||
OCV_OPTION(BUILD_WITH_DYNAMIC_IPP "Enables dynamic linking of IPP (only for standalone IPP)" OFF )
|
||||
OCV_OPTION(BUILD_FAT_JAVA_LIB "Create fat java wrapper containing the whole OpenCV library" ON IF NOT BUILD_SHARED_LIBS AND CMAKE_COMPILER_IS_GNUCXX )
|
||||
OCV_OPTION(BUILD_ANDROID_SERVICE "Build OpenCV Manager for Google Play" OFF IF ANDROID )
|
||||
OCV_OPTION(BUILD_CUDA_STUBS "Build CUDA modules stubs when no CUDA SDK" OFF IF (NOT IOS) )
|
||||
OCV_OPTION(BUILD_CUDA_STUBS "Build CUDA modules stubs when no CUDA SDK" OFF IF (NOT APPLE_FRAMEWORK) )
|
||||
|
||||
# 3rd party libs
|
||||
OCV_OPTION(BUILD_ZLIB "Build zlib from source" WIN32 OR APPLE )
|
||||
@ -244,12 +250,12 @@ OCV_OPTION(INSTALL_CREATE_DISTRIB "Change install rules to build the distribut
|
||||
OCV_OPTION(INSTALL_C_EXAMPLES "Install C examples" OFF )
|
||||
OCV_OPTION(INSTALL_PYTHON_EXAMPLES "Install Python examples" OFF )
|
||||
OCV_OPTION(INSTALL_ANDROID_EXAMPLES "Install Android examples" OFF IF ANDROID )
|
||||
OCV_OPTION(INSTALL_TO_MANGLED_PATHS "Enables mangled install paths, that help with side by side installs." OFF IF (UNIX AND NOT ANDROID AND NOT IOS AND BUILD_SHARED_LIBS) )
|
||||
OCV_OPTION(INSTALL_TO_MANGLED_PATHS "Enables mangled install paths, that help with side by side installs." OFF IF (UNIX AND NOT ANDROID AND NOT APPLE_FRAMEWORK AND BUILD_SHARED_LIBS) )
|
||||
OCV_OPTION(INSTALL_TESTS "Install accuracy and performance test binaries and test data" OFF)
|
||||
|
||||
# OpenCV build options
|
||||
# ===================================================
|
||||
OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers" ON IF (NOT IOS) )
|
||||
OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers" ON IF (NOT IOS AND NOT CMAKE_CROSSCOMPILING) )
|
||||
OCV_OPTION(ENABLE_SOLUTION_FOLDERS "Solution folder in Visual Studio or in other IDEs" (MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode) )
|
||||
OCV_OPTION(ENABLE_PROFILING "Enable profiling in the GCC compiler (Add flags: -g -pg)" OFF IF CMAKE_COMPILER_IS_GNUCXX )
|
||||
OCV_OPTION(ENABLE_COVERAGE "Enable coverage collection with GCov" OFF IF CMAKE_COMPILER_IS_GNUCXX )
|
||||
@ -266,7 +272,7 @@ OCV_OPTION(ENABLE_POPCNT "Enable POPCNT instructions"
|
||||
OCV_OPTION(ENABLE_AVX "Enable AVX instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_AVX2 "Enable AVX2 instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_FMA3 "Enable FMA3 instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_NEON "Enable NEON instructions" OFF IF CMAKE_COMPILER_IS_GNUCXX AND (ARM OR AARCH64 OR IOS) )
|
||||
OCV_OPTION(ENABLE_NEON "Enable NEON instructions" "${NEON}" IF CMAKE_COMPILER_IS_GNUCXX AND (ARM OR AARCH64 OR IOS) )
|
||||
OCV_OPTION(ENABLE_VFPV3 "Enable VFPv3-D32 instructions" OFF IF CMAKE_COMPILER_IS_GNUCXX AND (ARM OR AARCH64 OR IOS) )
|
||||
OCV_OPTION(ENABLE_NOISY_WARNINGS "Show all warnings even if they are too noisy" OFF )
|
||||
OCV_OPTION(OPENCV_WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF )
|
||||
@ -274,6 +280,9 @@ OCV_OPTION(ANDROID_EXAMPLES_WITH_LIBS "Build binaries of Android examples with n
|
||||
OCV_OPTION(ENABLE_IMPL_COLLECTION "Collect implementation data on function call" OFF )
|
||||
OCV_OPTION(GENERATE_ABI_DESCRIPTOR "Generate XML file for abi_compliance_checker tool" OFF IF UNIX)
|
||||
|
||||
OCV_OPTION(DOWNLOAD_EXTERNAL_TEST_DATA "Download external test data (Python executable and OPENCV_TEST_DATA_PATH environment variable may be required)" OFF )
|
||||
|
||||
|
||||
if(ENABLE_IMPL_COLLECTION)
|
||||
add_definitions(-DCV_COLLECT_IMPL_DATA)
|
||||
endif()
|
||||
@ -419,7 +428,7 @@ if(DEFINED CMAKE_DEBUG_POSTFIX)
|
||||
set(OPENCV_DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
|
||||
endif()
|
||||
|
||||
if(INSTALL_CREATE_DISTRIB AND BUILD_SHARED_LIBS AND NOT DEFINED BUILD_opencv_world)
|
||||
if((INSTALL_CREATE_DISTRIB AND BUILD_SHARED_LIBS AND NOT DEFINED BUILD_opencv_world) OR APPLE_FRAMEWORK)
|
||||
set(BUILD_opencv_world ON CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
@ -583,14 +592,36 @@ if(WITH_DIRECTX)
|
||||
endif()
|
||||
|
||||
# --- Matlab/Octave ---
|
||||
include(cmake/OpenCVFindMatlab.cmake)
|
||||
if(WITH_MATLAB)
|
||||
include(cmake/OpenCVFindMatlab.cmake)
|
||||
endif()
|
||||
|
||||
include(cmake/OpenCVDetectVTK.cmake)
|
||||
|
||||
# -- Custom HAL replacement --
|
||||
set(_includes "")
|
||||
# assuming OPENCV_HAL_HEADERS and OPENCV_HAL_LIBS are lists of files:
|
||||
# option example: -DOPENCV_HAL_HEADERS="<some-path>/header1.h;<some-path>/header2.h"
|
||||
if (OPENCV_HAL_HEADERS AND OPENCV_HAL_LIBS)
|
||||
get_filename_component(OPENCV_HAL_HEADERS "${OPENCV_HAL_HEADERS}" ABSOLUTE)
|
||||
get_filename_component(OPENCV_HAL_LIBS "${OPENCV_HAL_LIBS}" ABSOLUTE)
|
||||
foreach (h ${OPENCV_HAL_HEADERS})
|
||||
get_filename_component(h "${h}" ABSOLUTE)
|
||||
set(_includes "${_includes}\n#include \"${h}\"")
|
||||
endforeach()
|
||||
foreach (l ${OPENCV_HAL_LIBS})
|
||||
get_filename_component(l "${l}" ABSOLUTE)
|
||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${l})
|
||||
# TODO: install?
|
||||
# ocv_install_target(${l} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
endforeach()
|
||||
else()
|
||||
set(_includes "// using default HAL")
|
||||
unset(OPENCV_HAL_HEADERS CACHE)
|
||||
unset(OPENCV_HAL_LIBS CACHE)
|
||||
endif()
|
||||
set(OPENCV_HAL_HEADERS "${OPENCV_HAL_HEADERS}" CACHE STRING "Headers with custom HAL implementation")
|
||||
set(OPENCV_HAL_LIBS "${OPENCV_HAL_LIBS}" CACHE STRING "Libraries with custom HAL implementation")
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/custom_hal.hpp.in" "${CMAKE_BINARY_DIR}/custom_hal.hpp" @ONLY)
|
||||
unset(_includes)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Add CUDA libraries (needed for apps/tools, samples)
|
||||
@ -603,6 +634,9 @@ if(HAVE_CUDA)
|
||||
if(HAVE_CUFFT)
|
||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_cufft_LIBRARY})
|
||||
endif()
|
||||
foreach(p ${CUDA_LIBS_PATH})
|
||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} -L${p})
|
||||
endforeach()
|
||||
endif()
|
||||
# ----------------------------------------------------------------------------
|
||||
# Solution folders:
|
||||
@ -659,11 +693,13 @@ include(cmake/OpenCVGenPkgconfig.cmake)
|
||||
# Generate OpenCV.mk for ndk-build (Android build tool)
|
||||
include(cmake/OpenCVGenAndroidMK.cmake)
|
||||
|
||||
# Generate OpenCVСonfig.cmake and OpenCVConfig-version.cmake for cmake projects
|
||||
# Generate OpenCVConfig.cmake and OpenCVConfig-version.cmake for cmake projects
|
||||
include(cmake/OpenCVGenConfig.cmake)
|
||||
|
||||
# Generate Info.plist for the IOS framework
|
||||
include(cmake/OpenCVGenInfoPlist.cmake)
|
||||
if(APPLE_FRAMEWORK)
|
||||
include(cmake/OpenCVGenInfoPlist.cmake)
|
||||
endif()
|
||||
|
||||
# Generate ABI descriptor
|
||||
include(cmake/OpenCVGenABI.cmake)
|
||||
@ -719,10 +755,46 @@ status("General configuration for OpenCV ${OPENCV_VERSION} =====================
|
||||
if(OPENCV_VCSVERSION)
|
||||
status(" Version control:" ${OPENCV_VCSVERSION})
|
||||
endif()
|
||||
if(OPENCV_EXTRA_MODULES_PATH AND NOT BUILD_INFO_SKIP_EXTRA_MODULES)
|
||||
set(__dump_extra_header OFF)
|
||||
foreach(p ${OPENCV_EXTRA_MODULES_PATH})
|
||||
if(EXISTS ${p})
|
||||
if(NOT __dump_extra_header)
|
||||
set(__dump_extra_header ON)
|
||||
status("")
|
||||
status(" Extra modules:")
|
||||
else()
|
||||
status("")
|
||||
endif()
|
||||
set(EXTRA_MODULES_VCSVERSION "unknown")
|
||||
if(GIT_FOUND)
|
||||
execute_process(COMMAND "${GIT_EXECUTABLE}" describe --tags --always --dirty --match "[0-9].[0-9].[0-9]*"
|
||||
WORKING_DIRECTORY "${p}"
|
||||
OUTPUT_VARIABLE EXTRA_MODULES_VCSVERSION
|
||||
RESULT_VARIABLE GIT_RESULT
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if(NOT GIT_RESULT EQUAL 0)
|
||||
set(EXTRA_MODULES_VCSVERSION "unknown")
|
||||
endif()
|
||||
endif()
|
||||
status(" Location (extra):" ${p})
|
||||
status(" Version control (extra):" ${EXTRA_MODULES_VCSVERSION})
|
||||
endif()
|
||||
endforeach()
|
||||
unset(__dump_extra_header)
|
||||
endif()
|
||||
|
||||
# ========================== build platform ==========================
|
||||
status("")
|
||||
status(" Platform:")
|
||||
if(NOT CMAKE_VERSION VERSION_LESS 2.8.11 AND NOT BUILD_INFO_SKIP_TIMESTAMP)
|
||||
string(TIMESTAMP TIMESTAMP "" UTC)
|
||||
if(TIMESTAMP)
|
||||
status(" Timestamp:" ${TIMESTAMP})
|
||||
endif()
|
||||
endif()
|
||||
status(" Host:" ${CMAKE_HOST_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_VERSION} ${CMAKE_HOST_SYSTEM_PROCESSOR})
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
status(" Target:" ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION} ${CMAKE_SYSTEM_PROCESSOR})
|
||||
@ -829,6 +901,9 @@ status(" Windows RT support:" WINRT THEN YES ELSE NO)
|
||||
status(" Building for Microsoft platform: " ${CMAKE_SYSTEM_NAME})
|
||||
status(" Building for architectures: " ${CMAKE_VS_EFFECTIVE_PLATFORMS})
|
||||
status(" Building for version: " ${CMAKE_SYSTEM_VERSION})
|
||||
if (DEFINED ENABLE_WINRT_MODE_NATIVE)
|
||||
status(" Building for C++ without CX extensions")
|
||||
endif()
|
||||
endif()
|
||||
endif(WIN32)
|
||||
|
||||
@ -1085,6 +1160,7 @@ endif(DEFINED WITH_VA_INTEL)
|
||||
status(" Use Eigen:" HAVE_EIGEN THEN "YES (ver ${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION})" ELSE NO)
|
||||
status(" Use Cuda:" HAVE_CUDA THEN "YES (ver ${CUDA_VERSION_STRING})" ELSE NO)
|
||||
status(" Use OpenCL:" HAVE_OPENCL THEN YES ELSE NO)
|
||||
status(" Use custom HAL:" OPENCV_HAL_HEADERS AND OPENCV_HAL_LIBS THEN "YES (${OPENCV_HAL_HEADERS}; ${OPENCV_HAL_LIBS})" ELSE "NO")
|
||||
|
||||
if(HAVE_CUDA)
|
||||
status("")
|
||||
@ -1100,14 +1176,13 @@ endif()
|
||||
|
||||
if(HAVE_OPENCL)
|
||||
status("")
|
||||
status(" OpenCL:")
|
||||
if(HAVE_OPENCL_STATIC)
|
||||
set(__opencl_ver "static")
|
||||
set(__opencl_type "<Link with OpenCL library>")
|
||||
else()
|
||||
set(__opencl_ver "dynamic")
|
||||
set(__opencl_type "<Dynamic loading of OpenCL library>")
|
||||
endif()
|
||||
status(" Version:" ${__opencl_ver})
|
||||
if(OPENCL_INCLUDE_DIR)
|
||||
status(" OpenCL:" ${__opencl_type})
|
||||
if(OPENCL_INCLUDE_DIRS)
|
||||
status(" Include path:" ${OPENCL_INCLUDE_DIRS})
|
||||
endif()
|
||||
if(OPENCL_LIBRARIES)
|
||||
@ -1124,7 +1199,7 @@ if(HAVE_OPENCL)
|
||||
list(APPEND __libs "${l}")
|
||||
endif()
|
||||
endforeach()
|
||||
status(" libraries:" ${__libs})
|
||||
status(" Link libraries:" ${__libs})
|
||||
endif()
|
||||
status(" Use AMDFFT:" HAVE_CLAMDFFT THEN YES ELSE NO)
|
||||
status(" Use AMDBLAS:" HAVE_CLAMDBLAS THEN YES ELSE NO)
|
||||
@ -1172,10 +1247,12 @@ status(" Java tests:" BUILD_TESTS AND opencv_test_java_BINARY_DIR
|
||||
|
||||
# ========================= matlab =========================
|
||||
status("")
|
||||
status(" Matlab:")
|
||||
status(" mex:" MATLAB_MEX_SCRIPT THEN "${MATLAB_MEX_SCRIPT}" ELSE NO)
|
||||
if (MATLAB_FOUND)
|
||||
status(" Compiler/generator:" MEX_WORKS THEN "Working" ELSE "Not working (bindings will not be generated)")
|
||||
if(MATLAB_FOUND)
|
||||
status(" Matlab:")
|
||||
status(" mex:" MATLAB_MEX_SCRIPT THEN "${MATLAB_MEX_SCRIPT}" ELSE NO)
|
||||
status(" Compiler/generator:" MEX_WORKS THEN "Working" ELSE "Not working (bindings will not be generated)")
|
||||
else()
|
||||
status(" Matlab:" WITH_MATLAB AND NOT MATLAB_FOUND THEN "Matlab not found or implicitly disabled" ELSE NO)
|
||||
endif()
|
||||
|
||||
# ========================== documentation ==========================
|
||||
@ -1215,3 +1292,7 @@ endif()
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
include(cmake/OpenCVPackaging.cmake)
|
||||
|
||||
# This should be the last command
|
||||
ocv_cmake_dump_vars("" TOFILE "CMakeVars.txt")
|
||||
ocv_cmake_eval(DEBUG_POST ONCE)
|
||||
|
8
LICENSE
@ -7,12 +7,12 @@ copy or use the software.
|
||||
For Open Source Computer Vision Library
|
||||
(3-clause BSD License)
|
||||
|
||||
Copyright (C) 2000-2015, Intel Corporation, all rights reserved.
|
||||
Copyright (C) 2000-2016, Intel Corporation, all rights reserved.
|
||||
Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
|
||||
Copyright (C) 2009-2015, NVIDIA Corporation, all rights reserved.
|
||||
Copyright (C) 2009-2016, NVIDIA Corporation, all rights reserved.
|
||||
Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved.
|
||||
Copyright (C) 2015, OpenCV Foundation, all rights reserved.
|
||||
Copyright (C) 2015, Itseez Inc., all rights reserved.
|
||||
Copyright (C) 2015-2016, OpenCV Foundation, all rights reserved.
|
||||
Copyright (C) 2015-2016, Itseez Inc., all rights reserved.
|
||||
Third party copyrights are property of their respective owners.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -1,7 +1,5 @@
|
||||
### OpenCV: Open Source Computer Vision Library
|
||||
|
||||
[](https://www.gittip.com/OpenCV/)
|
||||
|
||||
#### Resources
|
||||
|
||||
* Homepage: <http://opencv.org>
|
||||
|
@ -206,7 +206,7 @@ bool CvCascadeClassifier::train( const string _cascadeDirName,
|
||||
cout << endl << "===== TRAINING " << i << "-stage =====" << endl;
|
||||
cout << "<BEGIN" << endl;
|
||||
|
||||
if ( !updateTrainingSet( tempLeafFARate ) )
|
||||
if ( !updateTrainingSet( requiredLeafFARate, tempLeafFARate ) )
|
||||
{
|
||||
cout << "Train dataset for temp stage can not be filled. "
|
||||
"Branch training terminated." << endl;
|
||||
@ -297,17 +297,17 @@ int CvCascadeClassifier::predict( int sampleIdx )
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool CvCascadeClassifier::updateTrainingSet( double& acceptanceRatio)
|
||||
bool CvCascadeClassifier::updateTrainingSet( double minimumAcceptanceRatio, double& acceptanceRatio)
|
||||
{
|
||||
int64 posConsumed = 0, negConsumed = 0;
|
||||
imgReader.restart();
|
||||
int posCount = fillPassedSamples( 0, numPos, true, posConsumed );
|
||||
int posCount = fillPassedSamples( 0, numPos, true, 0, posConsumed );
|
||||
if( !posCount )
|
||||
return false;
|
||||
cout << "POS count : consumed " << posCount << " : " << (int)posConsumed << endl;
|
||||
|
||||
int proNumNeg = cvRound( ( ((double)numNeg) * ((double)posCount) ) / numPos ); // apply only a fraction of negative samples. double is required since overflow is possible
|
||||
int negCount = fillPassedSamples( posCount, proNumNeg, false, negConsumed );
|
||||
int negCount = fillPassedSamples( posCount, proNumNeg, false, minimumAcceptanceRatio, negConsumed );
|
||||
if ( !negCount )
|
||||
return false;
|
||||
|
||||
@ -317,7 +317,7 @@ bool CvCascadeClassifier::updateTrainingSet( double& acceptanceRatio)
|
||||
return true;
|
||||
}
|
||||
|
||||
int CvCascadeClassifier::fillPassedSamples( int first, int count, bool isPositive, int64& consumed )
|
||||
int CvCascadeClassifier::fillPassedSamples( int first, int count, bool isPositive, double minimumAcceptanceRatio, int64& consumed )
|
||||
{
|
||||
int getcount = 0;
|
||||
Mat img(cascadeParams.winSize, CV_8UC1);
|
||||
@ -325,6 +325,9 @@ int CvCascadeClassifier::fillPassedSamples( int first, int count, bool isPositiv
|
||||
{
|
||||
for( ; ; )
|
||||
{
|
||||
if( consumed != 0 && ((double)getcount+1)/(double)(int64)consumed <= minimumAcceptanceRatio )
|
||||
return getcount;
|
||||
|
||||
bool isGetImg = isPositive ? imgReader.getPos( img ) :
|
||||
imgReader.getNeg( img );
|
||||
if( !isGetImg )
|
||||
|
@ -100,8 +100,8 @@ private:
|
||||
int predict( int sampleIdx );
|
||||
void save( const std::string cascadeDirName, bool baseFormat = false );
|
||||
bool load( const std::string cascadeDirName );
|
||||
bool updateTrainingSet( double& acceptanceRatio );
|
||||
int fillPassedSamples( int first, int count, bool isPositive, int64& consumed );
|
||||
bool updateTrainingSet( double minimumAcceptanceRatio, double& acceptanceRatio );
|
||||
int fillPassedSamples( int first, int count, bool isPositive, double requiredAcceptanceRatio, int64& consumed );
|
||||
|
||||
void writeParams( cv::FileStorage &fs ) const;
|
||||
void writeStages( cv::FileStorage &fs, const cv::Mat& featureMap ) const;
|
||||
|
@ -100,9 +100,14 @@ void CvHaarEvaluator::setImage(const Mat& img, uchar clsLabel, int idx)
|
||||
CV_DbgAssert( !sum.empty() && !tilted.empty() && !normfactor.empty() );
|
||||
CvFeatureEvaluator::setImage( img, clsLabel, idx);
|
||||
Mat innSum(winSize.height + 1, winSize.width + 1, sum.type(), sum.ptr<int>((int)idx));
|
||||
Mat innTilted(winSize.height + 1, winSize.width + 1, tilted.type(), tilted.ptr<int>((int)idx));
|
||||
Mat innSqSum;
|
||||
integral(img, innSum, innSqSum, innTilted);
|
||||
if (((const CvHaarFeatureParams*)featureParams)->mode == CvHaarFeatureParams::ALL)
|
||||
{
|
||||
Mat innTilted(winSize.height + 1, winSize.width + 1, tilted.type(), tilted.ptr<int>((int)idx));
|
||||
integral(img, innSum, innSqSum, innTilted);
|
||||
}
|
||||
else
|
||||
integral(img, innSum, innSqSum);
|
||||
normfactor.ptr<float>(0)[idx] = calcNormFactor( innSum, innSqSum );
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ CvCascadeImageReader::NegReader::NegReader()
|
||||
|
||||
bool CvCascadeImageReader::NegReader::create( const string _filename, Size _winSize )
|
||||
{
|
||||
string dirname, str;
|
||||
string str;
|
||||
std::ifstream file(_filename.c_str());
|
||||
if ( !file.is_open() )
|
||||
return false;
|
||||
|
139
cmake/FindGstreamerWindows.cmake
Normal file
@ -0,0 +1,139 @@
|
||||
FILE(TO_CMAKE_PATH "$ENV{GSTREAMER_DIR}" TRY1_DIR)
|
||||
FILE(TO_CMAKE_PATH "${GSTREAMER_DIR}" TRY2_DIR)
|
||||
FILE(GLOB GSTREAMER_DIR ${TRY1_DIR} ${TRY2_DIR})
|
||||
|
||||
FIND_PATH(GSTREAMER_gst_INCLUDE_DIR gst/gst.h
|
||||
PATHS ${GSTREAMER_DIR}/include/gstreamer-1.0 ${GSTREAMER_DIR}/include /usr/local/include/gstreamer-1.0 /usr/include/gstreamer-1.0
|
||||
ENV INCLUDE DOC "Directory containing gst/gst.h include file")
|
||||
|
||||
FIND_PATH(GSTREAMER_glib_INCLUDE_DIR glib.h
|
||||
PATHS ${GSTREAMER_DIR}/include/glib-2.0/
|
||||
ENV INCLUDE DOC "Directory containing glib.h include file")
|
||||
|
||||
FIND_PATH(GSTREAMER_glibconfig_INCLUDE_DIR glibconfig.h
|
||||
PATHS ${GSTREAMER_DIR}/lib/glib-2.0/include
|
||||
ENV INCLUDE DOC "Directory containing glibconfig.h include file")
|
||||
|
||||
FIND_PATH(GSTREAMER_gstconfig_INCLUDE_DIR gst/gstconfig.h
|
||||
PATHS ${GSTREAMER_DIR}/lib/gstreamer-1.0/include ${GSTREAMER_DIR}/include ${GSTREAMER_DIR}/lib/include /usr/local/include/gstreamer-1.0 /usr/include/gstreamer-1.0 /usr/local/lib/include/gstreamer-1.0 /usr/lib/include/gstreamer-1.0
|
||||
ENV INCLUDE DOC "Directory containing gst/gstconfig.h include file")
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstaudio_LIBRARY NAMES gstaudio libgstaudio-1.0 gstaudio-1.0
|
||||
PATHS ${GSTREMAER_DIR}/lib ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstaudio library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstapp_LIBRARY NAMES gstapp libgstapp-1.0 gstapp-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstapp library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstbase_LIBRARY NAMES gstbase libgstbase-1.0 gstbase-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstbase library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GLIB_gstcdda_LIBRARY NAMES gstcdda libgstcdda-1.0 gstcdda-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstcdda library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstcontroller_LIBRARY NAMES gstcontroller libgstcontroller-1.0 gstcontroller-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstcontroller library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstnet_LIBRARY NAMES gstnet libgstnet-1.0 gstnet-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstnet library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstpbutils_LIBRARY NAMES gstpbutils libgstpbutils-1.0 gstpbutils-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstpbutils library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstreamer_LIBRARY NAMES gstreamer libgstreamer-1.0 gstreamer-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstreamer library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstriff_LIBRARY NAMES gstriff libgstriff-1.0 gstriff-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstriff library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstrtp_LIBRARY NAMES gstrtp libgstrtp-1.0 gstrtp-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstrtp library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstrtsp_LIBRARY NAMES gstrtsp libgstrtsp-1.0 gstrtsp-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstrtsp library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstsdp_LIBRARY NAMES gstsdp libgstsdp-1.0 gstsdp-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstsdp library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gsttag_LIBRARY NAMES gsttag libgsttag-1.0 gsttag-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gsttag library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstvideo_LIBRARY NAMES gstvideo libgstvideo-1.0 gstvideo-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstvideo library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GLIB_LIBRARY NAMES libglib-2.0 glib-2.0
|
||||
PATHS ${GSTREAMER_DIR}/lib
|
||||
ENV LIB
|
||||
DOC "Glib library"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GOBJECT_LIBRARY NAMES libobject-2.0 gobject-2.0
|
||||
PATHS ${GSTREAMER_DIR}/lib
|
||||
ENV LIB
|
||||
DOC "Glib library"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
IF (GSTREAMER_gst_INCLUDE_DIR AND GSTREAMER_gstconfig_INCLUDE_DIR AND
|
||||
GSTREAMER_gstaudio_LIBRARY AND GSTREAMER_gstbase_LIBRARY AND GSTREAMER_gstcontroller_LIBRARY AND GSTREAMER_gstnet_LIBRARY
|
||||
AND GSTREAMER_gstpbutils_LIBRARY AND GSTREAMER_gstreamer_LIBRARY AND
|
||||
GSTREAMER_gstriff_LIBRARY AND GSTREAMER_gstrtp_LIBRARY AND GSTREAMER_gstrtsp_LIBRARY AND GSTREAMER_gstsdp_LIBRARY AND
|
||||
GSTREAMER_gsttag_LIBRARY AND GSTREAMER_gstvideo_LIBRARY AND GLIB_LIBRARY AND GSTREAMER_gstapp_LIBRARY AND GOBJECT_LIBRARY)
|
||||
SET(GSTREAMER_INCLUDE_DIR ${GSTREAMER_gst_INCLUDE_DIR} ${GSTREAMER_gstconfig_INCLUDE_DIR} ${GSTREAMER_glib_INCLUDE_DIR} ${GSTREAMER_glibconfig_INCLUDE_DIR})
|
||||
|
||||
list(REMOVE_DUPLICATES GSTREAMER_INCLUDE_DIR)
|
||||
SET(GSTREAMER_LIBRARIES ${GSTREAMER_gstaudio_LIBRARY} ${GSTREAMER_gstbase_LIBRARY}
|
||||
${GSTREAMER_gstcontroller_LIBRARY} ${GSTREAMER_gstdataprotocol_LIBRARY} ${GSTREAMER_gstinterfaces_LIBRARY}
|
||||
${GSTREAMER_gstnet_LIBRARY} ${GSTREAMER_gstpbutils_LIBRARY}
|
||||
${GSTREAMER_gstreamer_LIBRARY} ${GSTREAMER_gstriff_LIBRARY} ${GSTREAMER_gstrtp_LIBRARY}
|
||||
${GSTREAMER_gstrtsp_LIBRARY} ${GSTREAMER_gstsdp_LIBRARY} ${GSTREAMER_gsttag_LIBRARY} ${GSTREAMER_gstvideo_LIBRARY} ${GLIB_LIBRARY}
|
||||
${GSTREAMER_gstapp_LIBRARY} ${GOBJECT_LIBRARY})
|
||||
|
||||
list(REMOVE_DUPLICATES GSTREAMER_LIBRARIES)
|
||||
SET(GSTREAMER_FOUND TRUE)
|
||||
ENDIF (GSTREAMER_gst_INCLUDE_DIR AND GSTREAMER_gstconfig_INCLUDE_DIR AND
|
||||
GSTREAMER_gstaudio_LIBRARY AND GSTREAMER_gstbase_LIBRARY AND GSTREAMER_gstcontroller_LIBRARY
|
||||
AND GSTREAMER_gstnet_LIBRARY AND GSTREAMER_gstpbutils_LIBRARY AND GSTREAMER_gstreamer_LIBRARY AND
|
||||
GSTREAMER_gstriff_LIBRARY AND GSTREAMER_gstrtp_LIBRARY AND GSTREAMER_gstrtsp_LIBRARY AND GSTREAMER_gstsdp_LIBRARY AND
|
||||
GSTREAMER_gsttag_LIBRARY AND GSTREAMER_gstvideo_LIBRARY AND GLIB_LIBRARY AND GSTREAMER_gstapp_LIBRARY AND GOBJECT_LIBRARY)
|
@ -2,11 +2,14 @@ if(NOT MSVC)
|
||||
message(FATAL_ERROR "CRT options are available only for MSVC")
|
||||
endif()
|
||||
|
||||
#if (${CMAKE_SYSTEM_NAME} MATCHES "WindowsStore" OR ${CMAKE_SYSTEM_NAME} MATCHES "WindowsPhone")
|
||||
# set(WINRT TRUE)
|
||||
|
||||
if (WINRT)
|
||||
add_definitions(/DWINVER=_WIN32_WINNT_WIN8 /DNTDDI_VERSION=NTDDI_WIN8 /D_WIN32_WINNT=_WIN32_WINNT_WIN8)
|
||||
if (CMAKE_SYSTEM_VERSION MATCHES 10)
|
||||
add_definitions(/DWINVER=_WIN32_WINNT_WIN10 /DNTDDI_VERSION=NTDDI_WIN10 /D_WIN32_WINNT=_WIN32_WINNT_WIN10)
|
||||
elseif(CMAKE_SYSTEM_VERSION MATCHES 8.1)
|
||||
add_definitions(/DWINVER=_WIN32_WINNT_WINBLUE /DNTDDI_VERSION=NTDDI_WINBLUE /D_WIN32_WINNT=_WIN32_WINNT_WINBLUE)
|
||||
else()
|
||||
add_definitions(/DWINVER=_WIN32_WINNT_WIN8 /DNTDDI_VERSION=NTDDI_WIN8 /D_WIN32_WINNT=_WIN32_WINNT_WIN8)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Removing LNK4075 warnings for debug WinRT builds
|
||||
|
@ -33,7 +33,12 @@ if(CUDA_FOUND)
|
||||
if(WIN32)
|
||||
find_cuda_helper_libs(nvcuvenc)
|
||||
endif()
|
||||
set(HAVE_NVCUVID 1)
|
||||
if(CUDA_nvcuvid_LIBRARY)
|
||||
set(HAVE_NVCUVID 1)
|
||||
endif()
|
||||
if(CUDA_nvcuvenc_LIBRARY)
|
||||
set(HAVE_NVCUVENC 1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message(STATUS "CUDA detected: " ${CUDA_VERSION})
|
||||
|
@ -1,21 +1,21 @@
|
||||
set(OPENCL_FOUND ON CACHE BOOL "OpenCL library is found")
|
||||
if(APPLE)
|
||||
set(OPENCL_FOUND YES)
|
||||
set(OPENCL_LIBRARY "-framework OpenCL" CACHE STRING "OpenCL library")
|
||||
set(OPENCL_INCLUDE_DIR "" CACHE STRING "OpenCL include directory")
|
||||
mark_as_advanced(OPENCL_INCLUDE_DIR OPENCL_LIBRARY)
|
||||
set(HAVE_OPENCL_STATIC ON)
|
||||
set(OPENCL_INCLUDE_DIR "" CACHE PATH "OpenCL include directory")
|
||||
else(APPLE)
|
||||
set(OPENCL_FOUND YES)
|
||||
set(HAVE_OPENCL_STATIC OFF)
|
||||
set(OPENCL_INCLUDE_DIR "${OpenCV_SOURCE_DIR}/3rdparty/include/opencl/1.2")
|
||||
set(OPENCL_LIBRARY "" CACHE STRING "OpenCL library")
|
||||
set(OPENCL_INCLUDE_DIR "${OpenCV_SOURCE_DIR}/3rdparty/include/opencl/1.2" CACHE PATH "OpenCL include directory")
|
||||
endif(APPLE)
|
||||
|
||||
if(WINRT)
|
||||
set(OPENCL_FOUND NO)
|
||||
set(HAVE_OPENCL_STATIC OFF)
|
||||
endif(WINRT)
|
||||
mark_as_advanced(OPENCL_INCLUDE_DIR OPENCL_LIBRARY)
|
||||
|
||||
if(OPENCL_FOUND)
|
||||
if(OPENCL_LIBRARY)
|
||||
set(HAVE_OPENCL_STATIC ON)
|
||||
set(OPENCL_LIBRARIES "${OPENCL_LIBRARY}")
|
||||
else()
|
||||
set(HAVE_OPENCL_STATIC OFF)
|
||||
endif()
|
||||
|
||||
if(NOT HAVE_OPENCL_STATIC)
|
||||
try_compile(__VALID_OPENCL
|
||||
"${OpenCV_BINARY_DIR}"
|
||||
@ -29,20 +29,12 @@ if(OPENCL_FOUND)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT WINRT)
|
||||
set(HAVE_OPENCL 1)
|
||||
endif()
|
||||
set(HAVE_OPENCL 1)
|
||||
|
||||
if(WITH_OPENCL_SVM)
|
||||
set(HAVE_OPENCL_SVM 1)
|
||||
endif()
|
||||
|
||||
if(HAVE_OPENCL_STATIC)
|
||||
set(OPENCL_LIBRARIES "${OPENCL_LIBRARY}")
|
||||
else()
|
||||
unset(OPENCL_LIBRARIES)
|
||||
endif()
|
||||
|
||||
set(OPENCL_INCLUDE_DIRS ${OPENCL_INCLUDE_DIR})
|
||||
|
||||
if(WITH_OPENCLAMDFFT)
|
||||
|
@ -26,7 +26,7 @@ function(find_python preferred_version min_version library_env include_dir_env
|
||||
libs_found libs_version_string libraries library debug_libraries
|
||||
debug_library include_path include_dir include_dir2 packages_path
|
||||
numpy_include_dirs numpy_version)
|
||||
|
||||
if(NOT ${found})
|
||||
ocv_check_environment_variables(${executable})
|
||||
if(${executable})
|
||||
set(PYTHON_EXECUTABLE "${${executable}}")
|
||||
@ -73,7 +73,7 @@ function(find_python preferred_version min_version library_env include_dir_env
|
||||
if(_found)
|
||||
set(_version_major_minor "${_version_major}.${_version_minor}")
|
||||
|
||||
if(NOT ANDROID AND NOT IOS)
|
||||
if(NOT ANDROID AND NOT APPLE_FRAMEWORK)
|
||||
ocv_check_environment_variables(${library_env} ${include_dir_env})
|
||||
if(NOT ${${library_env}} EQUAL "")
|
||||
set(PYTHON_LIBRARY "${${library_env}}")
|
||||
@ -197,23 +197,24 @@ function(find_python preferred_version min_version library_env include_dir_env
|
||||
endif()
|
||||
|
||||
# Export return values
|
||||
set(${found} "${_found}" PARENT_SCOPE)
|
||||
set(${found} "${_found}" CACHE INTERNAL "")
|
||||
set(${executable} "${_executable}" CACHE FILEPATH "Path to Python interpretor")
|
||||
set(${version_string} "${_version_string}" PARENT_SCOPE)
|
||||
set(${version_major} "${_version_major}" PARENT_SCOPE)
|
||||
set(${version_minor} "${_version_minor}" PARENT_SCOPE)
|
||||
set(${libs_found} "${_libs_found}" PARENT_SCOPE)
|
||||
set(${libs_version_string} "${_libs_version_string}" PARENT_SCOPE)
|
||||
set(${libraries} "${_libraries}" PARENT_SCOPE)
|
||||
set(${version_string} "${_version_string}" CACHE INTERNAL "")
|
||||
set(${version_major} "${_version_major}" CACHE INTERNAL "")
|
||||
set(${version_minor} "${_version_minor}" CACHE INTERNAL "")
|
||||
set(${libs_found} "${_libs_found}" CACHE INTERNAL "")
|
||||
set(${libs_version_string} "${_libs_version_string}" CACHE INTERNAL "")
|
||||
set(${libraries} "${_libraries}" CACHE INTERNAL "Python libraries")
|
||||
set(${library} "${_library}" CACHE FILEPATH "Path to Python library")
|
||||
set(${debug_libraries} "${_debug_libraries}" PARENT_SCOPE)
|
||||
set(${debug_libraries} "${_debug_libraries}" CACHE INTERNAL "")
|
||||
set(${debug_library} "${_debug_library}" CACHE FILEPATH "Path to Python debug")
|
||||
set(${include_path} "${_include_path}" PARENT_SCOPE)
|
||||
set(${include_path} "${_include_path}" CACHE INTERNAL "")
|
||||
set(${include_dir} "${_include_dir}" CACHE PATH "Python include dir")
|
||||
set(${include_dir2} "${_include_dir2}" CACHE PATH "Python include dir 2")
|
||||
set(${packages_path} "${_packages_path}" CACHE PATH "Where to install the python packages.")
|
||||
set(${numpy_include_dirs} ${_numpy_include_dirs} CACHE PATH "Path to numpy headers")
|
||||
set(${numpy_version} "${_numpy_version}" PARENT_SCOPE)
|
||||
set(${numpy_version} "${_numpy_version}" CACHE INTERNAL "")
|
||||
endif()
|
||||
endfunction(find_python)
|
||||
|
||||
find_python(2.7 "${MIN_VER_PYTHON2}" PYTHON2_LIBRARY PYTHON2_INCLUDE_DIR
|
||||
|
@ -65,6 +65,8 @@ if(NOT HAVE_TBB)
|
||||
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/vc11")
|
||||
elseif(MSVC12)
|
||||
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/vc12")
|
||||
elseif(MSVC14)
|
||||
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/vc14")
|
||||
endif()
|
||||
set(TBB_LIB_DIR "${_TBB_LIB_PATH}" CACHE PATH "Full path of TBB library directory")
|
||||
link_directories("${TBB_LIB_DIR}")
|
||||
|
@ -3,7 +3,14 @@ if(NOT WITH_VTK)
|
||||
endif()
|
||||
|
||||
# VTK 6.x components
|
||||
find_package(VTK QUIET COMPONENTS vtkRenderingOpenGL vtkInteractionStyle vtkRenderingLOD vtkIOPLY vtkFiltersTexture vtkRenderingFreeType vtkIOExport NO_MODULE)
|
||||
find_package(VTK QUIET COMPONENTS vtkInteractionStyle vtkRenderingLOD vtkIOPLY vtkFiltersTexture vtkRenderingFreeType vtkIOExport NO_MODULE)
|
||||
IF(VTK_FOUND)
|
||||
IF(VTK_RENDERING_BACKEND) #in vtk 7, the rendering backend is exported as a var.
|
||||
find_package(VTK QUIET COMPONENTS vtkRendering${VTK_RENDERING_BACKEND} vtkInteractionStyle vtkRenderingLOD vtkIOPLY vtkFiltersTexture vtkRenderingFreeType vtkIOExport NO_MODULE)
|
||||
ELSE(VTK_RENDERING_BACKEND)
|
||||
find_package(VTK QUIET COMPONENTS vtkRenderingOpenGL vtkInteractionStyle vtkRenderingLOD vtkIOPLY vtkFiltersTexture vtkRenderingFreeType vtkIOExport NO_MODULE)
|
||||
ENDIF(VTK_RENDERING_BACKEND)
|
||||
ENDIF(VTK_FOUND)
|
||||
|
||||
# VTK 5.x components
|
||||
if(NOT VTK_FOUND)
|
||||
|
@ -146,12 +146,14 @@ macro(ipp_detect_version)
|
||||
IMPORTED_LOCATION ${IPP_LIBRARY_DIR}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX}
|
||||
)
|
||||
list(APPEND IPP_LIBRARIES ipp${name})
|
||||
# CMake doesn't support "install(TARGETS ${IPP_PREFIX}${name} " command with imported targets
|
||||
install(FILES ${IPP_LIBRARY_DIR}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX}
|
||||
DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
string(TOUPPER ${name} uname)
|
||||
set(IPP${uname}_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/${OPENCV_3P_LIB_INSTALL_PATH}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX}" CACHE INTERNAL "" FORCE)
|
||||
set(IPP${uname}_LOCATION_PATH "${IPP_LIBRARY_DIR}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX}" CACHE INTERNAL "" FORCE)
|
||||
if (NOT BUILD_SHARED_LIBS OR NOT INSTALL_CREATE_DISTRIB)
|
||||
# CMake doesn't support "install(TARGETS ${IPP_PREFIX}${name} " command with imported targets
|
||||
install(FILES ${IPP_LIBRARY_DIR}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX}
|
||||
DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
string(TOUPPER ${name} uname)
|
||||
set(IPP${uname}_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/${OPENCV_3P_LIB_INSTALL_PATH}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX}" CACHE INTERNAL "" FORCE)
|
||||
set(IPP${uname}_LOCATION_PATH "${IPP_LIBRARY_DIR}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX}" CACHE INTERNAL "" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "Can't find IPP library: ${name} at ${IPP_LIBRARY_DIR}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX}")
|
||||
|
@ -12,23 +12,36 @@ endif(WITH_VFW)
|
||||
|
||||
# --- GStreamer ---
|
||||
ocv_clear_vars(HAVE_GSTREAMER)
|
||||
# try to find gstreamer 1.x first
|
||||
# try to find gstreamer 1.x first if 0.10 was not requested
|
||||
if(WITH_GSTREAMER AND NOT WITH_GSTREAMER_0_10)
|
||||
CHECK_MODULE(gstreamer-base-1.0 HAVE_GSTREAMER_BASE)
|
||||
CHECK_MODULE(gstreamer-video-1.0 HAVE_GSTREAMER_VIDEO)
|
||||
CHECK_MODULE(gstreamer-app-1.0 HAVE_GSTREAMER_APP)
|
||||
CHECK_MODULE(gstreamer-riff-1.0 HAVE_GSTREAMER_RIFF)
|
||||
CHECK_MODULE(gstreamer-pbutils-1.0 HAVE_GSTREAMER_PBUTILS)
|
||||
if(WIN32)
|
||||
SET(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_LIST_DIR}")
|
||||
FIND_PACKAGE(GstreamerWindows)
|
||||
IF(GSTREAMER_gstbase_LIBRARY AND GSTREAMER_gstvideo_LIBRARY AND GSTREAMER_gstapp_LIBRARY AND GSTREAMER_gstpbutils_LIBRARY AND GSTREAMER_gstriff_LIBRARY)
|
||||
set(HAVE_GSTREAMER TRUE)
|
||||
set(GSTREAMER_BASE_VERSION 1.0)
|
||||
set(GSTREAMER_VIDEO_VERSION 1.0)
|
||||
set(GSTREAMER_APP_VERSION 1.0)
|
||||
set(GSTREAMER_RIFF_VERSION 1.0)
|
||||
set(GSTREAMER_PBUTILS_VERSION 1.0)
|
||||
ENDIF(GSTREAMER_gstbase_LIBRARY AND GSTREAMER_gstvideo_LIBRARY AND GSTREAMER_gstapp_LIBRARY AND GSTREAMER_gstpbutils_LIBRARY AND GSTREAMER_gstriff_LIBRARY)
|
||||
|
||||
if(HAVE_GSTREAMER_BASE AND HAVE_GSTREAMER_VIDEO AND HAVE_GSTREAMER_APP AND HAVE_GSTREAMER_RIFF AND HAVE_GSTREAMER_PBUTILS)
|
||||
else(WIN32)
|
||||
CHECK_MODULE(gstreamer-base-1.0 HAVE_GSTREAMER_BASE)
|
||||
CHECK_MODULE(gstreamer-video-1.0 HAVE_GSTREAMER_VIDEO)
|
||||
CHECK_MODULE(gstreamer-app-1.0 HAVE_GSTREAMER_APP)
|
||||
CHECK_MODULE(gstreamer-riff-1.0 HAVE_GSTREAMER_RIFF)
|
||||
CHECK_MODULE(gstreamer-pbutils-1.0 HAVE_GSTREAMER_PBUTILS)
|
||||
|
||||
if(HAVE_GSTREAMER_BASE AND HAVE_GSTREAMER_VIDEO AND HAVE_GSTREAMER_APP AND HAVE_GSTREAMER_RIFF AND HAVE_GSTREAMER_PBUTILS)
|
||||
set(HAVE_GSTREAMER TRUE)
|
||||
set(GSTREAMER_BASE_VERSION ${ALIASOF_gstreamer-base-1.0_VERSION})
|
||||
set(GSTREAMER_VIDEO_VERSION ${ALIASOF_gstreamer-video-1.0_VERSION})
|
||||
set(GSTREAMER_APP_VERSION ${ALIASOF_gstreamer-app-1.0_VERSION})
|
||||
set(GSTREAMER_RIFF_VERSION ${ALIASOF_gstreamer-riff-1.0_VERSION})
|
||||
set(GSTREAMER_PBUTILS_VERSION ${ALIASOF_gstreamer-pbutils-1.0_VERSION})
|
||||
endif()
|
||||
|
||||
endif()
|
||||
endif(WIN32)
|
||||
endif(WITH_GSTREAMER AND NOT WITH_GSTREAMER_0_10)
|
||||
|
||||
# if gstreamer 1.x was not found, or we specified we wanted 0.10, try to find it
|
||||
@ -201,7 +214,7 @@ if(WITH_FFMPEG)
|
||||
CHECK_INCLUDE_FILE(libavformat/avformat.h HAVE_GENTOO_FFMPEG)
|
||||
CHECK_INCLUDE_FILE(ffmpeg/avformat.h HAVE_FFMPEG_FFMPEG)
|
||||
if(NOT HAVE_GENTOO_FFMPEG AND NOT HAVE_FFMPEG_FFMPEG)
|
||||
if(EXISTS /usr/include/ffmpeg/libavformat/avformat.h OR HAVE_FFMPEG_SWSCALE)
|
||||
if((NOT CMAKE_CROSSCOMPILING AND EXISTS /usr/include/ffmpeg/libavformat/avformat.h) OR HAVE_FFMPEG_SWSCALE)
|
||||
set(HAVE_GENTOO_FFMPEG TRUE)
|
||||
endif()
|
||||
endif()
|
||||
@ -211,11 +224,7 @@ if(WITH_FFMPEG)
|
||||
|
||||
if(HAVE_FFMPEG)
|
||||
# Find the bzip2 library because it is required on some systems
|
||||
FIND_LIBRARY(BZIP2_LIBRARIES NAMES bz2 bzip2)
|
||||
if(NOT BZIP2_LIBRARIES)
|
||||
# Do an other trial
|
||||
FIND_FILE(BZIP2_LIBRARIES NAMES libbz2.so.1 PATHS /lib)
|
||||
endif()
|
||||
FIND_LIBRARY(BZIP2_LIBRARIES NAMES bz2 bzip2 libbz2.so.1)
|
||||
else()
|
||||
find_path(FFMPEG_INCLUDE_DIR "libavformat/avformat.h"
|
||||
PATHS /usr/local /usr /opt
|
||||
|
@ -83,7 +83,7 @@ endif()
|
||||
|
||||
export(TARGETS ${OpenCVModules_TARGETS} FILE "${CMAKE_BINARY_DIR}/OpenCVModules${modules_file_suffix}.cmake")
|
||||
|
||||
if(TARGET ippicv)
|
||||
if(TARGET ippicv AND (NOT BUILD_SHARED_LIBS OR NOT INSTALL_CREATE_DISTRIB))
|
||||
set(USE_IPPICV TRUE)
|
||||
file(RELATIVE_PATH INSTALL_PATH_RELATIVE_IPPICV ${CMAKE_BINARY_DIR} ${IPPICV_LOCATION_PATH})
|
||||
else()
|
||||
@ -133,11 +133,7 @@ if(WIN32)
|
||||
|
||||
exec_program(mkdir ARGS "-p \"${CMAKE_BINARY_DIR}/win-install/\"" OUTPUT_VARIABLE RET_VAL)
|
||||
if(USE_IPPICV)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
file(RELATIVE_PATH INSTALL_PATH_RELATIVE_IPPICV "${CMAKE_INSTALL_PREFIX}/${OpenCV_INSTALL_BINARIES_PREFIX}lib" ${IPPICV_INSTALL_PATH})
|
||||
else()
|
||||
file(RELATIVE_PATH INSTALL_PATH_RELATIVE_IPPICV "${CMAKE_INSTALL_PREFIX}/${OpenCV_INSTALL_BINARIES_PREFIX}staticlib" ${IPPICV_INSTALL_PATH})
|
||||
endif()
|
||||
file(RELATIVE_PATH INSTALL_PATH_RELATIVE_IPPICV "${CMAKE_INSTALL_PREFIX}/${OpenCV_INSTALL_BINARIES_PREFIX}staticlib" ${IPPICV_INSTALL_PATH})
|
||||
endif()
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" @ONLY)
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig-version.cmake" @ONLY)
|
||||
|
@ -1,10 +1,5 @@
|
||||
if(OPENCV_EXTRA_WORLD)
|
||||
set(OPENCV_APPLE_BUNDLE_NAME "OpenCV_contrib")
|
||||
set(OPENCV_APPLE_BUNDLE_ID "org.opencv_contrib")
|
||||
else()
|
||||
set(OPENCV_APPLE_BUNDLE_NAME "OpenCV")
|
||||
set(OPENCV_APPLE_BUNDLE_ID "org.opencv")
|
||||
endif()
|
||||
set(OPENCV_APPLE_BUNDLE_NAME "OpenCV")
|
||||
set(OPENCV_APPLE_BUNDLE_ID "org.opencv")
|
||||
|
||||
if(IOS)
|
||||
configure_file("${OpenCV_SOURCE_DIR}/platforms/ios/Info.plist.in"
|
||||
|
@ -21,6 +21,8 @@ macro(fix_prefix lst isown)
|
||||
endif()
|
||||
if(item MATCHES "^-l")
|
||||
list(APPEND _lst "${item}")
|
||||
elseif(item MATCHES "^-framework") # MacOS framework (assume single entry "-framework OpenCL")
|
||||
list(APPEND _lst "${item}")
|
||||
elseif(item MATCHES "[\\/]")
|
||||
get_filename_component(libdir "${item}" PATH)
|
||||
get_filename_component(libname "${item}" NAME_WE)
|
||||
|
@ -305,9 +305,10 @@ macro(ocv_glob_modules)
|
||||
set(OPENCV_INITIAL_PASS OFF PARENT_SCOPE)
|
||||
set(OPENCV_INITIAL_PASS OFF)
|
||||
if(${BUILD_opencv_world})
|
||||
add_subdirectory("${OPENCV_MODULE_opencv_world_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/world")
|
||||
foreach(m ${OPENCV_MODULES_BUILD})
|
||||
if(NOT OPENCV_MODULE_${m}_IS_PART_OF_WORLD AND NOT ${m} STREQUAL opencv_world)
|
||||
if("${m}" STREQUAL opencv_world)
|
||||
add_subdirectory("${OPENCV_MODULE_opencv_world_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/world")
|
||||
elseif(NOT OPENCV_MODULE_${m}_IS_PART_OF_WORLD AND NOT ${m} STREQUAL opencv_world)
|
||||
message(STATUS "Processing module ${m}...")
|
||||
if(m MATCHES "^opencv_")
|
||||
string(REGEX REPLACE "^opencv_" "" __shortname "${m}")
|
||||
@ -351,6 +352,7 @@ function(__ocv_sort_modules_by_deps __lst)
|
||||
ocv_list_sort(${__lst})
|
||||
set(input ${${__lst}})
|
||||
set(result "")
|
||||
set(result_extra "")
|
||||
while(input)
|
||||
list(LENGTH input length_before)
|
||||
foreach (m ${input})
|
||||
@ -375,16 +377,27 @@ function(__ocv_sort_modules_by_deps __lst)
|
||||
list(LENGTH input length_after)
|
||||
# check for infinite loop or unresolved dependencies
|
||||
if (NOT length_after LESS length_before)
|
||||
message(WARNING "Unresolved dependencies or loop in dependency graph (${length_after})\n"
|
||||
"Processed ${__lst}: ${${__lst}}\n"
|
||||
"Good modules: ${result}\n"
|
||||
"Bad modules: ${input}"
|
||||
)
|
||||
list(APPEND result ${input})
|
||||
break()
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
if (";${input};" MATCHES ";opencv_world;")
|
||||
list(REMOVE_ITEM input "opencv_world")
|
||||
list(APPEND result_extra "opencv_world")
|
||||
else()
|
||||
# We can't do here something
|
||||
list(APPEND result ${input})
|
||||
break()
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR WARNING "Unresolved dependencies or loop in dependency graph (${length_after})\n"
|
||||
"Processed ${__lst}: ${${__lst}}\n"
|
||||
"Good modules: ${result}\n"
|
||||
"Bad modules: ${input}"
|
||||
)
|
||||
list(APPEND result ${input})
|
||||
break()
|
||||
endif()
|
||||
endif()
|
||||
endwhile()
|
||||
set(${__lst} "${result}" PARENT_SCOPE)
|
||||
set(${__lst} "${result};${result_extra}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# resolve dependensies
|
||||
@ -446,6 +459,17 @@ function(__ocv_resolve_dependencies)
|
||||
list(APPEND deps_${m} ${d})
|
||||
set(has_changes ON)
|
||||
endif()
|
||||
if(BUILD_opencv_world
|
||||
AND NOT "${m}" STREQUAL "opencv_world"
|
||||
AND NOT "${m2}" STREQUAL "opencv_world"
|
||||
AND OPENCV_MODULE_${m2}_IS_PART_OF_WORLD
|
||||
AND NOT OPENCV_MODULE_${m}_IS_PART_OF_WORLD)
|
||||
if(NOT (";${deps_${m}};" MATCHES ";opencv_world;"))
|
||||
# message(STATUS " Transfer dependency opencv_world alias ${m2} to ${m}")
|
||||
list(APPEND deps_${m} opencv_world)
|
||||
set(has_changes ON)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endforeach()
|
||||
@ -643,6 +667,8 @@ macro(ocv_glob_module_sources)
|
||||
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/*.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.h"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/hal/*.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/hal/*.h"
|
||||
)
|
||||
file(GLOB lib_hdrs_detail
|
||||
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/detail/*.hpp"
|
||||
@ -675,7 +701,6 @@ macro(ocv_glob_module_sources)
|
||||
)
|
||||
if(cl_kernels)
|
||||
set(OCL_NAME opencl_kernels_${name})
|
||||
ocv_include_directories(${OPENCL_INCLUDE_DIRS})
|
||||
add_custom_command(
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.cpp" "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.hpp"
|
||||
COMMAND ${CMAKE_COMMAND} "-DMODULE_NAME=${name}" "-DCL_DIR=${CMAKE_CURRENT_LIST_DIR}/src/opencl" "-DOUTPUT=${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.cpp" -P "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake"
|
||||
@ -777,11 +802,20 @@ macro(_ocv_create_module)
|
||||
set_source_files_properties(${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES} ${${the_module}_pch}
|
||||
PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL};Module")
|
||||
|
||||
ocv_target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS_TO_LINK})
|
||||
ocv_target_link_libraries(${the_module} LINK_INTERFACE_LIBRARIES ${OPENCV_MODULE_${the_module}_DEPS_TO_LINK})
|
||||
ocv_target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN})
|
||||
if (HAVE_CUDA)
|
||||
ocv_target_link_libraries(${the_module} ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
|
||||
if(NOT BUILD_SHARED_LIBS OR NOT INSTALL_CREATE_DISTRIB)
|
||||
ocv_target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS_TO_LINK})
|
||||
ocv_target_link_libraries(${the_module} LINK_INTERFACE_LIBRARIES ${OPENCV_MODULE_${the_module}_DEPS_TO_LINK})
|
||||
ocv_target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN})
|
||||
if (HAVE_CUDA)
|
||||
ocv_target_link_libraries(${the_module} ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
|
||||
endif()
|
||||
else()
|
||||
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${OPENCV_MODULE_${the_module}_DEPS_TO_LINK})
|
||||
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${OPENCV_MODULE_${the_module}_DEPS_TO_LINK})
|
||||
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN})
|
||||
if (HAVE_CUDA)
|
||||
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_dependencies(opencv_modules ${the_module})
|
||||
@ -825,12 +859,14 @@ macro(_ocv_create_module)
|
||||
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc /DEBUG")
|
||||
endif()
|
||||
|
||||
ocv_install_target(${the_module} EXPORT OpenCVModules OPTIONAL
|
||||
RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT libs
|
||||
LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT libs NAMELINK_SKIP
|
||||
ARCHIVE DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT dev
|
||||
)
|
||||
get_target_property(_target_type ${the_module} TYPE)
|
||||
if("${_target_type}" STREQUAL "SHARED_LIBRARY" OR (NOT BUILD_SHARED_LIBS OR NOT INSTALL_CREATE_DISTRIB))
|
||||
ocv_install_target(${the_module} EXPORT OpenCVModules OPTIONAL
|
||||
RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT libs
|
||||
LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT libs NAMELINK_SKIP
|
||||
ARCHIVE DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT dev
|
||||
)
|
||||
endif()
|
||||
if("${_target_type}" STREQUAL "SHARED_LIBRARY")
|
||||
install(TARGETS ${the_module}
|
||||
LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT dev NAMELINK_ONLY)
|
||||
|
@ -164,9 +164,9 @@ MACRO(_PCH_GET_TARGET_COMPILE_FLAGS _cflags _header_name _pch_path _dowarn )
|
||||
# if you have different versions of the headers for different build types
|
||||
# you may set _pch_dowarn
|
||||
IF (_dowarn)
|
||||
SET(${_cflags} "${PCH_ADDITIONAL_COMPILER_FLAGS} -include \"${CMAKE_CURRENT_BINARY_DIR}/${_header_name}\" -Winvalid-pch " )
|
||||
SET(${_cflags} "${PCH_ADDITIONAL_COMPILER_FLAGS} -Winvalid-pch " )
|
||||
ELSE (_dowarn)
|
||||
SET(${_cflags} "${PCH_ADDITIONAL_COMPILER_FLAGS} -include \"${CMAKE_CURRENT_BINARY_DIR}/${_header_name}\" " )
|
||||
SET(${_cflags} "${PCH_ADDITIONAL_COMPILER_FLAGS} " )
|
||||
ENDIF (_dowarn)
|
||||
|
||||
ELSE(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
@ -1,11 +1,15 @@
|
||||
include(CMakeParseArguments)
|
||||
|
||||
# Debugging function
|
||||
function(ocv_cmake_dump_vars)
|
||||
set(VARS "")
|
||||
get_cmake_property(_variableNames VARIABLES)
|
||||
cmake_parse_arguments(DUMP "" "TOFILE" "" ${ARGN})
|
||||
set(regex "${DUMP_UNPARSED_ARGUMENTS}")
|
||||
get_cmake_property(_variableNames VARIABLES)
|
||||
set(VARS "")
|
||||
string(TOLOWER "${regex}" regex_lower)
|
||||
foreach(_variableName ${_variableNames})
|
||||
if(_variableName MATCHES "${regex}")
|
||||
string(TOLOWER "${_variableName}" _variableName_lower)
|
||||
if(_variableName MATCHES "${regex}" OR _variableName_lower MATCHES "${regex_lower}")
|
||||
set(VARS "${VARS}${_variableName}=${${_variableName}}\n")
|
||||
endif()
|
||||
endforeach()
|
||||
@ -16,6 +20,15 @@ function(ocv_cmake_dump_vars)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(ocv_cmake_eval var_name)
|
||||
if(DEFINED ${var_name})
|
||||
file(WRITE "${CMAKE_BINARY_DIR}/CMakeCommand-${var_name}.cmake" ${${var_name}})
|
||||
include("${CMAKE_BINARY_DIR}/CMakeCommand-${var_name}.cmake")
|
||||
endif()
|
||||
if(";${ARGN};" MATCHES ";ONCE;")
|
||||
unset(${var_name} CACHE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Search packages for host system instead of packages for target system
|
||||
# in case of cross compilation thess macro should be defined by toolchain file
|
||||
@ -503,17 +516,15 @@ endmacro()
|
||||
|
||||
|
||||
# convert list of paths to libraries names without lib prefix
|
||||
macro(ocv_convert_to_lib_name var)
|
||||
set(__tmp "")
|
||||
function(ocv_convert_to_lib_name var)
|
||||
set(tmp "")
|
||||
foreach(path ${ARGN})
|
||||
get_filename_component(__tmp_name "${path}" NAME_WE)
|
||||
string(REGEX REPLACE "^lib" "" __tmp_name ${__tmp_name})
|
||||
list(APPEND __tmp "${__tmp_name}")
|
||||
get_filename_component(tmp_name "${path}" NAME_WE)
|
||||
string(REGEX REPLACE "^lib" "" tmp_name "${tmp_name}")
|
||||
list(APPEND tmp "${tmp_name}")
|
||||
endforeach()
|
||||
set(${var} ${__tmp})
|
||||
unset(__tmp)
|
||||
unset(__tmp_name)
|
||||
endmacro()
|
||||
set(${var} ${tmp} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
# add install command
|
||||
@ -727,6 +738,9 @@ function(ocv_target_link_libraries target)
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
if(";${LINK_DEPS};" MATCHES ";${target};")
|
||||
list(REMOVE_ITEM LINK_DEPS "${target}") # prevent "link to itself" warning (world problem)
|
||||
endif()
|
||||
target_link_libraries(${target} ${LINK_DEPS})
|
||||
endfunction()
|
||||
|
||||
@ -746,20 +760,9 @@ function(ocv_add_executable target)
|
||||
endfunction()
|
||||
|
||||
function(ocv_add_library target)
|
||||
set(cuda_objs "")
|
||||
if(HAVE_CUDA)
|
||||
set(cuda_srcs "")
|
||||
|
||||
foreach(var ${ARGN})
|
||||
if(var MATCHES ".cu")
|
||||
list(APPEND cuda_srcs ${var})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(cuda_srcs)
|
||||
ocv_include_directories(${CUDA_INCLUDE_DIRS})
|
||||
ocv_cuda_compile(cuda_objs ${lib_cuda_srcs} ${lib_cuda_hdrs})
|
||||
endif()
|
||||
if(HAVE_CUDA AND ARGN MATCHES "\\.cu")
|
||||
ocv_include_directories(${CUDA_INCLUDE_DIRS})
|
||||
ocv_cuda_compile(cuda_objs ${ARGN})
|
||||
set(OPENCV_MODULE_${target}_CUDA_OBJECTS ${cuda_objs} CACHE INTERNAL "Compiled CUDA object files")
|
||||
endif()
|
||||
|
||||
@ -770,9 +773,10 @@ function(ocv_add_library target)
|
||||
AND NOT OPENCV_MODULE_${target}_CHILDREN
|
||||
AND NOT OPENCV_MODULE_${target}_CLASS STREQUAL "BINDINGS"
|
||||
AND NOT ${target} STREQUAL "opencv_ts"
|
||||
AND (NOT BUILD_opencv_world OR NOT HAVE_CUDA)
|
||||
)
|
||||
set(sources ${ARGN})
|
||||
ocv_list_filterout(sources "\\\\.(cl|inc)$")
|
||||
ocv_list_filterout(sources "\\\\.(cl|inc|cu)$")
|
||||
add_library(${target}_object OBJECT ${sources})
|
||||
set_target_properties(${target}_object PROPERTIES
|
||||
EXCLUDE_FROM_ALL True
|
||||
@ -805,7 +809,13 @@ macro(ocv_get_all_libs _modules _extra _3rdparty)
|
||||
else()
|
||||
set(deps "")
|
||||
endif()
|
||||
list(INSERT ${_modules} 0 ${deps} ${m})
|
||||
set(_rev_deps "${deps};${m}")
|
||||
ocv_list_reverse(_rev_deps)
|
||||
foreach (dep ${_rev_deps})
|
||||
if(DEFINED OPENCV_MODULE_${dep}_LOCATION)
|
||||
list(INSERT ${_modules} 0 ${dep})
|
||||
endif()
|
||||
endforeach()
|
||||
foreach (dep ${deps} ${OPENCV_LINKER_LIBS})
|
||||
if (NOT DEFINED OPENCV_MODULE_${dep}_LOCATION)
|
||||
if (TARGET ${dep})
|
||||
@ -826,11 +836,14 @@ macro(ocv_get_all_libs _modules _extra _3rdparty)
|
||||
list(FIND ${_extra} "ippicv" ippicv_idx)
|
||||
if (${ippicv_idx} GREATER -1)
|
||||
list(REMOVE_ITEM ${_extra} "ippicv")
|
||||
list(INSERT ${_3rdparty} 0 "ippicv")
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
list(INSERT ${_3rdparty} 0 "ippicv")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# split 3rdparty libs and modules
|
||||
list(REMOVE_ITEM ${_modules} ${${_3rdparty}} ${${_extra}} non_empty_list)
|
||||
ocv_list_filterout(${_modules} "^[\$]<")
|
||||
ocv_list_filterout(${_3rdparty} "^[\$]<")
|
||||
ocv_list_filterout(${_extra} "^[\$]<")
|
||||
|
||||
# convert CMake lists to makefile literals
|
||||
foreach(lst ${_modules} ${_3rdparty} ${_extra})
|
||||
|
@ -1,8 +1,5 @@
|
||||
#if defined __APPLE__
|
||||
#include <OpenCL/cl.h>
|
||||
#else
|
||||
// custom OpenCL headers are located in "CL" subfolder (3rdparty/include/...)
|
||||
#include <CL/cl.h>
|
||||
#endif
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#ifdef CL_VERSION_1_2
|
||||
|
@ -24,6 +24,7 @@ endif()
|
||||
set(STR_CPP "// This file is auto-generated. Do not edit!
|
||||
|
||||
#include \"precomp.hpp\"
|
||||
#include \"cvconfig.h\"
|
||||
#include \"${OUTPUT_HPP_NAME}\"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
@ -9,6 +9,7 @@ if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
|
||||
set(PACKAGE_VERSION_COMPATIBLE True)
|
||||
endif()
|
||||
|
||||
if(PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION)
|
||||
if(PACKAGE_FIND_VERSION_MAJOR EQUAL @OPENCV_VERSION_MAJOR@
|
||||
AND PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION)
|
||||
set(PACKAGE_VERSION_COMPATIBLE True)
|
||||
endif()
|
||||
|
@ -159,6 +159,7 @@ SET(OpenCV_VERSION_STATUS "@OPENCV_VERSION_STATUS@")
|
||||
# ====================================================================
|
||||
|
||||
SET(OpenCV_LIB_COMPONENTS @OPENCV_MODULES_CONFIGCMAKE@)
|
||||
list(REMOVE_ITEM OpenCV_LIB_COMPONENTS opencv_hal)
|
||||
SET(OpenCV_WORLD_COMPONENTS @OPENCV_WORLD_MODULES@)
|
||||
|
||||
# ==============================================================
|
||||
|
@ -1,6 +1,6 @@
|
||||
#ifndef _CUSTOM_HAL_INCLUDED_
|
||||
#define _CUSTOM_HAL_INCLUDED_
|
||||
|
||||
@OPENCV_HAL_HEADERS_INCLUDES@
|
||||
@_includes@
|
||||
|
||||
#endif
|
||||
|
@ -120,6 +120,9 @@
|
||||
/* NVidia Video Decoding API*/
|
||||
#cmakedefine HAVE_NVCUVID
|
||||
|
||||
/* NVidia Video Encoding API*/
|
||||
#cmakedefine HAVE_NVCUVENC
|
||||
|
||||
/* OpenCL Support */
|
||||
#cmakedefine HAVE_OPENCL
|
||||
#cmakedefine HAVE_OPENCL_STATIC
|
||||
|
@ -21,7 +21,7 @@
|
||||
</libs>
|
||||
|
||||
<skip_headers>
|
||||
opencv2/hal/intrin*
|
||||
opencv2/core/hal/intrin*
|
||||
opencv2/core/cuda*
|
||||
opencv2/core/private*
|
||||
opencv/cxeigen.hpp
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-
|
||||
<!--
|
||||
22x18 upperbody detector (see the detailed description below).
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -243,6 +243,7 @@ PREDEFINED = __cplusplus=1 \
|
||||
CV_NORETURN= \
|
||||
CV_DEFAULT(x)=" = x" \
|
||||
CV_NEON=1 \
|
||||
CV_SSE2=1 \
|
||||
FLANN_DEPRECATED=
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
|
@ -415,6 +415,16 @@
|
||||
pages = {2548--2555},
|
||||
organization = {IEEE}
|
||||
}
|
||||
@ARTICLE{Louhichi07,
|
||||
author = {Louhichi, H. and Fournel, T. and Lavest, J. M. and Ben Aissia, H.},
|
||||
title = {Self-calibration of Scheimpflug cameras: an easy protocol},
|
||||
year = {2007},
|
||||
pages = {2616–2622},
|
||||
journal = {Meas. Sci. Technol.},
|
||||
volume = {18},
|
||||
number = {8},
|
||||
publisher = {IOP Publishing Ltd}
|
||||
}
|
||||
@ARTICLE{LibSVM,
|
||||
author = {Chang, Chih-Chung and Lin, Chih-Jen},
|
||||
title = {LIBSVM: a library for support vector machines},
|
||||
|
@ -51,8 +51,7 @@ Otherwise open it using **cap.open()**.
|
||||
|
||||
You can also access some of the features of this video using **cap.get(propId)** method where propId
|
||||
is a number from 0 to 18. Each number denotes a property of the video (if it is applicable to that
|
||||
video) and full details can be seen here: [Property
|
||||
Identifier](http://docs.opencv.org/modules/highgui/doc/reading_and_writing_video.html#videocapture-get).
|
||||
video) and full details can be seen here: cv::VideoCapture::get() .
|
||||
Some of these values can be modified using **cap.set(propId, value)**. Value is the new value you
|
||||
want.
|
||||
|
||||
|
@ -16,8 +16,7 @@ intensity value of the pixel. But in two-dimensional histograms, you consider tw
|
||||
it is used for finding color histograms where two features are Hue & Saturation values of every
|
||||
pixel.
|
||||
|
||||
There is a [python sample in the official
|
||||
samples](https://github.com/Itseez/opencv/blob/master/samples/python2/color_histogram.py) already
|
||||
There is a python sample (samples/python/color_histogram.py) already
|
||||
for finding color histograms. We will try to understand how to create such a color histogram, and it
|
||||
will be useful in understanding further topics like Histogram Back-Projection.
|
||||
|
||||
@ -106,10 +105,11 @@ You can verify it with any image editing tools like GIMP.
|
||||
|
||||
### Method 3 : OpenCV sample style !!
|
||||
|
||||
There is a [sample code for color-histogram in OpenCV-Python2
|
||||
samples](https://github.com/Itseez/opencv/blob/master/samples/python2/color_histogram.py). If you
|
||||
run the code, you can see the histogram shows the corresponding color also. Or simply it outputs a
|
||||
color coded histogram. Its result is very good (although you need to add extra bunch of lines).
|
||||
There is a sample code for color-histogram in OpenCV-Python2 samples
|
||||
(samples/python/color_histogram.py).
|
||||
If you run the code, you can see the histogram shows the corresponding color also.
|
||||
Or simply it outputs a color coded histogram.
|
||||
Its result is very good (although you need to add extra bunch of lines).
|
||||
|
||||
In that code, the author created a color map in HSV. Then converted it into BGR. The resulting
|
||||
histogram image is multiplied with this color map. He also uses some preprocessing steps to remove
|
||||
|
@ -155,8 +155,8 @@ should be due to the sky)
|
||||
|
||||
Well, here you adjust the values of histograms along with its bin values to look like x,y
|
||||
coordinates so that you can draw it using cv2.line() or cv2.polyline() function to generate same
|
||||
image as above. This is already available with OpenCV-Python2 official samples. [Check the
|
||||
Code](https://github.com/Itseez/opencv/raw/master/samples/python2/hist.py)
|
||||
image as above. This is already available with OpenCV-Python2 official samples. Check the
|
||||
code at samples/python/hist.py.
|
||||
|
||||
Application of Mask
|
||||
-------------------
|
||||
|
@ -13,7 +13,7 @@ OCR of Hand-written Digits
|
||||
|
||||
Our goal is to build an application which can read the handwritten digits. For this we need some
|
||||
train_data and test_data. OpenCV comes with an image digits.png (in the folder
|
||||
opencv/samples/python2/data/) which has 5000 handwritten digits (500 for each digit). Each digit is
|
||||
opencv/samples/data/) which has 5000 handwritten digits (500 for each digit). Each digit is
|
||||
a 20x20 image. So our first step is to split this image into 5000 different digits. For each digit,
|
||||
we flatten it into a single row with 400 pixels. That is our feature set, ie intensity values of all
|
||||
pixels. It is the simplest feature set we can create. We use first 250 samples of each digit as
|
||||
|
BIN
doc/py_tutorials/py_photo/images/hdr_icon.jpg
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
doc/py_tutorials/py_photo/py_hdr/images/crf.jpg
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
doc/py_tutorials/py_photo/py_hdr/images/exposures.jpg
Normal file
After Width: | Height: | Size: 45 KiB |
BIN
doc/py_tutorials/py_photo/py_hdr/images/fusion_mertens.jpg
Normal file
After Width: | Height: | Size: 114 KiB |
BIN
doc/py_tutorials/py_photo/py_hdr/images/ldr_debvec.jpg
Normal file
After Width: | Height: | Size: 75 KiB |
BIN
doc/py_tutorials/py_photo/py_hdr/images/ldr_robertson.jpg
Normal file
After Width: | Height: | Size: 96 KiB |
177
doc/py_tutorials/py_photo/py_hdr/py_hdr.markdown
Normal file
@ -0,0 +1,177 @@
|
||||
High Dynamic Range (HDR) {#tutorial_py_hdr}
|
||||
========================
|
||||
|
||||
Goal
|
||||
----
|
||||
|
||||
In this chapter, we will
|
||||
|
||||
- Learn how to generate and display HDR image from an exposure sequence.
|
||||
- Use exposure fusion to merge an exposure sequence.
|
||||
|
||||
Theory
|
||||
------
|
||||
|
||||
High-dynamic-range imaging (HDRI or HDR) is a technique used in imaging and photography to reproduce
|
||||
a greater dynamic range of luminosity than is possible with standard digital imaging or photographic
|
||||
techniques. While the human eye can adjust to a wide range of light conditions, most imaging devices use 8-bits
|
||||
per channel, so we are limited to only 256 levels. When we take photographs of a real
|
||||
world scene, bright regions may be overexposed, while the dark ones may be underexposed, so we
|
||||
can’t capture all details using a single exposure. HDR imaging works with images that use more
|
||||
than 8 bits per channel (usually 32-bit float values), allowing much wider dynamic range.
|
||||
|
||||
There are different ways to obtain HDR images, but the most common one is to use photographs of
|
||||
the scene taken with different exposure values. To combine these exposures it is useful to know your
|
||||
camera’s response function and there are algorithms to estimate it. After the HDR image has been
|
||||
merged, it has to be converted back to 8-bit to view it on usual displays. This process is called
|
||||
tonemapping. Additional complexities arise when objects of the scene or camera move between shots,
|
||||
since images with different exposures should be registered and aligned.
|
||||
|
||||
In this tutorial we show 2 algorithms (Debvec, Robertson) to generate and display HDR image from an
|
||||
exposure sequence, and demonstrate an alternative approach called exposure fusion (Mertens), that
|
||||
produces low dynamic range image and does not need the exposure times data.
|
||||
Furthermore, we estimate the camera response function (CRF) which is of great value for many computer
|
||||
vision algorithms.
|
||||
Each step of HDR pipeline can be implemented using different algorithms and parameters, so take a
|
||||
look at the reference manual to see them all.
|
||||
|
||||
|
||||
Exposure sequence HDR
|
||||
---------------------
|
||||
|
||||
In this tutorial we will look on the following scene, where we have 4 exposure
|
||||
images, with exposure times of: 15, 2.5, 1/4 and 1/30 seconds. (You can download
|
||||
the images from [Wikipedia](https://en.wikipedia.org/wiki/High-dynamic-range_imaging))
|
||||
|
||||

|
||||
|
||||
### 1. Loading exposure images into a list
|
||||
|
||||
The first stage is simply loading all images into a list.
|
||||
In addition, we will need the exposure times for the regular HDR algorithms.
|
||||
Pay attention for the data types, as the images should be 1-channel or 3-channels
|
||||
8-bit (np.uint8) and the exposure times need to be float32 and in seconds.
|
||||
|
||||
@code{.py}
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
# Loading exposure images into a list
|
||||
img_fn = ["img0.jpg", "img1.jpg", "img2.jpg", "img3.jpg"]
|
||||
img_list = [cv2.imread(fn) for fn in img_fn]
|
||||
exposure_times = np.array([15.0, 2.5, 0.25, 0.0333], dtype=np.float32)
|
||||
@endcode
|
||||
|
||||
### 2. Merge exposures into HDR image
|
||||
|
||||
In this stage we merge the exposure sequence into one HDR image, showing 2 possibilities
|
||||
which we have in OpenCV. The first method is Debvec and the second one is Robertson.
|
||||
Notice that the HDR image is of type float32, and not uint8, as it contains the
|
||||
full dynamic range of all exposure images.
|
||||
|
||||
@code{.py}
|
||||
# Merge exposures to HDR image
|
||||
merge_debvec = cv2.createMergeDebevec()
|
||||
hdr_debvec = merge_debvec.process(img_list, times=exposure_times.copy())
|
||||
merge_robertson = cv2.createMergeRobertson()
|
||||
hdr_robertson = merge_robertson.process(img_list, times=exposure_times.copy())
|
||||
@endcode
|
||||
|
||||
### 3. Tonemap HDR image
|
||||
|
||||
We map the 32-bit float HDR data into the range [0..1].
|
||||
Actually, in some cases the values can be larger than 1 or lower the 0, so notice
|
||||
we will later have to clip the data in order to avoid overflow.
|
||||
|
||||
@code{.py}
|
||||
# Tonemap HDR image
|
||||
tonemap1 = cv2.createTonemapDurand(gamma=2.2)
|
||||
res_debvec = tonemap1.process(hdr_debvec.copy())
|
||||
tonemap2 = cv2.createTonemapDurand(gamma=1.3)
|
||||
res_robertson = tonemap2.process(hdr_robertson.copy())
|
||||
@endcode
|
||||
|
||||
### 4. Merge exposures using Mertens fusion
|
||||
|
||||
Here we show an alternative algorithm to merge the exposure images, where
|
||||
we do not need the exposure times. We also do not need to use any tonemap
|
||||
algorithm because the Mertens algorithm already gives us the result in the
|
||||
range of [0..1].
|
||||
|
||||
@code{.py}
|
||||
# Exposure fusion using Mertens
|
||||
merge_mertens = cv2.createMergeMertens()
|
||||
res_mertens = merge_mertens.process(img_list)
|
||||
@endcode
|
||||
|
||||
### 5. Convert to 8-bit and save
|
||||
|
||||
In order to save or display the results, we need to convert the data into 8-bit
|
||||
integers in the range of [0..255].
|
||||
|
||||
@code{.py}
|
||||
# Convert datatype to 8-bit and save
|
||||
res_debvec_8bit = np.clip(res_debvec*255, 0, 255).astype('uint8')
|
||||
res_robertson_8bit = np.clip(res_robertson*255, 0, 255).astype('uint8')
|
||||
res_mertens_8bit = np.clip(res_mertens*255, 0, 255).astype('uint8')
|
||||
|
||||
cv2.imwrite("ldr_debvec.jpg", res_debvec_8bit)
|
||||
cv2.imwrite("ldr_robertson.jpg", res_robertson_8bit)
|
||||
cv2.imwrite("fusion_mertens.jpg", res_mertens_8bit)
|
||||
@endcode
|
||||
|
||||
Results
|
||||
-------
|
||||
|
||||
You can see the different results but consider that each algorithm have additional
|
||||
extra parameters that you should fit to get your desired outcome. Best practice is
|
||||
to try the different methods and see which one performs best for your scene.
|
||||
|
||||
### Debvec:
|
||||
|
||||

|
||||
|
||||
### Robertson:
|
||||
|
||||

|
||||
|
||||
### Mertenes Fusion:
|
||||
|
||||

|
||||
|
||||
|
||||
Estimating Camera Response Function
|
||||
-----------------------------------
|
||||
|
||||
The camera response function (CRF) gives us the connection between the scene radiance
|
||||
to the measured intensity values. The CRF if of great importance in some computer vision
|
||||
algorithms, including HDR algorithms. Here we estimate the inverse camera response
|
||||
function and use it for the HDR merge.
|
||||
|
||||
@code{.py}
|
||||
# Estimate camera response function (CRF)
|
||||
cal_debvec = cv2.createCalibrateDebevec()
|
||||
crf_debvec = cal_debvec.process(img_list, times=exposure_times)
|
||||
hdr_debvec = merge_debvec.process(img_list, times=exposure_times.copy(), response=crf_debvec.copy())
|
||||
cal_robertson = cv2.createCalibrateRobertson()
|
||||
crf_robertson = cal_robertson.process(img_list, times=exposure_times)
|
||||
hdr_robertson = merge_robertson.process(img_list, times=exposure_times.copy(), response=crf_robertson.copy())
|
||||
@endcode
|
||||
|
||||
The camera response function is represented by a 256-length vector for each color channel.
|
||||
For this sequence we got the following estimation:
|
||||
|
||||

|
||||
|
||||
Additional Resources
|
||||
--------------------
|
||||
|
||||
1. Paul E Debevec and Jitendra Malik. Recovering high dynamic range radiance maps from photographs. In ACM SIGGRAPH 2008 classes, page 31. ACM, 2008.
|
||||
2. Mark A Robertson, Sean Borman, and Robert L Stevenson. Dynamic range improvement through multiple exposures. In Image Processing, 1999. ICIP 99. Proceedings. 1999 International Conference on, volume 3, pages 159–163. IEEE, 1999.
|
||||
3. Tom Mertens, Jan Kautz, and Frank Van Reeth. Exposure fusion. In Computer Graphics and Applications, 2007. PG'07. 15th Pacific Conference on, pages 382–390. IEEE, 2007.
|
||||
4. Images from [Wikipedia-HDR](https://en.wikipedia.org/wiki/High-dynamic-range_imaging)
|
||||
|
||||
Exercises
|
||||
---------
|
||||
1. Try all tonemap algorithms: [Drago](http://docs.opencv.org/master/da/d53/classcv_1_1TonemapDrago.html), [Durand](http://docs.opencv.org/master/da/d3d/classcv_1_1TonemapDurand.html), [Mantiuk](http://docs.opencv.org/master/de/d76/classcv_1_1TonemapMantiuk.html) and [Reinhard](http://docs.opencv.org/master/d0/dec/classcv_1_1TonemapReinhard.html).
|
||||
2. Try changing the parameters in the HDR calibration and tonemap methods.
|
@ -81,7 +81,7 @@ Additional Resources
|
||||
Exercises
|
||||
---------
|
||||
|
||||
-# OpenCV comes with an interactive sample on inpainting, samples/python2/inpaint.py, try it.
|
||||
-# OpenCV comes with an interactive sample on inpainting, samples/python/inpaint.py, try it.
|
||||
2. A few months ago, I watched a video on [Content-Aware
|
||||
Fill](http://www.youtube.com/watch?v=ZtoUiplKa2A), an advanced inpainting technique used in
|
||||
Adobe Photoshop. On further search, I was able to find that same technique is already there in
|
||||
|
@ -14,3 +14,7 @@ denoising etc.
|
||||
Do you have a old
|
||||
degraded photo with many black spots and strokes on it? Take it. Let's try to restore them with a
|
||||
technique called image inpainting.
|
||||
|
||||
- @subpage tutorial_py_hdr
|
||||
|
||||
Learn how to merge exposure sequence and process high dynamic range images.
|
||||
|
@ -156,7 +156,7 @@ in image, there is a chance that optical flow finds the next point which may loo
|
||||
actually for a robust tracking, corner points should be detected in particular intervals. OpenCV
|
||||
samples comes up with such a sample which finds the feature points at every 5 frames. It also run a
|
||||
backward-check of the optical flow points got to select only good ones. Check
|
||||
samples/python2/lk_track.py).
|
||||
samples/python/lk_track.py).
|
||||
|
||||
See the results we got:
|
||||
|
||||
@ -213,7 +213,7 @@ See the result below:
|
||||

|
||||
|
||||
OpenCV comes with a more advanced sample on dense optical flow, please see
|
||||
samples/python2/opt_flow.py.
|
||||
samples/python/opt_flow.py.
|
||||
|
||||
Additional Resources
|
||||
--------------------
|
||||
@ -221,5 +221,5 @@ Additional Resources
|
||||
Exercises
|
||||
---------
|
||||
|
||||
-# Check the code in samples/python2/lk_track.py. Try to understand the code.
|
||||
2. Check the code in samples/python2/opt_flow.py. Try to understand the code.
|
||||
-# Check the code in samples/python/lk_track.py. Try to understand the code.
|
||||
2. Check the code in samples/python/opt_flow.py. Try to understand the code.
|
||||
|
@ -75,7 +75,7 @@ int main( int argc, char** argv )
|
||||
std::vector< DMatch > good_matches;
|
||||
|
||||
for( int i = 0; i < descriptors_object.rows; i++ )
|
||||
{ if( matches[i].distance < 3*min_dist )
|
||||
{ if( matches[i].distance <= 3*min_dist )
|
||||
{ good_matches.push_back( matches[i]); }
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
High Level GUI and Media (highgui module) {#tutorial_table_of_content_highgui}
|
||||
=========================================
|
||||
|
||||
This section contains valuable tutorials about how to read/save your image/video files and how to
|
||||
use the built-in graphical user interface of the library.
|
||||
This section contains tutorials about how to use the built-in graphical user interface of the library.
|
||||
|
||||
- @subpage tutorial_trackbar
|
||||
|
||||
@ -11,33 +10,3 @@ use the built-in graphical user interface of the library.
|
||||
*Author:* Ana Huamán
|
||||
|
||||
We will learn how to add a Trackbar to our applications
|
||||
|
||||
- @subpage tutorial_video_input_psnr_ssim
|
||||
|
||||
*Compatibility:* \> OpenCV 2.0
|
||||
|
||||
*Author:* Bernát Gábor
|
||||
|
||||
You will learn how to read video streams, and how to calculate similarity values such as PSNR
|
||||
or SSIM.
|
||||
|
||||
- @subpage tutorial_video_write
|
||||
|
||||
*Compatibility:* \> OpenCV 2.0
|
||||
|
||||
*Author:* Bernát Gábor
|
||||
|
||||
Whenever you work with video feeds you may eventually want to save your image processing
|
||||
result in a form of a new video file. Here's how to do it.
|
||||
|
||||
- @subpage tutorial_raster_io_gdal
|
||||
|
||||
*Compatibility:* \> OpenCV 2.0
|
||||
|
||||
*Author:* Marvin Smith
|
||||
|
||||
Read common GIS Raster and DEM files to display and manipulate geographic data.
|
||||
|
||||
- @subpage tutorial_kinect_openni
|
||||
|
||||
- @subpage tutorial_intelperc
|
||||
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 111 KiB |
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB |
Before Width: | Height: | Size: 120 KiB After Width: | Height: | Size: 120 KiB |
@ -28,7 +28,7 @@ of the bay rise 10, 50, and 100 meters.
|
||||
Code
|
||||
----
|
||||
|
||||
@include cpp/tutorial_code/HighGUI/GDAL_IO/gdal-image.cpp
|
||||
@include cpp/tutorial_code/imgcodecs/GDAL_IO/gdal-image.cpp
|
||||
|
||||
How to Read Raster Data using GDAL
|
||||
----------------------------------
|
12
doc/tutorials/imgcodecs/table_of_content_highgui.markdown
Normal file
@ -0,0 +1,12 @@
|
||||
Image Input and Output (imgcodecs module) {#tutorial_table_of_content_imgcodecs}
|
||||
=========================================
|
||||
|
||||
This section contains tutorials about how to read/save your image files.
|
||||
|
||||
- @subpage tutorial_raster_io_gdal
|
||||
|
||||
*Compatibility:* \> OpenCV 2.0
|
||||
|
||||
*Author:* Marvin Smith
|
||||
|
||||
Read common GIS Raster and DEM files to display and manipulate geographic data.
|
@ -71,9 +71,9 @@ application. In contrast the *Release* is an optimized version, where the goal i
|
||||
application run as fast as possible or to be as small as possible. You may figure that these modes
|
||||
also require different rules to use during build. Therefore, there exist different rule packages for
|
||||
each of your build modes. These rule packages are called inside the IDE as *project properties* and
|
||||
you can view and modify them by using the *Property Manger*. You can bring up this with
|
||||
View --\> Property Pages. Expand it and you can see the existing rule packages (called *Proporty
|
||||
Sheets*).
|
||||
you can view and modify them by using the *Property Manager*. You can bring this up with
|
||||
View --\> Property Pages (For Visual Studio 2013 onwards, go to View --\> Other Windows --\> Property Manager).
|
||||
Expand it and you can see the existing rule packages (called *Property Sheets*).
|
||||
|
||||

|
||||
|
||||
|
@ -25,10 +25,17 @@ As always, we would be happy to hear your comments and receive your contribution
|
||||
|
||||
- @subpage tutorial_table_of_content_highgui
|
||||
|
||||
This section
|
||||
contains valuable tutorials about how to read/save your image/video files and how to use the
|
||||
This section contains valuable tutorials about how to use the
|
||||
built-in graphical user interface of the library.
|
||||
|
||||
- @subpage tutorial_table_of_content_imgcodecs
|
||||
|
||||
These tutorials show how to read and write images using imgcodecs module.
|
||||
|
||||
- @subpage tutorial_table_of_content_videoio
|
||||
|
||||
These tutorials show how to read and write videos using videio module.
|
||||
|
||||
- @subpage tutorial_table_of_content_calib3d
|
||||
|
||||
Although we got
|
||||
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.4 KiB |
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
23
doc/tutorials/videoio/table_of_content_videoio.markdown
Normal file
@ -0,0 +1,23 @@
|
||||
Video Input and Output (videoio module) {#tutorial_table_of_content_videoio}
|
||||
=========================================
|
||||
|
||||
This section contains tutorials about how to read/save your video files.
|
||||
|
||||
- @subpage tutorial_video_input_psnr_ssim
|
||||
|
||||
*Compatibility:* \> OpenCV 2.0
|
||||
|
||||
*Author:* Bernát Gábor
|
||||
|
||||
You will learn how to read video streams, and how to calculate similarity values such as PSNR
|
||||
or SSIM.
|
||||
|
||||
- @subpage tutorial_video_write
|
||||
|
||||
*Compatibility:* \> OpenCV 2.0
|
||||
|
||||
*Author:* Bernát Gábor
|
||||
|
||||
- @subpage tutorial_kinect_openni
|
||||
|
||||
- @subpage tutorial_intelperc
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
@ -20,12 +20,12 @@ As a test case where to show off these using OpenCV I've created a small program
|
||||
video files and performs a similarity check between them. This is something you could use to check
|
||||
just how well a new video compressing algorithms works. Let there be a reference (original) video
|
||||
like [this small Megamind clip
|
||||
](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/HighGUI/video-input-psnr-ssim/video/Megamind.avi) and [a compressed
|
||||
version of it ](https://github.com/Itseez/opencv/tree/master/samples/cpp/tutorial_code/HighGUI/video-input-psnr-ssim/video/Megamind_bugy.avi).
|
||||
](https://github.com/Itseez/opencv/tree/master/samples/data/Megamind.avi) and [a compressed
|
||||
version of it ](https://github.com/Itseez/opencv/tree/master/samples/data/Megamind_bugy.avi).
|
||||
You may also find the source code and these video file in the
|
||||
`samples/cpp/tutorial_code/HighGUI/video-input-psnr-ssim/` folder of the OpenCV source library.
|
||||
`samples/data` folder of the OpenCV source library.
|
||||
|
||||
@include cpp/tutorial_code/HighGUI/video-input-psnr-ssim/video-input-psnr-ssim.cpp
|
||||
@include cpp/tutorial_code/videoio/video-input-psnr-ssim/video-input-psnr-ssim.cpp
|
||||
|
||||
How to read a video stream (online-camera or offline-file)?
|
||||
-----------------------------------------------------------
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |