Merge remote-tracking branch 'remotes/origin/tm_sla_png_minz'
This commit is contained in:
commit
fc49abc2a4
23
deps/CMakeLists.txt
vendored
23
deps/CMakeLists.txt
vendored
@ -32,6 +32,7 @@ if (NPROC EQUAL 0)
|
||||
endif ()
|
||||
|
||||
set(DESTDIR "${CMAKE_CURRENT_BINARY_DIR}/destdir" CACHE PATH "Destination directory")
|
||||
|
||||
option(DEP_DEBUG "Build debug variants (only applicable on Windows)" ON)
|
||||
option(DEP_WX_STABLE "Build against wxWidgets stable 3.0 as opposed to default 3.1 (Linux only)" OFF)
|
||||
|
||||
@ -73,7 +74,9 @@ else ()
|
||||
include("deps-linux.cmake")
|
||||
endif()
|
||||
|
||||
add_custom_target(deps ALL
|
||||
if (MSVC)
|
||||
|
||||
add_custom_target(deps ALL
|
||||
DEPENDS
|
||||
dep_boost
|
||||
dep_tbb
|
||||
@ -81,8 +84,22 @@ add_custom_target(deps ALL
|
||||
dep_wxwidgets
|
||||
dep_gtest
|
||||
dep_nlopt
|
||||
dep_libpng
|
||||
)
|
||||
dep_zlib # on Windows we still need zlib
|
||||
)
|
||||
|
||||
else()
|
||||
|
||||
add_custom_target(deps ALL
|
||||
DEPENDS
|
||||
dep_boost
|
||||
dep_tbb
|
||||
dep_libcurl
|
||||
dep_wxwidgets
|
||||
dep_gtest
|
||||
dep_nlopt
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
# Note: I'm not using any of the LOG_xxx options in ExternalProject_Add() commands
|
||||
# because they seem to generate bogus build files (possibly a bug in ExternalProject).
|
||||
|
18
deps/deps-linux.cmake
vendored
18
deps/deps-linux.cmake
vendored
@ -3,7 +3,6 @@ set(DEP_CMAKE_OPTS "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
|
||||
|
||||
include("deps-unix-common.cmake")
|
||||
|
||||
|
||||
ExternalProject_Add(dep_boost
|
||||
EXCLUDE_FROM_ALL 1
|
||||
URL "https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.gz"
|
||||
@ -25,19 +24,6 @@ ExternalProject_Add(dep_boost
|
||||
INSTALL_COMMAND "" # b2 does that already
|
||||
)
|
||||
|
||||
ExternalProject_Add(dep_libpng
|
||||
EXCLUDE_FROM_ALL 1
|
||||
URL "https://github.com/glennrp/libpng/archive/v1.6.36.tar.gz"
|
||||
URL_HASH SHA256=5bef5a850a9255365a2dc344671b7e9ef810de491bd479c2506ac3c337e2d84f
|
||||
CMAKE_GENERATOR "${DEP_MSVC_GEN}"
|
||||
CMAKE_ARGS
|
||||
-DPNG_SHARED=OFF
|
||||
-DPNG_TESTS=OFF
|
||||
${DEP_CMAKE_OPTS}
|
||||
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
ExternalProject_Add(dep_libopenssl
|
||||
EXCLUDE_FROM_ALL 1
|
||||
URL "https://github.com/openssl/openssl/archive/OpenSSL_1_1_0g.tar.gz"
|
||||
@ -55,7 +41,7 @@ ExternalProject_Add(dep_libopenssl
|
||||
|
||||
ExternalProject_Add(dep_libcurl
|
||||
EXCLUDE_FROM_ALL 1
|
||||
DEPENDS dep_libopenssl
|
||||
DEPENDS dep_libopenssl
|
||||
URL "https://curl.haxx.se/download/curl-7.58.0.tar.gz"
|
||||
URL_HASH SHA256=cc245bf9a1a42a45df491501d97d5593392a03f7b4f07b952793518d97666115
|
||||
BUILD_IN_SOURCE 1
|
||||
@ -127,7 +113,7 @@ ExternalProject_Add(dep_wxwidgets
|
||||
--with-libxpm=builtin
|
||||
--with-libjpeg=builtin
|
||||
--with-libtiff=builtin
|
||||
--with-zlib=builtin
|
||||
--with-zlib
|
||||
--with-expat=builtin
|
||||
--disable-precomp-headers
|
||||
--enable-debug_info
|
||||
|
16
deps/deps-macos.cmake
vendored
16
deps/deps-macos.cmake
vendored
@ -87,20 +87,6 @@ ExternalProject_Add(dep_libcurl
|
||||
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
|
||||
)
|
||||
|
||||
ExternalProject_Add(dep_libpng
|
||||
EXCLUDE_FROM_ALL 1
|
||||
URL "https://github.com/glennrp/libpng/archive/v1.6.36.tar.gz"
|
||||
URL_HASH SHA256=5bef5a850a9255365a2dc344671b7e9ef810de491bd479c2506ac3c337e2d84f
|
||||
CMAKE_GENERATOR "${DEP_MSVC_GEN}"
|
||||
CMAKE_ARGS
|
||||
-DPNG_SHARED=OFF
|
||||
-DPNG_TESTS=OFF
|
||||
${DEP_CMAKE_OPTS}
|
||||
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
|
||||
ExternalProject_Add(dep_wxwidgets
|
||||
EXCLUDE_FROM_ALL 1
|
||||
URL "https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.2/wxWidgets-3.1.2.tar.bz2"
|
||||
@ -119,7 +105,7 @@ ExternalProject_Add(dep_wxwidgets
|
||||
--with-libxpm=builtin
|
||||
--with-libjpeg=builtin
|
||||
--with-libtiff=builtin
|
||||
--with-zlib=builtin
|
||||
--with-zlib
|
||||
--with-expat=builtin
|
||||
--disable-debug
|
||||
--disable-debug_flag
|
||||
|
9
deps/deps-unix-common.cmake
vendored
9
deps/deps-unix-common.cmake
vendored
@ -8,30 +8,27 @@ ExternalProject_Add(dep_tbb
|
||||
CMAKE_ARGS
|
||||
-DTBB_BUILD_SHARED=OFF
|
||||
-DTBB_BUILD_TESTS=OFF
|
||||
-DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
|
||||
${DEP_CMAKE_OPTS}
|
||||
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
|
||||
)
|
||||
|
||||
ExternalProject_Add(dep_gtest
|
||||
EXCLUDE_FROM_ALL 1
|
||||
URL "https://github.com/google/googletest/archive/release-1.8.1.tar.gz"
|
||||
URL_HASH SHA256=9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c
|
||||
CMAKE_ARGS -DBUILD_GMOCK=OFF ${DEP_CMAKE_OPTS}
|
||||
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
|
||||
CMAKE_ARGS -DBUILD_GMOCK=OFF ${DEP_CMAKE_OPTS} -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
|
||||
)
|
||||
|
||||
ExternalProject_Add(dep_nlopt
|
||||
EXCLUDE_FROM_ALL 1
|
||||
URL "https://github.com/stevengj/nlopt/archive/v2.5.0.tar.gz"
|
||||
URL_HASH SHA256=c6dd7a5701fff8ad5ebb45a3dc8e757e61d52658de3918e38bab233e7fd3b4ae
|
||||
CMAKE_GENERATOR "${DEP_MSVC_GEN}"
|
||||
CMAKE_ARGS
|
||||
-DBUILD_SHARED_LIBS=OFF
|
||||
-DNLOPT_PYTHON=OFF
|
||||
-DNLOPT_OCTAVE=OFF
|
||||
-DNLOPT_MATLAB=OFF
|
||||
-DNLOPT_GUILE=OFF
|
||||
-DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
|
||||
${DEP_CMAKE_OPTS}
|
||||
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
40
deps/deps-windows.cmake
vendored
40
deps/deps-windows.cmake
vendored
@ -165,46 +165,6 @@ if (${DEP_DEBUG})
|
||||
endif ()
|
||||
|
||||
|
||||
ExternalProject_Add(dep_libpng
|
||||
DEPENDS dep_zlib
|
||||
EXCLUDE_FROM_ALL 1
|
||||
URL "https://github.com/glennrp/libpng/archive/v1.6.36.tar.gz"
|
||||
URL_HASH SHA256=5bef5a850a9255365a2dc344671b7e9ef810de491bd479c2506ac3c337e2d84f
|
||||
CMAKE_GENERATOR "${DEP_MSVC_GEN}"
|
||||
CMAKE_ARGS
|
||||
-DPNG_SHARED=OFF
|
||||
-DPNG_TESTS=OFF
|
||||
-DSKIP_INSTALL_FILES=ON # Prevent installation of man pages et al.
|
||||
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
|
||||
"-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
|
||||
BUILD_COMMAND msbuild /P:Configuration=Release INSTALL.vcxproj
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
if (${DEP_DEBUG})
|
||||
ExternalProject_Get_Property(dep_libpng BINARY_DIR)
|
||||
ExternalProject_Add_Step(dep_libpng build_debug
|
||||
DEPENDEES build
|
||||
DEPENDERS install
|
||||
COMMAND msbuild /P:Configuration=Debug INSTALL.vcxproj
|
||||
WORKING_DIRECTORY "${BINARY_DIR}"
|
||||
)
|
||||
endif ()
|
||||
# The following steps are unfortunately needed to remove the _static suffix on libraries
|
||||
# (And also overwrite the dynamic .lib)
|
||||
ExternalProject_Add_Step(dep_libpng fix_static
|
||||
DEPENDEES install
|
||||
COMMAND "${CMAKE_COMMAND}" -E rename libpng16_static.lib libpng16.lib
|
||||
WORKING_DIRECTORY "${DESTDIR}\\usr\\local\\lib\\"
|
||||
)
|
||||
if (${DEP_DEBUG})
|
||||
ExternalProject_Add_Step(dep_libpng fix_static_debug
|
||||
DEPENDEES install
|
||||
COMMAND "${CMAKE_COMMAND}" -E rename libpng16_staticd.lib libpng16d.lib
|
||||
WORKING_DIRECTORY "${DESTDIR}\\usr\\local\\lib\\"
|
||||
)
|
||||
endif ()
|
||||
|
||||
|
||||
if (${DEPS_BITS} EQUAL 32)
|
||||
set(DEP_LIBCURL_TARGET "x86")
|
||||
else ()
|
||||
|
@ -21,30 +21,6 @@ add_subdirectory(libnest2d)
|
||||
include_directories(${LIBDIR}/qhull/src)
|
||||
#message(STATUS ${LIBDIR}/qhull/src)
|
||||
|
||||
# ##############################################################################
|
||||
# Configure rasterizer target
|
||||
# ##############################################################################
|
||||
|
||||
find_package(PNG QUIET)
|
||||
|
||||
option(RASTERIZER_FORCE_BUILTIN_LIBPNG "Force the usage of builting libpng instead of the system version." OFF)
|
||||
|
||||
if(PNG_FOUND AND NOT RASTERIZER_FORCE_BUILTIN_LIBPNG)
|
||||
message(STATUS "Using system libpng.")
|
||||
else()
|
||||
set(ZLIB_LIBRARY "")
|
||||
message(WARNING "Using builtin libpng. This can cause crashes on some platforms.")
|
||||
set(SKIP_INSTALL_ALL 1) # Prevent png+zlib from creating install targets
|
||||
add_subdirectory(png/zlib)
|
||||
set(ZLIB_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/png/zlib ${CMAKE_CURRENT_BINARY_DIR}/png/zlib)
|
||||
include_directories(${ZLIB_INCLUDE_DIR})
|
||||
add_subdirectory(png/libpng)
|
||||
set_target_properties(zlibstatic PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
set_target_properties(png_static PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
set(PNG_LIBRARIES png_static zlibstatic)
|
||||
set(PNG_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/png/libpng ${CMAKE_CURRENT_BINARY_DIR}/png/libpng)
|
||||
endif()
|
||||
|
||||
add_subdirectory(libslic3r)
|
||||
|
||||
if (SLIC3R_GUI)
|
||||
@ -65,6 +41,7 @@ if (SLIC3R_GUI)
|
||||
find_package(wxWidgets 3.0 REQUIRED COMPONENTS base core adv html gl)
|
||||
else ()
|
||||
find_package(wxWidgets 3.1 QUIET COMPONENTS base core adv html gl)
|
||||
|
||||
if (NOT wxWidgets_FOUND)
|
||||
message(FATAL_ERROR "\nCould not find wxWidgets 3.1.\n"
|
||||
"Hint: On Linux you can set -DSLIC3R_WX_STABLE=1 to use wxWidgets 3.0\n")
|
||||
@ -116,12 +93,13 @@ endif ()
|
||||
|
||||
# Add the Slic3r GUI library, libcurl, OpenGL and GLU libraries.
|
||||
if (SLIC3R_GUI)
|
||||
target_link_libraries(slic3r libslic3r_gui ${wxWidgets_LIBRARIES})
|
||||
target_link_libraries(slic3r libslic3r_gui ${wxWidgets_LIBRARIES})
|
||||
|
||||
# Configure libcurl & OpenSSL
|
||||
# Configure libcurl and its dependencies OpenSSL & zlib
|
||||
find_package(CURL REQUIRED)
|
||||
find_package(ZLIB REQUIRED)
|
||||
target_include_directories(slic3r PRIVATE ${CURL_INCLUDE_DIRS})
|
||||
target_link_libraries(slic3r CURL::libcurl)
|
||||
target_link_libraries(slic3r ${CURL_LIBRARIES} ${ZLIB_LIBRARIES})
|
||||
if (SLIC3R_STATIC)
|
||||
if (NOT APPLE)
|
||||
# libcurl is always linked dynamically to the system libcurl on OSX.
|
||||
@ -189,7 +167,7 @@ if (MSVC)
|
||||
)
|
||||
endif ()
|
||||
elseif (XCODE)
|
||||
# Because of Debug/Release/etc. configurations (similar to MSVC) the slic3r binary is located in an extra level
|
||||
# Because of Debug/Release/etc. configurations (similar to MSVC) the slic3r binary is located in an extra level
|
||||
add_custom_command(TARGET slic3r POST_BUILD
|
||||
COMMAND ln -sf "${SLIC3R_RESOURCES_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/resources"
|
||||
COMMENT "Symlinking the resources directory into the build tree"
|
||||
|
@ -161,6 +161,8 @@ add_library(libslic3r STATIC
|
||||
utils.cpp
|
||||
Utils.hpp
|
||||
MTUtils.hpp
|
||||
Zipper.hpp
|
||||
Zipper.cpp
|
||||
SLA/SLABoilerPlate.hpp
|
||||
SLA/SLABasePool.hpp
|
||||
SLA/SLABasePool.cpp
|
||||
@ -177,8 +179,8 @@ if (SLIC3R_PCH AND NOT SLIC3R_SYNTAXONLY)
|
||||
add_precompiled_header(libslic3r pchheader.hpp FORCEINCLUDE)
|
||||
endif ()
|
||||
|
||||
target_compile_definitions(libslic3r PUBLIC -DUSE_TBB ${PNG_DEFINITIONS})
|
||||
target_include_directories(libslic3r PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${LIBNEST2D_INCLUDES} ${PNG_INCLUDE_DIRS} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_compile_definitions(libslic3r PUBLIC -DUSE_TBB)
|
||||
target_include_directories(libslic3r PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${LIBNEST2D_INCLUDES} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_link_libraries(libslic3r
|
||||
libnest2d
|
||||
admesh
|
||||
@ -188,7 +190,6 @@ target_link_libraries(libslic3r
|
||||
nowide
|
||||
${EXPAT_LIBRARIES}
|
||||
${GLEW_LIBRARIES}
|
||||
${PNG_LIBRARIES}
|
||||
glu-libtess
|
||||
polypartition
|
||||
poly2tri
|
||||
|
@ -93,11 +93,15 @@ public:
|
||||
|
||||
void next_entry(const std::string& /*fname*/) {}
|
||||
|
||||
// binary entry
|
||||
void binary_entry(const std::string& /*fname*/,
|
||||
const std::uint8_t* buf, size_t len);
|
||||
|
||||
std::string get_name() { return ""; }
|
||||
|
||||
bool is_ok() { return false; }
|
||||
|
||||
template<class T> LayerWriter& operator<<(const T& /*arg*/) {
|
||||
template<class T> LayerWriter& operator<<(T&& /*arg*/) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -110,14 +114,14 @@ public:
|
||||
template<> class FilePrinter<FilePrinterFormat::SLA_PNGZIP>
|
||||
{
|
||||
struct Layer {
|
||||
Raster first;
|
||||
std::stringstream second;
|
||||
Raster raster;
|
||||
RawBytes rawbytes;
|
||||
|
||||
Layer() {}
|
||||
|
||||
Layer(const Layer&) = delete;
|
||||
Layer(Layer&& m):
|
||||
first(std::move(m.first))/*, second(std::move(m.second))*/ {}
|
||||
raster(std::move(m.raster)) {}
|
||||
};
|
||||
|
||||
// We will save the compressed PNG data into stringstreams which can be done
|
||||
@ -135,14 +139,11 @@ template<> class FilePrinter<FilePrinterFormat::SLA_PNGZIP>
|
||||
int m_cnt_fast_layers = 0;
|
||||
|
||||
std::string createIniContent(const std::string& projectname) {
|
||||
// double layer_height = m_layer_height;
|
||||
|
||||
using std::string;
|
||||
using std::to_string;
|
||||
|
||||
auto expt_str = to_string(m_exp_time_s);
|
||||
auto expt_first_str = to_string(m_exp_time_first_s);
|
||||
// auto stepnum_str = to_string(static_cast<unsigned>(800*layer_height));
|
||||
auto layerh_str = to_string(m_layer_height);
|
||||
|
||||
const std::string cnt_fade_layers = to_string(m_cnt_fade_layers);
|
||||
@ -211,31 +212,31 @@ public:
|
||||
|
||||
inline void draw_polygon(const ExPolygon& p, unsigned lyr) {
|
||||
assert(lyr < m_layers_rst.size());
|
||||
m_layers_rst[lyr].first.draw(p);
|
||||
m_layers_rst[lyr].raster.draw(p);
|
||||
}
|
||||
|
||||
inline void begin_layer(unsigned lyr) {
|
||||
if(m_layers_rst.size() <= lyr) m_layers_rst.resize(lyr+1);
|
||||
m_layers_rst[lyr].first.reset(m_res, m_pxdim, m_o);
|
||||
m_layers_rst[lyr].raster.reset(m_res, m_pxdim, m_o);
|
||||
}
|
||||
|
||||
inline void begin_layer() {
|
||||
m_layers_rst.emplace_back();
|
||||
m_layers_rst.front().first.reset(m_res, m_pxdim, m_o);
|
||||
m_layers_rst.front().raster.reset(m_res, m_pxdim, m_o);
|
||||
}
|
||||
|
||||
inline void finish_layer(unsigned lyr_id) {
|
||||
assert(lyr_id < m_layers_rst.size());
|
||||
m_layers_rst[lyr_id].first.save(m_layers_rst[lyr_id].second,
|
||||
Raster::Compression::PNG);
|
||||
m_layers_rst[lyr_id].first.reset();
|
||||
m_layers_rst[lyr_id].rawbytes =
|
||||
m_layers_rst[lyr_id].raster.save(Raster::Compression::PNG);
|
||||
m_layers_rst[lyr_id].raster.reset();
|
||||
}
|
||||
|
||||
inline void finish_layer() {
|
||||
if(!m_layers_rst.empty()) {
|
||||
m_layers_rst.back().first.save(m_layers_rst.back().second,
|
||||
Raster::Compression::PNG);
|
||||
m_layers_rst.back().first.reset();
|
||||
m_layers_rst.back().rawbytes =
|
||||
m_layers_rst.back().raster.save(Raster::Compression::PNG);
|
||||
m_layers_rst.back().raster.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,20 +255,19 @@ public:
|
||||
|
||||
for(unsigned i = 0; i < m_layers_rst.size() && writer.is_ok(); i++)
|
||||
{
|
||||
if(m_layers_rst[i].second.rdbuf()->in_avail() > 0) {
|
||||
if(m_layers_rst[i].rawbytes.size() > 0) {
|
||||
char lyrnum[6];
|
||||
std::sprintf(lyrnum, "%.5d", i);
|
||||
auto zfilename = project + lyrnum + ".png";
|
||||
writer.next_entry(zfilename);
|
||||
|
||||
if(!writer.is_ok()) break;
|
||||
|
||||
writer << m_layers_rst[i].second.str();
|
||||
// writer << m_layers_rst[i].second.rdbuf();
|
||||
// we can keep the date for later calls of this method
|
||||
//m_layers_rst[i].second.str("");
|
||||
writer.binary_entry(zfilename,
|
||||
m_layers_rst[i].rawbytes.data(),
|
||||
m_layers_rst[i].rawbytes.size());
|
||||
}
|
||||
}
|
||||
|
||||
writer.close();
|
||||
} catch(std::exception& e) {
|
||||
BOOST_LOG_TRIVIAL(error) << e.what();
|
||||
// Rethrow the exception
|
||||
@ -285,13 +285,13 @@ public:
|
||||
|
||||
std::fstream out(loc, std::fstream::out | std::fstream::binary);
|
||||
if(out.good()) {
|
||||
m_layers_rst[i].first.save(out, Raster::Compression::PNG);
|
||||
m_layers_rst[i].raster.save(out, Raster::Compression::PNG);
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(error) << "Can't create file for layer";
|
||||
}
|
||||
|
||||
out.close();
|
||||
m_layers_rst[i].first.reset();
|
||||
m_layers_rst[i].raster.reset();
|
||||
}
|
||||
|
||||
void set_statistics(const std::vector<double> statistics)
|
||||
|
@ -1,8 +1,6 @@
|
||||
#include "Rasterizer.hpp"
|
||||
#include <ExPolygon.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
// For rasterizing
|
||||
#include <agg/agg_basics.h>
|
||||
#include <agg/agg_rendering_buffer.h>
|
||||
@ -15,8 +13,8 @@
|
||||
#include <agg/agg_rasterizer_scanline_aa.h>
|
||||
#include <agg/agg_path_storage.h>
|
||||
|
||||
// For png compression
|
||||
#include <png/writer.hpp>
|
||||
// Experimental minz image write:
|
||||
#include <miniz/miniz_tdef.h>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
@ -178,29 +176,23 @@ void Raster::draw(const ExPolygon &poly)
|
||||
void Raster::save(std::ostream& stream, Compression comp)
|
||||
{
|
||||
assert(m_impl);
|
||||
if(!stream.good()) return;
|
||||
|
||||
switch(comp) {
|
||||
case Compression::PNG: {
|
||||
|
||||
png::writer<std::ostream> wr(stream);
|
||||
|
||||
wr.set_bit_depth(8);
|
||||
wr.set_color_type(png::color_type_gray);
|
||||
wr.set_width(resolution().width_px);
|
||||
wr.set_height(resolution().height_px);
|
||||
wr.set_compression_type(png::compression_type_default);
|
||||
|
||||
wr.write_info();
|
||||
|
||||
auto& b = m_impl->buffer();
|
||||
auto ptr = reinterpret_cast<png::byte*>( b.data() );
|
||||
unsigned stride =
|
||||
sizeof(Impl::TBuffer::value_type) * resolution().width_px;
|
||||
size_t out_len = 0;
|
||||
void * rawdata = tdefl_write_image_to_png_file_in_memory(
|
||||
b.data(),
|
||||
int(resolution().width_px),
|
||||
int(resolution().height_px), 1, &out_len);
|
||||
|
||||
for(unsigned r = 0; r < resolution().height_px; r++, ptr+=stride) {
|
||||
wr.write_row(ptr);
|
||||
}
|
||||
if(rawdata == nullptr) break;
|
||||
|
||||
wr.write_end_info();
|
||||
stream.write(static_cast<const char*>(rawdata),
|
||||
std::streamsize(out_len));
|
||||
|
||||
MZ_FREE(rawdata);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -217,4 +209,47 @@ void Raster::save(std::ostream& stream, Compression comp)
|
||||
}
|
||||
}
|
||||
|
||||
RawBytes Raster::save(Raster::Compression comp)
|
||||
{
|
||||
assert(m_impl);
|
||||
|
||||
std::uint8_t *ptr = nullptr; size_t s = 0;
|
||||
|
||||
switch(comp) {
|
||||
case Compression::PNG: {
|
||||
|
||||
void *rawdata = tdefl_write_image_to_png_file_in_memory(
|
||||
m_impl->buffer().data(),
|
||||
int(resolution().width_px),
|
||||
int(resolution().height_px), 1, &s);
|
||||
|
||||
if(rawdata == nullptr) break;
|
||||
|
||||
ptr = static_cast<std::uint8_t*>(rawdata);
|
||||
|
||||
break;
|
||||
}
|
||||
case Compression::RAW: {
|
||||
auto header = std::string("P5 ") +
|
||||
std::to_string(m_impl->resolution().width_px) + " " +
|
||||
std::to_string(m_impl->resolution().height_px) + " " + "255 ";
|
||||
|
||||
auto sz = m_impl->buffer().size()*sizeof(Impl::TBuffer::value_type);
|
||||
|
||||
s = sz + header.size();
|
||||
ptr = static_cast<std::uint8_t*>(MZ_MALLOC(s));
|
||||
|
||||
auto buff = reinterpret_cast<std::uint8_t*>(m_impl->buffer().data());
|
||||
std::copy(buff, buff+sz, ptr + header.size());
|
||||
}
|
||||
}
|
||||
|
||||
return {ptr, s};
|
||||
}
|
||||
|
||||
void RawBytes::MinzDeleter::operator()(uint8_t *rawptr)
|
||||
{
|
||||
MZ_FREE(rawptr);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,11 +3,50 @@
|
||||
|
||||
#include <ostream>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class ExPolygon;
|
||||
|
||||
// Raw byte buffer paired with its size. Suitable for compressed PNG data.
|
||||
class RawBytes {
|
||||
|
||||
class MinzDeleter {
|
||||
public:
|
||||
void operator()(std::uint8_t *rawptr);
|
||||
};
|
||||
|
||||
std::unique_ptr<std::uint8_t, MinzDeleter> m_buffer = nullptr;
|
||||
size_t m_size = 0;
|
||||
|
||||
public:
|
||||
|
||||
RawBytes() = default;
|
||||
RawBytes(std::uint8_t *rawptr, size_t s): m_buffer(rawptr), m_size(s) {}
|
||||
|
||||
size_t size() const { return m_size; }
|
||||
const uint8_t * data() { return m_buffer.get(); }
|
||||
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
// FIXME: the following is needed for MSVC2013 compatibility
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
|
||||
RawBytes(const RawBytes&) = delete;
|
||||
RawBytes(RawBytes&& mv):
|
||||
m_buffer(std::move(mv.m_buffer)), m_size(mv.m_size) {}
|
||||
|
||||
RawBytes& operator=(const RawBytes&) = delete;
|
||||
RawBytes& operator=(RawBytes&& mv) {
|
||||
m_buffer.swap(mv.m_buffer);
|
||||
m_size = mv.m_size;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Raster captures an anti-aliased monochrome canvas where vectorial
|
||||
* polygons can be rasterized. Fill color is always white and the background is
|
||||
@ -87,6 +126,8 @@ public:
|
||||
|
||||
/// Save the raster on the specified stream.
|
||||
void save(std::ostream& stream, Compression comp = Compression::RAW);
|
||||
|
||||
RawBytes save(Compression comp = Compression::RAW);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "PrintExport.hpp"
|
||||
#include "Point.hpp"
|
||||
#include "MTUtils.hpp"
|
||||
#include <iterator>
|
||||
#include "Zipper.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
@ -315,6 +315,39 @@ struct SLAPrintStatistics
|
||||
}
|
||||
};
|
||||
|
||||
struct SLAminzZipper {};
|
||||
|
||||
// The implementation of creating zipped archives with wxWidgets
|
||||
template<> class LayerWriter<SLAminzZipper> {
|
||||
Zipper m_zip;
|
||||
public:
|
||||
|
||||
inline LayerWriter(const std::string& zipfile_path): m_zip(zipfile_path) {}
|
||||
|
||||
inline void next_entry(const std::string& fname) { m_zip.add_entry(fname); }
|
||||
|
||||
inline void binary_entry(const std::string& fname,
|
||||
const std::uint8_t* buf,
|
||||
size_t l)
|
||||
{
|
||||
m_zip.add_entry(fname, buf, l);
|
||||
}
|
||||
|
||||
inline std::string get_name() const {
|
||||
return m_zip.get_name();
|
||||
}
|
||||
|
||||
template<class T> inline LayerWriter& operator<<(T&& arg) {
|
||||
m_zip << std::forward<T>(arg); return *this;
|
||||
}
|
||||
|
||||
bool is_ok() const {
|
||||
return true; // m_zip blows up if something goes wrong...
|
||||
}
|
||||
|
||||
inline void close() { m_zip.close(); }
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This class is the high level FSM for the SLA printing process.
|
||||
*
|
||||
@ -372,9 +405,11 @@ public:
|
||||
// Returns true if the last step was finished with success.
|
||||
bool finished() const override { return this->is_step_done(slaposIndexSlices) && this->Inherited::is_step_done(slapsRasterize); }
|
||||
|
||||
template<class Fmt> void export_raster(const std::string& fname) {
|
||||
template<class Fmt = SLAminzZipper>
|
||||
void export_raster(const std::string& fname) {
|
||||
if(m_printer) m_printer->save<Fmt>(fname);
|
||||
}
|
||||
|
||||
const PrintObjects& objects() const { return m_objects; }
|
||||
|
||||
const SLAPrintConfig& print_config() const { return m_print_config; }
|
||||
|
209
src/libslic3r/Zipper.cpp
Normal file
209
src/libslic3r/Zipper.cpp
Normal file
@ -0,0 +1,209 @@
|
||||
#include <exception>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
#include "Zipper.hpp"
|
||||
#include "miniz/miniz_zip.h"
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
#include "I18N.hpp"
|
||||
|
||||
//! macro used to mark string used at localization,
|
||||
//! return same string
|
||||
#define L(s) Slic3r::I18N::translate(s)
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1800 || __cplusplus < 201103L
|
||||
#define SLIC3R_NORETURN
|
||||
#elif __cplusplus >= 201103L
|
||||
#define SLIC3R_NORETURN [[noreturn]]
|
||||
#endif
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class Zipper::Impl {
|
||||
public:
|
||||
mz_zip_archive arch;
|
||||
std::string m_zipname;
|
||||
|
||||
static std::string get_errorstr(mz_zip_error mz_err)
|
||||
{
|
||||
switch (mz_err)
|
||||
{
|
||||
case MZ_ZIP_NO_ERROR:
|
||||
return "no error";
|
||||
case MZ_ZIP_UNDEFINED_ERROR:
|
||||
return L("undefined error");
|
||||
case MZ_ZIP_TOO_MANY_FILES:
|
||||
return L("too many files");
|
||||
case MZ_ZIP_FILE_TOO_LARGE:
|
||||
return L("file too large");
|
||||
case MZ_ZIP_UNSUPPORTED_METHOD:
|
||||
return L("unsupported method");
|
||||
case MZ_ZIP_UNSUPPORTED_ENCRYPTION:
|
||||
return L("unsupported encryption");
|
||||
case MZ_ZIP_UNSUPPORTED_FEATURE:
|
||||
return L("unsupported feature");
|
||||
case MZ_ZIP_FAILED_FINDING_CENTRAL_DIR:
|
||||
return L("failed finding central directory");
|
||||
case MZ_ZIP_NOT_AN_ARCHIVE:
|
||||
return L("not a ZIP archive");
|
||||
case MZ_ZIP_INVALID_HEADER_OR_CORRUPTED:
|
||||
return L("invalid header or archive is corrupted");
|
||||
case MZ_ZIP_UNSUPPORTED_MULTIDISK:
|
||||
return L("unsupported multidisk archive");
|
||||
case MZ_ZIP_DECOMPRESSION_FAILED:
|
||||
return L("decompression failed or archive is corrupted");
|
||||
case MZ_ZIP_COMPRESSION_FAILED:
|
||||
return L("compression failed");
|
||||
case MZ_ZIP_UNEXPECTED_DECOMPRESSED_SIZE:
|
||||
return L("unexpected decompressed size");
|
||||
case MZ_ZIP_CRC_CHECK_FAILED:
|
||||
return L("CRC-32 check failed");
|
||||
case MZ_ZIP_UNSUPPORTED_CDIR_SIZE:
|
||||
return L("unsupported central directory size");
|
||||
case MZ_ZIP_ALLOC_FAILED:
|
||||
return L("allocation failed");
|
||||
case MZ_ZIP_FILE_OPEN_FAILED:
|
||||
return L("file open failed");
|
||||
case MZ_ZIP_FILE_CREATE_FAILED:
|
||||
return L("file create failed");
|
||||
case MZ_ZIP_FILE_WRITE_FAILED:
|
||||
return L("file write failed");
|
||||
case MZ_ZIP_FILE_READ_FAILED:
|
||||
return L("file read failed");
|
||||
case MZ_ZIP_FILE_CLOSE_FAILED:
|
||||
return L("file close failed");
|
||||
case MZ_ZIP_FILE_SEEK_FAILED:
|
||||
return L("file seek failed");
|
||||
case MZ_ZIP_FILE_STAT_FAILED:
|
||||
return L("file stat failed");
|
||||
case MZ_ZIP_INVALID_PARAMETER:
|
||||
return L("invalid parameter");
|
||||
case MZ_ZIP_INVALID_FILENAME:
|
||||
return L("invalid filename");
|
||||
case MZ_ZIP_BUF_TOO_SMALL:
|
||||
return L("buffer too small");
|
||||
case MZ_ZIP_INTERNAL_ERROR:
|
||||
return L("internal error");
|
||||
case MZ_ZIP_FILE_NOT_FOUND:
|
||||
return L("file not found");
|
||||
case MZ_ZIP_ARCHIVE_TOO_LARGE:
|
||||
return L("archive is too large");
|
||||
case MZ_ZIP_VALIDATION_FAILED:
|
||||
return L("validation failed");
|
||||
case MZ_ZIP_WRITE_CALLBACK_FAILED:
|
||||
return L("write calledback failed");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return "unknown error";
|
||||
}
|
||||
|
||||
std::string formatted_errorstr() const
|
||||
{
|
||||
return L("Error with zip archive") + " " + m_zipname + ": " +
|
||||
get_errorstr(arch.m_last_error) + "!";
|
||||
}
|
||||
|
||||
SLIC3R_NORETURN void blow_up() const
|
||||
{
|
||||
throw std::runtime_error(formatted_errorstr());
|
||||
}
|
||||
};
|
||||
|
||||
Zipper::Zipper(const std::string &zipfname, e_compression compression)
|
||||
{
|
||||
m_impl.reset(new Impl());
|
||||
|
||||
m_compression = compression;
|
||||
m_impl->m_zipname = zipfname;
|
||||
|
||||
memset(&m_impl->arch, 0, sizeof(m_impl->arch));
|
||||
|
||||
// Initialize the archive data
|
||||
if(!mz_zip_writer_init_file(&m_impl->arch, zipfname.c_str(), 0))
|
||||
m_impl->blow_up();
|
||||
}
|
||||
|
||||
Zipper::~Zipper()
|
||||
{
|
||||
try {
|
||||
close();
|
||||
} catch(...) {
|
||||
BOOST_LOG_TRIVIAL(error) << m_impl->formatted_errorstr();
|
||||
}
|
||||
}
|
||||
|
||||
Zipper::Zipper(Zipper &&m):
|
||||
m_impl(std::move(m.m_impl)),
|
||||
m_data(std::move(m.m_data)),
|
||||
m_entry(std::move(m.m_entry)),
|
||||
m_compression(m.m_compression) {}
|
||||
|
||||
Zipper &Zipper::operator=(Zipper &&m) {
|
||||
m_impl = std::move(m.m_impl);
|
||||
m_data = std::move(m.m_data);
|
||||
m_entry = std::move(m.m_entry);
|
||||
m_compression = m.m_compression;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Zipper::add_entry(const std::string &name)
|
||||
{
|
||||
finish_entry(); // finish previous business
|
||||
m_entry = name;
|
||||
}
|
||||
|
||||
void Zipper::add_entry(const std::string &name, const uint8_t *data, size_t l)
|
||||
{
|
||||
finish_entry();
|
||||
mz_uint cmpr = MZ_NO_COMPRESSION;
|
||||
switch (m_compression) {
|
||||
case NO_COMPRESSION: cmpr = MZ_NO_COMPRESSION; break;
|
||||
case FAST_COMPRESSION: cmpr = MZ_BEST_SPEED; break;
|
||||
case TIGHT_COMPRESSION: cmpr = MZ_BEST_COMPRESSION; break;
|
||||
}
|
||||
|
||||
if(!mz_zip_writer_add_mem(&m_impl->arch, name.c_str(), data, l, cmpr))
|
||||
m_impl->blow_up();
|
||||
|
||||
m_entry.clear();
|
||||
m_data.clear();
|
||||
}
|
||||
|
||||
void Zipper::finish_entry()
|
||||
{
|
||||
if(!m_data.empty() > 0 && !m_entry.empty()) {
|
||||
mz_uint compression = MZ_NO_COMPRESSION;
|
||||
|
||||
switch (m_compression) {
|
||||
case NO_COMPRESSION: compression = MZ_NO_COMPRESSION; break;
|
||||
case FAST_COMPRESSION: compression = MZ_BEST_SPEED; break;
|
||||
case TIGHT_COMPRESSION: compression = MZ_BEST_COMPRESSION; break;
|
||||
}
|
||||
|
||||
if(!mz_zip_writer_add_mem(&m_impl->arch, m_entry.c_str(),
|
||||
m_data.c_str(),
|
||||
m_data.size(),
|
||||
compression)) m_impl->blow_up();
|
||||
}
|
||||
|
||||
m_data.clear();
|
||||
m_entry.clear();
|
||||
}
|
||||
|
||||
std::string Zipper::get_name() const {
|
||||
return boost::filesystem::path(m_impl->m_zipname).stem().string();
|
||||
}
|
||||
|
||||
void Zipper::close()
|
||||
{
|
||||
finish_entry();
|
||||
|
||||
if(!mz_zip_writer_finalize_archive(&m_impl->arch)) m_impl->blow_up();
|
||||
if(!mz_zip_writer_end(&m_impl->arch)) m_impl->blow_up();
|
||||
}
|
||||
|
||||
}
|
88
src/libslic3r/Zipper.hpp
Normal file
88
src/libslic3r/Zipper.hpp
Normal file
@ -0,0 +1,88 @@
|
||||
#ifndef ZIPPER_HPP
|
||||
#define ZIPPER_HPP
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
// Class for creating zip archives.
|
||||
class Zipper {
|
||||
public:
|
||||
// Three compression levels supported
|
||||
enum e_compression {
|
||||
NO_COMPRESSION,
|
||||
FAST_COMPRESSION,
|
||||
TIGHT_COMPRESSION
|
||||
};
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
std::unique_ptr<Impl> m_impl;
|
||||
std::string m_data;
|
||||
std::string m_entry;
|
||||
e_compression m_compression;
|
||||
|
||||
public:
|
||||
|
||||
// Will blow up in a runtime exception if the file cannot be created.
|
||||
explicit Zipper(const std::string& zipfname,
|
||||
e_compression level = NO_COMPRESSION);
|
||||
~Zipper();
|
||||
|
||||
// No copies allwed, this is a file resource...
|
||||
Zipper(const Zipper&) = delete;
|
||||
Zipper& operator=(const Zipper&) = delete;
|
||||
|
||||
// Moving is fine.
|
||||
// Zipper(Zipper&&) = default;
|
||||
// Zipper& operator=(Zipper&&) = default;
|
||||
// All becouse of VS2013:
|
||||
Zipper(Zipper &&m);
|
||||
Zipper& operator=(Zipper &&m);
|
||||
|
||||
/// Adding an entry means a file inside the new archive. Name param is the
|
||||
/// name of the new file. To create directories, append a forward slash.
|
||||
/// The previous entry is finished (see finish_entry)
|
||||
void add_entry(const std::string& name);
|
||||
|
||||
/// Add a new binary file entry with an instantly given byte buffer.
|
||||
void add_entry(const std::string& name, const std::uint8_t* data, size_t l);
|
||||
|
||||
// Writing data to the archive works like with standard streams. The target
|
||||
// within the zip file is the entry created with the add_entry method.
|
||||
|
||||
// Template taking only arithmetic values, that std::to_string can handle.
|
||||
template<class T> inline
|
||||
typename std::enable_if<std::is_arithmetic<T>::value, Zipper&>::type
|
||||
operator<<(T &&val) {
|
||||
return this->operator<<(std::to_string(std::forward<T>(val)));
|
||||
}
|
||||
|
||||
// Template applied only for types that std::string can handle for append
|
||||
// and copy. This includes c style strings...
|
||||
template<class T> inline
|
||||
typename std::enable_if<!std::is_arithmetic<T>::value, Zipper&>::type
|
||||
operator<<(T &&val) {
|
||||
if(m_data.empty()) m_data = std::forward<T>(val);
|
||||
else m_data.append(val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Finishing an entry means that subsequent writes will no longer be
|
||||
/// appended to the previous entry. They will be written into the internal
|
||||
/// buffer and ones an entry is added, the buffer will bind to the new entry
|
||||
/// If the buffer was written, but no entry was added, the buffer will be
|
||||
/// cleared after this call.
|
||||
void finish_entry();
|
||||
|
||||
/// Gets the name of the archive without the path or extension.
|
||||
std::string get_name() const;
|
||||
|
||||
void close();
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // ZIPPER_HPP
|
@ -1,4 +0,0 @@
|
||||
png++ is written by Alexander Shulgin (alex dot shulgin at gmail dot com)
|
||||
Copyright (C) 2007,2008
|
||||
|
||||
When writing to me be sure to put png++: in the subject :-)
|
@ -1,25 +0,0 @@
|
||||
Copying png++ is subject to the following license:
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
60
src/png/NEWS
60
src/png/NEWS
@ -1,60 +0,0 @@
|
||||
Version 0.2.7:
|
||||
|
||||
- Added solid_pixel_buffer (patch by Andrey Potapov).
|
||||
|
||||
- Fixed some compilation problems on Win32.
|
||||
|
||||
Version 0.2.5:
|
||||
|
||||
- Fixed compatibility with newer libpng versions (>= 1.4)
|
||||
|
||||
- Fixed compilation on FreeBSD.
|
||||
|
||||
- Fixed tRNS handling with transformations.
|
||||
|
||||
- Added IO transformation debugging facility.
|
||||
|
||||
- Better organized test suite.
|
||||
|
||||
Version 0.2.3:
|
||||
|
||||
- Fixed numerous `already defined' errors due to require_color_space
|
||||
implementation.
|
||||
|
||||
- Added `config.hpp'.
|
||||
|
||||
- Fixed `strerror' usage.
|
||||
|
||||
- Minor docs fixes.
|
||||
|
||||
|
||||
Version 0.2.1:
|
||||
|
||||
- Added support for tRNS chunk.
|
||||
|
||||
- Added non-std IO streams support.
|
||||
|
||||
- Fixed 16-bit endianness problems.
|
||||
|
||||
- Improved test script.
|
||||
|
||||
|
||||
Version 0.2.0:
|
||||
|
||||
- Added support for 16-bit data (RGB, RGBA, Grayscale and Gray+Alpha
|
||||
color types)
|
||||
|
||||
- Added support for packed 1-, 2- or 4-bit pixels (Grayscale and
|
||||
Indexed colors)
|
||||
|
||||
- Fixed interlace handling code which was severely broken
|
||||
|
||||
- Added possibility to process images without reading the entire
|
||||
image into memory
|
||||
|
||||
- Internals are refactored while the client interface is mostly
|
||||
unchanged
|
||||
|
||||
- Added intensive test suite
|
||||
|
||||
- Added documentation
|
@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2007,2008 Alex Shulgin
|
||||
*
|
||||
* This file is part of png++ the C++ wrapper for libpng. PNG++ is free
|
||||
* software; the exact copying conditions are as follows:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef PNGPP_COLOR_HPP_INCLUDED
|
||||
#define PNGPP_COLOR_HPP_INCLUDED
|
||||
|
||||
#include "types.hpp"
|
||||
|
||||
namespace png
|
||||
{
|
||||
|
||||
/**
|
||||
* \brief PNG color struct extension. Adds constructors.
|
||||
*/
|
||||
struct color
|
||||
: png_color
|
||||
{
|
||||
explicit color(byte r = 0, byte g = 0, byte b = 0)
|
||||
{
|
||||
this->red = r;
|
||||
this->green = g;
|
||||
this->blue = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Initializes color with a copy of png_color object.
|
||||
*/
|
||||
color(png_color const& other)
|
||||
{
|
||||
this->red = other.red;
|
||||
this->green = other.green;
|
||||
this->blue = other.blue;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace png
|
||||
|
||||
#endif // PNGPP_COLOR_HPP_INCLUDED
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2007,2008 Alex Shulgin
|
||||
*
|
||||
* This file is part of png++ the C++ wrapper for libpng. PNG++ is free
|
||||
* software; the exact copying conditions are as follows:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef PNGPP_END_INFO_HPP_INCLUDED
|
||||
#define PNGPP_END_INFO_HPP_INCLUDED
|
||||
|
||||
#include "info_base.hpp"
|
||||
|
||||
namespace png
|
||||
{
|
||||
|
||||
/**
|
||||
* \brief Internal class to hold PNG ending %info.
|
||||
*
|
||||
* \see info, info_base
|
||||
*/
|
||||
class end_info
|
||||
: public info_base
|
||||
{
|
||||
public:
|
||||
end_info(io_base& io, png_struct* png)
|
||||
: info_base(io, png)
|
||||
{
|
||||
}
|
||||
|
||||
void destroy()
|
||||
{
|
||||
assert(m_info);
|
||||
png_destroy_info_struct(m_png, & m_info);
|
||||
}
|
||||
|
||||
void read()
|
||||
{
|
||||
png_read_end(m_png, m_info);
|
||||
}
|
||||
|
||||
void write() const
|
||||
{
|
||||
png_write_end(m_png, m_info);
|
||||
}
|
||||
|
||||
// TODO: add methods to read/write text comments etc.
|
||||
};
|
||||
|
||||
} // namespace png
|
||||
|
||||
#endif // PNGPP_END_INFO_HPP_INCLUDED
|
@ -1,125 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2007,2008 Alex Shulgin
|
||||
*
|
||||
* This file is part of png++ the C++ wrapper for libpng. PNG++ is free
|
||||
* software; the exact copying conditions are as follows:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef PNGPP_ERROR_HPP_INCLUDED
|
||||
#define PNGPP_ERROR_HPP_INCLUDED
|
||||
|
||||
/* check if we have strerror_s or strerror_r, prefer the former which is C11 std */
|
||||
#ifdef __STDC_LIB_EXT1__
|
||||
#define __STDC_WANT_LIB_EXT1__ 1
|
||||
#include <string.h>
|
||||
|
||||
#define HAVE_STRERROR_S 1
|
||||
#else
|
||||
#undef HAVE_STRERROR_S
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <cerrno>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
namespace png
|
||||
{
|
||||
|
||||
/**
|
||||
* \brief Exception class to represent runtime errors related to
|
||||
* png++ operation.
|
||||
*/
|
||||
class error
|
||||
: public std::runtime_error
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \param message error description
|
||||
*/
|
||||
explicit error(std::string const& message)
|
||||
: std::runtime_error(message)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Exception class to represent standard library errors
|
||||
* (generally IO).
|
||||
*
|
||||
* \see reader, writer
|
||||
*/
|
||||
class std_error
|
||||
: public std::runtime_error
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructs an std_error object. The \a message string is
|
||||
* appended with <tt>": "</tt> and the error description as
|
||||
* returned by \c strerror(\a error).
|
||||
*
|
||||
* \param message error description
|
||||
* \param error error number
|
||||
*/
|
||||
explicit std_error(std::string const& message, int errnum = errno)
|
||||
: std::runtime_error((message + ": ") + thread_safe_strerror(errnum))
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
static std::string thread_safe_strerror(int errnum)
|
||||
{
|
||||
#define ERRBUF_SIZE 512
|
||||
|
||||
#ifdef HAVE_STRERROR_S
|
||||
char buf[ERRBUF_SIZE] = { 0 };
|
||||
strerror_s(buf, ERRBUF_SIZE, errnum);
|
||||
return std::string(buf);
|
||||
#else
|
||||
#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE
|
||||
char buf[ERRBUF_SIZE] = { 0 };
|
||||
strerror_r(errnum, buf, ERRBUF_SIZE);
|
||||
return std::string(buf);
|
||||
#elif _GNU_SOURCE
|
||||
/* GNU variant can return a pointer to static buffer instead of buf */
|
||||
char buf[ERRBUF_SIZE] = { 0 };
|
||||
return std::string(strerror_r(errnum, buf, ERRBUF_SIZE));
|
||||
#else
|
||||
return std::string("An error occured with errnum ") +
|
||||
std::to_string(errnum) +
|
||||
". Converting to the appropriate error message is disabled"
|
||||
"in this instance of the png++ library.";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#undef ERRBUF_SIZE
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace png
|
||||
|
||||
#endif // PNGPP_ERROR_HPP_INCLUDED
|
@ -1,215 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2007,2008 Alex Shulgin
|
||||
*
|
||||
* This file is part of png++ the C++ wrapper for libpng. PNG++ is free
|
||||
* software; the exact copying conditions are as follows:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef PNGPP_IMAGE_INFO_HPP_INCLUDED
|
||||
#define PNGPP_IMAGE_INFO_HPP_INCLUDED
|
||||
|
||||
#include "types.hpp"
|
||||
#include "palette.hpp"
|
||||
#include "tRNS.hpp"
|
||||
#include "pixel_traits.hpp"
|
||||
|
||||
namespace png
|
||||
{
|
||||
|
||||
/**
|
||||
* \brief Holds information about PNG image.
|
||||
*
|
||||
* \see image, generator, consumer
|
||||
*/
|
||||
class image_info
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \brief Constructs the image_info object with default values
|
||||
* for color_type, interlace_type, compression_method and
|
||||
* filter_type.
|
||||
*/
|
||||
image_info()
|
||||
: m_width(0),
|
||||
m_height(0),
|
||||
m_bit_depth(0),
|
||||
m_color_type(color_type_none),
|
||||
m_interlace_type(interlace_none),
|
||||
m_compression_type(compression_type_default),
|
||||
m_filter_type(filter_type_default),
|
||||
m_gamma(0.0)
|
||||
{
|
||||
}
|
||||
|
||||
uint_32 get_width() const
|
||||
{
|
||||
return m_width;
|
||||
}
|
||||
|
||||
void set_width(uint_32 width)
|
||||
{
|
||||
m_width = width;
|
||||
}
|
||||
|
||||
uint_32 get_height() const
|
||||
{
|
||||
return m_height;
|
||||
}
|
||||
|
||||
void set_height(uint_32 height)
|
||||
{
|
||||
m_height = height;
|
||||
}
|
||||
|
||||
color_type get_color_type() const
|
||||
{
|
||||
return m_color_type;
|
||||
}
|
||||
|
||||
void set_color_type(color_type color_space)
|
||||
{
|
||||
m_color_type = color_space;
|
||||
}
|
||||
|
||||
int get_bit_depth() const
|
||||
{
|
||||
return m_bit_depth;
|
||||
}
|
||||
|
||||
void set_bit_depth(int bit_depth)
|
||||
{
|
||||
m_bit_depth = bit_depth;
|
||||
}
|
||||
|
||||
interlace_type get_interlace_type() const
|
||||
{
|
||||
return m_interlace_type;
|
||||
}
|
||||
|
||||
void set_interlace_type(interlace_type interlace)
|
||||
{
|
||||
m_interlace_type = interlace;
|
||||
}
|
||||
|
||||
compression_type get_compression_type() const
|
||||
{
|
||||
return m_compression_type;
|
||||
}
|
||||
|
||||
void set_compression_type(compression_type compression)
|
||||
{
|
||||
m_compression_type = compression;
|
||||
}
|
||||
|
||||
filter_type get_filter_type() const
|
||||
{
|
||||
return m_filter_type;
|
||||
}
|
||||
|
||||
void set_filter_type(filter_type filter)
|
||||
{
|
||||
m_filter_type = filter;
|
||||
}
|
||||
|
||||
palette const& get_palette() const
|
||||
{
|
||||
return m_palette;
|
||||
}
|
||||
|
||||
palette& get_palette()
|
||||
{
|
||||
return m_palette;
|
||||
}
|
||||
|
||||
void set_palette(palette const& plte)
|
||||
{
|
||||
m_palette = plte;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Removes all entries from the palette.
|
||||
*/
|
||||
void drop_palette()
|
||||
{
|
||||
m_palette.clear();
|
||||
}
|
||||
|
||||
tRNS const& get_tRNS() const
|
||||
{
|
||||
return m_tRNS;
|
||||
}
|
||||
|
||||
tRNS& get_tRNS()
|
||||
{
|
||||
return m_tRNS;
|
||||
}
|
||||
|
||||
void set_tRNS(tRNS const& trns)
|
||||
{
|
||||
m_tRNS = trns;
|
||||
}
|
||||
|
||||
double get_gamma() const
|
||||
{
|
||||
return m_gamma;
|
||||
}
|
||||
|
||||
void set_gamma(double gamma)
|
||||
{
|
||||
m_gamma = gamma;
|
||||
}
|
||||
|
||||
protected:
|
||||
uint_32 m_width;
|
||||
uint_32 m_height;
|
||||
int m_bit_depth;
|
||||
color_type m_color_type;
|
||||
interlace_type m_interlace_type;
|
||||
compression_type m_compression_type;
|
||||
filter_type m_filter_type;
|
||||
palette m_palette;
|
||||
tRNS m_tRNS;
|
||||
double m_gamma;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Returns an image_info object with color_type and
|
||||
* bit_depth fields setup appropriate for the \c pixel type.
|
||||
*/
|
||||
template< typename pixel >
|
||||
image_info
|
||||
make_image_info()
|
||||
{
|
||||
typedef pixel_traits< pixel > traits;
|
||||
image_info info;
|
||||
info.set_color_type(traits::get_color_type());
|
||||
info.set_bit_depth(traits::get_bit_depth());
|
||||
return info;
|
||||
}
|
||||
|
||||
} // namespace png
|
||||
|
||||
#endif // PNGPP_IMAGE_INFO_HPP_INCLUDED
|
186
src/png/info.hpp
186
src/png/info.hpp
@ -1,186 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2007,2008 Alex Shulgin
|
||||
*
|
||||
* This file is part of png++ the C++ wrapper for libpng. PNG++ is free
|
||||
* software; the exact copying conditions are as follows:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef PNGPP_INFO_HPP_INCLUDED
|
||||
#define PNGPP_INFO_HPP_INCLUDED
|
||||
|
||||
#include <cassert>
|
||||
#include "info_base.hpp"
|
||||
#include "image_info.hpp"
|
||||
|
||||
namespace png
|
||||
{
|
||||
|
||||
/**
|
||||
* \brief Holds information about PNG image. Adapter class for IO
|
||||
* image operations.
|
||||
*/
|
||||
class info
|
||||
: public info_base,
|
||||
public image_info
|
||||
{
|
||||
public:
|
||||
info(io_base& io, png_struct* png)
|
||||
: info_base(io, png)
|
||||
{
|
||||
}
|
||||
|
||||
void read()
|
||||
{
|
||||
assert(m_png);
|
||||
assert(m_info);
|
||||
|
||||
png_read_info(m_png, m_info);
|
||||
png_get_IHDR(m_png,
|
||||
m_info,
|
||||
& m_width,
|
||||
& m_height,
|
||||
reinterpret_cast< int* >(& m_bit_depth),
|
||||
reinterpret_cast< int* >(& m_color_type),
|
||||
reinterpret_cast< int* >(& m_interlace_type),
|
||||
reinterpret_cast< int* >(& m_compression_type),
|
||||
reinterpret_cast< int* >(& m_filter_type));
|
||||
|
||||
if (png_get_valid(m_png, m_info, chunk_PLTE) == chunk_PLTE)
|
||||
{
|
||||
png_color* colors = 0;
|
||||
int count = 0;
|
||||
png_get_PLTE(m_png, m_info, & colors, & count);
|
||||
m_palette.assign(colors, colors + count);
|
||||
}
|
||||
|
||||
#ifdef PNG_tRNS_SUPPORTED
|
||||
if (png_get_valid(m_png, m_info, chunk_tRNS) == chunk_tRNS)
|
||||
{
|
||||
if (m_color_type == color_type_palette)
|
||||
{
|
||||
int count;
|
||||
byte* values;
|
||||
if (png_get_tRNS(m_png, m_info, & values, & count, NULL)
|
||||
!= PNG_INFO_tRNS)
|
||||
{
|
||||
throw error("png_get_tRNS() failed");
|
||||
}
|
||||
m_tRNS.assign(values, values + count);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_gAMA_SUPPORTED
|
||||
if (png_get_valid(m_png, m_info, chunk_gAMA) == chunk_gAMA)
|
||||
{
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
if (png_get_gAMA(m_png, m_info, &m_gamma) != PNG_INFO_gAMA)
|
||||
{
|
||||
throw error("png_get_gAMA() failed");
|
||||
}
|
||||
#else
|
||||
png_fixed_point gamma = 0;
|
||||
if (png_get_gAMA_fixed(m_png, m_info, &gamma) != PNG_INFO_gAMA)
|
||||
{
|
||||
throw error("png_get_gAMA_fixed() failed");
|
||||
}
|
||||
m_gamma = gamma / 100000.0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void write() const
|
||||
{
|
||||
assert(m_png);
|
||||
assert(m_info);
|
||||
|
||||
sync_ihdr();
|
||||
if (m_color_type == color_type_palette)
|
||||
{
|
||||
if (! m_palette.empty())
|
||||
{
|
||||
png_set_PLTE(m_png, m_info,
|
||||
const_cast< color* >(& m_palette[0]),
|
||||
(int) m_palette.size());
|
||||
}
|
||||
if (! m_tRNS.empty())
|
||||
{
|
||||
#ifdef PNG_tRNS_SUPPORTED
|
||||
png_set_tRNS(m_png, m_info,
|
||||
const_cast< byte* >(& m_tRNS[0]),
|
||||
m_tRNS.size(),
|
||||
NULL);
|
||||
#else
|
||||
throw error("attempted to write tRNS chunk; recompile with PNG_tRNS_SUPPORTED");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (m_gamma > 0)
|
||||
{
|
||||
#ifdef PNG_gAMA_SUPPORTED
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_set_gAMA(m_png, m_info, m_gamma);
|
||||
#else
|
||||
png_set_gAMA_fixed(m_png, m_info,
|
||||
(png_fixed_point)(m_gamma * 100000));
|
||||
#endif
|
||||
#else
|
||||
throw error("attempted to write gAMA chunk; recompile with PNG_gAMA_SUPPORTED");
|
||||
#endif
|
||||
}
|
||||
|
||||
png_write_info(m_png, m_info);
|
||||
}
|
||||
|
||||
void update()
|
||||
{
|
||||
assert(m_png);
|
||||
assert(m_info);
|
||||
|
||||
sync_ihdr();
|
||||
png_read_update_info(m_png, m_info);
|
||||
}
|
||||
|
||||
protected:
|
||||
void sync_ihdr(void) const
|
||||
{
|
||||
png_set_IHDR(m_png,
|
||||
m_info,
|
||||
m_width,
|
||||
m_height,
|
||||
m_bit_depth,
|
||||
m_color_type,
|
||||
m_interlace_type,
|
||||
m_compression_type,
|
||||
m_filter_type);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace png
|
||||
|
||||
#endif // PNGPP_INFO_HPP_INCLUDED
|
@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2007,2008 Alex Shulgin
|
||||
*
|
||||
* This file is part of png++ the C++ wrapper for libpng. PNG++ is free
|
||||
* software; the exact copying conditions are as follows:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef PNGPP_INFO_BASE_HPP_INCLUDED
|
||||
#define PNGPP_INFO_BASE_HPP_INCLUDED
|
||||
|
||||
#include <cassert>
|
||||
#include "error.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
namespace png
|
||||
{
|
||||
|
||||
class io_base;
|
||||
|
||||
/**
|
||||
* \brief Internal class to hold PNG info or end_info.
|
||||
*/
|
||||
class info_base
|
||||
{
|
||||
info_base(info_base const&);
|
||||
info_base& operator=(info_base const&);
|
||||
|
||||
public:
|
||||
info_base(io_base& io, png_struct* png)
|
||||
: m_io(io),
|
||||
m_png(png),
|
||||
m_info(png_create_info_struct(m_png))
|
||||
{
|
||||
}
|
||||
|
||||
png_info* get_png_info() const
|
||||
{
|
||||
return m_info;
|
||||
}
|
||||
|
||||
png_info** get_png_info_ptr()
|
||||
{
|
||||
return & m_info;
|
||||
}
|
||||
|
||||
protected:
|
||||
io_base& m_io;
|
||||
png_struct* m_png;
|
||||
png_info* m_info;
|
||||
};
|
||||
|
||||
} // namespace png
|
||||
|
||||
#endif // PNGPP_INFO_BASE_HPP_INCLUDED
|
@ -1,467 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2007,2008 Alex Shulgin
|
||||
*
|
||||
* This file is part of png++ the C++ wrapper for libpng. PNG++ is free
|
||||
* software; the exact copying conditions are as follows:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef PNGPP_IO_BASE_HPP_INCLUDED
|
||||
#define PNGPP_IO_BASE_HPP_INCLUDED
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <cstdarg>
|
||||
#include "error.hpp"
|
||||
#include "info.hpp"
|
||||
#include "end_info.hpp"
|
||||
|
||||
static void
|
||||
trace_io_transform(char const* fmt, ...)
|
||||
{
|
||||
#ifdef DEBUG_IO_TRANSFORM
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
fprintf(stderr, "TRANSFORM_IO: ");
|
||||
vfprintf(stderr, fmt, va);
|
||||
va_end(va);
|
||||
#endif
|
||||
}
|
||||
#define TRACE_IO_TRANSFORM trace_io_transform
|
||||
|
||||
namespace png
|
||||
{
|
||||
|
||||
/**
|
||||
* \brief Base class for PNG reader/writer classes.
|
||||
*
|
||||
* \see reader, writer
|
||||
*/
|
||||
class io_base
|
||||
{
|
||||
io_base(io_base const&);
|
||||
io_base& operator=(io_base const&);
|
||||
|
||||
public:
|
||||
explicit io_base(png_struct* png)
|
||||
: m_png(png),
|
||||
m_info(*this, m_png),
|
||||
m_end_info(*this, m_png)
|
||||
{
|
||||
}
|
||||
|
||||
~io_base()
|
||||
{
|
||||
assert(! m_png);
|
||||
assert(! m_info.get_png_info());
|
||||
assert(! m_end_info.get_png_info());
|
||||
}
|
||||
|
||||
png_struct* get_png_struct() const
|
||||
{
|
||||
return m_png;
|
||||
}
|
||||
|
||||
info& get_info()
|
||||
{
|
||||
return m_info;
|
||||
}
|
||||
|
||||
info const& get_info() const
|
||||
{
|
||||
return m_info;
|
||||
}
|
||||
|
||||
image_info const& get_image_info() const
|
||||
{
|
||||
return m_info;
|
||||
}
|
||||
|
||||
void set_image_info(image_info const& info)
|
||||
{
|
||||
static_cast< image_info& >(m_info) = info; // slice it
|
||||
}
|
||||
|
||||
end_info& get_end_info()
|
||||
{
|
||||
return m_end_info;
|
||||
}
|
||||
|
||||
end_info const& get_end_info() const
|
||||
{
|
||||
return m_end_info;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// info accessors
|
||||
//
|
||||
uint_32 get_width() const
|
||||
{
|
||||
return m_info.get_width();
|
||||
}
|
||||
|
||||
void set_width(uint_32 width)
|
||||
{
|
||||
m_info.set_width(width);
|
||||
}
|
||||
|
||||
uint_32 get_height() const
|
||||
{
|
||||
return m_info.get_height();
|
||||
}
|
||||
|
||||
void set_height(uint_32 height)
|
||||
{
|
||||
m_info.set_height(height);
|
||||
}
|
||||
|
||||
color_type get_color_type() const
|
||||
{
|
||||
return m_info.get_color_type();
|
||||
}
|
||||
|
||||
void set_color_type(color_type color_space)
|
||||
{
|
||||
m_info.set_color_type(color_space);
|
||||
}
|
||||
|
||||
int get_bit_depth() const
|
||||
{
|
||||
return m_info.get_bit_depth();
|
||||
}
|
||||
|
||||
void set_bit_depth(int bit_depth)
|
||||
{
|
||||
m_info.set_bit_depth(bit_depth);
|
||||
}
|
||||
|
||||
interlace_type get_interlace_type() const
|
||||
{
|
||||
return m_info.get_interlace_type();
|
||||
}
|
||||
|
||||
void set_interlace_type(interlace_type interlace)
|
||||
{
|
||||
m_info.set_interlace_type(interlace);
|
||||
}
|
||||
|
||||
compression_type get_compression_type() const
|
||||
{
|
||||
return m_info.get_compression_type();
|
||||
}
|
||||
|
||||
void set_compression_type(compression_type compression)
|
||||
{
|
||||
m_info.set_compression_type(compression);
|
||||
}
|
||||
|
||||
filter_type get_filter_type() const
|
||||
{
|
||||
return m_info.get_filter_type();
|
||||
}
|
||||
|
||||
void set_filter_type(filter_type filter)
|
||||
{
|
||||
m_info.set_filter_type(filter);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool has_chunk(chunk id)
|
||||
{
|
||||
return png_get_valid(m_png,
|
||||
m_info.get_png_info(),
|
||||
uint_32(id)) == uint_32(id);
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_EXPAND_SUPPORTED)
|
||||
void set_gray_1_2_4_to_8() const
|
||||
{
|
||||
TRACE_IO_TRANSFORM("png_set_expand_gray_1_2_4_to_8\n");
|
||||
png_set_expand_gray_1_2_4_to_8(m_png);
|
||||
}
|
||||
|
||||
void set_palette_to_rgb() const
|
||||
{
|
||||
TRACE_IO_TRANSFORM("png_set_palette_to_rgb\n");
|
||||
png_set_palette_to_rgb(m_png);
|
||||
}
|
||||
|
||||
void set_tRNS_to_alpha() const
|
||||
{
|
||||
TRACE_IO_TRANSFORM("png_set_tRNS_to_alpha\n");
|
||||
png_set_tRNS_to_alpha(m_png);
|
||||
}
|
||||
#endif // defined(PNG_READ_EXPAND_SUPPORTED)
|
||||
|
||||
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
||||
void set_bgr() const
|
||||
{
|
||||
TRACE_IO_TRANSFORM("png_set_bgr\n");
|
||||
png_set_bgr(m_png);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
|
||||
void set_gray_to_rgb() const
|
||||
{
|
||||
TRACE_IO_TRANSFORM("png_set_gray_to_rgb\n");
|
||||
png_set_gray_to_rgb(m_png);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
void set_rgb_to_gray(rgb_to_gray_error_action error_action
|
||||
= rgb_to_gray_silent,
|
||||
double red_weight = -1.0,
|
||||
double green_weight = -1.0) const
|
||||
{
|
||||
TRACE_IO_TRANSFORM("png_set_rgb_to_gray: error_action=%d,"
|
||||
" red_weight=%lf, green_weight=%lf\n",
|
||||
error_action, red_weight, green_weight);
|
||||
|
||||
png_set_rgb_to_gray(m_png, error_action, red_weight, green_weight);
|
||||
}
|
||||
#else
|
||||
void set_rgb_to_gray(rgb_to_gray_error_action error_action
|
||||
= rgb_to_gray_silent,
|
||||
fixed_point red_weight = -1,
|
||||
fixed_point green_weight = -1) const
|
||||
{
|
||||
TRACE_IO_TRANSFORM("png_set_rgb_to_gray_fixed: error_action=%d,"
|
||||
" red_weight=%d, green_weight=%d\n",
|
||||
error_action, red_weight, green_weight);
|
||||
|
||||
png_set_rgb_to_gray_fixed(m_png, error_action,
|
||||
red_weight, green_weight);
|
||||
}
|
||||
#endif // PNG_FLOATING_POINT_SUPPORTED
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// alpha channel transformations
|
||||
//
|
||||
#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||
void set_strip_alpha() const
|
||||
{
|
||||
TRACE_IO_TRANSFORM("png_set_strip_alpha\n");
|
||||
png_set_strip_alpha(m_png);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) \
|
||||
|| defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
|
||||
void set_swap_alpha() const
|
||||
{
|
||||
TRACE_IO_TRANSFORM("png_set_swap_alpha\n");
|
||||
png_set_swap_alpha(m_png);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) \
|
||||
|| defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||
void set_invert_alpha() const
|
||||
{
|
||||
TRACE_IO_TRANSFORM("png_set_invert_alpha\n");
|
||||
png_set_invert_alpha(m_png);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||
void set_filler(uint_32 filler, filler_type type) const
|
||||
{
|
||||
TRACE_IO_TRANSFORM("png_set_filler: filler=%08x, type=%d\n",
|
||||
filler, type);
|
||||
|
||||
png_set_filler(m_png, filler, type);
|
||||
}
|
||||
|
||||
#if !defined(PNG_1_0_X)
|
||||
void set_add_alpha(uint_32 filler, filler_type type) const
|
||||
{
|
||||
TRACE_IO_TRANSFORM("png_set_add_alpha: filler=%08x, type=%d\n",
|
||||
filler, type);
|
||||
|
||||
png_set_add_alpha(m_png, filler, type);
|
||||
}
|
||||
#endif
|
||||
#endif // PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED
|
||||
|
||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||
void set_swap() const
|
||||
{
|
||||
TRACE_IO_TRANSFORM("png_set_swap\n");
|
||||
png_set_swap(m_png);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
void set_packing() const
|
||||
{
|
||||
TRACE_IO_TRANSFORM("png_set_packing\n");
|
||||
png_set_packing(m_png);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED) \
|
||||
|| defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
||||
void set_packswap() const
|
||||
{
|
||||
TRACE_IO_TRANSFORM("png_set_packswap\n");
|
||||
png_set_packswap(m_png);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
|
||||
void set_shift(byte red_bits, byte green_bits, byte blue_bits,
|
||||
byte alpha_bits = 0) const
|
||||
{
|
||||
TRACE_IO_TRANSFORM("png_set_shift: red_bits=%d, green_bits=%d,"
|
||||
" blue_bits=%d, alpha_bits=%d\n",
|
||||
red_bits, green_bits, blue_bits, alpha_bits);
|
||||
|
||||
if (get_color_type() != color_type_rgb
|
||||
|| get_color_type() != color_type_rgb_alpha)
|
||||
{
|
||||
throw error("set_shift: expected RGB or RGBA color type");
|
||||
}
|
||||
color_info bits;
|
||||
bits.red = red_bits;
|
||||
bits.green = green_bits;
|
||||
bits.blue = blue_bits;
|
||||
bits.alpha = alpha_bits;
|
||||
png_set_shift(m_png, & bits);
|
||||
}
|
||||
|
||||
void set_shift(byte gray_bits, byte alpha_bits = 0) const
|
||||
{
|
||||
TRACE_IO_TRANSFORM("png_set_shift: gray_bits=%d, alpha_bits=%d\n",
|
||||
gray_bits, alpha_bits);
|
||||
|
||||
if (get_color_type() != color_type_gray
|
||||
|| get_color_type() != color_type_gray_alpha)
|
||||
{
|
||||
throw error("set_shift: expected Gray or Gray+Alpha color type");
|
||||
}
|
||||
color_info bits;
|
||||
bits.gray = gray_bits;
|
||||
bits.alpha = alpha_bits;
|
||||
png_set_shift(m_png, & bits);
|
||||
}
|
||||
#endif // PNG_READ_SHIFT_SUPPORTED || PNG_WRITE_SHIFT_SUPPORTED
|
||||
|
||||
#if defined(PNG_READ_INTERLACING_SUPPORTED) \
|
||||
|| defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||
int set_interlace_handling() const
|
||||
{
|
||||
TRACE_IO_TRANSFORM("png_set_interlace_handling\n");
|
||||
return png_set_interlace_handling(m_png);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
|
||||
void set_invert_mono() const
|
||||
{
|
||||
TRACE_IO_TRANSFORM("png_set_invert_mono\n");
|
||||
png_set_invert_mono(m_png);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_16_TO_8_SUPPORTED)
|
||||
void set_strip_16() const
|
||||
{
|
||||
TRACE_IO_TRANSFORM("png_set_strip_16\n");
|
||||
png_set_strip_16(m_png);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
void set_read_user_transform(png_user_transform_ptr transform_fn)
|
||||
{
|
||||
TRACE_IO_TRANSFORM("png_set_read_user_transform_fn\n");
|
||||
png_set_read_user_transform_fn(m_png, transform_fn);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) \
|
||||
|| defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
void set_user_transform_info(void* info, int bit_depth, int channels)
|
||||
{
|
||||
TRACE_IO_TRANSFORM("png_set_user_transform_info: bit_depth=%d,"
|
||||
" channels=%d\n", bit_depth, channels);
|
||||
|
||||
png_set_user_transform_info(m_png, info, bit_depth, channels);
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void* get_io_ptr() const
|
||||
{
|
||||
return png_get_io_ptr(m_png);
|
||||
}
|
||||
|
||||
void set_error(char const* message)
|
||||
{
|
||||
assert(message);
|
||||
m_error = message;
|
||||
}
|
||||
|
||||
void reset_error()
|
||||
{
|
||||
m_error.clear();
|
||||
}
|
||||
|
||||
/*
|
||||
std::string const& get_error() const
|
||||
{
|
||||
return m_error;
|
||||
}
|
||||
*/
|
||||
|
||||
bool is_error() const
|
||||
{
|
||||
return !m_error.empty();
|
||||
}
|
||||
|
||||
void raise_error()
|
||||
{
|
||||
longjmp(png_jmpbuf(m_png), -1);
|
||||
}
|
||||
|
||||
static void raise_error(png_struct* png, char const* message)
|
||||
{
|
||||
io_base* io = static_cast< io_base* >(png_get_error_ptr(png));
|
||||
io->set_error(message);
|
||||
io->raise_error();
|
||||
}
|
||||
|
||||
png_struct* m_png;
|
||||
info m_info;
|
||||
end_info m_end_info;
|
||||
std::string m_error;
|
||||
};
|
||||
|
||||
} // namespace png
|
||||
|
||||
#endif // PNGPP_IO_BASE_HPP_INCLUDED
|
@ -1,35 +0,0 @@
|
||||
Libpng 1.6.34 - September 29, 2017
|
||||
|
||||
This is a public release of libpng, intended for use in production codes.
|
||||
|
||||
Files available for download:
|
||||
|
||||
Source files with LF line endings (for Unix/Linux) and with a
|
||||
"configure" script
|
||||
|
||||
libpng-1.6.34.tar.xz (LZMA-compressed, recommended)
|
||||
libpng-1.6.34.tar.gz
|
||||
|
||||
Source files with CRLF line endings (for Windows), without the
|
||||
"configure" script
|
||||
|
||||
lpng1634.7z (LZMA-compressed, recommended)
|
||||
lpng1634.zip
|
||||
|
||||
Other information:
|
||||
|
||||
libpng-1.6.34-README.txt
|
||||
libpng-1.6.34-LICENSE.txt
|
||||
libpng-1.6.34-*.asc (armored detached GPG signatures)
|
||||
|
||||
Changes since the last public release (1.6.33):
|
||||
Removed contrib/pngsuite/i*.png; some of these were incorrect and caused
|
||||
test failures.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
to subscribe)
|
||||
or to glennrp at users.sourceforge.net
|
||||
|
||||
Glenn R-P
|
@ -1,937 +0,0 @@
|
||||
# CMakeLists.txt
|
||||
|
||||
# Copyright (C) 2007,2009-2017 Glenn Randers-Pehrson
|
||||
# Written by Christian Ehrlicher, 2007
|
||||
# Revised by Roger Lowman, 2009-2010
|
||||
# Revised by Clifford Yapp, 2011-2012
|
||||
# Revised by Roger Leigh, 2016
|
||||
# Revised by Andreas Franek, 2016
|
||||
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
|
||||
cmake_minimum_required(VERSION 3.0.2)
|
||||
cmake_policy(VERSION 3.0.2)
|
||||
|
||||
# Set MacOSX @rpath usage globally.
|
||||
if (POLICY CMP0020)
|
||||
cmake_policy(SET CMP0020 NEW)
|
||||
endif(POLICY CMP0020)
|
||||
if (POLICY CMP0042)
|
||||
cmake_policy(SET CMP0042 NEW)
|
||||
endif(POLICY CMP0042)
|
||||
# Use new variable expansion policy.
|
||||
if (POLICY CMP0053)
|
||||
cmake_policy(SET CMP0053 NEW)
|
||||
endif(POLICY CMP0053)
|
||||
if (POLICY CMP0054)
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
endif(POLICY CMP0054)
|
||||
|
||||
set(CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo")
|
||||
|
||||
project(libpng ASM C)
|
||||
|
||||
set(PNGLIB_MAJOR 1)
|
||||
set(PNGLIB_MINOR 6)
|
||||
set(PNGLIB_RELEASE 34)
|
||||
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
||||
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
|
||||
|
||||
# needed packages
|
||||
|
||||
#Allow users to specify location of Zlib,
|
||||
# Useful if zlib is being built alongside this as a sub-project
|
||||
|
||||
set(PNG_BUILD_ZLIB ${CMAKE_CURRENT_SOURCE_DIR}/zlib)
|
||||
|
||||
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()
|
||||
|
||||
# COMMAND LINE OPTIONS
|
||||
option(PNG_SHARED "Build shared lib" OFF)
|
||||
option(PNG_STATIC "Build static lib" ON)
|
||||
option(PNG_TESTS "Build libpng tests" OFF)
|
||||
|
||||
# Many more configuration options could be added here
|
||||
option(PNG_FRAMEWORK "Build OS X framework" OFF)
|
||||
option(PNG_DEBUG "Build with debug output" OFF)
|
||||
option(PNGARG "Disable ANSI-C prototypes" OFF)
|
||||
|
||||
option(PNG_HARDWARE_OPTIMIZATIONS "Enable Hardware Optimizations" ON)
|
||||
|
||||
set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names")
|
||||
set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings")
|
||||
|
||||
if(PNG_HARDWARE_OPTIMIZATIONS)
|
||||
# set definitions and sources for arm
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR
|
||||
CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
|
||||
set(PNG_ARM_NEON_POSSIBLE_VALUES check on off)
|
||||
set(PNG_ARM_NEON "check" CACHE STRING "Enable ARM NEON optimizations:
|
||||
check: (default) use internal checking code;
|
||||
off: disable the optimizations;
|
||||
on: turn on unconditionally.")
|
||||
set_property(CACHE PNG_ARM_NEON PROPERTY STRINGS
|
||||
${PNG_ARM_NEON_POSSIBLE_VALUES})
|
||||
list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index)
|
||||
if(index EQUAL -1)
|
||||
message(FATAL_ERROR
|
||||
" PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]")
|
||||
elseif(NOT ${PNG_ARM_NEON} STREQUAL "no")
|
||||
set(libpng_arm_sources
|
||||
arm/arm_init.c
|
||||
arm/filter_neon.S
|
||||
arm/filter_neon_intrinsics.c)
|
||||
|
||||
if(${PNG_ARM_NEON} STREQUAL "on")
|
||||
add_definitions(-DPNG_ARM_NEON_OPT=2)
|
||||
elseif(${PNG_ARM_NEON} STREQUAL "check")
|
||||
add_definitions(-DPNG_ARM_NEON_CHECK_SUPPORTED)
|
||||
endif()
|
||||
else()
|
||||
add_definitions(-DPNG_ARM_NEON_OPT=0)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# set definitions and sources for powerpc
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR
|
||||
CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*" )
|
||||
set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off)
|
||||
set(PNG_POWERPC_VSX "on" CACHE STRING "Enable POWERPC VSX optimizations:
|
||||
off: disable the optimizations.")
|
||||
set_property(CACHE PNG_POWERPC_VSX PROPERTY STRINGS
|
||||
${PNG_POWERPC_VSX_POSSIBLE_VALUES})
|
||||
list(FIND PNG_POWERPC_VSX_POSSIBLE_VALUES ${PNG_POWERPC_VSX} index)
|
||||
if(index EQUAL -1)
|
||||
message(FATAL_ERROR
|
||||
" PNG_POWERPC_VSX must be one of [${PNG_POWERPC_VSX_POSSIBLE_VALUES}]")
|
||||
elseif(NOT ${PNG_POWERPC_VSX} STREQUAL "no")
|
||||
set(libpng_powerpc_sources
|
||||
powerpc/powerpc_init.c
|
||||
powerpc/filter_vsx_intrinsics.c)
|
||||
if(${PNG_POWERPC_VSX} STREQUAL "on")
|
||||
add_definitions(-DPNG_POWERPC_VSX_OPT=2)
|
||||
endif()
|
||||
else()
|
||||
add_definitions(-DPNG_POWERPC_VSX_OPT=0)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# set definitions and sources for intel
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR
|
||||
CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*" )
|
||||
set(PNG_INTEL_SSE_POSSIBLE_VALUES on off)
|
||||
set(PNG_INTEL_SSE "on" CACHE STRING "Enable INTEL_SSE optimizations:
|
||||
off: disable the optimizations")
|
||||
set_property(CACHE PNG_INTEL_SSE PROPERTY STRINGS
|
||||
${PNG_INTEL_SSE_POSSIBLE_VALUES})
|
||||
list(FIND PNG_INTEL_SSE_POSSIBLE_VALUES ${PNG_INTEL_SSE} index)
|
||||
if(index EQUAL -1)
|
||||
message(FATAL_ERROR
|
||||
" PNG_INTEL_SSE must be one of [${PNG_INTEL_SSE_POSSIBLE_VALUES}]")
|
||||
elseif(NOT ${PNG_INTEL_SSE} STREQUAL "no")
|
||||
set(libpng_intel_sources
|
||||
intel/intel_init.c
|
||||
intel/filter_sse2_intrinsics.c)
|
||||
if(${PNG_INTEL_SSE} STREQUAL "on")
|
||||
add_definitions(-DPNG_INTEL_SSE_OPT=1)
|
||||
endif()
|
||||
else()
|
||||
add_definitions(-DPNG_INTEL_SSE_OPT=0)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# set definitions and sources for MIPS
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR
|
||||
CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*" )
|
||||
set(PNG_MIPS_MSA_POSSIBLE_VALUES on off)
|
||||
set(PNG_MIPS_MSA "on" CACHE STRING "Enable MIPS_MSA optimizations:
|
||||
off: disable the optimizations")
|
||||
set_property(CACHE PNG_MIPS_MSA PROPERTY STRINGS
|
||||
${PNG_MIPS_MSA_POSSIBLE_VALUES})
|
||||
list(FIND PNG_MIPS_MSA_POSSIBLE_VALUES ${PNG_MIPS_MSA} index)
|
||||
if(index EQUAL -1)
|
||||
message(FATAL_ERROR
|
||||
" PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]")
|
||||
elseif(NOT ${PNG_MIPS_MSA} STREQUAL "no")
|
||||
set(libpng_mips_sources
|
||||
mips/mips_init.c
|
||||
mips/filter_msa_intrinsics.c)
|
||||
if(${PNG_MIPS_MSA} STREQUAL "on")
|
||||
add_definitions(-DPNG_MIPS_MSA_OPT=2)
|
||||
endif()
|
||||
else()
|
||||
add_definitions(-DPNG_MIPS_MSA_OPT=0)
|
||||
endif()
|
||||
endif()
|
||||
endif(PNG_HARDWARE_OPTIMIZATIONS)
|
||||
|
||||
# SET LIBNAME
|
||||
set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
||||
|
||||
# to distinguish between debug and release lib
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
|
||||
include(CheckCSourceCompiles)
|
||||
option(ld-version-script "Enable linker version script" ON)
|
||||
if(ld-version-script AND NOT APPLE)
|
||||
# Check if LD supports linker scripts.
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 {
|
||||
global: sym;
|
||||
local: *;
|
||||
};
|
||||
|
||||
VERS_2 {
|
||||
global: sym2;
|
||||
main;
|
||||
} VERS_1;
|
||||
")
|
||||
set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
|
||||
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'")
|
||||
check_c_source_compiles("void sym(void) {}
|
||||
void sym2(void) {}
|
||||
int main(void) {return 0;}
|
||||
" HAVE_LD_VERSION_SCRIPT)
|
||||
if(NOT HAVE_LD_VERSION_SCRIPT)
|
||||
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE} "-Wl,-M -Wl,${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
|
||||
check_c_source_compiles("void sym(void) {}
|
||||
void sym2(void) {}
|
||||
int main(void) {return 0;}
|
||||
" HAVE_SOLARIS_LD_VERSION_SCRIPT)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})
|
||||
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
|
||||
endif()
|
||||
|
||||
# Find symbol prefix. Likely obsolete and unnecessary with recent
|
||||
# toolchains (it's not done in many other projects).
|
||||
function(symbol_prefix)
|
||||
set(SYMBOL_PREFIX)
|
||||
|
||||
execute_process(COMMAND "${CMAKE_C_COMPILER}" "-E" "-"
|
||||
INPUT_FILE /dev/null
|
||||
OUTPUT_VARIABLE OUT
|
||||
RESULT_VARIABLE STATUS)
|
||||
|
||||
if(CPP_FAIL)
|
||||
message(WARNING "Failed to run the C preprocessor")
|
||||
endif()
|
||||
|
||||
string(REPLACE "\n" ";" OUT "${OUT}")
|
||||
foreach(line ${OUT})
|
||||
string(REGEX MATCH "^PREFIX=" found_match "${line}")
|
||||
if(found_match)
|
||||
STRING(REGEX REPLACE "^PREFIX=(.*\)" "\\1" prefix "${line}")
|
||||
string(REGEX MATCH "__USER_LABEL_PREFIX__" found_match "${prefix}")
|
||||
if(found_match)
|
||||
STRING(REGEX REPLACE "(.*)__USER_LABEL_PREFIX__(.*)" "\\1\\2" prefix "${prefix}")
|
||||
endif()
|
||||
set(SYMBOL_PREFIX "${prefix}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
message(STATUS "Symbol prefix: ${SYMBOL_PREFIX}")
|
||||
set(SYMBOL_PREFIX "${SYMBOL_PREFIX}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
if(UNIX)
|
||||
symbol_prefix()
|
||||
endif()
|
||||
|
||||
find_program(AWK NAMES gawk awk)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
if(NOT AWK OR ANDROID)
|
||||
# No awk available to generate sources; use pre-built pnglibconf.h
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
|
||||
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h)
|
||||
add_custom_target(genfiles) # Dummy
|
||||
else()
|
||||
include(CMakeParseArguments)
|
||||
# Generate .chk from .out with awk
|
||||
# generate_chk(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
|
||||
function(generate_chk)
|
||||
set(options)
|
||||
set(oneValueArgs INPUT OUTPUT)
|
||||
set(multiValueArgs DEPENDS)
|
||||
cmake_parse_arguments(_GC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
if (NOT _GC_INPUT)
|
||||
message(FATAL_ERROR "Invalid arguments. generate_out requires input.")
|
||||
endif()
|
||||
if (NOT _GC_OUTPUT)
|
||||
message(FATAL_ERROR "Invalid arguments. generate_out requires output.")
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT "${_GC_OUTPUT}"
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
"-DINPUT=${_GC_INPUT}"
|
||||
"-DOUTPUT=${_GC_OUTPUT}"
|
||||
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake"
|
||||
DEPENDS "${_GC_INPUT}" ${_GC_DEPENDS}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
endfunction()
|
||||
|
||||
# Generate .out from .c with awk
|
||||
# generate_out(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
|
||||
function(generate_out)
|
||||
set(options)
|
||||
set(oneValueArgs INPUT OUTPUT)
|
||||
set(multiValueArgs DEPENDS)
|
||||
cmake_parse_arguments(_GO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
if (NOT _GO_INPUT)
|
||||
message(FATAL_ERROR "Invalid arguments. generate_out requires input.")
|
||||
endif()
|
||||
if (NOT _GO_OUTPUT)
|
||||
message(FATAL_ERROR "Invalid arguments. generate_out requires output.")
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT "${_GO_OUTPUT}"
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
"-DINPUT=${_GO_INPUT}"
|
||||
"-DOUTPUT=${_GO_OUTPUT}"
|
||||
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake"
|
||||
DEPENDS "${_GO_INPUT}" ${_GO_DEPENDS}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
endfunction()
|
||||
|
||||
# Generate specific source file with awk
|
||||
# generate_source(OUTPUT outputfile [DEPENDS dep1 [dep2...]])
|
||||
function(generate_source)
|
||||
set(options)
|
||||
set(oneValueArgs OUTPUT)
|
||||
set(multiValueArgs DEPENDS)
|
||||
cmake_parse_arguments(_GSO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
if (NOT _GSO_OUTPUT)
|
||||
message(FATAL_ERROR "Invalid arguments. generate_source requires output.")
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}"
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
"-DOUTPUT=${_GSO_OUTPUT}"
|
||||
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake"
|
||||
DEPENDS ${_GSO_DEPENDS}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
endfunction()
|
||||
|
||||
# Copy file
|
||||
function(generate_copy source destination)
|
||||
add_custom_command(OUTPUT "${destination}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E remove "${destination}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy "${source}"
|
||||
"${destination}"
|
||||
DEPENDS "${source}")
|
||||
endfunction()
|
||||
|
||||
# Generate scripts/pnglibconf.h
|
||||
generate_source(OUTPUT "scripts/pnglibconf.c"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h")
|
||||
|
||||
# Generate pnglibconf.c
|
||||
generate_source(OUTPUT "pnglibconf.c"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h")
|
||||
|
||||
if(PNG_PREFIX)
|
||||
set(PNGLIBCONF_H_EXTRA_DEPENDS
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/macro.lst")
|
||||
set(PNGPREFIX_H_EXTRA_DEPENDS
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out")
|
||||
endif()
|
||||
|
||||
generate_out(INPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c"
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out")
|
||||
|
||||
# Generate pnglibconf.h
|
||||
generate_source(OUTPUT "pnglibconf.h"
|
||||
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out"
|
||||
${PNGLIBCONF_H_EXTRA_DEPENDS})
|
||||
|
||||
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/intprefix.c"
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out"
|
||||
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
|
||||
|
||||
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/prefix.c"
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out")
|
||||
|
||||
# Generate pngprefix.h
|
||||
generate_source(OUTPUT "pngprefix.h"
|
||||
DEPENDS ${PNGPREFIX_H_EXTRA_DEPENDS})
|
||||
|
||||
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/sym.c"
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
|
||||
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
|
||||
|
||||
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.c"
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt")
|
||||
|
||||
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/vers.c"
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
|
||||
|
||||
generate_chk(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.def")
|
||||
|
||||
add_custom_target(symbol-check DEPENDS
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk")
|
||||
|
||||
generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/libpng.sym")
|
||||
generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/libpng.vers")
|
||||
|
||||
add_custom_target(genvers DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers")
|
||||
add_custom_target(gensym DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym")
|
||||
|
||||
add_custom_target("genprebuilt"
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
"-DOUTPUT=scripts/pnglibconf.h.prebuilt"
|
||||
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
# A single target handles generation of all generated files. If
|
||||
# they are dependend upon separately by multiple targets, this
|
||||
# confuses parallel make (it would require a separate top-level
|
||||
# target for each file to track the dependencies properly).
|
||||
add_custom_target(genfiles DEPENDS
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/libpng.sym"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/libpng.vers"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out")
|
||||
endif(NOT AWK OR ANDROID)
|
||||
|
||||
# OUR SOURCES
|
||||
set(libpng_public_hdrs
|
||||
png.h
|
||||
pngconf.h
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
|
||||
)
|
||||
set(libpng_private_hdrs
|
||||
pngpriv.h
|
||||
pngdebug.h
|
||||
pnginfo.h
|
||||
pngstruct.h
|
||||
)
|
||||
if(AWK AND NOT ANDROID)
|
||||
list(APPEND libpng_private_hdrs "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h")
|
||||
endif()
|
||||
set(libpng_sources
|
||||
${libpng_public_hdrs}
|
||||
${libpng_private_hdrs}
|
||||
png.c
|
||||
pngerror.c
|
||||
pngget.c
|
||||
pngmem.c
|
||||
pngpread.c
|
||||
pngread.c
|
||||
pngrio.c
|
||||
pngrtran.c
|
||||
pngrutil.c
|
||||
pngset.c
|
||||
pngtrans.c
|
||||
pngwio.c
|
||||
pngwrite.c
|
||||
pngwtran.c
|
||||
pngwutil.c
|
||||
${libpng_arm_sources}
|
||||
${libpng_intel_sources}
|
||||
${libpng_mips_sources}
|
||||
${libpng_powerpc_sources}
|
||||
)
|
||||
set(pngtest_sources
|
||||
pngtest.c
|
||||
)
|
||||
set(pngvalid_sources
|
||||
contrib/libtests/pngvalid.c
|
||||
)
|
||||
set(pngstest_sources
|
||||
contrib/libtests/pngstest.c
|
||||
)
|
||||
set(pngunknown_sources
|
||||
contrib/libtests/pngunknown.c
|
||||
)
|
||||
set(pngimage_sources
|
||||
contrib/libtests/pngimage.c
|
||||
)
|
||||
set(pngfix_sources
|
||||
contrib/tools/pngfix.c
|
||||
)
|
||||
set(png_fix_itxt_sources
|
||||
contrib/tools/png-fix-itxt.c
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
endif(MSVC)
|
||||
|
||||
if(PNG_DEBUG)
|
||||
add_definitions(-DPNG_DEBUG)
|
||||
endif()
|
||||
|
||||
# NOW BUILD OUR TARGET
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR})
|
||||
|
||||
unset(PNG_LIB_TARGETS)
|
||||
|
||||
if(PNG_SHARED)
|
||||
add_library(png SHARED ${libpng_sources})
|
||||
set(PNG_LIB_TARGETS png)
|
||||
set_target_properties(png PROPERTIES OUTPUT_NAME ${PNG_LIB_NAME})
|
||||
add_dependencies(png genfiles)
|
||||
if(MSVC)
|
||||
# msvc does not append 'lib' - do it here to have consistent name
|
||||
set_target_properties(png PROPERTIES PREFIX "lib")
|
||||
set_target_properties(png PROPERTIES IMPORT_PREFIX "lib")
|
||||
endif()
|
||||
target_link_libraries(png ${ZLIB_LIBRARY} ${M_LIBRARY})
|
||||
|
||||
if(UNIX AND AWK)
|
||||
if(HAVE_LD_VERSION_SCRIPT)
|
||||
set_target_properties(png PROPERTIES LINK_FLAGS
|
||||
"-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'")
|
||||
elseif(HAVE_SOLARIS_LD_VERSION_SCRIPT)
|
||||
set_target_properties(png PROPERTIES LINK_FLAGS
|
||||
"-Wl,-M -Wl,'${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(PNG_STATIC)
|
||||
# does not work without changing name
|
||||
set(PNG_LIB_NAME_STATIC png_static)
|
||||
add_library(png_static STATIC ${libpng_sources})
|
||||
add_dependencies(png_static genfiles)
|
||||
# MSVC doesn't use a different file extension for shared vs. static
|
||||
# libs. We are able to change OUTPUT_NAME to remove the _static
|
||||
# for all other platforms.
|
||||
if(NOT MSVC)
|
||||
set_target_properties(png_static PROPERTIES
|
||||
OUTPUT_NAME "${PNG_LIB_NAME}"
|
||||
CLEAN_DIRECT_OUTPUT 1)
|
||||
else()
|
||||
set_target_properties(png_static PROPERTIES
|
||||
OUTPUT_NAME "${PNG_LIB_NAME}_static"
|
||||
CLEAN_DIRECT_OUTPUT 1)
|
||||
endif()
|
||||
list(APPEND PNG_LIB_TARGETS png_static)
|
||||
if(MSVC)
|
||||
# msvc does not append 'lib' - do it here to have consistent name
|
||||
set_target_properties(png_static PROPERTIES PREFIX "lib")
|
||||
endif()
|
||||
target_link_libraries(png_static ${ZLIB_LIBRARY} ${M_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(PNG_FRAMEWORK)
|
||||
set(PNG_LIB_NAME_FRAMEWORK png_framework)
|
||||
add_library(png_framework SHARED ${libpng_sources})
|
||||
add_dependencies(png_framework genfiles)
|
||||
list(APPEND PNG_LIB_TARGETS png_framework)
|
||||
set_target_properties(png_framework PROPERTIES
|
||||
FRAMEWORK TRUE
|
||||
FRAMEWORK_VERSION ${PNGLIB_VERSION}
|
||||
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PNGLIB_MAJOR}.${PNGLIB_MINOR}
|
||||
MACOSX_FRAMEWORK_BUNDLE_VERSION ${PNGLIB_VERSION}
|
||||
MACOSX_FRAMEWORK_IDENTIFIER org.libpng.libpng
|
||||
XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
|
||||
PUBLIC_HEADER "${libpng_public_hdrs}"
|
||||
OUTPUT_NAME png)
|
||||
target_link_libraries(png_framework ${ZLIB_LIBRARY} ${M_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(NOT PNG_LIB_TARGETS)
|
||||
message(SEND_ERROR
|
||||
"No library variant selected to build. "
|
||||
"Please enable at least one of the following options: "
|
||||
" PNG_STATIC, PNG_SHARED, PNG_FRAMEWORK")
|
||||
endif()
|
||||
|
||||
if(PNG_SHARED AND WIN32)
|
||||
set_target_properties(png PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
|
||||
endif()
|
||||
|
||||
function(png_add_test)
|
||||
set(options)
|
||||
set(oneValueArgs NAME COMMAND)
|
||||
set(multiValueArgs OPTIONS FILES)
|
||||
cmake_parse_arguments(_PAT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if (NOT _PAT_NAME)
|
||||
message(FATAL_ERROR "Invalid arguments. png_add_test requires name.")
|
||||
endif()
|
||||
if (NOT _PAT_COMMAND)
|
||||
message(FATAL_ERROR "Invalid arguments. png_add_test requires command.")
|
||||
endif()
|
||||
|
||||
set(TEST_OPTIONS "${_PAT_OPTIONS}")
|
||||
set(TEST_FILES "${_PAT_FILES}")
|
||||
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/test.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake" @ONLY)
|
||||
if(CMAKE_MAJOR_VERSION GREATER 2) # have generator expressions
|
||||
add_test(NAME "${_PAT_NAME}"
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
"-DLIBPNG=$<TARGET_FILE:png>"
|
||||
"-DTEST_COMMAND=$<TARGET_FILE:${_PAT_COMMAND}>"
|
||||
-P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake")
|
||||
else() # old 2.x add_test; limited and won't work well on Windows
|
||||
# Note LIBPNG is a dummy value as there are no generator expressions
|
||||
add_test("${_PAT_NAME}" "${CMAKE_COMMAND}"
|
||||
"-DLIBPNG=${CMAKE_CURRENT_BINARY_DIR}/libpng.so"
|
||||
"-DTEST_COMMAND=./${_PAT_COMMAND}"
|
||||
-P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if(PNG_TESTS AND PNG_SHARED)
|
||||
# Find test PNG files by globbing, but sort lists to ensure
|
||||
# consistency between different filesystems.
|
||||
file(GLOB PNGSUITE_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/*.png")
|
||||
list(SORT PNGSUITE_PNGS)
|
||||
file(GLOB TEST_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/testpngs/*.png")
|
||||
list(SORT TEST_PNGS)
|
||||
|
||||
set(PNGTEST_PNG "${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png")
|
||||
|
||||
add_executable(pngtest ${pngtest_sources})
|
||||
target_link_libraries(pngtest png)
|
||||
|
||||
png_add_test(NAME pngtest COMMAND pngtest FILES "${PNGTEST_PNG}")
|
||||
|
||||
add_executable(pngvalid ${pngvalid_sources})
|
||||
target_link_libraries(pngvalid png)
|
||||
|
||||
png_add_test(NAME pngvalid-gamma-16-to-8
|
||||
COMMAND pngvalid OPTIONS --gamma-16-to-8)
|
||||
png_add_test(NAME pngvalid-gamma-alpha-mode
|
||||
COMMAND pngvalid OPTIONS --gamma-alpha-mode)
|
||||
png_add_test(NAME pngvalid-gamma-background
|
||||
COMMAND pngvalid OPTIONS --gamma-background)
|
||||
png_add_test(NAME pngvalid-gamma-expand16-alpha-mode
|
||||
COMMAND pngvalid OPTIONS --gamma-alpha-mode --expand16)
|
||||
png_add_test(NAME pngvalid-gamma-expand16-background
|
||||
COMMAND pngvalid OPTIONS --gamma-background --expand16)
|
||||
png_add_test(NAME pngvalid-gamma-expand16-transform
|
||||
COMMAND pngvalid OPTIONS --gamma-transform --expand16)
|
||||
png_add_test(NAME pngvalid-gamma-sbit
|
||||
COMMAND pngvalid OPTIONS --gamma-sbit)
|
||||
png_add_test(NAME pngvalid-gamma-threshold
|
||||
COMMAND pngvalid OPTIONS --gamma-threshold)
|
||||
png_add_test(NAME pngvalid-gamma-transform
|
||||
COMMAND pngvalid OPTIONS --gamma-transform)
|
||||
png_add_test(NAME pngvalid-progressive-interlace-standard
|
||||
COMMAND pngvalid OPTIONS --standard --progressive-read --interlace)
|
||||
png_add_test(NAME pngvalid-progressive-size
|
||||
COMMAND pngvalid OPTIONS --size --progressive-read)
|
||||
png_add_test(NAME pngvalid-progressive-standard
|
||||
COMMAND pngvalid OPTIONS --standard --progressive-read)
|
||||
png_add_test(NAME pngvalid-standard
|
||||
COMMAND pngvalid OPTIONS --standard)
|
||||
png_add_test(NAME pngvalid-transform
|
||||
COMMAND pngvalid OPTIONS --transform)
|
||||
|
||||
add_executable(pngstest ${pngstest_sources})
|
||||
target_link_libraries(pngstest png)
|
||||
|
||||
foreach(gamma_type 1.8 linear none sRGB)
|
||||
foreach(alpha_type none alpha)
|
||||
set(PNGSTEST_FILES)
|
||||
foreach(test_png ${TEST_PNGS})
|
||||
string(REGEX MATCH ".*-linear[-.].*" TEST_PNG_LINEAR "${test_png}")
|
||||
string(REGEX MATCH ".*-sRGB[-.].*" TEST_PNG_SRGB "${test_png}")
|
||||
string(REGEX MATCH ".*-1.8[-.].*" TEST_PNG_G18 "${test_png}")
|
||||
string(REGEX MATCH ".*-alpha-.*" TEST_PNG_ALPHA "${test_png}")
|
||||
|
||||
set(TEST_PNG_VALID TRUE)
|
||||
|
||||
if(TEST_PNG_ALPHA)
|
||||
if (NOT "${alpha_type}" STREQUAL "alpha")
|
||||
set(TEST_PNG_VALID FALSE)
|
||||
endif()
|
||||
else()
|
||||
if ("${alpha_type}" STREQUAL "alpha")
|
||||
set(TEST_PNG_VALID FALSE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TEST_PNG_LINEAR)
|
||||
if(NOT "${gamma_type}" STREQUAL "linear")
|
||||
set(TEST_PNG_VALID FALSE)
|
||||
endif()
|
||||
elseif(TEST_PNG_SRGB)
|
||||
if(NOT "${gamma_type}" STREQUAL "sRGB")
|
||||
set(TEST_PNG_VALID FALSE)
|
||||
endif()
|
||||
elseif(TEST_PNG_G18)
|
||||
if(NOT "${gamma_type}" STREQUAL "1.8")
|
||||
set(TEST_PNG_VALID FALSE)
|
||||
endif()
|
||||
else()
|
||||
if(NOT "${gamma_type}" STREQUAL "none")
|
||||
set(TEST_PNG_VALID FALSE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TEST_PNG_VALID)
|
||||
list(APPEND PNGSTEST_FILES "${test_png}")
|
||||
endif()
|
||||
endforeach()
|
||||
# Should already be sorted, but sort anyway to be certain.
|
||||
list(SORT PNGSTEST_FILES)
|
||||
png_add_test(NAME pngstest-${gamma_type}-${alpha_type}
|
||||
COMMAND pngstest
|
||||
OPTIONS --tmpfile "${gamma_type}-${alpha_type}-" --log
|
||||
FILES ${PNGSTEST_FILES})
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
add_executable(pngunknown ${pngunknown_sources})
|
||||
target_link_libraries(pngunknown png)
|
||||
|
||||
png_add_test(NAME pngunknown-discard COMMAND pngunknown OPTIONS --strict default=discard FILES "${PNGTEST_PNG}")
|
||||
png_add_test(NAME pngunknown-IDAT COMMAND pngunknown OPTIONS --strict default=discard IDAT=save FILES "${PNGTEST_PNG}")
|
||||
png_add_test(NAME pngunknown-if-safe COMMAND pngunknown OPTIONS --strict default=if-safe FILES "${PNGTEST_PNG}")
|
||||
png_add_test(NAME pngunknown-sAPI COMMAND pngunknown OPTIONS --strict bKGD=save cHRM=save gAMA=save all=discard iCCP=save sBIT=save sRGB=save FILES "${PNGTEST_PNG}")
|
||||
png_add_test(NAME pngunknown-save COMMAND pngunknown OPTIONS --strict default=save FILES "${PNGTEST_PNG}")
|
||||
png_add_test(NAME pngunknown-sTER COMMAND pngunknown OPTIONS --strict sTER=if-safe FILES "${PNGTEST_PNG}")
|
||||
png_add_test(NAME pngunknown-vpAg COMMAND pngunknown OPTIONS --strict vpAg=if-safe FILES "${PNGTEST_PNG}")
|
||||
|
||||
add_executable(pngimage ${pngimage_sources})
|
||||
target_link_libraries(pngimage png)
|
||||
|
||||
png_add_test(NAME pngimage-quick COMMAND pngimage OPTIONS --list-combos --log FILES ${PNGSUITE_PNGS})
|
||||
png_add_test(NAME pngimage-full COMMAND pngimage OPTIONS --exhaustive --list-combos --log FILES ${PNGSUITE_PNGS})
|
||||
endif()
|
||||
|
||||
if(PNG_SHARED)
|
||||
add_executable(pngfix ${pngfix_sources})
|
||||
target_link_libraries(pngfix png)
|
||||
set(PNG_BIN_TARGETS pngfix)
|
||||
|
||||
add_executable(png-fix-itxt ${png_fix_itxt_sources})
|
||||
target_link_libraries(png-fix-itxt ${ZLIB_LIBRARY} ${M_LIBRARY})
|
||||
list(APPEND PNG_BIN_TARGETS png-fix-itxt)
|
||||
endif()
|
||||
|
||||
# Set a variable with CMake code which:
|
||||
# Creates a symlink from src to dest (if possible) or alternatively
|
||||
# copies if different.
|
||||
include(CMakeParseArguments)
|
||||
|
||||
function(CREATE_SYMLINK DEST_FILE)
|
||||
|
||||
cmake_parse_arguments(S "" "FILE;TARGET" "" ${ARGN})
|
||||
|
||||
if(NOT S_TARGET AND NOT S_FILE)
|
||||
message(FATAL_ERROR "Specify either a TARGET or a FILE for CREATE_SYMLINK to link to.")
|
||||
endif(NOT S_TARGET AND NOT S_FILE)
|
||||
|
||||
if(S_TARGET AND S_FILE)
|
||||
message(FATAL_ERROR "CREATE_SYMLINK called with both source file ${S_FILE} and build target ${S_TARGET} arguments - can only handle 1 type per call.")
|
||||
endif(S_TARGET AND S_FILE)
|
||||
|
||||
if(S_FILE)
|
||||
# If we don't need to symlink something that's coming from a build target,
|
||||
# we can go ahead and symlink/copy at configure time.
|
||||
|
||||
if(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
execute_process(
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${S_FILE} ${DEST_FILE}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
)
|
||||
else(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink ${S_FILE} ${DEST_FILE}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
)
|
||||
endif(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
endif(S_FILE)
|
||||
|
||||
if(S_TARGET)
|
||||
# We need to use generator expressions, which can be a bit tricky, so for
|
||||
# simplicity make the symlink a POST_BUILD step and use the TARGET
|
||||
# signature of add_custom_command.
|
||||
|
||||
if(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
add_custom_command(TARGET ${S_TARGET} POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different $<TARGET_LINKER_FILE_NAME:${S_TARGET}> $<TARGET_LINKER_FILE_DIR:${S_TARGET}>/${DEST_FILE}
|
||||
)
|
||||
else(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
add_custom_command(TARGET ${S_TARGET} POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E create_symlink $<TARGET_LINKER_FILE_NAME:${S_TARGET}> $<TARGET_LINKER_FILE_DIR:${S_TARGET}>/${DEST_FILE}
|
||||
)
|
||||
endif(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
|
||||
endif(S_TARGET)
|
||||
|
||||
endfunction()
|
||||
|
||||
# Create source generation scripts.
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genchk.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake @ONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genout.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake @ONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/gensrc.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake @ONLY)
|
||||
|
||||
|
||||
# libpng is a library so default to 'lib'
|
||||
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
||||
set(CMAKE_INSTALL_LIBDIR lib)
|
||||
endif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
||||
|
||||
# CREATE PKGCONFIG FILES
|
||||
# we use the same files like ./configure, so we have to set its vars
|
||||
# Only do this on Windows for Cygwin - the files don't make much sense outside
|
||||
# a UNIX look alike
|
||||
if(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
set(prefix ${CMAKE_INSTALL_PREFIX})
|
||||
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
|
||||
set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
|
||||
set(includedir ${CMAKE_INSTALL_PREFIX}/include)
|
||||
set(LIBS "-lz -lm")
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY)
|
||||
CREATE_SYMLINK(libpng.pc FILE ${PNGLIB_NAME}.pc)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY)
|
||||
CREATE_SYMLINK(libpng-config FILE ${PNGLIB_NAME}-config)
|
||||
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
|
||||
# SET UP LINKS
|
||||
if(PNG_SHARED)
|
||||
set_target_properties(png PROPERTIES
|
||||
# VERSION 16.${PNGLIB_RELEASE}.1.6.34
|
||||
VERSION 16.${PNGLIB_RELEASE}.0
|
||||
SOVERSION 16
|
||||
CLEAN_DIRECT_OUTPUT 1)
|
||||
endif()
|
||||
|
||||
# If CMake > 2.4.x, we set a variable used below to export
|
||||
# targets to an export file.
|
||||
# TODO: Use VERSION_GREATER after our cmake_minimum_required >= 2.6.2
|
||||
if(CMAKE_MAJOR_VERSION GREATER 1 AND CMAKE_MINOR_VERSION GREATER 4)
|
||||
set(PNG_EXPORT_RULE EXPORT libpng)
|
||||
elseif(CMAKE_MAJOR_VERSION GREATER 2) # future proof
|
||||
set(PNG_EXPORT_RULE EXPORT libpng)
|
||||
endif()
|
||||
|
||||
# INSTALL
|
||||
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
|
||||
install(TARGETS ${PNG_LIB_TARGETS}
|
||||
${PNG_EXPORT_RULE}
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
if(PNG_SHARED)
|
||||
# Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin
|
||||
if(CYGWIN OR MINGW)
|
||||
CREATE_SYMLINK(libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} TARGET png)
|
||||
install(FILES $<TARGET_LINKER_FILE_DIR:png>/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif(CYGWIN OR MINGW)
|
||||
|
||||
if(NOT WIN32)
|
||||
CREATE_SYMLINK(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png)
|
||||
install(FILES $<TARGET_LINKER_FILE_DIR:png>/libpng${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif(NOT WIN32)
|
||||
endif(PNG_SHARED)
|
||||
|
||||
if(PNG_STATIC)
|
||||
if(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
CREATE_SYMLINK( libpng${CMAKE_STATIC_LIBRARY_SUFFIX} TARGET png_static)
|
||||
install(FILES $<TARGET_LINKER_FILE_DIR:png_static>/libpng${CMAKE_STATIC_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
|
||||
install(FILES ${libpng_public_hdrs} DESTINATION include)
|
||||
install(FILES ${libpng_public_hdrs} DESTINATION include/${PNGLIB_NAME})
|
||||
endif()
|
||||
if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL )
|
||||
if(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION bin)
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
|
||||
DESTINATION bin)
|
||||
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_INSTALL_PROGRAMS AND NOT SKIP_INSTALL_ALL )
|
||||
install(TARGETS ${PNG_BIN_TARGETS}
|
||||
RUNTIME DESTINATION bin)
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
|
||||
# Install man pages
|
||||
if(NOT PNG_MAN_DIR)
|
||||
set(PNG_MAN_DIR "share/man")
|
||||
endif()
|
||||
install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3)
|
||||
install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5)
|
||||
# Install pkg-config files
|
||||
if(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config
|
||||
DESTINATION bin)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
|
||||
DESTINATION bin)
|
||||
endif(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW)
|
||||
endif()
|
||||
|
||||
# On versions of CMake that support it, create an export file CMake
|
||||
# users can include() to import our targets
|
||||
if(PNG_EXPORT_RULE AND NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL )
|
||||
install(EXPORT libpng DESTINATION lib/libpng FILE lib${PNG_LIB_NAME}.cmake)
|
||||
endif()
|
||||
|
||||
# what's with libpng-manual.txt and all the extra files?
|
||||
|
||||
# UNINSTALL
|
||||
# do we need this?
|
||||
|
||||
# DIST
|
||||
# do we need this?
|
||||
|
||||
# to create msvc import lib for mingw compiled shared lib
|
||||
# pexports libpng.dll > libpng.def
|
||||
# lib /def:libpng.def /machine:x86
|
@ -1,133 +0,0 @@
|
||||
|
||||
This copy of the libpng notices is provided for your convenience. In case of
|
||||
any discrepancy between this copy and the notices in the file png.h that is
|
||||
included in the libpng distribution, the latter shall prevail.
|
||||
|
||||
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
|
||||
|
||||
If you modify libpng you may insert additional notices immediately following
|
||||
this sentence.
|
||||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.0.7, July 1, 2000 through 1.6.34, September 29, 2017 are
|
||||
Copyright (c) 2000-2002, 2004, 2006-2017 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
|
||||
Mandar Sahastrabuddhe
|
||||
Google Inc.
|
||||
Vadim Barkov
|
||||
|
||||
and with the following additions to the disclaimer:
|
||||
|
||||
There is no warranty against interference with your enjoyment of the
|
||||
library or against infringement. There is no warranty that our
|
||||
efforts or the library will fulfill any of your particular purposes
|
||||
or needs. This library is provided with all faults, and the entire
|
||||
risk of satisfactory quality, performance, accuracy, and effort is with
|
||||
the user.
|
||||
|
||||
Some files in the "contrib" directory and some configure-generated
|
||||
files that are distributed with libpng have other copyright owners and
|
||||
are released under other open source licenses.
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
||||
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, 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
|
||||
Sam Bushell
|
||||
Magnus Holmgren
|
||||
Greg Roelofs
|
||||
Tom Tanner
|
||||
|
||||
Some files in the "scripts" directory have other copyright owners
|
||||
but are released under this license.
|
||||
|
||||
libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
||||
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:
|
||||
|
||||
Andreas Dilger
|
||||
Dave Martindale
|
||||
Guy Eric Schalnat
|
||||
Paul Schmidt
|
||||
Tim Wegner
|
||||
|
||||
The PNG Reference Library is supplied "AS IS". The Contributing Authors
|
||||
and Group 42, Inc. disclaim all warranties, expressed or implied,
|
||||
including, without limitation, the warranties of merchantability and of
|
||||
fitness for any purpose. The Contributing Authors and Group 42, Inc.
|
||||
assume no liability for direct, indirect, incidental, special, exemplary,
|
||||
or consequential damages, which may result from the use of the PNG
|
||||
Reference Library, even if advised of the possibility of such damage.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
The Contributing Authors and Group 42, Inc. specifically permit, without
|
||||
fee, and encourage the use of this source code as a component to
|
||||
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.
|
||||
|
||||
TRADEMARK:
|
||||
|
||||
The name "libpng" has not been registered by the Copyright owner
|
||||
as a trademark in any jurisdiction. However, because libpng has
|
||||
been distributed and maintained world-wide, continually since 1995,
|
||||
the Copyright owner claims "common-law trademark protection" in any
|
||||
jurisdiction where common-law trademark is recognized.
|
||||
|
||||
OSI CERTIFICATION:
|
||||
|
||||
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.
|
||||
|
||||
EXPORT CONTROL:
|
||||
|
||||
The Copyright owner believes 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).
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
September 29, 2017
|
@ -1,135 +0,0 @@
|
||||
|
||||
/* arm_init.c - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2014,2016 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.6.22 [May 26, 2016]
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
png_debug(1, "in png_init_filter_functions_neon");
|
||||
#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 */
|
@ -1,253 +0,0 @@
|
||||
|
||||
/* filter_neon.S - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2014,2017 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.6.31 [July 27, 2017]
|
||||
*
|
||||
* 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(__FreeBSD__)) && 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
|
||||
# define ELF @
|
||||
#endif
|
||||
|
||||
.arch armv7-a
|
||||
.fpu neon
|
||||
|
||||
.macro func name, export=0
|
||||
.macro endfunc
|
||||
ELF .size \name, . - \name
|
||||
.endfunc
|
||||
.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
|
||||
ELF .type \name, STT_FUNC
|
||||
.func \name
|
||||
\name:
|
||||
.endm
|
||||
|
||||
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,: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,:128]!
|
||||
subs r3, r3, #16
|
||||
bgt 1b
|
||||
|
||||
bx lr
|
||||
endfunc
|
||||
|
||||
func png_read_filter_row_sub3_neon, export=1
|
||||
ldr r3, [r0, #4] @ rowbytes
|
||||
vmov.i8 d3, #0
|
||||
mov r0, r1
|
||||
mov r2, #3
|
||||
mov r12, #12
|
||||
vld1.8 {q11}, [r0], r12
|
||||
1:
|
||||
vext.8 d5, d22, d23, #3
|
||||
vadd.u8 d0, d3, d22
|
||||
vext.8 d6, d22, d23, #6
|
||||
vadd.u8 d1, d0, d5
|
||||
vext.8 d7, d23, d23, #1
|
||||
vld1.8 {q11}, [r0], r12
|
||||
vst1.32 {d0[0]}, [r1,:32], r2
|
||||
vadd.u8 d2, d1, d6
|
||||
vst1.32 {d1[0]}, [r1], r2
|
||||
vadd.u8 d3, d2, d7
|
||||
vst1.32 {d2[0]}, [r1], r2
|
||||
vst1.32 {d3[0]}, [r1], r2
|
||||
subs r3, r3, #12
|
||||
bgt 1b
|
||||
|
||||
bx lr
|
||||
endfunc
|
||||
|
||||
func png_read_filter_row_up_neon, export=1
|
||||
ldr r3, [r0, #4] @ rowbytes
|
||||
1:
|
||||
vld1.8 {q0}, [r1,:128]
|
||||
vld1.8 {q1}, [r2,:128]!
|
||||
vadd.u8 q0, q0, q1
|
||||
vst1.8 {q0}, [r1,:128]!
|
||||
subs r3, r3, #16
|
||||
bgt 1b
|
||||
|
||||
bx lr
|
||||
endfunc
|
||||
|
||||
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,:128]
|
||||
vld4.32 {d16[],d17[],d18[],d19[]},[r2,:128]!
|
||||
vhadd.u8 d0, d3, d16
|
||||
vadd.u8 d0, d0, d4
|
||||
vhadd.u8 d1, d0, d17
|
||||
vadd.u8 d1, d1, d5
|
||||
vhadd.u8 d2, d1, d18
|
||||
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,:128]!
|
||||
subs r12, r12, #16
|
||||
bgt 1b
|
||||
|
||||
bx lr
|
||||
endfunc
|
||||
|
||||
func png_read_filter_row_avg3_neon, export=1
|
||||
push {r4,lr}
|
||||
ldr r12, [r0, #4] @ rowbytes
|
||||
vmov.i8 d3, #0
|
||||
mov r0, r1
|
||||
mov r4, #3
|
||||
mov lr, #12
|
||||
vld1.8 {q11}, [r0], lr
|
||||
1:
|
||||
vld1.8 {q10}, [r2], lr
|
||||
vext.8 d5, d22, d23, #3
|
||||
vhadd.u8 d0, d3, d20
|
||||
vext.8 d17, d20, d21, #3
|
||||
vadd.u8 d0, d0, d22
|
||||
vext.8 d6, d22, d23, #6
|
||||
vhadd.u8 d1, d0, d17
|
||||
vext.8 d18, d20, d21, #6
|
||||
vadd.u8 d1, d1, d5
|
||||
vext.8 d7, d23, d23, #1
|
||||
vld1.8 {q11}, [r0], lr
|
||||
vst1.32 {d0[0]}, [r1,:32], r4
|
||||
vhadd.u8 d2, d1, d18
|
||||
vst1.32 {d1[0]}, [r1], r4
|
||||
vext.8 d19, d21, d21, #1
|
||||
vadd.u8 d2, d2, d6
|
||||
vhadd.u8 d3, d2, d19
|
||||
vst1.32 {d2[0]}, [r1], r4
|
||||
vadd.u8 d3, d3, d7
|
||||
vst1.32 {d3[0]}, [r1], r4
|
||||
subs r12, r12, #12
|
||||
bgt 1b
|
||||
|
||||
pop {r4,pc}
|
||||
endfunc
|
||||
|
||||
.macro paeth rx, ra, rb, rc
|
||||
vaddl.u8 q12, \ra, \rb @ a + b
|
||||
vaddl.u8 q15, \rc, \rc @ 2*c
|
||||
vabdl.u8 q13, \rb, \rc @ pa
|
||||
vabdl.u8 q14, \ra, \rc @ pb
|
||||
vabd.u16 q15, q12, q15 @ pc
|
||||
vcle.u16 q12, q13, q14 @ pa <= pb
|
||||
vcle.u16 q13, q13, q15 @ pa <= pc
|
||||
vcle.u16 q14, q14, q15 @ pb <= pc
|
||||
vand q12, q12, q13 @ pa <= pb && pa <= pc
|
||||
vmovn.u16 d28, q14
|
||||
vmovn.u16 \rx, q12
|
||||
vbsl d28, \rb, \rc
|
||||
vbsl \rx, \ra, d28
|
||||
.endm
|
||||
|
||||
func png_read_filter_row_paeth4_neon, export=1
|
||||
ldr r12, [r0, #4] @ rowbytes
|
||||
vmov.i8 d3, #0
|
||||
vmov.i8 d20, #0
|
||||
1:
|
||||
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
|
||||
vadd.u8 d1, d1, d5
|
||||
paeth d2, d1, d18, d17
|
||||
vadd.u8 d2, d2, d6
|
||||
paeth d3, d2, d19, d18
|
||||
vmov d20, d19
|
||||
vadd.u8 d3, d3, d7
|
||||
vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]!
|
||||
subs r12, r12, #16
|
||||
bgt 1b
|
||||
|
||||
bx lr
|
||||
endfunc
|
||||
|
||||
func png_read_filter_row_paeth3_neon, export=1
|
||||
push {r4,lr}
|
||||
ldr r12, [r0, #4] @ rowbytes
|
||||
vmov.i8 d3, #0
|
||||
vmov.i8 d4, #0
|
||||
mov r0, r1
|
||||
mov r4, #3
|
||||
mov lr, #12
|
||||
vld1.8 {q11}, [r0], lr
|
||||
1:
|
||||
vld1.8 {q10}, [r2], lr
|
||||
paeth d0, d3, d20, d4
|
||||
vext.8 d5, d22, d23, #3
|
||||
vadd.u8 d0, d0, d22
|
||||
vext.8 d17, d20, d21, #3
|
||||
paeth d1, d0, d17, d20
|
||||
vst1.32 {d0[0]}, [r1,:32], r4
|
||||
vext.8 d6, d22, d23, #6
|
||||
vadd.u8 d1, d1, d5
|
||||
vext.8 d18, d20, d21, #6
|
||||
paeth d2, d1, d18, d17
|
||||
vext.8 d7, d23, d23, #1
|
||||
vld1.8 {q11}, [r0], lr
|
||||
vst1.32 {d1[0]}, [r1], r4
|
||||
vadd.u8 d2, d2, d6
|
||||
vext.8 d19, d21, d21, #1
|
||||
paeth d3, d2, d19, d18
|
||||
vst1.32 {d2[0]}, [r1], r4
|
||||
vmov d4, d19
|
||||
vadd.u8 d3, d3, d7
|
||||
vst1.32 {d3[0]}, [r1], r4
|
||||
subs r12, r12, #12
|
||||
bgt 1b
|
||||
|
||||
pop {r4,pc}
|
||||
endfunc
|
||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||
#endif /* PNG_ARM_NEON_IMPLEMENTATION == 2 (assembler) */
|
||||
#endif /* READ */
|
@ -1,387 +0,0 @@
|
||||
|
||||
/* filter_neon_intrinsics.c - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2014,2016 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.22 [May 26, 2016]
|
||||
*
|
||||
* 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;
|
||||
|
||||
png_debug(1, "in png_read_filter_row_up_neon");
|
||||
|
||||
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);
|
||||
|
||||
png_debug(1, "in png_read_filter_row_sub3_neon");
|
||||
|
||||
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);
|
||||
|
||||
png_debug(1, "in png_read_filter_row_sub4_neon");
|
||||
|
||||
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;
|
||||
|
||||
png_debug(1, "in png_read_filter_row_avg3_neon");
|
||||
|
||||
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);
|
||||
|
||||
png_debug(1, "in png_read_filter_row_avg4_neon");
|
||||
|
||||
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;
|
||||
|
||||
png_debug(1, "in png_read_filter_row_paeth3_neon");
|
||||
|
||||
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);
|
||||
|
||||
png_debug(1, "in png_read_filter_row_paeth4_neon");
|
||||
|
||||
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 */
|
@ -1,406 +0,0 @@
|
||||
|
||||
/* filter_sse2_intrinsics.c - SSE2 optimized filter functions
|
||||
*
|
||||
* Copyright (c) 2016-2017 Glenn Randers-Pehrson
|
||||
* Written by Mike Klein and Matt Sarett
|
||||
* Derived from arm/filter_neon_intrinsics.c
|
||||
*
|
||||
* Last changed in libpng 1.6.31 [July 27, 2017]
|
||||
*
|
||||
* 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
|
||||
|
||||
#if PNG_INTEL_SSE_IMPLEMENTATION > 0
|
||||
|
||||
#include <immintrin.h>
|
||||
|
||||
/* Functions in this file look at most 3 pixels (a,b,c) to predict the 4th (d).
|
||||
* They're positioned like this:
|
||||
* prev: c b
|
||||
* row: a d
|
||||
* The Sub filter predicts d=a, Avg d=(a+b)/2, and Paeth predicts d to be
|
||||
* whichever of a, b, or c is closest to p=a+b-c.
|
||||
*/
|
||||
|
||||
static __m128i load4(const void* p) {
|
||||
return _mm_cvtsi32_si128(*(const int*)p);
|
||||
}
|
||||
|
||||
static void store4(void* p, __m128i v) {
|
||||
*(int*)p = _mm_cvtsi128_si32(v);
|
||||
}
|
||||
|
||||
static __m128i load3(const void* p) {
|
||||
/* We'll load 2 bytes, then 1 byte,
|
||||
* then mask them together, and finally load into SSE.
|
||||
*/
|
||||
const png_uint_16* p01 = (png_const_uint_16p)p;
|
||||
const png_byte* p2 = (const png_byte*)(p01+1);
|
||||
|
||||
png_uint_32 v012 = (png_uint_32)(*p01)
|
||||
| (png_uint_32)(*p2) << 16;
|
||||
return load4(&v012);
|
||||
}
|
||||
|
||||
static void store3(void* p, __m128i v) {
|
||||
/* We'll pull from SSE as a 32-bit int, then write
|
||||
* its bottom two bytes, then its third byte.
|
||||
*/
|
||||
png_uint_32 v012;
|
||||
png_uint_16* p01;
|
||||
png_byte* p2;
|
||||
|
||||
store4(&v012, v);
|
||||
|
||||
p01 = (png_uint_16p)p;
|
||||
p2 = (png_byte*)(p01+1);
|
||||
*p01 = (png_uint_16)v012;
|
||||
*p2 = (png_byte)(v012 >> 16);
|
||||
}
|
||||
|
||||
void png_read_filter_row_sub3_sse2(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev)
|
||||
{
|
||||
/* The Sub filter predicts each pixel as the previous pixel, a.
|
||||
* There is no pixel to the left of the first pixel. It's encoded directly.
|
||||
* That works with our main loop if we just say that left pixel was zero.
|
||||
*/
|
||||
png_size_t rb;
|
||||
|
||||
__m128i a, d = _mm_setzero_si128();
|
||||
|
||||
png_debug(1, "in png_read_filter_row_sub3_sse2");
|
||||
|
||||
rb = row_info->rowbytes;
|
||||
while (rb >= 4) {
|
||||
a = d; d = load4(row);
|
||||
d = _mm_add_epi8(d, a);
|
||||
store3(row, d);
|
||||
|
||||
row += 3;
|
||||
rb -= 3;
|
||||
}
|
||||
if (rb > 0) {
|
||||
a = d; d = load3(row);
|
||||
d = _mm_add_epi8(d, a);
|
||||
store3(row, d);
|
||||
|
||||
row += 3;
|
||||
rb -= 3;
|
||||
}
|
||||
PNG_UNUSED(prev)
|
||||
}
|
||||
|
||||
void png_read_filter_row_sub4_sse2(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev)
|
||||
{
|
||||
/* The Sub filter predicts each pixel as the previous pixel, a.
|
||||
* There is no pixel to the left of the first pixel. It's encoded directly.
|
||||
* That works with our main loop if we just say that left pixel was zero.
|
||||
*/
|
||||
png_size_t rb;
|
||||
|
||||
__m128i a, d = _mm_setzero_si128();
|
||||
|
||||
png_debug(1, "in png_read_filter_row_sub4_sse2");
|
||||
|
||||
rb = row_info->rowbytes+4;
|
||||
while (rb > 4) {
|
||||
a = d; d = load4(row);
|
||||
d = _mm_add_epi8(d, a);
|
||||
store4(row, d);
|
||||
|
||||
row += 4;
|
||||
rb -= 4;
|
||||
}
|
||||
PNG_UNUSED(prev)
|
||||
}
|
||||
|
||||
void png_read_filter_row_avg3_sse2(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev)
|
||||
{
|
||||
/* The Avg filter predicts each pixel as the (truncated) average of a and b.
|
||||
* There's no pixel to the left of the first pixel. Luckily, it's
|
||||
* predicted to be half of the pixel above it. So again, this works
|
||||
* perfectly with our loop if we make sure a starts at zero.
|
||||
*/
|
||||
|
||||
png_size_t rb;
|
||||
|
||||
const __m128i zero = _mm_setzero_si128();
|
||||
|
||||
__m128i b;
|
||||
__m128i a, d = zero;
|
||||
|
||||
png_debug(1, "in png_read_filter_row_avg3_sse2");
|
||||
rb = row_info->rowbytes;
|
||||
while (rb >= 4) {
|
||||
__m128i avg;
|
||||
b = load4(prev);
|
||||
a = d; d = load4(row );
|
||||
|
||||
/* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */
|
||||
avg = _mm_avg_epu8(a,b);
|
||||
/* ...but we can fix it up by subtracting off 1 if it rounded up. */
|
||||
avg = _mm_sub_epi8(avg, _mm_and_si128(_mm_xor_si128(a,b),
|
||||
_mm_set1_epi8(1)));
|
||||
d = _mm_add_epi8(d, avg);
|
||||
store3(row, d);
|
||||
|
||||
prev += 3;
|
||||
row += 3;
|
||||
rb -= 3;
|
||||
}
|
||||
if (rb > 0) {
|
||||
__m128i avg;
|
||||
b = load3(prev);
|
||||
a = d; d = load3(row );
|
||||
|
||||
/* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */
|
||||
avg = _mm_avg_epu8(a,b);
|
||||
/* ...but we can fix it up by subtracting off 1 if it rounded up. */
|
||||
avg = _mm_sub_epi8(avg, _mm_and_si128(_mm_xor_si128(a,b),
|
||||
_mm_set1_epi8(1)));
|
||||
|
||||
d = _mm_add_epi8(d, avg);
|
||||
store3(row, d);
|
||||
|
||||
prev += 3;
|
||||
row += 3;
|
||||
rb -= 3;
|
||||
}
|
||||
}
|
||||
|
||||
void png_read_filter_row_avg4_sse2(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev)
|
||||
{
|
||||
/* The Avg filter predicts each pixel as the (truncated) average of a and b.
|
||||
* There's no pixel to the left of the first pixel. Luckily, it's
|
||||
* predicted to be half of the pixel above it. So again, this works
|
||||
* perfectly with our loop if we make sure a starts at zero.
|
||||
*/
|
||||
png_size_t rb;
|
||||
const __m128i zero = _mm_setzero_si128();
|
||||
__m128i b;
|
||||
__m128i a, d = zero;
|
||||
|
||||
png_debug(1, "in png_read_filter_row_avg4_sse2");
|
||||
|
||||
rb = row_info->rowbytes+4;
|
||||
while (rb > 4) {
|
||||
__m128i avg;
|
||||
b = load4(prev);
|
||||
a = d; d = load4(row );
|
||||
|
||||
/* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */
|
||||
avg = _mm_avg_epu8(a,b);
|
||||
/* ...but we can fix it up by subtracting off 1 if it rounded up. */
|
||||
avg = _mm_sub_epi8(avg, _mm_and_si128(_mm_xor_si128(a,b),
|
||||
_mm_set1_epi8(1)));
|
||||
|
||||
d = _mm_add_epi8(d, avg);
|
||||
store4(row, d);
|
||||
|
||||
prev += 4;
|
||||
row += 4;
|
||||
rb -= 4;
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns |x| for 16-bit lanes. */
|
||||
static __m128i abs_i16(__m128i x) {
|
||||
#if PNG_INTEL_SSE_IMPLEMENTATION >= 2
|
||||
return _mm_abs_epi16(x);
|
||||
#else
|
||||
/* Read this all as, return x<0 ? -x : x.
|
||||
* To negate two's complement, you flip all the bits then add 1.
|
||||
*/
|
||||
__m128i is_negative = _mm_cmplt_epi16(x, _mm_setzero_si128());
|
||||
|
||||
/* Flip negative lanes. */
|
||||
x = _mm_xor_si128(x, is_negative);
|
||||
|
||||
/* +1 to negative lanes, else +0. */
|
||||
x = _mm_sub_epi16(x, is_negative);
|
||||
return x;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Bytewise c ? t : e. */
|
||||
static __m128i if_then_else(__m128i c, __m128i t, __m128i e) {
|
||||
#if PNG_INTEL_SSE_IMPLEMENTATION >= 3
|
||||
return _mm_blendv_epi8(e,t,c);
|
||||
#else
|
||||
return _mm_or_si128(_mm_and_si128(c, t), _mm_andnot_si128(c, e));
|
||||
#endif
|
||||
}
|
||||
|
||||
void png_read_filter_row_paeth3_sse2(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev)
|
||||
{
|
||||
/* Paeth tries to predict pixel d using the pixel to the left of it, a,
|
||||
* and two pixels from the previous row, b and c:
|
||||
* prev: c b
|
||||
* row: a d
|
||||
* The Paeth function predicts d to be whichever of a, b, or c is nearest to
|
||||
* p=a+b-c.
|
||||
*
|
||||
* The first pixel has no left context, and so uses an Up filter, p = b.
|
||||
* This works naturally with our main loop's p = a+b-c if we force a and c
|
||||
* to zero.
|
||||
* Here we zero b and d, which become c and a respectively at the start of
|
||||
* the loop.
|
||||
*/
|
||||
png_size_t rb;
|
||||
const __m128i zero = _mm_setzero_si128();
|
||||
__m128i c, b = zero,
|
||||
a, d = zero;
|
||||
|
||||
png_debug(1, "in png_read_filter_row_paeth3_sse2");
|
||||
|
||||
rb = row_info->rowbytes;
|
||||
while (rb >= 4) {
|
||||
/* It's easiest to do this math (particularly, deal with pc) with 16-bit
|
||||
* intermediates.
|
||||
*/
|
||||
__m128i pa,pb,pc,smallest,nearest;
|
||||
c = b; b = _mm_unpacklo_epi8(load4(prev), zero);
|
||||
a = d; d = _mm_unpacklo_epi8(load4(row ), zero);
|
||||
|
||||
/* (p-a) == (a+b-c - a) == (b-c) */
|
||||
|
||||
pa = _mm_sub_epi16(b,c);
|
||||
|
||||
/* (p-b) == (a+b-c - b) == (a-c) */
|
||||
pb = _mm_sub_epi16(a,c);
|
||||
|
||||
/* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */
|
||||
pc = _mm_add_epi16(pa,pb);
|
||||
|
||||
pa = abs_i16(pa); /* |p-a| */
|
||||
pb = abs_i16(pb); /* |p-b| */
|
||||
pc = abs_i16(pc); /* |p-c| */
|
||||
|
||||
smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb));
|
||||
|
||||
/* Paeth breaks ties favoring a over b over c. */
|
||||
nearest = if_then_else(_mm_cmpeq_epi16(smallest, pa), a,
|
||||
if_then_else(_mm_cmpeq_epi16(smallest, pb), b,
|
||||
c));
|
||||
|
||||
/* Note `_epi8`: we need addition to wrap modulo 255. */
|
||||
d = _mm_add_epi8(d, nearest);
|
||||
store3(row, _mm_packus_epi16(d,d));
|
||||
|
||||
prev += 3;
|
||||
row += 3;
|
||||
rb -= 3;
|
||||
}
|
||||
if (rb > 0) {
|
||||
/* It's easiest to do this math (particularly, deal with pc) with 16-bit
|
||||
* intermediates.
|
||||
*/
|
||||
__m128i pa,pb,pc,smallest,nearest;
|
||||
c = b; b = _mm_unpacklo_epi8(load3(prev), zero);
|
||||
a = d; d = _mm_unpacklo_epi8(load3(row ), zero);
|
||||
|
||||
/* (p-a) == (a+b-c - a) == (b-c) */
|
||||
pa = _mm_sub_epi16(b,c);
|
||||
|
||||
/* (p-b) == (a+b-c - b) == (a-c) */
|
||||
pb = _mm_sub_epi16(a,c);
|
||||
|
||||
/* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */
|
||||
pc = _mm_add_epi16(pa,pb);
|
||||
|
||||
pa = abs_i16(pa); /* |p-a| */
|
||||
pb = abs_i16(pb); /* |p-b| */
|
||||
pc = abs_i16(pc); /* |p-c| */
|
||||
|
||||
smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb));
|
||||
|
||||
/* Paeth breaks ties favoring a over b over c. */
|
||||
nearest = if_then_else(_mm_cmpeq_epi16(smallest, pa), a,
|
||||
if_then_else(_mm_cmpeq_epi16(smallest, pb), b,
|
||||
c));
|
||||
|
||||
/* Note `_epi8`: we need addition to wrap modulo 255. */
|
||||
d = _mm_add_epi8(d, nearest);
|
||||
store3(row, _mm_packus_epi16(d,d));
|
||||
|
||||
prev += 3;
|
||||
row += 3;
|
||||
rb -= 3;
|
||||
}
|
||||
}
|
||||
|
||||
void png_read_filter_row_paeth4_sse2(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev)
|
||||
{
|
||||
/* Paeth tries to predict pixel d using the pixel to the left of it, a,
|
||||
* and two pixels from the previous row, b and c:
|
||||
* prev: c b
|
||||
* row: a d
|
||||
* The Paeth function predicts d to be whichever of a, b, or c is nearest to
|
||||
* p=a+b-c.
|
||||
*
|
||||
* The first pixel has no left context, and so uses an Up filter, p = b.
|
||||
* This works naturally with our main loop's p = a+b-c if we force a and c
|
||||
* to zero.
|
||||
* Here we zero b and d, which become c and a respectively at the start of
|
||||
* the loop.
|
||||
*/
|
||||
png_size_t rb;
|
||||
const __m128i zero = _mm_setzero_si128();
|
||||
__m128i pa,pb,pc,smallest,nearest;
|
||||
__m128i c, b = zero,
|
||||
a, d = zero;
|
||||
|
||||
png_debug(1, "in png_read_filter_row_paeth4_sse2");
|
||||
|
||||
rb = row_info->rowbytes+4;
|
||||
while (rb > 4) {
|
||||
/* It's easiest to do this math (particularly, deal with pc) with 16-bit
|
||||
* intermediates.
|
||||
*/
|
||||
c = b; b = _mm_unpacklo_epi8(load4(prev), zero);
|
||||
a = d; d = _mm_unpacklo_epi8(load4(row ), zero);
|
||||
|
||||
/* (p-a) == (a+b-c - a) == (b-c) */
|
||||
pa = _mm_sub_epi16(b,c);
|
||||
|
||||
/* (p-b) == (a+b-c - b) == (a-c) */
|
||||
pb = _mm_sub_epi16(a,c);
|
||||
|
||||
/* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */
|
||||
pc = _mm_add_epi16(pa,pb);
|
||||
|
||||
pa = abs_i16(pa); /* |p-a| */
|
||||
pb = abs_i16(pb); /* |p-b| */
|
||||
pc = abs_i16(pc); /* |p-c| */
|
||||
|
||||
smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb));
|
||||
|
||||
/* Paeth breaks ties favoring a over b over c. */
|
||||
nearest = if_then_else(_mm_cmpeq_epi16(smallest, pa), a,
|
||||
if_then_else(_mm_cmpeq_epi16(smallest, pb), b,
|
||||
c));
|
||||
|
||||
/* Note `_epi8`: we need addition to wrap modulo 255. */
|
||||
d = _mm_add_epi8(d, nearest);
|
||||
store4(row, _mm_packus_epi16(d,d));
|
||||
|
||||
prev += 4;
|
||||
row += 4;
|
||||
rb -= 4;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* PNG_INTEL_SSE_IMPLEMENTATION > 0 */
|
||||
#endif /* READ */
|
@ -1,53 +0,0 @@
|
||||
|
||||
/* intel_init.c - SSE2 optimized filter functions
|
||||
*
|
||||
* Copyright (c) 2016-2017 Glenn Randers-Pehrson
|
||||
* Written by Mike Klein and Matt Sarett, Google, Inc.
|
||||
* Derived from arm/arm_init.c
|
||||
*
|
||||
* Last changed in libpng 1.6.29 [March 16, 2017]
|
||||
*
|
||||
* 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
|
||||
#if PNG_INTEL_SSE_IMPLEMENTATION > 0
|
||||
|
||||
void
|
||||
png_init_filter_functions_sse2(png_structp pp, unsigned int bpp)
|
||||
{
|
||||
/* The techniques used to implement each of these filters in SSE operate on
|
||||
* one pixel at a time.
|
||||
* So they generally speed up 3bpp images about 3x, 4bpp images about 4x.
|
||||
* They can scale up to 6 and 8 bpp images and down to 2 bpp images,
|
||||
* but they'd not likely have any benefit for 1bpp images.
|
||||
* Most of these can be implemented using only MMX and 64-bit registers,
|
||||
* but they end up a bit slower than using the equally-ubiquitous SSE2.
|
||||
*/
|
||||
png_debug(1, "in png_init_filter_functions_sse2");
|
||||
if (bpp == 3)
|
||||
{
|
||||
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_sse2;
|
||||
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_sse2;
|
||||
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
|
||||
png_read_filter_row_paeth3_sse2;
|
||||
}
|
||||
else if (bpp == 4)
|
||||
{
|
||||
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_sse2;
|
||||
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_sse2;
|
||||
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
|
||||
png_read_filter_row_paeth4_sse2;
|
||||
}
|
||||
|
||||
/* No need optimize PNG_FILTER_VALUE_UP. The compiler should
|
||||
* autovectorize.
|
||||
*/
|
||||
}
|
||||
|
||||
#endif /* PNG_INTEL_SSE_IMPLEMENTATION > 0 */
|
||||
#endif /* PNG_READ_SUPPORTED */
|
@ -1,127 +0,0 @@
|
||||
#! /bin/sh
|
||||
|
||||
# libpng-config
|
||||
# provides configuration info for libpng.
|
||||
|
||||
# Copyright (C) 2002, 2004, 2006, 2007 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
|
||||
|
||||
# Modeled after libxml-config.
|
||||
|
||||
version="@PNGLIB_VERSION@"
|
||||
prefix="@prefix@"
|
||||
exec_prefix="@exec_prefix@"
|
||||
libdir="@libdir@"
|
||||
includedir="@includedir@/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@"
|
||||
libs="-lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@"
|
||||
all_libs="-lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ @LIBS@"
|
||||
I_opts="-I${includedir}"
|
||||
L_opts="-L${libdir}"
|
||||
R_opts=""
|
||||
cppflags=""
|
||||
ccopts=""
|
||||
ldopts=""
|
||||
|
||||
usage()
|
||||
{
|
||||
cat <<EOF
|
||||
Usage: $0 [OPTION] ...
|
||||
|
||||
Known values for OPTION are:
|
||||
|
||||
--prefix print libpng prefix
|
||||
--libdir print path to directory containing library
|
||||
--libs print library linking information
|
||||
--ccopts print compiler options
|
||||
--cppflags print pre-processor flags
|
||||
--cflags print preprocessor flags, I_opts, and compiler options
|
||||
--I_opts print "-I" include options
|
||||
--L_opts print linker "-L" flags for dynamic linking
|
||||
--R_opts print dynamic linker "-R" or "-rpath" flags
|
||||
--ldopts print linker options
|
||||
--ldflags print linker flags (ldopts, L_opts, R_opts, and libs)
|
||||
--static revise subsequent outputs for static linking
|
||||
--help print this help and exit
|
||||
--version print version information
|
||||
EOF
|
||||
|
||||
exit $1
|
||||
}
|
||||
|
||||
if test $# -eq 0; then
|
||||
usage 1
|
||||
fi
|
||||
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
|
||||
--prefix)
|
||||
echo ${prefix}
|
||||
;;
|
||||
|
||||
--version)
|
||||
echo ${version}
|
||||
exit 0
|
||||
;;
|
||||
|
||||
--help)
|
||||
usage 0
|
||||
;;
|
||||
|
||||
--ccopts)
|
||||
echo ${ccopts}
|
||||
;;
|
||||
|
||||
--cppflags)
|
||||
echo ${cppflags}
|
||||
;;
|
||||
|
||||
--cflags)
|
||||
echo ${I_opts} ${cppflags} ${ccopts}
|
||||
;;
|
||||
|
||||
--libdir)
|
||||
echo ${libdir}
|
||||
;;
|
||||
|
||||
--libs)
|
||||
echo ${libs}
|
||||
;;
|
||||
|
||||
--I_opts)
|
||||
echo ${I_opts}
|
||||
;;
|
||||
|
||||
--L_opts)
|
||||
echo ${L_opts}
|
||||
;;
|
||||
|
||||
--R_opts)
|
||||
echo ${R_opts}
|
||||
;;
|
||||
|
||||
--ldopts)
|
||||
echo ${ldopts}
|
||||
;;
|
||||
|
||||
--ldflags)
|
||||
echo ${ldopts} ${L_opts} ${R_opts} ${libs}
|
||||
;;
|
||||
|
||||
--static)
|
||||
R_opts=""
|
||||
libs=${all_libs}
|
||||
;;
|
||||
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,12 +0,0 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
|
||||
|
||||
Name: libpng
|
||||
Description: Loads and saves PNG files
|
||||
Version: @PNGLIB_VERSION@
|
||||
Requires: zlib
|
||||
Libs: -L${libdir} -lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
|
||||
Libs.private: @LIBS@
|
||||
Cflags: -I${includedir}
|
@ -1,807 +0,0 @@
|
||||
|
||||
/* filter_msa_intrinsics.c - MSA optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2016 Glenn Randers-Pehrson
|
||||
* Written by Mandar Sahastrabuddhe, August 2016.
|
||||
* Last changed in libpng 1.6.25 [September 1, 2016]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include "../pngpriv.h"
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
/* This code requires -mfpu=msa on the command line: */
|
||||
#if PNG_MIPS_MSA_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
|
||||
|
||||
#include <msa.h>
|
||||
|
||||
/* libpng row pointers are not necessarily aligned to any particular boundary,
|
||||
* however this code will only work with appropriate alignment. mips/mips_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_MIPS_MSA_OPT > 0
|
||||
|
||||
#ifdef CLANG_BUILD
|
||||
#define MSA_SRLI_B(a, b) __msa_srli_b((v16i8) a, b)
|
||||
|
||||
#define LW(psrc) \
|
||||
( { \
|
||||
uint8_t *psrc_lw_m = (uint8_t *) (psrc); \
|
||||
uint32_t val_m; \
|
||||
\
|
||||
asm volatile ( \
|
||||
"lw %[val_m], %[psrc_lw_m] \n\t" \
|
||||
\
|
||||
: [val_m] "=r" (val_m) \
|
||||
: [psrc_lw_m] "m" (*psrc_lw_m) \
|
||||
); \
|
||||
\
|
||||
val_m; \
|
||||
} )
|
||||
|
||||
#define SH(val, pdst) \
|
||||
{ \
|
||||
uint8_t *pdst_sh_m = (uint8_t *) (pdst); \
|
||||
uint16_t val_m = (val); \
|
||||
\
|
||||
asm volatile ( \
|
||||
"sh %[val_m], %[pdst_sh_m] \n\t" \
|
||||
\
|
||||
: [pdst_sh_m] "=m" (*pdst_sh_m) \
|
||||
: [val_m] "r" (val_m) \
|
||||
); \
|
||||
}
|
||||
|
||||
#define SW(val, pdst) \
|
||||
{ \
|
||||
uint8_t *pdst_sw_m = (uint8_t *) (pdst); \
|
||||
uint32_t val_m = (val); \
|
||||
\
|
||||
asm volatile ( \
|
||||
"sw %[val_m], %[pdst_sw_m] \n\t" \
|
||||
\
|
||||
: [pdst_sw_m] "=m" (*pdst_sw_m) \
|
||||
: [val_m] "r" (val_m) \
|
||||
); \
|
||||
}
|
||||
|
||||
#if (__mips == 64)
|
||||
#define SD(val, pdst) \
|
||||
{ \
|
||||
uint8_t *pdst_sd_m = (uint8_t *) (pdst); \
|
||||
uint64_t val_m = (val); \
|
||||
\
|
||||
asm volatile ( \
|
||||
"sd %[val_m], %[pdst_sd_m] \n\t" \
|
||||
\
|
||||
: [pdst_sd_m] "=m" (*pdst_sd_m) \
|
||||
: [val_m] "r" (val_m) \
|
||||
); \
|
||||
}
|
||||
#else
|
||||
#define SD(val, pdst) \
|
||||
{ \
|
||||
uint8_t *pdst_sd_m = (uint8_t *) (pdst); \
|
||||
uint32_t val0_m, val1_m; \
|
||||
\
|
||||
val0_m = (uint32_t) ((val) & 0x00000000FFFFFFFF); \
|
||||
val1_m = (uint32_t) (((val) >> 32) & 0x00000000FFFFFFFF); \
|
||||
\
|
||||
SW(val0_m, pdst_sd_m); \
|
||||
SW(val1_m, pdst_sd_m + 4); \
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#define MSA_SRLI_B(a, b) (a >> b)
|
||||
|
||||
#if (__mips_isa_rev >= 6)
|
||||
#define LW(psrc) \
|
||||
( { \
|
||||
uint8_t *psrc_lw_m = (uint8_t *) (psrc); \
|
||||
uint32_t val_m; \
|
||||
\
|
||||
asm volatile ( \
|
||||
"lw %[val_m], %[psrc_lw_m] \n\t" \
|
||||
\
|
||||
: [val_m] "=r" (val_m) \
|
||||
: [psrc_lw_m] "m" (*psrc_lw_m) \
|
||||
); \
|
||||
\
|
||||
val_m; \
|
||||
} )
|
||||
|
||||
#define SH(val, pdst) \
|
||||
{ \
|
||||
uint8_t *pdst_sh_m = (uint8_t *) (pdst); \
|
||||
uint16_t val_m = (val); \
|
||||
\
|
||||
asm volatile ( \
|
||||
"sh %[val_m], %[pdst_sh_m] \n\t" \
|
||||
\
|
||||
: [pdst_sh_m] "=m" (*pdst_sh_m) \
|
||||
: [val_m] "r" (val_m) \
|
||||
); \
|
||||
}
|
||||
|
||||
#define SW(val, pdst) \
|
||||
{ \
|
||||
uint8_t *pdst_sw_m = (uint8_t *) (pdst); \
|
||||
uint32_t val_m = (val); \
|
||||
\
|
||||
asm volatile ( \
|
||||
"sw %[val_m], %[pdst_sw_m] \n\t" \
|
||||
\
|
||||
: [pdst_sw_m] "=m" (*pdst_sw_m) \
|
||||
: [val_m] "r" (val_m) \
|
||||
); \
|
||||
}
|
||||
|
||||
#if (__mips == 64)
|
||||
#define SD(val, pdst) \
|
||||
{ \
|
||||
uint8_t *pdst_sd_m = (uint8_t *) (pdst); \
|
||||
uint64_t val_m = (val); \
|
||||
\
|
||||
asm volatile ( \
|
||||
"sd %[val_m], %[pdst_sd_m] \n\t" \
|
||||
\
|
||||
: [pdst_sd_m] "=m" (*pdst_sd_m) \
|
||||
: [val_m] "r" (val_m) \
|
||||
); \
|
||||
}
|
||||
#else
|
||||
#define SD(val, pdst) \
|
||||
{ \
|
||||
uint8_t *pdst_sd_m = (uint8_t *) (pdst); \
|
||||
uint32_t val0_m, val1_m; \
|
||||
\
|
||||
val0_m = (uint32_t) ((val) & 0x00000000FFFFFFFF); \
|
||||
val1_m = (uint32_t) (((val) >> 32) & 0x00000000FFFFFFFF); \
|
||||
\
|
||||
SW(val0_m, pdst_sd_m); \
|
||||
SW(val1_m, pdst_sd_m + 4); \
|
||||
}
|
||||
#endif
|
||||
#else // !(__mips_isa_rev >= 6)
|
||||
#define LW(psrc) \
|
||||
( { \
|
||||
uint8_t *psrc_lw_m = (uint8_t *) (psrc); \
|
||||
uint32_t val_m; \
|
||||
\
|
||||
asm volatile ( \
|
||||
"ulw %[val_m], %[psrc_lw_m] \n\t" \
|
||||
\
|
||||
: [val_m] "=r" (val_m) \
|
||||
: [psrc_lw_m] "m" (*psrc_lw_m) \
|
||||
); \
|
||||
\
|
||||
val_m; \
|
||||
} )
|
||||
|
||||
#define SH(val, pdst) \
|
||||
{ \
|
||||
uint8_t *pdst_sh_m = (uint8_t *) (pdst); \
|
||||
uint16_t val_m = (val); \
|
||||
\
|
||||
asm volatile ( \
|
||||
"ush %[val_m], %[pdst_sh_m] \n\t" \
|
||||
\
|
||||
: [pdst_sh_m] "=m" (*pdst_sh_m) \
|
||||
: [val_m] "r" (val_m) \
|
||||
); \
|
||||
}
|
||||
|
||||
#define SW(val, pdst) \
|
||||
{ \
|
||||
uint8_t *pdst_sw_m = (uint8_t *) (pdst); \
|
||||
uint32_t val_m = (val); \
|
||||
\
|
||||
asm volatile ( \
|
||||
"usw %[val_m], %[pdst_sw_m] \n\t" \
|
||||
\
|
||||
: [pdst_sw_m] "=m" (*pdst_sw_m) \
|
||||
: [val_m] "r" (val_m) \
|
||||
); \
|
||||
}
|
||||
|
||||
#define SD(val, pdst) \
|
||||
{ \
|
||||
uint8_t *pdst_sd_m = (uint8_t *) (pdst); \
|
||||
uint32_t val0_m, val1_m; \
|
||||
\
|
||||
val0_m = (uint32_t) ((val) & 0x00000000FFFFFFFF); \
|
||||
val1_m = (uint32_t) (((val) >> 32) & 0x00000000FFFFFFFF); \
|
||||
\
|
||||
SW(val0_m, pdst_sd_m); \
|
||||
SW(val1_m, pdst_sd_m + 4); \
|
||||
}
|
||||
|
||||
#define SW_ZERO(pdst) \
|
||||
{ \
|
||||
uint8_t *pdst_m = (uint8_t *) (pdst); \
|
||||
\
|
||||
asm volatile ( \
|
||||
"usw $0, %[pdst_m] \n\t" \
|
||||
\
|
||||
: [pdst_m] "=m" (*pdst_m) \
|
||||
: \
|
||||
); \
|
||||
}
|
||||
#endif // (__mips_isa_rev >= 6)
|
||||
#endif
|
||||
|
||||
#define LD_B(RTYPE, psrc) *((RTYPE *) (psrc))
|
||||
#define LD_UB(...) LD_B(v16u8, __VA_ARGS__)
|
||||
#define LD_B2(RTYPE, psrc, stride, out0, out1) \
|
||||
{ \
|
||||
out0 = LD_B(RTYPE, (psrc)); \
|
||||
out1 = LD_B(RTYPE, (psrc) + stride); \
|
||||
}
|
||||
#define LD_UB2(...) LD_B2(v16u8, __VA_ARGS__)
|
||||
#define LD_B4(RTYPE, psrc, stride, out0, out1, out2, out3) \
|
||||
{ \
|
||||
LD_B2(RTYPE, (psrc), stride, out0, out1); \
|
||||
LD_B2(RTYPE, (psrc) + 2 * stride , stride, out2, out3); \
|
||||
}
|
||||
#define LD_UB4(...) LD_B4(v16u8, __VA_ARGS__)
|
||||
|
||||
#define ST_B(RTYPE, in, pdst) *((RTYPE *) (pdst)) = (in)
|
||||
#define ST_UB(...) ST_B(v16u8, __VA_ARGS__)
|
||||
#define ST_B2(RTYPE, in0, in1, pdst, stride) \
|
||||
{ \
|
||||
ST_B(RTYPE, in0, (pdst)); \
|
||||
ST_B(RTYPE, in1, (pdst) + stride); \
|
||||
}
|
||||
#define ST_UB2(...) ST_B2(v16u8, __VA_ARGS__)
|
||||
#define ST_B4(RTYPE, in0, in1, in2, in3, pdst, stride) \
|
||||
{ \
|
||||
ST_B2(RTYPE, in0, in1, (pdst), stride); \
|
||||
ST_B2(RTYPE, in2, in3, (pdst) + 2 * stride, stride); \
|
||||
}
|
||||
#define ST_UB4(...) ST_B4(v16u8, __VA_ARGS__)
|
||||
|
||||
#define ADD2(in0, in1, in2, in3, out0, out1) \
|
||||
{ \
|
||||
out0 = in0 + in1; \
|
||||
out1 = in2 + in3; \
|
||||
}
|
||||
#define ADD3(in0, in1, in2, in3, in4, in5, \
|
||||
out0, out1, out2) \
|
||||
{ \
|
||||
ADD2(in0, in1, in2, in3, out0, out1); \
|
||||
out2 = in4 + in5; \
|
||||
}
|
||||
#define ADD4(in0, in1, in2, in3, in4, in5, in6, in7, \
|
||||
out0, out1, out2, out3) \
|
||||
{ \
|
||||
ADD2(in0, in1, in2, in3, out0, out1); \
|
||||
ADD2(in4, in5, in6, in7, out2, out3); \
|
||||
}
|
||||
|
||||
#define ILVR_B2(RTYPE, in0, in1, in2, in3, out0, out1) \
|
||||
{ \
|
||||
out0 = (RTYPE) __msa_ilvr_b((v16i8) in0, (v16i8) in1); \
|
||||
out1 = (RTYPE) __msa_ilvr_b((v16i8) in2, (v16i8) in3); \
|
||||
}
|
||||
#define ILVR_B2_SH(...) ILVR_B2(v8i16, __VA_ARGS__)
|
||||
|
||||
#define HSUB_UB2(RTYPE, in0, in1, out0, out1) \
|
||||
{ \
|
||||
out0 = (RTYPE) __msa_hsub_u_h((v16u8) in0, (v16u8) in0); \
|
||||
out1 = (RTYPE) __msa_hsub_u_h((v16u8) in1, (v16u8) in1); \
|
||||
}
|
||||
#define HSUB_UB2_SH(...) HSUB_UB2(v8i16, __VA_ARGS__)
|
||||
|
||||
#define SLDI_B2_0(RTYPE, in0, in1, out0, out1, slide_val) \
|
||||
{ \
|
||||
v16i8 zero_m = { 0 }; \
|
||||
out0 = (RTYPE) __msa_sldi_b((v16i8) zero_m, (v16i8) in0, slide_val); \
|
||||
out1 = (RTYPE) __msa_sldi_b((v16i8) zero_m, (v16i8) in1, slide_val); \
|
||||
}
|
||||
#define SLDI_B2_0_UB(...) SLDI_B2_0(v16u8, __VA_ARGS__)
|
||||
|
||||
#define SLDI_B3_0(RTYPE, in0, in1, in2, out0, out1, out2, slide_val) \
|
||||
{ \
|
||||
v16i8 zero_m = { 0 }; \
|
||||
SLDI_B2_0(RTYPE, in0, in1, out0, out1, slide_val); \
|
||||
out2 = (RTYPE) __msa_sldi_b((v16i8) zero_m, (v16i8) in2, slide_val); \
|
||||
}
|
||||
#define SLDI_B3_0_UB(...) SLDI_B3_0(v16u8, __VA_ARGS__)
|
||||
|
||||
#define ILVEV_W2(RTYPE, in0, in1, in2, in3, out0, out1) \
|
||||
{ \
|
||||
out0 = (RTYPE) __msa_ilvev_w((v4i32) in1, (v4i32) in0); \
|
||||
out1 = (RTYPE) __msa_ilvev_w((v4i32) in3, (v4i32) in2); \
|
||||
}
|
||||
#define ILVEV_W2_UB(...) ILVEV_W2(v16u8, __VA_ARGS__)
|
||||
|
||||
#define ADD_ABS_H3(RTYPE, in0, in1, in2, out0, out1, out2) \
|
||||
{ \
|
||||
RTYPE zero = {0}; \
|
||||
\
|
||||
out0 = __msa_add_a_h((v8i16) zero, in0); \
|
||||
out1 = __msa_add_a_h((v8i16) zero, in1); \
|
||||
out2 = __msa_add_a_h((v8i16) zero, in2); \
|
||||
}
|
||||
#define ADD_ABS_H3_SH(...) ADD_ABS_H3(v8i16, __VA_ARGS__)
|
||||
|
||||
#define VSHF_B2(RTYPE, in0, in1, in2, in3, mask0, mask1, out0, out1) \
|
||||
{ \
|
||||
out0 = (RTYPE) __msa_vshf_b((v16i8) mask0, (v16i8) in1, (v16i8) in0); \
|
||||
out1 = (RTYPE) __msa_vshf_b((v16i8) mask1, (v16i8) in3, (v16i8) in2); \
|
||||
}
|
||||
#define VSHF_B2_UB(...) VSHF_B2(v16u8, __VA_ARGS__)
|
||||
|
||||
#define CMP_AND_SELECT(inp0, inp1, inp2, inp3, inp4, inp5, out0) \
|
||||
{ \
|
||||
v8i16 _sel_h0, _sel_h1; \
|
||||
v16u8 _sel_b0, _sel_b1; \
|
||||
_sel_h0 = (v8i16) __msa_clt_u_h((v8u16) inp1, (v8u16) inp0); \
|
||||
_sel_b0 = (v16u8) __msa_pckev_b((v16i8) _sel_h0, (v16i8) _sel_h0); \
|
||||
inp0 = (v8i16) __msa_bmnz_v((v16u8) inp0, (v16u8) inp1, (v16u8) _sel_h0); \
|
||||
inp4 = (v16u8) __msa_bmnz_v(inp3, inp4, _sel_b0); \
|
||||
_sel_h1 = (v8i16) __msa_clt_u_h((v8u16) inp2, (v8u16) inp0); \
|
||||
_sel_b1 = (v16u8) __msa_pckev_b((v16i8) _sel_h1, (v16i8) _sel_h1); \
|
||||
inp4 = (v16u8) __msa_bmnz_v(inp4, inp5, _sel_b1); \
|
||||
out0 += inp4; \
|
||||
}
|
||||
|
||||
void png_read_filter_row_up_msa(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
png_size_t i, cnt, cnt16, cnt32;
|
||||
png_size_t istop = row_info->rowbytes;
|
||||
png_bytep rp = row;
|
||||
png_const_bytep pp = prev_row;
|
||||
v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
|
||||
|
||||
for (i = 0; i < (istop >> 6); i++)
|
||||
{
|
||||
LD_UB4(rp, 16, src0, src1, src2, src3);
|
||||
LD_UB4(pp, 16, src4, src5, src6, src7);
|
||||
pp += 64;
|
||||
|
||||
ADD4(src0, src4, src1, src5, src2, src6, src3, src7,
|
||||
src0, src1, src2, src3);
|
||||
|
||||
ST_UB4(src0, src1, src2, src3, rp, 16);
|
||||
rp += 64;
|
||||
}
|
||||
|
||||
if (istop & 0x3F)
|
||||
{
|
||||
cnt32 = istop & 0x20;
|
||||
cnt16 = istop & 0x10;
|
||||
cnt = istop & 0xF;
|
||||
|
||||
if(cnt32)
|
||||
{
|
||||
if (cnt16 && cnt)
|
||||
{
|
||||
LD_UB4(rp, 16, src0, src1, src2, src3);
|
||||
LD_UB4(pp, 16, src4, src5, src6, src7);
|
||||
|
||||
ADD4(src0, src4, src1, src5, src2, src6, src3, src7,
|
||||
src0, src1, src2, src3);
|
||||
|
||||
ST_UB4(src0, src1, src2, src3, rp, 16);
|
||||
rp += 64;
|
||||
}
|
||||
else if (cnt16 || cnt)
|
||||
{
|
||||
LD_UB2(rp, 16, src0, src1);
|
||||
LD_UB2(pp, 16, src4, src5);
|
||||
pp += 32;
|
||||
src2 = LD_UB(rp + 32);
|
||||
src6 = LD_UB(pp);
|
||||
|
||||
ADD3(src0, src4, src1, src5, src2, src6, src0, src1, src2);
|
||||
|
||||
ST_UB2(src0, src1, rp, 16);
|
||||
rp += 32;
|
||||
ST_UB(src2, rp);
|
||||
rp += 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
LD_UB2(rp, 16, src0, src1);
|
||||
LD_UB2(pp, 16, src4, src5);
|
||||
|
||||
ADD2(src0, src4, src1, src5, src0, src1);
|
||||
|
||||
ST_UB2(src0, src1, rp, 16);
|
||||
rp += 32;
|
||||
}
|
||||
}
|
||||
else if (cnt16 && cnt)
|
||||
{
|
||||
LD_UB2(rp, 16, src0, src1);
|
||||
LD_UB2(pp, 16, src4, src5);
|
||||
|
||||
ADD2(src0, src4, src1, src5, src0, src1);
|
||||
|
||||
ST_UB2(src0, src1, rp, 16);
|
||||
rp += 32;
|
||||
}
|
||||
else if (cnt16 || cnt)
|
||||
{
|
||||
src0 = LD_UB(rp);
|
||||
src4 = LD_UB(pp);
|
||||
pp += 16;
|
||||
|
||||
src0 += src4;
|
||||
|
||||
ST_UB(src0, rp);
|
||||
rp += 16;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void png_read_filter_row_sub4_msa(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
png_size_t count;
|
||||
png_size_t istop = row_info->rowbytes;
|
||||
png_bytep src = row;
|
||||
png_bytep nxt = row + 4;
|
||||
int32_t inp0;
|
||||
v16u8 src0, src1, src2, src3, src4;
|
||||
v16u8 dst0, dst1;
|
||||
v16u8 zero = { 0 };
|
||||
|
||||
istop -= 4;
|
||||
|
||||
inp0 = LW(src);
|
||||
src += 4;
|
||||
src0 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp0);
|
||||
|
||||
for (count = 0; count < istop; count += 16)
|
||||
{
|
||||
src1 = LD_UB(src);
|
||||
src += 16;
|
||||
|
||||
src2 = (v16u8) __msa_sldi_b((v16i8) zero, (v16i8) src1, 4);
|
||||
src3 = (v16u8) __msa_sldi_b((v16i8) zero, (v16i8) src1, 8);
|
||||
src4 = (v16u8) __msa_sldi_b((v16i8) zero, (v16i8) src1, 12);
|
||||
src1 += src0;
|
||||
src2 += src1;
|
||||
src3 += src2;
|
||||
src4 += src3;
|
||||
src0 = src4;
|
||||
ILVEV_W2_UB(src1, src2, src3, src4, dst0, dst1);
|
||||
dst0 = (v16u8) __msa_pckev_d((v2i64) dst1, (v2i64) dst0);
|
||||
|
||||
ST_UB(dst0, nxt);
|
||||
nxt += 16;
|
||||
}
|
||||
}
|
||||
|
||||
void png_read_filter_row_sub3_msa(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
png_size_t count;
|
||||
png_size_t istop = row_info->rowbytes;
|
||||
png_bytep src = row;
|
||||
png_bytep nxt = row + 3;
|
||||
int64_t out0;
|
||||
int32_t inp0, out1;
|
||||
v16u8 src0, src1, src2, src3, src4, dst0, dst1;
|
||||
v16u8 zero = { 0 };
|
||||
v16i8 mask0 = { 0, 1, 2, 16, 17, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
v16i8 mask1 = { 0, 1, 2, 3, 4, 5, 16, 17, 18, 19, 20, 21, 0, 0, 0, 0 };
|
||||
|
||||
istop -= 3;
|
||||
|
||||
inp0 = LW(src);
|
||||
src += 3;
|
||||
src0 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp0);
|
||||
|
||||
for (count = 0; count < istop; count += 12)
|
||||
{
|
||||
src1 = LD_UB(src);
|
||||
src += 12;
|
||||
|
||||
src2 = (v16u8) __msa_sldi_b((v16i8) zero, (v16i8) src1, 3);
|
||||
src3 = (v16u8) __msa_sldi_b((v16i8) zero, (v16i8) src1, 6);
|
||||
src4 = (v16u8) __msa_sldi_b((v16i8) zero, (v16i8) src1, 9);
|
||||
src1 += src0;
|
||||
src2 += src1;
|
||||
src3 += src2;
|
||||
src4 += src3;
|
||||
src0 = src4;
|
||||
VSHF_B2_UB(src1, src2, src3, src4, mask0, mask0, dst0, dst1);
|
||||
dst0 = (v16u8) __msa_vshf_b(mask1, (v16i8) dst1, (v16i8) dst0);
|
||||
out0 = __msa_copy_s_d((v2i64) dst0, 0);
|
||||
out1 = __msa_copy_s_w((v4i32) dst0, 2);
|
||||
|
||||
SD(out0, nxt);
|
||||
nxt += 8;
|
||||
SW(out1, nxt);
|
||||
nxt += 4;
|
||||
}
|
||||
}
|
||||
|
||||
void png_read_filter_row_avg4_msa(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
png_size_t i;
|
||||
png_bytep src = row;
|
||||
png_bytep nxt = row;
|
||||
png_const_bytep pp = prev_row;
|
||||
png_size_t istop = row_info->rowbytes - 4;
|
||||
int32_t inp0, inp1, out0;
|
||||
v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, dst0, dst1;
|
||||
v16u8 zero = { 0 };
|
||||
|
||||
inp0 = LW(pp);
|
||||
pp += 4;
|
||||
inp1 = LW(src);
|
||||
src += 4;
|
||||
src0 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp0);
|
||||
src1 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp1);
|
||||
src0 = (v16u8) MSA_SRLI_B(src0, 1);
|
||||
src1 += src0;
|
||||
out0 = __msa_copy_s_w((v4i32) src1, 0);
|
||||
SW(out0, nxt);
|
||||
nxt += 4;
|
||||
|
||||
for (i = 0; i < istop; i += 16)
|
||||
{
|
||||
src2 = LD_UB(pp);
|
||||
pp += 16;
|
||||
src6 = LD_UB(src);
|
||||
src += 16;
|
||||
|
||||
SLDI_B2_0_UB(src2, src6, src3, src7, 4);
|
||||
SLDI_B2_0_UB(src2, src6, src4, src8, 8);
|
||||
SLDI_B2_0_UB(src2, src6, src5, src9, 12);
|
||||
src2 = __msa_ave_u_b(src2, src1);
|
||||
src6 += src2;
|
||||
src3 = __msa_ave_u_b(src3, src6);
|
||||
src7 += src3;
|
||||
src4 = __msa_ave_u_b(src4, src7);
|
||||
src8 += src4;
|
||||
src5 = __msa_ave_u_b(src5, src8);
|
||||
src9 += src5;
|
||||
src1 = src9;
|
||||
ILVEV_W2_UB(src6, src7, src8, src9, dst0, dst1);
|
||||
dst0 = (v16u8) __msa_pckev_d((v2i64) dst1, (v2i64) dst0);
|
||||
|
||||
ST_UB(dst0, nxt);
|
||||
nxt += 16;
|
||||
}
|
||||
}
|
||||
|
||||
void png_read_filter_row_avg3_msa(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
png_size_t i;
|
||||
png_bytep src = row;
|
||||
png_bytep nxt = row;
|
||||
png_const_bytep pp = prev_row;
|
||||
png_size_t istop = row_info->rowbytes - 3;
|
||||
int64_t out0;
|
||||
int32_t inp0, inp1, out1;
|
||||
int16_t out2;
|
||||
v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, dst0, dst1;
|
||||
v16u8 zero = { 0 };
|
||||
v16i8 mask0 = { 0, 1, 2, 16, 17, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
v16i8 mask1 = { 0, 1, 2, 3, 4, 5, 16, 17, 18, 19, 20, 21, 0, 0, 0, 0 };
|
||||
|
||||
inp0 = LW(pp);
|
||||
pp += 3;
|
||||
inp1 = LW(src);
|
||||
src += 3;
|
||||
src0 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp0);
|
||||
src1 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp1);
|
||||
src0 = (v16u8) MSA_SRLI_B(src0, 1);
|
||||
src1 += src0;
|
||||
out2 = __msa_copy_s_h((v8i16) src1, 0);
|
||||
SH(out2, nxt);
|
||||
nxt += 2;
|
||||
nxt[0] = src1[2];
|
||||
nxt++;
|
||||
|
||||
for (i = 0; i < istop; i += 12)
|
||||
{
|
||||
src2 = LD_UB(pp);
|
||||
pp += 12;
|
||||
src6 = LD_UB(src);
|
||||
src += 12;
|
||||
|
||||
SLDI_B2_0_UB(src2, src6, src3, src7, 3);
|
||||
SLDI_B2_0_UB(src2, src6, src4, src8, 6);
|
||||
SLDI_B2_0_UB(src2, src6, src5, src9, 9);
|
||||
src2 = __msa_ave_u_b(src2, src1);
|
||||
src6 += src2;
|
||||
src3 = __msa_ave_u_b(src3, src6);
|
||||
src7 += src3;
|
||||
src4 = __msa_ave_u_b(src4, src7);
|
||||
src8 += src4;
|
||||
src5 = __msa_ave_u_b(src5, src8);
|
||||
src9 += src5;
|
||||
src1 = src9;
|
||||
VSHF_B2_UB(src6, src7, src8, src9, mask0, mask0, dst0, dst1);
|
||||
dst0 = (v16u8) __msa_vshf_b(mask1, (v16i8) dst1, (v16i8) dst0);
|
||||
out0 = __msa_copy_s_d((v2i64) dst0, 0);
|
||||
out1 = __msa_copy_s_w((v4i32) dst0, 2);
|
||||
|
||||
SD(out0, nxt);
|
||||
nxt += 8;
|
||||
SW(out1, nxt);
|
||||
nxt += 4;
|
||||
}
|
||||
}
|
||||
|
||||
void png_read_filter_row_paeth4_msa(png_row_infop row_info,
|
||||
png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
int32_t count, rp_end;
|
||||
png_bytep nxt;
|
||||
png_const_bytep prev_nxt;
|
||||
int32_t inp0, inp1, res0;
|
||||
v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9;
|
||||
v16u8 src10, src11, src12, src13, dst0, dst1;
|
||||
v8i16 vec0, vec1, vec2;
|
||||
v16u8 zero = { 0 };
|
||||
|
||||
nxt = row;
|
||||
prev_nxt = prev_row;
|
||||
|
||||
inp0 = LW(nxt);
|
||||
inp1 = LW(prev_nxt);
|
||||
prev_nxt += 4;
|
||||
src0 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp0);
|
||||
src1 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp1);
|
||||
|
||||
src1 += src0;
|
||||
res0 = __msa_copy_s_w((v4i32) src1, 0);
|
||||
|
||||
SW(res0, nxt);
|
||||
nxt += 4;
|
||||
|
||||
/* Remainder */
|
||||
rp_end = row_info->rowbytes - 4;
|
||||
|
||||
for (count = 0; count < rp_end; count += 16)
|
||||
{
|
||||
src2 = LD_UB(prev_nxt);
|
||||
prev_nxt += 16;
|
||||
src6 = LD_UB(prev_row);
|
||||
prev_row += 16;
|
||||
src10 = LD_UB(nxt);
|
||||
|
||||
SLDI_B3_0_UB(src2, src6, src10, src3, src7, src11, 4);
|
||||
SLDI_B3_0_UB(src2, src6, src10, src4, src8, src12, 8);
|
||||
SLDI_B3_0_UB(src2, src6, src10, src5, src9, src13, 12);
|
||||
ILVR_B2_SH(src2, src6, src1, src6, vec0, vec1);
|
||||
HSUB_UB2_SH(vec0, vec1, vec0, vec1);
|
||||
vec2 = vec0 + vec1;
|
||||
ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2);
|
||||
CMP_AND_SELECT(vec0, vec1, vec2, src1, src2, src6, src10);
|
||||
ILVR_B2_SH(src3, src7, src10, src7, vec0, vec1);
|
||||
HSUB_UB2_SH(vec0, vec1, vec0, vec1);
|
||||
vec2 = vec0 + vec1;
|
||||
ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2);
|
||||
CMP_AND_SELECT(vec0, vec1, vec2, src10, src3, src7, src11);
|
||||
ILVR_B2_SH(src4, src8, src11, src8, vec0, vec1);
|
||||
HSUB_UB2_SH(vec0, vec1, vec0, vec1);
|
||||
vec2 = vec0 + vec1;
|
||||
ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2);
|
||||
CMP_AND_SELECT(vec0, vec1, vec2, src11, src4, src8, src12);
|
||||
ILVR_B2_SH(src5, src9, src12, src9, vec0, vec1);
|
||||
HSUB_UB2_SH(vec0, vec1, vec0, vec1);
|
||||
vec2 = vec0 + vec1;
|
||||
ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2);
|
||||
CMP_AND_SELECT(vec0, vec1, vec2, src12, src5, src9, src13);
|
||||
src1 = src13;
|
||||
ILVEV_W2_UB(src10, src11, src12, src1, dst0, dst1);
|
||||
dst0 = (v16u8) __msa_pckev_d((v2i64) dst1, (v2i64) dst0);
|
||||
|
||||
ST_UB(dst0, nxt);
|
||||
nxt += 16;
|
||||
}
|
||||
}
|
||||
|
||||
void png_read_filter_row_paeth3_msa(png_row_infop row_info,
|
||||
png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
int32_t count, rp_end;
|
||||
png_bytep nxt;
|
||||
png_const_bytep prev_nxt;
|
||||
int64_t out0;
|
||||
int32_t inp0, inp1, out1;
|
||||
int16_t out2;
|
||||
v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, dst0, dst1;
|
||||
v16u8 src10, src11, src12, src13;
|
||||
v8i16 vec0, vec1, vec2;
|
||||
v16u8 zero = { 0 };
|
||||
v16i8 mask0 = { 0, 1, 2, 16, 17, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
v16i8 mask1 = { 0, 1, 2, 3, 4, 5, 16, 17, 18, 19, 20, 21, 0, 0, 0, 0 };
|
||||
|
||||
nxt = row;
|
||||
prev_nxt = prev_row;
|
||||
|
||||
inp0 = LW(nxt);
|
||||
inp1 = LW(prev_nxt);
|
||||
prev_nxt += 3;
|
||||
src0 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp0);
|
||||
src1 = (v16u8) __msa_insert_w((v4i32) zero, 0, inp1);
|
||||
|
||||
src1 += src0;
|
||||
out2 = __msa_copy_s_h((v8i16) src1, 0);
|
||||
|
||||
SH(out2, nxt);
|
||||
nxt += 2;
|
||||
nxt[0] = src1[2];
|
||||
nxt++;
|
||||
|
||||
/* Remainder */
|
||||
rp_end = row_info->rowbytes - 3;
|
||||
|
||||
for (count = 0; count < rp_end; count += 12)
|
||||
{
|
||||
src2 = LD_UB(prev_nxt);
|
||||
prev_nxt += 12;
|
||||
src6 = LD_UB(prev_row);
|
||||
prev_row += 12;
|
||||
src10 = LD_UB(nxt);
|
||||
|
||||
SLDI_B3_0_UB(src2, src6, src10, src3, src7, src11, 3);
|
||||
SLDI_B3_0_UB(src2, src6, src10, src4, src8, src12, 6);
|
||||
SLDI_B3_0_UB(src2, src6, src10, src5, src9, src13, 9);
|
||||
ILVR_B2_SH(src2, src6, src1, src6, vec0, vec1);
|
||||
HSUB_UB2_SH(vec0, vec1, vec0, vec1);
|
||||
vec2 = vec0 + vec1;
|
||||
ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2);
|
||||
CMP_AND_SELECT(vec0, vec1, vec2, src1, src2, src6, src10);
|
||||
ILVR_B2_SH(src3, src7, src10, src7, vec0, vec1);
|
||||
HSUB_UB2_SH(vec0, vec1, vec0, vec1);
|
||||
vec2 = vec0 + vec1;
|
||||
ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2);
|
||||
CMP_AND_SELECT(vec0, vec1, vec2, src10, src3, src7, src11);
|
||||
ILVR_B2_SH(src4, src8, src11, src8, vec0, vec1);
|
||||
HSUB_UB2_SH(vec0, vec1, vec0, vec1);
|
||||
vec2 = vec0 + vec1;
|
||||
ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2);
|
||||
CMP_AND_SELECT(vec0, vec1, vec2, src11, src4, src8, src12);
|
||||
ILVR_B2_SH(src5, src9, src12, src9, vec0, vec1);
|
||||
HSUB_UB2_SH(vec0, vec1, vec0, vec1);
|
||||
vec2 = vec0 + vec1;
|
||||
ADD_ABS_H3_SH(vec0, vec1, vec2, vec0, vec1, vec2);
|
||||
CMP_AND_SELECT(vec0, vec1, vec2, src12, src5, src9, src13);
|
||||
src1 = src13;
|
||||
VSHF_B2_UB(src10, src11, src12, src13, mask0, mask0, dst0, dst1);
|
||||
dst0 = (v16u8) __msa_vshf_b(mask1, (v16i8) dst1, (v16i8) dst0);
|
||||
out0 = __msa_copy_s_d((v2i64) dst0, 0);
|
||||
out1 = __msa_copy_s_w((v4i32) dst0, 2);
|
||||
|
||||
SD(out0, nxt);
|
||||
nxt += 8;
|
||||
SW(out1, nxt);
|
||||
nxt += 4;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* PNG_MIPS_MSA_OPT > 0 */
|
||||
#endif /* PNG_MIPS_MSA_IMPLEMENTATION == 1 (intrinsics) */
|
||||
#endif /* READ */
|
@ -1,129 +0,0 @@
|
||||
|
||||
/* mips_init.c - MSA optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2016 Glenn Randers-Pehrson
|
||||
* Written by Mandar Sahastrabuddhe, 2016.
|
||||
* Last changed in libpng 1.6.25 [September 1, 2016]
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
#include "../pngpriv.h"
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
#if PNG_MIPS_MSA_OPT > 0
|
||||
#ifdef PNG_MIPS_MSA_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 MIPS
|
||||
* MSA 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_MIPS_MSA_FILE to the file name of file containing
|
||||
* a fragment of C source code which defines the png_have_msa function. There
|
||||
* are a number of implementations in contrib/mips-msa, but the only one that
|
||||
* has partial support is contrib/mips-msa/linux.c - a generic Linux
|
||||
* implementation which reads /proc/cpufino.
|
||||
*/
|
||||
#ifndef PNG_MIPS_MSA_FILE
|
||||
# ifdef __linux__
|
||||
# define PNG_MIPS_MSA_FILE "contrib/mips-msa/linux.c"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_MIPS_MSA_FILE
|
||||
|
||||
#include <signal.h> /* for sig_atomic_t */
|
||||
static int png_have_msa(png_structp png_ptr);
|
||||
#include PNG_MIPS_MSA_FILE
|
||||
|
||||
#else /* PNG_MIPS_MSA_FILE */
|
||||
# error "PNG_MIPS_MSA_FILE undefined: no support for run-time MIPS MSA checks"
|
||||
#endif /* PNG_MIPS_MSA_FILE */
|
||||
#endif /* PNG_MIPS_MSA_CHECK_SUPPORTED */
|
||||
|
||||
#ifndef PNG_ALIGNED_MEMORY_SUPPORTED
|
||||
# error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED"
|
||||
#endif
|
||||
|
||||
void
|
||||
png_init_filter_functions_msa(png_structp pp, unsigned int bpp)
|
||||
{
|
||||
/* The switch statement is compiled in for MIPS_MSA_API, the call to
|
||||
* png_have_msa is compiled in for MIPS_MSA_CHECK. If both are defined
|
||||
* the check is only performed if the API has not set the MSA option on
|
||||
* or off explicitly. In this case the check controls what happens.
|
||||
*/
|
||||
|
||||
#ifdef PNG_MIPS_MSA_API_SUPPORTED
|
||||
switch ((pp->options >> PNG_MIPS_MSA) & 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_MIPS_MSA_API_SUPPORTED */
|
||||
#ifdef PNG_MIPS_MSA_CHECK_SUPPORTED
|
||||
{
|
||||
static volatile sig_atomic_t no_msa = -1; /* not checked */
|
||||
|
||||
if (no_msa < 0)
|
||||
no_msa = !png_have_msa(pp);
|
||||
|
||||
if (no_msa)
|
||||
return;
|
||||
}
|
||||
#ifdef PNG_MIPS_MSA_API_SUPPORTED
|
||||
break;
|
||||
#endif
|
||||
#endif /* PNG_MIPS_MSA_CHECK_SUPPORTED */
|
||||
|
||||
#ifdef PNG_MIPS_MSA_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_msa;
|
||||
|
||||
if (bpp == 3)
|
||||
{
|
||||
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_msa;
|
||||
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_msa;
|
||||
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth3_msa;
|
||||
}
|
||||
|
||||
else if (bpp == 4)
|
||||
{
|
||||
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_msa;
|
||||
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_msa;
|
||||
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth4_msa;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_MIPS_MSA_OPT > 0 */
|
||||
#endif /* READ */
|
4614
src/png/libpng/png.c
4614
src/png/libpng/png.c
File diff suppressed because it is too large
Load Diff
3278
src/png/libpng/png.h
3278
src/png/libpng/png.h
File diff suppressed because it is too large
Load Diff
@ -1,622 +0,0 @@
|
||||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng version 1.6.34, September 29, 2017
|
||||
*
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 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.)
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef PNGCONF_H
|
||||
#define PNGCONF_H
|
||||
|
||||
#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/* 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
|
||||
/* Required for the definition of FILE: */
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
#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
|
||||
* built into the library the macro implementation is forced on.
|
||||
*/
|
||||
#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED
|
||||
# define PNG_USE_READ_MACROS
|
||||
#endif
|
||||
#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)
|
||||
# if PNG_DEFAULT_READ_MACROS
|
||||
# define PNG_USE_READ_MACROS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* COMPILER SPECIFIC OPTIONS.
|
||||
*
|
||||
* These options are provided so that a variety of difficult compilers
|
||||
* can be used. Some are fixed at build time (e.g. PNG_API_RULE
|
||||
* below) but still have compiler specific implementations, others
|
||||
* may be changed on a per-file basis when compiling against libpng.
|
||||
*/
|
||||
|
||||
/* 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
|
||||
# define PNGARG(arglist) arglist
|
||||
#endif
|
||||
|
||||
/* Function calling conventions.
|
||||
* =============================
|
||||
* Normally it is not necessary to specify to the compiler how to call
|
||||
* a function - it just does it - however on x86 systems derived from
|
||||
* Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems
|
||||
* and some others) there are multiple ways to call a function and the
|
||||
* default can be changed on the compiler command line. For this reason
|
||||
* libpng specifies the calling convention of every exported function and
|
||||
* every function called via a user supplied function pointer. This is
|
||||
* done in this file by defining the following macros:
|
||||
*
|
||||
* PNGAPI Calling convention for exported functions.
|
||||
* PNGCBAPI Calling convention for user provided (callback) functions.
|
||||
* PNGCAPI Calling convention used by the ANSI-C library (required
|
||||
* for longjmp callbacks and sometimes used internally to
|
||||
* specify the calling convention for zlib).
|
||||
*
|
||||
* These macros should never be overridden. If it is necessary to
|
||||
* change calling convention in a private build this can be done
|
||||
* by setting PNG_API_RULE (which defaults to 0) to one of the values
|
||||
* below to select the correct 'API' variants.
|
||||
*
|
||||
* PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout.
|
||||
* This is correct in every known environment.
|
||||
* PNG_API_RULE=1 Use the operating system convention for PNGAPI and
|
||||
* the 'C' calling convention (from PNGCAPI) for
|
||||
* callbacks (PNGCBAPI). This is no longer required
|
||||
* in any known environment - if it has to be used
|
||||
* please post an explanation of the problem to the
|
||||
* libpng mailing list.
|
||||
*
|
||||
* These cases only differ if the operating system does not use the C
|
||||
* calling convention, at present this just means the above cases
|
||||
* (x86 DOS/Windows sytems) and, even then, this does not apply to
|
||||
* Cygwin running on those systems.
|
||||
*
|
||||
* Note that the value must be defined in pnglibconf.h so that what
|
||||
* the application uses to call the library matches the conventions
|
||||
* set when building the library.
|
||||
*/
|
||||
|
||||
/* Symbol export
|
||||
* =============
|
||||
* When building a shared library it is almost always necessary to tell
|
||||
* the compiler which symbols to export. The png.h macro 'PNG_EXPORT'
|
||||
* is used to mark the symbols. On some systems these symbols can be
|
||||
* extracted at link time and need no special processing by the compiler,
|
||||
* on other systems the symbols are flagged by the compiler and just
|
||||
* the declaration requires a special tag applied (unfortunately) in a
|
||||
* compiler dependent way. Some systems can do either.
|
||||
*
|
||||
* A small number of older systems also require a symbol from a DLL to
|
||||
* be flagged to the program that calls it. This is a problem because
|
||||
* we do not know in the header file included by application code that
|
||||
* the symbol will come from a shared library, as opposed to a statically
|
||||
* linked one. For this reason the application must tell us by setting
|
||||
* the magic flag PNG_USE_DLL to turn on the special processing before
|
||||
* it includes png.h.
|
||||
*
|
||||
* Four additional macros are used to make this happen:
|
||||
*
|
||||
* PNG_IMPEXP The magic (if any) to cause a symbol to be exported from
|
||||
* the build or imported if PNG_USE_DLL is set - compiler
|
||||
* and system specific.
|
||||
*
|
||||
* PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to
|
||||
* 'type', compiler specific.
|
||||
*
|
||||
* PNG_DLL_EXPORT Set to the magic to use during a libpng build to
|
||||
* make a symbol exported from the DLL. Not used in the
|
||||
* public header files; see pngpriv.h for how it is used
|
||||
* in the libpng build.
|
||||
*
|
||||
* PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come
|
||||
* from a DLL - used to define PNG_IMPEXP when
|
||||
* PNG_USE_DLL is set.
|
||||
*/
|
||||
|
||||
/* System specific discovery.
|
||||
* ==========================
|
||||
* 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 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__)
|
||||
/* 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
|
||||
* understood or because of a redefine just below you cannot use *this*
|
||||
* build of the library with the compiler you are using. *This* build was
|
||||
* build using Watcom and applications must also be built using Watcom!
|
||||
*/
|
||||
# define PNGCAPI __watcall
|
||||
# endif
|
||||
|
||||
# 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
|
||||
/* An older compiler, or one not detected (erroneously) above,
|
||||
* if necessary override on the command line to get the correct
|
||||
* variants for the compiler.
|
||||
*/
|
||||
# ifndef PNGCAPI
|
||||
# define PNGCAPI _cdecl
|
||||
# endif
|
||||
# if PNG_API_RULE == 1 && !defined(PNGAPI)
|
||||
# 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"
|
||||
# endif
|
||||
|
||||
# if (defined(_MSC_VER) && _MSC_VER < 800) ||\
|
||||
(defined(__BORLANDC__) && __BORLANDC__ < 0x500)
|
||||
/* older Borland and MSC
|
||||
* compilers used '__export' and required this to be after
|
||||
* the type.
|
||||
*/
|
||||
# ifndef PNG_EXPORT_TYPE
|
||||
# define PNG_EXPORT_TYPE(type) type PNG_IMPEXP
|
||||
# endif
|
||||
# define PNG_DLL_EXPORT __export
|
||||
# else /* newer compiler */
|
||||
# define PNG_DLL_EXPORT __declspec(dllexport)
|
||||
# ifndef PNG_DLL_IMPORT
|
||||
# define PNG_DLL_IMPORT __declspec(dllimport)
|
||||
# endif
|
||||
# endif /* compiler */
|
||||
|
||||
#else /* !Windows */
|
||||
# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
|
||||
# define PNGAPI _System
|
||||
# else /* !Windows/x86 && !OS/2 */
|
||||
/* Use the defaults, or define PNG*API on the command line (but
|
||||
* this will have to be done for every compile!)
|
||||
*/
|
||||
# endif /* other system, !OS/2 */
|
||||
#endif /* !Windows/x86 */
|
||||
|
||||
/* Now do all the defaulting . */
|
||||
#ifndef PNGCAPI
|
||||
# define PNGCAPI
|
||||
#endif
|
||||
#ifndef PNGCBAPI
|
||||
# define PNGCBAPI PNGCAPI
|
||||
#endif
|
||||
#ifndef PNGAPI
|
||||
# define PNGAPI PNGCAPI
|
||||
#endif
|
||||
|
||||
/* PNG_IMPEXP may be set on the compilation system command line or (if not set)
|
||||
* then in an internal header file when building the library, otherwise (when
|
||||
* using the library) it is set here.
|
||||
*/
|
||||
#ifndef PNG_IMPEXP
|
||||
# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)
|
||||
/* This forces use of a DLL, disallowing static linking */
|
||||
# define PNG_IMPEXP PNG_DLL_IMPORT
|
||||
# endif
|
||||
|
||||
# ifndef PNG_IMPEXP
|
||||
# define PNG_IMPEXP
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat
|
||||
* 'attributes' as a storage class - the attributes go at the start of the
|
||||
* function definition, and attributes are always appended regardless of the
|
||||
* compiler. This considerably simplifies these macros but may cause problems
|
||||
* if any compilers both need function attributes and fail to handle them as
|
||||
* a storage class (this is unlikely.)
|
||||
*/
|
||||
#ifndef PNG_FUNCTION
|
||||
# define PNG_FUNCTION(type, name, args, attributes) attributes type name args
|
||||
#endif
|
||||
|
||||
#ifndef PNG_EXPORT_TYPE
|
||||
# define PNG_EXPORT_TYPE(type) PNG_IMPEXP type
|
||||
#endif
|
||||
|
||||
/* The ordinal value is only relevant when preprocessing png.h for symbol
|
||||
* 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), \
|
||||
PNG_LINKAGE_API attributes)
|
||||
#endif
|
||||
|
||||
/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
|
||||
* so make something non-empty to satisfy the requirement:
|
||||
*/
|
||||
#define PNG_EMPTY /*empty list*/
|
||||
|
||||
#define PNG_EXPORT(ordinal, type, name, args) \
|
||||
PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)
|
||||
|
||||
/* Use PNG_REMOVED to comment out a removed interface. */
|
||||
#ifndef PNG_REMOVED
|
||||
# define PNG_REMOVED(ordinal, type, name, args, attributes)
|
||||
#endif
|
||||
|
||||
#ifndef PNG_CALLBACK
|
||||
# define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args)
|
||||
#endif
|
||||
|
||||
/* Support for compiler specific function attributes. These are used
|
||||
* so that where compiler support is available incorrect use of API
|
||||
* functions in png.h will generate compiler warnings.
|
||||
*
|
||||
* Added at libpng-1.2.41.
|
||||
*/
|
||||
|
||||
#ifndef PNG_NO_PEDANTIC_WARNINGS
|
||||
# ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED
|
||||
# define PNG_PEDANTIC_WARNINGS_SUPPORTED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#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
|
||||
* functions in png.h will generate compiler warnings. Added at libpng
|
||||
* version 1.2.41. Disabling these removes the warnings but may also produce
|
||||
* less efficient code.
|
||||
*/
|
||||
# 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
|
||||
# if __GNUC__ >= 3
|
||||
# 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__))
|
||||
# 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 */
|
||||
|
||||
# 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)
|
||||
# endif
|
||||
# ifndef PNG_ALLOCATED
|
||||
# if (_MSC_VER >= 1400)
|
||||
# define PNG_ALLOCATED __declspec(restrict)
|
||||
# endif
|
||||
# endif
|
||||
# ifndef PNG_DEPRECATED
|
||||
# define PNG_DEPRECATED __declspec(deprecated)
|
||||
# endif
|
||||
# ifndef PNG_PRIVATE
|
||||
# define PNG_PRIVATE __declspec(deprecated)
|
||||
# endif
|
||||
# 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
|
||||
# define PNG_DEPRECATED /* Use of this function is deprecated */
|
||||
#endif
|
||||
#ifndef PNG_USE_RESULT
|
||||
# define PNG_USE_RESULT /* The result of this function must be checked */
|
||||
#endif
|
||||
#ifndef PNG_NORETURN
|
||||
# define PNG_NORETURN /* This function does not return */
|
||||
#endif
|
||||
#ifndef PNG_ALLOCATED
|
||||
# define PNG_ALLOCATED /* The result of the function is new memory */
|
||||
#endif
|
||||
#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);
|
||||
# else /* No floating point APIs */
|
||||
# define PNG_FP_EXPORT(ordinal, type, name, args)
|
||||
# endif
|
||||
#endif
|
||||
#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);
|
||||
# else /* No fixed point APIs */
|
||||
# define PNG_FIXED_EXPORT(ordinal, type, name, args)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef PNG_BUILDING_SYMBOL_TABLE
|
||||
/* Some typedefs to get us started. These should be safe on most of the common
|
||||
* platforms.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#if CHAR_BIT == 8 && UCHAR_MAX == 255
|
||||
typedef unsigned char png_byte;
|
||||
#else
|
||||
# error "libpng requires 8-bit bytes"
|
||||
#endif
|
||||
|
||||
#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
|
||||
# error "libpng requires a signed 16-bit type"
|
||||
#endif
|
||||
|
||||
#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 > 4294967294U
|
||||
typedef unsigned int png_uint_32;
|
||||
#elif ULONG_MAX > 4294967294U
|
||||
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;
|
||||
typedef ptrdiff_t png_ptrdiff_t;
|
||||
|
||||
/* 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().
|
||||
*/
|
||||
#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
|
||||
|
||||
/* 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
|
||||
|
||||
/* 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 png_int_32 png_fixed_point;
|
||||
|
||||
/* Add typedefs for pointers */
|
||||
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 * png_doublep;
|
||||
typedef const double * png_const_doublep;
|
||||
#endif
|
||||
|
||||
/* Pointers to pointers; i.e. arrays */
|
||||
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 * * png_doublepp;
|
||||
#endif
|
||||
|
||||
/* Pointers to pointers to pointers; i.e., pointer to array */
|
||||
typedef char * * * png_charppp;
|
||||
|
||||
#endif /* PNG_BUILDING_SYMBOL_TABLE */
|
||||
|
||||
#endif /* PNGCONF_H */
|
@ -1,153 +0,0 @@
|
||||
|
||||
/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c
|
||||
*
|
||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
||||
* Copyright (c) 1998-2002,2004,2006-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.)
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
/* Define PNG_DEBUG at compile time for debugging information. Higher
|
||||
* numbers for PNG_DEBUG mean more debugging information. This has
|
||||
* only been added since version 0.95 so it is not implemented throughout
|
||||
* libpng yet, but more support will be added as needed.
|
||||
*
|
||||
* png_debug[1-2]?(level, message ,arg{0-2})
|
||||
* Expands to a statement (either a simple expression or a compound
|
||||
* do..while(0) statement) that outputs a message with parameter
|
||||
* substitution if PNG_DEBUG is defined to 2 or more. If PNG_DEBUG
|
||||
* is undefined, 0 or 1 every png_debug expands to a simple expression
|
||||
* (actually ((void)0)).
|
||||
*
|
||||
* level: level of detail of message, starting at 0. A level 'n'
|
||||
* 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
|
||||
* to the message.
|
||||
* arg: 0 to 2 arguments for printf(3) style substitution in message.
|
||||
*/
|
||||
#ifndef PNGDEBUG_H
|
||||
#define PNGDEBUG_H
|
||||
/* These settings control the formatting of messages in png.c and pngerror.c */
|
||||
/* Moved to pngdebug.h at 1.5.0 */
|
||||
# ifndef PNG_LITERAL_SHARP
|
||||
# define PNG_LITERAL_SHARP 0x23
|
||||
# endif
|
||||
# ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET
|
||||
# define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b
|
||||
# endif
|
||||
# ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET
|
||||
# define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d
|
||||
# endif
|
||||
# ifndef PNG_STRING_NEWLINE
|
||||
# define PNG_STRING_NEWLINE "\n"
|
||||
# endif
|
||||
|
||||
#ifdef PNG_DEBUG
|
||||
# if (PNG_DEBUG > 0)
|
||||
# if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)
|
||||
# include <crtdbg.h>
|
||||
# if (PNG_DEBUG > 1)
|
||||
# ifndef _DEBUG
|
||||
# define _DEBUG
|
||||
# endif
|
||||
# ifndef png_debug
|
||||
# define png_debug(l,m) _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE)
|
||||
# endif
|
||||
# ifndef png_debug1
|
||||
# define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1)
|
||||
# endif
|
||||
# ifndef png_debug2
|
||||
# define png_debug2(l,m,p1,p2) \
|
||||
_RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2)
|
||||
# endif
|
||||
# endif
|
||||
# else /* PNG_DEBUG_FILE || !_MSC_VER */
|
||||
# ifndef PNG_STDIO_SUPPORTED
|
||||
# include <stdio.h> /* not included yet */
|
||||
# endif
|
||||
# ifndef PNG_DEBUG_FILE
|
||||
# define PNG_DEBUG_FILE stderr
|
||||
# endif /* PNG_DEBUG_FILE */
|
||||
|
||||
# if (PNG_DEBUG > 1)
|
||||
# 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 ? " " : \
|
||||
(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 ? " " : \
|
||||
(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 ? " " : \
|
||||
(num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1,p2);\
|
||||
} while (0)
|
||||
# endif
|
||||
# else /* __STDC __ */
|
||||
# ifndef png_debug
|
||||
# define png_debug(l,m) \
|
||||
do { \
|
||||
int num_tabs=l; \
|
||||
char format[256]; \
|
||||
snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
|
||||
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
|
||||
m,PNG_STRING_NEWLINE); \
|
||||
fprintf(PNG_DEBUG_FILE,format); \
|
||||
} while (0)
|
||||
# endif
|
||||
# ifndef png_debug1
|
||||
# define png_debug1(l,m,p1) \
|
||||
do { \
|
||||
int num_tabs=l; \
|
||||
char format[256]; \
|
||||
snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
|
||||
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
|
||||
m,PNG_STRING_NEWLINE); \
|
||||
fprintf(PNG_DEBUG_FILE,format,p1); \
|
||||
} while (0)
|
||||
# endif
|
||||
# ifndef png_debug2
|
||||
# define png_debug2(l,m,p1,p2) \
|
||||
do { \
|
||||
int num_tabs=l; \
|
||||
char format[256]; \
|
||||
snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
|
||||
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
|
||||
m,PNG_STRING_NEWLINE); \
|
||||
fprintf(PNG_DEBUG_FILE,format,p1,p2); \
|
||||
} while (0)
|
||||
# endif
|
||||
# endif /* __STDC __ */
|
||||
# endif /* (PNG_DEBUG > 1) */
|
||||
|
||||
# endif /* _MSC_VER */
|
||||
# endif /* (PNG_DEBUG > 0) */
|
||||
#endif /* PNG_DEBUG */
|
||||
#ifndef png_debug
|
||||
# define png_debug(l, m) ((void)0)
|
||||
#endif
|
||||
#ifndef png_debug1
|
||||
# define png_debug1(l, m, p1) ((void)0)
|
||||
#endif
|
||||
#ifndef png_debug2
|
||||
# define png_debug2(l, m, p1, p2) ((void)0)
|
||||
#endif
|
||||
#endif /* PNGDEBUG_H */
|
@ -1,963 +0,0 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.6.31 [July 27, 2017]
|
||||
* Copyright (c) 1998-2002,2004,2006-2017 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.)
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* This file provides a location for all error handling. Users who
|
||||
* need special error handling are expected to write replacement functions
|
||||
* and use png_set_error_fn() to use those functions. See the instructions
|
||||
* at each function.
|
||||
*/
|
||||
|
||||
#include "pngpriv.h"
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
|
||||
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_const_structrp png_ptr,
|
||||
png_const_charp warning_message));
|
||||
#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,
|
||||
* you should supply a replacement error function and use png_set_error_fn()
|
||||
* to replace the error function at run-time.
|
||||
*/
|
||||
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
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)) != 0)
|
||||
{
|
||||
if (*error_message == PNG_LITERAL_SHARP)
|
||||
{
|
||||
/* Strip "#nnnn " from beginning of error message. */
|
||||
int offset;
|
||||
for (offset = 1; offset<15; offset++)
|
||||
if (error_message[offset] == ' ')
|
||||
break;
|
||||
|
||||
if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < offset - 1; i++)
|
||||
msg[i] = error_message[i + 1];
|
||||
msg[i - 1] = '\0';
|
||||
error_message = msg;
|
||||
}
|
||||
|
||||
else
|
||||
error_message += offset;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
|
||||
{
|
||||
msg[0] = '0';
|
||||
msg[1] = '\0';
|
||||
error_message = msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
||||
(*(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. */
|
||||
png_default_error(png_ptr, error_message);
|
||||
}
|
||||
#else
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
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
|
||||
* apparently an error, introduced in libpng-1.2.20, and png_default_error
|
||||
* will crash in this case.
|
||||
*/
|
||||
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
||||
(*(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 /* ERROR_TEXT */
|
||||
|
||||
/* Utility to safely appends strings to a buffer. This never errors out so
|
||||
* error checking is not required in the caller.
|
||||
*/
|
||||
size_t
|
||||
png_safecat(png_charp buffer, size_t bufsize, size_t pos,
|
||||
png_const_charp string)
|
||||
{
|
||||
if (buffer != NULL && pos < bufsize)
|
||||
{
|
||||
if (string != NULL)
|
||||
while (*string != '\0' && pos < bufsize-1)
|
||||
buffer[pos++] = *string++;
|
||||
|
||||
buffer[pos] = '\0';
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||
/* Utility to dump an unsigned value into a buffer, given a start pointer and
|
||||
* and end pointer (which should point just *beyond* the end of the buffer!)
|
||||
* Returns the pointer to the start of the formatted string.
|
||||
*/
|
||||
png_charp
|
||||
png_format_number(png_const_charp start, png_charp end, int format,
|
||||
png_alloc_size_t number)
|
||||
{
|
||||
int count = 0; /* number of digits output */
|
||||
int mincount = 1; /* minimum number required */
|
||||
int output = 0; /* digit output (for the fixed point format) */
|
||||
|
||||
*--end = '\0';
|
||||
|
||||
/* This is written so that the loop always runs at least once, even with
|
||||
* number zero.
|
||||
*/
|
||||
while (end > start && (number != 0 || count < mincount))
|
||||
{
|
||||
|
||||
static const char digits[] = "0123456789ABCDEF";
|
||||
|
||||
switch (format)
|
||||
{
|
||||
case PNG_NUMBER_FORMAT_fixed:
|
||||
/* Needs five digits (the fraction) */
|
||||
mincount = 5;
|
||||
if (output != 0 || number % 10 != 0)
|
||||
{
|
||||
*--end = digits[number % 10];
|
||||
output = 1;
|
||||
}
|
||||
number /= 10;
|
||||
break;
|
||||
|
||||
case PNG_NUMBER_FORMAT_02u:
|
||||
/* Expects at least 2 digits. */
|
||||
mincount = 2;
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case PNG_NUMBER_FORMAT_u:
|
||||
*--end = digits[number % 10];
|
||||
number /= 10;
|
||||
break;
|
||||
|
||||
case PNG_NUMBER_FORMAT_02x:
|
||||
/* This format expects at least two digits */
|
||||
mincount = 2;
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case PNG_NUMBER_FORMAT_x:
|
||||
*--end = digits[number & 0xf];
|
||||
number >>= 4;
|
||||
break;
|
||||
|
||||
default: /* an error */
|
||||
number = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Keep track of the number of digits added */
|
||||
++count;
|
||||
|
||||
/* Float a fixed number here: */
|
||||
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 != 0)
|
||||
*--end = '.';
|
||||
else if (number == 0) /* and !output */
|
||||
*--end = '0';
|
||||
}
|
||||
}
|
||||
|
||||
return end;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
/* This function is called whenever there is a non-fatal error. This function
|
||||
* should not be changed. If there is a need to handle warnings differently,
|
||||
* you should supply a replacement warning function and use
|
||||
* png_set_error_fn() to replace the warning function at run-time.
|
||||
*/
|
||||
void PNGAPI
|
||||
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)) != 0)
|
||||
#endif
|
||||
{
|
||||
if (*warning_message == PNG_LITERAL_SHARP)
|
||||
{
|
||||
for (offset = 1; offset < 15; offset++)
|
||||
if (warning_message[offset] == ' ')
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (png_ptr != NULL && png_ptr->warning_fn != NULL)
|
||||
(*(png_ptr->warning_fn))(png_constcast(png_structrp,png_ptr),
|
||||
warning_message + offset);
|
||||
else
|
||||
png_default_warning(png_ptr, warning_message + offset);
|
||||
}
|
||||
|
||||
/* These functions support 'formatted' warning messages with up to
|
||||
* PNG_WARNING_PARAMETER_COUNT parameters. In the format string the parameter
|
||||
* is introduced by @<number>, where 'number' starts at 1. This follows the
|
||||
* standard established by X/Open for internationalizable error messages.
|
||||
*/
|
||||
void
|
||||
png_warning_parameter(png_warning_parameters p, int number,
|
||||
png_const_charp string)
|
||||
{
|
||||
if (number > 0 && number <= PNG_WARNING_PARAMETER_COUNT)
|
||||
(void)png_safecat(p[number-1], (sizeof p[number-1]), 0, string);
|
||||
}
|
||||
|
||||
void
|
||||
png_warning_parameter_unsigned(png_warning_parameters p, int number, int format,
|
||||
png_alloc_size_t value)
|
||||
{
|
||||
char buffer[PNG_NUMBER_BUFFER_SIZE];
|
||||
png_warning_parameter(p, number, PNG_FORMAT_NUMBER(buffer, format, value));
|
||||
}
|
||||
|
||||
void
|
||||
png_warning_parameter_signed(png_warning_parameters p, int number, int format,
|
||||
png_int_32 value)
|
||||
{
|
||||
png_alloc_size_t u;
|
||||
png_charp str;
|
||||
char buffer[PNG_NUMBER_BUFFER_SIZE];
|
||||
|
||||
/* Avoid overflow by doing the negate in a png_alloc_size_t: */
|
||||
u = (png_alloc_size_t)value;
|
||||
if (value < 0)
|
||||
u = ~u + 1;
|
||||
|
||||
str = PNG_FORMAT_NUMBER(buffer, format, u);
|
||||
|
||||
if (value < 0 && str > buffer)
|
||||
*--str = '-';
|
||||
|
||||
png_warning_parameter(p, number, str);
|
||||
}
|
||||
|
||||
void
|
||||
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,
|
||||
* overflow doesn't happen because this code checks! If someone figures
|
||||
* out how to send us a message longer than 192 bytes, all that will
|
||||
* happen is that the message will be truncated appropriately.
|
||||
*/
|
||||
size_t i = 0; /* Index in the msg[] buffer: */
|
||||
char msg[192];
|
||||
|
||||
/* Each iteration through the following loop writes at most one character
|
||||
* to msg[i++] then returns here to validate that there is still space for
|
||||
* the trailing '\0'. It may (in the case of a parameter) read more than
|
||||
* one character from message[]; it must check for '\0' and continue to the
|
||||
* test if it finds the end of string.
|
||||
*/
|
||||
while (i<(sizeof msg)-1 && *message != '\0')
|
||||
{
|
||||
/* '@' at end of string is now just printed (previously it was skipped);
|
||||
* it is an error in the calling code to terminate the string with @.
|
||||
*/
|
||||
if (p != NULL && *message == '@' && message[1] != '\0')
|
||||
{
|
||||
int parameter_char = *++message; /* Consume the '@' */
|
||||
static const char valid_parameters[] = "123456789";
|
||||
int parameter = 0;
|
||||
|
||||
/* Search for the parameter digit, the index in the string is the
|
||||
* parameter to use.
|
||||
*/
|
||||
while (valid_parameters[parameter] != parameter_char &&
|
||||
valid_parameters[parameter] != '\0')
|
||||
++parameter;
|
||||
|
||||
/* If the parameter digit is out of range it will just get printed. */
|
||||
if (parameter < PNG_WARNING_PARAMETER_COUNT)
|
||||
{
|
||||
/* Append this parameter */
|
||||
png_const_charp parm = p[parameter];
|
||||
png_const_charp pend = p[parameter] + (sizeof p[parameter]);
|
||||
|
||||
/* No need to copy the trailing '\0' here, but there is no guarantee
|
||||
* that parm[] has been initialized, so there is no guarantee of a
|
||||
* trailing '\0':
|
||||
*/
|
||||
while (i<(sizeof msg)-1 && *parm != '\0' && parm < pend)
|
||||
msg[i++] = *parm++;
|
||||
|
||||
/* Consume the parameter digit too: */
|
||||
++message;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* else not a parameter and there is a character after the @ sign; just
|
||||
* copy that. This is known not to be '\0' because of the test above.
|
||||
*/
|
||||
}
|
||||
|
||||
/* At this point *message can't be '\0', even in the bad parameter case
|
||||
* above where there is a lone '@' at the end of the message string.
|
||||
*/
|
||||
msg[i++] = *message++;
|
||||
}
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
png_warning(png_ptr, msg);
|
||||
}
|
||||
#endif /* WARNINGS */
|
||||
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_benign_error(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
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);
|
||||
|
||||
# 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,
|
||||
* 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))
|
||||
static PNG_CONST char png_digit[16] = {
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
'A', 'B', 'C', 'D', 'E', 'F'
|
||||
};
|
||||
|
||||
static void /* PRIVATE */
|
||||
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;
|
||||
int iout = 0, ishift = 24;
|
||||
|
||||
while (ishift >= 0)
|
||||
{
|
||||
int c = (int)(chunk_name >> ishift) & 0xff;
|
||||
|
||||
ishift -= 8;
|
||||
if (isnonalpha(c) != 0)
|
||||
{
|
||||
buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET;
|
||||
buffer[iout++] = png_digit[(c & 0xf0) >> 4];
|
||||
buffer[iout++] = png_digit[c & 0x0f];
|
||||
buffer[iout++] = PNG_LITERAL_RIGHT_SQUARE_BRACKET;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
buffer[iout++] = (char)c;
|
||||
}
|
||||
}
|
||||
|
||||
if (error_message == NULL)
|
||||
buffer[iout] = '\0';
|
||||
|
||||
else
|
||||
{
|
||||
int iin = 0;
|
||||
|
||||
buffer[iout++] = ':';
|
||||
buffer[iout++] = ' ';
|
||||
|
||||
while (iin < PNG_MAX_ERROR_TEXT-1 && error_message[iin] != '\0')
|
||||
buffer[iout++] = error_message[iin++];
|
||||
|
||||
/* iin < PNG_MAX_ERROR_TEXT, so the following is safe: */
|
||||
buffer[iout] = '\0';
|
||||
}
|
||||
}
|
||||
#endif /* WARNINGS || ERROR_TEXT */
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_chunk_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
{
|
||||
char msg[18+PNG_MAX_ERROR_TEXT];
|
||||
if (png_ptr == NULL)
|
||||
png_error(png_ptr, error_message);
|
||||
|
||||
else
|
||||
{
|
||||
png_format_buffer(png_ptr, msg, error_message);
|
||||
png_error(png_ptr, msg);
|
||||
}
|
||||
}
|
||||
#endif /* READ && ERROR_TEXT */
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_chunk_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||
{
|
||||
char msg[18+PNG_MAX_ERROR_TEXT];
|
||||
if (png_ptr == NULL)
|
||||
png_warning(png_ptr, warning_message);
|
||||
|
||||
else
|
||||
{
|
||||
png_format_buffer(png_ptr, msg, warning_message);
|
||||
png_warning(png_ptr, msg);
|
||||
}
|
||||
}
|
||||
#endif /* WARNINGS */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp
|
||||
error_message)
|
||||
{
|
||||
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 /* 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_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)
|
||||
unsigned int iin;
|
||||
char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];
|
||||
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;
|
||||
}
|
||||
msg[fixed_message_ln + iin] = 0;
|
||||
png_error(png_ptr, msg);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
/* This API only exists if ANSI-C style error handling is used,
|
||||
* otherwise it is necessary for png_default_error to be overridden.
|
||||
*/
|
||||
jmp_buf* PNGAPI
|
||||
png_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn,
|
||||
size_t jmp_buf_size)
|
||||
{
|
||||
/* 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->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
|
||||
|
||||
/* This is the default error handling function. Note that replacements for
|
||||
* this function MUST NOT RETURN, or the program will likely crash. This
|
||||
* function is used by default, or if the program supplies NULL for the
|
||||
* error function pointer in png_set_error_fn().
|
||||
*/
|
||||
static PNG_FUNCTION(void /* PRIVATE */,
|
||||
png_default_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
{
|
||||
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
/* Check on NULL only added in 1.5.4 */
|
||||
if (error_message != NULL && *error_message == PNG_LITERAL_SHARP)
|
||||
{
|
||||
/* Strip "#nnnn " from beginning of error message. */
|
||||
int offset;
|
||||
char error_number[16];
|
||||
for (offset = 0; offset<15; offset++)
|
||||
{
|
||||
error_number[offset] = error_message[offset + 1];
|
||||
if (error_message[offset] == ' ')
|
||||
break;
|
||||
}
|
||||
|
||||
if ((offset > 1) && (offset < 15))
|
||||
{
|
||||
error_number[offset - 1] = '\0';
|
||||
fprintf(stderr, "libpng error no. %s: %s",
|
||||
error_number, error_message + offset + 1);
|
||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "libpng error: %s, offset=%d",
|
||||
error_message, offset);
|
||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
fprintf(stderr, "libpng error: %s", error_message ? error_message :
|
||||
"undefined");
|
||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(error_message) /* Make compiler happy */
|
||||
#endif
|
||||
png_longjmp(png_ptr, 1);
|
||||
}
|
||||
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_longjmp,(png_const_structrp png_ptr, int val),PNG_NORETURN)
|
||||
{
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
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
|
||||
|
||||
/* 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();
|
||||
}
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
/* This function is called when there is a warning, but the library thinks
|
||||
* it can continue anyway. Replacement functions don't have to do anything
|
||||
* here if you don't want them to. In the default configuration, png_ptr is
|
||||
* not used, but it is passed in case it may be useful.
|
||||
*/
|
||||
static void /* PRIVATE */
|
||||
png_default_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||
{
|
||||
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
||||
# ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
if (*warning_message == PNG_LITERAL_SHARP)
|
||||
{
|
||||
int offset;
|
||||
char warning_number[16];
|
||||
for (offset = 0; offset < 15; offset++)
|
||||
{
|
||||
warning_number[offset] = warning_message[offset + 1];
|
||||
if (warning_message[offset] == ' ')
|
||||
break;
|
||||
}
|
||||
|
||||
if ((offset > 1) && (offset < 15))
|
||||
{
|
||||
warning_number[offset + 1] = '\0';
|
||||
fprintf(stderr, "libpng warning no. %s: %s",
|
||||
warning_number, warning_message + offset);
|
||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "libpng warning: %s",
|
||||
warning_message);
|
||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||
}
|
||||
}
|
||||
else
|
||||
# endif
|
||||
|
||||
{
|
||||
fprintf(stderr, "libpng warning: %s", warning_message);
|
||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(warning_message) /* Make compiler happy */
|
||||
#endif
|
||||
PNG_UNUSED(png_ptr) /* Make compiler happy */
|
||||
}
|
||||
#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->jmp_buf_ptr, 1)
|
||||
*/
|
||||
void PNGAPI
|
||||
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)
|
||||
return;
|
||||
|
||||
png_ptr->error_ptr = error_ptr;
|
||||
png_ptr->error_fn = error_fn;
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
png_ptr->warning_fn = warning_fn;
|
||||
#else
|
||||
PNG_UNUSED(warning_fn)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* This function returns a pointer to the error_ptr associated with the user
|
||||
* functions. The application should free any memory associated with this
|
||||
* pointer before png_write_destroy and png_read_destroy are called.
|
||||
*/
|
||||
png_voidp PNGAPI
|
||||
png_get_error_ptr(png_const_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
return ((png_voidp)png_ptr->error_ptr);
|
||||
}
|
||||
|
||||
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_strip_error_numbers(png_structrp png_ptr, png_uint_32 strip_mode)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
png_ptr->flags &=
|
||||
((~(PNG_FLAG_STRIP_ERROR_NUMBERS |
|
||||
PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#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 */
|
File diff suppressed because it is too large
Load Diff
@ -1,267 +0,0 @@
|
||||
|
||||
/* pnginfo.h - header file for PNG reference library
|
||||
*
|
||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
* Copyright (c) 1998-2002,2004,2006-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.)
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
/* png_info is a structure that holds the information in a PNG file so
|
||||
* that the application can find out the characteristics of the image.
|
||||
* If you are reading the file, this structure will tell you what is
|
||||
* in the PNG file. If you are writing the file, fill in the information
|
||||
* you want to put into the PNG file, using png_set_*() functions, then
|
||||
* call png_write_info().
|
||||
*
|
||||
* The names chosen should be very close to the PNG specification, so
|
||||
* consult that document for information about the meaning of each field.
|
||||
*
|
||||
* With libpng < 0.95, it was only possible to directly set and read the
|
||||
* the values in the png_info_struct, which meant that the contents and
|
||||
* order of the values had to remain fixed. With libpng 0.95 and later,
|
||||
* however, there are now functions that abstract the contents of
|
||||
* png_info_struct from the application, so this makes it easier to use
|
||||
* libpng with dynamic libraries, and even makes it possible to use
|
||||
* libraries that don't have all of the libpng ancillary chunk-handing
|
||||
* functionality. In libpng-1.5.0 this was moved into a separate private
|
||||
* file that is not visible to applications.
|
||||
*
|
||||
* The following members may have allocated storage attached that should be
|
||||
* cleaned up before the structure is discarded: palette, trans, text,
|
||||
* pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
|
||||
* splt_palettes, scal_unit, row_pointers, and unknowns. By default, these
|
||||
* are automatically freed when the info structure is deallocated, if they were
|
||||
* allocated internally by libpng. This behavior can be changed by means
|
||||
* of the png_data_freer() function.
|
||||
*
|
||||
* More allocation details: all the chunk-reading functions that
|
||||
* change these members go through the corresponding png_set_*
|
||||
* functions. A function to clear these members is available: see
|
||||
* png_free_data(). The png_set_* functions do not depend on being
|
||||
* able to point info structure members to any of the storage they are
|
||||
* passed (they make their own copies), EXCEPT that the png_set_text
|
||||
* functions use the same storage passed to them in the text_ptr or
|
||||
* itxt_ptr structure argument, and the png_set_rows and png_set_unknowns
|
||||
* functions do not make their own copies.
|
||||
*/
|
||||
#ifndef PNGINFO_H
|
||||
#define PNGINFO_H
|
||||
|
||||
struct png_info_def
|
||||
{
|
||||
/* 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) */
|
||||
png_size_t rowbytes; /* bytes needed to hold an untransformed row */
|
||||
png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */
|
||||
png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */
|
||||
png_uint_16 num_trans; /* number of transparent palette color (tRNS) */
|
||||
png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */
|
||||
png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */
|
||||
/* The following three should have been named *_method not *_type */
|
||||
png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */
|
||||
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 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
|
||||
* are writing, set the valid field to those chunks you want written,
|
||||
* and initialize the appropriate fields below.
|
||||
*/
|
||||
|
||||
#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_colorspace colorspace;
|
||||
#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 */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
/* The tEXt, and zTXt chunks contain human-readable textual data in
|
||||
* uncompressed, compressed, and optionally compressed forms, respectively.
|
||||
* The data in "text" is an array of pointers to uncompressed,
|
||||
* null-terminated C strings. Each chunk has a keyword that describes the
|
||||
* textual data contained in that chunk. Keywords are not required to be
|
||||
* unique, and the text string may be empty. Any number of text chunks may
|
||||
* be in an image.
|
||||
*/
|
||||
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 /* TEXT */
|
||||
|
||||
#ifdef PNG_tIME_SUPPORTED
|
||||
/* The tIME chunk holds the last time the displayed image data was
|
||||
* modified. See the png_time struct for the contents of this struct.
|
||||
*/
|
||||
png_time mod_time;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sBIT_SUPPORTED
|
||||
/* The sBIT chunk specifies the number of significant high-order bits
|
||||
* in the pixel data. Values are in the range [1, bit_depth], and are
|
||||
* only specified for the channels in the pixel data. The contents of
|
||||
* the low-order bits is not specified. Data is valid if
|
||||
* (valid & PNG_INFO_sBIT) is non-zero.
|
||||
*/
|
||||
png_color_8 sig_bit; /* significant bits in color channels */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \
|
||||
defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
/* The tRNS chunk supplies transparency data for paletted images and
|
||||
* other image types that don't need a full alpha channel. There are
|
||||
* "num_trans" transparency values for a paletted image, stored in the
|
||||
* same order as the palette colors, starting from index 0. Values
|
||||
* for the data are in the range [0, 255], ranging from fully transparent
|
||||
* to fully opaque, respectively. For non-paletted images, there is a
|
||||
* single color specified that should be treated as fully transparent.
|
||||
* Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
|
||||
*/
|
||||
png_bytep trans_alpha; /* alpha values for paletted image */
|
||||
png_color_16 trans_color; /* transparent color for non-palette image */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
/* The bKGD chunk gives the suggested image background color if the
|
||||
* display program does not have its own background color and the image
|
||||
* is needs to composited onto a background before display. The colors
|
||||
* in "background" are normally in the same color space/depth as the
|
||||
* pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
|
||||
*/
|
||||
png_color_16 background;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
/* The oFFs chunk gives the offset in "offset_unit_type" units rightwards
|
||||
* and downwards from the top-left corner of the display, page, or other
|
||||
* application-specific co-ordinate space. See the PNG_OFFSET_ defines
|
||||
* below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero.
|
||||
*/
|
||||
png_int_32 x_offset; /* x offset on page */
|
||||
png_int_32 y_offset; /* y offset on page */
|
||||
png_byte offset_unit_type; /* offset units type */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_pHYs_SUPPORTED
|
||||
/* The pHYs chunk gives the physical pixel density of the image for
|
||||
* display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
|
||||
* defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
|
||||
*/
|
||||
png_uint_32 x_pixels_per_unit; /* horizontal pixel density */
|
||||
png_uint_32 y_pixels_per_unit; /* vertical pixel density */
|
||||
png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_eXIf_SUPPORTED
|
||||
int num_exif; /* Added at libpng-1.6.31 */
|
||||
png_bytep exif;
|
||||
# ifdef PNG_READ_eXIf_SUPPORTED
|
||||
png_bytep eXIf_buf; /* Added at libpng-1.6.32 */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_hIST_SUPPORTED
|
||||
/* The hIST chunk contains the relative frequency or importance of the
|
||||
* various palette entries, so that a viewer can intelligently select a
|
||||
* reduced-color palette, if required. Data is an array of "num_palette"
|
||||
* values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)
|
||||
* is non-zero.
|
||||
*/
|
||||
png_uint_16p hist;
|
||||
#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.
|
||||
* The integer range [0, 2^bit_depth - 1] maps to the floating-point
|
||||
* range given by [pcal_X0, pcal_X1], and are further transformed by a
|
||||
* (possibly non-linear) transformation function given by "pcal_type"
|
||||
* and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_
|
||||
* defines below, and the PNG-Group's PNG extensions document for a
|
||||
* complete description of the transformations and how they should be
|
||||
* implemented, and for a description of the ASCII parameter strings.
|
||||
* Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
|
||||
*/
|
||||
png_charp pcal_purpose; /* pCAL chunk description string */
|
||||
png_int_32 pcal_X0; /* minimum value */
|
||||
png_int_32 pcal_X1; /* maximum value */
|
||||
png_charp pcal_units; /* Latin-1 string giving physical units */
|
||||
png_charpp pcal_params; /* ASCII strings containing parameter values */
|
||||
png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */
|
||||
png_byte pcal_nparams; /* number of parameters given in pcal_params */
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.0.6 */
|
||||
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
|
||||
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Storage for unknown chunks that the library doesn't recognize. */
|
||||
png_unknown_chunkp unknown_chunks;
|
||||
|
||||
/* 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;
|
||||
int splt_palettes_num; /* Match type returned by png_get API */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sCAL_SUPPORTED
|
||||
/* The sCAL chunk describes the actual physical dimensions of the
|
||||
* subject matter of the graphic. The chunk contains a unit specification
|
||||
* a byte value, and two ASCII strings representing floating-point
|
||||
* values. The values are width and height corresponsing to one pixel
|
||||
* in the image. Data values are valid if (valid & PNG_INFO_sCAL) is
|
||||
* non-zero.
|
||||
*/
|
||||
png_byte scal_unit; /* unit of physical scale */
|
||||
png_charp scal_s_width; /* string containing height */
|
||||
png_charp scal_s_height; /* string containing width */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_INFO_IMAGE_SUPPORTED
|
||||
/* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS)
|
||||
non-zero */
|
||||
/* Data valid if (valid & PNG_INFO_IDAT) non-zero */
|
||||
png_bytepp row_pointers; /* the image bits */
|
||||
#endif
|
||||
|
||||
};
|
||||
#endif /* PNGINFO_H */
|
@ -1,284 +0,0 @@
|
||||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.6.26 [October 20, 2016]
|
||||
* Copyright (c) 1998-2002,2004,2006-2014,2016 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.)
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* This file provides a location for all memory allocation. Users who
|
||||
* need special memory handling are expected to supply replacement
|
||||
* functions for png_malloc() and png_free(), and to use
|
||||
* png_create_read_struct_2() and png_create_write_struct_2() to
|
||||
* identify the replacement functions.
|
||||
*/
|
||||
|
||||
#include "pngpriv.h"
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
/* Free a png_struct */
|
||||
void /* PRIVATE */
|
||||
png_destroy_png_struct(png_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
/* 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);
|
||||
|
||||
# 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 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_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
ret = png_malloc(png_ptr, size);
|
||||
|
||||
if (ret != NULL)
|
||||
memset(ret, 0, size);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* 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)
|
||||
{
|
||||
/* 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
|
||||
|
||||
/* 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
|
||||
)
|
||||
{
|
||||
#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 malloc((size_t)size); /* checked for truncation above */
|
||||
}
|
||||
|
||||
else
|
||||
return 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 = (png_alloc_size_t)nelements; /* known to be > 0 */
|
||||
|
||||
if (req <= PNG_SIZE_MAX/element_size)
|
||||
return png_malloc_base(png_ptr, req * element_size);
|
||||
|
||||
/* The failure case when the request is too large */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
return png_malloc_array_checked(png_ptr, nelements, element_size);
|
||||
}
|
||||
|
||||
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_const_structrp 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_constcast(png_structrp,png_ptr), ptr);
|
||||
|
||||
else
|
||||
png_free_default(png_ptr, 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 */
|
||||
|
||||
free(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_structrp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
||||
malloc_fn, png_free_ptr free_fn)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
png_ptr->mem_ptr = mem_ptr;
|
||||
png_ptr->malloc_fn = malloc_fn;
|
||||
png_ptr->free_fn = free_fn;
|
||||
}
|
||||
}
|
||||
|
||||
/* This function returns a pointer to the mem_ptr associated with the user
|
||||
* functions. The application should free any memory associated with this
|
||||
* pointer before png_write_destroy and png_read_destroy are called.
|
||||
*/
|
||||
png_voidp PNGAPI
|
||||
png_get_mem_ptr(png_const_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
return png_ptr->mem_ptr;
|
||||
}
|
||||
#endif /* USER_MEM */
|
||||
#endif /* READ || WRITE */
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,120 +0,0 @@
|
||||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 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.)
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* This file provides a location for all input. Users who need
|
||||
* special handling are expected to write a function that has the same
|
||||
* arguments as this and performs a similar function, but that possibly
|
||||
* has a different input method. Note that you shouldn't change this
|
||||
* function, but rather write a replacement function and then make
|
||||
* libpng use it at run time with png_set_read_fn(...).
|
||||
*/
|
||||
|
||||
#include "pngpriv.h"
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
/* Read the data from whatever input you are using. The default routine
|
||||
* 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 than 64K on a 16-bit machine.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_read_data(png_structrp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_debug1(4, "reading %d bytes", (int)length);
|
||||
|
||||
if (png_ptr->read_data_fn != NULL)
|
||||
(*(png_ptr->read_data_fn))(png_ptr, data, length);
|
||||
|
||||
else
|
||||
png_error(png_ptr, "Call to NULL read function");
|
||||
}
|
||||
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
/* This is the function that does the actual reading of data. If you are
|
||||
* not reading from a standard C stream, you should create a replacement
|
||||
* read_data function and use it at run time with png_set_read_fn(), rather
|
||||
* than changing the library.
|
||||
*/
|
||||
void PNGCBAPI
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_size_t check;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* 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_voidcast(png_FILE_p, png_ptr->io_ptr));
|
||||
|
||||
if (check != length)
|
||||
png_error(png_ptr, "Read Error");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This function allows the application to supply a new input function
|
||||
* for libpng if standard C streams aren't being used.
|
||||
*
|
||||
* This function takes as its arguments:
|
||||
*
|
||||
* png_ptr - pointer to a png input data structure
|
||||
*
|
||||
* io_ptr - pointer to user supplied structure containing info about
|
||||
* the input functions. May be NULL.
|
||||
*
|
||||
* read_data_fn - pointer to a new input function that takes as its
|
||||
* arguments a pointer to a png_struct, a pointer to
|
||||
* a location where input data can be stored, and a 32-bit
|
||||
* unsigned int that is the number of bytes to be read.
|
||||
* To exit and output any fatal error messages the new write
|
||||
* function should call png_error(png_ptr, "Error msg").
|
||||
* May be NULL, in which case libpng's default function will
|
||||
* be used.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr read_data_fn)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->io_ptr = io_ptr;
|
||||
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
if (read_data_fn != NULL)
|
||||
png_ptr->read_data_fn = read_data_fn;
|
||||
|
||||
else
|
||||
png_ptr->read_data_fn = png_default_read_data;
|
||||
#else
|
||||
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)
|
||||
{
|
||||
png_ptr->write_data_fn = NULL;
|
||||
png_warning(png_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 /* READ */
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,483 +0,0 @@
|
||||
|
||||
/* pngstruct.h - header file for PNG reference library
|
||||
*
|
||||
* Last changed in libpng 1.6.32 [August 24, 2017]
|
||||
* Copyright (c) 1998-2002,2004,2006-2017 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.)
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
/* The structure that holds the information to read and write PNG files.
|
||||
* The only people who need to care about what is inside of this are the
|
||||
* people who will be modifying the library for their own special needs.
|
||||
* It should NOT be accessed directly by an application.
|
||||
*/
|
||||
|
||||
#ifndef PNGSTRUCT_H
|
||||
#define PNGSTRUCT_H
|
||||
/* zlib.h defines the structure z_stream, an instance of which is included
|
||||
* 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 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
|
||||
png_error_ptr warning_fn; /* function for printing warnings */
|
||||
#endif
|
||||
png_voidp error_ptr; /* user supplied struct for error functions */
|
||||
png_rw_ptr write_data_fn; /* function for writing output data */
|
||||
png_rw_ptr read_data_fn; /* function for reading input data */
|
||||
png_voidp io_ptr; /* ptr to application struct for I/O functions */
|
||||
|
||||
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
png_user_transform_ptr read_user_transform_fn; /* user read transform */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
png_user_transform_ptr write_user_transform_fn; /* user write transform */
|
||||
#endif
|
||||
|
||||
/* These were added in libpng-1.0.2 */
|
||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
png_voidp user_transform_ptr; /* user supplied struct for user transform */
|
||||
png_byte user_transform_depth; /* bit depth of user transformed pixels */
|
||||
png_byte user_transform_channels; /* channels in user transformed pixels */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
png_uint_32 mode; /* tells us where we are in the PNG file */
|
||||
png_uint_32 flags; /* flags indicating various things to libpng */
|
||||
png_uint_32 transformations; /* which transformations to perform */
|
||||
|
||||
png_uint_32 zowner; /* ID (chunk type) of zstream owner, 0 if none */
|
||||
z_stream zstream; /* decompression structure */
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
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 */
|
||||
int zlib_window_bits; /* holds zlib compression window bits */
|
||||
int zlib_mem_level; /* holds zlib compression memory level */
|
||||
int zlib_strategy; /* holds zlib compression strategy */
|
||||
#endif
|
||||
/* Added at libpng 1.5.4 */
|
||||
#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 */
|
||||
int zlib_text_mem_level; /* holds zlib compression memory level */
|
||||
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 */
|
||||
png_uint_32 num_rows; /* number of rows in current pass */
|
||||
png_uint_32 usr_width; /* width of row at start of write */
|
||||
png_size_t rowbytes; /* size of row in bytes */
|
||||
png_uint_32 iwidth; /* width of current interlaced row in pixels */
|
||||
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.
|
||||
* 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.
|
||||
* While reading, this is a pointer into
|
||||
* big_row_buf; while writing it is separately
|
||||
* allocated.
|
||||
*/
|
||||
#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 */
|
||||
png_uint_32 crc; /* current chunk CRC value */
|
||||
png_colorp palette; /* palette from the input file */
|
||||
png_uint_16 num_palette; /* number of color entries in palette */
|
||||
|
||||
/* Added at libpng-1.5.10 */
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
int num_palette_max; /* maximum palette index found in IDAT */
|
||||
#endif
|
||||
|
||||
png_uint_16 num_trans; /* number of transparency values */
|
||||
png_byte compression; /* file compression type (always 0) */
|
||||
png_byte filter; /* file filter type (always 0) */
|
||||
png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
|
||||
png_byte pass; /* current interlace pass (0 - 6) */
|
||||
png_byte do_filter; /* row filter flags (see PNG_FILTER_ in png.h ) */
|
||||
png_byte color_type; /* color type of file */
|
||||
png_byte bit_depth; /* bit depth of file */
|
||||
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 */
|
||||
#if ZLIB_VERNUM >= 0x1240
|
||||
png_byte zstream_start; /* at start of an input zlib stream */
|
||||
#endif /* Zlib >= 1.2.4 */
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||
png_uint_16 filler; /* filler bytes for pixel expansion */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
png_byte background_gamma_type;
|
||||
png_fixed_point background_gamma;
|
||||
png_color_16 background; /* background color in screen gamma space */
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
png_color_16 background_1; /* background normalized to gamma 1.0 */
|
||||
#endif
|
||||
#endif /* bKGD */
|
||||
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
png_flush_ptr output_flush_fn; /* Function for flushing output */
|
||||
png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */
|
||||
png_uint_32 flush_rows; /* number of rows written since last flush */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */
|
||||
png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */
|
||||
|
||||
png_bytep gamma_table; /* gamma table for 8-bit depth files */
|
||||
png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
|
||||
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
png_bytep gamma_from_1; /* converts from 1.0 to screen */
|
||||
png_bytep gamma_to_1; /* converts from file to 1.0 */
|
||||
png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
|
||||
png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
|
||||
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)
|
||||
png_color_8 sig_bit; /* significant bits in each available channel */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
|
||||
png_color_8 shift; /* shift for significant bit tranformation */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \
|
||||
|| defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
png_bytep trans_alpha; /* alpha values for paletted files */
|
||||
png_color_16 trans_color; /* transparent color for non-paletted files */
|
||||
#endif
|
||||
|
||||
png_read_status_ptr read_row_fn; /* called after each row is decoded */
|
||||
png_write_status_ptr write_row_fn; /* called after each row is encoded */
|
||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
png_progressive_info_ptr info_fn; /* called after header data fully read */
|
||||
png_progressive_row_ptr row_fn; /* called after a prog. row is decoded */
|
||||
png_progressive_end_ptr end_fn; /* called after image is complete */
|
||||
png_bytep save_buffer_ptr; /* current location in save_buffer */
|
||||
png_bytep save_buffer; /* buffer for previously read data */
|
||||
png_bytep current_buffer_ptr; /* current location in current_buffer */
|
||||
png_bytep current_buffer; /* buffer for recently used data */
|
||||
png_uint_32 push_length; /* size of current input chunk */
|
||||
png_uint_32 skip_length; /* bytes to skip in input data */
|
||||
png_size_t save_buffer_size; /* amount of data now in save_buffer */
|
||||
png_size_t save_buffer_max; /* total size of save_buffer */
|
||||
png_size_t buffer_size; /* total amount of available input data */
|
||||
png_size_t current_buffer_size; /* amount of data now in current_buffer */
|
||||
int process_mode; /* what push library is currently doing */
|
||||
int cur_palette; /* current push library palette index */
|
||||
|
||||
#endif /* PROGRESSIVE_READ */
|
||||
|
||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||
/* For the Borland special 64K segment handler */
|
||||
png_bytepp offset_table_ptr;
|
||||
png_bytep offset_table;
|
||||
png_uint_16 offset_table_number;
|
||||
png_uint_16 offset_table_count;
|
||||
png_uint_16 offset_table_count_free;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
png_bytep palette_lookup; /* lookup table for quantizing */
|
||||
png_bytep quantize_index; /* index translation for palette files */
|
||||
#endif
|
||||
|
||||
/* Options */
|
||||
#ifdef PNG_SET_OPTION_SUPPORTED
|
||||
png_uint_32 options; /* On/off state (up to 16 options) */
|
||||
#endif
|
||||
|
||||
#if PNG_LIBPNG_VER < 10700
|
||||
/* To do: remove this from libpng-1.7 */
|
||||
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||
char time_buffer[29]; /* String to hold RFC 1123 time text */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.0.6 */
|
||||
|
||||
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
|
||||
|
||||
#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
|
||||
#endif
|
||||
|
||||
#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 */
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
png_byte rgb_to_gray_status;
|
||||
/* Added in libpng 1.5.5 to record setting of coefficients: */
|
||||
png_byte rgb_to_gray_coefficients_set;
|
||||
/* These were changed from png_byte in libpng-1.0.6 */
|
||||
png_uint_16 rgb_to_gray_red_coeff;
|
||||
png_uint_16 rgb_to_gray_green_coeff;
|
||||
/* deleted in 1.5.5: rgb_to_gray_blue_coeff; */
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.0.4 (renamed in 1.0.9) */
|
||||
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||
/* Changed from png_byte to png_uint_32 at version 1.2.0 */
|
||||
png_uint_32 mng_features_permitted;
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
png_byte filter_type;
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.2.0 */
|
||||
|
||||
/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_voidp mem_ptr; /* user supplied struct for mem functions */
|
||||
png_malloc_ptr malloc_fn; /* function for allocating memory */
|
||||
png_free_ptr free_fn; /* function for freeing memory */
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.0.13 and 1.2.0 */
|
||||
png_bytep big_row_buf; /* buffer to save current (unfiltered) row */
|
||||
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
/* The following three members were added at version 1.0.14 and 1.2.4 */
|
||||
png_bytep quantize_sort; /* working sort array */
|
||||
png_bytep index_to_palette; /* where the original index currently is
|
||||
in the palette */
|
||||
png_bytep palette_to_index; /* which original index points to this
|
||||
palette color */
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.0.16 and 1.2.6 */
|
||||
png_byte compression_type;
|
||||
|
||||
#ifdef PNG_USER_LIMITS_SUPPORTED
|
||||
png_uint_32 user_width_max;
|
||||
png_uint_32 user_height_max;
|
||||
|
||||
/* Added in libpng-1.4.0: Total number of sPLT, text, and unknown
|
||||
* chunks that can be stored (0 means unlimited).
|
||||
*/
|
||||
png_uint_32 user_chunk_cache_max;
|
||||
|
||||
/* Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk
|
||||
* can occupy when decompressed. 0 means unlimited.
|
||||
*/
|
||||
png_alloc_size_t user_chunk_malloc_max;
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.0.25 and 1.2.17 */
|
||||
#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_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 */
|
||||
png_uint_32 io_state;
|
||||
#endif
|
||||
|
||||
/* 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 */
|
File diff suppressed because it is too large
Load Diff
@ -1,864 +0,0 @@
|
||||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* Last changed in libpng 1.6.33 [September 28, 2017]
|
||||
* Copyright (c) 1998-2002,2004,2006-2017 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.)
|
||||
*
|
||||
* 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"
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
|
||||
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
||||
/* Turn on BGR-to-RGB mapping */
|
||||
void PNGAPI
|
||||
png_set_bgr(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_bgr");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_BGR;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||
/* Turn on 16-bit byte swapping */
|
||||
void PNGAPI
|
||||
png_set_swap(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_swap");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (png_ptr->bit_depth == 16)
|
||||
png_ptr->transformations |= PNG_SWAP_BYTES;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
/* Turn on pixel packing */
|
||||
void PNGAPI
|
||||
png_set_packing(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_packing");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (png_ptr->bit_depth < 8)
|
||||
{
|
||||
png_ptr->transformations |= PNG_PACK;
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
png_ptr->usr_bit_depth = 8;
|
||||
# endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
||||
/* Turn on packed pixel swapping */
|
||||
void PNGAPI
|
||||
png_set_packswap(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_packswap");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (png_ptr->bit_depth < 8)
|
||||
png_ptr->transformations |= PNG_PACKSWAP;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_shift(png_structrp png_ptr, png_const_color_8p true_bits)
|
||||
{
|
||||
png_debug(1, "in png_set_shift");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_SHIFT;
|
||||
png_ptr->shift = *true_bits;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
|
||||
defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||
int PNGAPI
|
||||
png_set_interlace_handling(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_interlace handling");
|
||||
|
||||
if (png_ptr != 0 && png_ptr->interlaced != 0)
|
||||
{
|
||||
png_ptr->transformations |= PNG_INTERLACE;
|
||||
return (7);
|
||||
}
|
||||
|
||||
return (1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||
/* Add a filler byte on read, or remove a filler or alpha byte on write.
|
||||
* The filler type has changed in v0.95 to allow future 2-byte fillers
|
||||
* for 48-bit input data, as well as to avoid problems with some compilers
|
||||
* that don't like bytes as parameters.
|
||||
*/
|
||||
void PNGAPI
|
||||
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;
|
||||
|
||||
if (filler_loc == PNG_FILLER_AFTER)
|
||||
png_ptr->flags |= PNG_FLAG_FILLER_AFTER;
|
||||
|
||||
else
|
||||
png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER;
|
||||
}
|
||||
|
||||
/* Added to libpng-1.2.7 */
|
||||
void PNGAPI
|
||||
png_set_add_alpha(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
{
|
||||
png_debug(1, "in png_set_add_alpha");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_set_filler(png_ptr, filler, filler_loc);
|
||||
/* The above may fail to do anything. */
|
||||
if ((png_ptr->transformations & PNG_FILLER) != 0)
|
||||
png_ptr->transformations |= PNG_ADD_ALPHA;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
|
||||
defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_swap_alpha(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_swap_alpha");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_SWAP_ALPHA;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
|
||||
defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_invert_alpha(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_invert_alpha");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_INVERT_ALPHA;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_invert_mono(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_invert_mono");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_INVERT_MONO;
|
||||
}
|
||||
|
||||
/* Invert monochrome grayscale data */
|
||||
void /* PRIVATE */
|
||||
png_do_invert(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_invert");
|
||||
|
||||
/* This test removed from libpng version 1.0.13 and 1.2.0:
|
||||
* if (row_info->bit_depth == 1 &&
|
||||
*/
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_size_t i;
|
||||
png_size_t istop = row_info->rowbytes;
|
||||
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
*rp = (png_byte)(~(*rp));
|
||||
rp++;
|
||||
}
|
||||
}
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
|
||||
row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_size_t i;
|
||||
png_size_t istop = row_info->rowbytes;
|
||||
|
||||
for (i = 0; i < istop; i += 2)
|
||||
{
|
||||
*rp = (png_byte)(~(*rp));
|
||||
rp += 2;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_16BIT_SUPPORTED
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
|
||||
row_info->bit_depth == 16)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_size_t i;
|
||||
png_size_t istop = row_info->rowbytes;
|
||||
|
||||
for (i = 0; i < istop; i += 4)
|
||||
{
|
||||
*rp = (png_byte)(~(*rp));
|
||||
*(rp + 1) = (png_byte)(~(*(rp + 1)));
|
||||
rp += 4;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_16BIT_SUPPORTED
|
||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||
/* Swaps byte order on 16-bit depth images */
|
||||
void /* PRIVATE */
|
||||
png_do_swap(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_swap");
|
||||
|
||||
if (row_info->bit_depth == 16)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_uint_32 i;
|
||||
png_uint_32 istop= row_info->width * row_info->channels;
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
||||
static PNG_CONST png_byte onebppswaptable[256] = {
|
||||
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0,
|
||||
0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
|
||||
0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8,
|
||||
0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8,
|
||||
0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4,
|
||||
0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4,
|
||||
0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC,
|
||||
0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC,
|
||||
0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2,
|
||||
0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2,
|
||||
0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA,
|
||||
0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA,
|
||||
0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6,
|
||||
0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6,
|
||||
0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE,
|
||||
0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE,
|
||||
0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1,
|
||||
0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1,
|
||||
0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9,
|
||||
0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9,
|
||||
0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5,
|
||||
0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5,
|
||||
0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED,
|
||||
0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD,
|
||||
0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3,
|
||||
0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3,
|
||||
0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB,
|
||||
0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB,
|
||||
0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7,
|
||||
0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7,
|
||||
0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF,
|
||||
0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
|
||||
};
|
||||
|
||||
static PNG_CONST png_byte twobppswaptable[256] = {
|
||||
0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0,
|
||||
0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0,
|
||||
0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4,
|
||||
0x24, 0x64, 0xA4, 0xE4, 0x34, 0x74, 0xB4, 0xF4,
|
||||
0x08, 0x48, 0x88, 0xC8, 0x18, 0x58, 0x98, 0xD8,
|
||||
0x28, 0x68, 0xA8, 0xE8, 0x38, 0x78, 0xB8, 0xF8,
|
||||
0x0C, 0x4C, 0x8C, 0xCC, 0x1C, 0x5C, 0x9C, 0xDC,
|
||||
0x2C, 0x6C, 0xAC, 0xEC, 0x3C, 0x7C, 0xBC, 0xFC,
|
||||
0x01, 0x41, 0x81, 0xC1, 0x11, 0x51, 0x91, 0xD1,
|
||||
0x21, 0x61, 0xA1, 0xE1, 0x31, 0x71, 0xB1, 0xF1,
|
||||
0x05, 0x45, 0x85, 0xC5, 0x15, 0x55, 0x95, 0xD5,
|
||||
0x25, 0x65, 0xA5, 0xE5, 0x35, 0x75, 0xB5, 0xF5,
|
||||
0x09, 0x49, 0x89, 0xC9, 0x19, 0x59, 0x99, 0xD9,
|
||||
0x29, 0x69, 0xA9, 0xE9, 0x39, 0x79, 0xB9, 0xF9,
|
||||
0x0D, 0x4D, 0x8D, 0xCD, 0x1D, 0x5D, 0x9D, 0xDD,
|
||||
0x2D, 0x6D, 0xAD, 0xED, 0x3D, 0x7D, 0xBD, 0xFD,
|
||||
0x02, 0x42, 0x82, 0xC2, 0x12, 0x52, 0x92, 0xD2,
|
||||
0x22, 0x62, 0xA2, 0xE2, 0x32, 0x72, 0xB2, 0xF2,
|
||||
0x06, 0x46, 0x86, 0xC6, 0x16, 0x56, 0x96, 0xD6,
|
||||
0x26, 0x66, 0xA6, 0xE6, 0x36, 0x76, 0xB6, 0xF6,
|
||||
0x0A, 0x4A, 0x8A, 0xCA, 0x1A, 0x5A, 0x9A, 0xDA,
|
||||
0x2A, 0x6A, 0xAA, 0xEA, 0x3A, 0x7A, 0xBA, 0xFA,
|
||||
0x0E, 0x4E, 0x8E, 0xCE, 0x1E, 0x5E, 0x9E, 0xDE,
|
||||
0x2E, 0x6E, 0xAE, 0xEE, 0x3E, 0x7E, 0xBE, 0xFE,
|
||||
0x03, 0x43, 0x83, 0xC3, 0x13, 0x53, 0x93, 0xD3,
|
||||
0x23, 0x63, 0xA3, 0xE3, 0x33, 0x73, 0xB3, 0xF3,
|
||||
0x07, 0x47, 0x87, 0xC7, 0x17, 0x57, 0x97, 0xD7,
|
||||
0x27, 0x67, 0xA7, 0xE7, 0x37, 0x77, 0xB7, 0xF7,
|
||||
0x0B, 0x4B, 0x8B, 0xCB, 0x1B, 0x5B, 0x9B, 0xDB,
|
||||
0x2B, 0x6B, 0xAB, 0xEB, 0x3B, 0x7B, 0xBB, 0xFB,
|
||||
0x0F, 0x4F, 0x8F, 0xCF, 0x1F, 0x5F, 0x9F, 0xDF,
|
||||
0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF
|
||||
};
|
||||
|
||||
static PNG_CONST png_byte fourbppswaptable[256] = {
|
||||
0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
|
||||
0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0,
|
||||
0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71,
|
||||
0x81, 0x91, 0xA1, 0xB1, 0xC1, 0xD1, 0xE1, 0xF1,
|
||||
0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72,
|
||||
0x82, 0x92, 0xA2, 0xB2, 0xC2, 0xD2, 0xE2, 0xF2,
|
||||
0x03, 0x13, 0x23, 0x33, 0x43, 0x53, 0x63, 0x73,
|
||||
0x83, 0x93, 0xA3, 0xB3, 0xC3, 0xD3, 0xE3, 0xF3,
|
||||
0x04, 0x14, 0x24, 0x34, 0x44, 0x54, 0x64, 0x74,
|
||||
0x84, 0x94, 0xA4, 0xB4, 0xC4, 0xD4, 0xE4, 0xF4,
|
||||
0x05, 0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75,
|
||||
0x85, 0x95, 0xA5, 0xB5, 0xC5, 0xD5, 0xE5, 0xF5,
|
||||
0x06, 0x16, 0x26, 0x36, 0x46, 0x56, 0x66, 0x76,
|
||||
0x86, 0x96, 0xA6, 0xB6, 0xC6, 0xD6, 0xE6, 0xF6,
|
||||
0x07, 0x17, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77,
|
||||
0x87, 0x97, 0xA7, 0xB7, 0xC7, 0xD7, 0xE7, 0xF7,
|
||||
0x08, 0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78,
|
||||
0x88, 0x98, 0xA8, 0xB8, 0xC8, 0xD8, 0xE8, 0xF8,
|
||||
0x09, 0x19, 0x29, 0x39, 0x49, 0x59, 0x69, 0x79,
|
||||
0x89, 0x99, 0xA9, 0xB9, 0xC9, 0xD9, 0xE9, 0xF9,
|
||||
0x0A, 0x1A, 0x2A, 0x3A, 0x4A, 0x5A, 0x6A, 0x7A,
|
||||
0x8A, 0x9A, 0xAA, 0xBA, 0xCA, 0xDA, 0xEA, 0xFA,
|
||||
0x0B, 0x1B, 0x2B, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B,
|
||||
0x8B, 0x9B, 0xAB, 0xBB, 0xCB, 0xDB, 0xEB, 0xFB,
|
||||
0x0C, 0x1C, 0x2C, 0x3C, 0x4C, 0x5C, 0x6C, 0x7C,
|
||||
0x8C, 0x9C, 0xAC, 0xBC, 0xCC, 0xDC, 0xEC, 0xFC,
|
||||
0x0D, 0x1D, 0x2D, 0x3D, 0x4D, 0x5D, 0x6D, 0x7D,
|
||||
0x8D, 0x9D, 0xAD, 0xBD, 0xCD, 0xDD, 0xED, 0xFD,
|
||||
0x0E, 0x1E, 0x2E, 0x3E, 0x4E, 0x5E, 0x6E, 0x7E,
|
||||
0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0xDE, 0xEE, 0xFE,
|
||||
0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F,
|
||||
0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF
|
||||
};
|
||||
|
||||
/* Swaps pixel packing order within bytes */
|
||||
void /* PRIVATE */
|
||||
png_do_packswap(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_packswap");
|
||||
|
||||
if (row_info->bit_depth < 8)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_const_bytep end, table;
|
||||
|
||||
end = row + row_info->rowbytes;
|
||||
|
||||
if (row_info->bit_depth == 1)
|
||||
table = onebppswaptable;
|
||||
|
||||
else if (row_info->bit_depth == 2)
|
||||
table = twobppswaptable;
|
||||
|
||||
else if (row_info->bit_depth == 4)
|
||||
table = fourbppswaptable;
|
||||
|
||||
else
|
||||
return;
|
||||
|
||||
for (rp = row; rp < end; rp++)
|
||||
*rp = table[*rp];
|
||||
}
|
||||
}
|
||||
#endif /* PACKSWAP || WRITE_PACKSWAP */
|
||||
|
||||
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
|
||||
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||
/* Remove a channel - this used to be 'png_do_strip_filler' but it used a
|
||||
* somewhat weird combination of flags to determine what to do. All the calls
|
||||
* to png_do_strip_filler are changed in 1.5.2 to call this instead with the
|
||||
* correct arguments.
|
||||
*
|
||||
* The routine isn't general - the channel must be the channel at the start or
|
||||
* end (not in the middle) of each pixel.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
||||
{
|
||||
png_bytep sp = row; /* source pointer */
|
||||
png_bytep dp = row; /* destination pointer */
|
||||
png_bytep ep = row + row_info->rowbytes; /* One beyond end of row */
|
||||
|
||||
/* At the start sp will point to the first byte to copy and dp to where
|
||||
* it is copied to. ep always points just beyond the end of the row, so
|
||||
* the loop simply copies (channels-1) channels until sp reaches ep.
|
||||
*
|
||||
* at_start: 0 -- convert AG, XG, ARGB, XRGB, AAGG, XXGG, etc.
|
||||
* nonzero -- convert GA, GX, RGBA, RGBX, GGAA, RRGGBBXX, etc.
|
||||
*/
|
||||
|
||||
/* GA, GX, XG cases */
|
||||
if (row_info->channels == 2)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
if (at_start != 0) /* Skip initial filler */
|
||||
++sp;
|
||||
else /* Skip initial channel and, for sp, the filler */
|
||||
{
|
||||
sp += 2; ++dp;
|
||||
}
|
||||
|
||||
/* For a 1 pixel wide image there is nothing to do */
|
||||
while (sp < ep)
|
||||
{
|
||||
*dp++ = *sp; sp += 2;
|
||||
}
|
||||
|
||||
row_info->pixel_depth = 8;
|
||||
}
|
||||
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
if (at_start != 0) /* Skip initial filler */
|
||||
sp += 2;
|
||||
else /* Skip initial channel and, for sp, the filler */
|
||||
{
|
||||
sp += 4; dp += 2;
|
||||
}
|
||||
|
||||
while (sp < ep)
|
||||
{
|
||||
*dp++ = *sp++; *dp++ = *sp; sp += 3;
|
||||
}
|
||||
|
||||
row_info->pixel_depth = 16;
|
||||
}
|
||||
|
||||
else
|
||||
return; /* bad bit depth */
|
||||
|
||||
row_info->channels = 1;
|
||||
|
||||
/* Finally fix the color type if it records an alpha channel */
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
row_info->color_type = PNG_COLOR_TYPE_GRAY;
|
||||
}
|
||||
|
||||
/* RGBA, RGBX, XRGB cases */
|
||||
else if (row_info->channels == 4)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
if (at_start != 0) /* Skip initial filler */
|
||||
++sp;
|
||||
else /* Skip initial channels and, for sp, the filler */
|
||||
{
|
||||
sp += 4; dp += 3;
|
||||
}
|
||||
|
||||
/* Note that the loop adds 3 to dp and 4 to sp each time. */
|
||||
while (sp < ep)
|
||||
{
|
||||
*dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp; sp += 2;
|
||||
}
|
||||
|
||||
row_info->pixel_depth = 24;
|
||||
}
|
||||
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
if (at_start != 0) /* Skip initial filler */
|
||||
sp += 2;
|
||||
else /* Skip initial channels and, for sp, the filler */
|
||||
{
|
||||
sp += 8; dp += 6;
|
||||
}
|
||||
|
||||
while (sp < ep)
|
||||
{
|
||||
/* Copy 6 bytes, skip 2 */
|
||||
*dp++ = *sp++; *dp++ = *sp++;
|
||||
*dp++ = *sp++; *dp++ = *sp++;
|
||||
*dp++ = *sp++; *dp++ = *sp; sp += 3;
|
||||
}
|
||||
|
||||
row_info->pixel_depth = 48;
|
||||
}
|
||||
|
||||
else
|
||||
return; /* bad bit depth */
|
||||
|
||||
row_info->channels = 3;
|
||||
|
||||
/* Finally fix the color type if it records an alpha channel */
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
row_info->color_type = PNG_COLOR_TYPE_RGB;
|
||||
}
|
||||
|
||||
else
|
||||
return; /* The filler channel has gone already */
|
||||
|
||||
/* Fix the rowbytes value. */
|
||||
row_info->rowbytes = (png_size_t)(dp-row);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
||||
/* Swaps red and blue bytes within a pixel */
|
||||
void /* PRIVATE */
|
||||
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) != 0)
|
||||
{
|
||||
png_uint_32 row_width = row_info->width;
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0, rp = row; i < row_width; i++, rp += 3)
|
||||
{
|
||||
png_byte save = *rp;
|
||||
*rp = *(rp + 2);
|
||||
*(rp + 2) = save;
|
||||
}
|
||||
}
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0, rp = row; i < row_width; i++, rp += 4)
|
||||
{
|
||||
png_byte save = *rp;
|
||||
*rp = *(rp + 2);
|
||||
*(rp + 2) = save;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_16BIT_SUPPORTED
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0, rp = row; i < row_width; i++, rp += 6)
|
||||
{
|
||||
png_byte save = *rp;
|
||||
*rp = *(rp + 4);
|
||||
*(rp + 4) = save;
|
||||
save = *(rp + 1);
|
||||
*(rp + 1) = *(rp + 5);
|
||||
*(rp + 5) = save;
|
||||
}
|
||||
}
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0, rp = row; i < row_width; i++, rp += 8)
|
||||
{
|
||||
png_byte save = *rp;
|
||||
*rp = *(rp + 4);
|
||||
*(rp + 4) = save;
|
||||
save = *(rp + 1);
|
||||
*(rp + 1) = *(rp + 5);
|
||||
*(rp + 5) = save;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#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_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 */
|
||||
{
|
||||
/* Calculations moved outside switch in an attempt to stop different
|
||||
* compiler warnings. 'padding' is in *bits* within the last byte, it is
|
||||
* an 'int' because pixel_depth becomes an 'int' in the expression below,
|
||||
* and this calculation is used because it avoids warnings that other
|
||||
* forms produced on either GCC or MSVC.
|
||||
*/
|
||||
int padding = PNG_PADBITS(row_info->pixel_depth, row_info->width);
|
||||
png_bytep rp = png_ptr->row_buf + row_info->rowbytes - 1;
|
||||
|
||||
switch (row_info->bit_depth)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
/* in this case, all bytes must be 0 so we don't need
|
||||
* to unpack the pixels except for the rightmost one.
|
||||
*/
|
||||
for (; rp > png_ptr->row_buf; rp--)
|
||||
{
|
||||
if ((*rp >> padding) != 0)
|
||||
png_ptr->num_palette_max = 1;
|
||||
padding = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
for (; rp > png_ptr->row_buf; rp--)
|
||||
{
|
||||
int i = ((*rp >> padding) & 0x03);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
i = (((*rp >> padding) >> 2) & 0x03);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
i = (((*rp >> padding) >> 4) & 0x03);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
i = (((*rp >> padding) >> 6) & 0x03);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
padding = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 4:
|
||||
{
|
||||
for (; rp > png_ptr->row_buf; rp--)
|
||||
{
|
||||
int i = ((*rp >> padding) & 0x0f);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
i = (((*rp >> padding) >> 4) & 0x0f);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
padding = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 8:
|
||||
{
|
||||
for (; rp > png_ptr->row_buf; rp--)
|
||||
{
|
||||
if (*rp > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = (int) *rp;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#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_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;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This function returns a pointer to the user_transform_ptr associated with
|
||||
* the user transform functions. The application should free any memory
|
||||
* associated with this pointer before png_write_destroy and png_read_destroy
|
||||
* are called.
|
||||
*/
|
||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
png_voidp PNGAPI
|
||||
png_get_user_transform_ptr(png_const_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return (NULL);
|
||||
|
||||
return png_ptr->user_transform_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_current_row_number(png_const_structrp png_ptr)
|
||||
{
|
||||
/* See the comments in png.h - this is the sub-image row when reading an
|
||||
* interlaced image.
|
||||
*/
|
||||
if (png_ptr != NULL)
|
||||
return png_ptr->row_number;
|
||||
|
||||
return PNG_UINT_32_MAX; /* help the app not to fail silently */
|
||||
}
|
||||
|
||||
png_byte PNGAPI
|
||||
png_get_current_pass_number(png_const_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
return png_ptr->pass;
|
||||
return 8; /* invalid */
|
||||
}
|
||||
#endif /* USER_TRANSFORM_INFO */
|
||||
#endif /* READ_USER_TRANSFORM || WRITE_USER_TRANSFORM */
|
||||
#endif /* READ || WRITE */
|
@ -1,14 +0,0 @@
|
||||
# pngusr.dfa
|
||||
#
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Enter build configuration options in this file
|
||||
#
|
||||
# Security settings: by default these limits are unset, you can change them
|
||||
# here by entering the appropriate values as #defines preceded by '@' (to cause,
|
||||
# them to be passed through to the build of pnglibconf.h), for example:
|
||||
#
|
||||
# @# define PNG_USER_WIDTH_MAX 65535
|
||||
# @# define PNG_USER_HEIGHT_MAX 65535
|
||||
# @# define PNG_USER_CHUNK_CACHE_MAX 256
|
||||
# @# define PNG_USER_CHUNK_MALLOC_MAX 640000
|
@ -1,168 +0,0 @@
|
||||
|
||||
/* pngwio.c - functions for data output
|
||||
*
|
||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||
* Copyright (c) 1998-2002,2004,2006-2014,2016 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.)
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* This file provides a location for all output. Users who need
|
||||
* special handling are expected to write functions that have the same
|
||||
* arguments as these and perform similar functions, but that possibly
|
||||
* use different output methods. Note that you shouldn't change these
|
||||
* functions, but rather write replacement functions and then change
|
||||
* them at run time with png_set_write_fn(...).
|
||||
*/
|
||||
|
||||
#include "pngpriv.h"
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
|
||||
/* Write the data to whatever output you are using. The default routine
|
||||
* 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.
|
||||
*/
|
||||
|
||||
void /* PRIVATE */
|
||||
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_constcast(png_bytep,data),
|
||||
length);
|
||||
|
||||
else
|
||||
png_error(png_ptr, "Call to NULL write function");
|
||||
}
|
||||
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
/* This is the function that does the actual writing of data. If you are
|
||||
* not writing to a standard C stream, you should create a replacement
|
||||
* write_data function and use it at run time with png_set_write_fn(), rather
|
||||
* than changing the library.
|
||||
*/
|
||||
void PNGCBAPI
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_size_t check;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr));
|
||||
|
||||
if (check != length)
|
||||
png_error(png_ptr, "Write Error");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This function is called to output any data pending writing (normally
|
||||
* to disk). After png_flush is called, there should be no data pending
|
||||
* writing in any buffers.
|
||||
*/
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
png_flush(png_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr->output_flush_fn != NULL)
|
||||
(*(png_ptr->output_flush_fn))(png_ptr);
|
||||
}
|
||||
|
||||
# ifdef PNG_STDIO_SUPPORTED
|
||||
void PNGCBAPI
|
||||
png_default_flush(png_structp png_ptr)
|
||||
{
|
||||
png_FILE_p io_ptr;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
io_ptr = png_voidcast(png_FILE_p, (png_ptr->io_ptr));
|
||||
fflush(io_ptr);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* This function allows the application to supply new output functions for
|
||||
* libpng if standard C streams aren't being used.
|
||||
*
|
||||
* This function takes as its arguments:
|
||||
* png_ptr - pointer to a png output data structure
|
||||
* io_ptr - pointer to user supplied structure containing info about
|
||||
* the output functions. May be NULL.
|
||||
* write_data_fn - pointer to a new output function that takes as its
|
||||
* arguments a pointer to a png_struct, a pointer to
|
||||
* data to be written, and a 32-bit unsigned int that is
|
||||
* the number of bytes to be written. The new write
|
||||
* function should call png_error(png_ptr, "Error msg")
|
||||
* to exit and output any fatal error messages. May be
|
||||
* NULL, in which case libpng's default function will
|
||||
* be used.
|
||||
* flush_data_fn - pointer to a new flush function that takes as its
|
||||
* arguments a pointer to a png_struct. After a call to
|
||||
* the flush function, there should be no data in any buffers
|
||||
* or pending transmission. If the output method doesn't do
|
||||
* any buffering of output, a function prototype must still be
|
||||
* supplied although it doesn't have to do anything. If
|
||||
* PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile
|
||||
* time, output_flush_fn will be ignored, although it must be
|
||||
* supplied for compatibility. May be NULL, in which case
|
||||
* libpng's default function will be used, if
|
||||
* PNG_WRITE_FLUSH_SUPPORTED is defined. This is not
|
||||
* a good idea if io_ptr does not point to a standard
|
||||
* *FILE structure.
|
||||
*/
|
||||
void PNGAPI
|
||||
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)
|
||||
return;
|
||||
|
||||
png_ptr->io_ptr = io_ptr;
|
||||
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
if (write_data_fn != NULL)
|
||||
png_ptr->write_data_fn = write_data_fn;
|
||||
|
||||
else
|
||||
png_ptr->write_data_fn = png_default_write_data;
|
||||
#else
|
||||
png_ptr->write_data_fn = write_data_fn;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
# ifdef PNG_STDIO_SUPPORTED
|
||||
|
||||
if (output_flush_fn != NULL)
|
||||
png_ptr->output_flush_fn = output_flush_fn;
|
||||
|
||||
else
|
||||
png_ptr->output_flush_fn = png_default_flush;
|
||||
|
||||
# else
|
||||
png_ptr->output_flush_fn = output_flush_fn;
|
||||
# endif
|
||||
#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)
|
||||
{
|
||||
png_ptr->read_data_fn = NULL;
|
||||
|
||||
png_warning(png_ptr,
|
||||
"Can't set both read_data_fn and write_data_fn in the"
|
||||
" same structure");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif /* WRITE */
|
File diff suppressed because it is too large
Load Diff
@ -1,576 +0,0 @@
|
||||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* Last changed in libpng 1.6.26 [October 20, 2016]
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 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.)
|
||||
*
|
||||
* 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_WRITE_SUPPORTED
|
||||
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
|
||||
#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).
|
||||
*/
|
||||
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");
|
||||
|
||||
if (row_info->bit_depth == 8 &&
|
||||
row_info->channels == 1)
|
||||
{
|
||||
switch ((int)bit_depth)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
int mask, v;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
sp = row;
|
||||
dp = row;
|
||||
mask = 0x80;
|
||||
v = 0;
|
||||
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if (*sp != 0)
|
||||
v |= mask;
|
||||
|
||||
sp++;
|
||||
|
||||
if (mask > 1)
|
||||
mask >>= 1;
|
||||
|
||||
else
|
||||
{
|
||||
mask = 0x80;
|
||||
*dp = (png_byte)v;
|
||||
dp++;
|
||||
v = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (mask != 0x80)
|
||||
*dp = (png_byte)v;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
unsigned int shift;
|
||||
int v;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
sp = row;
|
||||
dp = row;
|
||||
shift = 6;
|
||||
v = 0;
|
||||
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
png_byte value;
|
||||
|
||||
value = (png_byte)(*sp & 0x03);
|
||||
v |= (value << shift);
|
||||
|
||||
if (shift == 0)
|
||||
{
|
||||
shift = 6;
|
||||
*dp = (png_byte)v;
|
||||
dp++;
|
||||
v = 0;
|
||||
}
|
||||
|
||||
else
|
||||
shift -= 2;
|
||||
|
||||
sp++;
|
||||
}
|
||||
|
||||
if (shift != 6)
|
||||
*dp = (png_byte)v;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 4:
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
unsigned int shift;
|
||||
int v;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
sp = row;
|
||||
dp = row;
|
||||
shift = 4;
|
||||
v = 0;
|
||||
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
png_byte value;
|
||||
|
||||
value = (png_byte)(*sp & 0x0f);
|
||||
v |= (value << shift);
|
||||
|
||||
if (shift == 0)
|
||||
{
|
||||
shift = 4;
|
||||
*dp = (png_byte)v;
|
||||
dp++;
|
||||
v = 0;
|
||||
}
|
||||
|
||||
else
|
||||
shift -= 4;
|
||||
|
||||
sp++;
|
||||
}
|
||||
|
||||
if (shift != 4)
|
||||
*dp = (png_byte)v;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
row_info->bit_depth = (png_byte)bit_depth;
|
||||
row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels);
|
||||
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
|
||||
row_info->width);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SHIFT_SUPPORTED
|
||||
/* Shift pixel values to take advantage of whole range. Pass the
|
||||
* true number of bits in bit_depth. The row should be packed
|
||||
* according to row_info->bit_depth. Thus, if you had a row of
|
||||
* bit depth 4, but the pixels only had values from 0 to 7, you
|
||||
* would pass 3 as bit_depth, and this routine would translate the
|
||||
* data to 0 to 15.
|
||||
*/
|
||||
static void
|
||||
png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
png_const_color_8p bit_depth)
|
||||
{
|
||||
png_debug(1, "in png_do_shift");
|
||||
|
||||
if (row_info->color_type != PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
int shift_start[4], shift_dec[4];
|
||||
unsigned int channels = 0;
|
||||
|
||||
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;
|
||||
channels++;
|
||||
|
||||
shift_start[channels] = row_info->bit_depth - bit_depth->green;
|
||||
shift_dec[channels] = bit_depth->green;
|
||||
channels++;
|
||||
|
||||
shift_start[channels] = row_info->bit_depth - bit_depth->blue;
|
||||
shift_dec[channels] = bit_depth->blue;
|
||||
channels++;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
shift_start[channels] = row_info->bit_depth - bit_depth->gray;
|
||||
shift_dec[channels] = bit_depth->gray;
|
||||
channels++;
|
||||
}
|
||||
|
||||
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;
|
||||
channels++;
|
||||
}
|
||||
|
||||
/* With low row depths, could only be grayscale, so one channel */
|
||||
if (row_info->bit_depth < 8)
|
||||
{
|
||||
png_bytep bp = row;
|
||||
png_size_t i;
|
||||
unsigned int mask;
|
||||
png_size_t row_bytes = row_info->rowbytes;
|
||||
|
||||
if (bit_depth->gray == 1 && row_info->bit_depth == 2)
|
||||
mask = 0x55;
|
||||
|
||||
else if (row_info->bit_depth == 4 && bit_depth->gray == 3)
|
||||
mask = 0x11;
|
||||
|
||||
else
|
||||
mask = 0xff;
|
||||
|
||||
for (i = 0; i < row_bytes; i++, bp++)
|
||||
{
|
||||
int j;
|
||||
unsigned int v, out;
|
||||
|
||||
v = *bp;
|
||||
out = 0;
|
||||
|
||||
for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0])
|
||||
{
|
||||
if (j > 0)
|
||||
out |= v << j;
|
||||
|
||||
else
|
||||
out |= (v >> (-j)) & mask;
|
||||
}
|
||||
|
||||
*bp = (png_byte)(out & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
else if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep bp = row;
|
||||
png_uint_32 i;
|
||||
png_uint_32 istop = channels * row_info->width;
|
||||
|
||||
for (i = 0; i < istop; i++, bp++)
|
||||
{
|
||||
|
||||
const unsigned int c = i%channels;
|
||||
int j;
|
||||
unsigned int v, out;
|
||||
|
||||
v = *bp;
|
||||
out = 0;
|
||||
|
||||
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
||||
{
|
||||
if (j > 0)
|
||||
out |= v << j;
|
||||
|
||||
else
|
||||
out |= v >> (-j);
|
||||
}
|
||||
|
||||
*bp = (png_byte)(out & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_bytep bp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 istop = channels * row_info->width;
|
||||
|
||||
for (bp = row, i = 0; i < istop; i++)
|
||||
{
|
||||
const unsigned int c = i%channels;
|
||||
int j;
|
||||
unsigned int value, v;
|
||||
|
||||
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 |= v << j;
|
||||
|
||||
else
|
||||
value |= v >> (-j);
|
||||
}
|
||||
*bp++ = (png_byte)((value >> 8) & 0xff);
|
||||
*bp++ = (png_byte)(value & 0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
static void
|
||||
png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_write_swap_alpha");
|
||||
|
||||
{
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
/* This converts from ARGB to RGBA */
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||
{
|
||||
png_byte save = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = save;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||
else
|
||||
{
|
||||
/* This converts from AARRGGBB to RRGGBBAA */
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||
{
|
||||
png_byte save[2];
|
||||
save[0] = *(sp++);
|
||||
save[1] = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = save[0];
|
||||
*(dp++) = save[1];
|
||||
}
|
||||
}
|
||||
#endif /* WRITE_16BIT */
|
||||
}
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
/* This converts from AG to GA */
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||
{
|
||||
png_byte save = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = save;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||
else
|
||||
{
|
||||
/* This converts from AAGG to GGAA */
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||
{
|
||||
png_byte save[2];
|
||||
save[0] = *(sp++);
|
||||
save[1] = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = save[0];
|
||||
*(dp++) = save[1];
|
||||
}
|
||||
}
|
||||
#endif /* WRITE_16BIT */
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
static void
|
||||
png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_write_invert_alpha");
|
||||
|
||||
{
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
/* This inverts the alpha channel in RGBA */
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||
{
|
||||
/* Does nothing
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*/
|
||||
sp+=3; dp = sp;
|
||||
*dp = (png_byte)(255 - *(sp++));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||
else
|
||||
{
|
||||
/* This inverts the alpha channel in RRGGBBAA */
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||
{
|
||||
/* Does nothing
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*/
|
||||
sp+=6; dp = sp;
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
*dp = (png_byte)(255 - *(sp++));
|
||||
}
|
||||
}
|
||||
#endif /* WRITE_16BIT */
|
||||
}
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
/* This inverts the alpha channel in GA */
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||
{
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||
else
|
||||
{
|
||||
/* This inverts the alpha channel in GGAA */
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||
{
|
||||
/* Does nothing
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*/
|
||||
sp+=2; dp = sp;
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
*dp = (png_byte)(255 - *(sp++));
|
||||
}
|
||||
}
|
||||
#endif /* WRITE_16BIT */
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Transform the data according to the user's wishes. The order of
|
||||
* transformations is significant.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_do_write_transformations(png_structrp 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) != 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
|
||||
|
||||
#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
|
||||
|
||||
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
|
||||
png_do_packswap(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#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_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
|
||||
|
||||
#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
|
||||
|
||||
#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
|
||||
|
||||
#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
|
||||
|
||||
#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 /* WRITE_TRANSFORMS */
|
||||
#endif /* WRITE */
|
File diff suppressed because it is too large
Load Diff
@ -1,767 +0,0 @@
|
||||
/* filter_vsx_intrinsics.c - PowerPC optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2017 Glenn Randers-Pehrson
|
||||
* Written by Vadim Barkov, 2017.
|
||||
* Last changed in libpng 1.6.29 [March 16, 2017]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include "../pngpriv.h"
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
/* This code requires -maltivec and -mvsx on the command line: */
|
||||
#if PNG_POWERPC_VSX_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
|
||||
|
||||
#include <altivec.h>
|
||||
|
||||
#if PNG_POWERPC_VSX_OPT > 0
|
||||
|
||||
#ifndef __VSX__
|
||||
# error "This code requires VSX support (POWER7 and later). Please provide -mvsx compiler flag."
|
||||
#endif
|
||||
|
||||
#define vec_ld_unaligned(vec,data) vec = vec_vsx_ld(0,data)
|
||||
#define vec_st_unaligned(vec,data) vec_vsx_st(vec,0,data)
|
||||
|
||||
|
||||
/* Functions in this file look at most 3 pixels (a,b,c) to predict the 4th (d).
|
||||
* They're positioned like this:
|
||||
* prev: c b
|
||||
* row: a d
|
||||
* The Sub filter predicts d=a, Avg d=(a+b)/2, and Paeth predicts d to be
|
||||
* whichever of a, b, or c is closest to p=a+b-c.
|
||||
* ( this is taken from ../intel/filter_sse2_intrinsics.c )
|
||||
*/
|
||||
|
||||
#define vsx_declare_common_vars(row_info,row,prev_row,offset) \
|
||||
png_byte i;\
|
||||
png_bytep rp = row + offset;\
|
||||
png_const_bytep pp = prev_row;\
|
||||
png_size_t unaligned_top = 16 - (((png_size_t)rp % 16));\
|
||||
png_size_t istop;\
|
||||
if(unaligned_top == 16)\
|
||||
unaligned_top = 0;\
|
||||
istop = row_info->rowbytes;\
|
||||
if((unaligned_top < istop))\
|
||||
istop -= unaligned_top;\
|
||||
else{\
|
||||
unaligned_top = istop;\
|
||||
istop = 0;\
|
||||
}
|
||||
|
||||
void png_read_filter_row_up_vsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
vector unsigned char rp_vec;
|
||||
vector unsigned char pp_vec;
|
||||
vsx_declare_common_vars(row_info,row,prev_row,0)
|
||||
|
||||
/* Altivec operations require 16-byte aligned data
|
||||
* but input can be unaligned. So we calculate
|
||||
* unaligned part as usual.
|
||||
*/
|
||||
for (i = 0; i < unaligned_top; i++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff);
|
||||
rp++;
|
||||
}
|
||||
|
||||
/* Using SIMD while we can */
|
||||
while( istop >= 16 )
|
||||
{
|
||||
rp_vec = vec_ld(0,rp);
|
||||
vec_ld_unaligned(pp_vec,pp);
|
||||
|
||||
rp_vec = vec_add(rp_vec,pp_vec);
|
||||
|
||||
vec_st(rp_vec,0,rp);
|
||||
|
||||
pp += 16;
|
||||
rp += 16;
|
||||
istop -= 16;
|
||||
}
|
||||
|
||||
if(istop > 0)
|
||||
{
|
||||
/* If byte count of row is not divisible by 16
|
||||
* we will process remaining part as usual
|
||||
*/
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff);
|
||||
rp++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static const vector unsigned char VSX_LEFTSHIFTED1_4 = {16,16,16,16, 0, 1, 2, 3,16,16,16,16,16,16,16,16};
|
||||
static const vector unsigned char VSX_LEFTSHIFTED2_4 = {16,16,16,16,16,16,16,16, 4, 5, 6, 7,16,16,16,16};
|
||||
static const vector unsigned char VSX_LEFTSHIFTED3_4 = {16,16,16,16,16,16,16,16,16,16,16,16, 8, 9,10,11};
|
||||
|
||||
static const vector unsigned char VSX_LEFTSHIFTED1_3 = {16,16,16, 0, 1, 2,16,16,16,16,16,16,16,16,16,16};
|
||||
static const vector unsigned char VSX_LEFTSHIFTED2_3 = {16,16,16,16,16,16, 3, 4, 5,16,16,16,16,16,16,16};
|
||||
static const vector unsigned char VSX_LEFTSHIFTED3_3 = {16,16,16,16,16,16,16,16,16, 6, 7, 8,16,16,16,16};
|
||||
static const vector unsigned char VSX_LEFTSHIFTED4_3 = {16,16,16,16,16,16,16,16,16,16,16,16, 9,10,11,16};
|
||||
|
||||
static const vector unsigned char VSX_NOT_SHIFTED1_4 = {16,16,16,16, 4, 5, 6, 7,16,16,16,16,16,16,16,16};
|
||||
static const vector unsigned char VSX_NOT_SHIFTED2_4 = {16,16,16,16,16,16,16,16, 8, 9,10,11,16,16,16,16};
|
||||
static const vector unsigned char VSX_NOT_SHIFTED3_4 = {16,16,16,16,16,16,16,16,16,16,16,16,12,13,14,15};
|
||||
|
||||
static const vector unsigned char VSX_NOT_SHIFTED1_3 = {16,16,16, 3, 4, 5,16,16,16,16,16,16,16,16,16,16};
|
||||
static const vector unsigned char VSX_NOT_SHIFTED2_3 = {16,16,16,16,16,16, 6, 7, 8,16,16,16,16,16,16,16};
|
||||
static const vector unsigned char VSX_NOT_SHIFTED3_3 = {16,16,16,16,16,16,16,16,16, 9,10,11,16,16,16,16};
|
||||
static const vector unsigned char VSX_NOT_SHIFTED4_3 = {16,16,16,16,16,16,16,16,16,16,16,16,12,13,14,16};
|
||||
|
||||
static const vector unsigned char VSX_CHAR_ZERO = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
#ifdef __LITTLE_ENDIAN__
|
||||
|
||||
static const vector unsigned char VSX_CHAR_TO_SHORT1_4 = { 4,16, 5,16, 6,16, 7,16,16,16,16,16,16,16,16,16};
|
||||
static const vector unsigned char VSX_CHAR_TO_SHORT2_4 = { 8,16, 9,16,10,16,11,16,16,16,16,16,16,16,16,16};
|
||||
static const vector unsigned char VSX_CHAR_TO_SHORT3_4 = {12,16,13,16,14,16,15,16,16,16,16,16,16,16,16,16};
|
||||
|
||||
static const vector unsigned char VSX_SHORT_TO_CHAR1_4 = {16,16,16,16, 0, 2, 4, 6,16,16,16,16,16,16,16,16};
|
||||
static const vector unsigned char VSX_SHORT_TO_CHAR2_4 = {16,16,16,16,16,16,16,16, 0, 2, 4, 6,16,16,16,16};
|
||||
static const vector unsigned char VSX_SHORT_TO_CHAR3_4 = {16,16,16,16,16,16,16,16,16,16,16,16, 0, 2, 4, 6};
|
||||
|
||||
static const vector unsigned char VSX_CHAR_TO_SHORT1_3 = { 3,16, 4,16, 5,16,16,16,16,16,16,16,16,16,16,16};
|
||||
static const vector unsigned char VSX_CHAR_TO_SHORT2_3 = { 6,16, 7,16, 8,16,16,16,16,16,16,16,16,16,16,16};
|
||||
static const vector unsigned char VSX_CHAR_TO_SHORT3_3 = { 9,16,10,16,11,16,16,16,16,16,16,16,16,16,16,16};
|
||||
static const vector unsigned char VSX_CHAR_TO_SHORT4_3 = {12,16,13,16,14,16,16,16,16,16,16,16,16,16,16,16};
|
||||
|
||||
static const vector unsigned char VSX_SHORT_TO_CHAR1_3 = {16,16,16, 0, 2, 4,16,16,16,16,16,16,16,16,16,16};
|
||||
static const vector unsigned char VSX_SHORT_TO_CHAR2_3 = {16,16,16,16,16,16, 0, 2, 4,16,16,16,16,16,16,16};
|
||||
static const vector unsigned char VSX_SHORT_TO_CHAR3_3 = {16,16,16,16,16,16,16,16,16, 0, 2, 4,16,16,16,16};
|
||||
static const vector unsigned char VSX_SHORT_TO_CHAR4_3 = {16,16,16,16,16,16,16,16,16,16,16,16, 0, 2, 4,16};
|
||||
|
||||
#elif defined(__BIG_ENDIAN__)
|
||||
|
||||
static const vector unsigned char VSX_CHAR_TO_SHORT1_4 = {16, 4,16, 5,16, 6,16, 7,16,16,16,16,16,16,16,16};
|
||||
static const vector unsigned char VSX_CHAR_TO_SHORT2_4 = {16, 8,16, 9,16,10,16,11,16,16,16,16,16,16,16,16};
|
||||
static const vector unsigned char VSX_CHAR_TO_SHORT3_4 = {16,12,16,13,16,14,16,15,16,16,16,16,16,16,16,16};
|
||||
|
||||
static const vector unsigned char VSX_SHORT_TO_CHAR1_4 = {16,16,16,16, 1, 3, 5, 7,16,16,16,16,16,16,16,16};
|
||||
static const vector unsigned char VSX_SHORT_TO_CHAR2_4 = {16,16,16,16,16,16,16,16, 1, 3, 5, 7,16,16,16,16};
|
||||
static const vector unsigned char VSX_SHORT_TO_CHAR3_4 = {16,16,16,16,16,16,16,16,16,16,16,16, 1, 3, 5, 7};
|
||||
|
||||
static const vector unsigned char VSX_CHAR_TO_SHORT1_3 = {16, 3,16, 4,16, 5,16,16,16,16,16,16,16,16,16,16};
|
||||
static const vector unsigned char VSX_CHAR_TO_SHORT2_3 = {16, 6,16, 7,16, 8,16,16,16,16,16,16,16,16,16,16};
|
||||
static const vector unsigned char VSX_CHAR_TO_SHORT3_3 = {16, 9,16,10,16,11,16,16,16,16,16,16,16,16,16,16};
|
||||
static const vector unsigned char VSX_CHAR_TO_SHORT4_3 = {16,12,16,13,16,14,16,16,16,16,16,16,16,16,16,16};
|
||||
|
||||
static const vector unsigned char VSX_SHORT_TO_CHAR1_3 = {16,16,16, 1, 3, 5,16,16,16,16,16,16,16,16,16,16};
|
||||
static const vector unsigned char VSX_SHORT_TO_CHAR2_3 = {16,16,16,16,16,16, 1, 3, 5,16,16,16,16,16,16,16};
|
||||
static const vector unsigned char VSX_SHORT_TO_CHAR3_3 = {16,16,16,16,16,16,16,16,16, 1, 3, 5,16,16,16,16};
|
||||
static const vector unsigned char VSX_SHORT_TO_CHAR4_3 = {16,16,16,16,16,16,16,16,16,16,16,16, 1, 3, 5,16};
|
||||
|
||||
#endif
|
||||
|
||||
#define vsx_char_to_short(vec,offset,bpp) (vector unsigned short)vec_perm((vec),VSX_CHAR_ZERO,VSX_CHAR_TO_SHORT##offset##_##bpp)
|
||||
#define vsx_short_to_char(vec,offset,bpp) vec_perm(((vector unsigned char)(vec)),VSX_CHAR_ZERO,VSX_SHORT_TO_CHAR##offset##_##bpp)
|
||||
|
||||
#ifdef PNG_USE_ABS
|
||||
# define vsx_abs(number) abs(number)
|
||||
#else
|
||||
# define vsx_abs(number) (number > 0) ? (number) : -(number)
|
||||
#endif
|
||||
|
||||
void png_read_filter_row_sub4_vsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
const png_byte bpp = 4;
|
||||
|
||||
vector unsigned char rp_vec;
|
||||
vector unsigned char part_vec;
|
||||
|
||||
vsx_declare_common_vars(row_info,row,prev_row,bpp)
|
||||
|
||||
PNG_UNUSED(pp)
|
||||
|
||||
/* Altivec operations require 16-byte aligned data
|
||||
* but input can be unaligned. So we calculate
|
||||
* unaligned part as usual.
|
||||
*/
|
||||
for (i = 0; i < unaligned_top; i++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff);
|
||||
rp++;
|
||||
}
|
||||
|
||||
/* Using SIMD while we can */
|
||||
while( istop >= 16 )
|
||||
{
|
||||
for(i=0;i < bpp ; i++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff);
|
||||
rp++;
|
||||
}
|
||||
rp -= bpp;
|
||||
|
||||
rp_vec = vec_ld(0,rp);
|
||||
part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED1_4);
|
||||
rp_vec = vec_add(rp_vec,part_vec);
|
||||
|
||||
part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED2_4);
|
||||
rp_vec = vec_add(rp_vec,part_vec);
|
||||
|
||||
part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED3_4);
|
||||
rp_vec = vec_add(rp_vec,part_vec);
|
||||
|
||||
vec_st(rp_vec,0,rp);
|
||||
|
||||
rp += 16;
|
||||
istop -= 16;
|
||||
}
|
||||
|
||||
if(istop > 0)
|
||||
for (i = 0; i < istop % 16; i++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) + (int)(*(rp - bpp))) & 0xff);
|
||||
rp++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void png_read_filter_row_sub3_vsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
const png_byte bpp = 3;
|
||||
|
||||
vector unsigned char rp_vec;
|
||||
vector unsigned char part_vec;
|
||||
|
||||
vsx_declare_common_vars(row_info,row,prev_row,bpp)
|
||||
|
||||
PNG_UNUSED(pp)
|
||||
|
||||
/* Altivec operations require 16-byte aligned data
|
||||
* but input can be unaligned. So we calculate
|
||||
* unaligned part as usual.
|
||||
*/
|
||||
for (i = 0; i < unaligned_top; i++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff);
|
||||
rp++;
|
||||
}
|
||||
|
||||
/* Using SIMD while we can */
|
||||
while( istop >= 16 )
|
||||
{
|
||||
for(i=0;i < bpp ; i++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff);
|
||||
rp++;
|
||||
}
|
||||
rp -= bpp;
|
||||
|
||||
rp_vec = vec_ld(0,rp);
|
||||
part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED1_3);
|
||||
rp_vec = vec_add(rp_vec,part_vec);
|
||||
|
||||
part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED2_3);
|
||||
rp_vec = vec_add(rp_vec,part_vec);
|
||||
|
||||
part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED3_3);
|
||||
rp_vec = vec_add(rp_vec,part_vec);
|
||||
|
||||
part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED4_3);
|
||||
rp_vec = vec_add(rp_vec,part_vec);
|
||||
|
||||
vec_st(rp_vec,0,rp);
|
||||
rp += 15;
|
||||
istop -= 16;
|
||||
|
||||
/* Since 16 % bpp = 16 % 3 = 1, last element of array must
|
||||
* be proceeded manually
|
||||
*/
|
||||
*rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff);
|
||||
rp++;
|
||||
}
|
||||
|
||||
if(istop > 0)
|
||||
for (i = 0; i < istop % 16; i++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff);
|
||||
rp++;
|
||||
}
|
||||
}
|
||||
|
||||
void png_read_filter_row_avg4_vsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
const png_byte bpp = 4;
|
||||
|
||||
vector unsigned char rp_vec;
|
||||
vector unsigned char pp_vec;
|
||||
vector unsigned char pp_part_vec;
|
||||
vector unsigned char rp_part_vec;
|
||||
vector unsigned char avg_vec;
|
||||
|
||||
vsx_declare_common_vars(row_info,row,prev_row,bpp)
|
||||
rp -= bpp;
|
||||
if(istop >= bpp)
|
||||
istop -= bpp;
|
||||
|
||||
for (i = 0; i < bpp; i++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) +
|
||||
((int)(*pp++) / 2 )) & 0xff);
|
||||
|
||||
rp++;
|
||||
}
|
||||
|
||||
/* Altivec operations require 16-byte aligned data
|
||||
* but input can be unaligned. So we calculate
|
||||
* unaligned part as usual.
|
||||
*/
|
||||
for (i = 0; i < unaligned_top; i++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) +
|
||||
(int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);
|
||||
|
||||
rp++;
|
||||
}
|
||||
|
||||
/* Using SIMD while we can */
|
||||
while( istop >= 16 )
|
||||
{
|
||||
for(i=0;i < bpp ; i++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) +
|
||||
(int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);
|
||||
|
||||
rp++;
|
||||
}
|
||||
rp -= bpp;
|
||||
pp -= bpp;
|
||||
|
||||
vec_ld_unaligned(pp_vec,pp);
|
||||
rp_vec = vec_ld(0,rp);
|
||||
|
||||
rp_part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED1_4);
|
||||
pp_part_vec = vec_perm(pp_vec,VSX_CHAR_ZERO,VSX_NOT_SHIFTED1_4);
|
||||
avg_vec = vec_avg(rp_part_vec,pp_part_vec);
|
||||
avg_vec = vec_sub(avg_vec, vec_and(vec_xor(rp_part_vec,pp_part_vec),vec_splat_u8(1)));
|
||||
rp_vec = vec_add(rp_vec,avg_vec);
|
||||
|
||||
rp_part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED2_4);
|
||||
pp_part_vec = vec_perm(pp_vec,VSX_CHAR_ZERO,VSX_NOT_SHIFTED2_4);
|
||||
avg_vec = vec_avg(rp_part_vec,pp_part_vec);
|
||||
avg_vec = vec_sub(avg_vec, vec_and(vec_xor(rp_part_vec,pp_part_vec),vec_splat_u8(1)));
|
||||
rp_vec = vec_add(rp_vec,avg_vec);
|
||||
|
||||
rp_part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED3_4);
|
||||
pp_part_vec = vec_perm(pp_vec,VSX_CHAR_ZERO,VSX_NOT_SHIFTED3_4);
|
||||
avg_vec = vec_avg(rp_part_vec,pp_part_vec);
|
||||
avg_vec = vec_sub(avg_vec, vec_and(vec_xor(rp_part_vec,pp_part_vec),vec_splat_u8(1)));
|
||||
rp_vec = vec_add(rp_vec,avg_vec);
|
||||
|
||||
vec_st(rp_vec,0,rp);
|
||||
|
||||
rp += 16;
|
||||
pp += 16;
|
||||
istop -= 16;
|
||||
}
|
||||
|
||||
if(istop > 0)
|
||||
for (i = 0; i < istop % 16; i++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) +
|
||||
(int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);
|
||||
|
||||
rp++;
|
||||
}
|
||||
}
|
||||
|
||||
void png_read_filter_row_avg3_vsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
const png_byte bpp = 3;
|
||||
|
||||
vector unsigned char rp_vec;
|
||||
vector unsigned char pp_vec;
|
||||
vector unsigned char pp_part_vec;
|
||||
vector unsigned char rp_part_vec;
|
||||
vector unsigned char avg_vec;
|
||||
|
||||
vsx_declare_common_vars(row_info,row,prev_row,bpp)
|
||||
rp -= bpp;
|
||||
if(istop >= bpp)
|
||||
istop -= bpp;
|
||||
|
||||
for (i = 0; i < bpp; i++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) +
|
||||
((int)(*pp++) / 2 )) & 0xff);
|
||||
|
||||
rp++;
|
||||
}
|
||||
|
||||
/* Altivec operations require 16-byte aligned data
|
||||
* but input can be unaligned. So we calculate
|
||||
* unaligned part as usual.
|
||||
*/
|
||||
for (i = 0; i < unaligned_top; i++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) +
|
||||
(int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);
|
||||
|
||||
rp++;
|
||||
}
|
||||
|
||||
/* Using SIMD while we can */
|
||||
while( istop >= 16 )
|
||||
{
|
||||
for(i=0;i < bpp ; i++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) +
|
||||
(int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);
|
||||
|
||||
rp++;
|
||||
}
|
||||
rp -= bpp;
|
||||
pp -= bpp;
|
||||
|
||||
vec_ld_unaligned(pp_vec,pp);
|
||||
rp_vec = vec_ld(0,rp);
|
||||
|
||||
rp_part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED1_3);
|
||||
pp_part_vec = vec_perm(pp_vec,VSX_CHAR_ZERO,VSX_NOT_SHIFTED1_3);
|
||||
avg_vec = vec_avg(rp_part_vec,pp_part_vec);
|
||||
avg_vec = vec_sub(avg_vec, vec_and(vec_xor(rp_part_vec,pp_part_vec),vec_splat_u8(1)));
|
||||
rp_vec = vec_add(rp_vec,avg_vec);
|
||||
|
||||
rp_part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED2_3);
|
||||
pp_part_vec = vec_perm(pp_vec,VSX_CHAR_ZERO,VSX_NOT_SHIFTED2_3);
|
||||
avg_vec = vec_avg(rp_part_vec,pp_part_vec);
|
||||
avg_vec = vec_sub(avg_vec, vec_and(vec_xor(rp_part_vec,pp_part_vec),vec_splat_u8(1)));
|
||||
rp_vec = vec_add(rp_vec,avg_vec);
|
||||
|
||||
rp_part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED3_3);
|
||||
pp_part_vec = vec_perm(pp_vec,VSX_CHAR_ZERO,VSX_NOT_SHIFTED3_3);
|
||||
avg_vec = vec_avg(rp_part_vec,pp_part_vec);
|
||||
avg_vec = vec_sub(avg_vec, vec_and(vec_xor(rp_part_vec,pp_part_vec),vec_splat_u8(1)));
|
||||
rp_vec = vec_add(rp_vec,avg_vec);
|
||||
|
||||
rp_part_vec = vec_perm(rp_vec,VSX_CHAR_ZERO,VSX_LEFTSHIFTED4_3);
|
||||
pp_part_vec = vec_perm(pp_vec,VSX_CHAR_ZERO,VSX_NOT_SHIFTED4_3);
|
||||
avg_vec = vec_avg(rp_part_vec,pp_part_vec);
|
||||
avg_vec = vec_sub(avg_vec, vec_and(vec_xor(rp_part_vec,pp_part_vec),vec_splat_u8(1)));
|
||||
rp_vec = vec_add(rp_vec,avg_vec);
|
||||
|
||||
vec_st(rp_vec,0,rp);
|
||||
|
||||
rp += 15;
|
||||
pp += 15;
|
||||
istop -= 16;
|
||||
|
||||
/* Since 16 % bpp = 16 % 3 = 1, last element of array must
|
||||
* be proceeded manually
|
||||
*/
|
||||
*rp = (png_byte)(((int)(*rp) +
|
||||
(int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);
|
||||
rp++;
|
||||
}
|
||||
|
||||
if(istop > 0)
|
||||
for (i = 0; i < istop % 16; i++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) +
|
||||
(int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);
|
||||
|
||||
rp++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Bytewise c ? t : e. */
|
||||
#define if_then_else(c,t,e) vec_sel(e,t,c)
|
||||
|
||||
#define vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp) {\
|
||||
c = *(pp - bpp);\
|
||||
a = *(rp - bpp);\
|
||||
b = *pp++;\
|
||||
p = b - c;\
|
||||
pc = a - c;\
|
||||
pa = vsx_abs(p);\
|
||||
pb = vsx_abs(pc);\
|
||||
pc = vsx_abs(p + pc);\
|
||||
if (pb < pa) pa = pb, a = b;\
|
||||
if (pc < pa) a = c;\
|
||||
a += *rp;\
|
||||
*rp++ = (png_byte)a;\
|
||||
}
|
||||
|
||||
void png_read_filter_row_paeth4_vsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
const png_byte bpp = 4;
|
||||
|
||||
int a, b, c, pa, pb, pc, p;
|
||||
vector unsigned char rp_vec;
|
||||
vector unsigned char pp_vec;
|
||||
vector unsigned short a_vec,b_vec,c_vec,nearest_vec;
|
||||
vector signed short pa_vec,pb_vec,pc_vec,smallest_vec;
|
||||
|
||||
vsx_declare_common_vars(row_info,row,prev_row,bpp)
|
||||
rp -= bpp;
|
||||
if(istop >= bpp)
|
||||
istop -= bpp;
|
||||
|
||||
/* Process the first pixel in the row completely (this is the same as 'up'
|
||||
* because there is only one candidate predictor for the first row).
|
||||
*/
|
||||
for(i = 0; i < bpp ; i++)
|
||||
{
|
||||
*rp = (png_byte)( *rp + *pp);
|
||||
rp++;
|
||||
pp++;
|
||||
}
|
||||
|
||||
for(i = 0; i < unaligned_top ; i++)
|
||||
{
|
||||
vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp)
|
||||
}
|
||||
|
||||
while( istop >= 16)
|
||||
{
|
||||
for(i = 0; i < bpp ; i++)
|
||||
{
|
||||
vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp)
|
||||
}
|
||||
|
||||
rp -= bpp;
|
||||
pp -= bpp;
|
||||
rp_vec = vec_ld(0,rp);
|
||||
vec_ld_unaligned(pp_vec,pp);
|
||||
|
||||
a_vec = vsx_char_to_short(vec_perm(rp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED1_4),1,4);
|
||||
b_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_NOT_SHIFTED1_4),1,4);
|
||||
c_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED1_4),1,4);
|
||||
pa_vec = (vector signed short) vec_sub(b_vec,c_vec);
|
||||
pb_vec = (vector signed short) vec_sub(a_vec , c_vec);
|
||||
pc_vec = vec_add(pa_vec,pb_vec);
|
||||
pa_vec = vec_abs(pa_vec);
|
||||
pb_vec = vec_abs(pb_vec);
|
||||
pc_vec = vec_abs(pc_vec);
|
||||
smallest_vec = vec_min(pc_vec, vec_min(pa_vec,pb_vec));
|
||||
nearest_vec = if_then_else(
|
||||
vec_cmpeq(pa_vec,smallest_vec),
|
||||
a_vec,
|
||||
if_then_else(
|
||||
vec_cmpeq(pb_vec,smallest_vec),
|
||||
b_vec,
|
||||
c_vec
|
||||
)
|
||||
);
|
||||
rp_vec = vec_add(rp_vec,(vsx_short_to_char(nearest_vec,1,4)));
|
||||
|
||||
a_vec = vsx_char_to_short(vec_perm(rp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED2_4),2,4);
|
||||
b_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_NOT_SHIFTED2_4),2,4);
|
||||
c_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED2_4),2,4);
|
||||
pa_vec = (vector signed short) vec_sub(b_vec,c_vec);
|
||||
pb_vec = (vector signed short) vec_sub(a_vec , c_vec);
|
||||
pc_vec = vec_add(pa_vec,pb_vec);
|
||||
pa_vec = vec_abs(pa_vec);
|
||||
pb_vec = vec_abs(pb_vec);
|
||||
pc_vec = vec_abs(pc_vec);
|
||||
smallest_vec = vec_min(pc_vec, vec_min(pa_vec,pb_vec));
|
||||
nearest_vec = if_then_else(
|
||||
vec_cmpeq(pa_vec,smallest_vec),
|
||||
a_vec,
|
||||
if_then_else(
|
||||
vec_cmpeq(pb_vec,smallest_vec),
|
||||
b_vec,
|
||||
c_vec
|
||||
)
|
||||
);
|
||||
rp_vec = vec_add(rp_vec,(vsx_short_to_char(nearest_vec,2,4)));
|
||||
|
||||
a_vec = vsx_char_to_short(vec_perm(rp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED3_4),3,4);
|
||||
b_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_NOT_SHIFTED3_4),3,4);
|
||||
c_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED3_4),3,4);
|
||||
pa_vec = (vector signed short) vec_sub(b_vec,c_vec);
|
||||
pb_vec = (vector signed short) vec_sub(a_vec , c_vec);
|
||||
pc_vec = vec_add(pa_vec,pb_vec);
|
||||
pa_vec = vec_abs(pa_vec);
|
||||
pb_vec = vec_abs(pb_vec);
|
||||
pc_vec = vec_abs(pc_vec);
|
||||
smallest_vec = vec_min(pc_vec, vec_min(pa_vec,pb_vec));
|
||||
nearest_vec = if_then_else(
|
||||
vec_cmpeq(pa_vec,smallest_vec),
|
||||
a_vec,
|
||||
if_then_else(
|
||||
vec_cmpeq(pb_vec,smallest_vec),
|
||||
b_vec,
|
||||
c_vec
|
||||
)
|
||||
);
|
||||
rp_vec = vec_add(rp_vec,(vsx_short_to_char(nearest_vec,3,4)));
|
||||
|
||||
vec_st(rp_vec,0,rp);
|
||||
|
||||
rp += 16;
|
||||
pp += 16;
|
||||
istop -= 16;
|
||||
}
|
||||
|
||||
if(istop > 0)
|
||||
for (i = 0; i < istop % 16; i++)
|
||||
{
|
||||
vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp)
|
||||
}
|
||||
}
|
||||
|
||||
void png_read_filter_row_paeth3_vsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
const png_byte bpp = 3;
|
||||
|
||||
int a, b, c, pa, pb, pc, p;
|
||||
vector unsigned char rp_vec;
|
||||
vector unsigned char pp_vec;
|
||||
vector unsigned short a_vec,b_vec,c_vec,nearest_vec;
|
||||
vector signed short pa_vec,pb_vec,pc_vec,smallest_vec;
|
||||
|
||||
vsx_declare_common_vars(row_info,row,prev_row,bpp)
|
||||
rp -= bpp;
|
||||
if(istop >= bpp)
|
||||
istop -= bpp;
|
||||
|
||||
/* Process the first pixel in the row completely (this is the same as 'up'
|
||||
* because there is only one candidate predictor for the first row).
|
||||
*/
|
||||
for(i = 0; i < bpp ; i++)
|
||||
{
|
||||
*rp = (png_byte)( *rp + *pp);
|
||||
rp++;
|
||||
pp++;
|
||||
}
|
||||
|
||||
for(i = 0; i < unaligned_top ; i++)
|
||||
{
|
||||
vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp)
|
||||
}
|
||||
|
||||
while( istop >= 16)
|
||||
{
|
||||
for(i = 0; i < bpp ; i++)
|
||||
{
|
||||
vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp)
|
||||
}
|
||||
|
||||
rp -= bpp;
|
||||
pp -= bpp;
|
||||
rp_vec = vec_ld(0,rp);
|
||||
vec_ld_unaligned(pp_vec,pp);
|
||||
|
||||
a_vec = vsx_char_to_short(vec_perm(rp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED1_3),1,3);
|
||||
b_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_NOT_SHIFTED1_3),1,3);
|
||||
c_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED1_3),1,3);
|
||||
pa_vec = (vector signed short) vec_sub(b_vec,c_vec);
|
||||
pb_vec = (vector signed short) vec_sub(a_vec , c_vec);
|
||||
pc_vec = vec_add(pa_vec,pb_vec);
|
||||
pa_vec = vec_abs(pa_vec);
|
||||
pb_vec = vec_abs(pb_vec);
|
||||
pc_vec = vec_abs(pc_vec);
|
||||
smallest_vec = vec_min(pc_vec, vec_min(pa_vec,pb_vec));
|
||||
nearest_vec = if_then_else(
|
||||
vec_cmpeq(pa_vec,smallest_vec),
|
||||
a_vec,
|
||||
if_then_else(
|
||||
vec_cmpeq(pb_vec,smallest_vec),
|
||||
b_vec,
|
||||
c_vec
|
||||
)
|
||||
);
|
||||
rp_vec = vec_add(rp_vec,(vsx_short_to_char(nearest_vec,1,3)));
|
||||
|
||||
a_vec = vsx_char_to_short(vec_perm(rp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED2_3),2,3);
|
||||
b_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_NOT_SHIFTED2_3),2,3);
|
||||
c_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED2_3),2,3);
|
||||
pa_vec = (vector signed short) vec_sub(b_vec,c_vec);
|
||||
pb_vec = (vector signed short) vec_sub(a_vec , c_vec);
|
||||
pc_vec = vec_add(pa_vec,pb_vec);
|
||||
pa_vec = vec_abs(pa_vec);
|
||||
pb_vec = vec_abs(pb_vec);
|
||||
pc_vec = vec_abs(pc_vec);
|
||||
smallest_vec = vec_min(pc_vec, vec_min(pa_vec,pb_vec));
|
||||
nearest_vec = if_then_else(
|
||||
vec_cmpeq(pa_vec,smallest_vec),
|
||||
a_vec,
|
||||
if_then_else(
|
||||
vec_cmpeq(pb_vec,smallest_vec),
|
||||
b_vec,
|
||||
c_vec
|
||||
)
|
||||
);
|
||||
rp_vec = vec_add(rp_vec,(vsx_short_to_char(nearest_vec,2,3)));
|
||||
|
||||
a_vec = vsx_char_to_short(vec_perm(rp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED3_3),3,3);
|
||||
b_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_NOT_SHIFTED3_3),3,3);
|
||||
c_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED3_3),3,3);
|
||||
pa_vec = (vector signed short) vec_sub(b_vec,c_vec);
|
||||
pb_vec = (vector signed short) vec_sub(a_vec , c_vec);
|
||||
pc_vec = vec_add(pa_vec,pb_vec);
|
||||
pa_vec = vec_abs(pa_vec);
|
||||
pb_vec = vec_abs(pb_vec);
|
||||
pc_vec = vec_abs(pc_vec);
|
||||
smallest_vec = vec_min(pc_vec, vec_min(pa_vec,pb_vec));
|
||||
nearest_vec = if_then_else(
|
||||
vec_cmpeq(pa_vec,smallest_vec),
|
||||
a_vec,
|
||||
if_then_else(
|
||||
vec_cmpeq(pb_vec,smallest_vec),
|
||||
b_vec,
|
||||
c_vec
|
||||
)
|
||||
);
|
||||
rp_vec = vec_add(rp_vec,(vsx_short_to_char(nearest_vec,3,3)));
|
||||
|
||||
a_vec = vsx_char_to_short(vec_perm(rp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED4_3),4,3);
|
||||
b_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_NOT_SHIFTED4_3),4,3);
|
||||
c_vec = vsx_char_to_short(vec_perm(pp_vec , VSX_CHAR_ZERO , VSX_LEFTSHIFTED4_3),4,3);
|
||||
pa_vec = (vector signed short) vec_sub(b_vec,c_vec);
|
||||
pb_vec = (vector signed short) vec_sub(a_vec , c_vec);
|
||||
pc_vec = vec_add(pa_vec,pb_vec);
|
||||
pa_vec = vec_abs(pa_vec);
|
||||
pb_vec = vec_abs(pb_vec);
|
||||
pc_vec = vec_abs(pc_vec);
|
||||
smallest_vec = vec_min(pc_vec, vec_min(pa_vec,pb_vec));
|
||||
nearest_vec = if_then_else(
|
||||
vec_cmpeq(pa_vec,smallest_vec),
|
||||
a_vec,
|
||||
if_then_else(
|
||||
vec_cmpeq(pb_vec,smallest_vec),
|
||||
b_vec,
|
||||
c_vec
|
||||
)
|
||||
);
|
||||
rp_vec = vec_add(rp_vec,(vsx_short_to_char(nearest_vec,4,3)));
|
||||
|
||||
vec_st(rp_vec,0,rp);
|
||||
|
||||
rp += 15;
|
||||
pp += 15;
|
||||
istop -= 16;
|
||||
|
||||
/* Since 16 % bpp = 16 % 3 = 1, last element of array must
|
||||
* be proceeded manually
|
||||
*/
|
||||
vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp)
|
||||
}
|
||||
|
||||
if(istop > 0)
|
||||
for (i = 0; i < istop % 16; i++)
|
||||
{
|
||||
vsx_paeth_process(rp,pp,a,b,c,pa,pb,pc,bpp)
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* PNG_POWERPC_VSX_OPT > 0 */
|
||||
#endif /* PNG_POWERPC_VSX_IMPLEMENTATION == 1 (intrinsics) */
|
||||
#endif /* READ */
|
@ -1,125 +0,0 @@
|
||||
|
||||
/* powerpc_init.c - POWERPC optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2017 Glenn Randers-Pehrson
|
||||
* Written by Vadim Barkov, 2017.
|
||||
* Last changed in libpng 1.6.29 [March 16, 2017]
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
#include "../pngpriv.h"
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
#if PNG_POWERPC_VSX_OPT > 0
|
||||
#ifdef PNG_POWERPC_VSX_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 PowerPC
|
||||
* VSX 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_POWERPC_VSX_FILE to the file name of file containing
|
||||
* a fragment of C source code which defines the png_have_vsx function. There
|
||||
* are a number of implementations in contrib/powerpc-vsx, but the only one that
|
||||
* has partial support is contrib/powerpc-vsx/linux.c - a generic Linux
|
||||
* implementation which reads /proc/cpufino.
|
||||
*/
|
||||
#ifndef PNG_POWERPC_VSX_FILE
|
||||
# ifdef __linux__
|
||||
# define PNG_POWERPC_VSX_FILE "contrib/powerpc-vsx/linux_aux.c"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_POWERPC_VSX_FILE
|
||||
|
||||
#include <signal.h> /* for sig_atomic_t */
|
||||
static int png_have_vsx(png_structp png_ptr);
|
||||
#include PNG_POWERPC_VSX_FILE
|
||||
|
||||
#else /* PNG_POWERPC_VSX_FILE */
|
||||
# error "PNG_POWERPC_VSX_FILE undefined: no support for run-time POWERPC VSX checks"
|
||||
#endif /* PNG_POWERPC_VSX_FILE */
|
||||
#endif /* PNG_POWERPC_VSX_CHECK_SUPPORTED */
|
||||
|
||||
void
|
||||
png_init_filter_functions_vsx(png_structp pp, unsigned int bpp)
|
||||
{
|
||||
/* The switch statement is compiled in for POWERPC_VSX_API, the call to
|
||||
* png_have_vsx is compiled in for POWERPC_VSX_CHECK. If both are defined
|
||||
* the check is only performed if the API has not set the PowerPC option on
|
||||
* or off explicitly. In this case the check controls what happens.
|
||||
*/
|
||||
|
||||
#ifdef PNG_POWERPC_VSX_API_SUPPORTED
|
||||
switch ((pp->options >> PNG_POWERPC_VSX) & 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_POWERPC_VSX_API_SUPPORTED */
|
||||
#ifdef PNG_POWERPC_VSX_CHECK_SUPPORTED
|
||||
{
|
||||
static volatile sig_atomic_t no_vsx = -1; /* not checked */
|
||||
|
||||
if (no_vsx < 0)
|
||||
no_vsx = !png_have_vsx(pp);
|
||||
|
||||
if (no_vsx)
|
||||
return;
|
||||
}
|
||||
#ifdef PNG_POWERPC_VSX_API_SUPPORTED
|
||||
break;
|
||||
#endif
|
||||
#endif /* PNG_POWERPC_VSX_CHECK_SUPPORTED */
|
||||
|
||||
#ifdef PNG_POWERPC_VSX_API_SUPPORTED
|
||||
default: /* OFF or INVALID */
|
||||
return;
|
||||
|
||||
case PNG_OPTION_ON:
|
||||
/* Option turned on */
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* IMPORTANT: any new internal 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_vsx;
|
||||
|
||||
if (bpp == 3)
|
||||
{
|
||||
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_vsx;
|
||||
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_vsx;
|
||||
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth3_vsx;
|
||||
}
|
||||
|
||||
else if (bpp == 4)
|
||||
{
|
||||
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_vsx;
|
||||
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_vsx;
|
||||
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth4_vsx;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_POWERPC_VSX_OPT > 0 */
|
||||
#endif /* READ */
|
@ -1,173 +0,0 @@
|
||||
#!/bin/awk -f
|
||||
# Check a list of symbols against the master definition
|
||||
# (official) list. Arguments:
|
||||
#
|
||||
# awk -f checksym.awk official-def list-to-check
|
||||
#
|
||||
# Output is a file in the current directory called 'symbols.new',
|
||||
# the value of the awk variable "of" (which can be changed on the
|
||||
# command line if required.) stdout holds error messages. Error
|
||||
# code indicates success or failure.
|
||||
#
|
||||
# NOTE: this is a pure, old fashioned, awk script. It will
|
||||
# work with any awk
|
||||
|
||||
BEGIN{
|
||||
err=0
|
||||
master="" # master file
|
||||
official[1] = "" # defined symbols from master file
|
||||
symbol[1] = "" # defined symbols from png.h
|
||||
removed[1] = "" # removed symbols from png.h
|
||||
lasto = 0 # last ordinal value from png.h
|
||||
mastero = 0 # highest ordinal in master file
|
||||
symbolo = 0 # highest ordinal in png.h
|
||||
missing = "error"# log an error on missing symbols
|
||||
of="symbols.new" # default to a fixed name
|
||||
}
|
||||
|
||||
# Read existing definitions from the master file (the first
|
||||
# file on the command line.) This must be a def file and it
|
||||
# has definition lines (others are ignored) of the form:
|
||||
#
|
||||
# symbol @ordinal
|
||||
#
|
||||
master == "" {
|
||||
master = FILENAME
|
||||
}
|
||||
FILENAME==master && NF==2 && $2~/^@/ && $1!~/^;/ {
|
||||
o=0+substr($2,2)
|
||||
if (o > 0) {
|
||||
if (official[o] == "") {
|
||||
official[o] = $1
|
||||
if (o > mastero) mastero = o
|
||||
next
|
||||
} else
|
||||
print master ": duplicated symbol:", official[o] ":", $0
|
||||
} else
|
||||
print master ": bad export line format:", $0
|
||||
err = 1
|
||||
}
|
||||
FILENAME==master && $1==";missing" && NF==2{
|
||||
# This allows the master file to control how missing symbols
|
||||
# are handled; symbols that aren't in either the master or
|
||||
# the new file. Valid values are 'ignore', 'warning' and
|
||||
# 'error'
|
||||
missing = $2
|
||||
}
|
||||
FILENAME==master {
|
||||
next
|
||||
}
|
||||
|
||||
# Read new definitions, these are free form but the lines must
|
||||
# just be symbol definitions. Lines will be commented out for
|
||||
# 'removed' symbols, introduced in png.h using PNG_REMOVED rather
|
||||
# than PNG_EXPORT. Use symbols.dfn or pngwin.dfn to generate the
|
||||
# input file.
|
||||
#
|
||||
# symbol @ordinal # two fields, exported symbol
|
||||
# ; symbol @ordinal # three fields, removed symbol
|
||||
# ; @ordinal # two fields, the last ordinal
|
||||
NF==2 && $1 == ";" && $2 ~ /^@[1-9][0-9]*$/ { # last ordinal
|
||||
o=0+substr($2,2)
|
||||
if (lasto == 0 || lasto == o)
|
||||
lasto=o
|
||||
else {
|
||||
print "png.h: duplicated last ordinal:", lasto, o
|
||||
err = 1
|
||||
}
|
||||
next
|
||||
}
|
||||
NF==3 && $1 == ";" && $3 ~ /^@[1-9][0-9]*$/ { # removed symbol
|
||||
o=0+substr($3,2)
|
||||
if (removed[o] == "" || removed[o] == $2) {
|
||||
removed[o] = $2
|
||||
if (o > symbolo) symbolo = o
|
||||
} else {
|
||||
print "png.h: duplicated removed symbol", o ": '" removed[o] "' != '" $2 "'"
|
||||
err = 1
|
||||
}
|
||||
next
|
||||
}
|
||||
NF==2 && $2 ~ /^@[1-9][0-9]*$/ { # exported symbol
|
||||
o=0+substr($2,2)
|
||||
if (symbol[o] == "" || symbol[o] == $1) {
|
||||
symbol[o] = $1
|
||||
if (o > symbolo) symbolo = o
|
||||
} else {
|
||||
print "png.h: duplicated symbol", o ": '" symbol[o] "' != '" $1 "'"
|
||||
err = 1
|
||||
}
|
||||
}
|
||||
{
|
||||
next # skip all other lines
|
||||
}
|
||||
|
||||
# At the end check for symbols marked as both duplicated and removed
|
||||
END{
|
||||
if (symbolo > lasto) {
|
||||
print "highest symbol ordinal in png.h,", symbolo ", exceeds last ordinal from png.h", lasto
|
||||
err = 1
|
||||
}
|
||||
if (mastero > lasto) {
|
||||
print "highest symbol ordinal in", master ",", mastero ", exceeds last ordinal from png.h", lasto
|
||||
err = 1
|
||||
}
|
||||
unexported=0
|
||||
# Add a standard header to symbols.new:
|
||||
print ";Version INSERT-VERSION-HERE" >of
|
||||
print ";--------------------------------------------------------------" >of
|
||||
print "; LIBPNG symbol list as a Win32 DEF file" >of
|
||||
print "; Contains all the symbols that can be exported from libpng" >of
|
||||
print ";--------------------------------------------------------------" >of
|
||||
print "LIBRARY" >of
|
||||
print "" >of
|
||||
print "EXPORTS" >of
|
||||
|
||||
for (o=1; o<=lasto; ++o) {
|
||||
if (symbol[o] == "" && removed[o] == "") {
|
||||
if (unexported == 0) unexported = o
|
||||
if (official[o] == "") {
|
||||
# missing in export list too, so ok
|
||||
if (o < lasto) continue
|
||||
}
|
||||
}
|
||||
if (unexported != 0) {
|
||||
# Symbols in the .def but not in the new file are errors, but
|
||||
# the 'unexported' symbols aren't in either. By default this
|
||||
# is an error too (see the setting of 'missing' at the start),
|
||||
# but this can be reset on the command line or by stuff in the
|
||||
# file - see the comments above.
|
||||
if (missing != "ignore") {
|
||||
if (o-1 > unexported)
|
||||
print "png.h:", missing ": missing symbols:", unexported "-" o-1
|
||||
else
|
||||
print "png.h:", missing ": missing symbol:", unexported
|
||||
if (missing != "warning")
|
||||
err = 1
|
||||
}
|
||||
unexported = 0
|
||||
}
|
||||
if (symbol[o] != "" && removed[o] != "") {
|
||||
print "png.h: symbol", o, "both exported as '" symbol[o] "' and removed as '" removed[o] "'"
|
||||
err = 1
|
||||
} else if (symbol[o] != official[o]) {
|
||||
# either the symbol is missing somewhere or it changed
|
||||
err = 1
|
||||
if (symbol[o] == "")
|
||||
print "png.h: symbol", o, "is exported as '" official[o] "' in", master
|
||||
else if (official[o] == "")
|
||||
print "png.h: exported symbol", o, "'" symbol[o] "' not present in", master
|
||||
else
|
||||
print "png.h: exported symbol", o, "'" symbol[o] "' exists as '" official[o] "' in", master
|
||||
}
|
||||
|
||||
# Finally generate symbols.new
|
||||
if (symbol[o] != "")
|
||||
print " " symbol[o], "@" o > of
|
||||
}
|
||||
|
||||
if (err != 0) {
|
||||
print "*** A new list is in", of, "***"
|
||||
exit 1
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
/* def.c - define format of libpng.def
|
||||
*
|
||||
* Last changed in libpng version 1.6.16 [December 22, 2014]
|
||||
* Copyright (c) 2011-2014 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
|
||||
*/
|
||||
|
||||
/* Write the export file header: */
|
||||
PNG_DFN ";--------------------------------------------------------------"
|
||||
PNG_DFN "; LIBPNG module definition file for OS/2"
|
||||
PNG_DFN ";--------------------------------------------------------------"
|
||||
PNG_DFN ""
|
||||
PNG_DFN "; If you give the library an explicit name one or other files"
|
||||
PNG_DFN "; may need modifying to support the new name on one or more"
|
||||
PNG_DFN "; systems."
|
||||
PNG_DFN "LIBRARY"
|
||||
PNG_DFN "OS2 DESCRIPTION "PNG image compression library""
|
||||
PNG_DFN "OS2 CODE PRELOAD MOVEABLE DISCARDABLE"
|
||||
PNG_DFN ""
|
||||
PNG_DFN "EXPORTS"
|
||||
PNG_DFN ";Version 1.6.35beta02"
|
||||
|
||||
#define PNG_EXPORTA(ordinal, type, name, args, attributes)\
|
||||
PNG_DFN "@" SYMBOL_PREFIX "@@" name "@"
|
||||
|
||||
#include "../png.h"
|
@ -1,203 +0,0 @@
|
||||
#!/bin/awk -f
|
||||
# scripts/dfn.awk - process a .dfn file
|
||||
#
|
||||
# last changed in libpng version 1.5.19 - August 21, 2014
|
||||
#
|
||||
# Copyright (c) 2013-2014 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
|
||||
|
||||
# The output of this script is written to the file given by
|
||||
# the variable 'out', which should be set on the command line.
|
||||
# Error messages are printed to stdout and if any are printed
|
||||
# the script will exit with error code 1.
|
||||
|
||||
BEGIN{
|
||||
out="/dev/null" # as a flag
|
||||
out_count=0 # count of output lines
|
||||
err=0 # set if an error occurred
|
||||
sort=0 # sort the output
|
||||
array[""]=""
|
||||
}
|
||||
|
||||
# The output file must be specified before any input:
|
||||
NR==1 && out == "/dev/null" {
|
||||
print "out=output.file must be given on the command line"
|
||||
# but continue without setting the error code; this allows the
|
||||
# script to be checked easily
|
||||
}
|
||||
|
||||
# Output can be sorted; two lines are recognized
|
||||
$1 == "PNG_DFN_START_SORT"{
|
||||
sort=0+$2
|
||||
next
|
||||
}
|
||||
|
||||
$1 ~ /^PNG_DFN_END_SORT/{
|
||||
# Do a very simple, slow, sort; notice that blank lines won't be
|
||||
# output by this
|
||||
for (entry in array) {
|
||||
while (array[entry] != "") {
|
||||
key = entry
|
||||
value = array[key]
|
||||
array[key] = ""
|
||||
|
||||
for (alt in array) {
|
||||
if (array[alt] != "" && alt < key) {
|
||||
array[key] = value
|
||||
value = array[alt]
|
||||
key = alt
|
||||
array[alt] = ""
|
||||
}
|
||||
}
|
||||
|
||||
print value >out
|
||||
}
|
||||
}
|
||||
sort=0
|
||||
next
|
||||
}
|
||||
|
||||
/^[^"]*PNG_DFN *".*"[^"]*$/{
|
||||
# A definition line, apparently correctly formatted; extract the
|
||||
# definition then replace any doubled "" that remain with a single
|
||||
# double quote. Notice that the original doubled double quotes
|
||||
# may have been split by tokenization
|
||||
#
|
||||
# Sometimes GCC splits the PNG_DFN lines; we know this has happened
|
||||
# if the quotes aren't closed and must read another line. In this
|
||||
# case it is essential to reject lines that start with '#' because those
|
||||
# are introduced #line directives.
|
||||
orig=$0
|
||||
line=$0
|
||||
lineno=FNR
|
||||
if (lineno == "") lineno=NR
|
||||
|
||||
if (sub(/^[^"]*PNG_DFN *"/,"",line) != 1) {
|
||||
print "line", lineno ": processing failed:"
|
||||
print orig
|
||||
err=1
|
||||
next
|
||||
} else {
|
||||
++out_count
|
||||
}
|
||||
|
||||
# Now examine quotes within the value:
|
||||
#
|
||||
# @" - delete this and any following spaces
|
||||
# "@ - delete this and any preceding spaces
|
||||
# @' - replace this by a double quote
|
||||
#
|
||||
# This allows macro substitution by the C compiler thus:
|
||||
#
|
||||
# #define first_name John
|
||||
# #define last_name Smith
|
||||
#
|
||||
# PNG_DFN"#define name @'@" first_name "@ @" last_name "@@'"
|
||||
#
|
||||
# Might get C preprocessed to:
|
||||
#
|
||||
# PNG_DFN "#define foo @'@" John "@ @" Smith "@@'"
|
||||
#
|
||||
# Which this script reduces to:
|
||||
#
|
||||
# #define name "John Smith"
|
||||
#
|
||||
while (1) {
|
||||
# While there is an @" remove it and the next "@
|
||||
if (line ~ /@"/) {
|
||||
if (line ~ /@".*"@/) {
|
||||
# Do this special case first to avoid swallowing extra spaces
|
||||
# before or after the @ stuff:
|
||||
if (!sub(/@" *"@/, "", line)) {
|
||||
# Ok, do it in pieces - there has to be a non-space between the
|
||||
# two. NOTE: really weird things happen if a leading @" is
|
||||
# lost - the code will error out below (I believe).
|
||||
if (!sub(/@" */, "", line) || !sub(/ *"@/, "", line)) {
|
||||
print "line", lineno, ": internal error:", orig
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# There is no matching "@. Assume a split line
|
||||
else while (1) {
|
||||
if (getline nextline) {
|
||||
# If the line starts with '#' it is a preprocesor line directive
|
||||
# from cc -E; skip it:
|
||||
if (nextline !~ /^#/) {
|
||||
line = line " " nextline
|
||||
break
|
||||
}
|
||||
} else {
|
||||
# This is end-of-input - probably a missing "@ on the first line:
|
||||
print "line", lineno ": unbalanced @\" ... \"@ pair"
|
||||
err=1
|
||||
next
|
||||
}
|
||||
}
|
||||
|
||||
# Keep going until all the @" have gone
|
||||
continue
|
||||
}
|
||||
|
||||
# Attempt to remove a trailing " (not preceded by '@') - if this can
|
||||
# be done, stop now; if not assume a split line again
|
||||
if (sub(/"[^"]*$/, "", line))
|
||||
break
|
||||
|
||||
# Read another line
|
||||
while (1) {
|
||||
if (getline nextline) {
|
||||
if (nextline !~ /^#/) {
|
||||
line = line " " nextline
|
||||
# Go back to stripping @" "@ pairs
|
||||
break
|
||||
}
|
||||
} else {
|
||||
print "line", lineno ": unterminated PNG_DFN string"
|
||||
err=1
|
||||
next
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Put any needed double quotes in (at the end, because these would otherwise
|
||||
# interfere with the processing above.)
|
||||
gsub(/@'/,"\"", line)
|
||||
|
||||
# Remove any trailing spaces (not really required, but for
|
||||
# editorial consistency
|
||||
sub(/ *$/, "", line)
|
||||
|
||||
# Remove trailing CR
|
||||
sub(/
$/, "", line)
|
||||
|
||||
if (sort) {
|
||||
if (split(line, parts) < sort) {
|
||||
print "line", lineno ": missing sort field:", line
|
||||
err=1
|
||||
} else
|
||||
array[parts[sort]] = line
|
||||
}
|
||||
|
||||
else
|
||||
print line >out
|
||||
next
|
||||
}
|
||||
|
||||
/PNG_DFN/{
|
||||
print "line", NR, "incorrectly formatted PNG_DFN line:"
|
||||
print $0
|
||||
err = 1
|
||||
}
|
||||
|
||||
END{
|
||||
if (out_count > 0 || err > 0)
|
||||
exit err
|
||||
|
||||
print "no definition lines found"
|
||||
exit 1
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
# genchk.cmake.in
|
||||
# Generate .chk from .out with awk (generic), based upon the automake logic.
|
||||
|
||||
# Copyright (C) 2016 Glenn Randers-Pehrson
|
||||
# Written by Roger Leigh, 2016
|
||||
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
|
||||
# Variables substituted from CMakeLists.txt
|
||||
set(SRCDIR "@CMAKE_CURRENT_SOURCE_DIR@")
|
||||
|
||||
set(AWK "@AWK@")
|
||||
|
||||
get_filename_component(INPUTEXT "${INPUT}" EXT)
|
||||
get_filename_component(OUTPUTEXT "${OUTPUT}" EXT)
|
||||
get_filename_component(INPUTBASE "${INPUT}" NAME_WE)
|
||||
get_filename_component(OUTPUTBASE "${OUTPUT}" NAME_WE)
|
||||
get_filename_component(INPUTDIR "${INPUT}" PATH)
|
||||
get_filename_component(OUTPUTDIR "${OUTPUT}" PATH)
|
||||
|
||||
if("${INPUTEXT}" STREQUAL ".out" AND "${OUTPUTEXT}" STREQUAL ".chk")
|
||||
# Generate .chk from .out with awk (generic)
|
||||
file(REMOVE "${OUTPUT}" "${OUTPUTDIR}/${OUTPUTBASE}.new")
|
||||
execute_process(COMMAND "${AWK}" -f "${SRCDIR}/scripts/checksym.awk"
|
||||
"${SRCDIR}/scripts/${INPUTBASE}.def"
|
||||
"of=${OUTPUTDIR}/${OUTPUTBASE}.new"
|
||||
"${INPUT}"
|
||||
RESULT_VARIABLE AWK_FAIL)
|
||||
if(AWK_FAIL)
|
||||
message(FATAL_ERROR "Failed to generate ${OUTPUTDIR}/${OUTPUTBASE}.new")
|
||||
endif()
|
||||
file(RENAME "${OUTPUTDIR}/${OUTPUTBASE}.new" "${OUTPUT}")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported conversion: ${INPUTEXT} to ${OUTPUTEXT}")
|
||||
endif()
|
@ -1,93 +0,0 @@
|
||||
# genout.cmake.in
|
||||
# Generate .out from .c with awk (generic), based upon the automake logic.
|
||||
|
||||
# Copyright (C) 2016 Glenn Randers-Pehrson
|
||||
# Written by Roger Leigh, 2016
|
||||
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
|
||||
# Variables substituted from CMakeLists.txt
|
||||
set(SRCDIR "@CMAKE_CURRENT_SOURCE_DIR@")
|
||||
set(BINDIR "@CMAKE_CURRENT_BINARY_DIR@")
|
||||
|
||||
set(AWK "@AWK@")
|
||||
set(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@")
|
||||
set(CMAKE_C_FLAGS @CMAKE_C_FLAGS@)
|
||||
set(INCDIR "@CMAKE_CURRENT_BINARY_DIR@")
|
||||
set(PNG_PREFIX "@PNG_PREFIX@")
|
||||
set(PNGLIB_MAJOR "@PNGLIB_MAJOR@")
|
||||
set(PNGLIB_MINOR "@PNGLIB_MINOR@")
|
||||
set(PNGLIB_VERSION "@PNGLIB_VERSION@")
|
||||
set(ZLIBINCDIR "@ZLIB_INCLUDE_DIR@")
|
||||
|
||||
set(PLATFORM_C_FLAGS)
|
||||
if(APPLE)
|
||||
set(CMAKE_OSX_ARCHITECTURES "@CMAKE_OSX_ARCHITECTURES@")
|
||||
set(CMAKE_OSX_SYSROOT "@CMAKE_OSX_SYSROOT@")
|
||||
if(CMAKE_OSX_ARCHITECTURES)
|
||||
set(PLATFORM_C_FLAGS ${PLATFORM_C_FLAGS} -arch ${CMAKE_OSX_ARCHITECTURES})
|
||||
endif()
|
||||
if(CMAKE_OSX_SYSROOT)
|
||||
set(PLATFORM_C_FLAGS ${PLATFORM_C_FLAGS} -isysroot ${CMAKE_OSX_SYSROOT})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
get_filename_component(INPUTEXT "${INPUT}" EXT)
|
||||
get_filename_component(OUTPUTEXT "${OUTPUT}" EXT)
|
||||
get_filename_component(INPUTBASE "${INPUT}" NAME_WE)
|
||||
get_filename_component(OUTPUTBASE "${OUTPUT}" NAME_WE)
|
||||
get_filename_component(INPUTDIR "${INPUT}" PATH)
|
||||
get_filename_component(OUTPUTDIR "${OUTPUT}" PATH)
|
||||
|
||||
if ("${INPUTEXT}" STREQUAL ".c" AND "${OUTPUTEXT}" STREQUAL ".out")
|
||||
get_filename_component(GENDIR "${OUTPUT}" PATH)
|
||||
file(MAKE_DIRECTORY "${GENDIR}")
|
||||
|
||||
file(REMOVE "${OUTPUT}.tf1" "${OUTPUT}.tf2")
|
||||
|
||||
set(INCLUDES "-I${INCDIR}")
|
||||
if(ZLIBINCDIR)
|
||||
foreach(dir ${ZLIBINCDIR})
|
||||
list(APPEND INCLUDES "-I${dir}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(PNG_PREFIX)
|
||||
set(PNG_PREFIX_DEF "-DPNG_PREFIX=${PNG_PREFIX}")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND "${CMAKE_C_COMPILER}" "-E"
|
||||
${CMAKE_C_FLAGS}
|
||||
${PLATFORM_C_FLAGS}
|
||||
"-I${SRCDIR}"
|
||||
"-I${BINDIR}"
|
||||
${INCLUDES}
|
||||
"-DPNGLIB_LIBNAME=PNG${PNGLIB_MAJOR}${PNGLIB_MINOR}_0"
|
||||
"-DPNGLIB_VERSION=${PNGLIB_VERSION}"
|
||||
"-DSYMBOL_PREFIX=${SYMBOL_PREFIX}"
|
||||
"-DPNG_NO_USE_READ_MACROS"
|
||||
"-DPNG_BUILDING_SYMBOL_TABLE"
|
||||
${PNG_PREFIX_DEF}
|
||||
"${INPUT}"
|
||||
OUTPUT_FILE "${OUTPUT}.tf1"
|
||||
WORKING_DIRECTORY "${BINDIR}"
|
||||
RESULT_VARIABLE CPP_FAIL)
|
||||
if(CPP_FAIL)
|
||||
message(FATAL_ERROR "Failed to generate ${OUTPUT}.tf1")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND "${AWK}" -f "${SRCDIR}/scripts/dfn.awk"
|
||||
"out=${OUTPUT}.tf2" "${OUTPUT}.tf1"
|
||||
WORKING_DIRECTORY "${BINDIR}"
|
||||
RESULT_VARIABLE AWK_FAIL)
|
||||
if(AWK_FAIL)
|
||||
message(FATAL_ERROR "Failed to generate ${OUTPUT}.tf2")
|
||||
endif()
|
||||
|
||||
file(REMOVE "${OUTPUT}.tf1")
|
||||
file(RENAME "${OUTPUT}.tf2" "${OUTPUT}")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported conversion: ${INPUTEXT} to ${OUTPUTEXT}")
|
||||
endif()
|
@ -1,138 +0,0 @@
|
||||
# gensrc.cmake.in
|
||||
# Generate source files with awk, based upon the automake logic.
|
||||
|
||||
# Copyright (C) 2016 Glenn Randers-Pehrson
|
||||
# Written by Roger Leigh, 2016
|
||||
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
|
||||
# Variables substituted from CMakeLists.txt
|
||||
set(SRCDIR "@CMAKE_CURRENT_SOURCE_DIR@")
|
||||
set(BINDIR "@CMAKE_CURRENT_BINARY_DIR@")
|
||||
|
||||
set(AWK "@AWK@")
|
||||
set(DFA_XTRA "@DFA_XTRA@")
|
||||
set(PNG_PREFIX "@PNG_PREFIX@")
|
||||
set(PNGLIB_VERSION "@PNGLIB_VERSION@")
|
||||
|
||||
if("${OUTPUT}" STREQUAL "scripts/pnglibconf.c")
|
||||
# Generate scripts/pnglibconf.c
|
||||
|
||||
file(REMOVE "${BINDIR}/pnglibconf.tf6" "${BINDIR}/pnglibconf.tf7")
|
||||
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E echo "com ${PNGLIB_VERSION} STANDARD API DEFINITION"
|
||||
COMMAND "${AWK}" -f "${SRCDIR}/scripts/options.awk"
|
||||
"out=pnglibconf.tf6" "logunsupported=1" "version=search"
|
||||
"${SRCDIR}/pngconf.h" "-"
|
||||
"${SRCDIR}/scripts/pnglibconf.dfa"
|
||||
WORKING_DIRECTORY "${BINDIR}"
|
||||
RESULT_VARIABLE AWK_FAIL)
|
||||
if(AWK_FAIL)
|
||||
message(FATAL_ERROR "Failed to generate pnglibconf.tf6")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND "${AWK}" -f "${SRCDIR}/scripts/options.awk"
|
||||
"out=pnglibconf.tf7" "pnglibconf.tf6"
|
||||
WORKING_DIRECTORY "${BINDIR}"
|
||||
RESULT_VARIABLE AWK_FAIL)
|
||||
if(AWK_FAIL)
|
||||
message(FATAL_ERROR "Failed to generate pnglibconf.tf7")
|
||||
endif()
|
||||
|
||||
file(REMOVE "pnglibconf.tf6")
|
||||
file(MAKE_DIRECTORY "${BINDIR}/scripts")
|
||||
file(RENAME "pnglibconf.tf7" "${BINDIR}/scripts/pnglibconf.c")
|
||||
|
||||
elseif ("${OUTPUT}" STREQUAL "pnglibconf.c")
|
||||
# Generate pnglibconf.c
|
||||
|
||||
file(REMOVE "${BINDIR}/pnglibconf.tf4" "${BINDIR}/pnglibconf.tf5")
|
||||
|
||||
execute_process(COMMAND "${AWK}" -f "${SRCDIR}/scripts/options.awk"
|
||||
out=pnglibconf.tf4 version=search
|
||||
${SRCDIR}/pngconf.h ${SRCDIR}/scripts/pnglibconf.dfa
|
||||
${SRCDIR}/pngusr.dfa ${DFA_XTRA}
|
||||
WORKING_DIRECTORY "${BINDIR}"
|
||||
RESULT_VARIABLE AWK_FAIL)
|
||||
if(AWK_FAIL)
|
||||
message(FATAL_ERROR "Failed to generate pnglibconf.tf4")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND "${AWK}" -f "${SRCDIR}/scripts/options.awk"
|
||||
out=pnglibconf.tf5 pnglibconf.tf4
|
||||
WORKING_DIRECTORY "${BINDIR}"
|
||||
RESULT_VARIABLE AWK_FAIL)
|
||||
if(AWK_FAIL)
|
||||
message(FATAL_ERROR "Failed to generate pnglibconf.tf5")
|
||||
endif()
|
||||
|
||||
file(REMOVE "pnglibconf.tf4")
|
||||
file(MAKE_DIRECTORY "${BINDIR}/scripts")
|
||||
file(RENAME "pnglibconf.tf5" "${BINDIR}/pnglibconf.c")
|
||||
|
||||
elseif ("${OUTPUT}" STREQUAL "pnglibconf.h")
|
||||
# Generate pnglibconf.h
|
||||
|
||||
file(REMOVE "${BINDIR}/${OUTPUT}")
|
||||
if(PNG_PREFIX)
|
||||
file(REMOVE "pnglibconf.tf8")
|
||||
|
||||
execute_process(COMMAND "${AWK}" "s==0 && NR>1{print prev}
|
||||
s==0{prev=\$0}
|
||||
s==1{print \"#define\", \$1, \"${PNG_PREFIX}\" \$1}
|
||||
s==2{print \"#define ${PNG_PREFIX}png_\" \$1, \"PNG_\" \$1}
|
||||
END{print prev}" s=0 pnglibconf.out s=1 "${BINDIR}/scripts/prefix.out"
|
||||
s=2 "${SRCDIR}/scripts/macro.lst"
|
||||
OUTPUT_FILE pnglibconf.tf8
|
||||
RESULT_VARIABLE AWK_FAIL)
|
||||
if(AWK_FAIL)
|
||||
message(FATAL_ERROR "Failed to generate pnglibconf.tf8")
|
||||
endif()
|
||||
|
||||
file(RENAME "pnglibconf.tf8" "${BINDIR}/${OUTPUT}")
|
||||
else()
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E copy "${BINDIR}/pnglibconf.out"
|
||||
"${BINDIR}/${OUTPUT}"
|
||||
RESULT_VARIABLE COPY_FAIL)
|
||||
if(COPY_FAIL)
|
||||
message(FATAL_ERROR "Failed to create pnglibconf.h")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
elseif ("${OUTPUT}" STREQUAL "pngprefix.h")
|
||||
# Generate pngprefix.h
|
||||
|
||||
file(REMOVE "${BINDIR}/${OUTPUT}")
|
||||
|
||||
if(PNG_PREFIX)
|
||||
file(REMOVE "pngprefix.tf1")
|
||||
|
||||
execute_process(COMMAND "${AWK}"
|
||||
"{print \"#define\", \$1, \"${PNG_PREFIX}\" \$1}"
|
||||
"${BINDIR}/scripts/intprefix.out"
|
||||
OUTPUT_FILE "pngprefix.tf1"
|
||||
RESULT_VARIABLE AWK_FAIL)
|
||||
if(AWK_FAIL)
|
||||
message(FATAL_ERROR "Failed to generate pngprefix.tf1")
|
||||
endif()
|
||||
|
||||
file(RENAME "pngprefix.tf1" "${BINDIR}/${OUTPUT}")
|
||||
else()
|
||||
file(WRITE "${BINDIR}/${OUTPUT}" "/* No libpng symbol prefix configured. */")
|
||||
endif()
|
||||
|
||||
elseif("${OUTPUT}" STREQUAL "scripts/pnglibconf.h.prebuilt")
|
||||
# Generate scripts/pnglibconf.h.prebuilt (fails build)
|
||||
|
||||
message(STATUS "Attempting to build scripts/pnglibconf.h.prebuilt")
|
||||
message(STATUS "This is a machine generated file, but if you want to make")
|
||||
message(STATUS "a new one simply build the 'genfiles' target, and copy")
|
||||
message(STATUS "scripts/pnglibconf.out to scripts/pnglibconf.h.prebuilt")
|
||||
message(STATUS "AND set PNG_ZLIB_VERNUM to 0 (you MUST do this)")
|
||||
message(FATAL_ERROR "Stopping build")
|
||||
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported output: ${OUTPUT}")
|
||||
endif()
|
@ -1,22 +0,0 @@
|
||||
|
||||
/* intprefix.c - generate an unprefixed internal symbol list
|
||||
*
|
||||
* Last changed in libpng version 1.6.16 [December 22, 2014]
|
||||
* Copyright (c) 2013-2014 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
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL_DATA(type, name, array)\
|
||||
PNG_DFN "@" name "@"
|
||||
|
||||
#define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\
|
||||
PNG_DFN "@" name "@"
|
||||
|
||||
#define PNG_INTERNAL_CALLBACK(type, name, args, attributes)\
|
||||
PNG_DFN "@" name "@"
|
||||
|
||||
#define PNGPREFIX_H /* self generation */
|
||||
#include "../pngpriv.h"
|
@ -1,96 +0,0 @@
|
||||
|
||||
usage()
|
||||
{
|
||||
cat <<EOF
|
||||
Usage: libpng-config [OPTION] ...
|
||||
|
||||
Known values for OPTION are:
|
||||
|
||||
--prefix print libpng prefix
|
||||
--libdir print path to directory containing library
|
||||
--libs print library linking information
|
||||
--ccopts print compiler options
|
||||
--cppflags print pre-processor flags
|
||||
--cflags print preprocessor flags, I_opts, and compiler options
|
||||
--I_opts print "-I" include options
|
||||
--L_opts print linker "-L" flags for dynamic linking
|
||||
--R_opts print dynamic linker "-R" or "-rpath" flags
|
||||
--ldopts print linker options
|
||||
--ldflags print linker flags (ldopts, L_opts, R_opts, and libs)
|
||||
--static revise subsequent outputs for static linking
|
||||
--help print this help and exit
|
||||
--version print version information
|
||||
EOF
|
||||
|
||||
exit $1
|
||||
}
|
||||
|
||||
if test $# -eq 0; then
|
||||
usage 1
|
||||
fi
|
||||
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
|
||||
--prefix)
|
||||
echo ${prefix}
|
||||
;;
|
||||
|
||||
--version)
|
||||
echo ${version}
|
||||
exit 0
|
||||
;;
|
||||
|
||||
--help)
|
||||
usage 0
|
||||
;;
|
||||
|
||||
--ccopts)
|
||||
echo ${ccopts}
|
||||
;;
|
||||
|
||||
--cppflags)
|
||||
echo ${cppflags}
|
||||
;;
|
||||
|
||||
--cflags)
|
||||
echo ${I_opts} ${cppflags} ${ccopts}
|
||||
;;
|
||||
|
||||
--libdir)
|
||||
echo ${libdir}
|
||||
;;
|
||||
|
||||
--libs)
|
||||
echo ${libs}
|
||||
;;
|
||||
|
||||
--I_opts)
|
||||
echo ${I_opts}
|
||||
;;
|
||||
|
||||
--L_opts)
|
||||
echo ${L_opts}
|
||||
;;
|
||||
|
||||
--R_opts)
|
||||
echo ${R_opts}
|
||||
;;
|
||||
|
||||
--ldflags)
|
||||
echo ${ldflags} ${L_opts} ${R_opts} ${libs}
|
||||
;;
|
||||
|
||||
--static)
|
||||
R_opts=""
|
||||
;;
|
||||
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,24 +0,0 @@
|
||||
#! /bin/sh
|
||||
|
||||
# libpng-config
|
||||
# provides configuration info for libpng.
|
||||
|
||||
# Copyright (C) 2002 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
|
||||
|
||||
# Modeled after libxml-config.
|
||||
|
||||
version=1.6.34
|
||||
prefix=""
|
||||
libdir=""
|
||||
libs=""
|
||||
I_opts=""
|
||||
L_opts=""
|
||||
R_opts=""
|
||||
cppflags=""
|
||||
ccopts=""
|
||||
ldopts=""
|
||||
|
@ -1,10 +0,0 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@/libpng16
|
||||
|
||||
Name: libpng
|
||||
Description: Loads and saves PNG files
|
||||
Version: 1.6.34
|
||||
Libs: -L${libdir} -lpng16
|
||||
Cflags: -I${includedir}
|
@ -1,898 +0,0 @@
|
||||
#!/bin/awk -f
|
||||
# scripts/options.awk - library build configuration control
|
||||
#
|
||||
# last changed in libpng version 1.6.11 - June 5, 2014
|
||||
#
|
||||
# Copyright (c) 1998-2014 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
|
||||
|
||||
# The output of this script is written to the file given by
|
||||
# the variable 'out'. The script is run twice, once with
|
||||
# an intermediate output file, 'options.tmp' then again on
|
||||
# that file to produce the final output:
|
||||
#
|
||||
# awk -f scripts/options.awk out=options.tmp scripts/options.dfa 1>&2
|
||||
# awk -f scripts/options.awk out=options.dfn options.tmp 1>&2
|
||||
#
|
||||
# Some options may be specified on the command line:
|
||||
#
|
||||
# deb=1 Causes debugging to be output
|
||||
# logunsupported=1 Causes all options to be recorded in the output
|
||||
# everything=off Causes all options to be disabled by default
|
||||
# everything=on Causes all options to be enabled by default
|
||||
#
|
||||
# If awk fails on your platform, try nawk instead.
|
||||
#
|
||||
# These options may also be specified in the original input file (and
|
||||
# are copied to the preprocessed file).
|
||||
|
||||
BEGIN{
|
||||
out="" # intermediate, preprocessed, file
|
||||
pre=-1 # preprocess (first line)
|
||||
version="libpng version unknown" # version information
|
||||
version_file="" # where to find the version
|
||||
err=0 # in-line exit sets this
|
||||
# The following definitions prevent the C preprocessor noticing the lines
|
||||
# that will be in the final output file. Some C preprocessors tokenise
|
||||
# the lines, for example by inserting spaces around operators, and all
|
||||
# C preprocessors notice lines that start with '#', most remove comments.
|
||||
# The technique adopted here is to make the final output lines into
|
||||
# C strings (enclosed in double quotes), preceded by PNG_DFN. As a
|
||||
# consequence the output cannot contain a 'raw' double quote - instead put
|
||||
# @' in, this will be replaced by a single " afterward. See the parser
|
||||
# script dfn.awk for more capabilities (not required here). Note that if
|
||||
# you need a " in a 'setting' in pnglibconf.dfa it must also be @'!
|
||||
dq="@'" # For a single double quote
|
||||
start=" PNG_DFN \"" # Start stuff to output (can't contain a "!)
|
||||
end="\" " # End stuff to output
|
||||
subs="@\" " # Substitute start (substitute a C macro)
|
||||
sube=" \"@" # Substitute end
|
||||
comment=start "/*" # Comment start
|
||||
cend="*/" end # Comment end
|
||||
def=start "#define PNG_" # Arbitrary define
|
||||
sup="_SUPPORTED" end # end supported option
|
||||
und=comment "#undef PNG_" # Unsupported option
|
||||
une="_SUPPORTED" cend # end unsupported option
|
||||
error=start "ERROR:" # error message, terminate with 'end'
|
||||
|
||||
# Variables
|
||||
deb=0 # debug - set on command line
|
||||
everything="" # do not override defaults
|
||||
logunsupported=0 # write unsupported options too
|
||||
|
||||
# Precreate arrays
|
||||
# for each option:
|
||||
option[""] = "" # list of all options: default enabled/disabled
|
||||
done[""] = 1 # marks option as having been output
|
||||
requires[""] = "" # requires by option
|
||||
iffs[""] = "" # if by option
|
||||
enabledby[""] = "" # options that enable it by option
|
||||
sets[""] = "" # settings set by each option
|
||||
setval[""] = "" # value to set (indexed: 'option sets[option]')
|
||||
# for each setting:
|
||||
setting[""] = "" # requires by setting
|
||||
defaults[""] = "" # used for a defaulted value
|
||||
doneset[""] = 1 # marks setting as having been output
|
||||
r[""] = "" # Temporary array
|
||||
|
||||
# For decorating the output file
|
||||
protect = ""
|
||||
}
|
||||
|
||||
# The output file must be specified before any input:
|
||||
out == "" {
|
||||
print "out=output.file must be given on the command line"
|
||||
err = 1
|
||||
exit 1
|
||||
}
|
||||
|
||||
# The very first line indicates whether we are reading pre-processed
|
||||
# input or not, this must come *first* because 'PREPROCESSED' needs
|
||||
# to be the very first line in the temporary file.
|
||||
pre == -1{
|
||||
if ($0 == "PREPROCESSED") {
|
||||
pre = 0
|
||||
next
|
||||
} else {
|
||||
pre = 1
|
||||
print "PREPROCESSED" >out
|
||||
# And fall through to continue processing
|
||||
}
|
||||
}
|
||||
|
||||
# While pre-processing if version is set to "search" look for a version string
|
||||
# in the following file.
|
||||
pre && version == "search" && version_file == ""{
|
||||
version_file = FILENAME
|
||||
}
|
||||
|
||||
pre && version == "search" && version_file != FILENAME{
|
||||
print "version string not found in", version_file
|
||||
err = 1
|
||||
exit 1
|
||||
}
|
||||
|
||||
pre && version == "search" && $0 ~ /^ \* libpng version/{
|
||||
version = substr($0, 4)
|
||||
print "version =", version >out
|
||||
next
|
||||
}
|
||||
|
||||
pre && FILENAME == version_file{
|
||||
next
|
||||
}
|
||||
|
||||
# variable=value
|
||||
# Sets the given variable to the given value (the syntax is fairly
|
||||
# free form, except for deb (you are expected to understand how to
|
||||
# set the debug variable...)
|
||||
#
|
||||
# This happens before the check on 'pre' below skips most of the
|
||||
# rest of the actions, so the variable settings happen during
|
||||
# preprocessing but are recorded in the END action too. This
|
||||
# allows them to be set on the command line too.
|
||||
$0 ~ /^[ ]*version[ ]*=/{
|
||||
sub(/^[ ]*version[ ]*=[ ]*/, "")
|
||||
version = $0
|
||||
next
|
||||
}
|
||||
$0 ~ /^[ ]*everything[ =]*off[ ]*$/{
|
||||
everything = "off"
|
||||
next
|
||||
}
|
||||
$0 ~ /^[ ]*everything[ =]*on[ ]*$/{
|
||||
everything = "on"
|
||||
next
|
||||
}
|
||||
$0 ~ /^[ ]*logunsupported[ =]*0[ ]*$/{
|
||||
logunsupported = 0
|
||||
next
|
||||
}
|
||||
$0 ~ /^[ ]*logunsupported[ =]*1[ ]*$/{
|
||||
logunsupported = 1
|
||||
next
|
||||
}
|
||||
$1 == "deb" && $2 == "=" && NF == 3{
|
||||
deb = $3
|
||||
next
|
||||
}
|
||||
|
||||
# Preprocessing - this just copies the input file with lines
|
||||
# that need preprocessing (just chunk at present) expanded
|
||||
# The bare "pre" instead of "pre != 0" crashes under Sunos awk
|
||||
pre && $1 != "chunk"{
|
||||
print >out
|
||||
next
|
||||
}
|
||||
|
||||
# The first characters of the line determine how it is processed,
|
||||
# leading spaces are ignored. In general tokens that are not
|
||||
# keywords are the names of options. An option 'name' is
|
||||
# controlled by the definition of the corresponding macros:
|
||||
#
|
||||
# PNG_name_SUPPORTED The option is turned on
|
||||
# PNG_NO_name
|
||||
# PNG_NO_name_SUPPORTED If the first macro is not defined
|
||||
# either of these will turn the option off
|
||||
#
|
||||
# If none of these macros are defined the option is turned on, unless
|
||||
# the keyword 'off' is given in a line relating to the option. The
|
||||
# keyword 'on' can also be given, but it will be ignored (since it is
|
||||
# the default.)
|
||||
#
|
||||
# In the syntax below a 'name' is indicated by "NAME", other macro
|
||||
# values are indicated by "MACRO", as with "NAME" the leading "PNG_"
|
||||
# is omitted, but in this case the "NO_" prefix and the "_SUPPORTED"
|
||||
# suffix are never used.
|
||||
#
|
||||
# Each line is introduced by a keyword - the first non-space characters
|
||||
# on the line. A line starting with a '#' is a comment - it is totally
|
||||
# ignored. Keywords are as follows, a NAME, is simply a macro name
|
||||
# without the leading PNG_, PNG_NO_ or the trailing _SUPPORTED.
|
||||
|
||||
$1 ~ /^#/ || $0 ~ /^[ ]*$/{
|
||||
next
|
||||
}
|
||||
|
||||
# com <comment>
|
||||
# The whole line is placed in the output file as a comment with
|
||||
# the preceding 'com' removed
|
||||
$1 == "com"{
|
||||
if (NF > 1) {
|
||||
# sub(/^[ ]*com[ ]*/, "")
|
||||
$1 = ""
|
||||
print comment $0, cend >out
|
||||
} else
|
||||
print start end >out
|
||||
next
|
||||
}
|
||||
|
||||
# version
|
||||
# Inserts a version comment
|
||||
$1 == "version" && NF == 1{
|
||||
if (version == "") {
|
||||
print "ERROR: no version string set"
|
||||
err = 1 # prevent END{} running
|
||||
exit 1
|
||||
}
|
||||
|
||||
print comment, version, cend >out
|
||||
next
|
||||
}
|
||||
|
||||
# file output input protect
|
||||
# Informational: the official name of the input file (without
|
||||
# make generated local directories), the official name of the
|
||||
# output file and, if required, a name to use in a protection
|
||||
# macro for the contents.
|
||||
$1 == "file" && NF >= 2{
|
||||
print comment, $2, cend >out
|
||||
print comment, "Machine generated file: DO NOT EDIT", cend >out
|
||||
if (NF >= 3)
|
||||
print comment, "Derived from:", $3, cend >out
|
||||
protect = $4
|
||||
if (protect != "") {
|
||||
print start "#ifndef", protect end >out
|
||||
print start "#define", protect end >out
|
||||
}
|
||||
next
|
||||
}
|
||||
|
||||
# option NAME ( (requires|enables|if) NAME* | on | off | disabled |
|
||||
# sets SETTING VALUE+ )*
|
||||
#
|
||||
# Declares an option 'NAME' and describes its default setting (disabled)
|
||||
# and its relationship to other options. The option is disabled
|
||||
# unless *all* the options listed after 'requires' are set and at
|
||||
# least one of the options listed after 'if' is set. If the
|
||||
# option is set then it turns on all the options listed after 'enables'.
|
||||
#
|
||||
# Note that "enables" takes priority over the required/if/disabled/off
|
||||
# setting of the target option.
|
||||
#
|
||||
# The definition file may list an option as 'disabled': off by default,
|
||||
# otherwise the option is enabled: on by default. A later (and it must
|
||||
# be later) entry may turn an option on or off explicitly.
|
||||
|
||||
$1 == "option" && NF >= 2{
|
||||
opt = $2
|
||||
sub(/,$/,"",opt)
|
||||
onoff = option[opt] # records current (and the default is "", enabled)
|
||||
key = ""
|
||||
istart = 3
|
||||
do {
|
||||
if (istart == 1) { # continuation line
|
||||
val = getline
|
||||
|
||||
if (val != 1) { # error reading it
|
||||
if (val == 0)
|
||||
print "option", opt ": ERROR: missing continuation line"
|
||||
else
|
||||
print "option", opt ": ERROR: error reading continuation line"
|
||||
|
||||
# This is a hard error
|
||||
err = 1 # prevent END{} running
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
for (i=istart; i<=NF; ++i) {
|
||||
val=$(i)
|
||||
sub(/,$/,"",val)
|
||||
if (val == "on" || val == "off" || val == "disabled" || val =="enabled") {
|
||||
key = ""
|
||||
if (onoff != val) {
|
||||
# on or off can zap disabled or enabled:
|
||||
if (onoff == "" || (onoff == "disabled" || onoff == "enabled") &&
|
||||
(val == "on" || val == "off")) {
|
||||
# It's easy to mis-spell the option when turning it
|
||||
# on or off, so warn about it here:
|
||||
if (onoff == "" && (val == "on" || val == "off")) {
|
||||
print "option", opt ": ERROR: turning unrecognized option", val
|
||||
# For the moment error out - it is safer
|
||||
err = 1 # prevent END{} running
|
||||
exit 1
|
||||
}
|
||||
onoff = val
|
||||
} else {
|
||||
# Print a message, otherwise the error
|
||||
# below is incomprehensible
|
||||
print "option", opt ": currently", onoff ": attempt to turn", val
|
||||
break
|
||||
}
|
||||
}
|
||||
} else if (val == "requires" || val == "if" || val == "enables" || val =="sets") {
|
||||
key = val
|
||||
} else if (key == "requires") {
|
||||
requires[opt] = requires[opt] " " val
|
||||
} else if (key == "if") {
|
||||
iffs[opt] = iffs[opt] " " val
|
||||
} else if (key == "enables") {
|
||||
enabledby[val] = enabledby[val] " " opt
|
||||
} else if (key == "sets") {
|
||||
sets[opt] = sets[opt] " " val
|
||||
key = "setval"
|
||||
set = val
|
||||
} else if (key == "setval") {
|
||||
setval[opt " " set] = setval[opt " " set] " " val
|
||||
} else
|
||||
break # bad line format
|
||||
}
|
||||
|
||||
istart = 1
|
||||
} while (i > NF && $0 ~ /,$/)
|
||||
|
||||
if (i > NF) {
|
||||
# Set the option, defaulting to 'enabled'
|
||||
if (onoff == "") onoff = "enabled"
|
||||
option[opt] = onoff
|
||||
next
|
||||
}
|
||||
# Else fall through to the error handler
|
||||
}
|
||||
|
||||
# chunk NAME [requires OPT] [enables LIST] [on|off|disabled]
|
||||
# Expands to the 'option' settings appropriate to the reading and
|
||||
# writing of an ancillary PNG chunk 'NAME':
|
||||
#
|
||||
# option READ_NAME requires READ_ANCILLARY_CHUNKS [READ_OPT]
|
||||
# option READ_NAME enables NAME LIST
|
||||
# [option READ_NAME off]
|
||||
# option WRITE_NAME requires WRITE_ANCILLARY_CHUNKS [WRITE_OPT]
|
||||
# option WRITE_NAME enables NAME LIST
|
||||
# [option WRITE_NAME off]
|
||||
|
||||
pre != 0 && $1 == "chunk" && NF >= 2{
|
||||
# 'chunk' is handled on the first pass by writing appropriate
|
||||
# 'option' lines into the intermediate file.
|
||||
opt = $2
|
||||
sub(/,$/,"",opt)
|
||||
onoff = ""
|
||||
reqread = ""
|
||||
reqwrite = ""
|
||||
enables = ""
|
||||
req = 0
|
||||
istart = 3
|
||||
do {
|
||||
if (istart == 1) { # continuation line
|
||||
val = getline
|
||||
|
||||
if (val != 1) { # error reading it
|
||||
if (val == 0)
|
||||
print "chunk", opt ": ERROR: missing continuation line"
|
||||
else
|
||||
print "chunk", opt ": ERROR: error reading continuation line"
|
||||
|
||||
# This is a hard error
|
||||
err = 1 # prevent END{} running
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# read the keywords/additional OPTS
|
||||
for (i=istart; i<=NF; ++i) {
|
||||
val = $(i)
|
||||
sub(/,$/,"",val)
|
||||
if (val == "on" || val == "off" || val == "disabled") {
|
||||
if (onoff != val) {
|
||||
if (onoff == "")
|
||||
onoff = val
|
||||
else
|
||||
break # on/off conflict
|
||||
}
|
||||
req = 0
|
||||
} else if (val == "requires")
|
||||
req = 1
|
||||
else if (val == "enables")
|
||||
req = 2
|
||||
else if (req == 1){
|
||||
reqread = reqread " READ_" val
|
||||
reqwrite = reqwrite " WRITE_" val
|
||||
} else if (req == 2)
|
||||
enables = enables " " val
|
||||
else
|
||||
break # bad line: handled below
|
||||
}
|
||||
|
||||
istart = 1
|
||||
} while (i > NF && $0 ~ /,$/)
|
||||
|
||||
if (i > NF) {
|
||||
# Output new 'option' lines to the intermediate file (out)
|
||||
print "option READ_" opt, "requires READ_ANCILLARY_CHUNKS" reqread, "enables", opt enables , onoff >out
|
||||
print "option WRITE_" opt, "requires WRITE_ANCILLARY_CHUNKS" reqwrite, "enables", opt enables, onoff >out
|
||||
next
|
||||
}
|
||||
# Else hit the error handler below - bad line format!
|
||||
}
|
||||
|
||||
# setting MACRO ( requires MACRO* )* [ default VALUE ]
|
||||
# Behaves in a similar way to 'option' without looking for NO_ or
|
||||
# _SUPPORTED; the macro is enabled if it is defined so long as all
|
||||
# the 'requires' macros are also defined. The definitions may be
|
||||
# empty, an error will be issued if the 'requires' macros are
|
||||
# *not* defined. If given the 'default' value is used if the
|
||||
# macro is not defined. The default value will be re-tokenised.
|
||||
# (BTW: this is somewhat restrictive, it mainly exists for the
|
||||
# support of non-standard configurations and numeric parameters,
|
||||
# see the uses in scripts/options.dat
|
||||
|
||||
$1 == "setting" && (NF == 2 || NF >= 3 && ($3 == "requires" || $3 == "default")){
|
||||
reqs = ""
|
||||
deflt = ""
|
||||
isdef = 0
|
||||
key = ""
|
||||
for (i=3; i<=NF; ++i)
|
||||
if ($(i) == "requires" || $(i) == "default") {
|
||||
key = $(i)
|
||||
if (key == "default") isdef = 1
|
||||
} else if (key == "requires")
|
||||
reqs = reqs " " $(i)
|
||||
else if (key == "default")
|
||||
deflt = deflt " " $(i)
|
||||
else
|
||||
break # Format error, handled below
|
||||
|
||||
setting[$2] = reqs
|
||||
# NOTE: this overwrites a previous value silently
|
||||
if (isdef && deflt == "")
|
||||
deflt = " " # as a flag to force output
|
||||
defaults[$2] = deflt
|
||||
next
|
||||
}
|
||||
|
||||
# The order of the dependency lines (option, chunk, setting) is irrelevant
|
||||
# - the 'enables', 'requires' and 'if' settings will be used to determine
|
||||
# the correct order in the output and the final values in pnglibconf.h are
|
||||
# not order dependent. 'requires' and 'if' entries take precedence over
|
||||
# 'enables' from other options; if an option requires another option it
|
||||
# won't be set regardless of any options that enable it unless the other
|
||||
# option is also enabled.
|
||||
#
|
||||
# Similarly 'enables' trumps a NO_ definition in CFLAGS or pngusr.h
|
||||
#
|
||||
# For simplicity cycles in the definitions are regarded as errors,
|
||||
# even if they are not ambiguous.
|
||||
# A given NAME can be specified in as many 'option' lines as required, the
|
||||
# definitions are additive.
|
||||
|
||||
# For backwards compatibility equivalent macros may be listed thus:
|
||||
#
|
||||
# = [NO_]NAME MACRO
|
||||
# Makes -DMACRO equivalent to -DPNG_NO_NAME or -DPNG_NAME_SUPPORTED
|
||||
# as appropriate.
|
||||
#
|
||||
# The definition is injected into the C compiler input when encountered
|
||||
# in the second pass (so all these definitions appear *after* the @
|
||||
# lines!)
|
||||
#
|
||||
# 'NAME' is as above, but 'MACRO' is the full text of the equivalent
|
||||
# old, deprecated, macro.
|
||||
|
||||
$1 == "=" && NF == 3{
|
||||
print "#ifdef PNG_" $3 >out
|
||||
if ($2 ~ /^NO_/)
|
||||
print "# define PNG_" $2 >out
|
||||
else
|
||||
print "# define PNG_" $2 "_SUPPORTED" >out
|
||||
print "#endif" >out
|
||||
next
|
||||
}
|
||||
|
||||
# Lines may be injected into the C compiler input by preceding them
|
||||
# with an "@" character. The line is copied with just the leading
|
||||
# @ removed.
|
||||
|
||||
$1 ~ /^@/{
|
||||
# sub(/^[ ]*@/, "")
|
||||
$1 = substr($1, 2)
|
||||
print >out
|
||||
next
|
||||
}
|
||||
|
||||
# Check for unrecognized lines, because of the preprocessing chunk
|
||||
# format errors will be detected on the first pass independent of
|
||||
# any other format errors.
|
||||
{
|
||||
print "options.awk: bad line (" NR "):", $0
|
||||
err = 1 # prevent END{} running
|
||||
exit 1
|
||||
}
|
||||
|
||||
# For checking purposes names that start with "ok_" or "fail_" are
|
||||
# not output to pnglibconf.h and must be either enabled or disabled
|
||||
# respectively for the build to succeed. This allows interdependencies
|
||||
# between options of the form "at least one of" or "at most one of"
|
||||
# to be checked. For example:
|
||||
#
|
||||
# option FLOATING_POINT enables ok_math
|
||||
# option FIXED_POINT enables ok_math
|
||||
# This ensures that at least one of FLOATING_POINT and FIXED_POINT
|
||||
# must be set for the build to succeed.
|
||||
#
|
||||
# option fail_math requires FLOATING_POINT FIXED_POINT
|
||||
# This means the build will fail if *both* FLOATING_POINT and
|
||||
# FIXED_POINT are set (this is an example; in fact both are allowed.)
|
||||
#
|
||||
# If all these options were given the build would require exactly one
|
||||
# of the names to be enabled.
|
||||
|
||||
END{
|
||||
# END{} gets run on an exit (a traditional awk feature)
|
||||
if (err) exit 1
|
||||
|
||||
if (pre) {
|
||||
# Record the final value of the variables
|
||||
print "deb =", deb >out
|
||||
if (everything != "") {
|
||||
print "everything =", everything >out
|
||||
}
|
||||
print "logunsupported =", logunsupported >out
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Do the options first (allowing options to set settings). The dependency
|
||||
# tree is thus:
|
||||
#
|
||||
# name > name
|
||||
# name requires name
|
||||
# name if name
|
||||
# name enabledby name
|
||||
#
|
||||
# First build a list 'tree' by option of all the things on which
|
||||
# it depends.
|
||||
print "" >out
|
||||
print "/* OPTIONS */" >out
|
||||
print comment, "options", cend >out
|
||||
for (opt in enabledby) tree[opt] = 1 # may not be explicit options
|
||||
for (opt in option) if (opt != "") {
|
||||
o = option[opt]
|
||||
# option should always be one of the following values
|
||||
if (o != "on" && o != "off" && o != "disabled" && o != "enabled") {
|
||||
print "internal option error (" o ")"
|
||||
exit 1
|
||||
}
|
||||
tree[opt] = "" # so unlisted options marked
|
||||
}
|
||||
for (opt in tree) if (opt != "") {
|
||||
if (tree[opt] == 1) {
|
||||
tree[opt] = ""
|
||||
if (option[opt] != "") {
|
||||
print "internal error (1)"
|
||||
exit 1
|
||||
}
|
||||
# Macros only listed in 'enables' remain off unless
|
||||
# one of the enabling macros is on.
|
||||
option[opt] = "disabled"
|
||||
}
|
||||
|
||||
split("", list) # clear 'list'
|
||||
# Now add every requires, iffs or enabledby entry to 'list'
|
||||
# so that we can add a unique list of requirements to tree[i]
|
||||
split(requires[opt] iffs[opt] enabledby[opt], r)
|
||||
for (i in r) list[r[i]] = 1
|
||||
for (i in list) tree[opt] = tree[opt] " " i
|
||||
}
|
||||
|
||||
# print the tree for extreme debugging
|
||||
if (deb > 2) for (i in tree) if (i != "") print i, "depends-on" tree[i]
|
||||
|
||||
# Ok, now check all options marked explicitly 'on' or 'off':
|
||||
#
|
||||
# If an option[opt] is 'on' then turn on all requires[opt]
|
||||
# If an option[opt] is 'off' then turn off all enabledby[opt]
|
||||
#
|
||||
# Error out if we have to turn 'on' to an 'off' option or vice versa.
|
||||
npending = 0
|
||||
for (opt in option) if (opt != "") {
|
||||
if (option[opt] == "on" || option[opt] == "off") {
|
||||
pending[++npending] = opt
|
||||
}
|
||||
}
|
||||
|
||||
err = 0 # set on error
|
||||
while (npending > 0) {
|
||||
opt = pending[npending--]
|
||||
if (option[opt] == "on") {
|
||||
nreqs = split(requires[opt], r)
|
||||
for (j=1; j<=nreqs; ++j) {
|
||||
if (option[r[j]] == "off") {
|
||||
print "option", opt, "turned on, but requirement", r[j], "is turned off"
|
||||
err = 1
|
||||
} else if (option[r[j]] != "on") {
|
||||
option[r[j]] = "on"
|
||||
pending[++npending] = r[j]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (option[opt] != "off") {
|
||||
print "internal error (2)"
|
||||
exit 1
|
||||
}
|
||||
nreqs = split(enabledby[opt], r)
|
||||
for (j=1; j<=nreqs; ++j) {
|
||||
if (option[r[j]] == "on") {
|
||||
print "option", opt, "turned off, but enabled by", r[j], "which is turned on"
|
||||
err = 1
|
||||
} else if (option[r[j]] != "off") {
|
||||
option[r[j]] = "off"
|
||||
pending[++npending] = r[j]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (err) exit 1
|
||||
|
||||
# Sort options:
|
||||
print "PNG_DFN_START_SORT 2" >out
|
||||
|
||||
# option[i] is now the complete list of all the tokens we may
|
||||
# need to output, go through it as above, depth first.
|
||||
finished = 0
|
||||
while (!finished) {
|
||||
finished = 1
|
||||
movement = 0 # done nothing
|
||||
for (i in option) if (!done[i]) {
|
||||
nreqs = split(tree[i], r)
|
||||
if (nreqs > 0) {
|
||||
for (j=1; j<=nreqs; ++j) if (!done[r[j]]) {
|
||||
break
|
||||
}
|
||||
if (j<=nreqs) {
|
||||
finished = 0
|
||||
continue # next option
|
||||
}
|
||||
}
|
||||
|
||||
# All the requirements have been processed, output
|
||||
# this option. An option is _SUPPORTED if:
|
||||
#
|
||||
# all 'requires' are _SUPPORTED AND
|
||||
# at least one of the 'if' options are _SUPPORTED AND
|
||||
# EITHER:
|
||||
# The name is _SUPPORTED (on the command line)
|
||||
# OR:
|
||||
# an 'enabledby' is _SUPPORTED
|
||||
# OR:
|
||||
# NO_name is not defined AND
|
||||
# the option is not disabled; an option is disabled if:
|
||||
# option == off
|
||||
# option == disabled && everything != on
|
||||
# option == "" && everything == off
|
||||
if (deb) print "option", i
|
||||
print "" >out
|
||||
print "/* option:", i, option[i] >out
|
||||
print " * requires: " requires[i] >out
|
||||
print " * if: " iffs[i] >out
|
||||
print " * enabled-by:" enabledby[i] >out
|
||||
print " * sets: " sets[i], "*/" >out
|
||||
print "#undef PNG_on" >out
|
||||
print "#define PNG_on 1" >out
|
||||
|
||||
# requires
|
||||
nreqs = split(requires[i], r)
|
||||
for (j=1; j<=nreqs; ++j) {
|
||||
print "#ifndef PNG_" r[j] "_SUPPORTED" >out
|
||||
print "# undef PNG_on /*!" r[j] "*/" >out
|
||||
# This error appears in the final output if something
|
||||
# was switched 'on' but the processing above to force
|
||||
# the requires did not work
|
||||
if (option[i] == "on") {
|
||||
print error, i, "requires", r[j] end >out
|
||||
}
|
||||
print "#endif" >out
|
||||
}
|
||||
|
||||
# if
|
||||
have_ifs = 0
|
||||
nreqs = split(iffs[i], r)
|
||||
print "#undef PNG_no_if" >out
|
||||
if (nreqs > 0) {
|
||||
have_ifs = 1
|
||||
print "/* if" iffs[i], "*/" >out
|
||||
print "#define PNG_no_if 1" >out
|
||||
for (j=1; j<=nreqs; ++j) {
|
||||
print "#ifdef PNG_" r[j] "_SUPPORTED" >out
|
||||
print "# undef PNG_no_if /*" r[j] "*/" >out
|
||||
print "#endif" >out
|
||||
}
|
||||
print "#ifdef PNG_no_if /*missing if*/" >out
|
||||
print "# undef PNG_on" >out
|
||||
# There is no checking above for this, because we
|
||||
# don't know which 'if' to choose, so whine about
|
||||
# it here:
|
||||
if (option[i] == "on") {
|
||||
print error, i, "needs one of:", iffs[i] end >out
|
||||
}
|
||||
print "#endif" >out
|
||||
}
|
||||
|
||||
print "#ifdef PNG_on /*requires, if*/" >out
|
||||
# enables
|
||||
print "# undef PNG_not_enabled" >out
|
||||
print "# define PNG_not_enabled 1" >out
|
||||
print " /* enabled by" enabledby[i], "*/" >out
|
||||
nreqs = split(enabledby[i], r)
|
||||
for (j=1; j<=nreqs; ++j) {
|
||||
print "#ifdef PNG_" r[j] "_SUPPORTED" >out
|
||||
print "# undef PNG_not_enabled /*" r[j] "*/" >out
|
||||
# Oops, probably not intended (should be factored
|
||||
# out by the checks above).
|
||||
if (option[i] == "off") {
|
||||
print error, i, "enabled by:", r[j] end >out
|
||||
}
|
||||
print "#endif" >out
|
||||
}
|
||||
|
||||
print "# ifndef PNG_" i "_SUPPORTED /*!command line*/" >out
|
||||
print "# ifdef PNG_not_enabled /*!enabled*/" >out
|
||||
# 'have_ifs' here means that everything = "off" still allows an 'if' on
|
||||
# an otherwise enabled option to turn it on; otherwise the 'if'
|
||||
# handling is effectively disabled by 'everything = off'
|
||||
if (option[i] == "off" || option[i] == "disabled" && everything != "on" || option[i] == "enabled" && everything == "off" && !have_ifs) {
|
||||
print "# undef PNG_on /*default off*/" >out
|
||||
} else {
|
||||
print "# ifdef PNG_NO_" i >out
|
||||
print "# undef PNG_on /*turned off*/" >out
|
||||
print "# endif" >out
|
||||
print "# ifdef PNG_NO_" i "_SUPPORTED" >out
|
||||
print "# undef PNG_on /*turned off*/" >out
|
||||
print "# endif" >out
|
||||
}
|
||||
print "# endif /*!enabled*/" >out
|
||||
print "# ifdef PNG_on" >out
|
||||
# The _SUPPORTED macro must be defined so that dependent
|
||||
# options output later work.
|
||||
print "# define PNG_" i "_SUPPORTED" >out
|
||||
print "# endif" >out
|
||||
print "# endif /*!command line*/" >out
|
||||
# If PNG_on is still set the option should be defined in
|
||||
# pnglibconf.h
|
||||
print "# ifdef PNG_on" >out
|
||||
if (i ~ /^fail_/) {
|
||||
print error, i, "is on: enabled by:" iffs[i] enabledby[i] ", requires" requires[i] end >out
|
||||
} else if (i !~ /^ok_/) {
|
||||
print def i sup >out
|
||||
# Supported option, set required settings
|
||||
nreqs = split(sets[i], r)
|
||||
for (j=1; j<=nreqs; ++j) {
|
||||
print "# ifdef PNG_set_" r[j] >out
|
||||
# Some other option has already set a value:
|
||||
print error, i, "sets", r[j] ": duplicate setting" end >out
|
||||
print error, " previous value: " end "PNG_set_" r[j] >out
|
||||
print "# else" >out
|
||||
# Else set the default: note that this won't accept arbitrary
|
||||
# values, the setval string must be acceptable to all the C
|
||||
# compilers we use. That means it must be VERY simple; a number,
|
||||
# a name or a string.
|
||||
print "# define PNG_set_" r[j], setval[i " " r[j]] >out
|
||||
print "# endif" >out
|
||||
}
|
||||
}
|
||||
print "# endif /* definition */" >out
|
||||
print "#endif /*requires, if*/" >out
|
||||
if (logunsupported || i ~ /^ok_/) {
|
||||
print "#ifndef PNG_on" >out
|
||||
if (logunsupported) {
|
||||
print und i une >out
|
||||
}
|
||||
if (i ~ /^ok_/) {
|
||||
print error, i, "not enabled: requires:" requires[i] ", enabled by:" iffs[i] enabledby[i] end >out
|
||||
}
|
||||
print "#endif" >out
|
||||
}
|
||||
|
||||
done[i] = 1
|
||||
++movement
|
||||
}
|
||||
|
||||
if (!finished && !movement) {
|
||||
print "option: loop or missing option in dependency tree, cannot process:"
|
||||
for (i in option) if (!done[i]) {
|
||||
print " option", i, "depends on" tree[i], "needs:"
|
||||
nreqs = split(tree[i], r)
|
||||
if (nreqs > 0) for (j=1; j<=nreqs; ++j) if (!done[r[j]]) {
|
||||
print " " r[j]
|
||||
}
|
||||
}
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
print "PNG_DFN_END_SORT" >out
|
||||
print comment, "end of options", cend >out
|
||||
|
||||
# Do the 'setting' values second, the algorithm the standard
|
||||
# tree walk (O(1)) done in an O(2) while/for loop; iterations
|
||||
# settings x depth, outputting the deepest required macros
|
||||
# first.
|
||||
print "" >out
|
||||
print "/* SETTINGS */" >out
|
||||
print comment, "settings", cend >out
|
||||
# Sort (in dfn.awk) on field 2, the setting name
|
||||
print "PNG_DFN_START_SORT 2" >out
|
||||
finished = 0
|
||||
while (!finished) {
|
||||
finished = 1
|
||||
movement = 0 # done nothing
|
||||
for (i in setting) if (!doneset[i]) {
|
||||
nreqs = split(setting[i], r)
|
||||
if (nreqs > 0) {
|
||||
# By default assume the requires values are options, but if there
|
||||
# is no option with that name check for a setting
|
||||
for (j=1; j<=nreqs; ++j) if (option[r[j]] == "" && !doneset[r[j]]) {
|
||||
break
|
||||
}
|
||||
if (j<=nreqs) {
|
||||
finished = 0
|
||||
continue # try a different setting
|
||||
}
|
||||
}
|
||||
|
||||
# All the requirements have been processed, output
|
||||
# this setting.
|
||||
if (deb) print "setting", i
|
||||
deflt = defaults[i]
|
||||
# Remove any spurious trailing spaces
|
||||
sub(/ *$/,"",deflt)
|
||||
# A leading @ means leave it unquoted so the preprocessor
|
||||
# can substitute the build time value
|
||||
if (deflt ~ /^ @/)
|
||||
deflt = " " subs substr(deflt, 3) sube
|
||||
print "" >out
|
||||
print "/* setting: ", i >out
|
||||
print " * requires:" setting[i] >out
|
||||
print " * default: ", defaults[i] deflt, "*/" >out
|
||||
for (j=1; j<=nreqs; ++j) {
|
||||
if (option[r[j]] != "")
|
||||
print "#ifndef PNG_" r[j] "_SUPPORTED" >out
|
||||
else
|
||||
print "#ifndef PNG_" r[j] >out
|
||||
print error, i, "requires", r[j] end >out
|
||||
print "# endif" >out
|
||||
}
|
||||
# The precedence is:
|
||||
#
|
||||
# 1) External definition; trumps:
|
||||
# 2) Option 'sets' value; trumps:
|
||||
# 3) Setting 'default'
|
||||
#
|
||||
print "#ifdef PNG_" i >out
|
||||
# PNG_<i> is defined, so substitute the value:
|
||||
print def i, subs "PNG_" i sube end >out
|
||||
print "#else /* use default */" >out
|
||||
print "# ifdef PNG_set_" i >out
|
||||
# Value from an option 'sets' argument
|
||||
print def i, subs "PNG_set_" i sube end >out
|
||||
# This is so that subsequent tests on the setting work:
|
||||
print "# define PNG_" i, "1" >out
|
||||
if (defaults[i] != "") {
|
||||
print "# else /*default*/" >out
|
||||
print def i deflt end >out
|
||||
print "# define PNG_" i, "1" >out
|
||||
}
|
||||
print "# endif /* defaults */" >out
|
||||
print "#endif /* setting", i, "*/" >out
|
||||
|
||||
doneset[i] = 1
|
||||
++movement
|
||||
}
|
||||
|
||||
if (!finished && !movement) {
|
||||
print "setting: loop or missing setting in 'requires', cannot process:"
|
||||
for (i in setting) if (!doneset[i]) {
|
||||
print " setting", i, "requires" setting[i]
|
||||
}
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
print "PNG_DFN_END_SORT" >out
|
||||
print comment, "end of settings", cend >out
|
||||
|
||||
# Regular end - everything looks ok
|
||||
if (protect != "") {
|
||||
print start "#endif", "/*", protect, "*/" end >out
|
||||
}
|
||||
}
|
@ -1,919 +0,0 @@
|
||||
# scripts/pnglibconf.dfa - library build configuration control
|
||||
#
|
||||
@/*- pnglibconf.dfn intermediate file
|
||||
@ * generated from scripts/pnglibconf.dfa
|
||||
@ */
|
||||
#
|
||||
com pnglibconf.h - library build configuration
|
||||
com
|
||||
version
|
||||
com
|
||||
com Copyright (c) 1998-2017 Glenn Randers-Pehrson
|
||||
com
|
||||
com This code is released under the libpng license.
|
||||
com For conditions of distribution and use, see the disclaimer
|
||||
com and license in png.h
|
||||
com
|
||||
|
||||
file pnglibconf.h scripts/pnglibconf.dfa PNGLCONF_H
|
||||
|
||||
# This file is preprocessed by scripts/options.awk and the
|
||||
# C compiler to generate 'pnglibconf.h' - a list of all the
|
||||
# configuration options. The file lists the various options
|
||||
# that can *only* be specified during the libpng build;
|
||||
# pnglibconf.h freezes the definitions selected for the specific
|
||||
# build.
|
||||
#
|
||||
# The syntax is detailed in scripts/options.awk; this is a summary
|
||||
# only:
|
||||
#
|
||||
# setting <name> [requires ...] [default]
|
||||
# #define PNG_<name> <value> /* value comes from current setting */
|
||||
# option <name> [requires ...] [if ...] [enables ...] [disabled]
|
||||
# #define PNG_<name>_SUPPORTED if the requirements are met and
|
||||
# enable the other options listed
|
||||
# chunk <name> [requires ...] [enables ...] [disabled]
|
||||
# Enable chunk processing for the given ancillary chunk; any
|
||||
# 'requires something' expands to READ_something for read and
|
||||
# WRITE_something for write, but the enables list members are
|
||||
# used as given (e.g. enables GAMMA just expands to that on the
|
||||
# correspond READ_name and WRITE_name lines.)
|
||||
#
|
||||
# "," may be used to separate options on an 'option' line and is ignored; it
|
||||
# doesn't change the meaning of the line. (NOT setting, where "," becomes
|
||||
# part of the setting!) A comma at the end of an option line causes a
|
||||
# continuation (the next line is included in the option too.)
|
||||
#
|
||||
# Note that the 'on' and 'off' keywords, while valid on both option
|
||||
# and chunk, should not be used in this file because they force the
|
||||
# relevant options on or off.
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
# The following setting, option and chunk values can all be changed
|
||||
# while building libpng:
|
||||
#
|
||||
# setting: change 'setting' lines to fine tune library performance;
|
||||
# changes to the settings don't affect the libpng API functionally
|
||||
#
|
||||
# option: change 'option' lines to remove or add capabilities from
|
||||
# or to the library; options change the library API
|
||||
#
|
||||
# chunk: change 'chunk' lines to remove capabilities to process
|
||||
# optional ('ancillary') chunks. This does not prevent PNG
|
||||
# decoding but does change the libpng API because some chunks
|
||||
# will be ignored.
|
||||
#
|
||||
# There are three ways of disabling features, in no particular order:
|
||||
#
|
||||
# 1) Create 'pngusr.h', enter the required private build information
|
||||
# detailed below and #define PNG_NO_<option> for each option you
|
||||
# don't want in that file in that file. You can also turn on options
|
||||
# using PNG_<option>_SUPPORTED. When you have finished rerun
|
||||
# configure and rebuild pnglibconf.h file with -DPNG_USER_CONFIG:
|
||||
#
|
||||
# make clean
|
||||
# CPPFLAGS='-DPNG_USER_CONFIG' ./configure
|
||||
# make pnglibconf.h
|
||||
#
|
||||
# pngusr.h is only used during the creation of pnglibconf.h, but it
|
||||
# is safer to ensure that -DPNG_USER_CONFIG is specified throughout
|
||||
# the build by changing the CPPFLAGS passed to the initial ./configure
|
||||
#
|
||||
# 2) Add definitions of the settings you want to change to
|
||||
# CPPFLAGS; for example:
|
||||
#
|
||||
# -DPNG_DEFAULT_READ_MACROS=0
|
||||
#
|
||||
# (This would change the default to *not* use read macros.) Be
|
||||
# very careful to change only settings that don't alter the API
|
||||
# because this approach bypasses the private build checking. You
|
||||
# can also change settings from pngpriv.h (read pngpriv.h) safely
|
||||
# without API changes. Do that in the same way.
|
||||
#
|
||||
# 3) Write a new '.dfa' file (say 'pngusr.dfa') and in this file
|
||||
# provide override values for setting entries and turn option or
|
||||
# chunk values explicitly 'on' or 'off':
|
||||
#
|
||||
# setting FOO default VALUE
|
||||
# option BAR [on|off]
|
||||
#
|
||||
# Then add this file to the options.awk command line (the *first*
|
||||
# one) after this file. The make macro DFA_XTRA is provided to make
|
||||
# this easier (set it like CPPFLAGS prior to running ./configure).
|
||||
# Look at the builds below contrib/pngminim for some extreme examples
|
||||
# of how this can be used.
|
||||
#
|
||||
# Don't edit this file unless you are contributing a patch to
|
||||
# libpng and need new or modified options/settings.
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
# The following causes commented out #undef lines to be written to
|
||||
# pnglibconf.h; this can be stopped by logunsupported=0 in a later
|
||||
# file or on the command line (after pnglibconf.dfa)
|
||||
|
||||
logunsupported = 1
|
||||
|
||||
# The following allows the output from configure to modify the contents of
|
||||
# pnglibconf.h
|
||||
|
||||
@#ifdef HAVE_CONFIG_H
|
||||
@# include "config.h"
|
||||
@#endif
|
||||
|
||||
# PNG_USER_CONFIG has to be defined on the compiler command line
|
||||
# to cause pngusr.h to be read while constructing pnglibconf.h
|
||||
#
|
||||
# If you create a private DLL you need to define the following
|
||||
# macros in the file 'pngusr.h' and set -DPNG_USER_CONFIG for
|
||||
# compilation (i.e. in CPPFLAGS.)
|
||||
# #define PNG_USER_PRIVATEBUILD \
|
||||
# <Describes by whom and why this version of the DLL was built>
|
||||
# e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons."
|
||||
# #define PNG_USER_DLLFNAME_POSTFIX <two-letter postfix that serve to
|
||||
# distinguish your DLL from those of the official release. These
|
||||
# correspond to the trailing letters that come after the version
|
||||
# number and must match your private DLL name>
|
||||
# e.g. // private DLL "libpng13gx.dll"
|
||||
# #define PNG_USER_DLLFNAME_POSTFIX "gx"
|
||||
#
|
||||
# The following macros are also at your disposal if you want to complete the
|
||||
# DLL VERSIONINFO structure.
|
||||
# - PNG_USER_VERSIONINFO_COMMENTS
|
||||
# - PNG_USER_VERSIONINFO_COMPANYNAME
|
||||
# - PNG_USER_VERSIONINFO_LEGALTRADEMARKS
|
||||
|
||||
# It is necessary to include configures definitions here so that AC_DEFINE
|
||||
# in configure.ac works in a comprehensible way
|
||||
@#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
|
||||
@# include "config.h"
|
||||
@#endif
|
||||
|
||||
@#ifdef PNG_USER_CONFIG
|
||||
@# include "pngusr.h"
|
||||
@#endif
|
||||
|
||||
# This is a special fixup for the Watcom C compiler on Windows, which has
|
||||
# multiple procedure call standards. Unless PNG_API_RULE is set explicitly
|
||||
# (i.e. if it is not defined at this point) it will be forced to '2' here when
|
||||
# using Watcom. This indicates to the other header files that Watcom behaviour
|
||||
# is required where appropriate.
|
||||
|
||||
@#ifdef __WATCOMC__
|
||||
@# ifndef PNG_API_RULE
|
||||
@# define PNG_API_RULE 2 /* Use Watcom calling conventions */
|
||||
@# endif
|
||||
@#endif
|
||||
|
||||
# IN DEVELOPMENT
|
||||
# These are currently experimental features; define them if you want (NOTE:
|
||||
# experimental options must be disabled before they are defined in this file!)
|
||||
|
||||
# NONE
|
||||
|
||||
# Note that PNG_USER_CONFIG only has an effect when building
|
||||
# pnglibconf.h
|
||||
|
||||
setting USER_CONFIG
|
||||
setting USER_PRIVATEBUILD
|
||||
setting USER_DLLFNAME_POSTFIX
|
||||
setting USER_VERSIONINFO_COMMENTS
|
||||
setting USER_VERSIONINFO_COMPANYNAME
|
||||
setting USER_VERSIONINFO_LEGALTRADEMARKS
|
||||
|
||||
# Record the 'API rule' used to select calling conventions on
|
||||
# those systems that support such things (see all the comments in
|
||||
# pngconf.h)
|
||||
# Changing this setting has a fundamental affect on the PNG ABI,
|
||||
# do not release shared libraries with this changed.
|
||||
|
||||
setting API_RULE default 0
|
||||
|
||||
# This allows a prefix to be added to the front of every API function name (and
|
||||
# therefore every symbol) by redefining all the function names with the prefix
|
||||
# at the end of pnglibconf.h. It also turns on similar internal symbol renaming
|
||||
# by causing a similar build-time only file, pngprefix.h, to be generated.
|
||||
|
||||
setting PREFIX
|
||||
|
||||
# Implementation specific control of the optimizations, enabled by those
|
||||
# hardware or software options that need it (typically when run-time choices
|
||||
# must be made by the user)
|
||||
option SET_OPTION disabled
|
||||
|
||||
# These options are specific to the ARM NEON hardware optimizations. At present
|
||||
# these optimizations depend on GCC specific pre-processing of an assembler (.S)
|
||||
# file so they probably won't work with other compilers.
|
||||
#
|
||||
# ARM_NEON_OPT: unset: check at compile time (__ARM_NEON__ must be defined by
|
||||
# the compiler, typically as a result of specifying
|
||||
# CC="gcc -mfpu=neon".)
|
||||
# 0: disable (even if the CPU has a NEON FPU.)
|
||||
# 1: check at run time (via ARM_NEON_{API,CHECK})
|
||||
# 2: switch on unconditionally (inadvisable - instead pass
|
||||
# -mfpu=neon to GCC in CC)
|
||||
# When building libpng avoid using any setting other than '0'; '1' is
|
||||
# set automatically when either 'API' or 'CHECK' are configured in,
|
||||
# '2' should not be necessary as -mfpu=neon will achieve the same
|
||||
# effect as well as applying NEON optimizations to the rest of the
|
||||
# libpng code.
|
||||
# NOTE: any setting other than '0' requires ALIGNED_MEMORY
|
||||
# ARM_NEON_API: (PNG_ARM_NEON == 1) allow the optimization to be switched on
|
||||
# with png_set_option
|
||||
# ARM_NEON_CHECK: (PNG_ARM_NEON == 1) compile a run-time check to see if Neon
|
||||
# extensions are supported. This is poorly supported and
|
||||
# deprecated - use the png_set_option API.
|
||||
setting ARM_NEON_OPT
|
||||
option ARM_NEON_API disabled requires ALIGNED_MEMORY enables SET_OPTION,
|
||||
sets ARM_NEON_OPT 1
|
||||
option ARM_NEON_CHECK disabled requires ALIGNED_MEMORY,
|
||||
sets ARM_NEON_OPT 1
|
||||
|
||||
# These options are specific to the PowerPC VSX hardware optimizations.
|
||||
#
|
||||
# POWERPC_VSX_OPT: unset: check at compile time (__PPC64__,__ALTIVEC__,__VSX__
|
||||
# must be defined by the compiler, typically as a result
|
||||
# of specifying
|
||||
# "-mvsx -maltivec" compiler flags)
|
||||
# 0: disable (even if the CPU supports VSX.)
|
||||
# 1: check at run time (via POWERPC_VSX_{API,CHECK})
|
||||
# 2: switch on unconditionally (inadvisable - instead pass
|
||||
# -mvsx -maltivec to compiler options)
|
||||
# When building libpng avoid using any setting other than '0'; '1' is
|
||||
# set automatically when either 'API' or 'CHECK' are configured in,
|
||||
# '2' should not be necessary as "-mvsx -maltivec" will achieve the same
|
||||
# effect as well as applying VSX optimizations to the rest of the
|
||||
# libpng code.
|
||||
# POWERPC_VSX_API: (PNG_POWERPC_VSX == 1) allow the optimization to be switched on
|
||||
# with png_set_option
|
||||
# POWERPC_VSX_CHECK: (PNG_POWERPC_VSX == 1) compile a run-time check to see if VSX
|
||||
# extensions are supported. This is supported not for all OSes
|
||||
# (see contrib/powerpc/README)
|
||||
setting POWERPC_VSX_OPT
|
||||
option POWERPC_VSX_API disabled enables SET_OPTION,
|
||||
sets POWERPC_VSX_OPT 1
|
||||
option POWERPC_VSX_CHECK disabled,
|
||||
sets POWERPC_VSX_OPT 1
|
||||
|
||||
|
||||
# These settings configure the default compression level (0-9) and 'strategy';
|
||||
# strategy is as defined by the implementors of zlib. It describes the input
|
||||
# data and modifies the zlib parameters in an attempt to optimize the balance
|
||||
# between search and huffman encoding in the zlib algorithms. The defaults are
|
||||
# the zlib.h defaults - the apparently recursive definition does not arise
|
||||
# because the name of the setting is prefixed by PNG_
|
||||
#
|
||||
# The TEXT values are the defaults when writing compressed text (all forms)
|
||||
|
||||
# Include the zlib header so that the defaults below are known
|
||||
@# include <zlib.h>
|
||||
|
||||
# The '@' here means to substitute the value when pnglibconf.h is built
|
||||
setting Z_DEFAULT_COMPRESSION default @Z_DEFAULT_COMPRESSION
|
||||
# TODO: why aren't these Z_RLE; zlib.h says that Z_RLE, specifically, is
|
||||
# appropriate for PNG images, maybe it doesn't exist in all versions?
|
||||
setting Z_DEFAULT_STRATEGY default @Z_FILTERED
|
||||
setting Z_DEFAULT_NOFILTER_STRATEGY default @Z_DEFAULT_STRATEGY
|
||||
setting ZLIB_VERNUM default @ZLIB_VERNUM
|
||||
|
||||
# Linkage of:
|
||||
#
|
||||
# API: libpng API functions
|
||||
# CALLBACK: internal non-file-local callbacks
|
||||
# FUNCTION: internal non-file-local functions
|
||||
# DATA: internal non-file-local (const) data
|
||||
setting LINKAGE_API default extern
|
||||
setting LINKAGE_CALLBACK default extern
|
||||
setting LINKAGE_FUNCTION default extern
|
||||
setting LINKAGE_DATA default extern
|
||||
|
||||
setting TEXT_Z_DEFAULT_COMPRESSION default @Z_DEFAULT_COMPRESSION
|
||||
setting TEXT_Z_DEFAULT_STRATEGY default @Z_DEFAULT_STRATEGY
|
||||
|
||||
# Default to using the read macros
|
||||
|
||||
setting DEFAULT_READ_MACROS default 1
|
||||
|
||||
# The alternative is to call functions to read PNG values, if
|
||||
# the functions are turned *off* the read macros must always
|
||||
# be enabled, so turning this off will actually force the
|
||||
# USE_READ_MACROS option on (see pngconf.h)
|
||||
|
||||
option READ_INT_FUNCTIONS requires READ
|
||||
|
||||
# The same for write but these can only be switched off if no writing
|
||||
# is required at all - hence the use of a 'disabled', not a 'requires'.
|
||||
# If these are needed, they are enabled in the 'WRITE options' section
|
||||
# below.
|
||||
|
||||
option WRITE_INT_FUNCTIONS disabled
|
||||
|
||||
# Error controls
|
||||
#
|
||||
# WARNINGS: normally on, if off no warnings are generated
|
||||
# ERROR_TEXT: normally on, if off errors happen but there is no message
|
||||
# ERROR_NUMBERS: unimplemented feature, therefore disabled
|
||||
# BENIGN_ERRORS: support for just issuing warnings for recoverable errors
|
||||
#
|
||||
# BENIGN_READ_ERRORS:
|
||||
# By default recoverable errors on read should just generate warnings,
|
||||
# generally safe but PNG files that don't conform to the specification will
|
||||
# be accepted if a meaningful result can be produced.
|
||||
#
|
||||
# BENIGN_WRITE_ERRORS:
|
||||
# By default recoverable errors on write should just generate warnings,
|
||||
# not generally safe because this allows the application to write invalid
|
||||
# PNG files. Applications should enable this themselves; it's useful
|
||||
# because it means that a failure to write an ancillary chunk can often be
|
||||
# ignored.
|
||||
|
||||
option WARNINGS
|
||||
option ERROR_TEXT
|
||||
option ERROR_NUMBERS disabled
|
||||
|
||||
option BENIGN_ERRORS
|
||||
option BENIGN_WRITE_ERRORS requires BENIGN_ERRORS disabled
|
||||
option BENIGN_READ_ERRORS requires BENIGN_ERRORS
|
||||
|
||||
|
||||
# Generic options - affect both read and write.
|
||||
|
||||
option MNG_FEATURES
|
||||
|
||||
# Arithmetic options, the first is the big switch that chooses between internal
|
||||
# floating and fixed point arithmetic implementations - it does not affect any
|
||||
# APIs. The second two (the _POINT settings) switch off individual APIs.
|
||||
#
|
||||
# Prior to libpng 1.6.8 one of the API (_POINT) variants had to be selected. At
|
||||
# 1.6.8 this restriction has been removed; the simplified API can be used
|
||||
# without enabling any of the low level fixed/floating APIs.
|
||||
|
||||
option FLOATING_ARITHMETIC
|
||||
option FLOATING_POINT
|
||||
option FIXED_POINT
|
||||
|
||||
# This protects us against compilers that run on a windowing system
|
||||
# and thus don't have or would rather us not use the stdio types:
|
||||
# stdin, stdout, and stderr. The only one currently used is stderr
|
||||
# in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will
|
||||
# prevent these from being compiled and used. #defining PNG_NO_STDIO
|
||||
# will also prevent these, plus will prevent the entire set of stdio
|
||||
# macros and functions (FILE *, printf, etc.) from being compiled and used,
|
||||
# unless (PNG_DEBUG > 0) has been #defined.
|
||||
|
||||
option STDIO
|
||||
option CONSOLE_IO requires STDIO
|
||||
|
||||
# Note: prior to 1.5.0 this option could not be disabled if STDIO
|
||||
# was enabled. Prior to 1.5.3 this option required STDIO
|
||||
|
||||
option TIME_RFC1123
|
||||
|
||||
# PNG_SETJMP_NOT_SUPPORTED is an old equivalent for NO_SETJMP
|
||||
|
||||
option SETJMP
|
||||
= NO_SETJMP SETJMP_NOT_SUPPORTED
|
||||
|
||||
# If this is disabled it is not possible for apps to get the
|
||||
# values from the 'info' structure, this effectively removes
|
||||
# quite a lot of the READ API.
|
||||
|
||||
option EASY_ACCESS
|
||||
|
||||
# Added at libpng-1.2.0
|
||||
|
||||
option USER_MEM
|
||||
|
||||
# Added at libpng-1.4.0
|
||||
|
||||
option IO_STATE
|
||||
|
||||
# Libpng limits: limit the size of images and data on read.
|
||||
#
|
||||
# If this option is disabled all the limit checking code will be disabled:
|
||||
|
||||
option USER_LIMITS requires READ
|
||||
|
||||
# The default settings given below for the limits mean that libpng will
|
||||
# limit the size of images or the size of data in ancillary chunks to less
|
||||
# than the specification or implementation limits. Settings have the
|
||||
# following interpretations:
|
||||
#
|
||||
# USER_WIDTH_MAX: maximum width of an image that will be read
|
||||
# USER_HEIGHT_MAX: maximum height
|
||||
# USER_CHUNK_MALLOC_MAX: maximum in-memory (decompressed) size of a single chunk
|
||||
# USER_CHUNK_CACHE_MAX: maximum number of chunks to be cached
|
||||
#
|
||||
# Only chunks that are variable in number are counted towards the
|
||||
|
||||
# Use 0x7fffffff for unlimited
|
||||
setting USER_WIDTH_MAX default 1000000
|
||||
setting USER_HEIGHT_MAX default 1000000
|
||||
|
||||
# Use 0 for unlimited
|
||||
setting USER_CHUNK_CACHE_MAX default 1000
|
||||
setting USER_CHUNK_MALLOC_MAX default 8000000
|
||||
|
||||
# If this option is enabled APIs to set the above limits at run time are added;
|
||||
# without this the hardwired (compile time) limits will be used.
|
||||
option SET_USER_LIMITS requires USER_LIMITS
|
||||
|
||||
# All of the following options relate to code capabilities for
|
||||
# processing image data before creating a PNG or after reading one.
|
||||
# You can remove these capabilities safely and still be PNG
|
||||
# conformant, however the library that results is still non-standard.
|
||||
# See the comments above about how to change options and settings.
|
||||
|
||||
# READ options
|
||||
#
|
||||
# WARNING: in libpng 1.5 maintained configuration compatibility with earlier
|
||||
# versions. In some cases turning off an option turned off other options, in
|
||||
# others it was ineffective unless dependent options were also turned off.
|
||||
# Libpng 1.6 changes this: in general if you turn off an option that affects
|
||||
# APIs it stays off and simply disables APIs that depend on it.
|
||||
#
|
||||
# As a result if you simply port the libpng 1.5 configuration to libpng 1.6 you
|
||||
# will probably see build failures due to missing APIs. Fixing these failures
|
||||
# requires some, perhaps considerable, knowledge of what your libpng using
|
||||
# applications are doing, fortunately there is no great reason for you to move
|
||||
# to libpng 1.6; the new interfaces in 1.6 will take several years to become
|
||||
# popular.
|
||||
|
||||
option READ enables READ_INTERLACING SET_OPTION
|
||||
|
||||
# Disabling READ_16BIT does not disable reading 16-bit PNG files, but it
|
||||
# forces them to be chopped down to 8-bit, and disables any 16-bit
|
||||
# processing after that has happened. You need to be sure to enable
|
||||
# READ_SCALE_16_TO_8 or READ_STRIP_16_TO_8 when you disable READ_16BIT for
|
||||
# this to work properly. You should disable the other option if you need to
|
||||
# ensure a particular conversion (otherwise the app can chose.)
|
||||
|
||||
option READ_16BIT requires READ enables 16BIT
|
||||
|
||||
option READ_QUANTIZE requires READ
|
||||
|
||||
option READ_TRANSFORMS requires READ
|
||||
= NO_READ_TRANSFORMS READ_TRANSFORMS_NOT_SUPPORTED
|
||||
|
||||
# Read gamma handling. Gamma processing is a core part of libpng and many of
|
||||
# the capabilities are dependent on libpng performing gamma correction.
|
||||
#
|
||||
# In libpng 1.6 disabling gamma processing (setting PNG_NO_READ_GAMMA)
|
||||
# consistently disables those parts of the API that depend on it. Prior to
|
||||
# 1.6.0 this was not true; the results were unpredictable and varied between
|
||||
# releases.
|
||||
#
|
||||
# If you disable gamma processing and your program no longer compiles you need
|
||||
# to ask whether you really need the APIs that are missing. If you do then you
|
||||
# almost certainly need the gamma processing.
|
||||
#
|
||||
# If you handle gamma issues outside libpng then you do not need the libpng
|
||||
# gamma processing; and it is an enormous waste of space. You just need to
|
||||
# remove the use of libpng APIs that depend on it.
|
||||
option READ_GAMMA requires READ_TRANSFORMS, READ_gAMA, READ_sRGB
|
||||
|
||||
option READ_ALPHA_MODE requires READ_TRANSFORMS, READ_GAMMA
|
||||
option READ_BACKGROUND requires READ_TRANSFORMS, READ_STRIP_ALPHA, READ_GAMMA
|
||||
option READ_BGR requires READ_TRANSFORMS
|
||||
option READ_EXPAND_16 requires READ_TRANSFORMS, READ_16BIT, READ_EXPAND
|
||||
option READ_EXPAND requires READ_TRANSFORMS
|
||||
option READ_FILLER requires READ_TRANSFORMS
|
||||
option READ_GRAY_TO_RGB requires READ_TRANSFORMS
|
||||
option READ_INVERT_ALPHA requires READ_TRANSFORMS
|
||||
option READ_INVERT requires READ_TRANSFORMS
|
||||
option READ_PACK requires READ_TRANSFORMS
|
||||
option READ_PACKSWAP requires READ_TRANSFORMS
|
||||
option READ_RGB_TO_GRAY requires READ_TRANSFORMS, READ_GAMMA enables COLORSPACE
|
||||
option READ_SCALE_16_TO_8 requires READ_TRANSFORMS
|
||||
option READ_SHIFT requires READ_TRANSFORMS
|
||||
option READ_STRIP_16_TO_8 requires READ_TRANSFORMS
|
||||
option READ_STRIP_ALPHA requires READ_TRANSFORMS
|
||||
option READ_SWAP_ALPHA requires READ_TRANSFORMS
|
||||
option READ_SWAP requires READ_TRANSFORMS, READ_16BIT
|
||||
option READ_USER_TRANSFORM requires READ_TRANSFORMS
|
||||
|
||||
option PROGRESSIVE_READ requires READ
|
||||
option SEQUENTIAL_READ requires READ
|
||||
|
||||
# You can define PNG_NO_PROGRESSIVE_READ if you don't do progressive reading.
|
||||
# This is not talking about interlacing capability! You'll still have
|
||||
# interlacing unless you turn off the following which is required
|
||||
# for PNG-compliant decoders. (In other words, do not do this - in
|
||||
# fact it can't be disabled from the command line!)
|
||||
#option READ_INTERLACING requires READ
|
||||
|
||||
option READ_COMPOSITE_NODIV requires READ
|
||||
= NO_READ_COMPOSITE_NODIV NO_READ_COMPOSITED_NODIV
|
||||
|
||||
# Inch conversions
|
||||
|
||||
option INCH_CONVERSIONS
|
||||
= INCH_CONVERSIONS INCH_CONVERSIONS
|
||||
|
||||
# API to build a grayscale palette
|
||||
# NOTE: this is not used internally by libpng at present.
|
||||
|
||||
option BUILD_GRAYSCALE_PALETTE
|
||||
|
||||
# WRITE options
|
||||
|
||||
option WRITE enables WRITE_INT_FUNCTIONS
|
||||
|
||||
# Disabling WRITE_16BIT prevents 16-bit PNG files from being
|
||||
# generated.
|
||||
option WRITE_16BIT requires WRITE enables 16BIT
|
||||
|
||||
option WRITE_TRANSFORMS requires WRITE
|
||||
= NO_WRITE_TRANSFORMS WRITE_TRANSFORMS_NOT_SUPPORTED
|
||||
|
||||
option WRITE_SHIFT requires WRITE_TRANSFORMS
|
||||
option WRITE_PACK requires WRITE_TRANSFORMS
|
||||
option WRITE_BGR requires WRITE_TRANSFORMS
|
||||
option WRITE_SWAP requires WRITE_TRANSFORMS, WRITE_16BIT
|
||||
option WRITE_PACKSWAP requires WRITE_TRANSFORMS
|
||||
option WRITE_INVERT requires WRITE_TRANSFORMS
|
||||
option WRITE_FILLER requires WRITE_TRANSFORMS
|
||||
option WRITE_SWAP_ALPHA requires WRITE_TRANSFORMS
|
||||
option WRITE_INVERT_ALPHA requires WRITE_TRANSFORMS
|
||||
option WRITE_USER_TRANSFORM requires WRITE_TRANSFORMS
|
||||
|
||||
# This is not required for PNG-compliant encoders, but can cause
|
||||
# trouble if left undefined
|
||||
|
||||
option WRITE_INTERLACING requires WRITE
|
||||
|
||||
# Deprecated, will be removed.
|
||||
option WRITE_WEIGHTED_FILTER requires WRITE
|
||||
|
||||
option WRITE_FLUSH requires WRITE
|
||||
|
||||
# Note: these can be turned off explicitly if not required by the
|
||||
# apps implementing the user transforms
|
||||
option USER_TRANSFORM_PTR if READ_USER_TRANSFORM, WRITE_USER_TRANSFORM
|
||||
option USER_TRANSFORM_INFO if READ_USER_TRANSFORM, WRITE_USER_TRANSFORM
|
||||
|
||||
# This enables API to set compression parameters for compressing
|
||||
# non-IDAT chunks (zTXt, iTXt, iCCP, and unknown chunks). This feature
|
||||
# was added at libpng-1.5.3.
|
||||
option WRITE_CUSTOMIZE_ZTXT_COMPRESSION requires WRITE
|
||||
option WRITE_CUSTOMIZE_COMPRESSION requires WRITE
|
||||
|
||||
# Any chunks you are not interested in, you can undef here. The
|
||||
# ones that allocate memory may be especially important (hIST,
|
||||
# tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info
|
||||
# a bit smaller.
|
||||
|
||||
# The size of the png_text structure changed in libpng-1.0.6 when
|
||||
# iTXt support was added. iTXt support was turned off by default through
|
||||
# libpng-1.2.x, to support old apps that malloc the png_text structure
|
||||
# instead of calling png_set_text() and letting libpng malloc it. It
|
||||
# was turned on by default in libpng-1.4.0.
|
||||
|
||||
option READ_ANCILLARY_CHUNKS requires READ
|
||||
# PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED is deprecated.
|
||||
= NO_READ_ANCILLARY_CHUNKS READ_ANCILLARY_CHUNKS_NOT_SUPPORTED
|
||||
|
||||
option WRITE_ANCILLARY_CHUNKS requires WRITE
|
||||
# PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED is deprecated.
|
||||
= NO_WRITE_ANCILLARY_CHUNKS WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED
|
||||
|
||||
# These options disable *all* the text chunks if turned off
|
||||
|
||||
option TEXT disabled
|
||||
option READ_TEXT requires READ_ANCILLARY_CHUNKS enables TEXT
|
||||
option WRITE_TEXT requires WRITE_ANCILLARY_CHUNKS enables TEXT
|
||||
|
||||
# Moved to pnglibconf.h at libpng-1.5.0
|
||||
# Feature support: in 1.4 this was in pngconf.h, but the following
|
||||
# features have no affect on the libpng API. Add library
|
||||
# only features to the end of this list. Add features that
|
||||
# affect the API above. (Note: the list of chunks follows
|
||||
# the library-only settings.)
|
||||
#
|
||||
# BUILD TIME ONLY OPTIONS
|
||||
# These options do not affect the API but rather alter how the
|
||||
# API is implemented, they get recorded in pnglibconf.h, but
|
||||
# can't be changed by the application.
|
||||
|
||||
# Colorspace support (enabled as required); just the support for colorant
|
||||
# information. Gamma support, likewise, is just support for the gamma
|
||||
# information, READ_GAMMA is required for gamma transformations (so it
|
||||
# is possible to read PNG gamma without enabling all the libpng transform
|
||||
# code - do this for applications that do their own gamma processing)
|
||||
#
|
||||
# As of 1.6.0 COLORSPACE is only useful if the application processes the
|
||||
# information; this is because the library does not do any colorspace
|
||||
# processing, it just validates the data in the PNG file.
|
||||
|
||||
option GAMMA disabled
|
||||
option COLORSPACE enables GAMMA disabled
|
||||
|
||||
# When an ICC profile is read, or png_set, it will be checked for a match
|
||||
# against known sRGB profiles if the sRGB handling is enabled. The
|
||||
# PNG_sRGB_PROFILE_CHECKS setting controls how much work is done during the
|
||||
# check:
|
||||
#
|
||||
# -1: Don't do any sRGB profile checking.
|
||||
#
|
||||
# 0: Just validate the profile MD5 signature if present, otherwise use
|
||||
# the checks in option 1.
|
||||
#
|
||||
# 1: Additionally check the length, intent and adler32 checksum of the
|
||||
# actual data. If enabled this will reject known profiles that have
|
||||
# had the rendering intent in the header changed as well as other edits
|
||||
# done without updating the checksum. See the discussion below.
|
||||
#
|
||||
# 2: Additionally checksum all the data using the ethernet CRC32 algorithm.
|
||||
# This makes it more difficult to fake profiles and makes it less likely
|
||||
# to get a false positive on profiles with no signature, but is probably
|
||||
# just a waste of time since all currently approved ICC sRGB profiles have
|
||||
# a secure MD5 signature.
|
||||
#
|
||||
# The rendering intent. An ICC profile stores an intended rendering intent,
|
||||
# but does not include the value in the signature. The intent is documented
|
||||
# as the intent that should be used when combining two profiles. The sRGB
|
||||
# profile is intended, however, to be used with any of the four defined intents.
|
||||
# For this reason the sRGB chunk includes an 'intent' to be used when displaying
|
||||
# the image (intent is really a property of the image not the profile.)
|
||||
#
|
||||
# Unfortunately the iCCP chunk does not. It may therefore be that some
|
||||
# applications modify the intent in profiles (including sRGB profiles) to work
|
||||
# round this problem. Selecting an option other than option '0' will cause such
|
||||
# modified profiles to be rejected.
|
||||
#
|
||||
# Security. The use of Adler32 and CRC32 checksums does not help significantly
|
||||
# with any security issues. It is relatively easy to produce arbitrary profiles
|
||||
# with the required checksums on current computer systems. Nevertheless
|
||||
# security does not seem to be an issue because the only consequence of a false
|
||||
# positive is a false assertion that the profile is an sRGB profile. This might
|
||||
# be used to hide data from libpng using applications, but it doesn't seem
|
||||
# possible to damage them.
|
||||
|
||||
setting sRGB_PROFILE_CHECKS default 2
|
||||
|
||||
# Artificially align memory - the code typically aligns to 8 byte
|
||||
# boundaries if this is switched on, it's a small waste of space
|
||||
# but can help (in theory) on some architectures. Only affects
|
||||
# internal structures. Added at libpng 1.4.0
|
||||
|
||||
option ALIGNED_MEMORY
|
||||
|
||||
# Buggy compilers (e.g., gcc 2.7.2.2) need PNG_NO_POINTER_INDEXING
|
||||
# See png[wr]util.c, normally this should always be *on*
|
||||
|
||||
option POINTER_INDEXING
|
||||
|
||||
# Other defines for things like memory and the like can go here.
|
||||
|
||||
# BUILD TIME SETTINGS
|
||||
# Like build time options these do not affect the API, but they
|
||||
# may be useful to applications because they record details of
|
||||
# how the API will behave particularly with regard to overall
|
||||
# accuracy.
|
||||
|
||||
# This controls how fine the quantizing gets. As this allocates
|
||||
# a largish chunk of memory (32K), those who are not as concerned
|
||||
# with quantizing quality can decrease some or all of these.
|
||||
|
||||
setting QUANTIZE_RED_BITS default 5
|
||||
setting QUANTIZE_GREEN_BITS default 5
|
||||
setting QUANTIZE_BLUE_BITS default 5
|
||||
|
||||
# This controls how fine the gamma correction becomes when you
|
||||
# are only interested in 8 bits anyway. Increasing this value
|
||||
# results in more memory being used, and more pow() functions
|
||||
# being called to fill in the gamma tables. Don't set this value
|
||||
# less than 8, and even that may not work (I haven't tested it).
|
||||
|
||||
setting MAX_GAMMA_8 default 11
|
||||
|
||||
# This controls how much a difference in gamma we can tolerate before
|
||||
# we actually start doing gamma conversion, it's a fixed point value,
|
||||
# so the default below is 0.05, meaning libpng ignores corrections in
|
||||
# the range 0.95 to 1.05
|
||||
|
||||
setting GAMMA_THRESHOLD_FIXED default 5000
|
||||
|
||||
# Precision to use when converting a floating point value to a PNG
|
||||
# extension format string in an sCAL chunk (only relevant if the
|
||||
# floating point API is enabled)
|
||||
|
||||
setting sCAL_PRECISION default 5
|
||||
|
||||
# This is the size of the compression buffer, and thus the size of
|
||||
# an IDAT chunk. Make this whatever size you feel is best for your
|
||||
# machine. One of these will be allocated per png_struct. When this
|
||||
# is full, it writes the data to the disk, and does some other
|
||||
# calculations. Making this an extremely small size may slow
|
||||
# the library down, but you may want to experiment to determine
|
||||
# where it becomes significant, if you are concerned with memory
|
||||
# usage. Note that zlib allocates at least 32Kb also. For readers,
|
||||
# this describes the size of the buffer available to read the data in.
|
||||
# Unless this gets smaller than the size of a row (compressed),
|
||||
# it should not make much difference how big this is.
|
||||
|
||||
setting ZBUF_SIZE default 8192
|
||||
|
||||
# This is the size of the decompression buffer used when counting or checking
|
||||
# the decompressed size of an LZ stream from a compressed ancillary chunk; the
|
||||
# decompressed data is never used so a different size may be optimal. This size
|
||||
# was determined using contrib/libtests/timepng.c with compressed zTXt data
|
||||
# around 11MByte in size. Slight speed improvements (up to about 14% in
|
||||
# timepng) can be achieved by very large increases (to 32kbyte) on regular data,
|
||||
# but highly compressible data shows only around 2% improvement. The size is
|
||||
# chosen to minimize the effects of DoS attacks based on using very large
|
||||
# amounts of highly compressible data.
|
||||
|
||||
setting INFLATE_BUF_SIZE default 1024
|
||||
|
||||
# This is the maximum amount of IDAT data that the sequential reader will
|
||||
# process at one time. The setting does not affect the size of IDAT chunks
|
||||
# read, just the amount read at once. Neither does it affect the progressive
|
||||
# reader, which processes just the amount of data the application gives it.
|
||||
# The sequential reader is currently unable to process more than one IDAT at
|
||||
# once - it has to read and process each one in turn. There is no point setting
|
||||
# this to a value larger than the IDAT chunks typically encountered (it would
|
||||
# just waste memory) but there may be some point in reducing it below the value
|
||||
# of ZBUF_SIZE (the size of IDAT chunks written by libpng.)
|
||||
|
||||
setting IDAT_READ_SIZE default PNG_ZBUF_SIZE
|
||||
|
||||
# Ancillary chunks
|
||||
chunk bKGD
|
||||
chunk cHRM enables COLORSPACE
|
||||
chunk eXIf
|
||||
chunk gAMA enables GAMMA
|
||||
chunk hIST
|
||||
chunk iCCP enables COLORSPACE, GAMMA
|
||||
chunk iTXt enables TEXT
|
||||
chunk oFFs
|
||||
chunk pCAL
|
||||
chunk pHYs
|
||||
chunk sBIT
|
||||
chunk sCAL
|
||||
chunk sPLT
|
||||
chunk sRGB enables COLORSPACE, GAMMA, SET_OPTION
|
||||
chunk tEXt requires TEXT
|
||||
chunk tIME
|
||||
chunk tRNS
|
||||
chunk zTXt enables TEXT
|
||||
|
||||
# This only affects support of the optional PLTE chunk in RGB and RGBA
|
||||
# images. Notice that READ_ANCILLARY_CHUNKS therefore disables part
|
||||
# of the regular chunk reading too.
|
||||
|
||||
option READ_OPT_PLTE requires READ_ANCILLARY_CHUNKS
|
||||
|
||||
# Unknown chunk handling
|
||||
#
|
||||
# 'UNKNOWN_CHUNKS' is a global option to disable all unknown chunk handling on
|
||||
# read or write; everything else below requires it (directly or indirectly).
|
||||
option UNKNOWN_CHUNKS
|
||||
|
||||
# There are three main options to control the ability to read and write unknown
|
||||
# chunks. If either read option is turned on then unknown chunks will be read,
|
||||
# otherwise they are skipped. If the write option is turned on unknown chunks
|
||||
# set by png_set_unknown_chunks will be written otherwise it is an error to call
|
||||
# that API on a write struct.
|
||||
option WRITE_UNKNOWN_CHUNKS requires WRITE requires UNKNOWN_CHUNKS
|
||||
option WRITE_UNKNOWN_CHUNKS enables STORE_UNKNOWN_CHUNKS
|
||||
|
||||
# The first way to read user chunks is to have libpng save them for a later call
|
||||
# to png_get_unknown_chunks, the application must call
|
||||
# png_set_keep_unknown_chunks to cause this to actually happen (see png.h)
|
||||
option SAVE_UNKNOWN_CHUNKS requires READ requires SET_UNKNOWN_CHUNKS
|
||||
option SAVE_UNKNOWN_CHUNKS enables READ_UNKNOWN_CHUNKS, STORE_UNKNOWN_CHUNKS
|
||||
|
||||
# The second approach is to use an application provided callback to process the
|
||||
# chunks, the callback can either handle the chunk entirely itself or request
|
||||
# that libpng store the chunk for later retrieval via png_get_unknown_chunks.
|
||||
#
|
||||
# NOTE: If STORE_UNKNOWN_CHUNKS is not enabled (which is the default if
|
||||
# both SAVE_UNKNOWN_CHUNKS and WRITE_UNKNOWN_CHUNKS are disabled) then a
|
||||
# 0 result from the callback will be ignored because no support for saving
|
||||
# unknown chunks has been compiled in. The normal symptom is that your app
|
||||
# fails to compile because png_get_unknown_chunks is no longer defined in png.h.
|
||||
# If you encounter this issue simply enable STORE_UNKNOWN_CHUNKS in your build.
|
||||
#
|
||||
# Note that there is no 'WRITE_USER_CHUNKS' so the USER_CHUNKS option is always
|
||||
# the same as READ_USER_CHUNKS at present
|
||||
option READ_USER_CHUNKS requires READ, UNKNOWN_CHUNKS
|
||||
option READ_USER_CHUNKS enables READ_UNKNOWN_CHUNKS, USER_CHUNKS
|
||||
|
||||
# Two further options are provided to allow detailed control of the handling.
|
||||
# The first enables png_set_keep_unknown_chunks; this allows the default to be
|
||||
# changed from discarding unknown chunks and allows per-chunk control. This is
|
||||
# required to use the SAVE_UNKNOWN_CHUNKS option. If enabled this option also
|
||||
# applies to write (see png.h), otherwise the write API simply writes all the
|
||||
# chunks it is given.
|
||||
#
|
||||
# The second option extends the unknown handling to allow known chunks to be
|
||||
# handled as though they were unknown. This option doesn't change any APIs, it
|
||||
# merely turns on the code to check known as well as unknown chunks.
|
||||
#
|
||||
# This option no longer affects the write code. It can be safely disabled and
|
||||
# will prevent applications stopping libpng reading known chunks.
|
||||
option SET_UNKNOWN_CHUNKS requires UNKNOWN_CHUNKS
|
||||
option HANDLE_AS_UNKNOWN requires SET_UNKNOWN_CHUNKS
|
||||
|
||||
# The following options are derived from the above and should not be turned on
|
||||
# explicitly.
|
||||
option READ_UNKNOWN_CHUNKS requires UNKNOWN_CHUNKS disabled
|
||||
option STORE_UNKNOWN_CHUNKS requires UNKNOWN_CHUNKS disabled
|
||||
|
||||
option CONVERT_tIME requires WRITE_ANCILLARY_CHUNKS
|
||||
# The "tm" structure is not supported on WindowsCE
|
||||
|
||||
@#ifdef _WIN32_WCE
|
||||
@# define PNG_NO_CONVERT_tIME
|
||||
@#endif
|
||||
|
||||
option WRITE_FILTER requires WRITE
|
||||
|
||||
option SAVE_INT_32 disabled
|
||||
# png_save_int_32 is required internally for writing the ancillary chunks oFFs
|
||||
# and pCAL and for both reading and writing iCCP (for the generation/checking of
|
||||
# the corresponding cHRM/gAMA chunks) if full ICC is supported.
|
||||
|
||||
# added at libpng-1.5.4
|
||||
|
||||
option WRITE_OPTIMIZE_CMF requires WRITE
|
||||
|
||||
option READ_COMPRESSED_TEXT disabled
|
||||
option READ_iCCP enables READ_COMPRESSED_TEXT
|
||||
option READ_iTXt enables READ_COMPRESSED_TEXT
|
||||
option READ_zTXt enables READ_COMPRESSED_TEXT
|
||||
|
||||
option WRITE_oFFs enables SAVE_INT_32
|
||||
option WRITE_pCAL enables SAVE_INT_32
|
||||
option WRITE_cHRM enables SAVE_INT_32
|
||||
|
||||
option WRITE_COMPRESSED_TEXT disabled
|
||||
option WRITE_iCCP enables WRITE_COMPRESSED_TEXT
|
||||
option WRITE_iTXt enables WRITE_COMPRESSED_TEXT
|
||||
option WRITE_zTXt enables WRITE_COMPRESSED_TEXT
|
||||
|
||||
# Turn this off to disable png_read_png() and png_write_png() and
|
||||
# leave the row_pointers member out of the info structure.
|
||||
|
||||
option INFO_IMAGE
|
||||
|
||||
# added at libpng-1.5.10
|
||||
# Turn this off to disable warning about invalid palette index and
|
||||
# leave the num_palette_max member out of the png structure.
|
||||
|
||||
option CHECK_FOR_INVALID_INDEX enables READ_CHECK_FOR_INVALID_INDEX
|
||||
option CHECK_FOR_INVALID_INDEX enables WRITE_CHECK_FOR_INVALID_INDEX
|
||||
option READ_CHECK_FOR_INVALID_INDEX requires READ, CHECK_FOR_INVALID_INDEX
|
||||
option WRITE_CHECK_FOR_INVALID_INDEX requires WRITE, CHECK_FOR_INVALID_INDEX
|
||||
|
||||
# added at libpng-1.5.15
|
||||
option GET_PALETTE_MAX enables READ_GET_PALETTE_MAX WRITE_GET_PALETTE_MAX
|
||||
option READ_GET_PALETTE_MAX requires READ_CHECK_FOR_INVALID_INDEX disabled
|
||||
option WRITE_GET_PALETTE_MAX requires WRITE_CHECK_FOR_INVALID_INDEX disabled
|
||||
|
||||
# Simplified API options (added at libpng-1.6.0)
|
||||
# In libpng 1.6.8 the handling of these options was changed to used 'requires'
|
||||
# throughout, so that disabling some of the low level support always disables
|
||||
# the base simplified read/write API. This much simplifies the handling and
|
||||
# makes 'everything = off' work in a more intuitive way. It eliminates a
|
||||
# previously reported feature that APIs previously enabled by the simplified
|
||||
# API couldn't be turned off without explicitly turning off the simplified
|
||||
# APIs.
|
||||
#
|
||||
# Read:
|
||||
option SIMPLIFIED_READ,
|
||||
requires SEQUENTIAL_READ, READ_TRANSFORMS, SETJMP, BENIGN_ERRORS,
|
||||
READ_EXPAND, READ_16BIT, READ_EXPAND_16, READ_SCALE_16_TO_8,
|
||||
READ_RGB_TO_GRAY, READ_ALPHA_MODE, READ_BACKGROUND, READ_STRIP_ALPHA,
|
||||
READ_FILLER, READ_SWAP, READ_PACK, READ_GRAY_TO_RGB, READ_GAMMA,
|
||||
READ_tRNS, READ_bKGD, READ_gAMA, READ_cHRM, READ_sRGB, READ_sBIT
|
||||
|
||||
# AFIRST and BGR read options:
|
||||
# Prior to libpng 1.6.8 these were disabled but switched on if the low level
|
||||
# libpng routines that do the swaps were enabled. This worked but was
|
||||
# confusing. In libpng 1.6.8 the options were changed to simple 'requires'
|
||||
# and are enabled by default. This should work the same way in practice.
|
||||
option SIMPLIFIED_READ_AFIRST enables FORMAT_AFIRST,
|
||||
requires SIMPLIFIED_READ READ_SWAP_ALPHA
|
||||
|
||||
option SIMPLIFIED_READ_BGR enables FORMAT_BGR,
|
||||
requires SIMPLIFIED_READ READ_BGR
|
||||
|
||||
# Write:
|
||||
option SIMPLIFIED_WRITE,
|
||||
requires WRITE, SETJMP, WRITE_SWAP, WRITE_PACK,
|
||||
WRITE_tRNS, WRITE_gAMA, WRITE_sRGB, WRITE_cHRM
|
||||
|
||||
# 1.6.22: allow simplified write without stdio support:
|
||||
option SIMPLIFIED_WRITE_STDIO requires SIMPLIFIED_WRITE STDIO
|
||||
|
||||
option SIMPLIFIED_WRITE_AFIRST enables FORMAT_AFIRST,
|
||||
requires SIMPLIFIED_WRITE WRITE_SWAP_ALPHA
|
||||
|
||||
option SIMPLIFIED_WRITE_BGR enables FORMAT_BGR,
|
||||
requires SIMPLIFIED_WRITE WRITE_BGR
|
||||
|
||||
# Formats:
|
||||
option FORMAT_AFIRST disabled
|
||||
option FORMAT_BGR disabled
|
@ -1,220 +0,0 @@
|
||||
/* libpng 1.6.34 STANDARD API DEFINITION */
|
||||
|
||||
/* pnglibconf.h - library build configuration */
|
||||
|
||||
/* Libpng version 1.6.34 - September 29, 2017 */
|
||||
|
||||
/* Copyright (c) 1998-2017 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 */
|
||||
#ifndef PNGLCONF_H
|
||||
#define PNGLCONF_H
|
||||
/* options */
|
||||
#define PNG_16BIT_SUPPORTED
|
||||
#define PNG_ALIGNED_MEMORY_SUPPORTED
|
||||
/*#undef PNG_ARM_NEON_API_SUPPORTED*/
|
||||
/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/
|
||||
/*#undef PNG_POWERPC_VSX_API_SUPPORTED*/
|
||||
/*#undef PNG_POWERPC_VSX_CHECK_SUPPORTED*/
|
||||
#define PNG_BENIGN_ERRORS_SUPPORTED
|
||||
#define PNG_BENIGN_READ_ERRORS_SUPPORTED
|
||||
/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/
|
||||
#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
|
||||
#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
#define PNG_COLORSPACE_SUPPORTED
|
||||
#define PNG_CONSOLE_IO_SUPPORTED
|
||||
#define PNG_CONVERT_tIME_SUPPORTED
|
||||
#define PNG_EASY_ACCESS_SUPPORTED
|
||||
/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
|
||||
#define PNG_ERROR_TEXT_SUPPORTED
|
||||
#define PNG_FIXED_POINT_SUPPORTED
|
||||
#define PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
#define PNG_FLOATING_POINT_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_INCH_CONVERSIONS_SUPPORTED
|
||||
#define PNG_INFO_IMAGE_SUPPORTED
|
||||
#define PNG_IO_STATE_SUPPORTED
|
||||
#define PNG_MNG_FEATURES_SUPPORTED
|
||||
#define PNG_POINTER_INDEXING_SUPPORTED
|
||||
#define PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
#define PNG_READ_16BIT_SUPPORTED
|
||||
#define PNG_READ_ALPHA_MODE_SUPPORTED
|
||||
#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#define PNG_READ_BACKGROUND_SUPPORTED
|
||||
#define PNG_READ_BGR_SUPPORTED
|
||||
#define PNG_READ_CHECK_FOR_INVALID_INDEX_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_GAMMA_SUPPORTED
|
||||
#define PNG_READ_GET_PALETTE_MAX_SUPPORTED
|
||||
#define PNG_READ_GRAY_TO_RGB_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_OPT_PLTE_SUPPORTED
|
||||
#define PNG_READ_PACKSWAP_SUPPORTED
|
||||
#define PNG_READ_PACK_SUPPORTED
|
||||
#define PNG_READ_QUANTIZE_SUPPORTED
|
||||
#define PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
#define PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
#define PNG_READ_SHIFT_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_TRANSFORMS_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_eXIf_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_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
#define PNG_SETJMP_SUPPORTED
|
||||
#define PNG_SET_OPTION_SUPPORTED
|
||||
#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_SET_USER_LIMITS_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_STDIO_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||
#define PNG_STDIO_SUPPORTED
|
||||
#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_TEXT_SUPPORTED
|
||||
#define PNG_TIME_RFC1123_SUPPORTED
|
||||
#define PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_USER_CHUNKS_SUPPORTED
|
||||
#define PNG_USER_LIMITS_SUPPORTED
|
||||
#define PNG_USER_MEM_SUPPORTED
|
||||
#define PNG_USER_TRANSFORM_INFO_SUPPORTED
|
||||
#define PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
#define PNG_WARNINGS_SUPPORTED
|
||||
#define PNG_WRITE_16BIT_SUPPORTED
|
||||
#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#define PNG_WRITE_BGR_SUPPORTED
|
||||
#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_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_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_eXIf_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_pCAL_SUPPORTED
|
||||
#define PNG_WRITE_pHYs_SUPPORTED
|
||||
#define PNG_WRITE_sBIT_SUPPORTED
|
||||
#define PNG_WRITE_sCAL_SUPPORTED
|
||||
#define PNG_WRITE_sPLT_SUPPORTED
|
||||
#define PNG_WRITE_sRGB_SUPPORTED
|
||||
#define PNG_WRITE_tEXt_SUPPORTED
|
||||
#define PNG_WRITE_tIME_SUPPORTED
|
||||
#define PNG_WRITE_tRNS_SUPPORTED
|
||||
#define PNG_WRITE_zTXt_SUPPORTED
|
||||
#define PNG_bKGD_SUPPORTED
|
||||
#define PNG_cHRM_SUPPORTED
|
||||
#define PNG_eXIf_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 */
|
@ -1,24 +0,0 @@
|
||||
|
||||
/* prefix.c - generate an unprefixed symbol list
|
||||
*
|
||||
* Last changed in libpng version 1.6.16 [December 22, 2014]
|
||||
* Copyright (c) 2013-2014 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
|
||||
*/
|
||||
|
||||
#define PNG_EXPORTA(ordinal, type, name, args, attributes)\
|
||||
PNG_DFN "@" name "@"
|
||||
|
||||
/* The configuration information *before* the additional of symbol renames,
|
||||
* the list is the C name list; no symbol prefix.
|
||||
*/
|
||||
#include "pnglibconf.out"
|
||||
|
||||
PNG_DFN_START_SORT 1
|
||||
|
||||
#include "../png.h"
|
||||
|
||||
PNG_DFN_END_SORT
|
@ -1,15 +0,0 @@
|
||||
|
||||
/* sym.c - define format of libpng.sym
|
||||
*
|
||||
* Last changed in libpng version 1.6.16 [December 22, 2014]
|
||||
* Copyright (c) 2011-2014 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
|
||||
*/
|
||||
|
||||
#define PNG_EXPORTA(ordinal, type, name, args, attributes)\
|
||||
PNG_DFN "@" SYMBOL_PREFIX "@@" name "@"
|
||||
|
||||
#include "../png.h"
|
@ -1,58 +0,0 @@
|
||||
|
||||
/* symbols.c - find all exported symbols
|
||||
*
|
||||
* Last changed in libpng version 1.6.16 [December 22, 2014]
|
||||
* Copyright (c) 2011-2014 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
|
||||
*/
|
||||
|
||||
/* NOTE: making 'symbols.chk' checks both that the exported
|
||||
* symbols in the library don't change and (implicitly) that
|
||||
* scripts/pnglibconf.h.prebuilt is as expected.
|
||||
* If scripts/pnglibconf.h.prebuilt is remade using
|
||||
* scripts/pnglibconf.dfa then this checks the .dfa file too.
|
||||
*/
|
||||
|
||||
#define PNG_EXPORTA(ordinal, type, name, args, attributes)\
|
||||
PNG_DFN "@" name "@ @@" ordinal "@"
|
||||
#define PNG_REMOVED(ordinal, type, name, args, attributes)\
|
||||
PNG_DFN "; @" name "@ @@" ordinal "@"
|
||||
#define PNG_EXPORT_LAST_ORDINAL(ordinal)\
|
||||
PNG_DFN "; @@" ordinal "@"
|
||||
|
||||
/* Read the defaults, but use scripts/pnglibconf.h.prebuilt; the 'standard'
|
||||
* header file.
|
||||
*/
|
||||
#include "pnglibconf.h.prebuilt"
|
||||
#include "../png.h"
|
||||
|
||||
/* Some things are turned off by default. Turn these things
|
||||
* on here (by hand) to get the APIs they expose and validate
|
||||
* that no harm is done. This list is the set of options
|
||||
* defaulted to 'off' in scripts/pnglibconf.dfa
|
||||
*
|
||||
* Maintenance: if scripts/pnglibconf.dfa options are changed
|
||||
* from, or to, 'disabled' this needs updating!
|
||||
*/
|
||||
#define PNG_BENIGN_ERRORS_SUPPORTED
|
||||
#define PNG_ERROR_NUMBERS_SUPPORTED
|
||||
#define PNG_READ_BIG_ENDIAN_SUPPORTED /* should do nothing! */
|
||||
#define PNG_INCH_CONVERSIONS_SUPPORTED
|
||||
#define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
|
||||
#define PNG_SET_OPTION_SUPPORTED
|
||||
|
||||
#undef PNG_H
|
||||
#include "../png.h"
|
||||
|
||||
/* Finally there are a couple of places where option support
|
||||
* actually changes the APIs revealed using a #if/#else/#endif
|
||||
* test in png.h, test these here.
|
||||
*/
|
||||
#undef PNG_FLOATING_POINT_SUPPORTED /* Exposes 'fixed' APIs */
|
||||
#undef PNG_ERROR_TEXT_SUPPORTED /* Exposes unsupported APIs */
|
||||
|
||||
#undef PNG_H
|
||||
#include "../png.h"
|
@ -1,256 +0,0 @@
|
||||
;Version 1.6.35beta02
|
||||
;--------------------------------------------------------------
|
||||
; LIBPNG symbol list as a Win32 DEF file
|
||||
; Contains all the symbols that can be exported from libpng
|
||||
;--------------------------------------------------------------
|
||||
LIBRARY
|
||||
|
||||
EXPORTS
|
||||
png_access_version_number @1
|
||||
png_set_sig_bytes @2
|
||||
png_sig_cmp @3
|
||||
png_create_read_struct @4
|
||||
png_create_write_struct @5
|
||||
png_get_compression_buffer_size @6
|
||||
png_set_compression_buffer_size @7
|
||||
png_set_longjmp_fn @8
|
||||
png_longjmp @9
|
||||
png_reset_zstream @10
|
||||
png_create_read_struct_2 @11
|
||||
png_create_write_struct_2 @12
|
||||
png_write_sig @13
|
||||
png_write_chunk @14
|
||||
png_write_chunk_start @15
|
||||
png_write_chunk_data @16
|
||||
png_write_chunk_end @17
|
||||
png_create_info_struct @18
|
||||
png_info_init_3 @19
|
||||
png_write_info_before_PLTE @20
|
||||
png_write_info @21
|
||||
png_read_info @22
|
||||
png_convert_to_rfc1123 @23
|
||||
png_convert_from_struct_tm @24
|
||||
png_convert_from_time_t @25
|
||||
png_set_expand @26
|
||||
png_set_expand_gray_1_2_4_to_8 @27
|
||||
png_set_palette_to_rgb @28
|
||||
png_set_tRNS_to_alpha @29
|
||||
png_set_bgr @30
|
||||
png_set_gray_to_rgb @31
|
||||
png_set_rgb_to_gray @32
|
||||
png_set_rgb_to_gray_fixed @33
|
||||
png_get_rgb_to_gray_status @34
|
||||
png_build_grayscale_palette @35
|
||||
png_set_strip_alpha @36
|
||||
png_set_swap_alpha @37
|
||||
png_set_invert_alpha @38
|
||||
png_set_filler @39
|
||||
png_set_add_alpha @40
|
||||
png_set_swap @41
|
||||
png_set_packing @42
|
||||
png_set_packswap @43
|
||||
png_set_shift @44
|
||||
png_set_interlace_handling @45
|
||||
png_set_invert_mono @46
|
||||
png_set_background @47
|
||||
png_set_strip_16 @48
|
||||
png_set_quantize @49
|
||||
png_set_gamma @50
|
||||
png_set_flush @51
|
||||
png_write_flush @52
|
||||
png_start_read_image @53
|
||||
png_read_update_info @54
|
||||
png_read_rows @55
|
||||
png_read_row @56
|
||||
png_read_image @57
|
||||
png_write_row @58
|
||||
png_write_rows @59
|
||||
png_write_image @60
|
||||
png_write_end @61
|
||||
png_read_end @62
|
||||
png_destroy_info_struct @63
|
||||
png_destroy_read_struct @64
|
||||
png_destroy_write_struct @65
|
||||
png_set_crc_action @66
|
||||
png_set_filter @67
|
||||
png_set_filter_heuristics @68
|
||||
png_set_compression_level @69
|
||||
png_set_compression_mem_level @70
|
||||
png_set_compression_strategy @71
|
||||
png_set_compression_window_bits @72
|
||||
png_set_compression_method @73
|
||||
png_init_io @74
|
||||
png_set_error_fn @75
|
||||
png_get_error_ptr @76
|
||||
png_set_write_fn @77
|
||||
png_set_read_fn @78
|
||||
png_get_io_ptr @79
|
||||
png_set_read_status_fn @80
|
||||
png_set_write_status_fn @81
|
||||
png_set_mem_fn @82
|
||||
png_get_mem_ptr @83
|
||||
png_set_read_user_transform_fn @84
|
||||
png_set_write_user_transform_fn @85
|
||||
png_set_user_transform_info @86
|
||||
png_get_user_transform_ptr @87
|
||||
png_set_read_user_chunk_fn @88
|
||||
png_get_user_chunk_ptr @89
|
||||
png_set_progressive_read_fn @90
|
||||
png_get_progressive_ptr @91
|
||||
png_process_data @92
|
||||
png_progressive_combine_row @93
|
||||
png_malloc @94
|
||||
png_calloc @95
|
||||
png_malloc_warn @96
|
||||
png_free @97
|
||||
png_free_data @98
|
||||
png_data_freer @99
|
||||
png_malloc_default @100
|
||||
png_free_default @101
|
||||
png_error @102
|
||||
png_chunk_error @103
|
||||
png_err @104
|
||||
png_warning @105
|
||||
png_chunk_warning @106
|
||||
png_benign_error @107
|
||||
png_chunk_benign_error @108
|
||||
png_set_benign_errors @109
|
||||
png_get_valid @110
|
||||
png_get_rowbytes @111
|
||||
png_get_rows @112
|
||||
png_set_rows @113
|
||||
png_get_channels @114
|
||||
png_get_image_width @115
|
||||
png_get_image_height @116
|
||||
png_get_bit_depth @117
|
||||
png_get_color_type @118
|
||||
png_get_filter_type @119
|
||||
png_get_interlace_type @120
|
||||
png_get_compression_type @121
|
||||
png_get_pixels_per_meter @122
|
||||
png_get_x_pixels_per_meter @123
|
||||
png_get_y_pixels_per_meter @124
|
||||
png_get_pixel_aspect_ratio @125
|
||||
png_get_x_offset_pixels @126
|
||||
png_get_y_offset_pixels @127
|
||||
png_get_x_offset_microns @128
|
||||
png_get_y_offset_microns @129
|
||||
png_get_signature @130
|
||||
png_get_bKGD @131
|
||||
png_set_bKGD @132
|
||||
png_get_cHRM @133
|
||||
png_get_cHRM_fixed @134
|
||||
png_set_cHRM @135
|
||||
png_set_cHRM_fixed @136
|
||||
png_get_gAMA @137
|
||||
png_get_gAMA_fixed @138
|
||||
png_set_gAMA @139
|
||||
png_set_gAMA_fixed @140
|
||||
png_get_hIST @141
|
||||
png_set_hIST @142
|
||||
png_get_IHDR @143
|
||||
png_set_IHDR @144
|
||||
png_get_oFFs @145
|
||||
png_set_oFFs @146
|
||||
png_get_pCAL @147
|
||||
png_set_pCAL @148
|
||||
png_get_pHYs @149
|
||||
png_set_pHYs @150
|
||||
png_get_PLTE @151
|
||||
png_set_PLTE @152
|
||||
png_get_sBIT @153
|
||||
png_set_sBIT @154
|
||||
png_get_sRGB @155
|
||||
png_set_sRGB @156
|
||||
png_set_sRGB_gAMA_and_cHRM @157
|
||||
png_get_iCCP @158
|
||||
png_set_iCCP @159
|
||||
png_get_sPLT @160
|
||||
png_set_sPLT @161
|
||||
png_get_text @162
|
||||
png_set_text @163
|
||||
png_get_tIME @164
|
||||
png_set_tIME @165
|
||||
png_get_tRNS @166
|
||||
png_set_tRNS @167
|
||||
png_get_sCAL @168
|
||||
png_get_sCAL_s @169
|
||||
png_set_sCAL @170
|
||||
png_set_sCAL_s @171
|
||||
png_set_keep_unknown_chunks @172
|
||||
png_handle_as_unknown @173
|
||||
png_set_unknown_chunks @174
|
||||
png_set_unknown_chunk_location @175
|
||||
png_get_unknown_chunks @176
|
||||
png_set_invalid @177
|
||||
png_read_png @178
|
||||
png_write_png @179
|
||||
png_get_copyright @180
|
||||
png_get_header_ver @181
|
||||
png_get_header_version @182
|
||||
png_get_libpng_ver @183
|
||||
png_permit_mng_features @184
|
||||
png_set_strip_error_numbers @185
|
||||
png_set_user_limits @186
|
||||
png_get_user_width_max @187
|
||||
png_get_user_height_max @188
|
||||
png_set_chunk_cache_max @189
|
||||
png_get_chunk_cache_max @190
|
||||
png_set_chunk_malloc_max @191
|
||||
png_get_chunk_malloc_max @192
|
||||
png_get_pixels_per_inch @193
|
||||
png_get_x_pixels_per_inch @194
|
||||
png_get_y_pixels_per_inch @195
|
||||
png_get_x_offset_inches @196
|
||||
png_get_y_offset_inches @197
|
||||
png_get_pHYs_dpi @198
|
||||
png_get_io_state @199
|
||||
png_get_uint_32 @201
|
||||
png_get_uint_16 @202
|
||||
png_get_int_32 @203
|
||||
png_get_uint_31 @204
|
||||
png_save_uint_32 @205
|
||||
png_save_int_32 @206
|
||||
png_save_uint_16 @207
|
||||
png_set_gamma_fixed @208
|
||||
png_set_filter_heuristics_fixed @209
|
||||
png_get_pixel_aspect_ratio_fixed @210
|
||||
png_get_x_offset_inches_fixed @211
|
||||
png_get_y_offset_inches_fixed @212
|
||||
png_set_sCAL_fixed @213
|
||||
png_get_sCAL_fixed @214
|
||||
png_set_background_fixed @215
|
||||
png_get_io_chunk_type @216
|
||||
png_get_current_row_number @217
|
||||
png_get_current_pass_number @218
|
||||
png_process_data_pause @219
|
||||
png_process_data_skip @220
|
||||
png_set_expand_16 @221
|
||||
png_set_text_compression_level @222
|
||||
png_set_text_compression_mem_level @223
|
||||
png_set_text_compression_strategy @224
|
||||
png_set_text_compression_window_bits @225
|
||||
png_set_text_compression_method @226
|
||||
png_set_alpha_mode @227
|
||||
png_set_alpha_mode_fixed @228
|
||||
png_set_scale_16 @229
|
||||
png_get_cHRM_XYZ @230
|
||||
png_get_cHRM_XYZ_fixed @231
|
||||
png_set_cHRM_XYZ @232
|
||||
png_set_cHRM_XYZ_fixed @233
|
||||
png_image_begin_read_from_file @234
|
||||
png_image_begin_read_from_stdio @235
|
||||
png_image_begin_read_from_memory @236
|
||||
png_image_finish_read @237
|
||||
png_image_free @238
|
||||
png_image_write_to_file @239
|
||||
png_image_write_to_stdio @240
|
||||
png_convert_to_rfc1123_buffer @241
|
||||
png_set_check_for_invalid_index @242
|
||||
png_get_palette_max @243
|
||||
png_set_option @244
|
||||
png_image_write_to_memory @245
|
||||
png_get_eXIf @246
|
||||
png_set_eXIf @247
|
||||
png_get_eXIf_1 @248
|
||||
png_set_eXIf_1 @249
|
@ -1,31 +0,0 @@
|
||||
# test.cmake.in
|
||||
|
||||
# Copyright (C) 2016 Glenn Randers-Pehrson
|
||||
# Written by Roger Leigh, 2016
|
||||
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
|
||||
set(TEST_OPTIONS "@TEST_OPTIONS@")
|
||||
set(TEST_FILES "@TEST_FILES@")
|
||||
|
||||
foreach(file ${TEST_FILES})
|
||||
file(TO_NATIVE_PATH "${file}" native_file)
|
||||
list(APPEND NATIVE_TEST_FILES "${native_file}")
|
||||
endforeach()
|
||||
|
||||
# Add the directory containing libpng to the PATH (Windows only)
|
||||
if(WIN32)
|
||||
get_filename_component(LIBPNG_DIR "${LIBPNG}" PATH)
|
||||
file(TO_NATIVE_PATH "${LIBPNG_DIR}" LIBPNG_DIR)
|
||||
set(ENV{PATH} "${LIBPNG_DIR};$ENV{PATH}")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E echo "Running ${TEST_COMMAND}" ${TEST_OPTIONS} ${NATIVE_TEST_FILES})
|
||||
|
||||
execute_process(COMMAND "${TEST_COMMAND}" ${TEST_OPTIONS} ${NATIVE_TEST_FILES}
|
||||
RESULT_VARIABLE TEST_STATUS)
|
||||
if(TEST_STATUS)
|
||||
message(FATAL_ERROR "Returned failed status ${TEST_STATUS}!")
|
||||
endif()
|
@ -1,19 +0,0 @@
|
||||
|
||||
/* vers.c - define format of libpng.vers
|
||||
*
|
||||
* Last changed in libpng version 1.6.16 [December 22, 2014]
|
||||
* Copyright (c) 2011-2014 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
|
||||
*/
|
||||
|
||||
#define PNG_EXPORTA(ordinal, type, name, args, attributes)\
|
||||
PNG_DFN " @" SYMBOL_PREFIX "@@" name "@;"
|
||||
|
||||
PNG_DFN "@" PNGLIB_LIBNAME "@ {global:"
|
||||
|
||||
#include "../png.h"
|
||||
|
||||
PNG_DFN "local: *; };"
|
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2007,2008 Alex Shulgin
|
||||
*
|
||||
* This file is part of png++ the C++ wrapper for libpng. PNG++ is free
|
||||
* software; the exact copying conditions are as follows:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef PNGPP_PALETTE_HPP_INCLUDED
|
||||
#define PNGPP_PALETTE_HPP_INCLUDED
|
||||
|
||||
#include <vector>
|
||||
#include "color.hpp"
|
||||
|
||||
namespace png
|
||||
{
|
||||
|
||||
/**
|
||||
* \brief The palette type. Currently implemented as \c std::vector
|
||||
* of png::color.
|
||||
*/
|
||||
typedef std::vector< color > palette;
|
||||
|
||||
} // namespace png
|
||||
|
||||
#endif // PNGPP_PALETTE_HPP_INCLUDED
|
@ -1,103 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2007,2008 Alex Shulgin
|
||||
*
|
||||
* This file is part of png++ the C++ wrapper for libpng. PNG++ is free
|
||||
* software; the exact copying conditions are as follows:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef PNGPP_PIXEL_TRAITS_HPP_INCLUDED
|
||||
#define PNGPP_PIXEL_TRAITS_HPP_INCLUDED
|
||||
|
||||
#include <limits>
|
||||
#include "types.hpp"
|
||||
|
||||
namespace png
|
||||
{
|
||||
|
||||
/**
|
||||
* \brief Pixel traits class template.
|
||||
*
|
||||
* Provides information about pixel color type and components bit depth.
|
||||
* Not implemented--see specializations.
|
||||
*
|
||||
* \see pixel_traits<rgb_pixel>, pixel_traits<rgba_pixel>
|
||||
*/
|
||||
template< typename pixel > struct pixel_traits;
|
||||
|
||||
/**
|
||||
* \brief Basic pixel traits class template.
|
||||
*
|
||||
* Provides common implementation for various pixel_traits<>
|
||||
* specializations.
|
||||
*/
|
||||
template< typename pixel,
|
||||
typename component,
|
||||
color_type pixel_color_type,
|
||||
int channels_value = sizeof(pixel) / sizeof(component),
|
||||
int bit_depth_value = std::numeric_limits< component >::digits >
|
||||
struct basic_pixel_traits
|
||||
{
|
||||
typedef pixel pixel_type;
|
||||
typedef component component_type;
|
||||
|
||||
static color_type get_color_type()
|
||||
{
|
||||
return pixel_color_type;
|
||||
}
|
||||
|
||||
static const int channels = channels_value;
|
||||
static int get_channels()
|
||||
{
|
||||
return channels;
|
||||
}
|
||||
|
||||
static const int bit_depth = bit_depth_value;
|
||||
static int get_bit_depth()
|
||||
{
|
||||
return bit_depth;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Basic pixel traits class template for pixels with alpha
|
||||
* channel.
|
||||
*/
|
||||
template< typename component >
|
||||
struct basic_alpha_pixel_traits
|
||||
{
|
||||
/**
|
||||
* \brief Returns the default alpha channel filler for full
|
||||
* opacity.
|
||||
*/
|
||||
static component get_alpha_filler()
|
||||
{
|
||||
return std::numeric_limits< component >::max();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace png
|
||||
|
||||
#endif // PNGPP_PIXEL_TRAITS_HPP_INCLUDED
|
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2007,2008 Alex Shulgin
|
||||
*
|
||||
* This file is part of png++ the C++ wrapper for libpng. PNG++ is free
|
||||
* software; the exact copying conditions are as follows:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef PNGPP_TRNS_HPP_INCLUDED
|
||||
#define PNGPP_TRNS_HPP_INCLUDED
|
||||
|
||||
#include <vector>
|
||||
#include "color.hpp"
|
||||
|
||||
namespace png
|
||||
{
|
||||
|
||||
/**
|
||||
* \brief The palette transparency map type. Currently
|
||||
* implemented as \c std::vector of png::byte.
|
||||
*/
|
||||
typedef std::vector< byte > tRNS;
|
||||
|
||||
} // namespace png
|
||||
|
||||
#endif // PNGPP_TRNS_HPP_INCLUDED
|
@ -1,120 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2007,2008 Alex Shulgin
|
||||
*
|
||||
* This file is part of png++ the C++ wrapper for libpng. PNG++ is free
|
||||
* software; the exact copying conditions are as follows:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef PNGPP_TYPES_HPP_INCLUDED
|
||||
#define PNGPP_TYPES_HPP_INCLUDED
|
||||
|
||||
#include <png.h>
|
||||
|
||||
namespace png
|
||||
{
|
||||
|
||||
typedef png_byte byte;
|
||||
typedef png_uint_16 uint_16;
|
||||
typedef png_uint_32 uint_32;
|
||||
typedef png_fixed_point fixed_point;
|
||||
typedef png_color_8 color_info;
|
||||
typedef png_color_16 color_info_16;
|
||||
|
||||
enum color_type
|
||||
{
|
||||
color_type_none = -1,
|
||||
color_type_gray = PNG_COLOR_TYPE_GRAY,
|
||||
color_type_palette = PNG_COLOR_TYPE_PALETTE,
|
||||
color_type_rgb = PNG_COLOR_TYPE_RGB,
|
||||
color_type_rgb_alpha = PNG_COLOR_TYPE_RGB_ALPHA,
|
||||
color_type_gray_alpha = PNG_COLOR_TYPE_GRAY_ALPHA,
|
||||
color_type_rgba = PNG_COLOR_TYPE_RGBA,
|
||||
color_type_ga = PNG_COLOR_TYPE_GA
|
||||
};
|
||||
|
||||
enum color_mask
|
||||
{
|
||||
color_mask_palette = PNG_COLOR_MASK_PALETTE,
|
||||
color_mask_color = PNG_COLOR_MASK_COLOR,
|
||||
color_mask_rgb = color_mask_color,
|
||||
color_mask_alpha = PNG_COLOR_MASK_ALPHA
|
||||
};
|
||||
|
||||
enum filler_type
|
||||
{
|
||||
filler_before = PNG_FILLER_BEFORE,
|
||||
filler_after = PNG_FILLER_AFTER
|
||||
};
|
||||
|
||||
enum rgb_to_gray_error_action
|
||||
{
|
||||
rgb_to_gray_silent = 1,
|
||||
rgb_to_gray_warning = 2,
|
||||
rgb_to_gray_error = 3
|
||||
};
|
||||
|
||||
enum interlace_type
|
||||
{
|
||||
interlace_none = PNG_INTERLACE_NONE,
|
||||
interlace_adam7 = PNG_INTERLACE_ADAM7
|
||||
};
|
||||
|
||||
enum compression_type
|
||||
{
|
||||
compression_type_base = PNG_COMPRESSION_TYPE_BASE,
|
||||
compression_type_default = PNG_COMPRESSION_TYPE_DEFAULT
|
||||
};
|
||||
|
||||
enum filter_type
|
||||
{
|
||||
filter_type_base = PNG_FILTER_TYPE_BASE,
|
||||
intrapixel_differencing = PNG_INTRAPIXEL_DIFFERENCING,
|
||||
filter_type_default = PNG_FILTER_TYPE_DEFAULT
|
||||
};
|
||||
|
||||
enum chunk
|
||||
{
|
||||
chunk_gAMA = PNG_INFO_gAMA,
|
||||
chunk_sBIT = PNG_INFO_sBIT,
|
||||
chunk_cHRM = PNG_INFO_cHRM,
|
||||
chunk_PLTE = PNG_INFO_PLTE,
|
||||
chunk_tRNS = PNG_INFO_tRNS,
|
||||
chunk_bKGD = PNG_INFO_bKGD,
|
||||
chunk_hIST = PNG_INFO_hIST,
|
||||
chunk_pHYs = PNG_INFO_pHYs,
|
||||
chunk_oFFs = PNG_INFO_oFFs,
|
||||
chunk_tIME = PNG_INFO_tIME,
|
||||
chunk_pCAL = PNG_INFO_pCAL,
|
||||
chunk_sRGB = PNG_INFO_sRGB,
|
||||
chunk_iCCP = PNG_INFO_iCCP,
|
||||
chunk_sPLT = PNG_INFO_sPLT,
|
||||
chunk_sCAL = PNG_INFO_sCAL,
|
||||
chunk_IDAT = PNG_INFO_IDAT
|
||||
};
|
||||
|
||||
} // namespace png
|
||||
|
||||
#endif // PNGPP_TYPES_HPP_INCLUDED
|
@ -1,199 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2007,2008 Alex Shulgin
|
||||
*
|
||||
* This file is part of png++ the C++ wrapper for libpng. PNG++ is free
|
||||
* software; the exact copying conditions are as follows:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef PNGPP_WRITER_HPP_INCLUDED
|
||||
#define PNGPP_WRITER_HPP_INCLUDED
|
||||
|
||||
#include <cassert>
|
||||
#include "io_base.hpp"
|
||||
|
||||
namespace png
|
||||
{
|
||||
|
||||
/**
|
||||
* \brief PNG writer class template. This is the low-level
|
||||
* writing interface--use image class or generator class to
|
||||
* actually write images.
|
||||
*
|
||||
* The \c ostream template parameter specifies the type of output
|
||||
* stream to work with. The \c ostream class should implement the
|
||||
* minimum of the following interface:
|
||||
*
|
||||
* \code
|
||||
* class my_ostream
|
||||
* {
|
||||
* public:
|
||||
* void write(char const*, size_t);
|
||||
* void flush();
|
||||
* bool good();
|
||||
* };
|
||||
* \endcode
|
||||
*
|
||||
* With the semantics similar to the \c std::ostream. Naturally,
|
||||
* \c std::ostream fits this requirement and can be used with the
|
||||
* writer class as is.
|
||||
*
|
||||
* \see image, reader, generator, io_base
|
||||
*/
|
||||
template< class ostream >
|
||||
class writer
|
||||
: public io_base
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \brief Constructs a writer prepared to write PNG image into
|
||||
* a \a stream.
|
||||
*/
|
||||
explicit writer(ostream& stream)
|
||||
: io_base(png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||
static_cast< io_base* >(this),
|
||||
raise_error,
|
||||
0))
|
||||
{
|
||||
png_set_write_fn(m_png, & stream, write_data, flush_data);
|
||||
}
|
||||
|
||||
~writer()
|
||||
{
|
||||
m_end_info.destroy();
|
||||
png_destroy_write_struct(& m_png, m_info.get_png_info_ptr());
|
||||
}
|
||||
|
||||
void write_png() const
|
||||
{
|
||||
if (setjmp(png_jmpbuf(m_png)))
|
||||
{
|
||||
throw error(m_error);
|
||||
}
|
||||
png_write_png(m_png,
|
||||
m_info.get_png_info(),
|
||||
/* transforms = */ 0,
|
||||
/* params = */ 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Write info about PNG image.
|
||||
*/
|
||||
void write_info() const
|
||||
{
|
||||
if (setjmp(png_jmpbuf(m_png)))
|
||||
{
|
||||
throw error(m_error);
|
||||
}
|
||||
m_info.write();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Writes a row of image data at a time.
|
||||
*/
|
||||
void write_row(byte* bytes)
|
||||
{
|
||||
if (setjmp(png_jmpbuf(m_png)))
|
||||
{
|
||||
throw error(m_error);
|
||||
}
|
||||
png_write_row(m_png, bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Reads ending info about PNG image.
|
||||
*/
|
||||
void write_end_info() const
|
||||
{
|
||||
if (setjmp(png_jmpbuf(m_png)))
|
||||
{
|
||||
throw error(m_error);
|
||||
}
|
||||
m_end_info.write();
|
||||
}
|
||||
|
||||
private:
|
||||
static void write_data(png_struct* png, byte* data, png_size_t length)
|
||||
{
|
||||
io_base* io = static_cast< io_base* >(png_get_error_ptr(png));
|
||||
writer* wr = static_cast< writer* >(io);
|
||||
wr->reset_error();
|
||||
ostream* stream = reinterpret_cast< ostream* >(png_get_io_ptr(png));
|
||||
try
|
||||
{
|
||||
stream->write(reinterpret_cast< char* >(data), length);
|
||||
if (!stream->good())
|
||||
{
|
||||
wr->set_error("ostream::write() failed");
|
||||
}
|
||||
}
|
||||
catch (std::exception const& error)
|
||||
{
|
||||
wr->set_error(error.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
assert(!"caught something wrong");
|
||||
wr->set_error("write_data: caught something wrong");
|
||||
}
|
||||
if (wr->is_error())
|
||||
{
|
||||
wr->raise_error();
|
||||
}
|
||||
}
|
||||
|
||||
static void flush_data(png_struct* png)
|
||||
{
|
||||
io_base* io = static_cast< io_base* >(png_get_error_ptr(png));
|
||||
writer* wr = static_cast< writer* >(io);
|
||||
wr->reset_error();
|
||||
ostream* stream = reinterpret_cast< ostream* >(png_get_io_ptr(png));
|
||||
try
|
||||
{
|
||||
stream->flush();
|
||||
if (!stream->good())
|
||||
{
|
||||
wr->set_error("ostream::flush() failed");
|
||||
}
|
||||
}
|
||||
catch (std::exception const& error)
|
||||
{
|
||||
wr->set_error(error.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
assert(!"caught something wrong");
|
||||
wr->set_error("flush_data: caught something wrong");
|
||||
}
|
||||
if (wr->is_error())
|
||||
{
|
||||
wr->raise_error();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace png
|
||||
|
||||
#endif // PNGPP_WRITER_HPP_INCLUDED
|
@ -1,253 +0,0 @@
|
||||
cmake_minimum_required(VERSION 2.4.4)
|
||||
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
|
||||
|
||||
project(zlib C)
|
||||
|
||||
set(VERSION "1.2.11")
|
||||
|
||||
option(ASM686 "Enable building i686 assembly implementation")
|
||||
option(AMD64 "Enable building amd64 assembly implementation")
|
||||
|
||||
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
|
||||
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
|
||||
set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
|
||||
set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages")
|
||||
set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
|
||||
|
||||
include(CheckTypeSize)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckIncludeFile)
|
||||
include(CheckCSourceCompiles)
|
||||
#enable_testing()
|
||||
|
||||
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
|
||||
check_include_file(stdint.h HAVE_STDINT_H)
|
||||
check_include_file(stddef.h HAVE_STDDEF_H)
|
||||
|
||||
#
|
||||
# Check to see if we have large file support
|
||||
#
|
||||
set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
|
||||
# We add these other definitions here because CheckTypeSize.cmake
|
||||
# in CMake 2.4.x does not automatically do so and we want
|
||||
# compatibility with CMake 2.4.x.
|
||||
if(HAVE_SYS_TYPES_H)
|
||||
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
|
||||
endif()
|
||||
if(HAVE_STDINT_H)
|
||||
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
|
||||
endif()
|
||||
if(HAVE_STDDEF_H)
|
||||
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
|
||||
endif()
|
||||
check_type_size(off64_t OFF64_T)
|
||||
if(HAVE_OFF64_T)
|
||||
add_definitions(-D_LARGEFILE64_SOURCE=1)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
|
||||
|
||||
#
|
||||
# Check for fseeko
|
||||
#
|
||||
check_function_exists(fseeko HAVE_FSEEKO)
|
||||
if(NOT HAVE_FSEEKO)
|
||||
add_definitions(-DNO_FSEEKO)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Check for unistd.h
|
||||
#
|
||||
check_include_file(unistd.h Z_HAVE_UNISTD_H)
|
||||
|
||||
if(MSVC)
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
|
||||
# If we're doing an out of source build and the user has a zconf.h
|
||||
# in their source tree...
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h)
|
||||
message(STATUS "Renaming")
|
||||
message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h")
|
||||
message(STATUS "to 'zconf.h.included' because this file is included with zlib")
|
||||
message(STATUS "but CMake generates it automatically in the build directory.")
|
||||
file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc)
|
||||
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
|
||||
${ZLIB_PC} @ONLY)
|
||||
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
|
||||
|
||||
|
||||
#============================================================================
|
||||
# zlib
|
||||
#============================================================================
|
||||
|
||||
set(ZLIB_PUBLIC_HDRS
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zconf.h
|
||||
zlib.h
|
||||
)
|
||||
set(ZLIB_PRIVATE_HDRS
|
||||
crc32.h
|
||||
deflate.h
|
||||
gzguts.h
|
||||
inffast.h
|
||||
inffixed.h
|
||||
inflate.h
|
||||
inftrees.h
|
||||
trees.h
|
||||
zutil.h
|
||||
)
|
||||
set(ZLIB_SRCS
|
||||
adler32.c
|
||||
compress.c
|
||||
crc32.c
|
||||
deflate.c
|
||||
gzclose.c
|
||||
gzlib.c
|
||||
gzread.c
|
||||
gzwrite.c
|
||||
inflate.c
|
||||
infback.c
|
||||
inftrees.c
|
||||
inffast.c
|
||||
trees.c
|
||||
uncompr.c
|
||||
zutil.c
|
||||
)
|
||||
|
||||
if(NOT MINGW)
|
||||
set(ZLIB_DLL_SRCS
|
||||
win32/zlib1.rc # If present will override custom build rule below.
|
||||
)
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
if(ASM686)
|
||||
set(ZLIB_ASMS contrib/asm686/match.S)
|
||||
elseif (AMD64)
|
||||
set(ZLIB_ASMS contrib/amd64/amd64-match.S)
|
||||
endif ()
|
||||
|
||||
if(ZLIB_ASMS)
|
||||
add_definitions(-DASMV)
|
||||
set_source_files_properties(${ZLIB_ASMS} PROPERTIES LANGUAGE C COMPILE_FLAGS -DNO_UNDERLINE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
if(ASM686)
|
||||
ENABLE_LANGUAGE(ASM_MASM)
|
||||
set(ZLIB_ASMS
|
||||
contrib/masmx86/inffas32.asm
|
||||
contrib/masmx86/match686.asm
|
||||
)
|
||||
elseif (AMD64)
|
||||
ENABLE_LANGUAGE(ASM_MASM)
|
||||
set(ZLIB_ASMS
|
||||
contrib/masmx64/gvmat64.asm
|
||||
contrib/masmx64/inffasx64.asm
|
||||
)
|
||||
endif()
|
||||
|
||||
if(ZLIB_ASMS)
|
||||
add_definitions(-DASMV -DASMINF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION
|
||||
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
|
||||
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
|
||||
"\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
|
||||
|
||||
if(MINGW)
|
||||
# This gets us DLL resource information when compiling on MinGW.
|
||||
if(NOT CMAKE_RC_COMPILER)
|
||||
set(CMAKE_RC_COMPILER windres.exe)
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
|
||||
COMMAND ${CMAKE_RC_COMPILER}
|
||||
-D GCC_WINDRES
|
||||
-I ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
-I ${CMAKE_CURRENT_BINARY_DIR}
|
||||
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
|
||||
-i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
|
||||
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
|
||||
endif(MINGW)
|
||||
|
||||
#add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
#set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
|
||||
#set_target_properties(zlib PROPERTIES SOVERSION 1)
|
||||
|
||||
if(NOT CYGWIN)
|
||||
# This property causes shared libraries on Linux to have the full version
|
||||
# encoded into their final filename. We disable this on Cygwin because
|
||||
# it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll
|
||||
# seems to be the default.
|
||||
#
|
||||
# This has no effect with MSVC, on that platform the version info for
|
||||
# the DLL comes from the resource file win32/zlib1.rc
|
||||
# set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
# On unix-like platforms the library is almost always called libz
|
||||
set_target_properties(
|
||||
# zlib
|
||||
zlibstatic PROPERTIES OUTPUT_NAME z)
|
||||
if(NOT APPLE)
|
||||
# set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
|
||||
endif()
|
||||
elseif(BUILD_SHARED_LIBS AND WIN32)
|
||||
# Creates zlib1.dll when building shared library version
|
||||
# set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
|
||||
install(TARGETS
|
||||
# zlib
|
||||
zlibstatic
|
||||
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
|
||||
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
|
||||
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
|
||||
endif()
|
||||
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
|
||||
install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}")
|
||||
endif()
|
||||
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
|
||||
install(FILES zlib.3 DESTINATION "${INSTALL_MAN_DIR}/man3")
|
||||
endif()
|
||||
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
|
||||
install(FILES ${ZLIB_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}")
|
||||
endif()
|
||||
|
||||
#============================================================================
|
||||
# Example binaries
|
||||
#============================================================================
|
||||
|
||||
#add_executable(example test/example.c)
|
||||
#target_link_libraries(example zlib)
|
||||
#add_test(example example)
|
||||
|
||||
#add_executable(minigzip test/minigzip.c)
|
||||
#target_link_libraries(minigzip zlib)
|
||||
|
||||
#if(HAVE_OFF64_T)
|
||||
# add_executable(example64 test/example.c)
|
||||
# target_link_libraries(example64 zlib)
|
||||
# set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
|
||||
# add_test(example64 example64)
|
||||
|
||||
# add_executable(minigzip64 test/minigzip.c)
|
||||
# target_link_libraries(minigzip64 zlib)
|
||||
# set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
|
||||
#endif()
|
File diff suppressed because it is too large
Load Diff
368
src/png/zlib/FAQ
368
src/png/zlib/FAQ
@ -1,368 +0,0 @@
|
||||
|
||||
Frequently Asked Questions about zlib
|
||||
|
||||
|
||||
If your question is not there, please check the zlib home page
|
||||
http://zlib.net/ which may have more recent information.
|
||||
The lastest zlib FAQ is at http://zlib.net/zlib_faq.html
|
||||
|
||||
|
||||
1. Is zlib Y2K-compliant?
|
||||
|
||||
Yes. zlib doesn't handle dates.
|
||||
|
||||
2. Where can I get a Windows DLL version?
|
||||
|
||||
The zlib sources can be compiled without change to produce a DLL. See the
|
||||
file win32/DLL_FAQ.txt in the zlib distribution. Pointers to the
|
||||
precompiled DLL are found in the zlib web site at http://zlib.net/ .
|
||||
|
||||
3. Where can I get a Visual Basic interface to zlib?
|
||||
|
||||
See
|
||||
* http://marknelson.us/1997/01/01/zlib-engine/
|
||||
* win32/DLL_FAQ.txt in the zlib distribution
|
||||
|
||||
4. compress() returns Z_BUF_ERROR.
|
||||
|
||||
Make sure that before the call of compress(), the length of the compressed
|
||||
buffer is equal to the available size of the compressed buffer and not
|
||||
zero. For Visual Basic, check that this parameter is passed by reference
|
||||
("as any"), not by value ("as long").
|
||||
|
||||
5. deflate() or inflate() returns Z_BUF_ERROR.
|
||||
|
||||
Before making the call, make sure that avail_in and avail_out are not zero.
|
||||
When setting the parameter flush equal to Z_FINISH, also make sure that
|
||||
avail_out is big enough to allow processing all pending input. Note that a
|
||||
Z_BUF_ERROR is not fatal--another call to deflate() or inflate() can be
|
||||
made with more input or output space. A Z_BUF_ERROR may in fact be
|
||||
unavoidable depending on how the functions are used, since it is not
|
||||
possible to tell whether or not there is more output pending when
|
||||
strm.avail_out returns with zero. See http://zlib.net/zlib_how.html for a
|
||||
heavily annotated example.
|
||||
|
||||
6. Where's the zlib documentation (man pages, etc.)?
|
||||
|
||||
It's in zlib.h . Examples of zlib usage are in the files test/example.c
|
||||
and test/minigzip.c, with more in examples/ .
|
||||
|
||||
7. Why don't you use GNU autoconf or libtool or ...?
|
||||
|
||||
Because we would like to keep zlib as a very small and simple package.
|
||||
zlib is rather portable and doesn't need much configuration.
|
||||
|
||||
8. I found a bug in zlib.
|
||||
|
||||
Most of the time, such problems are due to an incorrect usage of zlib.
|
||||
Please try to reproduce the problem with a small program and send the
|
||||
corresponding source to us at zlib@gzip.org . Do not send multi-megabyte
|
||||
data files without prior agreement.
|
||||
|
||||
9. Why do I get "undefined reference to gzputc"?
|
||||
|
||||
If "make test" produces something like
|
||||
|
||||
example.o(.text+0x154): undefined reference to `gzputc'
|
||||
|
||||
check that you don't have old files libz.* in /usr/lib, /usr/local/lib or
|
||||
/usr/X11R6/lib. Remove any old versions, then do "make install".
|
||||
|
||||
10. I need a Delphi interface to zlib.
|
||||
|
||||
See the contrib/delphi directory in the zlib distribution.
|
||||
|
||||
11. Can zlib handle .zip archives?
|
||||
|
||||
Not by itself, no. See the directory contrib/minizip in the zlib
|
||||
distribution.
|
||||
|
||||
12. Can zlib handle .Z files?
|
||||
|
||||
No, sorry. You have to spawn an uncompress or gunzip subprocess, or adapt
|
||||
the code of uncompress on your own.
|
||||
|
||||
13. How can I make a Unix shared library?
|
||||
|
||||
By default a shared (and a static) library is built for Unix. So:
|
||||
|
||||
make distclean
|
||||
./configure
|
||||
make
|
||||
|
||||
14. How do I install a shared zlib library on Unix?
|
||||
|
||||
After the above, then:
|
||||
|
||||
make install
|
||||
|
||||
However, many flavors of Unix come with a shared zlib already installed.
|
||||
Before going to the trouble of compiling a shared version of zlib and
|
||||
trying to install it, you may want to check if it's already there! If you
|
||||
can #include <zlib.h>, it's there. The -lz option will probably link to
|
||||
it. You can check the version at the top of zlib.h or with the
|
||||
ZLIB_VERSION symbol defined in zlib.h .
|
||||
|
||||
15. I have a question about OttoPDF.
|
||||
|
||||
We are not the authors of OttoPDF. The real author is on the OttoPDF web
|
||||
site: Joel Hainley, jhainley@myndkryme.com.
|
||||
|
||||
16. Can zlib decode Flate data in an Adobe PDF file?
|
||||
|
||||
Yes. See http://www.pdflib.com/ . To modify PDF forms, see
|
||||
http://sourceforge.net/projects/acroformtool/ .
|
||||
|
||||
17. Why am I getting this "register_frame_info not found" error on Solaris?
|
||||
|
||||
After installing zlib 1.1.4 on Solaris 2.6, running applications using zlib
|
||||
generates an error such as:
|
||||
|
||||
ld.so.1: rpm: fatal: relocation error: file /usr/local/lib/libz.so:
|
||||
symbol __register_frame_info: referenced symbol not found
|
||||
|
||||
The symbol __register_frame_info is not part of zlib, it is generated by
|
||||
the C compiler (cc or gcc). You must recompile applications using zlib
|
||||
which have this problem. This problem is specific to Solaris. See
|
||||
http://www.sunfreeware.com for Solaris versions of zlib and applications
|
||||
using zlib.
|
||||
|
||||
18. Why does gzip give an error on a file I make with compress/deflate?
|
||||
|
||||
The compress and deflate functions produce data in the zlib format, which
|
||||
is different and incompatible with the gzip format. The gz* functions in
|
||||
zlib on the other hand use the gzip format. Both the zlib and gzip formats
|
||||
use the same compressed data format internally, but have different headers
|
||||
and trailers around the compressed data.
|
||||
|
||||
19. Ok, so why are there two different formats?
|
||||
|
||||
The gzip format was designed to retain the directory information about a
|
||||
single file, such as the name and last modification date. The zlib format
|
||||
on the other hand was designed for in-memory and communication channel
|
||||
applications, and has a much more compact header and trailer and uses a
|
||||
faster integrity check than gzip.
|
||||
|
||||
20. Well that's nice, but how do I make a gzip file in memory?
|
||||
|
||||
You can request that deflate write the gzip format instead of the zlib
|
||||
format using deflateInit2(). You can also request that inflate decode the
|
||||
gzip format using inflateInit2(). Read zlib.h for more details.
|
||||
|
||||
21. Is zlib thread-safe?
|
||||
|
||||
Yes. However any library routines that zlib uses and any application-
|
||||
provided memory allocation routines must also be thread-safe. zlib's gz*
|
||||
functions use stdio library routines, and most of zlib's functions use the
|
||||
library memory allocation routines by default. zlib's *Init* functions
|
||||
allow for the application to provide custom memory allocation routines.
|
||||
|
||||
Of course, you should only operate on any given zlib or gzip stream from a
|
||||
single thread at a time.
|
||||
|
||||
22. Can I use zlib in my commercial application?
|
||||
|
||||
Yes. Please read the license in zlib.h.
|
||||
|
||||
23. Is zlib under the GNU license?
|
||||
|
||||
No. Please read the license in zlib.h.
|
||||
|
||||
24. The license says that altered source versions must be "plainly marked". So
|
||||
what exactly do I need to do to meet that requirement?
|
||||
|
||||
You need to change the ZLIB_VERSION and ZLIB_VERNUM #defines in zlib.h. In
|
||||
particular, the final version number needs to be changed to "f", and an
|
||||
identification string should be appended to ZLIB_VERSION. Version numbers
|
||||
x.x.x.f are reserved for modifications to zlib by others than the zlib
|
||||
maintainers. For example, if the version of the base zlib you are altering
|
||||
is "1.2.3.4", then in zlib.h you should change ZLIB_VERNUM to 0x123f, and
|
||||
ZLIB_VERSION to something like "1.2.3.f-zachary-mods-v3". You can also
|
||||
update the version strings in deflate.c and inftrees.c.
|
||||
|
||||
For altered source distributions, you should also note the origin and
|
||||
nature of the changes in zlib.h, as well as in ChangeLog and README, along
|
||||
with the dates of the alterations. The origin should include at least your
|
||||
name (or your company's name), and an email address to contact for help or
|
||||
issues with the library.
|
||||
|
||||
Note that distributing a compiled zlib library along with zlib.h and
|
||||
zconf.h is also a source distribution, and so you should change
|
||||
ZLIB_VERSION and ZLIB_VERNUM and note the origin and nature of the changes
|
||||
in zlib.h as you would for a full source distribution.
|
||||
|
||||
25. Will zlib work on a big-endian or little-endian architecture, and can I
|
||||
exchange compressed data between them?
|
||||
|
||||
Yes and yes.
|
||||
|
||||
26. Will zlib work on a 64-bit machine?
|
||||
|
||||
Yes. It has been tested on 64-bit machines, and has no dependence on any
|
||||
data types being limited to 32-bits in length. If you have any
|
||||
difficulties, please provide a complete problem report to zlib@gzip.org
|
||||
|
||||
27. Will zlib decompress data from the PKWare Data Compression Library?
|
||||
|
||||
No. The PKWare DCL uses a completely different compressed data format than
|
||||
does PKZIP and zlib. However, you can look in zlib's contrib/blast
|
||||
directory for a possible solution to your problem.
|
||||
|
||||
28. Can I access data randomly in a compressed stream?
|
||||
|
||||
No, not without some preparation. If when compressing you periodically use
|
||||
Z_FULL_FLUSH, carefully write all the pending data at those points, and
|
||||
keep an index of those locations, then you can start decompression at those
|
||||
points. You have to be careful to not use Z_FULL_FLUSH too often, since it
|
||||
can significantly degrade compression. Alternatively, you can scan a
|
||||
deflate stream once to generate an index, and then use that index for
|
||||
random access. See examples/zran.c .
|
||||
|
||||
29. Does zlib work on MVS, OS/390, CICS, etc.?
|
||||
|
||||
It has in the past, but we have not heard of any recent evidence. There
|
||||
were working ports of zlib 1.1.4 to MVS, but those links no longer work.
|
||||
If you know of recent, successful applications of zlib on these operating
|
||||
systems, please let us know. Thanks.
|
||||
|
||||
30. Is there some simpler, easier to read version of inflate I can look at to
|
||||
understand the deflate format?
|
||||
|
||||
First off, you should read RFC 1951. Second, yes. Look in zlib's
|
||||
contrib/puff directory.
|
||||
|
||||
31. Does zlib infringe on any patents?
|
||||
|
||||
As far as we know, no. In fact, that was originally the whole point behind
|
||||
zlib. Look here for some more information:
|
||||
|
||||
http://www.gzip.org/#faq11
|
||||
|
||||
32. Can zlib work with greater than 4 GB of data?
|
||||
|
||||
Yes. inflate() and deflate() will process any amount of data correctly.
|
||||
Each call of inflate() or deflate() is limited to input and output chunks
|
||||
of the maximum value that can be stored in the compiler's "unsigned int"
|
||||
type, but there is no limit to the number of chunks. Note however that the
|
||||
strm.total_in and strm_total_out counters may be limited to 4 GB. These
|
||||
counters are provided as a convenience and are not used internally by
|
||||
inflate() or deflate(). The application can easily set up its own counters
|
||||
updated after each call of inflate() or deflate() to count beyond 4 GB.
|
||||
compress() and uncompress() may be limited to 4 GB, since they operate in a
|
||||
single call. gzseek() and gztell() may be limited to 4 GB depending on how
|
||||
zlib is compiled. See the zlibCompileFlags() function in zlib.h.
|
||||
|
||||
The word "may" appears several times above since there is a 4 GB limit only
|
||||
if the compiler's "long" type is 32 bits. If the compiler's "long" type is
|
||||
64 bits, then the limit is 16 exabytes.
|
||||
|
||||
33. Does zlib have any security vulnerabilities?
|
||||
|
||||
The only one that we are aware of is potentially in gzprintf(). If zlib is
|
||||
compiled to use sprintf() or vsprintf(), then there is no protection
|
||||
against a buffer overflow of an 8K string space (or other value as set by
|
||||
gzbuffer()), other than the caller of gzprintf() assuring that the output
|
||||
will not exceed 8K. On the other hand, if zlib is compiled to use
|
||||
snprintf() or vsnprintf(), which should normally be the case, then there is
|
||||
no vulnerability. The ./configure script will display warnings if an
|
||||
insecure variation of sprintf() will be used by gzprintf(). Also the
|
||||
zlibCompileFlags() function will return information on what variant of
|
||||
sprintf() is used by gzprintf().
|
||||
|
||||
If you don't have snprintf() or vsnprintf() and would like one, you can
|
||||
find a portable implementation here:
|
||||
|
||||
http://www.ijs.si/software/snprintf/
|
||||
|
||||
Note that you should be using the most recent version of zlib. Versions
|
||||
1.1.3 and before were subject to a double-free vulnerability, and versions
|
||||
1.2.1 and 1.2.2 were subject to an access exception when decompressing
|
||||
invalid compressed data.
|
||||
|
||||
34. Is there a Java version of zlib?
|
||||
|
||||
Probably what you want is to use zlib in Java. zlib is already included
|
||||
as part of the Java SDK in the java.util.zip package. If you really want
|
||||
a version of zlib written in the Java language, look on the zlib home
|
||||
page for links: http://zlib.net/ .
|
||||
|
||||
35. I get this or that compiler or source-code scanner warning when I crank it
|
||||
up to maximally-pedantic. Can't you guys write proper code?
|
||||
|
||||
Many years ago, we gave up attempting to avoid warnings on every compiler
|
||||
in the universe. It just got to be a waste of time, and some compilers
|
||||
were downright silly as well as contradicted each other. So now, we simply
|
||||
make sure that the code always works.
|
||||
|
||||
36. Valgrind (or some similar memory access checker) says that deflate is
|
||||
performing a conditional jump that depends on an uninitialized value.
|
||||
Isn't that a bug?
|
||||
|
||||
No. That is intentional for performance reasons, and the output of deflate
|
||||
is not affected. This only started showing up recently since zlib 1.2.x
|
||||
uses malloc() by default for allocations, whereas earlier versions used
|
||||
calloc(), which zeros out the allocated memory. Even though the code was
|
||||
correct, versions 1.2.4 and later was changed to not stimulate these
|
||||
checkers.
|
||||
|
||||
37. Will zlib read the (insert any ancient or arcane format here) compressed
|
||||
data format?
|
||||
|
||||
Probably not. Look in the comp.compression FAQ for pointers to various
|
||||
formats and associated software.
|
||||
|
||||
38. How can I encrypt/decrypt zip files with zlib?
|
||||
|
||||
zlib doesn't support encryption. The original PKZIP encryption is very
|
||||
weak and can be broken with freely available programs. To get strong
|
||||
encryption, use GnuPG, http://www.gnupg.org/ , which already includes zlib
|
||||
compression. For PKZIP compatible "encryption", look at
|
||||
http://www.info-zip.org/
|
||||
|
||||
39. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
|
||||
|
||||
"gzip" is the gzip format, and "deflate" is the zlib format. They should
|
||||
probably have called the second one "zlib" instead to avoid confusion with
|
||||
the raw deflate compressed data format. While the HTTP 1.1 RFC 2616
|
||||
correctly points to the zlib specification in RFC 1950 for the "deflate"
|
||||
transfer encoding, there have been reports of servers and browsers that
|
||||
incorrectly produce or expect raw deflate data per the deflate
|
||||
specification in RFC 1951, most notably Microsoft. So even though the
|
||||
"deflate" transfer encoding using the zlib format would be the more
|
||||
efficient approach (and in fact exactly what the zlib format was designed
|
||||
for), using the "gzip" transfer encoding is probably more reliable due to
|
||||
an unfortunate choice of name on the part of the HTTP 1.1 authors.
|
||||
|
||||
Bottom line: use the gzip format for HTTP 1.1 encoding.
|
||||
|
||||
40. Does zlib support the new "Deflate64" format introduced by PKWare?
|
||||
|
||||
No. PKWare has apparently decided to keep that format proprietary, since
|
||||
they have not documented it as they have previous compression formats. In
|
||||
any case, the compression improvements are so modest compared to other more
|
||||
modern approaches, that it's not worth the effort to implement.
|
||||
|
||||
41. I'm having a problem with the zip functions in zlib, can you help?
|
||||
|
||||
There are no zip functions in zlib. You are probably using minizip by
|
||||
Giles Vollant, which is found in the contrib directory of zlib. It is not
|
||||
part of zlib. In fact none of the stuff in contrib is part of zlib. The
|
||||
files in there are not supported by the zlib authors. You need to contact
|
||||
the authors of the respective contribution for help.
|
||||
|
||||
42. The match.asm code in contrib is under the GNU General Public License.
|
||||
Since it's part of zlib, doesn't that mean that all of zlib falls under the
|
||||
GNU GPL?
|
||||
|
||||
No. The files in contrib are not part of zlib. They were contributed by
|
||||
other authors and are provided as a convenience to the user within the zlib
|
||||
distribution. Each item in contrib has its own license.
|
||||
|
||||
43. Is zlib subject to export controls? What is its ECCN?
|
||||
|
||||
zlib is not subject to export controls, and so is classified as EAR99.
|
||||
|
||||
44. Can you please sign these lengthy legal documents and fax them back to us
|
||||
so that we can use your software in our product?
|
||||
|
||||
No. Go away. Shoo.
|
@ -1,68 +0,0 @@
|
||||
CMakeLists.txt cmake build file
|
||||
ChangeLog history of changes
|
||||
FAQ Frequently Asked Questions about zlib
|
||||
INDEX this file
|
||||
Makefile dummy Makefile that tells you to ./configure
|
||||
Makefile.in template for Unix Makefile
|
||||
README guess what
|
||||
configure configure script for Unix
|
||||
make_vms.com makefile for VMS
|
||||
test/example.c zlib usages examples for build testing
|
||||
test/minigzip.c minimal gzip-like functionality for build testing
|
||||
test/infcover.c inf*.c code coverage for build coverage testing
|
||||
treebuild.xml XML description of source file dependencies
|
||||
zconf.h.cmakein zconf.h template for cmake
|
||||
zconf.h.in zconf.h template for configure
|
||||
zlib.3 Man page for zlib
|
||||
zlib.3.pdf Man page in PDF format
|
||||
zlib.map Linux symbol information
|
||||
zlib.pc.in Template for pkg-config descriptor
|
||||
zlib.pc.cmakein zlib.pc template for cmake
|
||||
zlib2ansi perl script to convert source files for C++ compilation
|
||||
|
||||
amiga/ makefiles for Amiga SAS C
|
||||
as400/ makefiles for AS/400
|
||||
doc/ documentation for formats and algorithms
|
||||
msdos/ makefiles for MSDOS
|
||||
nintendods/ makefile for Nintendo DS
|
||||
old/ makefiles for various architectures and zlib documentation
|
||||
files that have not yet been updated for zlib 1.2.x
|
||||
qnx/ makefiles for QNX
|
||||
watcom/ makefiles for OpenWatcom
|
||||
win32/ makefiles for Windows
|
||||
|
||||
zlib public header files (required for library use):
|
||||
zconf.h
|
||||
zlib.h
|
||||
|
||||
private source files used to build the zlib library:
|
||||
adler32.c
|
||||
compress.c
|
||||
crc32.c
|
||||
crc32.h
|
||||
deflate.c
|
||||
deflate.h
|
||||
gzclose.c
|
||||
gzguts.h
|
||||
gzlib.c
|
||||
gzread.c
|
||||
gzwrite.c
|
||||
infback.c
|
||||
inffast.c
|
||||
inffast.h
|
||||
inffixed.h
|
||||
inflate.c
|
||||
inflate.h
|
||||
inftrees.c
|
||||
inftrees.h
|
||||
trees.c
|
||||
trees.h
|
||||
uncompr.c
|
||||
zutil.c
|
||||
zutil.h
|
||||
|
||||
source files for sample programs
|
||||
See examples/README.examples
|
||||
|
||||
unsupported contributions by third parties
|
||||
See contrib/README.contrib
|
@ -1,5 +0,0 @@
|
||||
all:
|
||||
-@echo "Please use ./configure first. Thank you."
|
||||
|
||||
distclean:
|
||||
make -f Makefile.in distclean
|
@ -1,410 +0,0 @@
|
||||
# Makefile for zlib
|
||||
# Copyright (C) 1995-2017 Jean-loup Gailly, Mark Adler
|
||||
# For conditions of distribution and use, see copyright notice in zlib.h
|
||||
|
||||
# To compile and test, type:
|
||||
# ./configure; make test
|
||||
# Normally configure builds both a static and a shared library.
|
||||
# If you want to build just a static library, use: ./configure --static
|
||||
|
||||
# To use the asm code, type:
|
||||
# cp contrib/asm?86/match.S ./match.S
|
||||
# make LOC=-DASMV OBJA=match.o
|
||||
|
||||
# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
|
||||
# make install
|
||||
# To install in $HOME instead of /usr/local, use:
|
||||
# make install prefix=$HOME
|
||||
|
||||
CC=cc
|
||||
|
||||
CFLAGS=-O
|
||||
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
|
||||
#CFLAGS=-g -DZLIB_DEBUG
|
||||
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
|
||||
# -Wstrict-prototypes -Wmissing-prototypes
|
||||
|
||||
SFLAGS=-O
|
||||
LDFLAGS=
|
||||
TEST_LDFLAGS=-L. libz.a
|
||||
LDSHARED=$(CC)
|
||||
CPP=$(CC) -E
|
||||
|
||||
STATICLIB=libz.a
|
||||
SHAREDLIB=libz.so
|
||||
SHAREDLIBV=libz.so.1.2.11
|
||||
SHAREDLIBM=libz.so.1
|
||||
LIBS=$(STATICLIB) $(SHAREDLIBV)
|
||||
|
||||
AR=ar
|
||||
ARFLAGS=rc
|
||||
RANLIB=ranlib
|
||||
LDCONFIG=ldconfig
|
||||
LDSHAREDLIBC=-lc
|
||||
TAR=tar
|
||||
SHELL=/bin/sh
|
||||
EXE=
|
||||
|
||||
prefix = /usr/local
|
||||
exec_prefix = ${prefix}
|
||||
libdir = ${exec_prefix}/lib
|
||||
sharedlibdir = ${libdir}
|
||||
includedir = ${prefix}/include
|
||||
mandir = ${prefix}/share/man
|
||||
man3dir = ${mandir}/man3
|
||||
pkgconfigdir = ${libdir}/pkgconfig
|
||||
SRCDIR=
|
||||
ZINC=
|
||||
ZINCOUT=-I.
|
||||
|
||||
OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o
|
||||
OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
|
||||
OBJC = $(OBJZ) $(OBJG)
|
||||
|
||||
PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo
|
||||
PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo
|
||||
PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)
|
||||
|
||||
# to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo
|
||||
OBJA =
|
||||
PIC_OBJA =
|
||||
|
||||
OBJS = $(OBJC) $(OBJA)
|
||||
|
||||
PIC_OBJS = $(PIC_OBJC) $(PIC_OBJA)
|
||||
|
||||
all: static shared
|
||||
|
||||
static: example$(EXE) minigzip$(EXE)
|
||||
|
||||
shared: examplesh$(EXE) minigzipsh$(EXE)
|
||||
|
||||
all64: example64$(EXE) minigzip64$(EXE)
|
||||
|
||||
check: test
|
||||
|
||||
test: all teststatic testshared
|
||||
|
||||
teststatic: static
|
||||
@TMPST=tmpst_$$; \
|
||||
if echo hello world | ./minigzip | ./minigzip -d && ./example $$TMPST ; then \
|
||||
echo ' *** zlib test OK ***'; \
|
||||
else \
|
||||
echo ' *** zlib test FAILED ***'; false; \
|
||||
fi; \
|
||||
rm -f $$TMPST
|
||||
|
||||
testshared: shared
|
||||
@LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
|
||||
LD_LIBRARYN32_PATH=`pwd`:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \
|
||||
DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \
|
||||
SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \
|
||||
TMPSH=tmpsh_$$; \
|
||||
if echo hello world | ./minigzipsh | ./minigzipsh -d && ./examplesh $$TMPSH; then \
|
||||
echo ' *** zlib shared test OK ***'; \
|
||||
else \
|
||||
echo ' *** zlib shared test FAILED ***'; false; \
|
||||
fi; \
|
||||
rm -f $$TMPSH
|
||||
|
||||
test64: all64
|
||||
@TMP64=tmp64_$$; \
|
||||
if echo hello world | ./minigzip64 | ./minigzip64 -d && ./example64 $$TMP64; then \
|
||||
echo ' *** zlib 64-bit test OK ***'; \
|
||||
else \
|
||||
echo ' *** zlib 64-bit test FAILED ***'; false; \
|
||||
fi; \
|
||||
rm -f $$TMP64
|
||||
|
||||
infcover.o: $(SRCDIR)test/infcover.c $(SRCDIR)zlib.h zconf.h
|
||||
$(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/infcover.c
|
||||
|
||||
infcover: infcover.o libz.a
|
||||
$(CC) $(CFLAGS) -o $@ infcover.o libz.a
|
||||
|
||||
cover: infcover
|
||||
rm -f *.gcda
|
||||
./infcover
|
||||
gcov inf*.c
|
||||
|
||||
libz.a: $(OBJS)
|
||||
$(AR) $(ARFLAGS) $@ $(OBJS)
|
||||
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
|
||||
|
||||
match.o: match.S
|
||||
$(CPP) match.S > _match.s
|
||||
$(CC) -c _match.s
|
||||
mv _match.o match.o
|
||||
rm -f _match.s
|
||||
|
||||
match.lo: match.S
|
||||
$(CPP) match.S > _match.s
|
||||
$(CC) -c -fPIC _match.s
|
||||
mv _match.o match.lo
|
||||
rm -f _match.s
|
||||
|
||||
example.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h
|
||||
$(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/example.c
|
||||
|
||||
minigzip.o: $(SRCDIR)test/minigzip.c $(SRCDIR)zlib.h zconf.h
|
||||
$(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/minigzip.c
|
||||
|
||||
example64.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h
|
||||
$(CC) $(CFLAGS) $(ZINCOUT) -D_FILE_OFFSET_BITS=64 -c -o $@ $(SRCDIR)test/example.c
|
||||
|
||||
minigzip64.o: $(SRCDIR)test/minigzip.c $(SRCDIR)zlib.h zconf.h
|
||||
$(CC) $(CFLAGS) $(ZINCOUT) -D_FILE_OFFSET_BITS=64 -c -o $@ $(SRCDIR)test/minigzip.c
|
||||
|
||||
|
||||
adler32.o: $(SRCDIR)adler32.c
|
||||
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)adler32.c
|
||||
|
||||
crc32.o: $(SRCDIR)crc32.c
|
||||
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)crc32.c
|
||||
|
||||
deflate.o: $(SRCDIR)deflate.c
|
||||
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)deflate.c
|
||||
|
||||
infback.o: $(SRCDIR)infback.c
|
||||
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)infback.c
|
||||
|
||||
inffast.o: $(SRCDIR)inffast.c
|
||||
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inffast.c
|
||||
|
||||
inflate.o: $(SRCDIR)inflate.c
|
||||
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inflate.c
|
||||
|
||||
inftrees.o: $(SRCDIR)inftrees.c
|
||||
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inftrees.c
|
||||
|
||||
trees.o: $(SRCDIR)trees.c
|
||||
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)trees.c
|
||||
|
||||
zutil.o: $(SRCDIR)zutil.c
|
||||
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)zutil.c
|
||||
|
||||
compress.o: $(SRCDIR)compress.c
|
||||
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)compress.c
|
||||
|
||||
uncompr.o: $(SRCDIR)uncompr.c
|
||||
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)uncompr.c
|
||||
|
||||
gzclose.o: $(SRCDIR)gzclose.c
|
||||
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzclose.c
|
||||
|
||||
gzlib.o: $(SRCDIR)gzlib.c
|
||||
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzlib.c
|
||||
|
||||
gzread.o: $(SRCDIR)gzread.c
|
||||
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzread.c
|
||||
|
||||
gzwrite.o: $(SRCDIR)gzwrite.c
|
||||
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzwrite.c
|
||||
|
||||
|
||||
adler32.lo: $(SRCDIR)adler32.c
|
||||
-@mkdir objs 2>/dev/null || test -d objs
|
||||
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/adler32.o $(SRCDIR)adler32.c
|
||||
-@mv objs/adler32.o $@
|
||||
|
||||
crc32.lo: $(SRCDIR)crc32.c
|
||||
-@mkdir objs 2>/dev/null || test -d objs
|
||||
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/crc32.o $(SRCDIR)crc32.c
|
||||
-@mv objs/crc32.o $@
|
||||
|
||||
deflate.lo: $(SRCDIR)deflate.c
|
||||
-@mkdir objs 2>/dev/null || test -d objs
|
||||
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/deflate.o $(SRCDIR)deflate.c
|
||||
-@mv objs/deflate.o $@
|
||||
|
||||
infback.lo: $(SRCDIR)infback.c
|
||||
-@mkdir objs 2>/dev/null || test -d objs
|
||||
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/infback.o $(SRCDIR)infback.c
|
||||
-@mv objs/infback.o $@
|
||||
|
||||
inffast.lo: $(SRCDIR)inffast.c
|
||||
-@mkdir objs 2>/dev/null || test -d objs
|
||||
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/inffast.o $(SRCDIR)inffast.c
|
||||
-@mv objs/inffast.o $@
|
||||
|
||||
inflate.lo: $(SRCDIR)inflate.c
|
||||
-@mkdir objs 2>/dev/null || test -d objs
|
||||
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/inflate.o $(SRCDIR)inflate.c
|
||||
-@mv objs/inflate.o $@
|
||||
|
||||
inftrees.lo: $(SRCDIR)inftrees.c
|
||||
-@mkdir objs 2>/dev/null || test -d objs
|
||||
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/inftrees.o $(SRCDIR)inftrees.c
|
||||
-@mv objs/inftrees.o $@
|
||||
|
||||
trees.lo: $(SRCDIR)trees.c
|
||||
-@mkdir objs 2>/dev/null || test -d objs
|
||||
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/trees.o $(SRCDIR)trees.c
|
||||
-@mv objs/trees.o $@
|
||||
|
||||
zutil.lo: $(SRCDIR)zutil.c
|
||||
-@mkdir objs 2>/dev/null || test -d objs
|
||||
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/zutil.o $(SRCDIR)zutil.c
|
||||
-@mv objs/zutil.o $@
|
||||
|
||||
compress.lo: $(SRCDIR)compress.c
|
||||
-@mkdir objs 2>/dev/null || test -d objs
|
||||
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/compress.o $(SRCDIR)compress.c
|
||||
-@mv objs/compress.o $@
|
||||
|
||||
uncompr.lo: $(SRCDIR)uncompr.c
|
||||
-@mkdir objs 2>/dev/null || test -d objs
|
||||
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/uncompr.o $(SRCDIR)uncompr.c
|
||||
-@mv objs/uncompr.o $@
|
||||
|
||||
gzclose.lo: $(SRCDIR)gzclose.c
|
||||
-@mkdir objs 2>/dev/null || test -d objs
|
||||
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzclose.o $(SRCDIR)gzclose.c
|
||||
-@mv objs/gzclose.o $@
|
||||
|
||||
gzlib.lo: $(SRCDIR)gzlib.c
|
||||
-@mkdir objs 2>/dev/null || test -d objs
|
||||
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzlib.o $(SRCDIR)gzlib.c
|
||||
-@mv objs/gzlib.o $@
|
||||
|
||||
gzread.lo: $(SRCDIR)gzread.c
|
||||
-@mkdir objs 2>/dev/null || test -d objs
|
||||
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzread.o $(SRCDIR)gzread.c
|
||||
-@mv objs/gzread.o $@
|
||||
|
||||
gzwrite.lo: $(SRCDIR)gzwrite.c
|
||||
-@mkdir objs 2>/dev/null || test -d objs
|
||||
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzwrite.o $(SRCDIR)gzwrite.c
|
||||
-@mv objs/gzwrite.o $@
|
||||
|
||||
|
||||
placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
|
||||
$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
|
||||
rm -f $(SHAREDLIB) $(SHAREDLIBM)
|
||||
ln -s $@ $(SHAREDLIB)
|
||||
ln -s $@ $(SHAREDLIBM)
|
||||
-@rmdir objs
|
||||
|
||||
example$(EXE): example.o $(STATICLIB)
|
||||
$(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS)
|
||||
|
||||
minigzip$(EXE): minigzip.o $(STATICLIB)
|
||||
$(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS)
|
||||
|
||||
examplesh$(EXE): example.o $(SHAREDLIBV)
|
||||
$(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV)
|
||||
|
||||
minigzipsh$(EXE): minigzip.o $(SHAREDLIBV)
|
||||
$(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV)
|
||||
|
||||
example64$(EXE): example64.o $(STATICLIB)
|
||||
$(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS)
|
||||
|
||||
minigzip64$(EXE): minigzip64.o $(STATICLIB)
|
||||
$(CC) $(CFLAGS) -o $@ minigzip64.o $(TEST_LDFLAGS)
|
||||
|
||||
install-libs: $(LIBS)
|
||||
-@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi
|
||||
-@if [ ! -d $(DESTDIR)$(libdir) ]; then mkdir -p $(DESTDIR)$(libdir); fi
|
||||
-@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi
|
||||
-@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi
|
||||
-@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
|
||||
rm -f $(DESTDIR)$(libdir)/$(STATICLIB)
|
||||
cp $(STATICLIB) $(DESTDIR)$(libdir)
|
||||
chmod 644 $(DESTDIR)$(libdir)/$(STATICLIB)
|
||||
-@($(RANLIB) $(DESTDIR)$(libdir)/libz.a || true) >/dev/null 2>&1
|
||||
-@if test -n "$(SHAREDLIBV)"; then \
|
||||
rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \
|
||||
cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir); \
|
||||
echo "cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)"; \
|
||||
chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \
|
||||
echo "chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV)"; \
|
||||
rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
|
||||
ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB); \
|
||||
ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
|
||||
($(LDCONFIG) || true) >/dev/null 2>&1; \
|
||||
fi
|
||||
rm -f $(DESTDIR)$(man3dir)/zlib.3
|
||||
cp $(SRCDIR)zlib.3 $(DESTDIR)$(man3dir)
|
||||
chmod 644 $(DESTDIR)$(man3dir)/zlib.3
|
||||
rm -f $(DESTDIR)$(pkgconfigdir)/zlib.pc
|
||||
cp zlib.pc $(DESTDIR)$(pkgconfigdir)
|
||||
chmod 644 $(DESTDIR)$(pkgconfigdir)/zlib.pc
|
||||
# The ranlib in install is needed on NeXTSTEP which checks file times
|
||||
# ldconfig is for Linux
|
||||
|
||||
install: install-libs
|
||||
-@if [ ! -d $(DESTDIR)$(includedir) ]; then mkdir -p $(DESTDIR)$(includedir); fi
|
||||
rm -f $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h
|
||||
cp $(SRCDIR)zlib.h zconf.h $(DESTDIR)$(includedir)
|
||||
chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h
|
||||
|
||||
uninstall:
|
||||
cd $(DESTDIR)$(includedir) && rm -f zlib.h zconf.h
|
||||
cd $(DESTDIR)$(libdir) && rm -f libz.a; \
|
||||
if test -n "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \
|
||||
rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
|
||||
fi
|
||||
cd $(DESTDIR)$(man3dir) && rm -f zlib.3
|
||||
cd $(DESTDIR)$(pkgconfigdir) && rm -f zlib.pc
|
||||
|
||||
docs: zlib.3.pdf
|
||||
|
||||
zlib.3.pdf: $(SRCDIR)zlib.3
|
||||
groff -mandoc -f H -T ps $(SRCDIR)zlib.3 | ps2pdf - $@
|
||||
|
||||
zconf.h.cmakein: $(SRCDIR)zconf.h.in
|
||||
-@ TEMPFILE=zconfh_$$; \
|
||||
echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" >> $$TEMPFILE &&\
|
||||
sed -f $$TEMPFILE $(SRCDIR)zconf.h.in > $@ &&\
|
||||
touch -r $(SRCDIR)zconf.h.in $@ &&\
|
||||
rm $$TEMPFILE
|
||||
|
||||
zconf: $(SRCDIR)zconf.h.in
|
||||
cp -p $(SRCDIR)zconf.h.in zconf.h
|
||||
|
||||
mostlyclean: clean
|
||||
clean:
|
||||
rm -f *.o *.lo *~ \
|
||||
example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
|
||||
example64$(EXE) minigzip64$(EXE) \
|
||||
infcover \
|
||||
libz.* foo.gz so_locations \
|
||||
_match.s maketree contrib/infback9/*.o
|
||||
rm -rf objs
|
||||
rm -f *.gcda *.gcno *.gcov
|
||||
rm -f contrib/infback9/*.gcda contrib/infback9/*.gcno contrib/infback9/*.gcov
|
||||
|
||||
maintainer-clean: distclean
|
||||
distclean: clean zconf zconf.h.cmakein docs
|
||||
rm -f Makefile zlib.pc configure.log
|
||||
-@rm -f .DS_Store
|
||||
@if [ -f Makefile.in ]; then \
|
||||
printf 'all:\n\t-@echo "Please use ./configure first. Thank you."\n' > Makefile ; \
|
||||
printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile ; \
|
||||
touch -r $(SRCDIR)Makefile.in Makefile ; fi
|
||||
@if [ ! -f zconf.h.in ]; then rm -f zconf.h zconf.h.cmakein ; fi
|
||||
@if [ ! -f zlib.3 ]; then rm -f zlib.3.pdf ; fi
|
||||
|
||||
tags:
|
||||
etags $(SRCDIR)*.[ch]
|
||||
|
||||
adler32.o zutil.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
|
||||
gzclose.o gzlib.o gzread.o gzwrite.o: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
|
||||
compress.o example.o minigzip.o uncompr.o: $(SRCDIR)zlib.h zconf.h
|
||||
crc32.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h
|
||||
deflate.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
|
||||
infback.o inflate.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h $(SRCDIR)inffixed.h
|
||||
inffast.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
|
||||
inftrees.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
|
||||
trees.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
|
||||
|
||||
adler32.lo zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
|
||||
gzclose.lo gzlib.lo gzread.lo gzwrite.lo: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
|
||||
compress.lo example.lo minigzip.lo uncompr.lo: $(SRCDIR)zlib.h zconf.h
|
||||
crc32.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h
|
||||
deflate.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
|
||||
infback.lo inflate.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h $(SRCDIR)inffixed.h
|
||||
inffast.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
|
||||
inftrees.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
|
||||
trees.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
|
@ -1,115 +0,0 @@
|
||||
ZLIB DATA COMPRESSION LIBRARY
|
||||
|
||||
zlib 1.2.11 is a general purpose data compression library. All the code is
|
||||
thread safe. The data format used by the zlib library is described by RFCs
|
||||
(Request for Comments) 1950 to 1952 in the files
|
||||
http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
|
||||
rfc1952 (gzip format).
|
||||
|
||||
All functions of the compression library are documented in the file zlib.h
|
||||
(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example
|
||||
of the library is given in the file test/example.c which also tests that
|
||||
the library is working correctly. Another example is given in the file
|
||||
test/minigzip.c. The compression library itself is composed of all source
|
||||
files in the root directory.
|
||||
|
||||
To compile all files and run the test program, follow the instructions given at
|
||||
the top of Makefile.in. In short "./configure; make test", and if that goes
|
||||
well, "make install" should work for most flavors of Unix. For Windows, use
|
||||
one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use
|
||||
make_vms.com.
|
||||
|
||||
Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant
|
||||
<info@winimage.com> for the Windows DLL version. The zlib home page is
|
||||
http://zlib.net/ . Before reporting a problem, please check this site to
|
||||
verify that you have the latest version of zlib; otherwise get the latest
|
||||
version and check whether the problem still exists or not.
|
||||
|
||||
PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help.
|
||||
|
||||
Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
|
||||
issue of Dr. Dobb's Journal; a copy of the article is available at
|
||||
http://marknelson.us/1997/01/01/zlib-engine/ .
|
||||
|
||||
The changes made in version 1.2.11 are documented in the file ChangeLog.
|
||||
|
||||
Unsupported third party contributions are provided in directory contrib/ .
|
||||
|
||||
zlib is available in Java using the java.util.zip package, documented at
|
||||
http://java.sun.com/developer/technicalArticles/Programming/compression/ .
|
||||
|
||||
A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is available
|
||||
at CPAN (Comprehensive Perl Archive Network) sites, including
|
||||
http://search.cpan.org/~pmqs/IO-Compress-Zlib/ .
|
||||
|
||||
A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
|
||||
available in Python 1.5 and later versions, see
|
||||
http://docs.python.org/library/zlib.html .
|
||||
|
||||
zlib is built into tcl: http://wiki.tcl.tk/4610 .
|
||||
|
||||
An experimental package to read and write files in .zip format, written on top
|
||||
of zlib by Gilles Vollant <info@winimage.com>, is available in the
|
||||
contrib/minizip directory of zlib.
|
||||
|
||||
|
||||
Notes for some targets:
|
||||
|
||||
- For Windows DLL versions, please see win32/DLL_FAQ.txt
|
||||
|
||||
- For 64-bit Irix, deflate.c must be compiled without any optimization. With
|
||||
-O, one libpng test fails. The test works in 32 bit mode (with the -n32
|
||||
compiler flag). The compiler bug has been reported to SGI.
|
||||
|
||||
- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works
|
||||
when compiled with cc.
|
||||
|
||||
- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is
|
||||
necessary to get gzprintf working correctly. This is done by configure.
|
||||
|
||||
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
|
||||
other compilers. Use "make test" to check your compiler.
|
||||
|
||||
- gzdopen is not supported on RISCOS or BEOS.
|
||||
|
||||
- For PalmOs, see http://palmzlib.sourceforge.net/
|
||||
|
||||
|
||||
Acknowledgments:
|
||||
|
||||
The deflate format used by zlib was defined by Phil Katz. The deflate and
|
||||
zlib specifications were written by L. Peter Deutsch. Thanks to all the
|
||||
people who reported problems and suggested various improvements in zlib; they
|
||||
are too numerous to cite here.
|
||||
|
||||
Copyright notice:
|
||||
|
||||
(C) 1995-2017 Jean-loup Gailly and Mark Adler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jean-loup Gailly Mark Adler
|
||||
jloup@gzip.org madler@alumni.caltech.edu
|
||||
|
||||
If you use the zlib library in a product, we would appreciate *not* receiving
|
||||
lengthy legal documents to sign. The sources are provided for free but without
|
||||
warranty of any kind. The library has been entirely written by Jean-loup
|
||||
Gailly and Mark Adler; it does not include third-party code.
|
||||
|
||||
If you redistribute modified sources, we would appreciate that you include in
|
||||
the file ChangeLog history information documenting your changes. Please read
|
||||
the FAQ for more information on the distribution of modified source versions.
|
@ -1,186 +0,0 @@
|
||||
/* adler32.c -- compute the Adler-32 checksum of a data stream
|
||||
* Copyright (C) 1995-2011, 2016 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
#include "zutil.h"
|
||||
|
||||
local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
|
||||
|
||||
#define BASE 65521U /* largest prime smaller than 65536 */
|
||||
#define NMAX 5552
|
||||
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
||||
|
||||
#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
|
||||
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
|
||||
#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
|
||||
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
|
||||
#define DO16(buf) DO8(buf,0); DO8(buf,8);
|
||||
|
||||
/* use NO_DIVIDE if your processor does not do division in hardware --
|
||||
try it both ways to see which is faster */
|
||||
#ifdef NO_DIVIDE
|
||||
/* note that this assumes BASE is 65521, where 65536 % 65521 == 15
|
||||
(thank you to John Reiser for pointing this out) */
|
||||
# define CHOP(a) \
|
||||
do { \
|
||||
unsigned long tmp = a >> 16; \
|
||||
a &= 0xffffUL; \
|
||||
a += (tmp << 4) - tmp; \
|
||||
} while (0)
|
||||
# define MOD28(a) \
|
||||
do { \
|
||||
CHOP(a); \
|
||||
if (a >= BASE) a -= BASE; \
|
||||
} while (0)
|
||||
# define MOD(a) \
|
||||
do { \
|
||||
CHOP(a); \
|
||||
MOD28(a); \
|
||||
} while (0)
|
||||
# define MOD63(a) \
|
||||
do { /* this assumes a is not negative */ \
|
||||
z_off64_t tmp = a >> 32; \
|
||||
a &= 0xffffffffL; \
|
||||
a += (tmp << 8) - (tmp << 5) + tmp; \
|
||||
tmp = a >> 16; \
|
||||
a &= 0xffffL; \
|
||||
a += (tmp << 4) - tmp; \
|
||||
tmp = a >> 16; \
|
||||
a &= 0xffffL; \
|
||||
a += (tmp << 4) - tmp; \
|
||||
if (a >= BASE) a -= BASE; \
|
||||
} while (0)
|
||||
#else
|
||||
# define MOD(a) a %= BASE
|
||||
# define MOD28(a) a %= BASE
|
||||
# define MOD63(a) a %= BASE
|
||||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
uLong ZEXPORT adler32_z(adler, buf, len)
|
||||
uLong adler;
|
||||
const Bytef *buf;
|
||||
z_size_t len;
|
||||
{
|
||||
unsigned long sum2;
|
||||
unsigned n;
|
||||
|
||||
/* split Adler-32 into component sums */
|
||||
sum2 = (adler >> 16) & 0xffff;
|
||||
adler &= 0xffff;
|
||||
|
||||
/* in case user likes doing a byte at a time, keep it fast */
|
||||
if (len == 1) {
|
||||
adler += buf[0];
|
||||
if (adler >= BASE)
|
||||
adler -= BASE;
|
||||
sum2 += adler;
|
||||
if (sum2 >= BASE)
|
||||
sum2 -= BASE;
|
||||
return adler | (sum2 << 16);
|
||||
}
|
||||
|
||||
/* initial Adler-32 value (deferred check for len == 1 speed) */
|
||||
if (buf == Z_NULL)
|
||||
return 1L;
|
||||
|
||||
/* in case short lengths are provided, keep it somewhat fast */
|
||||
if (len < 16) {
|
||||
while (len--) {
|
||||
adler += *buf++;
|
||||
sum2 += adler;
|
||||
}
|
||||
if (adler >= BASE)
|
||||
adler -= BASE;
|
||||
MOD28(sum2); /* only added so many BASE's */
|
||||
return adler | (sum2 << 16);
|
||||
}
|
||||
|
||||
/* do length NMAX blocks -- requires just one modulo operation */
|
||||
while (len >= NMAX) {
|
||||
len -= NMAX;
|
||||
n = NMAX / 16; /* NMAX is divisible by 16 */
|
||||
do {
|
||||
DO16(buf); /* 16 sums unrolled */
|
||||
buf += 16;
|
||||
} while (--n);
|
||||
MOD(adler);
|
||||
MOD(sum2);
|
||||
}
|
||||
|
||||
/* do remaining bytes (less than NMAX, still just one modulo) */
|
||||
if (len) { /* avoid modulos if none remaining */
|
||||
while (len >= 16) {
|
||||
len -= 16;
|
||||
DO16(buf);
|
||||
buf += 16;
|
||||
}
|
||||
while (len--) {
|
||||
adler += *buf++;
|
||||
sum2 += adler;
|
||||
}
|
||||
MOD(adler);
|
||||
MOD(sum2);
|
||||
}
|
||||
|
||||
/* return recombined sums */
|
||||
return adler | (sum2 << 16);
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
uLong ZEXPORT adler32(adler, buf, len)
|
||||
uLong adler;
|
||||
const Bytef *buf;
|
||||
uInt len;
|
||||
{
|
||||
return adler32_z(adler, buf, len);
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
local uLong adler32_combine_(adler1, adler2, len2)
|
||||
uLong adler1;
|
||||
uLong adler2;
|
||||
z_off64_t len2;
|
||||
{
|
||||
unsigned long sum1;
|
||||
unsigned long sum2;
|
||||
unsigned rem;
|
||||
|
||||
/* for negative len, return invalid adler32 as a clue for debugging */
|
||||
if (len2 < 0)
|
||||
return 0xffffffffUL;
|
||||
|
||||
/* the derivation of this formula is left as an exercise for the reader */
|
||||
MOD63(len2); /* assumes len2 >= 0 */
|
||||
rem = (unsigned)len2;
|
||||
sum1 = adler1 & 0xffff;
|
||||
sum2 = rem * sum1;
|
||||
MOD(sum2);
|
||||
sum1 += (adler2 & 0xffff) + BASE - 1;
|
||||
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
|
||||
if (sum1 >= BASE) sum1 -= BASE;
|
||||
if (sum1 >= BASE) sum1 -= BASE;
|
||||
if (sum2 >= ((unsigned long)BASE << 1)) sum2 -= ((unsigned long)BASE << 1);
|
||||
if (sum2 >= BASE) sum2 -= BASE;
|
||||
return sum1 | (sum2 << 16);
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
uLong ZEXPORT adler32_combine(adler1, adler2, len2)
|
||||
uLong adler1;
|
||||
uLong adler2;
|
||||
z_off_t len2;
|
||||
{
|
||||
return adler32_combine_(adler1, adler2, len2);
|
||||
}
|
||||
|
||||
uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
|
||||
uLong adler1;
|
||||
uLong adler2;
|
||||
z_off64_t len2;
|
||||
{
|
||||
return adler32_combine_(adler1, adler2, len2);
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
# Amiga powerUP (TM) Makefile
|
||||
# makefile for libpng and SAS C V6.58/7.00 PPC compiler
|
||||
# Copyright (C) 1998 by Andreas R. Kleinert
|
||||
|
||||
LIBNAME = libzip.a
|
||||
|
||||
CC = scppc
|
||||
CFLAGS = NOSTKCHK NOSINT OPTIMIZE OPTGO OPTPEEP OPTINLOCAL OPTINL \
|
||||
OPTLOOP OPTRDEP=8 OPTDEP=8 OPTCOMP=8 NOVER
|
||||
AR = ppc-amigaos-ar cr
|
||||
RANLIB = ppc-amigaos-ranlib
|
||||
LD = ppc-amigaos-ld -r
|
||||
LDFLAGS = -o
|
||||
LDLIBS = LIB:scppc.a LIB:end.o
|
||||
RM = delete quiet
|
||||
|
||||
OBJS = adler32.o compress.o crc32.o gzclose.o gzlib.o gzread.o gzwrite.o \
|
||||
uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o
|
||||
|
||||
TEST_OBJS = example.o minigzip.o
|
||||
|
||||
all: example minigzip
|
||||
|
||||
check: test
|
||||
test: all
|
||||
example
|
||||
echo hello world | minigzip | minigzip -d
|
||||
|
||||
$(LIBNAME): $(OBJS)
|
||||
$(AR) $@ $(OBJS)
|
||||
-$(RANLIB) $@
|
||||
|
||||
example: example.o $(LIBNAME)
|
||||
$(LD) $(LDFLAGS) $@ LIB:c_ppc.o $@.o $(LIBNAME) $(LDLIBS)
|
||||
|
||||
minigzip: minigzip.o $(LIBNAME)
|
||||
$(LD) $(LDFLAGS) $@ LIB:c_ppc.o $@.o $(LIBNAME) $(LDLIBS)
|
||||
|
||||
mostlyclean: clean
|
||||
clean:
|
||||
$(RM) *.o example minigzip $(LIBNAME) foo.gz
|
||||
|
||||
zip:
|
||||
zip -ul9 zlib README ChangeLog Makefile Make????.??? Makefile.?? \
|
||||
descrip.mms *.[ch]
|
||||
|
||||
tgz:
|
||||
cd ..; tar cfz zlib/zlib.tgz zlib/README zlib/ChangeLog zlib/Makefile \
|
||||
zlib/Make????.??? zlib/Makefile.?? zlib/descrip.mms zlib/*.[ch]
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
adler32.o: zlib.h zconf.h
|
||||
compress.o: zlib.h zconf.h
|
||||
crc32.o: crc32.h zlib.h zconf.h
|
||||
deflate.o: deflate.h zutil.h zlib.h zconf.h
|
||||
example.o: zlib.h zconf.h
|
||||
gzclose.o: zlib.h zconf.h gzguts.h
|
||||
gzlib.o: zlib.h zconf.h gzguts.h
|
||||
gzread.o: zlib.h zconf.h gzguts.h
|
||||
gzwrite.o: zlib.h zconf.h gzguts.h
|
||||
inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
|
||||
inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
|
||||
infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
|
||||
inftrees.o: zutil.h zlib.h zconf.h inftrees.h
|
||||
minigzip.o: zlib.h zconf.h
|
||||
trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
|
||||
uncompr.o: zlib.h zconf.h
|
||||
zutil.o: zutil.h zlib.h zconf.h
|
@ -1,68 +0,0 @@
|
||||
# SMakefile for zlib
|
||||
# Modified from the standard UNIX Makefile Copyright Jean-loup Gailly
|
||||
# Osma Ahvenlampi <Osma.Ahvenlampi@hut.fi>
|
||||
# Amiga, SAS/C 6.56 & Smake
|
||||
|
||||
CC=sc
|
||||
CFLAGS=OPT
|
||||
#CFLAGS=OPT CPU=68030
|
||||
#CFLAGS=DEBUG=LINE
|
||||
LDFLAGS=LIB z.lib
|
||||
|
||||
SCOPTIONS=OPTSCHED OPTINLINE OPTALIAS OPTTIME OPTINLOCAL STRMERGE \
|
||||
NOICONS PARMS=BOTH NOSTACKCHECK UTILLIB NOVERSION ERRORREXX \
|
||||
DEF=POSTINC
|
||||
|
||||
OBJS = adler32.o compress.o crc32.o gzclose.o gzlib.o gzread.o gzwrite.o \
|
||||
uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o
|
||||
|
||||
TEST_OBJS = example.o minigzip.o
|
||||
|
||||
all: SCOPTIONS example minigzip
|
||||
|
||||
check: test
|
||||
test: all
|
||||
example
|
||||
echo hello world | minigzip | minigzip -d
|
||||
|
||||
install: z.lib
|
||||
copy clone zlib.h zconf.h INCLUDE:
|
||||
copy clone z.lib LIB:
|
||||
|
||||
z.lib: $(OBJS)
|
||||
oml z.lib r $(OBJS)
|
||||
|
||||
example: example.o z.lib
|
||||
$(CC) $(CFLAGS) LINK TO $@ example.o $(LDFLAGS)
|
||||
|
||||
minigzip: minigzip.o z.lib
|
||||
$(CC) $(CFLAGS) LINK TO $@ minigzip.o $(LDFLAGS)
|
||||
|
||||
mostlyclean: clean
|
||||
clean:
|
||||
-delete force quiet example minigzip *.o z.lib foo.gz *.lnk SCOPTIONS
|
||||
|
||||
SCOPTIONS: Makefile.sas
|
||||
copy to $@ <from <
|
||||
$(SCOPTIONS)
|
||||
<
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
adler32.o: zlib.h zconf.h
|
||||
compress.o: zlib.h zconf.h
|
||||
crc32.o: crc32.h zlib.h zconf.h
|
||||
deflate.o: deflate.h zutil.h zlib.h zconf.h
|
||||
example.o: zlib.h zconf.h
|
||||
gzclose.o: zlib.h zconf.h gzguts.h
|
||||
gzlib.o: zlib.h zconf.h gzguts.h
|
||||
gzread.o: zlib.h zconf.h gzguts.h
|
||||
gzwrite.o: zlib.h zconf.h gzguts.h
|
||||
inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
|
||||
inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
|
||||
infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
|
||||
inftrees.o: zutil.h zlib.h zconf.h inftrees.h
|
||||
minigzip.o: zlib.h zconf.h
|
||||
trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
|
||||
uncompr.o: zlib.h zconf.h
|
||||
zutil.o: zutil.h zlib.h zconf.h
|
@ -1,86 +0,0 @@
|
||||
/* compress.c -- compress a memory buffer
|
||||
* Copyright (C) 1995-2005, 2014, 2016 Jean-loup Gailly, Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
#define ZLIB_INTERNAL
|
||||
#include "zlib.h"
|
||||
|
||||
/* ===========================================================================
|
||||
Compresses the source buffer into the destination buffer. The level
|
||||
parameter has the same meaning as in deflateInit. sourceLen is the byte
|
||||
length of the source buffer. Upon entry, destLen is the total size of the
|
||||
destination buffer, which must be at least 0.1% larger than sourceLen plus
|
||||
12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
|
||||
|
||||
compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
|
||||
Z_STREAM_ERROR if the level parameter is invalid.
|
||||
*/
|
||||
int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
|
||||
Bytef *dest;
|
||||
uLongf *destLen;
|
||||
const Bytef *source;
|
||||
uLong sourceLen;
|
||||
int level;
|
||||
{
|
||||
z_stream stream;
|
||||
int err;
|
||||
const uInt max = (uInt)-1;
|
||||
uLong left;
|
||||
|
||||
left = *destLen;
|
||||
*destLen = 0;
|
||||
|
||||
stream.zalloc = (alloc_func)0;
|
||||
stream.zfree = (free_func)0;
|
||||
stream.opaque = (voidpf)0;
|
||||
|
||||
err = deflateInit(&stream, level);
|
||||
if (err != Z_OK) return err;
|
||||
|
||||
stream.next_out = dest;
|
||||
stream.avail_out = 0;
|
||||
stream.next_in = (z_const Bytef *)source;
|
||||
stream.avail_in = 0;
|
||||
|
||||
do {
|
||||
if (stream.avail_out == 0) {
|
||||
stream.avail_out = left > (uLong)max ? max : (uInt)left;
|
||||
left -= stream.avail_out;
|
||||
}
|
||||
if (stream.avail_in == 0) {
|
||||
stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen;
|
||||
sourceLen -= stream.avail_in;
|
||||
}
|
||||
err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH);
|
||||
} while (err == Z_OK);
|
||||
|
||||
*destLen = stream.total_out;
|
||||
deflateEnd(&stream);
|
||||
return err == Z_STREAM_END ? Z_OK : err;
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
*/
|
||||
int ZEXPORT compress (dest, destLen, source, sourceLen)
|
||||
Bytef *dest;
|
||||
uLongf *destLen;
|
||||
const Bytef *source;
|
||||
uLong sourceLen;
|
||||
{
|
||||
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
If the default memLevel or windowBits for deflateInit() is changed, then
|
||||
this function needs to be updated.
|
||||
*/
|
||||
uLong ZEXPORT compressBound (sourceLen)
|
||||
uLong sourceLen;
|
||||
{
|
||||
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
|
||||
(sourceLen >> 25) + 13;
|
||||
}
|
921
src/png/zlib/configure
vendored
921
src/png/zlib/configure
vendored
@ -1,921 +0,0 @@
|
||||
#!/bin/sh
|
||||
# configure script for zlib.
|
||||
#
|
||||
# Normally configure builds both a static and a shared library.
|
||||
# If you want to build just a static library, use: ./configure --static
|
||||
#
|
||||
# To impose specific compiler or flags or install directory, use for example:
|
||||
# prefix=$HOME CC=cc CFLAGS="-O4" ./configure
|
||||
# or for csh/tcsh users:
|
||||
# (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure)
|
||||
|
||||
# Incorrect settings of CC or CFLAGS may prevent creating a shared library.
|
||||
# If you have problems, try without defining CC and CFLAGS before reporting
|
||||
# an error.
|
||||
|
||||
# start off configure.log
|
||||
echo -------------------- >> configure.log
|
||||
echo $0 $* >> configure.log
|
||||
date >> configure.log
|
||||
|
||||
# get source directory
|
||||
SRCDIR=`dirname $0`
|
||||
if test $SRCDIR = "."; then
|
||||
ZINC=""
|
||||
ZINCOUT="-I."
|
||||
SRCDIR=""
|
||||
else
|
||||
ZINC='-include zconf.h'
|
||||
ZINCOUT='-I. -I$(SRCDIR)'
|
||||
SRCDIR="$SRCDIR/"
|
||||
fi
|
||||
|
||||
# set command prefix for cross-compilation
|
||||
if [ -n "${CHOST}" ]; then
|
||||
uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`"
|
||||
CROSS_PREFIX="${CHOST}-"
|
||||
fi
|
||||
|
||||
# destination name for static library
|
||||
STATICLIB=libz.a
|
||||
|
||||
# extract zlib version numbers from zlib.h
|
||||
VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}zlib.h`
|
||||
VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < ${SRCDIR}zlib.h`
|
||||
VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
|
||||
VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
|
||||
|
||||
# establish commands for library building
|
||||
if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then
|
||||
AR=${AR-"${CROSS_PREFIX}ar"}
|
||||
test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
|
||||
else
|
||||
AR=${AR-"ar"}
|
||||
test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
|
||||
fi
|
||||
ARFLAGS=${ARFLAGS-"rc"}
|
||||
if "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null || test $? -lt 126; then
|
||||
RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"}
|
||||
test -n "${CROSS_PREFIX}" && echo Using ${RANLIB} | tee -a configure.log
|
||||
else
|
||||
RANLIB=${RANLIB-"ranlib"}
|
||||
fi
|
||||
if "${CROSS_PREFIX}nm" --version >/dev/null 2>/dev/null || test $? -lt 126; then
|
||||
NM=${NM-"${CROSS_PREFIX}nm"}
|
||||
test -n "${CROSS_PREFIX}" && echo Using ${NM} | tee -a configure.log
|
||||
else
|
||||
NM=${NM-"nm"}
|
||||
fi
|
||||
|
||||
# set defaults before processing command line options
|
||||
LDCONFIG=${LDCONFIG-"ldconfig"}
|
||||
LDSHAREDLIBC="${LDSHAREDLIBC--lc}"
|
||||
ARCHS=
|
||||
prefix=${prefix-/usr/local}
|
||||
exec_prefix=${exec_prefix-'${prefix}'}
|
||||
libdir=${libdir-'${exec_prefix}/lib'}
|
||||
sharedlibdir=${sharedlibdir-'${libdir}'}
|
||||
includedir=${includedir-'${prefix}/include'}
|
||||
mandir=${mandir-'${prefix}/share/man'}
|
||||
shared_ext='.so'
|
||||
shared=1
|
||||
solo=0
|
||||
cover=0
|
||||
zprefix=0
|
||||
zconst=0
|
||||
build64=0
|
||||
gcc=0
|
||||
warn=0
|
||||
debug=0
|
||||
old_cc="$CC"
|
||||
old_cflags="$CFLAGS"
|
||||
OBJC='$(OBJZ) $(OBJG)'
|
||||
PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)'
|
||||
|
||||
# leave this script, optionally in a bad way
|
||||
leave()
|
||||
{
|
||||
if test "$*" != "0"; then
|
||||
echo "** $0 aborting." | tee -a configure.log
|
||||
fi
|
||||
rm -f $test.[co] $test $test$shared_ext $test.gcno ./--version
|
||||
echo -------------------- >> configure.log
|
||||
echo >> configure.log
|
||||
echo >> configure.log
|
||||
exit $1
|
||||
}
|
||||
|
||||
# process command line options
|
||||
while test $# -ge 1
|
||||
do
|
||||
case "$1" in
|
||||
-h* | --help)
|
||||
echo 'usage:' | tee -a configure.log
|
||||
echo ' configure [--const] [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log
|
||||
echo ' [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log
|
||||
echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log
|
||||
exit 0 ;;
|
||||
-p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;;
|
||||
-e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;;
|
||||
-l*=* | --libdir=*) libdir=`echo $1 | sed 's/.*=//'`; shift ;;
|
||||
--sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/.*=//'`; shift ;;
|
||||
-i*=* | --includedir=*) includedir=`echo $1 | sed 's/.*=//'`;shift ;;
|
||||
-u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;;
|
||||
-p* | --prefix) prefix="$2"; shift; shift ;;
|
||||
-e* | --eprefix) exec_prefix="$2"; shift; shift ;;
|
||||
-l* | --libdir) libdir="$2"; shift; shift ;;
|
||||
-i* | --includedir) includedir="$2"; shift; shift ;;
|
||||
-s* | --shared | --enable-shared) shared=1; shift ;;
|
||||
-t | --static) shared=0; shift ;;
|
||||
--solo) solo=1; shift ;;
|
||||
--cover) cover=1; shift ;;
|
||||
-z* | --zprefix) zprefix=1; shift ;;
|
||||
-6* | --64) build64=1; shift ;;
|
||||
-a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
|
||||
--sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;;
|
||||
--localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;;
|
||||
-c* | --const) zconst=1; shift ;;
|
||||
-w* | --warn) warn=1; shift ;;
|
||||
-d* | --debug) debug=1; shift ;;
|
||||
*)
|
||||
echo "unknown option: $1" | tee -a configure.log
|
||||
echo "$0 --help for help" | tee -a configure.log
|
||||
leave 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
# temporary file name
|
||||
test=ztest$$
|
||||
|
||||
# put arguments in log, also put test file in log if used in arguments
|
||||
show()
|
||||
{
|
||||
case "$*" in
|
||||
*$test.c*)
|
||||
echo === $test.c === >> configure.log
|
||||
cat $test.c >> configure.log
|
||||
echo === >> configure.log;;
|
||||
esac
|
||||
echo $* >> configure.log
|
||||
}
|
||||
|
||||
# check for gcc vs. cc and set compile and link flags based on the system identified by uname
|
||||
cat > $test.c <<EOF
|
||||
extern int getchar();
|
||||
int hello() {return getchar();}
|
||||
EOF
|
||||
|
||||
test -z "$CC" && echo Checking for ${CROSS_PREFIX}gcc... | tee -a configure.log
|
||||
cc=${CC-${CROSS_PREFIX}gcc}
|
||||
cflags=${CFLAGS-"-O3"}
|
||||
# to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
|
||||
case "$cc" in
|
||||
*gcc*) gcc=1 ;;
|
||||
*clang*) gcc=1 ;;
|
||||
esac
|
||||
case `$cc -v 2>&1` in
|
||||
*gcc*) gcc=1 ;;
|
||||
*clang*) gcc=1 ;;
|
||||
esac
|
||||
|
||||
show $cc -c $test.c
|
||||
if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
|
||||
echo ... using gcc >> configure.log
|
||||
CC="$cc"
|
||||
CFLAGS="${CFLAGS--O3}"
|
||||
SFLAGS="${CFLAGS--O3} -fPIC"
|
||||
if test "$ARCHS"; then
|
||||
CFLAGS="${CFLAGS} ${ARCHS}"
|
||||
LDFLAGS="${LDFLAGS} ${ARCHS}"
|
||||
fi
|
||||
if test $build64 -eq 1; then
|
||||
CFLAGS="${CFLAGS} -m64"
|
||||
SFLAGS="${SFLAGS} -m64"
|
||||
fi
|
||||
if test "$warn" -eq 1; then
|
||||
if test "$zconst" -eq 1; then
|
||||
CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -pedantic -DZLIB_CONST"
|
||||
else
|
||||
CFLAGS="${CFLAGS} -Wall -Wextra -pedantic"
|
||||
fi
|
||||
fi
|
||||
if test $debug -eq 1; then
|
||||
CFLAGS="${CFLAGS} -DZLIB_DEBUG"
|
||||
SFLAGS="${SFLAGS} -DZLIB_DEBUG"
|
||||
fi
|
||||
if test -z "$uname"; then
|
||||
uname=`(uname -s || echo unknown) 2>/dev/null`
|
||||
fi
|
||||
case "$uname" in
|
||||
Linux* | linux* | GNU | GNU/* | solaris*)
|
||||
LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;;
|
||||
*BSD | *bsd* | DragonFly)
|
||||
LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"}
|
||||
LDCONFIG="ldconfig -m" ;;
|
||||
CYGWIN* | Cygwin* | cygwin* | OS/2*)
|
||||
EXE='.exe' ;;
|
||||
MINGW* | mingw*)
|
||||
# temporary bypass
|
||||
rm -f $test.[co] $test $test$shared_ext
|
||||
echo "Please use win32/Makefile.gcc instead." | tee -a configure.log
|
||||
leave 1
|
||||
LDSHARED=${LDSHARED-"$cc -shared"}
|
||||
LDSHAREDLIBC=""
|
||||
EXE='.exe' ;;
|
||||
QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
|
||||
# (alain.bonnefoy@icbt.com)
|
||||
LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
|
||||
HP-UX*)
|
||||
LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
|
||||
case `(uname -m || echo unknown) 2>/dev/null` in
|
||||
ia64)
|
||||
shared_ext='.so'
|
||||
SHAREDLIB='libz.so' ;;
|
||||
*)
|
||||
shared_ext='.sl'
|
||||
SHAREDLIB='libz.sl' ;;
|
||||
esac ;;
|
||||
Darwin* | darwin*)
|
||||
shared_ext='.dylib'
|
||||
SHAREDLIB=libz$shared_ext
|
||||
SHAREDLIBV=libz.$VER$shared_ext
|
||||
SHAREDLIBM=libz.$VER1$shared_ext
|
||||
LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
|
||||
if libtool -V 2>&1 | grep Apple > /dev/null; then
|
||||
AR="libtool"
|
||||
else
|
||||
AR="/usr/bin/libtool"
|
||||
fi
|
||||
ARFLAGS="-o" ;;
|
||||
*) LDSHARED=${LDSHARED-"$cc -shared"} ;;
|
||||
esac
|
||||
else
|
||||
# find system name and corresponding cc options
|
||||
CC=${CC-cc}
|
||||
gcc=0
|
||||
echo ... using $CC >> configure.log
|
||||
if test -z "$uname"; then
|
||||
uname=`(uname -sr || echo unknown) 2>/dev/null`
|
||||
fi
|
||||
case "$uname" in
|
||||
HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
|
||||
CFLAGS=${CFLAGS-"-O"}
|
||||
# LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
|
||||
LDSHARED=${LDSHARED-"ld -b"}
|
||||
case `(uname -m || echo unknown) 2>/dev/null` in
|
||||
ia64)
|
||||
shared_ext='.so'
|
||||
SHAREDLIB='libz.so' ;;
|
||||
*)
|
||||
shared_ext='.sl'
|
||||
SHAREDLIB='libz.sl' ;;
|
||||
esac ;;
|
||||
IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
|
||||
CFLAGS=${CFLAGS-"-ansi -O2"}
|
||||
LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
|
||||
OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
|
||||
CFLAGS=${CFLAGS-"-O -std1"}
|
||||
LDFLAGS="${LDFLAGS} -Wl,-rpath,."
|
||||
LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;;
|
||||
OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
|
||||
CFLAGS=${CFLAGS-"-O -std1"}
|
||||
LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
|
||||
QNX*) SFLAGS=${CFLAGS-"-4 -O"}
|
||||
CFLAGS=${CFLAGS-"-4 -O"}
|
||||
LDSHARED=${LDSHARED-"cc"}
|
||||
RANLIB=${RANLIB-"true"}
|
||||
AR="cc"
|
||||
ARFLAGS="-A" ;;
|
||||
SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
|
||||
CFLAGS=${CFLAGS-"-O3"}
|
||||
LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;;
|
||||
SunOS\ 5* | solaris*)
|
||||
LDSHARED=${LDSHARED-"cc -G -h libz$shared_ext.$VER1"}
|
||||
SFLAGS=${CFLAGS-"-fast -KPIC"}
|
||||
CFLAGS=${CFLAGS-"-fast"}
|
||||
if test $build64 -eq 1; then
|
||||
# old versions of SunPRO/Workshop/Studio don't support -m64,
|
||||
# but newer ones do. Check for it.
|
||||
flag64=`$CC -flags | egrep -- '^-m64'`
|
||||
if test x"$flag64" != x"" ; then
|
||||
CFLAGS="${CFLAGS} -m64"
|
||||
SFLAGS="${SFLAGS} -m64"
|
||||
else
|
||||
case `(uname -m || echo unknown) 2>/dev/null` in
|
||||
i86*)
|
||||
SFLAGS="$SFLAGS -xarch=amd64"
|
||||
CFLAGS="$CFLAGS -xarch=amd64" ;;
|
||||
*)
|
||||
SFLAGS="$SFLAGS -xarch=v9"
|
||||
CFLAGS="$CFLAGS -xarch=v9" ;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
if test -n "$ZINC"; then
|
||||
ZINC='-I- -I. -I$(SRCDIR)'
|
||||
fi
|
||||
;;
|
||||
SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
|
||||
CFLAGS=${CFLAGS-"-O2"}
|
||||
LDSHARED=${LDSHARED-"ld"} ;;
|
||||
SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
|
||||
CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"}
|
||||
LDSHARED=${LDSHARED-"cc -xarch=v9b"} ;;
|
||||
UNIX_System_V\ 4.2.0)
|
||||
SFLAGS=${CFLAGS-"-KPIC -O"}
|
||||
CFLAGS=${CFLAGS-"-O"}
|
||||
LDSHARED=${LDSHARED-"cc -G"} ;;
|
||||
UNIX_SV\ 4.2MP)
|
||||
SFLAGS=${CFLAGS-"-Kconform_pic -O"}
|
||||
CFLAGS=${CFLAGS-"-O"}
|
||||
LDSHARED=${LDSHARED-"cc -G"} ;;
|
||||
OpenUNIX\ 5)
|
||||
SFLAGS=${CFLAGS-"-KPIC -O"}
|
||||
CFLAGS=${CFLAGS-"-O"}
|
||||
LDSHARED=${LDSHARED-"cc -G"} ;;
|
||||
AIX*) # Courtesy of dbakker@arrayasolutions.com
|
||||
SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
|
||||
CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
|
||||
LDSHARED=${LDSHARED-"xlc -G"} ;;
|
||||
# send working options for other systems to zlib@gzip.org
|
||||
*) SFLAGS=${CFLAGS-"-O"}
|
||||
CFLAGS=${CFLAGS-"-O"}
|
||||
LDSHARED=${LDSHARED-"cc -shared"} ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# destination names for shared library if not defined above
|
||||
SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
|
||||
SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
|
||||
SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
|
||||
|
||||
echo >> configure.log
|
||||
|
||||
# define functions for testing compiler and library characteristics and logging the results
|
||||
|
||||
cat > $test.c <<EOF
|
||||
#error error
|
||||
EOF
|
||||
if ($CC -c $CFLAGS $test.c) 2>/dev/null; then
|
||||
try()
|
||||
{
|
||||
show $*
|
||||
test "`( $* ) 2>&1 | tee -a configure.log`" = ""
|
||||
}
|
||||
echo - using any output from compiler to indicate an error >> configure.log
|
||||
else
|
||||
try()
|
||||
{
|
||||
show $*
|
||||
( $* ) >> configure.log 2>&1
|
||||
ret=$?
|
||||
if test $ret -ne 0; then
|
||||
echo "(exit code "$ret")" >> configure.log
|
||||
fi
|
||||
return $ret
|
||||
}
|
||||
fi
|
||||
|
||||
tryboth()
|
||||
{
|
||||
show $*
|
||||
got=`( $* ) 2>&1`
|
||||
ret=$?
|
||||
printf %s "$got" >> configure.log
|
||||
if test $ret -ne 0; then
|
||||
return $ret
|
||||
fi
|
||||
test "$got" = ""
|
||||
}
|
||||
|
||||
cat > $test.c << EOF
|
||||
int foo() { return 0; }
|
||||
EOF
|
||||
echo "Checking for obsessive-compulsive compiler options..." >> configure.log
|
||||
if try $CC -c $CFLAGS $test.c; then
|
||||
:
|
||||
else
|
||||
echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log
|
||||
leave 1
|
||||
fi
|
||||
|
||||
echo >> configure.log
|
||||
|
||||
# see if shared library build supported
|
||||
cat > $test.c <<EOF
|
||||
extern int getchar();
|
||||
int hello() {return getchar();}
|
||||
EOF
|
||||
if test $shared -eq 1; then
|
||||
echo Checking for shared library support... | tee -a configure.log
|
||||
# we must test in two steps (cc then ld), required at least on SunOS 4.x
|
||||
if try $CC -w -c $SFLAGS $test.c &&
|
||||
try $LDSHARED $SFLAGS -o $test$shared_ext $test.o; then
|
||||
echo Building shared library $SHAREDLIBV with $CC. | tee -a configure.log
|
||||
elif test -z "$old_cc" -a -z "$old_cflags"; then
|
||||
echo No shared library support. | tee -a configure.log
|
||||
shared=0;
|
||||
else
|
||||
echo 'No shared library support; try without defining CC and CFLAGS' | tee -a configure.log
|
||||
shared=0;
|
||||
fi
|
||||
fi
|
||||
if test $shared -eq 0; then
|
||||
LDSHARED="$CC"
|
||||
ALL="static"
|
||||
TEST="all teststatic"
|
||||
SHAREDLIB=""
|
||||
SHAREDLIBV=""
|
||||
SHAREDLIBM=""
|
||||
echo Building static library $STATICLIB version $VER with $CC. | tee -a configure.log
|
||||
else
|
||||
ALL="static shared"
|
||||
TEST="all teststatic testshared"
|
||||
fi
|
||||
|
||||
# check for underscores in external names for use by assembler code
|
||||
CPP=${CPP-"$CC -E"}
|
||||
case $CFLAGS in
|
||||
*ASMV*)
|
||||
echo >> configure.log
|
||||
show "$NM $test.o | grep _hello"
|
||||
if test "`$NM $test.o | grep _hello | tee -a configure.log`" = ""; then
|
||||
CPP="$CPP -DNO_UNDERLINE"
|
||||
echo Checking for underline in external names... No. | tee -a configure.log
|
||||
else
|
||||
echo Checking for underline in external names... Yes. | tee -a configure.log
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
echo >> configure.log
|
||||
|
||||
# check for size_t
|
||||
cat > $test.c <<EOF
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
size_t dummy = 0;
|
||||
EOF
|
||||
if try $CC -c $CFLAGS $test.c; then
|
||||
echo "Checking for size_t... Yes." | tee -a configure.log
|
||||
need_sizet=0
|
||||
else
|
||||
echo "Checking for size_t... No." | tee -a configure.log
|
||||
need_sizet=1
|
||||
fi
|
||||
|
||||
echo >> configure.log
|
||||
|
||||
# find the size_t integer type, if needed
|
||||
if test $need_sizet -eq 1; then
|
||||
cat > $test.c <<EOF
|
||||
long long dummy = 0;
|
||||
EOF
|
||||
if try $CC -c $CFLAGS $test.c; then
|
||||
echo "Checking for long long... Yes." | tee -a configure.log
|
||||
cat > $test.c <<EOF
|
||||
#include <stdio.h>
|
||||
int main(void) {
|
||||
if (sizeof(void *) <= sizeof(int)) puts("int");
|
||||
else if (sizeof(void *) <= sizeof(long)) puts("long");
|
||||
else puts("z_longlong");
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
else
|
||||
echo "Checking for long long... No." | tee -a configure.log
|
||||
cat > $test.c <<EOF
|
||||
#include <stdio.h>
|
||||
int main(void) {
|
||||
if (sizeof(void *) <= sizeof(int)) puts("int");
|
||||
else puts("long");
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
if try $CC $CFLAGS -o $test $test.c; then
|
||||
sizet=`./$test`
|
||||
echo "Checking for a pointer-size integer type..." $sizet"." | tee -a configure.log
|
||||
else
|
||||
echo "Failed to find a pointer-size integer type." | tee -a configure.log
|
||||
leave 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $need_sizet -eq 1; then
|
||||
CFLAGS="${CFLAGS} -DNO_SIZE_T=${sizet}"
|
||||
SFLAGS="${SFLAGS} -DNO_SIZE_T=${sizet}"
|
||||
fi
|
||||
|
||||
echo >> configure.log
|
||||
|
||||
# check for large file support, and if none, check for fseeko()
|
||||
cat > $test.c <<EOF
|
||||
#include <sys/types.h>
|
||||
off64_t dummy = 0;
|
||||
EOF
|
||||
if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then
|
||||
CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1"
|
||||
SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1"
|
||||
ALL="${ALL} all64"
|
||||
TEST="${TEST} test64"
|
||||
echo "Checking for off64_t... Yes." | tee -a configure.log
|
||||
echo "Checking for fseeko... Yes." | tee -a configure.log
|
||||
else
|
||||
echo "Checking for off64_t... No." | tee -a configure.log
|
||||
echo >> configure.log
|
||||
cat > $test.c <<EOF
|
||||
#include <stdio.h>
|
||||
int main(void) {
|
||||
fseeko(NULL, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
if try $CC $CFLAGS -o $test $test.c; then
|
||||
echo "Checking for fseeko... Yes." | tee -a configure.log
|
||||
else
|
||||
CFLAGS="${CFLAGS} -DNO_FSEEKO"
|
||||
SFLAGS="${SFLAGS} -DNO_FSEEKO"
|
||||
echo "Checking for fseeko... No." | tee -a configure.log
|
||||
fi
|
||||
fi
|
||||
|
||||
echo >> configure.log
|
||||
|
||||
# check for strerror() for use by gz* functions
|
||||
cat > $test.c <<EOF
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
int main() { return strlen(strerror(errno)); }
|
||||
EOF
|
||||
if try $CC $CFLAGS -o $test $test.c; then
|
||||
echo "Checking for strerror... Yes." | tee -a configure.log
|
||||
else
|
||||
CFLAGS="${CFLAGS} -DNO_STRERROR"
|
||||
SFLAGS="${SFLAGS} -DNO_STRERROR"
|
||||
echo "Checking for strerror... No." | tee -a configure.log
|
||||
fi
|
||||
|
||||
# copy clean zconf.h for subsequent edits
|
||||
cp -p ${SRCDIR}zconf.h.in zconf.h
|
||||
|
||||
echo >> configure.log
|
||||
|
||||
# check for unistd.h and save result in zconf.h
|
||||
cat > $test.c <<EOF
|
||||
#include <unistd.h>
|
||||
int main() { return 0; }
|
||||
EOF
|
||||
if try $CC -c $CFLAGS $test.c; then
|
||||
sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
|
||||
mv zconf.temp.h zconf.h
|
||||
echo "Checking for unistd.h... Yes." | tee -a configure.log
|
||||
else
|
||||
echo "Checking for unistd.h... No." | tee -a configure.log
|
||||
fi
|
||||
|
||||
echo >> configure.log
|
||||
|
||||
# check for stdarg.h and save result in zconf.h
|
||||
cat > $test.c <<EOF
|
||||
#include <stdarg.h>
|
||||
int main() { return 0; }
|
||||
EOF
|
||||
if try $CC -c $CFLAGS $test.c; then
|
||||
sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
|
||||
mv zconf.temp.h zconf.h
|
||||
echo "Checking for stdarg.h... Yes." | tee -a configure.log
|
||||
else
|
||||
echo "Checking for stdarg.h... No." | tee -a configure.log
|
||||
fi
|
||||
|
||||
# if the z_ prefix was requested, save that in zconf.h
|
||||
if test $zprefix -eq 1; then
|
||||
sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h
|
||||
mv zconf.temp.h zconf.h
|
||||
echo >> configure.log
|
||||
echo "Using z_ prefix on all symbols." | tee -a configure.log
|
||||
fi
|
||||
|
||||
# if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists
|
||||
if test $solo -eq 1; then
|
||||
sed '/#define ZCONF_H/a\
|
||||
#define Z_SOLO
|
||||
|
||||
' < zconf.h > zconf.temp.h
|
||||
mv zconf.temp.h zconf.h
|
||||
OBJC='$(OBJZ)'
|
||||
PIC_OBJC='$(PIC_OBJZ)'
|
||||
fi
|
||||
|
||||
# if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
|
||||
if test $cover -eq 1; then
|
||||
CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
|
||||
if test -n "$GCC_CLASSIC"; then
|
||||
CC=$GCC_CLASSIC
|
||||
fi
|
||||
fi
|
||||
|
||||
echo >> configure.log
|
||||
|
||||
# conduct a series of tests to resolve eight possible cases of using "vs" or "s" printf functions
|
||||
# (using stdarg or not), with or without "n" (proving size of buffer), and with or without a
|
||||
# return value. The most secure result is vsnprintf() with a return value. snprintf() with a
|
||||
# return value is secure as well, but then gzprintf() will be limited to 20 arguments.
|
||||
cat > $test.c <<EOF
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "zconf.h"
|
||||
int main()
|
||||
{
|
||||
#ifndef STDC
|
||||
choke me
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
if try $CC -c $CFLAGS $test.c; then
|
||||
echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." | tee -a configure.log
|
||||
|
||||
echo >> configure.log
|
||||
cat > $test.c <<EOF
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
int mytest(const char *fmt, ...)
|
||||
{
|
||||
char buf[20];
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||
va_end(ap);
|
||||
return 0;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
return (mytest("Hello%d\n", 1));
|
||||
}
|
||||
EOF
|
||||
if try $CC $CFLAGS -o $test $test.c; then
|
||||
echo "Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log
|
||||
|
||||
echo >> configure.log
|
||||
cat >$test.c <<EOF
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
int mytest(const char *fmt, ...)
|
||||
{
|
||||
int n;
|
||||
char buf[20];
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
n = vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||
va_end(ap);
|
||||
return n;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
return (mytest("Hello%d\n", 1));
|
||||
}
|
||||
EOF
|
||||
|
||||
if try $CC -c $CFLAGS $test.c; then
|
||||
echo "Checking for return value of vsnprintf()... Yes." | tee -a configure.log
|
||||
else
|
||||
CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
|
||||
SFLAGS="$SFLAGS -DHAS_vsnprintf_void"
|
||||
echo "Checking for return value of vsnprintf()... No." | tee -a configure.log
|
||||
echo " WARNING: apparently vsnprintf() does not return a value. zlib" | tee -a configure.log
|
||||
echo " can build but will be open to possible string-format security" | tee -a configure.log
|
||||
echo " vulnerabilities." | tee -a configure.log
|
||||
fi
|
||||
else
|
||||
CFLAGS="$CFLAGS -DNO_vsnprintf"
|
||||
SFLAGS="$SFLAGS -DNO_vsnprintf"
|
||||
echo "Checking for vsnprintf() in stdio.h... No." | tee -a configure.log
|
||||
echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log
|
||||
echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
|
||||
echo " vulnerabilities." | tee -a configure.log
|
||||
|
||||
echo >> configure.log
|
||||
cat >$test.c <<EOF
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
int mytest(const char *fmt, ...)
|
||||
{
|
||||
int n;
|
||||
char buf[20];
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
n = vsprintf(buf, fmt, ap);
|
||||
va_end(ap);
|
||||
return n;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
return (mytest("Hello%d\n", 1));
|
||||
}
|
||||
EOF
|
||||
|
||||
if try $CC -c $CFLAGS $test.c; then
|
||||
echo "Checking for return value of vsprintf()... Yes." | tee -a configure.log
|
||||
else
|
||||
CFLAGS="$CFLAGS -DHAS_vsprintf_void"
|
||||
SFLAGS="$SFLAGS -DHAS_vsprintf_void"
|
||||
echo "Checking for return value of vsprintf()... No." | tee -a configure.log
|
||||
echo " WARNING: apparently vsprintf() does not return a value. zlib" | tee -a configure.log
|
||||
echo " can build but will be open to possible string-format security" | tee -a configure.log
|
||||
echo " vulnerabilities." | tee -a configure.log
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." | tee -a configure.log
|
||||
|
||||
echo >> configure.log
|
||||
cat >$test.c <<EOF
|
||||
#include <stdio.h>
|
||||
int mytest()
|
||||
{
|
||||
char buf[20];
|
||||
snprintf(buf, sizeof(buf), "%s", "foo");
|
||||
return 0;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
return (mytest());
|
||||
}
|
||||
EOF
|
||||
|
||||
if try $CC $CFLAGS -o $test $test.c; then
|
||||
echo "Checking for snprintf() in stdio.h... Yes." | tee -a configure.log
|
||||
|
||||
echo >> configure.log
|
||||
cat >$test.c <<EOF
|
||||
#include <stdio.h>
|
||||
int mytest()
|
||||
{
|
||||
char buf[20];
|
||||
return snprintf(buf, sizeof(buf), "%s", "foo");
|
||||
}
|
||||
int main()
|
||||
{
|
||||
return (mytest());
|
||||
}
|
||||
EOF
|
||||
|
||||
if try $CC -c $CFLAGS $test.c; then
|
||||
echo "Checking for return value of snprintf()... Yes." | tee -a configure.log
|
||||
else
|
||||
CFLAGS="$CFLAGS -DHAS_snprintf_void"
|
||||
SFLAGS="$SFLAGS -DHAS_snprintf_void"
|
||||
echo "Checking for return value of snprintf()... No." | tee -a configure.log
|
||||
echo " WARNING: apparently snprintf() does not return a value. zlib" | tee -a configure.log
|
||||
echo " can build but will be open to possible string-format security" | tee -a configure.log
|
||||
echo " vulnerabilities." | tee -a configure.log
|
||||
fi
|
||||
else
|
||||
CFLAGS="$CFLAGS -DNO_snprintf"
|
||||
SFLAGS="$SFLAGS -DNO_snprintf"
|
||||
echo "Checking for snprintf() in stdio.h... No." | tee -a configure.log
|
||||
echo " WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log
|
||||
echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
|
||||
echo " vulnerabilities." | tee -a configure.log
|
||||
|
||||
echo >> configure.log
|
||||
cat >$test.c <<EOF
|
||||
#include <stdio.h>
|
||||
int mytest()
|
||||
{
|
||||
char buf[20];
|
||||
return sprintf(buf, "%s", "foo");
|
||||
}
|
||||
int main()
|
||||
{
|
||||
return (mytest());
|
||||
}
|
||||
EOF
|
||||
|
||||
if try $CC -c $CFLAGS $test.c; then
|
||||
echo "Checking for return value of sprintf()... Yes." | tee -a configure.log
|
||||
else
|
||||
CFLAGS="$CFLAGS -DHAS_sprintf_void"
|
||||
SFLAGS="$SFLAGS -DHAS_sprintf_void"
|
||||
echo "Checking for return value of sprintf()... No." | tee -a configure.log
|
||||
echo " WARNING: apparently sprintf() does not return a value. zlib" | tee -a configure.log
|
||||
echo " can build but will be open to possible string-format security" | tee -a configure.log
|
||||
echo " vulnerabilities." | tee -a configure.log
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# see if we can hide zlib internal symbols that are linked between separate source files
|
||||
if test "$gcc" -eq 1; then
|
||||
echo >> configure.log
|
||||
cat > $test.c <<EOF
|
||||
#define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
|
||||
int ZLIB_INTERNAL foo;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
if tryboth $CC -c $CFLAGS $test.c; then
|
||||
CFLAGS="$CFLAGS -DHAVE_HIDDEN"
|
||||
SFLAGS="$SFLAGS -DHAVE_HIDDEN"
|
||||
echo "Checking for attribute(visibility) support... Yes." | tee -a configure.log
|
||||
else
|
||||
echo "Checking for attribute(visibility) support... No." | tee -a configure.log
|
||||
fi
|
||||
fi
|
||||
|
||||
# show the results in the log
|
||||
echo >> configure.log
|
||||
echo ALL = $ALL >> configure.log
|
||||
echo AR = $AR >> configure.log
|
||||
echo ARFLAGS = $ARFLAGS >> configure.log
|
||||
echo CC = $CC >> configure.log
|
||||
echo CFLAGS = $CFLAGS >> configure.log
|
||||
echo CPP = $CPP >> configure.log
|
||||
echo EXE = $EXE >> configure.log
|
||||
echo LDCONFIG = $LDCONFIG >> configure.log
|
||||
echo LDFLAGS = $LDFLAGS >> configure.log
|
||||
echo LDSHARED = $LDSHARED >> configure.log
|
||||
echo LDSHAREDLIBC = $LDSHAREDLIBC >> configure.log
|
||||
echo OBJC = $OBJC >> configure.log
|
||||
echo PIC_OBJC = $PIC_OBJC >> configure.log
|
||||
echo RANLIB = $RANLIB >> configure.log
|
||||
echo SFLAGS = $SFLAGS >> configure.log
|
||||
echo SHAREDLIB = $SHAREDLIB >> configure.log
|
||||
echo SHAREDLIBM = $SHAREDLIBM >> configure.log
|
||||
echo SHAREDLIBV = $SHAREDLIBV >> configure.log
|
||||
echo STATICLIB = $STATICLIB >> configure.log
|
||||
echo TEST = $TEST >> configure.log
|
||||
echo VER = $VER >> configure.log
|
||||
echo Z_U4 = $Z_U4 >> configure.log
|
||||
echo SRCDIR = $SRCDIR >> configure.log
|
||||
echo exec_prefix = $exec_prefix >> configure.log
|
||||
echo includedir = $includedir >> configure.log
|
||||
echo libdir = $libdir >> configure.log
|
||||
echo mandir = $mandir >> configure.log
|
||||
echo prefix = $prefix >> configure.log
|
||||
echo sharedlibdir = $sharedlibdir >> configure.log
|
||||
echo uname = $uname >> configure.log
|
||||
|
||||
# udpate Makefile with the configure results
|
||||
sed < ${SRCDIR}Makefile.in "
|
||||
/^CC *=/s#=.*#=$CC#
|
||||
/^CFLAGS *=/s#=.*#=$CFLAGS#
|
||||
/^SFLAGS *=/s#=.*#=$SFLAGS#
|
||||
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
|
||||
/^LDSHARED *=/s#=.*#=$LDSHARED#
|
||||
/^CPP *=/s#=.*#=$CPP#
|
||||
/^STATICLIB *=/s#=.*#=$STATICLIB#
|
||||
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
|
||||
/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
|
||||
/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
|
||||
/^AR *=/s#=.*#=$AR#
|
||||
/^ARFLAGS *=/s#=.*#=$ARFLAGS#
|
||||
/^RANLIB *=/s#=.*#=$RANLIB#
|
||||
/^LDCONFIG *=/s#=.*#=$LDCONFIG#
|
||||
/^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
|
||||
/^EXE *=/s#=.*#=$EXE#
|
||||
/^SRCDIR *=/s#=.*#=$SRCDIR#
|
||||
/^ZINC *=/s#=.*#=$ZINC#
|
||||
/^ZINCOUT *=/s#=.*#=$ZINCOUT#
|
||||
/^prefix *=/s#=.*#=$prefix#
|
||||
/^exec_prefix *=/s#=.*#=$exec_prefix#
|
||||
/^libdir *=/s#=.*#=$libdir#
|
||||
/^sharedlibdir *=/s#=.*#=$sharedlibdir#
|
||||
/^includedir *=/s#=.*#=$includedir#
|
||||
/^mandir *=/s#=.*#=$mandir#
|
||||
/^OBJC *=/s#=.*#= $OBJC#
|
||||
/^PIC_OBJC *=/s#=.*#= $PIC_OBJC#
|
||||
/^all: */s#:.*#: $ALL#
|
||||
/^test: */s#:.*#: $TEST#
|
||||
" > Makefile
|
||||
|
||||
# create zlib.pc with the configure results
|
||||
sed < ${SRCDIR}zlib.pc.in "
|
||||
/^CC *=/s#=.*#=$CC#
|
||||
/^CFLAGS *=/s#=.*#=$CFLAGS#
|
||||
/^CPP *=/s#=.*#=$CPP#
|
||||
/^LDSHARED *=/s#=.*#=$LDSHARED#
|
||||
/^STATICLIB *=/s#=.*#=$STATICLIB#
|
||||
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
|
||||
/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
|
||||
/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
|
||||
/^AR *=/s#=.*#=$AR#
|
||||
/^ARFLAGS *=/s#=.*#=$ARFLAGS#
|
||||
/^RANLIB *=/s#=.*#=$RANLIB#
|
||||
/^EXE *=/s#=.*#=$EXE#
|
||||
/^prefix *=/s#=.*#=$prefix#
|
||||
/^exec_prefix *=/s#=.*#=$exec_prefix#
|
||||
/^libdir *=/s#=.*#=$libdir#
|
||||
/^sharedlibdir *=/s#=.*#=$sharedlibdir#
|
||||
/^includedir *=/s#=.*#=$includedir#
|
||||
/^mandir *=/s#=.*#=$mandir#
|
||||
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
|
||||
" | sed -e "
|
||||
s/\@VERSION\@/$VER/g;
|
||||
" > zlib.pc
|
||||
|
||||
# done
|
||||
leave 0
|
@ -1,78 +0,0 @@
|
||||
All files under this contrib directory are UNSUPPORTED. There were
|
||||
provided by users of zlib and were not tested by the authors of zlib.
|
||||
Use at your own risk. Please contact the authors of the contributions
|
||||
for help about these, not the zlib authors. Thanks.
|
||||
|
||||
|
||||
ada/ by Dmitriy Anisimkov <anisimkov@yahoo.com>
|
||||
Support for Ada
|
||||
See http://zlib-ada.sourceforge.net/
|
||||
|
||||
amd64/ by Mikhail Teterin <mi@ALDAN.algebra.com>
|
||||
asm code for AMD64
|
||||
See patch at http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/96393
|
||||
|
||||
asm686/ by Brian Raiter <breadbox@muppetlabs.com>
|
||||
asm code for Pentium and PPro/PII, using the AT&T (GNU as) syntax
|
||||
See http://www.muppetlabs.com/~breadbox/software/assembly.html
|
||||
|
||||
blast/ by Mark Adler <madler@alumni.caltech.edu>
|
||||
Decompressor for output of PKWare Data Compression Library (DCL)
|
||||
|
||||
delphi/ by Cosmin Truta <cosmint@cs.ubbcluj.ro>
|
||||
Support for Delphi and C++ Builder
|
||||
|
||||
dotzlib/ by Henrik Ravn <henrik@ravn.com>
|
||||
Support for Microsoft .Net and Visual C++ .Net
|
||||
|
||||
gcc_gvmat64/by Gilles Vollant <info@winimage.com>
|
||||
GCC Version of x86 64-bit (AMD64 and Intel EM64t) code for x64
|
||||
assembler to replace longest_match() and inflate_fast()
|
||||
|
||||
infback9/ by Mark Adler <madler@alumni.caltech.edu>
|
||||
Unsupported diffs to infback to decode the deflate64 format
|
||||
|
||||
inflate86/ by Chris Anderson <christop@charm.net>
|
||||
Tuned x86 gcc asm code to replace inflate_fast()
|
||||
|
||||
iostream/ by Kevin Ruland <kevin@rodin.wustl.edu>
|
||||
A C++ I/O streams interface to the zlib gz* functions
|
||||
|
||||
iostream2/ by Tyge Løvset <Tyge.Lovset@cmr.no>
|
||||
Another C++ I/O streams interface
|
||||
|
||||
iostream3/ by Ludwig Schwardt <schwardt@sun.ac.za>
|
||||
and Kevin Ruland <kevin@rodin.wustl.edu>
|
||||
Yet another C++ I/O streams interface
|
||||
|
||||
masmx64/ by Gilles Vollant <info@winimage.com>
|
||||
x86 64-bit (AMD64 and Intel EM64t) code for x64 assembler to
|
||||
replace longest_match() and inflate_fast(), also masm x86
|
||||
64-bits translation of Chris Anderson inflate_fast()
|
||||
|
||||
masmx86/ by Gilles Vollant <info@winimage.com>
|
||||
x86 asm code to replace longest_match() and inflate_fast(),
|
||||
for Visual C++ and MASM (32 bits).
|
||||
Based on Brian Raiter (asm686) and Chris Anderson (inflate86)
|
||||
|
||||
minizip/ by Gilles Vollant <info@winimage.com>
|
||||
Mini zip and unzip based on zlib
|
||||
Includes Zip64 support by Mathias Svensson <mathias@result42.com>
|
||||
See http://www.winimage.com/zLibDll/minizip.html
|
||||
|
||||
pascal/ by Bob Dellaca <bobdl@xtra.co.nz> et al.
|
||||
Support for Pascal
|
||||
|
||||
puff/ by Mark Adler <madler@alumni.caltech.edu>
|
||||
Small, low memory usage inflate. Also serves to provide an
|
||||
unambiguous description of the deflate format.
|
||||
|
||||
testzlib/ by Gilles Vollant <info@winimage.com>
|
||||
Example of the use of zlib
|
||||
|
||||
untgz/ by Pedro A. Aranda Gutierrez <paag@tid.es>
|
||||
A very simple tar.gz file extractor using zlib
|
||||
|
||||
vstudio/ by Gilles Vollant <info@winimage.com>
|
||||
Building a minizip-enhanced zlib with Microsoft Visual Studio
|
||||
Includes vc11 from kreuzerkrieg and vc12 from davispuh
|
@ -1,106 +0,0 @@
|
||||
----------------------------------------------------------------
|
||||
-- ZLib for Ada thick binding. --
|
||||
-- --
|
||||
-- Copyright (C) 2002-2004 Dmitriy Anisimkov --
|
||||
-- --
|
||||
-- Open source license information is in the zlib.ads file. --
|
||||
----------------------------------------------------------------
|
||||
--
|
||||
-- $Id: buffer_demo.adb,v 1.3 2004/09/06 06:55:35 vagul Exp $
|
||||
|
||||
-- This demo program provided by Dr Steve Sangwine <sjs@essex.ac.uk>
|
||||
--
|
||||
-- Demonstration of a problem with Zlib-Ada (already fixed) when a buffer
|
||||
-- of exactly the correct size is used for decompressed data, and the last
|
||||
-- few bytes passed in to Zlib are checksum bytes.
|
||||
|
||||
-- This program compresses a string of text, and then decompresses the
|
||||
-- compressed text into a buffer of the same size as the original text.
|
||||
|
||||
with Ada.Streams; use Ada.Streams;
|
||||
with Ada.Text_IO;
|
||||
|
||||
with ZLib; use ZLib;
|
||||
|
||||
procedure Buffer_Demo is
|
||||
EOL : Character renames ASCII.LF;
|
||||
Text : constant String
|
||||
:= "Four score and seven years ago our fathers brought forth," & EOL &
|
||||
"upon this continent, a new nation, conceived in liberty," & EOL &
|
||||
"and dedicated to the proposition that `all men are created equal'.";
|
||||
|
||||
Source : Stream_Element_Array (1 .. Text'Length);
|
||||
for Source'Address use Text'Address;
|
||||
|
||||
begin
|
||||
Ada.Text_IO.Put (Text);
|
||||
Ada.Text_IO.New_Line;
|
||||
Ada.Text_IO.Put_Line
|
||||
("Uncompressed size : " & Positive'Image (Text'Length) & " bytes");
|
||||
|
||||
declare
|
||||
Compressed_Data : Stream_Element_Array (1 .. Text'Length);
|
||||
L : Stream_Element_Offset;
|
||||
begin
|
||||
Compress : declare
|
||||
Compressor : Filter_Type;
|
||||
I : Stream_Element_Offset;
|
||||
begin
|
||||
Deflate_Init (Compressor);
|
||||
|
||||
-- Compress the whole of T at once.
|
||||
|
||||
Translate (Compressor, Source, I, Compressed_Data, L, Finish);
|
||||
pragma Assert (I = Source'Last);
|
||||
|
||||
Close (Compressor);
|
||||
|
||||
Ada.Text_IO.Put_Line
|
||||
("Compressed size : "
|
||||
& Stream_Element_Offset'Image (L) & " bytes");
|
||||
end Compress;
|
||||
|
||||
-- Now we decompress the data, passing short blocks of data to Zlib
|
||||
-- (because this demonstrates the problem - the last block passed will
|
||||
-- contain checksum information and there will be no output, only a
|
||||
-- check inside Zlib that the checksum is correct).
|
||||
|
||||
Decompress : declare
|
||||
Decompressor : Filter_Type;
|
||||
|
||||
Uncompressed_Data : Stream_Element_Array (1 .. Text'Length);
|
||||
|
||||
Block_Size : constant := 4;
|
||||
-- This makes sure that the last block contains
|
||||
-- only Adler checksum data.
|
||||
|
||||
P : Stream_Element_Offset := Compressed_Data'First - 1;
|
||||
O : Stream_Element_Offset;
|
||||
begin
|
||||
Inflate_Init (Decompressor);
|
||||
|
||||
loop
|
||||
Translate
|
||||
(Decompressor,
|
||||
Compressed_Data
|
||||
(P + 1 .. Stream_Element_Offset'Min (P + Block_Size, L)),
|
||||
P,
|
||||
Uncompressed_Data
|
||||
(Total_Out (Decompressor) + 1 .. Uncompressed_Data'Last),
|
||||
O,
|
||||
No_Flush);
|
||||
|
||||
Ada.Text_IO.Put_Line
|
||||
("Total in : " & Count'Image (Total_In (Decompressor)) &
|
||||
", out : " & Count'Image (Total_Out (Decompressor)));
|
||||
|
||||
exit when P = L;
|
||||
end loop;
|
||||
|
||||
Ada.Text_IO.New_Line;
|
||||
Ada.Text_IO.Put_Line
|
||||
("Decompressed text matches original text : "
|
||||
& Boolean'Image (Uncompressed_Data = Source));
|
||||
end Decompress;
|
||||
end;
|
||||
end Buffer_Demo;
|
@ -1,156 +0,0 @@
|
||||
----------------------------------------------------------------
|
||||
-- ZLib for Ada thick binding. --
|
||||
-- --
|
||||
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
|
||||
-- --
|
||||
-- Open source license information is in the zlib.ads file. --
|
||||
----------------------------------------------------------------
|
||||
-- Continuous test for ZLib multithreading. If the test would fail
|
||||
-- we should provide thread safe allocation routines for the Z_Stream.
|
||||
--
|
||||
-- $Id: mtest.adb,v 1.4 2004/07/23 07:49:54 vagul Exp $
|
||||
|
||||
with ZLib;
|
||||
with Ada.Streams;
|
||||
with Ada.Numerics.Discrete_Random;
|
||||
with Ada.Text_IO;
|
||||
with Ada.Exceptions;
|
||||
with Ada.Task_Identification;
|
||||
|
||||
procedure MTest is
|
||||
use Ada.Streams;
|
||||
use ZLib;
|
||||
|
||||
Stop : Boolean := False;
|
||||
|
||||
pragma Atomic (Stop);
|
||||
|
||||
subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#;
|
||||
|
||||
package Random_Elements is
|
||||
new Ada.Numerics.Discrete_Random (Visible_Symbols);
|
||||
|
||||
task type Test_Task;
|
||||
|
||||
task body Test_Task is
|
||||
Buffer : Stream_Element_Array (1 .. 100_000);
|
||||
Gen : Random_Elements.Generator;
|
||||
|
||||
Buffer_First : Stream_Element_Offset;
|
||||
Compare_First : Stream_Element_Offset;
|
||||
|
||||
Deflate : Filter_Type;
|
||||
Inflate : Filter_Type;
|
||||
|
||||
procedure Further (Item : in Stream_Element_Array);
|
||||
|
||||
procedure Read_Buffer
|
||||
(Item : out Ada.Streams.Stream_Element_Array;
|
||||
Last : out Ada.Streams.Stream_Element_Offset);
|
||||
|
||||
-------------
|
||||
-- Further --
|
||||
-------------
|
||||
|
||||
procedure Further (Item : in Stream_Element_Array) is
|
||||
|
||||
procedure Compare (Item : in Stream_Element_Array);
|
||||
|
||||
-------------
|
||||
-- Compare --
|
||||
-------------
|
||||
|
||||
procedure Compare (Item : in Stream_Element_Array) is
|
||||
Next_First : Stream_Element_Offset := Compare_First + Item'Length;
|
||||
begin
|
||||
if Buffer (Compare_First .. Next_First - 1) /= Item then
|
||||
raise Program_Error;
|
||||
end if;
|
||||
|
||||
Compare_First := Next_First;
|
||||
end Compare;
|
||||
|
||||
procedure Compare_Write is new ZLib.Write (Write => Compare);
|
||||
begin
|
||||
Compare_Write (Inflate, Item, No_Flush);
|
||||
end Further;
|
||||
|
||||
-----------------
|
||||
-- Read_Buffer --
|
||||
-----------------
|
||||
|
||||
procedure Read_Buffer
|
||||
(Item : out Ada.Streams.Stream_Element_Array;
|
||||
Last : out Ada.Streams.Stream_Element_Offset)
|
||||
is
|
||||
Buff_Diff : Stream_Element_Offset := Buffer'Last - Buffer_First;
|
||||
Next_First : Stream_Element_Offset;
|
||||
begin
|
||||
if Item'Length <= Buff_Diff then
|
||||
Last := Item'Last;
|
||||
|
||||
Next_First := Buffer_First + Item'Length;
|
||||
|
||||
Item := Buffer (Buffer_First .. Next_First - 1);
|
||||
|
||||
Buffer_First := Next_First;
|
||||
else
|
||||
Last := Item'First + Buff_Diff;
|
||||
Item (Item'First .. Last) := Buffer (Buffer_First .. Buffer'Last);
|
||||
Buffer_First := Buffer'Last + 1;
|
||||
end if;
|
||||
end Read_Buffer;
|
||||
|
||||
procedure Translate is new Generic_Translate
|
||||
(Data_In => Read_Buffer,
|
||||
Data_Out => Further);
|
||||
|
||||
begin
|
||||
Random_Elements.Reset (Gen);
|
||||
|
||||
Buffer := (others => 20);
|
||||
|
||||
Main : loop
|
||||
for J in Buffer'Range loop
|
||||
Buffer (J) := Random_Elements.Random (Gen);
|
||||
|
||||
Deflate_Init (Deflate);
|
||||
Inflate_Init (Inflate);
|
||||
|
||||
Buffer_First := Buffer'First;
|
||||
Compare_First := Buffer'First;
|
||||
|
||||
Translate (Deflate);
|
||||
|
||||
if Compare_First /= Buffer'Last + 1 then
|
||||
raise Program_Error;
|
||||
end if;
|
||||
|
||||
Ada.Text_IO.Put_Line
|
||||
(Ada.Task_Identification.Image
|
||||
(Ada.Task_Identification.Current_Task)
|
||||
& Stream_Element_Offset'Image (J)
|
||||
& ZLib.Count'Image (Total_Out (Deflate)));
|
||||
|
||||
Close (Deflate);
|
||||
Close (Inflate);
|
||||
|
||||
exit Main when Stop;
|
||||
end loop;
|
||||
end loop Main;
|
||||
exception
|
||||
when E : others =>
|
||||
Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E));
|
||||
Stop := True;
|
||||
end Test_Task;
|
||||
|
||||
Test : array (1 .. 4) of Test_Task;
|
||||
|
||||
pragma Unreferenced (Test);
|
||||
|
||||
Dummy : Character;
|
||||
|
||||
begin
|
||||
Ada.Text_IO.Get_Immediate (Dummy);
|
||||
Stop := True;
|
||||
end MTest;
|
@ -1,156 +0,0 @@
|
||||
----------------------------------------------------------------
|
||||
-- ZLib for Ada thick binding. --
|
||||
-- --
|
||||
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
|
||||
-- --
|
||||
-- Open source license information is in the zlib.ads file. --
|
||||
----------------------------------------------------------------
|
||||
|
||||
-- $Id: read.adb,v 1.8 2004/05/31 10:53:40 vagul Exp $
|
||||
|
||||
-- Test/demo program for the generic read interface.
|
||||
|
||||
with Ada.Numerics.Discrete_Random;
|
||||
with Ada.Streams;
|
||||
with Ada.Text_IO;
|
||||
|
||||
with ZLib;
|
||||
|
||||
procedure Read is
|
||||
|
||||
use Ada.Streams;
|
||||
|
||||
------------------------------------
|
||||
-- Test configuration parameters --
|
||||
------------------------------------
|
||||
|
||||
File_Size : Stream_Element_Offset := 100_000;
|
||||
|
||||
Continuous : constant Boolean := False;
|
||||
-- If this constant is True, the test would be repeated again and again,
|
||||
-- with increment File_Size for every iteration.
|
||||
|
||||
Header : constant ZLib.Header_Type := ZLib.Default;
|
||||
-- Do not use Header other than Default in ZLib versions 1.1.4 and older.
|
||||
|
||||
Init_Random : constant := 8;
|
||||
-- We are using the same random sequence, in case of we catch bug,
|
||||
-- so we would be able to reproduce it.
|
||||
|
||||
-- End --
|
||||
|
||||
Pack_Size : Stream_Element_Offset;
|
||||
Offset : Stream_Element_Offset;
|
||||
|
||||
Filter : ZLib.Filter_Type;
|
||||
|
||||
subtype Visible_Symbols
|
||||
is Stream_Element range 16#20# .. 16#7E#;
|
||||
|
||||
package Random_Elements is new
|
||||
Ada.Numerics.Discrete_Random (Visible_Symbols);
|
||||
|
||||
Gen : Random_Elements.Generator;
|
||||
Period : constant Stream_Element_Offset := 200;
|
||||
-- Period constant variable for random generator not to be very random.
|
||||
-- Bigger period, harder random.
|
||||
|
||||
Read_Buffer : Stream_Element_Array (1 .. 2048);
|
||||
Read_First : Stream_Element_Offset;
|
||||
Read_Last : Stream_Element_Offset;
|
||||
|
||||
procedure Reset;
|
||||
|
||||
procedure Read
|
||||
(Item : out Stream_Element_Array;
|
||||
Last : out Stream_Element_Offset);
|
||||
-- this procedure is for generic instantiation of
|
||||
-- ZLib.Read
|
||||
-- reading data from the File_In.
|
||||
|
||||
procedure Read is new ZLib.Read
|
||||
(Read,
|
||||
Read_Buffer,
|
||||
Rest_First => Read_First,
|
||||
Rest_Last => Read_Last);
|
||||
|
||||
----------
|
||||
-- Read --
|
||||
----------
|
||||
|
||||
procedure Read
|
||||
(Item : out Stream_Element_Array;
|
||||
Last : out Stream_Element_Offset) is
|
||||
begin
|
||||
Last := Stream_Element_Offset'Min
|
||||
(Item'Last,
|
||||
Item'First + File_Size - Offset);
|
||||
|
||||
for J in Item'First .. Last loop
|
||||
if J < Item'First + Period then
|
||||
Item (J) := Random_Elements.Random (Gen);
|
||||
else
|
||||
Item (J) := Item (J - Period);
|
||||
end if;
|
||||
|
||||
Offset := Offset + 1;
|
||||
end loop;
|
||||
end Read;
|
||||
|
||||
-----------
|
||||
-- Reset --
|
||||
-----------
|
||||
|
||||
procedure Reset is
|
||||
begin
|
||||
Random_Elements.Reset (Gen, Init_Random);
|
||||
Pack_Size := 0;
|
||||
Offset := 1;
|
||||
Read_First := Read_Buffer'Last + 1;
|
||||
Read_Last := Read_Buffer'Last;
|
||||
end Reset;
|
||||
|
||||
begin
|
||||
Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version);
|
||||
|
||||
loop
|
||||
for Level in ZLib.Compression_Level'Range loop
|
||||
|
||||
Ada.Text_IO.Put ("Level ="
|
||||
& ZLib.Compression_Level'Image (Level));
|
||||
|
||||
-- Deflate using generic instantiation.
|
||||
|
||||
ZLib.Deflate_Init
|
||||
(Filter,
|
||||
Level,
|
||||
Header => Header);
|
||||
|
||||
Reset;
|
||||
|
||||
Ada.Text_IO.Put
|
||||
(Stream_Element_Offset'Image (File_Size) & " ->");
|
||||
|
||||
loop
|
||||
declare
|
||||
Buffer : Stream_Element_Array (1 .. 1024);
|
||||
Last : Stream_Element_Offset;
|
||||
begin
|
||||
Read (Filter, Buffer, Last);
|
||||
|
||||
Pack_Size := Pack_Size + Last - Buffer'First + 1;
|
||||
|
||||
exit when Last < Buffer'Last;
|
||||
end;
|
||||
end loop;
|
||||
|
||||
Ada.Text_IO.Put_Line (Stream_Element_Offset'Image (Pack_Size));
|
||||
|
||||
ZLib.Close (Filter);
|
||||
end loop;
|
||||
|
||||
exit when not Continuous;
|
||||
|
||||
File_Size := File_Size + 1;
|
||||
end loop;
|
||||
end Read;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user